X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/bb613923865e6a702e35ad13fdba19cbc7c20c2c..977be0cf4f369f586d0606887498066ee0565e2f:/components/wifi.c diff --git a/components/wifi.c b/components/wifi.c index 7dfa4e2..414d533 100644 --- a/components/wifi.c +++ b/components/wifi.c @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include #include #include "../util.h" @@ -66,14 +66,14 @@ wifi_essid(const char *iface) { static char id[IW_ESSID_MAX_SIZE+1]; - int sockfd = socket(AF_INET, SOCK_DGRAM, 0); + int sockfd; struct iwreq wreq; memset(&wreq, 0, sizeof(struct iwreq)); wreq.u.essid.length = IW_ESSID_MAX_SIZE+1; snprintf(wreq.ifr_name, sizeof(wreq.ifr_name), "%s", iface); - if (sockfd < 0) { + if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { fprintf(stderr, "socket 'AF_INET': %s\n", strerror(errno)); return NULL; @@ -97,6 +97,7 @@ #include #include #include + #include /* before for NBBY */ #include #include #include @@ -122,7 +123,7 @@ return 0; } strlcpy(nr->nr_ifname, iface, sizeof(nr->nr_ifname)); - memmove(&nr->nr_macaddr, bssid.i_bssid, sizeof(nr->nr_macaddr)); + memcpy(&nr->nr_macaddr, bssid.i_bssid, sizeof(nr->nr_macaddr)); if ((ioctl(sockfd, SIOCG80211NODE, nr)) < 0 && nr->nr_rssi) { fprintf(stderr, "ioctl 'SIOCG80211NODE': %s\n", strerror(errno));