[Winpcap-users] Is there a way to get the 'adapter' field in winpcap 4.1.2?

Guy Harris guy at alum.mit.edu
Thu Jun 20 13:21:22 PDT 2013


On Jun 20, 2013, at 12:52 PM, Ben Greear <greearb at candelatech.com> wrote:

> I'm trying to upgrade from an older (OEM) winpcap to winpcap OME 4.1.2.
> 
> I have been using code like this:
> 
>      oid->Oid = OID_GEN_MEDIA_CONNECT_STATUS;
>      oid->Length = 1024 - (sizeof(oid->Oid) - sizeof(oid->Length));
>      if (PacketRequest(np->adapter, false, oid)) {
> 
> But, it seems that the 'struct pcap' is no longer defined anywhere,
> and I cannot find anything equivalent to get the adapter.
> 
> Anyone have any ideas?

I would suggest writing a pcap_get_adapter() routine:

	/*
	 * XXX - "struct pcap" is not guaranteed to look the same from
	 * release to release, so use this only with current releases;
	 * if it changes, the future release should include a pcap_get_adapter()
	 * routine that will return the ADAPTER regardless of the layout of
	 * the structure.
	 */
	struct pcap_internal {
		ADAPTER *adapter;
	};

	ADAPTER *
	pcap_get_adapter(pcap_t *p)
	{
		struct pcap_internal *p_int = (struct pcap_internal *)(void *)p;

		return (p->adapter);
	}

and be prepared for a future release perhaps 1) having the "adapter" member at a different offset in the pcap_t structure (which is opaque outside libpcap/WinPcap, and subject to change from release to release) and 2) providing a pcap_get_adapter() routine.  (See libpcap checkins e9e96bbc3efd45ba6d1dbb097bc09845ba54c5d6 and 2933fb0ae763f9463eb904ed6ddf0a033b6ba635; some future WinPcap release might pick up a newer libpcap version, but there's a fair bit of libpcap work needed to make that happen, so that remote capture is still available.)


More information about the Winpcap-users mailing list