/* * General-purpose utilities used by multiple files. */ #include "wavemon.h" #include "nl80211.h" #include #include #include #include #include #include #include /* Maximum length of a MAC address: 2 * 6 hex digits, 6 - 1 colons, plus '\0' */ #define MAC_ADDR_MAX 18 /* Return true if all ethernet octets are zero. */ bool ether_addr_is_zero(const struct ether_addr *ea) { static const struct ether_addr zero = {{0}}; return memcmp(ea, &zero, sizeof(zero)) == 0; } /* Print a mac-address, include leading zeroes (unlike ether_ntoa(3)) */ char *ether_addr(const struct ether_addr *ea) { static char mac[MAC_ADDR_MAX]; char *d = mac, *a = ether_ntoa(ea); next_chunk: if (a[0] == '\0' || a[1] == '\0' || a[1] == ':') *d++ = '0'; while ((*d++ = conf.cisco_mac ? (*a == ':' ? '.' : *a) : toupper(*a))) if (*a++ == ':') goto next_chunk; return mac; } /* Print mac-address translation from /etc/ethers if available */ char *ether_lookup(const struct ether_addr *ea) { static char hostname[BUFSIZ]; if (ether_ntohost(hostname, ea) == 0) return hostname; return ether_addr(ea); } /* Format an Ethernet mac address */ char *mac_addr(const struct sockaddr *sa) { if (sa->sa_family != ARPHRD_ETHER) return "00:00:00:00:00:00"; return ether_lookup((const struct ether_addr *)sa->sa_data); } /* Format a (I)BSSID */ char *format_bssid(const struct sockaddr *ap) { uint8_t bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; uint8_t zero_addr[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; if (memcmp(ap->sa_data, zero_addr, ETH_ALEN) == 0) return "Not-Associated"; if (memcmp(ap->sa_data, bcast_addr, ETH_ALEN) == 0) return "Invalid"; return mac_addr(ap); } /* count bits set in @mask the Brian Kernighan way */ uint8_t bit_count(uint32_t mask) { uint8_t bits_set; for (bits_set = 0; mask; bits_set++) mask &= mask - 1; return bits_set; } /* netmask = contiguous 1's followed by contiguous 0's */ uint8_t prefix_len(const struct in_addr *netmask) { return bit_count(netmask->s_addr); } /* Pretty-print @sec into a string of up to 6 characters. */ const char *pretty_time(const unsigned sec) { static char buf[12]; unsigned d = sec / 86400, h = sec % 86400 / 3600, m = sec % 3600 / 60; if (d > 9) { sprintf(buf, "%u days", d); } else if (d) { if (h) { sprintf(buf, "%ud %uh", d, h); } else if (m) { sprintf(buf, "%ud %dm", d, m); } else { sprintf(buf, "%u day%s", d, d == 1 ? "" : "s"); } } else if (h) { sprintf(buf, "%u:%02uh", h, m); } else if (m) { sprintf(buf, "%u:%02um", m, sec % 60); } else { sprintf(buf, "%u sec", sec); } return buf; } /* Like pretty_time, but allow milliseconds */ const char *pretty_time_ms(const unsigned msec) { static char buf[12]; if (msec < 1000) { sprintf(buf, "%u ms", msec); return buf; } return pretty_time(msec/1000); } /* Absolute power measurement in dBm (IW_QUAL_DBM): map into -192 .. 63 range */ int u8_to_dbm(const int power) { return power > 63 ? power - 0x100 : power; } uint8_t dbm_to_u8(const int dbm) { return dbm < 0 ? dbm + 0x100 : dbm; } /* Convert log dBm values to linear mW */ double dbm2mw(const double in) { return pow(10.0, in / 10.0); } char *dbm2units(const double
# AMC 9 @ 83W
# freq pol sr fec

S 11745000 H 04232000 AUTO
S 11751000 H 04232000 AUTO
S 11757000 H 04232000 AUTO
S 11763000 H 04232000 AUTO
S 11769000 H 04232000 AUTO
S 11775000 H 04232000 AUTO
S 11826000 H 05632000 AUTO
S 11864000 H 03979000 AUTO
S 11871000 H 13000000 AUTO
S 11889000 H 13025000 AUTO
S 11926000 V 06511000 AUTO
S 11953000 V 03979000 AUTO
S 11960000 H 05000000 AUTO
S 12002000 H 03979000 AUTO
S 12011000 H 03979000 AUTO