Package mmc :: Package plugins :: Package network :: Module tools
[hide private]
[frames] | no frames]

Module tools

source code

Functions [hide private]
 
dottedQuadToNum(ip)
Convert decimal dotted quad string to long integer
source code
 
numToDottedQuad(n)
Convert long int to dotted quad string
source code
 
makeMask(n)
Return a mask of n bits as a long integer
source code
 
ipInRange(ipAddress, beginRange, endRange)
Return True if IP is between begin and end
source code
str
ipNext(network, netmask, startAt=None, boundaries=False)
Return the next IP address on a network range, or an empty string
source code
list
getAllNetworkInterfaces()
Get all network device interfaces using /proc.
source code
int
detectNetworkInterfaceRate(device, cmd='/usr/sbin/ethtool')
Use ethtool to detect network device rate.
source code
Function Details [hide private]

ipNext(network, netmask, startAt=None, boundaries=False)

source code 

Return the next IP address on a network range, or an empty string

Parameters:
  • network (str) - dotted quad IP representation
  • netmask (int) - number of bits in netmask
  • startAt (str) - IP from which to get the next IP
  • boundaries (bool) - flag telling whether the network address and the broadcast address are also returned
Returns: str
an IP address in dotted quad representation, or an empty string

getAllNetworkInterfaces()

source code 

Get all network device interfaces using /proc. Linux only.

Returns: list
a list of ethernet interfaces

detectNetworkInterfaceRate(device, cmd='/usr/sbin/ethtool')

source code 

Use ethtool to detect network device rate. We can use the given rate only if:

  • the link is up on the device (if the link is down, the device is on low speed mode, and this speed may change when the link is up again)
  • auto-negociation is on (else the speed information can't be really trusted)
Returns: int
interface rate in kbit/s, or None if the rate can't be detected