Documentation ¶
Overview ¶
Package omapi implements the OMAPI protocol of the ISC DHCP server, allowing it to query and modify objects as well as control the server itself.
Index ¶
- Constants
- Variables
- type Authenticator
- type Connection
- func (con *Connection) CreateHost(host Host) (Host, error)
- func (con *Connection) Delete(handle int32) error
- func (con *Connection) FindFailover(name string) (Failover, error)
- func (con *Connection) FindHost(host Host) (Host, error)
- func (con *Connection) FindLease(lease Lease) (Lease, error)
- func (con *Connection) Query(msg *Message) (*Message, Status)
- func (con *Connection) Shutdown()
- func (con *Connection) Update(handle int32, object Object) error
- type Failover
- type FailoverHierarchy
- type FailoverState
- type HardwareType
- type Host
- type Lease
- type LeaseState
- type Message
- func (m *Message) Bytes(forSigning bool) []byte
- func (m *Message) IsResponseTo(other *Message) bool
- func (m *Message) Sign(auth Authenticator)
- func (m *Message) ToFailover() Failover
- func (m *Message) ToHost() Host
- func (m *Message) ToLease() Lease
- func (m *Message) ToStatus() Status
- func (m *Message) Verify(auth Authenticator) bool
- type Opcode
- type Status
Constants ¶
const ( LeaseStateFree = iota LeaseStateActive LeaseStateExpired LeaseStateReleased LeaseStateAbandoned LeaseStateReset LeaseStateBackup LeaseStateReserved LeaseStateBootp )
const ( FailoverStateStartup FailoverState = 1 FailoverStateNormal = 2 FailoverStateCommunicationsInterrupted = 3 FailoverStatePartnerDown = 4 FailoverStatePotentialConflict = 5 FailoverStateRecover = 6 FailoverStatePaused = 7 FailoverStateShutdown = 8 FailoverStateRecoverDone = 9 FailoverStateResolutionInterrupted = 10 FailoverStateConflictDone = 11 FailoverStateRecoverWait = 254 )
const ( Ethernet HardwareType = 1 TokenRing = 6 FDDI = 8 )
const DefaultPort = 7911
Variables ¶
var ( True = []byte{0, 0, 0, 1} False = []byte{0, 0, 0, 0} )
var Statuses = []Status{ Status{0, "success"}, Status{1, "out of memory"}, Status{2, "timed out"}, Status{3, "no available threads"}, Status{4, "address not available"}, Status{5, "address in use"}, Status{6, "permission denied"}, Status{7, "no pending connections"}, Status{8, "network unreachable"}, Status{9, "host unreachable"}, Status{10, "network down"}, Status{11, "host down"}, Status{12, "connection refused"}, Status{13, "not enough free resources"}, Status{14, "end of file"}, Status{15, "socket already bound"}, Status{16, "task is done"}, Status{17, "lock busy"}, Status{18, "already exists"}, Status{19, "ran out of space"}, Status{20, "operation canceled"}, Status{21, "sending events is not allowed"}, Status{22, "shutting down"}, Status{23, "not found"}, Status{24, "unexpected end of input"}, Status{25, "failure"}, Status{26, "I/O error"}, Status{27, "not implemented"}, Status{28, "unbalanced parentheses"}, Status{29, "no more"}, Status{30, "invalid file"}, Status{31, "bad base64 encoding"}, Status{32, "unexpected token"}, Status{33, "quota reached"}, Status{34, "unexpected error"}, Status{35, "already running"}, Status{36, "host unknown"}, Status{37, "protocol version mismatch"}, Status{38, "protocol error"}, Status{39, "invalid argument"}, Status{40, "not connected"}, Status{41, "data not yet available"}, Status{42, "object unchanged"}, Status{43, "more than one object matches key"}, Status{44, "key conflict"}, Status{45, "parse error(s) occurred"}, Status{46, "no key specified"}, Status{47, "zone TSIG key not known"}, Status{48, "invalid TSIG key"}, Status{49, "operation in progress"}, Status{50, "DNS format error"}, Status{51, "DNS server failed"}, Status{52, "no such domain"}, Status{53, "not implemented"}, Status{54, "refused"}, Status{55, "domain already exists"}, Status{56, "RRset already exists"}, Status{57, "no such RRset"}, Status{58, "not authorized"}, Status{59, "not a zone"}, Status{60, "bad DNS signature"}, Status{61, "bad DNS key"}, Status{62, "clock skew too great"}, Status{63, "no root zone"}, Status{64, "destination address required"}, Status{65, "cross-zone update"}, Status{66, "no TSIG signature"}, Status{67, "not equal"}, Status{68, "connection reset by peer"}, Status{69, "unknown attribute"}, }
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func Dial ¶
func Dial(addr, username, key string) (*Connection, error)
Dial establishes a connection to an OMAPI-enabled server.
func (*Connection) CreateHost ¶
func (con *Connection) CreateHost(host Host) (Host, error)
CreateHost creates a new host object on the server. The passed argument with its fields populated will be sent to the server and saved, if possible. The server's representation of the new host will be returned.
The returned object will be incomplete compared to the original argument, because OMAPI doesn't transfer all information back to us.
Example:
mac, _ := net.ParseMAC("aa:bb:cc:dd:ee:ff") host := Host{ Name: "new_host", HardwareAddress: mac, HardwareType: Ethernet, IP: net.ParseIP("10.0.0.2"), Statements: `ddns-hostname "the.hostname";`, } newHost, err := connection.CreateHost(host) if err != nil { // Couldn't create the new host, error string will tell us why } else { // We successfuly created a new host. newHost will contain the // OMAPI representation of it, including a handle }
func (*Connection) Delete ¶
func (con *Connection) Delete(handle int32) error
Delete deletes an object from the server, given its handle.
func (*Connection) FindFailover ¶
func (con *Connection) FindFailover(name string) (Failover, error)
FindFailover finds a failover-state given its name.
func (*Connection) Query ¶
func (con *Connection) Query(msg *Message) (*Message, Status)
Query sends a message to the server and waits for a reply. It returns the underlying response as well as its representation as a status. If the message didn't contain a status, the success status will be returned instead.
func (*Connection) Shutdown ¶
func (con *Connection) Shutdown()
func (*Connection) Update ¶
func (con *Connection) Update(handle int32, object Object) error
type Failover ¶
type Failover struct { Name string PartnerAddress net.IP LocalAddress net.IP PartnerPort int32 LocalPort int32 MaxOutstandingUpdates int32 Mclt int32 // TODO maybe find a better name LoadBalanceMaxSecs int32 LoadBalanceHBA []byte // TODO what type would this be? LocalState FailoverState PartnerState FailoverState LocalStos time.Time // TODO maybe find a better name PartnerStos time.Time // TODO maybe find a better name Hierarchy FailoverHierarchy LastPacketSent time.Time LastTimestampReceived time.Time Skew int32 MaxResponseDelay int32 CurUnackedUpdates int32 }
type FailoverHierarchy ¶
type FailoverHierarchy int32
const ( HierarchyPrimary FailoverHierarchy = iota HierarchySecondary )
func (FailoverHierarchy) String ¶
func (h FailoverHierarchy) String() (ret string)
type FailoverState ¶
type FailoverState int32
func (FailoverState) String ¶
func (state FailoverState) String() (ret string)
type HardwareType ¶
type HardwareType int32
func (HardwareType) String ¶
func (hw HardwareType) String() (ret string)
type Lease ¶
type Lease struct { State LeaseState IP net.IP DHCPClientIdentifier []byte ClientHostname string Host int32 // TODO figure out what to do with handles // Subnet, Pool, BillingClass are "currently not supported" by the dhcpd HardwareAddress net.HardwareAddr HardwareType HardwareType Ends time.Time // TODO maybe find nicer names for these times Tstp time.Time Atsfp time.Time Cltt time.Time Handle int32 }
type LeaseState ¶
type LeaseState int32
func (LeaseState) String ¶
func (state LeaseState) String() (ret string)
type Message ¶
type Message struct { AuthID int32 Opcode Opcode Handle int32 TransactionID int32 ResponseID int32 Message map[string][]byte Object map[string][]byte Signature []byte }
func NewCreateMessage ¶
func NewDeleteMessage ¶
func NewMessage ¶
func NewMessage() *Message
func NewOpenMessage ¶
func (*Message) IsResponseTo ¶
func (*Message) Sign ¶
func (m *Message) Sign(auth Authenticator)
func (*Message) ToFailover ¶
func (*Message) Verify ¶
func (m *Message) Verify(auth Authenticator) bool