Initial commit.

FossilOrigin-Name: 2a25e1b91d547dd1ba641479ba7e335b6b1d0868690cfa05207e9da8f5d182a1
This commit is contained in:
7u83@mail.ru 2016-03-12 00:54:46 +00:00
parent 92e961b5c1
commit 5e0c583669
2 changed files with 240 additions and 0 deletions

View File

@ -0,0 +1,113 @@
/*
This file is part of libcapwap.
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 <http://www.gnu.org/licenses/>.
*/
#include "cw/capwap.h"
#include "cw/cipwap.h"
#include "cw/action.h"
#include "cw/capwap_items.h"
#include "cw/strheap.h"
#include "cw/radio.h"
#include "cw/capwap_cisco.h"
#include "cw/capwap80211.h"
#include "mod_cisco.h"
#include "cisco.h"
static cw_action_in_t actions_in[] = {
/* End of list */
{0, 0}
};
static cw_action_out_t actions_out[]={
{0,0}
};
#include "cw/item.h"
static struct cw_itemdef _capwap_itemdefs[] = {
{"wtp_name_cisco",CW_ITEM_NONE,MBAG_STR},
/* {"wtp_mac_type",CW_ITEM_NONE,MBAG_BYTE},
{"discovery_type",CW_ITEM_NONE,MBAG_BYTE},
{"wtp_frame_tunnel_mode",CW_ITEM_NONE,MBAG_BYTE},
*/ {CW_ITEM_NONE}
};
#include "../modload.h"
int cisco_register_actions_wtp(struct cw_actiondef *def)
{
int rc;
rc = cw_actionlist_in_register_actions(def->in, actions_in);
rc += cw_actionlist_out_register_actions(def->out, actions_out);
rc += cw_strheap_register_strings(def->strmsg, capwap_strings_msg);
rc += cw_strheap_register_strings(def->strelem, cipwap_strings_elem);
rc += cw_itemdefheap_register(def->items, _capwap_itemdefs);
rc += cw_itemdefheap_register(def->radioitems, capwap_radioitemdefs);
// intavltree_add(def->wbids, 0);
return rc;
}
int cisco_register_actions80211_wtp(struct cw_actiondef *def)
{
int rc;
rc=0;
// rc = cw_actionlist_in_register_actions(def->in, actions80211_in);
/* rc += cw_actionlist_out_register_actions(def->out, actions_out);
rc += cw_strheap_register_strings(def->strmsg, capwap_strings_msg);
rc += cw_strheap_register_strings(def->strelem, cipwap_strings_elem);
rc += cw_itemdefheap_register(def->items, _capwap_itemdefs);
rc += cw_itemdefheap_register(def->radioitems, capwap_radioitemdefs);
intavltree_add(def->wbids, 0);
*/
return rc;
}

View File

@ -0,0 +1,127 @@
#include "cw/cw.h"
#include "cw/mod.h"
#include "cw/log.h"
#include "cw/dbg.h"
#include "cw/action.h"
#include "mod_cisco.h"
#include "../modload.h"
extern int cisco_register_actions80211_ac(struct cw_actiondef *def);
extern int cisco_register_actions_wtp(struct cw_actiondef *def);
static int register_actions(struct cw_actiondef *actions, int mode)
{
switch (mode) {
case MOD_MODE_CAPWAP:
{
struct mod_ac *cmod = modload_wtp("capwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initzialize mod_cisco, failed to load base mod mod_capwap");
return 1;
}
printf("Nax\n");
cmod->register_actions(actions, MOD_MODE_CAPWAP);
printf("No\n");
int rc = cisco_register_actions_wtp(actions);
printf("Nuex\n");
cw_dbg(DBG_INFO, "Initialized mod cisco with %d actions", rc);
return 0;
}
case MOD_MODE_BINDINGS:
{
struct mod_ac *cmod = modload_wtp("capwap80211");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initzialize mod_cisco, failed to load base mod mod_capwap80211");
return 1;
}
cmod->register_actions(actions, MOD_MODE_BINDINGS);
int rc = cisco_register_actions80211_ac(actions);
cw_dbg(DBG_INFO, "Initialized mod cisco 80211 with %d actions", rc);
return 0;
}
}
return 0;
}
static int init()
{
cw_dbg(DBG_INFO, "Initialiazing mod_cisco ...");
// struct mod_ac *cmod = modload_ac("capwap");
return 1;
}
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
struct sockaddr *from, int mode)
{
int offset = cw_get_hdr_msg_offset(rawmsg);
const uint8_t *msg_ptr = rawmsg + offset;
const uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
const uint8_t *elem;
/* To detect a Cisco AP we look for any vendor
* specific payload Cisco identifier */
cw_foreach_elem(elem, elems_ptr, elems_len) {
int id = cw_get_elem_id(elem);
if (id == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
if (vendor_id == CW_VENDOR_ID_CISCO) {
// conn->actions = &actions;
if (mode == MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "CISCO capwap detected: yes");
} else {
cw_dbg(DBG_MOD, "CISCO bindings detected: yes");
}
return 1;
}
}
}
if (mode == MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "CISCO capwap detected: no");
} else {
cw_dbg(DBG_MOD, "CISCO bindings detected: no");
}
return 0;
}
static struct mod_ac cisco_wtp = {
.name = "cisco",
.init = init,
.detect = detect,
.register_actions = register_actions
};
struct mod_ac *mod_cisco_wtp()
{
return &cisco_wtp;
};