All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sir_socket_misc.h
Go to the documentation of this file.
1 /*
2  * sir_socket_misc.h
3  *
4  * Created on: Mar 7, 2014
5  * Author: root
6  */
7  // Needed by doxygen
9 
10 #ifndef SIR_SOCKET_MISC_H_
11 #define SIR_SOCKET_MISC_H_
12 
13 #ifdef __cplusplus
14 #include "tcp/sir_tcp_includes.h"
15 #endif
16 #define MAXSOCKETONPORT 16 // Maximum number of sockets listening to the same port
17 
18 typedef enum
19 {
29 
30 #ifdef __cplusplus
31 
32 typedef struct // struct that contains the listen fd's per listen port
33 {
34  TIPAddr tBoundIPAddr[MAXSOCKETONPORT]; // IP address socket is bound to
35  int fd[MAXSOCKETONPORT]; // List of sockets that are listening to this port
36  int iNrOfUsers; // Count value of sockets using this port
37 }TPrt2Fd;
38 
39 typedef struct // Struct that holds some information about the socket when using UDP/RAW retransmit
40 {
41  int fd; // Fd of originating socket
42 }TRetr_ID;
43 
45 
48 {
49 public:
50  static int handle_to_fd(sir_so_socket_t *ptSocket);
51  static sir_so_socket_t* fd_to_handle(int fd);
52  bool SetStartUnused(uint8_t ui8StartUnused);
53  bool SetWindowSize(uint32_t ui32WindowSize);
54 
55  static TIPAddr pton(int domain, const char *src);
56  static TIPAddr pton(const char *src);
57 
58  static const char* ntop(int domain, const TIPAddr &tIpAddr, char *dst, int size);
59  static const char* ntop(TIPAddr &tIpAddr, char *dst, int size);
60 };
61 
62 class CLookupTable2Fd : public CFreeIndexStorage<TPrt2Fd>
63 {
64 public:
65  // Test if a fd is assigned to the designated port
66  bool IsInUse(uint16_t ui16SrcPrt);
67  bool IsInUse(const sir_ip_sockaddr_t *ptSockAddr);
68  bool Add(int fd, const sir_ip_sockaddr_t *ptSockAddr);
69  bool Remove(int fd, const sir_ip_sockaddr_t *ptSockAddr);
70  int GetEntryWithIndex(uint16_t ui16SrcPrt, int iIndex);
71  int MaxPortEntries();
72  bool Clear(int fd, uint16_t ui16SrcPrt);
73 };
74 #endif /* cplusplus */
75 #endif /* SIR_SOCKET_MISC_H_ */
bool IsInUse(uint16_t ui16SrcPrt)
static sir_so_socket_t * fd_to_handle(int fd)
Sirius Misc class.
bool Remove(int fd, const sir_ip_sockaddr_t *ptSockAddr)
bool SetWindowSize(uint32_t ui32WindowSize)
bool Add(int fd, const sir_ip_sockaddr_t *ptSockAddr)
static TIPAddr pton(int domain, const char *src)
bool SetStartUnused(uint8_t ui8StartUnused)
Struct contains an IPV4 or an IPV6 address.
Definition: packet-defines.h:7
Struct contains address information.
bool Clear(int fd, uint16_t ui16SrcPrt)
static int handle_to_fd(sir_so_socket_t *ptSocket)
int GetEntryWithIndex(uint16_t ui16SrcPrt, int iIndex)
#define MAXSOCKETONPORT
EResourceType
static const char * ntop(int domain, const TIPAddr &tIpAddr, char *dst, int size)
int iNrOfUsers