orweis / winpcapy

A Modern Python wrapper for WinPcap
GNU General Public License v2.0
76 stars 23 forks source link

Can I get the IP address through a certain dev name? #5

Closed litesky closed 7 years ago

litesky commented 7 years ago

My work environment is Win10 64bit, Python 3.5.2, Win10Pcap:

>>> from winpcapy import WinPcapDevices
>>> with WinPcapDevices() as devices:
...     for device in devices:
...         print (device.addresses.contents.addr.contents.sa_data)
b''
>>> from winpcapy import winpcapy_types as wtypes
>>> import ctypes
>>> err_buffer = ctypes.create_string_buffer(wtypes.PCAP_ERRBUF_SIZE)
>>> dev_name = b'...'
>>> valA = ctypes.c_uint(1)
>>> valB = ctypes.c_uint(1)
>>> wtypes.pcap_lookupnet(dev_name, valA, valB, err_buffer)
0
>>> valA
0
>>> valB
0
orweis commented 7 years ago

While this isn't something currently handled by this module, you should be able to do it with WinPcap (through ctypes) and (several other methods as well) I'd suggest glancing at: https://www.winpcap.org/pipermail/winpcap-users/2006-July/001214.html Specifically item #6.