4 static char *interface
= NULL
;
5 static int rand_seed_by_time(void)
10 srand((unsigned long)atime
);
15 static unsigned long get_5g_count()
20 unsigned long counter1
, counter2
;
22 if((f
= fopen("/proc/net/dev", "r"))==NULL
) return -1;
24 fgets(buf
, sizeof(buf
), f
);
25 fgets(buf
, sizeof(buf
), f
);
29 while (fgets(buf
, sizeof(buf
), f
)) {
30 if((p
=strchr(buf
, ':'))==NULL
) continue;
32 if((ifname
= strrchr(buf
, ' '))==NULL
) ifname
= buf
;
35 if(strcmp(ifname
, interface
)) continue;
37 if(sscanf(p
+1, "%lu%*u%*u%*u%*u%*u%*u%*u%*u%lu", &counter1
, &counter2
)!=2) continue;
45 int get_lanports_status(void)
51 if ((f
= popen("/usr/sbin/robocfg showports", "r")) != NULL
) {
52 while (fgets(s
, sizeof(s
), f
)) {
53 if ((sscanf(s
, "Port 1: %s", a
) == 1) ||
54 (sscanf(s
, "Port 2: %s", a
) == 1) ||
55 (sscanf(s
, "Port 3: %s", a
) == 1) ||
56 (sscanf(s
, "Port 4: %s", a
) == 1)) {
57 if (strncmp(a
, "DOWN", 4)) {
68 int blink_5g_main(int argc
, char *argv
[])
70 static unsigned int blink_5g
= 0;
71 static unsigned int data_5g
= 0;
72 unsigned long count_5g
;
76 static int status
= -1;
77 static int status_old
;
78 if (fork() != 0) return 0;
80 signal(SIGCHLD
, chld_reap
);
81 #define INTERFACE_MAXLEN 10
82 interface
= calloc(INTERFACE_MAXLEN
,1);
83 char *tmp_interface
= nvram_get("blink_5g_interface");
85 strncpy(interface
,tmp_interface
, INTERFACE_MAXLEN
);
86 // check data per 10 count
89 if (model
== MODEL_WS880
) {
91 if (get_lanports_status()) {
92 led(LED_BRIDGE
, LED_ON
);
95 led(LED_BRIDGE
, LED_OFF
);
101 tmp_interface
= nvram_get("blink_5g_interface");
103 strncpy(interface
,tmp_interface
, INTERFACE_MAXLEN
);
106 count_5g
= get_5g_count();
107 if(count_5g
&& data_5g
!=count_5g
) {
116 j
= rand_seed_by_time() % 3;
120 if (((i
%2)==0) && (i
> (3 + 2*j
)))
125 if (status
!= status_old
)
130 led(LED_5G
, LED_OFF
);