summaryrefslogtreecommitdiffstats
path: root/contrib/wpa
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2009-03-02 02:26:53 +0000
committersam <sam@FreeBSD.org>2009-03-02 02:26:53 +0000
commit3cac7b891b7108169f5fed3997e777b56c060178 (patch)
tree9a4702b2a6316a180fa6909823635da3b5aa8524 /contrib/wpa
parent2af41b09fa9d6ff3f4c736a224f545663be143d2 (diff)
downloadFreeBSD-src-3cac7b891b7108169f5fed3997e777b56c060178.zip
FreeBSD-src-3cac7b891b7108169f5fed3997e777b56c060178.tar.gz
bring in local changes for:
CONFIG_DEBUG_SYSLOG CONFIG_TERMINATE_ONLASTIF EAP_SERVER
Diffstat (limited to 'contrib/wpa')
-rw-r--r--contrib/wpa/hostapd/hostapd.c4
-rw-r--r--contrib/wpa/src/utils/wpa_debug.c47
-rw-r--r--contrib/wpa/wpa_supplicant/events.c17
-rw-r--r--contrib/wpa/wpa_supplicant/main.c30
-rw-r--r--contrib/wpa/wpa_supplicant/wpa_supplicant.c3
-rw-r--r--contrib/wpa/wpa_supplicant/wpa_supplicant_i.h5
6 files changed, 102 insertions, 4 deletions
diff --git a/contrib/wpa/hostapd/hostapd.c b/contrib/wpa/hostapd/hostapd.c
index df6062b..065a5fd 100644
--- a/contrib/wpa/hostapd/hostapd.c
+++ b/contrib/wpa/hostapd/hostapd.c
@@ -1910,10 +1910,12 @@ int main(int argc, char *argv[])
if (optind == argc)
usage();
+#ifdef EAP_SERVER
if (eap_server_register_methods()) {
wpa_printf(MSG_ERROR, "Failed to register EAP methods");
return -1;
}
+#endif /* EAP_SERVER */
interfaces.count = argc - optind;
@@ -2019,7 +2021,9 @@ int main(int argc, char *argv[])
closelog();
#endif /* CONFIG_NATIVE_WINDOWS */
+#ifdef EAP_SERVER
eap_server_unregister_methods();
+#endif /* EAP_SERVER */
os_daemonize_terminate(pid_file);
diff --git a/contrib/wpa/src/utils/wpa_debug.c b/contrib/wpa/src/utils/wpa_debug.c
index e17cf06..5d53bf8 100644
--- a/contrib/wpa/src/utils/wpa_debug.c
+++ b/contrib/wpa/src/utils/wpa_debug.c
@@ -16,6 +16,10 @@
#include "common.h"
+#ifdef CONFIG_DEBUG_SYSLOG
+#include <syslog.h>
+#endif /* CONFIG_DEBUG_SYSLOG */
+
#ifdef CONFIG_DEBUG_FILE
static FILE *out_file = NULL;
@@ -23,6 +27,7 @@ static FILE *out_file = NULL;
int wpa_debug_level = MSG_INFO;
int wpa_debug_show_keys = 0;
int wpa_debug_timestamp = 0;
+int wpa_debug_syslog = 0;
#ifndef CONFIG_NO_STDOUT_DEBUG
@@ -44,6 +49,40 @@ void wpa_debug_print_timestamp(void)
printf("%ld.%06u: ", (long) tv.sec, (unsigned int) tv.usec);
}
+void wpa_debug_open_syslog(void)
+{
+#ifdef CONFIG_DEBUG_SYSLOG
+ openlog("wpa_supplicant", LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ wpa_debug_syslog++;
+#endif
+}
+
+void wpa_debug_close_syslog(void)
+{
+#ifdef CONFIG_DEBUG_SYSLOG
+ if (wpa_debug_syslog)
+ closelog();
+#endif
+}
+
+#ifdef CONFIG_DEBUG_SYSLOG
+static int syslog_priority(int level)
+{
+ switch (level) {
+ case MSG_MSGDUMP:
+ case MSG_DEBUG:
+ return LOG_DEBUG;
+ case MSG_INFO:
+ return LOG_NOTICE;
+ case MSG_WARNING:
+ return LOG_WARNING;
+ case MSG_ERROR:
+ return LOG_ERR;
+ }
+ return LOG_INFO;
+}
+#endif /* CONFIG_DEBUG_SYSLOG */
+
/**
* wpa_printf - conditional printf
@@ -62,6 +101,11 @@ void wpa_printf(int level, char *fmt, ...)
va_start(ap, fmt);
if (level >= wpa_debug_level) {
+#ifdef CONFIG_DEBUG_SYSLOG
+ if (wpa_debug_syslog) {
+ vsyslog(syslog_priority(level), fmt, ap);
+ } else {
+#endif /* CONFIG_DEBUG_SYSLOG */
wpa_debug_print_timestamp();
#ifdef CONFIG_DEBUG_FILE
if (out_file) {
@@ -74,6 +118,9 @@ void wpa_printf(int level, char *fmt, ...)
#ifdef CONFIG_DEBUG_FILE
}
#endif /* CONFIG_DEBUG_FILE */
+#ifdef CONFIG_DEBUG_SYSLOG
+ }
+#endif /* CONFIG_DEBUG_SYSLOG */
}
va_end(ap);
}
diff --git a/contrib/wpa/wpa_supplicant/events.c b/contrib/wpa/wpa_supplicant/events.c
index dd4595a..d3c785f 100644
--- a/contrib/wpa/wpa_supplicant/events.c
+++ b/contrib/wpa/wpa_supplicant/events.c
@@ -1011,6 +1011,18 @@ wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
}
+#ifdef CONFIG_TERMINATE_ONLASTIF
+static int any_interfaces(struct wpa_supplicant *head)
+{
+ struct wpa_supplicant *wpa_s;
+
+ for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
+ if (!wpa_s->interface_removed)
+ return 1;
+ return 0;
+}
+#endif /* CONFIG_TERMINATE_ONLASTIF */
+
static void
wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
union wpa_event_data *data)
@@ -1035,6 +1047,11 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
wpa_supplicant_mark_disassoc(wpa_s);
l2_packet_deinit(wpa_s->l2);
wpa_s->l2 = NULL;
+#ifdef CONFIG_TERMINATE_ONLASTIF
+ /* check if last interface */
+ if (!any_interfaces(wpa_s->global->ifaces))
+ eloop_terminate();
+#endif /* CONFIG_TERMINATE_ONLASTIF */
break;
}
}
diff --git a/contrib/wpa/wpa_supplicant/main.c b/contrib/wpa/wpa_supplicant/main.c
index 6f90cc5..1f413f1 100644
--- a/contrib/wpa/wpa_supplicant/main.c
+++ b/contrib/wpa/wpa_supplicant/main.c
@@ -26,11 +26,23 @@ static void usage(void)
int i;
printf("%s\n\n%s\n"
"usage:\n"
- " wpa_supplicant [-BddhKLqqtuvW] [-P<pid file>] "
+ " wpa_supplicant [-BddhKLqq"
+#ifdef CONFIG_DEBUG_SYSLOG
+ "s"
+#endif /* CONFIG_DEBUG_SYSLOG */
+ "t"
+#ifdef CONFIG_CTRL_IFACE_DBUS
+ "u"
+#endif /* CONFIG_CTRL_IFACE_DBUS */
+ "vW] [-P<pid file>] "
"[-g<global ctrl>] \\\n"
" -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
"[-p<driver_param>] \\\n"
- " [-b<br_ifname>] [-f<debug file>] \\\n"
+ " [-b<br_ifname>]"
+#ifdef CONFIG_DEBUG_FILE
+ " [-f<debug file>]"
+#endif /* CONFIG_DEBUG_FILE */
+ " \\\n"
" [-N -i<ifname> -c<conf> [-C<ctrl>] "
"[-D<driver>] \\\n"
" [-p<driver_param>] [-b<br_ifname>] ...]\n"
@@ -58,6 +70,9 @@ static void usage(void)
#endif /* CONFIG_DEBUG_FILE */
" -g = global ctrl_interface\n"
" -K = include keys (passwords, etc.) in debug output\n"
+#ifdef CONFIG_DEBUG_SYSLOG
+ " -s = log output to syslog instead of stdout\n"
+#endif /* CONFIG_DEBUG_SYSLOG */
" -t = include timestamp in debug messages\n"
" -h = show this help text\n"
" -L = show license (GPL and BSD)\n");
@@ -72,7 +87,9 @@ static void usage(void)
" -N = start describing new interface\n");
printf("example:\n"
- " wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf\n");
+ " wpa_supplicant -D%s -iwlan0 -c/etc/wpa_supplicant.conf\n",
+ wpa_supplicant_drivers[i] ?
+ wpa_supplicant_drivers[i]->name : "wext");
#endif /* CONFIG_NO_STDOUT_DEBUG */
}
@@ -133,7 +150,7 @@ int main(int argc, char *argv[])
wpa_supplicant_fd_workaround();
for (;;) {
- c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNp:P:qtuvW");
+ c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNp:P:qstuvW");
if (c < 0)
break;
switch (c) {
@@ -194,6 +211,11 @@ int main(int argc, char *argv[])
case 'q':
params.wpa_debug_level++;
break;
+#ifdef CONFIG_DEBUG_SYSLOG
+ case 's':
+ params.wpa_debug_syslog++;
+ break;
+#endif /* CONFIG_DEBUG_SYSLOG */
case 't':
params.wpa_debug_timestamp++;
break;
diff --git a/contrib/wpa/wpa_supplicant/wpa_supplicant.c b/contrib/wpa/wpa_supplicant/wpa_supplicant.c
index c1f95cb..b472eb3 100644
--- a/contrib/wpa/wpa_supplicant/wpa_supplicant.c
+++ b/contrib/wpa/wpa_supplicant/wpa_supplicant.c
@@ -2016,6 +2016,8 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
return NULL;
wpa_debug_open_file(params->wpa_debug_file_path);
+ if (params->wpa_debug_syslog)
+ wpa_debug_open_syslog();
ret = eap_peer_register_methods();
if (ret) {
@@ -2166,5 +2168,6 @@ void wpa_supplicant_deinit(struct wpa_global *global)
os_free(global->params.ctrl_interface);
os_free(global);
+ wpa_debug_close_syslog();
wpa_debug_close_file();
}
diff --git a/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h b/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h
index 5e4dcc1..71db428 100644
--- a/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h
+++ b/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h
@@ -156,6 +156,11 @@ struct wpa_params {
* wpa_debug_file_path - Path of debug file or %NULL to use stdout
*/
const char *wpa_debug_file_path;
+
+ /**
+ * wpa_debug_syslog - Enable log output through syslog
+ */
+ const char *wpa_debug_syslog;
};
/**
OpenPOWER on IntegriCloud