sctp

package module
v0.0.0-...-01e8a4c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

Stream Control Transmission Protocol (SCTP)

Build Status

Examples

See example/sctp.go

$ cd example
$ go build
$ # run example SCTP server
$ ./example -server -port 1000 -ip 10.10.0.1,10.20.0.1
$ # run example SCTP client
$ ./example -port 1000 -ip 10.10.0.1,10.20.0.1

Documentation

Index

Constants

View Source
const (
	SOL_SCTP = 132

	SCTP_BINDX_ADD_ADDR = 0x01
	SCTP_BINDX_REM_ADDR = 0x02

	MSG_NOTIFICATION = C.MSG_NOTIFICATION
	MSG_EOR          = C.MSG_EOR
)
View Source
const (
	SCTP_RTOINFO = iota
	SCTP_ASSOCINFO
	SCTP_INITMSG
	SCTP_NODELAY
	SCTP_AUTOCLOSE
	SCTP_SET_PEER_PRIMARY_ADDR
	SCTP_PRIMARY_ADDR
	SCTP_ADAPTATION_LAYER
	SCTP_DISABLE_FRAGMENTS
	SCTP_PEER_ADDR_PARAMS
	SCTP_DEFAULT_SENT_PARAM
	SCTP_EVENTS
	SCTP_I_WANT_MAPPED_V4_ADDR
	SCTP_MAXSEG
	SCTP_STATUS
	SCTP_GET_PEER_ADDR_INFO
	SCTP_DELAYED_ACK_TIME
	SCTP_DELAYED_ACK  = SCTP_DELAYED_ACK_TIME
	SCTP_DELAYED_SACK = SCTP_DELAYED_ACK_TIME

	SCTP_SOCKOPT_BINDX_ADD = 100
	SCTP_SOCKOPT_BINDX_REM = 101
	SCTP_SOCKOPT_PEELOFF   = 102
	SCTP_GET_PEER_ADDRS    = 108
	SCTP_GET_LOCAL_ADDRS   = 109
	SCTP_SOCKOPT_CONNECTX  = 110
	SCTP_SOCKOPT_CONNECTX3 = 111
)
View Source
const (
	SCTP_EVENT_DATA_IO = 1 << iota
	SCTP_EVENT_ASSOCIATION
	SCTP_EVENT_ADDRESS
	SCTP_EVENT_SEND_FAILURE
	SCTP_EVENT_PEER_ERROR
	SCTP_EVENT_SHUTDOWN
	SCTP_EVENT_PARTIAL_DELIVERY
	SCTP_EVENT_ADAPTATION_LAYER
	SCTP_EVENT_AUTHENTICATION
	SCTP_EVENT_SENDER_DRY

	SCTP_EVENT_ALL = SCTP_EVENT_DATA_IO | SCTP_EVENT_ASSOCIATION | SCTP_EVENT_ADDRESS | SCTP_EVENT_SEND_FAILURE | SCTP_EVENT_PEER_ERROR | SCTP_EVENT_SHUTDOWN | SCTP_EVENT_PARTIAL_DELIVERY | SCTP_EVENT_ADAPTATION_LAYER | SCTP_EVENT_AUTHENTICATION | SCTP_EVENT_SENDER_DRY
)
View Source
const (
	SCTP_SN_TYPE_BASE = SCTPNotificationType(iota + (1 << 15))
	SCTP_ASSOC_CHANGE
	SCTP_PEER_ADDR_CHANGE
	SCTP_SEND_FAILED
	SCTP_REMOTE_ERROR
	SCTP_SHUTDOWN_EVENT
	SCTP_PARTIAL_DELIVERY_EVENT
	SCTP_ADAPTATION_INDICATION
	SCTP_AUTHENTICATION_INDICATION
	SCTP_SENDER_DRY_EVENT
)
View Source
const (
	SCTP_CMSG_INIT = SCTPCmsgType(iota)
	SCTP_CMSG_SNDRCV
	SCTP_CMSG_SNDINFO
	SCTP_CMSG_RCVINFO
	SCTP_CMSG_NXTINFO
)
View Source
const (
	SCTP_UNORDERED = 1 << iota
	SCTP_ADDR_OVER
	SCTP_ABORT
	SCTP_SACK_IMMEDIATELY
	SCTP_EOF
)
View Source
const (
	SCTP_COMM_UP = SCTPState(iota)
	SCTP_COMM_LOST
	SCTP_RESTART
	SCTP_SHUTDOWN_COMP
	SCTP_CANT_STR_ASSOC
)
View Source
const (
	SCTP4 = SCTPAddressFamily(iota)
	SCTP6
	SCTP6Only
)
View Source
const (
	OneToOne = SCTPSocketMode(iota)
	OneToMany
)
View Source
const (
	SCTP_ADDR_AVAILABLE = iota
	SCTP_ADDR_UNREACHABLE
	SCTP_ADDR_REMOVED
	SCTP_ADDR_ADDED
	SCTP_ADDR_MADE_PRIM
)
View Source
const (
	SCTP_MAX_STREAM = 0xffff
)

Variables

This section is empty.

Functions

func SCTPAccept

func SCTPAccept(fd int) (int, error)

func SCTPAddrFamily

func SCTPAddrFamily(laddr *SCTPAddr, raddr *SCTPAddr) (family int, ipv6only bool)

func SCTPBind

func SCTPBind(fd int, addr *SCTPAddr, flags int) error

func SCTPClose

func SCTPClose(fd int) error

func SCTPConnect

func SCTPConnect(fd int, addr *SCTPAddr) (int, error)

func SCTPGetEvents

func SCTPGetEvents(fd int) (int, error)

func SCTPGetNonblocking

func SCTPGetNonblocking(fd int) (bool, error)

func SCTPListen

func SCTPListen(fd int) error

func SCTPPeelOff

func SCTPPeelOff(fd int, associd int32) (int, error)

func SCTPSetDefaultSentParam

func SCTPSetDefaultSentParam(fd int, info *SndRcvInfo) error

func SCTPSetDefaultSockopts

func SCTPSetDefaultSockopts(s int, family int, ipv6only bool) error

from https://github.com/golang/go Changes: it is for SCTP only

func SCTPSetEvents

func SCTPSetEvents(fd, flags int) error

func SCTPSetInitOpts

func SCTPSetInitOpts(fd int, options InitMsg) error

func SCTPSetNonblocking

func SCTPSetNonblocking(fd int, nonblocking bool) error

func SCTPSocket

func SCTPSocket(af int, mode SCTPSocketMode) (int, error)

func SCTPWrite

func SCTPWrite(fd int, b []byte, info *SndRcvInfo) (int, error)

Types

type AdaptationIndication

type AdaptationIndication struct {
	Type       SCTPNotificationType
	Flags      uint16
	Length     uint32
	Indication uint32
	AssocID    int32
}

type AssociationChange

type AssociationChange struct {
	Type            SCTPNotificationType
	Flags           uint16
	Length          uint32
	State           SCTPState
	Error           uint16
	OutboundStreams uint16
	InboundStreams  uint16
	AssocID         int32
	Info            []byte
}

type Authentication

type Authentication struct {
	Type       SCTPNotificationType
	Flags      uint16
	Length     uint32
	KeyNumber  uint16
	Indication uint32
	AssocID    int32
}

type EventSubscribe

type EventSubscribe struct {
	DataIO          uint8
	Association     uint8
	Address         uint8
	SendFailure     uint8
	PeerError       uint8
	Shutdown        uint8
	PartialDelivery uint8
	AdaptationLayer uint8
	Authentication  uint8
	SenderDry       uint8
}

type GetAddrsOld

type GetAddrsOld struct {
	AssocID int32
	AddrNum int32
	Addrs   uintptr
}

type InitMsg

type InitMsg struct {
	NumOstreams    uint16
	MaxInstreams   uint16
	MaxAttempts    uint16
	MaxInitTimeout uint16
}

func NewDefaultInitMsg

func NewDefaultInitMsg() *InitMsg

func SCTPGetInitOpts

func SCTPGetInitOpts(fd int) (InitMsg, error)

type Notification

type Notification struct {
	Data []byte
}

func SCTPParseNotification

func SCTPParseNotification(b []byte) (*Notification, error)

func (*Notification) GetAdaptationIndication

func (n *Notification) GetAdaptationIndication() *AdaptationIndication

func (*Notification) GetAssociationChange

func (n *Notification) GetAssociationChange() *AssociationChange

func (*Notification) GetAuthentication

func (n *Notification) GetAuthentication() *Authentication

func (*Notification) GetPartialDelivery

func (n *Notification) GetPartialDelivery() *PartialDelivery

func (*Notification) GetPeerAddrChange

func (n *Notification) GetPeerAddrChange() *PeerAddrChange

func (*Notification) GetRemoteError

func (n *Notification) GetRemoteError() *RemoteError

func (*Notification) GetSendFailed

func (n *Notification) GetSendFailed() *SendFailed

func (*Notification) GetSenderDry

func (n *Notification) GetSenderDry() *SenderDry

func (*Notification) Header

func (n *Notification) Header() *NotificationHeader

func (*Notification) Type

type NotificationHeader

type NotificationHeader struct {
	Type   SCTPNotificationType
	Flags  uint16
	Length uint32
}

type NxtInfo

type NxtInfo struct {
	Stream  uint16
	Flags   uint16
	PPID    uint32
	Length  uint32
	AssocID int32
}

type OOBMessage

type OOBMessage struct {
	syscall.SocketControlMessage
}

func SCTPParseOOB

func SCTPParseOOB(b []byte) (*OOBMessage, error)

func SCTPRead

func SCTPRead(fd int, b []byte) (dataCount int, oob *OOBMessage, flags int, err error)

func (*OOBMessage) GetNxtInfo

func (o *OOBMessage) GetNxtInfo() *NxtInfo

func (*OOBMessage) GetSndInfo

func (o *OOBMessage) GetSndInfo() *SndInfo

func (*OOBMessage) GetSndRcvInfo

func (o *OOBMessage) GetSndRcvInfo() *SndRcvInfo

func (*OOBMessage) IsSCTP

func (o *OOBMessage) IsSCTP() bool

func (*OOBMessage) Type

func (o *OOBMessage) Type() SCTPCmsgType

type PartialDelivery

type PartialDelivery struct {
	Type           SCTPNotificationType
	Flags          uint16
	Length         uint32
	Indication     uint32
	StreamID       uint32
	SequenceNumber uint32
}

type PeerAddrChange

type PeerAddrChange struct {
	Type    SCTPNotificationType
	Length  uint32
	Addr    C.struct_sockaddr_storage
	State   PeerChangeState
	Error   uint32
	AssocID int32
}

type PeerChangeState

type PeerChangeState uint32

type RemoteError

type RemoteError struct {
	Type    SCTPNotificationType
	Flags   uint16
	Length  uint32
	Error   uint16
	AssocID int32
	Info    []byte
}

type SCTPAddr

type SCTPAddr struct {
	IPAddrs       []net.IPAddr
	Port          int
	AddressFamily SCTPAddressFamily
}

func ResolveSCTPAddr

func ResolveSCTPAddr(addressFamily SCTPAddressFamily, addrs string) (*SCTPAddr, error)

func SCTPGetAddrs

func SCTPGetAddrs(fd int, id uint16, optname int) (*SCTPAddr, error)

func SCTPGetLocalAddr

func SCTPGetLocalAddr(fd int, stream uint16) (*SCTPAddr, error)

func SCTPGetRemoteAddr

func SCTPGetRemoteAddr(fd int, stream uint16) (*SCTPAddr, error)

func (*SCTPAddr) Network

func (a *SCTPAddr) Network() string

func (*SCTPAddr) String

func (a *SCTPAddr) String() string

func (*SCTPAddr) ToRawSockAddrBuf

func (a *SCTPAddr) ToRawSockAddrBuf() []byte

type SCTPAddressFamily

type SCTPAddressFamily int

func (SCTPAddressFamily) String

func (af SCTPAddressFamily) String() string

func (SCTPAddressFamily) ToSyscall

func (af SCTPAddressFamily) ToSyscall() int

type SCTPCmsgType

type SCTPCmsgType int32

type SCTPConn

type SCTPConn struct {
	// contains filtered or unexported fields
}

func NewSCTPConnection

func NewSCTPConnection(af SCTPAddressFamily, options InitMsg, mode SCTPSocketMode, nonblocking bool) (*SCTPConn, error)

func (*SCTPConn) Bind

func (c *SCTPConn) Bind(laddr *SCTPAddr) error

func (*SCTPConn) Close

func (c *SCTPConn) Close() error

func (*SCTPConn) Connect

func (c *SCTPConn) Connect(raddr *SCTPAddr) error

func (*SCTPConn) FD

func (c *SCTPConn) FD() int

func (*SCTPConn) GetDefaultSentParam

func (c *SCTPConn) GetDefaultSentParam() (*SndRcvInfo, error)

func (*SCTPConn) GetEvents

func (c *SCTPConn) GetEvents() (int, error)

func (*SCTPConn) GetNonblocking

func (c *SCTPConn) GetNonblocking() (bool, error)

func (*SCTPConn) GetSocketMode

func (c *SCTPConn) GetSocketMode() (SCTPSocketMode, error)

func (*SCTPConn) Listen

func (c *SCTPConn) Listen() error

func (*SCTPConn) LocalAddr

func (c *SCTPConn) LocalAddr() net.Addr

func (*SCTPConn) PeelOff

func (c *SCTPConn) PeelOff(id int32) (*SCTPConn, error)

func (*SCTPConn) Read

func (c *SCTPConn) Read(b []byte) (int, error)

func (*SCTPConn) RemoteAddr

func (c *SCTPConn) RemoteAddr() net.Addr

func (*SCTPConn) SCTPGetPrimaryPeerAddr

func (c *SCTPConn) SCTPGetPrimaryPeerAddr() (*SCTPAddr, error)

func (*SCTPConn) SCTPLocalAddr

func (c *SCTPConn) SCTPLocalAddr(id uint16) (*SCTPAddr, error)

func (*SCTPConn) SCTPRead

func (c *SCTPConn) SCTPRead(b []byte) (int, *OOBMessage, int, error)

func (*SCTPConn) SCTPRemoteAddr

func (c *SCTPConn) SCTPRemoteAddr(id uint16) (*SCTPAddr, error)

func (*SCTPConn) SCTPWrite

func (c *SCTPConn) SCTPWrite(b []byte, info *SndRcvInfo) (int, error)

func (*SCTPConn) SetDeadline

func (c *SCTPConn) SetDeadline(t time.Time) error

func (*SCTPConn) SetDefaultSentParam

func (c *SCTPConn) SetDefaultSentParam(info *SndRcvInfo) error

func (*SCTPConn) SetEvents

func (c *SCTPConn) SetEvents(flags int) error

func (*SCTPConn) SetNonblocking

func (c *SCTPConn) SetNonblocking(val bool) error

func (*SCTPConn) SetReadDeadline

func (c *SCTPConn) SetReadDeadline(t time.Time) error

func (*SCTPConn) SetWriteDeadline

func (c *SCTPConn) SetWriteDeadline(t time.Time) error

func (*SCTPConn) Write

func (c *SCTPConn) Write(b []byte) (int, error)

type SCTPListener

type SCTPListener struct {
	SCTPConn
	// contains filtered or unexported fields
}

func NewSCTPListener

func NewSCTPListener(laddr *SCTPAddr, init InitMsg, mode SCTPSocketMode, nonblocking bool) (*SCTPListener, error)

func (*SCTPListener) Accept

func (ln *SCTPListener) Accept() (net.Conn, error)

Accept waits for and returns the next connection connection to the listener.

func (*SCTPListener) AcceptSCTP

func (ln *SCTPListener) AcceptSCTP() (*SCTPConn, error)

AcceptSCTP waits for and returns the next SCTP connection to the listener.

func (*SCTPListener) SCTPRead

func (ln *SCTPListener) SCTPRead(b []byte) (int, *OOBMessage, int, error)

func (*SCTPListener) SCTPWrite

func (ln *SCTPListener) SCTPWrite(b []byte, info *SndRcvInfo) (int, error)

type SCTPNotificationType

type SCTPNotificationType uint16

func (SCTPNotificationType) String

func (n SCTPNotificationType) String() string

type SCTPSocketMode

type SCTPSocketMode int

func SCTPGetSocketMode

func SCTPGetSocketMode(fd int) (SCTPSocketMode, error)

type SCTPState

type SCTPState uint16

func (SCTPState) String

func (s SCTPState) String() string

type SendFailed

type SendFailed struct {
	Type    SCTPNotificationType
	Flags   uint16
	Length  uint32
	Error   uint16
	SndInfo SndInfo
	AssocID int32
	Data    []byte
}

type SenderDry

type SenderDry struct {
	Type    SCTPNotificationType
	Flags   uint16
	Length  uint32
	AssocID int32
}

type SndInfo

type SndInfo struct {
	Stream  uint16
	Flags   uint16
	PPID    uint32
	Context uint32
	AssocID int32
}

type SndRcvInfo

type SndRcvInfo struct {
	Stream uint16
	SSN    uint16
	Flags  uint16

	PPID    uint32
	Context uint32
	TTL     uint32
	TSN     uint32
	CumTSN  uint32
	AssocID int32
	// contains filtered or unexported fields
}

func SCTPGetDefaultSentParam

func SCTPGetDefaultSentParam(fd int) (*SndRcvInfo, error)

Jump to

Keyboard shortcuts

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