static int cw_read_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)); /* Get number of encryption elements */ int ncrypt = cw_get_byte(data + 2); if (ncrypt == 0) { if (conn->strict_capwap) { if (!silent) cw_dbg(DBG_ELEM_ERR, "Bad WTP Descriptor, number of encryption elements is 0."); return 0; } if (!silent) cw_dbg(DBG_RFC, "Non standard conform WTP Descriptor, number of encryptoin elements is 0."); } int pos = 3; int i; for (i = 0; i < ncrypt; i++) { // It's a dummy for now pos += 3; } return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent); }
int cw_in_cisco_add_wlan(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, struct sockaddr *from) { int rid = cw_get_byte(data); mbag_t wlan = mbag_i_get_mbag(conn->radios,rid,NULL); if ( !wlan ) { printf("No Radio git\n"); } mbag_set_byte(wlan,"radio_id",rid); int mytype=mbag_get_byte(conn->config,CW_ITEM_AP_MODE_AND_TYPE,77) & 0xff; printf("My type: %d\n",mytype); exit(0); cw_cisco_get_wlan_legacy(wlan,data,len); return 0; }
int cw_in_radio_generic(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->radioitems,a->item_id,CW_ITEM_NONE); if (!idef){ cw_log(LOG_ERR,"No definition found for %s",a->item_id); return 0; } int rid = cw_get_byte(data); mbag_t radio = mbag_i_get_mbag(conn->radios, rid, NULL); if (!radio) { if (a->vendor_id != 0 || ( (a->vendor_id == 0) && (a->msg_id != CW_MSG_DISCOVERY_REQUEST && a->msg_id != CW_MSG_JOIN_REQUEST) )) { cw_dbg(DBG_ELEM_ERR, "Radio not found %d", rid); return 0; } mbag_i_set_mbag(conn->radios,rid,mbag_create()); radio = mbag_i_get_mbag(conn->radios, rid, NULL); } int rc = mbag_set_from_buf(radio,idef->type,a->item_id,data+1,len-1); if (!rc){ cw_log(LOG_ERR, "Can't handle item type %s in definition for incomming msg %d (%s) - %d, cw_in_radio_generic.", idef->type->name, a->msg_id, cw_strmsg(a->msg_id), a->elem_id); } return rc; }
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); }
int cisco80211_in_mac_operation(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, struct sockaddr *from) { int rid = cw_get_byte(data); mbag_t r = mbag_i_get_mbag(conn->radios,rid,NULL); if (!r){ cw_dbg(DBG_ELEM_ERR,"Radio %d not defined. Can't set mac operation."); return 0; } return cw_read_80211_mac_operation(data+3,r); }
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; }
int cw_in_ac_name_with_priority(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, struct sockaddr *from) { cw_acpriolist_t prios = mbag_get_mavl(conn->config,CW_ITEM_AC_NAME_WITH_PRIORITY); if (!prios) return 0; cw_acprio_t * prio = malloc(sizeof(cw_acprio_t)); if (!prio) return 0; prio->prio=cw_get_byte(data); prio->name=strndup((char*)data+1,len-1); mavl_replace(prios,prio); return 1; }
int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, struct sockaddr *from) { if (!check_len(conn, a, data, len, from)) return 0; int rid = cw_get_byte(data); mbag_t radio = mbag_i_get_mbag(conn->radios, rid, NULL); if (!radio) { if (a->vendor_id != 0 || ( (a->vendor_id == 0) && (a->msg_id != CW_MSG_DISCOVERY_REQUEST && a->msg_id != CW_MSG_JOIN_REQUEST) )) { cw_dbg(DBG_ELEM_ERR, "Radio not found %d", rid); return 0; } mbag_i_set_mbag(conn->radios,rid,mbag_create()); } return 1; }
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; }