Inital commit.

FossilOrigin-Name: db7698bb220820c184e89340dbb642a7b97d2e9ccfd3baad58ae496b64b32263
This commit is contained in:
7u83@mail.ru
2016-04-02 07:03:03 +00:00
parent 6de87bb433
commit d50b1b411a
5 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#include "cw.h"
/**
* Put an Operational State message element to a buffer.
* @param dst Destination buffer
* @param rid Radio ID
* @param os Operational State
* @param d7mode puts the Operational Stae element in CAPWAP draft 7 mode.
* @return Number of byes put
*/
int cw_put_elem_radio_operational_state(uint8_t * dst, int rid, int os, int d7mode)
{
uint8_t *d=dst;
/* Put the radio ID */
cw_put_byte(d+4,rid);
if ( d7mode ){
/* 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);
return d-dst;
}