All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Friends | List of all members
CSirius Class Reference

Sirius main class. More...

#include <sir_socket.h>

Inheritance diagram for CSirius:
Inheritance graph
Collaboration diagram for CSirius:
Collaboration graph

Classes

struct  TTcpStatistics
 TCP Statistics. More...
 

Public Member Functions

int Init (int iGroup, void *pCSiriusI, ILogging *pILogging=NULL)
 Initialize Sirius TCP stack. More...
 
bool Handle_Packet (cvmx_wqe_t *pWQE, CSiriusMemList *ptDestList=NULL)
 Process packet designated in pWQE. More...
 
int GetLastError ()
 Retrieve last error from stack. More...
 
int So_Accept (int fd, sir_ip_sockaddr_t *ptSockaddr)
 Create a new connection on socket fd. More...
 
int So_Socket (int domain, int type, int protocol)
 Create a new socket. More...
 
int So_Bind (int fd, sir_ip_sockaddr_t *ptSockaddr)
 Bind the socket to a local IP address and port number. More...
 
int So_BindOverload (int fd, sir_ip_sockaddr_t *ptSockaddr, const int iPortNr)
 Bind the socket to physical port and overload the source IP address with the value in ptSockaddr->ui32Sin_Addr. More...
 
int So_Listen (int fd, int backlog)
 Prepare the socket to be used for accept incoming connections using So_Accept. More...
 
int So_Connect (int fd, const sir_ip_sockaddr_t *ptSockaddr)
 Connect the socket to the address specified in ptSockAddr. More...
 
int So_Close (int fd)
 Closes the file descriptor so that it no longer refers to a session. More...
 
int So_Abort (int fd)
 Abort the file descriptor. It is terminated immediately. More...
 
int So_Notify (int fd, void *pReference)
 Set the context for the fd. More...
 
void * So_Notify (int fd)
 Get the context for the fd. More...
 
int So_Recv (int fd, char *pBuf, int iLen, int iFlags)
 Get data from socket. More...
 
int So_RecvFrom (int fd, char *pBuf, int iLen, int iFlags, sir_ip_sockaddr_t *ptSrc_Addr)
 Get message from socket. More...
 
int So_RecvFast (int fd, int iLen, CSiriusMemList *pMemList)
 Get message from socket (using CSiriusMemList) More...
 
int So_RecvFromFast (int fd, int iLen, CSiriusMemList *pMemList, sir_ip_sockaddr_t *ptSrc_Addr)
 Get message from socket (using CSiriusMemList) More...
 
int So_SendTo (int fd, char *pBuf, int iLen, const sir_ip_sockaddr_t *ptSockaddr=NULL)
 Send data on a socket. More...
 
int So_CanSend (int fd)
 Check the number of bytes that can be send on this session. More...
 
int So_SendToFast (int fd, CSiriusMemList *pMemList, const sir_ip_sockaddr_t *ptSockaddr=NULL, CSiriusMemList *ptRemains=NULL)
 Send a memory list on a socket (using CSiriusMemList) More...
 
int So_SendToFastRetransmit (int fd, CSiriusMemList *ptMemList, const sir_ip_sockaddr_t *ptSockAddr, void *pVoid, int iSize, int iGrp=-1)
 Send a memory list on a UDP or RAW socket (using CSiriusMemList) and do not delete the packet after is was sent. More...
 
uint32_t So_GetAppTag (int fd)
 Switch to the application tag. More...
 
int So_SetAppTag (int fd, uint32_t ui32AppTag)
 Set the application tag. More...
 
int So_GetAvailableData (int fd, EPayload_Indicator ePayloadIndicator)
 Get the size of data that is waiting in the receive queue of the specified session. More...
 
int So_SetSockOpt (int fd, ESockOptLevel eSockLevel, ESockOptName eSockOptName, char *pValue, int iValueLength)
 Set socket option. More...
 
int So_GetSockOpt (int fd, ESockOptLevel eSockLevel, ESockOptName eSockOptName, char *pValue, int iValueLength)
 Get socket option. More...
 
int So_GetSockName (int fd, sir_ip_sockaddr_t *ptSockaddr)
 Get the current address to which the socket is bound. More...
 
sir_tcp_tcbSo_GetTCB (int fd)
 Get pointer to TCB which belongs to the file descriptor. More...
 
int So_PushOverflowQueue (int fd, void *pContext)
 
bool AddPort (int iPortNr)
 Add port configuration to Sirius stack using default parameters. More...
 
bool AddPort (int iPortNr, int iIpv4NrOfArpEntries, int iIpv4NrOfVlans, int iIpv6NrOfCacheEntriesPow2, int iIpv6NrOfInterfaceEntries, int iIpv6NrOfRouterEntries, int iIpv6NrOfPrefixEntries, bool bIpv6SlaacEnabled)
 Add port configuration to Sirius stack. More...
 
bool AddIPV6Vlan (int iPortNr, uint16_t ui16VLAN)
 Add a VLAN to a physical port. This VLAN will only be used under an IPV6 configuration. More...
 
CSystemInfo::prt_linkstatus_t GetLinkStatus (int iPortNr)
 Get link status of physical port. More...
 
bool AddIPV4Address (int iPortNr, uint32_t ui32IP, uint32_t ui32Gateway, uint32_t ui32Netmask, uint16_t ui16VLan=0)
 Add an IPV4 address to a physical port. More...
 
bool AddIPV4Address (int iPortNr, uint32_t ui32IP, uint32_t ui32Gateway, uint8_t ui8BitMask, uint16_t ui16VLan)
 Add an IPV4 address to a physical port. More...
 
bool RemoveIPV4Address (int iPortNr, uint32_t ui32IP, uint16_t ui16VLan)
 Remove an IPV4 address from a physical port. More...
 
bool AddIPV6Address (int iPortNr, TIPAddr tIP, TIPAddr tGateway, uint8_t ui8BitMask, uint16_t ui16VLan=0)
 Add an IPV6 address to a physical port. More...
 
bool RemoveIPV6Address (int iPortNr, TIPAddr tIp, uint16_t ui16VLan=0)
 Remove an IPV6 address from a physical port. More...
 
bool GetPortConfig (EPortConfig ePortConfig, int iPortNr, struct sir_port_config_t *ptPortConfig, bool bFirst=false)
 Get configuration info from a physical port. More...
 
void EnableTimeStamp (bool bTimeStampOn)
 Enable the time stamp option. Defaults to ON. More...
 
bool TimeStampEnabled ()
 Check if time stamp option is on. More...
 
void EnableSACK (bool bSACKOn)
 Enable the SACK option. Defaults to ON. More...
 
bool SACKEnabled ()
 Check if SACK option is on. More...
 
int AddAndGetSocketResourcesInUse (int iIncrement)
 Diagnostic function. Get nr of allocated memory segments by sockets. More...
 
int AddAndGetcSocketResourcesInUse (int iIncrement)
 Diagnostic function. Get nr of resources in cSocket hash table. More...
 
int AddAndGetcBoundSocketResourcesInUse (int iIncrement)
 Diagnostic function. Get nr of resources in cBoundSocket hash table. More...
 
int GetArpHashResources (int iPortNr)
 Diagnostic function. Get nr of resources in ARP hash table. More...
 
bool DisplayARPStats (int iPortNr)
 Diagnostic function. Display ARP status of physical port. More...
 
int GetNrOfResourcesInUse (EResourceType eResourceType, int iAux)
 Diagnostic function. Get resource in use. More...
 
void * GetReferenceOfResource (EResourceType eResourceType, int iAux)
 Helper function. Get reference of designated resource. More...
 
void Diagnostics (uint16_t ui16Selection, uint16_t *pOffset, uint8_t *pui8Bytes, int iLength)
 Diagnostic function. Display diagnostic information on the console. More...
 
- Public Member Functions inherited from CSocketMisc
bool SetStartUnused (uint8_t ui8StartUnused)
 
bool SetWindowSize (uint32_t ui32WindowSize)
 

Friends

class CSiriusTCP
 

Additional Inherited Members

- Static Public Member Functions inherited from CSocketMisc
static int handle_to_fd (sir_so_socket_t *ptSocket)
 
static sir_so_socket_tfd_to_handle (int fd)
 
static TIPAddr pton (int domain, const char *src)
 
static TIPAddr pton (const char *src)
 
static const charntop (int domain, const TIPAddr &tIpAddr, char *dst, int size)
 
static const charntop (TIPAddr &tIpAddr, char *dst, int size)
 

