Andrew,

Thanks for the information on the history of the ipaddress module - the background reading is very useful. With regards to using existing Pypi modules, that does sounds like a very sensible approach if we can find something suitable; I will research some of the modules you mentioned as well as some others and see if they could be adapted. 

I guess my main objective here is to see if there is sufficient interest from others to warrant pursuing the idea. 

Personally I have found that stdlib support for networking is strangely patchy at the moment; with ipaddress being a great handy module for IP work without requiring dependencies; but seemingly very little networking support before or after that. The 'before' part is what my idea is attempting to tackle. I am not recommending we start investigating further layers of the networking stack post-IP, however I feel the logical step forwards is to have some form of support for the most common form of layer 2 addressing.

Given what i have looked at from your recommendations so far, netaddr seems to be the most fitting at the moment.
Of course an argument can be made that people should simply look to modules like netaddr for their work, however given the point in the above paragraph and that installing a third party module may feel overkill for certain environments that would typically run code performing mac and ip address inspection (e.g. scripts/small programs on a network switch), it is my personal opinion that this would be well suited in the stdlib (which I recognise would require a lot of work and scrutiny to get there).

I'm looking forward to hearing people's opinions on this.


On Sat, Apr 4, 2020 at 10:01 PM Andrew Barnert <abarnert@yahoo.com> wrote:
On Apr 4, 2020, at 12:45, Pete Wicken <petewicken@gmail.com> wrote:
>
> Agreed that this could be achieved by a third party library; and probably already is

PS, I’ve needed something like this a few times in the past, so I can offer some vague memories of what’s available.

I’ve mostly used netifaces, which is amazing and does all the low-level stuff you’d want and is more cross-platform than you’d believe possible. But its API isn’t very ipaddress-like; it’s mostly dicts of strings and enum ints, and most of what it does isn’t relevant here.

There’s a library that I believe is called netaddr (and I think it’s the one with that name on PyPI), which took Google’s ipaddr and expanded it to add MAC/EUI and various other kinds of addresses. If the author is willing, and if it’s solid enough, I’d bet that stripping it down to just MAC and changing the API to parallel ipaddress instead of ipaddr would be a lot easier.

I’ve also used QtNetwork in a GUI app. That obviously isn’t as amenable to borrowing, but if there are any design questions that come up, looking at how Qt does it (and whether they have a billion bug reports/feature requests complaining about it) can be helpful.