diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/aes.c | 13 | ||||
-rw-r--r-- | src/aeswepd.c | 6 | ||||
-rw-r--r-- | src/ifmonitor.c | 34 | ||||
-rw-r--r-- | src/interface.c | 9 | ||||
-rw-r--r-- | src/iwapi.c | 30 | ||||
-rw-r--r-- | src/iwkey.c | 12 | ||||
-rw-r--r-- | src/nlapi.c | 5 | ||||
-rw-r--r-- | src/waproamd.c | 19 | ||||
-rw-r--r-- | src/wireless.h | 2 |
10 files changed, 53 insertions, 82 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 1080a15..5a51db3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,3 +49,8 @@ aeswepd_LDADD = -lmcrypt install-exec-hook: cd $(DESTDIR)/$(sbindir) && ln -sf aeswepd aeswepls endif + +svnkeywords: + svn propset svn:keywords Id *.c *.h Makefile.am + +.PHONY: svnkeywords @@ -24,6 +24,8 @@ #include <stdint.h> #include <time.h> +#include <libdaemon/dlog.h> + #include "aes.h" #include "util.h" #include "aeswepd.h" @@ -50,33 +52,30 @@ int aes_crypt(uint8_t *key, uint8_t *data, uint8_t *result) { for (j = 0; j < n_cache; j++) if (!memcmp(cache[j].key, key, AES_KEY_LEN) && !memcmp(cache[j].data, data, AES_KEY_LEN)) { - //fprintf(stderr, "Cache hit\n"); memcpy(result, cache[j].result, AES_KEY_LEN); return 0; } - //fprintf(stderr, "Cache miss\n"); - if (m == MCRYPT_FAILED) { if ((m = mcrypt_module_open("rijndael-128", NULL, "ecb", NULL)) == MCRYPT_FAILED) { - fprintf(stderr, "Failed to open rijndael mcrypt module\n"); + daemon_log(LOG_ERR, "Failed to open rijndael mcrypt module\n"); return -1; } } if ((r = mcrypt_generic_init(m, key, AES_KEY_LEN, NULL)) != 0) { - fprintf(stderr, "Failed to encrypt: %s\n", mcrypt_strerror(r)); + daemon_log(LOG_ERR, "Failed to encrypt: %s\n", mcrypt_strerror(r)); return -1; } memcpy(result, data, AES_KEY_LEN); if (mcrypt_generic(m, result, AES_KEY_LEN) != 0) { - fprintf(stderr, "mdecrypt_generic() failed.\n"); + daemon_log(LOG_ERR, "mdecrypt_generic() failed.\n"); return -1; } if (mcrypt_generic_deinit(m) != 0) { - fprintf(stderr, "mdecrypt_generic() failed.\n"); + daemon_log(LOG_ERR, "mdecrypt_generic() failed.\n"); return -1; } diff --git a/src/aeswepd.c b/src/aeswepd.c index 684b224..d144977 100644 --- a/src/aeswepd.c +++ b/src/aeswepd.c @@ -376,14 +376,14 @@ void parse_args(int argc, char *argv[]) { break; case 't': if ((rekey_time = atoi(optarg)) <= 0) { - fprintf(stderr, "Rekey time too short.\n"); + daemon_log(LOG_ERR, "Rekey time too short.\n"); exit(1); } break; case 'm': n_max_keys = atoi(optarg); if (n_max_keys <= 0 || n_max_keys > 4) { - fprintf(stderr, "--max-keys has to be between 1 and 4\n"); + daemon_log(LOG_ERR, "--max-keys has to be between 1 and 4\n"); exit(1); } break; @@ -454,7 +454,7 @@ void parse_args(int argc, char *argv[]) { } default: - fprintf(stderr, "Unknown parameter.\n"); + daemon_log(LOG_ERR, "Unknown parameter.\n"); exit(1); } } diff --git a/src/ifmonitor.c b/src/ifmonitor.c index c1e05ec..9991893 100644 --- a/src/ifmonitor.c +++ b/src/ifmonitor.c @@ -28,6 +28,8 @@ #include <unistd.h> #include <errno.h> +#include <libdaemon/dlog.h> + #include "util.h" #include "nlapi.h" @@ -43,7 +45,7 @@ static int callback(struct nlmsghdr *n, void *u) { i = NLMSG_DATA(n); if (n->nlmsg_len < NLMSG_LENGTH(sizeof(struct ifinfomsg))) { - fprintf(stderr, "NETLINK: Packet too small or truncated! (2)\n"); + daemon_log(LOG_ERR, "NETLINK: Packet too small or truncated! (2)\n"); return -1; } @@ -72,33 +74,3 @@ static int callback(struct nlmsghdr *n, void *u) { int ifmonitor_init(int (*cb) (int b, int index, unsigned short type, const char *name)) { return nlapi_register(callback, cb); } - -#if 0 - -int test(int b, int index, unsigned short type, const char * name) { - printf("CALLBACK %s %s %i %i\n", b ? "new" : "del", name, index, type); - return 0; -} - -int main(int argc, char *argv[]) { - int r = 1; - - if (nlapi_open(RTMGRP_LINK) < 0) - goto finish; - - if (ifmonitor_init(test) < 0) - goto finish; - - for (;;) - if (nlapi_work() < 0) - goto finish; - - r = 0; - -finish: - nlapi_close(); - - return r; -} - -#endif diff --git a/src/interface.c b/src/interface.c index 72030c3..e835ab3 100644 --- a/src/interface.c +++ b/src/interface.c @@ -26,6 +26,8 @@ #include <unistd.h> #include <sys/ioctl.h> +#include <libdaemon/dlog.h> + #include "interface.h" #include "util.h" #include "wireless.h" @@ -40,7 +42,7 @@ struct interface *interface_open(char *name) { strncpy(i->name, name, IFNAMSIZ); if ((i->fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { - fprintf(stderr, "socket(): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "socket(): %s\n", strerror(errno)); goto fail; } @@ -77,7 +79,7 @@ int interface_is_assoc(struct interface *i, struct hw_addr *ap) { strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ); if (ioctl(i->fd, SIOCGIWAP, &req) < 0) { - fprintf(stderr, "Failed to get AP address\n"); + daemon_log(LOG_ERR, "Failed to get AP address\n"); return -1; } @@ -94,11 +96,10 @@ int interface_is_assoc(struct interface *i, struct hw_addr *ap) { req.u.data.flags = 1; if (ioctl(i->fd, SIOCGIWSTATS, &req) < 0) { - fprintf(stderr, "Failed to get interface quality\n"); + daemon_log(LOG_ERR, "Failed to get interface quality\n"); return -1; } - if (q.qual.qual <= 0) return 0; 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; diff --git a/src/iwkey.c b/src/iwkey.c index b4b44c5..a3403a8 100644 --- a/src/iwkey.c +++ b/src/iwkey.c @@ -24,6 +24,8 @@ #include <sys/ioctl.h> #include <errno.h> +#include <libdaemon/dlog.h> + #include "iwkey.h" #include "wireless.h" #include "util.h" @@ -35,7 +37,7 @@ int wep_key_add(struct interface *i, uint8_t w[WEP_KEY_LEN]) { assert(i); if (n_used_keys >= n_max_keys) { - fprintf(stderr, "Too many keys added!\n"); + daemon_log(LOG_ERR, "Too many keys added!\n"); return -1; } @@ -47,7 +49,7 @@ int wep_key_add(struct interface *i, uint8_t w[WEP_KEY_LEN]) { req.u.encoding.flags = key_map[n_used_keys++]+1; if (ioctl(i->fd, SIOCSIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); return -1; } @@ -70,7 +72,7 @@ int wep_key_finish(struct interface *i) { req.u.encoding.flags = (key_map[n_used_keys-1]+1); if (ioctl(i->fd, SIOCGIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCGIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCGIWENCODE): %s\n", strerror(errno)); return -1; } @@ -83,7 +85,7 @@ int wep_key_finish(struct interface *i) { req.u.encoding.flags = (key_map[j]+1); if (ioctl(i->fd, SIOCSIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); return -1; } } @@ -97,7 +99,7 @@ int wep_key_finish(struct interface *i) { req.u.encoding.flags = IW_ENCODE_RESTRICTED; if (ioctl(i->fd, SIOCSIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); return -1; } diff --git a/src/nlapi.c b/src/nlapi.c index d88a1ed..318199f 100644 --- a/src/nlapi.c +++ b/src/nlapi.c @@ -43,7 +43,7 @@ int nlapi_open(uint32_t groups) { struct sockaddr_nl addr; if ((nlapi_fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) { - fprintf(stderr, "socket(PF_NETLINK): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "socket(PF_NETLINK): %s\n", strerror(errno)); return -1; } @@ -54,7 +54,7 @@ int nlapi_open(uint32_t groups) { if (bind(nlapi_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { close(nlapi_fd); - fprintf(stderr, "bind(): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "bind(): %s\n", strerror(errno)); return -1; } @@ -104,7 +104,6 @@ void nlapi_close(void) { close(nlapi_fd); nlapi_fd = -1; - while (callbacks) { struct callback_info *c = callbacks; callbacks = callbacks->next; diff --git a/src/waproamd.c b/src/waproamd.c index 430c839..7c8d7d8 100644 --- a/src/waproamd.c +++ b/src/waproamd.c @@ -64,7 +64,7 @@ char log_ident[32], pid_ident[32]; int issue_scan(struct interface *i) { - //fprintf(stderr, "Scanning...\n"); + //daemon_log(LOG_ERR, "Scanning...\n"); if (iw_set_mode(i, IW_MODE_INFRA) < 0) return -1; @@ -167,16 +167,13 @@ int set_current_ap(struct hw_addr *a) { setenv("IFACE", interface_name, 1); if (!hw_addr_equal(¤t_ap, &null_ap)) { - fprintf(stderr, "Selected AP "); - print_hw_addr(stderr, ¤t_ap); - fprintf(stderr, "\n"); + daemon_log(LOG_INFO, "Selected new AP %s", t); if (run_script(¤t_ap, "start") < 0) return -1; } } - return 0; } @@ -319,7 +316,7 @@ int go(struct interface *i) { if (errno == EINTR) continue; - fprintf(stderr, "select() failed: %s\n", strerror(errno)); + daemon_log(LOG_ERR, "select() failed: %s\n", strerror(errno)); goto finish; } @@ -341,7 +338,7 @@ int go(struct interface *i) { /* Changed: enabled -> disabled */ if (!d && disabled) { - fprintf(stderr, "Interface disabled\n"); + daemon_log(LOG_INFO, "Interface disabled\n"); if (associated) if (set_current_ap(&null_ap) < 0) @@ -352,21 +349,21 @@ int go(struct interface *i) { /* Changed: disabled -> enabled */ if (d && !disabled) { - fprintf(stderr, "Interface enabled\n"); + daemon_log(LOG_INFO, "Interface enabled\n"); associated = 0; } if (!disabled) { /* Changed: associated -> not associated */ if (a && !associated) - fprintf(stderr, "No longer associated.\n"); + daemon_log(LOG_INFO, "No longer associated.\n"); /* Changed: not associated -> associated */ if (!a && associated) { if (set_current_ap(&associated_ap) < 0) goto finish; - fprintf(stderr, "Associated.\n"); + daemon_log(LOG_INFO, "Associated.\n"); next_scan = (time_t) -1; } @@ -559,7 +556,7 @@ void parse_args(int argc, char *argv[]) { break; default: - fprintf(stderr, "Unknown parameter.\n"); + daemon_log(LOG_ERR, "Unknown parameter.\n"); exit(1); } } diff --git a/src/wireless.h b/src/wireless.h index db302a8..0a4ef2e 100644 --- a/src/wireless.h +++ b/src/wireless.h @@ -1,7 +1,7 @@ #ifndef foowirelesshfoo #define foowirelesshfoo -/* $Id: waproamd.c 1.12 Sat, 01 Feb 2003 03:00:07 +0100 lennart $ */ +/* $Id$ */ /* * This file is part of waproamd. |