Mercurial > hg > nginx
comparison src/core/ngx_inet.c @ 368:15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 24 Jun 2004 16:07:04 +0000 |
parents | 0bf903191ceb |
children | 37b5381fb6d8 |
comparison
equal
deleted
inserted
replaced
367:ceec87d1c2b3 | 368:15c84a40e87d |
---|---|
168 | 168 |
169 /* AF_INET only */ | 169 /* AF_INET only */ |
170 | 170 |
171 ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr) | 171 ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr) |
172 { | 172 { |
173 ngx_int_t m; | |
173 ngx_uint_t i; | 174 ngx_uint_t i; |
174 ngx_inet_cidr_t *in_cidr; | 175 ngx_inet_cidr_t *in_cidr; |
175 | 176 |
176 in_cidr = cidr; | 177 in_cidr = cidr; |
177 | 178 |
190 text->data[i] = '/'; | 191 text->data[i] = '/'; |
191 if (in_cidr->addr == INADDR_NONE) { | 192 if (in_cidr->addr == INADDR_NONE) { |
192 return NGX_ERROR; | 193 return NGX_ERROR; |
193 } | 194 } |
194 | 195 |
195 in_cidr->mask = ngx_atoi(&text->data[i + 1], text->len - (i + 1)); | 196 m = ngx_atoi(&text->data[i + 1], text->len - (i + 1)); |
196 if (in_cidr->mask == (in_addr_t) NGX_ERROR) { | 197 if (m == NGX_ERROR) { |
197 return NGX_ERROR; | 198 return NGX_ERROR; |
198 } | 199 } |
199 | 200 |
201 if (m == 0) { | |
202 | |
203 /* the x86 compilers use the shl instruction that shifts by modulo 32 */ | |
204 | |
205 in_cidr->mask = 0; | |
206 return NGX_OK; | |
207 } | |
208 | |
209 in_cidr->mask = (ngx_uint_t) (0 - (1 << (32 - m))); | |
210 | |
200 return NGX_OK; | 211 return NGX_OK; |
201 } | 212 } |