blob: 41589d2f31410a3257e3bc054745679ae165e2bd [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#include <softap_api.h>
2#include <errno.h>
3#include "wlan_interface.h"
4
5#define WIFI_SSID_LEN 33
6
7#define WLAN_SECURITY_LEN 20
8#define WLAN_ENCRYTYPE_LEN 10
9#define WLAN_DEFAULTID_LEN 2
10#define WLAN_WEPKEY_LEN 32
11#define WLAN_PSK_LEN 65
12#define WLAN_ENCODE_PSK_LEN 100
13
14#define WF_AU_OPEN "OPEN" //wifi auth mode?
15#define WF_AU_SHARE "SHARED"
16#define WF_AU_WEPAUTO "WEPAUTO"
17#define WF_AU_WPA "WPAPSK"
18#define WF_AU_WPA2 "WPA2PSK"
19#define WF_AU_WPA_WPA2 "WPAPSKWPA2PSK"
20#define WF_AU_WAPIPSK "WAPIPSK"
21#define WF_ENCRY_NONE "NONE" //encrypt
22#define WF_ENCRY_WEP "WEP"
23#define WF_ENCRY_TKIP "TKIP"
24#define WF_ENCRY_CCMP "CCMP"
25#define WF_ENCRY_AES "AES"
26#define WF_ENCRY_TKIP_CCMP "TKIPCCMP"
27#define WF_ENCRY_TKIP_AES "TKIPAES"
28
29static void zte_wlan_get_wifi_station_list(RT_802_11_MAC_TABLE *staionlist);
30
31
32void zte_wlan_get_wifi_mac_list(RT_802_11_MAC_TABLE *maclist)
33{
34 int s = 0;
35 int k = 0;
36
37 FILE *pp = NULL;
38 //FILE *pp2 = NULL;
39 char buf[128]={0};
40 char mac_tmp[18] = {0};
41 char num_tmp[3] = {0};
42 char *p = NULL;
43 char *p_tmp = NULL;
44
45 char authmode[20]={0};
46 char encryptype[20]={0};
47
48 char wifi_sta_connection[8]={0};
49
50 char cmd[128]={0};
51 char iifname[20]={0};
52 RT_802_11_MAC_TABLE *mac_list=NULL ;
53 memset(buf, 0, sizeof(buf));
54 mac_list =(RT_802_11_MAC_TABLE*)malloc(sizeof(RT_802_11_MAC_TABLE));
55 if(mac_list == NULL)
56 {
57 assert(mac_list);
58 }
59 else
60 {
61 memset(mac_list, 0, sizeof(RT_802_11_MAC_TABLE));
62 }
63
64
65 cfg_get_item("wifi_sta_connection", wifi_sta_connection, sizeof(wifi_sta_connection));
66
67 if(strncmp(wifi_sta_connection, "1",1) == 0){
68 strcpy(iifname,"-i wl0.1");
69 }
70
71 //memset(&table,0,sizeof(table));
72
73 cfg_get_item("AuthMode",authmode,sizeof(authmode));
74 cfg_get_item("EncrypType",encryptype,sizeof(encryptype));
75 if((!strcmp(authmode,"WPAPSK"))||(!strcmp(authmode,"WPA2PSK"))||(!strcmp(authmode,"WPAPSKWPA2PSK")))
76 {
77 sprintf(cmd,"wl %s autho_sta_list",iifname);
78 }
79 else
80 {
81 sprintf(cmd,"wl %s assoclist",iifname);
82 }
83 printf("[%s:%s]iifname:%s\n",__FILE__, __FUNCTION__, cmd);
84 pp = popen(cmd, "r"); //½¨Á¢¹ÜµÀ
85 if (!pp)
86 {
87 return ;
88
89 }
90
91 strcpy(buf,"ABNORMAL");
92again:
93 while(fgets(buf, 128, pp) != NULL)
94 {
95
96 if(strcmp(buf,"ABNORMAL")==0) /*ps command error*/
97 {
98 printf("[%s] detect_process strerror: %s\n",__FUNCTION__,strerror(errno));
99 if(errno == EINTR) //Interrupted system call,´Ëʱ¿ÉÖØÊÔ
100 {
101 goto again;
102 }
103
104 pclose(pp);//¹Ø±Õ¹ÜµÀ
105 return ;
106 }
107 memset(mac_tmp, 0, 18);
108 if((p = strstr(buf, ":")) != NULL)
109 {
110 p_tmp = p-2;
111 strncpy(mac_tmp, p_tmp, 17);
112
113 for(s=0,k=0; s<6; s++,k+=3)
114 {
115 strncpy(num_tmp, mac_tmp + k, 2);
116 //printf("zhouti num_tmp is %s\n", num_tmp);
117 //table.Entry[sta_num].Addr[s]=atoi(num_tmp);
118 mac_list->Entry[mac_list->Num].Addr[s] = s2x(num_tmp);
119 //mac_list->Entry[mac_list->Num].Addr[s] = 0;
120 }
121 mac_list->Num += 1;
122
123 }
124 memset(buf, 0, sizeof(buf));
125 }
126 (*maclist)= (*mac_list);
127 if(mac_list)
128 {
129 free(mac_list);
130 mac_list=NULL;
131 }
132 pclose(pp); //¹Ø±Õ¹ÜµÀ;
133
134}
135
136static void zte_wlan_get_wifi_station_list(RT_802_11_MAC_TABLE *staionlist)
137{
138
139 int i = 0;
140 char buf[128]={0};
141 FILE *pp2 = NULL;
142 char mac_tmp[18] = {0};
143 char *p_tmp = NULL;
144 char station_mac[18*32]={0}; // 00:00:00:00:00:00;
145 char stationinfo[100] = {0};
146 char mac_time[33] = {0};
147
148 RT_802_11_MAC_TABLE *sta_list = NULL;
149 sta_list = (RT_802_11_MAC_TABLE*)malloc(sizeof(RT_802_11_MAC_TABLE));
150 if(sta_list == NULL)
151 {
152 assert(sta_list);
153 }
154 else
155 {
156 memset(sta_list, 0, sizeof(RT_802_11_MAC_TABLE)+1);
157 }
158 zte_wlan_get_wifi_mac_list(sta_list);
159
160 for (i = 0; i <sta_list->Num; i++)
161 {
162 sprintf(station_mac + i * 18, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X;",\
163 sta_list->Entry[i].Addr[0], sta_list->Entry[i].Addr[1],
164 sta_list->Entry[i].Addr[2], sta_list->Entry[i].Addr[3],
165 sta_list->Entry[i].Addr[4], sta_list->Entry[i].Addr[5]);
166 sprintf(stationinfo,"wl sta_info %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \
167 | grep \"in network\" | cut -d\" \" -f4",
168 sta_list->Entry[i].Addr[0], sta_list->Entry[i].Addr[1],
169 sta_list->Entry[i].Addr[2], sta_list->Entry[i].Addr[3],
170 sta_list->Entry[i].Addr[4], sta_list->Entry[i].Addr[5]);
171
172 printf("[%s:%s]stationinfo:%s\n",__FILE__, __FUNCTION__, stationinfo);
173 pp2 = popen(stationinfo, "r"); //½¨Á¢¹ÜµÀ
174
175 if(NULL == pp2)
176 {
177 continue;
178 }
179 memset(buf, 0, sizeof(buf));
180 strcpy(buf,"ABNORMAL");
181 while(fgets(buf, sizeof(buf), pp2))
182 {
183
184 if(strcmp(buf,"ABNORMAL")==0) /*ps command error*/
185 {
186 printf("[%s] detect_process strerror: %s\n",__FUNCTION__,strerror(errno));
187
188 pclose(pp2);//¹Ø±Õ¹ÜµÀ
189 return ;
190 }
191 memset(mac_time,0,33);
192 strncpy(mac_time,buf,32);
193
194 printf("[%s:%s]buf0:%s\n",__FILE__, __FUNCTION__, buf);
195
196 if(NULL != mac_time)
197 {
198 sta_list->Entry[i].ConnectedTime = atol(mac_time);
199 printf("[%s:%s]ConnectedTime->Num3:%d\n",__FILE__, __FUNCTION__, sta_list->Entry[i].ConnectedTime);
200 }
201 else
202 {
203 sta_list->Entry[i].ConnectedTime = 0;
204 }
205 memset(buf, 0, sizeof(buf));
206 printf("[%s:%s]mac_time:%d\n",__FILE__, __FUNCTION__, mac_time);
207
208 }
209
210 pclose(pp2); //¹Ø±Õ¹ÜµÀ
211 }
212
213 (*staionlist)= (*sta_list);
214 if(sta_list)
215 {
216 free(sta_list);
217 sta_list=NULL;
218 }
219
220}
221
222static void wlan_set_change_ssid_key_status()
223{
224 ipc_send_message(MODULE_ID_WLAN_SERVER, MODULE_ID_WIFI, MSG_CMD_MODIFY_SSID_KEY, 0, NULL, 0);
225}
226
227static int zte_wlan_ssid1_basic_set(char* ssid_in)
228{
229 char *ssid = NULL;
230 char nv_tmp[WIFI_SSID_LEN] = {0};
231
232 if(NULL == ssid_in)
233 {
234 printf("input ssid is null\n");
235 return -1;
236 }
237
238 if((!strcmp(ssid_in, " ")) || (strlen(ssid_in) <= 0) || (strlen(ssid_in) > WIFI_SSID_LEN ))
239 {
240 printf("input ssid is error\n");
241 return -1;
242 }
243 //ssid
244 memset(nv_tmp,0,sizeof(nv_tmp));
245 if(ssid_in != NULL)
246 {
247
248 cfg_get_item("SSID1",nv_tmp,sizeof(nv_tmp));
249 if (0 != strcmp(ssid_in, nv_tmp))
250 {
251 cfg_set("SSID1", ssid_in);
252 //cfg_save();
253 wlan_set_change_ssid_key_status();
254 }
255 else
256 {
257 printf("input ssid is same \n");
258 return 1;
259 }
260 }
261 return 0;
262}
263
264static int zte_wlan_ssid1_security_set(char* password)
265{
266 char authMode[WLAN_SECURITY_LEN] = {0};
267 char encrypType[WLAN_ENCRYTYPE_LEN] = {0};
268 char DefaultKeyID[WLAN_DEFAULTID_LEN] = {0};
269
270 cfg_get_item("AuthMode",authMode,sizeof(authMode));
271 cfg_get_item("EncrypType",encrypType,sizeof(encrypType));
272
273
274 if(authMode != NULL && encrypType != NULL)
275 {
276 printf("zte_wlan_ssid1_security_set authMode = [%s]\n", authMode);
277 printf("zte_wlan_ssid1_security_set encrypType = [%s]\n", encrypType);
278 if(NULL == password && (!(!strcmp(authMode, WF_AU_OPEN) && !strcmp(encrypType, WF_ENCRY_NONE))))
279 {
280 printf("zte_wlan_ssid1_security_set password is null\n");
281 return -1;
282 }
283
284 if((!strcmp(authMode, WF_AU_OPEN)) || (!strcmp(authMode, WF_AU_SHARE)) || (!strcmp(authMode, WF_AU_WEPAUTO)))
285 {
286 if(((!strcmp(authMode, WF_AU_OPEN)) && (!strcmp(authMode, WF_ENCRY_WEP))) ||
287 (!strcmp(authMode, WF_AU_SHARE)) || (!strcmp(authMode, WF_AU_WEPAUTO)))
288 {
289 int len = 0;
290 len = strlen(password);
291 if(len != 5 || len != 10 || len != 13 || len != 26)
292 {
293 printf("zte_wlan_ssid1_security_set wep psk len = [%s]\n", len);
294 return -1;
295 }
296
297 cfg_get_item("DefaultKeyID",DefaultKeyID,sizeof(DefaultKeyID));
298 if(DefaultKeyID != NULL)
299 {
300 char old_wep_key[WLAN_WEPKEY_LEN] = {0};
301
302 if(!strcmp(DefaultKeyID, "1"))
303 {
304 cfg_get_item("Key2Str1",old_wep_key,sizeof(old_wep_key));
305 if(strcmp(old_wep_key, password))
306 {
307 cfg_set("Key2Str1", password);
308 //cfg_save();
309 wlan_set_change_ssid_key_status();
310 }
311 else
312 {
313 printf("zte_wlan_ssid1_security_set wep psk is same\n");
314 return 1;
315 }
316 }
317 else if(!strcmp(DefaultKeyID, "2"))
318 {
319 cfg_get_item("Key3Str1",old_wep_key,sizeof(old_wep_key));
320 if(strcmp(old_wep_key, password))
321 {
322 cfg_set("Key3Str1", password);
323 //cfg_save();
324 wlan_set_change_ssid_key_status();
325 }
326 else
327 {
328 printf("zte_wlan_ssid1_security_set wep psk is same\n");
329 return 1;
330 }
331 }
332 else if(!strcmp(DefaultKeyID, "3"))
333 {
334 cfg_get_item("Key4Str1",old_wep_key,sizeof(old_wep_key));
335 if(strcmp(old_wep_key, password))
336 {
337 cfg_set("Key4Str1", password);
338 //cfg_save();
339 wlan_set_change_ssid_key_status();
340 }
341 else
342 {
343 printf("zte_wlan_ssid1_security_set wep psk is same\n");
344 return 1;
345 }
346 }
347 else
348 {
349 cfg_get_item("Key1Str1",old_wep_key,sizeof(old_wep_key));
350 if(strcmp(old_wep_key, password))
351 {
352 cfg_set("Key1Str1", password);
353 //cfg_save();
354 wlan_set_change_ssid_key_status();
355 }
356 else
357 {
358 printf("zte_wlan_ssid1_security_set wep psk is same\n");
359 return 1;
360 }
361 }
362 }
363 }
364 else if(!strcmp(authMode, WF_AU_OPEN) && !strcmp(encrypType, WF_ENCRY_NONE))
365 {
366 printf("authMode is open and not wep \n");
367 wlan_set_change_ssid_key_status();
368 return 1;
369
370 }
371 }
372 else if(!strcmp(authMode, WF_AU_WPA) || !strcmp(authMode, WF_AU_WPA2) || !strcmp(authMode, WF_AU_WPA_WPA2))
373 {
374 char psk[WLAN_PSK_LEN] = {0};
375 int len = 0;
376 char encode[WLAN_ENCODE_PSK_LEN] = {0};
377 len = strlen(password);
378
379 if(len < 8 || len > 64)
380 {
381 printf("%s password len is %d \n",authMode, len);
382 return -1;
383 }
384
385 cfg_get_item("WPAPSK1",psk,sizeof(psk));
386 if(psk != NULL)
387 {
388 if(strcmp(psk, password))
389 {
390 cfg_set("WPAPSK1", password);
391 base64_encode(password, len, encode, WLAN_ENCODE_PSK_LEN);
392 cfg_set("WPAPSK1_encode", encode);
393 //cfg_save();
394 wlan_set_change_ssid_key_status();
395 }
396 }
397 else
398 {
399 cfg_set("WPAPSK1", password);
400 base64_encode(password, len, encode, WLAN_ENCODE_PSK_LEN);
401 cfg_set("WPAPSK1_encode", encode);
402 //cfg_save();
403 wlan_set_change_ssid_key_status();
404 }
405 }
406 else if(!strcmp(authMode, WF_AU_WAPIPSK))
407 {
408 char psk[WLAN_PSK_LEN] = {0};
409 int len = 0;
410 char encode[WLAN_PSK_LEN] = {0};
411 len = strlen(password);
412
413 if(len < 8 || len > 64)
414 {
415 printf("WF_AU_WAPIPSK password len is %d \n", len);
416 return -1;
417 }
418
419 cfg_get_item("WPAPSK1",psk,sizeof(psk));
420 if(psk != NULL)
421 {
422 if(strcmp(psk, password))
423 {
424 cfg_set("WPAPSK1", password);
425 base64_encode(password, len, encode, WLAN_ENCODE_PSK_LEN);
426 cfg_set("WPAPSK1_encode", encode);
427 //cfg_save();
428 wlan_set_change_ssid_key_status();
429 }
430 }
431 else
432 {
433 cfg_set("WPAPSK1", password);
434 base64_encode(password, len, encode, WLAN_ENCODE_PSK_LEN);
435 cfg_set("WPAPSK1_encode", encode);
436 //cfg_save();
437 wlan_set_change_ssid_key_status();
438 }
439 }
440 else
441 {
442 // other security mode is invalid
443 printf("ERROR:security mode is invalid\n");
444 return -1;
445 }
446 }
447 else
448 {
449 //security_mode is NULL
450 printf("ERROR:security_mode is null\n");
451 return -1;
452 }
453
454 return 0;
455}
456
457int zte_wlan_get_ssid1_settings(char* ssid, char* password, int ssid_len, int password_len)
458{
459 char authMode[WLAN_SECURITY_LEN] = {0};
460 char encrypType[WLAN_ENCRYTYPE_LEN] = {0};
461 char DefaultKeyID[WLAN_DEFAULTID_LEN] = {0};
462
463 if(NULL == ssid || NULL == password)
464 {
465 printf("ERROR:input ssid && password is null\n");
466 return -1;
467 }
468
469 if(NULL != ssid)
470 {
471 char old_ssid[WIFI_SSID_LEN] = {0};
472 cfg_get_item("SSID1",old_ssid,sizeof(old_ssid));
473 if(old_ssid != NULL)
474 {
475 strncpy(ssid, old_ssid, ssid_len - 1);
476 }
477 else
478 {
479 printf("ERROR:input old_ssid is null\n");
480 return -1;
481 }
482 }
483
484 if(NULL != password)
485 {
486 cfg_get_item("AuthMode",authMode,sizeof(authMode));
487 cfg_get_item("EncrypType",encrypType,sizeof(encrypType));
488
489
490 if(authMode != NULL && encrypType != NULL)
491 {
492 printf("zte_wlan_ssid1_security_get authMode = [%s]\n", authMode);
493 printf("zte_wlan_ssid1_security_get encrypType = [%s]\n", encrypType);
494
495 if((!strcmp(authMode, WF_AU_OPEN)) || (!strcmp(authMode, WF_AU_SHARE)) || (!strcmp(authMode, WF_AU_WEPAUTO)))
496 {
497 if(((!strcmp(authMode, WF_AU_OPEN)) && (!strcmp(authMode, WF_ENCRY_WEP))) ||
498 (!strcmp(authMode, WF_AU_SHARE)) || (!strcmp(authMode, WF_AU_WEPAUTO)))
499 {
500 cfg_get_item("DefaultKeyID",DefaultKeyID,sizeof(DefaultKeyID));
501 if(DefaultKeyID != NULL)
502 {
503 char old_wep_key[WLAN_WEPKEY_LEN] = {0};
504 if(!strcmp(DefaultKeyID, "1"))
505 {
506 cfg_get_item("Key2Str1",old_wep_key,sizeof(old_wep_key));
507 if(old_wep_key != NULL)
508 {
509 strncpy(password, old_wep_key, password_len-1);
510 }
511 else
512 {
513 printf("ERROR:input old_wep_key is null\n");
514 return -1;
515 }
516 }
517 else if(!strcmp(DefaultKeyID, "2"))
518 {
519 cfg_get_item("Key3Str1",old_wep_key,sizeof(old_wep_key));
520 if(old_wep_key != NULL)
521 {
522 strncpy(password, old_wep_key, password_len-1);
523 }
524 else
525 {
526 printf("ERROR:input old_wep_key is null\n");
527 return -1;
528 }
529 }
530 else if(!strcmp(DefaultKeyID, "3"))
531 {
532 cfg_get_item("Key4Str1",old_wep_key,sizeof(old_wep_key));
533 if(old_wep_key != NULL)
534 {
535 strncpy(password, old_wep_key, password_len-1);
536 }
537 else
538 {
539 printf("ERROR:input old_wep_key is null\n");
540 return -1;
541 }
542 }
543 else
544 {
545 cfg_get_item("Key1Str1",old_wep_key,sizeof(old_wep_key));
546 if(old_wep_key != NULL)
547 {
548 strncpy(password, old_wep_key, password_len-1);
549 }
550 else
551 {
552 printf("ERROR:input old_wep_key is null\n");
553 return -1;
554 }
555 }
556 }
557 }
558 }
559 else if(!strcmp(authMode, WF_AU_WPA) || !strcmp(authMode, WF_AU_WPA2) || !strcmp(authMode, WF_AU_WPA_WPA2))
560 {
561 char psk[WLAN_PSK_LEN] = {0};
562 cfg_get_item("WPAPSK1",psk,sizeof(psk));
563 if(psk != NULL)
564 {
565 strncpy(password, psk, password_len-1);
566 }
567 else
568 {
569 printf("ERROR:%s input psk is null\n", authMode);
570 return -1;
571 }
572 }
573 else if(!strcmp(authMode, WF_AU_WAPIPSK))
574 {
575 char psk[WLAN_PSK_LEN] = {0};
576 cfg_get_item("WPAPSK1",psk,sizeof(psk));
577 if(psk != NULL)
578 {
579 strncpy(password, psk, password_len-1);
580 }
581 else
582 {
583 printf("ERROR:%s input psk is null\n", authMode);
584 return -1;
585 }
586 }
587 else
588 {
589 return -1;
590 }
591 }
592 else
593 {
594 return -1;
595 }
596 }
597 return 0;
598}
599
600int zte_wlan_ssid1_set(char* ssid, char* password)
601{
602 int ret_for_basic = 0;
603 int ret_for_security = 0;
604
605 ret_for_basic = zte_wlan_ssid1_basic_set(ssid);
606 if(-1 == ret_for_basic)
607 {
608 printf("zte_wlan_ssid1_basic_set is false\n");
609 return -1;
610 }
611 ret_for_security = zte_wlan_ssid1_security_set(password);
612 if(-1 == ret_for_security)
613 {
614 printf("call zte_lan_ssid1_security_set failure .\n");
615 return -1;
616 }
617
618 if(ret_for_basic == 0 || ret_for_security == 0)
619 {
620 if(0 == ipc_send_message(MODULE_ID_WLAN_SERVER, MODULE_ID_WIFI, MSG_CMD_WIFI_ADVANCED, 2, "1", 0))
621 {
622 cfg_set("RadioOff", "0");
623 printf("wifi set cmd done!\n");
624 }
625 else
626 {
627 printf("wifi set cmd zte_wlan_ssid1_set error!\n");
628 return -1;
629 }
630 }
631 return 0;
632}
633
634
635int zte_wlan_capture_sta_num()
636{
637 int total_station_num = 0;
638 FILE *pp = NULL;
639 char *tmp = NULL;
640 char buf[128]={0};
641 char authmode[20]={0};
642 char radio_off[20] = {0};
643 char wifi_sta_connection[8]={0};
644 char cmd[128]={0};
645 char iifname[16]={0};
646
647 cfg_get_item("RadioOff",radio_off,sizeof(radio_off));
648 cfg_get_item("wifi_sta_connection", wifi_sta_connection, sizeof(wifi_sta_connection));
649 cfg_get_item("AuthMode",authmode, 20);
650
651 if (!strncmp(radio_off, "0", 1))
652 {
653 printf("[wlan-interface]ap-service stopped! return!\n");
654 return 0;
655 }
656
657 if(strncmp(wifi_sta_connection, "1",1) == 0)
658 {
659 strcpy(iifname,"-i wl0.1");
660 }
661 else
662 {
663 strcpy(iifname,"-i wlan0");
664 }
665
666 if((!strcmp(authmode,"WPAPSK"))||(!strcmp(authmode,"WPA2PSK"))||(!strcmp(authmode,"WPAPSKWPA2PSK")))
667 {
668 sprintf(cmd, "wl %s autho_sta_list", iifname);
669 sprintf(cmd, "wl %s autho_sta_list", iifname);
670 }
671 else
672 {
673 sprintf(cmd, "wl %s assoclist", iifname);
674 }
675
676 if ( cmd == NULL )
677 {
678 printf("[wlan-interface]error!! cmd is NULL!!\n");
679 return 0;
680 }
681
682 pp = popen(cmd, "r"); //pipe starts
683 if (!pp)
684 {
685 printf("[wlan-interface]error!! create pipe failed!!\n");
686 return 0;
687 }
688
689 strcpy(buf,"ABNORMAL");
690
691Again:
692 while(fgets(buf, 128, pp) != NULL)
693 {
694 if(strcmp(buf,"ABNORMAL")==0) //fgets error
695 {
696 printf("[wlan-interface]error!! [%s] strerror: %s\n",__FUNCTION__,strerror(errno));
697 if(errno == EINTR) //Interrupted system call,try again
698 {
699 goto Again;
700 }
701
702 pclose(pp);//close pipe
703 return 0;
704 }
705
706 if(strlen(buf) > 0)
707 {
708 if((tmp = strstr(buf, ":")) != NULL)
709 {
710 total_station_num += 1;
711 }
712 }
713 memset(buf,0,128);
714 strcpy(buf,"ABNORMAL");
715
716 }
717
718 pclose(pp);//close pipe
719 printf("[wlan-interface] total_station_num=%d\n",total_station_num);
720 return total_station_num;
721}
722
723
724void zte_get_wifi_sta_list(RT_802_11_MAC_TABLE *staList)
725{
726
727 int i = 0;
728 char station_mac[18*32]={0}; // 00:00:00:00:00:00;
729 char station_mac_tmp[18*32]={0};
730 char tmp_str[10] = {0};
731
732 if(NULL == staList)
733 {
734 return;
735 }
736 zte_wlan_get_wifi_station_list(staList);
737
738 printf("[%s:%s]staList->Num1:%d\n",__FILE__, __FUNCTION__, staList->Num);
739 printf("[%s:%s]staList->ConnectedTime:%d\n",__FILE__, __FUNCTION__, staList->Entry[0].ConnectedTime);
740
741 sprintf(tmp_str, "%d", staList->Num);
742 cfg_set("wificount", tmp_str);
743 cfg_set("station_num", tmp_str);
744 for(i=0; i<staList->Num; i++)
745 {
746 sprintf(station_mac + i * 18, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X;",\
747 staList->Entry[i].Addr[0], staList->Entry[i].Addr[1],
748 staList->Entry[i].Addr[2], staList->Entry[i].Addr[3],
749 staList->Entry[i].Addr[4], staList->Entry[i].Addr[5]);
750 }
751 if(staList->Num != 0)
752 {
753 strncpy(station_mac_tmp, station_mac, strlen(station_mac) - 1);
754 }
755
756 cfg_set("station_mac", station_mac_tmp);
757
758}
759
760#if 0 //kw 3
761int get_channel()
762{
763 char channel[8]={0};
764 pipecmd("wl channel | grep mac |cut -f2", channel);
765 return atoi(channel);
766}
767#endif