tcpdump mailing list archives

Re: Adding loopback adapter detection for Windows


From: Yang Luo <hsluoyb () gmail com>
Date: Mon, 25 Jan 2016 11:52:34 +0800

On Mon, Jan 25, 2016 at 3:10 AM, Guy Harris <guy () alum mit edu> wrote:

On Jan 24, 2016, at 8:30 AM, Yang Luo <hsluoyb () gmail com> wrote:

I forgot about one most important thing that libpcap seemingly doesn't
compile under Windows, even if there's a Win32\Prj in it. Actually I got
many errors when I build libpcap under VS2005.

I am quite confused with some lines like this in pcap-int.h:

The current version of libpcap's pcap-int.h doesn't look like:


I used the release 1.7.4 because I thought it would be stable.



typedef int (*activate_op_t)(pcap_t *);
typedef int (*can_set_rfmon_op_t)(pcap_t *);
typedef int (*read_op_t)(pcap_t *, int cnt, pcap_handler, u_char *);
typedef int (*inject_op_t)(pcap_t *, const void *, size_t);
typedef int (*setfilter_op_t)(pcap_t *, struct bpf_program *);
typedef int (*setdirection_op_t)(pcap_t *, pcap_direction_t);
typedef int (*set_datalink_op_t)(pcap_t *, int);
typedef int (*getnonblock_op_t)(pcap_t *, char *);
typedef int (*setnonblock_op_t)(pcap_t *, int, char *);
typedef int (*stats_op_t)(pcap_t *, struct pcap_stat *);
#ifdef WIN32
typedef int (*setbuff_op_t)(pcap_t *, int);
typedef int (*setmode_op_t)(pcap_t *, int);
typedef int (*setmintocopy_op_t)(pcap_t *, int);
typedef Adapter *(*getadapter_op_t)(pcap_t *);
#endif
typedef void (*cleanup_op_t)(pcap_t *);

it looks like:

typedef int     (*activate_op_t)(pcap_t *);
typedef int     (*can_set_rfmon_op_t)(pcap_t *);
typedef int     (*read_op_t)(pcap_t *, int cnt, pcap_handler, u_char *);
typedef int     (*inject_op_t)(pcap_t *, const void *, size_t);
typedef int     (*setfilter_op_t)(pcap_t *, struct bpf_program *);
typedef int     (*setdirection_op_t)(pcap_t *, pcap_direction_t);
typedef int     (*set_datalink_op_t)(pcap_t *, int);
typedef int     (*getnonblock_op_t)(pcap_t *, char *);
typedef int     (*setnonblock_op_t)(pcap_t *, int, char *);
typedef int     (*stats_op_t)(pcap_t *, struct pcap_stat *);
#ifdef _WIN32
typedef struct pcap_stat *(*stats_ex_op_t)(pcap_t *, int *);
typedef int     (*setbuff_op_t)(pcap_t *, int);
typedef int     (*setmode_op_t)(pcap_t *, int);
typedef int     (*setmintocopy_op_t)(pcap_t *, int);
typedef HANDLE  (*getevent_op_t)(pcap_t *);
typedef int     (*oid_get_request_op_t)(pcap_t *, bpf_u_int32, void *,
size_t);
typedef int     (*oid_set_request_op_t)(pcap_t *, bpf_u_int32, const void
*, size_t);
typedef u_int   (*sendqueue_transmit_op_t)(pcap_t *, pcap_send_queue *,
int);
typedef int     (*setuserbuffer_op_t)(pcap_t *, int);
typedef int     (*live_dump_op_t)(pcap_t *, char *, int, int);
typedef int     (*live_dump_ended_op_t)(pcap_t *, int);
typedef PAirpcapHandle  (*get_airpcap_handle_op_t)(pcap_t *);
#endif
typedef void    (*cleanup_op_t)(pcap_t *);

which, among other things, doesn't use "Adapter" at all.


It seems that the trunk is better than the 1.7.4 release, at least the
former doesn't have something like Adapter.



And, speaking of Win32\Prj, that's now deprecated - get CMake:

        https://cmake.org

and use that.  autotools are also supported (and are the main build
mechanisms supported) on UN*X, but the old Windows projects aren't being
kept up-to-date.


Good. Is there some official guideline about how to build libpcap (or try
to port) on Windows, or how to use CMAKE on libpcap?



It seems that libpcap has considered Windows as there's WIN32 macro, but
Adapter is not defined as VS2005 error shows.

You should use the *current* version of libpcap, not whatever older
version you're using (the one that comes with WinPcap?).



Cheers,
Yang
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers () lists tcpdump org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers


Current thread: