raphdg / netifaces Goto Github PK
View Code? Open in Web Editor NEWI'm not the author of netifaces, I just added the project on github and I added a spec file to build the RPM package for the basic Amazon Linux AMI 2012.03
I'm not the author of netifaces, I just added the project on github and I added a spec file to build the RPM package for the basic Amazon Linux AMI 2012.03
running install
running bdist_egg
running egg_info
writing netifaces.egg-info/PKG-INFO
writing top-level names to netifaces.egg-info/top_level.txt
writing dependency_links to netifaces.egg-info/dependency_links.txt
reading manifest file 'netifaces.egg-info/SOURCES.txt'
writing manifest file 'netifaces.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_ext
checking for getifaddrs... found. (cached)
checking for getnameinfo... found. (cached)
checking for optional header files... netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h linux/irda.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h. (cached)
checking whether struct sockaddr has a length field... no. (cached)
checking which sockaddr_xxx structs are defined... at ax25 in in6 ipx un ash ec ll atmpvc atmsvc dn irda llc. (cached)
building 'netifaces' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DNETIFACES_VERSION=0.8 -DHAVE_GETIFADDRS=1 -DHAVE_GETNAMEINFO=1 -DHAVE_NETASH_ASH_H=1 -DHAVE_NETATALK_AT_H=1 -DHAVE_NETAX25_AX25_H=1 -DHAVE_NETECONET_EC_H=1 -DHAVE_NETIPX_IPX_H=1 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_LINUX_IRDA_H=1 -DHAVE_LINUX_ATM_H=1 -DHAVE_LINUX_LLC_H=1 -DHAVE_LINUX_TIPC_H=1 -DHAVE_LINUX_DN_H=1 -DHAVE_SOCKADDR_AT=1 -DHAVE_SOCKADDR_AX25=1 -DHAVE_SOCKADDR_IN=1 -DHAVE_SOCKADDR_IN6=1 -DHAVE_SOCKADDR_IPX=1 -DHAVE_SOCKADDR_UN=1 -DHAVE_SOCKADDR_ASH=1 -DHAVE_SOCKADDR_EC=1 -DHAVE_SOCKADDR_LL=1 -DHAVE_SOCKADDR_ATMPVC=1 -DHAVE_SOCKADDR_ATMSVC=1 -DHAVE_SOCKADDR_DN=1 -DHAVE_SOCKADDR_IRDA=1 -DHAVE_SOCKADDR_LLC=1 -I/usr/include/python2.7 -c netifaces.c -o build/temp.linux-armv7l-2.7/netifaces.o
netifaces.c:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
Give me a moment to get to my question in context.
I am building a skill for Alexa to control my Onkyo Stereo orally. There is already good python code for this project on Github that can be adapted to an Echo skill. The existing code uses netifaces to 'discover' Onkyo receivers on the target network.
I can not get the netifaces module up and running on Amazon Lambda server. The Lambda site does not appear to use .pyd files. No problem, I should not have built netifaces on a Win10 machine and tried to use it on Amazon's Linux server. I built a .so file on my Raspberry Pi 3. Sadly, the PI is 32 bit and the Lambda server is apparently 64 bit since it rejected the 32 bit .so file with an error message to that effect.
Finally the question.
So, can I build a 64 bit .so file with what I have got , a Raspberry Pi and a Win10 machine? If not can some one build me a 64 bit .so file for linux?
For convenience, we also allow you to index the dictionary with the special value 'default', which returns a dictionary mapping address families to the default gateway in each case. Thus you can get the default IPv4 gateway with
gws = netifaces.gateways()
gws['default'][netifaces.AF_INET]
('10.0.1.1', 'en0')
The results from this test - I tried replacing "[]" with "()" in different combinations but get errors as follows:
TypeError Traceback (most recent call last)
in ()
----> 1 gws['default'][netifaces.AF_INET]
TypeError: 'builtin_function_or_method' object is not subscriptable
TypeError Traceback (most recent call last)
in ()
----> 1 gws['default'][netifaces.AF_INET]
TypeError: 'builtin_function_or_method' object is not subscriptable
TypeError Traceback (most recent call last)
in ()
----> 1 gws('default')[netifaces.AF_INET]
TypeError: gateways() takes no arguments (1 given)
TypeError Traceback (most recent call last)
in ()
----> 1 gws'default'
TypeError: 'builtin_function_or_method' object is not subscriptable
TypeError Traceback (most recent call last)
in ()
----> 1 gws('default')(netifaces.AF_INET)
TypeError: gateways() takes no arguments (1 given)
Is there a solution to this issue?
First, let me say I have no idea whose repo to contribute to for netifaces. The one that pypy lists as the Github project is now 'archived' and no one can contribute to it. I don't know why this was done but I feel it was a bad decision. This project is very useful and multiple people have tried to contribute stuff!
Anyway, NIC names for interfaces on windows are basically just hex strings. The most intelligible data you have for NIC on Windows seems to be the description where you have something like 'Realtek Gaming 2.5GbE Family Controller' instead of '{B2FE597D-E4C7-40E6-960B-E4BFEB88062F}'. I have too much to do to write a pull request but I wanted to provide a simple function that lets you convert a description to a NIC id which can then be used with the netifaces code. Here it is:
def nt_reg_nic(value, desc=0, guid=0):
import winreg
nic_keys = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards')
nic_no, _, _ = winreg.QueryInfoKey(nic_keys)
for nic_offset in range(0, nic_no):
nic_key = None
try:
nic_key_name = winreg.EnumKey(nic_keys, nic_offset)
nic_key = winreg.OpenKey(nic_keys, nic_key_name)
nic_desc, _ = winreg.QueryValueEx(nic_key, "Description")
nic_guid, _ = winreg.QueryValueEx(nic_key, "ServiceName")
if desc:
if value in nic_desc:
winreg.CloseKey(nic_keys)
return nic_guid
if guid:
if value in nic_guid:
winreg.CloseKey(nic_keys)
return nic_desc
except:
continue
finally:
if nic_key is not None:
winreg.CloseKey(nic_key)
winreg.CloseKey(nic_keys)
return None
nt_reg_nic("Realtek Gaming 2.5GbE Family Controller", desc=1) == '{B2FE597D-E4C7-40E6-960B-E4BFEB88062F}'
nt_reg_nic('{B2FE597D-E4C7-40E6-960B-E4BFEB88062F}', guid=1) == "Realtek Gaming 2.5GbE Family Controller"
By the way: to get NIC descriptions for use with this function you can type route print into CMD. This command will show an interface list that has: [nic_no, nic_mac, nic_description] -- the 3rd column is what you can use for the above function. Note also that there's a lot of garbage in this output. I.E. interfaces that might not even have IPs, are virtual interfaces (mine has VBOX interfaces), and so on. As far as I know netifaces also shows all such interfaces on Windows but has some nice functions to show what the 'default' interfaces are for IPv4 and IPv6 routing. So engineers might want to check out that. Cheers.
Output from netifaces.ifaddresses("enp3s0")[netifaces.AF_INET6]:
[{'addr': 'some link local address here%enp3s0', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]
The netmask for link-local in IPv6 is: 'fe80:0000:0000:0000:0000:0000:0000:0000.' It's specified to be /10 but in practice people use /64. I showed it using the uncompressed form of the address to avoid confusion. The last 64 bits are the host portion.
I'm also not sure the netmask returned for IPv6 'global addresses' makes sense either. With IPv4, you might write something like 0.0.0.0? But netifaces returns FF:FF:... setting all bits to one. It might make more sense to return something like ::/128 -- there is no network part for such global addresses.
Hello Github,
I've been using netifaces for my P2P networking project and the software is great for the most part. But on Windows it requires the .NET framework which isn't very portable. There is also the issue of interface names being unintelligible and other small bugs. For example: I've noticed on some platforms IPv6 link-local net masks are incorrect. While on Android the software fails to find default gateways. So I've written some patches for these problems.
My own library replaces netifaces on Windows completely with a wrapper around powershell. It uses async coroutines so the program doesn't block. Usage looks like this:
python3 -m asyncio
... REPR starts now with await support ...
from p2pd import *
netifaces = await init_p2pd()
The interface for this object is compatible with netifaces. The software also supports selecting different interfaces for use with network programming and handles loading all address information for you.
i = await Interface()
await i.load_nat()
print(i)
If you're interested in async networking or P2P networking there's more information on p2pd.net. Cheers and hope this issue isn't taken badly.
support ip hash and RR ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.