int cw_put_item(uint8_t * dst, struct mbag_item *item) { if (MBAG_STR == item->type ){ return cw_put_data(dst, item->data, strlen((char *) item->data)); } if (MBAG_BYTE == item->type){ return cw_put_byte(dst, item->byte); } if (MBAG_WORD == item->type){ return cw_put_word(dst, item->word); } if (MBAG_DWORD == item->type){ return cw_put_dword(dst, item->dword); } if (MBAG_BSTR == item->type) { return cw_put_bstr(dst, item->data); } if ( MBAG_BSTR16 == item->type) return cw_put_bstr16(dst,item->data); if (MBAG_VENDORSTR == item->type) { int l=0; l+=cw_put_dword(dst, bstrv_get_vendor_id(item->data)); l+=cw_put_data(dst+4, bstrv_data(item->data),bstrv_len(item->data)); return l; } cw_log(LOG_ERR,"No method to put items of type %d",item->type); return 0; }
int cw_put_mbag_item(uint8_t * dst, struct mbag_item *item) { if (item->type->put){ cw_dbg(DBG_X,"User put method to put "); return item->type->put(item,dst); } if (MBAG_STR == item->type ){ return cw_put_data(dst, item->data, strlen((char *) item->data)); } if (MBAG_DATA == item->type){ return cw_put_data(dst, item->data+1, *((uint8_t*)item->data)); } if (MBAG_BYTE == item->type){ return cw_put_byte(dst, item->byte); } if (MBAG_WORD == item->type){ return cw_put_word(dst, item->word); } if (MBAG_DWORD == item->type){ return cw_put_dword(dst, item->dword); } if (MBAG_BSTR == item->type) { return cw_put_bstr(dst, item->data); } if ( MBAG_BSTR16 == item->type) return cw_put_bstr16(dst,item->data); if (MBAG_VENDORSTR == item->type) { int l=0; l+=cw_put_dword(dst, bstrv_get_vendor_id(item->data)); l+=cw_put_data(dst+4, bstrv_data(item->data),bstrv_len(item->data)); return l; } if (MBAG_MBAG == item->type){ *((void**)dst)=item->data; return sizeof(void *); } cw_log(LOG_ERR,"No method to put items of type %s",item->type->name); return 0; }
int capwap_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst) { mbag_t mbag = conn->config; // XXX Dummy WTP Descriptor Header uint8_t *d = dst+4; //int n =conn->radios->count; //printf("radio count %d\n",n); d+=cw_put_byte(d,conn->radios->count); //max radios d+=cw_put_byte(d,2); //radios in use d+=cw_put_encryption_subelems(d,conn->capwap_mode); mbag_item_t * i; i = mbag_get(mbag,CW_ITEM_WTP_HARDWARE_VERSION); if ( i ) { d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->data); if (bstrv_get_vendor_id(i->data)){ d += cw_put_dword(d, 0); d += cw_put_word(d, CW_SUBELEM_WTP_HARDWARE_VERSION); d += cw_put_word(d, bstrv_len(i->data)); d += cw_put_data(d, bstrv_data(i->data), bstrv_len(i->data)); } } else { cw_log(LOG_ERR, "Can't send Hardware Version in WTP Descriptor, not set."); } i = mbag_get(mbag,CW_ITEM_WTP_SOFTWARE_VERSION); if ( i ) { d += cw_put_version(d,CW_SUBELEM_WTP_SOFTWARE_VERSION,i->data); } else { cw_log(LOG_ERR, "Can't send Software Version in WTP descriptor, not set."); } i = mbag_get(mbag,CW_ITEM_WTP_BOOTLOADER_VERSION); if ( i ) { d += cw_put_version(d,CW_SUBELEM_WTP_BOOTLOADER_VERSION,i->data); } else { cw_log(LOG_ERR, "Can't send Bootloader Version in WTP descriptor, not set."); } int len = d-dst-4; return len + cw_put_elem_hdr(dst,a->elem_id,len); }
int cw_out_ac_name(uint8_t * dst,cw_item *item) { uint8_t *data = item->data; int len = cw_put_data(dst+4,data,strlen(data)); return len + cw_put_elem_hdr(str,CW_ELEM_AC_NAME,len); }