Documentation ¶
Index ¶
- Constants
- Variables
- func CountRxCode(c uint32)
- func CountTxCode(c uint32)
- func GetAuthAppID(a AVP) (v uint32, e error)
- func GetAuthSessionState(a AVP) (v bool, e error)
- func GetErrorMessage(a AVP) (v string, e error)
- func GetResultCode(a AVP) (c uint32, e error)
- func GetSessionID(a AVP) (v string, e error)
- func GetUserName(a AVP) (v string, e error)
- func GetVendorID(a AVP) (v uint32, e error)
- func GetVendorSpecAppID(a AVP) (vi, ai uint32, e error)
- func NextSession(h string) string
- type AVP
- func GetFailedAVP(a AVP) (v []AVP, e error)
- func SetAuthAppID(v uint32) (a AVP)
- func SetAuthSessionState(v bool) (a AVP)
- func SetDestinationHost(v Identity) (a AVP)
- func SetDestinationRealm(v Identity) (a AVP)
- func SetErrorMessage(v string) (a AVP)
- func SetFailedAVP(v []AVP) (a AVP)
- func SetGenericAVP(c, v uint32, m bool, b interface{}) AVP
- func SetOriginHost(v Identity) (a AVP)
- func SetOriginRealm(v Identity) (a AVP)
- func SetResultCode(c uint32) (a AVP)
- func SetRouteRecord(v Identity) (a AVP)
- func SetSessionID(v string) (a AVP)
- func SetUserName(v string) (a AVP)
- func SetVendorID(v uint32) (a AVP)
- func SetVendorSpecAppID(vi, ai uint32) (a AVP)
- type Connection
- func (c *Connection) Close(cause Enumerated)
- func (c *Connection) DefaultTxHandler(m Message) Message
- func (c *Connection) DialAndServe(con net.Conn) (e error)
- func (c *Connection) ListenAndServe(con net.Conn) (e error)
- func (c *Connection) LocalAddr() net.Addr
- func (c *Connection) PeerAddr() net.Addr
- func (c *Connection) RxQueue() int
- func (c *Connection) State() string
- func (c *Connection) TxQueue() int
- type Direction
- type Enumerated
- type FailureAnswer
- type Handler
- type IPFilterRule
- type Identity
- func GetDestinationHost(a AVP) (v Identity, e error)
- func GetDestinationRealm(a AVP) (v Identity, e error)
- func GetOriginHost(a AVP) (v Identity, e error)
- func GetOriginRealm(a AVP) (v Identity, e error)
- func GetRouteRecord(a AVP) (v Identity, e error)
- func ParseIdentity(str string) (id Identity, err error)
- type InvalidAVP
- type InvalidMessage
- type Message
- type Router
- type URI
Constants ¶
const ( MultiRoundAuth uint32 = 1001 // MultiRoundAuth is Result-Code 1001 Success uint32 = 2001 // Success is Result-Code 2001 LimitedSuccess uint32 = 2002 // LimitedSuccess is Result-Code 2002 CommandUnspported uint32 = 3001 // CommandUnspported is Result-Code 3001 UnableToDeliver uint32 = 3002 // UnableToDeliver is Result-Code 3002 RealmNotServed uint32 = 3003 // RealmNotServed is Result-Code 3003 TooBusy uint32 = 3004 // TooBusy is Result-Code 3004 LoopDetected uint32 = 3005 // LoopDetected is Result-Code 3005 RedirectIndication uint32 = 3006 // RedirectIndication is Result-Code 3006 ApplicationUnsupported uint32 = 3007 // ApplicationUnsupported is Result-Code 3007 InvalidHdrBits uint32 = 3008 // InvalidHdrBits is Result-Code 3008 InvalidAvpBits uint32 = 3009 // InvalidAvpBits is Result-Code 3009 UnknownPeer uint32 = 3010 // UnknownPeer is Result-Code 3010 AuthenticationRejected uint32 = 4001 // AuthenticationRejected is Result-Code 4001 OutOfSpace uint32 = 4002 // OutOfSpace is Result-Code 4002 ElectionLost uint32 = 4003 // ElectionLost is Result-Code 4003 AvpUnsupported uint32 = 5001 // AvpUnsupported is Result-Code 5001 UnknownSessionID uint32 = 5002 // UnknownSessionID is Result-Code 5002 AuthorizationRejected uint32 = 5003 // AuthorizationRejected is Result-Code 5003 InvalidAvpValue uint32 = 5004 // InvalidAvpValue is Result-Code 5004 MissingAvp uint32 = 5005 // MissingAvp is Result-Code 5005 ResourcesExceeded uint32 = 5006 // ResourcesExceeded is Result-Code 5006 ContradictingAvps uint32 = 5007 // ContradictingAvps is Result-Code 5007 AvpNotAllowed uint32 = 5008 // AvpNotAllowed is Result-Code 5008 AvpOccursTooManyTimes uint32 = 5009 // AvpOccursTooManyTimes is Result-Code 5009 NoCommonApplication uint32 = 5010 // NoCommonApplication is Result-Code 5010 UnsupportedVersion uint32 = 5011 // UnsupportedVersion is Result-Code 5011 UnableToComply uint32 = 5012 // UnableToComply is Result-Code 5012 InvalidBitInHeader uint32 = 5013 // InvalidBitInHeader is Result-Code 5013 InvalidAvpLength uint32 = 5014 // InvalidAvpLength is Result-Code 5014 InvalidMessageLength uint32 = 5015 // InvalidMessageLength is Result-Code 5015 InvalidAvpBitCombo uint32 = 5016 // InvalidAvpBitCombo is Result-Code 5016 NoCommonSecurity uint32 = 5017 // NoCommonSecurity is Result-Code 5017 )
const ( VendorID uint32 = 41102 // VendorID of this code ProductName = "round-robin" // ProductName of this code FirmwareRev uint32 = 230619001 // FirmwareRev of this code )
Variables ¶
var ( WDInterval = time.Second * 30 // WDInterval is watchdog send interval time WDMaxSend = 3 // WDMaxSend is watchdog expired count Host Identity // Local diameter hostname Realm Identity // Local diameter realm OverwriteAddr []net.IP // Overwrite IP addresses of local host in CER )
var ( // TraceMessage is called when Diameter message is receved or sent. // Inputs are handled message, message direction and occured error while message handling. TraceMessage func(Message, Direction, error) // TraceEvent is called on event. // Inputs are old state, new state, event name and occured error while event handling. TraceEvent func(string, string, string, error) // ConnectionUpNotify is called when Diameter connection up. ConnectionUpNotify func(*Connection) // ConnectionDownNotify is called when Diameter connection down. ConnectionDownNotify func(*Connection) // ConnectionAbortNotify is called when Diameter connection abort. ConnectionAbortNotify func(*Connection) )
var ( // Statistics values RxReq uint64 RejectReq uint64 TxAnsFail uint64 Tx1xxx uint64 Tx2xxx uint64 Tx3xxx uint64 Tx4xxx uint64 Tx5xxx uint64 TxEtc uint64 TxReq uint64 InvalidAns uint64 Rx1xxx uint64 Rx2xxx uint64 Rx3xxx uint64 Rx4xxx uint64 Rx5xxx uint64 RxEtc uint64 )
var DefaultRxHandler func(Message) Message = func(m Message) Message { return m.generateAnswerBy(UnableToDeliver) }
DefaultRxHandler for receiving Diameter request message without Handler or ralay application.
Functions ¶
func CountRxCode ¶
func CountRxCode(c uint32)
func CountTxCode ¶
func CountTxCode(c uint32)
func GetAuthAppID ¶
GetAuthAppID read Auth-Application-Id AVP
func GetAuthSessionState ¶
GetAuthSessionState read Auth-Session-State AVP
func GetErrorMessage ¶
GetErrorMessage read Error-Message AVP
func GetResultCode ¶
GetResultCode read Result-Code AVP
func GetVendorSpecAppID ¶
GetVendorSpecAppID read Vendor-Specific-Application-Id AVP
Types ¶
type AVP ¶
type AVP struct { Code uint32 // AVP Code VendorID uint32 // Vendor-ID Mandatory bool // Mandatory AVP Flag // Protected bool // Protected AVP Flag Data []byte // AVP Data }
AVP data and header
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AVP Code | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |V M P r r r r r| AVP Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Vendor-ID (opt) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data ... +-+-+-+-+-+-+-+-+
func SetAuthSessionState ¶
SetAuthSessionState make Auth-Session-State AVP
func SetDestinationHost ¶
SetDestinationHost make Destination-Host AVP
func SetDestinationRealm ¶
SetDestinationRealm make Destination-Realm AVP
func SetErrorMessage ¶
SetErrorMessage make Error-Message AVP
func SetGenericAVP ¶
func SetVendorSpecAppID ¶
SetVendorSpecAppID make Vendor-Specific-Application-Id AVP
type Connection ¶
type Connection struct { Host Identity // Peer diameter hostname Realm Identity // Peer diameter realm // contains filtered or unexported fields }
func (*Connection) Close ¶
func (c *Connection) Close(cause Enumerated)
Close Diameter connection and stop state machine.
func (*Connection) DefaultTxHandler ¶
func (c *Connection) DefaultTxHandler(m Message) Message
DefaultTxHandler for sending Diameter request message without Handler or relay application.
func (*Connection) DialAndServe ¶
func (c *Connection) DialAndServe(con net.Conn) (e error)
func (*Connection) ListenAndServe ¶
func (c *Connection) ListenAndServe(con net.Conn) (e error)
func (*Connection) LocalAddr ¶
func (c *Connection) LocalAddr() net.Addr
LocalAddr returns transport connection of state machine
func (*Connection) PeerAddr ¶
func (c *Connection) PeerAddr() net.Addr
PeerAddr returns transport connection of state machine
type Enumerated ¶
type Enumerated int32
Enumerated is Enumerated format AVP value.
const ( // Rebooting is Enumerated value 0 Rebooting Enumerated = 0 // Busy is Enumerated value 1 Busy Enumerated = 1 // DoNotWantToTalkToYou is Enumerated value 2 DoNotWantToTalkToYou Enumerated = 2 )
type FailureAnswer ¶
FailureAnswer is error response from peer.
func (FailureAnswer) Error ¶
func (e FailureAnswer) Error() string
type Handler ¶
Handler handles Diameter message. Inputs are Retry flag and AVPs of Request. Outputs are Error flag and AVPs of Answer.
type Identity ¶
type Identity string
Identity is identity of Diameter protocol
func GetDestinationHost ¶
GetDestinationHost read Destination-Host AVP
func GetDestinationRealm ¶
GetDestinationRealm read Destination-Realm AVP
func GetOriginHost ¶
GetOriginHost read Origin-Host AVP
func GetOriginRealm ¶
GetOriginRealm read Origin-Realm AVP
func GetRouteRecord ¶
GetRouteRecord read Route-Record AVP
func ParseIdentity ¶
ParseIdentity parse Diamter identity form string
type InvalidAVP ¶
InvalidAVP is error of invalid AVP value
func (InvalidAVP) Error ¶
func (e InvalidAVP) Error() string
type InvalidMessage ¶
InvalidMessage is error of invalid message
func (InvalidMessage) Error ¶
func (e InvalidMessage) Error() string
type Message ¶
type Message struct { FlgR bool // Request FlgP bool // Proxiable FlgE bool // Error FlgT bool // Potentially re-transmitted message Code uint32 // Command-Code (24bit) AppID uint32 // Application-ID HbHID uint32 // Hop-by-Hop ID EtEID uint32 // End-to-End ID AVPs []byte // Message body AVP binary data }
Message is Diameter message.
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version | Message Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Command Flags | Command Code | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Application-ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Hop-by-Hop Identifier | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | End-to-End Identifier | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AVPs ... +-+-+-+-+-+-+-+-+-+-+-+-+-
type Router ¶
type Router func(Message) *Connection
Router select destination peer for specific message.