MCPcopy Create free account
hub / github.com/mininet/mininet / ipAdd

Function ipAdd

mininet/util.py:396–406  ·  view source on GitHub ↗

Return IP address string from ints i: int to be added to ipbase prefixLen: optional IP prefix length ipBaseNum: option base IP address as int returns IP address as string

( i, prefixLen=8, ipBaseNum=0x0a000000 )

Source from the content-addressed store, hash-verified

394 return ( w << 24 ) | ( x << 16 ) | ( y << 8 ) | z
395
396def ipAdd( i, prefixLen=8, ipBaseNum=0x0a000000 ):
397 """Return IP address string from ints
398 i: int to be added to ipbase
399 prefixLen: optional IP prefix length
400 ipBaseNum: option base IP address as int
401 returns IP address as string"""
402 imax = 0xffffffff >> prefixLen
403 assert i <= imax, 'Not enough IP addresses in the subnet'
404 mask = 0xffffffff ^ imax
405 ipnum = ( ipBaseNum & mask ) + i
406 return ipStr( ipnum )
407
408def ipParse( ip ):
409 "Parse an IP address and return an unsigned int."

Callers 3

addHostMethod · 0.90
exportScriptMethod · 0.90
buildNodesMethod · 0.90

Calls 1

ipStrFunction · 0.85

Tested by

no test coverage detected