Documentation ¶
Overview ¶
Package m3ua provides easy and painless handling of M3UA protocol in pure Golang.
The API design is kept as similar as possible to other protocols in standard net package. To establish M3UA connection as client/server, you can use Dial() and Listen() / Accept() without caring about the underlying SCTP association, as go-m3ua handles it together with M3UA ASPSM & ASPTM procedures.
This package relies much on github.com/ishidawataru/sctp, as M3UA requires underlying SCTP connection,
Specification: https://tools.ietf.org/html/rfc4666
Index ¶
- Constants
- Variables
- func FormatPC(pc uint32, format PCFormat) string
- func ParsePC(pc string, format PCFormat) uint32
- type Config
- func (c *Config) EnableHeartbeat(interval, timer time.Duration) *Config
- func (c *Config) SetAspIdentifier(id uint32) *Config
- func (c *Config) SetCorrelationID(id uint32) *Config
- func (c *Config) SetNetworkAppearance(nwApr uint32) *Config
- func (c *Config) SetRoutingContexts(rtCtxs ...uint32) *Config
- func (c *Config) SetTrafficModeType(tmType uint32) *Config
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- 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) State() State
- func (c *Conn) Write(b []byte) (n int, err error)
- func (c *Conn) WriteSignal(m3 messages.M3UA) (n int, err error)
- type ErrAspIDRequired
- type ErrInvalidSCTPStreamID
- type ErrInvalidVersion
- type ErrUnexpectedMessage
- type ErrUnsupportedClass
- type ErrUnsupportedMessage
- type HeartbeatInfo
- type Listener
- type PCFormat
- type State
Constants ¶
const (
PCFormat3_2_3 = "3-2-3"
)
PointCode Format definitions.
NOT IMPLEMENTED YET!
Variables ¶
var ( ErrSCTPNotAlive = errors.New("SCTP is no longer alive") ErrInvalidState = errors.New("invalid state") ErrNotEstablished = errors.New("M3UA Conn not established") ErrFailedToEstablish = errors.New("failed to establish M3UA Conn") ErrTimeout = errors.New("timed out") ErrHeartbeatExpired = errors.New("heartbeat timer expired") ErrFailedToPeelOff = errors.New("failed to peel off Protocol Data") ErrFailedToWriteSignal = errors.New("failed to write signal") )
Error definitions.
Functions ¶
Types ¶
type Config ¶
type Config struct { *HeartbeatInfo AspIdentifier *params.Param TrafficModeType *params.Param NetworkAppearance *params.Param RoutingContexts *params.Param CorrelationID *params.Param OriginatingPointCode uint32 DestinationPointCode uint32 ServiceIndicator uint8 NetworkIndicator uint8 MessagePriority uint8 SignalingLinkSelection uint8 }
Config is a configration that defines a M3UA server.
func NewClientConfig ¶
func NewClientConfig(hbInfo *HeartbeatInfo, opc, dpc, aspID, tmt, nwApr, corrID uint32, rtCtxs []uint32, si, ni, mp, sls uint8) *Config
NewClientConfig creates a new Config for Client.
The optional parameters that is not required (like CorrelationID) can be omitted by setting it to nil after created *Config.
func NewConfig ¶
NewConfig creates a new Config.
To set additional parameters, use constructors in param package or setters defined in this package. Note that the params left nil won't appear in the packets but the initialized params will, with zero values.
func NewServerConfig ¶
func NewServerConfig(hbInfo *HeartbeatInfo, opc, dpc, aspID, tmt, nwApr, corrID uint32, rtCtxs []uint32, si, ni, mp, sls uint8) *Config
NewServerConfig creates a new Config for Server.
The optional parameters that is not required (like CorrelationID) can be omitted by setting it to nil after created *Config.
func (*Config) EnableHeartbeat ¶
EnableHeartbeat enables M3UA BEAT with interval and expiration timer given.
The data is hard-coded by default. Manipulate the exported field Config.HeartbeatInfo.Data to customize it such as including current time to identify the BEAT and BEAT ACK pair.
func (*Config) SetAspIdentifier ¶
SetAspIdentifier sets AspIdentifier in Config.
func (*Config) SetCorrelationID ¶
SetCorrelationID sets CorrelationID in Config.
func (*Config) SetNetworkAppearance ¶
SetNetworkAppearance sets NetworkAppearance in Config.
func (*Config) SetRoutingContexts ¶
SetRoutingContexts sets RoutingContexts in Config.
func (*Config) SetTrafficModeType ¶
SetTrafficModeType sets TrafficModeType in Config.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a M3UA connection, which satisfies standard net.Conn interface.
func Dial ¶
Dial establishes a M3UA connection as a client.
After successfully established the connection with peer, state-changing signals and heartbeats are automatically handled background in another goroutine.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote network address.
func (*Conn) SetDeadline ¶
SetDeadline sets the read and write deadlines associated.
func (*Conn) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls.
type ErrAspIDRequired ¶
type ErrAspIDRequired struct{}
ErrAspIDRequired is used by an SGP in response to an ASP Up message that does not contain an ASP Identifier parameter when the SGP requires one..
func NewErrAspIDRequired ¶
func NewErrAspIDRequired() *ErrAspIDRequired
NewErrAspIDRequired creates ErrAspIDRequired
func (*ErrAspIDRequired) Error ¶
func (e *ErrAspIDRequired) Error() string
Error returns error string.
type ErrInvalidSCTPStreamID ¶
type ErrInvalidSCTPStreamID struct {
ID uint16
}
ErrInvalidSCTPStreamID is used if a message is received on an unexpected SCTP stream.
func NewErrInvalidSCTPStreamID ¶
func NewErrInvalidSCTPStreamID(id uint16) *ErrInvalidSCTPStreamID
NewErrInvalidSCTPStreamID creates ErrInvalidSCTPStreamID
func (*ErrInvalidSCTPStreamID) Error ¶
func (e *ErrInvalidSCTPStreamID) Error() string
Error returns error string with violating stream ID.
type ErrInvalidVersion ¶
type ErrInvalidVersion struct {
Ver uint8
}
ErrInvalidVersion is used if a message with an unsupported version is received.
func NewErrInvalidVersion ¶
func NewErrInvalidVersion(ver uint8) *ErrInvalidVersion
NewErrInvalidVersion creates ErrInvalidVersion.
func (*ErrInvalidVersion) Error ¶
func (e *ErrInvalidVersion) Error() string
Error returns error string with violating version.
type ErrUnexpectedMessage ¶
ErrUnexpectedMessage is used if a defined and recognized message is received that is not expected in the current state (in some cases, the ASP may optionally silently discard the message and not send an Error message).
func NewErrUnexpectedMessage ¶
func NewErrUnexpectedMessage(msg messages.M3UA) *ErrUnexpectedMessage
NewErrUnexpectedMessage creates ErrUnexpectedMessage
func (*ErrUnexpectedMessage) Error ¶
func (e *ErrUnexpectedMessage) Error() string
Error returns error string with message class and type.
type ErrUnsupportedClass ¶
ErrUnsupportedClass is used if a message with an unexpected or unsupported Message Class is received.
func NewErrUnsupportedClass ¶
func NewErrUnsupportedClass(msg messages.M3UA) *ErrUnsupportedClass
NewErrUnsupportedClass creates ErrUnsupportedClass
func (*ErrUnsupportedClass) Error ¶
func (e *ErrUnsupportedClass) Error() string
Error returns error string with message class.
type ErrUnsupportedMessage ¶
ErrUnsupportedMessage is used if a message with an unexpected or unsupported Message Type is received.
func NewErrUnsupportedMessage ¶
func NewErrUnsupportedMessage(msg messages.M3UA) *ErrUnsupportedMessage
NewErrUnsupportedMessage creates ErrUnsupportedMessage
func (*ErrUnsupportedMessage) Error ¶
func (e *ErrUnsupportedMessage) Error() string
Error returns error string with message class and type.
type HeartbeatInfo ¶
HeartbeatInfo is a set of information for M3UA BEAT.
func NewHeartbeatInfo ¶
func NewHeartbeatInfo(interval, timer time.Duration, data []byte) *HeartbeatInfo
NewHeartbeatInfo creates a new HeartbeatInfo.
type Listener ¶
type Listener struct { *Config // contains filtered or unexported fields }
Listener is a M3UA listener.
func (*Listener) Accept ¶
Accept waits for and returns the next connection to the listener. After successfully established the association with peer, Payload can be read with Read() func. Other signals are automatically handled background in another goroutine.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
client
Command m3ua-client works as M3UA client.
|
Command m3ua-client works as M3UA client. |
server
Command m3ua-server works as M3UA server.
|
Command m3ua-server works as M3UA server. |
Package messages provides protocol definitions and encoding/decoding feature of M3UA messages.
|
Package messages provides protocol definitions and encoding/decoding feature of M3UA messages. |
params
Package params provides the protocol definition and encoding/decoding feature of M3UA Common Paratemeters and M3UA-specific parameters.
|
Package params provides the protocol definition and encoding/decoding feature of M3UA Common Paratemeters and M3UA-specific parameters. |
Package pc provides Point Code converting from some variants and translation to IP.
|
Package pc provides Point Code converting from some variants and translation to IP. |