Documentation
¶
Overview ¶
Package v2 provides the simple and painless handling of GTPv2-C protocol in pure Golang.
Please see README.md for detailed usage of the APIs provided by this package.
Index ¶
- Constants
- Variables
- func DisableLogging()
- func EnableLogging(l *log.Logger)
- func PassMessageTo(s *Session, msg messages.Message, timeout time.Duration) error
- func SetLogger(l *log.Logger)
- type Bearer
- type BearerNotFoundError
- type CauseNotOKError
- type Conn
- func (c *Conn) AddHandler(msgType uint8, fn HandlerFunc)
- func (c *Conn) AddHandlers(funcs map[uint8]HandlerFunc)
- func (c *Conn) BearerCount() int
- func (c *Conn) Close() error
- func (c *Conn) CreateSession(raddr net.Addr, ie ...*ies.IE) (*Session, uint32, error)
- func (c *Conn) DecSequence() uint32
- func (c *Conn) DeleteBearer(teid uint32, sess *Session, ie ...*ies.IE) (uint32, error)
- func (c *Conn) DeleteSession(teid uint32, sess *Session, ie ...*ies.IE) (uint32, error)
- func (c *Conn) DisableValidation()
- func (c *Conn) EchoRequest(raddr net.Addr) (uint32, error)
- func (c *Conn) EchoResponse(raddr net.Addr, req messages.Message) error
- func (c *Conn) EnableValidation()
- func (c *Conn) GetIMSIByTEID(teid uint32, peer net.Addr) (string, error)
- func (c *Conn) GetSessionByIMSI(imsi string) (*Session, error)
- func (c *Conn) GetSessionByTEID(teid uint32, peer net.Addr) (*Session, error)
- func (c *Conn) IncSequence() uint32
- func (c *Conn) ListenAndServe(ctx context.Context) error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) ModifyBearer(teid uint32, sess *Session, ie ...*ies.IE) (uint32, error)
- func (c *Conn) NewSenderFTEID(v4, v6 string) (fteidIE *ies.IE)
- func (c *Conn) ParseCreateSession(raddr net.Addr, ie ...*ies.IE) (*Session, error)
- func (c *Conn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (c *Conn) RegisterSession(itei uint32, session *Session)
- func (c *Conn) RemoveSession(session *Session)
- func (c *Conn) RemoveSessionByIMSI(imsi string)
- func (c *Conn) RespondTo(raddr net.Addr, received, toBeSent messages.Message) error
- func (c *Conn) SendMessageTo(msg messages.Message, addr net.Addr) (uint32, error)
- func (c *Conn) SequenceNumber() uint32
- func (c *Conn) SessionCount() int
- func (c *Conn) Sessions() []*Session
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) VersionNotSupportedIndication(raddr net.Addr, req messages.Message) error
- func (c *Conn) WriteTo(p []byte, addr net.Addr) (n int, err error)
- type HandlerFunc
- type HandlerNotFoundError
- type InvalidSequenceError
- type InvalidSessionError
- type InvalidTEIDError
- type InvalidVersionError
- type Location
- type QoSProfile
- type RequiredIEMissingError
- type RequiredParameterMissingError
- type Session
- func (s *Session) Activate() error
- func (s *Session) AddBearer(name string, br *Bearer)
- func (s *Session) AddTEID(ifType uint8, teid uint32)
- func (s *Session) BearerCount() int
- func (s *Session) Bearers() []*Bearer
- func (s *Session) Deactivate() error
- func (s *Session) GetDefaultBearer() *Bearer
- func (s *Session) GetTEID(ifType uint8) (uint32, error)
- func (s *Session) IsActive() bool
- func (s *Session) LookupBearerByEBI(ebi uint8) (*Bearer, error)
- func (s *Session) LookupBearerByName(name string) (*Bearer, error)
- func (s *Session) LookupBearerNameByEBI(ebi uint8) (string, error)
- func (s *Session) LookupEBIByName(name string) uint8
- func (s *Session) LookupEBIByTEID(teid uint32) uint8
- func (s *Session) PeerAddr() net.Addr
- func (s *Session) RemoveBearer(name string)
- func (s *Session) RemoveBearerByEBI(ebi uint8)
- func (s *Session) SetDefaultBearer(bearer *Bearer)
- func (s *Session) UpdatePeerAddr(peer net.Addr)
- func (s *Session) WaitMessage(seq uint32, timeout time.Duration) (messages.Message, error)
- type Subscriber
- type UnexpectedIEError
- type UnexpectedTypeError
- type UnknownAPNError
- type UnknownIMSIError
Constants ¶
const ( GTPCPort = ":2123" GTPUPort = ":2152" )
Registered UDP ports
const ( IFTypeS1UeNodeBGTPU uint8 = iota IFTypeS1USGWGTPU IFTypeS12RNCGTPU IFTypeS12SGWGTPU IFTypeS5S8SGWGTPU IFTypeS5S8PGWGTPU IFTypeS5S8SGWGTPC IFTypeS5S8PGWGTPC IFTypeS5S8SGWPMIPv6 IFTypeS5S8PGWPMIPv6 IFTypeS11MMEGTPC IFTypeS11S4SGWGTPC IFTypeS10MMEGTPC IFTypeS3MMEGTPC IFTypeS3SGSNGTPC IFTypeS4SGSNGTPU IFTypeS4SGWGTPU IFTypeS4SGSNGTPC IFTypeS16SGSNGTPC IFTypeeNodeBGTPUForDL IFTypeeNodeBGTPUForUL IFTypeRNCGTPUForData IFTypeSGSNGTPUForData IFTypeSGWUPFGTPUForDL IFTypeSmMBMSGWGTPC IFTypeSnMBMSGWGTPC IFTypeSmMMEGTPC IFTypeSnSGSNGTPC IFTypeSGWGTPUForUL IFTypeSnSGSNGTPU IFTypeS2bePDGGTPC IFTypeS2bUePDGGTPU IFTypeS2bPGWGTPC IFTypeS2bUPGWGTPU IFTypeS2aTWANGTPU IFTypeS2aTWANGTPC IFTypeS2aPGWGTPC IFTypeS2aPGWGTPU IFTypeS11MMEGTPU IFTypeS11SGWGTPU )
InterfaceType definitions.
const ( APNRestrictionNoExistingContextsorRestriction uint8 = iota APNRestrictionPublic1 APNRestrictionPublic2 APNRestrictionPrivate1 APNRestrictionPrivate2 )
APN Restriction definitions.
const ( CauseLocalDetach uint8 = 2 CauseCompleteDetach uint8 = 3 CauseRATChangedFrom3GPPToNon3GPP uint8 = 4 CauseISRDeactivation uint8 = 5 CauseErrorIndicationReceivedFromRNCeNodeBS4SGSNMME uint8 = 6 CauseIMSIDetachOnly uint8 = 7 CauseReactivationRequested uint8 = 8 CausePDNReconnectionToThisAPNDisallowed uint8 = 9 CauseAccessChangedFromNon3GPPTo3GPP uint8 = 10 CausePDNConnectionInactivityTimerExpires uint8 = 11 CausePGWNotResponding uint8 = 12 CauseNetworkFailure uint8 = 13 CauseQoSParameterMismatch uint8 = 14 CauseRequestAccepted uint8 = 16 CauseRequestAcceptedPartially uint8 = 17 CauseNewPDNTypeDueToNetworkPreference uint8 = 18 CauseNewPDNTypeDueToSingleAddressBearerOnly uint8 = 19 CauseContextNotFound uint8 = 64 CauseInvalidMessageFormat uint8 = 65 CauseVersionNotSupportedByNextPeer uint8 = 66 CauseInvalidLength uint8 = 67 CauseServiceNotSupported uint8 = 68 CauseMandatoryIEIncorrect uint8 = 69 CauseMandatoryIEMissing uint8 = 70 CauseSystemFailure uint8 = 72 CauseNoResourcesAvailable uint8 = 73 CauseSemanticErrorInTheTFTOperation uint8 = 74 CauseSyntacticErrorInTheTFTOperation uint8 = 75 CauseSemanticErrorsInPacketFilters uint8 = 76 CauseSyntacticErrorsInPacketFilters uint8 = 77 CauseMissingOrUnknownAPN uint8 = 78 CauseGREKeyNotFound uint8 = 80 CauseRelocationFailure uint8 = 81 CauseDeniedInRAT uint8 = 82 CausePreferredPDNTypeNotSupported uint8 = 83 CauseAllDynamicAddressesAreOccupied uint8 = 84 CauseUEContextWithoutTFTAlreadyActivated uint8 = 85 CauseProtocolTypeNotSupported uint8 = 86 CauseUENotResponding uint8 = 87 CauseUERefuses uint8 = 88 CauseServiceDenied uint8 = 89 CauseUnableToPageUE uint8 = 90 CauseNoMemoryAvailable uint8 = 91 CauseUserAuthenticationFailed uint8 = 92 CauseAPNAccessDeniedNoSubscription uint8 = 93 CauseRequestRejectedReasonNotSpecified uint8 = 94 CausePTMSISignatureMismatch uint8 = 95 CauseIMSIIMEINotKnown uint8 = 96 CauseSemanticErrorInTheTADOperation uint8 = 97 CauseSyntacticErrorInTheTADOperation uint8 = 98 CauseRemotePeerNotResponding uint8 = 100 CauseCollisionWithNetworkInitiatedRequest uint8 = 101 CauseUnableToPageUEDueToSuspension uint8 = 102 CauseConditionalIEMissing uint8 = 103 CauseAPNRestrictionTypeIncompatibleWithCurrentlyActivePDNConnection uint8 = 104 CauseInvalidOverallLengthOfTheTriggeredResponseMessageAndAPiggybackedInitialMessage uint8 = 105 CauseDataForwardingNotSupported uint8 = 106 CauseInvalidReplyFromRemotePeer uint8 = 107 CauseFallbackToGTPv1 uint8 = 108 CauseInvalidPeer uint8 = 109 CauseTemporarilyRejectedDueToHandoverTAURAUProcedureInProgress uint8 = 110 CauseModificationsNotLimitedToS1UBearers uint8 = 111 CauseRequestRejectedForAPMIPv6Reason uint8 = 112 CauseAPNCongestion uint8 = 113 CauseBearerHandlingNotSupported uint8 = 114 CauseUEAlreadyReattached uint8 = 115 CauseMultiplePDNConnectionsForAGivenAPNNotAllowed uint8 = 116 CauseTargetAccessRestrictedForTheSubscriber uint8 = 117 CauseMMESGSNRefusesDueToVPLMNPolicy uint8 = 119 CauseGTPCEntityCongestion uint8 = 120 CauseLateOverlappingRequest uint8 = 121 CauseTimedOutRequest uint8 = 122 CauseUEIsTemporarilyNotReachableDueToPowerSaving uint8 = 123 CauseRelocationFailureDueToNASMessageRedirection uint8 = 124 CauseUENotAuthorisedByOCSOrExternalAAAServer uint8 = 125 CauseMultipleAccessesToAPDNConnectionNotAllowed uint8 = 126 CauseRequestRejectedDueToUECapability uint8 = 127 CauseS1UPathFailure uint8 = 128 )
Cause definitions.
const ( CMINonCSG uint8 = iota CMICSG )
CSG Membership Indication definitions.
const ( DetachTypePS uint8 DetachTypeCombinedPSCS )
Detach Type definitions.
const ( NodeIDIPv4 uint8 = iota NodeIDIPv6 NodeIDOther )
Node-ID Type definitions.
const ( NodeTypeSGSN uint8 = iota NodeTypeMME )
Node Type definitions.
const ( ProtoIDLCP uint16 = 0xc021 ProtoIDPAP uint16 = 0xc023 ProtoIDCHAP uint16 = 0xc223 ProtoIDIPCP uint16 = 0x8021 )
Protocol ID definitions. For more identifiers, see RFC 3232.
const ( ContIDPCSCFIPv6AddressRequest uint16 ContIDIMCNSubsystemSignalingFlag ContIDDNSServerIPv6AddressRequest ContIDNotSupported ContIDMSSupportofNetworkRequestedBearerControlIndicator ContIDDSMIPv6HomeAgentAddressRequest ContIDDSMIPv6HomeNetworkPrefixRequest ContIDDSMIPv6IPv4HomeAgentAddressRequest ContIDIPaddressAllocationViaNASSignalling ContIDIPv4addressAllocationViaDHCPv4 ContIDPCSCFIPv4AddressRequest ContIDDNSServerIPv4AddressRequest ContIDMSISDNRequest ContIDIFOMSupportRequest ContIDIPv4LinkMTURequest ContIDMSSupportOfLocalAddressInTFTIndicator ContIDPCSCFReselectionSupport ContIDNBIFOMRequestIndicator ContIDNBIFOMMode ContIDNonIPLinkMTURequest ContIDAPNRateControlSupportIndicator ContID3GPPPSDataOffUEstatus ContIDReliableDataServiceRequestIndicator ContIDAdditionalAPNRateControlForExceptionDataSupportIndicator ContIDPDUSessionID ContIDEthernetFramePayloadMTURequest ContIDUnstructuredLinkMTURequest ContID5GSMCauseValue )
Container ID definitions.
const ( PDNTypeIPv4 uint8 PDNTypeIPv6 PDNTypeIPv4v6 PDNTypeNonIP )
PDN Type definitions.
const ( ProtoTypeS1APCause uint8 ProtoTypeEMMCause ProtoTypeESMCause ProtoTypeDiameterCause ProtoTypeIKEv2Cause )
Protocol Type definitions.
const ( CauseType uint8 = iota CauseTypeRadioNetworkLayer CauseTypeTransportLayer CauseTypeNAS CauseTypeProtocol CauseTypeMiscellaneous )
Cause Type definitions.
const ( RATTypeUTRAN uint8 RATTypeGERAN RATTypeWLAN RATTypeGAN RATTypeHSPAEvolution RATTypeEUTRAN RATTypeVirtual RATTypeEUTRANNBIoT RATTypeLTEM RATTypeNR )
RAT Type definitions.
const ( SelectionModeMSorNetworkProvidedAPNSubscribedVerified uint8 = iota SelectionModeMSProvidedAPNSubscriptionNotVerified SelectionModeNetworkProvidedAPNSubscriptionNotVerified )
SelectionMode definitions.
const ( ServiceIndCSCall uint8 ServiceIndSMS )
Service Indicator definitions.
const ( AccessModeClosed uint8 = iota AccessModeHybrid )
Access Mode definitions.
const ( DaylightSavingNoAdjustment uint8 = iota DaylightSavingPlusOneHour DaylightSavingPlusTwoHours )
Daylight Saving Time definitions.
const (
ConfigProtocolPPPWithIP uint8 = 0
)
Configuration Protocol definitions.
Variables ¶
var ( // ErrTEIDNotFound indicates that TEID is not registered for the interface specified. ErrTEIDNotFound = errors.New("no TEID found") // ErrTimeout indicates that a handler failed to complete its work due to the // absence of messages expected to come from another endpoint. ErrTimeout = errors.New("timed out") )
Functions ¶
func DisableLogging ¶ added in v0.6.1
func DisableLogging()
DisableLogging disables the logging from the package. Logging is enabled by default.
func EnableLogging ¶ added in v0.6.1
EnableLogging enables the logging from the package. If l is nil, it uses default logger provided by the package. Logging is enabled by default.
See also: SetLogger.
func PassMessageTo ¶
PassMessageTo passes the message (typically "triggerred message") to the session expecting to receive it.
If the message queue of s is full, it waits for certain period of time specified by timeout. It discards the msg and returns error if expired. The default queue size of a Session is 1000 and it cannot be configured in the current implementation.
func SetLogger ¶ added in v0.6.1
SetLogger replaces the standard logger with arbitrary *log.Logger.
This package prints just informational logs from goroutines working background that might help developers test the program but can be ignored safely. More important ones that needs any action by caller would be returned as errors.
Types ¶
type Bearer ¶
type Bearer struct { EBI uint8 SubscriberIP, APN string ChargingID uint32 *QoSProfile // contains filtered or unexported fields }
Bearer represents a GTPv2 bearer.
func NewBearer ¶
func NewBearer(ebi uint8, apn string, qos *QoSProfile) *Bearer
NewBearer creates a new Bearer.
func (*Bearer) IncomingTEID ¶
IncomingTEID returns the incoming TEID associated with Bearer.
func (*Bearer) OutgoingTEID ¶
OutgoingTEID returns the outgoing TEID associated with Bearer.
func (*Bearer) RemoteAddress ¶
RemoteAddress returns the remote address associated with Bearer.
func (*Bearer) SetIncomingTEID ¶
SetIncomingTEID sets the incoming TEID associated with Bearer.
func (*Bearer) SetOutgoingTEID ¶
SetOutgoingTEID sets the outgoing TEID associated with Bearer.
func (*Bearer) SetRemoteAddress ¶
SetRemoteAddress sets the remote address associated with Bearer.
type BearerNotFoundError ¶ added in v0.6.0
type BearerNotFoundError struct {
IMSI string
}
BearerNotFoundError indicates that no Bearer found by lookup methods.
func (*BearerNotFoundError) Error ¶ added in v0.6.0
func (e *BearerNotFoundError) Error() string
x Error returns message with IMSI associated with Bearer if available.
type CauseNotOKError ¶ added in v0.6.0
CauseNotOKError indicates that the value in Cause IE is not OK.
func (*CauseNotOKError) Error ¶ added in v0.6.0
func (e *CauseNotOKError) Error() string
x Error returns error cause with message.
type Conn ¶
type Conn struct { // RestartCounter is the RestartCounter value in Recovery IE, which represents how many // times the GTPv2-C endpoint is restarted. RestartCounter uint8 // contains filtered or unexported fields }
Conn represents a GTPv2-C connection.
Conn provides the automatic handling of message by adding handlers to it with AddHandler(s). See AddHandler for detailed usage.
Conn also provides the functions to manage Sessions/Bearers that works over the connection(=between a node to another). See the docs of CreateSession, AddSession, DeleteSession methods for details.
func Dial ¶
Dial sends Echo Request to raddr to check if the endpoint is alive and returns Conn.
It does not bind the raddr to the underlying connection, which enables a Conn to send to/receive from multiple peers with single laddr.
If Echo exchange is unnecessary, use NewConn and ListenAndServe instead.
func (*Conn) AddHandler ¶
func (c *Conn) AddHandler(msgType uint8, fn HandlerFunc)
AddHandler adds a message handler to Conn.
By adding HandlerFunc, Conn(and Session, Bearer created over the Conn) will handle the specified type of message with it's paired HandlerFunc when receiving. Messages without registered handlers are just ignored and logged.
This should be performed just after creating Conn, otherwise the user cannot retrieve any values, which is in most cases vital to continue working as a node, from the incoming messages.
The error returned from handler is just logged. Any important due should be done inside the HandlerFunc before returning. This behavior might change in the future.
HandlerFunc for EchoResponse and VersionNotSupportedIndication are registered by default. These HandlerFunc can be overridden by specifying messages.MsgTypeEchoResponse and/or messages.MsgTypeVersionNotSupportedIndication as msgType parameter.
func (*Conn) AddHandlers ¶
func (c *Conn) AddHandlers(funcs map[uint8]HandlerFunc)
AddHandlers adds multiple handler funcs at a time, using a map. The key of the map is message type of the GTPv2-C messages. You can use MsgTypeFooBar constants defined in this package as well as any raw uint8 values.
See AddHandler for how the given handlers behave.
func (*Conn) BearerCount ¶ added in v0.2.0
BearerCount returns the number of bearers registered in Conn.
This may have some impact on performance in case of large number of Session and Bearer exist.
func (*Conn) Close ¶
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*Conn) CreateSession ¶
CreateSession sends a CreateSessionRequest and stores information given with IE in the Session returned.
After using this method, users don't need to call AddSession with the session returned.
By creating a Session with this method, the values in IEs given, such as TEID in F-TEID are stored with "best effort". See the source code to see what kind information is handled automatically in this method.
Also, a Bearer named "default" is also created to be used as default bearer. The default bearer can be retrieved by using GetDefaultBearer() or LookupBearerByName("default").
Note that this method doesn't care IEs given are sufficient or not, as the required IE varies much depending on the context in which the Create Session Request is used. In other words, any kind of IE can be put on the Create Session Request message using this method.
func (*Conn) DecSequence ¶ added in v0.3.1
DecSequence decrements the SequenceNumber associated with Conn.
func (*Conn) DeleteBearer ¶ added in v0.2.0
DeleteBearer sends a DeleteBearerRequest TEID and with IEs given.
func (*Conn) DeleteSession ¶
DeleteSession sends a DeleteSessionRequest with TEID and IEs given.
func (*Conn) DisableValidation ¶
func (c *Conn) DisableValidation()
DisableValidation turns off automatic validation of incoming messages. It is not recommended to use this except the node is in debugging mode.
See EnableValidation for what are validated.
func (*Conn) EchoRequest ¶
EchoRequest sends a EchoRequest.
func (*Conn) EchoResponse ¶
EchoResponse sends a EchoResponse in response to the EchoRequest.
func (*Conn) EnableValidation ¶
func (c *Conn) EnableValidation()
EnableValidation turns on automatic validation of incoming messages. This is expected to be used only after DisableValidation() is used, as the validation is enabled by default.
Conn checks if;
GTP Version is 2 TEID is known to Conn
Even the validation is failed, it does not return error to user. Instead, it just logs and discards the packets so that the HandlerFunc won't get the invalid message. Extra validations should be done in HandlerFunc.
func (*Conn) GetIMSIByTEID ¶
GetIMSIByTEID returns IMSI associated with TEID and the peer node.
func (*Conn) GetSessionByIMSI ¶
GetSessionByIMSI returns Session looked up by IMSI.
func (*Conn) GetSessionByTEID ¶
GetSessionByTEID returns Session looked up by TEID and sender of the message.
func (*Conn) IncSequence ¶ added in v0.3.1
IncSequence increments the SequenceNumber associated with Conn.
func (*Conn) ListenAndServe ¶ added in v0.7.0
ListenAndServe creates a new GTPv2-C Conn and start serving background.
func (*Conn) ModifyBearer ¶
ModifyBearer sends a ModifyBearerRequest with TEID and IEs given..
func (*Conn) NewSenderFTEID ¶ added in v0.7.3
NewSenderFTEID creates a new F-TEID with random TEID value that is unique within Conn. To ensure the uniqueness, don't create in the other way if you once use this method. This is meant to be used for creating F-TEID IE only for local interface type that is specified at the creation of Conn.
Note that in the case there's a lot of Session on the Conn, it may take a long time to find a new unique value.
TODO: optimize performance...
func (*Conn) ParseCreateSession ¶ added in v0.7.4
ParseCreateSession iterates through the ies and returns a session
func (*Conn) ReadFrom ¶
ReadFrom reads a packet from the connection, copying the payload into p. It returns the number of bytes copied into p and the return address that was on the packet. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Callers should always process the n > 0 bytes returned before considering the error err. ReadFrom can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*Conn) RegisterSession ¶ added in v0.7.3
RegisterSession registers session to Conn with its incoming TEID to distinguish which session the incoming messages are for.
Incoming TEID(itei) should be the one with it's local interface type. e.g., if the Conn is used for S-GW on S11 I/F, itei should be the one with interface type=IFTypeS11S4SGWGTPC.
func (*Conn) RemoveSession ¶
RemoveSession removes a session registered in a Conn.
func (*Conn) RemoveSessionByIMSI ¶ added in v0.6.1
RemoveSessionByIMSI removes a session looked up by IMSI.
Use RemoveSession instead if you already have the Session in your hand.
func (*Conn) RespondTo ¶
RespondTo sends a message(specified with "toBeSent" param) in response to a message (specified with "received" param).
This exists to make it easier to handle SequenceNumber.
func (*Conn) SendMessageTo ¶ added in v0.3.1
SendMessageTo sends a message to addr. Unlike WriteTo, it sets the Sequence Number properly and returns the one used in the message.
func (*Conn) SequenceNumber ¶ added in v0.3.1
SequenceNumber returns the current(=last used) SequenceNumber associated with Conn.
func (*Conn) SessionCount ¶ added in v0.2.0
SessionCount returns the number of sessions registered in Conn.
This may have some impact on performance in case of large number of Session exists.
func (*Conn) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*Conn) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.
func (*Conn) VersionNotSupportedIndication ¶
VersionNotSupportedIndication sends VersionNotSupportedIndication message in response to any kind of message.Message.
type HandlerFunc ¶
HandlerFunc is a handler for specific GTPv2-C message.
type HandlerNotFoundError ¶ added in v0.6.0
type HandlerNotFoundError struct {
MsgType string
}
HandlerNotFoundError indicates that the handler func is not registered in *Conn for the incoming GTPv2 message. In usual cases this error should not be taken as fatal, as the other endpoint can make your program stop working just by sending unregistered messages.
func (*HandlerNotFoundError) Error ¶ added in v0.6.0
func (e *HandlerNotFoundError) Error() string
x Error returns violating message type to handle.
type InvalidSequenceError ¶ added in v0.6.0
type InvalidSequenceError struct {
Seq uint32
}
InvalidSequenceError indicates that the Sequence Number is invalid.
func (*InvalidSequenceError) Error ¶ added in v0.6.0
func (e *InvalidSequenceError) Error() string
x Error returns violating Sequence Number.
type InvalidSessionError ¶ added in v0.6.0
type InvalidSessionError struct {
IMSI string
}
InvalidSessionError indicates that something went wrong with Session.
func (*InvalidSessionError) Error ¶ added in v0.6.0
func (e *InvalidSessionError) Error() string
x Error returns message with IMSI associated with Session if available.
type InvalidTEIDError ¶ added in v0.6.0
type InvalidTEIDError struct {
TEID uint32
}
InvalidTEIDError indicates that the TEID value is different from expected one or not registered in TEIDMap.
func (*InvalidTEIDError) Error ¶ added in v0.6.0
func (e *InvalidTEIDError) Error() string
x Error returns violating TEID.
type InvalidVersionError ¶ added in v0.6.0
type InvalidVersionError struct {
Version int
}
InvalidVersionError indicates that the version of the message specified by the user is not acceptable for the receiver.
func (*InvalidVersionError) Error ¶ added in v0.6.0
func (e *InvalidVersionError) Error() string
x Error returns violationg version.
type Location ¶
type Location struct {
MCC, MNC string
RATType uint8
LAC, CI, SAI, RAI, TAI uint16
ECI, MeNBI, EMeNBI uint32
}
Location is a subscriber's location.
type QoSProfile ¶
type QoSProfile struct {
PCI, PVI bool
PL, QCI uint8
// Max bit rate for Uplink and Donwlink
MBRUL, MBRDL uint64
// Guaranteed bit rate for Uplink and Donwlink
GBRUL, GBRDL uint64
}
QoSProfile represents a QoS-related information that belongs to a Bearer.
type RequiredIEMissingError ¶ added in v0.6.0
type RequiredIEMissingError struct {
Type uint8
}
RequiredIEMissingError indicates that the IE required is missing.
func (*RequiredIEMissingError) Error ¶ added in v0.6.0
func (e *RequiredIEMissingError) Error() string
x Error returns error with missing IE type.
type RequiredParameterMissingError ¶ added in v0.6.0
type RequiredParameterMissingError struct {
Name, Msg string
}
RequiredParameterMissingError indicates that no Bearer found by lookup methods.
func (*RequiredParameterMissingError) Error ¶ added in v0.6.0
func (e *RequiredParameterMissingError) Error() string
x Error returns missing parameter with message.
type Session ¶
type Session struct { // Subscriber is a Subscriber associated with Session. *Subscriber // contains filtered or unexported fields }
Session is a GTPv2 Session.
func NewSession ¶
func NewSession(peerAddr net.Addr, sub *Subscriber) *Session
NewSession creates a new Session with subscriber information.
This is expected to be used by server-like nodes. Otherwise, use CreateSession(), which sends Create Session Request and returns a new Session.
func (*Session) AddBearer ¶
AddBearer adds a Bearer to Session with arbitrary name given.
In the single-bearer environment it is not used, as a bearer named "default" is always available after created a Session.
func (*Session) AddTEID ¶
AddTEID adds TEID to session with InterfaceType.
This is used to keep TEIDs of any interface types that may be used later, including the ones that are assigned to U-Plane.
For incoming TEID of local interface type, (*Conn).RegisterSession does that instead of users but it is safe to call it.
func (*Session) BearerCount ¶ added in v0.2.0
BearerCount returns the number of bearers registered in Session.
func (*Session) Deactivate ¶
Deactivate marks a Session inactive.
func (*Session) GetDefaultBearer ¶
GetDefaultBearer returns the default bearer.
func (*Session) LookupBearerByEBI ¶
LookupBearerByEBI looks up Bearer registered in Session by EBI.
func (*Session) LookupBearerByName ¶
LookupBearerByName looks up Bearer registered in Session by name.
func (*Session) LookupBearerNameByEBI ¶ added in v0.2.0
LookupBearerNameByEBI looks up name of Bearer by EBI and returns its name.
func (*Session) LookupEBIByName ¶
LookupEBIByName returns EBI associated with name.
If no EBI found, it returns 0(=invalid value for EBI).
func (*Session) LookupEBIByTEID ¶
LookupEBIByTEID returns EBI associated with TEID.
If no EBI found, it returns 0(=invalid value for EBI).
func (*Session) RemoveBearer ¶
RemoveBearer removes a Bearer looked up by name.
func (*Session) RemoveBearerByEBI ¶ added in v0.2.0
RemoveBearerByEBI removes a Bearer looked up by name.
func (*Session) SetDefaultBearer ¶
SetDefaultBearer sets given bearer as the default bearer.
func (*Session) UpdatePeerAddr ¶ added in v0.6.1
UpdatePeerAddr updates the address of the peer node associated with Session.
func (*Session) WaitMessage ¶
WaitMessage waits for a message to come from other Session.
It waits for certain period of time specified by timeout, and returns the message if seq matches the SequenceNumber of message. Otherwise it returns error immediately.
type Subscriber ¶
Subscriber is a subscriber that belongs to a GTPv2 session.
type UnexpectedIEError ¶ added in v0.6.0
type UnexpectedIEError struct {
IEType uint8
}
UnexpectedIEError indicates that the type of incoming message is not expected.
func (*UnexpectedIEError) Error ¶ added in v0.6.0
func (e *UnexpectedIEError) Error() string
x Error returns violating message type.
type UnexpectedTypeError ¶ added in v0.6.0
UnexpectedTypeError indicates that the type of incoming message is not expected.
func (*UnexpectedTypeError) Error ¶ added in v0.6.0
func (e *UnexpectedTypeError) Error() string
x Error returns violating message type.
type UnknownAPNError ¶ added in v0.6.0
type UnknownAPNError struct {
APN string
}
UnknownAPNError indicates that the APN is different from expected one.
func (*UnknownAPNError) Error ¶ added in v0.6.0
func (e *UnknownAPNError) Error() string
x Error returns violating APN.
type UnknownIMSIError ¶ added in v0.6.0
type UnknownIMSIError struct {
IMSI string
}
UnknownIMSIError indicates that the IMSI is different from expected one.
func (*UnknownIMSIError) Error ¶ added in v0.6.0
func (e *UnknownIMSIError) Error() string
x Error returns violating IMSI.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package ies provides encoding/decoding feature of GTPv2 Information Elements.
|
Package ies provides encoding/decoding feature of GTPv2 Information Elements. |
Package messages provides encoding/decoding feature of GTPv2 protocol.
|
Package messages provides encoding/decoding feature of GTPv2 protocol. |
Package testutils is an internal package to be used for unit tests.
|
Package testutils is an internal package to be used for unit tests. |