Networking Data Types

Overview

IP Addresses

An IP address is a self evaluating native data type in Inlab Scheme. The tag of an IP address is IPADDR_TYPE where a pointer points to a struct in6_addr which is kept in constant memory at a fixed address (as long as referenced).

The following external representations are supported by (read) and (print):

  • The usual IPv4 dotted decimal notation
  • Any IPv6 notation as implemented by inet_pton() and inet_ntop()

If an external representation cannot be interpreted as an IP address, it is read like an ordinary, non self-evaluating symbol.

Example:

> (define addr1 ::ffff:127.0.0.1)
addr1
> (define addr2 '10.1.2.3)
addr2
> (define addr3 2001:DB8::1:1)
addr3
> (list addr1 addr2 addr3)
(127.0.0.1 10.1.2.3 2001:db8::1:1)
> (ipv4addr? addr1)
#t
> (ipv4addr? addr3)
#f
> (ipaddr? addr3)
#t
>

IP Address Ranges

General Definitions

The data type IP Address Range (in short ipaddr-range) internally consists of two IP addresses:

  • The START IP Address defines the lower boundary of the IP address range.
  • The END IP Address defines the upper boundary of the IP address range and must be greater or equal than the START IP Address.

IPv4 addresses are alway mapped to their 16 byte IPv6 equivalent with a prefix of ::ffff.

Parsing + Evaluation

The start IP address is required to be less or equal to the end IP address, otherwise an error is signalled.

IP address ranges are self evaluating.

Here some valid examples for (read):

fe80::18b6:417b:3344:1170-fe80::18b6:417b:3344:ffff
10.10.10.0-10.10.10.10
::ffff:127.0.0.0-::ffff:127.255.255.255

MAC Addresses

A MAC address is a self evaluating native data type in Inlab Scheme. The parser (read) accepts the usual 6-octet hexadecimal notation for Ethernet MAC addresses (case insensitive).

Example:

> a1:b2:b3:b4:c5:ff
a1:b2:b3:b4:c5:ff
> a1:b2:b3:b4:c5:Ff
a1:b2:b3:b4:c5:ff
> (macaddr? a1:b2:b3:b4:c5:ff)
#t
> (macaddr? 'a1:b2:b3:b4:c5:ff)
#t
> a1:b2:b3:b4:c5

ERROR!
  message   : variable not found
  irritant  : a1:b2:b3:b4:c5
  expression: a1:b2:b3:b4:c5
  continue  : possible, continue with value as obtained from variable

Error (? for help) >>

Mac Address Ranges

General Definitions

The data type Mac Address Range (in short macaddr-range) internally consists of two MAC addresses:

  • The START MAC Address defines the lower boundary of the MACRange.
  • The END MAC Address defines the upper boundary of the MACRange and must be greater or equal than the START MAC Address.

Parsing + Evaluation

The start MAC address is required to be less or equal to the end MAC address, otherwise an error is signalled.

Mac address ranges are self evaluating.

Here some valid examples:

> 00:00:00:00:00:00-00:00:00:00:00:00
00:00:00:00:00:00-00:00:00:00:00:00
> '00:00:00:00:00:00-00:00:00:00:00:00
00:00:00:00:00:00-00:00:00:00:00:00
> 00:12:22:00:44:55-00:13:22:33:00:5f
00:12:22:00:44:55-00:13:22:33:00:5f

Interfaces

The data type interface allows the Scheme interpreter to access physical interfaces for packet reading and packet injection.

Frames

Networking frames are simply kept as strings within Inlab Scheme. This is possible since strings are byte vectors which can hold arbitrary data.