diff --git a/config.c b/config.c index 11afdf5..6cc9e5a 100644 --- a/config.c +++ b/config.c @@ -620,6 +620,17 @@ int get_global_config(struct config *conf) value = NULL; } } + if((error = uci_get_value(UCI_ACS_IPV6_ENABLE,&value)) == CWMP_OK) + { + if(value != NULL) + { + if ((strcasecmp(value,"true")==0) || (strcmp(value,"1")==0)) + { + conf->ipv6_enable = true; + } + value = NULL; + } + } if((error = uci_get_value(UCI_ACS_SSL_VERSION,&value)) == CWMP_OK) { if(value != NULL) diff --git a/config/cwmp b/config/cwmp index e9d4f68..8785553 100644 --- a/config/cwmp +++ b/config/cwmp @@ -15,6 +15,7 @@ config 'cwmp' 'acs' #­ possible configs interval :[1000:65535] option retry_interval_multiplier '2000' option https_ssl_capath '' + option ipv6_enable '0' config 'cwmp' 'cpe' option 'interface' 'eth0.1' option 'default_wan_interface' 'wan' diff --git a/http.c b/http.c index 3086ccd..207f330 100644 --- a/http.c +++ b/http.c @@ -109,14 +109,16 @@ http_client_init(struct cwmp *cwmp) return -1; #endif /* HTTP_ZSTREAM */ -char *ip = NULL; -curl_easy_setopt(curl, CURLOPT_URL, http_c.url); -curl_easy_setopt(curl, CURLOPT_TIMEOUT, HTTP_TIMEOUT); -curl_easy_setopt(curl, CURLOPT_NOBODY, 1); -curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip); -curl_easy_perform(curl); -int tmp = inet_pton(AF_INET, ip, buf); -ip_version = (tmp == 1) ? 4 : 6; +if (cwmp->conf.ipv6_enable) { + char *ip = NULL; + curl_easy_setopt(curl, CURLOPT_URL, http_c.url); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, HTTP_TIMEOUT); + curl_easy_setopt(curl, CURLOPT_NOBODY, 1); + curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip); + curl_easy_perform(curl); + int tmp = inet_pton(AF_INET, ip, buf); + ip_version = (tmp == 1) ? 4 : 6; +} return 0; } @@ -167,6 +169,7 @@ int http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len,char **msg_in) { unsigned char buf[sizeof(struct in6_addr)]; + int tmp = 0; #ifdef HTTP_CURL CURLcode res; long http_code = 0; @@ -251,11 +254,13 @@ http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len,char **msg_i if (!ip_acs || strcmp(ip_acs, ip) != 0) { FREE(ip_acs); ip_acs = strdup(ip); - int tmp = inet_pton(AF_INET, ip, buf); - if (tmp == 1) - tmp = 0; - else - tmp = inet_pton(AF_INET6, ip, buf); + if (cwmp->conf.ipv6_enable) { + tmp = inet_pton(AF_INET, ip, buf); + if (tmp == 1) + tmp = 0; + else + tmp = inet_pton(AF_INET6, ip, buf); + } external_init(); external_simple("allow_cr_ip", ip_acs, tmp); external_exit(); diff --git a/inc/cwmp.h b/inc/cwmp.h index a9e6721..500f5d0 100644 --- a/inc/cwmp.h +++ b/inc/cwmp.h @@ -53,6 +53,7 @@ #define UCI_ACS_SSL_CAPATH "cwmp.acs.ssl_capath" #define UCI_HTTPS_SSL_CAPATH "cwmp.acs.https_ssl_capath" #define UCI_ACS_INSECURE_ENABLE "cwmp.acs.insecure_enable" +#define UCI_ACS_IPV6_ENABLE "cwmp.acs.ipv6_enable" #define UCI_ACS_SSL_VERSION "cwmp.acs.ssl_version" #define UCI_ACS_COMPRESSION "cwmp.acs.compression" #define UCI_ACS_RETRY_MIN_WAIT_INTERVAL "cwmp.acs.retry_min_wait_interval" @@ -191,6 +192,7 @@ typedef struct config { time_t time; bool periodic_enable; bool insecure_enable; + bool ipv6_enable; int retry_min_wait_interval; int retry_interval_multiplier; bool lw_notification_enable; diff --git a/ubus.c b/ubus.c index 9645059..b1163ea 100644 --- a/ubus.c +++ b/ubus.c @@ -329,8 +329,10 @@ ubus_init(struct cwmp *cwmp) CWMP_LOG(ERROR,"netlink initialization failed"); } - if (netlink_init_v6()) { - CWMP_LOG(ERROR,"netlink initialization failed"); + if (cwmp->conf.ipv6_enable) { + if (netlink_init_v6()) { + CWMP_LOG(ERROR,"netlink initialization failed"); + } } ctx = ubus_connect(cwmp->conf.ubus_socket); if (!ctx) return -1;