Detailed Description

Sirius main class.

This class contains the main functions needed to make use of the stack

Definition at line 40 of file sir_socket.h.

Member Function Documentation

int CSirius::AddAndGetcBoundSocketResourcesInUse ( int  iIncrement)

Diagnostic function. Get nr of resources in cBoundSocket hash table.

Returns
Nr of entries in cBoundSocket hash tableL
int CSirius::AddAndGetcSocketResourcesInUse ( int  iIncrement)

Diagnostic function. Get nr of resources in cSocket hash table.

Returns
Nr of entries in cSocket hash tableL
int CSirius::AddAndGetSocketResourcesInUse ( int  iIncrement)

Diagnostic function. Get nr of allocated memory segments by sockets.

Returns
Nr of memory segments from CVMX_FPA_SOCKET_POOL
bool CSirius::AddIPV4Address ( int  iPortNr,
uint32_t  ui32IP,
uint32_t  ui32Gateway,
uint32_t  ui32Netmask,
uint16_t  ui16VLan = 0 
)

Add an IPV4 address to a physical port.

The address should be added to a port that was added via AddPort()

Parameters
[in]iPortNrPhysical port number to which IP address must be added
[in]ui32IPIP address to add
[in]ui32GatewayDefault gateway
[in]ui32NetmaskNetmask
[in]ui16VLanVLAN if needed. If omitted or zero, no Vlan is added.
Returns
true Success
false Failure
bool CSirius::AddIPV4Address ( int  iPortNr,
uint32_t  ui32IP,
uint32_t  ui32Gateway,
uint8_t  ui8BitMask,
uint16_t  ui16VLan 
)

Add an IPV4 address to a physical port.

The address should be added to a port that was added via AddPort()

Parameters
[in]iPortNrPhysical port number to which IP address must be added
[in]ui32IPIP address to add
[in]ui32GatewayDefault gateway
[in]ui8BitmaskBitmask, eq nr of bits that define the netmask (for example: bitmask 24 is netmask 255.255.255.0)
[in]ui16VLanVLAN if needed. If omitted or zero, no Vlan is added.
Returns
true Success
false Failure
bool CSirius::AddIPV6Address ( int  iPortNr,
TIPAddr  tIP,
TIPAddr  tGateway,
uint8_t  ui8BitMask,
uint16_t  ui16VLan = 0 
)

Add an IPV6 address to a physical port.

The address should be added to a port that was added via AddPort()

Parameters
[in]iPortNrPhysical port number to add
[in]tIPIP address to add
[in]tGatewayDefault gateway
[in]ui8BitMaskNr of bits used to define the prefix in "slash notation"
[in]ui16VLanVLAN if needed. If omitted or zero, no Vlan is added.
Returns
true Success
false Failure
bool CSirius::AddIPV6Vlan ( int  iPortNr,
uint16_t  ui16VLAN 
)

Add a VLAN to a physical port. This VLAN will only be used under an IPV6 configuration.

Parameters
[in]iPortNrPhysical port number to add
[in]ui16VlanVLAN to add to this port
Returns
true Success
false Failure
bool CSirius::AddPort ( int  iPortNr)

Add port configuration to Sirius stack using default parameters.

    @param[in]  iPortNr     Physical port number to add

. *

Returns
true Success
false Failure
bool CSirius::AddPort ( int  iPortNr,
int  iIpv4NrOfArpEntries,
int  iIpv4NrOfVlans,
int  iIpv6NrOfCacheEntriesPow2,
int  iIpv6NrOfInterfaceEntries,
int  iIpv6NrOfRouterEntries,
int  iIpv6NrOfPrefixEntries,
bool  bIpv6SlaacEnabled 
)

Add port configuration to Sirius stack.

    @param[in]  iPortNr Physical port number to add
   @param[in]   iIpv4NrOfArpEntries Maximum number of ARP entries to cache
   @param[in]   iIpv4NrOfVlans Maximum number of VLANs to support
   @param[in]   iIpv6NrOfCacheEntriesPow2 Maximum number of cache entries pow 2 to support
   @param[in]   iIpv6NrOfInterfaceEntries Maximum number of interface entries to support
   @param[in]   iIpv6NrOfRouterEntries Maximum number of router entries to support
   @param[in]   iIpv6NrOfPrefixEntries Maximum number of prefix entries to support
   @param[in]   bIpv6SlaacEnabled Set to true to configure a slaac address

. *

Returns
true Success
false Failure
void CSirius::Diagnostics ( uint16_t  ui16Selection,
uint16_t *  pOffset,
uint8_t *  pui8Bytes,
int  iLength 
)

Diagnostic function. Display diagnostic information on the console.

Parameters
[in]ui16SelectionSelection value
[in]pui16OffsetPointer to offset value
[in]pui8BytesPointer to parameter bytes
[in]iLengthLength of buffer
bool CSirius::DisplayARPStats ( int  iPortNr)

Diagnostic function. Display ARP status of physical port.

Returns
true: Ok
false: Invalid port number
void CSirius::EnableSACK ( bool  bSACKOn)

Enable the SACK option. Defaults to ON.

Parameters
bSACKOn: Sets the SACK option ON (true) or OFF (false)
void CSirius::EnableTimeStamp ( bool  bTimeStampOn)

Enable the time stamp option. Defaults to ON.

Parameters
bTimeStampOn: Sets TCP time stamp option ON (true) or OFF (false)
int CSirius::GetArpHashResources ( int  iPortNr)

Diagnostic function. Get nr of resources in ARP hash table.

Returns
Nr of entries in ARP hash tableL
int CSirius::GetLastError ( )

Retrieve last error from stack.

Returns
Check sir_socket_defs.h for possible return values
CSystemInfo::prt_linkstatus_t CSirius::GetLinkStatus ( int  iPortNr)

Get link status of physical port.

Parameters
[in]iPortNrPhysical port number
Returns
Pointer to link status sir_eth_linkstatus_t
int CSirius::GetNrOfResourcesInUse ( EResourceType  eResourceType,
int  iAux 
)

Diagnostic function. Get resource in use.

Returns
Nr Of resources in use by designated type
bool CSirius::GetPortConfig ( EPortConfig  ePortConfig,
int  iPortNr,
struct sir_port_config_t ptPortConfig,
bool  bFirst = false 
)

Get configuration info from a physical port.

Only IP configuration info is supported at this moment

Parameters
[in]ePortConfigSpecifies the type of information
[in]iPortNrPhysical port number from which the IP address must be removed
[in]ptPortConfigpointer to sir_port_config_t type variable
[in]bFirstWhen true the first entry is returned, else the next entry is returned.
Returns
true ptPOrtConfig contains valid information
false ptPOrtConfig does not contain valid information, end of list was reached
void* CSirius::GetReferenceOfResource ( EResourceType  eResourceType,
int  iAux 
)

Helper function. Get reference of designated resource.

Returns
Pointer to the resource
bool CSirius::Handle_Packet ( cvmx_wqe_t *  pWQE,
CSiriusMemList ptDestList = NULL 
)

Process packet designated in pWQE.

Packets that should be handled by Sirius stack should be processed by this function

Parameters
[in]pWQEPointer to work queue entry
[in]ptDestListPointer to a memory list were all the received data will be put in. If this is spacified, only IP layer will handle data, RAW, UDP or TCP are skipped
Returns
true Packet was handled and digested by this stack.
false Packet was not handled by this stack. Caller must take care releasing its resources!
int CSirius::Init ( int  iGroup,
void *  pCSiriusI,
ILogging pILogging = NULL 
)

Initialize Sirius TCP stack.

Initialize the socket class before is can be used.

Parameters
[in]iGroupGroup that will handle traffic for this Sirius instance. Cores that are a member of this group will handle packets associated with this Sirius instance. Normally only one instance of Sirius will be sufficient to handle the applications' TCP functionality.
[in]pCSiriusIPointer to class containing the Sirius interface class functions
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
bool CSirius::RemoveIPV4Address ( int  iPortNr,
uint32_t  ui32IP,
uint16_t  ui16VLan 
)

Remove an IPV4 address from a physical port.

The address should be removed from a port that was added via AddPort()

Parameters
[in]iPortNrPhysical port number from which the IP address must be removed
[in]ui32IPIP address to remove
[in]ui16VLanVLAN if needed.
Returns
true Success
false Failure
bool CSirius::RemoveIPV6Address ( int  iPortNr,
TIPAddr  tIp,
uint16_t  ui16VLan = 0 
)

Remove an IPV6 address from a physical port.

The address should be removed from a port that was added via AddPort()

Parameters
[in]iPortNrPhysical port number from which the IP address must be removed
[in]tIpIP address to remove
[in]ui16VLanVLAN if needed. If omitted or zero, no Vlan used
Returns
true Success
false Failure
bool CSirius::SACKEnabled ( )

Check if SACK option is on.

Returns
true: SACK option is ON
false: SACK option is OFF
int CSirius::So_Abort ( int  fd)

Abort the file descriptor. It is terminated immediately.

Parameters
[in]fdFile descriptor
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_Accept ( int  fd,
sir_ip_sockaddr_t ptSockaddr 
)

Create a new connection on socket fd.

When a new connection is available, so_accept will create a new socket, fill the data in ptSockaddr and return the new socket's descriptor

Parameters
[in]fdFile descriptor of the listen socket that is listening for new connections
[in]ptSockaddrPointer to sir_ip_sockaddr_t struct. The function will fill this struct with the clients IP address, the address family and port number on which the connection was initiated.
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information.
SIR_COMMON_OK: No error
SIR_COMMON_EFAULT: Received a NULL pointer for ptSockaddr
SIR_COMMON_EBADF: File descriptor not found or TCB of file descriptor not found
SIR_COMMON_ENOBUFS: Could not insert new socket in cSocket table or could not claim memory for new socket
int CSirius::So_Bind ( int  fd,
sir_ip_sockaddr_t ptSockaddr 
)

Bind the socket to a local IP address and port number.

Parameters
[in]fdFile descriptor
[in]ptSockaddrPointer to address structure containing local addresses and port number.
ptSockaddr->tSin_Addr is IP address of adapter or can be CVM_IP_INADDR_ANY or CVM_IP6_INADDR_ANY if socket should be bound to any adapter
ptSockAddr->ui16Sin_Port is the local port number. If it is zero, Sirius will select one. ptSockAddr->ui8Sin_Family is the address family for this socket (SIR_SO_AF_INET or SIR_SO_AF_INET6)
Returns
0: Success
-1: Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EFAULT: Received a NULL pointer for ptSockaddr
SIR_COMMON_EAFNOSUPPORT: Address family defined in ptSockAddr is not supported
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_ENOSR: Out of stream resources
SIR_COMMON_EINVAL: Source port already in use
SIR_COMMON_EADDRNOTAVAIL: Can not bind address in ptSockAddr to a port
SIR_COMMON_ENOBUFS: Could not insert file descriptor in cBoundSocket table
int CSirius::So_BindOverload ( int  fd,
sir_ip_sockaddr_t ptSockaddr,
const int  iPortNr 
)

Bind the socket to physical port and overload the source IP address with the value in ptSockaddr->ui32Sin_Addr.

When designing an SSL offloader, this function can be used to setup a new connection to a destination. By using the source IP address of the originating party it will fool the destination in thinking the connection is setup by the originating party. When the destination has set its default gateway to the adapter IP address of this port, traffic send to the default gateway will arrive at the SSL offloader.

Parameters
[in]fdFile descriptor
[in]ptSockaddrPointer to address structure containing address family type, local addresses and port number.
ptSockaddr->tSin_Addr is IP address of adapter or can be CVM_IP_INADDR_ANY or CVM_IP6_INADDR_ANY if socket should be bound to any adapter
ptSockAddr->ui16Sin_Port is the local port number. If it is zero, Sirius will select one. ptSockAddr->ui8Sin_Family is the address family for this socket (SIR_SO_AF_INET or SIR_SO_AF_INET6)
[in]iPortNrPhysical port number to which this address is bound
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EFAULT: Received a NULL pointer for ptSockaddr
SIR_COMMON_EAFNOSUPPORT: Address family defined in ptSockAddr is not supported
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_ENOSR: Out of stream resources
SIR_COMMON_EINVAL: Source port already in use or physical port number not supported
SIR_COMMON_EADDRNOTAVAIL: Can not bind address in ptSockAddr to a port
SIR_COMMON_ENOBUFS: Could not insert file descriptor in cBoundSocket table
int CSirius::So_CanSend ( int  fd)

Check the number of bytes that can be send on this session.

Calculates how many bytes can be send according to the TCP usable window size

Parameters
[in]fdFile descriptor
Returns
>=0 Number of bytes that can be send on this socket
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_Close ( int  fd)

Closes the file descriptor so that it no longer refers to a session.

Parameters
[in]fdFile descriptor
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_Connect ( int  fd,
const sir_ip_sockaddr_t ptSockaddr 
)

Connect the socket to the address specified in ptSockAddr.

Parameters
[in]fdFile descriptor
[in]ptSockaddrPointer to address structure containing address family type, local addresses and port number.
ptSockaddr->tSin_Addr is destination IP address
ptSockaddr->ui16Sin_Port is the destination port number
ptSockAddr->ui8Sin_Family is the address family for this socket (SIR_SO_AF_INET or SIR_SO_AF_INET6)
Returns
0: Success
-1: Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EFAULT: Received a NULL pointer for ptSockaddr
SIR_COMMON_EAFNOSUPPORT: Address family defined in ptSockAddr is not supported
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EINVAL: Can not find physical port for this destination
SIR_COMMON_ENOBUFS: Could not insert new socket in cSocket table or could not claim memory for new socket or could not create new TCB for this file descriptor
uint32_t CSirius::So_GetAppTag ( int  fd)

Switch to the application tag.

Handling of application data received by Sirius is processed under the atomic tag of the incoming packet. When this takes a long time, processing of other packets of the same session will be stalled as they need the same atomic tag. To overcome this, the application can switch to the application tag. This will release the atomic tag of this packet and enables processing of packets of the same session on other cores. The application data will be protected by the application tag.

Parameters
[in]fdFile descriptor
Returns
>0 Application Tag
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_GetAvailableData ( int  fd,
EPayload_Indicator  ePayloadIndicator 
)

Get the size of data that is waiting in the receive queue of the specified session.

Request for a ConnCanSend_Notification event when the peers' usable window increases above the specified value. This event can be used to send data to peer that was not sent earlier because the peers´window was too small.

Parameters
[in]fdFile descriptor
[in]ePayloadIndicatorPayload indicator of type ePayloadIndicator
Returns
>=0 Nr of bytes in receive queue of session
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_GetSockName ( int  fd,
sir_ip_sockaddr_t ptSockaddr 
)

Get the current address to which the socket is bound.

Parameters
fdFile Descriptor
ptSockaddrPointer to socket address to which the socket is bound
Returns
0: Success
-1: Failure, use GetLastError() to retrieve more information
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EFAULT: ptSockaddr is NULL pointer
int CSirius::So_GetSockOpt ( int  fd,
ESockOptLevel  eSockLevel,
ESockOptName  eSockOptName,
char pValue,
int  iValueLength 
)

Get socket option.

Get the opstion for a socket, set by So_SetSockOpt function

Parameters
[in]fdFile descriptor
[in]eSockLevelLevel of the option
[in]eSockOptNameName of the option
[in]pValuePointer to Value of the option
[in]iValueLengthLength of the value
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_EINVAL: Illegal value
sir_tcp_tcb* CSirius::So_GetTCB ( int  fd)

Get pointer to TCB which belongs to the file descriptor.

The TCB (Transmission Control Block) is a data structure containing information about the current state of the session.

Parameters
[in]fdFile descriptor
Returns
=0 TCB not found
>0 Pointer to TCB
-1: Failure, use GetLastError() to retrieve more information
int CSirius::So_Listen ( int  fd,
int  backlog 
)

Prepare the socket to be used for accept incoming connections using So_Accept.

Parameters
[in]fdFile descriptor
[in]backlogMaximum number of connections requests queued before further request are allowed
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EFAULT: Can not listen to local port zero or an UDP socket
int CSirius::So_Notify ( int  fd,
void *  pReference 
)

Set the context for the fd.

This context is an application specific pointer which is returned back as a parameter when socket events occur.

Parameters
[in]fdFile descriptor
[in]pReferenceContext specific pointer to user data
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
void* CSirius::So_Notify ( int  fd)

Get the context for the fd.

Get the application specific pointer that was set by So_Notify(int fd, void *pReference).

Parameters
[in]fdFile descriptor
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information.
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_PushOverflowQueue ( int  fd,
void *  pContext 
)
int CSirius::So_Recv ( int  fd,
char pBuf,
int  iLen,
int  iFlags 
)

Get data from socket.

Get up to iLen bytes from the socket. This function is always non-blocking.

Parameters
[in]fdFile descriptor
[in]pBufPointer to char buffer where data is stored
[in]iLenMaximum number of bytes to receive
[in]iFlagsOptions for this function, see sir_socket_defs.h
SIR_SO_PEEK : Do not delete data from receive queue after it has been read
Returns
> 0 Number of bytes returned to pBuf
= 0 Peer has closed the connection
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EAGAIN: Currently no data is available
SIR_COMMON_EINVAL: No data found although it should be there
int CSirius::So_RecvFast ( int  fd,
int  iLen,
CSiriusMemList pMemList 
)

Get message from socket (using CSiriusMemList)

Get up to iLen bytes from the socket and put the result in pMemList.

Parameters
[in]fdFile descriptor
[in]iLenNumber of bytes to get. If set to zero, all bytes of the input socket queue will be transfered. If set to non-zero, the numbers of bytes transfered will be equal to the cumulative payload size of the packets from the input queue that were needed to gather iLen bytes or more.
[in]pMemListPointer to a CSiriusMemList variable which is used to store the data (it may me necessary to store this variable in tag protected memory)
Returns
> 0 Number of bytes returned to pMemList
= 0 Peer has closed the connection
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EAGAIN: Currently no data is available
int CSirius::So_RecvFrom ( int  fd,
char pBuf,
int  iLen,
int  iFlags,
sir_ip_sockaddr_t ptSrc_Addr 
)

Get message from socket.

Get up to iLen bytes from the socket. This function is always non-blocking.

Parameters
[in]fdFile descriptor
[in]pBufPointer to char buffer where data is stored
[in]iLenMaximum number of bytes to receive
[in]iFlagsOptions for this function, see sir_socket_defs.h
SIR_SO_PEEK : Do not delete data from receive queue after it has been read
[in]ptSrc_AddrPointer to sir_ip_sockaddr_t struct. The function will fill this struct with the clients' IP address and port number of which sent the data received.
Returns
> 0 Number of bytes returned to pBuf
= 0 Peer has closed the connection
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EAGAIN: Currently no data is available
SIR_COMMON_EINVAL: No data found although it should be there
int CSirius::So_RecvFromFast ( int  fd,
int  iLen,
CSiriusMemList pMemList,
sir_ip_sockaddr_t ptSrc_Addr 
)

Get message from socket (using CSiriusMemList)

Get up to iLen bytes from the socket and put the result in pMemList.

Parameters
[in]fdFile descriptor
[in]iLenNumber of bytes to get. If set to zero, all bytes of the input socket queue will be transfered. If set to non-zero, the numbers of bytes transfered will be equal to the cumulative payload size of the packets from the input queue that were needed to gather iLen bytes or more.
[in]pMemLisPointer to a CSiriusMemList variable which is used to store the data (it may me necessary to store this variable in tag protected memory)
Returns
> 0 Number of bytes returned to pMemList
= 0 Peer has closed the connection
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EAGAIN: Currently no data is available
int CSirius::So_SendTo ( int  fd,
char pBuf,
int  iLen,
const sir_ip_sockaddr_t ptSockaddr = NULL 
)

Send data on a socket.

If So_SendTo is used on a connection-mode socket (SIR_SO_SOCK_STREAM), the argument of ptSockAddr is ignored.

Parameters
[in]pBufPointer to char buffer
[in]iLenLength of buffer
[in]iFlagsOptions for this function, see sir_socket_defs.h
[in]ptSockaddrPointer to destination of type sir_ip_sockaddr_t. Do not use this parameter if socket is of type SIR_SO_SOCK_STREAM
ptSockaddr->tSin_Addr is destination IP address
ptSockaddr->ui16Sin_Port is the destination port number
ptSockAddr->ui8Sin_Family is the address family for this socket (SIR_SO_AF_INET or SIR_SO_AF_INET6)
Returns
>0 Number of bytes returned to pBuf
=0 Peer has closed the connection
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_SendToFast ( int  fd,
CSiriusMemList pMemList,
const sir_ip_sockaddr_t ptSockaddr = NULL,
CSiriusMemList ptRemains = NULL 
)

Send a memory list on a socket (using CSiriusMemList)

