2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16 * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
32 #include <sys/ioctl.h>
33 #include <sys/socket.h>
36 #include "wireless.22.h"
42 /* How to call myself in the logs */
43 #define SYSLOG_IDENT "Freifunk Watchdog"
45 /* Wifi error action */
46 #define WIFI_ACTION "/sbin/wifi", "/sbin/wifi"
48 /* Crond error action */
49 #define CRON_ACTION "/etc/init.d/cron", "/etc/init.d/cron", "restart"
51 /* Fallback binary name (passed by makefile) */
53 #define BINARY "ffwatchd"
57 /* ifname/bssid/channel tuples */
62 struct wifi_tuple *next;
65 /* structure to hold tuple-list and uci context during iteration */
67 struct wifi_tuple *list;
68 struct uci_context *ctx;
71 typedef struct wifi_tuple wifi_tuple_t;
74 /* ioctl() helper (stolen from iwlib) */
76 iw_ioctl(int skfd, /* Socket to the kernel */
77 const char * ifname, /* Device name */
78 int request, /* WE ID */
79 struct iwreq * pwrq) /* Fixed part of the request */
82 strncpy(pwrq->ifr_ifrn.ifrn_name, ifname, 16);
85 return(ioctl(skfd, request, pwrq));
88 /* fork() & execl() helper */
94 syslog(LOG_CRIT, "Unable to fork child: %s", \
101 syslog(LOG_CRIT, "Unable to execute action: %s", \