Documentation ¶
Overview ¶
Package sctp implements the SCTP spec
Index ¶
- Constants
- func Listen(network string, laddr *net.UDPAddr) (net.Listener, error)
- type Association
- type AssociationListener
- type Config
- type Dialer
- type ListenConfig
- type PayloadProtocolIdentifier
- type Stream
- func (s *Stream) BufferedAmount() uint64
- func (s *Stream) BufferedAmountLowThreshold() uint64
- func (s *Stream) Close() error
- func (s *Stream) LocalAddr() net.Addr
- func (s *Stream) OnBufferedAmountLow(f func())
- func (s *Stream) Read(p []byte) (int, error)
- func (s *Stream) ReadSCTP(p []byte) (int, PayloadProtocolIdentifier, error)
- func (s *Stream) RemoteAddr() net.Addr
- func (s *Stream) SetBufferedAmountLowThreshold(th uint64)
- func (s *Stream) SetDeadline(t time.Time) error
- func (s *Stream) SetDefaultPayloadType(defaultPayloadType PayloadProtocolIdentifier)
- func (s *Stream) SetReadDeadline(t time.Time) error
- func (s *Stream) SetReliabilityParams(unordered bool, relType byte, relVal uint32)
- func (s *Stream) SetWriteDeadline(t time.Time) error
- func (s *Stream) StreamIdentifier() uint16
- func (s *Stream) String() string
- func (s *Stream) Write(p []byte) (n int, err error)
- func (s *Stream) WriteSCTP(p []byte, ppi PayloadProtocolIdentifier) (n int, err error)
Constants ¶
const ( // ReliabilityTypeReliable is used for reliable transmission ReliabilityTypeReliable byte = 0 // ReliabilityTypeRexmit is used for partial reliability by retransmission count ReliabilityTypeRexmit byte = 1 // ReliabilityTypeTimed is used for partial reliability by retransmission duration ReliabilityTypeTimed byte = 2 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Association ¶
type Association struct {
// contains filtered or unexported fields
}
Association represents an SCTP association 13.2. Parameters Necessary per Association (i.e., the TCB) Peer : Tag value to be sent in every packet and is received Verification: in the INIT or INIT ACK chunk. Tag :
My : Tag expected in every inbound packet and sent in the Verification: INIT or INIT ACK chunk.
Tag : State : A state variable indicating what state the association
: is in, i.e., COOKIE-WAIT, COOKIE-ECHOED, ESTABLISHED, : SHUTDOWN-PENDING, SHUTDOWN-SENT, SHUTDOWN-RECEIVED, : SHUTDOWN-ACK-SENT. Note: No "CLOSED" state is illustrated since if a association is "CLOSED" its TCB SHOULD be removed.
func Client ¶
func Client(config Config) (*Association, error)
Client opens a SCTP stream over a conn
func DialAssociation ¶
DialAssociation connects to the given network address and establishes a SCTP association on top. The net.Conn in the config is ignored.
func Server ¶
func Server(config Config) (*Association, error)
Server accepts a SCTP stream over a conn
func (*Association) AcceptStream ¶
func (a *Association) AcceptStream() (*Stream, error)
AcceptStream accepts a stream
func (*Association) BytesReceived ¶
func (a *Association) BytesReceived() uint64
BytesReceived returns the number of bytes received
func (*Association) BytesSent ¶
func (a *Association) BytesSent() uint64
BytesSent returns the number of bytes sent
func (*Association) Close ¶
func (a *Association) Close() error
Close ends the SCTP Association and cleans up any state
func (*Association) OpenStream ¶
func (a *Association) OpenStream(streamIdentifier uint16, defaultPayloadType PayloadProtocolIdentifier) (*Stream, error)
OpenStream opens a stream
type AssociationListener ¶
type AssociationListener struct {
// contains filtered or unexported fields
}
AssociationListener represents a SCTP association listener
func ListenAssociation ¶
func ListenAssociation(network string, laddr *net.UDPAddr) (*AssociationListener, error)
ListenAssociation creates a SCTP association listener.
func NewAssociationListener ¶
func NewAssociationListener(inner net.Listener, config Config) (*AssociationListener, error)
NewAssociationListener creates a SCTP association listener which accepts connections from an inner Listener.
func (*AssociationListener) Accept ¶
func (l *AssociationListener) Accept() (*Association, error)
Accept waits for and returns the next association to the listener. You have to either close or read on all connection that are created.
func (*AssociationListener) Addr ¶
func (l *AssociationListener) Addr() net.Addr
Addr returns the listener's network address.
func (*AssociationListener) Close ¶
func (l *AssociationListener) Close() error
Close closes the listener. Any blocked Accept operations will be unblocked and return errors. Already Accepted connections are not closed.
type Config ¶
type Config struct { NetConn net.Conn MaxReceiveBufferSize uint32 LoggerFactory logging.LoggerFactory }
Config collects the arguments to createAssociation construction into a single structure
type Dialer ¶
type Dialer struct { // PayloadType determines the PayloadProtocolIdentifier used PayloadType PayloadProtocolIdentifier // Config holds common config Config *Config }
A Dialer contains options for connecting to an address.
The zero value for each field is equivalent to dialing without that option. Dialing with the zero value of Dialer is therefore equivalent to just calling the Dial function.
The net.Conn in the config is ignored.
type ListenConfig ¶
type ListenConfig struct {
Config *Config
}
ListenConfig stores options for listening to an address. The net.Conn in the config is ignored.
func (*ListenConfig) Listen ¶
Listen creates a basic SCTP stream listener. For more control check out the AssociationListener.
func (*ListenConfig) ListenAssociation ¶
func (lc *ListenConfig) ListenAssociation(network string, laddr *net.UDPAddr) (*AssociationListener, error)
ListenAssociation creates a SCTP association listener.
type PayloadProtocolIdentifier ¶
type PayloadProtocolIdentifier uint32
PayloadProtocolIdentifier is an enum for DataChannel payload types
const ( PayloadTypeUnspecified PayloadProtocolIdentifier = 0 PayloadTypeWebRTCDCEP PayloadProtocolIdentifier = 50 PayloadTypeWebRTCString PayloadProtocolIdentifier = 51 PayloadTypeWebRTCBinary PayloadProtocolIdentifier = 53 PayloadTypeWebRTCStringEmpty PayloadProtocolIdentifier = 56 PayloadTypeWebRTCBinaryEmpty PayloadProtocolIdentifier = 57 )
PayloadProtocolIdentifier enums https://www.iana.org/assignments/sctp-parameters/sctp-parameters.xhtml#sctp-parameters-25
func (PayloadProtocolIdentifier) String ¶
func (p PayloadProtocolIdentifier) String() string
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream represents an SCTP stream
func Dial ¶
Dial connects to the given network address and establishes a SCTP stream on top. For more control use DialAssociation.
func (*Stream) BufferedAmount ¶
BufferedAmount returns the number of bytes of data currently queued to be sent over this stream.
func (*Stream) BufferedAmountLowThreshold ¶
BufferedAmountLowThreshold returns the number of bytes of buffered outgoing data that is considered "low." Defaults to 0.
func (*Stream) Close ¶
Close closes the write-direction of the stream. Future calls to Write are not permitted after calling Close.
func (*Stream) OnBufferedAmountLow ¶
func (s *Stream) OnBufferedAmountLow(f func())
OnBufferedAmountLow sets the callback handler which would be called when the number of bytes of outgoing data buffered is lower than the threshold.
func (*Stream) Read ¶
Read reads a packet of len(p) bytes, dropping the Payload Protocol Identifier. Returns EOF when the stream is reset or an error if the stream is closed otherwise.
func (*Stream) ReadSCTP ¶
func (s *Stream) ReadSCTP(p []byte) (int, PayloadProtocolIdentifier, error)
ReadSCTP reads a packet of len(p) bytes and returns the associated Payload Protocol Identifier. Returns EOF when the stream is reset or an error if the stream is closed otherwise.
func (*Stream) RemoteAddr ¶
RemoteAddr implements net.Conn.RemoteAddr
func (*Stream) SetBufferedAmountLowThreshold ¶
SetBufferedAmountLowThreshold is used to update the threshold. See BufferedAmountLowThreshold().
func (*Stream) SetDefaultPayloadType ¶
func (s *Stream) SetDefaultPayloadType(defaultPayloadType PayloadProtocolIdentifier)
SetDefaultPayloadType sets the default payload type used by Write.
func (*Stream) SetReadDeadline ¶
SetReadDeadline is a stub
func (*Stream) SetReliabilityParams ¶
SetReliabilityParams sets reliability parameters for this stream.
func (*Stream) SetWriteDeadline ¶
SetWriteDeadline is a stub
func (*Stream) StreamIdentifier ¶
StreamIdentifier returns the Stream identifier associated to the stream.
Source Files ¶
- ack_timer.go
- association.go
- association_stats.go
- chunk.go
- chunk_abort.go
- chunk_cookie_ack.go
- chunk_cookie_echo.go
- chunk_error.go
- chunk_forward_tsn.go
- chunk_heartbeat.go
- chunk_heartbeat_ack.go
- chunk_init.go
- chunk_init_ack.go
- chunk_init_common.go
- chunk_payload_data.go
- chunk_reconfig.go
- chunk_selective_ack.go
- chunkheader.go
- chunktype.go
- control_queue.go
- dialer.go
- error_cause.go
- error_cause_header.go
- error_cause_invalid_mandatory_parameter.go
- error_cause_protocol_violation.go
- error_cause_unrecognized_chunk_type.go
- listener.go
- packet.go
- param.go
- param_chunk_list.go
- param_forward_tsn_supported.go
- param_heartbeat_info.go
- param_outgoing_reset_request.go
- param_random.go
- param_reconfig_response.go
- param_requested_hmac_algorithm.go
- param_state_cookie.go
- param_supported_extensions.go
- paramheader.go
- paramtype.go
- payload_queue.go
- pending_queue.go
- reassembly_queue.go
- rtx_timer.go
- sctp.go
- stream.go
- util.go