summaryrefslogtreecommitdiff
path: root/usr.sbin/hostapd/iapp.c
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 /usr.sbin/hostapd/iapp.c
parent50f672c3d16ad331c278a65643b9808bb7cf1075 (diff)
move iapp configuration in a separate data structure
Diffstat (limited to 'usr.sbin/hostapd/iapp.c')
-rw-r--r--usr.sbin/hostapd/iapp.c39
1 files changed, 22 insertions, 17 deletions
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: