dhcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dhcp reads an ISC dhcpd configuration.

The host declarations are parsed rather than grepped. Reading a fixed number of lines after a match, which the shell tools did, breaks as soon as a declaration is one line longer or the options are in another order, and it silently reports a neighbour's address.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GUIDFromMAC

func GUIDFromMAC(mac string) (string, error)

GUIDFromMAC derives the InfiniBand port GUID of a Mellanox adapter from its hardware address, which is what the fabric tools are asked about.

The address is split in the middle and 0300 is inserted, which is the mapping Mellanox firmware uses between the two.

Types

type Config

type Config struct {
	Hosts []Host `json:"hosts" yaml:"hosts"`
}

Config is a parsed dhcpd configuration.

func Parse

func Parse(data []byte) (*Config, error)

Parse reads a dhcpd configuration.

func (*Config) Lookup

func (c *Config) Lookup(node string) []Host

Lookup finds the declarations belonging to a node.

A declaration matches when its name is the node name, when its name starts with the node name followed by a separator, which is how a second interface is usually written, or when a comment above it names the node.

type Host

type Host struct {
	// Name is the name the declaration carries.
	Name string `json:"name" yaml:"name"`
	// MACs are the hardware addresses it matches.
	MACs []string `json:"macs,omitempty" yaml:"macs,omitempty"`
	// Address is the fixed address it hands out.
	Address string `json:"address,omitempty" yaml:"address,omitempty"`
	// Filename is the boot file it offers.
	Filename string `json:"filename,omitempty" yaml:"filename,omitempty"`
	// ClientIdentifier is the dhcp-client-identifier option it matches.
	ClientIdentifier string `json:"clientIdentifier,omitempty" yaml:"clientIdentifier,omitempty"`
	// Options holds every other option of the declaration.
	Options map[string]string `json:"options,omitempty" yaml:"options,omitempty"`
	// Comments are the comment lines directly above the declaration, which
	// is where sites often write the node name.
	Comments []string `json:"comments,omitempty" yaml:"comments,omitempty"`
}

Host is one host declaration.

Jump to

Keyboard shortcuts

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