src/stack/rawethsock/rawethsock.c File Reference

The file implements the RAWETHSOCK object which is the socket library for Raw Ethernet Sockets. Raw Ethernet Sockets are useful for transporting data over Ethernet network using custom Layer 2 Protocol types, i.e other than IPv4, IPv6 etc. More...


Functions

int RawEthSockNew (int Family, int Type, int Protocol, int RxBufSize, int TxBufSize, HANDLE *phSock)
int RawEthSockClose (HANDLE h)
int RawEthSockCheck (HANDLE h, int IoType)
int RawEthSockStatus (HANDLE h, int request, int *results)
int RawEthSockShutdown (HANDLE h, int how)
int RawEthSockSet (HANDLE hSock, int Type, int Prop, void *pbuf, int size)
int RawEthSockGet (HANDLE hSock, int Type, int Prop, void *pbuf, int *psize)
int RawEthSockRecvNC (HANDLE h, PBM_Pkt **ppPkt)
int RawEthSockSend (HANDLE h, char *pBuf, INT32 size, INT32 *pRetSize)
int RawEthSockSendNC (HANDLE h, char *pBuf, INT32 size, HANDLE hPkt, INT32 *pRetSize)
int RawEthSockNotify (HANDLE h, int Notification)
PBM_Pkt * RawEthSockCreatePacket (HANDLE hSock, UINT32 Payload, UINT32 *pError)


Detailed Description

The file implements the RAWETHSOCK object which is the socket library for Raw Ethernet Sockets. Raw Ethernet Sockets are useful for transporting data over Ethernet network using custom Layer 2 Protocol types, i.e other than IPv4, IPv6 etc.

NOTE: (C) Copyright 2008, Texas Instruments, Inc.

Function Documentation

int RawEthSockCheck ( HANDLE  h,
int  IoType 
)

Description
The function is called to determine if there is any operation pending on the socket.

Parameters:
[in] h Socket Handle which needs to be checked.
[in] IoType Type of operation which is pending.
Return values:
1 - Operation is pending
0 - Operation is not pending

int RawEthSockClose ( HANDLE  h  ) 

Description
The function closes a Raw ethernet Socket.

Parameters:
[in] h Socket Handle which is to be closed.
Return values:
Success - 0
Error - Non Zero

PBM_Pkt* RawEthSockCreatePacket ( HANDLE  hSock,
UINT32  Payload,
UINT32 *  pError 
)

Description
The function creates a Raw Ethernet packet for the SOCKRAWETH Family.

Parameters:
[in] hSock Handle of the socket for which the packet is being created.
[in] Payload Size of the packet
[in] pError Pointer to propagate back any errors from this API.
Return values:
Success - Pointer to the packet created
Error - NULL

int RawEthSockGet ( HANDLE  hSock,
int  Type,
int  Prop,
void *  pbuf,
int *  psize 
)

Description
The function is used to get the socket parameters

Parameters:
[in] hSock Handle to the socket.
[in] Type Socket Level which is to be configured.
  • SOL_SOCKET: Socket Properties
[in] Prop The Property which needs to be configured.
[out] pbuf Data buffer where the value of property will be stored.
[out] psize Size of the Data buffer
Return values:
Success - 0
Error - Non Zero

int RawEthSockNew ( int  Family,
int  Type,
int  Protocol,
int  RxBufSize,
int  TxBufSize,
HANDLE *  phSock 
)

Description
The function creates a new Raw Ethernet Socket.

Parameters:
[in] Family Socket Family. Only AF_RAWETH is supported.
[in] Type The type of socket being created
  • SOCKRAWETH : RAW Socket
[in] Protocol Valid Values are 0, IPPROTO_UDP and IPPROTO_TCP.
[in] RxBufSize Receive buffer size of the Socket.
[in] TxBufSize Transmit buffer size of the Socket.
[out] phSock Socket Handle which is returned.
Return values:
Success - 0
Error - Non Zero

int RawEthSockNotify ( HANDLE  h,
int  Notification 
)

Description
This function is called by RawEthernet object to notify the socket of any read/write/connection status activity.

Parameters:
[in] h Socket handle on which activity has been detected
[in] Notification Notification Event detected.
Return values:
1 - Message was accepted
0 - Message was not accepted
The action taken on a rejected message is message and protocol dependent.

int RawEthSockRecvNC ( HANDLE  h,
PBM_Pkt **  ppPkt 
)

Description
The function receives data from a socket without copy.

Parameters:
[in] h Socket Handle from where data has to be read.
[in] ppPkt Pointer in which the packet received will be returned.
Return values:
Success - 0
Error - Non Zero

int RawEthSockSend ( HANDLE  h,
char *  pBuf,
INT32  size,
INT32 *  pRetSize 
)

Description
The function send data out using a socket. This is the "copy" implementation of send() wherein the data buffer is copied over by the L3 before being sent out. Thus, the buffer allocation and free is responsibility of the application.

Parameters:
[in] h Socket Handle from where data has to be send out
[in] pBuf Data Buffer which contains the data to be sent out.
[in] size Size of the data buffer passed.
[in] pRetSize Total number of data bytes actually sent out.
Return values:
Success - 0
Error - Non Zero

int RawEthSockSendNC ( HANDLE  h,
char *  pBuf,
INT32  size,
HANDLE  hPkt,
INT32 *  pRetSize 
)

Description
The function send data out using a socket without copy.

Parameters:
[in] h Socket Handle from where data has to be send out
[in] pBuf Data Buffer which contains the data to be sent out.
[in] size Size of the data buffer passed.
[in] hPkt Handle to the packet that needs to be sent out on wire.
[in] pRetSize Total number of data bytes actually sent out.
Return values:
Success - 0
Error - Non Zero

int RawEthSockSet ( HANDLE  hSock,
int  Type,
int  Prop,
void *  pbuf,
int  size 
)

Description
The function is used to set the socket parameters

Parameters:
[in] hSock Handle to the socket.
[in] Type Socket Level which is to be configured.
  • SOL_SOCKET: Socket Properties
[in] Prop The Property which needs to be configured.
[in] pbuf Data buffer where the value of property is present
[in] size Size of the Data buffer
Return values:
Success - 0
Error - Non Zero

int RawEthSockShutdown ( HANDLE  h,
int  how 
)

Description
The function shuts down the raw ethernet socket.

Parameters:
[in] h Socket Handle which is to be shutdown.
[out] how 
  • SHUT_RD: Closes the Read pipe of the socket
  • SHUT_WR: Closes the Write pipe of the socket
  • SHUT_RDWR: Closes both the Read & Write pipes.
Return values:
Always returns 0.

int RawEthSockStatus ( HANDLE  h,
int  request,
int *  results 
)

Description
The function returns the socket status.

Parameters:
[in] h Socket Handle which needs to be checked.
[in] request Type of request
[out] results Result buffer which has the result of the request.
Return values:
Success - 0
Error - Non Zero


Copyright 2009, Texas Instruments Incorporated