comparison src/event/ngx_event.c @ 2537:a472d954c534

prepare ngx_ptocidr() for IPv6
author Igor Sysoev <igor@sysoev.ru>
date Tue, 24 Feb 2009 14:01:40 +0000
parents 2300ab9b069e
children b3b8c66bd520
comparison
equal deleted inserted replaced
2536:a6d6d762c554 2537:a472d954c534
1038 1038
1039 ngx_int_t rc; 1039 ngx_int_t rc;
1040 ngx_str_t *value; 1040 ngx_str_t *value;
1041 ngx_event_debug_t *dc; 1041 ngx_event_debug_t *dc;
1042 struct hostent *h; 1042 struct hostent *h;
1043 ngx_inet_cidr_t in_cidr; 1043 ngx_cidr_t cidr;
1044 1044
1045 value = cf->args->elts; 1045 value = cf->args->elts;
1046
1047 /* AF_INET only */
1048 1046
1049 dc = ngx_array_push(&ecf->debug_connection); 1047 dc = ngx_array_push(&ecf->debug_connection);
1050 if (dc == NULL) { 1048 if (dc == NULL) {
1051 return NGX_CONF_ERROR; 1049 return NGX_CONF_ERROR;
1052 } 1050 }
1053 1051
1054 rc = ngx_ptocidr(&value[1], &in_cidr); 1052 rc = ngx_ptocidr(&value[1], &cidr);
1055 1053
1056 if (rc == NGX_DONE) { 1054 if (rc == NGX_DONE) {
1057 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, 1055 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1058 "low address bits of %V are meaningless", &value[1]); 1056 "low address bits of %V are meaningless", &value[1]);
1059 rc = NGX_OK; 1057 rc = NGX_OK;
1060 } 1058 }
1061 1059
1062 if (rc == NGX_OK) { 1060 if (rc == NGX_OK) {
1063 dc->mask = in_cidr.mask; 1061
1064 dc->addr = in_cidr.addr; 1062 /* AF_INET only */
1063
1064 if (cidr.family != AF_INET) {
1065 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1066 "\"debug_connection\" supports IPv4 only");
1067 return NGX_CONF_ERROR;
1068 }
1069
1070 dc->mask = cidr.u.in.mask;
1071 dc->addr = cidr.u.in.addr;
1072
1065 return NGX_CONF_OK; 1073 return NGX_CONF_OK;
1066 } 1074 }
1067 1075
1068 h = gethostbyname((char *) value[1].data); 1076 h = gethostbyname((char *) value[1].data);
1069 1077