Browse code

core: typedef'ed several structs, enums and unions

Daniel-Constantin Mierla authored on 20/10/2020 10:36:55
Showing 3 changed files
... ...
@@ -43,12 +43,12 @@
43 43
 
44 44
 extern str ksr_ipv6_hex_style;
45 45
 
46
-enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS, PROTO_SCTP,
47
-	PROTO_WS, PROTO_WSS, PROTO_OTHER };
46
+typedef enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS, PROTO_SCTP,
47
+	PROTO_WS, PROTO_WSS, PROTO_OTHER } sip_protos_t;
48 48
 #define PROTO_LAST PROTO_OTHER
49 49
 
50 50
 #ifdef USE_COMP
51
-enum comp_methods { COMP_NONE, COMP_SIGCOMP, COMP_SERGZ };
51
+typedef enum comp_methods { COMP_NONE, COMP_SIGCOMP, COMP_SERGZ } comp_methods_t;
52 52
 #endif
53 53
 
54 54
 typedef struct ip_addr {
... ...
@@ -69,22 +69,22 @@ typedef struct net {
69 69
 	struct ip_addr mask;
70 70
 } sr_net_t;
71 71
 
72
-union sockaddr_union{
72
+typedef union sockaddr_union{
73 73
 	struct sockaddr     s;
74 74
 	struct sockaddr_in  sin;
75 75
 	struct sockaddr_in6 sin6;
76 76
 	struct sockaddr_storage sas;
77
-};
77
+} sr_sockaddr_union_t;
78 78
 
79 79
 
80
-enum si_flags {
80
+typedef enum si_flags {
81 81
 	SI_NONE         = 0,
82 82
 	SI_IS_IP        = (1<<0),
83 83
 	SI_IS_LO        = (1<<1),
84 84
 	SI_IS_MCAST     = (1<<2),
85 85
 	SI_IS_ANY       = (1<<3),
86 86
 	SI_IS_MHOMED    = (1<<4),
87
-};
87
+} si_flags_t;
88 88
 
89 89
 typedef struct addr_info {
90 90
 	str name; /* name - eg.: foo.bar or 10.0.0.1 */
... ...
@@ -134,11 +134,11 @@ typedef struct socket_info {
134 134
 
135 135
 
136 136
 /* send flags */
137
-enum send_flags {
137
+typedef enum send_flags {
138 138
 	SND_F_FORCE_CON_REUSE   = (1 << 0), /* reuse an existing connection or fail */
139 139
 	SND_F_CON_CLOSE         = (1 << 1), /* close the connection after sending */
140 140
 	SND_F_FORCE_SOCKET      = (1 << 2), /* send socket in dst is forced */
141
-};
141
+} send_flags_t;
142 142
 
143 143
 typedef struct snd_flags {
144 144
 	unsigned short f;          /* snd flags */
... ...
@@ -72,9 +72,9 @@
72 72
 #define READ_WS
73 73
 #endif
74 74
 
75
-enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
76
-						TCP_REQ_OVERRUN, TCP_REQ_BAD_LEN };
77
-enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND,
75
+typedef enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
76
+		TCP_REQ_OVERRUN, TCP_REQ_BAD_LEN } tcp_req_errors_t;
77
+typedef enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND,
78 78
 		H_SKIP_EMPTY_CRLF_FOUND, H_SKIP_EMPTY_CRLFCR_FOUND,
79 79
 		H_SKIP, H_LF, H_LFCR,  H_BODY, H_STARTWS,
80 80
 		H_CONT_LEN1, H_CONT_LEN2, H_CONT_LEN3, H_CONT_LEN4, H_CONT_LEN5,
... ...
@@ -89,18 +89,18 @@ enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND,
89 89
 #ifdef READ_MSRP
90 90
 		, H_MSRP_BODY, H_MSRP_BODY_LF, H_MSRP_BODY_END, H_MSRP_FINISH
91 91
 #endif
92
-	};
92
+	} tcp_req_states_t;
93 93
 
94
-enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1,
94
+typedef enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1,
95 95
 						S_CONN_OK=0, /* established (write or read) */
96 96
 						S_CONN_INIT, /* initial state (invalid) */
97 97
 						S_CONN_EOF,
98 98
 						S_CONN_ACCEPT, S_CONN_CONNECT
99
-					};
99
+					} tcp_conn_states_t;
100 100
 
101 101
 
102 102
 /* fd communication commands */
103
-enum conn_cmds {
103
+typedef enum conn_cmds {
104 104
 	CONN_DESTROY=-3 /* destroy connection & auto-dec. refcnt */,
105 105
 	CONN_ERROR=-2   /* error on connection & auto-dec. refcnt */,
106 106
 	CONN_EOF=-1     /* eof received or conn. closed & auto-dec refcnt */,
... ...
@@ -117,12 +117,12 @@ enum conn_cmds {
117 117
 							* non-empty); refcnts are not touced */,
118 118
 	CONN_NEW_COMPLETE  /* like CONN_NEW_PENDING_WRITE, but there is no
119 119
 						* pending write (the write queue might be empty) */
120
-};
120
+} conn_cmds_t;
121 121
 /* CONN_RELEASE, EOF, ERROR, DESTROY can be used by "reader" processes
122 122
  * CONN_GET_FD, CONN_NEW*, CONN_QUEUED_WRITE only by writers */
123 123
 
124 124
 /* tcp_req flags */
125
-enum tcp_req_flags {
125
+typedef enum tcp_req_flags {
126 126
 	F_TCP_REQ_HAS_CLEN      = (1<<0),
127 127
 	F_TCP_REQ_COMPLETE      = (1<<1),
128 128
 #ifdef READ_HTTP11
... ...
@@ -134,7 +134,7 @@ enum tcp_req_flags {
134 134
 	F_TCP_REQ_MSRP_BODY     = (1<<5),
135 135
 #endif
136 136
 	F_TCP_REQ_HEP3          = (1<<6),
137
-};
137
+} tcp_req_flags_t;
138 138
 
139 139
 #define TCP_REQ_HAS_CLEN(tr)  ((tr)->flags & F_TCP_REQ_HAS_CLEN)
140 140
 #define TCP_REQ_COMPLETE(tr)  ((tr)->flags & F_TCP_REQ_COMPLETE)
... ...
@@ -142,7 +142,7 @@ enum tcp_req_flags {
142 142
 #define TCP_REQ_BCHUNKED(tr)  ((tr)->flags & F_TCP_REQ_BCHUNKED)
143 143
 #endif
144 144
 
145
-struct tcp_req{
145
+typedef struct tcp_req {
146 146
 	struct tcp_req* next;
147 147
 	/* sockaddr ? */
148 148
 	char* buf; /* bytes read so far (+0-terminator)*/
... ...
@@ -160,7 +160,7 @@ struct tcp_req{
160 160
 	int bytes_to_go; /* how many bytes we have still to read from the body*/
161 161
 	enum tcp_req_errors error;
162 162
 	enum tcp_req_states state;
163
-};
163
+} tcp_req_t;
164 164
 
165 165
 struct tcp_connection;
166 166
 
... ...
@@ -41,7 +41,7 @@
41 41
 
42 42
 
43 43
 
44
-struct tls_hooks{
44
+typedef struct tls_hooks{
45 45
 	/* read using tls (should use tcp internal read functions to
46 46
 	   get the data from the connection) */
47 47
 	int  (*read)(struct tcp_connection* c, rd_conn_flags_t* flags);
... ...
@@ -77,7 +77,7 @@ struct tls_hooks{
77 77
 	/* generic pre-init function (called at kamailio start, before module
78 78
 	 * initialization (after modparams) */
79 79
 	int (*pre_init)(void);
80
-};
80
+} tls_hooks_t;
81 81
 
82 82
 
83 83
 extern struct tls_hooks tls_hook;