Standard Library

contextoutput: Log
contextrpki: Rpki
contextasn_lists: AsnLists
contextprefix_lists: PrefixLists
contextmetrics: Metrics
constantNO_PEER: Community

The well-known NO_PEER community (RFC3765)

constantNO_EXPORT_SUBCONFED: Community

The well-known NO_EXPORT_SUBCONFED community (RFC1997)

constantNO_EXPORT: Community

The well-known NO_EXPORT community (RFC1997)

constantLOCALHOSTV4: IpAddr

The IPv4 address pointing to localhost: 127.0.0.1

constantNO_ADVERTISE: Community

The well-known NO_ADVERTISE community (RFC1997)

constantLOCALHOSTV6: IpAddr

The IPv6 address pointing to localhost: ::1

typebool

The boolean type

This type has two possible values: true and false. Several boolean operations can be used with booleans, such as && (logical and), || (logical or) and not.

methodbool.to_string() String

Convert this value into a String

typeu8

The unsigned 8-bit integer type

This type can represent integers from 0 up to (and including) 255.

methodu8.to_string() String

Convert this value into a String

typeu16

The unsigned 16-bit integer type

This type can represent integers from 0 up to (and including) 65535.

methodu16.to_string() String

Convert this value into a String

typeu32

The unsigned 32-bit integer type

This type can represent integers from 0 up to (and including) 4294967295.

methodu32.to_string() String

Convert this value into a String

methodu32.fmt() String
typeu64

The unsigned 64-bit integer type

This type can represent integers from 0 up to (and including) 18446744073709551615.

methodu64.to_string() String

Convert this value into a String

typei8

The signed 8-bit integer type

This type can represent integers from -128 up to (and including) 127.

methodi8.to_string() String

Convert this value into a String

typei16

The signed 16-bit integer type

This type can represent integers from -32768 up to (and including) 32767.

methodi16.to_string() String

Convert this value into a String

typei32

The signed 32-bit integer type

This type can represent integers from -2147483648 up to (and including) 2147483647.

methodi32.to_string() String

Convert this value into a String

typei64

The signed 64-bit integer type

This type can represent integers from -9223372036854775808 up to (and including) 9223372036854775807.

methodi64.to_string() String

Convert this value into a String

typef32

The 32-bit floating point type

methodf32.to_string() String

Convert this value into a String

methodf32.floor() f32

Returns the largest integer less than or equal to self.

methodf32.ceil() f32

Returns the smallest integer greater than or equal to self.

methodf32.round() f32

Returns the nearest integer to self. If a value is half-way between two integers, round away from 0.0.

methodf32.abs() f32

Computes the absolute value of self.

methodf32.sqrt() f32

Returns the square root of a number.

methodf32.pow(y: f32) f32

Raises a number to a floating point power.

methodf32.is_nan() bool

Returns true if this value is NaN.

methodf32.is_infinite() bool

Returns true if this value is positive infinity or negative infinity, and false otherwise.

methodf32.is_finite() bool

Returns true if this number is neither infinite nor NaN.

typef64

The 64-bit floating point type

methodf64.to_string() String

Convert this value into a String

methodf64.floor() f64

Returns the largest integer less than or equal to self.

methodf64.ceil() f64

Returns the smallest integer greater than or equal to self.

methodf64.round() f64

Returns the nearest integer to self. If a value is half-way between two integers, round away from 0.0.

methodf64.abs() f64

Computes the absolute value of self.

methodf64.sqrt() f64

Returns the square root of a number.

methodf64.pow(y: f64) f64

Raises a number to a floating point power.

methodf64.is_nan() bool

Returns true if this value is NaN.

methodf64.is_infinite() bool

Returns true if this value is positive infinity or negative infinity, and false otherwise.

methodf64.is_finite() bool

Returns true if this number is neither infinite nor NaN.

typeAsn

An ASN: an Autonomous System Number

An AS number can contain a number of 32-bits and is therefore similar to a u32. However, AS numbers cannot be manipulated with arithmetic operations. An AS number is constructed with the AS prefix followed by a number.

AS0
AS1010
AS4294967295
methodAsn.to_string() String

Convert this value into a String

methodAsn.fmt() String

Return the formatted string for asn

typeIpAddr

An IP address

Can be either IPv4 or IPv6.

For IPv4, only dot-separated quad notation is supported.

# IPv4 examples
127.0.0.1
0.0.0.0
255.255.255.255

# IPv6 examples
0:0:0:0:0:0:0:1
::1
::
methodIpAddr.to_string() String

Convert this value into a String

methodIpAddr.eq(b: IpAddr) bool

Check whether two IP addresses are equal

A more convenient but equivalent method for checking equality is via the == operator.

