From 7a1e1bab720a2f7ab5b7684f0df13dacc6651cc2 Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Thu, 1 Dec 2005 01:28:20 +0000 Subject: support netmasks in table entry ip address assignments --- usr.sbin/hostapd/hostapd.conf.5 | 9 ++++++--- usr.sbin/hostapd/hostapd.h | 21 +++++++++++++++++---- usr.sbin/hostapd/parse.y | 20 ++++++++++++++++---- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/usr.sbin/hostapd/hostapd.conf.5 b/usr.sbin/hostapd/hostapd.conf.5 index 8505e11521c..c10749b0c98 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.21 2005/11/23 20:40:38 reyk Exp $ +.\" $OpenBSD: hostapd.conf.5,v 1.22 2005/12/01 01:28:19 reyk Exp $ .\" .\" Copyright (c) 2004, 2005 Reyk Floeter .\" @@ -81,8 +81,8 @@ Tables are used for .Xr hostapd 8 .Em event rules to match specified IEEE 802.11 link layer addresses and address ranges, -and the capability to assign link layer to IP addresses is a -requirement for advanced IAPP functionality. +and the capability to assign link layer to IP addresses and a option netmask +is a requirement for advanced IAPP functionality. .Pp Table options may be presented after the table name declaration. The following options are supported: @@ -102,6 +102,9 @@ table const { 00:00:24:c3:40:19 -> 10.195.64.25, 00:00:24:c3:40:1a -> 10.195.64.26 } +table const { + 00:05:4e:45:d4:b9 -> 172.23.5.1/30 +} .Ed .Sh GLOBAL CONFIGURATION The following configuration settings are understood: diff --git a/usr.sbin/hostapd/hostapd.h b/usr.sbin/hostapd/hostapd.h index 376c3404f56..f386bcc47cd 100644 --- a/usr.sbin/hostapd/hostapd.h +++ b/usr.sbin/hostapd/hostapd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hostapd.h,v 1.12 2005/12/01 01:11:30 reyk Exp $ */ +/* $OpenBSD: hostapd.h,v 1.13 2005/12/01 01:28:19 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter @@ -92,17 +92,29 @@ struct hostapd_counter { ((_e)->e_lladdr[5] == ((_b)[5] & (_e)->e_addr.a_mask[5])) \ ) +struct hostapd_inaddr { + sa_family_t in_af; + union { + struct in_addr v4; + struct in6_addr v6; + } in_v; + int in_netmask; +}; + +#define in_v4 in_v.v4 +#define in_v6 in_v.v6 + struct hostapd_entry { u_int8_t e_lladdr[IEEE80211_ADDR_LEN]; u_int8_t e_flags; #define HOSTAPD_ENTRY_F_LLADDR 0x00 #define HOSTAPD_ENTRY_F_MASK 0x01 -#define HOSTAPD_ENTRY_F_IPV4 0x02 +#define HOSTAPD_ENTRY_F_INADDR 0x02 union { u_int8_t a_mask[IEEE80211_ADDR_LEN]; - struct in_addr a_ipv4; + struct hostapd_inaddr a_inaddr; } e_addr; RB_ENTRY(hostapd_entry) e_nodes; @@ -110,7 +122,7 @@ struct hostapd_entry { }; #define e_mask e_addr.a_mask -#define e_ipv4 e_addr.a_ipv4 +#define e_inaddr e_addr.a_inaddr #define HOSTAPD_TABLE_NAMELEN 32 @@ -236,6 +248,7 @@ struct hostapd_apme { char a_iface[IFNAMSIZ]; u_int8_t a_bssid[IEEE80211_ADDR_LEN]; void *a_cfg; + struct sockaddr_in a_addr; TAILQ_ENTRY(hostapd_apme) a_entries; }; diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y index d985ec500b9..179d1172bb2 100644 --- a/usr.sbin/hostapd/parse.y +++ b/usr.sbin/hostapd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.15 2005/12/01 01:11:30 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.16 2005/12/01 01:28:19 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter @@ -813,10 +813,12 @@ tableaddrentry : lladdr ; tableaddropt : /* empty */ - | assign ipv4addr + | assign ipv4addr ipnetmask { - entry->e_flags |= HOSTAPD_ENTRY_F_IPV4; - bcopy(&$2, &entry->e_ipv4, sizeof(struct in_addr)); + entry->e_flags |= HOSTAPD_ENTRY_F_INADDR; + entry->e_inaddr.in_af = AF_INET; + bcopy(&$2, &entry->e_inaddr.in_v4, + sizeof(struct in_addr)); } | mask lladdr { @@ -839,6 +841,16 @@ ipv4addr : STRING } ; +ipnetmask : /* empty */ + { + entry->e_inaddr.in_netmask = -1; + } + | '/' number + { + entry->e_inaddr.in_netmask = $2; + } + ; + lladdr : STRING { struct ether_addr *ea; -- cgit v1.2.3