resynth 0.4.0

A packet synthesis language
Documentation
import ipv4;
import dhcp;
import arp;

let client = 192.168.238.112/dhcp::CLIENT_PORT;
let server = 142.250.207.36/dhcp::SERVER_PORT;

# There is a low-level DNS API which you can use to construct exact queries,
# and even malformed queries
ipv4::udp::broadcast(
  src: client,
  dst: 255.255.255.255/dhcp::SERVER_PORT,
  srcip: 0.0.0.0,
  dhcp::hdr(
    opcode: dhcp::opcode::REQUEST,
    xid: 0xdeadbeef,
    chaddr: "|78:24:af:23:f0:a9|",
  ),
  dhcp::option(
    dhcp::opt::MESSAGE_TYPE,
    "|01|"
  ),
  dhcp::option(
    dhcp::opt::CLIENT_ID,
    "|07 01 78:24:af:23:f0:a9|"
  ),
  dhcp::option(
    dhcp::opt::REQUESTED_ADDRESS,
    0.0.0.0
  ),
  dhcp::option(
    dhcp::opt::PARAM_REQUEST_LIST,
    "|01 03 06 2a|"
  ),
  dhcp::option(
    dhcp::opt::CLIENT_HOSTNAME,
    "resynth",
  ),
  dhcp::option(
    dhcp::opt::CLIENT_FQDN,
    "|19 00 00|resynth.local",
  ),
  dhcp::opt::END,
);

ipv4::udp::unicast(
  src: server,
  dst: client,
  dhcp::hdr(
    opcode: dhcp::opcode::REPLY,
    xid: 0xdeadbeef,
    chaddr: "|78:24:af:23:f0:a9|",
  ),
);