static int print_event(struct nl_msg *msg, void *arg)
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
- struct nlattr *tb[NL80211_ATTR_MAX + 1];
+ struct nlattr *tb[NL80211_ATTR_MAX + 1], *nst;
struct print_event_args *args = arg;
char ifname[100];
char macbuf[6*3];
__u8 reg_type;
+ int rem_nst;
if (args->time) {
struct timeval tv;
printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
break;
case NL80211_CMD_NEW_SCAN_RESULTS:
- printf("scan finished\n");
- break;
+ printf("scan finished:");
case NL80211_CMD_SCAN_ABORTED:
- printf("scan aborted\n");
+ if (gnlh->cmd == NL80211_CMD_SCAN_ABORTED)
+ printf("scan aborted:");
+ if (tb[NL80211_ATTR_SCAN_FREQUENCIES]) {
+ nla_for_each_nested(nst, tb[NL80211_ATTR_SCAN_FREQUENCIES], rem_nst)
+ printf(" %d", nla_get_u32(nst));
+ printf(",");
+ }
+ if (tb[NL80211_ATTR_SCAN_SSIDS]) {
+ nla_for_each_nested(nst, tb[NL80211_ATTR_SCAN_SSIDS], rem_nst) {
+ printf(" \"");
+ print_ssid_escaped(nla_len(nst), nla_data(nst));
+ printf("\"");
+ }
+ }
+ printf("\n");
break;
case NL80211_CMD_REG_CHANGE:
printf("regulatory domain change: ");
int ieee80211_channel_to_frequency(int chan);
int ieee80211_frequency_to_channel(int freq);
+void print_ssid_escaped(const uint8_t len, const uint8_t *data);
+
int nl_get_multicast_id(struct nl_sock *sock, const char *family, const char *group);
char *reg_initiator_to_string(__u8 initiator);
static void print_ssid(const uint8_t type, uint8_t len, const uint8_t *data)
{
- int i;
-
printf(" ");
-
- for (i = 0; i < len; i++) {
- if (isprint(data[i]))
- printf("%c", data[i]);
- else
- printf("\\x%.2x", data[i]);
- }
+ print_ssid_escaped(len, data);
printf("\n");
}
+#include <ctype.h>
#include "iw.h"
#include "nl80211.h"
/* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
return freq/5 - 1000;
}
+
+void print_ssid_escaped(const uint8_t len, const uint8_t *data)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (isprint(data[i]))
+ printf("%c", data[i]);
+ else
+ printf("\\x%.2x", data[i]);
+ }
+}