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);
}	
Beispiel #2
0
int cisco_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst) 
{

	uint8_t *d = dst+4;
	struct mbag_item * i;
	i = mbag_get(conn->local,CW_ITEM_AC_STATUS);
	
	if (!i) {
		cw_log(LOG_ERR,"Can't send AC Descriptor, no AC Status Item found");
		return 0; 
	}

	d+=cw_put_ac_status(d ,(struct cw_ac_status*)(i->data),conn);

	
	/* Send back the same software as the WTP has,
	   otherwise the AP wants us to send an image */

	i = mbag_get(conn->incomming,CW_ITEM_WTP_SOFTWARE_VERSION);

	//i = mbag_get(conn->local,CW_ITEM_AC_SOFTWARE_VERSION);
	if ( i ) {	
	 	d += cw_put_version(d,1,i->data);
	}
	else {
		cw_log(LOG_ERR, "Can't set Cisco Software Version in AC descriptor, No value defined.");
	}

	i = mbag_get(conn->local,CW_ITEM_AC_HARDWARE_VERSION);
	if ( i ) {	
	 	d += cw_put_version(d,0,i->data);
	}
	else {
		cw_log(LOG_ERR, "Can't set Cisco Hardware Version in AC descriptor, No value defined.");
	}




	int len = d-dst-4;
	
	return len + cw_put_elem_hdr(dst,a->elem_id,len);

}
int cw_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst) 
{

	uint8_t *d = dst+4;
	struct mbag_item * i;
	i = mbag_get(conn->local,CW_ITEM_AC_STATUS);
	
	if (!i) {
		cw_log(LOG_ERR,"Can't send AC Descriptor, no AC Status Item found");
		return 0; 
	}

	d+=cw_put_ac_status(d ,(struct cw_ac_status*)(i->data));



	i = mbag_get(conn->local,CW_ITEM_AC_HARDWARE_VERSION);
	if ( i ) {	
	 	d += cw_put_version(d,CW_SUBELEM_AC_HARDWARE_VERSION,i->data);
	}
	else {
		cw_log(LOG_ERR, "Can't send hard version in AC descriptor, not set.");
	}

	
	i = mbag_get(conn->local,CW_ITEM_AC_SOFTWARE_VERSION);

	if ( i ) {	
	 	d += cw_put_version(d,CW_SUBELEM_AC_SOFTWARE_VERSION,i->data);
	}
	else {
		cw_log(LOG_ERR, "Can't send software version in AC descriptor, not set.");
	}

	int len = d-dst-4;
	
	return len + cw_put_elem_hdr(dst,a->elem_id,len);

}