From f5e9417bd5b4a7128d4abeebd4bb95ae87276e91 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Sun, 9 Nov 2014 23:16:28 +0000 Subject: [PATCH] Initial commit. FossilOrigin-Name: 0affe26bfbc60feead59b740811a0c8b054ca7e6389a2a5e31c8215b0e56f41e --- src/wtp/dot11.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 src/wtp/dot11.c diff --git a/src/wtp/dot11.c b/src/wtp/dot11.c new file mode 100644 index 00000000..901f0a82 --- /dev/null +++ b/src/wtp/dot11.c @@ -0,0 +1,117 @@ +/* + This file is part of actube-wtp. + + libcapwap 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 . +*/ + +#include +#include + +#include "dot11.h" + + +uint8_t * mk_frame( uint8_t *b) +{ + +} + + +int add_bytes(uint8_t * b, uint8_t *bytes, int len) +{ + memcpy(b,bytes,len); + return len; +} + + +uint16_t get_capab_info(struct apdata *ap) +{ + uint16_t capab=0; + + capab |= WLAN_CAPAB_ESS; + + return capab; +} + + +int add_ssid_ie(uint8_t *b, const uint8_t *ssid, uint8_t ssid_len) +{ + *b = WLAN_EID_SSID; + *(b+1) = ssid_len; + memcpy(b+2,ssid,ssid_len); + return ssid_len+2; +} + + +int add_ds_ie(uint8_t *b) +{ + *b = WLAN_EID_DS_PARAMS; + *(b+1) = 1; + *(b+2) = 6; + return 3; + +} + + +int dot11_get_beacon_head(struct apdata *ap, uint8_t *dst, int *len) +{ + uint8_t * buffer = dst; + uint8_t *b = buffer; + +printf("t1\n"); + + /* set-up head */ + struct dot11_mgmt_head head; + memset (&head,0,sizeof(head)); + +printf("t2\n"); + + head.frame_control = htole16 (DOT11_FTYPE_MGMT | DOT11_STYPE_BEACON); + head.duration = htole16(0); + + /* destination address */ + memset(head.da, 0xff, sizeof(head.da)); +printf("t3\n"); + + /* source address */ + memcpy (head.sa , ap->mac,6); + memcpy (head.bssid , ap->mac,6); + b += add_bytes(b,&head,sizeof(head)); + +printf("t4\n"); + + struct dot11_mgmt_beacon beacon; + memset (&beacon,0,sizeof(beacon)); + beacon.capab_info=htole16(get_capab_info(ap)); + b += add_bytes(b,&beacon,sizeof(beacon)); + +printf("t5 ss %s\n",ap->ssid); + + b += add_ssid_ie(b,ap->ssid,strlen(ap->ssid)); +printf("t6\n"); + + b+= add_ds_ie(b); +printf("return ayhead = malloc(256); + dot11_get_beacon_head(ap,bd->head,&bd->head_len); + return 0; + +} + +