|
|
This class manages a SCTP socket (SCTP instance).
enum SCTPSocketFlags { SSF_GlobalQueue = (1 << 0), SSF_AutoConnect = (1 << 1), SSF_Listening = (1 << 31) } | SCTPSocketFlags |
SCTP socket flags.
SCTPSocket (const cardinal flags = 0)
| SCTPSocket |
Constructor.
Parameters:
flags | SCTP socket flags. |
~SCTPSocket ()
| ~SCTPSocket |
Destructor.
inline unsigned short getID ()
| getID |
[const]
Get internal instance ID.
Returns: Instance ID.
int bind (const unsigned short localPort,
const unsigned short noOfInStreams,
const unsigned short noOfOutStreams,
const SocketAddress** localAddressList)
| bind |
Bind socket to local port and address(es).
Parameters:
localPort | Local port. |
noOfInStreams | Number of incoming streams. |
noOfOutStreams | Number of outgoing streams. |
localAddressList | NULL-terminated array of local addresses. |
void unbind (const bool sendAbort = false)
| unbind |
Release socket binding.
Parameters:
sendAbort | true to send abort to all UDP-like associations; false for graceful shutdown (default). |
See also: bind
SCTPAssociation* associate (const unsigned short noOfOutStreams,
const SocketAddress& destinationAddress,
const bool blocking = true)
| associate |
Establish new association.
Parameters:
noOfOutStreams | Number of outgoing streams. |
destinationAddress | Destination address. |
blocking | true to wait for establishment (default); false otherwise. |
Returns: Association or NULL in case of failure.
void listen (const unsigned int backlog)
| listen |
Set socket to listen mode: accept new incoming assocations.
Parameters:
backlog | Maximum number of incoming connections to accept simultaneously. |
SCTPAssociation* accept (SocketAddress*** addressArray = NULL,
const bool blocking = true)
| accept |
Wait for incoming association.
Parameters:
addressArray | Reference to store NULL-terminated array of peer addresses. The addresses are allocated automatically and have to be freed using deleteAddressList(). Set NULL to skip creation of the address array. |
blocking | true to wait for new association (default); false otherwise. |
Returns: New association or NULL in case of failure.
See also: SocketAddress#deleteAddressList
SCTPAssociation* peelOff (const unsigned int assocID)
| peelOff |
Peel automatically established association in UDP-like mode off.
Parameters:
assocID | Association ID. |
Returns: Association peeled of or NULL, if there is no such association.
SCTPAssociation* peelOff (const SocketAddress& destinationAddress)
| peelOff |
Peel automatically established association in UDP-like mode off.
Parameters:
assocID | Association ID. |
Returns: Association peeled of or NULL, if there is no such association.
bool getLocalAddresses (SocketAddress**& addressArray)
| getLocalAddresses |
Get socket's local addresses.
Parameters:
addressArray | Reference to store NULL-terminated array of local addresses. The addresses are allocated automatically and have to be freed using deleteAddressList(). |
Returns: true, if addressEntries are sufficient; false otherwise.
See also: SocketAddress#deleteAddressList
bool getRemoteAddresses (SocketAddress**& addressArray,
unsigned int assocID)
| getRemoteAddresses |
Get socket's remote addresses for given association ID.
Parameters:
addressArray | Reference to store NULL-terminated array of local addresses. The addresses are allocated automatically and have to be freed using deleteAddressList(). |
assocID | Association ID. |
Returns: true, if addressEntries are sufficient; false otherwise.
See also: SocketAddress#deleteAddressList
int receive (char* buffer,
size_t& bufferSize,
int& flags,
unsigned int& assocID,
unsigned short& streamID,
unsigned int& protoID)
| receive |
Receive data.
Parameters:
buffer | Buffer to store data to. |
bufferSize | Size of data buffer; this will be overwritten with actual size of data content. |
flags | Flags; this will be overwritten with actual reception flags. |
assocID | Variable to store association ID to. |
streamID | Variable to store stream ID to. |
protoID | Variable to store protocol ID to. |
addressArray | Reference to store NULL-terminated array of peer addresses. The addresses are allocated automatically and have to be freed using deleteAddressList(). Set NULL to skip creation of the address array. |
status | Variable to store SCTPNotification data to. |
Returns: error code (0 for success).
int receiveFrom (char* buffer,
size_t& bufferSize,
int& flags,
unsigned int& assocID,
unsigned short& streamID,
unsigned int& protoID,
SocketAddress*** addressArray,
SCTPNotification& notification)
| receiveFrom |
Receive data.
Parameters:
buffer | Buffer to store data to. |
bufferSize | Size of data buffer; this will be overwritten with actual size of data content. |
flags | Flags; this will be overwritten with actual reception flags. |
assocID | Variable to store association ID to. |
streamID | Variable to store stream ID to. |
protoID | Variable to store protocol ID to. |
addressArray | Reference to store NULL-terminated array of peer addresses. The addresses are allocated automatically and have to be freed using deleteAddressList(). Set NULL to skip creation of the address array. |
status | Variable to store SCTPNotification data to. |
Returns: error code (0 for success).
See also: SocketAddress#deleteAddressList
int sendTo (const char* buffer,
const size_t length,
const int flags,
const unsigned short streamID,
const unsigned int protoID,
const SocketAddress& destinationAddress,
const cardinal noOfOutgoingStreams = 1)
| sendTo |
Send data.
Parameters:
buffer | Data to be sent. |
length | Length of data to be sent. |
flags | Flags. |
streamID | Stream ID. |
protoID | Protocol ID. |
destinationAddress | Destination address. |
noOfOutgoingStreams | For AutoConnect mode: Number of outgoing streams for newly created connections. |
Returns: error code (0 for success).
inline unsigned int getNotificationFlags ()
| getNotificationFlags |
[const]
Get notification flags.
Returns: Notification flags.
inline void setNotificationFlags (const unsigned int notificationFlags)
| setNotificationFlags |
Get notification flags.
Parameters:
notificationFlags | Notification flags. |
void getInstanceParameters (SCTP_Instance_Parameters& instanceParameters)
| getInstanceParameters |
Get instance parameters.
Parameters:
instanceParameters | Reference to store instance parameters. |
bool setInstanceParameters (const SCTP_Instance_Parameters& instanceParameters)
| setInstanceParameters |
Set instance parameters.
Parameters:
instanceParameters | Instance parameters. |
Returns: true, if successful; false otherwise.
bool getAssociationParameters (const unsigned int assocID,
SCTP_Association_Status& associationParameters)
| getAssociationParameters |
Get association parameters.
Parameters:
assocID | Association ID. |
associationParameters | Reference to store association parameters. |
Returns: true, if successful; false otherwise.
bool setAssociationParameters (const unsigned int assocID,
const SCTP_Association_Status& associationParameters)
| setAssociationParameters |
Set association parameters.
Parameters:
assocID | Association ID. |
associationParameters | Association parameters. |
Returns: true, if successful; false otherwise.
bool getPathParameters (const unsigned int assocID,
const int pathIndex,
SCTP_PathStatus& pathParameters)
| getPathParameters |
Get path parameters.
Parameters:
assocID | Path ID. |
pathIndex | Path index (-1 for primary). |
pathParameters | Reference to store path parameters. |
Returns: true, if successful; false otherwise.
bool setPathParameters (const unsigned int assocID,
const int pathIndex,
const SCTP_PathStatus& pathParameters)
| setPathParameters |
Set path parameters.
Parameters:
assocID | Path ID. |
pathIndex | Path index (-1 for primary). |
pathParameters | Path parameters. |
Returns: true, if successful; false otherwise.
SocketAddress* getPrimaryAddress (const unsigned int assocID)
| getPrimaryAddress |
Get primary address of given association.
Parameters:
assocID | Association ID. |
Returns: Primary address. This address has to be deleted after usage.
bool setPrimary (const unsigned int assocID,
const SocketAddress& primary)
| setPrimary |
Set primary address of given association.
Parameters:
assocID | Association ID. |
primary | Primary address. |
Returns: true for success; false otherwise.
bool setPeerPrimary (const unsigned int assocID,
const SocketAddress& primary)
| setPeerPrimary |
Set peer primary address of given association.
Parameters:
assocID | Association ID. |
primary | Peer primary address. |
Returns: true for success; false otherwise.
bool addAddress (const unsigned int assocID,
const SocketAddress& addAddress)
| addAddress |
Add address to given association.
Parameters:
assocID | Association ID (0 for all UDP-like associations). |
addAddress | Address to be added. |
Returns: true for success; false otherwise.
bool deleteAddress (const unsigned int assocID,
const SocketAddress& delAddress)
| deleteAddress |
Delete address from given association.
Parameters:
assocID | Association ID (0 for all UDP-like associations). |
delAddress | Address to be deleted. |
Returns: true for success; false otherwise.
inline card64 getAutoClose ()
| getAutoClose |
[const]
Get AutoClose parameter.
Returns: Timeout in microseconds.
inline void setAutoClose (const card64 timeout)
| setAutoClose |
Set AutoClose parameter.
Parameters:
timeout | Timeout in microseconds. |
bool setSendBuffer (const size_t size)
| setSendBuffer |
Set send buffer size for all UDP-like associations.
Parameters:
size | Send buffer size. |
bool setReceiveBuffer (const size_t size)
| setReceiveBuffer |
Set receive buffer size for all UDP-like associations.
Parameters:
size | Receive buffer size. |
inline card8 getDefaultTrafficClass ()
| getDefaultTrafficClass |
[const]
Get default traffic class.
Returns: Default traffic class.
bool setTrafficClass (const card8 trafficClass,
const int streamID = -1)
| setTrafficClass |
Set traffic class for all UDP-like associations.
Parameters:
trafficClass | Traffic class. |
streamID | Stream ID (-1 for all streams, default). |
enum UpdateConditionTypes { UCT_Read = 0, UCT_Write = 1, UCT_Except = 2 } | UpdateConditionTypes |
Update condition types.
inline Condition* getUpdateCondition (const cardinal type)
| getUpdateCondition |
Get pointer to update condition.
Parameters:
type | Update condition type. |
Returns: Update condition.
SCTPAssociation* getAssociationForAssociationID (const unsigned int assocID,
const bool activeOnly = true)
| getAssociationForAssociationID |
[protected]
int getErrorCode (const unsigned int assocID)
| getErrorCode |
[protected]
int internalReceive (SCTPNotificationQueue& queue,
char* buffer,
size_t& bufferSize,
int& flags,
unsigned int& assocID,
unsigned short& streamID,
unsigned int& protoID,
SCTPNotification& notification,
const unsigned int notificationFlags)
| internalReceive |
[protected]
int internalSend (const char* buffer,
const size_t length,
const int flags,
const unsigned int assocID,
const unsigned short streamID,
const unsigned int protoID,
Condition* waitCondition)
| internalSend |
[protected]
IncomingConnection (struct) | IncomingConnection |
[protected]
SCTPNotificationQueue GlobalQueue | GlobalQueue |
[protected]
Condition EstablishCondition | EstablishCondition |
[protected]
Condition ReadUpdateCondition | ReadUpdateCondition |
[protected]
Condition WriteUpdateCondition | WriteUpdateCondition |
[protected]
Condition ExceptUpdateCondition | ExceptUpdateCondition |
[protected]
IncomingConnection* ConnectionRequests | ConnectionRequests |
[protected]
multimap<unsigned int, SCTPAssociation*> AssociationList | AssociationList |
[protected]
unsigned short InstanceName | InstanceName |
[protected]
unsigned short LocalPort | LocalPort |
[protected]
unsigned short NoOfInStreams | NoOfInStreams |
[protected]
unsigned short NoOfOutStreams | NoOfOutStreams |
[protected]
unsigned int NoOfLocalAddresses | NoOfLocalAddresses |
[protected]
unsigned char LocalAddressList[SCTP_MAX_NUM_ADDRESSES][SCTP_MAX_IP_LEN] | LocalAddressList[SCTP_MAX_NUM_ADDRESSES][SCTP_MAX_IP_LEN] |
[protected]
cardinal Flags | Flags |
[protected]
unsigned int NotificationFlags | NotificationFlags |
[protected]
unsigned int CorrelationID | CorrelationID |
[protected]
card64 AutoCloseTimeout | AutoCloseTimeout |
[protected]