summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2005-12-01 01:11:31 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2005-12-01 01:11:31 +0000
commitd3f81cc9daa83c281602dc9cb7188d1074bcfc89 (patch)
tree65594674afed608ca95b793a733e0da920c2d90c
parent50f672c3d16ad331c278a65643b9808bb7cf1075 (diff)
move iapp configuration in a separate data structure
-rw-r--r--usr.sbin/hostapd/apme.c14
-rw-r--r--usr.sbin/hostapd/handle.c5
-rw-r--r--usr.sbin/hostapd/hostapd.c63
-rw-r--r--usr.sbin/hostapd/hostapd.h24
-rw-r--r--usr.sbin/hostapd/iapp.c39
-rw-r--r--usr.sbin/hostapd/llc.c20
-rw-r--r--usr.sbin/hostapd/parse.y12
-rw-r--r--usr.sbin/hostapd/privsep.c13
8 files changed, 106 insertions, 84 deletions
diff --git a/usr.sbin/hostapd/apme.c b/usr.sbin/hostapd/apme.c
index 11ea738de36..32b67b93856 100644
--- a/usr.sbin/hostapd/apme.c
+++ b/usr.sbin/hostapd/apme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apme.c,v 1.7 2005/12/01 00:36:41 reyk Exp $ */
+/* $OpenBSD: apme.c,v 1.8 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -73,6 +73,7 @@ int
hostapd_apme_deauth(struct hostapd_apme *apme)
{
struct hostapd_config *cfg = (struct hostapd_config *)apme->a_cfg;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
u_int8_t buf[sizeof(struct ieee80211_frame) + sizeof(u_int16_t)];
struct ieee80211_frame *wh;
@@ -89,14 +90,14 @@ hostapd_apme_deauth(struct hostapd_apme *apme)
if (write(apme->a_raw, buf, sizeof(buf)) == -1) {
hostapd_log(HOSTAPD_LOG_VERBOSE,
"%s/%s: failed to deauthenticate all stations: %s\n",
- cfg->c_iapp_iface, apme->a_iface,
+ iapp->i_iface, apme->a_iface,
strerror(errno));
return (EIO);
}
hostapd_log(HOSTAPD_LOG_VERBOSE,
"%s/%s: deauthenticated all stations\n",
- apme->a_iface, cfg->c_iapp_iface);
+ apme->a_iface, iapp->i_iface);
return (0);
}
@@ -119,14 +120,15 @@ hostapd_apme_term(struct hostapd_apme *apme)
{
struct hostapd_config *cfg = (struct hostapd_config *)apme->a_cfg;
- hostapd_log(HOSTAPD_LOG_DEBUG,
- "%s: Host AP interface removed\n", apme->a_iface);
-
/* Kick a specified Host AP interface */
event_del(&apme->a_ev);
close(apme->a_raw);
TAILQ_REMOVE(&cfg->c_apmes, apme, a_entries);
+
+ hostapd_log(HOSTAPD_LOG_DEBUG,
+ "%s: Host AP interface removed\n", apme->a_iface);
+
free(apme);
}
diff --git a/usr.sbin/hostapd/handle.c b/usr.sbin/hostapd/handle.c
index 656b3beeffb..2dc80997cac 100644
--- a/usr.sbin/hostapd/handle.c
+++ b/usr.sbin/hostapd/handle.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: handle.c,v 1.6 2005/11/23 20:40:38 reyk Exp $ */
+/* $OpenBSD: handle.c,v 1.7 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2005 Reyk Floeter <reyk@vantronix.net>
@@ -245,6 +245,7 @@ hostapd_handle_action(struct hostapd_apme *apme, struct hostapd_frame *frame,
const u_int len)
{
struct hostapd_config *cfg = (struct hostapd_config *)apme->a_cfg;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct hostapd_action_data *action = &frame->f_action_data;
struct hostapd_node node;
u_int8_t *lladdr = NULL;
@@ -261,7 +262,7 @@ hostapd_handle_action(struct hostapd_apme *apme, struct hostapd_frame *frame,
hostapd_log(HOSTAPD_LOG,
"%s: sent IAPP frame HOSTAPD_%s (%u bytes)\n",
- cfg->c_iapp_iface, cfg->c_apme_dlt ==
+ iapp->i_iface, cfg->c_apme_dlt ==
DLT_IEEE802_11_RADIO ? "RADIOTAP" : "PCAP", len);
break;
diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c
index 3a080ce9f93..81a08942526 100644
--- a/usr.sbin/hostapd/hostapd.c
+++ b/usr.sbin/hostapd/hostapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.c,v 1.23 2005/11/20 12:02:04 reyk Exp $ */
+/* $OpenBSD: hostapd.c,v 1.24 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -198,6 +198,7 @@ hostapd_bpf_open(u_int flags)
void
hostapd_udp_init(struct hostapd_config *cfg)
{
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct ifreq ifr;
struct sockaddr_in *addr, baddr;
struct ip_mreq mreq;
@@ -209,37 +210,37 @@ hostapd_udp_init(struct hostapd_config *cfg)
* Open a listening UDP socket
*/
- if ((cfg->c_iapp_udp = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ if ((iapp->i_udp = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
hostapd_fatal("unable to open udp socket\n");
cfg->c_flags |= HOSTAPD_CFG_F_UDP;
- strlcpy(ifr.ifr_name, cfg->c_iapp_iface, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, iapp->i_iface, sizeof(ifr.ifr_name));
- if (ioctl(cfg->c_iapp_udp, SIOCGIFADDR, &ifr) == -1)
+ if (ioctl(iapp->i_udp, SIOCGIFADDR, &ifr) == -1)
hostapd_fatal("UDP ioctl %s on \"%s\" failed: %s\n",
"SIOCGIFADDR", ifr.ifr_name, strerror(errno));
addr = (struct sockaddr_in *)&ifr.ifr_addr;
- cfg->c_iapp_addr.sin_family = AF_INET;
- cfg->c_iapp_addr.sin_addr.s_addr = addr->sin_addr.s_addr;
- if (cfg->c_iapp_addr.sin_port == 0)
- cfg->c_iapp_addr.sin_port = htons(IAPP_PORT);
+ iapp->i_addr.sin_family = AF_INET;
+ iapp->i_addr.sin_addr.s_addr = addr->sin_addr.s_addr;
+ if (iapp->i_addr.sin_port == 0)
+ iapp->i_addr.sin_port = htons(IAPP_PORT);
- if (ioctl(cfg->c_iapp_udp, SIOCGIFBRDADDR, &ifr) == -1)
+ if (ioctl(iapp->i_udp, SIOCGIFBRDADDR, &ifr) == -1)
hostapd_fatal("UDP ioctl %s on \"%s\" failed: %s\n",
"SIOCGIFBRDADDR", ifr.ifr_name, strerror(errno));
addr = (struct sockaddr_in *)&ifr.ifr_addr;
- cfg->c_iapp_broadcast.sin_family = AF_INET;
- cfg->c_iapp_broadcast.sin_addr.s_addr = addr->sin_addr.s_addr;
- cfg->c_iapp_broadcast.sin_port = cfg->c_iapp_addr.sin_port;
+ iapp->i_broadcast.sin_family = AF_INET;
+ iapp->i_broadcast.sin_addr.s_addr = addr->sin_addr.s_addr;
+ iapp->i_broadcast.sin_port = iapp->i_addr.sin_port;
baddr.sin_family = AF_INET;
baddr.sin_addr.s_addr = htonl(INADDR_ANY);
- baddr.sin_port = cfg->c_iapp_addr.sin_port;
+ baddr.sin_port = iapp->i_addr.sin_port;
- if (bind(cfg->c_iapp_udp, (struct sockaddr *)&baddr,
+ if (bind(iapp->i_udp, (struct sockaddr *)&baddr,
sizeof(baddr)) == -1)
hostapd_fatal("failed to bind UDP socket: %s\n",
strerror(errno));
@@ -257,7 +258,7 @@ hostapd_udp_init(struct hostapd_config *cfg)
hostapd_log(HOSTAPD_LOG_DEBUG, "using broadcast mode\n");
- if (setsockopt(cfg->c_iapp_udp, SOL_SOCKET, SO_BROADCAST,
+ if (setsockopt(iapp->i_udp, SOL_SOCKET, SO_BROADCAST,
&brd, sizeof(brd)) == -1)
hostapd_fatal("failed to enable broadcast on socket\n");
} else {
@@ -269,18 +270,18 @@ hostapd_udp_init(struct hostapd_config *cfg)
bzero(&mreq, sizeof(mreq));
- cfg->c_iapp_multicast.sin_family = AF_INET;
- if (cfg->c_iapp_multicast.sin_addr.s_addr == INADDR_ANY)
- cfg->c_iapp_multicast.sin_addr.s_addr =
+ iapp->i_multicast.sin_family = AF_INET;
+ if (iapp->i_multicast.sin_addr.s_addr == INADDR_ANY)
+ iapp->i_multicast.sin_addr.s_addr =
inet_addr(IAPP_MCASTADDR);
- cfg->c_iapp_multicast.sin_port = cfg->c_iapp_addr.sin_port;
+ iapp->i_multicast.sin_port = iapp->i_addr.sin_port;
mreq.imr_multiaddr.s_addr =
- cfg->c_iapp_multicast.sin_addr.s_addr;
+ iapp->i_multicast.sin_addr.s_addr;
mreq.imr_interface.s_addr =
- cfg->c_iapp_addr.sin_addr.s_addr;
+ iapp->i_addr.sin_addr.s_addr;
- if (setsockopt(cfg->c_iapp_udp, IPPROTO_IP,
+ if (setsockopt(iapp->i_udp, IPPROTO_IP,
IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) == -1)
hostapd_fatal("failed to add multicast membership to "
"%s: %s\n", IAPP_MCASTADDR, strerror(errno));
@@ -307,6 +308,7 @@ hostapd_sig_handler(int sig)
void
hostapd_cleanup(struct hostapd_config *cfg)
{
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct ip_mreq mreq;
struct hostapd_apme *apme;
struct hostapd_table *table;
@@ -330,9 +332,9 @@ hostapd_cleanup(struct hostapd_config *cfg)
mreq.imr_multiaddr.s_addr =
inet_addr(IAPP_MCASTADDR);
mreq.imr_interface.s_addr =
- cfg->c_iapp_addr.sin_addr.s_addr;
+ iapp->i_addr.sin_addr.s_addr;
- if (setsockopt(cfg->c_iapp_udp, IPPROTO_IP,
+ if (setsockopt(iapp->i_udp, IPPROTO_IP,
IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) == -1)
hostapd_log(HOSTAPD_LOG, "failed to remove multicast"
" membership to %s: %s\n",
@@ -366,6 +368,7 @@ int
main(int argc, char *argv[])
{
struct hostapd_config *cfg = &hostapd_cfg;
+ struct hostapd_iapp *iapp;
struct hostapd_apme *apme;
char *config = NULL;
u_int debug = 0;
@@ -410,6 +413,8 @@ main(int argc, char *argv[])
if (hostapd_parse_file(cfg) != 0)
hostapd_fatal("invalid configuration in %s\n", cfg->c_config);
+ iapp = &cfg->c_iapp;
+
if ((cfg->c_flags & HOSTAPD_CFG_F_IAPP) == 0)
hostapd_fatal("IAPP interface not specified\n");
@@ -435,15 +440,15 @@ main(int argc, char *argv[])
hostapd_apme_init(apme);
} else
hostapd_log(HOSTAPD_LOG, "%s: running without a Host AP\n",
- cfg->c_iapp_iface);
+ iapp->i_iface);
/* Drop all privileges in an unprivileged child process */
hostapd_priv_init(cfg);
if (cfg->c_flags & HOSTAPD_CFG_F_APME)
- setproctitle("IAPP: %s, Host AP", cfg->c_iapp_iface);
+ setproctitle("IAPP: %s, Host AP", iapp->i_iface);
else
- setproctitle("IAPP: %s", cfg->c_iapp_iface);
+ setproctitle("IAPP: %s", iapp->i_iface);
/*
* Unprivileged child process
@@ -478,9 +483,9 @@ main(int argc, char *argv[])
/*
* Schedule the IAPP listener
*/
- event_set(&cfg->c_iapp_udp_ev, cfg->c_iapp_udp, EV_READ | EV_PERSIST,
+ event_set(&iapp->i_udp_ev, iapp->i_udp, EV_READ | EV_PERSIST,
hostapd_iapp_input, cfg);
- event_add(&cfg->c_iapp_udp_ev, NULL);
+ event_add(&iapp->i_udp_ev, NULL);
hostapd_log(HOSTAPD_LOG, "starting hostapd with pid %u\n",
getpid());
diff --git a/usr.sbin/hostapd/hostapd.h b/usr.sbin/hostapd/hostapd.h
index 153447049d6..376c3404f56 100644
--- a/usr.sbin/hostapd/hostapd.h
+++ b/usr.sbin/hostapd/hostapd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.h,v 1.11 2005/12/01 00:36:41 reyk Exp $ */
+/* $OpenBSD: hostapd.h,v 1.12 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -240,19 +240,23 @@ struct hostapd_apme {
TAILQ_ENTRY(hostapd_apme) a_entries;
};
+struct hostapd_iapp {
+ u_int16_t i_cnt;
+ int i_raw;
+ char i_iface[IFNAMSIZ];
+ int i_udp;
+ struct event i_udp_ev;
+ u_int16_t i_udp_port;
+ struct sockaddr_in i_addr;
+ struct sockaddr_in i_broadcast;
+ struct sockaddr_in i_multicast;
+};
+
struct hostapd_config {
int c_apme_ctl;
u_int c_apme_dlt;
- u_int16_t c_iapp;
- int c_iapp_raw;
- char c_iapp_iface[IFNAMSIZ];
- int c_iapp_udp;
- struct event c_iapp_udp_ev;
- u_int16_t c_iapp_udp_port;
- struct sockaddr_in c_iapp_addr;
- struct sockaddr_in c_iapp_broadcast;
- struct sockaddr_in c_iapp_multicast;
+ struct hostapd_iapp c_iapp;
u_int8_t c_flags;
diff --git a/usr.sbin/hostapd/iapp.c b/usr.sbin/hostapd/iapp.c
index 8fdcd972373..0c723cc1123 100644
--- a/usr.sbin/hostapd/iapp.c
+++ b/usr.sbin/hostapd/iapp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iapp.c,v 1.11 2005/12/01 00:36:41 reyk Exp $ */
+/* $OpenBSD: iapp.c,v 1.12 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -46,6 +46,7 @@ void
hostapd_iapp_init(struct hostapd_config *cfg)
{
struct hostapd_apme *apme;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
if ((cfg->c_flags & HOSTAPD_CFG_F_APME) == 0)
return;
@@ -55,7 +56,7 @@ hostapd_iapp_init(struct hostapd_config *cfg)
hostapd_priv_apme_bssid(apme);
hostapd_log(HOSTAPD_LOG,
"%s/%s: attached Host AP interface with BSSID %s\n",
- apme->a_iface, cfg->c_iapp_iface,
+ apme->a_iface, iapp->i_iface,
etheraddr_string(apme->a_bssid));
/* Deauthenticate all stations on startup */
@@ -67,6 +68,7 @@ void
hostapd_iapp_term(struct hostapd_config *cfg)
{
struct hostapd_apme *apme;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
if ((cfg->c_flags & HOSTAPD_CFG_F_APME) == 0)
return;
@@ -74,7 +76,7 @@ hostapd_iapp_term(struct hostapd_config *cfg)
TAILQ_FOREACH(apme, &cfg->c_apmes, a_entries) {
hostapd_log(HOSTAPD_LOG_VERBOSE,
"%s/%s: detaching from Host AP\n",
- apme->a_iface, cfg->c_iapp_iface);
+ apme->a_iface, iapp->i_iface);
}
}
@@ -82,6 +84,7 @@ int
hostapd_iapp_add_notify(struct hostapd_apme *apme, struct hostapd_node *node)
{
struct hostapd_config *cfg = (struct hostapd_config *)apme->a_cfg;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct sockaddr_in *addr;
struct {
struct ieee80211_iapp_frame hdr;
@@ -96,7 +99,7 @@ hostapd_iapp_add_notify(struct hostapd_apme *apme, struct hostapd_node *node)
frame.hdr.i_version = IEEE80211_IAPP_VERSION;
frame.hdr.i_command = IEEE80211_IAPP_FRAME_ADD_NOTIFY;
- frame.hdr.i_identifier = htons(cfg->c_iapp++);
+ frame.hdr.i_identifier = htons(iapp->i_cnt++);
frame.hdr.i_length = sizeof(struct ieee80211_iapp_add_notify);
frame.add.a_length = IEEE80211_ADDR_LEN;
@@ -104,20 +107,20 @@ hostapd_iapp_add_notify(struct hostapd_apme *apme, struct hostapd_node *node)
bcopy(node->ni_macaddr, frame.add.a_macaddr, IEEE80211_ADDR_LEN);
if (cfg->c_flags & HOSTAPD_CFG_F_BRDCAST)
- addr = &cfg->c_iapp_broadcast;
+ addr = &iapp->i_broadcast;
else
- addr = &cfg->c_iapp_multicast;
+ addr = &iapp->i_multicast;
- if (sendto(cfg->c_iapp_udp, &frame, sizeof(frame),
+ if (sendto(iapp->i_udp, &frame, sizeof(frame),
0, (struct sockaddr *)addr, sizeof(struct sockaddr_in)) == -1) {
hostapd_log(HOSTAPD_LOG,
"%s: failed to send ADD notification: %s\n",
- cfg->c_iapp_iface, strerror(errno));
+ iapp->i_iface, strerror(errno));
return (errno);
}
hostapd_log(HOSTAPD_LOG, "%s/%s: sent ADD notification for %s\n",
- apme->a_iface, cfg->c_iapp_iface,
+ apme->a_iface, iapp->i_iface,
etheraddr_string(frame.add.a_macaddr));
/* Send a LLC XID frame, see llc.c for details */
@@ -129,6 +132,7 @@ hostapd_iapp_radiotap(struct hostapd_apme *apme, u_int8_t *buf,
const u_int len)
{
struct hostapd_config *cfg = (struct hostapd_config *)apme->a_cfg;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct sockaddr_in *addr;
struct ieee80211_iapp_frame hdr;
struct msghdr msg;
@@ -148,13 +152,13 @@ hostapd_iapp_radiotap(struct hostapd_apme *apme, u_int8_t *buf,
hdr.i_command = IEEE80211_IAPP_FRAME_HOSTAPD_PCAP;
else
return (EINVAL);
- hdr.i_identifier = htons(cfg->c_iapp++);
+ hdr.i_identifier = htons(iapp->i_cnt++);
hdr.i_length = len;
if (cfg->c_flags & HOSTAPD_CFG_F_BRDCAST)
- addr = &cfg->c_iapp_broadcast;
+ addr = &iapp->i_broadcast;
else
- addr = &cfg->c_iapp_multicast;
+ addr = &iapp->i_multicast;
iov[0].iov_base = &hdr;
iov[0].iov_len = sizeof(hdr);
@@ -168,10 +172,10 @@ hostapd_iapp_radiotap(struct hostapd_apme *apme, u_int8_t *buf,
msg.msg_controllen = 0;
msg.msg_flags = 0;
- if (sendmsg(cfg->c_iapp_udp, &msg, 0) == -1) {
+ if (sendmsg(iapp->i_udp, &msg, 0) == -1) {
hostapd_log(HOSTAPD_LOG,
"%s: failed to send HOSTAPD %s: %s\n",
- cfg->c_iapp_iface, cfg->c_apme_dlt ==
+ iapp->i_iface, cfg->c_apme_dlt ==
DLT_IEEE802_11_RADIO ? "radiotap" : "pcap",
strerror(errno));
return (errno);
@@ -184,6 +188,7 @@ void
hostapd_iapp_input(int fd, short sig, void *arg)
{
struct hostapd_config *cfg = (struct hostapd_config *)arg;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct hostapd_apme *apme;
struct sockaddr_in addr;
socklen_t addr_len;
@@ -213,7 +218,7 @@ hostapd_iapp_input(int fd, short sig, void *arg)
(struct sockaddr*)&addr, &addr_len)) < 1)
return;
- if (bcmp(&cfg->c_iapp_addr.sin_addr, &addr.sin_addr,
+ if (bcmp(&iapp->i_addr.sin_addr, &addr.sin_addr,
sizeof(addr.sin_addr)) == 0)
return;
@@ -261,7 +266,7 @@ hostapd_iapp_input(int fd, short sig, void *arg)
hostapd_log(HOSTAPD_LOG, "%s: %s ADD notification "
"for %s at %s\n",
- cfg->c_iapp_iface, ret == 0 ?
+ iapp->i_iface, ret == 0 ?
"received" : "ignored",
etheraddr_string(node.ni_macaddr),
inet_ntoa(addr.sin_addr));
@@ -295,7 +300,7 @@ hostapd_iapp_input(int fd, short sig, void *arg)
hostapd_log(HOSTAPD_LOG_VERBOSE,
"%s: received unsupported IAPP message %d\n",
- cfg->c_iapp_iface, frame->hdr.i_command);
+ iapp->i_iface, frame->hdr.i_command);
return;
default:
diff --git a/usr.sbin/hostapd/llc.c b/usr.sbin/hostapd/llc.c
index 2aca90d250d..81684874ead 100644
--- a/usr.sbin/hostapd/llc.c
+++ b/usr.sbin/hostapd/llc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: llc.c,v 1.2 2005/04/13 20:25:31 deraadt Exp $ */
+/* $OpenBSD: llc.c,v 1.3 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -44,34 +44,36 @@
void
hostapd_llc_init(struct hostapd_config *cfg)
{
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct ifreq ifr;
u_int i;
- cfg->c_iapp_raw = hostapd_bpf_open(O_WRONLY);
+ iapp->i_raw = hostapd_bpf_open(O_WRONLY);
cfg->c_flags |= HOSTAPD_CFG_F_RAW;
bzero(&ifr, sizeof(struct ifreq));
- strlcpy(ifr.ifr_name, cfg->c_iapp_iface, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, iapp->i_iface, sizeof(ifr.ifr_name));
/* Associate the wired network interface to the BPF descriptor */
- if (ioctl(cfg->c_iapp_raw, BIOCSETIF, &ifr) == -1)
+ if (ioctl(iapp->i_raw, BIOCSETIF, &ifr) == -1)
hostapd_fatal("failed to set BPF interface \"%s\": %s\n",
- cfg->c_iapp_iface, strerror(errno));
+ iapp->i_iface, strerror(errno));
i = 1;
- if (ioctl(cfg->c_iapp_raw, BIOCSHDRCMPLT, &i) == -1)
+ if (ioctl(iapp->i_raw, BIOCSHDRCMPLT, &i) == -1)
hostapd_fatal("failed to set BPF header completion: %s\n",
strerror(errno));
/* Lock the BPF descriptor, no further configuration */
- if (ioctl(cfg->c_iapp_raw, BIOCLOCK, NULL) == -1)
+ if (ioctl(iapp->i_raw, BIOCLOCK, NULL) == -1)
hostapd_fatal("failed to lock BPF interface on \"%s\": %s\n",
- cfg->c_iapp_iface, strerror(errno));
+ iapp->i_iface, strerror(errno));
}
int
hostapd_llc_send_xid(struct hostapd_config *cfg, struct hostapd_node *node)
{
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
struct hostapd_llc *llc;
u_int8_t buf[ETHER_HDR_LEN + (LLC_UFRAMELEN * 2)];
@@ -92,7 +94,7 @@ hostapd_llc_send_xid(struct hostapd_config *cfg, struct hostapd_node *node)
llc->x_llc.llc_class = IAPP_LLC_CLASS;
llc->x_llc.llc_window = IAPP_LLC_WINDOW;
- if (write(cfg->c_iapp_raw, &buf, sizeof(buf)) == -1)
+ if (write(iapp->i_raw, &buf, sizeof(buf)) == -1)
return (errno);
return (0);
}
diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y
index 9ef593f411e..d985ec500b9 100644
--- a/usr.sbin/hostapd/parse.y
+++ b/usr.sbin/hostapd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.14 2005/11/23 20:40:38 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.15 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -157,8 +157,8 @@ option : SET HOSTAP INTERFACE hostapifaces
| SET HOSTAP MODE hostapmode
| SET IAPP INTERFACE STRING passive
{
- strlcpy(hostapd_cfg.c_iapp_iface, $4,
- sizeof(hostapd_cfg.c_iapp_iface));
+ strlcpy(hostapd_cfg.c_iapp.i_iface, $4,
+ sizeof(hostapd_cfg.c_iapp.i_iface));
hostapd_cfg.c_flags |= HOSTAPD_CFG_F_IAPP;
@@ -183,7 +183,7 @@ iappmode : MULTICAST iappmodeaddr iappmodeport
iappmodeaddr : /* empty */
| ADDRESS ipv4addr
{
- bcopy(&$2, &hostapd_cfg.c_iapp_multicast.sin_addr,
+ bcopy(&$2, &hostapd_cfg.c_iapp.i_multicast.sin_addr,
sizeof(struct in_addr));
}
;
@@ -191,7 +191,7 @@ iappmodeaddr : /* empty */
iappmodeport : /* empty */
| PORT number
{
- hostapd_cfg.c_iapp_addr.sin_port = htons($2);
+ hostapd_cfg.c_iapp.i_addr.sin_port = htons($2);
}
;
@@ -1286,7 +1286,7 @@ hostapd_parse_file(struct hostapd_config *cfg)
TAILQ_INIT(&cfg->c_apmes);
TAILQ_INIT(&cfg->c_tables);
TAILQ_INIT(&cfg->c_frames);
- cfg->c_iapp_multicast.sin_addr.s_addr = INADDR_ANY;
+ cfg->c_iapp.i_multicast.sin_addr.s_addr = INADDR_ANY;
lineno = 1;
errors = 0;
diff --git a/usr.sbin/hostapd/privsep.c b/usr.sbin/hostapd/privsep.c
index fed76080f6f..0fd4eb9dec0 100644
--- a/usr.sbin/hostapd/privsep.c
+++ b/usr.sbin/hostapd/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.15 2005/11/20 12:02:04 reyk Exp $ */
+/* $OpenBSD: privsep.c,v 1.16 2005/12/01 01:11:30 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -78,6 +78,7 @@ static volatile pid_t child_pid = -1;
void
hostapd_priv_init(struct hostapd_config *cfg)
{
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
int i, socks[2];
struct passwd *pw;
struct servent *se;
@@ -86,9 +87,9 @@ hostapd_priv_init(struct hostapd_config *cfg)
signal(i, SIG_DFL);
if ((se = getservbyname("iapp", "udp")) == NULL) {
- cfg->c_iapp_udp_port = IAPP_PORT;
+ iapp->i_udp_port = IAPP_PORT;
} else
- cfg->c_iapp_udp_port = se->s_port;
+ iapp->i_udp_port = se->s_port;
if ((pw = getpwnam(HOSTAPD_USER)) == NULL)
hostapd_fatal("failed to get user \"%s\"\n", HOSTAPD_USER);
@@ -326,6 +327,7 @@ hostapd_priv_apme_setnode(struct hostapd_apme *apme, struct hostapd_node *node,
int add)
{
struct hostapd_config *cfg = (struct hostapd_config *)apme->a_cfg;
+ struct hostapd_iapp *iapp = &cfg->c_iapp;
int ret, cmd;
if (priv_fd < 0)
@@ -344,8 +346,9 @@ hostapd_priv_apme_setnode(struct hostapd_apme *apme, struct hostapd_node *node,
hostapd_must_read(priv_fd, &ret, sizeof(int));
if (ret == 0)
- hostapd_log(HOSTAPD_LOG, "%s: %s node %s\n",
- apme->a_iface, add ? "added" : "removed",
+ hostapd_log(HOSTAPD_LOG_VERBOSE, "%s/%s: %s node %s\n",
+ apme->a_iface, iapp->i_iface,
+ add ? "added" : "removed",
etheraddr_string(node->ni_macaddr));
return (ret);