sctp

package module
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 17 Imported by: 62

README


Pion SCTP

A Go implementation of SCTP

Pion SCTP Slack Widget
Build Status GoDoc Coverage Status Go Report Card


See DESIGN.md for an overview of features and future goals.

Roadmap

The library is used as a part of our WebRTC implementation. Please refer to that roadmap to track our major milestones.

Community

Pion has an active community on the Golang Slack. Sign up and join the #pion channel for discussions and support. You can also use Pion mailing list.

We are always looking to support your projects. Please reach out if you have something to build!

If you need commercial support or don't want to use public methods you can contact us at team@pion.ly

Contributing

Check out the contributing wiki to join the group of amazing people making this project possible:

License

MIT License - see LICENSE for full text

Documentation

Overview

Package sctp implements the SCTP spec

Index

Constants

View Source
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

This section is empty.

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 Server

func Server(config Config) (*Association, error)

Server accepts a SCTP stream over a conn

func (*Association) Abort added in v1.8.3

func (a *Association) Abort(reason string)

Abort sends the abort packet with user initiated abort and immediately closes the connection.

func (*Association) AcceptStream

func (a *Association) AcceptStream() (*Stream, error)

AcceptStream accepts a stream

func (*Association) BytesReceived added in v1.6.8

func (a *Association) BytesReceived() uint64

BytesReceived returns the number of bytes received

func (*Association) BytesSent added in v1.6.8

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) MaxMessageSize added in v1.7.10

func (a *Association) MaxMessageSize() uint32

MaxMessageSize returns the maximum message size you can send.

func (*Association) OpenStream

func (a *Association) OpenStream(streamIdentifier uint16, defaultPayloadType PayloadProtocolIdentifier) (*Stream, error)

OpenStream opens a stream

func (*Association) SetMaxMessageSize added in v1.7.10

func (a *Association) SetMaxMessageSize(maxMsgSize uint32)

SetMaxMessageSize sets the maximum message size you can send.

func (*Association) Shutdown added in v1.7.12

func (a *Association) Shutdown(ctx context.Context) error

Shutdown initiates the shutdown sequence. The method blocks until the shutdown sequence is completed and the connection is closed, or until the passed context is done, in which case the context's error is returned.

type Config added in v1.5.0

type Config struct {
	NetConn              net.Conn
	MaxReceiveBufferSize uint32
	MaxMessageSize       uint32
	LoggerFactory        logging.LoggerFactory
}

Config collects the arguments to createAssociation construction into a single structure

type PayloadProtocolIdentifier

type PayloadProtocolIdentifier uint32

PayloadProtocolIdentifier is an enum for DataChannel payload types

const (
	PayloadTypeUnknown           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 (*Stream) BufferedAmount added in v1.5.0

func (s *Stream) BufferedAmount() uint64

BufferedAmount returns the number of bytes of data currently queued to be sent over this stream.

func (*Stream) BufferedAmountLowThreshold added in v1.5.0

func (s *Stream) BufferedAmountLowThreshold() uint64

BufferedAmountLowThreshold returns the number of bytes of buffered outgoing data that is considered "low." Defaults to 0.

func (*Stream) Close

func (s *Stream) Close() error

Close closes the write-direction of the stream. Future calls to Write are not permitted after calling Close.

func (*Stream) OnBufferedAmountLow added in v1.5.0

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

func (s *Stream) Read(p []byte) (int, error)

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) SetBufferedAmountLowThreshold added in v1.5.0

func (s *Stream) SetBufferedAmountLowThreshold(th uint64)

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) SetReliabilityParams

func (s *Stream) SetReliabilityParams(unordered bool, relType byte, relVal uint32)

SetReliabilityParams sets reliability parameters for this stream.

func (*Stream) State added in v1.8.3

func (s *Stream) State() StreamState

State return the stream state.

func (*Stream) StreamIdentifier

func (s *Stream) StreamIdentifier() uint16

StreamIdentifier returns the Stream identifier associated to the stream.

func (*Stream) Write

func (s *Stream) Write(p []byte) (n int, err error)

Write writes len(p) bytes from p with the default Payload Protocol Identifier

func (*Stream) WriteSCTP

func (s *Stream) WriteSCTP(p []byte, ppi PayloadProtocolIdentifier) (int, error)

WriteSCTP writes len(p) bytes from p to the DTLS connection

type StreamState added in v1.8.3

type StreamState int

StreamState is an enum for SCTP Stream state field This field identifies the state of stream.

const (
	StreamStateOpen    StreamState = iota // Stream object starts with StreamStateOpen
	StreamStateClosing                    // Outgoing stream is being reset
	StreamStateClosed                     // Stream has been closed
)

StreamState enums

func (StreamState) String added in v1.8.3

func (ss StreamState) String() string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL