Can now set wtp name.

FossilOrigin-Name: ab369bcf8374345b1f96f85b8f1df0291e9c306fefff7c37654bf9a7a70b6f6e
This commit is contained in:
7u83@mail.ru 2015-03-16 01:41:35 +00:00
parent 35657312b5
commit 760b929da1
16 changed files with 132 additions and 68 deletions

View File

@ -59,7 +59,7 @@
#endif
#define CONF_DEFAULT_CISCO_HARDWARE_VERSION ".x01000001"
#define CONF_DEFAULT_CISCO_SOFTWARE_VERSION ".x05007E00"
#define CONF_DEFAULT_CISCO_SOFTWARE_VERSION ".x08006E00"
#ifndef CONF_DEFAULT_CONTROL_PORT

View File

@ -96,6 +96,10 @@ static int conn_rh(void *param)
int i;
int *msglist=p->msglist;
printf("Param %p\n",param);
for (i=0; msglist[i]!=-1; i++){
if (msglist[i] == p->conn->cwrmsg.type )
return 0;
@ -409,6 +413,8 @@ printf("HW: %s\n",sock_hwaddr2str(bstr_data(cwrmsg->rmac),bstr_len(cwrmsg->rmac)
static void wtpman_run_run(void *arg)
{
struct wtpman * wtpman = (struct wtpman *)arg;
struct conn * conn = wtpman->conn;
@ -434,7 +440,7 @@ static void wtpman_run_run(void *arg)
cwmsg_addelem(&conn->req_msg,CWMSGELEM_WTP_NAME,(uint8_t*)"Tube7u83",strlen("Tube7u83")+1);
cwmsg_addelem(&conn->req_msg,CWMSGELEM_LOCATION_DATA,(uint8_t*)"Berlin",strlen("Berlin")+1);
cwmsg_addelem_vendor_specific_payload(&conn->req_msg,CW_VENDOR_ID_CISCO,CWVENDOR_CISCO_RAD_NAME,(uint8_t*)"CiscoClient",strlen("CiscoClient"));
cwmsg_addelem_vendor_specific_payload(&conn->req_msg,CW_VENDOR_ID_CISCO,CWVENDOR_CISCO_RAD_NAME,(uint8_t*)"NudelSuppe",strlen("NudelSuppe"));
cwrmsg = conn_send_request(conn);
@ -560,6 +566,9 @@ static int wtpman_join(void *arg,time_t timer)
int result_code = 0;
cw_dbg(DBG_CW_MSG,"Sending join response to %s",CLIENT_IP);
printf("SLeep befor join resp\n");
printf("Slept befor join resp\n");
cwsend_join_response(wtpman->conn,cwrmsg->seqnum,result_code,&radioinfo,acinfo,&wtpman->wtpinfo);
cw_log(LOG_INFO,"WTP joined, Name = %s, Location = %s, IP = %s",
wtpman->wtpinfo.name,wtpman->wtpinfo.location,
@ -601,10 +610,13 @@ static void wtpman_run(void *arg)
}
/* here the WTP has joined, now image update or change state event */
int msgs[] = { CWMSG_IMAGE_DATA_REQUEST, CWMSG_CONFIGURATION_STATUS_REQUEST, -1 };
cwrmsg = conn_wait_for_request(wtpman->conn, msgs, timer);
int cfg_status_msgs[] = { CWMSG_IMAGE_DATA_REQUEST, CWMSG_CONFIGURATION_STATUS_REQUEST, -1 };
cwrmsg = conn_wait_for_request(wtpman->conn, cfg_status_msgs, timer);
printf("Have a message (con status req)\n");
if (!cwrmsg){
cw_dbg(DBG_CW_MSG_ERR,"No config uration status request from %s after %d seconds, WTP died.",
@ -612,15 +624,19 @@ static void wtpman_run(void *arg)
wtpman_remove(wtpman);
return;
}
printf("Con Stat Req waitr\n");
cwread_configuration_status_request(&wtpman->wtpinfo,cwrmsg->msgelems, cwrmsg->msgelems_len);
// cwsend_conf_status_response(wtpman->conn,cwrmsg->seqnum,result_code,&radioinfo,acinfo,&wtpman->wtpinfo);
int result_code=0;
struct ac_info *acinfo = get_acinfo();
struct radioinfo rinf;
cwsend_conf_status_response(wtpman->conn,cwrmsg->seqnum,result_code,&rinf,acinfo,&wtpman->wtpinfo);
printf("Send the respi but sleep\n");
exit(0);
// msgs = { CWMSG_IMAGE_DATA_REQUEST, CWMSG_CHANGE_STATE_EVENT_REQUEST, -1 };
cwrmsg = conn_wait_for_request(wtpman->conn, msgs, timer);
printf("Next thoing\n");
int change_status_msgs[] = { CWMSG_CHANGE_STATE_EVENT_REQUEST, -1 };
cwrmsg = conn_wait_for_request(wtpman->conn, change_status_msgs, timer);
printf("Done\n");
if (!cwrmsg){
wtpman_remove(wtpman);
@ -629,12 +645,13 @@ exit(0);
switch (cwrmsg->type){
case CWMSG_CHANGE_STATE_EVENT_REQUEST:
{
printf("Change state event\n!");
struct radioinfo ri;
cwsend_change_state_event_response(wtpman->conn,cwrmsg->seqnum,&ri);
}
break;
case CWMSG_IMAGE_DATA_REQUEST:
printf("Image update\n!");
@ -656,7 +673,7 @@ exit(0);
printf("WTP is joined now\n");
int result_code = 0;
/*
struct radioinfo * radioinfo;
@ -672,7 +689,7 @@ exit(0);
printf("CWR TYPE %d\n",cwrmsg->type);
exit(0);
*/
// cwread_configuration_status_request(&wtpman->wtpinfo,cwrmsg->msgelems, cwrmsg->msgelems_len);
// cwsend_conf_status_response(wtpman->conn,cwrmsg->seqnum,result_code,&radioinfo,acinfo,&wtpman->wtpinfo);
@ -685,7 +702,7 @@ exit(0);
wtpman_run_run(wtpman);
exit(0);
/*
int ii;
for (ii=0; ii<3; ii++){
cwrmsg = wtpman_wait_for_message(wtpman,timer);
@ -697,7 +714,7 @@ for (ii=0; ii<3; ii++){
}
}
}
*/
wtpman_run_run(wtpman);

View File

@ -16,6 +16,11 @@
*/
/**
* @file
* @brief Ciscospcific CAPWAP definitions
*/
#ifndef __CAPWAP_CISCO_H
#define __CAPWAP_CISCO_H
@ -32,33 +37,42 @@
#define CWVENDOR_CISCO_BOARD DATA LWMSGELEM_WTP_BOARD_DATA /* 50 */
#define CWVENDER_CISCO_AP_MODE_AND_TYPE 54
#define CWVENDOR_CISCO_AP_IP_ADDR 83
#define CWVENDOR_CISCO_SPAM_VENDOR_SPECIFIC 104
#define CWVENDOR_CISCO_AP_GROUP_NAME 123
#define CWVENDOR_CISCO_AP_LED_STATE_CONFIG 125
#define CWVENDOR_CISCO_AP_REGULATORY_DOMAIN 126
#define CWVENDOR_CISCO_AP_PRE_STD_SWITCH_CONFIG 137
#define CWVENDOR_CISCO_AP_POWER_INJECTOR_CONFIG 138
#define CWVENDOR_CISCO_AP_TIMESYNC 151
#define CWVENDOR_CISCO_PL207 207
#define CWVENDOR_CISCO_BOARD_DATA_OPTIONS 207
#define CWVENDOR_CISCO_MWAR_TYPE 208
extern void cwmsg_addelem_vendor_cisco_ap_timesync(struct cwmsg * cwmsg);
/* rad_name payload */
/**
* Add Cisco rad_name payload
* @param cwmsg message to add payload to
* @param str data to add
*/
#define cwmsg_addelem_vendor_cisco_rad_name(cwmsg,str) \
cwmsg_addelem_vendor_specific_payload(cwmsg,CW_VENDOR_ID_CISCO, \
CWVENDOR_CISCO_RAD_NAME,str,strlen((char*)str))
/* group name payload */
/** Add group name payload */
#define cwmsg_addelem_vendor_cisco_group_name(cwmsg,str) \
cwmsg_addelem_vendor_secific_payload(cwmsg,CW_VENDOR_ID_CISCO, \
CWVENDOR_CISCO_GROUP_NAME,str,strlen((char*)str));
/* payload 207 */
#endif

View File

@ -29,7 +29,7 @@
#include <syslog.h>
/**
* \defgroup Debug options
* @defgroup DebugOptions Dbug Options
* @{
*/

View File

@ -24,7 +24,7 @@
#include "capwap.h"
#include "acinfo.h"
#include "bstr.h"
#include "cw_log.h"
static int read_subelem_cisco(struct ac_info* acinfo,int subtype,uint8_t * elem, int len)
@ -40,7 +40,8 @@ static int read_subelem_cisco(struct ac_info* acinfo,int subtype,uint8_t * elem,
break;
default:
printf("What? %d\n",subtype);
//printf("What? %d\n",subtype);
break;
}
@ -115,7 +116,7 @@ int cw_readelem_ac_descriptor(struct ac_info * acinfo,int type, uint8_t *msgelem
sub+=8;
int subtype = val>>16;
cw_dbg(DBG_CW_MSGELEM,"ac descriptor sub-element vendor: %d, type:%d, len: %d",vendor,subtype,sublen);
switch (vendor) {
case 0:
read_subelem(acinfo,subtype,msgelem+sub,sublen);

View File

@ -23,6 +23,12 @@ int cw_readelem_cisco_payload(void *data,int msgtype,int elem_id,uint8_t *msgele
return 0;
}
case CWMSG_DISCOVERY_REQUEST:
{
}
default:
return 0;
@ -59,8 +65,6 @@ int cw_readelem_vendor_specific_payload(void * data,int msgtype,int elemtype,uin
}
return 1;
}

View File

@ -38,7 +38,7 @@ extern void cwmsg_addelem_image_identifier(struct cwmsg *msg,uint32_t vendor_id,
extern void cwmsg_addelem_radio_operational_state(struct cwmsg * cwmsg, struct radioinfo * ri);
extern void cwmsg_addelem_vendor_cosco_mwar_addr(struct cwmsg *msg, struct conn *conn);
extern void cwmsg_addelem_vendor_cisco_mwar_addr(struct cwmsg *msg, struct conn *conn);
#define cwmsg_addelem_session_id(msg,session_id) \
cwmsg_addelem(msg,CWMSGELEM_SESSION_ID,bstr_data(session_id),bstr_len(session_id));

View File

@ -55,14 +55,17 @@ void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo)
switch (msg->capwap_mode){
case CWMODE_CISCO:
len+=add_subelem(buffer+len,0,CW_VENDOR_ID_CISCO,acinfo->cisco_hardware_version);
/* It seems to be very important, that the software version sub-elemnt is
sent first. If not, the WTP gets confused and thinks the AP has
version 0.0.0.0. Tested with an 8.0.110.0 image on a LAP 1131a */
len+=add_subelem(buffer+len,1,CW_VENDOR_ID_CISCO,acinfo->cisco_software_version);
//len+=add_subelem(buffer+len,5,CW_VENDOR_ID_CISCO,acinfo->cisco_software_version);
len+=add_subelem(buffer+len,0,CW_VENDOR_ID_CISCO,acinfo->cisco_hardware_version);
break;
default:
len+=add_subelem(buffer+len,4,0,acinfo->hardware_version);
len+=add_subelem(buffer+len,5,0,acinfo->software_version);
len+=add_subelem(buffer+len,4,0,acinfo->hardware_version);
break;
}

View File

@ -1,9 +1,20 @@
/**
* @file
* @brief Implements change state event
*/
#include "cwmsg.h"
#include "capwap.h"
#include "cw_log.h"
#include "sock.h"
/**
* Send change state event response
* @param conn connection to use
* @param seqnum sequence number
* @param radioinfo radioinfo to us
*/
void cwsend_change_state_event_response(struct conn * conn,int seqnum, struct radioinfo * radioinfo)
{
cw_dbg(DBG_CW_MSG,"Sending change state response to %s, seq = %d",sock_addr2str(&conn->addr),seqnum);
@ -12,7 +23,7 @@ void cwsend_change_state_event_response(struct conn * conn,int seqnum, struct ra
cwmsg_init(cwmsg,conn->resp_buffer,CWMSG_CHANGE_STATE_EVENT_RESPONSE,seqnum,NULL);
cwmsg_addelem_result_code(cwmsg,0);
cwmsg_addelem_radio_operational_state(cwmsg,radioinfo);
// cwmsg_addelem_radio_operational_state(cwmsg,radioinfo);
conn_send_response(conn,cwmsg,seqnum);
}

View File

@ -16,6 +16,11 @@
*/
/**
* @file
* @brief cwsend_discovery_request
*/
#include "capwap.h"
#include "capwap_cisco.h"
@ -23,56 +28,54 @@
#include "conn.h"
#include "cwmsg.h"
int cwsend_discovery_request(struct conn * conn,struct radioinfo * radioinfo,struct wtpinfo * wtpinfo)
int cwsend_discovery_request(struct conn *conn, struct radioinfo *radioinfo,
struct wtpinfo *wtpinfo)
{
uint8_t buffer[CWMSG_MAX_SIZE];
struct cwmsg cwmsg;
cwmsg_init(&cwmsg,buffer,CWMSG_DISCOVERY_REQUEST,conn_get_next_seqnum(conn),NULL /*radioinfo*/);
cwmsg.capwap_mode=conn->capwap_mode;
cwmsg_init(&cwmsg, buffer, CWMSG_DISCOVERY_REQUEST, conn_get_next_seqnum(conn),
NULL /*radioinfo */ );
cwmsg.capwap_mode = conn->capwap_mode;
/* Mandatory elements */
/* discovery type */
cwmsg_addelem(&cwmsg,CWMSGELEM_DISCOVERY_TYPE,&wtpinfo->discovery_type,sizeof(uint8_t));
/* discovery type */
cwmsg_addelem(&cwmsg, CWMSGELEM_DISCOVERY_TYPE, &wtpinfo->discovery_type, sizeof(uint8_t));
/* wtp board data */
cwmsg_addelem_wtp_board_data(&cwmsg,wtpinfo);
cwmsg_addelem_wtp_board_data(&cwmsg, wtpinfo);
/* wtp descriptor */
cwmsg_addelem_wtp_descriptor(&cwmsg,wtpinfo);
cwmsg_addelem_wtp_descriptor(&cwmsg, wtpinfo);
/* wtp frame tunnel mode */
cwmsg_addelem(&cwmsg,CWMSGELEM_WTP_FRAME_TUNNEL_MODE,&wtpinfo->frame_tunnel_mode,sizeof(uint8_t));
cwmsg_addelem(&cwmsg, CWMSGELEM_WTP_FRAME_TUNNEL_MODE, &wtpinfo->frame_tunnel_mode,
sizeof(uint8_t));
/* mac type */
cwmsg_addelem(&cwmsg,CWMSGELEM_WTP_MAC_TYPE,&wtpinfo->mac_type,sizeof(uint8_t));
cwmsg_addelem(&cwmsg, CWMSGELEM_WTP_MAC_TYPE, &wtpinfo->mac_type, sizeof(uint8_t));
/* radio infos */
cwmsg_addelem_wtp_radio_infos(&cwmsg,wtpinfo->radioinfo);
cwmsg_addelem_wtp_radio_infos(&cwmsg, wtpinfo->radioinfo);
/* Non-mandatory elements */
switch (cwmsg.capwap_mode){
switch (cwmsg.capwap_mode) {
case CWMODE_CISCO:
cwmsg_addelem_vendor_cisco_rad_name(&cwmsg,(uint8_t*)wtpinfo->name);
cwmsg_addelem_vendor_cisco_rad_name(&cwmsg, (uint8_t *) wtpinfo->name);
break;
default:
if (conn->mtu_discovery)
cwmsg_addelem_mtu_discovery_padding(&cwmsg,conn);
cwmsg_addelem_mtu_discovery_padding(&cwmsg, conn);
}
return conn_send_cwmsg(conn,&cwmsg);
return conn_send_cwmsg(conn, &cwmsg);
}

View File

@ -64,10 +64,10 @@ int cwsend_join_request(struct conn *conn, struct radioinfo *radioinfo, struct w
case CWMODE_CISCO:
cwmsg_addelem_vendor_cisco_mwar_addr(&cwmsg,conn);
uint8_t data207[4] = {1,1,0,1};
uint8_t data207[4] = {11,77,30,31};
cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO,
CWVENDOR_CISCO_PL207,data207,4);
CWVENDOR_CISCO_BOARD_DATA_OPTIONS,data207,4);
cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO,
CWVENDOR_CISCO_AP_GROUP_NAME,(uint8_t*)"Tobias",strlen("Tobias"));

View File

@ -18,11 +18,11 @@ void cwsend_join_response(struct conn * conn,int seqnum, int rc, struct radioinf
cwmsg_addelem(cwmsg,CWMSGELEM_AC_NAME,acinfo->ac_name,strlen((char*)acinfo->ac_name));
cwmsg_addelem(cwmsg,CWMSGELEM_ECN_SUPPORT,&acinfo->ecn_support,sizeof(uint8_t));
cwmsg_addelem_ctrl_ip_addrs(cwmsg,acinfo);
cwmsg_addelem_cw_local_ip_addr(cwmsg,conn);
// cwmsg_addelem_cw_local_ip_addr(cwmsg,conn);
/* */
cwmsg_addelem_image_identifier(cwmsg,CW_VENDOR_ID_CISCO,(uint8_t*)"/tobias",strlen("/tobias"));
// cwmsg_addelem_image_identifier(cwmsg,CW_VENDOR_ID_CISCO,(uint8_t*)"/tobias",strlen("/tobias"));
uint8_t buffer[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

View File

@ -1,7 +1,18 @@
/**
* @file
* @brief Hndlr for unknown request messages
*/
#include "capwap.h"
#include "conn.h"
/**
* Send response to a unknown or missplaced request message
* @param conn connection object
* @param seqnum sequence number of unknown request message
* @param unknown_request the unknownrequest received
*/
void cwsend_unknown_response(struct conn * conn,int seqnum, int unknown_request)
{

View File

@ -27,14 +27,11 @@ int lw_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgel
if ( len != 46 ) {
cw_dbg(DBG_CW_MSG_ERR,"LWAPP msg size wrong. (WTP BOARD DATA) must be 46");
exit(0);
return -1;
}
uint16_t card_id = htonl( * ( (uint16_t*)(msgelem) ) );
uint16_t card_rev = htonl( * ( (uint16_t*)(msgelem +2 ) ) );
// uint16_t card_id = htonl( * ( (uint16_t*)(msgelem) ) );
// uint16_t card_rev = htonl( * ( (uint16_t*)(msgelem +2 ) ) );
return 1;
}

View File

@ -100,6 +100,8 @@
#define LWMSGELEM_WTP_DESCRIPTOR 3
#define LWMSGELEM_SUPPORTED_RATES 16
#define LWMSGELEM_WTP_BOARD_DATA 50

View File

@ -170,12 +170,13 @@ int wtpinfo_print(char *str, struct wtpinfo * wtpinfo)
// sock_addrtostr((struct sockaddr*)&wtpinfo->local_ip,hstr,64);
/*
int i0;
for (i0=0; i0<10; i0++){
printf("%d\n", ((char*)(&wtpinfo->local_ip))[i0] );
}
s+=sprintf (s,"\tLocal IP: %s\n",sock_addr2str(&(wtpinfo->local_ip)));
*/ s+=sprintf (s,"\tLocal IP: %s\n",sock_addr2str(&(wtpinfo->local_ip)));