ue_context

package
v0.0.2-0...-24b9605 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitUeContext

func InitUeContext()

Types

type ChildSecurityAssociation

type ChildSecurityAssociation struct {
	// SPI
	SPI uint32

	// IP address
	PeerPublicIPAddr  net.IP
	LocalPublicIPAddr net.IP

	// Traffic selector
	SelectedIPProtocol    uint8
	TrafficSelectorLocal  net.IPNet
	TrafficSelectorRemote net.IPNet

	// Security
	EncryptionAlgorithm               uint16
	InitiatorToResponderEncryptionKey []byte
	ResponderToInitiatorEncryptionKey []byte
	IntegrityAlgorithm                uint16
	InitiatorToResponderIntegrityKey  []byte
	ResponderToInitiatorIntegrityKey  []byte
	ESN                               bool

	// UE context
	ThisUE *UeN3IWF
}

type GTPConnectionInfo

type GTPConnectionInfo struct {
	UPFIPAddr           string
	UPFUDPAddr          net.Addr
	IncomingTEID        uint32
	OutgoingTEID        uint32
	UserPlaneConnection *gtpv1.UPlaneConn
}

type IKESecurityAssociation

type IKESecurityAssociation struct {
	// SPI
	RemoteSPI uint64
	LocalSPI  uint64

	// Message ID
	MessageID uint32

	// Transforms for IKE SA
	EncryptionAlgorithm    *ike_message.Transform
	PseudorandomFunction   *ike_message.Transform
	IntegrityAlgorithm     *ike_message.Transform
	DiffieHellmanGroup     *ike_message.Transform
	ExpandedSequenceNumber *ike_message.Transform

	// Used for key generating
	ConcatenatedNonce      []byte
	DiffieHellmanSharedKey []byte

	// Keys
	SK_d  []byte // used for child SA key deriving
	SK_ai []byte // used by initiator for integrity checking
	SK_ar []byte // used by responder for integrity checking
	SK_ei []byte // used by initiator for encrypting
	SK_er []byte // used by responder for encrypting
	SK_pi []byte // used by initiator for IKE authentication
	SK_pr []byte // used by responder for IKE authentication

	// State for IKE_AUTH
	State uint8

	// Temporary data stored for the use in later exchange
	InitiatorID              *ike_message.IdentificationInitiator
	InitiatorCertificate     *ike_message.Certificate
	IKEAuthResponseSA        *ike_message.SecurityAssociation
	TrafficSelectorInitiator *ike_message.TrafficSelectorInitiator
	TrafficSelectorResponder *ike_message.TrafficSelectorResponder
	LastEAPIdentifier        uint8

	// Authentication data
	LocalUnsignedAuthentication  []byte
	RemoteUnsignedAuthentication []byte

	// UE context
	ThisUE *UeN3IWF
}

type OpcType

type OpcType string
const (
	OP  OpcType = "5G_AKA"
	OPc OpcType = "EAP_AKA_PRIME"
)

List of AuthMethod

type PDUSession

type PDUSession struct {
	Id                               int64 // PDU Session ID
	Type                             *ngapType.PDUSessionType
	Ambr                             *ngapType.PDUSessionAggregateMaximumBitRate
	Snssai                           ngapType.SNSSAI
	NetworkInstance                  *ngapType.NetworkInstance
	SecurityCipher                   bool
	SecurityIntegrity                bool
	MaximumIntegrityDataRateUplink   *ngapType.MaximumIntegrityProtectedDataRate
	MaximumIntegrityDataRateDownlink *ngapType.MaximumIntegrityProtectedDataRate
	GTPConnection                    *GTPConnectionInfo
	QFIList                          []uint8
	QosFlows                         map[int64]*QosFlow // QosFlowIdentifier as key
}

type PDUSessionSetupTemporaryData

type PDUSessionSetupTemporaryData struct {
	// Slice of unactivated PDU session
	UnactivatedPDUSession []int64 // PDUSessionID as content
	// NGAPProcedureCode is used to identify which type of
	// response shall be used
	NGAPProcedureCode ngapType.ProcedureCode
	// PDU session setup list response
	SetupListCxtRes  *ngapType.PDUSessionResourceSetupListCxtRes
	FailedListCxtRes *ngapType.PDUSessionResourceFailedToSetupListCxtRes
	SetupListSURes   *ngapType.PDUSessionResourceSetupListSURes
	FailedListSURes  *ngapType.PDUSessionResourceFailedToSetupListSURes
}

type QosFlow

type QosFlow struct {
	Identifier int64
	Parameters ngapType.QosFlowLevelQosParameters
}

