]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Remove non-dissection related fields from struct netdissect_options
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 14 Sep 2015 17:19:43 +0000 (19:19 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 14 Sep 2015 17:39:57 +0000 (19:39 +0200)
Remove 'ndo_dlt' and 'ndo_dltname' from netdissect_options, only
used is frontend.
Use instead 'yflag_dlt' and 'yflag_dlt_name' variables in frontend.

Moreover:
Fix style

netdissect.h
tcpdump.c

index bc3cba6ee2485d6594b9f3904aea233b83d4ae25..03555178bd47104958e705b6bb29380c1ed26ed8 100644 (file)
@@ -110,13 +110,10 @@ struct netdissect_options {
   int ndo_Aflag;               /* print packet only in ascii observing TAB,
                                 * LF, CR and SPACE as graphical chars
                                 */
-  int ndo_dlt;                  /* if != -1, ask libpcap for the DLT it names */
-
   int ndo_Hflag;               /* dissect 802.11s draft mesh standard */
   int ndo_packet_number;       /* print a packet number in the beginning of line */
   int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
   int ndo_tstamp_precision;    /* requested time stamp precision */
-  const char *ndo_dltname;
   const char *program_name;    /* Name of the program using the library */
 
   char *ndo_espsecret;
index 11d1a0a9e36cd0f5c4d7854927f486452eb0523f..58d38a284840fd34fe3262d5b850ce265ebc03a4 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -736,16 +736,18 @@ main(int argc, char **argv)
        cap_rights_t rights;
        int cansandbox;
 #endif /* HAVE_CAPSICUM */
-       int Bflag=0;                    /* buffer size */
-       int jflag=-1;                   /* packet time stamp source */
-       int Oflag=1;                    /* run filter code optimizer */
-       int pflag=0;                    /* don't go promiscuous */
+       int Bflag = 0;                  /* buffer size */
+       int jflag = -1;                 /* packet time stamp source */
+       int Oflag = 1;                  /* run filter code optimizer */
+       int pflag = 0;                  /* don't go promiscuous */
+       int yflag_dlt = -1;
+       const char *yflag_dlt_name = NULL;
+
        netdissect_options Ndo;
        netdissect_options *ndo = &Ndo;
        int immediate_mode = 0;
 
        memset(ndo, 0, sizeof(*ndo));
-       ndo->ndo_dlt=-1;
        ndo_set_function_pointers(ndo);
        ndo->ndo_snaplen = DEFAULT_SNAPLEN;
 
@@ -1110,11 +1112,11 @@ main(int argc, char **argv)
                        break;
 
                case 'y':
-                       ndo->ndo_dltname = optarg;
-                       ndo->ndo_dlt =
-                         pcap_datalink_name_to_val(ndo->ndo_dltname);
-                       if (ndo->ndo_dlt < 0)
-                               error("invalid data link type %s", ndo->ndo_dltname);
+                       yflag_dlt_name = optarg;
+                       yflag_dlt =
+                               pcap_datalink_name_to_val(yflag_dlt_name);
+                       if (yflag_dlt < 0)
+                               error("invalid data link type %s", yflag_dlt_name);
                        break;
 
 #if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
@@ -1448,9 +1450,9 @@ main(int argc, char **argv)
 #endif /* !defined(HAVE_PCAP_CREATE) && defined(_WIN32) */
                if (Lflag)
                        show_dlts_and_exit(device);
-               if (ndo->ndo_dlt >= 0) {
+               if (yflag_dlt >= 0) {
 #ifdef HAVE_PCAP_SET_DATALINK
-                       if (pcap_set_datalink(pd, ndo->ndo_dlt) < 0)
+                       if (pcap_set_datalink(pd, yflag_dlt) < 0)
                                error("%s", pcap_geterr(pd));
 #else
                        /*
@@ -1458,13 +1460,13 @@ main(int argc, char **argv)
                         * data link type, so we only let them
                         * set it to what it already is.
                         */
-                       if (ndo->ndo_dlt != pcap_datalink(pd)) {
+                       if (yflag_dlt != pcap_datalink(pd)) {
                                error("%s is not one of the DLTs supported by this device\n",
-                                     ndo->ndo_dltname);
+                                     yflag_dlt_name);
                        }
 #endif
                        (void)fprintf(stderr, "%s: data link type %s\n",
-                                     program_name, ndo->ndo_dltname);
+                                     program_name, yflag_dlt_name);
                        (void)fflush(stderr);
                }
                i = pcap_snapshot(pd);