summaryrefslogtreecommitdiff
path: root/cesar/tools/sniffer_phy/inc/lowlevel.h
blob: b21b2d30f2b585e6e38d4fe0dbe85367bbc45cfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef inc_lowlevel_h
#define inc_lowlevel_h
/* Cesar project {{{
 *
 * Copyright (C) 2010 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    inc/lowlevel.h
 * \brief   Low level sniffer functions.
 * \ingroup sniffer_phy
 */
#include "hal/phy/forward.h"
#include "mac/common/tonemask.h"
#include "mac/common/pb.h"

#include "inc/forward.h"

/** Size of the low level pool. */
#define LOWLEVEL_POOL_SIZE 512

/** Received MPDU. */
struct lowlevel_rx_t
{
    /** Preamble start date. */
    u32 date;
    /** Frame control 1.0. */
    u32 fc10;
    /** Frame control. */
    u32 fc[4];
    /** FC1.0 CRC. */
    bool fc10_bad_crc;
    /** FC AV CRC. */
    bool fc_bad_crc;
    /** PB size. */
    phy_pb_size_t pb_size;
    /** PB list head. */
    pb_t *pb_head;
    /** PB list tail. */
    pb_t *pb_tail;
    /** Number of PB. */
    uint pb_nb;
};
typedef struct lowlevel_rx_t lowlevel_rx_t;

/** Received MPDU descriptor. */
union lowlevel_rx_desc_t
{
    /** Common block descriptor. */
    blk_t blk;
    struct
    {
        /** Pointer to next descriptor. */
        union lowlevel_rx_desc_t *next;
        /** Pointer to data. */
        lowlevel_rx_t *rx;
    };
};
typedef union lowlevel_rx_desc_t lowlevel_rx_desc_t;

/** Low level context. */
struct lowlevel_t
{
    /* Phy context. */
    phy_t *phy;
    /** Block pool head. */
    blk_t *pool_head;
    /** Block pool tail. */
    blk_t *pool_tail;
    /** Block pool size. */
    uint pool_size;
    /** RX MPDU queue head. */
    lowlevel_rx_desc_t *rx_head;
    /** RX MPDU queue tail. */
    lowlevel_rx_desc_t *rx_tail;
    /* Current tonemask. */
    tonemask_info_t *tonemask_info;
    /** MPDU being received. */
    lowlevel_rx_desc_t *rxing;
};
typedef struct lowlevel_t lowlevel_t;

BEGIN_DECLS

/**
 * Initialise low level.
 * \param  ctx  sniffer context
 */
void
lowlevel_init (sniffer_phy_t *ctx);

/**
 * Activate reception.
 * \param  ctx  sniffer context
 * \param  state  activation state
 *
 * Set tonemask when activating.
 */
void
lowlevel_activate (sniffer_phy_t *ctx, bool state);

END_DECLS

#endif /* inc_lowlevel_h */