nll2tp

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 6 Imported by: 0

README

Within this directory the file const.go is autogenerated from the l2tp.h C header file
using the c-for-go tool[1].

To regenerate:

    cd ../ && ~/go/bin/c-for-go -nocgo nll2tp/nll2tp.yml

[1]  https://github.com/xlab/c-for-go

Documentation

Overview

Package nll2tp provides Go bindings for the Linux L2TP GeNetlink API

Index

Constants

View Source
const (
	// CmdMax as defined in nll2tp/l2tp.h:90
	CmdMax = -1
	// AttrMax as defined in nll2tp/l2tp.h:135
	AttrMax = -1
	// AttrStatsMax as defined in nll2tp/l2tp.h:152
	AttrStatsMax = -1
	// GenlName as defined in nll2tp/l2tp.h:198
	GenlName = "l2tp"
	// GenlVersion as defined in nll2tp/l2tp.h:199
	GenlVersion = 0x1
	// GenlMcgroup as defined in nll2tp/l2tp.h:200
	GenlMcgroup = "l2tp"
)
View Source
const (
	// CmdNoop as declared in nll2tp/l2tp.h:78
	CmdNoop = iota
	// CmdTunnelCreate as declared in nll2tp/l2tp.h:79
	CmdTunnelCreate = 1
	// CmdTunnelDelete as declared in nll2tp/l2tp.h:80
	CmdTunnelDelete = 2
	// CmdTunnelModify as declared in nll2tp/l2tp.h:81
	CmdTunnelModify = 3
	// CmdTunnelGet as declared in nll2tp/l2tp.h:82
	CmdTunnelGet = 4
	// CmdSessionCreate as declared in nll2tp/l2tp.h:83
	CmdSessionCreate = 5
	// CmdSessionDelete as declared in nll2tp/l2tp.h:84
	CmdSessionDelete = 6
	// CmdSessionModify as declared in nll2tp/l2tp.h:85
	CmdSessionModify = 7
	// CmdSessionGet as declared in nll2tp/l2tp.h:86
	CmdSessionGet = 8
)
View Source
const (
	// AttrNone as declared in nll2tp/l2tp.h:96
	AttrNone = iota
	// AttrPwType as declared in nll2tp/l2tp.h:97
	AttrPwType = 1
	// AttrEncapType as declared in nll2tp/l2tp.h:98
	AttrEncapType = 2
	// AttrOffset as declared in nll2tp/l2tp.h:99
	AttrOffset = 3
	// AttrDataSeq as declared in nll2tp/l2tp.h:100
	AttrDataSeq = 4
	// AttrL2specType as declared in nll2tp/l2tp.h:101
	AttrL2specType = 5
	// AttrL2specLen as declared in nll2tp/l2tp.h:102
	AttrL2specLen = 6
	// AttrProtoVersion as declared in nll2tp/l2tp.h:103
	AttrProtoVersion = 7
	// AttrIfname as declared in nll2tp/l2tp.h:104
	AttrIfname = 8
	// AttrConnId as declared in nll2tp/l2tp.h:105
	AttrConnId = 9
	// AttrPeerConnId as declared in nll2tp/l2tp.h:106
	AttrPeerConnId = 10
	// AttrSessionId as declared in nll2tp/l2tp.h:107
	AttrSessionId = 11
	// AttrPeerSessionId as declared in nll2tp/l2tp.h:108
	AttrPeerSessionId = 12
	// AttrUdpCsum as declared in nll2tp/l2tp.h:109
	AttrUdpCsum = 13
	// AttrVlanId as declared in nll2tp/l2tp.h:110
	AttrVlanId = 14
	// AttrCookie as declared in nll2tp/l2tp.h:111
	AttrCookie = 15
	// AttrPeerCookie as declared in nll2tp/l2tp.h:112
	AttrPeerCookie = 16
	// AttrDebug as declared in nll2tp/l2tp.h:113
	AttrDebug = 17
	// AttrRecvSeq as declared in nll2tp/l2tp.h:114
	AttrRecvSeq = 18
	// AttrSendSeq as declared in nll2tp/l2tp.h:115
	AttrSendSeq = 19
	// AttrLnsMode as declared in nll2tp/l2tp.h:116
	AttrLnsMode = 20
	// AttrUsingIpsec as declared in nll2tp/l2tp.h:117
	AttrUsingIpsec = 21
	// AttrRecvTimeout as declared in nll2tp/l2tp.h:118
	AttrRecvTimeout = 22
	// AttrFd as declared in nll2tp/l2tp.h:119
	AttrFd = 23
	// AttrIpSaddr as declared in nll2tp/l2tp.h:120
	AttrIpSaddr = 24
	// AttrIpDaddr as declared in nll2tp/l2tp.h:121
	AttrIpDaddr = 25
	// AttrUdpSport as declared in nll2tp/l2tp.h:122
	AttrUdpSport = 26
	// AttrUdpDport as declared in nll2tp/l2tp.h:123
	AttrUdpDport = 27
	// AttrMtu as declared in nll2tp/l2tp.h:124
	AttrMtu = 28
	// AttrMru as declared in nll2tp/l2tp.h:125
	AttrMru = 29
	// AttrStats as declared in nll2tp/l2tp.h:126
	AttrStats = 30
	// AttrIp6Saddr as declared in nll2tp/l2tp.h:127
	AttrIp6Saddr = 31
	// AttrIp6Daddr as declared in nll2tp/l2tp.h:128
	AttrIp6Daddr = 32
	// AttrUdpZeroCsum6Tx as declared in nll2tp/l2tp.h:129
	AttrUdpZeroCsum6Tx = 33
	// AttrUdpZeroCsum6Rx as declared in nll2tp/l2tp.h:130
	AttrUdpZeroCsum6Rx = 34
	// AttrPad as declared in nll2tp/l2tp.h:131
	AttrPad = 35
)
View Source
const (
	// AttrStatsNone as declared in nll2tp/l2tp.h:139
	AttrStatsNone = iota
	// AttrTxPackets as declared in nll2tp/l2tp.h:140
	AttrTxPackets = 1
	// AttrTxBytes as declared in nll2tp/l2tp.h:141
	AttrTxBytes = 2
	// AttrTxErrors as declared in nll2tp/l2tp.h:142
	AttrTxErrors = 3
	// AttrRxPackets as declared in nll2tp/l2tp.h:143
	AttrRxPackets = 4
	// AttrRxBytes as declared in nll2tp/l2tp.h:144
	AttrRxBytes = 5
	// AttrRxSeqDiscards as declared in nll2tp/l2tp.h:145
	AttrRxSeqDiscards = 6
	// AttrRxOosPackets as declared in nll2tp/l2tp.h:146
	AttrRxOosPackets = 7
	// AttrRxErrors as declared in nll2tp/l2tp.h:147
	AttrRxErrors = 8
	// AttrStatsPad as declared in nll2tp/l2tp.h:148
	AttrStatsPad = 9
)
View Source
const (
	PwtypeNone    = 0x0000
	PwtypeEthVlan = 0x0004
	PwtypeEth     = 0x0005
	PwtypePpp     = 0x0007
	PwtypePppAc   = 0x0008
	PwtypeIp      = 0x000b
)

L2tpPwtype enumeration from nll2tp/l2tp.h:154

View Source
const (
	L2spectypeNone    = iota
	L2spectypeDefault = 1
)

L2tpL2specType enumeration from nll2tp/l2tp.h:164

View Source
const (
	EncaptypeUdp = iota
	EncaptypeIp  = 1
)

L2tpEncapType enumeration from nll2tp/l2tp.h:169

View Source
const (
	SeqNone = iota
	SeqIp   = 1
	SeqAll  = 2
)

L2tpSeqmode enumeration from nll2tp/l2tp.h:174

View Source
const (
	MsgDebug   = (1 << 0)
	MsgControl = (1 << 1)
	MsgSeq     = (1 << 2)
	MsgData    = (1 << 3)
)

L2tpDebugFlags enumeration from nll2tp/l2tp.h:188

View Source
const (
	// ProtocolVersion2 specifies L2TPv2 RFC2661
	ProtocolVersion2 = 2
	// ProtocolVersion3 specifies L2TPv3 RFC3931
	ProtocolVersion3 = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn represents the genetlink L2TP connection to the kernel.

func Dial

func Dial() (*Conn, error)

Dial creates a new genetlink L2TP connection to the kernel.

func (*Conn) Close

func (c *Conn) Close()

Close connection, releasing associated resources

func (*Conn) CreateManagedTunnel

func (c *Conn) CreateManagedTunnel(fd int, config *TunnelConfig) (err error)

CreateManagedTunnel creates a new managed tunnel instance in the kernel. A "managed" tunnel is one whose tunnel socket fd is created and managed by a userspace process. A managed tunnel's lifetime is bound by the lifetime of the tunnel socket fd, and may optionally be destroyed using explicit netlink commands.

func (*Conn) CreateSession

func (c *Conn) CreateSession(config *SessionConfig) error

CreateSession creates a session instance in the kernel. The parent tunnel instance referenced by the tunnel IDs in the session configuration must already exist in the kernel.

func (*Conn) CreateStaticTunnel

func (c *Conn) CreateStaticTunnel(
	localAddr []byte, localPort uint16,
	peerAddr []byte, peerPort uint16,
	config *TunnelConfig) (err error)

CreateStaticTunnel creates a new static tunnel instance in the kernel. A "static" tunnel is one whose tunnel socket fd is implicitly created by the kernel. A static tunnel must be explicitly deleted using netlink commands.

func (*Conn) DeleteSession

func (c *Conn) DeleteSession(config *SessionConfig) error

DeleteSession deletes a session instance from the kernel.

func (*Conn) DeleteTunnel

func (c *Conn) DeleteTunnel(config *TunnelConfig) error

DeleteTunnel deletes a tunnel instance from the kernel. Deleting a tunnel instance implicitly destroys any sessions running in that tunnel.

func (*Conn) GetSessionInfo

func (c *Conn) GetSessionInfo(config *SessionConfig) (*SessionInfo, error)

GetSessionInfo retrieves dataplane session information from the kernel.

type L2tpDebugFlags

type L2tpDebugFlags uint32

L2tpDebugFlags as declared in nll2tp/l2tp.h:188

type L2tpEncapType

type L2tpEncapType int32

L2tpEncapType as declared in nll2tp/l2tp.h:169

type L2tpL2specType

type L2tpL2specType int32

L2tpL2specType as declared in nll2tp/l2tp.h:164

type L2tpProtocolVersion

type L2tpProtocolVersion uint32

L2tpProtocolVersion describes the RFC version of the tunnel: L2TPv2 is described by RFC2661, while L2TPv3 is described by RFC3931.

type L2tpPwtype

type L2tpPwtype int32

L2tpPwtype as declared in nll2tp/l2tp.h:154

type L2tpSeqmode

type L2tpSeqmode int32

L2tpSeqmode as declared in nll2tp/l2tp.h:174

type L2tpSessionID

type L2tpSessionID uint32

L2tpSessionID represents the numeric identifier of an L2TP session. This ID is used in L2TP control and data packet headers and AVPs, and is unique to the tunnel for L2TPv2, or the host for L2TPv3.

type L2tpTunnelID

type L2tpTunnelID uint32

L2tpTunnelID represents the numeric identifier of an L2TP tunnel. This ID is used in L2TP control and data packet headers and AVPs, and is unique to the host.

type SessionConfig

type SessionConfig struct {
	// Tid is the host's L2TP ID for the tunnel containing the session.
	Tid L2tpTunnelID
	// Ptid is the peer's L2TP ID for the tunnel containing the session.
	Ptid L2tpTunnelID
	// Sid is the host's L2TP ID for the session.
	Sid L2tpSessionID
	// Psid is the peer's L2TP ID for the session.
	Psid L2tpSessionID
	// PseudowireType specifies the type of traffic carried by the session.
	// For L2TPv3 this may be PPP or Ethernet.
	// For L2TPv2 this may be PPP only.
	PseudowireType L2tpPwtype
	// SendSeq controls whether to send data packet sequence numbers per RFC2661 section 5.4.
	SendSeq bool
	// RecvSeq if set will cause data packets without sequence numbers to be dropped.
	RecvSeq bool
	// IsLNS if unset allows the LNS to enable data packet sequence numbers per RFC2661 section 5.4
	IsLNS bool
	// ReorderTimeout sets the maximum amount of time, in milliseconds, to hold a data packet
	// in the reorder queue when sequence numbers are enabled.
	ReorderTimeout uint64
	// LocalCookie sets the RFC3931 cookie for the session.
	// Transmitted data packets will include the cookie.
	// The LocalCookie may be either 4 or 8 bytes in length if set.
	LocalCookie []byte
	// PeerCookie sets the RFC3931 peer cookie for the session as negotiated by the control protocol.
	// Received data packets with a cookie mismatch are discarded.
	// The PeerCookie may be either 4 or 8 bytes in length if set.
	PeerCookie []byte
	// IfName use depends on the pseudowire type.
	// For an RFC3931 Ethernet pseudowire, IfName specifies the interface name to use for
	// the L2TP Ethernet interface.  By default the kernel generates a name "l2tpethX".
	// For an RFC2661 PPP/AC pseudowire, IfName specifies the name of the interface associated
	// with the PPPoE session.
	IfName string
	// L2SpecType specifies the Layer 2 specific sublayer field to be used in data packets
	// as per RFC3931 section 3.2.2
	L2SpecType L2tpL2specType
	// DebugFlags specifies the kernel debugging flags to use for the session instance.
	DebugFlags L2tpDebugFlags
}

SessionConfig encapsulates genetlink parameters for L2TP session commands.

type SessionInfo

type SessionInfo struct {
	// Tid is the host's L2TP ID for the tunnel containing the session.
	Tid L2tpTunnelID
	// Ptid is the peer's L2TP ID for the tunnel containing the session.
	Ptid L2tpTunnelID
	// Sid is the host's L2TP ID for the session.
	Sid L2tpSessionID
	// Psid is the peer's L2TP ID for the session.
	Psid L2tpSessionID
	// IfName is the assigned interface name for this session.
	IfName string
	// LocalCookie is the RFC3931 cookie for the session.
	LocalCookie []byte
	// PeerCookie is the RFC3931 peer cookie for the session.
	PeerCookie []byte
	// SendSeq is true if session is sending data packet sequence numbers per RFC2661 section 5.4.
	SendSeq bool
	// RecvSeq is true if session is dropping data packets received without sequence numbers.
	RecvSeq bool
	// LnsMode is true if the session is running as server.  If running as server
	// the session will not permit the peer to control data sequence number settings.
	LnsMode bool
	// UsingIPSec is true if the session is using IPSec.
	UsingIPSec bool
	// ReorderTimeout is the maximum amount of time to hold a data packet in the reorder
	// queue when sequence numbers are enabled.  This number is defined in milliseconds.
	ReorderTimeout uint64
	// Statistics is the current dataplane tx/rx stats.
	Statistics SessionStatistics
}

SessionInfo encapsulates dataplane session information provided by the kernel.

type SessionStatistics

type SessionStatistics struct {
	// TxPacketCount is the number of data packets the session has transmitted.
	TxPacketCount uint64
	// TxBytes is the number of data bytes the session has transmitted.
	TxBytes uint64
	// TxErrorCount is the number of transmission errors the session has recorded.
	TxErrorCount uint64
	// RxPacketCount is the number of data packets the session has received.
	RxPacketCount uint64
	// RxBytes is the number of data bytes the session has received.
	RxBytes uint64
	// RxErrorCount is the number of receive errors the session has recorded.
	RxErrorCount uint64
	// RxSeqDiscardCount is the number of packets the session has discarded due to sequence errors.
	// For example, if the session is in LNS mode, has requested sequence numbers, and the client
	// isn't sending them.
	RxSeqDiscardCount uint64
	// RxOOSCount is the number of packets the session has received out of sequence if data packet
	// reordering is enabled.
	RxOOSCount uint64
}

SessionStatistics includes statistics on dataplane receive and transmit.

type TunnelConfig

type TunnelConfig struct {
	// Tid is the host's L2TP ID for the tunnel.
	Tid L2tpTunnelID
	// Ptid is the peer's L2TP ID for the tunnel
	Ptid L2tpTunnelID
	// Version is the tunnel protocol version (L2TPv2 or L2TPv3)
	Version L2tpProtocolVersion
	// Encap specifies the tunnel encapsulation type.
	// For L2TPv3 this may be UDP or IP.
	// For L2TPv2 this may only be UDP.
	Encap L2tpEncapType
	// DebugFlags specifies the kernel debugging flags to use for the tunnel instance.
	DebugFlags L2tpDebugFlags
}

TunnelConfig encapsulates genetlink parameters for L2TP tunnel commands.

Jump to

Keyboard shortcuts

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