Create a "dummy" `struct sockaddr_dl` for devices.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- networking
Direzione di ricerca
Start by reading the pcap_findalldevs.3pcap documentation cited in the issue and inspect how Npcap currently populates each device's address list. Compare the Windows sockaddr_dl option with a Npcap-specific MAC address function and account for older Npcap versions. Done means choosing and implementing a documented way to expose device MAC addresses while preserving the stated compatibility expectations.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Inside a project so far, I've had to use GetAdaptersAddresses to retrieve PhysicalAddress and PhysicalAddressLength as a dirty workaround to retrieve the MAC address of each device. As WinPcap/Npcap does not fill out Data/Linklayer information.
However, like I suspected, it turns out the linked list between IP_ADAPTER_ADDRESSES and pcap_if are not always in the same order. Which means I'll either have to lazily loop over and match devices, or build something to make a lookup.
On the Linux end, I can simply go through the pcap_if_t's addresses linked list, checking if addr->sa_family matches the value of AF_PACKET, and if so, it should (probably) be the MAC address.
Despite Windows seemingly tries everything to avoid anything related to the datalink layer. WinSock2 (ws2def.h to be specific) does seem to include some barebone structure for it. The only caveat is that it's only available on Windows 7 and up (_WIN32_WINNT < 0x0601) inside the header, but that shouldn't really be an issue since Npcap is meant to run on that.
MS seems to be using AF_LINK and sockaddr_dl as their standard for datalink MAC addresses. I'm saying seem to because I was unable to find any official documentation about it from MS Learn.
sockaddr_dl seems to be the best match though, since the man pages for pcap_findalldevs.3pcap says:
Note that the addresses in the list of addresses might be IPv4 addresses, IPv6 addresses, or some other type of addresses, [...] Whether other addresses are returned, and what types they might have is platform-dependent. Namely, link-layer addresses, such as Ethernet MAC addresses, have the value
AF_PACKET(on Linux) orAF_LINK(on AIX, FreeBSD, Haiku, illumos, macOS, NetBSD, OpenBSD and QNX) or are not returned at all (on GNU/Hurd and Solaris).[...] For link-layer addresses, it can be interpreted as if it pointed to a
struct sockaddr_ll(forAF_PACKET, see packet(7)) or astruct sockaddr_dl(forAF_LINK).
And the fact that sockaddr_ll seems to be absent from WinSock2.
One big caveat is that, since this won't be available on older versions of Npcap, it means for backward compatibility I would have to keep a workaround, or warn that MAC addresses will be unavailable unless updated to a more recent version.
A more naive solution would be to make a Npcap exclusive function to return the MAC address (and length) of a device, or return a NULL pointer if no MAC address are available (I.E. loopback).
Also please let me know if I've missed anything from documentation about being able to retrieve MAC addresses via Npcap.
- Lingua principale
- C
- Stelle
- 3.6k
- Fork
- 601
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nmap/npcap
-
driverquery.exe copying to npcap install folder triggers Windows Defender Attack Surface ReductionAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
Installer looks blurryAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Issue simili
-
bug severity: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
AlessandroSangiuliano/Uros#1014 ·
-
severity: low
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
luainkernel/lunatik#2727 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 6 giorni
-
Termux compilation failureApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bot-triaged module: cuda module: memory usage module: pybind module: tensor creation triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pytorch/pytorch#206707 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno