All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sir_cwrapper.h
Go to the documentation of this file.
1 /*
2  * sir_cwrapper.h
3  *
4  * Created on: Jan 27, 2015
5  * Author: root
6  */
7 
8 #ifndef SIR_CWRAPPER_H_
9 #define SIR_CWRAPPER_H_
10 
11 #include <cvmx.h>
12 
14 typedef union
15 {
16  uint64_t u64;
17  struct {
18  uint64_t duplex:8;
19  uint64_t status:8;
20 #if OCTEON_SDK_VERSION_NUM < 301020000ull // SDK 3.1.2 build 000
21  uint64_t speed:16;
22  uint64_t reserved:32;
23 #else
24  uint64_t speed:18;
25  uint64_t reserved:30;
26 #endif
27  };
29 
30 
31 #ifdef __cplusplus
33 
35 
38 {
39 public:
42  static void CToCppSockAddr(const sir_ip_sockaddr_t *ptCSockAddr, sir_ip_sockaddr_t *ptCppSockAddr)
43  {
44  if (ptCppSockAddr == NULL || ptCSockAddr == NULL) return;
45  ptCppSockAddr->ui8Sin_Family = ptCSockAddr->ui8Sin_Family;
46  ptCppSockAddr->ui16Sin_Port = ptCSockAddr->ui16Sin_Port;
47  if (ptCSockAddr->ui8Sin_Family == SIR_SO_AF_INET)
48  ptCppSockAddr->tSin_Addr = ptCSockAddr->tSin_Addr.ui32IPV4Addr;
49  else
50  ptCppSockAddr->tSin_Addr = ptCSockAddr->tSin_Addr;
51  }
52 
53 private:
54  // Virtual functions from ISirius class that handle notifications
55  void Read_Notification(int fd, void *pContext);
56  void Accept_Notification(int fd, void *pContext);
57  void Close_Notification(int fd, void *pContext);
58  void Reset_Rx_Notification(int fd, void *pContext);
59  void Reset_Tx_Notification(int fd, void *pContext);
60  void ConnError_Notification(int fd, void *pContext);
61  void ConnEst_Notification(int fd, void *pContext);
62  void ConnCanSend_Notification(int fd, void *pContext);
63  void Retransmit_Notification(int fd, void *pContext, void *pUserAux, sir_memlist_seg *ptSegment);
64  void Timer_Notification(int fd, void *pContext);
65  void SysTimer_Notification(void);
66  void PortStatusChanged(int iPortNr, CSystemInfo::prt_linkstatus_t *ptPortStatusNew);
67 
68 };
69 #else
70  #include <cvmx-wqe.h>
71  #include <stdbool.h>
72  #include "sir_socket_defs.h"
73  #include "sir_cmemlist.h"
74  #include "sir_ctimer.h"
75  #include "sir_ccoremask.h"
76  #include "sir_socket_misc.h"
77 
78  #define set_last_error(err) sir_errno = err;
79 
80  extern int sir_errno; // Last error
81 
82  int Sirius_Init();
83  int So_Accept(int fd, struct sir_ip_sockaddr_t *ptSockaddr);
84  int So_Bind(int fd, struct sir_ip_sockaddr_t *ptSockaddr);
85  int So_BindOverload(int fd, struct sir_ip_sockaddr_t *ptSockaddr, const int iPortNr);
86  int So_CanSend(int fd);
87  int So_Close(int fd);
88  int So_Abort(int fd);
89  int So_Connect(int fd, const struct sir_ip_sockaddr_t *ptSockaddr);
90  int So_GetSockName(int fd, struct sir_ip_sockaddr_t *ptSockaddr);
91  int So_Listen(int fd, int backlog);
92  int So_SetNotify(int fd, void *pReference);
93  void *So_GetNotify(int fd);
94  int So_Recv(int fd, char *pBuf, int iLen, int iFlags);
95  int So_RecvFast(int fd, pMemList pMemList, int iFlags);
96  int So_RecvFrom(int fd, char *pBuf, int iLen, int iFlags, struct sir_ip_sockaddr_t *ptSrc_Addr);
97  int So_RecvFromFast(int fd, pMemList ptMemList, int iFlags, struct sir_ip_sockaddr_t *ptSrc_Addr);
98 
99  int So_SendTo (int fd, char *pBuf, int iLen, const struct sir_ip_sockaddr_t *ptSockaddr);
100  int So_SendToFast(int fd, pMemList ptMemList, const struct sir_ip_sockaddr_t *ptSockaddr);
101  int So_SendToFastRetransmit(int fd, CSiriusMemList *ptMemList, const sir_ip_sockaddr_t *ptSockAddr, void *pVoid, int iSize, int iGrp);
102 
103  int So_SetSockOpt(int fd, ESockOptLevel eSockLevel, ESockOptName eSockOptName, char *pValue, int iValueLength);
104  int So_GetSockOpt(int fd, ESockOptLevel eSockLevel, ESockOptName eSockOptName, char *pValue, int iValueLength);
105  int So_Socket(int domain, int type, int protocol);
106  int So_PushOverflowQueue(int fd, void *pContext);
107 
108  int AddIPV4Address(int iPortNr, uint32_t ui32IP, uint32_t ui32Gateway, uint32_t ui32Netmask, uint16_t ui16VLan);
109  int RemoveIPV4Address(int iPortNr, uint32_t ui32IP, uint16_t ui16VLan);
110  bool AddIPV6Address(int iPortNr, TIPAddr tIP, TIPAddr tGateway, uint8_t ui8BitMask, uint16_t ui16VLan);
111 
112  bool RemoveIPV6Address(int iPortNr, TIPAddr tIP, uint16_t ui16VLan);
113 
114  int AddPortDefault(int iPortNr);
115  int AddPort(int iPortNr, int iIpv4NrOfArpEntries, int iIpv4NrOfVlans, int iIpv6NrOfCacheEntriesPow2, int iIpv6NrOfInterfaceEntries,
116  int iIpv6NrOfRouterEntries, int iIpv6NrOfPrefixEntries, bool bIpv6SlaacEnabled);
117  int AddIPV6VLAN(int iPortNr, uint16_t ui16VLAN);
118 
119  int DisplayARPStats(int iPortNr);
120  int GetNrOfResourcesInUse(EResourceType eResourceTType, int iAux);
121  int GetLastError();
122  sir_linkstatus_t GetPortStatus(int iPortNr);
123  int Handle_Packet(cvmx_wqe_t *pWQE);
124  int Handle_Packet_IP(cvmx_wqe_t *pWQE, void *pMemlist);
125 
126  void DropPacket(cvmx_wqe_t *pWQE);
127  bool SetWindowSize(int iWindowSize);
128 
129  void EnableTimeStamp(bool bTimeStampOn);
130  bool TimeStampEnabled();
131  void EnableSACK(bool bSACKOn);
132  bool SACKEnabled();
133 
134 #endif /* __cplusplus */
135 
136 #endif /* SIR_CWRAPPER_H_ */
Sirius interface class.
Definition: sir_isocket.h:20
uint16_t ui16Sin_Port
TCP/UDP port number.
Struct contains link information.
Definition: sir_cwrapper.h:14
#define SIR_SO_AF_INET
Sirius C-wrapper class.
Definition: sir_cwrapper.h:37
ESockOptName
SetSocknames enumeration.
Struct contains an IPV4 or an IPV6 address.
Definition: packet-defines.h:7
void * pMemList
Definition: sir_cmemlist.h:16
Struct contains address information.
uint64_t u64
union
Definition: sir_cwrapper.h:16
struct TIPAddr tSin_Addr
IP4/IPV6 address struct.
uint32_t ui32IPV4Addr
IPV4 address.
Sirius main class.
Definition: sir_socket.h:40
EResourceType
ESockOptLevel
SetSocklevels.
uint8_t ui8Sin_Family
Address family type (SIR_SO_AF_INET = IPv4, SIR_SO_AF_INET6 = IPV6)
Most important class of Sirius. Used to maintain and process all kinds of queues. ...
Definition: sir_memlist.h:51
CSirius m_cSirius
Definition: sir_cwrapper.h:40
static void CToCppSockAddr(const sir_ip_sockaddr_t *ptCSockAddr, sir_ip_sockaddr_t *ptCppSockAddr)
C does not have operators that automatically setup a IPV4 address in the sir_ip_sockaddr_t struct...
Definition: sir_cwrapper.h:42