Compare commits

..

2 Commits

Author SHA1 Message Date
e974b3ae2d Work on wifi implemntation 2022-09-20 08:31:04 +02:00
07257f51fe Removed 2022-09-18 23:36:34 +02:00
11 changed files with 155 additions and 294 deletions

View File

@ -317,19 +317,51 @@ int run_update(struct wtpman *wtpman)
static int dataman_process_msg(struct cw_Conn *nc, uint8_t * rawmsg, int len, static int dataman_process_msg(struct cw_Conn *nc, uint8_t * rawmsg, int len,
struct sockaddr *from) struct sockaddr *from)
{ {
char rframe[1000];
int offs = cw_get_hdr_msg_offset(rawmsg); int offs = cw_get_hdr_msg_offset(rawmsg);
uint8_t * dot11frame = rawmsg + offs; uint8_t * frame = rawmsg + offs;
int dot11len = len-offs; int frame_len = len-offs;
cw_dbg_dot11_frame(dot11frame,dot11len); cw_dbg_dot11_frame(frame,frame_len);
char frame[1000]; /* dot11_init_assoc_resp(frame);
dot11_init_assoc_resp(frame);
dot11_copy_mac(dot11_get_sa(dot11frame),dot11_get_da(frame)); dot11_copy_mac(dot11_get_sa(dot11frame),dot11_get_da(frame));
dot11_copy_mac(dot11_get_bssid(dot11frame),dot11_get_bssid(frame)); dot11_copy_mac(dot11_get_bssid(dot11frame),dot11_get_bssid(frame));
dot11_copy_mac(dot11_get_da(dot11frame),dot11_get_sa(frame)); dot11_copy_mac(dot11_get_da(dot11frame),dot11_get_sa(frame));
dot11_set_seq(frame,0); dot11_set_seq(frame,0);
*/
if ( dot11_get_type_and_subtype(frame) == DOT11_ASSOC_REQ){
int l;
uint8_t rates[] = {
12,0x82,0x84,0x8b,0x96,0x0c,0x12,0x18,0x24,0x30,0x48,0x60,0x6c
};
cw_dbg(DBG_X, "there is an assoc request!");
uint8_t rframe[1000];
nc->mtu=800;
dot11_init_assoc_resp(rframe);
dot11_set_duration(rframe,100);
dot11_copy_mac(dot11_get_sa(frame),dot11_get_da(rframe));
dot11_copy_mac(dot11_get_bssid(frame),dot11_get_bssid(rframe));
dot11_copy_mac(dot11_get_da(frame),dot11_get_sa(rframe));
dot11_set_seq(rframe,dot11_get_seq(frame));
dot11_assoc_resp_set_cap(rframe,dot11_assoc_req_get_cap(frame));
dot11_assoc_resp_set_status_code(rframe,0);
dot11_assoc_resp_set_assoc_id(rframe,17);
l=24+6;
l+=dot11_put_supported_rates(rframe+l,rates);
cw_dbg_dot11_frame(rframe,l);
uint8_t buf[1024];
int hlen;
hlen = cw_init_capwap_packet(buf,1,0,NULL,NULL);
cw_set_hdr_flags(buf, CAPWAP_FLAG_HDR_T, 1);
cw_send_capwap_packet(nc,buf,hlen,rframe,l);
}
return 0; return 0;

View File

@ -565,6 +565,14 @@ int cw_out_generic_walk(struct cw_ElemHandler * handler, struct cw_ElemHandlerPa
int cw_out_generic0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params int cw_out_generic0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst,const char *key); , uint8_t * dst,const char *key);
int cw_init_capwap_packet( uint8_t * buf, int wbid ,int rid, bstr_t rmac, bstr_t wd);
int cw_send_capwap_packet(struct cw_Conn * conn, uint8_t * buf, int hlen, uint8_t * data, int len);
/** /**
*@} *@}
*/ */

View File

@ -1,12 +0,0 @@
#ifndef __CW_80211_H
#define __CW_80211_H
/*
int cw_in_80211_mac_operation(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from);
int cw_read_80211_mac_operation(uint8_t *data,mbag_t r);
*/
#endif

View File

@ -38,19 +38,14 @@
*@{ *@{
*/ */
/*
* @defgroup DebugFunctions Debug Functions
* @{
*/
uint32_t cw_dbg_opt_display = DBG_DISP_COLORS; uint32_t cw_dbg_opt_display = DBG_DISP_COLORS;
/** /**
* Current debug level * Contains all debuglevels currently set
*/ */
//static uint32_t cw_dbg_opt_level = 0;
//
static struct mavl * cw_dbg_opt_level = NULL; static struct mavl * cw_dbg_opt_level = NULL;
static int dbg_cmp(const void *a, const void*b) static int dbg_cmp(const void *a, const void*b)
{ {
return (*((int*)a)-*((int*)b)); return (*((int*)a)-*((int*)b));
@ -91,13 +86,6 @@ static const char * dbg_level_elem_all[] = {
static const char * dbg_level_std[] = { static const char * dbg_level_std[] = {
"msg","elem","msg_err", "elem_err", "pkt_err", "rfc", "warn", "state", "info", NULL "msg","elem","msg_err", "elem_err", "pkt_err", "rfc", "warn", "state", "info", NULL
/*
DBG_MSG_IN, DBG_MSG_OUT,
DBG_ELEM_IN, DBG_ELEM_OUT,
DBG_MSG_ERR, DBG_ELEM_ERR,
DBG_PKT_ERR, DBG_RFC, DBG_WARN,
DBG_STATE, DBG_INFO,
0*/
}; };
@ -159,14 +147,6 @@ struct cw_DbgStr cw_dbg_strings[] = {
{ 0, NULL } { 0, NULL }
}; };
/**
*@}
*/
static struct cw_StrListElem theme0[] = { static struct cw_StrListElem theme0[] = {
@ -217,7 +197,6 @@ static struct cw_StrListElem * color_on = theme0;
struct cw_StrListElem color_ontext[] = { struct cw_StrListElem color_ontext[] = {
/* {DBG_ELEM_DMP, "\x1b[37m"},*/
{DBG_ELEM_DMP_OUT, ANSI_BBLACK ANSI_ITALIC}, {DBG_ELEM_DMP_OUT, ANSI_BBLACK ANSI_ITALIC},
{DBG_ELEM_DMP_IN, ANSI_BBLACK}, {DBG_ELEM_DMP_IN, ANSI_BBLACK},
@ -296,22 +275,36 @@ const char *get_dbg_color_ontext(int level)
* @param level Level to check * @param level Level to check
* @return 0 if leveln is not set, otherwise level is set * @return 0 if leveln is not set, otherwise level is set
*/ */
int cw_dbg_is_level(int level) int cw_dbg_is_level(int level)
{ {
if (cw_dbg_opt_level == NULL) if (cw_dbg_opt_level == NULL)
return 0; return 0;
return mavl_get(cw_dbg_opt_level,&level) == NULL ? 0:1; return mavl_get(cw_dbg_opt_level,&level) == NULL ? 0:1;
}
/**
* Set debug level
* @param level debug level to set, allowed values are enumberated in #cw_dbg_levels structure.
* @param on 1: turns the specified debug level on, 0: turns the specified debug level off.
*
* To check if a specific debug level is set, call #cw_dbg_is_level.
*/
void cw_dbg_set_level (int level, int on)
{
int exists;
// if (level > 1 && (level &1)) if (cw_dbg_opt_level == NULL){
return 1; cw_dbg_opt_level = mavl_create(dbg_cmp,NULL,sizeof(int));
if (cw_dbg_opt_level == NULL)
return;
}
/* if (level >= DBG_ALL ){ if (on){
return 1; mavl_insert(cw_dbg_opt_level,&level,&exists);
}*/ }
// return (cw_dbg_opt_level & (level)); else
mavl_del(cw_dbg_opt_level,&level);
} }
@ -331,48 +324,12 @@ static void cw_dbg_vlog_line(struct cw_LogWriter * writer,
} }
writer->write(LOG_DEBUG,fbuf,args,writer); writer->write(LOG_DEBUG,fbuf,args,writer);
} }
/** /**
* Put a list of missing mandatory message elements to debug output * Display a packet on debugger
*/
void cw_dbg_missing_mand(int level, struct cw_Conn *conn, int ** ml, int n,
int * a)
{
/*
// if (!cw_dbg_is_level(DBG_MSG_ERR) || n == 0)
// return;
*/
char buffer[2000];
/* char *p = buffer; */
int i;
/* char *delim = "";*/
if (!cw_dbg_is_level(level) || n == 0)
return;
/*
// TODO XXXX
*/
for (i = 0; i < n; i++) {
/* p += sprintf(p, "%s", delim);
delim = ", ";
p += sprintf(p, "%s", cw_strelemp(conn->actions, ml[i]->elem_id));
*/
}
cw_dbg(level, "Missing mandatory elements: [%s]", buffer);
}
/**
* Display a packet on for debugger
*/ */
void cw_dbg_pkt(int level, struct cw_Conn *conn, uint8_t * packet, int len, void cw_dbg_pkt(int level, struct cw_Conn *conn, uint8_t * packet, int len,
struct sockaddr *from) struct sockaddr *from)
@ -558,46 +515,6 @@ void cw_dbg_elem(int level, struct cw_Conn *conn, int msg,
/**
* Set debug level
* @param level debug level to set, allowed values are enumberated in #cw_dbg_levels structure.
* @param on 1: turns the specified debug level on, 0: turns the specified debug level off.
*/
void cw_dbg_set_level (int level, int on)
{
int exists;
if (cw_dbg_opt_level == NULL){
cw_dbg_opt_level = mavl_create(dbg_cmp,NULL,sizeof(int));
if (cw_dbg_opt_level == NULL)
return;
}
if (on){
mavl_insert(cw_dbg_opt_level,&level,&exists);
}
else
mavl_del(cw_dbg_opt_level,&level);
/*
switch (level) {
case DBG_ALL:
if (on)
cw_dbg_opt_level = 0xffffffff;
else
cw_dbg_opt_level = 0;
break;
default:
if (on)
cw_dbg_opt_level |= (level);
else
cw_dbg_opt_level &= (0xffffffff) ^ (level);
}
*/
}
int cw_dbg_set_level_from_str0(const char *level,int on) int cw_dbg_set_level_from_str0(const char *level,int on)
{ {
@ -728,4 +645,3 @@ void cw_dbg_dot11_frame(uint8_t * frame,int len)
/**@}*/ /**@}*/
/**@}*/

View File

@ -39,7 +39,7 @@
/** /**
*@addtogroup LOGDBG *@addtogroup DBG
*@{ *@{
*/ */
@ -82,9 +82,6 @@ enum cw_dbg_levels{
/** Error in msg elements */ /** Error in msg elements */
DBG_ELEM_ERR, DBG_ELEM_ERR,
/** hex dump elements */
DBG_ELEM_DMP,
/** General infos, like CAPWAP state */ /** General infos, like CAPWAP state */
DBG_INFO, DBG_INFO,
@ -116,11 +113,13 @@ enum cw_dbg_levels{
/**Debug State machine */ /**Debug State machine */
DBG_STATE, DBG_STATE,
/** Infos about nessage composing */
DBG_MSG_COMPOSE, DBG_MSG_COMPOSE,
/** Debug Configuration updates */
DBG_CFG_UPDATES, DBG_CFG_UPDATES,
/** Debug Vendor elements */
DBG_ELEM_VNDR, DBG_ELEM_VNDR,
@ -130,11 +129,11 @@ enum cw_dbg_levels{
DBG_ALL, DBG_ALL,
/** Hexdump incoming msg elemenets */
DBG_ELEM_DMP_IN, DBG_ELEM_DMP_IN,
/** Hexdump outgoing msg elemenst */
DBG_ELEM_DMP_OUT, DBG_ELEM_DMP_OUT,
}; };
#define DBG_MSG (DBG_MSG_IN | DBG_MSG_OUT) #define DBG_MSG (DBG_MSG_IN | DBG_MSG_OUT)
@ -220,8 +219,6 @@ void cw_dbg_msg(int level,struct cw_Conn *conn, uint8_t * packet, int len,struct
char * cw_dbg_mkdmp(const uint8_t * data, int len); char * cw_dbg_mkdmp(const uint8_t * data, int len);
//void cw_dbg_version_subelem(int level, const char *context, int subtype, //void cw_dbg_version_subelem(int level, const char *context, int subtype,
// uint32_t vendor_id, const uint8_t * vstr, int len); // uint32_t vendor_id, const uint8_t * vstr, int len);
void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
const char *header, const char *prefix, const char *footer );
/** /**
* Set debug level * Set debug level

View File

@ -1,135 +0,0 @@
/*
This file is part of actube.
actube is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*@file
*@brief
*/
#include "dbg.h"
/**
*@addtogroup DbgOptions
*@{
*/
/**
* Debug strings
*/
struct cw_StrListElem cw_dbg_strings[] = {
{ DBG_INFO, "info", },
{ DBG_PKT_IN, "pkt_in" },
{ DBG_PKT_OUT, "pkt_out" },
{ DBG_PKT_ERR, "pkt_err" },
{ DBG_PKT_DMP_IN, "pkt_dmp_in" },
{ DBG_PKT_DMP_OUT, "pkt_dmp_out" },
{ DBG_MSG_IN, "msg_in" },
{ DBG_MSG_OUT, "msg_out" },
{ DBG_MSG_DMP_IN, "msg_dmp_in" },
{ DBG_MSG_DMP_OUT, "msg_dmp_out" },
{ DBG_MSG_ERR, "msg_err"},
{ DBG_RFC, "rfc", },
{ DBG_ELEM_IN, "elem_in"},
{ DBG_ELEM_OUT, "elem_out"},
{ DBG_ELEM_DMP, "elem_dmp"},
{ DBG_ELEM_ERR, "elem_err" },
{ DBG_ELEM_DETAIL_IN, "elem_detail_in" },
{ DBG_ELEM_DETAIL_OUT, "elem_detail_out" },
{ DBG_ELEM_VNDR, "elem_vndr"},
{ DBG_DTLS, "dtls" },
{ DBG_DTLS_BIO, "dtls_bio" },
{ DBG_DTLS_BIO_DMP, "dtls_bio_dmp"},
{ DBG_DTLS_DETAIL, "dtls_detail"},
{ DBG_CFG_UPDATES, "cfg_updates" },
{ DBG_X, "x" },
// {DBG_CFG_DMP, "cfg_dmp" },
{ DBG_WARN, "warn" },
{ DBG_MOD, "mod"},
{ DBG_STATE, "state" },
{ DBG_MSG_COMPOSE, "msg_compose" },
{ (DBG_MSG_IN | DBG_MSG_OUT), "msg" },
{ (DBG_PKT_IN | DBG_PKT_OUT), "pkt" },
{ (DBG_ELEM_IN | DBG_ELEM_OUT), "elem" },
{ (DBG_ELEM_DETAIL_IN | DBG_ELEM_DETAIL_OUT), "elem_detail" },
{ (DBG_ELEM_IN | DBG_ELEM_OUT | DBG_ELEM_DMP | DBG_ELEM_DETAIL_IN | DBG_ELEM_DETAIL_OUT), "elem_all" },
{ ( DBG_MSG_IN | DBG_MSG_OUT |
DBG_ELEM_IN | DBG_ELEM_OUT |
DBG_MSG_ERR | DBG_ELEM_ERR |
DBG_PKT_ERR | DBG_RFC | DBG_WARN
| DBG_STATE | DBG_INFO), "std" },
{ DBG_ALL, "all"},
{ CW_STR_STOP, NULL }
};
/**
*@}
*/
/*
struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
{"info",DBG_CW_INFO},
{"msg",DBG_MSG},
{"elem",DBG_ELEM},
{"elem_dmp",DBG_ELEM_DMP},
{"rfc",DBG_CW_RFC},
{"pkt_in",DBG_CW_PKT_IN},
{"pkt_out",DBG_CW_PKT_OUT},
{"pkt_dtl",DBG_CW_PKT_DTL},
{"pkt",(DBG_CW_PKT_IN | DBG_CW_PKT_OUT)},
{"pkt_dmp",DBG_CW_PKT_DMP},
{"pkt_err",DBG_CW_PKT_ERR},
{"msg_err",DBG_MSG_ERR},
{"img_dtl",DBG_CW_IMG_DTL},
{"elem_err",DBG_ELEM_ERR},
{"dtls",DBG_DTLS},
{"dtls_detail",DBG_DTLS_DETAIL},
{"dtls_bio",DBG_DTLS_BIO},
{"dtls_bio_dmp",DBG_DTLS_BIO_DMP},
{"all",DBG_ALL},
{"err",DBG_ERR},
{0,0}
};
*/

View File

@ -21,6 +21,7 @@
#endif #endif
#include "strlist.h" #include "strlist.h"
#include "bstr.h"
/** /**
* @defgroup DOT11_FRAME_TYPES Frame Types * @defgroup DOT11_FRAME_TYPES Frame Types
@ -238,7 +239,9 @@ int dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len);
*/ */
#define dot11_rate2float(rate) (((float)(rate))/2.0) #define dot11_rate2float(rate) (((float)(rate))/2.0)
int dot11_put_supported_rates(uint8_t *dst, float *basic, float *rates); int dot11_put_supported_rates(uint8_t *dst, bstr_t src);
// float *basic, float *rates);
int dot11_put_dsss_param_set(uint8_t *dst,int ch); int dot11_put_dsss_param_set(uint8_t *dst,int ch);
@ -295,10 +298,22 @@ extern struct cw_StrListElem dot11_names[];
*/ */
#define dot11_assoc_resp_set_cap(frame,cap)\ #define dot11_assoc_resp_set_cap(frame,cap)\
dot11_set_word(dot11_get_body(frame),cap) dot11_set_word(dot11_get_body(frame),cap)
#define dot11_assoc_resp_get_cap(frame)\
dot11_get_word(dot11_get_body(frame))
#define dot11_assoc_resp_set_status_code(frame,code)\ #define dot11_assoc_resp_set_status_code(frame,code)\
dot11_set_word(dot11_get_body(frame)+2,code) dot11_set_word(dot11_get_body(frame)+2,code)
#define dot11_assoc_resp_get_status_code(frame)\
dot11_get_word(dot11_get_body(frame)+2)
#define dot11_assoc_resp_set_assoc_id(frame,id)\ #define dot11_assoc_resp_set_assoc_id(frame,id)\
dot11_set_word(dot11_get_body(frame)+4,id) dot11_set_word(dot11_get_body(frame)+4,id)
#define dot11_assoc_resp_get_assoc_id(frame)\
dot11_get_word(dot11_get_body(frame)+4)
//#define dot11_assoce_resp_get_var_body(frame) //#define dot11_assoce_resp_get_var_body(frame)
// (get_frame_body(frame)+6) // (get_frame_body(frame)+6)
@ -309,6 +324,12 @@ extern struct cw_StrListElem dot11_names[];
memcpy(dst,src,6); memcpy(dst,src,6);
struct cw_Dot11Elemenst {
bstr_t supportet_rates;
};
int dot11_init_assoc_resp(uint8_t * dst);
/** /**

View File

@ -45,7 +45,9 @@ int dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len){
return len; return len;
} }
int dot11_put_supported_rates(uint8_t *dst, float *basic, float *rates){
int dot11_convert_supported_rates(uint8_t *dst, float *basic, float *rates){
uint8_t *d = dst+2; uint8_t *d = dst+2;
while(*basic != 0.0){ while(*basic != 0.0){
*d++ = 0x80 | dot11_float2rate(*basic); *d++ = 0x80 | dot11_float2rate(*basic);
@ -62,6 +64,15 @@ int dot11_put_supported_rates(uint8_t *dst, float *basic, float *rates){
} }
int dot11_put_supported_rates(uint8_t * dst, bstr_t src)
{
int l = bstr_len(src);
dot11_set_byte(dst,DOT11_ELEM_SUPPORTED_RATES);
memcpy(dst+1, src,l+1);
return l+2;
}
int dot11_put_dsss_param_set(uint8_t *dst,int ch) { int dot11_put_dsss_param_set(uint8_t *dst,int ch) {
dot11_set_byte(dst,DOT11_ELEM_DSSS_PARAM_SET); dot11_set_byte(dst,DOT11_ELEM_DSSS_PARAM_SET);

View File

@ -5,9 +5,9 @@ OBJDIR=./o
LIBDIR := ../../lib LIBDIR := ../../lib
LIBARCHDIR := $(LIBDIR)/$(KERNEL)/$(ARCH) LIBARCHDIR := $(LIBDIR)/$(KERNEL)/$(ARCH)
CFLAGS+=-I../ -DUSE_OPENSSL -I../../include CFLAGS+=-I../ -DUSE_OPENSSL -I../../include -I/usr/include/libnl3
LDFLAGS+=-L$(LIBARCHDIR) -L/usr/local/lib LDFLAGS+=-L$(LIBARCHDIR) -L/usr/local/lib
LIBS+=-lcw -lnettle -lssl -lcrypto -ldl -lpthread -lmavl -lwifi LIBS+=-lcw -lnettle -lssl -lcrypto -ldl -lpthread -lmavl -lwifi -lnl-3 -lnl-genl-3
SOURCES=\ SOURCES=\
wtp_main.c\ wtp_main.c\
@ -15,6 +15,7 @@ SOURCES=\
join.c\ join.c\
configure.c\ configure.c\
run.c\ run.c\
changestate.c changestate.c \
nlt.c
include ../prog.mk include ../prog.mk

View File

@ -1,16 +1,17 @@
#include "netlink/netlink.h" #include <netlink/netlink.h>
#include "netlink/genl/genl.h" #include <netlink/genl/genl.h>
#include "netlink/genl/ctrl.h" #include <netlink/genl/ctrl.h>
#include <netlink/msg.h> #include <netlink/msg.h>
#include "cw/log.h" #include "cw/log.h"
#include "cw/dbg.h" #include "cw/dbg.h"
#include "cw/avltree.h"
#include <mavl.h>
#include "nlt.h" #include "nlt.h"
/*
static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg) static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
{ {
@ -32,21 +33,22 @@ static int wiphylist_cmp(const void * d1,const void *d2)
} }
struct avltree * wiphylist_create() struct mavl * wiphylist_create()
{ {
return avltree_create(wiphylist_cmp,0); return mavl_create(wiphylist_cmp,0,sizeof(struct nlt_wiphyinfo));
} }
struct nlt_wiphyinfo * wiphylist_get( struct avltree * l,int idx) struct nlt_wiphyinfo * wiphylist_get( struct mavl * l,int idx)
{ {
//return avltree_get(l); //return avltree_get(l);
} }
struct nlt_wiphyinfo * nlt_wiphylist_add(struct avltree * t, struct nlt_wiphyinfo * wi) struct nlt_wiphyinfo * nlt_wiphylist_add(struct mavl * t, struct nlt_wiphyinfo * wi)
{ {
return avltree_add(t,wi); int exists;
return mavl_insert(t,wi,exists);
} }
@ -258,7 +260,7 @@ static int nlCallback(struct nl_msg *msg, void *arg)
genlmsg_attrlen(ghdr, 0), NULL); genlmsg_attrlen(ghdr, 0), NULL);
if (rc < 0) { if (rc < 0) {
cw_dbg(DBG_DRV_ERR, "nla_parse failed: %d %d", rc, nl_geterror(rc)); cw_dbg(DBG_X, "nla_parse failed: %d %d", rc, nl_geterror(rc));
return NL_SKIP; return NL_SKIP;
} }
@ -267,7 +269,7 @@ static int nlCallback(struct nl_msg *msg, void *arg)
switch (cmd) { switch (cmd) {
case NL80211_CMD_NEW_WIPHY: case NL80211_CMD_NEW_WIPHY:
add_wiphy_data(msgattribs, arg); //add_wiphy_data(msgattribs, arg);
break; break;
// case NL80211_CMD_NEW_INTERFACE: // case NL80211_CMD_NEW_INTERFACE:
// add_interface_data(msgattribs); // add_interface_data(msgattribs);
@ -337,7 +339,6 @@ static int get_wiphy_info_cb(struct nl_msg * msg,void * arg)
int nlt_get_wiphy_list(struct nl_sock *sk) int nlt_get_wiphy_list(struct nl_sock *sk)
{ {
struct nlt_wiphyinfo ** wi = malloc (sizeof(struct nlt_wiphyinfo *)*NLT_MAX_WIPHYINDEX); struct nlt_wiphyinfo ** wi = malloc (sizeof(struct nlt_wiphyinfo *)*NLT_MAX_WIPHYINDEX);
if (wi==0) if (wi==0)
return 0; return 0;
@ -347,9 +348,9 @@ int nlt_get_wiphy_list(struct nl_sock *sk)
struct nl_msg * msg = nlt_nl_msg_new(sk,NL80211_CMD_GET_WIPHY,NLM_F_DUMP); struct nl_msg * msg = nlt_nl_msg_new(sk,NL80211_CMD_GET_WIPHY,NLM_F_DUMP);
nl_send_auto(sk, msg); nl_send_auto(sk, msg);
struct nl_cb *nl_cb = get_nl_cb(get_wiphy_info_cb,wi); struct nl_cb *nl_cb = get_nl_cb(get_wiphy_info_cb,wi);
// while(1){ while(1){
int nlr = nl_recvmsgs(sk, nl_cb); int nlr = nl_recvmsgs(sk, nl_cb);
// } }
int i; int i;
@ -364,4 +365,15 @@ int nlt_get_wiphy_list(struct nl_sock *sk)
} }
*/ nlt_test()
{
struct nl_sock *nl;
nl = nl_socket_alloc();
if (!nl) {
fprintf(stderr, "Failed to allocate netlink socket.\n");
return -ENOMEM;
}
nlt_get_wiphy_list(nl);
}

View File

@ -100,6 +100,11 @@ int test()
size_t len; size_t len;
f=(uint8_t*)cw_load_file("wificap-002",&len); f=(uint8_t*)cw_load_file("wificap-002",&len);
cw_dbg(DBG_X, "Loaded %d bytes",len); cw_dbg(DBG_X, "Loaded %d bytes",len);
int l;
uint8_t rates[] = {
12,0x82,0x84,0x8b,0x96,0x0c,0x12,0x18,0x24,0x30,0x48,0x60,0x6c
};
// static int got_radiotap = 0; // static int got_radiotap = 0;
// struct libwifi_frame frame = {0}; // struct libwifi_frame frame = {0};
@ -145,8 +150,12 @@ int test()
dot11_assoc_resp_set_cap(rframe,dot11_assoc_req_get_cap(frame)); dot11_assoc_resp_set_cap(rframe,dot11_assoc_req_get_cap(frame));
dot11_assoc_resp_set_status_code(rframe,0); dot11_assoc_resp_set_status_code(rframe,0);
dot11_assoc_resp_set_assoc_id(rframe,17); dot11_assoc_resp_set_assoc_id(rframe,17);
l=24+6;
cw_dbg_dot11_frame(rframe,24+6);
l+=dot11_put_supported_rates(rframe+l,rates);
cw_dbg_dot11_frame(rframe,l);
@ -205,6 +214,7 @@ int main (int argc, char **argv)
} }
test(); test();
nlt_test();
stop(); stop();