summaryrefslogtreecommitdiff
path: root/usr.sbin/hostapd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2005-11-16 00:01:20 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2005-11-16 00:01:20 +0000
commitf107fd127d1e8d610de6fece78f1f18af52b6afb (patch)
tree96036af4d84d2be977e6c5395747bbdde6020800 /usr.sbin/hostapd
parent5c7cfd2c78dcdf4749d1e97e14cc38ad27228f23 (diff)
add a configuration option for specifying a non-standard port and multicast
address for the IAPP messages. this is an initial approach to run multiple hostapds on one machine, further work will be done later.
Diffstat (limited to 'usr.sbin/hostapd')
-rw-r--r--usr.sbin/hostapd/hostapd.c22
-rw-r--r--usr.sbin/hostapd/hostapd.conf.58
-rw-r--r--usr.sbin/hostapd/parse.y25
3 files changed, 39 insertions, 16 deletions
diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c
index af11614042a..d86c3507ad4 100644
--- a/usr.sbin/hostapd/hostapd.c
+++ b/usr.sbin/hostapd/hostapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.c,v 1.21 2005/10/07 22:32:52 reyk Exp $ */
+/* $OpenBSD: hostapd.c,v 1.22 2005/11/16 00:01:19 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -223,7 +223,8 @@ hostapd_udp_init(struct hostapd_config *cfg)
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;
- cfg->c_iapp_addr.sin_port = htons(IAPP_PORT);
+ if (cfg->c_iapp_addr.sin_port == 0)
+ cfg->c_iapp_addr.sin_port = htons(IAPP_PORT);
if (ioctl(cfg->c_iapp_udp, SIOCGIFBRDADDR, &ifr) == -1)
hostapd_fatal("UDP ioctl %s on \"%s\" failed: %s\n",
@@ -232,11 +233,11 @@ hostapd_udp_init(struct hostapd_config *cfg)
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 = htons(IAPP_PORT);
+ cfg->c_iapp_broadcast.sin_port = cfg->c_iapp_addr.sin_port;
baddr.sin_family = AF_INET;
baddr.sin_addr.s_addr = htonl(INADDR_ANY);
- baddr.sin_port = htons(IAPP_PORT);
+ baddr.sin_port = cfg->c_iapp_addr.sin_port;
if (bind(cfg->c_iapp_udp, (struct sockaddr *)&baddr,
sizeof(baddr)) == -1)
@@ -245,9 +246,9 @@ hostapd_udp_init(struct hostapd_config *cfg)
/*
* The revised 802.11F standard requires IAPP messages to be
- * sent via multicast to the group 224.0.1.178. Nevertheless,
- * some implementations still use broadcasts for IAPP
- * messages.
+ * sent via multicast to the default group 224.0.1.178.
+ * Nevertheless, some implementations still use broadcasts
+ * for IAPP messages.
*/
if (cfg->c_flags & HOSTAPD_CFG_F_BRDCAST) {
/*
@@ -269,9 +270,10 @@ hostapd_udp_init(struct hostapd_config *cfg)
bzero(&mreq, sizeof(mreq));
cfg->c_iapp_multicast.sin_family = AF_INET;
- cfg->c_iapp_multicast.sin_addr.s_addr =
- inet_addr(IAPP_MCASTADDR);
- cfg->c_iapp_multicast.sin_port = htons(IAPP_PORT);
+ if (cfg->c_iapp_multicast.sin_addr.s_addr == INADDR_ANY)
+ cfg->c_iapp_multicast.sin_addr.s_addr =
+ inet_addr(IAPP_MCASTADDR);
+ cfg->c_iapp_multicast.sin_port = cfg->c_iapp_addr.sin_port;
mreq.imr_multiaddr.s_addr =
cfg->c_iapp_multicast.sin_addr.s_addr;
diff --git a/usr.sbin/hostapd/hostapd.conf.5 b/usr.sbin/hostapd/hostapd.conf.5
index ffdc8ec5105..2d6a351f691 100644
--- a/usr.sbin/hostapd/hostapd.conf.5
+++ b/usr.sbin/hostapd/hostapd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: hostapd.conf.5,v 1.17 2005/10/15 08:18:32 jmc Exp $
+.\" $OpenBSD: hostapd.conf.5,v 1.18 2005/11/16 00:01:19 reyk Exp $
.\"
.\" Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
.\"
@@ -134,13 +134,15 @@ The supported modes are:
.Pp
.Bl -tag -width broadcast -offset indent -compact
.It Ic multicast
+.Op Ic address Ar ipv4addr
+.Op Ic port Ar number
Use multicast frames.
.It Ic broadcast
+.Op Ic port Ar number
Use broadcast frames.
.El
.Pp
-The default is multicast.
-The multicast group used is 224.0.1.178.
+The default is multicast using the multicast address 224.0.1.178.
.El
.Sh EVENT RULES
Event rules provide a powerful way to trigger a certain action when
diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y
index 31697a4c1b2..8bbc0e25b32 100644
--- a/usr.sbin/hostapd/parse.y
+++ b/usr.sbin/hostapd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.11 2005/09/30 16:50:03 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.12 2005/11/16 00:01:19 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -123,6 +123,7 @@ u_int negative;
%token ERROR CONST TABLE NODE DELETE ADD LOG VERBOSE LIMIT QUICK SKIP
%token REASON UNSPECIFIED EXPIRE LEAVE ASSOC TOOMANY NOT AUTHED ASSOCED
%token RESERVED RSN REQUIRED INCONSISTENT IE INVALID MIC FAILURE OPEN
+%token ADDRESS PORT
%token <v.string> STRING
%token <v.val> VALUE
%type <v.val> number
@@ -177,16 +178,31 @@ option : SET HOSTAP INTERFACE STRING
| SET IAPP MODE iappmode
;
-iappmode : MULTICAST
+iappmode : MULTICAST iappmodeaddr iappmodeport
{
hostapd_cfg.c_flags &= ~HOSTAPD_CFG_F_BRDCAST;
}
- | BROADCAST
+ | BROADCAST iappmodeport
{
hostapd_cfg.c_flags |= HOSTAPD_CFG_F_BRDCAST;
}
;
+iappmodeaddr : /* empty */
+ | ADDRESS ipv4addr
+ {
+ bcopy(&$2, &hostapd_cfg.c_iapp_multicast.sin_addr,
+ sizeof(struct in_addr));
+ }
+ ;
+
+iappmodeport : /* empty */
+ | PORT number
+ {
+ hostapd_cfg.c_iapp_addr.sin_port = htons($2);
+ }
+ ;
+
hostapmode : RADIOTAP
{
hostapd_cfg.c_apme_dlt = DLT_IEEE802_11_RADIO;
@@ -882,6 +898,7 @@ lookup(char *token)
/* Keep this list sorted */
static const struct keywords keywords[] = {
{ "add", ADD },
+ { "address", ADDRESS },
{ "any", ANY },
{ "assoc", ASSOC },
{ "assoced", ASSOCED },
@@ -923,6 +940,7 @@ lookup(char *token)
{ "open", OPEN },
{ "passive", PASSIVE },
{ "pcap", PCAP },
+ { "port", PORT },
{ "probe", PROBE },
{ "quick", QUICK },
{ "radiotap", RADIOTAP },
@@ -1241,6 +1259,7 @@ hostapd_parse_file(struct hostapd_config *cfg)
/* Init tables and data structures */
TAILQ_INIT(&cfg->c_tables);
TAILQ_INIT(&cfg->c_frames);
+ cfg->c_iapp_multicast.sin_addr.s_addr = INADDR_ANY;
lineno = 1;
errors = 0;