summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in1
-rw-r--r--addrtoname.c79
-rw-r--r--netdissect.h4
-rw-r--r--print-atalk.c11
-rw-r--r--print-decnet.c2
-rw-r--r--print-esp.c17
-rw-r--r--print-tcp.c6
-rw-r--r--print.c15
-rw-r--r--status-exit-codes.h32
-rw-r--r--tcpdump.c36
10 files changed, 132 insertions, 71 deletions
diff --git a/Makefile.in b/Makefile.in
index 9f4f2f4e..67ee3281 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -293,6 +293,7 @@ HDR = \
signature.h \
slcompress.h \
smb.h \
+ status-exit-codes.h \
strtoaddr.h \
tcp.h \
timeval-operations.h \
diff --git a/addrtoname.c b/addrtoname.c
index f488dde0..d43daac8 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -125,7 +125,7 @@
/*
* hash tables for whatever-to-name translations
*
- * ndo_error() called on strdup(3) failure
+ * ndo_error() called on strdup(3) failure with S_ERR_ND_MEM_ALLOC status
*/
#define HASHNAMESIZE 4096
@@ -319,8 +319,8 @@ ipaddr_string(netdissect_options *ndo, const u_char *ap)
p->name = strdup(hp->h_name);
if (p->name == NULL)
- (*ndo->ndo_error)(ndo,
- "ipaddr_string: strdup(hp->h_name)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ipaddr_string: strdup(hp->h_name)");
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@@ -332,7 +332,8 @@ ipaddr_string(netdissect_options *ndo, const u_char *ap)
}
p->name = strdup(intoa(addr));
if (p->name == NULL)
- (*ndo->ndo_error)(ndo, "ipaddr_string: strdup(intoa(addr))");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ipaddr_string: strdup(intoa(addr))");
return (p->name);
}
@@ -381,8 +382,8 @@ ip6addr_string(netdissect_options *ndo, const u_char *ap)
p->name = strdup(hp->h_name);
if (p->name == NULL)
- (*ndo->ndo_error)(ndo,
- "ip6addr_string: strdup(hp->h_name)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ip6addr_string: strdup(hp->h_name)");
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@@ -395,7 +396,8 @@ ip6addr_string(netdissect_options *ndo, const u_char *ap)
cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf));
p->name = strdup(cp);
if (p->name == NULL)
- (*ndo->ndo_error)(ndo, "ip6addr_string: strdup(cp)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ip6addr_string: strdup(cp)");
return (p->name);
}
@@ -429,7 +431,7 @@ lookup_emem(netdissect_options *ndo, const u_char *ep)
tp->e_addr2 = k;
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- (*ndo->ndo_error)(ndo, "lookup_emem: calloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "lookup_emem: calloc");
return tp;
}
@@ -474,13 +476,15 @@ lookup_bytestring(netdissect_options *ndo, const u_char *bs,
tp->bs_bytes = (u_char *) calloc(1, nlen);
if (tp->bs_bytes == NULL)
- (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "lookup_bytestring: calloc");
memcpy(tp->bs_bytes, bs, nlen);
tp->bs_nbytes = nlen;
tp->bs_nxt = (struct bsnamemem *)calloc(1, sizeof(*tp));
if (tp->bs_nxt == NULL)
- (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "lookup_bytestring: calloc");
return tp;
}
@@ -520,12 +524,12 @@ lookup_nsap(netdissect_options *ndo, const u_char *nsap,
tp->e_addr2 = k;
tp->e_nsap = (u_char *)malloc(nsap_length + 1);
if (tp->e_nsap == NULL)
- (*ndo->ndo_error)(ndo, "lookup_nsap: malloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "lookup_nsap: malloc");
tp->e_nsap[0] = (u_char)nsap_length; /* guaranteed < ISONSAP_MAX_LENGTH */
memcpy((char *)&tp->e_nsap[1], (const char *)nsap, nsap_length);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- (*ndo->ndo_error)(ndo, "lookup_nsap: calloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "lookup_nsap: calloc");
return tp;
}
@@ -553,7 +557,7 @@ lookup_protoid(netdissect_options *ndo, const u_char *pi)
tp->p_proto = j;
tp->p_nxt = (struct protoidmem *)calloc(1, sizeof(*tp));
if (tp->p_nxt == NULL)
- (*ndo->ndo_error)(ndo, "lookup_protoid: calloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "lookup_protoid: calloc");
return tp;
}
@@ -577,8 +581,8 @@ etheraddr_string(netdissect_options *ndo, const u_char *ep)
if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
tp->e_name = strdup(buf2);
if (tp->e_name == NULL)
- (*ndo->ndo_error)(ndo,
- "etheraddr_string: strdup(buf2)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "etheraddr_string: strdup(buf2)");
return (tp->e_name);
}
}
@@ -600,7 +604,8 @@ etheraddr_string(netdissect_options *ndo, const u_char *ep)
*cp = '\0';
tp->e_name = strdup(buf);
if (tp->e_name == NULL)
- (*ndo->ndo_error)(ndo, "etheraddr_string: strdup(buf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "etheraddr_string: strdup(buf)");
return (tp->e_name);
}
@@ -629,7 +634,8 @@ le64addr_string(netdissect_options *ndo, const u_char *ep)
tp->bs_name = strdup(buf);
if (tp->bs_name == NULL)
- (*ndo->ndo_error)(ndo, "le64addr_string: strdup(buf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "le64addr_string: strdup(buf)");
return (tp->bs_name);
}
@@ -657,7 +663,8 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep,
tp->bs_name = cp = (char *)malloc(len*3);
if (tp->bs_name == NULL)
- (*ndo->ndo_error)(ndo, "linkaddr_string: malloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "linkaddr_string: malloc");
*cp++ = hex[*ep >> 4];
*cp++ = hex[*ep++ & 0xf];
for (i = len-1; i > 0 ; --i) {
@@ -693,7 +700,8 @@ etherproto_string(netdissect_options *ndo, u_short port)
*cp++ = '\0';
tp->name = strdup(buf);
if (tp->name == NULL)
- (*ndo->ndo_error)(ndo, "etherproto_string: strdup(buf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "etherproto_string: strdup(buf)");
return (tp->name);
}
@@ -715,7 +723,8 @@ isonsap_string(netdissect_options *ndo, const u_char *nsap,
tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
if (cp == NULL)
- (*ndo->ndo_error)(ndo, "isonsap_string: malloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "isonsap_string: malloc");
for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
*cp++ = hex[*nsap >> 4];
@@ -746,7 +755,8 @@ tcpport_string(netdissect_options *ndo, u_short port)
(void)nd_snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
if (tp->name == NULL)
- (*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "tcpport_string: strdup(buf)");
return (tp->name);
}
@@ -767,7 +777,8 @@ udpport_string(netdissect_options *ndo, u_short port)
(void)nd_snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
if (tp->name == NULL)
- (*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "udpport_string: strdup(buf)");
return (tp->name);
}
@@ -795,7 +806,8 @@ ipxsap_string(netdissect_options *ndo, u_short port)
*cp++ = '\0';
tp->name = strdup(buf);
if (tp->name == NULL)
- (*ndo->ndo_error)(ndo, "ipxsap_string: strdup(buf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ipxsap_string: strdup(buf)");
return (tp->name);
}
@@ -825,7 +837,8 @@ init_servarray(netdissect_options *ndo)
} else
table->name = strdup(sv->s_name);
if (table->name == NULL)
- (*ndo->ndo_error)(ndo, "init_servarray: strdup");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "init_servarray: strdup");
table->addr = port;
table->nxt = newhnamemem(ndo);
@@ -911,8 +924,8 @@ init_protoidarray(netdissect_options *ndo)
tp = lookup_protoid(ndo, protoid);
tp->p_name = strdup(eproto_db[i].s);
if (tp->p_name == NULL)
- (*ndo->ndo_error)(ndo,
- "init_protoidarray: strdup(eproto_db[i].s)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "init_protoidarray: strdup(eproto_db[i].s)");
}
/* Hardwire some SNAP proto ID names */
for (pl = protoidlist; pl->name != NULL; ++pl) {
@@ -965,8 +978,8 @@ init_etherarray(netdissect_options *ndo)
tp = lookup_emem(ndo, ep->addr);
tp->e_name = strdup(ep->name);
if (tp->e_name == NULL)
- (*ndo->ndo_error)(ndo,
- "init_etherarray: strdup(ep->addr)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "init_etherarray: strdup(ep->addr)");
}
(void)fclose(fp);
}
@@ -986,8 +999,8 @@ init_etherarray(netdissect_options *ndo)
if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
tp->e_name = strdup(name);
if (tp->e_name == NULL)
- (*ndo->ndo_error)(ndo,
- "init_etherarray: strdup(name)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "init_etherarray: strdup(name)");
continue;
}
#endif
@@ -1287,7 +1300,8 @@ newhnamemem(netdissect_options *ndo)
num = 64;
ptr = (struct hnamemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
- (*ndo->ndo_error)(ndo, "newhnamemem: calloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "newhnamemem: calloc");
}
--num;
p = ptr++;
@@ -1306,7 +1320,8 @@ newh6namemem(netdissect_options *ndo)
num = 64;
ptr = (struct h6namemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
- (*ndo->ndo_error)(ndo, "newh6namemem: calloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "newh6namemem: calloc");
}
--num;
p = ptr++;
diff --git a/netdissect.h b/netdissect.h
index 7aed8313..73fec2e2 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -29,6 +29,7 @@
#include "os-proto.h"
#endif
#include <sys/types.h>
+#include "status-exit-codes.h"
/*
* Data types corresponding to multi-byte integral values within data
@@ -213,8 +214,9 @@ struct netdissect_options {
PRINTFLIKE_FUNCPTR(2, 3);
/* pointer to function to output errors */
void NORETURN_FUNCPTR (*ndo_error)(netdissect_options *,
+ status_exit_codes_t status,
const char *fmt, ...)
- PRINTFLIKE_FUNCPTR(2, 3);
+ PRINTFLIKE_FUNCPTR(3, 4);
/* pointer to function to output warnings */
void (*ndo_warning)(netdissect_options *,
const char *fmt, ...)
diff --git a/print-atalk.c b/print-atalk.c
index 25a1801a..3cd04177 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -608,8 +608,8 @@ ataddr_string(netdissect_options *ndo,
tp->nxt = newhnamemem(ndo);
tp->name = strdup(nambuf);
if (tp->name == NULL)
- (*ndo->ndo_error)(ndo,
- "ataddr_string: strdup(nambuf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ataddr_string: strdup(nambuf)");
}
fclose(fp);
}
@@ -628,8 +628,8 @@ ataddr_string(netdissect_options *ndo,
tp2->name, athost);
tp->name = strdup(nambuf);
if (tp->name == NULL)
- (*ndo->ndo_error)(ndo,
- "ataddr_string: strdup(nambuf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ataddr_string: strdup(nambuf)");
return (tp->name);
}
@@ -641,7 +641,8 @@ ataddr_string(netdissect_options *ndo,
(void)nd_snprintf(nambuf, sizeof(nambuf), "%u", atnet);
tp->name = strdup(nambuf);
if (tp->name == NULL)
- (*ndo->ndo_error)(ndo, "ataddr_string: strdup(nambuf)");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "ataddr_string: strdup(nambuf)");
return (tp->name);
}
diff --git a/print-decnet.c b/print-decnet.c
index ef610767..253d133d 100644
--- a/print-decnet.c
+++ b/print-decnet.c
@@ -1246,7 +1246,7 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr)
/* malloc() return used by the 'dnaddrtable' hash table: do not free() */
str = (char *)malloc(siz = sizeof("00.0000"));
if (str == NULL)
- (*ndo->ndo_error)(ndo, "dnnum_string: malloc");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "dnnum_string: malloc");
nd_snprintf(str, siz, "%u.%u", area, node);
return(str);
}
diff --git a/print-esp.c b/print-esp.c
index fbe99ad2..094b9f7f 100644
--- a/print-esp.c
+++ b/print-esp.c
@@ -236,7 +236,8 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
output_buffer_size = len + (block_size - len % block_size);
output_buffer = (u_char *)malloc(output_buffer_size);
if (output_buffer == NULL) {
- (*ndo->ndo_warning)(ndo, "can't allocate memory for decryption buffer");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "can't allocate memory for decryption buffer");
EVP_CIPHER_CTX_free(ctx);
return 0;
}
@@ -266,7 +267,8 @@ static void esp_print_addsa(netdissect_options *ndo,
nsa = (struct sa_list *)malloc(sizeof(struct sa_list));
if (nsa == NULL)
- (*ndo->ndo_error)(ndo, "ran out of memory to allocate sa structure");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "esp_print_addsa: malloc");
*nsa = *sa;
@@ -287,7 +289,8 @@ static u_int hexdigit(netdissect_options *ndo, char hex)
else if (hex >= 'a' && hex <= 'f')
return (hex - 'a' + 10);
else {
- (*ndo->ndo_error)(ndo, "invalid hex digit %c in espsecret\n", hex);
+ (*ndo->ndo_error)(ndo, S_ERR_ND_ESP_SECRET,
+ "invalid hex digit %c in espsecret\n", hex);
return 0;
}
}
@@ -520,8 +523,9 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
secretfile = fopen(filename, FOPEN_READ_TXT);
if (secretfile == NULL) {
- (*ndo->ndo_error)(ndo, "print_esp: can't open %s: %s\n",
- filename, strerror(errno));
+ (*ndo->ndo_error)(ndo, S_ERR_ND_OPEN_FILE,
+ "print_esp: can't open %s: %s\n",
+ filename, strerror(errno));
return;
}
@@ -787,7 +791,8 @@ esp_print(netdissect_options *ndo,
output_buffer_size = len + (block_size - len % block_size);
output_buffer = (u_char *)malloc(output_buffer_size);
if (output_buffer == NULL) {
- (*ndo->ndo_warning)(ndo, "can't allocate memory for decryption buffer");
+ (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+ "esp_print: malloc decryption buffer");
EVP_CIPHER_CTX_free(ctx);
return -1;
}
diff --git a/print-tcp.c b/print-tcp.c
index 66e87492..ab3dbbf3 100644
--- a/print-tcp.c
+++ b/print-tcp.c
@@ -295,7 +295,8 @@ tcp_print(netdissect_options *ndo,
calloc(1, sizeof(*th));
if (th->nxt == NULL)
(*ndo->ndo_error)(ndo,
- "tcp_print: calloc");
+ S_ERR_ND_MEM_ALLOC,
+ "tcp_print: calloc");
}
th->addr = tha;
if (rev)
@@ -352,7 +353,8 @@ tcp_print(netdissect_options *ndo,
calloc(1, sizeof(*th));
if (th->nxt == NULL)
(*ndo->ndo_error)(ndo,
- "tcp_print: calloc");
+ S_ERR_ND_MEM_ALLOC,
+ "tcp_print: calloc");
}
th->addr = tha;
if (rev)
diff --git a/print.c b/print.c
index 274ac202..fd95b512 100644
--- a/print.c
+++ b/print.c
@@ -225,8 +225,9 @@ static void ndo_default_print(netdissect_options *ndo, const u_char *bp,
u_int length);
static void NORETURN ndo_error(netdissect_options *ndo,
+ status_exit_codes_t status,
FORMAT_STRING(const char *fmt), ...)
- PRINTFLIKE(2, 3);
+ PRINTFLIKE(3, 4);
static void ndo_warning(netdissect_options *ndo,
FORMAT_STRING(const char *fmt), ...)
PRINTFLIKE(2, 3);
@@ -298,11 +299,11 @@ get_if_printer(netdissect_options *ndo, int type)
if (printer == NULL) {
dltname = pcap_datalink_val_to_name(type);
if (dltname != NULL)
- (*ndo->ndo_error)(ndo,
+ (*ndo->ndo_error)(ndo, S_ERR_ND_NO_PRINTER,
"packet printing is not supported for link type %s: use -w",
dltname);
else
- (*ndo->ndo_error)(ndo,
+ (*ndo->ndo_error)(ndo, S_ERR_ND_NO_PRINTER,
"packet printing is not supported for link type %d: use -w", type);
}
return printer;
@@ -460,7 +461,8 @@ ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
/* VARARGS */
static void
-ndo_error(netdissect_options *ndo, const char *fmt, ...)
+ndo_error(netdissect_options *ndo, status_exit_codes_t status,
+ const char *fmt, ...)
{
va_list ap;
@@ -475,7 +477,7 @@ ndo_error(netdissect_options *ndo, const char *fmt, ...)
(void)fputc('\n', stderr);
}
nd_cleanup();
- exit(1);
+ exit(status);
/* NOTREACHED */
}
@@ -509,7 +511,8 @@ ndo_printf(netdissect_options *ndo, const char *fmt, ...)
va_end(args);
if (ret < 0)
- ndo_error(ndo, "Unable to write output: %s", pcap_strerror(errno));
+ ndo_error(ndo, S_ERR_ND_WRITE_FILE,
+ "Unable to write output: %s", pcap_strerror(errno));
return (ret);
}
diff --git a/status-exit-codes.h b/status-exit-codes.h
new file mode 100644
index 00000000..87872daa
--- /dev/null
+++ b/status-exit-codes.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef status_exit_codes_h
+#define status_exit_codes_h
+
+/* S_ERR_ND_* are libnetdissect status */
+
+typedef enum {
+ S_SUCCESS = 0, /* not a libnetdissect status */
+ S_ERR_HOST_PROGRAM = 1, /* not a libnetdissect status */
+ S_ERR_ND_NO_PRINTER = 2,
+ S_ERR_ND_MEM_ALLOC = 3,
+ S_ERR_ND_OPEN_FILE = 4,
+ S_ERR_ND_WRITE_FILE = 5,
+ S_ERR_ND_ESP_SECRET = 6
+} status_exit_codes_t;
+
+#endif /* status_exit_codes_h */
diff --git a/tcpdump.c b/tcpdump.c
index f0505fe2..4ab2c249 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -338,7 +338,7 @@ error(const char *fmt, ...)
if (fmt[-1] != '\n')
(void)fputc('\n', stderr);
}
- exit_tcpdump(1);
+ exit_tcpdump(S_ERR_HOST_PROGRAM);
/* NOTREACHED */
}
@@ -382,7 +382,7 @@ show_tstamp_types_and_exit(pcap_t *pc, const char *device)
if (n_tstamp_types == 0) {
fprintf(stderr, "Time stamp type cannot be set for %s\n",
device);
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
}
fprintf(stderr, "Time stamp types for %s (use option -j to set):\n",
device);
@@ -396,7 +396,7 @@ show_tstamp_types_and_exit(pcap_t *pc, const char *device)
}
}
pcap_free_tstamp_types(tstamp_types);
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
}
#endif
@@ -449,7 +449,7 @@ show_dlts_and_exit(pcap_t *pc, const char *device)
#ifdef HAVE_PCAP_FREE_DATALINKS
pcap_free_datalinks(dlts);
#endif
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
}
#ifdef HAVE_PCAP_FINDALLDEVS
@@ -471,7 +471,7 @@ show_devices_and_exit(void)
printf("\n");
}
pcap_freealldevs(devlist);
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
}
#endif /* HAVE_PCAP_FINDALLDEVS */
@@ -495,7 +495,7 @@ show_remote_devices_and_exit(void)
printf("\n");
}
pcap_freealldevs(devlist);
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
}
#endif /* HAVE_PCAP_FINDALLDEVS */
@@ -679,7 +679,7 @@ droproot(const char *username, const char *chroot_dir)
if (chroot_dir && !username) {
fprintf(stderr, "%s: Chroot without dropping root is insecure\n",
program_name);
- exit_tcpdump(1);
+ exit_tcpdump(S_ERR_HOST_PROGRAM);
}
pw = getpwnam(username);
@@ -688,7 +688,7 @@ droproot(const char *username, const char *chroot_dir)
if (chroot(chroot_dir) != 0 || chdir ("/") != 0) {
fprintf(stderr, "%s: Couldn't chroot/chdir to '%.64s': %s\n",
program_name, chroot_dir, pcap_strerror(errno));
- exit_tcpdump(1);
+ exit_tcpdump(S_ERR_HOST_PROGRAM);
}
}
#ifdef HAVE_LIBCAP_NG
@@ -708,7 +708,7 @@ droproot(const char *username, const char *chroot_dir)
(unsigned long)pw->pw_uid,
(unsigned long)pw->pw_gid,
pcap_strerror(errno));
- exit_tcpdump(1);
+ exit_tcpdump(S_ERR_HOST_PROGRAM);
}
else {
fprintf(stderr, "dropped privs to %s\n", username);
@@ -718,7 +718,7 @@ droproot(const char *username, const char *chroot_dir)
else {
fprintf(stderr, "%s: Couldn't find user '%.32s'\n",
program_name, username);
- exit_tcpdump(1);
+ exit_tcpdump(S_ERR_HOST_PROGRAM);
}
#ifdef HAVE_LIBCAP_NG
/* We don't need CAP_SETUID, CAP_SETGID and CAP_SYS_CHROOT any more. */
@@ -1472,7 +1472,7 @@ main(int argc, char **argv)
case 'h':
print_usage();
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
break;
case 'H':
@@ -1706,7 +1706,7 @@ main(int argc, char **argv)
case OPTION_VERSION:
print_version();
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
break;
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
@@ -1729,7 +1729,7 @@ main(int argc, char **argv)
default:
print_usage();
- exit_tcpdump(1);
+ exit_tcpdump(S_ERR_HOST_PROGRAM);
/* NOTREACHED */
}
@@ -2002,7 +2002,7 @@ main(int argc, char **argv)
pcap_close(pd);
free(cmdbuf);
pcap_freecode(&fcode);
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
}
#ifdef HAVE_CASPER
@@ -2461,7 +2461,7 @@ cleanup(int signo _U_)
(void)fflush(stdout);
info(1);
}
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
#endif
}
@@ -2561,9 +2561,9 @@ compress_savefile(const char *filename)
filename,
pcap_strerror(errno));
#ifdef HAVE_FORK
- exit(1);
+ exit(S_ERR_HOST_PROGRAM);
#else
- _exit(1);
+ _exit(S_ERR_HOST_PROGRAM);
#endif
}
#else /* HAVE_FORK && HAVE_VFORK */
@@ -2635,7 +2635,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
(void)fprintf(stderr, "Maximum file limit reached: %d\n",
Wflag);
info(1);
- exit_tcpdump(0);
+ exit_tcpdump(S_SUCCESS);
/* NOTREACHED */
}
if (dump_info->CurrentFileName != NULL)