Annotation of embedaddon/nginx/src/core/ngx_resolver.h, revision 1.1
1.1 ! misho 1:
! 2: /*
! 3: * Copyright (C) Igor Sysoev
! 4: * Copyright (C) Nginx, Inc.
! 5: */
! 6:
! 7:
! 8: #include <ngx_config.h>
! 9: #include <ngx_core.h>
! 10:
! 11:
! 12: #ifndef _NGX_RESOLVER_H_INCLUDED_
! 13: #define _NGX_RESOLVER_H_INCLUDED_
! 14:
! 15:
! 16: #define NGX_RESOLVE_A 1
! 17: #define NGX_RESOLVE_CNAME 5
! 18: #define NGX_RESOLVE_PTR 12
! 19: #define NGX_RESOLVE_MX 15
! 20: #define NGX_RESOLVE_TXT 16
! 21: #define NGX_RESOLVE_DNAME 39
! 22:
! 23: #define NGX_RESOLVE_FORMERR 1
! 24: #define NGX_RESOLVE_SERVFAIL 2
! 25: #define NGX_RESOLVE_NXDOMAIN 3
! 26: #define NGX_RESOLVE_NOTIMP 4
! 27: #define NGX_RESOLVE_REFUSED 5
! 28: #define NGX_RESOLVE_TIMEDOUT NGX_ETIMEDOUT
! 29:
! 30:
! 31: #define NGX_NO_RESOLVER (void *) -1
! 32:
! 33: #define NGX_RESOLVER_MAX_RECURSION 50
! 34:
! 35:
! 36: typedef struct {
! 37: ngx_connection_t *connection;
! 38: struct sockaddr *sockaddr;
! 39: socklen_t socklen;
! 40: ngx_str_t server;
! 41: ngx_log_t log;
! 42: } ngx_udp_connection_t;
! 43:
! 44:
! 45: typedef struct ngx_resolver_ctx_s ngx_resolver_ctx_t;
! 46:
! 47: typedef void (*ngx_resolver_handler_pt)(ngx_resolver_ctx_t *ctx);
! 48:
! 49:
! 50: typedef struct {
! 51: ngx_rbtree_node_t node;
! 52: ngx_queue_t queue;
! 53:
! 54: /* PTR: resolved name, A: name to resolve */
! 55: u_char *name;
! 56:
! 57: u_short nlen;
! 58: u_short qlen;
! 59:
! 60: u_char *query;
! 61:
! 62: union {
! 63: in_addr_t addr;
! 64: in_addr_t *addrs;
! 65: u_char *cname;
! 66: } u;
! 67:
! 68: u_short naddrs;
! 69: u_short cnlen;
! 70:
! 71: time_t expire;
! 72: time_t valid;
! 73:
! 74: ngx_resolver_ctx_t *waiting;
! 75: } ngx_resolver_node_t;
! 76:
! 77:
! 78: typedef struct {
! 79: /* has to be pointer because of "incomplete type" */
! 80: ngx_event_t *event;
! 81: void *dummy;
! 82: ngx_log_t *log;
! 83:
! 84: /* ident must be after 3 pointers */
! 85: ngx_int_t ident;
! 86:
! 87: /* simple round robin DNS peers balancer */
! 88: ngx_array_t udp_connections;
! 89: ngx_uint_t last_connection;
! 90:
! 91: ngx_rbtree_t name_rbtree;
! 92: ngx_rbtree_node_t name_sentinel;
! 93:
! 94: ngx_rbtree_t addr_rbtree;
! 95: ngx_rbtree_node_t addr_sentinel;
! 96:
! 97: ngx_queue_t name_resend_queue;
! 98: ngx_queue_t addr_resend_queue;
! 99:
! 100: ngx_queue_t name_expire_queue;
! 101: ngx_queue_t addr_expire_queue;
! 102:
! 103: time_t resend_timeout;
! 104: time_t expire;
! 105: time_t valid;
! 106:
! 107: ngx_uint_t log_level;
! 108: } ngx_resolver_t;
! 109:
! 110:
! 111: struct ngx_resolver_ctx_s {
! 112: ngx_resolver_ctx_t *next;
! 113: ngx_resolver_t *resolver;
! 114: ngx_udp_connection_t *udp_connection;
! 115:
! 116: /* ident must be after 3 pointers */
! 117: ngx_int_t ident;
! 118:
! 119: ngx_int_t state;
! 120: ngx_int_t type;
! 121: ngx_str_t name;
! 122:
! 123: ngx_uint_t naddrs;
! 124: in_addr_t *addrs;
! 125: in_addr_t addr;
! 126:
! 127: ngx_resolver_handler_pt handler;
! 128: void *data;
! 129: ngx_msec_t timeout;
! 130:
! 131: ngx_uint_t quick; /* unsigned quick:1; */
! 132: ngx_uint_t recursion;
! 133: ngx_event_t *event;
! 134: };
! 135:
! 136:
! 137: ngx_resolver_t *ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names,
! 138: ngx_uint_t n);
! 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_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>