summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/hostapd/hostapd.c20
-rw-r--r--usr.sbin/hostapd/hostapd.conf.59
-rw-r--r--usr.sbin/hostapd/hostapd.h3
-rw-r--r--usr.sbin/hostapd/parse.y15
4 files changed, 34 insertions, 13 deletions
diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c
index 81a08942526..595a2384821 100644
--- a/usr.sbin/hostapd/hostapd.c
+++ b/usr.sbin/hostapd/hostapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.c,v 1.24 2005/12/01 01:11:30 reyk Exp $ */
+/* $OpenBSD: hostapd.c,v 1.25 2005/12/10 13:42:37 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -255,19 +255,16 @@ hostapd_udp_init(struct hostapd_config *cfg)
/*
* Enable broadcast
*/
-
- hostapd_log(HOSTAPD_LOG_DEBUG, "using broadcast mode\n");
-
if (setsockopt(iapp->i_udp, SOL_SOCKET, SO_BROADCAST,
&brd, sizeof(brd)) == -1)
hostapd_fatal("failed to enable broadcast on socket\n");
+
+ hostapd_log(HOSTAPD_LOG_DEBUG, "%s: using broadcast mode "
+ "(address %s)\n", iapp->i_iface, inet_ntoa(addr->sin_addr));
} else {
/*
* Enable multicast
*/
-
- hostapd_log(HOSTAPD_LOG_DEBUG, "using multicast mode\n");
-
bzero(&mreq, sizeof(mreq));
iapp->i_multicast.sin_family = AF_INET;
@@ -285,6 +282,15 @@ hostapd_udp_init(struct hostapd_config *cfg)
IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) == -1)
hostapd_fatal("failed to add multicast membership to "
"%s: %s\n", IAPP_MCASTADDR, strerror(errno));
+
+ if (setsockopt(iapp->i_udp, IPPROTO_IP, IP_MULTICAST_TTL,
+ &iapp->i_ttl, sizeof(iapp->i_ttl)) < 0)
+ hostapd_fatal("failed to set multicast ttl to "
+ "%u: %s\n", iapp->i_ttl, strerror(errno));
+
+ hostapd_log(HOSTAPD_LOG_DEBUG, "%s: using multicast mode "
+ "(ttl %u, group %s)\n", iapp->i_iface, iapp->i_ttl,
+ inet_ntoa(iapp->i_multicast.sin_addr));
}
}
diff --git a/usr.sbin/hostapd/hostapd.conf.5 b/usr.sbin/hostapd/hostapd.conf.5
index e1dbf8f1427..42b6030191e 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.25 2005/12/01 08:28:58 jmc Exp $
+.\" $OpenBSD: hostapd.conf.5,v 1.26 2005/12/10 13:42:37 reyk Exp $
.\"
.\" Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
.\"
@@ -174,8 +174,12 @@ The supported modes are:
.Ic multicast
.Op Ic address Ar ipv4addr
.Op Ic port Ar number
+.Op Ic ttl Ar number
.Xc
Use multicast frames.
+A multicast ttl (time-to-live) of 2 or higher is required to allow
+multicast forwarding, for example with
+.Xr mrouted 8 .
.It Xo
.Ic broadcast
.Op Ic port Ar number
@@ -183,7 +187,8 @@ Use multicast frames.
Use broadcast frames.
.El
.Pp
-The default is multicast using the multicast address 224.0.1.178.
+The default is multicast using the multicast address 224.0.1.178 with a ttl
+limited to 1 hop.
.El
.Sh EVENT RULES
Event rules provide a powerful way to trigger a certain action when
diff --git a/usr.sbin/hostapd/hostapd.h b/usr.sbin/hostapd/hostapd.h
index 89191156a4f..50044830924 100644
--- a/usr.sbin/hostapd/hostapd.h
+++ b/usr.sbin/hostapd/hostapd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.h,v 1.14 2005/12/01 02:03:58 reyk Exp $ */
+/* $OpenBSD: hostapd.h,v 1.15 2005/12/10 13:42:37 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -263,6 +263,7 @@ struct hostapd_iapp {
struct sockaddr_in i_addr;
struct sockaddr_in i_broadcast;
struct sockaddr_in i_multicast;
+ u_int8_t i_ttl;
u_int8_t i_flags;
#define HOSTAPD_IAPP_F_ADD_NOTIFY 0x01
diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y
index 0220e6aac19..8032745d288 100644
--- a/usr.sbin/hostapd/parse.y
+++ b/usr.sbin/hostapd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.17 2005/12/01 02:03:58 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.18 2005/12/10 13:42:37 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -127,7 +127,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 ON NOTIFY
+%token ADDRESS PORT ON NOTIFY TTL
%token <v.string> STRING
%token <v.val> VALUE
%type <v.val> number
@@ -175,7 +175,7 @@ option : SET HOSTAP INTERFACE hostapifaces
| SET IAPP HANDLE SUBTYPE iappsubtypes
;
-iappmode : MULTICAST iappmodeaddr iappmodeport
+iappmode : MULTICAST iappmodeaddr iappmodeport iappmodettl
{
hostapd_cfg.c_flags &= ~HOSTAPD_CFG_F_BRDCAST;
}
@@ -200,6 +200,13 @@ iappmodeport : /* empty */
}
;
+iappmodettl : /* empty */
+ | TTL number
+ {
+ hostapd_cfg.c_iapp.i_ttl = $2;
+ }
+ ;
+
hostapmode : RADIOTAP
{
hostapd_cfg.c_apme_dlt = DLT_IEEE802_11_RADIO;
@@ -1026,6 +1033,7 @@ lookup(char *token)
{ "table", TABLE },
{ "to", TO },
{ "toomany", TOOMANY },
+ { "ttl", TTL },
{ "type", TYPE },
{ "unspecified", UNSPECIFIED },
{ "usec", USEC },
@@ -1327,6 +1335,7 @@ hostapd_parse_file(struct hostapd_config *cfg)
TAILQ_INIT(&cfg->c_frames);
cfg->c_iapp.i_multicast.sin_addr.s_addr = INADDR_ANY;
cfg->c_iapp.i_flags = HOSTAPD_IAPP_F_DEFAULT;
+ cfg->c_iapp.i_ttl = IP_DEFAULT_MULTICAST_TTL;
lineno = 1;
errors = 0;