swlib

package module
v0.0.0-...-ab19ebf Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

README

swlib

Incomplete native OpenWRT's swconfig bindings for Go.

Documentation

Index

Constants

View Source
const FamilyName = "switch"

Variables

View Source
var (
	// ErrInvalidAttributeType is returned when an unknown attribute type is encountered.
	ErrInvalidAttributeType = errors.New("invalid attribute type")

	// ErrIncompatibleNetlink is returned when an incompatible netlink response is detected.
	ErrIncompatibleNetlink = errors.New("incompatible netlink response")
)

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Device *Device
	Group  Group

	ID          uint32
	Type        DataType
	Name        string
	Description string
}

func (*Attribute) UnmarshalAttributes

func (a *Attribute) UnmarshalAttributes(ad *netlink.AttributeDecoder) error

func (*Attribute) UnmarshalBinary

func (a *Attribute) UnmarshalBinary(data []byte) error

type AttributeType

type AttributeType int
const (
	AttrUnspec AttributeType = iota
	AttrType
	AttrID
	AttrDevName
	AttrAlias
	AttrName
	AttrVLANs
	AttrPorts
	AttrPortMap
	AttrCPUPort
	AttrOPID
	AttrOPType
	AttrOPName
	AttrOPPort
	AttrOPVLAN
	AttrOPValueInt
	AttrOPValueStr
	AttrOPValuePorts
	AttrOPValueLink
	AttrOPDescription
	AttrPort
)

func (AttributeType) String

func (i AttributeType) String() string

type Attributes

type Attributes map[string]*Attribute

func AttributesFromMessages

func AttributesFromMessages(d *Device, g Group, msgs []genetlink.Message) (Attributes, error)

type CommandType

type CommandType int
const (
	CmdUnspec CommandType = iota
	CmdGetSwitch
	CmdNewAttr
	CmdListGlobal
	CmdGetGlobal
	CmdSetGlobal
	CmdListPort
	CmdGetPort
	CmdSetPort
	CmdListVLAN
	CmdGetVLan
	CmdSetVLan
)

type Conn

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

Conn represents a genetlink connection to the OpenWRT swconfig subsystem and implements their available actions.

func Dial

func Dial(config *netlink.Config) (*Conn, error)

Dial opens a new genetlink connection and returns a Conn structure instance that implements the switch API.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) GetAttributeInt

func (c *Conn) GetAttributeInt(a *Attribute, portOrVLAN uint32) (uint32, error)
func (c *Conn) GetAttributeLink(a *Attribute, portOrVLAN uint32) (l *Link, err error)

func (*Conn) GetAttributePorts

func (c *Conn) GetAttributePorts(a *Attribute, portOrVLAN uint32) (p Ports, err error)

func (*Conn) ListGlobalAttributes

func (c *Conn) ListGlobalAttributes(dev *Device) (a Attributes, err error)

func (*Conn) ListPortAttributes

func (c *Conn) ListPortAttributes(dev *Device) (a Attributes, err error)

func (*Conn) ListSwitches

func (c *Conn) ListSwitches() ([]Device, error)

func (*Conn) ListVLANAttributes

func (c *Conn) ListVLANAttributes(dev *Device) (a Attributes, err error)

type DataType

type DataType uint32
const (
	DataTypeUnspec DataType = iota
	DataTypeInt
	DataTypeString
	DataTypePorts
	DataTypeLink
	DataTypeNoVal
)

func (DataType) String

func (i DataType) String() string

type Device

type Device struct {
	ID         uint32
	DeviceName string
	Alias      string
	Name       string
	VLANs      uint32
	Ports      uint32
	CPUPort    uint32
	PortMap    []*PortMap
}

func (*Device) UnmarshalAttributes

func (d *Device) UnmarshalAttributes(ad *netlink.AttributeDecoder) error

func (*Device) UnmarshalBinary

func (d *Device) UnmarshalBinary(data []byte) error

type DeviceBase

type DeviceBase struct {
	ID uint32
}

func (*DeviceBase) MarshalBinary

func (d *DeviceBase) MarshalBinary() (data []byte, err error)

type Group

type Group int
const (
	GroupGlobal Group = iota
	GroupVLAN
	GroupPort
)

func (Group) String

func (i Group) String() string
type Link struct {
	Link   bool
	Duplex bool
	ANeg   bool
	TXFlow bool
	RXFlow bool
	Speed  uint32
	EEE    LinkEEE
}

func (*Link) UnmarshalAttributes

func (l *Link) UnmarshalAttributes(ad *netlink.AttributeDecoder) error

type LinkAttr

type LinkAttr int
const (
	LinkAttrUnspec LinkAttr = iota
	LinkAttrFlagLink
	LinkAttrFlagDuplex
	LinkAttrFlagANeg
	LinkAttrFlagTXFlow
	LinkAttrFlagRXFlow
	LinkAttrSpeed
	LinkAttrFlagEEE100BaseT
	LinkAttrFlagEEE1000BaseT
)

func (LinkAttr) String

func (i LinkAttr) String() string

type LinkEEE

type LinkEEE int
const (
	LinkEEE100BaseT LinkEEE = 1 << iota
	LinkEEE1000BaseT
)

type Port

type Port struct {
	ID    uint32
	Flags PortFlags
}

func (*Port) UnmarshalAttributes

func (p *Port) UnmarshalAttributes(ad *netlink.AttributeDecoder) error

type PortAttribute

type PortAttribute int
const (
	PortAttrUnspec PortAttribute = iota
	PortAttrID
	PortAttrFlagTagged
)

func (PortAttribute) String

func (i PortAttribute) String() string

type PortFlags

type PortFlags int
const (
	PortFlagTagged PortFlags = 1 << iota
)

type PortMap

type PortMap struct {
	Number  uint32
	Segment string
	Virt    uint32
}

func (*PortMap) UnmarshalAttributes

func (m *PortMap) UnmarshalAttributes(ad *netlink.AttributeDecoder) error

type PortMapAttribute

type PortMapAttribute int
const (
	PortMapAttrPorts PortMapAttribute = iota
	PortMapAttrSegment
	PortMapAttrVirt
)

func (PortMapAttribute) String

func (i PortMapAttribute) String() string

type Ports

type Ports []Port

func (*Ports) UnmarshalAttributes

func (s *Ports) UnmarshalAttributes(ad *netlink.AttributeDecoder) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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