| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /************************************************************************ | 
 | 2 | * °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£ | 
 | 3 | * | 
 | 4 | * ÎļþÃû³Æ£º zte_web_wan.c | 
 | 5 | * Îļþ±êʶ£º | 
 | 6 | * ÄÚÈÝÕªÒª£º | 
 | 7 | * ÆäËü˵Ã÷£º | 
 | 8 | * µ±Ç°°æ±¾£º V0.1 | 
 | 9 | * ×÷    Õߣº zyt | 
 | 10 | * Íê³ÉÈÕÆÚ£º 2010-11-06 | 
 | 11 | * | 
 | 12 | * Ð޸ļǼ1£º | 
 | 13 | * ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾ | 
 | 14 | ************************************************************************/ | 
 | 15 |  | 
 | 16 | /************************************************************************** | 
 | 17 | * Ð޸ıàºÅ : EC:617002790374 | 
 | 18 | * ÐÞ ¸Ä ÈË : chenjie10092374 | 
 | 19 | * ÐÞ¸ÄÈÕÆÚ : 2014.6.13 | 
 | 20 | * ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÓû§ÉèÖÃÊÖ¶¯²¦ºÅÇÒ´ËÊ±ÍøÂç¶Ï¿ªÊ±Äܼ°Ê±ÖÐÖ¹×Ô¶¯²¦ºÅ¹ý³ÌµÄ´úÂë | 
 | 21 | **************************************************************************/ | 
 | 22 |  | 
 | 23 | /************************************************************************** | 
 | 24 | * Ð޸ıàºÅ : EC:617002790374 | 
 | 25 | * ÐÞ ¸Ä ÈË : chenjie10092374 | 
 | 26 | * ÐÞ¸ÄÈÕÆÚ : 2014.6.23 | 
 | 27 | * ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÓû§È¡Ïû×Ô¶¯ÖØÁ¬¹¦ÄÜ | 
 | 28 | **************************************************************************/ | 
 | 29 | /************************************************************************** | 
 | 30 | * Ð޸ıàºÅ : EC:616000235589 | 
 | 31 | * ÐÞ ¸Ä ÈË : chenjie10092374 | 
 | 32 | * ÐÞ¸ÄÈÕÆÚ : 2014.7.16 | 
 | 33 | * ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÕÒÍø·½Ê½Á÷³Ì±£»¤ | 
 | 34 | **************************************************************************/ | 
 | 35 | #include "zte_web_interface.h" | 
 | 36 |  | 
 | 37 | /************************************************************/ | 
 | 38 | #define FEATRUE_WEB_DEBUG | 
 | 39 | #define FEATRUE_QMI_CONNECT | 
 | 40 |  | 
 | 41 | /************ALL the WAN CFG para****************************/ | 
 | 42 | #define N_PPP_APN_MODEL            "apn_select" | 
 | 43 | #define V_PPP_APN_MODEL_AUTO       "auto" | 
 | 44 | #define V_PPP_APN_MODEL_MANUAL     "manual" | 
 | 45 | #define N_PPP_APN_NAME             "wan_apn" | 
 | 46 | #define N_PPP_DIAL_NUM             "wan_dial" | 
 | 47 | #define V_PPP_DNS_MODEL_AUTO       "auto" | 
 | 48 | #define V_PPP_DNS_MODEL_MANUAL     "manual" | 
 | 49 | #define N_PPP_PDP_TYPE             "pdp_type" | 
 | 50 | #define N_PPP_PDP_MODEL            "pdp_select" | 
 | 51 | #define V_PPP_PDP_MODEL_AUTO       "auto" | 
 | 52 | #define V_PPP_PDP_MODEL_MANUAL     "manual" | 
 | 53 | #define N_PPP_PDP_ADDR             "pdp_addr" | 
 | 54 | #define N_PPP_AUTH_MODEL           "ppp_auth_mode" | 
 | 55 | #define V_PPP_AUTH_MODEL_PAP       "pap" | 
 | 56 | #define V_PPP_AUTH_MODEL_CHAP      "chap" | 
 | 57 | #define N_PPP_USER_NAME            "ppp_username" | 
 | 58 | #define N_PPP_PASSWORD             "ppp_passtmp" | 
 | 59 | #define N_NET_SELECT               "net_select" | 
 | 60 | //#define N_NET_SELECT_NAME          "net_select_name" | 
 | 61 | #define N_NO_MODEM                 "modem_undetected" | 
 | 62 |  | 
 | 63 | #define TIME_STEP                         1 | 
 | 64 | #define APNCONFIG_NUM_MAX                 10 | 
 | 65 | #define APNCONFIG_ELEMENT_NUM             14 | 
 | 66 | #define APNCONFIG_MEMORY                  1024 | 
 | 67 | #define APNCONFIG_ELEMENT_MEMORY          64 | 
 | 68 | #define IFSTREQUAL(str1, str2) (strcmp((str1), (str2))?0:1) | 
 | 69 | #define IFSTRNEQUAL(str1, str2, n) (strncmp((str1), (str2), (n))?0:1) | 
 | 70 |  | 
 | 71 |  | 
 | 72 |  | 
 | 73 | typedef struct { | 
 | 74 | 	CHAR pre_mode[64]; | 
 | 75 | 	CHAR net_select_mode[64]; | 
 | 76 | 	CHAR net_select[64]; | 
 | 77 | 	CHAR m_netselect_save[64]; | 
 | 78 | 	CHAR m_netselect_contents[64]; | 
 | 79 | 	CHAR m_netselect_status[64]; | 
 | 80 | } netSelectCfgNv; | 
 | 81 | /*************************function define******************************/ | 
 | 82 |  | 
 | 83 | void apn_save_process_ex(webs_t wp); | 
 | 84 | void apn_delete_process_ex(webs_t wp); | 
 | 85 | void apn_set_default_with_profile_index_ex(webs_t wp); | 
 | 86 | void apn_set_default_process_ex(webs_t wp); | 
 | 87 | void apn_set_default_with_new_profile_ex(webs_t wp); | 
 | 88 | static void set_apn_to_cfg(APN_PROFILE *apn_profile); | 
 | 89 | static void set_ipv6_apn_to_cfg(IPV6_APN_PROFILE *apn_profile); | 
 | 90 | static void set_ipv4v6_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile); | 
 | 91 | static void get_apn_para_form_web(webs_t wp, APN_PROFILE *apn_profile); | 
 | 92 | static void get_ipv6_apn_para_form_web(webs_t wp, IPV6_APN_PROFILE *apn_profile); | 
 | 93 | static int zte_wan_auto_apn_set(); | 
 | 94 | static int zte_wan_util_set_dial_roam_switch(const char_t *roam_set); | 
 | 95 |  | 
 | 96 |  | 
 | 97 | void zte_wan_connect_network(webs_t wp) | 
 | 98 | { | 
 | 99 | 	char traffic_limit[NV_ITEM_STRING_LEN_10] = {0}; | 
 | 100 | 	char flux_month_total[NV_ITEM_STRING_LEN_50] = {0}; | 
 | 101 | 	char traffic_alined_delta[NV_ITEM_STRING_LEN_50] = {0}; | 
 | 102 | 	char traffic_month_total[NV_ITEM_STRING_LEN_50] = {0}; | 
 | 103 | 	long long int llflux_month_total = 0; | 
 | 104 | 	long long int lltraffic_alined_delta = 0; | 
 | 105 | 	long long int lltraffic_month_total = 0; | 
 | 106 |  | 
 | 107 | 	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User connect network!\n")); | 
 | 108 |  | 
 | 109 | 	sc_cfg_set("user_initiate_disconnect", "0");  //Óû§Ö÷¶¯Á¬½Ó״̬£¬Í˳ö¸ÉԤģʽ | 
 | 110 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PDP_ACT_REQ, 0, NULL, 0); | 
 | 111 |  | 
 | 112 | 	sc_cfg_get("is_traffic_limit_on", &traffic_limit, sizeof(traffic_limit)); | 
 | 113 | 	sc_cfg_get("flux_month_total", &flux_month_total, sizeof(flux_month_total)); | 
 | 114 | 	sc_cfg_get("traffic_alined_delta", &traffic_alined_delta, sizeof(traffic_alined_delta)); | 
 | 115 | 	sc_cfg_get("traffic_month_total", &traffic_month_total, sizeof(traffic_month_total)); | 
 | 116 |  | 
 | 117 | 	llflux_month_total = atoll(&flux_month_total); | 
 | 118 | 	lltraffic_alined_delta = atoll(&traffic_alined_delta); | 
 | 119 | 	lltraffic_month_total = atoll(&traffic_month_total); | 
 | 120 |  | 
 | 121 | 	if(llflux_month_total < 0 || llflux_month_total > LLONG_MAX-1){ | 
 | 122 |         llflux_month_total = LLONG_MAX; | 
 | 123 | 	} | 
 | 124 |  | 
 | 125 | 	if(lltraffic_alined_delta < 0 || lltraffic_alined_delta > LLONG_MAX-1){ | 
 | 126 |         lltraffic_alined_delta = LLONG_MAX; | 
 | 127 | 	} | 
 | 128 |  | 
 | 129 | 	if(lltraffic_month_total < 0 || lltraffic_month_total > LLONG_MAX-1){ | 
 | 130 |         lltraffic_month_total = LLONG_MAX; | 
 | 131 | 	}	 | 
 | 132 |  | 
 | 133 | 	if (0 == strcmp(&traffic_limit, "yes") | 
 | 134 | 	    && llflux_month_total + lltraffic_alined_delta >= lltraffic_month_total * 1024 * 1024) { | 
 | 135 | 		sc_cfg_set("keep_online_when_limited", "yes"); | 
 | 136 | 	} | 
 | 137 | 	zte_write_result_to_web(wp, SUCCESS); //"success" | 
 | 138 | } | 
 | 139 |  | 
 | 140 | /*ÊÖ¶¯¶ÏÍø*/ | 
 | 141 | void zte_wan_disconnect_network(webs_t wp) | 
 | 142 | { | 
 | 143 |  | 
 | 144 | 	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User disconnect network!\n")); | 
 | 145 | 	sc_cfg_set("user_initiate_disconnect", "1");   //Óû§Ö÷¶¯¶Ï¿ª×´Ì¬£¬¸ÉԤģʽ | 
 | 146 |  | 
 | 147 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PDP_DEACT_REQ, 0, NULL, 0); | 
 | 148 | 	zte_write_result_to_web(wp, SUCCESS); | 
 | 149 | } | 
 | 150 |  | 
 | 151 | /*ÊÖ¶¯ËÑÍøºóÉèÖÃÍøÂç*/ | 
 | 152 | void zte_wan_set_network(webs_t wp) | 
 | 153 | { | 
 | 154 |  | 
 | 155 | 	CHAR *pMccmnc       = NULL; | 
 | 156 | 	CHAR *pNetType      = NULL; | 
 | 157 | 	CHAR *pSubType      = NULL; | 
 | 158 | 	CHAR curMccmnc[20]  = {0}; | 
 | 159 | 	CHAR curNetType[5]  = {0}; | 
 | 160 | 	CHAR curSubType[5]	= {0}; | 
 | 161 |  | 
 | 162 | 	pMccmnc     = websGetVar(wp, T("NetworkNumber"), T("")); | 
 | 163 | 	pNetType    = websGetVar(wp, T("Rat"), T("")); | 
 | 164 | 	pSubType	= websGetVar(wp, T("nSubrat"), T("")); | 
 | 165 |  | 
 | 166 | 	if (('\0' == (*pMccmnc)) || ('\0' == (*pNetType))) { | 
 | 167 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 168 | 		return; | 
 | 169 | 	} | 
 | 170 | 	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set network %s!\n"), pMccmnc); | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 171 | 	slog(MISC_PRINT, SLOG_DEBUG,"LPC: wan_set_network, pSubType = %s \n", pSubType); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 172 | 	(void)zte_web_read("current_rat", curNetType); //0:2G; 2:3G | 
 | 173 | 	(void)zte_web_read("str_num_rplmn", curMccmnc); | 
 | 174 | 	(void)zte_web_read("current_subrat", curSubType); | 
 | 175 |  | 
 | 176 | 	if ((0 == strcmp(pMccmnc, curMccmnc)) && (0 == strcmp(pNetType, curNetType)) && (0 == strcmp(pSubType, curSubType))) { | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 177 | 		slog(MISC_PRINT, SLOG_DEBUG, "wan_set_network: to set network is equal to registered network."); /*lint !e26*/ | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 178 | 		(void)zte_web_write("manual_netsel_flag", "1"); | 
 | 179 | 	} else { | 
 | 180 | 		(void)zte_web_write("manual_netsel_flag", ""); | 
 | 181 | 	} | 
 | 182 | 	(void)zte_web_write(NV_M_NETSELECT_CONTENTS, ""); | 
 | 183 | 	(void)zte_web_write("current_rat_tmp", pNetType); | 
 | 184 | 	(void)zte_web_write("str_num_rplmn_tmp", pMccmnc); | 
 | 185 | 	(void)zte_web_write("current_subrat_tmp", pSubType); | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 186 | 	//slog(MISC_PRINT,SLOG_DEBUG, "wan_set_network send message:ZUFI_MODULE_ID_AT_MAIN MSG_CMD_SET_NETWORK."); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 187 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_NETWORK_SET_REQ, 0, NULL, 0); | 
 | 188 | 	zte_write_result_to_web(wp, SUCCESS); | 
 | 189 | } | 
 | 190 |  | 
 | 191 |  | 
 | 192 | /*ÉèÖò¦ºÅģʽ*/ | 
 | 193 | void zte_wan_set_connection_mode(webs_t wp) | 
 | 194 | { | 
 | 195 | 	CHAR *pConnMode = NULL; | 
 | 196 | 	CHAR *pRoamOption = NULL; //dial roam | 
 | 197 | 	char_t ppp_status[CONFIG_DEFAULT_LENGTH] = {0}; | 
 | 198 | 	char traffic_limit[NV_ITEM_STRING_LEN_10] = {0}; | 
 | 199 | 	char flux_month_total[NV_ITEM_STRING_LEN_50] = {0}; | 
 | 200 | 	char traffic_alined_delta[NV_ITEM_STRING_LEN_50] = {0}; | 
 | 201 | 	char traffic_month_total[NV_ITEM_STRING_LEN_50] = {0}; | 
 | 202 | 	char pdp_dial_mode[NV_ITEM_STRING_LEN_10] = {0}; | 
 | 203 |  | 
 | 204 | 	long long int llflux_month_total = 0; | 
 | 205 | 	long long int lltraffic_alined_delta = 0; | 
 | 206 | 	long long int lltraffic_month_total = 0;	 | 
 | 207 |  | 
 | 208 | 	sc_cfg_get("ppp_status", &ppp_status, sizeof(ppp_status)); | 
 | 209 |  | 
 | 210 |  | 
 | 211 | 	pConnMode    = websGetVar(wp, "ConnectionMode", T("")); | 
 | 212 | 	pRoamOption  = websGetVar(wp, T(NV_ROAM_SETTING_OPTION), NULL); | 
 | 213 |  | 
 | 214 | 	if ('\0' == (*pConnMode)) { | 
 | 215 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 216 | 		return; | 
 | 217 | 	} | 
 | 218 |  | 
 | 219 | 	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set connection mode %s!\n"), pConnMode); | 
 | 220 | 	(void)zte_web_write(NV_DIAL_MODE, pConnMode); | 
 | 221 |  | 
 | 222 | 	if (IFSTREQUAL(ppp_status, "ppp_disconnected") | 
 | 223 | 	    && IFSTREQUAL(pConnMode, "manual_dial")) { | 
 | 224 | 		sc_cfg_set("auto_reconnect", "0"); | 
 | 225 | 	} | 
 | 226 |  | 
 | 227 | 	sc_cfg_get("is_traffic_limit_on", &traffic_limit, sizeof(traffic_limit)); | 
 | 228 | 	sc_cfg_get("flux_month_total", &flux_month_total, sizeof(flux_month_total)); | 
 | 229 | 	sc_cfg_get("traffic_alined_delta", &traffic_alined_delta, sizeof(traffic_alined_delta)); | 
 | 230 | 	sc_cfg_get("traffic_month_total", &traffic_month_total, sizeof(traffic_month_total)); | 
 | 231 |  | 
 | 232 | 	llflux_month_total = atoll(&flux_month_total); | 
 | 233 | 	lltraffic_alined_delta = atoll(&traffic_alined_delta); | 
 | 234 | 	lltraffic_month_total = atoll(&traffic_month_total); | 
 | 235 |  | 
 | 236 | 	if(llflux_month_total < 0 || llflux_month_total > LLONG_MAX-1 ){ | 
 | 237 |         llflux_month_total = LLONG_MAX; | 
 | 238 | 	} | 
 | 239 |  | 
 | 240 | 	if(lltraffic_alined_delta < 0 || lltraffic_alined_delta > LLONG_MAX-1){ | 
 | 241 |         lltraffic_alined_delta = LLONG_MAX; | 
 | 242 | 	} | 
 | 243 |  | 
 | 244 | 	if(lltraffic_month_total < 0 || lltraffic_month_total > LLONG_MAX-1){ | 
 | 245 |         lltraffic_month_total = LLONG_MAX; | 
 | 246 | 	}	 | 
 | 247 |  | 
 | 248 | 	if (0 == strcmp(&traffic_limit, "yes") | 
 | 249 | 	    && llflux_month_total + lltraffic_alined_delta >= lltraffic_month_total * 1024 * 1024) { | 
 | 250 | 		sc_cfg_get(NV_DIAL_MODE, &pdp_dial_mode, sizeof(pdp_dial_mode)); | 
 | 251 |  | 
 | 252 | 		if (0 == strcmp(&pdp_dial_mode, "manual_dial")) { | 
 | 253 | 			sc_cfg_set("auto_connect_when_limited", "no"); | 
 | 254 | 		} else if (0 == strcmp(&pdp_dial_mode, "auto_dial")) { | 
 | 255 | 			sc_cfg_set("auto_connect_when_limited", "yes"); | 
 | 256 | 		} | 
 | 257 | 	} | 
 | 258 | 	//set dial roam switch | 
 | 259 | 	if (-1 == zte_wan_util_set_dial_roam_switch(pRoamOption)) { | 
 | 260 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 261 | 		return; | 
 | 262 | 	} | 
 | 263 |  | 
 | 264 | 	//sc_cfg_save(); | 
 | 265 | 	zte_write_result_to_web(wp, SUCCESS); | 
 | 266 | 	slog(MISC_PRINT, SLOG_DEBUG, "ZUFI_MODULE_ID_AT_MAIN!!!!set ppp_dial Mode:%s.\n", pConnMode); | 
 | 267 |  | 
 | 268 | } | 
 | 269 |  | 
 | 270 | /*ÉèÖÃ×Ô¶¯Ñ¡ÍøµÄÍøÂçÖÆÊ½*/ | 
 | 271 | void zte_wan_network_select(webs_t wp) | 
 | 272 | { | 
 | 273 | 	char_t *netSelect = NULL; | 
 | 274 | 	char_t *pre_mode = NULL; | 
 | 275 | 	char_t ppp_status[CONFIG_DEFAULT_LENGTH] = {0}; | 
 | 276 | 	int tryCount = 0; | 
 | 277 | 	netSelectCfgNv netSelectPreCfg = {0}; | 
 | 278 | 	char select_result[NV_ITEM_STRING_LEN_20] = {0}; | 
 | 279 | 	char buf[NV_ITEM_STRING_LEN_10] = {0}; | 
 | 280 |  | 
 | 281 | 	netSelect = websGetVar(wp, T("BearerPreference"), T("")); | 
 | 282 | 	pre_mode = websGetVar(wp, T("pre_mode"), T("")); | 
 | 283 |  | 
 | 284 | 	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set network select %s!\n"), netSelect); | 
 | 285 | 	if ('\0' == (*netSelect)) { | 
 | 286 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 287 | 		return; | 
 | 288 | 	} | 
 | 289 |  | 
 | 290 | 	sc_cfg_get("ppp_status", &ppp_status, sizeof(ppp_status)); | 
 | 291 | 	if (ppp_status[0] != '\0') { | 
 | 292 | 		if (!IFSTREQUAL(ppp_status, "ppp_disconnected") && !IFSTREQUAL(ppp_status, "ppp_ready")) { | 
 | 293 | 			zte_write_result_to_web(wp, FAILURE); | 
 | 294 | 			return; | 
 | 295 | 		} | 
 | 296 | 	} | 
 | 297 |  | 
 | 298 | 	(void)zte_web_read("pre_mode", netSelectPreCfg.pre_mode); | 
 | 299 | 	(void)zte_web_read("net_select_mode", netSelectPreCfg.net_select_mode); | 
 | 300 | 	(void)zte_web_read(N_NET_SELECT, netSelectPreCfg.net_select); | 
 | 301 | 	(void)zte_web_read("m_netselect_save", netSelectPreCfg.m_netselect_save); | 
 | 302 | 	(void)zte_web_read(NV_M_NETSELECT_CONTENTS, netSelectPreCfg.m_netselect_contents); | 
 | 303 | 	(void)zte_web_read("m_netselect_status", netSelectPreCfg.m_netselect_status); | 
 | 304 |  | 
 | 305 | 	(void)zte_web_write("pre_mode", pre_mode); | 
 | 306 | 	(void)zte_web_write("net_select_mode", "auto_select"); | 
 | 307 | 	(void)zte_web_write(N_NET_SELECT, netSelect); | 
 | 308 | 	(void)zte_web_write("m_netselect_save", ""); | 
 | 309 | 	(void)zte_web_write(NV_M_NETSELECT_CONTENTS, ""); | 
 | 310 | 	(void)zte_web_write("m_netselect_status", ""); | 
 | 311 | 	sc_cfg_set("net_select_result", ""); | 
 | 312 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_NET_SELECT_REQ, 0, NULL, 0); | 
 | 313 |  | 
 | 314 | 	while (tryCount++ < 200) { | 
 | 315 | 		memset(select_result, 0, sizeof(select_result)); | 
 | 316 | 		sc_cfg_get("net_select_result", select_result, sizeof(select_result)); | 
 | 317 | 		if (strcmp("", select_result) != 0) { | 
 | 318 | 			break; | 
 | 319 | 		} | 
 | 320 |  | 
 | 321 | 		// 200*1000us | 
 | 322 | 		usleep(200000); | 
 | 323 | 	} | 
 | 324 |  | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 325 | 	slog(MISC_PRINT, SLOG_DEBUG,"wan_network_select: net_select_result = %s \n", select_result); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 326 | 	if (strcmp("sucess", select_result) == 0) { | 
 | 327 | 		zte_write_result_to_web(wp, SUCCESS); | 
 | 328 | 	} else { | 
 | 329 | 		(void)zte_web_write("pre_mode", netSelectPreCfg.pre_mode); | 
 | 330 | 		(void)zte_web_write("net_select_mode", netSelectPreCfg.net_select_mode); | 
 | 331 | 		(void)zte_web_write(N_NET_SELECT, netSelectPreCfg.net_select); | 
 | 332 | 		(void)zte_web_write("m_netselect_save", netSelectPreCfg.m_netselect_save); | 
 | 333 | 		(void)zte_web_write(NV_M_NETSELECT_CONTENTS, netSelectPreCfg.m_netselect_contents); | 
 | 334 | 		(void)zte_web_write("m_netselect_status", netSelectPreCfg.m_netselect_status); | 
 | 335 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 336 | 	} | 
 | 337 |  | 
 | 338 | } | 
 | 339 |  | 
 | 340 | /*ÊÖ¶¯ËÑÍø*/ | 
 | 341 | void zte_wan_scan_network(webs_t wp) | 
 | 342 | { | 
 | 343 | 	if (NULL == wp) { | 
 | 344 | 		return; | 
 | 345 | 	} | 
 | 346 |  | 
 | 347 | 	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User scan network!\n")); | 
 | 348 |  | 
 | 349 | 	(void)zte_web_write("net_select_mode", "manual_select"); | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 350 | 	slog(MISC_PRINT, SLOG_NORMAL, "wan_scan_network send message ZUFI_MODULE_ID_AT_MAIN,MSG_CMD_WEB_REQ_NET_SELECT"); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 351 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_NET_SELECT_REQ, 0, NULL, 0); | 
 | 352 | 	(void)zte_web_write("m_netselect_status", "manual_selecting"); | 
 | 353 | 	zte_write_result_to_web(wp, SUCCESS); | 
 | 354 |  | 
 | 355 | } | 
 | 356 |  | 
 | 357 | /*Á÷Á¿¹ÜÀíÉèÖÃ*/ | 
 | 358 | void zte_wan_data_limit_setting(webs_t wp) | 
 | 359 | { | 
 | 360 | 	char *data_limit_switch = NULL; | 
 | 361 | 	char *data_limit_type = NULL; | 
 | 362 | 	char *data_limit_size = NULL; | 
 | 363 | 	char *data_limit_percent = NULL; | 
 | 364 |  | 
 | 365 | 	if (NULL == wp) { | 
 | 366 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 367 | 		return; | 
 | 368 | 	} | 
 | 369 |  | 
 | 370 | 	data_limit_switch = websGetVar(wp, T("data_volume_limit_switch"), T(""));    /*0:disable;1:enable*/ | 
 | 371 | 	if (0 == strcmp(data_limit_switch, "0")) { | 
 | 372 | 		slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User disable net data statistics!\n")); | 
 | 373 | 		sc_cfg_set(NV_DATA_VOLUME_LIMIT_SWITCH, "0"); | 
 | 374 | 		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0); | 
 | 375 | 		zte_write_result_to_web(wp, SUCCESS); | 
 | 376 | 	} else if (0 == strcmp(data_limit_switch, "1")) { | 
 | 377 | 		slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User enable net data statistics!\n")); | 
 | 378 | 		data_limit_type = websGetVar(wp, T("data_volume_limit_unit"), T(""));    /*time/data*/ | 
 | 379 | 		data_limit_size = websGetVar(wp, T("data_volume_limit_size"), T("")); | 
 | 380 | 		data_limit_percent = websGetVar(wp, T("data_volume_alert_percent"), T(""));    /*1-100*/ | 
 | 381 |  | 
 | 382 | 		//param validation check | 
 | 383 | 		if ((0 != strcmp(data_limit_type, DATA_VOLUME_LIMIT_UNIT_TIME)) | 
 | 384 | 		    && (0 != strcmp(data_limit_type, DATA_VOLUME_LIMIT_UNIT_DATA))) { | 
 | 385 |  | 
 | 386 | 			slog(MISC_PRINT, SLOG_ERR, "invalid value for data_limit_type:[%s]\n", data_limit_type); /*lint !e26*/ | 
 | 387 | 			zte_write_result_to_web(wp, FAILURE); | 
 | 388 | 			return; | 
 | 389 | 		} | 
 | 390 |  | 
 | 391 | 		if ((0 == strcmp(data_limit_size, "")) || (0 == strcmp(data_limit_percent, ""))) { | 
 | 392 | 			slog(MISC_PRINT, SLOG_ERR, "invalid value :[%s,%s]\n", data_limit_size, data_limit_percent); /*lint !e26*/ | 
 | 393 | 			zte_write_result_to_web(wp, FAILURE); | 
 | 394 | 			return; | 
 | 395 | 		} | 
 | 396 |  | 
 | 397 | 		sc_cfg_set(NV_DATA_VOLUME_LIMIT_SWITCH, "1"); | 
 | 398 | 		sc_cfg_set(NV_DATA_VOLUME_LIMIT_UNIT, data_limit_type); | 
 | 399 | 		sc_cfg_set(NV_DATA_VOLUME_LIMIT_SIZE, data_limit_size); | 
 | 400 | 		sc_cfg_set(NV_DATA_VOLUME_ALERT_PERCENT, data_limit_percent); | 
 | 401 | 		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0); | 
 | 402 | 		zte_write_result_to_web(wp, SUCCESS); | 
 | 403 | 	} else { | 
 | 404 | 		slog(MISC_PRINT, SLOG_ERR, "invalid value for data_limit_switch:[%s]\n", data_limit_switch); /*lint !e26*/ | 
 | 405 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 406 | 	} | 
 | 407 | } | 
 | 408 |  | 
 | 409 |  | 
 | 410 | /********************************************************************** | 
 | 411 | * Function:         apn_save_process_ex | 
 | 412 | * Description:      save the APN | 
 | 413 | * Input:            NULL | 
 | 414 | * Output:           NULL | 
 | 415 | * Return:           0 is invalid, 1 is valid | 
 | 416 | * Others: | 
 | 417 | * Modify Date   Version     Author          Modification | 
 | 418 | * ----------------------------------------------- | 
 | 419 | * 2010/11/17   V1.0         maquan          first version | 
 | 420 | **********************************************************************/ | 
 | 421 | void apn_save_process_ex(webs_t wp) | 
 | 422 | { | 
 | 423 | 	int index_apn = 0; | 
 | 424 | 	char currentApnIndex[8] = {0}; | 
 | 425 | 	APN_PROFILE newApn; | 
 | 426 | 	IPV6_APN_PROFILE newIPV6Apn; | 
 | 427 | 	memset(&newApn, 0, sizeof(APN_PROFILE)); | 
 | 428 | 	memset(&newIPV6Apn, 0, sizeof(IPV6_APN_PROFILE)); | 
 | 429 |  | 
 | 430 | 	slog(MISC_PRINT, SLOG_NORMAL, "come get_apn_para_form_web \n"); /*lint !e26*/ | 
 | 431 | 	get_apn_para_form_web(wp, &newApn); | 
 | 432 | 	get_ipv6_apn_para_form_web(wp, &newIPV6Apn); | 
 | 433 |  | 
 | 434 | 	index_apn = atoi(websGetVar(wp, "index", T(""))); | 
 | 435 | 	slog(MISC_PRINT, SLOG_DEBUG, "index_apn=%d \n", index_apn); /*lint !e26*/ | 
 | 436 | 	snprintf(currentApnIndex, sizeof(currentApnIndex) , "%d", index_apn); | 
 | 437 | 	slog(MISC_PRINT, SLOG_DEBUG, "come set_apn_profile_by_index \n"); /*lint !e26*/ | 
 | 438 |  | 
 | 439 | 	set_apn_profile_by_index(index_apn, &newApn); | 
 | 440 | 	set_apn_prof_aes_by_index(index_apn, &newApn); | 
 | 441 | 	set_ipv6_apn_profile_by_index(index_apn, &newIPV6Apn); | 
 | 442 | 	set_ipv6_apn_prof_aes_by_index(index_apn, &newIPV6Apn); | 
 | 443 |  | 
 | 444 | } | 
 | 445 |  | 
 | 446 | /********************************************************************** | 
 | 447 | * Function:         apn_delete_process_ex | 
 | 448 | * Description:      delete apn | 
 | 449 | * Input:            NULL | 
 | 450 | * Output:           NULL | 
 | 451 | * Return:           NULL | 
 | 452 | * Others: | 
 | 453 | * Modify Date   Version     Author          Modification | 
 | 454 | * ----------------------------------------------- | 
 | 455 | * 2010/11/17   V1.0         maquan          first version | 
 | 456 | * 2011/01/15   V1.0         qiuzhenhui      modify | 
 | 457 | **********************************************************************/ | 
 | 458 | void apn_delete_process_ex(webs_t wp) | 
 | 459 | { | 
 | 460 | 	char apn_default_index[APNCONFIG_ELEMENT_MEMORY] = {0}; | 
 | 461 | 	char apn_buf[APNCONFIG_ELEMENT_MEMORY] = {0}; | 
 | 462 | 	int i; | 
 | 463 |  | 
 | 464 | 	int apn_index = atoi(websGetVar(wp, "index", T(""))); | 
 | 465 | 	if(apn_index<0 || apn_index> INT_MAX-1) | 
 | 466 | 	{ | 
 | 467 | 	    apn_index = 0; | 
 | 468 | 	} | 
 | 469 | 	 | 
 | 470 | 	sc_cfg_get("apn_index", &apn_buf, sizeof(apn_buf)); | 
 | 471 | 	int apn_index_setdefault = atoi(&apn_buf); | 
 | 472 | 	if(apn_index_setdefault<0 || apn_index_setdefault> INT_MAX-1) | 
 | 473 | 	{ | 
 | 474 | 	    apn_index_setdefault = 0; | 
 | 475 | 	} | 
 | 476 |  | 
 | 477 | 	for (i = apn_index; i < APNCONFIG_NUM_MAX; i++) { | 
 | 478 | 		char profile1[APNCONFIG_MEMORY] = {0}; | 
 | 479 | 		char profile2[APNCONFIG_MEMORY] = {0}; | 
 | 480 | 		char ipv6profile1[APNCONFIG_MEMORY] = {0}; | 
 | 481 | 		char ipv6profile2[APNCONFIG_MEMORY] = {0}; | 
 | 482 | 		char next_profile[APNCONFIG_MEMORY] = {0}; | 
 | 483 | 		char ipv6_next_profile[APNCONFIG_MEMORY] = {0}; | 
 | 484 |  | 
 | 485 | 		sprintf(profile1, "APN_config%d", i); | 
 | 486 | 		sprintf(profile2, "APN_config%d", i + 1); | 
 | 487 |  | 
 | 488 | 		sprintf(ipv6profile1, "ipv6_APN_config%d", i); | 
 | 489 | 		sprintf(ipv6profile2, "ipv6_APN_config%d", i + 1); | 
 | 490 |  | 
 | 491 | 		sc_cfg_get(profile2, &next_profile, sizeof(next_profile)); | 
 | 492 | 		sc_cfg_get(ipv6profile2, &ipv6_next_profile, sizeof(ipv6_next_profile)); | 
 | 493 |  | 
 | 494 |  | 
 | 495 | #ifdef FEATRUE_WEB_DEBUG | 
 | 496 | 		slog(MISC_PRINT, SLOG_DEBUG, "profile1=%s\n", profile1); /*lint !e26*/ | 
 | 497 | 		slog(MISC_PRINT, SLOG_DEBUG, "profile2=%s\n", profile2); /*lint !e26*/ | 
 | 498 | 		slog(MISC_PRINT, SLOG_DEBUG, "next_profile=%s\n", next_profile); /*lint !e26*/ | 
 | 499 | #endif | 
 | 500 | 		if (strcmp(next_profile, "")) { | 
 | 501 | 			sc_cfg_set(profile1, next_profile); | 
 | 502 | 		} else { | 
 | 503 | 			sc_cfg_set(profile1, ""); | 
 | 504 | 		} | 
 | 505 |  | 
 | 506 |  | 
 | 507 | 		if (strcmp(ipv6_next_profile, "")) { | 
 | 508 | 			sc_cfg_set(ipv6profile1, ipv6_next_profile); | 
 | 509 | 		} else { | 
 | 510 | 			sc_cfg_set(ipv6profile1, ""); | 
 | 511 | 		} | 
 | 512 |  | 
 | 513 |  | 
 | 514 | 	} //endof delete | 
 | 515 | 	for (i = apn_index; i < APNCONFIG_NUM_MAX; i++) { | 
 | 516 | 		char profile1[APNCONFIG_MEMORY] = {0}; | 
 | 517 | 		char profile2[APNCONFIG_MEMORY] = {0}; | 
 | 518 | 		char ipv6profile1[APNCONFIG_MEMORY] = {0}; | 
 | 519 | 		char ipv6profile2[APNCONFIG_MEMORY] = {0}; | 
 | 520 | 		char next_profile[APNCONFIG_MEMORY] = {0}; | 
 | 521 | 		char ipv6_next_profile[APNCONFIG_MEMORY] = {0}; | 
 | 522 |  | 
 | 523 | 		sprintf(profile1, "APN_configtmp%d", i); | 
 | 524 | 		sprintf(profile2, "APN_configtmp%d", i + 1); | 
 | 525 |  | 
 | 526 | 		sprintf(ipv6profile1, "ipv6_APN_configtmp%d", i); | 
 | 527 | 		sprintf(ipv6profile2, "ipv6_APN_configtmp%d", i + 1); | 
 | 528 |  | 
 | 529 | 		sc_cfg_get(profile2, &next_profile, sizeof(next_profile)); | 
 | 530 | 		sc_cfg_get(ipv6profile2, &ipv6_next_profile, sizeof(ipv6_next_profile)); | 
 | 531 |  | 
 | 532 |  | 
 | 533 | #ifdef FEATRUE_WEB_DEBUG | 
 | 534 | 		slog(MISC_PRINT, SLOG_DEBUG, "profile1tmp=%s\n", profile1); /*lint !e26*/ | 
 | 535 | 		slog(MISC_PRINT, SLOG_DEBUG, "profile2tmp=%s\n", profile2); /*lint !e26*/ | 
 | 536 | 		slog(MISC_PRINT, SLOG_DEBUG, "next_profiletmp=%s\n", next_profile); /*lint !e26*/ | 
 | 537 | #endif | 
 | 538 | 		if (strcmp(next_profile, "")) { | 
 | 539 | 			sc_cfg_set(profile1, next_profile); | 
 | 540 | 		} else { | 
 | 541 | 			sc_cfg_set(profile1, ""); | 
 | 542 | 		} | 
 | 543 |  | 
 | 544 |  | 
 | 545 | 		if (strcmp(ipv6_next_profile, "")) { | 
 | 546 | 			sc_cfg_set(ipv6profile1, ipv6_next_profile); | 
 | 547 | 		} else { | 
 | 548 | 			sc_cfg_set(ipv6profile1, ""); | 
 | 549 | 		} | 
 | 550 |  | 
 | 551 |  | 
 | 552 | 	} //endof delete | 
 | 553 | 	if (0 < apn_index_setdefault - apn_index) { | 
 | 554 | 		apn_index_setdefault -= 1; | 
 | 555 | 		sprintf(apn_default_index, "%d", apn_index_setdefault); | 
 | 556 | 		sc_cfg_set("apn_index", apn_default_index); | 
 | 557 | 	} else if (apn_index_setdefault == apn_index) { | 
 | 558 | 		apn_index_setdefault = 0; | 
 | 559 | 		sprintf(apn_default_index, "%d", apn_index_setdefault); | 
 | 560 | 		sc_cfg_set("apn_index", apn_default_index); | 
 | 561 | 	} | 
 | 562 | #ifdef FEATRUE_WEB_DEBUG | 
 | 563 |     memset(apn_buf, 0, sizeof(apn_buf)); | 
 | 564 |     sc_cfg_get("apn_index", apn_buf, sizeof(apn_buf)); | 
 | 565 |     slog(MISC_PRINT, SLOG_DEBUG, "Del action apn_index=%s\n", apn_buf); /*lint !e26*/ | 
 | 566 |  | 
 | 567 | #endif | 
 | 568 |  | 
 | 569 | } | 
 | 570 |  | 
 | 571 | /********************************************************************** | 
 | 572 | * Function:         apn_delete_process | 
 | 573 | * Description:      delete apn | 
 | 574 | * Input:            NULL | 
 | 575 | * Output:           NULL | 
 | 576 | * Return:           NULL | 
 | 577 | * Others: | 
 | 578 | * Modify Date   Version     Author          Modification | 
 | 579 | * ----------------------------------------------- | 
 | 580 | * 2010/11/17   V1.0         maquan          first version | 
 | 581 | * 2011/01/15   V1.0         qiuzhenhui      modify | 
 | 582 | **********************************************************************/ | 
 | 583 | void apn_set_default_with_profile_index_ex(webs_t wp) | 
 | 584 | { | 
 | 585 | 	int index_apn = 0; | 
 | 586 | 	char_t *pdp_type = NULL; | 
 | 587 |  | 
 | 588 | 	pdp_type = websGetVar(wp, T("pdp_type"), T("")); | 
 | 589 |  | 
 | 590 | 	APN_PROFILE  newProfile; | 
 | 591 | 	IPV6_APN_PROFILE  newIpv6Profile; | 
 | 592 | 	memset(&newProfile, 0, sizeof(APN_PROFILE)); | 
 | 593 | 	memset(&newIpv6Profile, 0, sizeof(IPV6_APN_PROFILE)); | 
 | 594 | 	char_t *apn_mode = NULL; | 
 | 595 |  | 
 | 596 | 	index_apn = atoi(websGetVar(wp, "index", T(""))); | 
 | 597 | 	apn_mode = websGetVar(wp, T("apn_mode"), T("")); | 
 | 598 |  | 
 | 599 | 	sc_cfg_set("auto_apn_index", websGetVar(wp, "auto_apn_index", T("0"))); | 
 | 600 | 	if (0 == strcmp(apn_mode, "auto")) { | 
 | 601 | 		slog(MISC_PRINT, SLOG_DEBUG, "apn_mode=%s\n", apn_mode); /*lint !e26*/ | 
 | 602 | 		get_autoapn_profile(&newProfile); | 
 | 603 | 		set_apn_to_cfg(&newProfile); | 
 | 604 | 	} else { | 
 | 605 | 		if (0 == strcmp(pdp_type, "IPv6")) { | 
 | 606 | 			slog(MISC_PRINT, SLOG_DEBUG, "come to get_ipv6apn_profile_by_index"); /*lint !e26*/ | 
 | 607 |  | 
 | 608 | 			get_ipv6apn_profile_by_index(index_apn, &newIpv6Profile); | 
 | 609 | 			set_ipv6_apn_to_cfg(&newIpv6Profile); | 
 | 610 |  | 
 | 611 | 		} else if (0 == strcmp(pdp_type, "IPv4v6")) { | 
 | 612 |  | 
 | 613 | 			slog(MISC_PRINT, SLOG_DEBUG, "come to get_ipv4v6apn_profile_by_index"); /*lint !e26*/ | 
 | 614 | 			get_ipv4v6apn_profile_by_index(index_apn, &newProfile, &newIpv6Profile); | 
 | 615 | 			set_ipv4v6_apn_to_cfg(&newProfile, &newIpv6Profile); | 
 | 616 | 		} else { | 
 | 617 | 			slog(MISC_PRINT, SLOG_DEBUG, "come to get_ipv4apn_profile_by_index"); /*lint !e26*/ | 
 | 618 | 			get_apn_profile_by_index(index_apn, &newProfile); | 
 | 619 | 			set_apn_to_cfg(&newProfile); | 
 | 620 | 		} | 
 | 621 | 		sc_cfg_set("apn_index", websGetVar(wp, "index", T(""))); | 
 | 622 | 	} | 
 | 623 |  | 
 | 624 |  | 
 | 625 | 	//send message to MainControl to infrom modify apn | 
 | 626 | 	//zte_send_message(ZUFI_MODULE_ID_AT_MAIN,MSG_CMD_WEB_REQ_APN_SET,0,0); | 
 | 627 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0); | 
 | 628 | } | 
 | 629 |  | 
 | 630 | /********************************************************************** | 
 | 631 | * Function:         get_apn_para_form_web | 
 | 632 | * Description:      get apn parametre from web | 
 | 633 | * Input:            wp | 
 | 634 | * Output:           apn para struct pointer | 
 | 635 | * Return:           NULL | 
 | 636 | * Others: | 
 | 637 | * Modify Date   Version     Author          Modification | 
 | 638 | * ----------------------------------------------- | 
 | 639 | * 2010/11/17   V1.0         maquan          first version | 
 | 640 | **********************************************************************/ | 
 | 641 | static void get_apn_para_form_web(webs_t wp, APN_PROFILE *apn_profile) | 
 | 642 | { | 
 | 643 | 	if (NULL == wp) { | 
 | 644 | 		slog(MISC_PRINT, SLOG_ERR, "NULL para input"); /*lint !e26*/ | 
 | 645 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 646 | 		return; | 
 | 647 | 	} | 
 | 648 |  | 
 | 649 | 	if (zte_apn_param_check(wp, "ipv4") < 0) { | 
 | 650 | 		slog(MISC_PRINT, SLOG_ERR, "ipv4 para input is no safe"); /*lint !e26*/ | 
 | 651 | 		return; | 
 | 652 | 	} | 
 | 653 |  | 
 | 654 | 	strncpy(apn_profile->profile_name, websGetVar(wp, T("profile_name"), T("")), sizeof(apn_profile->profile_name)-1); | 
 | 655 | 	strncpy(apn_profile->apn_name, websGetVar(wp, T("wan_apn"), T("")), sizeof(apn_profile->apn_name)-1); | 
 | 656 | 	strncpy(apn_profile->apn_select, websGetVar(wp, T("apn_select"), T("")), sizeof(apn_profile->apn_select)-1); | 
 | 657 | 	strncpy(apn_profile->dial_num, websGetVar(wp, T("wan_dial"), T("")), sizeof(apn_profile->dial_num)-1); | 
 | 658 | 	strncpy(apn_profile->ppp_auth_mode, websGetVar(wp, T("ppp_auth_mode"), T("")), sizeof(apn_profile->ppp_auth_mode)-1); | 
 | 659 | 	strncpy(apn_profile->ppp_username, websGetVar(wp, T("ppp_username"), T("")), sizeof(apn_profile->ppp_username)-1); | 
 | 660 | 	strncpy(apn_profile->ppp_passwd, websGetVar(wp, T("ppp_passtmp"), T("")), sizeof(apn_profile->ppp_passwd)-1); | 
 | 661 |     strncpy(apn_profile->pdp_type, websGetVar(wp, T("pdp_type"), T("")), sizeof(apn_profile->pdp_type)-1); | 
 | 662 | 	strncpy(apn_profile->pdp_select, websGetVar(wp, T("pdp_select"), T("")), sizeof(apn_profile->pdp_select)-1); | 
 | 663 | 	strncpy(apn_profile->pdp_addr, websGetVar(wp, T("pdp_addr"), T("")), sizeof(apn_profile->pdp_addr)-1); | 
 | 664 | 	strncpy(apn_profile->dns_mode, websGetVar(wp, T("dns_mode"), T("")), sizeof(apn_profile->dns_mode)-1); | 
 | 665 | 	strncpy(apn_profile->prefer_dns_manual, websGetVar(wp, T("prefer_dns_manual"), T("")), sizeof(apn_profile->prefer_dns_manual)-1); | 
 | 666 | 	strncpy(apn_profile->standby_dns_manual, websGetVar(wp, T("standby_dns_manual"), T("")), sizeof(apn_profile->standby_dns_manual)-1); | 
 | 667 |  | 
 | 668 | 	return; | 
 | 669 | } | 
 | 670 |  | 
 | 671 |  | 
 | 672 | static void get_ipv6_apn_para_form_web(webs_t wp, IPV6_APN_PROFILE *apn_profile) | 
 | 673 | { | 
 | 674 | 	if (NULL == wp) { | 
 | 675 | 		slog(MISC_PRINT, SLOG_ERR, "NULL para input"); /*lint !e26*/ | 
 | 676 | 		return; | 
 | 677 | 	} | 
 | 678 |  | 
 | 679 | 	if (zte_apn_param_check(wp, "ipv6") < 0) { | 
 | 680 | 		slog(MISC_PRINT, SLOG_ERR, "ipv6 para input is no safe"); /*lint !e26*/ | 
 | 681 | 		return; | 
 | 682 | 	} | 
 | 683 |  | 
 | 684 | 	strncpy(apn_profile->profile_name, websGetVar(wp, T("profile_name"), T("")), sizeof(apn_profile->profile_name)-1); | 
 | 685 | 	strncpy(apn_profile->apn_name, websGetVar(wp, T("ipv6_wan_apn"), T("")), sizeof(apn_profile->apn_name)-1); | 
 | 686 | 	strncpy(apn_profile->apn_select, websGetVar(wp, T("apn_select"), T("")), sizeof(apn_profile->apn_select)-1); | 
 | 687 | 	strncpy(apn_profile->dial_num, websGetVar(wp, T("wan_dial"), T("")), sizeof(apn_profile->dial_num)-1); | 
 | 688 | 	strncpy(apn_profile->ppp_auth_mode, websGetVar(wp, T(NV_IPV6_PPP_AUTH_MODE), T("")), sizeof(apn_profile->ppp_auth_mode)-1); | 
 | 689 | 	strncpy(apn_profile->ppp_username, websGetVar(wp, T("ipv6_ppp_username"), T("")), sizeof(apn_profile->ppp_username)-1); | 
 | 690 | 	strncpy(apn_profile->ppp_passwd, websGetVar(wp, T("ipv6_ppp_passtmp"), T("")), sizeof(apn_profile->ppp_passwd)-1); | 
 | 691 | 	strncpy(apn_profile->pdp_type, websGetVar(wp, T("pdp_type"), T("")), sizeof(apn_profile->pdp_type)-1); | 
 | 692 | 	strncpy(apn_profile->pdp_select, websGetVar(wp, T("pdp_select"), T("")), sizeof(apn_profile->pdp_select)-1); | 
 | 693 | 	strncpy(apn_profile->pdp_addr, websGetVar(wp, T("pdp_addr"), T("")), sizeof(apn_profile->pdp_addr)-1); | 
 | 694 | 	strncpy(apn_profile->dns_mode, websGetVar(wp, T("ipv6_dns_mode"), T("")), sizeof(apn_profile->dns_mode)-1); | 
 | 695 | 	strncpy(apn_profile->prefer_dns_manual, websGetVar(wp, T("ipv6_prefer_dns_manual"), T("")), sizeof(apn_profile->prefer_dns_manual)-1); | 
 | 696 | 	strncpy(apn_profile->standby_dns_manual, websGetVar(wp, T("ipv6_standby_dns_manual"), T("")), sizeof(apn_profile->standby_dns_manual)-1); | 
 | 697 |  | 
 | 698 | 	return; | 
 | 699 | } | 
 | 700 |  | 
 | 701 | int zte_apn_param_check(webs_t  wp, char * type) | 
 | 702 | { | 
 | 703 | 	char *profile_name = NULL; | 
 | 704 | 	char *wan_apn = NULL; | 
 | 705 | 	char *ppp_username = NULL; | 
 | 706 | 	char *ppp_passwd = NULL; | 
 | 707 |  | 
 | 708 | 	if (0 == strcmp("ipv4", type)) { | 
 | 709 | 		profile_name = websGetVar(wp, T("profile_name"), T("")); | 
 | 710 | 		wan_apn = websGetVar(wp, T("wan_apn"), T("")); | 
 | 711 | 		ppp_username = websGetVar(wp, T("ppp_username"), T("")); | 
 | 712 | 		ppp_passwd = websGetVar(wp, T("ppp_passtmp"), T("")); | 
 | 713 | 		if (DATA_NO_SAFE == zte_Safe_noSpecialChar(profile_name) | 
 | 714 | 		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(wan_apn) | 
 | 715 | 		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_username) | 
 | 716 | 		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_passwd) | 
 | 717 | 		   ) { | 
 | 718 | 			slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:ivp4\n"); /*lint !e26*/ | 
 | 719 | 			return -1; | 
 | 720 | 		} else { | 
 | 721 | 			slog(MISC_PRINT, SLOG_DEBUG, "Get Data is Safe:ivp6\n"); /*lint !e26*/ | 
 | 722 | 			return 1; | 
 | 723 | 		} | 
 | 724 | 	} else if (0 == strcmp("ipv6", type)) { | 
 | 725 | 		profile_name = websGetVar(wp, T("profile_name"), T("")); | 
 | 726 | 		wan_apn = websGetVar(wp, T("ipv6_wan_apn"), T("")); | 
 | 727 | 		ppp_username = websGetVar(wp, T("ipv6_ppp_username"), T("")); | 
 | 728 | 		ppp_passwd = websGetVar(wp, T("ipv6_ppp_passtmp"), T("")); | 
 | 729 | 		if (DATA_NO_SAFE == zte_Safe_noSpecialChar(profile_name) | 
 | 730 | 		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(wan_apn) | 
 | 731 | 		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_username) | 
 | 732 | 		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_passwd) | 
 | 733 | 		   ) { | 
 | 734 | 			slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:ipv6\n"); /*lint !e26*/ | 
 | 735 | 			return -1; | 
 | 736 | 		} else { | 
 | 737 | 			slog(MISC_PRINT, SLOG_DEBUG, "Get Data is Safe:ipv6\n"); /*lint !e26*/ | 
 | 738 | 			return 1; | 
 | 739 | 		} | 
 | 740 | 	} | 
 | 741 | 	slog(MISC_PRINT, SLOG_DEBUG, "Get Data is Safe:no ipv4 or ivp6\n"); /*lint !e26*/ | 
 | 742 | 	return 0; | 
 | 743 | } | 
 | 744 |  | 
 | 745 |  | 
 | 746 |  | 
 | 747 | /********************************************************************** | 
 | 748 | * Function:         set_apn_to_cfg | 
 | 749 | * Description:      set apn para to CFG | 
 | 750 | * Input:            apn parametre struct pointer | 
 | 751 | * Output:           NULL | 
 | 752 | * Return:           NULL | 
 | 753 | * Others: | 
 | 754 | * Modify Date   Version     Author          Modification | 
 | 755 | * ----------------------------------------------- | 
 | 756 | * 2010/11/17   V1.0         maquan          first version | 
 | 757 | **********************************************************************/ | 
 | 758 | static void set_apn_to_cfg(APN_PROFILE *apn_profile) | 
 | 759 | { | 
 | 760 |  | 
 | 761 | 	if (NULL == apn_profile) { | 
 | 762 | 		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/ | 
 | 763 | 		return; | 
 | 764 | 	} | 
 | 765 | 	slog(MISC_PRINT, SLOG_DEBUG, "wan_apn==%s", apn_profile->apn_name); /*lint !e26*/ | 
 | 766 | 	sc_cfg_set("m_profile_name", apn_profile->profile_name); | 
 | 767 | 	sc_cfg_set("wan_apn", apn_profile->apn_name); | 
 | 768 | 	sc_cfg_set("apn_select", apn_profile->apn_select); | 
 | 769 | 	sc_cfg_set("wan_dial", apn_profile->dial_num); | 
 | 770 | 	sc_cfg_set("ppp_auth_mode", apn_profile->ppp_auth_mode); | 
 | 771 | 	sc_cfg_set("ppp_username", apn_profile->ppp_username); | 
 | 772 | 	sc_cfg_set("ppp_passtmp", apn_profile->ppp_passwd); | 
 | 773 | 	sc_cfg_set("pdp_type", apn_profile->pdp_type); | 
 | 774 | 	sc_cfg_set("ipv6_pdp_type", apn_profile->pdp_type); | 
 | 775 | 	sc_cfg_set("pdp_select", apn_profile->pdp_select); | 
 | 776 | 	sc_cfg_set("pdp_addr", apn_profile->pdp_addr); | 
 | 777 | 	apn_encrypt_code(); | 
 | 778 |  | 
 | 779 | 	return; | 
 | 780 | } | 
 | 781 |  | 
 | 782 | static void set_ipv6_apn_to_cfg(IPV6_APN_PROFILE *apn_profile) | 
 | 783 | { | 
 | 784 | 	slog(MISC_PRINT, SLOG_DEBUG, "set_ipv6_apn_to_cfg"); /*lint !e26*/ | 
 | 785 | 	if (NULL == apn_profile) { | 
 | 786 | 		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/ | 
 | 787 | 		return; | 
 | 788 | 	} | 
 | 789 | 	slog(MISC_PRINT, SLOG_DEBUG, "wan_apn==%s", apn_profile->apn_name); /*lint !e26*/ | 
 | 790 | 	sc_cfg_set("m_profile_name", apn_profile->profile_name); | 
 | 791 | 	sc_cfg_set("ipv6_wan_apn", apn_profile->apn_name); | 
 | 792 | 	sc_cfg_set("apn_select", apn_profile->apn_select); | 
 | 793 | 	sc_cfg_set("wan_dial", apn_profile->dial_num); | 
 | 794 | 	sc_cfg_set(NV_IPV6_PPP_AUTH_MODE, apn_profile->ppp_auth_mode); | 
 | 795 | 	sc_cfg_set("ipv6_ppp_username", apn_profile->ppp_username); | 
 | 796 | 	sc_cfg_set("ipv6_ppp_passtmp", apn_profile->ppp_passwd); | 
 | 797 | 	sc_cfg_set("pdp_type", apn_profile->pdp_type); | 
 | 798 | 	sc_cfg_set("ipv6_pdp_type", apn_profile->pdp_type); | 
 | 799 | 	sc_cfg_set("pdp_select", apn_profile->pdp_select); | 
 | 800 | 	sc_cfg_set("pdp_addr", apn_profile->pdp_addr); | 
 | 801 | 	ipv6apn_encrypt_code(); | 
 | 802 |  | 
 | 803 | 	return; | 
 | 804 | } | 
 | 805 |  | 
 | 806 |  | 
 | 807 | static void set_ipv4v6_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile) | 
 | 808 | { | 
 | 809 |  | 
 | 810 | 	if (NULL == apn_profile) { | 
 | 811 | 		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/ | 
 | 812 | 		return; | 
 | 813 | 	} | 
 | 814 | 	sc_cfg_set("m_profile_name", apn_profile->profile_name); | 
 | 815 | 	sc_cfg_set("wan_apn", apn_profile->apn_name); | 
 | 816 | 	sc_cfg_set("apn_select", apn_profile->apn_select); | 
 | 817 | 	sc_cfg_set("wan_dial", apn_profile->dial_num); | 
 | 818 | 	sc_cfg_set("ppp_auth_mode", apn_profile->ppp_auth_mode); | 
 | 819 | 	sc_cfg_set("ppp_username", apn_profile->ppp_username); | 
 | 820 | 	sc_cfg_set("ppp_passtmp", apn_profile->ppp_passwd); | 
 | 821 | 	sc_cfg_set("pdp_type", apn_profile->pdp_type); | 
 | 822 | 	sc_cfg_set("ipv6_pdp_type", apn_profile->pdp_type); | 
 | 823 | 	sc_cfg_set("pdp_select", apn_profile->pdp_select); | 
 | 824 | 	sc_cfg_set("pdp_addr", apn_profile->pdp_addr); | 
 | 825 | 	apn_encrypt_code(); | 
 | 826 |  | 
 | 827 | 	if (NULL == ipv6_apn_profile) { | 
 | 828 | 		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/ | 
 | 829 | 		return; | 
 | 830 | 	} | 
 | 831 | 	sc_cfg_set("m_profile_name", ipv6_apn_profile->profile_name); | 
 | 832 | 	sc_cfg_set("ipv6_wan_apn", ipv6_apn_profile->apn_name); | 
 | 833 | 	sc_cfg_set("apn_select", ipv6_apn_profile->apn_select); | 
 | 834 | 	sc_cfg_set("wan_dial", ipv6_apn_profile->dial_num); | 
 | 835 | 	sc_cfg_set(NV_IPV6_PPP_AUTH_MODE, ipv6_apn_profile->ppp_auth_mode); | 
 | 836 | 	sc_cfg_set("ipv6_ppp_username", ipv6_apn_profile->ppp_username); | 
 | 837 | 	sc_cfg_set("ipv6_ppp_passtmp", ipv6_apn_profile->ppp_passwd); | 
 | 838 | 	sc_cfg_set("pdp_type", apn_profile->pdp_type); | 
 | 839 | 	sc_cfg_set("ipv6_pdp_type", ipv6_apn_profile->pdp_type); | 
 | 840 | 	sc_cfg_set("pdp_select", ipv6_apn_profile->pdp_select); | 
 | 841 | 	sc_cfg_set("pdp_addr", ipv6_apn_profile->pdp_addr); | 
 | 842 | 	ipv6apn_encrypt_code(); | 
 | 843 | 	return; | 
 | 844 | } | 
 | 845 |  | 
 | 846 | /********************************************************************** | 
 | 847 | * Function:         zte_wan_data_statistics_clear_process | 
 | 848 | * Description:      to clear the statistics | 
 | 849 | * Input:            the web para | 
 | 850 | * Output: | 
 | 851 | * Return: | 
 | 852 | * Others:         add form uFi | 
 | 853 | * Modify Date   Version     Author          Modification | 
 | 854 | * ----------------------------------------------- | 
 | 855 |  | 
 | 856 | **********************************************************************/ | 
 | 857 | void zte_wan_data_statistics_clear_process(webs_t wp, char_t *path, char_t *query) | 
 | 858 | { | 
 | 859 | 	long nowtime; | 
 | 860 | 	if (NULL == wp) { | 
 | 861 | 		return; | 
 | 862 | 	} | 
 | 863 |  | 
 | 864 | 	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User clear net data statistics!\n")); | 
 | 865 | 	/*start added by jhy Nov 28, 2013*/ | 
 | 866 | 	(void)zte_web_write("realtime_tx_thrpt", "0"); | 
 | 867 | 	(void)zte_web_write("realtime_rx_thrpt", "0"); | 
 | 868 |  | 
 | 869 | 	(void)zte_web_write("realtime_tx_bytes", "0"); | 
 | 870 | 	(void)zte_web_write("realtime_rx_bytes", "0"); | 
 | 871 | 	(void)zte_web_write("CTotal_vol", "0"); | 
 | 872 | 	(void)zte_web_write("realtime_time", "0"); | 
 | 873 |  | 
 | 874 |  | 
 | 875 | 	time(&nowtime); | 
 | 876 | 	char lastConectedTimeStr[16] = {0}; | 
 | 877 | 	sprintf(lastConectedTimeStr, "%d", nowtime); | 
 | 878 | 	sc_cfg_set("ppp_start_time", lastConectedTimeStr); | 
 | 879 | 	sc_cfg_set("syn_ppp_total", "0"); | 
 | 880 |  | 
 | 881 | 	(void)zte_web_write("monthly_tx_bytes", "0"); | 
 | 882 | 	(void)zte_web_write("monthly_rx_bytes", "0"); | 
 | 883 | 	(void)zte_web_write("flux_month_total", "0"); | 
 | 884 | 	(void)zte_web_write("monthly_time", "0"); | 
 | 885 | 	(void)zte_web_write("MonthlyConTime_Last", "0"); | 
 | 886 | 	(void)zte_web_write("traffic_alined_delta", "0"); | 
 | 887 | 	(void)zte_web_write("duraConTime_before_time_modify", "0"); | 
 | 888 |  | 
 | 889 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0); | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 890 | 	slog(MISC_PRINT, SLOG_NORMAL, "wan_data_statistics_clear_process: send CURR_TOTAL_WIFI_DATA to mc success."); /*lint !e26*/ | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 891 | 	zte_write_result_to_web(wp, SUCCESS); | 
 | 892 | } | 
 | 893 |  | 
 | 894 |  | 
 | 895 | /********************************************************************** | 
 | 896 |  * Function:         zte_form_multi_apn_proc_ex | 
 | 897 |  * Description:      to handle the auto or manual apn set for ipv4ipv6 | 
 | 898 |  * Input:            the web para | 
 | 899 |  * Output: | 
 | 900 |  * Return: | 
 | 901 |  * Others: | 
 | 902 |  * Modify Date   Version     Author          Modification | 
 | 903 |  * ----------------------------------------------- | 
 | 904 |  * | 
 | 905 |  **********************************************************************/ | 
 | 906 |  | 
 | 907 | void zte_form_multi_apn_proc_ex(webs_t wp) | 
 | 908 | { | 
 | 909 | 	char_t *apn_mode  = NULL; | 
 | 910 | 	char_t *apn_action = NULL; | 
 | 911 | 	//int result = 0; | 
 | 912 |  | 
 | 913 | 	// Get the params from pages | 
 | 914 | 	apn_mode = websGetVar(wp, T("apn_mode"), T(""));  /* auto | manual  */ | 
 | 915 | 	apn_action = websGetVar(wp, T("apn_action"), T(""));  // save | delete | set_default | 
 | 916 |  | 
 | 917 | 	slog(MISC_PRINT, SLOG_DEBUG, "apn_mode:[%s], apn_action[%s] \n", apn_mode, apn_action); /*lint !e26*/ | 
 | 918 |  | 
 | 919 | 	//not to check apn_action,auto apn will not need it | 
 | 920 | 	if ('\0' == *apn_mode) { | 
 | 921 | 		slog(MISC_PRINT, SLOG_ERR, "apn_mode is empty. \n"); /*lint !e26*/ | 
 | 922 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 923 | 		return; | 
 | 924 | 	} | 
 | 925 | 	/* AUTO APN */ | 
 | 926 | 	if (0 == strcmp(ZTE_WEB_ACT_AUTO, apn_mode)) { | 
 | 927 | 		sc_cfg_set("auto_apn_index", websGetVar(wp, "auto_apn_index", T("0"))); | 
 | 928 | 		if (0 == zte_wan_auto_apn_set()) { | 
 | 929 | 			zte_write_result_to_web(wp, SUCCESS); | 
 | 930 | 		} else { | 
 | 931 | 			zte_write_result_to_web(wp, FAILURE); | 
 | 932 | 		} | 
 | 933 | 		return; | 
 | 934 | 	} else if (0 == strcmp(ZTE_WEB_ACT_MANUAL, apn_mode)) { | 
 | 935 | 		if (0 == strcmp(apn_action, ZTE_WEB_ACT_SAVE)) { | 
 | 936 | 			slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User save apn! \n")); | 
 | 937 | 			apn_save_process_ex(wp); | 
 | 938 | 		} else if (0 == strcmp(apn_action, ZTE_WEB_ACT_SETDEFAULT)) { | 
 | 939 | 			slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set default apn! \n")); | 
 | 940 | 			zte_web_write("apn_mode", ZTE_WEB_ACT_MANUAL); | 
 | 941 | 			apn_set_default_process_ex(wp); | 
 | 942 | 			//apn_set_default_with_profile_index_ex(wp); | 
 | 943 | 		} else if (0 == strcmp(apn_action, ZTE_WEB_ACT_DELETE)) { | 
 | 944 | 			slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User delete apn! \n")); | 
 | 945 | 			apn_delete_process_ex(wp); | 
 | 946 | 		} else { | 
 | 947 | 			slog(MISC_PRINT, SLOG_ERR, "invalid apn_action. \n"); /*lint !e26*/ | 
 | 948 | 			zte_write_result_to_web(wp, FAILURE); | 
 | 949 | 			return; | 
 | 950 | 		} | 
 | 951 | 	} else { | 
 | 952 | 		slog(MISC_PRINT, SLOG_ERR, "invalid apn_mode. \n"); /*lint !e26*/ | 
 | 953 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 954 | 		return; | 
 | 955 | 	} | 
 | 956 |  | 
 | 957 |  | 
 | 958 | 	zte_write_result_to_web(wp, SUCCESS); | 
 | 959 |  | 
 | 960 | 	return; | 
 | 961 |  | 
 | 962 | } | 
 | 963 |  | 
 | 964 |  | 
 | 965 | static int zte_wan_auto_apn_set() | 
 | 966 | { | 
 | 967 | 	//int count = 0; | 
 | 968 | 	APN_PROFILE  newProfile; | 
 | 969 | 	zte_web_write("apn_mode", ZTE_WEB_ACT_AUTO); | 
 | 970 | 	memset(&newProfile, 0, sizeof(newProfile)); | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 971 | 	slog(MISC_PRINT, SLOG_NORMAL,"LPC: wan_auto_apn_set enter! \n"); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 972 | 	get_autoapn_profile(&newProfile); | 
 | 973 | 	set_apn_to_cfg(&newProfile); | 
 | 974 | 	//send message to MainControl to infrom modify apn | 
 | 975 | #if 0	// kw 3 | 
 | 976 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0); | 
 | 977 | 	return 0; | 
 | 978 | #else | 
 | 979 |     return ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0); | 
 | 980 | #endif | 
 | 981 | } | 
 | 982 |  | 
 | 983 |  | 
 | 984 |  | 
 | 985 | void apn_set_default_process_ex(webs_t wp) | 
 | 986 | { | 
 | 987 | 	char_t *webAction = NULL; | 
 | 988 | 	webAction = websGetVar(wp, T("set_default_flag"), T("")); | 
 | 989 | 	slog(MISC_PRINT, SLOG_NORMAL, "goahead apn_set_default_process apn_action=%s.\n", webAction); | 
 | 990 |  | 
 | 991 | 	if (0 == strcmp(webAction, APN_ONLY_SET_DEFAULT)) { //profile_name | 
 | 992 | 		apn_set_default_with_profile_index_ex(wp); | 
 | 993 | 	} else if (0 == strcmp(webAction, APN_SAVE_AND_SET_DEFAULT)) { | 
 | 994 | 		apn_set_default_with_new_profile_ex(wp); | 
 | 995 | 	} else { | 
 | 996 | 		slog(MISC_PRINT, SLOG_DEBUG, "invalid set_default_flag[%s].", webAction); | 
 | 997 | 		return ; | 
 | 998 | 	} | 
 | 999 |  | 
 | 1000 | } | 
 | 1001 | void apn_set_default_with_new_profile_ex(webs_t wp) | 
 | 1002 | { | 
 | 1003 | 	int index_apn = 0; | 
 | 1004 | 	APN_PROFILE newApn; | 
 | 1005 | 	IPV6_APN_PROFILE  newIpv6Profile; | 
 | 1006 |  | 
 | 1007 | 	char_t *pdp_type = NULL; | 
 | 1008 |  | 
 | 1009 | 	pdp_type = websGetVar(wp, T("pdp_type"), T("")); | 
 | 1010 |  | 
 | 1011 |  | 
 | 1012 |  | 
 | 1013 | 	memset(&newApn, 0, sizeof(APN_PROFILE)); | 
 | 1014 | 	memset(&newIpv6Profile, 0, sizeof(IPV6_APN_PROFILE)); | 
 | 1015 |  | 
 | 1016 | 	index_apn = atoi(websGetVar(wp, "index", T(""))); | 
 | 1017 |  | 
 | 1018 | 	get_apn_para_form_web(wp, &newApn); | 
 | 1019 | 	set_apn_profile_by_index(index_apn, &newApn); | 
 | 1020 | 	set_apn_prof_aes_by_index(index_apn, &newApn); | 
 | 1021 |  | 
 | 1022 | 	get_ipv6_apn_para_form_web(wp, &newIpv6Profile); | 
 | 1023 | 	set_ipv6_apn_profile_by_index(index_apn, &newIpv6Profile); | 
 | 1024 | 	set_ipv6_apn_prof_aes_by_index(index_apn, &newIpv6Profile); | 
 | 1025 |  | 
 | 1026 | 	if (0 == strcmp(pdp_type, "IPv6")) { | 
 | 1027 | 		set_ipv6_apn_to_cfg(&newIpv6Profile); | 
 | 1028 | 	} else if (0 == strcmp(pdp_type, "IPv4v6")) { | 
 | 1029 | 		set_ipv4v6_apn_to_cfg(&newApn, &newIpv6Profile); | 
 | 1030 | 	} else { | 
 | 1031 | 		set_apn_to_cfg(&newApn); | 
 | 1032 | 	} | 
 | 1033 |  | 
 | 1034 |  | 
 | 1035 | 	slog(MISC_PRINT, SLOG_NORMAL, "apn_set_default_with_new_profile_ex index_apn=%d", index_apn); | 
 | 1036 |  | 
 | 1037 | 	sc_cfg_set("apn_index", websGetVar(wp, "index", T(""))); | 
 | 1038 | 	//send message to MainControl to infrom modify apn | 
 | 1039 | 	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0); | 
 | 1040 |  | 
 | 1041 | } | 
 | 1042 |  | 
 | 1043 | /********************************************************************** | 
 | 1044 | * Function:         zte_wan_util_set_dial_roam_switch | 
 | 1045 | * Description:      to set the dial roam switch | 
 | 1046 | * Input:            roam_set: to set value | 
 | 1047 | * Output: | 
 | 1048 | * Return:           -1:fail;0:success | 
 | 1049 | * Others: | 
 | 1050 | * Modify Date   Version     Author          Modification | 
 | 1051 | * ----------------------------------------------- | 
 | 1052 | * 2012/09/19    V1.0        chenyi       first version | 
 | 1053 | **********************************************************************/ | 
 | 1054 | static int zte_wan_util_set_dial_roam_switch(const char_t *roam_set) | 
 | 1055 | { | 
 | 1056 | 	if (NULL == roam_set) { | 
 | 1057 | 		return 0;//user don't care it ,so return 0 | 
 | 1058 | 	} | 
 | 1059 |  | 
 | 1060 | 	if ('\0' == (*roam_set)) { | 
 | 1061 | 		slog(MISC_PRINT, SLOG_ERR, "dial roam set is empty."); /*lint !e26*/ | 
 | 1062 | 		return -1; | 
 | 1063 | 	} | 
 | 1064 |  | 
 | 1065 | 	if (ZTE_NVIO_DONE != zte_web_write(NV_ROAM_SETTING_OPTION, roam_set)) { /*lint !e605*/ | 
 | 1066 | 		slog(MISC_PRINT, SLOG_ERR, "write nv [%s] fail.", NV_ROAM_SETTING_OPTION); /*lint !e26*/ | 
 | 1067 | 		return -1; | 
 | 1068 | 	} else { | 
 | 1069 | 		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_ROAM_SET_REQ, 0, NULL, 0); | 
 | 1070 | 		return 0; | 
 | 1071 | 	} | 
 | 1072 | } | 
 | 1073 |  | 
 | 1074 |  | 
 | 1075 | void zte_wan_data_flow_calibration_manual(webs_t wp) | 
 | 1076 | { | 
 | 1077 | 	char *p_data = NULL; | 
 | 1078 | 	float time = 0; | 
 | 1079 | 	char buf[NV_ITEM_STRING_LEN_50] = {0}; | 
 | 1080 | 	unsigned long long data = 0; | 
 | 1081 | 	if (NULL == wp) { | 
 | 1082 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 1083 | 		return; | 
 | 1084 | 	} | 
 | 1085 |  | 
 | 1086 | 	p_data = websGetVar(wp, T("calibration_way"), NULL); | 
 | 1087 |  | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1088 | 	slog(MISC_PRINT, SLOG_NORMAL,"wan_data_flow_calibration_manual calibration_way = %s\n", p_data); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1089 | 	if (p_data == NULL) { | 
 | 1090 | 		zte_write_result_to_web(wp, FAILURE); | 
 | 1091 | 		return; | 
 | 1092 | 	} | 
 | 1093 |  | 
 | 1094 | 	if (0 == strcmp(p_data, "time")) { | 
 | 1095 | 		p_data = websGetVar(wp, T("time"), NULL); | 
 | 1096 | 		if (p_data != NULL) { | 
 | 1097 | 			time = atof(p_data); | 
 | 1098 | 			sprintf(buf, "%ld", (long)(time * 60 * 60)); | 
 | 1099 | 			sc_cfg_set("monthly_time", buf); | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1100 | 			slog(MISC_PRINT, SLOG_DEBUG,"wan_data_flow_calibration_manual time:value = %f, buf = %s\n", time, buf); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1101 | 			zte_write_result_to_web(wp, SUCCESS); | 
 | 1102 | 			ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0); | 
 | 1103 | 			return; | 
 | 1104 | 		} | 
 | 1105 | 	} else if (0 == strcmp(p_data, "data")) { | 
 | 1106 | 		p_data = websGetVar(wp, T("data"), NULL); | 
 | 1107 | 		if (p_data != NULL) { | 
 | 1108 | 			float data_tmp = 0; | 
 | 1109 | 			data_tmp = atof(p_data); | 
 | 1110 | 			//data = strtoll(p_data,NULL,10); | 
 | 1111 | 			data = (unsigned long long)(data_tmp * 1024 * 1024); | 
 | 1112 | 			errno = 0; | 
 | 1113 | 			long long ret_strtoll = strtoll(p_data, NULL, 10); | 
 | 1114 | 			if (errno == ERANGE)// kw ERRNO.NOT_CHECKED | 
 | 1115 | 			{ | 
 | 1116 | 				slog(MISC_PRINT, SLOG_ERR,"strtoll errno %d: %s\n", errno, strerror(errno)); | 
 | 1117 | 			} | 
| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1118 | 			slog(MISC_PRINT, SLOG_DEBUG,"wan_data_flow_calibration_manual data:111 data = %lld, %lld\n", data, ret_strtoll); | 
| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1119 | 			sprintf(buf, "%lld", data); | 
 | 1120 | 			sc_cfg_set("monthly_tx_bytes", "0"); | 
 | 1121 | 			sc_cfg_set("monthly_rx_bytes", buf); | 
 | 1122 | 			sc_cfg_set("flux_month_total", buf); | 
 | 1123 | 			zte_write_result_to_web(wp, SUCCESS); | 
 | 1124 | 			//flux_call_cb(CB_MSG_MMI_TRAFFIC_INFO_RESET, NULL ,0); | 
 | 1125 | 			ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0); | 
 | 1126 | 			return; | 
 | 1127 | 		} | 
 | 1128 | 	} | 
 | 1129 |  | 
 | 1130 | 	zte_write_result_to_web(wp, FAILURE); | 
 | 1131 | } |