Mercurial > hg > nginx
annotate src/core/ngx_resolver.h @ 4104:84f34973684c
Version bump.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 14 Sep 2011 15:20:01 +0000 |
parents | 71193a456616 |
children | 016352c19049 4919fb357a5d |
rev | line source |
---|---|
1649 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 | |
10 | |
11 #ifndef _NGX_RESOLVER_H_INCLUDED_ | |
12 #define _NGX_RESOLVER_H_INCLUDED_ | |
13 | |
14 | |
15 #define NGX_RESOLVE_A 1 | |
16 #define NGX_RESOLVE_CNAME 5 | |
17 #define NGX_RESOLVE_PTR 12 | |
18 #define NGX_RESOLVE_MX 15 | |
19 #define NGX_RESOLVE_TXT 16 | |
1965 | 20 #define NGX_RESOLVE_DNAME 39 |
1649 | 21 |
22 #define NGX_RESOLVE_FORMERR 1 | |
23 #define NGX_RESOLVE_SERVFAIL 2 | |
24 #define NGX_RESOLVE_NXDOMAIN 3 | |
25 #define NGX_RESOLVE_NOTIMP 4 | |
26 #define NGX_RESOLVE_REFUSED 5 | |
27 #define NGX_RESOLVE_TIMEDOUT NGX_ETIMEDOUT | |
28 | |
29 | |
1683
1e0b028055ec
allow to use IP addresses without defined resolver
Igor Sysoev <igor@sysoev.ru>
parents:
1649
diff
changeset
|
30 #define NGX_NO_RESOLVER (void *) -1 |
1e0b028055ec
allow to use IP addresses without defined resolver
Igor Sysoev <igor@sysoev.ru>
parents:
1649
diff
changeset
|
31 |
1969 | 32 #define NGX_RESOLVER_MAX_RECURSION 50 |
33 | |
1683
1e0b028055ec
allow to use IP addresses without defined resolver
Igor Sysoev <igor@sysoev.ru>
parents:
1649
diff
changeset
|
34 |
1649 | 35 typedef struct { |
36 ngx_connection_t *connection; | |
37 struct sockaddr *sockaddr; | |
38 socklen_t socklen; | |
39 ngx_str_t server; | |
3408
71193a456616
add context to a resolver log
Igor Sysoev <igor@sysoev.ru>
parents:
3269
diff
changeset
|
40 ngx_log_t log; |
1649 | 41 } ngx_udp_connection_t; |
42 | |
43 | |
44 typedef struct ngx_resolver_ctx_s ngx_resolver_ctx_t; | |
45 | |
46 typedef void (*ngx_resolver_handler_pt)(ngx_resolver_ctx_t *ctx); | |
47 | |
48 | |
49 typedef struct { | |
50 ngx_rbtree_node_t node; | |
51 ngx_queue_t queue; | |
52 | |
53 /* PTR: resolved name, A: name to resolve */ | |
54 u_char *name; | |
55 | |
56 u_short nlen; | |
57 u_short qlen; | |
58 | |
59 u_char *query; | |
60 | |
61 union { | |
62 in_addr_t addr; | |
63 in_addr_t *addrs; | |
64 u_char *cname; | |
65 } u; | |
66 | |
67 u_short naddrs; | |
68 u_short cnlen; | |
69 | |
70 time_t expire; | |
71 time_t valid; | |
72 | |
73 ngx_resolver_ctx_t *waiting; | |
74 } ngx_resolver_node_t; | |
75 | |
76 | |
77 typedef struct { | |
78 /* has to be pointer because of "incomplete type" */ | |
79 ngx_event_t *event; | |
80 | |
81 /* TODO: DNS peers balancer */ | |
82 /* STUB */ | |
83 ngx_udp_connection_t *udp_connection; | |
84 | |
85 ngx_log_t *log; | |
86 | |
87 /* ident must be after 3 pointers */ | |
88 ngx_int_t ident; | |
89 | |
90 ngx_rbtree_t name_rbtree; | |
91 ngx_rbtree_node_t name_sentinel; | |
92 | |
93 ngx_rbtree_t addr_rbtree; | |
94 ngx_rbtree_node_t addr_sentinel; | |
95 | |
96 ngx_queue_t name_resend_queue; | |
97 ngx_queue_t addr_resend_queue; | |
98 | |
99 ngx_queue_t name_expire_queue; | |
100 ngx_queue_t addr_expire_queue; | |
101 | |
102 time_t resend_timeout; | |
103 time_t expire; | |
104 time_t valid; | |
105 | |
106 ngx_uint_t log_level; | |
107 } ngx_resolver_t; | |
108 | |
109 | |
110 struct ngx_resolver_ctx_s { | |
111 ngx_resolver_ctx_t *next; | |
112 ngx_resolver_t *resolver; | |
113 ngx_udp_connection_t *udp_connection; | |
114 | |
115 /* ident must be after 3 pointers */ | |
116 ngx_int_t ident; | |
117 | |
118 ngx_int_t state; | |
119 ngx_int_t type; | |
120 ngx_str_t name; | |
121 | |
122 ngx_uint_t naddrs; | |
123 in_addr_t *addrs; | |
124 in_addr_t addr; | |
125 | |
126 /* TODO: DNS peers balancer ctx */ | |
127 | |
128 ngx_resolver_handler_pt handler; | |
129 void *data; | |
130 ngx_msec_t timeout; | |
131 | |
132 ngx_uint_t quick; /* unsigned quick:1; */ | |
1969 | 133 ngx_uint_t recursion; |
1649 | 134 ngx_event_t *event; |
135 }; | |
136 | |
137 | |
3269
f0d596e84634
rename ngx_peer_addr_t to ngx_addr_t
Igor Sysoev <igor@sysoev.ru>
parents:
1969
diff
changeset
|
138 ngx_resolver_t *ngx_resolver_create(ngx_conf_t *cf, ngx_addr_t *addr); |
1649 | 139 ngx_resolver_ctx_t *ngx_resolve_start(ngx_resolver_t *r, |
140 ngx_resolver_ctx_t *temp); | |
141 ngx_int_t ngx_resolve_name(ngx_resolver_ctx_t *ctx); | |
142 void ngx_resolve_name_done(ngx_resolver_ctx_t *ctx); | |
143 ngx_int_t ngx_resolve_addr(ngx_resolver_ctx_t *ctx); | |
144 void ngx_resolve_addr_done(ngx_resolver_ctx_t *ctx); | |
145 char *ngx_resolver_strerror(ngx_int_t err); | |
146 | |
147 | |
148 #endif /* _NGX_RESOLVER_H_INCLUDED_ */ |