Separating cipwap/capwap/...

FossilOrigin-Name: b1ce08cd3e7e9389bef7f6f2b038cd5fc95c31150341b17b78b8a116594cb4cb
This commit is contained in:
7u83@mail.ru
2016-04-02 07:05:07 +00:00
parent 9915c579c8
commit da9f2ca6af
39 changed files with 450 additions and 141 deletions

View File

@ -94,7 +94,7 @@ static cw_action_in_t actions_in[] = {
.msg_id = CW_MSG_DISCOVERY_REQUEST,
.elem_id = CW_ELEM_WTP_MAC_TYPE,
.start = cw_in_generic2,
.item_id = "wtp_mac_type",
.item_id = CW_ITEM_WTP_MAC_TYPE,
.mand = 1,
.min_len = 1,
.max_len = 1
@ -314,7 +314,7 @@ static cw_action_in_t actions_in[] = {
/* --------------------------------------------------------------------------
* Configuration Status Request
* Configuration Status Request - IN
*/
{
.capwap_state = CW_STATE_CONFIGURE,
@ -342,7 +342,7 @@ static cw_action_in_t actions_in[] = {
.capwap_state = CW_STATE_CONFIGURE,
.msg_id = CW_MSG_CONFIGURATION_STATUS_REQUEST,
.elem_id = CW_ELEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_ITEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_RADIOITEM_ADMIN_STATE,
.start = cw_in_radio_administrative_state,
.mand = 1
@ -417,8 +417,8 @@ static cw_action_in_t actions_in[] = {
.capwap_state = CW_STATE_CONFIGURE,
.msg_id= CW_MSG_CHANGE_STATE_EVENT_REQUEST,
.elem_id = CW_ELEM_RADIO_OPERATIONAL_STATE,
.item_id = CW_RADIO_OPER_STATE,
.start = cw_in_radio_operational_state,
.item_id = CW_RADIOITEM_OPER_STATE,
.start = cw_in_radio_generic, //operational_state,
.min_len=3,
.max_len=3,
.mand = 0
@ -465,7 +465,7 @@ static cw_action_in_t actions_in[] = {
.capwap_state = CW_STATE_RUN,
.msg_id= CW_MSG_CHANGE_STATE_EVENT_REQUEST,
.elem_id = CW_ELEM_RADIO_OPERATIONAL_STATE,
.item_id = CW_RADIO_OPER_STATE,
.item_id = CW_RADIOITEM_OPER_STATE,
.start = cw_in_radio_operational_state,
.min_len=3,
.max_len=3,
@ -730,6 +730,17 @@ static cw_action_out_t actions_out[]={
}
,
/* Radio Administrative State - OUT */
{
.msg_id = CW_MSG_CONFIGURATION_UPDATE_REQUEST,
.elem_id = CW_ELEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_RADIOITEM_ADMIN_STATE,
.out = cw_out_radio_administrative_states,
.get = cw_out_get_outgoing,
.mand = 0
}
,
@ -772,7 +783,7 @@ int capwap_register_actions_ac(struct cw_actiondef *def)
rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem);
rc += cw_itemdefheap_register(def->items, capwap_itemdefs);
rc += cw_itemdefheap_register(def->radioitems, capwap_radioitemdefs);
rc += cw_itemdefheap_register(def->radioitems, capwap_radiodefs);
intavltree_add(def->wbids, 0);

View File

@ -353,9 +353,9 @@ static cw_action_in_t actions_in[] = {
.capwap_state = CW_STATE_RUN,
.msg_id = CW_MSG_CONFIGURATION_UPDATE_REQUEST,
.elem_id = CW_ELEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_ITEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_RADIOITEM_ADMIN_STATE,
.start = cw_in_radio_administrative_state,
.mand = 1
.mand = 0
}
,
@ -568,7 +568,7 @@ static cw_action_out_t actions_out[] = {
/* Radio Admin State - Config Status Request */
{
.msg_id = CW_MSG_CONFIGURATION_STATUS_REQUEST,
.item_id = CW_ITEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_RADIOITEM_ADMIN_STATE,
.out = cw_out_radio_administrative_states,
.get = cw_out_get_config,
.mand = 1

View File

@ -29,7 +29,7 @@ static cw_action_in_t actions_ac_in[] = {
.capwap_state = CW_STATE_DISCOVERY,
.msg_id = CW_MSG_DISCOVERY_REQUEST,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION,
.start = cw_in_radio_generic,
.mand = 1,
.min_len = 5,
@ -47,7 +47,7 @@ static cw_action_in_t actions_ac_in[] = {
.capwap_state = CW_STATE_JOIN,
.msg_id = CW_MSG_JOIN_REQUEST,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION,
.start = cw_in_radio_generic,
.mand = 1,
.min_len = 5,
@ -64,7 +64,7 @@ static cw_action_in_t actions_ac_in[] = {
.capwap_state = CW_STATE_CONFIGURE,
.msg_id = CW_MSG_CONFIGURATION_STATUS_REQUEST,
.elem_id = CW_ELEM80211_SUPPORTED_RATES,
.item_id = CW_ITEM80211_SUPPORTED_RATES,
.item_id = CW_RADIOITEM80211_SUPPORTED_RATES,
.start = cw_in_radio_generic,
.mand = 0,
.min_len = 3,
@ -90,8 +90,8 @@ cw_action_out_t actions_ac_out[]={
/* 802.11 Radio Information - Discovery Response */
{
.msg_id = CW_MSG_DISCOVERY_RESPONSE,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION ,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION ,
.out = cw_out_radio_infos,
.mand = 1
}
@ -105,8 +105,8 @@ cw_action_out_t actions_ac_out[]={
/* 802.11 Radio Information - Discovery Response */
{
.msg_id = CW_MSG_JOIN_RESPONSE,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION,
.out = cw_out_radio_infos,
.mand = 1
}
@ -135,6 +135,7 @@ int capwap80211_register_actions_ac(struct cw_actiondef *def)
rc+= cw_strheap_register_strings(def->strelem, capwap_strings_elem80211);
rc += cw_itemdefheap_register(def->items,capwap80211_itemdefs);
rc += cw_itemdefheap_register(def->radioitems,capwap80211_radioitemdefs);
/*rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem);
*/

View File

@ -8,12 +8,6 @@
#include "cw/capwap80211_items.h"
#include "cw/radio.h"
//#include "capwap_80211_actions.h"
//#include "capwap_80211.h"
//#include "capwap.h"
@ -28,7 +22,7 @@ static cw_action_in_t actions_wtp_in[] = {
.capwap_state = CW_STATE_DISCOVERY,
.msg_id = CW_MSG_DISCOVERY_RESPONSE,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION,
// .start = cw_in_radio_generic,
.mand = 1,
.min_len = 5,
@ -45,7 +39,7 @@ static cw_action_in_t actions_wtp_in[] = {
.capwap_state = CW_STATE_JOIN,
.msg_id = CW_MSG_JOIN_RESPONSE,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION,
// .start = cw_in_radio_generic,
.mand = 1,
.min_len = 5,

View File

@ -1,6 +1,8 @@
OBJS=\
mod_cipwap_ac.o
mod_cipwap_ac.o \
cipwap_actions_ac.o
NAME=libcipwap.a

View File

@ -0,0 +1,62 @@
/*
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/cw.h"
#include "cw/action.h"
#include "cw/cipwap_items.h"
#include "cw/strheap.h"
#include "cw/radio.h"
#include "mod_cipwap.h"
static cw_action_in_t actions_in[] = {
/* End of list */
{0, 0}
};
static cw_action_out_t actions_out[]={
/* End of list */
{0,0}
};
int cipwap_register_actions_ac(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, capwap_strings_elem);
*/
rc += cw_itemdefheap_register(def->items, cipwap_itemdefs);
/* rc += cw_itemdefheap_register(def->radioitems, capwap_radiodefs);
intavltree_add(def->wbids, 0);
*/
return rc;
}

View File

@ -2,5 +2,6 @@
#define __MOD_CIPWAP_H
struct mod_ac * mod_cipwap_ac();
extern int cipwap_register_actions_ac(struct cw_actiondef *def);
#endif

View File

@ -1,4 +1,7 @@
#include "../modload.h"
#include "cw/mod.h"
#include "cw/log.h"
#include "cw/dbg.h"
@ -15,19 +18,62 @@ int cipwap_init()
static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_len, struct sockaddr *from, int mode)
{
if (mode != MOD_MODE_CAPWAP)
return 0;
if (mode == MOD_MODE_CAPWAP)
return 1;
cw_dbg(DBG_MOD,"CIPWAP detected: no");
return 0;
}
static int register_actions(struct cw_actiondef *actions, int mode)
{
switch (mode) {
case MOD_MODE_CAPWAP:
{
struct mod_ac *cmod = modload_ac("capwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_cisco, failed to load base mod mod_capwap");
return 1;
}
cmod->register_actions(actions, MOD_MODE_CAPWAP);
int rc = cipwap_register_actions_ac(actions);
cw_dbg(DBG_INFO, "Initialized mod_cisco with %d actions", rc);
return rc;
}
/*
case MOD_MODE_BINDINGS:
{
struct mod_ac *cmod = modload_ac("capwap80211");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_cisco, failed to load base mod mod_capwap80211");
return 1;
}
cmod->register_actions(actions, MOD_MODE_BINDINGS);
int rc = cipwap_register_actions80211_ac(actions);
cw_dbg(DBG_INFO, "Initialized mod_cisco 80211 with %d actions", rc);
return 0;
}
*/
}
return 0;
}
static struct mod_ac cipwap_ac = {
.name ="cipwap",
.init = cipwap_init,
.detect = detect
.detect = detect,
.register_actions=register_actions
};

View File

@ -15,6 +15,7 @@ OBJS=\
cisco_in_radio_administrative_state.o \
cisco_in_spam_vendor_specific.o \
cisco_in_telnet_ssh.o \
cisco_out_radio_administrative_states.o

View File

@ -31,4 +31,8 @@ int cisco_in_telnet_ssh(struct conn *conn, struct cw_action_in *a, uint8_t * dat
int cisco_out_telnet_ssh(struct conn *conn,struct cw_action_out * a,uint8_t *dst);
int cisco_out_radio_administrative_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
#endif

View File

@ -300,6 +300,17 @@ static cw_action_out_t actions_out[]={
}
,
/* Radio Administrative State - OUT */
{
.msg_id = CW_MSG_CONFIGURATION_UPDATE_REQUEST,
.elem_id = CW_ELEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_RADIOITEM_ADMIN_STATE,
.out = cisco_out_radio_administrative_states,
.get = cw_out_get_outgoing,
.mand = 0
}
,
@ -320,7 +331,7 @@ static cw_action_in_t actions80211_in[] = {
.capwap_state = CW_STATE_DISCOVERY,
.msg_id = CW_MSG_DISCOVERY_REQUEST,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION,
.start = cw_in_radio_generic,
.mand = 0,
.min_len = 5,
@ -333,7 +344,7 @@ static cw_action_in_t actions80211_in[] = {
.vendor_id = CW_VENDOR_ID_CISCO,
.msg_id = CW_MSG_CONFIGURATION_STATUS_REQUEST,
.elem_id = CW_CISCO_SUPPORTED_RATES,
.item_id = CW_ITEM80211_SUPPORTED_RATES,
.item_id = CW_RADIOITEM80211_SUPPORTED_RATES,
.start = cw_in_radio_generic,
.mand = 0,
.min_len = 5,
@ -345,6 +356,7 @@ static cw_action_in_t actions80211_in[] = {
};
#include "cw/item.h"
static struct cw_itemdef _capwap_itemdefs[] = {

View File

@ -125,7 +125,7 @@ static cw_action_in_t actions_in[] = {
.capwap_state = CW_STATE_RUN,
.msg_id = CW_MSG_CONFIGURATION_UPDATE_REQUEST,
.elem_id = CW_ELEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_ITEM_RADIO_ADMINISTRATIVE_STATE,
.item_id = CW_RADIOITEM_ADMIN_STATE,
.start = cisco_in_radio_administrative_state_wtp,
.mand = 1
}
@ -238,7 +238,7 @@ static cw_action_out_t actions_out[]={
.vendor_id = CW_VENDOR_ID_CISCO,
.msg_id = CW_MSG_CONFIGURATION_STATUS_REQUEST,
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_ITEM80211_WTP_RADIO_INFORMATION,
.item_id = CW_RADIOITEM80211_WTP_RADIO_INFORMATION,
.out = cisco_out_80211_wtp_radio_cfg,
.get = cw_out_get_config,
.mand = 1

View File

@ -1,7 +1,7 @@
#include "cisco.h"
#include "cw/capwap_items.h"
#include "cw/cipwap_items.h"
#include "cw/cw.h"
#include "cw/dbg.h"
@ -14,10 +14,10 @@ int cisco_in_telnet_ssh(struct conn *conn, struct cw_action_in *a, uint8_t * dat
switch (type){
case 0:
mbag_set_byte(conn->incomming,CW_ITEM_TELNET_ENABLE,enable);
mbag_set_byte(conn->incomming,CIPWAP_ITEM_TELNET_ENABLE,enable);
break;
case 1:
mbag_set_byte(conn->incomming,CW_ITEM_SSH_ENABLE,enable);
mbag_set_byte(conn->incomming,CIPWAP_ITEM_SSH_ENABLE,enable);
break;
default:
cw_dbg(DBG_ELEM_ERR,"Unknown Telnet/SSH Type: %d",type);

View File

@ -0,0 +1,24 @@
#include "cw/cw.h"
#include "cw/dbg.h"
#include "cw/capwap_items.h"
int cisco_out_radio_administrative_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
{
int l=0;
MAVLITER_DEFINE(it,conn->radios_upd);
mavliter_foreach(&it){
struct mbag_item *i = mavliter_get(&it);
if ( i->type != MBAG_MBAG ) {
continue;
}
int state = mbag_get_byte(i->data,CW_RADIOITEM_ADMIN_STATE,CW_RADIO_ADMIN_STATE_DISABLED);
l+=cw_put_elem_radio_administrative_state(dst+l,i->iid,i->data);
// l+=cw_put_elem_radio_operational_state(dst+l,i->iid,state<<8,0);
}
return l;
}

View File

@ -1,6 +1,8 @@
#include "cisco.h"
#include "cw/capwap_items.h"
#include "cw/cipwap_items.h"
#include "cw/lwapp.h"
#include "cw/cw.h"
#include "cw/dbg.h"
@ -56,8 +58,8 @@ int cw_cisco_put_telnet_ssh(struct conn *conn,uint8_t type,const char * item_id,
int cisco_out_telnet_ssh(struct conn *conn,struct cw_action_out * a,uint8_t *dst)
{
int l;
l=cw_cisco_put_telnet_ssh(conn,0,CW_ITEM_TELNET_ENABLE,dst);
l+=cw_cisco_put_telnet_ssh(conn,1,CW_ITEM_SSH_ENABLE,dst+l);
l=cw_cisco_put_telnet_ssh(conn,0,CIPWAP_ITEM_TELNET_ENABLE,dst);
l+=cw_cisco_put_telnet_ssh(conn,1,CIPWAP_ITEM_SSH_ENABLE,dst+l);
return l;
}

View File

@ -21,10 +21,10 @@ static int register_actions(struct cw_actiondef *actions, int mode)
case MOD_MODE_CAPWAP:
{
struct mod_ac *cmod = modload_ac("capwap");
struct mod_ac *cmod = modload_ac("cipwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_cisco, failed to load base mod mod_capwap");
"Can't initialize mod_cisco, failed to load base mod mod_cipwap");
return 1;
}
cmod->register_actions(actions, MOD_MODE_CAPWAP);