Documentation ¶
Index ¶
- Constants
- func ConvertAVPDataToTypedData(avpData []byte, dataType AVPDataType) (interface{}, error)
- type AVP
- func DecodeAVP(input []byte) (*AVP, error)
- func NewAVP(code uint32, VendorID uint32, mandatory bool, data []byte) *AVP
- func NewTypedAVP(code uint32, vendorID uint32, mandatory bool, avpType AVPDataType, ...) *AVP
- func NewTypedAVPErrorable(code uint32, vendorID uint32, mandatory bool, avpType AVPDataType, ...) (*AVP, error)
- type AVPDataType
- type AVPExtendedAttributes
- type CapabiltiesExchangeInformation
- type Dictionary
- func (dictionary *Dictionary) AVP(name string, value interface{}) *AVP
- func (dictionary *Dictionary) AVPErrorable(name string, value interface{}) (*AVP, error)
- func (dictionary *Dictionary) DataTypeForAVPNamed(name string) (AVPDataType, error)
- func (dictionary *Dictionary) Message(name string, flags MessageFlags, mandatoryAVPs []*AVP, additionalAVPs []*AVP) *Message
- func (dictionary *Dictionary) MessageErrorable(name string, flags MessageFlags, mandatoryAVPs []*AVP, additionalAVPs []*AVP) (*Message, error)
- type DictionaryYaml
- type DictionaryYamlAvpEnumerationType
- type DictionaryYamlAvpType
- type DictionaryYamlMessageAbbreviation
- type DictionaryYamlMessageType
- type DictionaryYamlMetadataSpecificationType
- type DictionaryYamlMetadataType
- type IncomingPeerListener
- type Message
- func (m *Message) BecomeAnAnswerBasedOnTheRequestMessage(request *Message) *Message
- func (m *Message) Clone() *Message
- func (m *Message) Encode() []byte
- func (m *Message) Equals(c *Message) bool
- func (m *Message) FindFirstAVPByCode(code Uint24) *AVP
- func (m *Message) IsError() bool
- func (m *Message) IsPotentiallyRetransmitted() bool
- func (m *Message) IsProxiable() bool
- func (m *Message) IsRequest() bool
- type MessageByteReader
- type MessageFlags
- type MessageStreamReader
- type Node
- func (node *Node) AddListener(listener *NodeListener) *Node
- func (node *Node) AddListeners(listeners []*NodeListener) *Node
- func (node *Node) AutomaticallyDisconnectAnyPeerThatSendsDisconnectRequest() *Node
- func (node *Node) AutomaticallyDisconnectPeerWhenPeerSendsDisconnectRequest(peer *Peer) error
- func (node *Node) ChangeDefaultOutboundCapabilitiesInformationTo(defaultInformation CapabiltiesExchangeInformation) *Node
- func (node *Node) ConnectToPeer(usingConnection net.Conn) (*Peer, error)
- func (node *Node) ConnectToPeerAsynchronously(usingConnection net.Conn)
- func (node *Node) ConnectToPeerUsingCapabilities(usingConnection net.Conn, information CapabiltiesExchangeInformation) (*Peer, error)
- func (node *Node) ConnectToPeerUsingCapabilitiesAsynchronously(usingConnection net.Conn, information CapabiltiesExchangeInformation)
- func (node *Node) DisconnectAllPeerFlowsAsynchronously()
- func (node *Node) DisconnectAllPeerFlowsWithCustomInformation(disconnectCauseValue uint32, additionalAVPs []*AVP) []PeerSpecificError
- func (node *Node) DisconnectAllPeerFlowsWithCustomInformationAsynchronously(disconnectCauseValue uint32, additionalAVPs []*AVP)
- func (node *Node) DisconnectFromAllPeerFlows() []PeerSpecificError
- func (node *Node) DisconnectFromPeer(peer *Peer) error
- func (node *Node) DisconnectFromPeerAsynchronously(peer *Peer)
- func (node *Node) DisconnectFromPeerWithCustomInformation(peer *Peer, disconnectCauseValue uint32, additionalAVPs []*AVP) error
- func (node *Node) DisconnectFromPeerWithCustomInformationAsynchronously(peer *Peer, disconnectCauseValue uint32, additionalAVPs []*AVP)
- func (node *Node) FilterOutStateMessages() *Node
- func (node *Node) Start() chan<- *NodeEvent
- func (node *Node) StopAllListeners() error
- func (node *Node) StopListener(listener *NodeListener) error
- func (node *Node) UnfilterStateMessages() *Node
- type NodeEvent
- type NodeEventType
- type NodeListener
- type Peer
- type PeerConnectionInformation
- type PeerFlowInformation
- type PeerHandler
- func (handler *PeerHandler) CloseDiameterFlow() error
- func (handler *PeerHandler) SeedIdentifiers() (*PeerHandler, error)
- func (handler *PeerHandler) SendMessageToPeer(message *Message) error
- func (handler *PeerHandler) StartHandling()
- func (handler *PeerHandler) Terminate() error
- func (handler *PeerHandler) WithCapabilities(capabilities *CapabiltiesExchangeInformation) *PeerHandler
- func (handler *PeerHandler) WithSeededIdentifiers() (*PeerHandler, error)
- type PeerSpecificError
- type PeerType
- type Uint24
Constants ¶
const ( MsgFlagRequest = 0x80 MsgFlagProxiable = 0x40 MsgFlagError = 0x20 MsgFlagPotentialRetransmit = 0x10 MsgHeaderSize = Uint24(20) )
Possible flag values for a Diameter message
Variables ¶
This section is empty.
Functions ¶
func ConvertAVPDataToTypedData ¶
func ConvertAVPDataToTypedData(avpData []byte, dataType AVPDataType) (interface{}, error)
ConvertAVPDataToTypedData attempts to convert the provided AVP data into a typed value, according to the data type provided.
Types ¶
type AVP ¶
type AVP struct { Code uint32 VendorSpecific bool Mandatory bool Protected bool VendorID uint32 Data []byte Length int PaddedLength int ExtendedAttributes *AVPExtendedAttributes }
AVP represents a Diameter Message AVP
func DecodeAVP ¶
DecodeAVP accepts a byte stream in network byte order and produces an AVP object from it.
func NewTypedAVP ¶
func NewTypedAVP(code uint32, vendorID uint32, mandatory bool, avpType AVPDataType, value interface{}) *AVP
NewTypedAVP is the same as NewTypedAVPErrorable, except that it raises panic() on an error
func NewTypedAVPErrorable ¶
func NewTypedAVPErrorable(code uint32, vendorID uint32, mandatory bool, avpType AVPDataType, value interface{}) (*AVP, error)
NewTypedAVPErrorable is an AVP constructor provided typed data rather than the raw data. Returns an error if the value is not convertible from the avpType. The ExtendedAttributes will be set, but the Name will be the empty string
func (*AVP) Clone ¶
Clone makes a copy of this AVP and returns it. No effort is made to make the copy thread-safe.
func (*AVP) ConvertDataToTypedData ¶
func (avp *AVP) ConvertDataToTypedData(dataType AVPDataType) (interface{}, error)
ConvertDataToTypedData overrides any internally stored typed data representation for the AVP and attempts to convert the raw data into the named type.
func (*AVP) Equal ¶
Equal compares the current AVP to another AVP to determine if they are byte-wise identical (that is, if they would map identically as a byte stream using Encode)
func (*AVP) MakeProtected ¶
MakeProtected sets avp.Protected to true and returns the AVP reference. It is so rare for this flag to be set, this provides a convenient method to set the value inline after AVP creation
type AVPDataType ¶
type AVPDataType int
AVPDataType is an enumeration of Diameter AVP types
const ( // Unsigned32 indicates AVP type for unsigned 32-bit integer Unsigned32 AVPDataType = 1 + iota // Unsigned64 indicates AVP type for unsigned 64-bit integer Unsigned64 // Integer32 indicates AVP type for signed 32-bit integer Integer32 // Integer64 indicates AVP type for signed 64-bit integer Integer64 // Float32 indicates AVP type for signed 32-bit floating point Float32 // Float64 indicates AVP type for signed 64-bit floating point Float64 // Enumerated indicates AVP type for enumerated (integer) Enumerated // UTF8String indicates AVP type for UTF8String (a UTF8 encoded octet stream) UTF8String // OctetString indicates AVP type for octet string (an arbitrary octet stream) OctetString // Time indicates AVP type for time (unix epoch time as unsigned 32) Time // Address indicates AVP type for address (an IPv4 or IPv6 address with leading type qualifier) Address // DiamIdent indicates AVP type for diameter identity (an octet stream) DiamIdent // DiamURI indicates AVP type for a diameter URI (an octet stream) DiamURI // Grouped indicates AVP type for grouped (a set of AVPs) Grouped // IPFilterRule indicates AVP type for IP Filter Rule IPFilterRule // TypeOrAvpUnknown is used when a query is made for an unknown AVP or the dictionary // contains an unknown type TypeOrAvpUnknown )
type AVPExtendedAttributes ¶
type AVPExtendedAttributes struct { Name string DataType AVPDataType TypedValue interface{} }
AVPExtendedAttributes includes extended AVP attributes that can be provided by, for example, a dictionary. It includes a human-friendly name and a typed value (e.g., a uint32 for AVPs of Unsigned32 type)
type CapabiltiesExchangeInformation ¶
type CapabiltiesExchangeInformation struct { OriginHost string OriginRealm string HostIPAddresses []*net.IPAddr VendorID uint32 ProductName string AdditionalAVPsToSendToPeer []*AVP }
CapabiltiesExchangeInformation contains information sent to peer nodes during the capabilities exchange, or received from peer nodes during the capabilities exchange
func (*CapabiltiesExchangeInformation) MakeCEA ¶
func (info *CapabiltiesExchangeInformation) MakeCEA() *Message
MakeCEA is shorthand for MakeCeaUsingResultCode(2002).
func (*CapabiltiesExchangeInformation) MakeCEAUsingResultCode ¶
func (info *CapabiltiesExchangeInformation) MakeCEAUsingResultCode(resultCode uint32) *Message
MakeCEAUsingResultCode makes a CEA using the exchange information values, with a Result-Code set to the provided value.
func (*CapabiltiesExchangeInformation) MakeCER ¶
func (info *CapabiltiesExchangeInformation) MakeCER() *Message
MakeCER creates a CER using the exchange information values.
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
Dictionary is a Diameter dictionary, mapping AVP and message type data to names
func DictionaryFromYamlFile ¶
func DictionaryFromYamlFile(filepath string) (*Dictionary, error)
DictionaryFromYamlFile processes a file that should be a YAML formatted Diameter dictionary
func DictionaryFromYamlString ¶
func DictionaryFromYamlString(yamlString string) (*Dictionary, error)
DictionaryFromYamlString reads a string containing a Diameter dictionary in YAML format
func (*Dictionary) AVP ¶
func (dictionary *Dictionary) AVP(name string, value interface{}) *AVP
AVP is the same as AVPErrorable, except that, if an error occurs, panic() is invoked with the error string
func (*Dictionary) AVPErrorable ¶
func (dictionary *Dictionary) AVPErrorable(name string, value interface{}) (*AVP, error)
AVPErrorable returns an AVP based on the dictionary definition. If the name is not in the dictionary, or the value type is incorrect based on the dictionary definition, return an error. This is Errorable because it may throw an error. It is assumed that this will be the uncommon case, because ordinarily, the value will be known in advance by the application creating it.
func (*Dictionary) DataTypeForAVPNamed ¶
func (dictionary *Dictionary) DataTypeForAVPNamed(name string) (AVPDataType, error)
DataTypeForAVPNamed looks up the data type for the specific AVP
func (*Dictionary) Message ¶
func (dictionary *Dictionary) Message(name string, flags MessageFlags, mandatoryAVPs []*AVP, additionalAVPs []*AVP) *Message
Message is the same as MessageErrorable, except that, if an error occurs, panic() is invoked with the error string
func (*Dictionary) MessageErrorable ¶
func (dictionary *Dictionary) MessageErrorable(name string, flags MessageFlags, mandatoryAVPs []*AVP, additionalAVPs []*AVP) (*Message, error)
MessageErrorable returns a Message based on the dictionary definition. If the name is not present in the dictionary, an error is returned. The AVP set will be re-arranged to match the AVP order presented in the dictionary for the message type, and the mandatory flag will be changed to match the definition for the message type. An error, however, is not raised if a mandatory flag is not present.
type DictionaryYaml ¶
type DictionaryYaml struct { AvpTypes []DictionaryYamlAvpType `yaml:"AvpTypes"` MessageTypes []DictionaryYamlMessageType `yaml:"MessageTypes"` }
DictionaryYaml represents a YAML dictionary containing Diameter message type and AVP definitions
type DictionaryYamlAvpEnumerationType ¶
type DictionaryYamlAvpEnumerationType struct { Name string `yaml:"Name"` Value uint32 `yaml:"Value"` }
DictionaryYamlAvpEnumerationType is the type for Avp Enumerations
type DictionaryYamlAvpType ¶
type DictionaryYamlAvpType struct { Name string `yaml:"Name"` Code uint32 `yaml:"Code"` Type string `yaml:"Type"` VendorID uint32 `yaml:"Vendor-Id"` Enumeration []DictionaryYamlAvpEnumerationType `yaml:"Enumeration"` }
DictionaryYamlAvpType is the type for AvpTypes in a Diameter YAML Dictionary
type DictionaryYamlMessageAbbreviation ¶
type DictionaryYamlMessageAbbreviation struct { Request string `yaml:"Request"` Answer string `yaml:"Answer"` }
DictionaryYamlMessageAbbreviation is the type for MessageTypes.Abbreviations in a Diameter YAML Dictionary
type DictionaryYamlMessageType ¶
type DictionaryYamlMessageType struct { Basename string `yaml:"Basename"` Code uint32 `yaml:"Code"` ApplicationID uint32 `yaml:"Application-Id"` Abbreviations DictionaryYamlMessageAbbreviation `yaml:"Abbreviations"` }
DictionaryYamlMessageType is the type for MessageTypes in a Diameter YAML Dictionary
type DictionaryYamlMetadataSpecificationType ¶
type DictionaryYamlMetadataSpecificationType struct { Type string `yaml:"Type"` Identifier string `yaml:"Identifier"` URL string `yaml:"URL"` }
DictionaryYamlMetadataSpecificationType is the type for a dictionary yaml field Metadata section
type DictionaryYamlMetadataType ¶
type DictionaryYamlMetadataType struct { Name string `yaml:"Name"` Specifications []DictionaryYamlMetadataSpecificationType `yaml:"Specifications"` }
DictionaryYamlMetadataType is the type for a dictionary yaml Metadata section Specification subsection
type IncomingPeerListener ¶
type IncomingPeerListener struct {
// contains filtered or unexported fields
}
func NewIncomingPeerListener ¶
func NewIncomingPeerListener(usingUnderlyingListener net.Listener, usingCapabilitiesInformation CapabiltiesExchangeInformation) *IncomingPeerListener
func (*IncomingPeerListener) StartListening ¶
func (peerListener *IncomingPeerListener) StartListening(eventChannel chan<- *NodeEvent)
func (*IncomingPeerListener) StopListening ¶
func (peerListener *IncomingPeerListener) StopListening() error
type Message ¶
type Message struct { Version uint8 Length Uint24 Flags uint8 Code Uint24 AppID uint32 HopByHopID uint32 EndToEndID uint32 Avps []*AVP }
Message represents a single Diameter message
func DecodeMessage ¶
DecodeMessage accepts an octet stream and attempts to interpret it as a Diameter message. The stream must contain at least a single Diameter message. To decode incoming streams, use a MessageStreamReader. If the input stream is at least one Diameter message, or an error occurs in the reading of the stream or creation of the message, return nil and an error; otherwise return a Message object and nil for the error.
func NewMessage ¶
func NewMessage(flags uint8, code Uint24, appID uint32, hopByHopID uint32, endToEndID uint32, mandatoryAvps []*AVP, additionalAvps []*AVP) (m *Message)
NewMessage creates a new diameter.Message instance. 'mandatoryAvps' will all have their Mandatory flag set to true. The Mandatory flag for 'additionalAvps' will be left untouched.
func (*Message) BecomeAnAnswerBasedOnTheRequestMessage ¶
BecomeAnAnswerBasedOnTheRequestMessage extracts the end-to-end-id and hop-by-hop-id from the request message and applies them to this message. It also clears the request flag if it is set and sets this message's code to the request message's code. Return this message, so that this call may be chained, if desired.
func (*Message) Clone ¶
Clone makes a copy of the current message. No effort is made to be thread-safe against changes to the message being cloned. All AVPs in this message are also cloned.
func (*Message) Encode ¶
Encode transforms the current message into an octet stream appropriate for network transmission
func (*Message) Equals ¶
Equals compares the current Message object to a different message object. If they have equivalent values for all fields and AVPs, return true; otherwise return false. AVPs are compared exactly in order.
func (*Message) FindFirstAVPByCode ¶
FindFirstAVPByCode returns the first instance of the identified AVP associated with the current Message, or nil if the Message has no instances of the AVP
func (*Message) IsError ¶
IsError returns true if the message is a Diameter erro9r message (that is, the error flag in the Diameter message header is set)
func (*Message) IsPotentiallyRetransmitted ¶
IsPotentiallyRetransmitted returns true if the potentially retransmit flag in the Diameter message header is set
func (*Message) IsProxiable ¶
IsProxiable returns true if the proxiable flag in the Diameter message header is set
type MessageByteReader ¶
type MessageByteReader struct {
// contains filtered or unexported fields
}
MessageByteReader simplifies the reading of an octet stream which must be converted to one or more diameter.Message objects. Generally, a new MessageByteReader is created, then ReceiveBytes() is repeatedly called on an input stream (which must be in network byte order) as bytes arrive. This method will return diameter.Message objects as they can be extracted, and store any bytes that are left over after message conversion
func NewMessageByteReader ¶
func NewMessageByteReader() *MessageByteReader
NewMessageByteReader creates a new MessageStreamReader object
func (*MessageByteReader) ReceiveBytes ¶
func (reader *MessageByteReader) ReceiveBytes(incoming []byte) ([]*Message, error)
ReceiveBytes returns one or more diameter.Message objects read from the incoming byte stream. Return nil if no Message is yet found. Return error on malformed byte stream. If an error is returned, subsequent calls are no longer reliable.
func (*MessageByteReader) ReceiveBytesButReturnAtMostOneMessage ¶
func (reader *MessageByteReader) ReceiveBytesButReturnAtMostOneMessage(incoming []byte) (*Message, error)
ReceiveBytesButReturnAtMostOneMessage is the same as ReceiveBytes(), but it will return no more than one message. If more than one message is available in the internal buffer plus the incoming bytes, all messages after the first are saved in the internal buffer, which means they'll be returned on the next call to ReceiveBytes().
type MessageFlags ¶
MessageFlags provides the Diameter Message flag types
type MessageStreamReader ¶
type MessageStreamReader struct {
// contains filtered or unexported fields
}
MessageStreamReader is the same as MessageByteReader, but instead of being passed bytes repeatedly, it is supplied an io.Reader, and reads from that, blocking until messages are found on each call to ReadNextMessage().
func NewMessageStreamReader ¶
func NewMessageStreamReader(usingReader io.Reader) *MessageStreamReader
NewMessageStreamReader creates an empty reader which will use the provided io.Reader for each call to ReadNextMessage().
func (*MessageStreamReader) ReadNextMessage ¶
func (reader *MessageStreamReader) ReadNextMessage() (*Message, error)
ReadNextMessage will repeatedly perform a Read() on the underlying Reader until a message is found. It will then queue any additional bytes after the returned message. If that internal byte buffer contains a complete message, a subsequent call will return that message and buffer again any left over bytes. This will continue until the internal buffer no longer contains a complete message, at which point, another Read() will occur. The returned error may be io.EOF. In this case, the returned message will still be nil.
func (*MessageStreamReader) ReadOnce ¶
func (reader *MessageStreamReader) ReadOnce() (*Message, error)
ReadOnce does the same as ReadNextMessage(), but it will perform no more than a single Read() on the underlying Reader. If the Read() (plus any internal buffer) does not yield a complete message, this will return. In that case, the returned Message and error will both be nil.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is an entity that implements the Diameter base protocol state machine for Peer node flows. It can both listen for incoming flows and initiate outbound flows.
func NewNode ¶
func NewNode(defaultCapabilitiesExchangeAssertion CapabiltiesExchangeInformation) *Node
NewNode creates a new Diameter node. The provided default capabilities exchange assertion will be used in any capabilities exchange request if it is not overridden when the request for the outbound connection to a peer is made.
func (*Node) AddListener ¶
func (node *Node) AddListener(listener *NodeListener) *Node
AddListener adds a listener and the capabilities exchange assertion that should be used when a new incoming flow is initiated to the listener and a CER is received on that flow. Returns the node on which the operation is being applied so that it can be chained with other calls, if desired.
func (*Node) AddListeners ¶
func (node *Node) AddListeners(listeners []*NodeListener) *Node
AddListeners is the same as AddListener() but adds multiple listeners at the same time.
func (*Node) AutomaticallyDisconnectAnyPeerThatSendsDisconnectRequest ¶
AutomaticallyDisconnectAnyPeerThatSendsDisconnectRequest signals that when a DPR is received on a previously accepted flow for any peer, a DPA should be automatically sent. Normally, this is done manually when the PeerSentDisconnectRequest is received.
func (*Node) AutomaticallyDisconnectPeerWhenPeerSendsDisconnectRequest ¶
AutomaticallyDisconnectPeerWhenPeerSendsDisconnectRequest signals that when a DPR is received on a previously accepted flow for the identified peer, a DPA should be automatically sent. Normally, this is done manually when the PeerSentDisconnectRequest is received.
func (*Node) ChangeDefaultOutboundCapabilitiesInformationTo ¶
func (node *Node) ChangeDefaultOutboundCapabilitiesInformationTo(defaultInformation CapabiltiesExchangeInformation) *Node
ChangeDefaultOutboundCapabilitiesInformationTo changes the default information asserted in the capabilities exchange request sent by this node when it initiates an outbound flow.
func (*Node) ConnectToPeer ¶
ConnectToPeer synchronously attempts to complete a capabilities exchange over the provided connection. Returns a Peer object on success, or an error on failure.
func (*Node) ConnectToPeerAsynchronously ¶
ConnectToPeerAsynchronously is the same as ConnectToPeer(), but does so asynchronously. It launches a goroutine then immediately returns. The attempt will generate generate events.
func (*Node) ConnectToPeerUsingCapabilities ¶
func (node *Node) ConnectToPeerUsingCapabilities(usingConnection net.Conn, information CapabiltiesExchangeInformation) (*Peer, error)
ConnectToPeerUsingCapabilities is the same as ConnectToPeer(), but instead of using the default outgoing capabilities assertion, it uses the provided information.
func (*Node) ConnectToPeerUsingCapabilitiesAsynchronously ¶
func (node *Node) ConnectToPeerUsingCapabilitiesAsynchronously(usingConnection net.Conn, information CapabiltiesExchangeInformation)
ConnectToPeerUsingCapabilitiesAsynchronously is the same as ConnectToPeerAsynchronously(), but rather than using the default outgoing capabilities assertion, it uses the provided information.
func (*Node) DisconnectAllPeerFlowsAsynchronously ¶
func (node *Node) DisconnectAllPeerFlowsAsynchronously()
DisconnectAllPeerFlowsAsynchronously does the same as DisconnectFromAllPeerFlows(), but does so asynchronously. It launches a goroutine then immediately returns. The attempt will generate events.
func (*Node) DisconnectAllPeerFlowsWithCustomInformation ¶
func (node *Node) DisconnectAllPeerFlowsWithCustomInformation(disconnectCauseValue uint32, additionalAVPs []*AVP) []PeerSpecificError
DisconnectAllPeerFlowsWithCustomInformation does the same as DisconnectFromAllPeerFlows(), but sends the provided Disconnect-Cause value (the caller is responsible for ensuring that the value is valid for the Disconnect-Cause enumeration) and any desired additional AVPs in the DPR.
func (*Node) DisconnectAllPeerFlowsWithCustomInformationAsynchronously ¶
func (node *Node) DisconnectAllPeerFlowsWithCustomInformationAsynchronously(disconnectCauseValue uint32, additionalAVPs []*AVP)
DisconnectAllPeerFlowsWithCustomInformationAsynchronously does the same as DisconnectFromAllPeerFlowsWithCustomInformation but does so asynchronously. It launches a goroutine then immediately returns. The attempt will generate events.
func (*Node) DisconnectFromAllPeerFlows ¶
func (node *Node) DisconnectFromAllPeerFlows() []PeerSpecificError
DisconnectFromAllPeerFlows attempts to disconnect all peer flows by sending a DPR to each. It will send DO_NOT_WANT_TO_TALK_TO_YOU as the Disconnect-Reason. It also attempts to close the underlying connection. If an error occurs for a flow, it still attempts to continue. Returns the accumulated set of errors, as well as Peer connected to flow on which the error occurred. Returns nil if no error occurred.
func (*Node) DisconnectFromPeer ¶
DisconnectFromPeer sends a DPR toward the named Peer. There are two cases where this is valid: 1. to initiate a disconnect (i.e., signaling that the node should send a DPR); and 2. after a DPR is received by a Peer (and thus, this would be called after receiving the event PeerSentDisconnectRequest). If this is for case 1 (node sends DPR), then the node will set the Disconnect-Cause to DO_NOT_WANT_TO_TALK_TO_YOU. If this is case 1 (nodes sends DPR), then on the receipt of a DPA, the node will attempt to close the underlying connection. If this is for case 2 (responding to DPR with a DPA), the ndoe will send the DPA then attempt to close the underlying connection.
func (*Node) DisconnectFromPeerAsynchronously ¶
DisconnectFromPeerAsynchronously does the same as DisconnectFromPeer(), but does so asynchronously. It launches a goroutine then immediately returns. The attempt will generate events.
func (*Node) DisconnectFromPeerWithCustomInformation ¶
func (node *Node) DisconnectFromPeerWithCustomInformation(peer *Peer, disconnectCauseValue uint32, additionalAVPs []*AVP) error
DisconnectFromPeerWithCustomInformation is the same as DisconnectFromPeer() but it sends for the Disconnect-Cause the provided value (it is up to the caller to ensure that it is a valid value for the Disconnect-Cause enumeration type), and sends any provided additional AVPs.
func (*Node) DisconnectFromPeerWithCustomInformationAsynchronously ¶
func (node *Node) DisconnectFromPeerWithCustomInformationAsynchronously(peer *Peer, disconnectCauseValue uint32, additionalAVPs []*AVP)
DisconnectFromPeerWithCustomInformationAsynchronously does the same as DisconnectFromPeerWithCustomInformation(), but does so asynchronously. It launches a goroutine then immediately returns. The attempt will generate events.
func (*Node) FilterOutStateMessages ¶
FilterOutStateMessages signals that Capabilities-Exchange, Diameter-Watchdog and Disconnect-Peer messages should not be included in the event stream. This is the default behavior.
func (*Node) Start ¶
Start starts the node. It returns a channel of events that are produced by this node.
func (*Node) StopAllListeners ¶
StopAllListeners stops all listener from listening. It does not close any flows initiated through the listeners. This is a synchronous action.
func (*Node) StopListener ¶
func (node *Node) StopListener(listener *NodeListener) error
StopListener stops a listener from listening. It does not close any flows initiated through the listener. This is a synchronous action.
func (*Node) UnfilterStateMessages ¶
UnfilterStateMessages signals that Capabilities-Exchange, Diameter-Watchdog and Disconnect-Peer messages that are received should be included in the event stream. By default, messages of this type are supressed.
type NodeEvent ¶
type NodeEvent struct { Type NodeEventType Peer *Peer Connection net.Conn Message *Message Error error }
NodeEvent is an event related to the node's operation.
type NodeEventType ¶
type NodeEventType int
NodeEventType describes the types of events that are raised in relationship to a node's operation.
const ( FatalTransportError NodeEventType = -1 RecoverableTransportError NodeEventType = -2 MessageDeliveryError NodeEventType = -3 CapabilitiesExchangeFailed NodeEventType = -4 WatchdogTimeoutExceeded NodeEventType = -5 IncomingTransportAttemptBlocked NodeEventType = -6 IncomingPeerBlockedOnCapbilitiesExchange NodeEventType = -7 TimedOutConnectingToPeer NodeEventType = -8 ListenerFailed NodeEventType = -9 DuplicationPeerFlowRejected NodeEventType = -10 UnableToParseIncomingMessageStream NodeEventType = -11 InternalFailure NodeEventType = -12 CapabilitiesExchangeSuccessfullyCompleted NodeEventType = 1 CapabilitiesRequestReceivedFromPeer NodeEventType = 2 ReceivedDiameterMessageFromPeer NodeEventType = 3 SuccessfullyDeliveredDiameterMessageToPeer NodeEventType = 4 PeerSentDisconnectRequest NodeEventType = 5 PeerFullyDisconnected NodeEventType = 6 ReceivedCapabilitiesExchangeRequest NodeEventType = 7 ReceivedWatchdogRequest NodeEventType = 8 WatchdogSuccessful NodeEventType = 9 TransportClosed NodeEventType = 10 )
type NodeListener ¶
type NodeListener struct {
// contains filtered or unexported fields
}
NodeListener contains information describing a listener for incoming peer flows
func NewNodeListener ¶
func NewNodeListener(listener net.Listener, informationAssertedInCapabilitiesAnswer *CapabiltiesExchangeInformation) *NodeListener
NewNodeListener creates attaches a listener to the node, and provides information that should be asserted to any incoming peer when the peer initiates a flow against the listener.
type Peer ¶
type Peer struct { TypeOfPeer PeerType PeerCapabilitiesInformation *CapabiltiesExchangeInformation ConnectionInformation PeerConnectionInformation }
type PeerFlowInformation ¶
type PeerFlowInformation struct { PeerAddress *net.IPAddr PeerPort uint16 MyAddress *net.IPAddr MyPort uint16 TransportProtocol string // "tcp" or "sctp" }
PeerFlowInformation contains information for an active connection flow with a peer node.
type PeerHandler ¶
type PeerHandler struct {
// contains filtered or unexported fields
}
func NewHandlerForInitiatorPeer ¶
func NewHandlerForInitiatorPeer(flowConnection net.Conn, eventChannel chan<- *NodeEvent) *PeerHandler
func NewHandlerForResponderPeer ¶
func NewHandlerForResponderPeer(flowConnection net.Conn, eventChannel chan<- *NodeEvent) *PeerHandler
func (*PeerHandler) CloseDiameterFlow ¶
func (handler *PeerHandler) CloseDiameterFlow() error
func (*PeerHandler) SeedIdentifiers ¶
func (handler *PeerHandler) SeedIdentifiers() (*PeerHandler, error)
func (*PeerHandler) SendMessageToPeer ¶
func (handler *PeerHandler) SendMessageToPeer(message *Message) error
func (*PeerHandler) StartHandling ¶
func (handler *PeerHandler) StartHandling()
func (*PeerHandler) Terminate ¶
func (handler *PeerHandler) Terminate() error
func (*PeerHandler) WithCapabilities ¶
func (handler *PeerHandler) WithCapabilities(capabilities *CapabiltiesExchangeInformation) *PeerHandler
func (*PeerHandler) WithSeededIdentifiers ¶
func (handler *PeerHandler) WithSeededIdentifiers() (*PeerHandler, error)
type PeerSpecificError ¶
PeerSpecificError connects an error to a specific peer.