ethernet

package
v1.2.0-rc.1.0...-65ced95 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: GPL-2.0, GPL-2.0-or-later Imports: 15 Imported by: 1

Documentation

Overview

Copyright 2018 Platina Systems, Inc. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Ethernet hardware interfaces.

Index

Constants

View Source
const (
	ErrorCorrectionNone = iota
	ErrorCorrectionCL74 // IEEE Clause 74 for 10g ethernet
	ErrorCorrectionCL91 // IEEE Clause 91 for 100g ethernet
)
View Source
const (
	SizeofAddress    = 6
	SizeofHeader     = 14
	SizeofVlanHeader = 4
)
View Source
const MaxVlan = 1 << 12
View Source
const SizeofVlanTypeAndTag = 4

Variables

View Source
var BroadcastAddr = Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
View Source
var ErrDelUnknownNeighbor = errors.New("delete unknown neighbor")
View Source
var PipePortByPortVid map[uint16]uint16 // FIXME remove, not needed for learning lookup

Functions

func FormatRewrite

func FormatRewrite(v *vnet.Vnet, r *vnet.Rewrite) (lines []string)

func GetBridgeBySi

func GetBridgeBySi(si vnet.Si) (br *bridgeEntry)

func GetPacketHeader

func GetPacketHeader(r *vnet.Ref) vnet.PacketHeader

func Init

func Init(v *vnet.Vnet, m4, m6 *ip.Main)

func ParseHeader

func ParseHeader(b []byte) (h *Header, vs []*VlanHeader, payloadType Type, payload []byte)

func ProcessChangeUpper

func ProcessChangeUpper(msg *xeth.MsgChangeUpper, action vnet.ActionType, v *vnet.Vnet) (err error)

add/remove port from bridge, no change to netns update fdb map of stag/pipeport to ifindex of bridge member

func RefString

func RefString(r *vnet.Ref) string

func RegisterInterface

func RegisterInterface(v *vnet.Vnet, hi HwInterfacer, config *InterfaceConfig, format string, args ...interface{})

func RegisterLayer

func RegisterLayer(v *vnet.Vnet, t Type, l vnet.Layer)

func SetBridge

func SetBridge(stag uint16, ifname string) *vnet.PortEntry

Bridge interface is mapped by name and by stag entry is allocated when creating map by ifname stag may change, so that map must be refreshed

func SetInterfaceErrorCorrection

func SetInterfaceErrorCorrection(v *vnet.Vnet, hi vnet.Hi, et ErrorCorrectionType) (err error)

func StartFromFeReceivers

func StartFromFeReceivers()

l2-mod-fifo learning, aging, and flush is posted async from fe1 to vnet

func UnregisterLayer

func UnregisterLayer(v *vnet.Vnet, t Type) (ok bool)

func UnsetBridge

func UnsetBridge(stag uint16)

Types

type Address

type Address [SizeofAddress]byte

func AddressUint64

func AddressUint64(x uint64) (a Address)

func RandomAddress

func RandomAddress() (a Address)

func (*Address) Add

func (a *Address) Add(x uint64)

func (*Address) Equal

func (a *Address) Equal(b Address) bool

func (*Address) FromUint64

func (a *Address) FromUint64(x vnet.Uint64)

func (*Address) IsBroadcast

func (a *Address) IsBroadcast() bool

func (*Address) IsLocallyAdministered

func (a *Address) IsLocallyAdministered() bool

func (*Address) IsUnicast

func (a *Address) IsUnicast() bool

func (*Address) IsZero

func (a *Address) IsZero() bool

func (*Address) MaskedString

func (v *Address) MaskedString(r vnet.MaskedStringer) (s string)

func (*Address) Parse

func (a *Address) Parse(in *parse.Input)

func (*Address) String

func (a *Address) String() string

func (*Address) ToUint64

func (a *Address) ToUint64() (x vnet.Uint64)

type AddressBlock

type AddressBlock struct {
	// Base ethernet address (stored in board's EEPROM).
	Base Address

	// Number of addresses starting at base.
	Count uint32
	// contains filtered or unexported fields
}

Block of ethernet addresses for allocation by a switch.

func (*AddressBlock) Alloc

func (b *AddressBlock) Alloc() (Address, bool)

func (*AddressBlock) Free

func (b *AddressBlock) Free(a *Address)

type DoubleTaggedInjectNode

type DoubleTaggedInjectNode struct {
	vnet.InOutNode
	// contains filtered or unexported fields
}

func (*DoubleTaggedInjectNode) AddDisposition

func (n *DoubleTaggedInjectNode) AddDisposition(next uint, offset_valid bool, si vnet.Si, tags [2]VlanTag)

func (*DoubleTaggedInjectNode) Init

func (n *DoubleTaggedInjectNode) Init(v *vnet.Vnet, name string)

func (*DoubleTaggedInjectNode) NodeInput

func (n *DoubleTaggedInjectNode) NodeInput(in *vnet.RefIn, o *vnet.RefOut)

type DoubleTaggedPuntInjectNodes

type DoubleTaggedPuntInjectNodes struct {
	Punt   DoubleTaggedPuntNode
	Inject DoubleTaggedInjectNode
}

func (*DoubleTaggedPuntInjectNodes) Init

func (n *DoubleTaggedPuntInjectNodes) Init(v *vnet.Vnet, name string)

type DoubleTaggedPuntNode

type DoubleTaggedPuntNode vlan_tagged_punt_node

func (*DoubleTaggedPuntNode) AddDisposition

func (n *DoubleTaggedPuntNode) AddDisposition(cf PuntConfig) (i PuntDisposition)

func (*DoubleTaggedPuntNode) DelDisposition

func (n *DoubleTaggedPuntNode) DelDisposition(i PuntDisposition) (ok bool)

func (*DoubleTaggedPuntNode) Init

func (n *DoubleTaggedPuntNode) Init(v *vnet.Vnet, name string)

func (*DoubleTaggedPuntNode) NodeInput

func (n *DoubleTaggedPuntNode) NodeInput(in *vnet.RefIn, o *vnet.RefOut)

type ErrorCorrectionType

type ErrorCorrectionType uint8

func (*ErrorCorrectionType) Parse

func (t *ErrorCorrectionType) Parse(in *parse.Input)

func (ErrorCorrectionType) String

func (x ErrorCorrectionType) String() string
type Header struct {
	Dst  Address
	Src  Address
	Type Type
}

Header for ethernet packets as they appear on the network.

func GetHeader

func GetHeader(r *vnet.Ref) *Header

func (*Header) GetPayload

func (h *Header) GetPayload() unsafe.Pointer

func (*Header) GetType

func (h *Header) GetType() Type

func (*Header) IsBroadcast

func (h *Header) IsBroadcast() bool

func (*Header) IsUnicast

func (h *Header) IsUnicast() bool

func (*Header) Len

func (h *Header) Len() uint

Implement vnet.Header interface.

func (*Header) Parse

func (h *Header) Parse(in *parse.Input)

func (*Header) Read

func (h *Header) Read(b []byte) vnet.PacketHeader

func (*Header) String

func (h *Header) String() (s string)

func (*Header) TypeIs

func (h *Header) TypeIs(t Type) bool

func (*Header) Write

func (h *Header) Write(b []byte)

type HeaderNoType

type HeaderNoType header_no_type

type HeaderParser

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

func (*HeaderParser) Parse

func (h *HeaderParser) Parse(in *parse.Input) (innerType Type)

func (*HeaderParser) Sizeof

func (h *HeaderParser) Sizeof() uint

func (*HeaderParser) Write

func (h *HeaderParser) Write(b []byte)

type HwInterfacer

type HwInterfacer interface {
	GetInterface() *Interface
	SetErrorCorrection() (err error)
	vnet.HwInterfacer
}

type IfDuplex

type IfDuplex int

Full or half duplex.

const (
	Full IfDuplex = iota + 1
	Half
)

func (IfDuplex) String

func (x IfDuplex) String() string

type IfId

type IfId vnet.IfId

func (IfId) InnerVlan

func (i IfId) InnerVlan() (id vnet.Uint16, valid bool)

func (IfId) OuterVlan

func (i IfId) OuterVlan() (id vnet.Uint16, valid bool)

func (*IfId) Set

func (i *IfId) Set(outer vnet.Uint16)

func (*IfId) Set2

func (i *IfId) Set2(outer, inner vnet.Uint16)

type IfSpanningTreeState

type IfSpanningTreeState int

Spanning Tree State IEEE 802.1d

const (
	Disable IfSpanningTreeState = iota + 1
	Block
	Listen
	Learn
	Forward
)

Possible spanning tree states.

func (IfSpanningTreeState) String

func (x IfSpanningTreeState) String() string

type Interface

type Interface struct {
	vnet.HwIf

	InterfaceConfig
	// contains filtered or unexported fields
}

func (*Interface) ConfigureHwIf

func (i *Interface) ConfigureHwIf(in *cli.Input) (ok bool, err error)

func (*Interface) FormatAddress

func (hi *Interface) FormatAddress() string

func (*Interface) FormatId

func (i *Interface) FormatId(aʹ vnet.IfId) (v string)

func (*Interface) FormatRewrite

func (hi *Interface) FormatRewrite(r *vnet.Rewrite) []string

func (*Interface) GetAddress

func (hi *Interface) GetAddress() []byte

func (*Interface) GetInterface

func (i *Interface) GetInterface() *Interface

func (*Interface) LessThanId

func (i *Interface) LessThanId(aʹ, bʹ vnet.IfId) bool

func (*Interface) ParseId

func (intf *Interface) ParseId(a *vnet.IfId, in *parse.Input) bool

func (*Interface) ParseRewrite

func (hi *Interface) ParseRewrite(r *vnet.Rewrite, in *parse.Input)

func (*Interface) SetAddress

func (hi *Interface) SetAddress(a []byte)

func (*Interface) SetErrorCorrection

func (i *Interface) SetErrorCorrection() (err error)

Default implementation: nothing supported.

func (*Interface) SetRewrite

func (hi *Interface) SetRewrite(v *vnet.Vnet, rw *vnet.Rewrite, packetType vnet.PacketType, da []byte)

func (*Interface) SupportsArp

func (i *Interface) SupportsArp()

See vnet.Arper interface. Dummy function to mark ethernet interfaces as supporting ARP.

type InterfaceConfig

type InterfaceConfig struct {
	Address             Address
	PhyInterface        PhyInterface
	NativeVlan          Vlan
	Unprovisioned       bool
	ErrorCorrectionType ErrorCorrectionType
}

type IpNeighbor

type IpNeighbor struct {
	Ethernet Address
	Ip       net.IP
	Si       vnet.Si
}

type Main

type Main struct {
	vnet.Package
	// contains filtered or unexported fields
}

func GetMain

func GetMain(v *vnet.Vnet) *Main

func (*Main) AddDelIpNeighbor

func (m *Main) AddDelIpNeighbor(im *ip.Main, n *IpNeighbor, isDel bool) (ai ip.Adj, err error)

func (*Main) Init

func (m *Main) Init() (err error)

func (*Main) Name

func (m *Main) Name() string

func (*Main) ParseStream

func (m *Main) ParseStream(in *parse.Input) (r pg.Streamer, err error)

func (*Main) SetPortMap

func (m *Main) SetPortMap(fi []PortFdbInfo)

called from fe1 to init map so vnet can call br api by pipe-port

type PhyInterface

type PhyInterface int

Physical interface between ethernet MAC and PHY.

const (
	CAUI PhyInterface = iota + 1
	CR
	CR2
	CR4
	GMII
	INTERLAKEN
	KR
	KR2
	KR4
	KX
	LR
	LR4
	MII
	QSGMII
	RGMII
	RXAUI
	SFI
	SGMII
	SPAUI
	SR
	SR10
	SR2
	SR4
	XAUI
	XFI
	XGMII
	XLAUI
	XLAUI2
	ZR
)

Mac to PHY physical interface types. Sorted alphabetically.

func (PhyInterface) String

func (x PhyInterface) String() string

type PortFdbInfo

type PortFdbInfo struct {
	PipePort uint16
	PortVid  uint16
}

learned by pipe_port, lookup bridge member via portvid

type PuntConfig

type PuntConfig struct {
	// Next hop in vnet packet processing for this dispostion.
	Next string
	// Software interface and aux data to use for packet.
	RefOpaque vnet.RefOpaque
	// True to advance past vlan/2-vlan tags to layer 3 header.
	AdvanceL3Header     bool
	NReplaceVlanHeaders uint
	ReplaceVlanHeaders  [2]VlanTypeAndTag
	Stag                uint16
}

type PuntDisposition

type PuntDisposition uint32

func PuntDispositionForTags

func PuntDispositionForTags(outer, inner VlanTag) (i PuntDisposition)

type SingleTaggedInjectNode

type SingleTaggedInjectNode struct {
	vnet.InOutNode
	// contains filtered or unexported fields
}

func (*SingleTaggedInjectNode) AddDisposition

func (n *SingleTaggedInjectNode) AddDisposition(next uint, offset_valid bool, si vnet.Si, tag VlanTag)

func (*SingleTaggedInjectNode) Init

func (n *SingleTaggedInjectNode) Init(v *vnet.Vnet, name string)

func (*SingleTaggedInjectNode) NodeInput

func (n *SingleTaggedInjectNode) NodeInput(in *vnet.RefIn, o *vnet.RefOut)

type SingleTaggedPuntInjectNodes

type SingleTaggedPuntInjectNodes struct {
	Punt   SingleTaggedPuntNode
	Inject SingleTaggedInjectNode
}

func (*SingleTaggedPuntInjectNodes) Init

func (n *SingleTaggedPuntInjectNodes) Init(v *vnet.Vnet, name string)

type SingleTaggedPuntNode

type SingleTaggedPuntNode vlan_tagged_punt_node

func (*SingleTaggedPuntNode) AddDisposition

func (n *SingleTaggedPuntNode) AddDisposition(cf PuntConfig) PuntDisposition

func (*SingleTaggedPuntNode) DelDisposition

func (n *SingleTaggedPuntNode) DelDisposition(i PuntDisposition) (ok bool)

func (*SingleTaggedPuntNode) Init

func (n *SingleTaggedPuntNode) Init(v *vnet.Vnet, name string)

func (*SingleTaggedPuntNode) NodeInput

func (n *SingleTaggedPuntNode) NodeInput(in *vnet.RefIn, o *vnet.RefOut)

type Type

type Type vnet.Uint16

Packet type from ethernet header.

const (
	// Types < 0x600 (1536) are LLC packet lengths.
	TYPE_LLC_LENGTH              Type = 0x600
	TYPE_XNS_IDP                 Type = 0x600
	TYPE_IP4                     Type = 0x800
	TYPE_ARP                     Type = 0x806
	TYPE_VINES_IP                Type = 0x0BAD
	TYPE_VINES_LOOPBACK          Type = 0x0BAE
	TYPE_VINES_ECHO              Type = 0x0BAF
	TYPE_TRAIN                   Type = 0x1984
	TYPE_CDP                     Type = 0x2000
	TYPE_CGMP                    Type = 0x2001
	TYPE_SRP_CONTROL             Type = 0x2007
	TYPE_CENTRINO_PROMISC        Type = 0x2452
	TYPE_DECNET                  Type = 0x6000
	TYPE_DECNET_DUMP_LOAD        Type = 0x6001
	TYPE_DECNET_REMOTE_CONSOLE   Type = 0x6002
	TYPE_DECNET_ROUTE            Type = 0x6003
	TYPE_DEC_LAT                 Type = 0x6004
	TYPE_DEC_DIAGNOSTIC          Type = 0x6005
	TYPE_DEC_CUSTOMER            Type = 0x6006
	TYPE_DEC_SCA                 Type = 0x6007
	TYPE_TRANSPARENT_BRIDGING    Type = 0x6558
	TYPE_RAW_FRAME_RELAY         Type = 0x6559
	TYPE_REVERSE_ARP             Type = 0x8035
	TYPE_DEC_LAN_BRIDGE          Type = 0x8038
	TYPE_DEC_ETHERNET_ENCRYPTION Type = 0x803D
	TYPE_DEC_LAN_TRAFFIC_MONITOR Type = 0x803F
	TYPE_DEC_LAST                Type = 0x8041
	TYPE_APPLETALK               Type = 0x809B
	TYPE_IBM_SNA                 Type = 0x80D5
	TYPE_APPLETALK_AARP          Type = 0x80F3
	TYPE_WELLFLEET_COMPRESSION   Type = 0x80FF
	TYPE_VLAN                    Type = 0x8100
	TYPE_VLAN_IN_VLAN            Type = 0x9100
	TYPE_VLAN_802_1AD            Type = 0x88a8
	TYPE_IPX                     Type = 0x8137
	TYPE_SNMP                    Type = 0x814C
	TYPE_CABLETRON_ISMP          Type = 0x81FD
	TYPE_CABLETRON_ISMP_TBFLOOD  Type = 0x81FF
	TYPE_IP6                     Type = 0x86DD
	TYPE_ATOMIC                  Type = 0x86DF
	TYPE_TCP_IP_COMPRESSION      Type = 0x876B
	TYPE_IP_AUTONOMOUS_SYSTEMS   Type = 0x876C
	TYPE_SECURE_DATA             Type = 0x876D
	TYPE_MAC_CONTROL             Type = 0x8808
	TYPE_SLOW_PROTOCOLS          Type = 0x8809
	TYPE_PPP                     Type = 0x880B
	TYPE_MPLS_UNICAST            Type = 0x8847
	TYPE_MPLS_MULTICAST          Type = 0x8848
	TYPE_PPPOE_DISCOVERY         Type = 0x8863
	TYPE_PPPOE_SESSION           Type = 0x8864
	TYPE_INTEL_ANS               Type = 0x886D
	TYPE_MICROSOFT_NLB_HEARTBEAT Type = 0x886F
	TYPE_CDMA_2000               Type = 0x8881
	TYPE_PROFINET                Type = 0x8892
	TYPE_HYPERSCSI               Type = 0x889a
	TYPE_AOE                     Type = 0x88a2
	TYPE_BRDWALK                 Type = 0x88AE
	TYPE_LOOPBACK                Type = 0x9000
	TYPE_RTNET_MAC               Type = 0x9021
	TYPE_RTNET_CONFIG            Type = 0x9022
	TYPE_PGLAN                   Type = 0x9999
	TYPE_SRP_ISIS                Type = 0xFEFE
	TYPE_RESERVED                Type = 0xFFFF
)

func (Type) FromHost

func (t Type) FromHost() Type

func (Type) IsVLAN

func (t Type) IsVLAN() (ok bool)

func (Type) IsVlan

func (t Type) IsVlan() bool

func (Type) MaskedString

func (v Type) MaskedString(r vnet.MaskedStringer) (s string)

func (*Type) Parse

func (t *Type) Parse(in *parse.Input)

func (*Type) SetPacketType

func (et *Type) SetPacketType(pt vnet.PacketType)

func (Type) String

func (t Type) String() string

func (Type) ToHost

func (t Type) ToHost() Type

type Vlan

type Vlan vnet.Uint16

A 12 bit vlan id.

type VlanHeader

type VlanHeader struct {
	/* 3 bit priority, 1 bit CFI and 12 bit vlan id. */
	Tag VlanTag

	/* Inner ethernet type. */
	Type Type
}

Tagged packets have VlanHeader after ethernet header.

func (*VlanHeader) GetType

func (h *VlanHeader) GetType() Type

func (*VlanHeader) Len

func (h *VlanHeader) Len() uint

func (*VlanHeader) Parse

func (h *VlanHeader) Parse(sup_in *parse.Input)

func (*VlanHeader) Read

func (h *VlanHeader) Read(b []byte) vnet.PacketHeader

func (*VlanHeader) String

func (h *VlanHeader) String() (s string)

func (*VlanHeader) Write

func (h *VlanHeader) Write(b []byte)

type VlanTag

type VlanTag vnet.Uint16

A 16 bit vlan tag in network byte order.

func PuntTagsForDisposition

func PuntTagsForDisposition(i PuntDisposition) (outer, inner VlanTag)

func (VlanTag) CFI

func (v VlanTag) CFI() bool

func (VlanTag) FromHost

func (t VlanTag) FromHost() VlanTag

func (VlanTag) Id

func (v VlanTag) Id() uint16

func (VlanTag) MaskedString

func (v VlanTag) MaskedString(r vnet.MaskedStringer) (s string)

func (VlanTag) Priority

func (v VlanTag) Priority() uint8

func (*VlanTag) Set

func (v *VlanTag) Set(i uint16, p uint8, cfi bool)

func (*VlanTag) String

func (v *VlanTag) String() string

func (VlanTag) ToHost

func (t VlanTag) ToHost() VlanTag

type VlanTypeAndTag

type VlanTypeAndTag struct {
	Type Type
	Tag  VlanTag
}

Like a VlanHeader but with fields in reverse order. Packet looks like either of the following:

DST-ETHERNET SRC-ETHERNET TypeAndTag INNER-TYPE
DST-ETHERNET SRC-ETHERNET 0x8100 VlanHeader

func (*VlanTypeAndTag) Write

func (h *VlanTypeAndTag) Write(b []byte)

Jump to

Keyboard shortcuts

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