Exscript.stdlib.ipv4 module

Exscript.stdlib.ipv4.broadcast(*args, **kwargs)[source]

Given a prefix, this function returns the corresponding broadcast address.

Parameters:prefixes (string) – An IP prefix.
Return type:string
Returns:The broadcast address(es) of the prefix length(s).
Exscript.stdlib.ipv4.in_network(*args, **kwargs)[source]

Returns True if the given destination is in the network range that is defined by the given prefix (e.g. 10.0.0.1/22). If the given prefix does not have a prefix length specified, the given default prefix length is applied. If no such prefix length is given, the default length is /24.

If a list of prefixes is passed, this function returns True only if the given destination is in ANY of the given prefixes.

Parameters:
  • prefixes (string) – A prefix, or a list of IP prefixes.
  • destination (string) – An IP address.
  • default_pfxlen (int) – The default prefix length.
Return type:

True

Returns:

Whether the given destination is in the given network.

Exscript.stdlib.ipv4.mask(*args, **kwargs)[source]

Applies the given IP mask (e.g. 255.255.255.0) to the given IP address (or list of IP addresses) and returns it.

Parameters:
  • ips (string) – A prefix, or a list of IP prefixes.
  • mask (string) – An IP mask.
Return type:

string

Returns:

The network(s) that result(s) from applying the mask.

Exscript.stdlib.ipv4.mask2pfxlen(*args, **kwargs)[source]

Converts the given IP mask(s) (e.g. 255.255.255.0) to prefix length(s).

Parameters:masks (string) – An IP mask, or a list of masks.
Return type:string
Returns:The prefix length(s) that result(s) from converting the mask.
Exscript.stdlib.ipv4.network(*args, **kwargs)[source]

Given a prefix, this function returns the corresponding network address.

Parameters:prefixes (string) – An IP prefix.
Return type:string
Returns:The network address(es) of the prefix length(s).
Exscript.stdlib.ipv4.pfxlen2mask(*args, **kwargs)[source]

Converts the given prefix length(s) (e.g. 30) to IP mask(s).

Parameters:pfxlen (int) – An IP prefix length.
Return type:string
Returns:The mask(s) that result(s) from converting the prefix length.
Exscript.stdlib.ipv4.pfxmask(*args, **kwargs)[source]

Applies the given prefix length to the given ips, resulting in a (list of) IP network addresses.

Parameters:
  • ips (string) – An IP address, or a list of IP addresses.
  • pfxlen (int) – An IP prefix length.
Return type:

string

Returns:

The mask(s) that result(s) from converting the prefix length.

Exscript.stdlib.ipv4.remote_ip(*args, **kwargs)[source]

Given an IP address, this function calculates the remaining available IP address under the assumption that it is a /30 network. In other words, given one link net address, this function returns the other link net address.

Parameters:local_ips (string) – An IP address, or a list of IP addresses.
Return type:string
Returns:The other IP address of the link address pair.