nginx 0.7.36
[nginx-catap.git] / src / core / ngx_inet.h
blobd60c9c75573ef97c283cc8970e993b3ddceb81b6
2 /*
3 * Copyright (C) Igor Sysoev
4 */
7 #ifndef _NGX_INET_H_INCLUDED_
8 #define _NGX_INET_H_INCLUDED_
11 #include <ngx_config.h>
12 #include <ngx_core.h>
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)
19 #define NGX_SOCKADDR_STRLEN (NGX_INET6_ADDRSTRLEN + sizeof(":65535") - 1)
23 * TODO: autoconfigure NGX_SOCKADDRLEN as
24 * sizeof(struct sockaddr_storage)
25 * sizeof(struct sockaddr_in6)
26 * sizeof(struct sockaddr_in)
29 #if (NGX_HAVE_INET6)
30 #define NGX_SOCKADDRLEN sizeof(struct sockaddr_in6)
31 #else
32 #define NGX_SOCKADDRLEN sizeof(struct sockaddr_in)
33 #endif
36 typedef struct {
37 in_addr_t addr;
38 in_addr_t mask;
39 } ngx_inet_cidr_t;
42 typedef union {
43 in_addr_t in_addr;
44 } ngx_url_addr_t;
47 typedef struct {
48 struct sockaddr *sockaddr;
49 socklen_t socklen;
50 ngx_str_t name;
51 } ngx_peer_addr_t;
54 typedef struct {
55 ngx_str_t url;
56 ngx_str_t host;
57 ngx_str_t port_text;
58 ngx_str_t uri;
60 in_port_t port;
61 in_port_t default_port;
62 int family;
64 unsigned listen:1;
65 unsigned uri_part:1;
66 unsigned no_resolve:1;
67 unsigned one_addr:1;
69 unsigned no_port:1;
70 unsigned wildcard:1;
72 ngx_url_addr_t addr;
74 socklen_t socklen;
75 u_char sockaddr[NGX_SOCKADDRLEN];
77 ngx_peer_addr_t *addrs;
78 ngx_uint_t naddrs;
80 char *err;
81 } ngx_url_t;
84 in_addr_t ngx_inet_addr(u_char *text, size_t len);
85 size_t ngx_sock_ntop(struct sockaddr *sa, u_char *text, size_t len,
86 ngx_uint_t port);
87 size_t ngx_inet_ntop(int family, void *addr, u_char *text, size_t len);
88 ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr);
89 ngx_int_t ngx_parse_url(ngx_pool_t *pool, ngx_url_t *u);
90 ngx_int_t ngx_inet_resolve_host(ngx_pool_t *pool, ngx_url_t *u);
94 #endif /* _NGX_INET_H_INCLUDED_ */