Some AC actions added.

FossilOrigin-Name: 81ab5c5c07e3ed0b84527274f3c80314fc6411fdd9aede3dba3b2cb2ae0eef8c
This commit is contained in:
7u83@mail.ru
2015-04-26 10:36:53 +00:00
parent e1a6017211
commit f3a034122f
27 changed files with 216 additions and 1288 deletions

View File

@ -322,6 +322,7 @@ CWACTION=action.o \
capwap_actions_ac.o \
capwap_actions_wtp.o \
capwap_80211_actions_wtp.o \
capwap_80211_actions_ac.o \
cw_in_generic.o \
cw_in_wtp_descriptor.o \
cw_out_wtp_board_data.o \

View File

@ -45,12 +45,13 @@ struct cw_action_in{
uint16_t elem_id;
int (*start)(struct conn *conn,struct cw_action_in *a,uint8_t*data,int len,struct sockaddr *from);
int (*end)(struct conn *conn,struct cw_action_in *a,uint8_t*elem,int len,struct sockaddr *from);
// uint8_t itemtype;
const struct mbag_typedef * itemtype;
uint16_t item_id;
uint16_t min_len;
uint16_t max_len;
uint8_t mand;
// mbag_t (*target)(struct conn *conn,struct cw_action_in *a);
};
typedef int(*cw_action_fun_t)(struct conn *,struct cw_action_in *,uint8_t*,int ,struct sockaddr *);
@ -92,7 +93,7 @@ struct cw_action_out{
struct mbag_typedef * itemtype;
void *defval;
int xopt;
// int xopt;
};

View File

@ -1114,5 +1114,7 @@ int cw_out_radio_administrative_states(struct conn *conn, struct cw_action_out *
int cw_in_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
struct sockaddr *from);
int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
struct sockaddr *from);
#endif

View File

@ -91,6 +91,8 @@ int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst
extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def);
extern struct cw_str capwap_strings_elem80211[];
extern int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def);

View File

@ -5,8 +5,8 @@
#define CW_ACTION_IN_80211_WTP_RADIO_INFORMATION \
CW_ELEM80211_WTP_RADIO_INFORMATION, /* Element ID*/ \
cw_in_generic, 0, /* start/end callback */ \
MBAG_STR, /* Type of element */ \
cw_in_radio_generic, 0, /* start/end callback */ \
MBAG_DWORD, /* Type of element */ \
CW_ITEM_LOCATION_DATA, /* ID to use store */ \
5, 5 /* min/max length */

View File

@ -28,7 +28,21 @@ cw_action_in_t capwap_80211_actions_wtp_in[] = {
cw_action_out_t capwap_80211_actions_wtp_out[]={
/* Session ID */
/* --------------------------------------------------------
* Discovery Resquest
*/
/* 802.11 Radio Information */
{CW_MSG_DISCOVERY_REQUEST, CW_ELEM80211_WTP_RADIO_INFORMATION, 0,
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
,
/* --------------------------------------------------------
* Join Resquest
*/
/* 802.11 Radio Information */
{CW_MSG_JOIN_REQUEST, CW_ELEM80211_WTP_RADIO_INFORMATION, 0,
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}

View File

@ -4,7 +4,6 @@
int cw_in_set_state_none(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len)
{
conn->capwap_state=CW_STATE_NONE;

View File

@ -233,9 +233,9 @@ cw_action_out_t capwap_actions_ac_out[] = {
,
/* Result Code */
{CW_MSG_CONFIGURATION_STATUS_RESPONSE, CW_ITEM_RESULT_CODE, 0,
CW_ELEM_RESULT_CODE, NULL,cw_out_generic, cw_out_get_outgoing, 1}
,
// {CW_MSG_CONFIGURATION_STATUS_RESPONSE, CW_ITEM_RESULT_CODE, 0,
// CW_ELEM_RESULT_CODE, NULL,cw_out_generic, cw_out_get_outgoing, 1}
// ,

View File

@ -56,6 +56,7 @@ struct conn {
mbag_t local;
mbag_t radios;
uint8_t radio_create;
mbag_t config;
@ -256,6 +257,8 @@ extern int cw_read_messages(struct conn *conn);
extern int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
struct sockaddr_storage *from);
int conn_send_msg(struct conn * conn, uint8_t *rawmsg);
int cw_read_from(struct conn * conn);

View File

@ -247,7 +247,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,struct
if (!af) {
cw_dbg(DBG_ELEM_ERR,
"Element %d (%s) not allowed in msg of type %d (%s), ignoring.",
as.elem_id, cw_strelem(as.elem_id), as.msg_id,
as.elem_id, cw_strelemp(conn->actions,as.elem_id), as.msg_id,
cw_strmsg(as.msg_id));
continue;
}

View File

@ -6,9 +6,8 @@
#include "capwap.h"
int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
struct sockaddr *from)
int static check_len(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
struct sockaddr *from)
{
if (len < a->min_len) {
cw_dbg(DBG_ELEM_ERR,
@ -24,8 +23,13 @@ int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int
return 0;
}
return 1;
}
mbag_t itemstore = conn->incomming;
int static do_save(mbag_t itemstore, struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len, struct sockaddr *from)
{
if (a->itemtype == MBAG_BYTE) {
mbag_set_byte(itemstore, a->item_id, *data);
@ -60,7 +64,7 @@ int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int
*/
if (a->itemtype == MBAG_VENDORSTR) {
mbag_set_vendorstr(itemstore, a->item_id,
cw_get_dword(data), data + 4, len - 4);
cw_get_dword(data), data + 4, len - 4);
return 1;
}
@ -70,6 +74,49 @@ int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int
return 0;
}
int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
struct sockaddr *from)
{
if (!check_len(conn, a, data, len, from))
return 0;
mbag_t itemstore;
/// if (!a->target)
itemstore = conn->incomming;
// else
// itemstore = a->target(conn, a);
return do_save(itemstore, conn, a, data, len, from);
}
int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from)
{
if (!check_len(conn, a, data, len, from))
return 0;
int rid = cw_get_byte(data);
mbag_t radio = mbag_get_mbag(conn->radios, rid, NULL);
if (!radio) {
if (a->vendor_id != 0
|| ( (a->vendor_id == 0) && (a->msg_id != CW_MSG_DISCOVERY_REQUEST
&& a->msg_id != CW_MSG_JOIN_REQUEST) )) {
cw_dbg(DBG_ELEM_ERR, "Radio not found %d", rid);
return 0;
}
mbag_set_mbag(conn->radios,rid,mbag_create());
}
return 1;
}