summaryrefslogtreecommitdiff
path: root/cesar/interface
diff options
context:
space:
mode:
authorlaranjeiro2009-09-25 07:28:17 +0000
committerlaranjeiro2009-09-25 07:28:17 +0000
commit6dd83bb079f07dab7036e1b5edf5b5e49e1fa1c2 (patch)
tree2a24cda479f68da63309f8b96f5a8d1b6f17410f /cesar/interface
parent3deff37714dfd58e8d187d663e3dde0a09121718 (diff)
*interface/sniffer: (See 573)
* Added the OUI to the VS_SNIFFER_MESSAGES. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5751 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/interface')
-rw-r--r--cesar/interface/sniffer/src/sniffer.c29
-rw-r--r--cesar/interface/sniffer/test/src/test-sniffer.c16
2 files changed, 32 insertions, 13 deletions
diff --git a/cesar/interface/sniffer/src/sniffer.c b/cesar/interface/sniffer/src/sniffer.c
index 69a318ca5b..da12418c48 100644
--- a/cesar/interface/sniffer/src/sniffer.c
+++ b/cesar/interface/sniffer/src/sniffer.c
@@ -13,6 +13,7 @@
* « long description »
*/
#include "common/std.h"
+#include "common/defs/spidcom.h"
#include "lib/swap.h"
#include "hal/hle/defs.h"
@@ -122,8 +123,10 @@ interface_sniffer_copy_beacon (interface_sniffer_t *ctx, pb_beacon_t *beacon,
length = INTERFACE_BEACON_SIZE + sizeof (pbproc_rx_beacon_params_t);
// Fill the buffer header.
- bitstream_init (&bitstream, buffer, length + HPAV_MME_HEADER
- + INTERFACE_MME_HEADER_SIZE, BITSTREAM_WRITE);
+ bitstream_init (&bitstream, buffer,
+ length + HPAV_MME_HEADER + INTERFACE_MME_HEADER_SIZE +
+ OUI_SIZE,
+ BITSTREAM_WRITE);
bitstream_write_large (&bitstream, ctx->da, 48);
bitstream_write_large (&bitstream, ctx->mac_config->sta_mac_address, 48);
if (ctx->vlan_tag)
@@ -132,6 +135,7 @@ interface_sniffer_copy_beacon (interface_sniffer_t *ctx, pb_beacon_t *beacon,
bitstream_write (&bitstream, HPAV_MMV, 8);
bitstream_write (&bitstream, VS_SNIFFER_IND, 16);
bitstream_write (&bitstream, 0, 16);
+ bitstream_write (&bitstream, SPC_OUI, OUI_SIZE_BITS);
bitstream_write (&bitstream, INTERFACE_SNIFFER_TYPE_BEACON, 8);
/* 0 for TX, 1 for RX. */
@@ -216,6 +220,7 @@ interface_sniffer_configure_and_respond (interface_sniffer_t *ctx, u8 *buffer,
mac_t osa = 0;
uint data = 0;
bool ok = false;
+ uint oui;
bitstream_t stream;
dbg_assert (ctx);
@@ -226,20 +231,29 @@ interface_sniffer_configure_and_respond (interface_sniffer_t *ctx, u8 *buffer,
osa = bitstream_direct_read_large (buffer, 48, 48);
if (bitstream_direct_read (buffer, 96, 16) == swap16(HPAV_MTYPE_MME))
- data = bitstream_direct_read (buffer, HPAV_MME_HEADER * 8, 8);
+ {
+ oui = bitstream_direct_read (buffer, HPAV_MME_HEADER * 8,
+ OUI_SIZE_BITS);
+ data = bitstream_direct_read (buffer, HPAV_MME_HEADER * 8 +
+ OUI_SIZE_BITS, 8);
+ }
else
{
vlan_value = bitstream_direct_read (buffer, 96, 32);
+ oui = bitstream_direct_read (buffer, HPAV_MME_HEADER_LEN_WITH_VLAN * 8,
+ OUI_SIZE_BITS);
data = bitstream_direct_read (buffer,
- HPAV_MME_HEADER_LEN_WITH_VLAN * 8,
+ HPAV_MME_HEADER_LEN_WITH_VLAN * 8 +
+ OUI_SIZE_BITS,
8);
}
/* If the sniffer is activated, only the computer which had activated it
* can change the sniffer mode, the others should only stop the sniffer. */
- if ((ctx->da == 0)
- || (ctx->da == osa)
- || ((ctx->da != osa) && (data == 0x0)))
+ if (((ctx->da == 0)
+ || (ctx->da == osa)
+ || ((ctx->da != osa) && (data == 0x0)))
+ && (oui == SPC_OUI))
{
ctx->da = bitstream_direct_read_large (buffer, 48, 48);
ctx->vlan_tag = vlan_value;
@@ -259,6 +273,7 @@ interface_sniffer_configure_and_respond (interface_sniffer_t *ctx, u8 *buffer,
bitstream_write (&stream, HPAV_MMV, 8);
bitstream_write (&stream, VS_SNIFFER_CNF, 16);
bitstream_write (&stream, 0, 16);
+ bitstream_write (&stream, SPC_OUI, OUI_SIZE_BITS);
bitstream_write (&stream, ok && (data == interface_sniffer_status (ctx)),
8);
bitstream_write (&stream, interface_sniffer_status (ctx), 8);
diff --git a/cesar/interface/sniffer/test/src/test-sniffer.c b/cesar/interface/sniffer/test/src/test-sniffer.c
index c70311a83b..d83d5c3267 100644
--- a/cesar/interface/sniffer/test/src/test-sniffer.c
+++ b/cesar/interface/sniffer/test/src/test-sniffer.c
@@ -15,6 +15,7 @@
#include "lib/test.h"
#include "lib/bitstream.h"
#include "lib/swap.h"
+#include "common/defs/spidcom.h"
#include "interface/sniffer/sniffer.h"
#include "interface/sniffer/inc/context.h"
@@ -51,6 +52,7 @@ test_sniffer_prepare_request (mac_t osa, uint req, uint vlan)
bitstream_write (&stream, HPAV_MMV, 8);
bitstream_write (&stream, VS_SNIFFER_REQ, 16);
bitstream_write (&stream, 0, 16);
+ bitstream_write (&stream, SPC_OUI, 24);
bitstream_write (&stream, req, 8);
bitstream_finalise (&stream);
}
@@ -69,16 +71,16 @@ test_sniffer_read_answer (mac_t *oda, uint *res, uint *status,
if (swap16(bitstream_direct_read (answer, 96, 16)) == HPAV_MTYPE_MME)
{
mmtype = bitstream_direct_read (answer, 120, 16);
- *res = bitstream_direct_read (answer, 152, 8);
- *status = bitstream_direct_read (answer, 160, 8);
- *da = bitstream_direct_read_large (answer, 168, 48);
+ *res = bitstream_direct_read (answer, 176, 8);
+ *status = bitstream_direct_read (answer, 184, 8);
+ *da = bitstream_direct_read_large (answer, 192, 48);
}
else
{
mmtype = bitstream_direct_read (answer, 152, 16);
- *res = bitstream_direct_read (answer, 184, 8);
- *status = bitstream_direct_read (answer, 192, 8);
- *da = bitstream_direct_read_large (answer, 200, 48);
+ *res = bitstream_direct_read (answer, 208, 8);
+ *status = bitstream_direct_read (answer, 216, 8);
+ *da = bitstream_direct_read_large (answer, 224, 48);
}
if (mmtype != VS_SNIFFER_CNF)
@@ -432,6 +434,7 @@ test_sniffer_beacon (test_t test)
test_fail_unless (HPAV_MMV == bitstream_read (&stream, 8));
test_fail_unless (VS_SNIFFER_IND == bitstream_read (&stream, 16));
test_fail_unless (0 == bitstream_read (&stream, 16));
+ test_fail_unless (SPC_OUI == bitstream_read (&stream, OUI_SIZE_BITS));
test_fail_unless (INTERFACE_SNIFFER_TYPE_BEACON == bitstream_read
(&stream, 8));
/* Direction TX. */
@@ -452,6 +455,7 @@ test_sniffer_beacon (test_t test)
test_fail_unless (HPAV_MMV == bitstream_read (&stream, 8));
test_fail_unless (VS_SNIFFER_IND == bitstream_read (&stream, 16));
test_fail_unless (0 == bitstream_read (&stream, 16));
+ test_fail_unless (SPC_OUI == bitstream_read (&stream, OUI_SIZE_BITS));
test_fail_unless (INTERFACE_SNIFFER_TYPE_BEACON == bitstream_read
(&stream, 8));
/* Direction RX. */