From 368f43e1a0a0759368cabd67231f812ed687aee3 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Tue, 28 Apr 2015 08:17:51 +0000 Subject: [PATCH] Inital commit FossilOrigin-Name: 3758857847eb72bee8553fb2272e452c0db21dae38bf62171137bccbdd41018d --- src/capwap/cw_out_radio_operational_state.c | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/capwap/cw_out_radio_operational_state.c diff --git a/src/capwap/cw_out_radio_operational_state.c b/src/capwap/cw_out_radio_operational_state.c new file mode 100644 index 00000000..0be15a96 --- /dev/null +++ b/src/capwap/cw_out_radio_operational_state.c @@ -0,0 +1,55 @@ + +#include "capwap.h" +#include "capwap_items.h" + +#include "dbg.h" +#include "log.h" +#include "radio.h" + +int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst) +{ + uint8_t *d=dst; + + /* Iterate through all radios and send the CW_RADIO_OPER_STATE item if found. + We assume, that any other processes, dealing with setting the + the Radio Admin state, adds a CW_RADIO_OPER_STATE item to the radio, + depending on results. */ + + MAVLITER_DEFINE(it,conn->radios); + mavliter_foreach(&it){ + mbag_item_t * radioitem = mavliter_get(&it); + mbag_item_t *ositem = mbag_get(radioitem->data,CW_RADIO_OPER_STATE); + if (!ositem) + continue; + + /* Put the radio ID */ + cw_put_byte(d+4,radioitem->id); + + /* Get the operational state and cause */ + uint16_t os = ositem->word; + + if ( conn->capwap_mode==CW_MODE_CISCO ){ + /* Isolate Oper Sate from cause */ + uint8_t o=os>>8; + + /* Invert oper state for Cisco, if oper state is 2 or 1 */ + if (o!=0 && o<=2) { + /* 2 becomes 1 and 1 becomes 2 */ + os = (os & 0x00ff ) | ((3-o)<<8); + } + } + + /* Put oper state */ + cw_put_word(d+5,os); + d+=3+cw_put_elem_hdr(d,CW_ELEM_RADIO_OPERATIONAL_STATE,3); + + /* delete the operational state item, so it won't be + sent again, until it is set again by a change through + Set Radio Admin State */ + mbag_del(radioitem->data,CW_RADIO_OPER_STATE); + + } + + return d-dst; +} +