New files fpr 802.11 items.
FossilOrigin-Name: 241c0aa5669c3f3719db4952c513f36a1d687719d689e7bf1687bed7fc0563ae
This commit is contained in:
parent
c9d93cea01
commit
5f0d4f441d
16
src/cw/capwap80211_items.c
Normal file
16
src/cw/capwap80211_items.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include "item.h"
|
||||
#include "capwap80211_items.h"
|
||||
#include "capwap80211_types.h"
|
||||
|
||||
|
||||
|
||||
const char CW_ITEM_80211_SUPPORTED_RATES[]="supported_rates";
|
||||
|
||||
|
||||
struct cw_itemdef capwap80211_itemdefs[] = {
|
||||
|
||||
{CW_ITEM_80211_SUPPORTED_RATES,CW_ITEM_NONE,CAPWAP80211_TYPE_RATESET},
|
||||
|
||||
};
|
||||
|
||||
|
8
src/cw/capwap80211_items.h
Normal file
8
src/cw/capwap80211_items.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __CAPWAP80211_H
|
||||
#define __CAPWAP80211_H
|
||||
|
||||
extern const char CW_ITEM_80211_SUPPORTED_RATES[];
|
||||
|
||||
|
||||
#endif
|
||||
|
100
src/cw/capwap80211_type_rateset.c
Normal file
100
src/cw/capwap80211_type_rateset.c
Normal file
@ -0,0 +1,100 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "capwap80211_types.h"
|
||||
#include "dot11.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int to_str(void *item,char *dst)
|
||||
{
|
||||
mbag_item_t *it= item;
|
||||
|
||||
uint8_t *data = (uint8_t*)it->data;
|
||||
int n=*data;
|
||||
data++;
|
||||
|
||||
char *d=dst;
|
||||
char *space="";
|
||||
int i;
|
||||
for (i=0; i<n; i++){
|
||||
int val = data[i];
|
||||
|
||||
|
||||
d+=sprintf(d,"%s",space);
|
||||
if (val & 0x80){
|
||||
d+=sprintf(d,"*");
|
||||
}
|
||||
|
||||
d+=sprintf(d,"%0.1f",dot11_rate2float(val & 0x7f));
|
||||
|
||||
space=" ";
|
||||
|
||||
}
|
||||
|
||||
return d-dst;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct mbag_item * from_str(const char *src)
|
||||
{
|
||||
mbag_item_t * item = mbag_item_new(CAPWAP80211_TYPE_RATESET);
|
||||
if (!item)
|
||||
return NULL;
|
||||
|
||||
if (strlen(src)==0)
|
||||
return 0;
|
||||
|
||||
uint8_t rates[64];
|
||||
int nrates =0;
|
||||
|
||||
const char *s = src;
|
||||
|
||||
while (*s!=0){
|
||||
while (*s==' ')
|
||||
s++;
|
||||
int m=0;
|
||||
if(*s=='*'){
|
||||
m=0x80;
|
||||
s++;
|
||||
}
|
||||
else{
|
||||
m=0;
|
||||
}
|
||||
|
||||
float val;
|
||||
int n=sscanf(s,"%f",&val);
|
||||
if (n!=1)
|
||||
break;
|
||||
|
||||
int r = dot11_float2rate(val) | m;
|
||||
|
||||
rates[nrates++]=r;
|
||||
|
||||
|
||||
while (*s!=0 && *s!=' ')
|
||||
s++;
|
||||
|
||||
}
|
||||
|
||||
uint8_t *data = malloc(nrates+1);
|
||||
*data=nrates;
|
||||
memcpy(data+1,rates,nrates);
|
||||
|
||||
item->data=data;
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const struct mbag_typedef capwap80211_type_rateset = {
|
||||
.name = "802.11 Rate Set",
|
||||
.del = free,
|
||||
.from_str = from_str,
|
||||
.to_str = to_str
|
||||
};
|
10
src/cw/capwap80211_types.h
Normal file
10
src/cw/capwap80211_types.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __CAPWAP80211_TYPES_H
|
||||
#define __CAPWAP80211_TYPES_H
|
||||
|
||||
#include "mbag.h"
|
||||
|
||||
extern const struct mbag_typedef capwap80211_type_rateset;
|
||||
|
||||
#define CAPWAP80211_TYPE_RATESET (&capwap80211_type_rateset)
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user