summaryrefslogtreecommitdiffstats
path: root/src/iwapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/iwapi.c')
-rw-r--r--src/iwapi.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/iwapi.c b/src/iwapi.c
index e9b4177..356f144 100644
--- a/src/iwapi.c
+++ b/src/iwapi.c
@@ -23,6 +23,8 @@
#include <assert.h>
#include <string.h>
#include <sys/ioctl.h>
+
+#include <libdaemon/dlog.h>
#include "iwapi.h"
int iw_set_essid(struct interface *i, const char* essid) {
@@ -42,7 +44,7 @@ int iw_set_essid(struct interface *i, const char* essid) {
}
if (ioctl(i->fd, SIOCSIWESSID, &req) < 0) {
- fprintf(stderr, "ioctl(SIOCSIWESSID): %s\n", strerror(errno));
+ daemon_log(LOG_ERR, "ioctl(SIOCSIWESSID): %s\n", strerror(errno));
return -1;
}
@@ -57,7 +59,7 @@ int iw_set_mode(struct interface *i, int m) {
req.u.mode = m;
if (ioctl(i->fd, SIOCSIWMODE, &req) < 0) {
- fprintf(stderr, "ioctl(SIOCSIWMODE): %s\n", strerror(errno));
+ daemon_log(LOG_ERR, "ioctl(SIOCSIWMODE): %s\n", strerror(errno));
return -1;
}
@@ -72,7 +74,7 @@ int iw_set_freq(struct interface *i, struct iw_freq *f) {
req.u.freq = *f;
if (ioctl(i->fd, SIOCSIWFREQ, &req) < 0) {
- fprintf(stderr, "ioctl(SIOCSIWFREQ): %s\n", strerror(errno));
+ daemon_log(LOG_ERR, "ioctl(SIOCSIWFREQ): %s\n", strerror(errno));
return -1;
}
@@ -89,7 +91,7 @@ int iw_set_ap(struct interface *i, struct hw_addr *ap) {
memcpy(req.u.ap_addr.sa_data, ap->addr, ETH_ALEN);
if (ioctl(i->fd, SIOCSIWAP, &req) < 0) {
- fprintf(stderr, "ioctl(SIOCSIWAP): %s\n", strerror(errno));
+ daemon_log(LOG_ERR, "ioctl(SIOCSIWAP): %s\n", strerror(errno));
return -1;
}
@@ -106,12 +108,10 @@ int iw_scan(struct interface *i) {
req.u.param.value = 0;
if (ioctl(i->fd, SIOCSIWSCAN, &req) < 0) {
- fprintf(stderr, "ioctl(SIOCSIWSCAN): %s\n", strerror(errno));
+ daemon_log(LOG_ERR, "ioctl(SIOCSIWSCAN): %s\n", strerror(errno));
return -1;
}
-// fprintf(stderr, "scan!\n");
-
return 0;
}
@@ -136,19 +136,17 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) {
if (errno == EAGAIN)
return 1;
- fprintf(stderr, "ioctl(SIOCGIWSCAN): %s\n", strerror(errno));
+ daemon_log(LOG_ERR, "ioctl(SIOCGIWSCAN): %s\n", strerror(errno));
return -1;
}
-// fprintf(stderr, "scan response!\n");
-
e = (struct iw_event*) req.u.data.pointer;
l = req.u.data.length;
f = 0;
hs = sizeof(struct iw_event)-sizeof(union iwreq_data);
while (l >= sizeof(struct iw_event)) {
if (e->len < hs) {
- fprintf(stderr, "Recieved bogus wireless event\n");
+ daemon_log(LOG_ERR, "Recieved bogus wireless event\n");
return -1;
}
@@ -162,7 +160,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) {
f = 1;
if (e->len < hs + sizeof(struct sockaddr)) {
- fprintf(stderr, "Corrupt scan result (1)\n");
+ daemon_log(LOG_ERR, "Corrupt scan result (1)\n");
return -1;
}
@@ -173,7 +171,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) {
case SIOCGIWESSID:
if (e->len < hs + sizeof(struct iw_point)) {
- fprintf(stderr, "Corrupt scan result (2)\n");
+ daemon_log(LOG_ERR, "Corrupt scan result (2)\n");
return -1;
}
@@ -187,7 +185,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) {
case SIOCGIWMODE:
if (e->len < hs + sizeof(__u32)) {
- fprintf(stderr, "Corrupt scan result (3)\n");
+ daemon_log(LOG_ERR, "Corrupt scan result (3)\n");
return -1;
}
@@ -200,7 +198,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) {
case SIOCGIWFREQ:
if (e->len < hs + sizeof(struct iw_freq)) {
- fprintf(stderr, "Corrupt scan result (4)\n");
+ daemon_log(LOG_ERR, "Corrupt scan result (4)\n");
return -1;
}
@@ -211,8 +209,6 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) {
if (f == 15) {
- //fprintf(stderr, "Scan successful\n");
-
if (callback(&ap) < 0)
return -1;