An IPv4 address is never equal to an IPv6 address. IP addresses are considered equal if all their bits are equal.

192.0.0.0 == 192.0.0.0   # -> true
::0 == ::0               # -> true
192.0.0.0 == 192.0.0.1   # -> false
0.0.0.0 == 0::0          # -> false

# or equivalently:
192.0.0.0.eq(192.0.0.0)  # -> true
methodIpAddr.is_ipv4() bool

Returns true if this address is an IPv4 address, and false otherwise.

1.1.1.1.is_ipv4() # -> true
::.is_ipv4()      # -> false
methodIpAddr.is_ipv6() bool

Returns true if this address is an IPv6 address, and false otherwise.

1.1.1.1.is_ipv6() # -> false
::.is_ipv6()      # -> true
methodIpAddr.to_canonical() IpAddr

Converts this address to an IPv4 if it is an IPv4-mapped IPv6 address, otherwise it returns self as-is.

typePrefix

An IP address prefix: the combination of an IP address and a prefix length

A prefix can be constructed with the / operator or with the Prefix.new function. This operator takes an IpAddr and a u8 as operands.

1.1.1.0 / 8
192.0.0.0.0 / 24
methodPrefix.to_string() String

Convert this value into a String

static methodPrefix.new(ip: IpAddr, len: u8) Prefix

Construct a new prefix

A prefix can also be constructed with the / operator.

Prefix.new(192.169.0.0, 16)

# or equivalently
192.169.0.0 / 16
typeString

The string type

methodString.to_string() String

Convert this value into a String

methodString.append(b: String) String

Append a string to another, creating a new string

"hello".append(" ").append("world") # -> "hello world"
methodString.contains(needle: String) bool

Check whether a string contains another string

"haystack".contains("hay")  # -> true
"haystack".contains("corn") # -> false
methodString.starts_with(prefix: String) bool

Check whether a string starts with a given prefix

"haystack".starts_with("hay")   # -> true
"haystack".starts_with("trees") # -> false
methodString.ends_with(suffix: String) bool

Check whether a string end with a given suffix

"haystack".ends_with("stack") # -> true
"haystack".ends_with("black") # -> false
methodString.to_lowercase() String

Create a new string with all characters converted to lowercase

"LOUD".to_lowercase() # -> "loud"
methodString.to_uppercase() String

Create a new string with all characters converted to uppercase

"quiet".to_uppercase() # -> "QUIET"
methodString.repeat(n: u32) String

Repeat a string n times and join them

"ha".repeat(6) # -> "hahahahahaha"
methodString.eq(other: String) bool

Check for string equality

typeRoute

A single announced or withdrawn path

methodRoute.prefix() Prefix

Return the prefix for this RotondaRoute

methodRoute.prefix_matches(to_match: Prefix) bool

Check whether the prefix for this RotondaRoute matches

methodRoute.aspath_contains(to_match: Asn) bool

Check whether the AS_PATH contains the given Asn

methodRoute.match_aspath_origin(to_match: Asn) bool

Check whether the AS_PATH origin matches the given Asn

methodRoute.contains_community(to_match: Community) bool

Check whether this RotondaRoute contains the given Standard Community

methodRoute.contains_large_community(to_match: LargeCommunity) bool

Check whether this RotondaRoute contains the given Large Community

methodRoute.has_attribute(to_match: u8) bool

Check whether this RotondaRoute contains the given Path Attribute

methodRoute.fmt_prefix() String

Return a formatted string for the prefix

methodRoute.fmt_rov_status() String

Return a formatted string for the ROV status

methodRoute.fmt_aspath() String

Return a formatted string for the AS_PATH

methodRoute.fmt_aspath_origin() String

Return a formatted string for the AS_PATH origin

methodRoute.fmt_communities() String

Return a formatted string for the Standard Communities

methodRoute.fmt_large_communities() String

Return a formatted string for the Large Communities

typePathAttributes

The Path attributes pertaining to a certain Route

methodPathAttributes.otc() Asn?
methodPathAttributes.contains_community(to_match: Community) bool
methodPathAttributes.contains_large_community(to_match: LargeCommunity) bool
methodPathAttributes.aspath() aspath?
typeRouteContext

Contextual information pertaining to the Route

typeProvenance

Session/state information

methodProvenance.peer_asn() Asn

Return the peer ASN

typeLog

Machinery to create output entries

methodLog.log_prefix(prefix: Prefix) ()

Log the given prefix (NB: this method will likely be removed)

methodLog.log_matched_asn(asn: Asn) ()

Log the given ASN (NB: this method will likely be removed)

methodLog.log_matched_origin(origin: Asn) ()

