Compare commits
5 Commits
300b737efd
...
ec6809b552
Author | SHA1 | Date | |
---|---|---|---|
ec6809b552 | |||
1297c46a15 | |||
cc257ed27f | |||
059c0e542e | |||
9d3fa452aa |
@ -509,7 +509,7 @@ void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
|
||||
dataman_list_unlock();
|
||||
|
||||
//dataman_add_packet (dm, buffer, len);
|
||||
dataman_add_packet (dm, buffer, len);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -5,10 +5,12 @@
|
||||
#include "cw/timer.h"
|
||||
#include "cw/cw.h"
|
||||
#include "cw/format.h"
|
||||
#include "cw/netconn.h"
|
||||
#include "cw/conn.h"
|
||||
|
||||
#include "cw/log.h"
|
||||
#include "cw/dbg.h"
|
||||
#include "cw/file.h"
|
||||
#include "cw/dot11.h"
|
||||
|
||||
#include "wtplist.h"
|
||||
#include "dataman.h"
|
||||
@ -19,8 +21,8 @@ pthread_mutex_t dataman_list_mutex;
|
||||
|
||||
static int cmp(const void *d1, const void *d2)
|
||||
{
|
||||
struct netconn *nc1 = ((struct dataman *) d1)->nc;
|
||||
struct netconn *nc2 = ((struct dataman *) d1)->nc;
|
||||
struct cw_Conn *nc1 = ((struct dataman *) d1)->nc;
|
||||
struct cw_Conn *nc2 = ((struct dataman *) d1)->nc;
|
||||
|
||||
int r = nc1->sock - nc2->sock;
|
||||
if (r != 0)
|
||||
@ -52,7 +54,7 @@ void dataman_destroy(struct dataman *dm)
|
||||
{
|
||||
if (!dm)
|
||||
return;
|
||||
netconn_destroy(dm->nc);
|
||||
conn_destroy(dm->nc);
|
||||
}
|
||||
|
||||
struct dataman *dataman_create(int sock, struct sockaddr *addr)
|
||||
@ -60,15 +62,15 @@ struct dataman *dataman_create(int sock, struct sockaddr *addr)
|
||||
struct dataman *dm = malloc(sizeof(struct dataman));
|
||||
if (!dm)
|
||||
return NULL;
|
||||
|
||||
dm->nc = netconn_create(sock, addr, 100);
|
||||
memset(dm,0,sizeof(struct dataman));
|
||||
dm->nc = cw_conn_create(sock, addr, 100);
|
||||
return dm;
|
||||
}
|
||||
|
||||
|
||||
struct dataman *dataman_list_get(int sock, struct sockaddr *addr)
|
||||
{
|
||||
struct netconn search_nc;
|
||||
struct cw_Conn search_nc;
|
||||
struct dataman search_dm;
|
||||
|
||||
search_nc.sock = sock;
|
||||
@ -91,7 +93,7 @@ struct dataman *dataman_list_add(struct dataman *dm)
|
||||
|
||||
|
||||
|
||||
int dataman_process_keep_alive(struct netconn *nc, uint8_t *rawmsg, int len)
|
||||
int dataman_process_keep_alive(struct cw_Conn *nc, uint8_t *rawmsg, int len)
|
||||
{
|
||||
struct dataman * dm = (struct dataman *)(nc->data);
|
||||
|
||||
@ -133,7 +135,7 @@ int dataman_process_keep_alive(struct netconn *nc, uint8_t *rawmsg, int len)
|
||||
printf("len len %d\n",l);
|
||||
printf("Total len = %d\n",total_len);
|
||||
|
||||
netconn_send_capwap_msg(nc,buffer,total_len);
|
||||
cw_send_msg(nc,buffer,total_len);
|
||||
return len;
|
||||
|
||||
|
||||
@ -167,26 +169,47 @@ int dataman_process_keep_alive(struct netconn *nc, uint8_t *rawmsg, int len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int dataman_process_message0(struct netconn *nc, uint8_t * rawmsg, int len,
|
||||
int dataman_process_message0(struct cw_Conn *nc, uint8_t * rawmsg, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
|
||||
static int c=0;
|
||||
char fn[100];
|
||||
sprintf(fn,"wificap-%03d",c++);
|
||||
/// cw_save_file(fn,(char*)rawmsg,len);
|
||||
/// cw_dbg(DBG_X,"saving %d bytes",len);
|
||||
|
||||
uint8_t * dot11frame = rawmsg + cw_get_hdr_msg_offset(rawmsg);
|
||||
|
||||
cw_dbg(DBG_X,"802.11 - %s",dot11_get_frame_name(dot11frame));
|
||||
|
||||
/* The very first data message MUST be a keep-alive message */
|
||||
if (!cw_get_hdr_flag_k(rawmsg)){
|
||||
|
||||
cw_dbg(DBG_X,"No K Flag founde");
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_X, "Goto Keep Alive Pack");
|
||||
return dataman_process_keep_alive(nc,rawmsg,len);
|
||||
}
|
||||
|
||||
int dataman_process_message(struct netconn *nc, uint8_t * rawmsg, int len,
|
||||
int dataman_process_message(struct cw_Conn *nc, uint8_t * rawmsg, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
if (cw_get_hdr_flag_k(rawmsg)){
|
||||
return dataman_process_keep_alive(nc,rawmsg,len);
|
||||
}
|
||||
static int c=0;
|
||||
|
||||
char fn[100];
|
||||
sprintf(fn,"wificap-%03d",c++);
|
||||
cw_save_file(fn,(char*)rawmsg,len);
|
||||
|
||||
|
||||
cw_dbg(DBG_X,"There was someting else than dataman");
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
@ -195,12 +218,22 @@ void dataman_run(struct dataman *dm)
|
||||
{
|
||||
time_t timer = cw_timer_start(2);
|
||||
|
||||
dm->nc->process_packet=netconn_process_packet;
|
||||
dm->nc->process_packet=conn_process_packet;
|
||||
dm->nc->process_message=dataman_process_message0;
|
||||
dm->nc->data = dm;
|
||||
|
||||
|
||||
while (1){
|
||||
time_t timer = cw_timer_start(2);
|
||||
while (!cw_timer_timeout(timer)){
|
||||
cw_read_messages(dm->nc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
while (!cw_timer_timeout(timer)){
|
||||
netconn_read_messages(dm->nc);
|
||||
cw_read_messages(dm->nc);
|
||||
}
|
||||
|
||||
if (!dm->wtpman){
|
||||
@ -215,7 +248,7 @@ void dataman_run(struct dataman *dm)
|
||||
while (1){
|
||||
time_t timer = cw_timer_start(2);
|
||||
while (!cw_timer_timeout(timer)){
|
||||
netconn_read_messages(dm->nc);
|
||||
cw_read_messages(dm->nc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,11 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/*#include "cw/netconn.h"*/
|
||||
|
||||
#include "wtpman.h"
|
||||
|
||||
struct dataman {
|
||||
struct netconn *nc;
|
||||
struct cw_Conn *nc;
|
||||
pthread_t thread;
|
||||
struct wtpman * wtpman;
|
||||
|
||||
@ -28,6 +27,6 @@ extern pthread_mutex_t dataman_list_mutex;
|
||||
#define dataman_list_lock() pthread_mutex_lock(&dataman_list_mutex)
|
||||
#define dataman_list_unlock() pthread_mutex_unlock(&dataman_list_mutex)
|
||||
|
||||
#define dataman_add_packet(dm,data,len) (netconn_q_add_packet(dm->nc,data,len))
|
||||
#define dataman_add_packet(dm,data,len) (conn_q_add_packet(dm->nc,data,len))
|
||||
|
||||
#endif
|
||||
|
@ -171,7 +171,6 @@ MISCSRC=\
|
||||
msgset.c\
|
||||
send.c\
|
||||
strheap.c\
|
||||
netconn.c\
|
||||
conn.c \
|
||||
val.c \
|
||||
discovery.c\
|
||||
@ -188,6 +187,7 @@ MISCSRC=\
|
||||
# cw_put_msg.c\
|
||||
# conn_process_packet.c\
|
||||
# conn_destroy.c\
|
||||
netconn.c\
|
||||
|
||||
DTLSSRC+=\
|
||||
dtls_bio.c\
|
||||
|
@ -665,7 +665,13 @@ int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, int def)
|
||||
return v.val.boolean;
|
||||
}
|
||||
|
||||
/*
|
||||
int cw_cfg_set_bool(cw_Cfg_t * cfg, const char * key, int val)
|
||||
{
|
||||
return cw_cfg_set(cfg,key,val ? "true":"false");
|
||||
}
|
||||
|
||||
*/
|
||||
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def)
|
||||
{
|
||||
struct cw_Val v;
|
||||
|
@ -92,6 +92,8 @@ int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n);
|
||||
int cw_cfg_get_int(cw_Cfg_t * cfg, const char *key, int def);
|
||||
int cw_cfg_write_to_file(FILE *f, cw_Cfg_t * cfg);
|
||||
|
||||
#define cw_cfg_set_bool(cfg,key,val) \
|
||||
cw_cfg_set(cfg,key,(val) ? "true":"false")
|
||||
|
||||
|
||||
int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, const void * valguard, const uint8_t * data, int len);
|
||||
|
@ -765,24 +765,22 @@ int conn_process_packet2(struct cw_Conn *conn, uint8_t * packet, int len,
|
||||
|
||||
if (cw_get_hdr_flag_f(packet)) {
|
||||
/* fragmented, add the packet to fragman */
|
||||
uint8_t *f;
|
||||
uint8_t *f,*fp;
|
||||
int rc;
|
||||
|
||||
f = fragman_add(conn->fragman, packet, offs, payloadlen);
|
||||
if (f == NULL) {
|
||||
fp = fragman_add(conn->fragman, packet, offs, payloadlen);
|
||||
if (fp == NULL) {
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
f =fp+MAX_PKT_HDR_LEN;
|
||||
|
||||
cw_dbg_pkt(DBG_PKT_IN, conn, f + 4, *(uint32_t *) f, from);
|
||||
/*// cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from);*/
|
||||
|
||||
/* // XXX: Modify fragman to not throw away CAPWAP headers*/
|
||||
cw_dbg_pkt(DBG_PKT_IN, conn, fp, *(uint32_t *) f+MAX_PKT_HDR_LEN, from);
|
||||
|
||||
rc = conn->process_message(conn, f + 4, *(uint32_t *) f, from);
|
||||
|
||||
free(f);
|
||||
free(fp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "val.h"
|
||||
#include "cfg.h"
|
||||
#include "dbg.h"
|
||||
|
||||
static int get_len(const struct cw_ValBit *bits)
|
||||
{
|
||||
@ -16,15 +18,28 @@ static int get_bit(const uint8_t * src,int pos, int len)
|
||||
return src[b]&m ? 1:0;
|
||||
}
|
||||
|
||||
static void set_bit(uint8_t * dst,int pos, int len,int val)
|
||||
{
|
||||
int b;
|
||||
uint8_t m;
|
||||
cw_dbg(DBG_X,"set bit val %d",val);
|
||||
if (!val)
|
||||
return;
|
||||
b = len-1-pos/8;
|
||||
m = 1<<(pos%8);
|
||||
dst[b]|=m;
|
||||
}
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
char skey[CW_CFG_MAX_KEY_LEN];
|
||||
const struct cw_ValBit * bits=param;
|
||||
int l,i;
|
||||
|
||||
l = get_len(bits);
|
||||
for(i=0;bits[i].key!=NULL;i++){
|
||||
int rc;
|
||||
printf("%s: %d\n",bits[i].key,get_bit(src,bits[i].bit,l));
|
||||
sprintf(skey,"%s/%s",key,bits[i].key);
|
||||
cw_cfg_set_bool(cfg,skey,get_bit(src,bits[i].bit,l));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -32,11 +47,26 @@ static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, c
|
||||
|
||||
static int bwrite(cw_Cfg_t ** cfgs, const char *key, uint8_t *dst, const void * param)
|
||||
{
|
||||
return 0;
|
||||
int l,i;
|
||||
char skey[CW_CFG_MAX_KEY_LEN];
|
||||
const struct cw_ValBit * bits=param;
|
||||
l = get_len(bits);
|
||||
memset(dst,0,l);
|
||||
for(i=0;bits[i].key!=NULL;i++){
|
||||
uint8_t val;
|
||||
int rc;
|
||||
val=0;
|
||||
sprintf(skey,"%s/%s",key,bits[i].key);
|
||||
rc = CW_TYPE_BOOL->write(cfgs, skey, &val, NULL);
|
||||
if (rc<0)
|
||||
val=0;
|
||||
cw_dbg(DBG_X,"%s (rc: %d)",skey,rc);
|
||||
set_bit(dst,bits[i].bit,l,val);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct cw_Type cw_type_bits = {
|
||||
"Bits", /* name */
|
||||
NULL, /* del */
|
||||
|
@ -38,3 +38,25 @@ const char * dot11_type_strings[]=
|
||||
"Probe Req",
|
||||
"Probe Resp"
|
||||
};
|
||||
|
||||
|
||||
struct dot11_name{
|
||||
uint8_t val;
|
||||
const char * str;
|
||||
};
|
||||
|
||||
struct cw_StrListElem dot11_names[]={
|
||||
{DOT11_ASSOC_REQ, "Assoc Req"},
|
||||
{DOT11_ASSOC_RESP, "Assoc Resp"},
|
||||
{DOT11_REASSOC_REQ, "Reassoc Req"},
|
||||
{DOT11_REASSOC_RESP, "Reassoc Resp"},
|
||||
{DOT11_PROBE_REQ, "Probe Req"},
|
||||
{DOT11_PROBE_RESP, "Probe Resp"},
|
||||
{DOT11_TIMING_ADV, "Timing Adv"},
|
||||
{DOT11_MGM_RES111, "MGMRES111"},
|
||||
{DOT11_BEACON, "Beacon"},
|
||||
{CW_STR_STOP,"Unknown"},
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#include "strlist.h"
|
||||
|
||||
/**
|
||||
* @defgroup DOT11_FRAME_TYPES Frame Types
|
||||
@ -47,17 +48,17 @@
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#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)
|
||||
#define DOT11_ASSOC_REQ dot11_fc_mgm(0b0000)
|
||||
#define DOT11_ASSOC_RESP dot11_fc_mgm(0b0001)
|
||||
#define DOT11_REASSOC_REQ dot11_fc_mgm(0b0010)
|
||||
#define DOT11_REASSOC_RESP dot11_fc_mgm(0b0011)
|
||||
#define DOT11_PROBE_REQ dot11_fc_mgm(0b0100)
|
||||
#define DOT11_PROBE_RESP dot11_fc_mgm(0b0101)
|
||||
#define DOT11_TIMING_ADV dot11_fc_mgm(0b0110)
|
||||
#define DOT11_MGM_RES111 dot11_fc_mgm(0b0111)
|
||||
#define DOT11_BEACON dot11_fc_mgm(0b1000)
|
||||
|
||||
#define DOT11_FC_DATA dot11_fc_dta(0b0000)
|
||||
#define DOT11_DATA dot11_fc_dta(0b0000)
|
||||
|
||||
/**
|
||||
* @}
|
||||
@ -125,9 +126,9 @@ extern const uint8_t dot11_tab_br[256];
|
||||
|
||||
#define dot11_get_byte(ptr) (*(ptr))
|
||||
|
||||
#define dot11_put_byte(ptr,b) (*(ptr) = b)
|
||||
#define dot11_put_byte(ptr,b) (*(ptr) = b,1)
|
||||
#define dot11_put_word(dst,v) ((*((uint16_t*)(dst))=htobe16(v)),2)
|
||||
#define dot11_put_dword(dst,v) ((*((uint16_t*)(dst))=htobe16(v)),4)
|
||||
#define dot11_put_dword(dst,v) ((*((uint32_t*)(dst))=htobe32(v)),4)
|
||||
#define dot11_put_qword(dst,v) ((*((uint64_t*)(dst))=htobe64(v)),8)
|
||||
|
||||
|
||||
@ -135,9 +136,11 @@ uint16_t dot11_get_word(uint8_t * ptr);
|
||||
|
||||
|
||||
|
||||
#define dot11_get_version(frame) ((frame[1])&0x03)
|
||||
#define dot11_get_type(frame) (((frame[1])&0x0c) >> 2)
|
||||
#define dot11_get_subtype(frame) (((frame[1])&0xf0) >> 4)
|
||||
#define cw_dot11_get_version(frame) ( (frame)[1] & 0x03)
|
||||
#define cw_dot11_get_type(frame) ( ((frame)[1] & 0x0c) >> 2)
|
||||
#define cw_dot11_get_subtype(frame) ( (frame)[1] >> 4 )
|
||||
|
||||
|
||||
/**
|
||||
* Get Frame Control field
|
||||
* @param frame
|
||||
@ -235,6 +238,9 @@ extern uint8_t dot11_broadcast_address[6];
|
||||
|
||||
|
||||
|
||||
extern struct cw_StrListElem dot11_names[];
|
||||
|
||||
#define dot11_get_frame_name(data) cw_strlist_get_str(dot11_names,(data)[1])
|
||||
|
||||
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
|
||||
|
||||
#include "capwap.h"
|
||||
#include "cw.h"
|
||||
#include "fragman.h"
|
||||
|
||||
/**
|
||||
@ -101,20 +102,6 @@ static struct frag * frag_new(struct frag * frags, int fragid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
void fragman_free(frag_t * frags,struct frag * f)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<FRAG_MAXIDS; i++){
|
||||
if (frags[i]->fragid==f->fragid){
|
||||
frags[i]=NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(f);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add a fragment
|
||||
* @pram frags Fragman object
|
||||
@ -129,12 +116,10 @@ uint8_t * fragman_add(frag_t * frags, uint8_t *packet, int hlen, int payloadlen)
|
||||
uint32_t val0,val1;
|
||||
int fragid,fragoffset;
|
||||
int dst;
|
||||
int ti;
|
||||
|
||||
/* read the transport header dword 0,
|
||||
* contains hlen*/
|
||||
val0 = ntohl(*((uint32_t*)packet));
|
||||
/* int hlen = (val0 >> 19) & 0x1f;*/
|
||||
|
||||
/* read the transport header dword 1,
|
||||
* contains fragid and fragoffset */
|
||||
@ -142,33 +127,30 @@ uint8_t * fragman_add(frag_t * frags, uint8_t *packet, int hlen, int payloadlen)
|
||||
fragid = val1>>16;
|
||||
fragoffset=(val1 >>3) & 0x1fff;
|
||||
|
||||
/*// printf("Fragid = %i, offset = %i\n",fragid,fragoffset);*/
|
||||
|
||||
/* determine size of payload */
|
||||
/* int payloadlen = len - hlen*4;
|
||||
if (payloadlen<0){
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
/* find / create cfragment */
|
||||
f = frag_get(frags,fragid);
|
||||
if (!f){
|
||||
f = frag_new(frags,fragid);
|
||||
if (!f){
|
||||
errno = ENOMEM;
|
||||
/* out of fragmentation space */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!f){
|
||||
errno = ENOMEM;
|
||||
/* out of fragmentation space */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
|
||||
dst = fragoffset*8;
|
||||
|
||||
/* copy fragment*/
|
||||
if (dst + payloadlen < FRAG_MAXSIZE) {
|
||||
memcpy( f->buffer+4+dst,packet+hlen,payloadlen);
|
||||
if (fragoffset==0){
|
||||
/* preserve header of 1st fragment */
|
||||
memset(f->buffer,0,MAX_PKT_HDR_LEN);
|
||||
memcpy(f->buffer,packet,hlen);
|
||||
cw_set_hdr_hlen(f->buffer,MAX_PKT_HDR_LEN/4);
|
||||
cw_set_hdr_flags(f->buffer, CAPWAP_FLAG_HDR_F, 0);
|
||||
}
|
||||
memcpy( f->buffer+MAX_PKT_HDR_LEN+4+dst,packet+hlen,payloadlen);
|
||||
f->bytesreceived+=payloadlen;
|
||||
}
|
||||
|
||||
@ -176,22 +158,14 @@ uint8_t * fragman_add(frag_t * frags, uint8_t *packet, int hlen, int payloadlen)
|
||||
f->bytesneeded=dst+payloadlen;
|
||||
}
|
||||
|
||||
|
||||
for (ti=0; ti<16; ti++){
|
||||
/*// printf("%02X ",(f->buffer+4)[ti]);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (f->bytesneeded>0 && f->bytesneeded<=f->bytesreceived){
|
||||
uint8_t * r=f->buffer;
|
||||
f->buffer=0;
|
||||
/*// printf("last bytes need %i\n",f->bytesneeded);*/
|
||||
*((uint32_t*)(r))=f->bytesneeded;
|
||||
*((uint32_t*)(r+MAX_PKT_HDR_LEN))=f->bytesneeded;
|
||||
return r;
|
||||
}
|
||||
|
||||
/*// printf("Fragman bytes needed: %i, received %i\n",f->bytesneeded,f->bytesreceived);*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
/**
|
||||
*@defgroup Fragman FRAGMAN
|
||||
*@breif Frgaman functions
|
||||
*@brief Frgaman functions
|
||||
*
|
||||
* Detailed esription
|
||||
* Detailed desription
|
||||
*@{
|
||||
*/
|
||||
|
||||
@ -33,18 +33,18 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef FRAG_MAXSIZE
|
||||
/** maximaum size of a fragment */
|
||||
#define FRAG_MAXSIZE 65536+4
|
||||
#endif
|
||||
|
||||
#ifndef FRAG_MAXIDS
|
||||
#define FRAG_MAXIDS 10
|
||||
#endif
|
||||
#define MAX_PKT_HDR_LEN 64
|
||||
|
||||
#ifndef FRAG_TTL
|
||||
#define FRAG_TTL 5
|
||||
#endif
|
||||
/** maximaum size of a fragment */
|
||||
#define FRAG_MAXSIZE (65536+MAX_PKT_HDR_LEN)
|
||||
|
||||
#define FRAG_MAXIDS 10
|
||||
|
||||
/**
|
||||
* TTL of received fragment in seconds
|
||||
*/
|
||||
#define FRAG_TTL 5
|
||||
|
||||
|
||||
struct frag {
|
||||
@ -57,7 +57,7 @@ struct frag {
|
||||
int bytesreceived;
|
||||
int bytesneeded;
|
||||
struct timespec t;
|
||||
uint8_t * header;
|
||||
// uint8_t * header;
|
||||
};
|
||||
|
||||
typedef struct frag frag_t; /*FRAGMAN;*/
|
||||
|
@ -85,7 +85,26 @@ static cw_ValValRange_t mac_types[]={
|
||||
{0,0,NULL}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
struct cw_ValBit xx[] = {
|
||||
{0,"ess"},
|
||||
{1,"ibss"},
|
||||
{2,"cf-pollable"},
|
||||
{3,"cf-poll-request"},
|
||||
{4,"privacy"},
|
||||
{5,"short-preamble"},
|
||||
{2,"pbcc"},
|
||||
{3,"cf-poll-request"},
|
||||
{2,NULL}
|
||||
};
|
||||
*/
|
||||
struct cw_ValBit frame_tunnel_bits[] = {
|
||||
{3,"native"},
|
||||
{2,"802-3"},
|
||||
{1,"local-bridging"},
|
||||
{0,"reserved"},
|
||||
{1, NULL}
|
||||
};
|
||||
|
||||
|
||||
static cw_ValStruct_t radio_admin_state[] = {
|
||||
@ -151,10 +170,13 @@ static struct cw_ElemHandler handlers[] = {
|
||||
CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE, /* Element ID */
|
||||
0,0, /* Vendor / Proto */
|
||||
1,1, /* min/max length */
|
||||
CW_TYPE_BYTE, /* type */
|
||||
CW_TYPE_BITS, /* type */
|
||||
"capwap/wtp-frame-tunnel-mode", /* Key */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic /* put */
|
||||
cw_out_generic, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
frame_tunnel_bits
|
||||
}
|
||||
,
|
||||
{
|
||||
|
@ -48,6 +48,16 @@ int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
|
||||
, uint8_t * dst);
|
||||
|
||||
|
||||
|
||||
|
||||
struct cw_ValBit frame_tunnel_bits_draft7[] = {
|
||||
{2,"native"},
|
||||
{1,"802-3"},
|
||||
{0,"local-bridging"},
|
||||
{1, NULL}
|
||||
};
|
||||
|
||||
|
||||
static cw_ValValRange_t cfg_type[]={
|
||||
{1,1,"1 - global"},
|
||||
{2,2,"2 - custom"},
|
||||
@ -679,8 +689,19 @@ static cw_ValStruct_t cisco_ap_venue_settings[]={
|
||||
|
||||
};
|
||||
|
||||
|
||||
static cw_ValValRange_t cisco_ap_modes[]={
|
||||
{0,0,"0 - local"},
|
||||
{1,1,"1 - monitor"},
|
||||
{2,2,"2 - FlexConnect"},
|
||||
{3,3,"3 - Rouge Detector"},
|
||||
{4,4,"4 - Sniffer"},
|
||||
{5,5,"5 - Bridge"},
|
||||
{0,0,NULL}
|
||||
};
|
||||
|
||||
static cw_ValStruct_t cisco_ap_mode_and_type[]={
|
||||
{CW_TYPE_BYTE,"mode",1,-1},
|
||||
{CW_TYPE_BYTE,"mode",1,-1,cisco_ap_modes},
|
||||
{CW_TYPE_BYTE,"type",1,-1},
|
||||
{NULL,NULL,0,0}
|
||||
};
|
||||
@ -946,6 +967,20 @@ static int cisco_data(struct cw_ElemHandler *eh,
|
||||
*/
|
||||
|
||||
static struct cw_ElemHandler handlers70[] = {
|
||||
{
|
||||
"WTP Frame Tunnel Mode (Draft 7)", /* name */
|
||||
CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE, /* Element ID */
|
||||
0,0, /* Vendor / Proto */
|
||||
1,1, /* min/max length */
|
||||
CW_TYPE_BITS, /* type */
|
||||
"capwap/wtp-frame-tunnel-mode", /* Key */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
frame_tunnel_bits_draft7
|
||||
}
|
||||
,
|
||||
|
||||
{
|
||||
"AC Name - (zero-length allowed)", /* name */
|
||||
|
@ -7,7 +7,7 @@ LIBARCHDIR := $(LIBDIR)/$(KERNEL)/$(ARCH)
|
||||
|
||||
CFLAGS+=-I../ -DUSE_OPENSSL -I../../include
|
||||
LDFLAGS+=-L$(LIBARCHDIR) -L/usr/local/lib
|
||||
LIBS+=-lcw -lnettle -lssl -lcrypto -ldl -lpthread -lmavl
|
||||
LIBS+=-lcw -lnettle -lssl -lcrypto -ldl -lpthread -lmavl
|
||||
|
||||
SOURCES=\
|
||||
wtp_main.c\
|
||||
|
@ -322,6 +322,9 @@ struct beacon_data{
|
||||
int dot11_get_beacon_data(struct apdata *ap,struct beacon_data *bd);
|
||||
|
||||
|
||||
#define cw_dot11_get_version(frame) ( (frame)[1] & 3)
|
||||
#define cw_dot11_get_type(frame) ( ( (frame)[1] & 0x0c) >> 2)
|
||||
#define cw_dot11_get_subtype(frame) ( (frame)[1] >> 4)
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
\
|
||||
|
||||
|
||||
#include "cw/val.h"
|
||||
#include "cw/dbg.h"
|
||||
@ -88,6 +88,40 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
||||
struct bootcfg bootcfg;
|
||||
|
||||
|
||||
#include "cw/file.h"
|
||||
#include <libwifi.h>
|
||||
|
||||
#include "cw/dot11.h"
|
||||
|
||||
int test()
|
||||
{
|
||||
int rc;
|
||||
char *f;
|
||||
size_t len;
|
||||
f=cw_load_file("wificap-005",&len);
|
||||
cw_dbg(DBG_X, "Loaded %d bytes",len);
|
||||
|
||||
// static int got_radiotap = 0;
|
||||
// struct libwifi_frame frame = {0};
|
||||
// rc = libwifi_get_wifi_frame(&frame, (unsigned char*)(f+16), len-16, got_radiotap);
|
||||
|
||||
|
||||
|
||||
// if (rc != 0) {
|
||||
// printf("[!] Error getting libwifi_frame: %d\n", rc);
|
||||
// }
|
||||
|
||||
// cw_dbg(DBG_X,"Frame CTL:%d,%d",frame.frame_control.type, frame.frame_control.subtype);
|
||||
|
||||
cw_dbg(DBG_X,"MY RESULT: Type %d, SubType %d",cw_dot11_get_type(f+16), cw_dot11_get_subtype(f+16));
|
||||
cw_dbg(DBG_X,"FRAME: %s",dot11_get_frame_name(f+16+1));
|
||||
|
||||
free(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct cw_Mod * mod;
|
||||
@ -102,6 +136,7 @@ int main (int argc, char **argv)
|
||||
const char *bind_addr, *disc_addr;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
{
|
||||
@ -135,6 +170,10 @@ int main (int argc, char **argv)
|
||||
bootcfg.nmods=2;
|
||||
}
|
||||
|
||||
// test();
|
||||
// stop();
|
||||
|
||||
|
||||
/*
|
||||
* set ths for production
|
||||
* cw_dbg_set_level(DBG_X,0);
|
||||
|
Loading…
Reference in New Issue
Block a user