blob: 7e999fb261f43323803583eb6b808b59ee89640a [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001//Á÷Á¿Í³¼Æ
2#include "fluxstat.h"
3#include <sys/sem.h>
4#include <sys/ipc.h>
5#include <errno.h>
6#include <sys/prctl.h>
7#include <limits.h>
8
9
10pthread_mutex_t g_getaddrinfo_mutex;
11pthread_mutex_t g_getnameinfo_mutex;
12
13int flux_enable_flag = 0;//Á÷Á¿Í³¼ÆÔËÐбêÖ¾
14time_t last_connect_time = 0; //×î½üÒ»´ÎpdpÁ¬½Óʱ¼ä
15BOOL g_need_send_flux_warnning = TRUE; //ÊÇ·ñÐèÒª·¢ËÍÁ÷Á¿¸æ¾¯ÏûÏ¢
16BOOL g_need_send_flux_over =TRUE; //ÊÇ·ñÐèÒª·¢ËÍ×ÜÁ÷Á¿³¬ÏÞÏûÏ¢
17static int init_sem(int sem_id, int init_value)
18{
19 union semun sem_union;
20 sem_union.val = init_value;
21 if (semctl(sem_id, 0, SETVAL, sem_union) == -1) {
22 return -1;
23 }
24 return 0;
25}
26
27// ɾ³ýsem_idÐźÅÁ¿
28static int del_sem(int sem_id)
29{
30 union semun sem_union = {0}; //cov h
31 if (semctl(sem_id, 0, IPC_RMID, sem_union) == -1) {
32 return -1;
33 }
34 return 0;
35}
36
37// ¶Ôsem_idÖ´ÐÐp²Ù×÷
38static int sem_p(int sem_id)
39{
40 struct sembuf sem_buf;
41 sem_buf.sem_num = 0; //ÐźÅÁ¿±àºÅ
42 sem_buf.sem_op = -1; //P²Ù×÷
43 sem_buf.sem_flg = SEM_UNDO; //ϵͳÍ˳öǰδÊÍ·ÅÐźÅÁ¿£¬ÏµÍ³×Ô¶¯ÊÍ·Å
44 if (semop(sem_id, &sem_buf, 1) == -1) {
45 return -1;
46 }
47 return 0;
48}
49
50// ¶Ôsem_idÖ´ÐÐV²Ù×÷
51static int sem_v(int sem_id)
52{
53 struct sembuf sem_buf;
54 sem_buf.sem_num = 0;
55 sem_buf.sem_op = 1; //V²Ù×÷
56 sem_buf.sem_flg = SEM_UNDO;
57 if (semop(sem_id, &sem_buf, 1) == -1) {
58 return -1;
59 }
60 return 0;
61}
62
63static int get_sem(key_t sem_key)
64{
65 int sem_id = -1;
66
67 sem_id = semget(sem_key, 1, 0666 | IPC_CREAT | IPC_EXCL);
68 if (sem_id < 0) {
69 if (errno == EEXIST) {
70 slog(FLUXSTAT_PRINT, SLOG_ERR, "[fluxstat]semget already exist\n");
71 return semget(sem_key, 1, 0666 | IPC_CREAT);
72 }
73 slog(FLUXSTAT_PRINT, SLOG_ERR, "[fluxstat]semget == -1, return fail\n");
74 return -1;
75 }
76
77 union semun sem_union;
78 sem_union.val = 1;
79 if (semctl(sem_id, 0, SETVAL, sem_union) == -1) {
80 return -1;
81 }
82
83 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[fluxstat]semget sem_id= %d, get sem success\n", sem_id);;
84 return sem_id;
85}
86
87
88void action_reach_month_limit(void)
89{
90 char keep_online[10] = {0};
91 char auto_connect[10] = {0};
92
93 sc_cfg_get("keep_online_when_limited", keep_online, sizeof(keep_online));
94 if (0 == strcmp(keep_online, "no")) {
95 if (0 != ipc_send_message(MODULE_ID_FLUXSTAT, MODULE_ID_AT_CTL, MSG_CMD_PDP_DEACT_REQ, 0, NULL, 0)) {
96 slog(FLUXSTAT_PRINT, SLOG_ERR, "fluxstat send disconnect msg fail.\n");
97 return;
98 }
99 }
100
101 sc_cfg_get("auto_connect_when_limited", auto_connect, sizeof(auto_connect));
102 if (0 == strcmp(auto_connect, "no")) {
103 sc_cfg_set(NV_DIAL_MODE, "manual_dial");
104 } else if (0 == strcmp(auto_connect, "yes")) {
105 sc_cfg_set(NV_DIAL_MODE, "auto_dial");
106 }
107}
108
109void flux_reach_month_limit()
110{
111 char total1[20] = {0};
112 char total2[20] = {0};
113 char delta[20] = {0};
114 long long total1_v = 0; //kw 3
115 long long total2_v = 0;
116 long long delta_v = 0;
117 char limit_swith[10] = {0};
118 char percent[10] = {0};
119 char data_switch[10] = {0};
120 int m_warn_value = 0;
121
122 sc_cfg_get("is_traffic_limit_on", limit_swith, sizeof(limit_swith));
123 sc_cfg_get("flux_month_total", total1, sizeof(total1));
124 sc_cfg_get("traffic_alined_delta", delta, sizeof(delta));
125 sc_cfg_get("traffic_month_total", total2, sizeof(total2));
126 //kw 3
127 total1_v = atoll(total1);
128 if (total1_v < 0 || total1_v > LLONG_MAX-1)
129 total1_v = 0;
130 delta_v = atoll(delta);
131 if (delta_v < 0 || delta_v > LLONG_MAX-1)
132 delta_v = 0;
133 total2_v = atoll(total2);
134 if (total2_v < 0 || total2_v > LLONG_MAX-1)
135 total2_v = 0;
136
137 if (0 == strcmp(limit_swith, "yes") && total1_v + delta_v >= total2_v * 1024 * 1024) {
138 action_reach_month_limit();
139 }
140#if (PRODUCT_TYPE == PRODUCT_PHONE)
141 sc_cfg_get(NV_TRAFFIC_LIMIT_SWITCH, data_switch, sizeof(percent));
142 sc_cfg_get(NV_TRAFFIC_ALERT_PERCENT, percent, sizeof(percent));
143 m_warn_value = strlen(percent) == 0 ? 100 : atoi(percent);
144 /*klocwork 3 SV.TAINTED.BINOP, add if condition*/
145 if((m_warn_value < 0 ) || (m_warn_value > 100))
146 {
147 return;
148 }
149 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux] flux_reach_warnning_limit,data_switch=%s, flux_enable_flag=%d, m_warn_value = %d, total = %lld\n", data_switch, flux_enable_flag, m_warn_value, total2_v); //cov m
150
151 if ((0==strcmp(data_switch, "1")) && (1 == flux_enable_flag) && (m_warn_value > 0) && (total2_v > 0))
152 {
153 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux] flux_reach_warnning_limit,used =%lld, warn =%lld\n", atoll(total1), (total2_v * 1024 * 1024 * m_warn_value)/100);
154
155 if(total1_v >= (total2_v * 1024 * 1024 * m_warn_value)/100)
156 {
157 if(m_warn_value == 100 && TRUE == g_need_send_flux_over)
158 {
159 platform_send_msg(MODULE_ID_FLUXSTAT, MODULE_ID_MMI_SVR, MSG_CMD_DATAMANAGER_REACH_LIMIT, 0, NULL);
160 g_need_send_flux_over = FALSE;
161 }
162 else
163 {
164 if((total1_v >= (total2_v * 1024 * 1024)) && TRUE == g_need_send_flux_over)
165 {
166 platform_send_msg(MODULE_ID_FLUXSTAT, MODULE_ID_MMI_SVR, MSG_CMD_DATAMANAGER_REACH_LIMIT, 0, NULL);
167 g_need_send_flux_over = FALSE;
168 }
169 else if(TRUE == g_need_send_flux_warnning)
170 {
171 platform_send_msg(MODULE_ID_FLUXSTAT, MODULE_ID_MMI_SVR, MSG_CMD_DATAMANAGER_REACH_WARNVALUE, 0, NULL);
172 g_need_send_flux_warnning = FALSE;
173 }
174 }
175 }
176 }
177#endif
178}
179
180void data_cfg_init()
181{
182 //sc_cfg_set("DataStatus","");
183 sc_cfg_set("realtime_time", "0");
184 sc_cfg_set("realtime_tx_bytes", "0");
185 sc_cfg_set("realtime_rx_bytes", "0");
186 sc_cfg_set("CTotal_vol", "0");
187 sc_cfg_set("realtime_tx_thrpt", "0");
188 sc_cfg_set("realtime_rx_thrpt", "0");
189 //sc_cfg_set("CurrSpeed_total","0");
190// sc_cfg_set("AverSpeed_up","0");
191// sc_cfg_set("AverSpeed_down","0");
192// sc_cfg_set("AverSpeed_total","0");
193 sc_cfg_set("duraConTime_before_time_modify", "0");
194 sc_cfg_set("flux_total_flow_when_power_on", "0");
195
196}
197
198void clear_nv()
199{
200 sc_cfg_set("realtime_tx_thrpt", "0");
201 sc_cfg_set("realtime_rx_thrpt", "0");
202 sc_cfg_set("traffic_alined_delta", "0");
203 sc_cfg_set("monthly_tx_bytes", "0");
204 sc_cfg_set("monthly_rx_bytes", "0");
205 sc_cfg_set("flux_month_total", "0");
206 sc_cfg_set("monthly_time", "0");
207 sc_cfg_set("MonthlyConTime_Last", "0");
208}
209
210
211int fluxstat_clear_process(char *str_year_buf, char *str_month_buf)
212{
213 char sntp_mode[20] = {0};
214 char sntp_nv_year[20] = {0};
215 char sntp_nv_month[20] = {0};
216 char need_clear[20] = {0};
217 char sntp_result[20] = {0};
218
219 sc_cfg_get("need_clear_traffic_data", need_clear, sizeof(need_clear));
220
221 sc_cfg_get("sntp_time_set_mode", sntp_mode, sizeof(sntp_mode));
222
223 if (strcmp("manual", sntp_mode) == 0) {
224 slog(FLUXSTAT_PRINT, SLOG_NORMAL, "[flux] manual time,check clear_nv,need_clear=%s\n", need_clear);
225
226 if (0 != strcmp("no", need_clear)) {
227 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux] manual reset fluxstat\n");
228 clear_nv();
229 }
230 } else {
231 slog(FLUXSTAT_PRINT, SLOG_NORMAL, "[flux] sntp time\n");
232
233 sc_cfg_get("clear_nv_year_temp", sntp_nv_year, sizeof(sntp_nv_year));
234 sc_cfg_get("clear_nv_month_temp", sntp_nv_month, sizeof(sntp_nv_month));
235 sc_cfg_get("sntp_process_result", sntp_result, sizeof(sntp_result));
236
237 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux] sntp time,nv temp:%s %s\n", sntp_nv_year, sntp_nv_month);
238 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux] sntp time,result:%s\n", sntp_result);
239 if (strcmp("success", sntp_result) == 0) {
240 if ((strcmp(str_year_buf, sntp_nv_year) != 0) || (strcmp(str_month_buf, sntp_nv_month) != 0)) {
241 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux] sntp need reset\n");
242
243 if (0 != strcmp("no", need_clear)) {
244 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux] reset fluxstat\n");
245 clear_nv();
246 }
247 }
248 }
249
250 }
251 return 1;
252
253}
254
255void month_turnto_num(char *imonth, char *month)
256{
257 if (0 == strcmp("Jan", month)) {
258 strcpy(imonth, "01");
259 } else if (0 == strcmp("Feb", month)) {
260 strcpy(imonth, "02");
261 } else if (0 == strcmp("Mar", month)) {
262 strcpy(imonth, "03");
263 } else if (0 == strcmp("Apr", month)) {
264 strcpy(imonth, "04");
265 } else if (0 == strcmp("May", month)) {
266 strcpy(imonth, "05");
267 } else if (0 == strcmp("Jun", month)) {
268 strcpy(imonth, "06");
269 } else if (0 == strcmp("Jul", month)) {
270 strcpy(imonth, "07");
271 } else if (0 == strcmp("Aug", month)) {
272 strcpy(imonth, "08");
273 } else if (0 == strcmp("Sep", month)) {
274 strcpy(imonth, "09");
275 } else if (0 == strcmp("Oct", month)) {
276 strcpy(imonth, "10");
277 } else if (0 == strcmp("Nov", month)) {
278 strcpy(imonth, "11");
279 } else if (0 == strcmp("Dec", month)) {
280 strcpy(imonth, "12");
281 }
282}
283
284void set_time_flux_day_and_month(int update_flag)
285{
286 char set_current_day[10] = {0};
287 char set_current_month[10] = {0};
288 char set_current_year[10] = {0};
289
290 sc_cfg_get("flux_set_day", set_current_day, sizeof(set_current_day));
291 sc_cfg_get("flux_set_month", set_current_month, sizeof(set_current_month));
292 sc_cfg_get("flux_set_year", set_current_year, sizeof(set_current_year));
293
294
295 if (1 == update_flag || 0 == strlen(set_current_day)
296 || 0 == strlen(set_current_month) || 0 == strlen(set_current_year)) {
297 memset(set_current_day, 0, sizeof(set_current_day));
298 memset(set_current_month, 0, sizeof(set_current_month));
299 memset(set_current_year, 0, sizeof(set_current_year));
300 sc_cfg_get("sntp_day", set_current_day, sizeof(set_current_day));
301 sc_cfg_get("sntp_month", set_current_month, sizeof(set_current_month));
302 sc_cfg_get("sntp_year", set_current_year, sizeof(set_current_year));
303
304 sc_cfg_set("flux_set_day", set_current_day);
305 sc_cfg_set("flux_set_month", set_current_month);
306 sc_cfg_set("flux_set_year", set_current_year);
307 }
308}
309
310//cov m
311void flux_day_and_month(unsigned long long current_send, unsigned long long current_rcv)
312{
313
314 char current_day_flux[128] = {0};
315 char current_month_flux[128] = {0};
316 char current_month_send_flux[128] = {0};
317 char current_month_rcv_flux[128] = {0};
318 char char_last_send_day_and_month[128] = {0};
319 char char_last_rcv_day_and_month[128] = {0};
320 unsigned long long current_total_day = 0;
321 unsigned long long current_total_month = 0;
322 unsigned long long current_total_send_month = 0;
323 unsigned long long current_total_rcv_month = 0;
324 long long tmp_day = 0; //kw 3
325 long long tmp_month = 0;
326 long long tmp_send_month = 0;
327 long long tmp_rcv_month = 0;
328
329 sc_cfg_get("flux_day_total", current_day_flux, sizeof(current_day_flux));
330 sc_cfg_get("flux_month_total", current_month_flux, sizeof(current_month_flux));
331 sc_cfg_get("monthly_tx_bytes", current_month_send_flux, sizeof(current_month_send_flux));
332 sc_cfg_get("monthly_rx_bytes", current_month_rcv_flux, sizeof(current_month_rcv_flux));
333
334 tmp_day = atoll(current_day_flux);
335 if (tmp_day < 0 || tmp_day > LLONG_MAX-1)
336 tmp_day = 0;
337 tmp_month = atoll(current_month_flux);
338 if (tmp_month < 0 || tmp_month > LLONG_MAX-1)
339 tmp_month = 0;
340 tmp_send_month = atoll(current_month_send_flux);
341 if (tmp_send_month < 0 || tmp_send_month > LLONG_MAX-1)
342 tmp_send_month = 0;
343 tmp_rcv_month = atoll(current_month_rcv_flux);
344 if (tmp_rcv_month < 0 || tmp_rcv_month > LLONG_MAX-1)
345 tmp_rcv_month = 0;
346
347 current_total_day = tmp_day + current_send + current_rcv;
348 current_total_month = tmp_month + current_send + current_rcv;
349 current_total_send_month = tmp_send_month + current_send;
350 current_total_rcv_month = tmp_rcv_month + current_rcv;
351
352 snprintf(current_day_flux, 64, "%llu", current_total_day);
353 snprintf(current_month_flux, 64, "%llu", current_total_month);
354 snprintf(current_month_send_flux, 64, "%llu", current_total_send_month);
355 snprintf(current_month_rcv_flux, 64, "%llu", current_total_rcv_month);
356
357 sc_cfg_set("flux_day_total", current_day_flux);
358 sc_cfg_set("flux_month_total", current_month_flux);
359 sc_cfg_set("monthly_tx_bytes", current_month_send_flux);
360 sc_cfg_set("monthly_rx_bytes", current_month_rcv_flux);
361
362 flux_reach_month_limit();
363}
364
365
366int getInterface(char *wan_name, int len)
367{
368 char default_wan_rel[30] = {0};
369 char default_wan6_rel[30] = {0};
370 char pswan[30] = {0};
371 sc_cfg_get("pswan", pswan, sizeof(pswan));
372 sc_cfg_get("default_wan_rel", default_wan_rel, sizeof(default_wan_rel));
373 sc_cfg_get("default_wan6_rel", default_wan6_rel, sizeof(default_wan6_rel));
374
375 if (0 != strcmp(default_wan_rel, "") && 0 == strncmp(default_wan_rel, pswan, strlen(pswan))) {
376 strcpy(wan_name, default_wan_rel);
377 return 0;
378 } else if (0 != strcmp(default_wan6_rel, "") && 0 == strncmp(default_wan6_rel, pswan, strlen(pswan))) {
379 strcpy(wan_name, default_wan6_rel);
380 return 0;
381 } else {
382 return -1;
383 }
384
385}
386
387
388
389//ÖÕ¶ËÉϵçºó£¬ÏàÓ¦µÄ·¢ËÍ¡¢½ÓÊÕÒÔ¼°×ÜÁ÷Á¿ºÍÏàÓ¦ËÙÂʵÄͳ¼Æ
390void flux_realtime(unsigned long long current_tx_bytes, unsigned long long current_rx_bytes)
391{
392 char rbuf1[64] = {0};
393 char rbuf2[64] = {0};
394 char rbuf3[64] = {0};
395 char wbuf1[64] = {0};
396 char wbuf2[64] = {0};
397 char wbuf3[64] = {0};
398 unsigned long long total_tx = 0, total_rx = 0, total_bytes = 0;
399 unsigned long long last_tx = 0, last_rx = 0, last_bytes = 0;
400 unsigned long long current_total_bytes = 0;
401 unsigned long long current_tx_speed = 0, current_rx_speed = 0, current_total_speed = 0;
402 unsigned long long current_boot_total = 0;
403 long long tmp_rbuf1 = 0; //kw 3
404 long long tmp_rbuf2 = 0;
405 long long tmp_rbuf3 = 0;
406
407 current_total_bytes = current_tx_bytes + current_rx_bytes;
408
409 //Á÷ËÙ
410 current_tx_speed = current_tx_bytes / 1;
411 current_rx_speed = current_rx_bytes / 1;
412 current_total_speed = current_tx_speed + current_rx_speed;
413 snprintf(wbuf1, 64, "%llu", current_tx_speed);
414 snprintf(wbuf2, 64, "%llu", current_rx_speed);
415 snprintf(wbuf3, 64, "%llu", current_total_speed);
416 sc_cfg_set("realtime_tx_thrpt", wbuf1);
417 sc_cfg_set("realtime_rx_thrpt", wbuf2);
418 //sc_cfg_set("CurrSpeed_total", wbuf3);
419
420
421 memset(wbuf1, 0, sizeof(wbuf1));
422 memset(wbuf2, 0, sizeof(wbuf2));
423 memset(wbuf3, 0, sizeof(wbuf3));
424
425
426
427 //±¾´Î¿ª»úÉÏÏÂÐÐÁ÷Á¿
428 sc_cfg_get("realtime_tx_bytes", rbuf1, sizeof(rbuf1));
429 sc_cfg_get("realtime_rx_bytes", rbuf2, sizeof(rbuf2));
430 sc_cfg_get("CTotal_vol", rbuf3, sizeof(rbuf3));
431 tmp_rbuf1 = atoll(rbuf1);
432 if (tmp_rbuf1 < 0 || tmp_rbuf1 > LLONG_MAX-1)
433 tmp_rbuf1 = 0;
434 tmp_rbuf2 = atoll(rbuf2);
435 if (tmp_rbuf2 < 0 || tmp_rbuf2 > LLONG_MAX-1)
436 tmp_rbuf2 = 0;
437 tmp_rbuf3 = atoll(rbuf3);
438 if (tmp_rbuf3 < 0 || tmp_rbuf3 > LLONG_MAX-1)
439 tmp_rbuf3 = 0;
440 total_tx = tmp_rbuf1 + current_tx_bytes;
441 total_rx = tmp_rbuf2 + current_rx_bytes;
442 total_bytes = tmp_rbuf3 + current_total_bytes;
443 snprintf(wbuf1, 64, "%llu", total_tx);
444 snprintf(wbuf2, 64, "%llu", total_rx);
445 snprintf(wbuf3, 64, "%llu", total_bytes);
446 sc_cfg_set("realtime_tx_bytes", wbuf1);
447 sc_cfg_set("realtime_rx_bytes", wbuf2);
448 sc_cfg_set("CTotal_vol", wbuf3);
449
450
451 memset(rbuf1, 0, sizeof(rbuf1));
452 memset(rbuf2, 0, sizeof(rbuf2));
453 memset(rbuf3, 0, sizeof(rbuf3));
454 memset(wbuf1, 0, sizeof(wbuf1));
455 memset(wbuf2, 0, sizeof(wbuf2));
456 memset(wbuf3, 0, sizeof(wbuf3));
457
458 //ÉÏÏÂÐÐ×ÜÁ÷Á¿
459 sc_cfg_get("Last_up", rbuf1, sizeof(rbuf1));
460 sc_cfg_get("Last_down", rbuf2, sizeof(rbuf2));
461 sc_cfg_get("Last_total", rbuf3, sizeof(rbuf3));
462 tmp_rbuf1 = atoll(rbuf1);
463 if (tmp_rbuf1 < 0 || tmp_rbuf1 > LLONG_MAX-1)
464 tmp_rbuf1 = 0;
465 tmp_rbuf2 = atoll(rbuf2);
466 if (tmp_rbuf2 < 0 || tmp_rbuf2 > LLONG_MAX-1)
467 tmp_rbuf2 = 0;
468 tmp_rbuf3 = atoll(rbuf3);
469 if (tmp_rbuf3 < 0 || tmp_rbuf3 > LLONG_MAX-1)
470 tmp_rbuf3 = 0;
471 last_tx = tmp_rbuf1 + current_tx_bytes;
472 last_rx = tmp_rbuf2 + current_rx_bytes;
473 last_bytes = tmp_rbuf3 + current_total_bytes;
474 snprintf(wbuf1, 64, "%llu", last_tx);
475 snprintf(wbuf2, 64, "%llu", last_rx);
476 snprintf(wbuf3, 64, "%llu", last_bytes);
477 sc_cfg_set("Last_up", wbuf1);
478 sc_cfg_set("Last_down", wbuf2);
479 sc_cfg_set("Last_total", wbuf3);
480
481 memset(rbuf1, 0, sizeof(rbuf1));
482 memset(wbuf1, 0, sizeof(wbuf1));
483
484 //±¾´Î¿ª»úÁ÷Á¿£¬ºÍCTotal_volÓÐÖØ¸´
485 sc_cfg_get("flux_total_flow_when_power_on", rbuf1, sizeof(rbuf1));
486 tmp_rbuf1 = atoll(rbuf1);
487 if (tmp_rbuf1 < 0 || tmp_rbuf1 > LLONG_MAX-1)
488 tmp_rbuf1 = 0;
489 current_boot_total = tmp_rbuf1 + current_total_bytes;
490 snprintf(wbuf1, 64, "%llu", current_boot_total);
491 sc_cfg_set("flux_total_flow_when_power_on", wbuf1);
492}
493
494void fluxstat_main_loop(void *arg)
495{
496 unsigned long long data_send = 0, data_rcv = 0;
497 unsigned long long data_send_total = 0, data_rcv_total = 0;
498 unsigned long long last_send = 0, last_rcv = 0;
499 int tx_res = 0;
500 int rx_res = 0;
501
502 prctl(PR_SET_NAME, "fluxstat-main", 0, 0, 0);
503
504 int sem_id = -1;
505 int result = 0;
506 char wan_name[30] = {0};
507 char byte_num[64] = {0};
508 int first_data_flag = 1;
509 sem_id = get_sem(TIME_SEM_KEY_1);
510
511 while (1) {
512 //webui½çÃæÊµÊ±Ê±¼ä¸üв»Ó¦ÊÜsntpͬ²½Ó°Ïì
513 webui_time_nv_set();
514 //ʵʱËÙÂÊͳ¼Æ¸üв»Ó¦ÊÜsntpͬ²½Ó°Ïì
515 memset(wan_name, 0, sizeof(wan_name));
516 if (0 != getInterface(wan_name, sizeof(wan_name))) {
517 fluxstat_date_changed();
518 goto LOOP_END;
519 }
520
521 tx_res = getIfStatistic(wan_name, TXBYTE, &data_send_total); //¶ÁÈ¡·¢ËÍÊý¾Ý
522 rx_res = getIfStatistic(wan_name, RXBYTE, &data_rcv_total); //¶ÁÈ¡½ÓÊÕÊý¾Ý
523 sprintf(byte_num, "%llu", data_send);
524 sc_cfg_set("wan_tx_byte", byte_num);
525 memset(byte_num, 0, sizeof(byte_num));
526 sprintf(byte_num, "%llu", data_rcv);
527 sc_cfg_set("wan_rx_byte", byte_num);
528
529 if (tx_res == -1 || rx_res == -1) //kw 3
530 goto LOOP_END;
531
532 if (data_send_total >= last_send) {
533 data_send = data_send_total - last_send;
534 } else {
535 data_send = data_send_total;
536 }
537
538 if(data_rcv_total >= last_rcv) {
539 data_rcv = data_rcv_total - last_rcv;
540 } else {
541 data_rcv = data_rcv_total;
542 }
543
544 last_send = data_send_total;
545 last_rcv = data_rcv_total;
546
547 //±¾´ÎÉϵçºóµÄÏàÓ¦Á÷Á¿¼°ËÙÂÊͳ¼Æ
548 flux_realtime(data_send, data_rcv);
549
550 if (fluxstat_date_changed() || first_data_flag) {
551 //slog(FLUXSTAT_PRINT,SLOG_DEBUG, "[flux]fluxstat date or month changed.\n");
552 first_data_flag = 0;
553 time(&last_connect_time);
554 }
555
556 //ÈÕ¡¢ÔÂÀÛ¼Óͳ¼ÆÊÜsntp¿ØÖÆ
557 if (flux_enable_flag) {
558 if (sem_id != -1) {
559 result = sem_p(sem_id);
560 }
561
562 flux_day_and_month(data_send, data_rcv);
563 flux_connect_time();
564
565 if (sem_id != -1) {
566 result = sem_v(sem_id);
567 }
568 }
569
570LOOP_END:
571 sleep(1);
572 }
573}
574int mc_create_msg_q(void)
575{
576 return msgget(MODULE_ID_FLUXSTAT, IPC_CREAT | 0600);
577}
578void update_data_cfg()
579{
580 long record_time = 0, total_time = 0;
581 long long last_s = 0, last_r = 0, record_send = 0, record_rcv = 0, total_tot = 0;
582 char t_time[12], t_send[20], t_rcv[20], t_vol[20];
583 long timestat_month = 0;
584 long timestat_last = 0;
585 char ConectedTimeStr[20] = {0};
586 char buf1[64] = {0};
587 char buf2[64] = {0};
588 char buf3[64] = {0};
589
590 sc_cfg_get("Last_time", buf1, sizeof(buf1));
591 sc_cfg_get("Last_up", buf2, sizeof(buf2));
592 sc_cfg_get("Last_down", buf3, sizeof(buf3));
593 record_time = atol(buf1); //kw 3
594 if (record_time < 0 || record_time > LONG_MAX-1)
595 record_time = 0;
596 record_send = atoll(buf2);
597 if (record_send < 0 || record_send > LLONG_MAX-1)
598 record_send = 0;
599 record_rcv = atoll(buf3);
600 if (record_rcv < 0 || record_rcv > LLONG_MAX-1)
601 record_rcv = 0;
602 memset(buf1, 0, sizeof(buf1));
603 memset(buf2, 0, sizeof(buf2));
604 memset(buf3, 0, sizeof(buf3));
605
606 sc_cfg_get("realtime_time", buf1, sizeof(buf1));
607 sc_cfg_get("realtime_tx_bytes", buf2, sizeof(buf2));
608 sc_cfg_get("realtime_rx_bytes", buf3, sizeof(buf3));
609 total_time = atol(buf1);
610 if (total_time < 0 || total_time > LONG_MAX-1)
611 total_time = 0;
612 total_time = record_time + total_time;
613
614 last_s = atoll(buf2);
615 if (last_s < 0 || last_s > LLONG_MAX-1)
616 last_s = 0;
617 last_s = record_send + last_s;
618
619 last_r = atoll(buf3);
620 if (last_r < 0 || last_r > LLONG_MAX-1)
621 last_r = 0;
622 last_r = record_rcv + last_r;
623 total_tot = last_s + last_r;
624 sprintf(t_time, "%ld", total_time);
625 sprintf(t_send, "%lld", last_s);
626 sprintf(t_rcv, "%lld", last_r);
627 sprintf(t_vol, "%lld", total_tot);
628 sc_cfg_set("Last_time", t_time);
629 memset(buf1, 0, sizeof(buf1));
630 memset(buf2, 0, sizeof(buf2));
631
632 /*start added by jhy Nov 28, 2013*/
633 sc_cfg_get("MonthlyConTime_Last", buf1, sizeof(buf1));
634 sc_cfg_get("realtime_time", buf2, sizeof(buf2));
635 timestat_month = atol(buf1);
636 if (timestat_month < 0 || timestat_month > LONG_MAX-1)
637 timestat_month = 0;
638 timestat_last = atol(buf2);
639 if (timestat_last < 0 || timestat_last > LONG_MAX-1)
640 timestat_last = 0;
641 sprintf(ConectedTimeStr, "%ld", timestat_month + timestat_last);
642 sc_cfg_set("MonthlyConTime_Last", ConectedTimeStr);
643 //sc_cfg_save();
644 /*end added by jhy Nov 28, 2013*/
645
646 data_cfg_init();
647}
648
649void time_analyze(char *time_ex, struct date_time_t* current_time)
650{
651 char timetmp[128] = {0};
652 char month[4] = {0};
653 char day[3] = {0};
654 char *tmp = NULL;
655 char *save = NULL;
656 char nowtime[16] = {0};
657 memset(current_time, 0, sizeof(struct date_time_t));
658
659 strncpy(timetmp, time_ex, sizeof(timetmp)-1);
660 char *loc = timetmp;
661 while (*loc == ' ') {
662 loc++;
663 }
664
665 tmp = strtok_r(loc, " ", &save);
666 if (tmp == NULL)
667 return;
668 strncpy(current_time->weekday, tmp, sizeof(current_time->weekday)-1);
669 tmp = strtok_r(NULL, " ", &save);
670 if (tmp == NULL)
671 return;
672 strncpy(month, tmp, sizeof(month)-1);
673 tmp = strtok_r(NULL, " ", &save);
674 if (tmp == NULL)
675 return;
676 strncpy(day, tmp, sizeof(day)-1);
677 if (strlen(tmp) == 1) {
678 snprintf(current_time->day, 3, "0%d", atoi(tmp));//klocwork
679 } else {
680 strncpy(current_time->day, tmp, sizeof(current_time->day)-1);
681 }
682
683 tmp = strtok_r(NULL, " ", &save);
684 if (tmp == NULL)
685 return;
686 strncpy(current_time->nowtime, tmp, sizeof(current_time->nowtime)-1);
687 strncpy(nowtime, tmp, sizeof(nowtime)-1);
688 tmp = strtok_r(NULL, " ", &save);
689 if (tmp == NULL)
690 return;
691 strncpy(current_time->year, tmp, 4);
692 month_turnto_num(current_time->month, month);
693
694 tmp = strtok_r(nowtime, ":", &save);
695 if (tmp == NULL)
696 return;
697 strncpy(current_time->hour, tmp, sizeof(current_time->hour)-1);
698 tmp = strtok_r(NULL, ":", &save);
699 if (tmp == NULL)
700 return;
701 strncpy(current_time->minute, tmp, sizeof(current_time->minute)-1);
702 tmp = strtok_r(NULL, ":", &save);
703 if (tmp == NULL)
704 return;
705 strncpy(current_time->second, tmp, sizeof(current_time->second)-1);
706}
707
708void set_sntp_nv(struct date_time_t* current_time)
709{
710 sc_cfg_set("sntp_hour", current_time->hour);
711 sc_cfg_set("sntp_minute", current_time->minute);
712 sc_cfg_set("sntp_second", current_time->second);
713 sc_cfg_set("sntp_year", current_time->year);
714 sc_cfg_set("sntp_month", current_time->month);
715 sc_cfg_set("sntp_day", current_time->day);
716 sc_cfg_set("sntp_weekday", current_time->weekday);
717 sc_cfg_set("sntp_nowtime", current_time->nowtime);
718}
719
720void get_current_date(struct date_time_t* current_time)
721{
722 time_t flux_timenow = 0;
723 char stri_flux_time[128] = {0};
724 time(&flux_timenow);
725 ctime_r(&flux_timenow, stri_flux_time);
726 time_analyze(stri_flux_time, current_time);
727}
728
729//webuiûÄÜÁ¦»ñÈ¡µ±Ç°ÏµÍ³Ê±¼ä£¬Ó¦µ±ÓÉgoahead×ö
730void webui_time_nv_set()
731{
732 struct date_time_t current_time = {0};
733 get_current_date(&current_time);
734 set_sntp_nv(&current_time);
735}
736
737void fluxstat_init()
738{
739 //sc_cfg_set("DataStatus","");
740 sc_cfg_set("realtime_time", "0");
741 sc_cfg_set("realtime_tx_bytes", "0");
742 sc_cfg_set("realtime_rx_bytes", "0");
743 sc_cfg_set("CTotal_vol", "0");
744 sc_cfg_set("realtime_tx_thrpt", "0");
745 sc_cfg_set("realtime_rx_thrpt", "0");
746 //sc_cfg_set("CurrSpeed_total","0");
747// sc_cfg_set("AverSpeed_up","0");
748// sc_cfg_set("AverSpeed_down","0");
749 //sc_cfg_set("AverSpeed_total","0");
750 sc_cfg_set("duraConTime_before_time_modify", "0");
751 sc_cfg_set("flux_total_flow_when_power_on", "0");
752}
753
754int fluxstat_date_changed()
755{
756
757 char last_day[3] = {0};
758 char last_month[3] = {0};
759 char last_year[5] = {0};
760 char sntp_result[20] = {0};
761 char sntp_mode[20] = {0};
762 char tmp[20] = {0};
763 int compare_day = 0;
764 int compare_month = 0;
765 int compare_year = 0;
766 int day_changed = 0;
767 int month_changed = 0;
768 int sem_id = -1;
769 struct date_time_t current_time = {0};
770 char ppp_status[64] = {0};
771
772 sc_cfg_get("sntp_time_set_mode", sntp_mode, sizeof(sntp_mode));
773 sc_cfg_get("sntp_process_result", sntp_result, sizeof(sntp_result));
774 sc_cfg_get("ppp_status", ppp_status, sizeof(ppp_status));
775
776 if (0 == strcmp("ppp_connected", ppp_status)) {
777 flux_enable_flag = 1;
778 }
779
780 if (strcmp("manual", sntp_mode) != 0 && strcmp("success", sntp_result) != 0) {
781 //slog(FLUXSTAT_PRINT,SLOG_DEBUG, "[flux]fluxstat_date_changed: sntp_mode =%s,sntp_result =%s\n",sntp_mode, sntp_result);
782 return 0;
783 }
784
785 get_current_date(&current_time);
786 sc_cfg_get("flux_last_day", last_day, sizeof(last_day));
787 sc_cfg_get("flux_last_month", last_month, sizeof(last_month));
788 sc_cfg_get("flux_last_year", last_year, sizeof(last_year));
789 compare_day = strcmp(current_time.day, last_day);
790 compare_month = strcmp(current_time.month, last_month);
791 compare_year = strcmp(current_time.year, last_year);
792
793 day_changed = compare_day | compare_month | compare_year;
794 month_changed = compare_month | compare_year;
795
796 if (day_changed) {
797 sc_cfg_set("flux_day_total", "0");
798 sc_cfg_get("realtime_time", tmp, sizeof(tmp));
799 sc_cfg_set("duraConTime_before_time_modify", tmp);
800 }
801 if (month_changed) {
802 sem_id = get_sem(TIME_SEM_KEY_2);
803
804 if (sem_id != -1) {
805 sem_p(sem_id);
806 }
807
808 fluxstat_clear_process(current_time.year, current_time.month);
809 if (sem_id != -1) {
810 sem_v(sem_id);
811 }
812
813 }
814 if (day_changed || month_changed) {
815 sc_cfg_set("flux_last_day", current_time.day);
816 sc_cfg_set("flux_last_month", current_time.month);
817 sc_cfg_set("flux_last_year", current_time.year);
818 return 1;
819 }
820 return 0;
821}
822
823//ÿÃë¸üÐÂÒ»ÏÂÒÑÁ¬½Óʱ¼ä£¬²»ºÏÀí´ý¸ÄÉÆ
824void flux_connect_time()
825{
826 long conneted_time = 0;
827 char ConectedTimeStr[20] = {0};
828 long duraConTime_before_time_modify = 0;
829 char tmp[20] = {0};
830 long last_total_connect_time = 0;
831 char totalConnectTime[16] = {0};
832 long lastDuraConTime = 0;
833 long lastMonthlyTime = 0;
834 time_t nowtime = 0;
835 time(&nowtime);
836
837 conneted_time = nowtime - last_connect_time;
838 if (conneted_time < 0 || conneted_time > FLUXSTAT_MAX_WAIT_TIME) {
839 slog(FLUXSTAT_PRINT, SLOG_ERR, "[flux]conneted_time =%ld, last_connect_time=%ld, nowtime=%ld\n", conneted_time, last_connect_time, nowtime);
840 conneted_time = 0;
841 }
842 last_connect_time = nowtime;
843
844 sc_cfg_get("realtime_time", tmp, sizeof(tmp));
845 sscanf(tmp, "%ld", &lastDuraConTime);
846 if (lastDuraConTime < 0 || lastDuraConTime > LONG_MAX-1)
847 lastDuraConTime = 0;//kw 3
848
849 memset(tmp, 0, sizeof(tmp));
850 sc_cfg_get("duraConTime_before_time_modify", tmp, sizeof(tmp));
851 sscanf(tmp, "%ld", &duraConTime_before_time_modify);
852 if (duraConTime_before_time_modify < 0 || duraConTime_before_time_modify > LONG_MAX-1)
853 duraConTime_before_time_modify = 0;
854 if (duraConTime_before_time_modify) {
855 sprintf(ConectedTimeStr, "%ld", conneted_time + duraConTime_before_time_modify);
856 sc_cfg_set("duraConTime_before_time_modify", "0");
857 } else
858 sprintf(ConectedTimeStr, "%ld", conneted_time + lastDuraConTime);
859
860 sc_cfg_set("realtime_time", ConectedTimeStr);
861
862 memset(ConectedTimeStr, 0, sizeof(ConectedTimeStr));
863 memset(tmp, 0, sizeof(tmp));
864
865 sc_cfg_get("monthly_time", tmp, sizeof(tmp));
866 sscanf(tmp, "%ld", &lastMonthlyTime);
867 if (lastMonthlyTime < 0 || lastMonthlyTime > LONG_MAX-1)
868 lastMonthlyTime = 0;//kw 3
869 sprintf(ConectedTimeStr, "%ld", lastMonthlyTime + conneted_time);
870 sc_cfg_set("monthly_time", ConectedTimeStr);
871
872
873 memset(ConectedTimeStr, 0, sizeof(ConectedTimeStr));
874 sc_cfg_get("flux_total_connect_time", totalConnectTime, sizeof(totalConnectTime));
875 sscanf(totalConnectTime, "%ld", &last_total_connect_time);
876 if (last_total_connect_time < 0 || last_total_connect_time > LONG_MAX-1)
877 last_total_connect_time = 0;//kw 3
878 last_total_connect_time = last_total_connect_time + conneted_time;
879 sprintf(ConectedTimeStr, "%ld", last_total_connect_time);
880 sc_cfg_set("flux_total_connect_time", ConectedTimeStr);
881}
882
883int fluxstat_main(int argc, char * argv[])
884{
885 int iMsgHandle = 0;
886 int iRet = 0;
887 int interruptSIG = 0;
888 long nowtime;
889 UINT32 iConnect_State = -1; //ÍøÂç״̬0-¶Ï¿ª£¬1-Á¬½Ó 2-Á¬½ÓÖÐ 3-¶Ï¿ªÖÐ
890 UINT32 iSwitch_State = -1; //Á÷Á¿Í³¼Æ¿ª¹Ø0-¹Ø±Õ1-´ò¿ª
891 MSG_BUF stMsg;
892 prctl(PR_SET_NAME, "fluxstat", 0, 0, 0);
893
894 LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
895 pthread_t Create_Data_Thread_id;
896 int Create_Data_Thread_result = 0;
897 pthread_attr_t attr;
898
899 //¸ù¾ÝNV³õʼ»¯´òÓ¡¼¶±ð£¬²¢×¢²á¶¯Ì¬µ÷Õû´òÓ¡¼¶±ðÐźÅÁ¿
900 loglevel_init();
901
902 iMsgHandle = mc_create_msg_q();
903
904 fluxstat_init();
905
906 pthread_attr_init(&attr);
907 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
908 Create_Data_Thread_result = pthread_create(&Create_Data_Thread_id, &attr, fluxstat_main_loop, NULL);
909 pthread_attr_destroy(&attr);
910 if (Create_Data_Thread_result != 0) {
911 slog(FLUXSTAT_PRINT, SLOG_ERR, "Create_Data_Thread_result faild!\n");
912 exit(-1);
913 } else {
914 slog(FLUXSTAT_PRINT, SLOG_NORMAL, "Create_Data_Thread_result SUCCESS!\n");
915 }
916
917 #if (PRODUCT_TYPE == PRODUCT_PHONE)
918 platform_send_msg(MODULE_ID_FLUXSTAT,MODULE_ID_MMI_SVR,MSG_CMD_DATAMANAGER_FLUXSTAT_READY,0,NULL);
919 #endif
920 //RndisÁ¬½Ó״̬Ö÷¶¯Éϱ¨ºó,at¸øÁ÷Á¿Í³¼Æ·¢ÏûÏ¢£¬¿ªÊ¼»ò¹Ø±ÕÁ÷Á¿Í³¼Æ;Á÷Á¿Í³¼ÆÔÙmmi·¢ÏûÏ¢
921 for (;;) {
922 if (0 == interruptSIG) {
923 slog(FLUXSTAT_PRINT, SLOG_ERR, "data begin to rcv msg from queue %d. \n", iMsgHandle);
924 }
925 memset(&stMsg, '\0', sizeof(stMsg));
926 iRet = 0;
927
928 //×èÈû½ÓÊÕÏûÏ¢
929 iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
930
931 if (-1 == iRet) {
932 if (EINTR == errno) {
933 interruptSIG = 1;
934 continue;
935 } else {
936 slog(FLUXSTAT_PRINT, SLOG_ERR, "recv msg from the MODULE_ID_DATA fail errno=%d!\n", errno);
937 return ERROR;
938 }
939 } else {
940 interruptSIG = 1;
941 }
942
943 switch (stMsg.usMsgCmd) {
944 case MSG_CMD_CHANNEL_CONNECT_STATUS: {
945 iConnect_State = *(UINT32*)stMsg.aucDataBuf;
946 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux]MSG_CMD_CHANNEL_CONNECT_STATUS come in.iConnect_State =%d\n", iConnect_State);
947 if (1 == iConnect_State) {
948 flux_enable_flag = 1;
949 time(&last_connect_time);
950 sc_cfg_set("syn_ppp_total", "0");
951 ipc_send_message(MODULE_ID_FLUXSTAT, MODULE_ID_MMI, MSG_CMD_GET_TRAFFIC_INFO_START, 0, NULL, 0);
952 } else if (0 == iConnect_State) {
953 update_data_cfg();
954 flux_enable_flag = 0;
955 sc_cfg_set("syn_ppp_total", "0");
956 ipc_send_message(MODULE_ID_FLUXSTAT, MODULE_ID_MMI, MSG_CMD_GET_TRAFFIC_INFO_END, 0, NULL, 0);
957 }
958 break;
959 }
960 case MSG_CMD_DATA_END: {
961 update_data_cfg();
962 flux_enable_flag = 0;
963 sc_cfg_set("syn_ppp_total", "0");
964 break;
965 }
966 //¹Ì¶¨Ì¨Á÷Á¿¹ÜÀí
967 case MSG_CMD_DATAMANAGER_SET_SWITCH_REQ: {
968 iSwitch_State = *(UINT32*)stMsg.aucDataBuf;
969 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux]MSG_CMD_DATAMANAGER_SET_SWITCH_REQ come in.iSwitch_State =%d\n", iSwitch_State);
970 flux_enable_flag = 1;
971 if(1 == iSwitch_State) {
972 sc_cfg_set(NV_TRAFFIC_LIMIT_SWITCH, "1");
973 g_need_send_flux_over = TRUE;
974 g_need_send_flux_warnning = TRUE;
975 } else if(0 == iSwitch_State) {
976 sc_cfg_set(NV_TRAFFIC_LIMIT_SWITCH, "0");
977 }
978 break;
979 }
980 case MSG_CMD_DATAMANAGER_GET_INFO_REQ: {
981 fluxstat_info info = {0};
982 sc_cfg_get("traffic_month_total",info.total_flux,sizeof(info.total_flux));
983 sc_cfg_get("flux_month_total",info.used_flux,sizeof(info.used_flux));
984 sc_cfg_get(NV_TRAFFIC_ALERT_PERCENT,info.warn_percent,sizeof(info.warn_percent));
985 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux]MSG_CMD_DATAMANAGER_GET_INFO_REQ total =%s,used = %s warn = %s\n", info.total_flux, info.used_flux, info.warn_percent);
986 platform_send_msg(MODULE_ID_FLUXSTAT, MODULE_ID_MMI_SVR, MSG_CMD_DATAMANAGER_GET_INFO_RSP, sizeof(fluxstat_info), &info);
987 break;
988 }
989 case MSG_CMD_DATAMANAGER_SET_TOTAL_REQ: {
990 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux]MSG_CMD_DATAMANAGER_SET_TOTAL_REQ stMsg.aucDataBuf =%s\n", stMsg.aucDataBuf);
991 sc_cfg_set("traffic_month_total",stMsg.aucDataBuf);
992 g_need_send_flux_over = TRUE;
993 g_need_send_flux_warnning = TRUE;
994 platform_send_msg(MODULE_ID_FLUXSTAT, MODULE_ID_MMI_SVR, MSG_CMD_DATAMANAGER_SET_TOTAL_RSP, 0, NULL);
995 break;
996 }
997 case MSG_CMD_DATAMANAGER_SET_WARNVALUE_REQ: {
998 slog(FLUXSTAT_PRINT, SLOG_DEBUG, "[flux]MSG_CMD_DATAMANAGER_SET_WARNVALUE_REQ stMsg.aucDataBuf =%s\n", stMsg.aucDataBuf);
999 sc_cfg_set(NV_TRAFFIC_ALERT_PERCENT,stMsg.aucDataBuf);
1000 g_need_send_flux_over = TRUE;
1001 g_need_send_flux_warnning = TRUE;
1002 platform_send_msg(MODULE_ID_FLUXSTAT, MODULE_ID_MMI_SVR, MSG_CMD_DATAMANAGER_SET_WARNVALUE_RSP, 0, NULL);
1003 break;
1004 }
1005 case MSG_CMD_PDPSTATUS_SET_SWITCH_REQ:{ //ÍøÂçÁ¬½Ó¿ª¹Ø´ò¿ªºó£¬Í¨ÖªÁ÷Á¿³¬ÏÞ
1006 iSwitch_State = *(UINT32*)stMsg.aucDataBuf;
1007 if(1 == iSwitch_State)
1008 {
1009 g_need_send_flux_over = TRUE;
1010 g_need_send_flux_warnning = TRUE;
1011 }
1012 break;
1013 }
1014 default:
1015 break;
1016 }
1017 }
1018}
1019
1020