int cw_cisco_get_wlan_(mbag_t wlan, uint8_t *data, int len)
{
	mbag_set_word(wlan,"enc_capab", cw_get_word(data+1));

	int wlan_id=cw_get_word(data+3);
	mbag_set_word(wlan,"wlan_id",wlan_id);

	mbag_set_dword(wlan,"enc_policy",cw_get_dword(data+5));
	mbag_set_bstr16n(wlan,"key",data+9,32);

	mbag_set_byte(wlan,"key_index",cw_get_byte(data+41));
	mbag_set_byte(wlan,"key_shared",cw_get_byte(data+42));
	
	mbag_set_byte(wlan,"wpa_len",cw_get_byte(data+43));
	mbag_set_bstr16n(wlan,"wpa_data",data+44,32);

	mbag_set_byte(wlan,"rsn_len",cw_get_byte(data+76));
	mbag_set_bstr16n(wlan,"rsn_data",data+77,64);

	mbag_set_bstr16n(wlan,"reserved",data+141,49);

	mbag_set_byte(wlan,"wme_len",cw_get_byte(data+190));	
	mbag_set_bstr16n(wlan,"wme_data",data+191,32);	

	mbag_set_byte(wlan,"dot11e_len",cw_get_byte(data+223));	
	mbag_set_bstr16n(wlan,"dot11e_data",data+224,32);	

	mbag_set_byte(wlan,"qos",cw_get_byte(data+256));	

//	mbag_set_byte(wlan,"ssid_broadcast",cw_get_byte(data+257));
	mbag_set_byte(wlan,"ssid_broadcast",cw_get_byte(data+435));
	mbag_set_byte(wlan,"aironet_ie",cw_get_byte(data+436));

	mbag_set_bstr16n(wlan,"reserved2",data+258,40);


	mbag_set_byte(wlan,"dtim_period",cw_get_byte(data+554));
	mbag_set_bstr16n(wlan,"wlan_name",data+558,32);
	mbag_set_byte(wlan,"allow_aaa_override",cw_get_byte(data+591));
	mbag_set_byte(wlan,"max_clients",cw_get_byte(data+593));

	
	mbag_set_bstr16n(wlan,"ssid",data+622,len-622);

	return 0;
}
Beispiel #2
0
int cw_in_ac_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
			int len, struct sockaddr *from)
{

	return cw_read_ac_descriptor(conn->config,data,len,NULL);

	struct cw_ac_status *status = malloc(sizeof(struct cw_ac_status));
	if (!status)
		return 0;

	status->stations = cw_get_word(data);
	status->limit = cw_get_word(data + 2);
	status->active_wtps = cw_get_word(data + 4);
	status->max_wtps = cw_get_word(data + 6);
	status->security = cw_get_byte(data + 8);
	status->rmac_field = cw_get_byte(data + 9);
	status->dtls_policy = cw_get_byte(data + 11);

	cw_dbg(DBG_SUBELEM,
	       "AC Descriptor: WTPs:%d/%d, Stations:%d/%d, Security:%d, Rmac:%d, DTLS-Policy:%d",
	       status->active_wtps, status->max_wtps, status->stations, status->limit,
	       status->security, status->rmac_field, status->dtls_policy);


	mbag_set_ptr(conn->incomming, CW_ITEM_AC_STATUS, status);

	static struct cw_descriptor_subelem_def allowed[] = {
		{0,CW_SUBELEM_AC_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1},
		{0,CW_SUBELEM_AC_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1},
		{0,0, NULL,0, 0}
	};

	cw_read_descriptor_subelems(conn->config, data + 12, len - 12, allowed);

	return 1;
}
Beispiel #3
0
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);
		return 1;
	}
	if (a->itemtype == MBAG_WORD) {
		mbag_set_word(itemstore, a->item_id, cw_get_word(data));
		return 1;
	}
	if (a->itemtype == MBAG_DWORD) {
		mbag_set_dword(itemstore, a->item_id, cw_get_dword(data));
		return 1;
	}
	if (a->itemtype == MBAG_STR) {
		mbag_set_strn(itemstore, a->item_id, (char *) data, len);
		return 1;
	}
	if (a->itemtype == MBAG_BSTR) {
		mbag_set_bstrn(itemstore, a->item_id, data, len);
		return 1;
	}

	if (a->itemtype == MBAG_BSTR16) {
		mbag_set_bstr16n(itemstore, a->item_id, data, len);
		return 1;
	}

/*	if (a->itemtype == MBAG_DATA) {
		mbag_set_data(itemstore, a->item_id, data, len);
		return 1;
	}
*/
	if (a->itemtype == MBAG_VENDORSTR) {
		mbag_set_bstrv(itemstore, a->item_id,
				   cw_get_dword(data), data + 4, len - 4);
		return 1;
	}

	cw_log(LOG_ERR,
	       "Can't handle item type %d in definition for incomming msg %d (%s) - %d, cw_in_generic.",
	       a->itemtype, a->msg_id, cw_strmsg(a->msg_id), a->elem_id);
	return 0;


}
static int cw_read_cisco_wtp_descriptor(mbag_t mbag, struct conn *conn,
					struct cw_action_in *a, uint8_t * data, int len,
					int silent)
{

	mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
	mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE,
			      cw_get_byte(data + 1));


	int pos = 2;

	/* Encryption element, for now dumy XXX */
	cw_get_word(data + pos + 2);
	pos += 2;

	return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);

}
Beispiel #5
0
static void readsubelems_wtp_board_data(mbag_t itemstore, uint8_t * msgelem,
					int len)
{
	if (len<4)
		return;

	int i = 0;
//	uint32_t val;
	do {
//		val = ntohl(*((uint32_t *) (msgelem + i)));
//		int subtype = (val >> 16) & 0xffff;
//		int sublen = val & 0xffff;
//
		int subtype = cw_get_word(msgelem+i);
		int sublen = cw_get_word(msgelem+i+2);
		i += 4;
		if (sublen + i > len) {
			cw_dbg(DBG_ELEM_ERR,
			       "WTP Board data sub-element too long, type=%d,len=%d",
			       subtype, sublen);
			return;
		}

		cw_dbg(DBG_SUBELEM, "board data sub-element, type=%d (%s), len=%d",
		       subtype, cw_strboardelem(subtype),sublen);

		cw_dbg_dmp(DBG_SUBELEM,msgelem+i,sublen,"Dump...");

		switch (subtype) {
			case CW_BOARDDATA_MODELNO:
				mbag_set_bstrn(itemstore,
						       CW_ITEM_WTP_BOARD_MODELNO,
						       msgelem + i, sublen);
				break;
			case CW_BOARDDATA_SERIALNO:
				mbag_set_bstrn(itemstore,
						       CW_ITEM_WTP_BOARD_SERIALNO,
						       msgelem + i, sublen);

				break;
			case CW_BOARDDATA_MACADDRESS:
				mbag_set_bstrn(itemstore,
						       CW_ITEM_WTP_BOARD_MACADDRESS,
						       msgelem + i, sublen);

				break;
			case CW_BOARDDATA_BOARDID:
				mbag_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_ID,
						       msgelem + i, sublen);
				break;
			case CW_BOARDDATA_REVISION:
				mbag_set_bstrn(itemstore,
						       CW_ITEM_WTP_BOARD_REVISION,
						       msgelem + i, sublen);
			default:
				break;
		}
		i += sublen;

	} while (i < len);
}
int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key, 
				uint8_t * data, int len,
				struct cw_DescriptorSubelemDef *elems)
{
	uint32_t vendor_id;
	int sublen,subtype;
	int errors = 0;
	int success = 0;
	int sub = 0;
	while (sub < len) {
		int i;
		
		if (len - sub < 8) {
			return 0;
		}
		vendor_id = cw_get_dword(data + sub);
		sublen = cw_get_word(data + sub + 6);
		subtype = cw_get_word(data + sub + 4);

		
		/* search sub-element */
		for (i = 0; elems[i].maxlen; i++) {
			
			if (elems[i].type == subtype /* && elems[i].vendor_id==vendor_id*/)
				break;
		}
		
		
		if (!elems[i].maxlen) {
			cw_dbg_version_subelem(DBG_ELEM_ERR, "Can't handle sub-elem, vendor or type unknown",
				subtype, vendor_id, data+sub+8, sublen);
			errors++;
		} else {
			int l = sublen;

			char dbgstr[1048];
			char key[1024];
			
			if (elems[i].maxlen < sublen) {
				cw_dbg(DBG_ELEM_ERR,
				       "SubType %d Too long (truncating), len = %d,max. len=%d",
				       subtype, sublen, elems[i].maxlen);
				l = elems[i].maxlen;
			}


			/* vendor */
			sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_SKEY_VENDOR);
			cw_ktv_add(cfg,key,CW_TYPE_DWORD,NULL,data + sub,4);
	
			/* version */
			sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_SKEY_VERSION);
			cw_ktv_add(cfg,key,CW_TYPE_BSTR16,NULL,data+sub+8,l);
	
			sprintf(dbgstr, "%s", key);
			cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype, vendor_id, data+sub+8,l);
			success++;
		}

		if (sub + sublen > len)
			return -1;

		sub += sublen + 8;

	}

	return success;
}
Beispiel #7
0
int static do_save(mbag_t itemstore, struct conn *conn, struct cw_action_in *a,
		   uint8_t * data, int len, struct sockaddr *from)
{
	const cw_itemdef_t * idef = cw_itemdef_get(conn->actions->items,a->item_id,CW_ITEM_NONE);

	if (!idef) {
		cw_log(LOG_ERR,"No itemdef found for %s",a->item_id);
		return 0;
	}




	if (idef->type == MBAG_BYTE) {
		mbag_set_byte(itemstore, a->item_id, *data);
		return 1;
	}
	if (idef->type == MBAG_WORD) {
		mbag_set_word(itemstore, a->item_id, cw_get_word(data));
		return 1;
	}
	if (idef->type == MBAG_DWORD) {
		mbag_set_dword(itemstore, a->item_id, cw_get_dword(data));
		return 1;
	}
	if (idef->type == MBAG_STR) {
		mbag_set_strn(itemstore, a->item_id, (char *) data, len);
		return 1;
	}
	if (idef->type == MBAG_BSTR) {
		mbag_set_bstrn(itemstore, a->item_id, data, len);
		return 1;
	}

	if (idef->type == MBAG_BSTR16) {
		mbag_set_bstr16n(itemstore, a->item_id, data, len);
		return 1;
	}

/*	if (idef->type == MBAG_DATA) {
		mbag_set_data(itemstore, a->item_id, data, len);
		return 1;
	}
*/
	if (idef->type == MBAG_VENDORSTR) {
		mbag_set_bstrv(itemstore, a->item_id,
				   cw_get_dword(data), data + 4, len - 4);
		return 1;
	}



//	printf("Idef: %s\n",idef->type->name);



	cw_log(LOG_ERR,
	       "Can't handle item type %d in definition for incomming msg %d (%s) - %d, cw_in_generic.",
	       idef->type, a->msg_id, cw_strmsg(a->msg_id), a->elem_id);
	return 0;


}