morpheus.parsers.ip

Functions

hostmask(ips[, prefixlen]) Compute a column of hostmasks for a column of IP addresses.
int_to_ip(values) Convert integer column to IP addresses.
ip_to_int(values) Convert string column of IP addresses to integer values.
is_global(ips) Indicates whether each address is global.
is_ip(ips) Indicates whether each address is an ip string.
is_link_local(ips) Indicates whether each address is link local.
is_loopback(ips) Indicates whether each address is loopback.
is_multicast(ips) Indicates whether each address is multicast.
is_private(ips) Indicates whether each address is private.
is_reserved(ips) Indicates whether each address is reserved.
is_unspecified(ips) Indicates whether each address is unspecified.
mask(ips, masks) Apply a mask to a column of IP addresses.
netmask(ips[, prefixlen]) Compute a column of netmasks for a column of IP addresses.
hostmask(ips, prefixlen=16)[source]

Compute a column of hostmasks for a column of IP addresses. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

prefixlen: integer

Length of the network prefix, in bits, for IPv4 addresses

Returns
rtypecudf.Series

Hostmask ouput from set of IP address

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.hostmask(cudf.Series(["192.168.0.1","10.0.0.1"]), prefixlen=16) 0 0.0.255.255 1 0.0.255.255 Name: hostmask, dtype: object

int_to_ip(values)[source]

Convert integer column to IP addresses. Addresses must be IPv4. IPv6 not yet supported.

Parameters
valuescudf.Series

Integer representations of IP addresses

Returns
rtypecudf.Series

IPv4 addresses

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.int_to_ip(cudf.Series([3232235521, 167772161])) 0 192.168.0.1 1 10.0.0.1 dtype: object

ip_to_int(values)[source]

Convert string column of IP addresses to integer values. Addresses must be IPv4. IPv6 not yet supported.

Parameters
valuescudf.Series

IPv4 addresses to be converted

Returns
rtypecudf.Series

Integer representations of IP addresses

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.ip_to_int(cudf.Series(["192.168.0.1","10.0.0.1"])) 0 3232235521 1 167772161 dtype: int64

is_global(ips)[source]

Indicates whether each address is global. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_global(cudf.Series(["127.0.0.1","207.46.13.151"])) 0 False 1 True dtype: bool

is_ip(ips)[source]

Indicates whether each address is an ip string. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_ip(cudf.Series(["192.168.0.1","10.123.0"])) 0 True 1 False dtype: bool

Indicates whether each address is link local. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_link_local(cudf.Series(["127.0.0.1","169.254.123.123"])) 0 False 1 True dtype: bool

is_loopback(ips)[source]

Indicates whether each address is loopback. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_loopback(cudf.Series(["127.0.0.1","10.0.0.1"])) 0 True 1 False dtype: bool

is_multicast(ips)[source]

Indicates whether each address is multicast. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_multicast(cudf.Series(["127.0.0.1","224.0.0.0"])) 0 False 1 True dtype: bool

is_private(ips)[source]

Indicates whether each address is private. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_private(cudf.Series(["127.0.0.1","207.46.13.151"])) 0 True 1 False dtype: bool

is_reserved(ips)[source]

Indicates whether each address is reserved. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_reserved(cudf.Series(["127.0.0.1","10.0.0.1"])) 0 False 1 False dtype: bool

is_unspecified(ips)[source]

Indicates whether each address is unspecified. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

Returns
rtypecudf.Series

Boolean values true or false

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.is_unspecified(cudf.Series(["127.0.0.1","10.0.0.1"])) 0 False 1 False dtype: bool

mask(ips, masks)[source]

Apply a mask to a column of IP addresses. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

masks: cudf.Series

The host or subnet masks to be applied

Returns
rtypecudf.Series

Masked IP address from list of IPs

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> input_ips = cudf.Series(["192.168.0.1","10.0.0.1"]) >>> input_masks = cudf.Series(["255.255.0.0", "255.255.0.0"]) >>> ip.mask(input_ips, input_masks) 0 192.168.0.0 1 10.0.0.0 Name: mask, dtype: object

netmask(ips, prefixlen=16)[source]

Compute a column of netmasks for a column of IP addresses. Addresses must be IPv4. IPv6 not yet supported.

Parameters
ipscudf.Series

IPv4 addresses to be checked

prefixlen: int

Length of the network prefix, in bits, for IPv4 addresses

Returns
rtypecudf.Series

Netmask ouput from set of IP address

Examples

Copy
Copied!
            

>>> import morpheus.parsers.ip as ip >>> import cudf >>> ip.netmask(cudf.Series(["192.168.0.1","10.0.0.1"]), prefixlen=16) 0 255.255.0.0 1 255.255.0.0 Name: net_mask, dtype: object

Previous morpheus.parsers.event_parser.EventParser
Next morpheus.parsers.splunk_notable_parser
© Copyright 2023, NVIDIA. Last updated on Feb 2, 2024.