mfontanini / libtins

High-level, multiplatform C++ network packet sniffing and crafting library.
http://libtins.github.io/
BSD 2-Clause "Simplified" License
1.91k stars 377 forks source link

Don't throw exception for empty interface #531

Open someburner opened 5 months ago

someburner commented 5 months ago

had an odd issue on my openwrt router. my libtins app would worked fine until installing netem e.g. opkg install kmod-netem which depends on kmod-sched. After installing that, a new empty interface is created (at least on openwrt, not sure about other distros) that has no IP address.

I see no reason to throw an exception here. It is especially problematic because at least in my app, the interfaces are initialized when the program starts, I suppose in a constructor somewhere.

Simply removing this solves the issue. Perhaps a better approach would be to only throw an exception when a given interface is empty and chosen for us with a sniffer. I'm not exactly sure how kmod-sched uses the empty interface, but it may even be desirable to monitor such an interface.

In short.. I believe this check should be deleted or at least turned into something that doesnt abort a program.