1
2 /*
3 * Copyright (C) Igor Sysoev
4 */
5
6
7 #ifndef _NGX_INET_H_INCLUDED_
8 #define _NGX_INET_H_INCLUDED_
9
10
11 #include <ngx_config.h>
12 #include <ngx_core.h>
13
14
15 #define NGX_INET_ADDRSTRLEN (sizeof("255.255.255.255") - 1)
16 #define NGX_INET6_ADDRSTRLEN \
17 (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") - 1)
18
19 #define NGX_SOCKADDR_STRLEN (NGX_INET6_ADDRSTRLEN + sizeof(":65535") - 1)
20
21
22 /*
23 * TODO: autoconfigure NGX_SOCKADDRLEN as
24 * sizeof(struct sockaddr_storage)
25 * sizeof(struct sockaddr_un)
26 * sizeof(struct sockaddr_in6)
27 * sizeof(struct sockaddr_in)
28 */
29
30 #if (NGX_HAVE_UNIX_DOMAIN)
31 #define NGX_SOCKADDRLEN sizeof(struct sockaddr_un)
32 #else
33 #define NGX_SOCKADDRLEN 512
34 #endif
35
36
37 typedef struct {
38 in_addr_t addr;
39 in_addr_t mask;
40 } ngx_in_cidr_t;
41
42
43 #if (NGX_HAVE_INET6)
44
45 typedef struct {
46 struct in6_addr addr;
47 struct in6_addr mask;
48 } ngx_in6_cidr_t;
49
50 #endif
51
52
53 typedef struct {
54 ngx_uint_t family;
55 union {
56 ngx_in_cidr_t in;
57 #if (NGX_HAVE_INET6)
58 ngx_in6_cidr_t in6;
59 #endif
60 } u;
61 } ngx_cidr_t;
62
63
64 typedef struct {
65 struct sockaddr *sockaddr;
66 socklen_t socklen;
67 ngx_str_t name;
68 } ngx_peer_addr_t;
69
70
71 typedef struct {
72 ngx_str_t url;
73 ngx_str_t host;
74 ngx_str_t port_text;
75 ngx_str_t uri;
76
77 in_port_t port;
78 in_port_t default_port;
79 int family;
80
81 unsigned listen:1;
82 unsigned uri_part:1;
83 unsigned no_resolve:1;
84 unsigned one_addr:1;
85
86 unsigned no_port:1;
87 unsigned wildcard:1;
88
89 socklen_t socklen;
90 u_char sockaddr[NGX_SOCKADDRLEN];
91
92 ngx_peer_addr_t *addrs;
93 ngx_uint_t naddrs;
94
95 char *err;
96 } ngx_url_t;
97
98
99 in_addr_t ngx_inet_addr(u_char *text, size_t len);
100 size_t ngx_sock_ntop(struct sockaddr *sa, u_char *text, size_t len,
101 ngx_uint_t port);
102 size_t ngx_inet_ntop(int family, void *addr, u_char *text, size_t len);
103 ngx_int_t ngx_ptocidr(ngx_str_t *text, ngx_cidr_t *cidr);
104 ngx_int_t ngx_parse_url(ngx_pool_t *pool, ngx_url_t *u);
105 ngx_int_t ngx_inet_resolve_host(ngx_pool_t *pool, ngx_url_t *u);
106
107
108
109 #endif /* _NGX_INET_H_INCLUDED_ */
110
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.