Log the given ASN as origin (NB: this method will likely be removed)

methodLog.log_matched_community(community: Community) ()

Log the given community (NB: this method will likely be removed)

methodLog.log_peer_down() ()

Log a PeerDown event

methodLog.log_custom(id: u32, local: u32) ()

Log a custom entry in forms of a tuple (NB: this method will likely be removed)

methodLog.print(msg: String) ()

Print a message to standard error

methodLog.timestamped_print(msg: String) ()

Print a timestamped message to standard error

methodLog.entry() LogEntry

Get the current/new entry

A LogEntry is only written to the output if [write_entry] is called on it after populating its fields.

methodLog.write_entry() ()

Finalize this entry and ensure it will be written to the output

Calling this method will close the log entry that is currently being composed, and ensures a subsequent call to [entry] returns a new, empty LogEntry.

typeRpki

RPKI information retrieved via RTR

methodRpki.check_rov(rr: Route) RovStatus

Perform Route Origin Validation on the route

This sets the ‘rpki_info’ for this Route to Valid, Invalid or NotFound (RFC6811).

In order for this method to have effect, a ‘rtr-in’ connector should be configured, and it should have received VRP data from the connected RP software.

typeVrpUpdate

A single announced or withdrawn VRP

methodVrpUpdate.asn() Asn

Returns the Asn for this VrpUpdate

methodVrpUpdate.prefix() Prefix

Returns the prefix of the updated route

methodVrpUpdate.fmt() String

Return a formatted string for vrp_update

typeOriginAsn

Origin ASN

Represents an optional ASN.

typeAsnLists

Named lists of ASNs

methodAsnLists.add(name: String, s: String) ()

Add a named ASN list

methodAsnLists.contains(name: String, asn: Asn) bool

Returns ‘true’ if asn is in the named list

methodAsnLists.contains_origin(name: String, origin: OriginAsn) bool

Returns ‘true’ if the named list contains origin

This method returns false if the list does not exist, or if origin does not actually contain an Asn. The latter could occur for announcements with an empty ‘AS_PATH’ attribute (iBGP).

typePrefixLists

Named lists of prefixes

methodPrefixLists.add(name: String, s: String) ()

Add a named prefix list

methodPrefixLists.contains(name: String, prefix: Prefix) bool

Returns ‘true’ if prefix is in the named list

methodPrefixLists.covers(name: String, prefix: Prefix) bool

Returns ‘true’ if prefix or a less-specific is in the named list

typeMetrics

User-defined Prometheus style metrics

methodMetrics.increase_counter(name: String, value: u64) ()
methodMetrics.set_gauge(name: String, value: u64) ()
typeIngressInfo

Information pertaining to the source of the Message or Route

methodIngressInfo.peer_asn() Asn
methodIngressInfo.peer_address() IpAddr
typeInsertionInfo

Information from the RIB on an inserted route

typeLogEntry

Entry to log to file/mqtt

methodLogEntry.custom(custom_msg: String) ()

Log a custom message based on the given string

By setting a custom message for a LogEntry, all other fields are ignored when the entry is written to the output. Combining the custom message with the built-in fields is currently not possible.

methodLogEntry.timestamped_custom(custom_msg: String) ()

Log a custom, timestamped message based on the given string

Also see [custom].

methodLogEntry.origin_as(msg: BmpMsg) LogEntry

Log the AS_PATH origin ASN for the given message

methodLogEntry.peer_as(msg: BmpMsg) LogEntry

Log the peer ASN for the given message

methodLogEntry.as_path_hops(msg: BmpMsg) LogEntry

Log the number of AS_PATH hops for the given message

methodLogEntry.conventional_reach(msg: BmpMsg) LogEntry

Log the number of conventional announcements for the given message

methodLogEntry.conventional_unreach(msg: BmpMsg) LogEntry

Log the number of conventional withdrawals for the given message

methodLogEntry.mp_reach(msg: BmpMsg) LogEntry

Log the number of MultiProtocol announcements for the given message

methodLogEntry.mp_unreach(msg: BmpMsg) LogEntry

Log the number of MultiProtocol withdrawals for the given message

methodLogEntry.log_all(msg: BmpMsg) LogEntry

Log all the built-in features for the given message

typeBgpMsg

BGP UPDATE message

methodBgpMsg.aspath_contains(to_match: Asn) bool

Check whether the AS_PATH contains the given Asn

methodBgpMsg.aspath_origin() OriginAsn

Returns the right-most Asn in the ‘AS_PATH’ attribute

Note that the returned value is of type OriginAsn, which optionally contains an Asn. In case of empty an ‘AS_PATH’ (e.g. in iBGP) this method will still return an OriginAsn, though representing ‘None’.

