Functional Weave
Code in Python

Suites · network-tools

Network tools and inventory

Parse and classify IPv4 and IPv6 addresses, CIDR and subnet maths, ports, MAC addresses and host names, and a network inventory with device status.

14 capabilities (7 core, 7 optional) and 4 gaps, in build order. Put each line in the file that calls it, then fune build.

1. Addresses

Read, write and classify IP addresses strictly.

net.ipv4 core
Parses, formats and checks dotted-quad IPv4, refusing leading zeros, octal and short forms.
Parse, format and check dotted-quad IPv4 addresses, refusing leading zeros, octal, hex and short forms.
from fune.net.ipv4 import parse_ipv4, format_ipv4, is_ipv4  # net.ipv4@^1
net.ipv6 core
Parses IPv6 and writes it in RFC 5952 canonical form.
Parse IPv6 addresses and write them in RFC 5952 canonical form: lower-case, zeros compressed, IPv4 embedded.
from fune.net.ipv6 import parse_ipv6, format_ipv6, is_ipv6  # net.ipv6@^1
net.ip-classify core
Loopback, private, link-local, multicast, documentation, CGNAT or global.
Classify an IPv4 or IPv6 address as loopback, private, link-local, multicast, documentation, CGNAT or global.
from fune.net.ip_classify import classify_ip  # net.ip-classify@^1

2. Subnets

CIDR blocks and the hosts in them.

net.cidr core
Network, broadcast, first and last host, host count, netmask and membership of a CIDR block.
CIDR blocks: network, broadcast, first and last host, host count, netmask and prefix, and membership.
from fune.net.cidr import cidr_info, cidr_contains, is_cidr, prefix_to_netmask, netmask_to_prefix  # net.cidr@^1
net.cidr-hosts optional
Lists every usable host in an IPv4 block, refusing blocks over a limit.
List every usable host address in an IPv4 CIDR block, refusing blocks larger than a limit.
from fune.net.cidr_hosts import cidr_hosts  # net.cidr-hosts@^1

3. Names, ports and hardware

Validate the other identifiers an inventory holds.

net.hostname-validate core
Checks a host name against RFC 1123/952 label rules and normalises it.
Check a host name against RFC 1123 and RFC 952 label rules and length limits, and normalise it.
from fune.net.hostname_validate import validate_hostname  # net.hostname-validate@^1
net.port core
Checks a port number and names its IANA service and range.
Check a TCP/UDP port number and name the IANA service registered on it, with its system/user/dynamic range.
from fune.net.port import is_port, port_service  # net.port@^1
net.port-list optional
Parses "22,80,8000-8010" into port numbers.
Parse a port list such as 22,80,8000-8010 into port numbers, in order and without duplicates.
from fune.net.port_list import parse_port_list  # net.port-list@^1
net.mac-address optional
Validates and normalises a MAC address in any common form.
Validate a MAC address in colon, hyphen, Cisco dot or bare form and normalise it, with multicast and local bits.
from fune.net.mac_address import validate_mac_address  # net.mac-address@^1

4. Inventory and status

Keep a list of devices and say how each is doing.

net.device-validate core
Validates an inventory entry (name, host, ports, MAC, subnet), listing every problem.
Validate one network inventory entry: name, host, ports, optional MAC and subnet, with every problem listed.
from fune.net.device_validate import validate_device  # net.device-validate@^1
net.latency-summary optional
Loss, min/avg/max, p95 and jitter from probe results.
Summarise probe results: sent, received, loss, min/avg/max, p95 and jitter, in whole microseconds.
from fune.net.latency_summary import summarise_latency  # net.latency-summary@^1
net.device-status optional
Up, degraded or down from that summary and thresholds.
Classify a device as up, degraded or down from its latency summary and loss, p95 and jitter thresholds.
from fune.net.device_status import device_status  # net.device-status@^1
collections.sort-by optional
Sorts device records by a column.
Stably sort records by one key, ascending or descending, with a total order across mixed types.
from fune.collections.sort_by import sort_by  # collections.sort-by@^1
collections.search-text optional
Filters device records by a search box.
Filter records by a case-insensitive substring match across named fields, in input order.
from fune.collections.search_text import search_text  # collections.search-text@^1
  • probing Pinging, port scanning and SNMP polling: the network I/O itself is yours.

Gaps

What this kind of app usually needs that Functional Weave does not have yet: write these yourself, or use a service.

  • ipv6-subnets Describing IPv6 prefixes (network, range, size, host lists): net.cidr describes IPv4 blocks and only tests IPv6 membership.
  • dns DNS lookups (A, AAAA, PTR, MX records) and whois are network work, not in caps.
  • discovery Discovering devices on a network (ARP, mDNS, scans) and importing them.