ifconfig C module
M.-A. Lemburg
mal at lemburg.com
Fri Aug 13 05:55:32 EDT 1999
> I got permission to publish the results of my 'ifconfig' module.
>
> Since it's rather small, I thought I would post the whole thing here.
>
> I realize it's not perfect, but it does what I need. I'll accept
> patches to make it better. I'm sure the license could be changed to
> the Python one if there is interest in including it in the main
> distribution.
I'd suggest adding this to either the socketmodule.c or the
fcntlmodule.c in the standard Python distribution.
FYI, I've spiced up the file a bit and turned it into a package
which is available here for easier install:
http://starship.skyport.net/~lemburg/ifconfig-0.1.zip
I changed the names a little in the above archive:
Package name: ifconfig
API: ifconfig.ifconfig
>From David's code:
The command ifconfig.ifconfig(interface_name), where
interface_name is the name of the interface, such as 'eth0' or 'lo'
returns a dictionary with the following keys:
hwaddr: hardware address
addr: ip address
brdaddr: broadcast address
netmask: netmask
Great work, David ! I never thought it would be that easy to get
at the hardware MAC address. Now the only question remaining is:
how portable is this code ? E.g. does it compile on Windows ?
Cheers,
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 140 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/
More information about the Python-list
mailing list