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 blink_5g_main(int argc
, char *argv
[])
47 static unsigned int blink_5g
= 0;
48 static unsigned int data_5g
= 0;
49 unsigned long count_5g
;
52 static int status
= -1;
53 static int status_old
;
54 if (fork() != 0) return 0;
56 signal(SIGCHLD
, chld_reap
);
57 #define INTERFACE_MAXLEN 10
58 interface
= calloc(INTERFACE_MAXLEN
,1);
59 char *tmp_interface
= nvram_get("blink_5g_interface");
61 strncpy(interface
,tmp_interface
, INTERFACE_MAXLEN
);
62 // check data per 10 count
66 tmp_interface
= nvram_get("blink_5g_interface");
68 strncpy(interface
,tmp_interface
, INTERFACE_MAXLEN
);
71 count_5g
= get_5g_count();
72 if(count_5g
&& data_5g
!=count_5g
) {
81 j
= rand_seed_by_time() % 3;
85 if (((i
%2)==0) && (i
> (3 + 2*j
)))
90 if (status
!= status_old
)