1522 strncpy(wrq.ifr_name, ifa->ifa_name, IFNAMSIZ-1); |
1522 strncpy(wrq.ifr_name, ifa->ifa_name, IFNAMSIZ-1); |
1523 |
1523 |
1524 if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { |
1524 if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { |
1525 syslog(LOG_NOTICE, "Error %d opening INET socket", errno); |
1525 syslog(LOG_NOTICE, "Error %d opening INET socket", errno); |
1526 } else { |
1526 } else { |
1527 if (ioctl(sock, SIOCGIWNAME, &wrq) == 0) { |
|
1528 syslog(LOG_NOTICE, "IF: %s", wrq.ifr_name); |
|
1529 } |
|
1530 |
|
1531 wrq.u.essid.pointer = essid; |
1527 wrq.u.essid.pointer = essid; |
1532 if (ioctl(sock, SIOCGIWESSID, &wrq) != -1) { |
1528 if (ioctl(sock, SIOCGIWESSID, &wrq) != -1) { |
1533 payload = xstrcat(payload, (char *)",\"ssid\":\""); |
1529 payload = xstrcat(payload, (char *)",\"ssid\":\""); |
1534 payload = xstrcat(payload, wrq.u.essid.pointer); |
1530 payload = xstrcat(payload, wrq.u.essid.pointer); |
1535 payload = xstrcat(payload, (char *)"\""); |
1531 payload = xstrcat(payload, (char *)"\""); |
1538 memset(&iwstats, 0, sizeof(iwstats)); |
1534 memset(&iwstats, 0, sizeof(iwstats)); |
1539 wrq.u.data.pointer = &iwstats; |
1535 wrq.u.data.pointer = &iwstats; |
1540 wrq.u.data.length = sizeof(struct iw_statistics); |
1536 wrq.u.data.length = sizeof(struct iw_statistics); |
1541 wrq.u.data.flags = 1; |
1537 wrq.u.data.flags = 1; |
1542 if (ioctl(sock, SIOCGIWSTATS, &wrq) != -1) { |
1538 if (ioctl(sock, SIOCGIWSTATS, &wrq) != -1) { |
1543 syslog(LOG_NOTICE, "Signal level is %d %d %d", iwstats.qual.updated & IW_QUAL_DBM, iwstats.qual.level, iwstats.qual.noise); |
|
1544 if ((iwstats.qual.updated & (IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID)) == 0) { |
1539 if ((iwstats.qual.updated & (IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID)) == 0) { |
1545 /* iwstats.qual.level is __u8 */ |
1540 /* iwstats.qual.level is __u8 */ |
1546 if (iwstats.qual.updated & IW_QUAL_DBM) { |
1541 if (iwstats.qual.updated & IW_QUAL_DBM) { |
1547 rssi = (iwstats.qual.level > 63) ? iwstats.qual.level - 0x100 : iwstats.qual.level; |
1542 rssi = (iwstats.qual.level > 63) ? iwstats.qual.level - 0x100 : iwstats.qual.level; |
1548 } else { |
1543 } else { |