-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement socket.if_{nametoindex,indextoname} for Windows #81188
Comments
These two calls are currently Unix-only in the socket module. However, Windows supports them starting with Vista: I checked with ctypes and they do seem to work. Unfortunately, if_nameindex is not implemented. |
I've created a PR for this issue. Few changes are needed to implement these functions on Windows. |
Is it worth also implementing if_nameindex() using (I assume) GetIfTable2Ex 1? Or maybe just the simpler GetIfTable is sufficient - I'm not sure exactly what semantics Unix if_nameindex() has, whether it includes all logical adapters. |
That would be fantastic, but I did not dare asking for it :) This is how the output of if_nameindex looks on my Fedora 29: [(1, 'lo'), (2, 'enp0s31f6'), (3, 'wlp4s0'), (4, 'virbr0'), (5, 'virbr0-nic'), (12, 'tun0')] It includes the loopback, two real adapters (ethernet and wifi) and devices apparently created by libvirt. This is how it looks on my OpenStack testing environment: [(1, 'lo'), (2, 'eth0'), (3, 'virbr0'), (4, 'virbr0-nic'), (5, 'ovs-system'), (6, 'br-int'), (7, 'br-ex'), (8, 'brbm'), (9, 'br-tun'), (14, 'ovs-node-0i1'), (15, 'tap-node-0i1'), (16, 'ovs-node-0i2'), (17, 'tap-node-0i2'), (18, 'ovs-node-1i1'), (19, 'tap-node-1i1'), (20, 'ovs-node-1i2'), (21, 'tap-node-1i2'), (22, 'ovs-node-2i1'), (23, 'tap-node-2i1'), (24, 'ovs-node-2i2'), (25, 'tap-node-2i2'), (26, 'ovs-tap'), (27, 'brbm-tap'), (34, 'br-inspector'), (35, 'brbm-inspector'), (55, 'macvtap2'), (56, 'macvtap3'), (79, 'macvtap0'), (80, 'macvtap1')] It seems to actually include everything. |
Well, it turns out that implementing if_nameindex() on Windows using GetIfTable2Ex() was also quite simple. I've updated the PR. |
Great, thanks Zackery! (And thanks for the ping - I don't notice GitHub notifications.) Had a few comments about error handling, but it looks great. |
Thanks, Steve. I've addressed your comments on the PR. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: