Skip to content

Commit

Permalink
Merge pull request #52 from kn6plv/lqm-changes
Browse files Browse the repository at this point in the history
OLSR changes to track changes in LQM
  • Loading branch information
aanon4 authored May 12, 2024
2 parents 17b4f8d + fbfcad6 commit 414ee59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 8 additions & 8 deletions net/olsrd/patches/019-broadcast-to-unicast.patch
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ index 22a0fa16..689db076 100644
+ uint32_t check = 0;
+ struct sockaddr_ll socket_address;
+ struct pseudo_header pseudo;
+ DIR *f;
+ struct dirent* d;
+ FILE *f;
+ char macbuf[32];
+
+ struct ether_header *ether_hdr = (struct ether_header *)pkt;
+ struct iphdr *ip_hdr = (struct iphdr *)(pkt + sizeof(struct ether_header));
Expand Down Expand Up @@ -242,15 +242,15 @@ index 22a0fa16..689db076 100644
+#endif
+
+ /* Get destinations */
+ if (iface->stations[0] == 0 || (f = opendir(iface->stations)) == NULL) {
+ if (iface->stations[0] == 0 || (f = fopen(iface->stations, "r")) == NULL) {
+ /* No stations - use broadcast */
+ memset(socket_address.sll_addr, 255, sizeof(dst_mac));
+ memset(ether_hdr->ether_dhost, 255, sizeof(dst_mac));
+ return sendto(s, pkt, sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct udphdr) + len, 0, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll));
+ }
+ /* Send the packet to each peer individually */
+ while ((d = readdir(f)) != NULL) {
+ if (sscanf(d->d_name, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &dst_mac[0], &dst_mac[1], &dst_mac[2], &dst_mac[3], &dst_mac[4], &dst_mac[5]) == 6) {
+ while (fgets(macbuf, sizeof(macbuf), f) != NULL) {
+ if (sscanf(macbuf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &dst_mac[0], &dst_mac[1], &dst_mac[2], &dst_mac[3], &dst_mac[4], &dst_mac[5]) == 6) {
+ socket_address.sll_addr[0] = ether_hdr->ether_dhost[0] = dst_mac[0];
+ socket_address.sll_addr[1] = ether_hdr->ether_dhost[1] = dst_mac[1];
+ socket_address.sll_addr[2] = ether_hdr->ether_dhost[2] = dst_mac[2];
Expand All @@ -260,7 +260,7 @@ index 22a0fa16..689db076 100644
+ r = sendto(s, pkt, sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct udphdr) + len, 0, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll));
+ }
+ }
+ closedir(f);
+ fclose(f);
+
+ return r;
+}
Expand Down Expand Up @@ -338,7 +338,7 @@ index c286289b..a39653a4 100644

static const uint8_t zero_v6[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

+static const char PATH_STATIONS_PATTERN[] = "/sys/kernel/debug/ieee80211/phy%d/netdev:wlan%d/stations";
+static const char PATH_STATIONS_PATTERN[] = "/tmp/lqm.phy%d.macs";
+
void
check_interface_updates(void *foo __attribute__ ((unused)))
Expand All @@ -359,7 +359,7 @@ index c286289b..a39653a4 100644
+ if (strcmp(ifr.ifr_name, "wlan0") == 0 || strcmp(ifr.ifr_name, "wlan1") == 0) {
+ struct stat stat_buf;
+ int phyid = ifr.ifr_name[4] - '0';
+ sprintf(ifp->stations, PATH_STATIONS_PATTERN, phyid, phyid);
+ sprintf(ifp->stations, PATH_STATIONS_PATTERN, phyid);
+ if (stat(ifp->stations, &stat_buf) != 0) {
+ ifp->stations[0] = 0;
+ }
Expand Down
8 changes: 6 additions & 2 deletions utils/prometheus-exporter/files/metrics/lqm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ if f then
"distance",
"exposed",
"hidden",
"last_tx",
"last_tx_total",
"tx",
"tx_retries",
"tx_fail",
"avg_tx",
"avg_tx_retries",
"avg_tx_fail",
"lat",
"lon",
"ping_quality",
Expand Down

0 comments on commit 414ee59

Please sign in to comment.