Documentation ¶
Overview ¶
Package pppoe implements pppoe as defined in RFC2516
Index ¶
- Constants
- type BBFSubTagByteSlice
- type BBFSubTagNum
- type BBFSubTagString
- type BBFSubTagUint32
- type BBFTag
- type Code
- type Endpoint
- type Modifier
- type PPPoE
- func (pppoe *PPPoE) Close() error
- func (pppoe *PPPoE) Dial(ctx context.Context) error
- func (pppoe *PPPoE) GetLogger() *zap.Logger
- func (pppoe *PPPoE) LocalAddr() net.Addr
- func (pppoe *PPPoE) ReadFrom(buf []byte) (int, net.Addr, error)
- func (pppoe *PPPoE) SetDeadline(t time.Time) error
- func (pppoe *PPPoE) SetReadDeadline(t time.Time) error
- func (pppoe *PPPoE) SetWriteDeadline(t time.Time) error
- func (pppoe *PPPoE) WriteTo(p []byte, addr net.Addr) (n int, err error)
- type Pkt
- type Tag
- type TagByteSlice
- type TagEndofList
- type TagString
- type TagType
Constants ¶
const ( // DefaultTimeout is default timeout for PPPoE DefaultTimeout = 3 * time.Second // DefaultRetry is the default retry for PPPoE DefaultRetry = 3 )
const ( // EtherTypePPPoESession is the Ether type for PPPoE session pkt EtherTypePPPoESession = 0x8864 // EtherTypePPPoEDiscovery is the Ether type for PPPoE discovery pkt EtherTypePPPoEDiscovery = 0x8863 )
const MaxTags = 32
MaxTags is the max tags allowed in a PPPoE pkt
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BBFSubTagByteSlice ¶
type BBFSubTagByteSlice struct { Value []byte TagType BBFSubTagNum }
BBFSubTagByteSlice is for all byte slice type BBF sub-tag
func (*BBFSubTagByteSlice) Parse ¶
func (bslice *BBFSubTagByteSlice) Parse(buf []byte) (int, error)
Parse implements Tag interface
func (BBFSubTagByteSlice) Serialize ¶
func (bslice BBFSubTagByteSlice) Serialize() ([]byte, error)
Serialize implements Tag interface
func (BBFSubTagByteSlice) String ¶
func (bslice BBFSubTagByteSlice) String() string
String implements Tag interface
func (BBFSubTagByteSlice) Type ¶
func (bslice BBFSubTagByteSlice) Type() uint16
Type implements Tag interface
type BBFSubTagNum ¶
type BBFSubTagNum uint8
BBFSubTagNum is the BBF sub tag type
const ( BBFSubTagNumCircuitID BBFSubTagNum = 1 BBFSubTagNumRemoteID BBFSubTagNum = 2 BBFSubTagActualDataRateUpstream BBFSubTagNum = 0x81 BBFSubTagActualDataRateDownstream BBFSubTagNum = 0x82 BBFSubTagMinimumDataRateUpstream BBFSubTagNum = 0x83 BBFSubTagMinimumDataRateDownstream BBFSubTagNum = 0x84 BBFSubTagAttainableDataRateUpstream BBFSubTagNum = 0x85 BBFSubTagAttainableDataRateDownstream BBFSubTagNum = 0x86 BBFSubTagMaximumDataRateUpstream BBFSubTagNum = 0x87 BBFSubTagMaximumDataRateDownstream BBFSubTagNum = 0x88 BBFSubTagMinDataRateUpstreaminlow BBFSubTagNum = 0x89 BBFSubTagMinimumDataRateDownstreaminlow BBFSubTagNum = 0x8A BBFSubTagMaxInterleavingDelay BBFSubTagNum = 0x8B BBFSubTagActualInterleavingUpstreamDelay BBFSubTagNum = 0x8C BBFSubTagMaximumInterleavingDelay BBFSubTagNum = 0x8D BBFSubTagActualInterleavingDownstreamDelay BBFSubTagNum = 0x8E BBFSubTagDataLinkEncap BBFSubTagNum = 0x90 BBFSubTagIWFSessionFlag BBFSubTagNum = 0xFE )
a list of BBF sub tag type
func (BBFSubTagNum) String ¶
func (t BBFSubTagNum) String() string
String returns a string representation of t
type BBFSubTagString ¶
type BBFSubTagString struct { TagType BBFSubTagNum Value string }
BBFSubTagString is for string type of BBF sub-tag
func (*BBFSubTagString) Parse ¶
func (str *BBFSubTagString) Parse(buf []byte) (int, error)
Parse implements Tag interface
func (BBFSubTagString) Serialize ¶
func (str BBFSubTagString) Serialize() ([]byte, error)
Serialize implements Tag interface
func (BBFSubTagString) String ¶
func (str BBFSubTagString) String() string
String implements Tag interface
func (BBFSubTagString) Type ¶
func (str BBFSubTagString) Type() uint16
Type implements Tag interface
type BBFSubTagUint32 ¶
type BBFSubTagUint32 struct { TagType BBFSubTagNum Value uint32 }
BBFSubTagUint32 is for all numberic type of BBF sub-tag
func (*BBFSubTagUint32) Parse ¶
func (num *BBFSubTagUint32) Parse(buf []byte) (int, error)
Parse implements Tag interface
func (BBFSubTagUint32) Serialize ¶
func (num BBFSubTagUint32) Serialize() ([]byte, error)
Serialize implements Tag interface
func (BBFSubTagUint32) String ¶
func (num BBFSubTagUint32) String() string
String implements Tag interface
func (BBFSubTagUint32) Type ¶
func (num BBFSubTagUint32) Type() uint16
Type implements Tag interface
type BBFTag ¶
type BBFTag []Tag
BBFTag represents a BBF PPPoE tag, which could include multiple sub-tag
func NewCircuitRemoteIDTag ¶
NewCircuitRemoteIDTag return a BBF Tag with circuit-id and remote-id sub tag. if cid or rid is empty string, then it will not be included
type Code ¶
type Code uint8
Code is the PPPoE msg code
type Endpoint ¶
type Endpoint struct { // L2EP is the associated EtherConn's L2Endpoint L2EP *etherconn.L2Endpoint // SessionId is the PPPoE session ID SessionID uint16 }
Endpoint represents a PPPoE endpont
type Modifier ¶
type Modifier func(pppoe *PPPoE)
Modifier is a function to provide custom configuration when creating new PPPoE instances
type PPPoE ¶
type PPPoE struct {
// contains filtered or unexported fields
}
PPPoE is the PPPoE protocol
func NewPPPoE ¶
NewPPPoE return a new PPPoE struct; use conn as underlying transport, logger for logging; optionally Modifer could provide custom configurations;
func (*PPPoE) ReadFrom ¶
ReadFrom implments net.PacketConn interface; only works after pppoe session is open
func (*PPPoE) SetDeadline ¶
SetDeadline implements net.PacketConn interface
func (*PPPoE) SetReadDeadline ¶
SetReadDeadline implements net.PacketConn interface
func (*PPPoE) SetWriteDeadline ¶
SetWriteDeadline implements net.PacketConn interface
type Pkt ¶
Pkt is the struct for PPPoE pkt
type Tag ¶
type Tag interface { // Serialize Tag into byte slice Serialize() ([]byte, error) // Parse buf into Tag Parse(buf []byte) (int, error) // Type return PPPoE Tag type as uint16 Type() uint16 // String returns a string representation of Tag String() string }
Tag is the interface for PPPoE Tag
type TagByteSlice ¶
TagByteSlice is for all byte slice and unknown type of tag, e.g. ACuniq, ACCookie
func (*TagByteSlice) Parse ¶
func (bslice *TagByteSlice) Parse(buf []byte) (int, error)
Parse implements Tag interface
func (TagByteSlice) Serialize ¶
func (bslice TagByteSlice) Serialize() ([]byte, error)
Serialize implements Tag interface
func (TagByteSlice) String ¶
func (bslice TagByteSlice) String() string
String implements Tag interface
type TagEndofList ¶
type TagEndofList struct{}
TagEndofList is the End-of-List tag
func (TagEndofList) Parse ¶
func (eol TagEndofList) Parse(buf []byte) (int, error)
Parse implements Tag interface
func (TagEndofList) Serialize ¶
func (eol TagEndofList) Serialize() ([]byte, error)
Serialize implements Tag interface
func (TagEndofList) String ¶
func (eol TagEndofList) String() string
String implements Tag interface
type TagString ¶
TagString is for all string type of tag, like ACName,SVCName
type TagType ¶
type TagType uint16
TagType is the PPPoE tag type
const ( TagTypeEndOfList TagType = 0 TagTypeServiceName TagType = 257 TagTypeACName TagType = 258 TagTypeHostUniq TagType = 259 TagTypeACCookie TagType = 260 TagTypeVendorSpecific TagType = 261 TagTypeCredits TagType = 262 TagTypeMetrics TagType = 263 TagTypeSequenceNumber TagType = 264 TagTypeCreditScaleFactor TagType = 265 TagTypeRelaySessionID TagType = 272 TagTypeHURL TagType = 273 TagTypeMOTM TagType = 274 TagTypePPPMaxPayload TagType = 288 TagTypeIPRouteAdd TagType = 289 TagTypeServiceNameError TagType = 513 TagTypeACSystemError TagType = 514 TagTypeGenericError TagType = 515 )
a list of PPPoE tag type