methodBgpMsg.match_aspath_origin(to_match: Asn) bool

Check whether the AS_PATH origin matches the given Asn

methodBgpMsg.contains_community(to_match: Community) bool

Check whether this message contains the given Standard Community

methodBgpMsg.contains_large_community(to_match: LargeCommunity) bool

Check whether this message contains the given Large Community

methodBgpMsg.has_attribute(to_match: u8) bool

Check whether this message contains the given Path Attribute

methodBgpMsg.announcements_count() u64

Return the number of announcements in this message

methodBgpMsg.withdrawals_count() u64

Return the number of withdrawals in this message

methodBgpMsg.fmt_aspath() String

Return a formatted string for the AS_PATH

methodBgpMsg.fmt_aspath_origin() String

Return a formatted string for the AS_PATH origin

methodBgpMsg.fmt_communities() String

Return a formatted string for the Standard Communities

methodBgpMsg.fmt_large_communities() String

Return a formatted string for the Large Communities

methodBgpMsg.fmt_pcap() String

Format this message as hexadecimal Wireshark input

typeCommunity

A BGP Standard Community (RFC1997)

static methodCommunity.from(s: String) Community
typeLargeCommunity

A BGP Large Community (RFC8092)

static methodLargeCommunity.from(s: String) LargeCommunity
typeBmpMsg

BMP Message

methodBmpMsg.is_ibgp(asn: Asn) bool

Check whether this is an iBGP message based on a given asn

Return true if asn matches the asn in the BmpMsg. returns false if no PPH is present.

methodBmpMsg.is_route_monitoring() bool

Check whether this message is of type ‘RouteMonitoring’

methodBmpMsg.is_peer_down() bool

Check whether this message is of type ‘PeerDownNotification’

methodBmpMsg.is_peer_up() bool

Check whether this message is of type ‘PeerUpNotification’

methodBmpMsg.aspath_contains(to_match: Asn) bool

Check whether the AS_PATH contains the given Asn

methodBmpMsg.aspath_origin() OriginAsn

Returns the right-most Asn in the ‘AS_PATH’ attribute

Note that the returned value is of type OriginAsn, which optionally contains an Asn. In case of empty an ‘AS_PATH’ (e.g. in iBGP) this method will still return an OriginAsn, though representing ‘None’.

When called on BMP messages not of type ‘RouteMonitoring’, the ‘None’-variant is returned as well.

methodBmpMsg.match_aspath_origin(to_match: Asn) bool

Check whether the AS_PATH origin matches the given Asn

methodBmpMsg.contains_community(to_match: Community) bool

Check whether this message contains the given Standard Community

methodBmpMsg.contains_large_community(to_match: LargeCommunity) bool

Check whether this message contains the given Large Community

methodBmpMsg.has_attribute(to_match: u8) bool

Check whether this message contains the given Path Attribute

methodBmpMsg.announcements_count() u64

Return the number of announcements in this message

methodBmpMsg.withdrawals_count() u64

Return the number of withdrawals in this message

methodBmpMsg.fmt_aspath() String

Return a formatted string for the AS_PATH

methodBmpMsg.fmt_aspath_origin() String

Return a string of the AS_PATH origin for this BmpMsg.

methodBmpMsg.fmt_communities() String

Return a string for the Standard Communities in this BmpMsg.

methodBmpMsg.fmt_large_communities() String

Return a string for the Large Communities in this BmpMsg.

methodBmpMsg.fmt_pcap() String

Format this message as hexadecimal Wireshark input

typePerPeerHeader

BMP Per Peer Header

typeRovStatus

ROV status of a Route

methodRovStatus.is_valid() bool

Returns ‘true’ if the status is ‘Valid’

methodRovStatus.is_invalid() bool

Returns ‘true’ if the status is ‘Invalid’

methodRovStatus.is_not_found() bool

Returns ‘true’ if the status is ‘NotFound’

typeRovStatusUpdate

ROV update of a Route

methodRovStatusUpdate.prefix() Prefix

Returns the prefix of the updated route

methodRovStatusUpdate.origin() Asn

Returns the origin asn from the ‘AS_PATH’ of the updated route

methodRovStatusUpdate.peer_asn() Asn

Returns the peer asn from which the route was received

methodRovStatusUpdate.has_changed() bool

Returns ‘true’ if the new status differs from the old status

methodRovStatusUpdate.previous_status() RovStatus

Returns the old status of the route

methodRovStatusUpdate.current_status() RovStatus

Returns the new status of the route

methodRovStatusUpdate.fmt() String

Return a formatted string for rov_update

typeaspath

AS_PATH path attribute

methodaspath.contains(asn: Asn) bool