bird

package
v0.0.0-...-b34e599 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package bird provides a client for communicating with a BIRD routing daemon using Unix domain sockets.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptySock = errors.New("empty sock")

ErrEmptySock is returned when attempting to send a message using an uninitialized socket.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for communicating with the BIRD routing daemon. It manages Unix domain sockets for sending and receiving messages.

func NewClient

func NewClient(sockDir, sockNamePrefix string, opts ...ClientOption) (*Client, error)

NewClient creates a new Client with the specified socket directory and name prefix. The client listens and sends messages using Unix domain sockets. Additional options can be provided using the ClientOption functions.

func (*Client) ListenRequest

func (m *Client) ListenRequest() error

ListenRequest listens for an incoming request on the client's socket. This is a blocking call that waits for a message to be received.

func (*Client) Send

func (m *Client) Send(msg Message) error

Send sends a single Message to the BIRD daemon. The message is serialized using BigEndian byte order before sending.

func (*Client) SendBatch

func (m *Client) SendBatch(msgs ...Message) error

SendBatch sends a batch of Message to the BIRD daemon. The messages are sent in batches according to the client's batch size.

func (*Client) Shutdown

func (m *Client) Shutdown()

type ClientOption

type ClientOption func(*Client)

ClientOption is a function that configures a Client.

func WithBatchSize

func WithBatchSize(size uint) ClientOption

WithBatchSize is a ClientOption that sets the batch size for the Client.

type Message

type Message struct {
	// contains filtered or unexported fields
}

Message represents a message sent to the BIRD daemon. It contains information about the IP version, address, prefix length, and status.

func NewMessage

func NewMessage(prefix netip.Prefix, status PrefixStatus) Message

NewMessage creates a new Message with the given network prefix and status. It automatically determines the IP version based on the prefix and sets the appropriate fields.

type PrefixStatus

type PrefixStatus byte

PrefixStatus represents the status of a network prefix, either enabled or disabled.

const (
	// Enable indicates that the prefix should be enabled.
	Enable PrefixStatus = 0x01

	// Disable indicates that the prefix should be disabled.
	Disable PrefixStatus = 0x00
)

Jump to

Keyboard shortcuts

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