Mercurial > hg > nginx
comparison src/core/ngx_proxy_protocol.c @ 7254:1fd992589ffe
Core: fixed build, broken by 63e91f263a49.
Both Solaris and Windows define "s_addr" as a macro.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 02 Apr 2018 20:38:43 +0300 |
parents | 63e91f263a49 |
children | 06b01840bd42 |
comparison
equal
deleted
inserted
replaced
7253:63e91f263a49 | 7254:1fd992589ffe |
---|---|
23 u_char len[2]; | 23 u_char len[2]; |
24 } ngx_proxy_protocol_header_t; | 24 } ngx_proxy_protocol_header_t; |
25 | 25 |
26 | 26 |
27 typedef struct { | 27 typedef struct { |
28 u_char s_addr[4]; | 28 u_char src_addr[4]; |
29 u_char d_addr[4]; | 29 u_char dst_addr[4]; |
30 u_char s_port[2]; | 30 u_char src_port[2]; |
31 u_char d_port[2]; | 31 u_char dst_port[2]; |
32 } ngx_proxy_protocol_inet_addrs_t; | 32 } ngx_proxy_protocol_inet_addrs_t; |
33 | 33 |
34 | 34 |
35 typedef struct { | 35 typedef struct { |
36 u_char s_addr[16]; | 36 u_char src_addr[16]; |
37 u_char d_addr[16]; | 37 u_char dst_addr[16]; |
38 u_char s_port[2]; | 38 u_char src_port[2]; |
39 u_char d_port[2]; | 39 u_char dst_port[2]; |
40 } ngx_proxy_protocol_inet6_addrs_t; | 40 } ngx_proxy_protocol_inet6_addrs_t; |
41 | 41 |
42 | 42 |
43 static u_char *ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf, | 43 static u_char *ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf, |
44 u_char *last); | 44 u_char *last); |
219 size_t len; | 219 size_t len; |
220 socklen_t socklen; | 220 socklen_t socklen; |
221 ngx_uint_t version, command, family, transport; | 221 ngx_uint_t version, command, family, transport; |
222 ngx_sockaddr_t sockaddr; | 222 ngx_sockaddr_t sockaddr; |
223 ngx_proxy_protocol_header_t *header; | 223 ngx_proxy_protocol_header_t *header; |
224 ngx_proxy_protocol_inet_addrs_t *inet; | 224 ngx_proxy_protocol_inet_addrs_t *in; |
225 #if (NGX_HAVE_INET6) | 225 #if (NGX_HAVE_INET6) |
226 ngx_proxy_protocol_inet6_addrs_t *inet6; | 226 ngx_proxy_protocol_inet6_addrs_t *in6; |
227 #endif | 227 #endif |
228 | 228 |
229 header = (ngx_proxy_protocol_header_t *) buf; | 229 header = (ngx_proxy_protocol_header_t *) buf; |
230 | 230 |
231 buf += sizeof(ngx_proxy_protocol_header_t); | 231 buf += sizeof(ngx_proxy_protocol_header_t); |
274 | 274 |
275 if ((size_t) (end - buf) < sizeof(ngx_proxy_protocol_inet_addrs_t)) { | 275 if ((size_t) (end - buf) < sizeof(ngx_proxy_protocol_inet_addrs_t)) { |
276 return NULL; | 276 return NULL; |
277 } | 277 } |
278 | 278 |
279 inet = (ngx_proxy_protocol_inet_addrs_t *) buf; | 279 in = (ngx_proxy_protocol_inet_addrs_t *) buf; |
280 | 280 |
281 sockaddr.sockaddr_in.sin_family = AF_INET; | 281 sockaddr.sockaddr_in.sin_family = AF_INET; |
282 sockaddr.sockaddr_in.sin_port = 0; | 282 sockaddr.sockaddr_in.sin_port = 0; |
283 memcpy(&sockaddr.sockaddr_in.sin_addr, inet->s_addr, 4); | 283 memcpy(&sockaddr.sockaddr_in.sin_addr, in->src_addr, 4); |
284 | 284 |
285 c->proxy_protocol_port = ngx_proxy_protocol_parse_uint16(inet->s_port); | 285 c->proxy_protocol_port = ngx_proxy_protocol_parse_uint16(in->src_port); |
286 | 286 |
287 socklen = sizeof(struct sockaddr_in); | 287 socklen = sizeof(struct sockaddr_in); |
288 | 288 |
289 buf += sizeof(ngx_proxy_protocol_inet_addrs_t); | 289 buf += sizeof(ngx_proxy_protocol_inet_addrs_t); |
290 | 290 |
296 | 296 |
297 if ((size_t) (end - buf) < sizeof(ngx_proxy_protocol_inet6_addrs_t)) { | 297 if ((size_t) (end - buf) < sizeof(ngx_proxy_protocol_inet6_addrs_t)) { |
298 return NULL; | 298 return NULL; |
299 } | 299 } |
300 | 300 |
301 inet6 = (ngx_proxy_protocol_inet6_addrs_t *) buf; | 301 in6 = (ngx_proxy_protocol_inet6_addrs_t *) buf; |
302 | 302 |
303 sockaddr.sockaddr_in6.sin6_family = AF_INET6; | 303 sockaddr.sockaddr_in6.sin6_family = AF_INET6; |
304 sockaddr.sockaddr_in6.sin6_port = 0; | 304 sockaddr.sockaddr_in6.sin6_port = 0; |
305 memcpy(&sockaddr.sockaddr_in6.sin6_addr, inet6->s_addr, 16); | 305 memcpy(&sockaddr.sockaddr_in6.sin6_addr, in6->src_addr, 16); |
306 | 306 |
307 c->proxy_protocol_port = ngx_proxy_protocol_parse_uint16(inet6->s_port); | 307 c->proxy_protocol_port = ngx_proxy_protocol_parse_uint16(in6->src_port); |
308 | 308 |
309 socklen = sizeof(struct sockaddr_in6); | 309 socklen = sizeof(struct sockaddr_in6); |
310 | 310 |
311 buf += sizeof(ngx_proxy_protocol_inet6_addrs_t); | 311 buf += sizeof(ngx_proxy_protocol_inet6_addrs_t); |
312 | 312 |