Working on nl driver... more testing.

FossilOrigin-Name: ebb74d0b26abb33cff11c8eeb3f3ba264b900f5a02b377ffc0d9c90085739fa8
This commit is contained in:
7u83@mail.ru 2014-11-09 23:16:55 +00:00
parent f5e9417bd5
commit e341d7ec4c
3 changed files with 92 additions and 12 deletions

View File

@ -94,6 +94,7 @@ OBJS += wtp_main.o
OBJS += discovery.o
OBJS += wtp_interface.o
OBJS += wtpdrv.o
OBJS += dot11.o
OBJS += join.o
OBJS += run.o
OBJS += sulking.o

View File

@ -1,3 +1,10 @@
#ifndef __DOT11_H
#define __DOT11_H
#include <stdint.h>
struct dot11_mgmt_head {
uint16_t frame_control;
uint16_t duration;
@ -7,6 +14,13 @@ struct dot11_mgmt_head {
uint16_t seq_ctrl;
};
struct dot11_mgmt_beacon{
uint8_t timestamp[8];
uint16_t beacon_int;
uint16_t capab_info;
};
#define ETH_ALEN 6
/* SA Query Action frame (IEEE 802.11w/D8.0, 7.4.9) */
#define WLAN_SA_QUERY_REQUEST 0
@ -262,3 +276,52 @@ struct dot11_mgmt {
#define WLAN_EID_IBSS_DFS 41
/* EIDs defined by IEEE 802.11h - END */
/* capability bits */
#define WLAN_CAPAB_ESS 0x001
#define WLAN_CAPAB_IBSS 0x002
#define WLAN_CAPAB_CF_POLLABLE 0x004
#define WLAN_CAPAB_CF_POLL_REQUEST 0x008
#define WLAN_CAPAB_PRIVACY 0x010
#define WLAN_CAPAB_SHORT_PREAMBLE 0x020
#define WLAN_CAPAB_PBCC 0x040
#define WLAN_CAPAB_CHANNEL_AGILITY 0x080
#define WLAN_CAPAB_SPECTRUM_MGMT BIT 0x100
#define WLAN_CAPAB_SHORT_SLOT_TIME BIT 0x200
#define WLAN_CAPAB_DSSS_OFDM 0x400
struct apdata {
int phy;
uint32_t idx;
uint8_t mac[6];
const char * ssid;
};
struct beacon_data{
uint8_t * head;
int head_len;
uint8_t * tail;
int tail_len;
};
dot11_get_beacon_data(struct apdata *ap,struct beacon_data *bd);
#endif

View File

@ -56,14 +56,8 @@ typedef __le16 le16
struct radioinfo radioinfos[31];
static struct nl_sock * sk;
struct rd {
int phy;
uint32_t idx;
uint8_t mac[6];
};
static struct rd rd;
static struct apdata rd;
struct wiphydata {
@ -141,6 +135,10 @@ struct hostapd_freq_params {
static int nlt_put_freq_params(struct nl_msg *msg,
struct hostapd_freq_params *freq)
{
@ -718,6 +716,8 @@ int start_ap(struct nl_sock *sk)
// NL80211_CMD_SET_BEACON, 0);
/*
struct dot11_mgmt *head = NULL;
head = malloc(256);
@ -725,8 +725,8 @@ int start_ap(struct nl_sock *sk)
head->frame_control = htole16 (DOT11_FTYPE_MGMT | DOT11_STYPE_BEACON) ;
head->duration = htons(0);
/* destination address */
head->duration = htole16(0);
memset(head->da, 0xff, sizeof(head->da));
memcpy (head->sa , rd.mac,6);
memcpy (head->bssid , rd.mac,6);
@ -742,17 +742,28 @@ int start_ap(struct nl_sock *sk)
hs += sizeof( head->u.beacon);
printf("Head size is now %d\n",hs);
*/
struct beacon_data bd;
NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, hs, head);
const char *ssid = "HelloWorld";
struct apdata * ap = &rd;
ap->ssid=ssid;
printf("Get Beacon Data \n");
dot11_get_beacon_data(ap,&bd);
printf("Got Beaqcon Fata\n");
NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, bd.head_len, bd.head);
printf("Put message 1\n");
/*
tail = (uint8_t*)(head)+hs;
uint8_t * pos = tail;
printf("Put message 1 posss\n");
const char *ssid = "HelloWorld";
*pos = WLAN_EID_SSID;
pos++;
@ -769,7 +780,7 @@ printf ("Memcoy done\n");
printf ("Tail len %d\n",tl);
NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tl, tail);
*/
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, rd.idx);
NLA_PUT_U16(msg, NL80211_ATTR_BEACON_INTERVAL, 100);
NLA_PUT_U32(msg, NL80211_ATTR_HIDDEN_SSID, NL80211_HIDDEN_SSID_NOT_IN_USE);
@ -916,8 +927,13 @@ int gr()
del_if("wlan0");
make_if("wlan0");
printf("Now starting the AP\n");
start_ap(sk);
printf("Started the AP\n");
sleep(1000);
return 0;