dot11 timer functions introduced.
FossilOrigin-Name: c178ea605edf092e928f73799eb7ae8d27b8cda3f0aac6da490dc345740ca24a
This commit is contained in:
parent
28a1e50d6b
commit
f6e923536e
@ -2,6 +2,12 @@
|
||||
|
||||
#include "dot11.h"
|
||||
|
||||
|
||||
uint64_t dot11_timer_offset=0;
|
||||
|
||||
|
||||
|
||||
|
||||
const unsigned char dot11_tab_br[] =
|
||||
{
|
||||
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
||||
@ -22,3 +28,12 @@ const unsigned char dot11_tab_br[] =
|
||||
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||
};
|
||||
|
||||
const char * dot11_type_strings[]=
|
||||
{
|
||||
"Assoc Req",
|
||||
"Assoc Resp",
|
||||
"ReAssoc Req",
|
||||
"ReAssoc Resp",
|
||||
"Probe Req",
|
||||
"Probe Resp"
|
||||
};
|
||||
|
@ -1,8 +1,41 @@
|
||||
#ifndef __DOT11_H
|
||||
#define __DOT11_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Definitions and protoypes for 802.11
|
||||
*
|
||||
* @defgroup DOT11
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
#define DOT11_T_MGM 0b00
|
||||
#define DOT11_T_CTL 0b01
|
||||
#define DOT11_T_DTA 0b10
|
||||
#define DOT11_T_RES 0b11
|
||||
|
||||
#define dot11_fc_mgm(subtype) (DOT11_T_MGM << 2 | subtype(<<4))
|
||||
|
||||
|
||||
#define DOT11_FC_ASSOC_REQ dot11_fc_mgm(0b0000)
|
||||
#define DOT11_FC_ASSOC_RESP dot11_fc_mgm(0b0001)
|
||||
#define DOT11_FC_REASSOC_REQ dot11_fc_mgm(0b0010)
|
||||
#define DOT11_FC_REASSOC_RESP dot11_fc_mgm(0b0011)
|
||||
#define DOT11_FC_PROBE_REQ dot11_fc_mgm(0b0100)
|
||||
#define DOT11_FC_PROBE_RESP dot11_fc_mgm(0b0101)
|
||||
#define DOT11_FC_TIMING_ADV dot11_fc_mgm(0b0110)
|
||||
#define DOT11_FC_MGM_RES111 dot11_fc_mgm(0b0111)
|
||||
#define DOT11_FC_BEACON dot11_fc_mgm(0b1000)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern const uint8_t dot11_tab_br[256];
|
||||
|
||||
@ -13,8 +46,8 @@ extern const uint8_t dot11_tab_br[256];
|
||||
|
||||
static inline int dot11_put_word(uint8_t *ptr,uint16_t w)
|
||||
{
|
||||
dot11_put_byte(ptr,w&0xff);
|
||||
dot11_put_byte(ptr+1,w>>8);
|
||||
dot11_put_byte(ptr+1,w&0xff);
|
||||
dot11_put_byte(ptr,w>>8);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -38,18 +71,18 @@ static inline uint16_t dot11_get_word(uint8_t *ptr)
|
||||
|
||||
#define dot11_get_duration(frame) dot11_get_word(frame+2)
|
||||
|
||||
static inline void dot11_get_address(uint8_t * dst, uint8_t *frame, int field)
|
||||
static inline void dot11_get_address(uint8_t * dst, uint8_t *frame)
|
||||
{
|
||||
uint8_t *s = frame+4+field*6;
|
||||
memcpy(dst,s,6);
|
||||
memcpy(dst,frame,6);
|
||||
}
|
||||
|
||||
#define dot11_get_address1(dst,frame) dot11_get_address(dst,frame,0)
|
||||
#define dot11_get_address2(dst,frame) dot11_get_address(dst,frame,1)
|
||||
#define dot11_get_address3(dst,frame) dot11_get_address(dst,frame,2)
|
||||
#define dot11_get_address1(dst,frame) dot11_get_address(dst,frame+4)
|
||||
#define dot11_get_address2(dst,frame) dot11_get_address(dst,frame+4*2*6)
|
||||
#define dot11_get_address3(dst,frame) dot11_get_address(dst,frame+4*3*6)
|
||||
|
||||
#define dot11_get_sequence_control(frame) dot11_get_word(frame+22)
|
||||
|
||||
|
||||
#define DOT11_FC_FLAG_FROM_DS 0x100
|
||||
#define DOT11_FC_FLAG_TO_DS 0x200
|
||||
#define DOT11_FC_FLAG_MOREFRAGS 0x400
|
||||
@ -67,4 +100,28 @@ static inline void dot11_get_address(uint8_t * dst, uint8_t *frame, int field)
|
||||
#define dot11_fc_get_more_fragments(fc) (fc&DOT11_FC_FLAG_MOREFRAGS?1:0)
|
||||
|
||||
|
||||
#define dot11_fc_put_frame_control(dst,fc) dot11_put_word(dst,fc)
|
||||
|
||||
|
||||
|
||||
extern uint64_t dot11_timer_offset;
|
||||
|
||||
static inline uint64_t dot11_timer_get(){
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return 1000000 * tv.tv_sec + tv.tv_usec - dot11_timer_offset;
|
||||
}
|
||||
|
||||
static inline void dot11_timer_set(uint64_t val) {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
dot11_timer_offset = 1000000 * tv.tv_sec + tv.tv_usec - val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user