Re: [OpenWrt-Devel] [PATCH] hostapd: Add client association log file
nak on this one as it was rejected upstream aswell On 21/01/2015 14:59, Stefan Tomanek wrote: This change adds the configuration option assoc_log_file to hostapd, making it possible to specify a log file to which clients joining and parting the corresponding BSS are written. Every BSS can have an individual log file, and each entry written contains a timestamp, an indicator whether the client is associating (+) or disassociating (-), the client and the bss hardware addresses as well as the device and SSID identifiers of the affected network. This makes it easy to join the file with the leases database of an DHCP server like dnsmasq. To use a logfile with OpenWrt, simply add an assoc_log_file entry to the wireless network: config wifi-iface option device 'radio1' option network 'hotspot' option ssid 'MyNetwork' option mode 'ap' option encryption 'none' option assoc_log_file '/tmp/assoc_log-hotspot' Signed-off-by: Stefan Tomanek stefan.tomanek+open...@wertarbyte.de --- package/network/services/hostapd/files/netifd.sh |7 +- ...rite-client-dis-associations-to-a-logfile.patch | 231 2 files changed, 237 insertions(+), 1 deletions(-) create mode 100644 package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh index ed2a631..be94398 100644 --- a/package/network/services/hostapd/files/netifd.sh +++ b/package/network/services/hostapd/files/netifd.sh @@ -159,6 +159,8 @@ hostapd_common_add_bss_config() { config_add_int mcast_rate config_add_array basic_rate config_add_array supported_rates + + config_add_string assoc_log_file } hostapd_set_bss_options() { @@ -177,7 +179,7 @@ hostapd_set_bss_options() { wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 \ wps_device_type wps_device_name wps_manufacturer wps_pin \ macfilter ssid wmm uapsd hidden short_preamble rsn_preauth \ - iapp_interface + iapp_interface assoc_log_file set_default isolate 0 set_default maxassoc 0 @@ -189,6 +191,9 @@ hostapd_set_bss_options() { set_default uapsd 1 append bss_conf ctrl_interface=/var/run/hostapd + if [ $assoc_log_file ]; then + append bss_conf assoc_log_file=$assoc_log_file $N + fi if [ $isolate -gt 0 ]; then append bss_conf ap_isolate=$isolate $N fi diff --git a/package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch b/package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch new file mode 100644 index 000..7a87529 --- /dev/null +++ b/package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch @@ -0,0 +1,231 @@ +Write client (dis)associations to a logfile + +This change adds the configuration option assoc_log_file to hostapd, making +it possible to specify a log file to which clients joining and parting the +corresponding BSS are written. + +Every BSS can have an individual log file, and each entry written contains a +timestamp, an indicator whether the client is associating (+) or disassociating +(-), the client and the bss hardware addresses as well as the device and SSID +identifiers of the affected network. This makes it easy to join the file with +the leases database of an DHCP server like dnsmasq. +--- + hostapd/config_file.c | 3 +++ + hostapd/hostapd.conf | 3 +++ + hostapd/main.c| 6 ++ + src/ap/ap_config.c| 27 +++ + src/ap/ap_config.h| 5 + + src/ap/ap_mlme.c | 26 ++ + src/ap/hostapd.c | 4 + src/ap/hostapd.h | 2 ++ + 8 files changed, 76 insertions(+) + +diff --git a/hostapd/config_file.c b/hostapd/config_file.c +index ddebf1f..827f9b4 100644 +--- a/hostapd/config_file.c b/hostapd/config_file.c +@@ -1876,6 +1876,9 @@ static int hostapd_config_fill(struct hostapd_config *conf, + bss-logger_syslog = atoi(pos); + } else if (os_strcmp(buf, logger_stdout) == 0) { + bss-logger_stdout = atoi(pos); ++} else if (os_strcmp(buf, assoc_log_file) == 0) { ++os_free(bss-assoc_log_file); ++bss-assoc_log_file = os_strdup(pos); + } else if (os_strcmp(buf, dump_file) == 0) { + wpa_printf(MSG_INFO, Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore, +line); +diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf +index 2e6f841..31b2193 100644 +--- a/hostapd/hostapd.conf b/hostapd/hostapd.conf +@@ -51,6 +51,9 @@ logger_syslog_level=2 + logger_stdout=-1 + logger_stdout_level=2 + ++# Clients joining
[OpenWrt-Devel] [PATCH] hostapd: Add client association log file
This change adds the configuration option assoc_log_file to hostapd, making it possible to specify a log file to which clients joining and parting the corresponding BSS are written. Every BSS can have an individual log file, and each entry written contains a timestamp, an indicator whether the client is associating (+) or disassociating (-), the client and the bss hardware addresses as well as the device and SSID identifiers of the affected network. This makes it easy to join the file with the leases database of an DHCP server like dnsmasq. To use a logfile with OpenWrt, simply add an assoc_log_file entry to the wireless network: config wifi-iface option device 'radio1' option network 'hotspot' option ssid 'MyNetwork' option mode 'ap' option encryption 'none' option assoc_log_file '/tmp/assoc_log-hotspot' Signed-off-by: Stefan Tomanek stefan.tomanek+open...@wertarbyte.de --- package/network/services/hostapd/files/netifd.sh |7 +- ...rite-client-dis-associations-to-a-logfile.patch | 231 2 files changed, 237 insertions(+), 1 deletions(-) create mode 100644 package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh index ed2a631..be94398 100644 --- a/package/network/services/hostapd/files/netifd.sh +++ b/package/network/services/hostapd/files/netifd.sh @@ -159,6 +159,8 @@ hostapd_common_add_bss_config() { config_add_int mcast_rate config_add_array basic_rate config_add_array supported_rates + + config_add_string assoc_log_file } hostapd_set_bss_options() { @@ -177,7 +179,7 @@ hostapd_set_bss_options() { wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 \ wps_device_type wps_device_name wps_manufacturer wps_pin \ macfilter ssid wmm uapsd hidden short_preamble rsn_preauth \ - iapp_interface + iapp_interface assoc_log_file set_default isolate 0 set_default maxassoc 0 @@ -189,6 +191,9 @@ hostapd_set_bss_options() { set_default uapsd 1 append bss_conf ctrl_interface=/var/run/hostapd + if [ $assoc_log_file ]; then + append bss_conf assoc_log_file=$assoc_log_file $N + fi if [ $isolate -gt 0 ]; then append bss_conf ap_isolate=$isolate $N fi diff --git a/package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch b/package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch new file mode 100644 index 000..7a87529 --- /dev/null +++ b/package/network/services/hostapd/patches/720-Write-client-dis-associations-to-a-logfile.patch @@ -0,0 +1,231 @@ +Write client (dis)associations to a logfile + +This change adds the configuration option assoc_log_file to hostapd, making +it possible to specify a log file to which clients joining and parting the +corresponding BSS are written. + +Every BSS can have an individual log file, and each entry written contains a +timestamp, an indicator whether the client is associating (+) or disassociating +(-), the client and the bss hardware addresses as well as the device and SSID +identifiers of the affected network. This makes it easy to join the file with +the leases database of an DHCP server like dnsmasq. +--- + hostapd/config_file.c | 3 +++ + hostapd/hostapd.conf | 3 +++ + hostapd/main.c| 6 ++ + src/ap/ap_config.c| 27 +++ + src/ap/ap_config.h| 5 + + src/ap/ap_mlme.c | 26 ++ + src/ap/hostapd.c | 4 + src/ap/hostapd.h | 2 ++ + 8 files changed, 76 insertions(+) + +diff --git a/hostapd/config_file.c b/hostapd/config_file.c +index ddebf1f..827f9b4 100644 +--- a/hostapd/config_file.c b/hostapd/config_file.c +@@ -1876,6 +1876,9 @@ static int hostapd_config_fill(struct hostapd_config *conf, + bss-logger_syslog = atoi(pos); + } else if (os_strcmp(buf, logger_stdout) == 0) { + bss-logger_stdout = atoi(pos); ++ } else if (os_strcmp(buf, assoc_log_file) == 0) { ++ os_free(bss-assoc_log_file); ++ bss-assoc_log_file = os_strdup(pos); + } else if (os_strcmp(buf, dump_file) == 0) { + wpa_printf(MSG_INFO, Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore, + line); +diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf +index 2e6f841..31b2193 100644 +--- a/hostapd/hostapd.conf b/hostapd/hostapd.conf +@@ -51,6 +51,9 @@ logger_syslog_level=2 + logger_stdout=-1 + logger_stdout_level=2 + ++# Clients joining or departing the AP can be logged to a separate file. ++assoc_log_file=/tmp/assoc_log-wlan0 ++ + # Interface for separate control program. If this is