48
48
#include <sys/types.h>
49
49
#include <inttypes.h>
50
50
51
+ #include "haproxy.h"
52
+
51
53
#if defined(_WIN32 )
52
54
53
55
#define __BEGIN_DECLS
54
56
#define __END_DECLS
55
57
56
58
/* integral types */
57
59
#ifndef _MSC_VER
58
- #include <_bsd_types.h> /* XXX mingw (defines u_long) */
60
+ #include <_bsd_types.h> /* XXX mingw (defines u_long) */
59
61
#endif
60
62
typedef uint8_t u_char ;
61
63
typedef uint16_t u_int16_t ;
@@ -77,7 +79,7 @@ struct iovec {
77
79
};
78
80
79
81
#include <winsock2.h>
80
- #include <ws2tcpip.h> /* XXX mingw */
82
+ #include <ws2tcpip.h> /* XXX mingw */
81
83
82
84
#endif
83
85
@@ -109,107 +111,107 @@ typedef int32_t rpc_inline_t;
109
111
* Package params support
110
112
*/
111
113
112
- #define TIRPC_GET_PARAMETERS 0
113
- #define TIRPC_PUT_PARAMETERS 1
114
- #define TIRPC_GET_DEBUG_FLAGS 2
115
- #define TIRPC_SET_DEBUG_FLAGS 3
116
- #define TIRPC_GET_OTHER_FLAGS 4
117
- #define TIRPC_SET_OTHER_FLAGS 5
114
+ #define TIRPC_GET_PARAMETERS 0
115
+ #define TIRPC_PUT_PARAMETERS 1
116
+ #define TIRPC_GET_DEBUG_FLAGS 2
117
+ #define TIRPC_SET_DEBUG_FLAGS 3
118
+ #define TIRPC_GET_OTHER_FLAGS 4
119
+ #define TIRPC_SET_OTHER_FLAGS 5
118
120
119
121
/*
120
122
* Debug flags support
121
123
*/
122
124
123
- #define TIRPC_FLAG_NONE 0x0000000
124
- #define TIRPC_DEBUG_FLAG_NONE 0x0000000
125
- #define TIRPC_DEBUG_FLAG_ERROR 0x0000001
126
- #define TIRPC_DEBUG_FLAG_EVENT 0x0000002
127
- #define TIRPC_DEBUG_FLAG_WARN 0x0000004
128
- #define TIRPC_DEBUG_FLAG_LOCK 0x0000008
129
- #define TIRPC_DEBUG_FLAG_REFCNT 0x0000010
130
- #define TIRPC_DEBUG_FLAG_RBTREE 0x0000020
131
- #define TIRPC_DEBUG_FLAG_RPCSEC_GSS 0x0000040
132
- #define TIRPC_DEBUG_FLAG_AUTH 0x0000080
133
- #define TIRPC_DEBUG_FLAG_CLNT_DG 0x0000100
134
- #define TIRPC_DEBUG_FLAG_CLNT_RDMA 0x0000200
135
- #define TIRPC_DEBUG_FLAG_CLNT_SCTP 0x0000400
136
- #define TIRPC_DEBUG_FLAG_CLNT_VC 0x0000800
137
- #define TIRPC_DEBUG_FLAG_CLNT_BCAST 0x0001000
138
- #define TIRPC_DEBUG_FLAG_CLNT_RAW 0x0002000
139
- #define TIRPC_DEBUG_FLAG_CLNT_REQ 0x0004000
140
- #define TIRPC_DEBUG_FLAG_CLNT 0x0008000
141
- #define TIRPC_DEBUG_FLAG_SVC_DG 0x0010000
142
- #define TIRPC_DEBUG_FLAG_SVC_RDMA 0x0020000
143
- #define TIRPC_DEBUG_FLAG_SVC_SCTP 0x0040000
144
- #define TIRPC_DEBUG_FLAG_SVC_VC 0x0080000
145
- #define TIRPC_DEBUG_FLAG_SVC_RQST 0x0100000
146
- #define TIRPC_DEBUG_FLAG_SVC_XPRT 0x0200000
147
- #define TIRPC_DEBUG_FLAG_SVC 0x0400000
148
- #define TIRPC_DEBUG_FLAG_XDR 0x0800000
149
- #define TIRPC_DEBUG_FLAG_WORKER 0x1000000
150
- #define TIRPC_DEBUG_FLAG_RPC_MSG 0x2000000
151
- #define TIRPC_DEBUG_FLAG_RPC_RDMA 0x4000000
152
- #define TIRPC_DEBUG_FLAG_XDR_RDMA 0x8000000
125
+ #define TIRPC_FLAG_NONE 0x0000000
126
+ #define TIRPC_DEBUG_FLAG_NONE 0x0000000
127
+ #define TIRPC_DEBUG_FLAG_ERROR 0x0000001
128
+ #define TIRPC_DEBUG_FLAG_EVENT 0x0000002
129
+ #define TIRPC_DEBUG_FLAG_WARN 0x0000004
130
+ #define TIRPC_DEBUG_FLAG_LOCK 0x0000008
131
+ #define TIRPC_DEBUG_FLAG_REFCNT 0x0000010
132
+ #define TIRPC_DEBUG_FLAG_RBTREE 0x0000020
133
+ #define TIRPC_DEBUG_FLAG_RPCSEC_GSS 0x0000040
134
+ #define TIRPC_DEBUG_FLAG_AUTH 0x0000080
135
+ #define TIRPC_DEBUG_FLAG_CLNT_DG 0x0000100
136
+ #define TIRPC_DEBUG_FLAG_CLNT_RDMA 0x0000200
137
+ #define TIRPC_DEBUG_FLAG_CLNT_SCTP 0x0000400
138
+ #define TIRPC_DEBUG_FLAG_CLNT_VC 0x0000800
139
+ #define TIRPC_DEBUG_FLAG_CLNT_BCAST 0x0001000
140
+ #define TIRPC_DEBUG_FLAG_CLNT_RAW 0x0002000
141
+ #define TIRPC_DEBUG_FLAG_CLNT_REQ 0x0004000
142
+ #define TIRPC_DEBUG_FLAG_CLNT 0x0008000
143
+ #define TIRPC_DEBUG_FLAG_SVC_DG 0x0010000
144
+ #define TIRPC_DEBUG_FLAG_SVC_RDMA 0x0020000
145
+ #define TIRPC_DEBUG_FLAG_SVC_SCTP 0x0040000
146
+ #define TIRPC_DEBUG_FLAG_SVC_VC 0x0080000
147
+ #define TIRPC_DEBUG_FLAG_SVC_RQST 0x0100000
148
+ #define TIRPC_DEBUG_FLAG_SVC_XPRT 0x0200000
149
+ #define TIRPC_DEBUG_FLAG_SVC 0x0400000
150
+ #define TIRPC_DEBUG_FLAG_XDR 0x0800000
151
+ #define TIRPC_DEBUG_FLAG_WORKER 0x1000000
152
+ #define TIRPC_DEBUG_FLAG_RPC_MSG 0x2000000
153
+ #define TIRPC_DEBUG_FLAG_RPC_RDMA 0x4000000
154
+ #define TIRPC_DEBUG_FLAG_XDR_RDMA 0x8000000
153
155
154
156
/* or symbolic names for default */
155
- #define TIRPC_DEBUG_FLAG_DEFAULT \
156
- (TIRPC_DEBUG_FLAG_ERROR | \
157
- TIRPC_DEBUG_FLAG_EVENT | \
157
+ #define TIRPC_DEBUG_FLAG_DEFAULT \
158
+ (TIRPC_DEBUG_FLAG_ERROR | TIRPC_DEBUG_FLAG_EVENT | \
158
159
TIRPC_DEBUG_FLAG_WARN)
159
160
160
- #define TIRPC_DEBUG_FLAG_CLNT_RPCB (TIRPC_DEBUG_FLAG_CLNT)
161
+ #define TIRPC_DEBUG_FLAG_CLNT_RPCB (TIRPC_DEBUG_FLAG_CLNT)
161
162
162
- typedef void * (* mem_1_size_t ) (size_t ,
163
- const char * file , int line , const char * function );
164
- typedef void * (* mem_2_size_t ) (size_t , size_t ,
165
- const char * file , int line , const char * function );
166
- typedef void * (* mem_p_size_t ) (void * , size_t ,
167
- const char * file , int line , const char * function );
168
- typedef void (* mem_free_size_t ) (void * , size_t );
169
- typedef void (* mem_format_t ) (const char * fmt , ...);
170
- typedef void (* mem_char_t ) (const char * );
163
+ typedef void * (* mem_1_size_t )(size_t , const char * file , int line ,
164
+ const char * function );
165
+ typedef void * (* mem_2_size_t )(size_t , size_t , const char * file , int line ,
166
+ const char * function );
167
+ typedef void * (* mem_p_size_t )(void * , size_t , const char * file , int line ,
168
+ const char * function );
169
+ typedef void (* mem_free_size_t )(void * , size_t );
170
+ typedef void (* mem_format_t )(const char * fmt , ...);
171
+ typedef void (* mem_char_t )(const char * );
171
172
172
173
/*
173
174
* Package params support
174
175
*/
175
176
typedef struct tirpc_pkg_params {
176
177
uint32_t debug_flags ;
177
178
uint32_t other_flags ;
178
- mem_char_t thread_name_ ;
179
- mem_format_t warnx_ ;
180
- mem_free_size_t free_size_ ;
181
- mem_1_size_t malloc_ ;
182
- mem_2_size_t aligned_ ;
183
- mem_2_size_t calloc_ ;
184
- mem_p_size_t realloc_ ;
179
+ mem_char_t thread_name_ ;
180
+ mem_format_t warnx_ ;
181
+ mem_free_size_t free_size_ ;
182
+ mem_1_size_t malloc_ ;
183
+ mem_2_size_t aligned_ ;
184
+ mem_2_size_t calloc_ ;
185
+ mem_p_size_t realloc_ ;
185
186
} tirpc_pkg_params ;
186
187
187
188
extern tirpc_pkg_params __ntirpc_pkg_params ;
188
189
189
190
#include <misc/abstract_atomic.h>
190
191
191
- #define __warnx (flags , ...) \
192
- do { \
193
- if (__ntirpc_pkg_params.debug_flags & (flags)) { \
194
- __ntirpc_pkg_params.warnx_(__VA_ARGS__); \
195
- } \
192
+ #define __warnx (flags , ...) \
193
+ do { \
194
+ if (__ntirpc_pkg_params.debug_flags & (flags)) { \
195
+ __ntirpc_pkg_params.warnx_(__VA_ARGS__); \
196
+ } \
196
197
} while (0)
197
198
198
199
#define __debug_flag (flags ) (__ntirpc_pkg_params.debug_flags & (flags))
199
200
200
- #define mem_alloc (size ) __ntirpc_pkg_params.malloc_((size), \
201
- __FILE__, __LINE__, __func__)
202
- #define mem_aligned (align , size ) __ntirpc_pkg_params.aligned_((align), (size), \
203
- __FILE__, __LINE__, __func__)
204
- #define mem_calloc (count , size ) __ntirpc_pkg_params.calloc_((count), (size), \
205
- __FILE__, __LINE__, __func__)
206
- #define mem_realloc (p , size ) __ntirpc_pkg_params.realloc_((p), (size), \
207
- __FILE__, __LINE__, __func__)
208
- #define mem_zalloc (size ) __ntirpc_pkg_params.calloc_(1, (size), \
209
- __FILE__, __LINE__, __func__)
210
-
211
- static inline void
212
- mem_free (void * p , size_t n )
201
+ #define mem_alloc (size ) \
202
+ __ntirpc_pkg_params.malloc_((size), __FILE__, __LINE__, __func__)
203
+ #define mem_aligned (align , size ) \
204
+ __ntirpc_pkg_params.aligned_((align), (size), __FILE__, __LINE__, \
205
+ __func__)
206
+ #define mem_calloc (count , size ) \
207
+ __ntirpc_pkg_params.calloc_((count), (size), __FILE__, __LINE__, \
208
+ __func__)
209
+ #define mem_realloc (p , size ) \
210
+ __ntirpc_pkg_params.realloc_((p), (size), __FILE__, __LINE__, __func__)
211
+ #define mem_zalloc (size ) \
212
+ __ntirpc_pkg_params.calloc_(1, (size), __FILE__, __LINE__, __func__)
213
+
214
+ static inline void mem_free (void * p , size_t n )
213
215
{
214
216
__ntirpc_pkg_params .free_size_ (p , n );
215
217
}
@@ -220,8 +222,8 @@ mem_free(void *p, size_t n)
220
222
221
223
#include <string.h>
222
224
223
- static inline void *
224
- mem_strdup_ ( const char * s , const char * file , int line , const char * function )
225
+ static inline void * mem_strdup_ ( const char * s , const char * file , int line ,
226
+ const char * function )
225
227
{
226
228
size_t l = strlen (s ) + 1 ;
227
229
void * t = __ntirpc_pkg_params .malloc_ (l , file , line , function );
@@ -256,7 +258,24 @@ struct netbuf {
256
258
257
259
struct rpc_address {
258
260
struct netbuf nb ;
259
- struct sockaddr_storage ss ; /* address buffer */
261
+ struct sockaddr_storage ss ; /* address buffer */
262
+ };
263
+
264
+ /*
265
+ * The network id struct is used in combination with the client address
266
+ * to identify the unique client.
267
+ * Using proxy protocol, it's possible for clients from multiple networks to connect
268
+ * to the server, although they have the same IP address.
269
+ * This means that the client IP is not enough to identify the client and the network id
270
+ * is needed as well.
271
+ */
272
+ struct network_id {
273
+ /* based on proxy protocol TLV header type values */
274
+ uint32_t source ;
275
+ union {
276
+ uint64_t gcp_psc_connection_id ;
277
+ /* TODO: add support for more common cloud providers */
278
+ };
260
279
};
261
280
262
281
/*
@@ -280,4 +299,4 @@ struct __rpc_sockinfo {
280
299
int si_alen ;
281
300
};
282
301
283
- #endif /* _TIRPC_TYPES_H */
302
+ #endif /* _TIRPC_TYPES_H */
0 commit comments