#include <netdissect-stdinc.h>
#ifdef _WIN32
-#ifndef _WINSOCKAPI_
-#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
-#endif /* _WINSOCKAPI_ */
-#include <windows.h>
-#include <winsock2.h>
-extern int SIZE_BUF;
#define off_t long
#define uint UINT
#endif /* _WIN32 */
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;
- ndo->ndo_immediate = 0;
cnt = -1;
device = NULL;
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)
#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
case OPTION_IMMEDIATE_MODE:
- ndo->ndo_immediate = 1;
+ immediate_mode = 1;
break;
#endif
* probably expecting to see packets pop up immediately.
*/
if (WFileName == NULL && isatty(1))
- ndo->ndo_immediate = 1;
+ immediate_mode = 1;
#endif
#ifdef WITH_CHROOT
#endif
#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
- if (ndo->ndo_immediate) {
+ if (immediate_mode) {
status = pcap_set_immediate_mode(pd, 1);
if (status != 0)
error("%s: Can't set immediate mode: %s",
#endif /* HAVE_PCAP_SETDIRECTION */
#else
*ebuf = '\0';
- pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
+ pd = pcap_open_live(device, ndo->ndo_snaplen, !pflag, 1000,
+ ebuf);
if (pd == NULL)
error("%s", ebuf);
else if (*ebuf)
#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
/*
* 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);