type UEContext

type UEContext struct {
	Version         string
	UeId            string
	HttpIPv4Address string
	HttpIPv4Port    int

	GUAMI   *ngapType.GUAMI // connected AMF global identifier TODO: Discutir
	CmState models.CmState  // usada no gerenciamento de conexão (interface de sinalização N1 entre UE e AMF) [IDLE|CONNECTED]
	RmState models.RmState  // usado no gerenciamento de registro do UE junto ao núcleo [REGISTERED|DEREGISTERED]

	IKESA   IKESecurityAssociation
	ChildSA ChildSecurityAssociation

	// N3IWF FQDN
	FQDN string

	// security data
	CertificateAuthority []byte
	UECertificate        []byte
	UEPrivateKey         *rsa.PrivateKey

	// Network interface mark for xfrm
	Mark uint32

	// UE local address
	IKEBindAddress      string
	IPSecGatewayAddress string
	GREBindAddress      string
	TCPPort             uint16
	TCPConnection       *net.TCPConn

	// Tunnels
	GRETunnel netlink.Link

	// N3IWF N1 interface raw socket
	N1RawSocket *ipv4.RawConn

	// UDP
	UDPSocketAddr *net.UDPAddr

	// subscriber data
	SUPIorSUCI string

	UeAuthenticationCtx *models.UeAuthenticationCtx

	// TODO: #LABORA Include Network Slicing Selection Information??
	SNssai *models.Snssai

	N3IWFIpAddress string

	// data for registration procedure
	PermanentKeyValue    string
	AuthenticationMethod models.AuthMethod
	OpcType              string
	Opc                  string
}

func UE_Self

func UE_Self() *UEContext

Create new UE context

func (*UEContext) GetAuthSubscription

func (context *UEContext) GetAuthSubscription() (authSubs models.AuthenticationSubscription)

func (*UEContext) GetAuthSubscription2

func (context *UEContext) GetAuthSubscription2() (authSubs models.AuthenticationSubscription)

temporário

func (*UEContext) Reset

func (context *UEContext) Reset()

Reset UE Context

func (*UEContext) SetupUDPSocket

func (context *UEContext) SetupUDPSocket(log *logrus.Entry) *net.UDPConn

type UeN3IWF

type UeN3IWF struct {
	/* UE identity*/
	RanUeNgapId           int64
	AmfUeNgapId           int64
	IPAddrv4              string
	IPAddrv6              string
	PortNumber            int32
	MaskedIMEISV          *ngapType.MaskedIMEISV // TS 38.413 9.3.1.54
	Guti                  string
	RRCEstablishmentCause int16
	IPSecInnerIP          string

	/* PDU Session */
	PduSessionList map[int64]*PDUSession // pduSessionId as key

	/* PDU Session Setup Temporary Data */
	TemporaryPDUSessionSetupData *PDUSessionSetupTemporaryData

	/* Security */
	Kn3iwf               []uint8                          // 32 bytes (256 bits), value is from NGAP IE "Security Key"
	SecurityCapabilities *ngapType.UESecurityCapabilities // TS 38.413 9.3.1.86

	/* IKE Security Association */
	N3IWFIKESecurityAssociation   *IKESecurityAssociation
	N3IWFChildSecurityAssociation *ChildSecurityAssociation

	/* NAS IKE Connection */
	UDPSendInfoGroup *n3iwf_message.UDPSendInfoGroup
	/* NAS TCP Connection */
	TCPConnection net.Conn

	/* Others */
	Guami                            *ngapType.GUAMI
	IndexToRfsp                      int64
	Ambr                             *ngapType.UEAggregateMaximumBitRate
	AllowedNssai                     *ngapType.AllowedNSSAI
	RadioCapability                  *ngapType.UERadioCapability                // TODO: This is for RRC, can be deleted
	CoreNetworkAssistanceInformation *ngapType.CoreNetworkAssistanceInformation // TS 38.413 9.3.1.15
	IMSVoiceSupported                int32
}

func (*UeN3IWF) CreateIKEChildSecurityAssociation

func (ue *UeN3IWF) CreateIKEChildSecurityAssociation(chosenSecurityAssociation *ike_message.SecurityAssociation) (*ChildSecurityAssociation, error)

func (*UeN3IWF) CreatePDUSession

func (ue *UeN3IWF) CreatePDUSession(pduSessionID int64, snssai ngapType.SNSSAI) (*PDUSession, error)

func (*UeN3IWF) FindPDUSession

func (ue *UeN3IWF) FindPDUSession(pduSessionID int64) *PDUSession

Jump to

Keyboard shortcuts

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