File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ Specifiers starting with a dollar sign are used to represent real-time statistic
2929```
3030curl http://192.168.1.17/api/osd/1?text=$B%20C:$C%20M:$M
3131```
32- N.B. Spaces have to be escaped with %20 in curl URL syntaxes
32+ N.B. Spaces have to be escaped with %20 in curl URL syntaxes, $B can take an optional interface name preceded by a colon
3333
3434Showing the time and customizing the time format is done this way:
3535```
Original file line number Diff line number Diff line change @@ -19,13 +19,25 @@ void region_fill_formatted(char* str) {
1919 }
2020 else if (str [ipos + 1 ] == 'B' )
2121 {
22- ipos ++ ;
22+ char ifname [ 16 ] = { 0 } ;
2323 struct ifaddrs * ifaddr , * ifa ;
24+
25+ ipos ++ ;
26+
27+ if (str [ipos + 1 ] == ':' ) {
28+ int j = 0 ;
29+ ipos ++ ;
30+ while (str [ipos + 1 ] && str [ipos + 1 ] != '$' && str [ipos + 1 ] != ' ' && j < (sizeof (ifname ) - 1 ))
31+ ifname [j ++ ] = str [++ ipos ];
32+ ifname [j ] = '\0' ;
33+ }
34+
2435 if (getifaddrs (& ifaddr ) == -1 ) continue ;
2536
2637 for (ifa = ifaddr ; ifa != NULL ; ifa = ifa -> ifa_next )
2738 {
2839 if (EQUALS (ifa -> ifa_name , "lo" )) continue ;
40+ if (ifname [0 ] && !EQUALS (ifa -> ifa_name , ifname )) continue ;
2941 if (!ifa -> ifa_addr || ifa -> ifa_addr -> sa_family != AF_PACKET ) continue ;
3042 if (!ifa -> ifa_data ) continue ;
3143
You can’t perform that action at this time.
0 commit comments