bootp

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package bootp answers RFC 951 BOOTP requests for explicitly configured clients and nobody else. SGI PROMs speak classic BOOTP, not DHCP: the PROM broadcasts a BOOTREQUEST carrying the boot path it wants in the file field, and expects a reply naming its address and the server's. Replies are broadcast by default because the client owns no IP address yet, so it cannot be reached by unicast without ARP games.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenBroadcast

func ListenBroadcast(addr string) (net.PacketConn, error)

ListenBroadcast opens the server socket on addr (":67" in production) with SO_BROADCAST set, so replies can go to 255.255.255.255.

Types

type Client

type Client struct {
	Name string
	MAC  net.HardwareAddr
	IP   netip.Addr
}

Client is one machine the server answers.

type Server

type Server struct {
	// ServerIP is advertised as siaddr, the address the PROM tftps from.
	ServerIP netip.Addr

	// Netmask, when valid, is offered in the RFC 1048 vendor area.
	Netmask netip.Prefix

	// Clients lists the MACs answered; everything else is ignored.
	Clients []Client

	// ReplyAddr overrides the destination of replies. Nil means the
	// limited broadcast 255.255.255.255:68.
	ReplyAddr net.Addr

	// Logger, when set, receives leveled log output: DEBUG for every
	// datagram decoded, INFO for each request answered or ignored,
	// ERROR for a reply that failed to send. A nil Logger is silent.
	Logger *logging.Logger

	// Recorder, when set, receives a bootp_reply record for each request
	// answered or ignored. A nil Recorder is a no-op.
	Recorder *capture.Recorder
}

Server answers BOOTP requests.

func (*Server) Serve

func (s *Server) Serve(pc net.PacketConn) error

Serve answers requests arriving on pc (conventionally bound to :67) until pc is closed. The socket needs SO_BROADCAST when replies go to the default broadcast address; ListenBroadcast provides that.

The reply goes to the broadcast address at the request's own source port, not the standard 68. SGI ARCS PROMs send their BOOTREQUEST from an ephemeral port and listen for the reply there; a reply hardwired to port 68 never reaches them and the PROM retries forever. Broadcasting to the source port serves both the RFC client (source 68) and the SGI PROM (ephemeral source).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL