sgw

package
v0.0.0-...-d15df5a Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleSGSN   = int(gtpv1.RoleSGSN)
	SCOPE_LINK = netlink.SCOPE_LINK
	FAMILY_ALL = netlink.FAMILY_ALL
)
View Source
const (
	GTPU_PORT = 2152
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KernelTunnel

type KernelTunnel struct {
	GTPLink *netlink.GTP
	// contains filtered or unexported fields
}

func NewKernelTunnel

func NewKernelTunnel(up *UserPlaneServer, cfg SGWGTPUTunnel) *KernelTunnel

func (*KernelTunnel) Close

func (kt *KernelTunnel) Close() error

func (*KernelTunnel) HandleTPDU

func (kt *KernelTunnel) HandleTPDU(data []byte, src *net.UDPAddr) error

func (*KernelTunnel) RegisterSession

func (kt *KernelTunnel) RegisterSession(s Session) error

func (*KernelTunnel) Start

func (kt *KernelTunnel) Start(ctx context.Context) error

func (*KernelTunnel) UnregisterSession

func (kt *KernelTunnel) UnregisterSession(s Session) error

type NetNS

type NetNS interface {
	Handle() netns.NsHandle
	ListenUDP(ctx context.Context, laddr *net.UDPAddr) (*net.UDPConn, error)
	Do(toCall func() error) error
}
var DefaultNetNS NetNS = defaultNetNS{}

type SGWGTPUTunnel

type SGWGTPUTunnel struct {
	Type          SGWGTPUTunnelType `yaml:"type"`
	InterfaceName string            `yaml:"interface_name" default:"gtpu_sgw"`
	MTU           int               `yaml:"mtu" default:"1300"`
}

type SGWGTPUTunnelType

type SGWGTPUTunnelType string
const (
	SGWGTPUTunnelTypeNone   SGWGTPUTunnelType = ""
	SGWGTPUTunnelTypeKernel SGWGTPUTunnelType = "kernel"
	SGWGTPUTunnelTypeTun    SGWGTPUTunnelType = "tun"
)

type Session

type Session interface {
	TriggerEvent(ev SessionEvent)
	UNodeAddr() *net.UDPAddr
	TEIDPGWs5u() uint32
	TEIDSGWs5u() uint32
	IPv4() net.IP
	IPv6() net.IP
	TunnelRegistered() bool
	SetTunnelRegistered(r bool)
	Logger() *logrus.Entry
}

type SessionCreateSessionResponseEvent

type SessionCreateSessionResponseEvent struct{ Error error }

type SessionDeleteSessionResponseEvent

type SessionDeleteSessionResponseEvent struct{ Error error }

type SessionEvent

type SessionEvent interface{}

type SessionEventHandler

type SessionEventHandler = func(s Session, ev SessionEvent)

type SessionIncomingTPDUEvent

type SessionIncomingTPDUEvent struct {
	Data    []byte
	PeerSrc *net.UDPAddr
}

type SessionModifyBearerResponseEvent

type SessionModifyBearerResponseEvent struct{ Error error }

type SessionTunnelStartEvent

type SessionTunnelStartEvent struct{}

type SessionTunnelStopEvent

type SessionTunnelStopEvent struct{}

type SimpleSession

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

func NewSimpleSession

func NewSimpleSession(cfg SimpleSessionConfig) *SimpleSession

func (*SimpleSession) IPv4

func (s *SimpleSession) IPv4() net.IP

func (*SimpleSession) IPv6

func (s *SimpleSession) IPv6() net.IP

func (*SimpleSession) Logger

func (s *SimpleSession) Logger() *logrus.Entry

func (*SimpleSession) SetTunnelRegistered

func (s *SimpleSession) SetTunnelRegistered(r bool)

func (*SimpleSession) TEIDPGWs5u

func (s *SimpleSession) TEIDPGWs5u() uint32

func (*SimpleSession) TEIDSGWs5u

func (s *SimpleSession) TEIDSGWs5u() uint32

func (*SimpleSession) TriggerEvent

func (s *SimpleSession) TriggerEvent(ev SessionEvent)

func (*SimpleSession) TunnelRegistered

func (s *SimpleSession) TunnelRegistered() bool

func (*SimpleSession) UNodeAddr

func (s *SimpleSession) UNodeAddr() *net.UDPAddr

type SimpleSessionConfig

type SimpleSessionConfig struct {
	UNodeAddr  *net.UDPAddr
	TEIDPGWs5u uint32
	TEIDSGWs5u uint32
	IPv4       net.IP
	IPv6       net.IP
	Logger     *logrus.Entry
}

type TPDUHook

type TPDUHook func(tpdu *message.TPDU, fromPGW bool)

type TunTunnel

type TunTunnel struct {
	TUNNetLink netlink.Link
	// contains filtered or unexported fields
}

func NewTunTunnel

func NewTunTunnel(up *UserPlaneServer, cfg SGWGTPUTunnel) *TunTunnel

func (*TunTunnel) Close

func (tt *TunTunnel) Close() error

func (*TunTunnel) HandleTPDU

func (tt *TunTunnel) HandleTPDU(data []byte, src *net.UDPAddr) error

func (*TunTunnel) RegisterSession

func (tt *TunTunnel) RegisterSession(s Session) error

func (*TunTunnel) Start

func (tt *TunTunnel) Start(ctx context.Context) error

func (*TunTunnel) UnregisterSession

func (tt *TunTunnel) UnregisterSession(s Session) error

type UserPlaneConfig

type UserPlaneConfig struct {
	S5uIP      net.IP
	GTPUTunnel SGWGTPUTunnel
	GRXNetNS   NetNS
	UENetNS    NetNS
	AddRule    bool
	// Specify a hook function to run on ougtoing and incoming
	// encapsulated T-PDUs. If this hook is non-nil, userspace
	// GTP mode must always be used
	TPDUHook TPDUHook
}

func (*UserPlaneConfig) SetDefaults

func (cfg *UserPlaneConfig) SetDefaults()

type UserPlaneServer

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

func NewUserPlaneServer

func NewUserPlaneServer(cfg UserPlaneConfig, restartCounter uint8) (up *UserPlaneServer, err error)

func (*UserPlaneServer) Context

func (up *UserPlaneServer) Context(parent context.Context) context.Context

func (*UserPlaneServer) RegisterSession

func (up *UserPlaneServer) RegisterSession(s Session) error

func (*UserPlaneServer) SendResponse

func (up *UserPlaneServer) SendResponse(dstAddr *net.UDPAddr, receivedMsg, toBeSentMsg message.Message) error

func (*UserPlaneServer) Start

func (up *UserPlaneServer) Start(ctx context.Context) error

func (*UserPlaneServer) Stop

func (up *UserPlaneServer) Stop() error

func (*UserPlaneServer) UnRegisterSession

func (up *UserPlaneServer) UnRegisterSession(s Session) error

func (*UserPlaneServer) WriteTo

func (up *UserPlaneServer) WriteTo(dstAddr *net.UDPAddr, toBeSentMsg message.Message) error

type UserPlaneTunnel

type UserPlaneTunnel interface {
	Start(context.Context) error
	Close() error
	RegisterSession(s Session) error
	UnregisterSession(s Session) error
	HandleTPDU(data []byte, src *net.UDPAddr) error
}

Jump to

Keyboard shortcuts

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