If So_SendToFast is used on a connection-mode socket (SIR_SO_SOCK_STREAM), the argument of ptSockAddr is ignored.

Parameters
[in]pMemListPointer to a CSiriusMemList variable which is used to send the data
[in]ptSockaddrPointer to destination of type sir_ip_sockaddr_t
ptSockaddr->tSin_Addr is destination IP address
ptSockaddr->ui16Sin_Port is the destination port number
ptSockAddr->ui8Sin_Family is the address family for this socket (SIR_SO_AF_INET or SIR_SO_AF_INET6)
[in]ptRemainsPointer to memory list that will contain packets not sent by this function because window not large enough If pointer is NULL, no unsent packets will be returned
Returns
>0 Number of bytes sent
=0 Peer has closed the connection
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EINVAL: Destination can not be NULL when using UDP
SIR_COMMON_EPERM: Fragmented memory lists are not supported in SIR_SO_SOCK_STREAM mode
SIR_COMMON_ENOBUFS: Not enough memory available
SIR_COMMON_EAGAIN: Usable window too small, try again later. Unsent packets are returned in ptRemains
int CSirius::So_SendToFastRetransmit ( int  fd,
CSiriusMemList ptMemList,
const sir_ip_sockaddr_t ptSockAddr,
void *  pVoid,
int  iSize,
int  iGrp = -1 
)

Send a memory list on a UDP or RAW socket (using CSiriusMemList) and do not delete the packet after is was sent.

Parameters
[in]pMemListPointer to a CSiriusMemList variable which is used to send the data
[in]ptSockaddrPointer to destination of type sir_ip_sockaddr_t
ptSockaddr->tSin_Addr is destination IP address
ptSockaddr->ui16Sin_Port is the destination port number
ptSockAddr->ui8Sin_Family is the address family for this socket (SIR_SO_AF_INET or SIR_SO_AF_INET6)
[in]pVoidPointer to application bookkeeping that will be stored for this packet. This pointer will be returned to application when ISirius::Retransmit_Notification will be called.
[in]Groupon which the packets will be coming back to. Defaults to the instance number of Sirius
Returns
>0 Number of bytes send out
=0 Peer has closed the connection
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
SIR_COMMON_EINVAL: Destination can not be NULL when using UDP
SIR_COMMON_ENOBUFS: Not enough memory available
int CSirius::So_SetAppTag ( int  fd,
uint32_t  ui32AppTag 
)

Set the application tag.

When a socket is created, the application tag is assigned a default value that is unique for the associated session. This function will override that default value. Use this if multiple sessions share the same data structure.

Parameters
[in]fdFile descriptor
Returns
0 Ok
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EBADF: File descriptor not found
int CSirius::So_SetSockOpt ( int  fd,
ESockOptLevel  eSockLevel,
ESockOptName  eSockOptName,
char pValue,
int  iValueLength 
)

Set socket option.

Manipulate options for the socket referred to by the file descriptor

Parameters
[in]fdFile descriptor
[in]eSockLevelLevel of the option
[in]eSockOptNameName of the option
[in]pValuePointer to Value of the option
[in]iValueLengthLength of the value
Returns
0 Success
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_EINVAL: Illegal value
int CSirius::So_Socket ( int  domain,
int  type,
int  protocol 
)

Create a new socket.

The socket created is of type "type" in domain "domain" using protocol "protocol"

Parameters
[in]domainSIR_SO_AF_INET or SIR_SO_AF_INET6
[in]typeSIR_SO_SOCK_STREAM, SIR_SO_SOCK_DGRAM , SIR_SO_SOCK_RAW
[in]protocolSIR_IP_IPPROTO_TCP, SIR_IP_IPPROTO_UDP SIR_IP_PROTO_RAW
Returns
!0 Returns the file descriptor of the new socket
-1 Failure, use GetLastError() to retrieve more information
SIR_COMMON_OK: No error
SIR_COMMON_EAFNOSUPPORT: Protocol, domain or type is not supported
SIR_COMMON_EMFILE: No memory for new socket available
bool CSirius::TimeStampEnabled ( )

Check if time stamp option is on.

Returns
true Time stamp option is ON
false Time stamp option is OFF

Friends And Related Function Documentation

friend class CSiriusTCP
friend

Definition at line 42 of file sir_socket.h.


The documentation for this class was generated from the following file: