Mercurial > hg > nginx-quic
annotate src/core/ngx_inet.h @ 6432:cf3e75cfa951
Added variables support to server_tokens.
It can now be set to "off" conditionally, e.g. using the map
directive.
An empty value will disable the emission of the Server: header
and the signature in error messages generated by nginx.
Any other value is treated as "on", meaning that full nginx
version is emitted in the Server: header and error messages
generated by nginx.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Tue, 15 Mar 2016 13:36:19 +0300 |
parents | d39ef821d03e |
children | 6d3a60a909c8 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
340
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
340
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
340
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
340
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
340
diff
changeset
|
7 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #ifndef _NGX_INET_H_INCLUDED_ |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #define _NGX_INET_H_INCLUDED_ |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
479 | 12 #include <ngx_config.h> |
13 #include <ngx_core.h> | |
14 | |
15 | |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
16 /* |
3230
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
17 * TODO: autoconfigure NGX_SOCKADDRLEN and NGX_SOCKADDR_STRLEN as |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
18 * sizeof(struct sockaddr_storage) |
2521
119ab57ffaa1
fix NGX_SOCKADDRLEN, introduced in r2513
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
19 * sizeof(struct sockaddr_un) |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
20 * sizeof(struct sockaddr_in6) |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
21 * sizeof(struct sockaddr_in) |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
22 */ |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
23 |
3230
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
24 #define NGX_INET_ADDRSTRLEN (sizeof("255.255.255.255") - 1) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
25 #define NGX_INET6_ADDRSTRLEN \ |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
26 (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") - 1) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
27 #define NGX_UNIX_ADDRSTRLEN \ |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
28 (sizeof(struct sockaddr_un) - offsetof(struct sockaddr_un, sun_path)) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
29 |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
30 #if (NGX_HAVE_UNIX_DOMAIN) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
31 #define NGX_SOCKADDR_STRLEN (sizeof("unix:") - 1 + NGX_UNIX_ADDRSTRLEN) |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
32 #else |
4944
ab7a21ce8778
Fixed the NGX_SOCKADDR_STRLEN macro definition.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
33 #define NGX_SOCKADDR_STRLEN (NGX_INET6_ADDRSTRLEN + sizeof("[]:65535") - 1) |
3230
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
34 #endif |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2856
diff
changeset
|
35 |
2521
119ab57ffaa1
fix NGX_SOCKADDRLEN, introduced in r2513
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
36 #if (NGX_HAVE_UNIX_DOMAIN) |
119ab57ffaa1
fix NGX_SOCKADDRLEN, introduced in r2513
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
37 #define NGX_SOCKADDRLEN sizeof(struct sockaddr_un) |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
38 #else |
2521
119ab57ffaa1
fix NGX_SOCKADDRLEN, introduced in r2513
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
39 #define NGX_SOCKADDRLEN 512 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
40 #endif |
2197
74477ea8074f
*) remove zero termination in ngx_inet_ntop() and ngx_sock_ntop()
Igor Sysoev <igor@sysoev.ru>
parents:
1671
diff
changeset
|
41 |
74477ea8074f
*) remove zero termination in ngx_inet_ntop() and ngx_sock_ntop()
Igor Sysoev <igor@sysoev.ru>
parents:
1671
diff
changeset
|
42 |
340
0bf903191ceb
nginx-0.0.3-2004-05-25-19:28:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
43 typedef struct { |
2538 | 44 in_addr_t addr; |
45 in_addr_t mask; | |
46 } ngx_in_cidr_t; | |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
47 |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
48 |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
49 #if (NGX_HAVE_INET6) |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
50 |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
51 typedef struct { |
2538 | 52 struct in6_addr addr; |
53 struct in6_addr mask; | |
54 } ngx_in6_cidr_t; | |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
55 |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
56 #endif |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
57 |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
58 |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
59 typedef struct { |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
60 ngx_uint_t family; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
61 union { |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
62 ngx_in_cidr_t in; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
63 #if (NGX_HAVE_INET6) |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
64 ngx_in6_cidr_t in6; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
65 #endif |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
66 } u; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
67 } ngx_cidr_t; |
340
0bf903191ceb
nginx-0.0.3-2004-05-25-19:28:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
68 |
0bf903191ceb
nginx-0.0.3-2004-05-25-19:28:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
69 |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
70 typedef struct { |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
71 struct sockaddr *sockaddr; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
72 socklen_t socklen; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
73 ngx_str_t name; |
3269
f0d596e84634
rename ngx_peer_addr_t to ngx_addr_t
Igor Sysoev <igor@sysoev.ru>
parents:
3265
diff
changeset
|
74 } ngx_addr_t; |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
75 |
651 | 76 |
884 | 77 typedef struct { |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
78 ngx_str_t url; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
79 ngx_str_t host; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
80 ngx_str_t port_text; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
81 ngx_str_t uri; |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
82 |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
83 in_port_t port; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
84 in_port_t default_port; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
85 int family; |
651 | 86 |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
87 unsigned listen:1; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
88 unsigned uri_part:1; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
89 unsigned no_resolve:1; |
4971
eaf95350d75c
Implemented IPv6 support for URLs specified using domain names.
Ruslan Ermilov <ru@nginx.com>
parents:
4944
diff
changeset
|
90 unsigned one_addr:1; /* compatibility */ |
651 | 91 |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
92 unsigned no_port:1; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
93 unsigned wildcard:1; |
884 | 94 |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
95 socklen_t socklen; |
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
96 u_char sockaddr[NGX_SOCKADDRLEN]; |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2203
diff
changeset
|
97 |
3269
f0d596e84634
rename ngx_peer_addr_t to ngx_addr_t
Igor Sysoev <igor@sysoev.ru>
parents:
3265
diff
changeset
|
98 ngx_addr_t *addrs; |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
99 ngx_uint_t naddrs; |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
100 |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
101 char *err; |
651 | 102 } ngx_url_t; |
103 | |
104 | |
1647 | 105 in_addr_t ngx_inet_addr(u_char *text, size_t len); |
3265 | 106 #if (NGX_HAVE_INET6) |
107 ngx_int_t ngx_inet6_addr(u_char *p, size_t len, u_char *addr); | |
3276
beaf94f2f265
make ngx_inet6_ntop() non-static
Igor Sysoev <igor@sysoev.ru>
parents:
3272
diff
changeset
|
108 size_t ngx_inet6_ntop(u_char *p, u_char *text, size_t len); |
3265 | 109 #endif |
5263
05ba5bce31e0
Core: extended ngx_sock_ntop() with socklen parameter.
Vladimir Homutov <vl@nginx.com>
parents:
4971
diff
changeset
|
110 size_t ngx_sock_ntop(struct sockaddr *sa, socklen_t socklen, u_char *text, |
05ba5bce31e0
Core: extended ngx_sock_ntop() with socklen parameter.
Vladimir Homutov <vl@nginx.com>
parents:
4971
diff
changeset
|
111 size_t len, ngx_uint_t port); |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
112 size_t ngx_inet_ntop(int family, void *addr, u_char *text, size_t len); |
2537
a472d954c534
prepare ngx_ptocidr() for IPv6
Igor Sysoev <igor@sysoev.ru>
parents:
2521
diff
changeset
|
113 ngx_int_t ngx_ptocidr(ngx_str_t *text, ngx_cidr_t *cidr); |
3272
98f49b2bcae8
change ngx_parse_addr() interface
Igor Sysoev <igor@sysoev.ru>
parents:
3270
diff
changeset
|
114 ngx_int_t ngx_parse_addr(ngx_pool_t *pool, ngx_addr_t *addr, u_char *text, |
98f49b2bcae8
change ngx_parse_addr() interface
Igor Sysoev <igor@sysoev.ru>
parents:
3270
diff
changeset
|
115 size_t len); |
1559
fe11e2a3946d
use pool instead of ngx_conf_t
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
116 ngx_int_t ngx_parse_url(ngx_pool_t *pool, ngx_url_t *u); |
fe11e2a3946d
use pool instead of ngx_conf_t
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
117 ngx_int_t ngx_inet_resolve_host(ngx_pool_t *pool, ngx_url_t *u); |
5473
d39ef821d03e
Core: externalized ngx_cmp_sockaddr().
Ruslan Ermilov <ru@nginx.com>
parents:
5263
diff
changeset
|
118 ngx_int_t ngx_cmp_sockaddr(struct sockaddr *sa1, socklen_t slen1, |
d39ef821d03e
Core: externalized ngx_cmp_sockaddr().
Ruslan Ermilov <ru@nginx.com>
parents:
5263
diff
changeset
|
119 struct sockaddr *sa2, socklen_t slen2, ngx_uint_t cmp_port); |
884 | 120 |
479 | 121 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 #endif /* _NGX_INET_H_INCLUDED_ */ |