gonslib

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func AFToEtherType ¶

func AFToEtherType(family int) uint16

AFToEtherType returns ether-type of family.

func AddPortsToVlan ¶ added in v0.4.0

func AddPortsToVlan(unit int, allBmp *opennsl.PBmp, untagBmp *opennsl.PBmp, vid opennsl.Vlan, strictlyUntagged bool) error

func ClearNativeVlan ¶ added in v0.4.0

func ClearNativeVlan(unit int, vid opennsl.Vlan, pbmp *opennsl.PBmp, strictlyUntagged bool)

func CreateVlan ¶ added in v0.4.0

func CreateVlan(unit int, vid opennsl.Vlan) error

func DelPortsFromVlan ¶ added in v0.4.0

func DelPortsFromVlan(unit int, allBmp *opennsl.PBmp, untagBmp *opennsl.PBmp, vid opennsl.Vlan, strictlyUntagged bool)

func DeleteL2Addrs ¶ added in v0.4.0

func DeleteL2Addrs(unit int, vid opennsl.Vlan)

func DestroyVlan ¶ added in v0.4.0

func DestroyVlan(unit int, vid opennsl.Vlan)

func DestroyVlanIfEmpty ¶ added in v0.4.0

func DestroyVlanIfEmpty(unit int, vid opennsl.Vlan)

func DriverExit ¶

func DriverExit()

DriverExit terminates opennsl driver.

func DriverInfo ¶

func DriverInfo(unit int)

func DriverInit ¶

func DriverInit(unit int, cfg *ONSLConfig) error

DriverInit initialize opennsl driver.

func EtherTypeToLen ¶

func EtherTypeToLen(etherType uint16) int

func IPToAF ¶

func IPToAF(ip net.IP) int

IPToAF returns address-family of ip.

func IPToEtherType ¶

func IPToEtherType(ip net.IP) uint16

IPToEtherType returns ether-type of ip.

func LinkmonServe ¶

func LinkmonServe(unit int, linkCh chan<- *LinkInfo, done <-chan struct{})

LinkmonServe monitor link state and notify.

func NewL2addrmonKeyFromL2Addr ¶ added in v0.4.0

func NewL2addrmonKeyFromL2Addr(l2addr *opennsl.L2Addr) string

func PortBmpGet ¶

func PortBmpGet(unit int) (*opennsl.PBmp, error)

PortBmpGet returns port map instance.

func PortDefaultConfig ¶

func PortDefaultConfig(unit int) error

PortDefaultConfig setup ports.

func PortDefaultVlanConfig ¶

func PortDefaultVlanConfig(unit int) error

PortDefaultVlanConfig registers port to default vlan.

func PortInfoGet ¶

func PortInfoGet(unit int, port opennsl.Port) (*opennsl.PortInfo, error)

PortInfoGet returns opennsl port info.

func PortStatInit ¶

func PortStatInit(unit int) error

PortStatInit initialze opennsl port stats function.

func RxInit ¶

func RxInit(unit int) error

RxInit initialize opennsl rx function.

func RxServe ¶

func RxServe(unit int, rxCh chan<- *opennsl.Pkt, done <-chan struct{})

RxServe serve receiving packets.

func SetNativeVlan ¶ added in v0.4.0

func SetNativeVlan(unit int, vid opennsl.Vlan, pbmp *opennsl.PBmp, strictlyUntagged bool) error

func SetPortVlanTranslation ¶ added in v0.4.0

func SetPortVlanTranslation(unit int, port opennsl.Port, enable int) error

func SimInit ¶

func SimInit(unit int)

SimInit initialize simlator mode.

Types ¶

type APIServer ¶

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

APIServer is api server.

func NewAPIServer ¶

func NewAPIServer(server *Server) *APIServer

NewAPIServer returns new instance.

func (*APIServer) FindL3Iface ¶

func (s *APIServer) FindL3Iface(ctxt context.Context, req *api.FindL3IfaceRequest) (*api.FindL3IfaceReply, error)

FindL3Iface process api.FindL3IfaceRequest.

func (*APIServer) GetFieldEntries ¶

func (s *APIServer) GetFieldEntries(ctxt context.Context, req *api.GetFieldEntriesRequest) (*api.GetFieldEntriesReply, error)

GetFieldEntries process api.GetFieldEntriesRequest.

func (*APIServer) GetIDMapEntries ¶

func (s *APIServer) GetIDMapEntries(ctxt context.Context, req *api.GetIDMapEntriesRequest) (*api.GetIDMapEntriesReply, error)

GetIDMapEntries process api.GetIDMapEntriesRequest.

func (*APIServer) GetL2Addrs ¶

func (s *APIServer) GetL2Addrs(ctxt context.Context, req *api.GetL2AddrsRequest) (*api.GetL2AddrsReply, error)

GetL2Addrs process api.GetL2AddrsRequest.

func (*APIServer) GetL2Stations ¶

func (s *APIServer) GetL2Stations(ctxt context.Context, req *api.GetL2StationsRequest) (*api.GetL2StationsReply, error)

GetL2Stations process api.GetL2StationsRequest.

func (*APIServer) GetL3Egresses ¶

func (s *APIServer) GetL3Egresses(ctxt context.Context, req *api.GetL3EgressesRequest) (*api.GetL3EgressesReply, error)

GetL3Egresses process api.GetL3EgressesRequest.

func (*APIServer) GetL3Hosts ¶

func (s *APIServer) GetL3Hosts(ctxt context.Context, req *api.GetL3HostsRequest) (*api.GetL3HostsReply, error)

GetL3Hosts process api.GetL3HostsRequest.

func (*APIServer) GetL3Iface ¶

func (s *APIServer) GetL3Iface(ctxt context.Context, req *api.GetL3IfaceRequest) (*api.GetL3IfaceReply, error)

GetL3Iface process api.GetL3IfaceRequest.

func (*APIServer) GetL3Ifaces ¶

func (s *APIServer) GetL3Ifaces(ctxt context.Context, req *api.GetL3IfacesRequest) (*api.GetL3IfacesReply, error)

GetL3Ifaces process api.GetL3IfacesRequest.

func (*APIServer) GetL3Routes ¶

func (s *APIServer) GetL3Routes(ctxt context.Context, req *api.GetL3RoutesRequest) (*api.GetL3RoutesReply, error)

GetL3Routes process api.GetL3RoutesRequest.

func (*APIServer) GetPortInfos ¶ added in v0.4.0

func (s *APIServer) GetPortInfos(ctxt context.Context, req *api.GetPortInfosRequest) (*api.GetPortInfosReply, error)

func (*APIServer) GetTunnelInitiators ¶

GetTunnelInitiators process api.GetTunnelInitiatorsRequest.

func (*APIServer) GetTunnelTerminators ¶

GetTunnelTerminators process api.GetTunnelTerminatorsRequest.

func (*APIServer) GetVlans ¶

func (s *APIServer) GetVlans(ctxt context.Context, req *api.GetVlansRequest) (*api.GetVlansReply, error)

GetVlans process api.GetVlansRequest.

func (*APIServer) Start ¶

func (s *APIServer) Start(addr string) error

Start starts sub modules.

type Args ¶

type Args struct {
	ConfigFile string
	ConfigType string
	UseSim     bool
	DpName     string
	APIAddr    string
	Daemon     bool
	PidFile    string
	LogFile    string
	Verbose    bool
}

Args is gonsl arguments.

func NewArgs ¶

func NewArgs() *Args

NewArgs returns new instance.

func (*Args) Parse ¶

func (a *Args) Parse()

Parse parses argument and get.

type BlockBcastConfig ¶

type BlockBcastConfig struct {
	Range BlockBcastRangeConfig   `mapstructure:"range"`
	Ports []*BlockBcastPortConfig `mapstructure:"ports"`
}

VlanPortConfig is vlan config that port belongs to.

func (*BlockBcastConfig) Block ¶

func (c *BlockBcastConfig) Block() bool

func (*BlockBcastConfig) String ¶

func (c *BlockBcastConfig) String() string

type BlockBcastPortConfig ¶

type BlockBcastPortConfig struct {
	Port int    `mapstructure:"port"`
	Vid  uint16 `mapstructure:"vid"`
	PVid uint16 `mapstructure:"pvid"`
}

BlockBcastPortConfig is port entry of BlockBcastConfig.

func (*BlockBcastPortConfig) String ¶

func (c *BlockBcastPortConfig) String() string

type BlockBcastRangeConfig ¶

type BlockBcastRangeConfig struct {
	Min     int    `mapstructure:"min"`
	Max     int    `mapstructure:"max"`
	BaseVID uint16 `mapstructure:"base_vid"`
}

BlockBcastRangeConfig is port entry of BlockBcastConfig.

func (*BlockBcastRangeConfig) Block ¶

func (c *BlockBcastRangeConfig) Block() bool

func (*BlockBcastRangeConfig) GetBaseVID ¶

func (c *BlockBcastRangeConfig) GetBaseVID() uint16

func (*BlockBcastRangeConfig) String ¶

func (c *BlockBcastRangeConfig) String() string

type BrVlan ¶ added in v0.4.0

type BrVlan struct {
	Vid              opennsl.Vlan
	Pbmp             *opennsl.PBmp
	UntagBmp         *opennsl.PBmp
	StrictlyUntagged bool
}

func NewBrVlan ¶ added in v0.4.0

func NewBrVlan(unit int, vid opennsl.Vlan) *BrVlan

func (*BrVlan) Create ¶ added in v0.4.0

func (b *BrVlan) Create(unit int) error

func (*BrVlan) Delete ¶ added in v0.4.0

func (b *BrVlan) Delete(unit int)

func (*BrVlan) String ¶ added in v0.4.0

func (b *BrVlan) String() string

type Config ¶

type Config struct {
	Dpaths  map[string]*DpConfig `mapstructure:"dpaths"`
	Logging LogConfig            `mapstructure:"logging"`
}

Config is gonsl config file.

func NewConfig ¶

func NewConfig() *Config

NewConfig returns new instance.

func (*Config) GetDpConfig ¶

func (c *Config) GetDpConfig(name string) (*DpConfig, error)

GetDpConfig returns dp cofig.

func (*Config) ReadFile ¶

func (c *Config) ReadFile(args *Args) (*viper.Viper, error)

ReadFile reads config file.

type DpConfig ¶

type DpConfig struct {
	DpID       uint64           `mapstructure:"dpid"`
	Addr       string           `mapstructure:"addr"`
	Port       uint16           `mapstructure:"port"`
	Unit       int              `mapstructure:"unit"`
	BlockBcast BlockBcastConfig `mapstructure:"block_bcast"`
	OpenNSL    *ONSLConfig      `mapstructure:"opennsl"`
	L2SW       L2SWConfig       `mapstructure:"l2sw"`
}

DpConfig is part of gonsl config.

func (*DpConfig) GetAddr ¶

func (c *DpConfig) GetAddr() string

GetAddr returns address of server.

func (*DpConfig) GetHost ¶

func (c *DpConfig) GetHost() string

GetHost returns ipaddr:port

func (*DpConfig) GetL2AgingTimer ¶ added in v0.4.0

func (c *DpConfig) GetL2AgingTimer() int

GetL2AgingTimer returns l2 aging timer (second).

func (*DpConfig) GetL2NotifyLimit ¶ added in v0.4.0

func (c *DpConfig) GetL2NotifyLimit() uint32

func (*DpConfig) GetL2SweepTime ¶ added in v0.4.0

func (c *DpConfig) GetL2SweepTime() time.Duration

GetL2SweepTime returns l2 addr table sweep time.

func (*DpConfig) GetPort ¶

func (c *DpConfig) GetPort() uint16

GetPort returns port number of server.

func (*DpConfig) String ¶

func (c *DpConfig) String() string

String retuns config information.

type FieldEntry ¶ added in v0.4.0

type FieldEntry interface {
	// contains filtered or unexported methods
}

FieldEntry is interface of field entry.

type FieldEntryDstIP ¶ added in v0.4.0

type FieldEntryDstIP struct {
	EthType opennsl.Ethertype
	Dest    *net.IPNet
	InPort  opennsl.Port
}

FieldEntryDstIP is field entry (DstIPv4 or DstIPv6).

func NewFieldEntryDstIP ¶ added in v0.4.0

func NewFieldEntryDstIP(dest *net.IPNet, inPort opennsl.Port, ethType uint16) *FieldEntryDstIP

NewFieldEntryDstIP returns new FieldEntryDstIP(IPv4 or IPv6)

func NewFieldEntryDstIPv4 ¶ added in v0.4.0

func NewFieldEntryDstIPv4(dest *net.IPNet, inPort opennsl.Port) *FieldEntryDstIP

NewFieldEntryDstIPv4 returns new FieldEntryDstIP(IPv4)

func NewFieldEntryDstIPv6 ¶ added in v0.4.0

func NewFieldEntryDstIPv6(dest *net.IPNet, inPort opennsl.Port) *FieldEntryDstIP

NewFieldEntryDstIPv6 returns new FieldEntryDstIP(IPv6)

func (*FieldEntryDstIP) String ¶ added in v0.4.0

func (e *FieldEntryDstIP) String() string

type FieldEntryEthDst ¶ added in v0.4.0

type FieldEntryEthDst struct {
	Dest   net.HardwareAddr
	Mask   net.HardwareAddr
	InPort opennsl.Port
}

FieldEntryEthDst is field entry (EthDst).

func NewFieldEntryEthDst ¶ added in v0.4.0

func NewFieldEntryEthDst(dest, mask net.HardwareAddr, inPort opennsl.Port) *FieldEntryEthDst

NewFieldEntryEthDst returns new FieldEntryEthDst.

func (*FieldEntryEthDst) String ¶ added in v0.4.0

func (e *FieldEntryEthDst) String() string

String returns string.

type FieldEntryEthType ¶ added in v0.4.0

type FieldEntryEthType struct {
	EthType uint16
	InPort  opennsl.Port
}

FieldEntryEthType is field entry (EthType).

func NewFieldEntryEthType ¶ added in v0.4.0

func NewFieldEntryEthType(ethType uint16, inPort opennsl.Port) *FieldEntryEthType

NewFieldEntryEthType returns new FieldEntryEthType.

func (*FieldEntryEthType) String ¶ added in v0.4.0

func (e *FieldEntryEthType) String() string

type FieldEntryIPProto ¶ added in v0.4.0

type FieldEntryIPProto struct {
	EthType uint16
	IPProto uint8
	InPort  opennsl.Port
}

FieldEntryIPProto is field entry (IP proto).

func NewFieldEntryIPProto ¶ added in v0.4.0

func NewFieldEntryIPProto(ipProto uint8, ethType uint16, inPort opennsl.Port) *FieldEntryIPProto

NewFieldEntryIPProto returns new FieldEntryIPProto.

func (*FieldEntryIPProto) String ¶ added in v0.4.0

func (e *FieldEntryIPProto) String() string

type FieldGroup ¶

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

FieldGroup has cos, field_group and entries.

func NewFieldGroup ¶

func NewFieldGroup(unit int, cos uint32, pri int, qs ...opennsl.FieldQualify) *FieldGroup

NewFieldGroup returns new instance.

func NewFieldGroupDstIPv4 ¶

func NewFieldGroupDstIPv4(unit int) *FieldGroup

NewFieldGroupDstIPv4 returns new FieldGroup for FieldEntryDstIP(v4)

func NewFieldGroupDstIPv6 ¶

func NewFieldGroupDstIPv6(unit int) *FieldGroup

NewFieldGroupDstIPv6 returns new FieldGroup for FieldEntryDstIP(v6)

func NewFieldGroupEthDst ¶

func NewFieldGroupEthDst(unit int) *FieldGroup

NewFieldGroupEthDst created new FieldGroup for FieldEntryEthDst.

func NewFieldGroupEthType ¶

func NewFieldGroupEthType(unit int) *FieldGroup

NewFieldGroupEthType create new FieldGroup for FieldEntryEthType.

func NewFieldGroupIPProto ¶

func NewFieldGroupIPProto(unit int) *FieldGroup

NewFieldGroupIPProto created new FieldGroup for FieldEntryIPProto.

func (*FieldGroup) AddEntry ¶ added in v0.4.0

func (f *FieldGroup) AddEntry(e FieldEntry) error

AddEntry installs field entry.

func (*FieldGroup) DeleteEntry ¶ added in v0.4.0

func (f *FieldGroup) DeleteEntry(e FieldEntry)

DeleteEntry uninstall field entry.

func (*FieldGroup) GetEntries ¶

func (f *FieldGroup) GetEntries() ([]opennsl.FieldEntry, error)

GetEntries get all field entry from H.W.

func (*FieldGroup) GetEntry ¶ added in v0.4.0

func (f *FieldGroup) GetEntry(e FieldEntry, entry opennsl.FieldEntry) error

GetEntry get field entry form H.W.

type FieldGroups ¶

type FieldGroups struct {
	EthDst  *FieldGroup
	EthType *FieldGroup
	DstIPv4 *FieldGroup
	DstIPv6 *FieldGroup
	IPProto *FieldGroup
}

FieldGroups has opennsl field_groups.

func NewFieldGroups ¶

func NewFieldGroups(unit int) *FieldGroups

NewFieldGroups returns new instance.

type IDMaps ¶

type IDMaps struct {
	L2Stations *L2StationIDMap
	L3Ifaces   *L3IfaceIDMap
	L3Egress   *L3EgressIDMap
	Trunks     *TrunkIDMap
}

IDMaps has sub-maps.

func NewIDMaps ¶

func NewIDMaps() *IDMaps

NewIDMaps returns new instance.

type L2SWConfig ¶ added in v0.4.0

type L2SWConfig struct {
	NotifyLimit uint32 `mapstructure:"notify_limit"`
	SweepSec    uint32 `mapstructure:"sweep_sec"`
	AgingSec    uint32 `mapstructure:"aging_sec"`
}

L2SWConfig is l2sw configurations.

func (*L2SWConfig) String ¶ added in v0.4.0

func (c *L2SWConfig) String() string

type L2StationIDKey ¶ added in v0.4.0

type L2StationIDKey uint32

L2StationIDKey is key of L2StationIDMap

func NewL2StationIDKey ¶ added in v0.4.0

func NewL2StationIDKey(id uint32) L2StationIDKey

NewL2StationIDKey returns new L2StationIDKey

func (L2StationIDKey) String ¶ added in v0.4.0

func (k L2StationIDKey) String() string

String returns string.

type L2StationIDMap ¶ added in v0.4.0

type L2StationIDMap struct {
	sync.Map
}

L2StationIDMap has id and l2station id.

func NewL2StationIDMap ¶ added in v0.4.0

func NewL2StationIDMap() *L2StationIDMap

NewL2StationIDMap returns new L2StationIDMap

func (*L2StationIDMap) Get ¶ added in v0.4.0

Get returns L2StationID by id.

func (*L2StationIDMap) Register ¶ added in v0.4.0

func (m *L2StationIDMap) Register(id uint32, l2stationId opennsl.L2StationID) bool

Register registers id and l3egrId.

func (*L2StationIDMap) Traverse ¶ added in v0.4.0

func (m *L2StationIDMap) Traverse(f func(L2StationIDKey, opennsl.L2StationID) bool)

Traverse enumerates all entries.

func (*L2StationIDMap) Unregister ¶ added in v0.4.0

func (m *L2StationIDMap) Unregister(id uint32)

Unregister removes id.

type L2addrmonEntry ¶ added in v0.4.0

type L2addrmonEntry struct {
	L2Addr *opennsl.L2Addr
	Oper   opennsl.L2CallbackOper
}

func NewL2addrmonEntry ¶ added in v0.4.0

func NewL2addrmonEntry(src *opennsl.L2Addr, oper opennsl.L2CallbackOper) *L2addrmonEntry

func (*L2addrmonEntry) Key ¶ added in v0.4.0

func (e *L2addrmonEntry) Key() string

func (*L2addrmonEntry) SetAdd ¶ added in v0.4.0

func (e *L2addrmonEntry) SetAdd() bool

func (*L2addrmonEntry) SetDel ¶ added in v0.4.0

func (e *L2addrmonEntry) SetDel() bool

func (*L2addrmonEntry) String ¶ added in v0.4.0

func (e *L2addrmonEntry) String() string

type L2addrmonTable ¶ added in v0.4.0

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

func NewL2addrmonTable ¶ added in v0.4.0

func NewL2addrmonTable(maxEntry uint32) *L2addrmonTable

func (*L2addrmonTable) Add ¶ added in v0.4.0

func (t *L2addrmonTable) Add(newEntry *L2addrmonEntry)

func (*L2addrmonTable) Del ¶ added in v0.4.0

func (t *L2addrmonTable) Del(delEntry *L2addrmonEntry)

func (*L2addrmonTable) Put ¶ added in v0.4.0

func (t *L2addrmonTable) Put(e *L2addrmonEntry)

func (*L2addrmonTable) Reset ¶ added in v0.4.0

func (t *L2addrmonTable) Reset(force bool) []*L2addrmonEntry

type L3EgressIDKey ¶ added in v0.4.0

type L3EgressIDKey uint32

L3EgressIDKey is key of L3EgressIDMap

func NewL3EgressIDKey ¶ added in v0.4.0

func NewL3EgressIDKey(neighId uint32) L3EgressIDKey

NewL3EgressIDKey returns new L3EgressIDKey

func (L3EgressIDKey) String ¶ added in v0.4.0

func (k L3EgressIDKey) String() string

String returns string.

type L3EgressIDMap ¶ added in v0.4.0

type L3EgressIDMap struct {
	sync.Map
}

L3EgressIDMap has id(key) and l3-egress-id(value).

func NewL3EgressIDMap ¶ added in v0.4.0

func NewL3EgressIDMap() *L3EgressIDMap

NewL3EgressIDMap returns new L3EgressIDMap

func (*L3EgressIDMap) Get ¶ added in v0.4.0

func (m *L3EgressIDMap) Get(id uint32) (opennsl.L3EgressID, bool)

Get returns L3EgressID by id.

func (*L3EgressIDMap) Register ¶ added in v0.4.0

func (m *L3EgressIDMap) Register(id uint32, l3egrId opennsl.L3EgressID) bool

Register registers id and l3egrId.

func (*L3EgressIDMap) Traverse ¶ added in v0.4.0

func (m *L3EgressIDMap) Traverse(f func(L3EgressIDKey, opennsl.L3EgressID) bool)

Traverse enumerates all entries.

func (*L3EgressIDMap) Unregister ¶ added in v0.4.0

func (m *L3EgressIDMap) Unregister(id uint32)

Unregister removes id.

type L3IfaceIDKey ¶ added in v0.4.0

type L3IfaceIDKey struct {
	Port uint32
	Vid  uint16
}

L3IfaceIDKey is key of L3IfaceIDMap.

func NewL3IfaceIDKey ¶ added in v0.4.0

func NewL3IfaceIDKey(port uint32, vid uint16) L3IfaceIDKey

NewL3IfaceIDKey returns new L3IfaceIDKey

func (*L3IfaceIDKey) String ¶ added in v0.4.0

func (k *L3IfaceIDKey) String() string

String returns string.

type L3IfaceIDMap ¶ added in v0.4.0

type L3IfaceIDMap struct {
	sync.Map
}

L3IfaceIDMap has id/vid(key) and l3-interface-id(value).

func NewL3IfaceIDMap ¶ added in v0.4.0

func NewL3IfaceIDMap() *L3IfaceIDMap

NewL3IfaceIDMap returns new NewL3IfaceIDMap

func (*L3IfaceIDMap) Get ¶ added in v0.4.0

func (m *L3IfaceIDMap) Get(port uint32, vid uint16) (opennsl.L3IfaceID, bool)

func (*L3IfaceIDMap) Register ¶ added in v0.4.0

func (m *L3IfaceIDMap) Register(port uint32, vid uint16, l3ifaceId opennsl.L3IfaceID) bool

Register registers id and l3ifaceId.

func (*L3IfaceIDMap) Traverse ¶ added in v0.4.0

func (m *L3IfaceIDMap) Traverse(f func(L3IfaceIDKey, opennsl.L3IfaceID) bool)

Traverse enumerates all entries.

func (*L3IfaceIDMap) Unregister ¶ added in v0.4.0

func (m *L3IfaceIDMap) Unregister(port uint32, vid uint16)

Unregister removes id.

type L3Vlan ¶ added in v0.4.0

type L3Vlan struct {
	Vlan opennsl.Vlan
	Vid  opennsl.Vlan
	Pbmp *opennsl.PBmp
}

func NewL3Vlan ¶ added in v0.4.0

func NewL3Vlan(unit int, vid opennsl.Vlan) *L3Vlan

func (*L3Vlan) Create ¶ added in v0.4.0

func (b *L3Vlan) Create(unit int) error

func (*L3Vlan) Delete ¶ added in v0.4.0

func (b *L3Vlan) Delete(unit int) error

func (*L3Vlan) String ¶ added in v0.4.0

func (b *L3Vlan) String() string

type LinkInfo ¶

type LinkInfo struct {
	*opennsl.PortInfo
	Port opennsl.Port
}

LinkInfo is opennsl port_info and port_no.

func NewLinkInfo ¶

func NewLinkInfo(port opennsl.Port, info *opennsl.PortInfo) *LinkInfo

NewLinkInfo create new instance of LinkInfo.

func (*LinkInfo) PortNo ¶

func (l *LinkInfo) PortNo() uint32

PortNo returns port_no.

func (*LinkInfo) PortState ¶

func (l *LinkInfo) PortState() uint32

PortState returns port statte.

port is up : fibcapi.FFPORT_STATE_NONE port is down: fibcapi.FFPORT_STATE_LINKDOWN

type LogConfig ¶

type LogConfig struct {
	RxDetail bool `mapstructure:"rx_detail"`
	RxDump   bool `mapstructure:"rx_dump"`
}

LogConfig is logging config.

func (*LogConfig) String ¶

func (c *LogConfig) String() string

String retuns config information.

type ONSLConfig ¶

type ONSLConfig struct {
	Config     string `mapstructure:"cfg_fname"`
	ConfigPost string `mapstructure:"cfg_post_fname"`
	Flags      uint   `mapstructure:"flags"`
	RmConfig   string `mapstructure:"rmcfg_fname"`
	WbConfig   string `mapstructure:"wb_fname"`
}

ONSLConfig is opennsl config file.

type PortStats ¶

type PortStats []opennsl.StatVal

PortStats is list of opennsl.StatVal.

func NewPortStats ¶

func NewPortStats(names []string) PortStats

NewPortStats creates new instance.

func (PortStats) Get ¶

func (p PortStats) Get(unit int, port opennsl.Port) (map[string]uint64, error)

Get gets stats of specified port.

func (PortStats) GetAll ¶

func (p PortStats) GetAll(unit int, ports []opennsl.Port) ([]map[string]uint64, error)

GetAll gets Stats of all port.

type Server ¶

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

Server is main service of gonsld.

func NewServer ¶

func NewServer(dpCfg *DpConfig, logCfg *LogConfig) *Server

NewServer cerates new instance of Server.

func (*Server) DpID ¶

func (s *Server) DpID() uint64

func (*Server) FIBCBridgingFlowMod ¶

func (s *Server) FIBCBridgingFlowMod(hdr *fibcnet.Header, mod *fibcapi.FlowMod, flow *fibcapi.BridgingFlow)

FIBCBridgingFlowMod process FlowMod (Bridging)

func (*Server) FIBCFFMultipartPortDescRequest ¶

func (s *Server) FIBCFFMultipartPortDescRequest(hdr *fibcnet.Header, mp *fibcapi.FFMultipart_Request, pd *fibcapi.FFMultipart_PortDescRequest)

FIBCFFMultipartPortDescRequest process multipart-request(port desc) from fibcd.

func (*Server) FIBCFFMultipartPortRequest ¶

func (s *Server) FIBCFFMultipartPortRequest(hdr *fibcnet.Header, mp *fibcapi.FFMultipart_Request, req *fibcapi.FFMultipart_PortRequest)

FIBCFFMultipartPortRequest process multipart-request(port stats) from fibcd.

func (*Server) FIBCFFPacketOut ¶

func (s *Server) FIBCFFPacketOut(hdr *fibcnet.Header, pktout *fibcapi.FFPacketOut)

FIBCFFPacketOut process FFPacketOUT message from fibcd.

func (*Server) FIBCFFPortMod ¶

func (s *Server) FIBCFFPortMod(hdr *fibcnet.Header, mod *fibcapi.FFPortMod)

func (*Server) FIBCFlowMod ¶

func (s *Server) FIBCFlowMod(hdr *fibcnet.Header, mod *fibcapi.FlowMod)

FIBCFlowMod process any FlowMod.

func (*Server) FIBCGroupMod ¶

func (s *Server) FIBCGroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod)

FIBCGroupMod process any GroupMod.

func (*Server) FIBCL2InterfaceGroupMod ¶

func (s *Server) FIBCL2InterfaceGroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.L2InterfaceGroup)

FIBCL2InterfaceGroupMod process GroupMod(L2 Interface)

func (*Server) FIBCL3UnicastGroupMod ¶

func (s *Server) FIBCL3UnicastGroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.L3UnicastGroup)

FIBCL3UnicastGroupMod process GroupMod(L3 Unicst)

func (*Server) FIBCMPLSFlowMod ¶

func (s *Server) FIBCMPLSFlowMod(hdr *fibcnet.Header, mod *fibcapi.FlowMod, flow *fibcapi.MPLSFlow)

FIBCMPLSFlowMod process FlowMod (MPLS)

func (*Server) FIBCMPLSInterfaceGroupMod ¶

func (s *Server) FIBCMPLSInterfaceGroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.MPLSInterfaceGroup)

FIBCMPLSInterfaceGroupMod process GroupMod(MPLS Interface)

func (*Server) FIBCMPLSLabelL2VpnGroupMod ¶

func (s *Server) FIBCMPLSLabelL2VpnGroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.MPLSLabelGroup)

FIBCMPLSLabelL2VpnGroupMod process GroupMod(MPLS Label(L2 VPN))

func (*Server) FIBCMPLSLabelL3VpnGroupMod ¶

func (s *Server) FIBCMPLSLabelL3VpnGroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.MPLSLabelGroup)

FIBCMPLSLabelL3VpnGroupMod process GroupMod(MPLS Label(L3 VPN))

func (*Server) FIBCMPLSLabelSwapGroupMod ¶

func (s *Server) FIBCMPLSLabelSwapGroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.MPLSLabelGroup)

FIBCMPLSLabelSwapGroupMod process GroupMod(MPLS Label(Swap))

func (*Server) FIBCMPLSLabelTun1GroupMod ¶

func (s *Server) FIBCMPLSLabelTun1GroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.MPLSLabelGroup)

FIBCMPLSLabelTun1GroupMod process GroupMod(MPLS Label(Tunnel1))

func (*Server) FIBCMPLSLabelTun2GroupMod ¶

func (s *Server) FIBCMPLSLabelTun2GroupMod(hdr *fibcnet.Header, mod *fibcapi.GroupMod, group *fibcapi.MPLSLabelGroup)

FIBCMPLSLabelTun2GroupMod process GroupMod(MPLS Label(Tunnel2))

func (*Server) FIBCPolicyACLFlowMod ¶

func (s *Server) FIBCPolicyACLFlowMod(hdr *fibcnet.Header, mod *fibcapi.FlowMod, flow *fibcapi.PolicyACLFlow)

FIBCPolicyACLFlowMod process FlowMod(ACL Policy)

func (*Server) FIBCTerminationMacFlowMod ¶

func (s *Server) FIBCTerminationMacFlowMod(hdr *fibcnet.Header, mod *fibcapi.FlowMod, flow *fibcapi.TerminationMacFlow)

FIBCTerminationMacFlowMod process FlowMod(Termination MAC)

func (*Server) FIBCUnicastRoutingFlowMod ¶

func (s *Server) FIBCUnicastRoutingFlowMod(hdr *fibcnet.Header, mod *fibcapi.FlowMod, flow *fibcapi.UnicastRoutingFlow)

FIBCUnicastRoutingFlowMod process FlowMod(Unicast Routing)

func (*Server) FIBCVLANFlowMod ¶

func (s *Server) FIBCVLANFlowMod(hdr *fibcnet.Header, mod *fibcapi.FlowMod, flow *fibcapi.VLANFlow)

FIBCVLANFlowMod process FlowMod(VLAN)

func (*Server) Fields ¶

func (s *Server) Fields() *FieldGroups

func (*Server) L2AddrInit ¶ added in v0.4.0

func (s *Server) L2AddrInit()

func (*Server) L2AddrMonServe ¶ added in v0.4.0

func (s *Server) L2AddrMonServe(unit int, sweepTime time.Duration, done <-chan struct{})

func (*Server) L2AddrMonStart ¶ added in v0.4.0

func (s *Server) L2AddrMonStart(done <-chan struct{})

func (*Server) LinkmonStart ¶

func (s *Server) LinkmonStart(done <-chan struct{}) <-chan *LinkInfo

LinkmonStart starts link monitor.

func (*Server) LogConfig ¶

func (s *Server) LogConfig() *LogConfig

func (*Server) RecvMain ¶

func (s *Server) RecvMain()

RecvMain reveives and dispatch messages from fibcd.

func (*Server) RxStart ¶

func (s *Server) RxStart(done <-chan struct{}) <-chan *opennsl.Pkt

RxStart starts receiving packets.

func (*Server) Serve ¶

func (s *Server) Serve(done <-chan struct{})

Serve is main loop of Service.

func (*Server) Start ¶

func (s *Server) Start(done <-chan struct{}) error

Start starts submodules.

func (*Server) Unit ¶

func (s *Server) Unit() int

func (*Server) VlanPorts ¶

func (s *Server) VlanPorts() *VlanPortTable

type TrunkIDKey ¶ added in v0.4.0

type TrunkIDKey struct {
	LagId uint32
	Vid   uint16
}

TrunkIDKey is key of TrunkIDMap

func NewTrunkIDKey ¶ added in v0.4.0

func NewTrunkIDKey(lagId uint32, vid uint16) TrunkIDKey

NewTrunkIDKey returns new TrunkIDKey

func (*TrunkIDKey) String ¶ added in v0.4.0

func (k *TrunkIDKey) String() string

String returns string

type TrunkIDMap ¶ added in v0.4.0

type TrunkIDMap struct {
	sync.Map
}

TrunkIDMap has lag-id/vid(key) and trunk-id(value)

func NewTrunkIDMap ¶ added in v0.4.0

func NewTrunkIDMap() *TrunkIDMap

NewTrunkIDMap returns new TrunkIDMap

func (*TrunkIDMap) Get ¶ added in v0.4.0

func (m *TrunkIDMap) Get(lagid uint32, vid uint16) (opennsl.Trunk, bool)

Get returns L3IfaceID by id.

func (*TrunkIDMap) Register ¶ added in v0.4.0

func (m *TrunkIDMap) Register(lagid uint32, vid uint16, trunkId opennsl.Trunk) bool

Register registers id and trunkId.

func (*TrunkIDMap) Traverse ¶ added in v0.4.0

func (m *TrunkIDMap) Traverse(f func(TrunkIDKey, opennsl.Trunk) bool)

Traverse enumerates all entries.

func (*TrunkIDMap) Unregister ¶ added in v0.4.0

func (m *TrunkIDMap) Unregister(lagid uint32, vid uint16)

Unregister removes id.

type VlanPortEntry ¶

type VlanPortEntry struct {
	Vid opennsl.Vlan
}

func NewVlanPortEntry ¶

func NewVlanPortEntry(vid opennsl.Vlan) *VlanPortEntry

func NewVlanPortEntryDefault ¶

func NewVlanPortEntryDefault() *VlanPortEntry

type VlanPortKey ¶

type VlanPortKey struct {
	Port opennsl.Port
	Vid  opennsl.Vlan
}

func NewVlanPortKey ¶

func NewVlanPortKey(port opennsl.Port, vid opennsl.Vlan) *VlanPortKey

func (*VlanPortKey) String ¶

func (k *VlanPortKey) String() string

type VlanPortTable ¶

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

func NewVlanPortTable ¶

func NewVlanPortTable() *VlanPortTable

func NewVlanPortTableFromConfig ¶

func NewVlanPortTableFromConfig(config *BlockBcastConfig) *VlanPortTable

func (*VlanPortTable) ConvVID ¶

func (t *VlanPortTable) ConvVID(port opennsl.Port, vid opennsl.Vlan) opennsl.Vlan

func (*VlanPortTable) Has ¶ added in v0.4.0

func (t *VlanPortTable) Has(vid opennsl.Vlan) bool

func (*VlanPortTable) Insert ¶

func (t *VlanPortTable) Insert(key *VlanPortKey, entry *VlanPortEntry) bool

func (*VlanPortTable) SetBaseVID ¶

func (t *VlanPortTable) SetBaseVID(vid opennsl.Vlan)

func (*VlanPortTable) SetDefaultVID ¶

func (t *VlanPortTable) SetDefaultVID(vid opennsl.Vlan)

func (*VlanPortTable) SetMaxPort ¶

func (t *VlanPortTable) SetMaxPort(maxPort opennsl.Port)

func (*VlanPortTable) SetMinPort ¶

func (t *VlanPortTable) SetMinPort(minPort opennsl.Port)

Jump to

Keyboard shortcuts

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