driver.net.util¶
Network utility functions for address handling, packet context management, and checksum computation.
Overview¶
This unit provides stateless helper routines used across all network protocol layers. It covers copying and comparing MAC and IPv4 addresses, converting address strings to binary, packet context allocation and cleanup, RFC 1071 checksum calculation, and common packet-forwarding helpers.
Dependencies¶
driver.net.typescore.memory
Functions and Procedures¶
Address Copy¶
procedure copyMAC(dst: PMACAddress; src: PMACAddress);
procedure copyIPv4(dst: PIPv4Address; src: PIPv4Address);
src to dst.
Address Comparison¶
Returnstrue if both addresses are identical byte-for-byte.
Address Parsing¶
Parses a colon-delimited MAC address string (AA:BB:CC:DD:EE:FF) or a dotted-decimal IPv4 string (A.B.C.D) into the corresponding binary record.
Address Formatting¶
procedure writeMACAddress(mac: TMACAddress);
procedure writeMACAddressEx(mac: TMACAddress);
procedure writeIPv4Address(ip: TIPv4Address);
procedure writeIPv4AddressEx(ip: TIPv4Address);
Ex variants omit the trailing newline.
Packet Context Management¶
Allocates or frees aTPacketContext on the kernel heap.
Checksum¶
function calculateChecksum(data: pointer; length: uint32): uint16;
function verifyChecksum(data: pointer; length: uint32): boolean;
length bytes. verifyChecksum returns true if the checksum over the data (including the checksum field) equals zero.
Routing Helpers¶
Returnstrue if addresses a and b are on the same subnet given mask.