2016-03-12 01:54:46 +01:00
|
|
|
|
|
|
|
#include "cw/cw.h"
|
|
|
|
#include "cw/mod.h"
|
|
|
|
#include "cw/log.h"
|
|
|
|
#include "cw/dbg.h"
|
2016-03-13 09:41:46 +01:00
|
|
|
#include "cw/capwap_items.h"
|
2016-03-12 01:54:46 +01:00
|
|
|
|
|
|
|
#include "cw/action.h"
|
|
|
|
|
|
|
|
#include "mod_cisco.h"
|
|
|
|
#include "../modload.h"
|
|
|
|
|
2016-03-13 09:41:46 +01:00
|
|
|
#include "cw/vendors.h"
|
2016-03-12 01:54:46 +01:00
|
|
|
|
2016-04-18 07:40:30 +02:00
|
|
|
#include "include/cipwap_items.h"
|
|
|
|
|
2016-03-14 08:20:46 +01:00
|
|
|
extern int cisco_register_actions80211_wtp(struct cw_actiondef *def);
|
2016-03-12 01:54:46 +01:00
|
|
|
extern int cisco_register_actions_wtp(struct cw_actiondef *def);
|
|
|
|
|
|
|
|
static int register_actions(struct cw_actiondef *actions, int mode)
|
|
|
|
{
|
2018-02-25 19:12:28 +01:00
|
|
|
|
2016-03-12 01:54:46 +01:00
|
|
|
switch (mode) {
|
2018-02-26 12:21:50 +01:00
|
|
|
case CW_MOD_MODE_CAPWAP:
|
2016-03-12 01:54:46 +01:00
|
|
|
{
|
|
|
|
|
2018-02-25 19:12:28 +01:00
|
|
|
struct cw_Mod *cmod = modload_wtp("cipwap");
|
2016-03-12 01:54:46 +01:00
|
|
|
if (!cmod) {
|
|
|
|
cw_log(LOG_ERR,
|
2016-04-02 16:53:04 +02:00
|
|
|
"Can't initzialize mod_cisco, failed to load base mod mod_cipwap");
|
2016-03-12 01:54:46 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-02-26 12:21:50 +01:00
|
|
|
cmod->register_actions(actions, CW_MOD_MODE_CAPWAP);
|
2016-03-12 01:54:46 +01:00
|
|
|
|
|
|
|
int rc = cisco_register_actions_wtp(actions);
|
|
|
|
|
|
|
|
|
|
|
|
cw_dbg(DBG_INFO, "Initialized mod cisco with %d actions", rc);
|
2016-03-13 09:41:46 +01:00
|
|
|
return rc;
|
2016-03-12 01:54:46 +01:00
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
case CW_MOD_MODE_BINDINGS:
|
2016-03-12 01:54:46 +01:00
|
|
|
{
|
2018-02-25 19:12:28 +01:00
|
|
|
struct cw_Mod *cmod = modload_wtp("capwap80211");
|
2016-03-12 01:54:46 +01:00
|
|
|
if (!cmod) {
|
|
|
|
cw_log(LOG_ERR,
|
|
|
|
"Can't initzialize mod_cisco, failed to load base mod mod_capwap80211");
|
|
|
|
return 1;
|
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
cmod->register_actions(actions, CW_MOD_MODE_BINDINGS);
|
2016-03-14 08:20:46 +01:00
|
|
|
int rc = cisco_register_actions80211_wtp(actions);
|
2016-03-12 01:54:46 +01:00
|
|
|
cw_dbg(DBG_INFO, "Initialized mod cisco 80211 with %d actions", rc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-13 09:41:46 +01:00
|
|
|
#include "cw/capwap_items.h"
|
|
|
|
mbag_t cisco_config_wtp;
|
2016-03-12 01:54:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
static int init()
|
|
|
|
{
|
|
|
|
cw_dbg(DBG_INFO, "Initialiazing mod_cisco ...");
|
2016-03-13 09:41:46 +01:00
|
|
|
|
|
|
|
cisco_config_wtp = mbag_create();
|
|
|
|
|
|
|
|
bstrv_t v;
|
|
|
|
v = bstrv_create_from_str(CW_VENDOR_ID_CISCO,".x01000000");
|
|
|
|
mbag_set_bstr16(cisco_config_wtp,CW_ITEM_WTP_HARDWARE_VERSION,v);
|
|
|
|
|
2018-02-20 07:49:57 +01:00
|
|
|
// v = bstrv_create_from_str(CW_VENDOR_ID_CISCO,".x08007900");
|
|
|
|
v = bstrv_create_from_str(CW_VENDOR_ID_CISCO,".x07036500");
|
2016-03-13 09:41:46 +01:00
|
|
|
mbag_set_bstr16(cisco_config_wtp,CW_ITEM_WTP_SOFTWARE_VERSION,v);
|
|
|
|
|
|
|
|
v = bstrv_create_from_str(CW_VENDOR_ID_CISCO,".x0C030800");
|
|
|
|
mbag_set_bstr16(cisco_config_wtp,CW_ITEM_WTP_BOOTLOADER_VERSION,v);
|
|
|
|
|
|
|
|
|
2016-03-12 01:54:46 +01:00
|
|
|
// struct mod_ac *cmod = modload_ac("capwap");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-03-13 09:41:46 +01:00
|
|
|
static int init_config(mbag_t config)
|
|
|
|
{
|
2016-04-18 07:40:30 +02:00
|
|
|
bstr16_t gname = mbag_get_bstr16(config,CIPWAP_ITEM_WTP_GROUP_NAME,NULL);
|
2016-03-13 09:41:46 +01:00
|
|
|
if (!gname){
|
|
|
|
gname = bstr16_create_from_str("Entangled");
|
2016-04-18 07:40:30 +02:00
|
|
|
mbag_set_bstr16(config,CIPWAP_ITEM_WTP_GROUP_NAME,gname);
|
2016-03-13 09:41:46 +01:00
|
|
|
}
|
2016-03-13 18:55:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
mbag_t board_data = mbag_get_mbag_c(config,CW_ITEM_WTP_BOARD_DATA,mbag_create);
|
|
|
|
|
|
|
|
mbag_set_dword(board_data, CW_ITEM_WTP_BOARD_VENDOR,CW_VENDOR_ID_CISCO);
|
|
|
|
|
2016-04-05 08:35:35 +02:00
|
|
|
// mbag_set_bstr16(board_data, CW_ITEM_WTP_BOARD_MODELNO,bstr16_create_from_str("AIR-LAP1131AG-E-K9"));
|
|
|
|
mbag_set_bstr16(board_data, CW_ITEM_WTP_BOARD_MODELNO,bstr16_create_from_str("AIR-LAP1142N-E-K9"));
|
2016-03-13 18:55:03 +01:00
|
|
|
mbag_set_bstr16(board_data, CW_ITEM_WTP_BOARD_SERIALNO,bstr16_create_from_str("FCZ1441Q0XZ"));
|
|
|
|
mbag_set_bstr16(board_data, CW_ITEM_WTP_BOARD_ID,bstr16_create_from_cfgstr(".x0000"));
|
|
|
|
mbag_set_bstr16(board_data, CW_ITEM_WTP_BOARD_REVISION,bstr16_create_from_cfgstr(".x4230"));
|
|
|
|
// "F8 66 F2 A3 42 FC"
|
|
|
|
|
2016-03-13 09:41:46 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-03-12 01:54:46 +01:00
|
|
|
|
|
|
|
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);
|
2018-02-24 23:58:31 +01:00
|
|
|
if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
2016-03-12 01:54:46 +01:00
|
|
|
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
|
|
|
if (vendor_id == CW_VENDOR_ID_CISCO) {
|
|
|
|
// conn->actions = &actions;
|
2018-02-26 12:21:50 +01:00
|
|
|
if (mode == CW_MOD_MODE_CAPWAP) {
|
2016-03-12 01:54:46 +01:00
|
|
|
cw_dbg(DBG_MOD, "CISCO capwap detected: yes");
|
|
|
|
} else {
|
|
|
|
cw_dbg(DBG_MOD, "CISCO bindings detected: yes");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-26 12:21:50 +01:00
|
|
|
if (mode == CW_MOD_MODE_CAPWAP) {
|
2016-03-12 01:54:46 +01:00
|
|
|
cw_dbg(DBG_MOD, "CISCO capwap detected: no");
|
|
|
|
} else {
|
|
|
|
cw_dbg(DBG_MOD, "CISCO bindings detected: no");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-25 19:12:28 +01:00
|
|
|
static struct cw_Mod cisco_wtp = {
|
2016-03-12 01:54:46 +01:00
|
|
|
.name = "cisco",
|
|
|
|
.init = init,
|
2016-03-13 09:41:46 +01:00
|
|
|
.init_config = init_config,
|
2016-03-12 01:54:46 +01:00
|
|
|
.detect = detect,
|
|
|
|
.register_actions = register_actions
|
|
|
|
};
|
|
|
|
|
2018-02-25 19:12:28 +01:00
|
|
|
struct cw_Mod *mod_cisco_wtp()
|
2016-03-12 01:54:46 +01:00
|
|
|
{
|
|
|
|
return &cisco_wtp;
|
|
|
|
};
|