summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/hostapd/handle.c7
-rw-r--r--usr.sbin/hostapd/hostapd.c16
-rw-r--r--usr.sbin/hostapd/hostapd.h8
-rw-r--r--usr.sbin/hostapd/parse.y66
4 files changed, 84 insertions, 13 deletions
diff --git a/usr.sbin/hostapd/handle.c b/usr.sbin/hostapd/handle.c
index a82f37a4eb8..5ce37022dc4 100644
--- a/usr.sbin/hostapd/handle.c
+++ b/usr.sbin/hostapd/handle.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: handle.c,v 1.1 2005/06/17 19:13:35 reyk Exp $ */
+/* $OpenBSD: handle.c,v 1.2 2005/07/04 16:48:55 reyk Exp $ */
/*
* Copyright (c) 2005 Reyk Floeter <reyk@vantronix.net>
@@ -91,6 +91,11 @@ hostapd_handle_ref(u_int flags, u_int shift, u_int8_t *wfrom, u_int8_t *wto,
bcopy(wto, addr, IEEE80211_ADDR_LEN);
else if (flags & (HOSTAPD_ACTION_F_REF_BSSID << shift))
bcopy(wbssid, addr, IEEE80211_ADDR_LEN);
+ else if (flags & (HOSTAPD_ACTION_F_REF_RANDOM << shift)) {
+ hostapd_randval(addr, IEEE80211_ADDR_LEN);
+ /* Avoid multicast/broadcast addresses */
+ addr[0] &= ~0x1;
+ }
}
int
diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c
index e7dabf43f51..0e9d74857b1 100644
--- a/usr.sbin/hostapd/hostapd.c
+++ b/usr.sbin/hostapd/hostapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.c,v 1.11 2005/06/17 19:13:35 reyk Exp $ */
+/* $OpenBSD: hostapd.c,v 1.12 2005/07/04 16:48:55 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -494,6 +494,20 @@ main(int argc, char *argv[])
return (EXIT_SUCCESS);
}
+void
+hostapd_randval(u_int8_t *buf, const u_int len)
+{
+ u_int32_t data = 0;
+ u_int i;
+
+ for (i = 0; i < len; i++) {
+ if ((i % sizeof(data)) == 0)
+ data = arc4random();
+ buf[i] = data & 0xff;
+ data >>= 8;
+ }
+}
+
struct hostapd_table *
hostapd_table_add(struct hostapd_config *cfg, const char *name)
{
diff --git a/usr.sbin/hostapd/hostapd.h b/usr.sbin/hostapd/hostapd.h
index 226d6bc710d..5c11c010cb9 100644
--- a/usr.sbin/hostapd/hostapd.h
+++ b/usr.sbin/hostapd/hostapd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.h,v 1.3 2005/06/17 19:13:35 reyk Exp $ */
+/* $OpenBSD: hostapd.h,v 1.4 2005/07/04 16:48:55 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -188,12 +188,13 @@ struct hostapd_action_data {
u_int16_t a_flags;
#define HOSTAPD_ACTION_F_REF_FROM 0x0001
+#define HOSTAPD_ACTION_F_REF_TO 0x0002
+#define HOSTAPD_ACTION_F_REF_BSSID 0x0004
+#define HOSTAPD_ACTION_F_REF_RANDOM 0x0008
#define HOSTAPD_ACTION_F_REF_FROM_M 0x000f
#define HOSTAPD_ACTION_F_REF_FROM_S 0
-#define HOSTAPD_ACTION_F_REF_TO 0x0002
#define HOSTAPD_ACTION_F_REF_TO_M 0x00f0
#define HOSTAPD_ACTION_F_REF_TO_S 4
-#define HOSTAPD_ACTION_F_REF_BSSID 0x0004
#define HOSTAPD_ACTION_F_REF_BSSID_M 0x0f00
#define HOSTAPD_ACTION_F_REF_BSSID_S 8
#define HOSTAPD_ACTION_F_REF_M 0x0fff
@@ -327,6 +328,7 @@ void hostapd_fatal(const char *, ...);
int hostapd_bpf_open(u_int);
void hostapd_cleanup(struct hostapd_config *);
int hostapd_check_file_secrecy(int, const char *);
+void hostapd_randval(u_int8_t *, const u_int);
struct hostapd_table *hostapd_table_add(struct hostapd_config *,
const char *);
diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y
index ff7a0938f0f..3d06bc71d47 100644
--- a/usr.sbin/hostapd/parse.y
+++ b/usr.sbin/hostapd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.6 2005/06/17 21:22:00 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.7 2005/07/04 16:48:55 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -86,6 +86,10 @@ typedef struct {
struct hostapd_table *table;
u_int32_t flags;
} reflladdr __packed;
+ struct {
+ u_int16_t alg;
+ u_int16_t transaction;
+ } authalg;
struct in_addr in;
char *string;
long val;
@@ -114,19 +118,20 @@ u_int negative;
%token MODE INTERFACE IAPP HOSTAP MULTICAST BROADCAST SET SEC USEC
%token HANDLE TYPE SUBTYPE FROM TO BSSID WITH FRAME RADIOTAP NWID PASSIVE
-%token MANAGEMENT DATA PROBE BEACON ATIM ANY DS NO DIR RESEND
+%token MANAGEMENT DATA PROBE BEACON ATIM ANY DS NO DIR RESEND RANDOM
%token AUTH DEAUTH ASSOC DISASSOC REASSOC REQUEST RESPONSE PCAP
%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
+%token RESERVED RSN REQUIRED INCONSISTENT IE INVALID MIC FAILURE OPEN
%token <v.string> STRING
%token <v.val> VALUE
%type <v.val> number
%type <v.in> ipv4addr
-%type <v.reflladdr> refaddr, lladdr, frmactionaddr, frmmatchaddr
+%type <v.reflladdr> refaddr, lladdr, randaddr, frmactionaddr, frmmatchaddr
%type <v.reason> frmreason_l
%type <v.string> table
%type <v.string> string
+%type <v.authalg> authalg
%%
@@ -282,7 +287,13 @@ nodeopt : DELETE
}
;
-frmmatch : frmmatchtype frmmatchdir frmmatchfrom frmmatchto frmmatchbssid
+frmmatch : ANY
+ | frm frmmatchtype frmmatchdir frmmatchfrom frmmatchto
+ frmmatchbssid
+ ;
+
+frm : /* empty */
+ | FRAME
;
frmaction : frmactiontype frmactiondir frmactionfrom frmactionto frmactionbssid
@@ -343,7 +354,7 @@ frmsubtype : PROBE REQUEST frmelems
frame_ieee80211->i_fc[0] |=
IEEE80211_FC0_SUBTYPE_ATIM;
}
- | AUTH
+ | AUTH frmauth
{
frame_ieee80211->i_fc[0] |=
IEEE80211_FC0_SUBTYPE_AUTH;
@@ -391,6 +402,33 @@ frmelems_l : frmelems_l frmelem
frmelem : NWID not STRING
;
+frmauth : /* empty */
+ | authalg
+ {
+ if ((frame_ieee80211->i_data = malloc(6)) == NULL) {
+ yyerror("failed to allocate auth");
+ YYERROR;
+ }
+ ((u_int16_t *)frame_ieee80211->i_data)[0] =
+ $1.alg;
+ ((u_int16_t *)frame_ieee80211->i_data)[1] =
+ $1.transaction;
+ ((u_int16_t *)frame_ieee80211->i_data)[0] = 0;
+ frame_ieee80211->i_data_len = 6;
+ }
+ ;
+
+authalg : OPEN REQUEST
+ {
+ $$.alg = htole16(IEEE80211_AUTH_ALG_OPEN);
+ $$.transaction = htole16(IEEE80211_AUTH_OPEN_REQUEST);
+ }
+ | OPEN RESPONSE
+ {
+ $$.alg = htole16(IEEE80211_AUTH_ALG_OPEN);
+ $$.transaction = htole16(IEEE80211_AUTH_OPEN_RESPONSE);
+ }
+ ;
frmreason : frmreason_l
{
@@ -617,7 +655,11 @@ frmactionbssid : BSSID frmactionaddr
frmactionaddr : lladdr
{
bcopy($1.lladdr, $$.lladdr, IEEE80211_ADDR_LEN);
- $$.flags = 0;
+ $$.flags = $1.flags;
+ }
+ | randaddr
+ {
+ $$.flags = $1.flags;
}
| refaddr
{
@@ -757,7 +799,13 @@ lladdr : STRING
free($1);
bcopy(ea, $$.lladdr, IEEE80211_ADDR_LEN);
- $$.flags = 0;
+ $$.flags = HOSTAPD_ACTION_F_OPT_LLADDR;
+ }
+ ;
+
+randaddr : RANDOM
+ {
+ $$.flags |= HOSTAPD_ACTION_F_REF_RANDOM;
}
;
@@ -857,11 +905,13 @@ lookup(char *token)
{ "not", NOT },
{ "node", NODE },
{ "nwid", NWID },
+ { "open", OPEN },
{ "passive", PASSIVE },
{ "pcap", PCAP },
{ "probe", PROBE },
{ "quick", QUICK },
{ "radiotap", RADIOTAP },
+ { "random", RANDOM },
{ "reason", REASON },
{ "reassoc", REASSOC },
{ "request", REQUEST },