Mercurial > hg > nginx-vendor-0-8
diff src/core/ngx_inet.c @ 348:e10168d6e371 NGINX_0_6_18
nginx 0.6.18
*) Change: now the ngx_http_userid_module adds start time microseconds
to the cookie field contains a pid value.
*) Change: now the full request line instead of URI only is written to
error_log.
*) Feature: variables support in the "proxy_pass" directive.
*) Feature: the "resolver" and "resolver_timeout" directives.
*) Feature: now the directive "add_header last-modified ''" deletes a
"Last-Modified" response header line.
*) Bugfix: the "limit_rate" directive did not allow to use full
throughput, even if limit value was very high.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 27 Nov 2007 00:00:00 +0300 |
parents | 10cc350ed8a1 |
children | 583decdb82a4 |
line wrap: on
line diff
--- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -8,6 +8,51 @@ #include <ngx_core.h> +/* AF_INET only */ + +in_addr_t +ngx_inet_addr(u_char *text, size_t len) +{ + u_char *p, c; + in_addr_t addr; + ngx_uint_t octet, n; + + addr = 0; + octet = 0; + n = 0; + + for (p = text; p < text + len; p++) { + + c = *p; + + if (c >= '0' && c <= '9') { + octet = octet * 10 + (c - '0'); + continue; + } + + if (c == '.' && octet < 256) { + addr = (addr << 8) + octet; + octet = 0; + n++; + continue; + } + + return INADDR_NONE; + } + + if (n != 3) { + return INADDR_NONE; + } + + if (octet < 256) { + addr = (addr << 8) + octet; + return htonl(addr); + } + + return INADDR_NONE; +} + + /* * ngx_sock_ntop() and ngx_inet_ntop() may be implemented as * "ngx_sprintf(text, "%ud.%ud.%ud.%ud", p[0], p[1], p[2], p[3])", however,