segevfiner / cypcap

A Cython based Python binding for modern libpcap
https://pypi.org/project/cypcap/
BSD 3-Clause "New" or "Revised" License
14 stars 1 forks source link

Add additional per-platform sockaddr support for findalldevs #10

Closed segevfiner closed 2 years ago

segevfiner commented 2 years ago

findalldevs might return additional sockaddr families than just AF_INET/AF_INET6, for example on Linux we get AF_PACKET/sockaddr_sll. The current code just dumps the raw bytes of the sockaddr which is also truncated as we don't know the correct length.

Sadly Cython doesn't support conditional compilation properly (IF is troublesome as it is done in C generation time, see https://groups.google.com/g/cython-users/c/C52mc9lm5xo), so we will need to drop such additional conversion to an auxiliary C source file or verbatim C code in a cdef extern.

Also, outputting the raw bytes like that might be useful for debugging, but might be confusing for users if it happens to them in the future, might want to consider this case.