Work in progress ...
FossilOrigin-Name: 33e1ed226e6651e85e45bdc2f54c9e0b616d51b13ec76d2df0e01c22ded791e6
This commit is contained in:
parent
06210cb4fa
commit
c1ffe70955
@ -9,3 +9,4 @@ USE_CONTRIB_OPENSSL=1
|
||||
CONF_LIBRARY=UCI
|
||||
USE_CONTRIB_UCI=1
|
||||
|
||||
CC=clang
|
||||
|
@ -40,6 +40,7 @@ int ac_run();
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
{
|
||||
// send_image_file(0,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAP.tar");
|
||||
|
||||
|
||||
cw_log_name="AC-Tube";
|
||||
|
@ -530,6 +530,11 @@ static int conf_read_dbg_level(cfg_t *cfg)
|
||||
|
||||
for (i=0; i<n; i++) {
|
||||
char * str = cfg_getnstr(cfg,name,i);
|
||||
if (!strcmp(str,"info")){
|
||||
cw_dbg_opt_level|=DBG_CW_INFO;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(str,"msg")){
|
||||
cw_dbg_opt_level|=DBG_CW_MSG;
|
||||
continue;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "conf.h"
|
||||
|
||||
#include "lwmsg.h"
|
||||
#include "lwapp.h"
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
@ -158,6 +159,8 @@ struct cwrmsg * conn_send_request(struct conn * conn)
|
||||
struct cwrmsg * cwrmsg;
|
||||
struct cwmsg * cwmsg = &conn->req_msg;
|
||||
|
||||
printf("Retrans interval = %d\n",conn->retransmit_interval);
|
||||
printf("Current Seqnum = %d\n",conn->seqnum);
|
||||
|
||||
|
||||
for (i=0; i<conn->max_retransmit; i++) {
|
||||
@ -215,6 +218,11 @@ void send_image_file(struct conn * conn,const char * filename)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cw_log(LOG_INFO,"Sending image file %s to %s",filename,sock_addr2str(&conn->addr));
|
||||
|
||||
struct cwrmsg * cwrmsg;
|
||||
@ -223,15 +231,47 @@ void send_image_file(struct conn * conn,const char * filename)
|
||||
data.data = buffer;
|
||||
|
||||
|
||||
conn->request_handler = conn_handle_echo_request;
|
||||
conn->request_handler_param = conn;
|
||||
|
||||
int bl=0;
|
||||
|
||||
//fseek(infile,2703*1024,SEEK_SET);
|
||||
do{
|
||||
|
||||
|
||||
|
||||
int ai;
|
||||
for (ai=0; ai<1024; ai++){
|
||||
printf("%02X ",buffer[ai]);
|
||||
|
||||
}
|
||||
|
||||
data.len = fread(buffer,1,sizeof(buffer),infile);
|
||||
//data.len=0;
|
||||
|
||||
|
||||
|
||||
|
||||
if (feof(infile))
|
||||
data.type=2;
|
||||
else
|
||||
data.type=1;
|
||||
printf("Send img data request\n");
|
||||
cwsend_image_data_request(conn,&data,0);
|
||||
cwrmsg = conn_get_response(conn);
|
||||
|
||||
if (data.len==0){
|
||||
printf("*******************************************len0************************************\n");
|
||||
}
|
||||
|
||||
printf("Send img data request, block=%d, len=%d, ch=%d\n",bl,data.len,lw_checksum(data.data,data.len));
|
||||
|
||||
//exit(0);
|
||||
|
||||
bl++;
|
||||
|
||||
conn_prepare_image_data_request(conn,&data,0);
|
||||
cwrmsg = conn_send_request(conn);
|
||||
|
||||
|
||||
if (cwrmsg){
|
||||
printf("Got img data response\n");
|
||||
}
|
||||
@ -361,7 +401,6 @@ static void wtpman_run_run(void *arg)
|
||||
printf("Update now?\n");
|
||||
|
||||
|
||||
conn->seqnum=1;
|
||||
|
||||
conn_prepare_request(conn,CWMSG_CONFIGURATION_UPDATE_REQUEST);
|
||||
cwmsg_addelem(&conn->req_msg,CWMSGELEM_WTP_NAME,(uint8_t*)"Tube7u83",strlen("Tube7u83")+1);
|
||||
@ -441,6 +480,7 @@ static int wtpman_join(void *arg,time_t timer)
|
||||
int join_msgs[] = { CWMSG_JOIN_REQUEST, -1 };
|
||||
struct cwrmsg * cwrmsg;
|
||||
cwrmsg = conn_wait_for_request(wtpman->conn, join_msgs, timer);
|
||||
|
||||
if (!cwrmsg){
|
||||
if (conn_is_error(wtpman->conn)){
|
||||
cw_dbg(DBG_CW_MSG_ERR,"DTLS connection closed while waiting for join request from %s.",CLIENT_IP);
|
||||
@ -482,7 +522,9 @@ static int wtpman_join(void *arg,time_t timer)
|
||||
static void wtpman_run(void *arg)
|
||||
{
|
||||
struct wtpman * wtpman = (struct wtpman *)arg;
|
||||
struct cwrmsg * cwrmsg = conn_get_message(wtpman->conn);
|
||||
struct cwrmsg * cwrmsg; // = conn_get_message(wtpman->conn);
|
||||
|
||||
wtpman->conn->seqnum=0;
|
||||
|
||||
/* reject connections to our multi- or broadcast sockets */
|
||||
if (socklist[wtpman->socklistindex].type != SOCKLIST_UNICAST_SOCKET){
|
||||
@ -507,7 +549,31 @@ static void wtpman_run(void *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
/* here the WTP has joined */
|
||||
/* here the WTP has joined, now image update or change state event */
|
||||
|
||||
int msgs[] = { CWMSG_IMAGE_DATA_REQUEST, CWMSG_CHANGE_STATE_EVENT_REQUEST, -1 };
|
||||
cwrmsg = conn_wait_for_request(wtpman->conn, msgs, timer);
|
||||
|
||||
if (!cwrmsg){
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (cwrmsg->type){
|
||||
case CWMSG_CHANGE_STATE_EVENT_REQUEST:
|
||||
printf("Change state event\n!");
|
||||
break;
|
||||
case CWMSG_IMAGE_DATA_REQUEST:
|
||||
printf("Image update\n!");
|
||||
cwsend_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_SUCCESS);
|
||||
// send_image_file(wtpman->conn,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAO5.tar");
|
||||
// send_image_file(wtpman->conn,"/home/tube/Downloads/c1130-k9w8-tar.124-25e.JAP.tar");
|
||||
send_image_file(wtpman->conn,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAP.tar");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("WTP is joined now\n");
|
||||
|
@ -1,3 +1,4 @@
|
||||
CC=clang
|
||||
ifndef CC
|
||||
CC=gcc
|
||||
endif
|
||||
@ -81,7 +82,6 @@ CAPWAPOBJS= \
|
||||
cwread_discovery_response.o \
|
||||
cwsend_discovery_request.o \
|
||||
cwread_image_data_request.o \
|
||||
cwsend_image_data_request.o \
|
||||
cwsend_image_data_response.o \
|
||||
cwsend_join_request.o \
|
||||
cwsend_join_response.o \
|
||||
@ -122,8 +122,10 @@ CAPWAPOBJS= \
|
||||
cw_readelem_radio_operational_state.o \
|
||||
cw_readelem_statistics_timer.o \
|
||||
cw_readelem_wtp_reboot_statistics.o\
|
||||
cwmsg_addelem_vendor_cisco_ap_timesync.o
|
||||
cwmsg_addelem_vendor_cisco_ap_timesync.o \
|
||||
lw_checksum.o
|
||||
|
||||
# cwsend_image_data_request.o
|
||||
|
||||
|
||||
# cwmsg_set_control_header.o
|
||||
@ -154,7 +156,8 @@ CONNOBJS= conn.o \
|
||||
conn_get_message.o \
|
||||
conn_get_response.o \
|
||||
conn_prepare_configuration_update_request.o \
|
||||
conn_prepare_request.o
|
||||
conn_prepare_request.o \
|
||||
conn_prepare_image_data_request.o
|
||||
|
||||
|
||||
|
||||
|
@ -318,7 +318,7 @@ extern int wtpinfo_set_radioinfo(struct wtpinfo * wtpinfo,uint8_t *msgelem, int
|
||||
|
||||
struct image_data{
|
||||
uint8_t * data;
|
||||
int type;
|
||||
uint8_t type;
|
||||
int len;
|
||||
};
|
||||
|
||||
|
@ -169,9 +169,11 @@ void connlist_remove(struct connlist *cl,struct conn * conn);
|
||||
void connlist_destroy(struct connlist * cl);
|
||||
void conn_q_add_packet(struct conn * conn,uint8_t *packet,int len);
|
||||
|
||||
|
||||
struct image_identifier;
|
||||
struct image_data;
|
||||
|
||||
extern void conn_prepare_request(struct conn * conn, int type);
|
||||
extern int conn_prepare_image_data_request(struct conn * conn, struct image_data *, struct image_identifier *id );
|
||||
|
||||
#define conn_is_error(conn) (conn->dtls_error)
|
||||
|
||||
|
@ -28,10 +28,10 @@ void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo)
|
||||
*((uint32_t*)(acd+4))=htonl((acinfo->active_wtps<<16) | acinfo->max_wtps);
|
||||
*((uint32_t*)(acd+8))=htonl((acinfo->security<<24) | (acinfo->rmac<<16) | acinfo->dtls_policy );
|
||||
|
||||
|
||||
int len = 12;
|
||||
int sublen;
|
||||
|
||||
|
||||
sublen = 4;
|
||||
|
||||
*((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||
@ -39,18 +39,36 @@ void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo)
|
||||
*((uint32_t*)(acd+len))=htonl((1<<16)|sublen);
|
||||
len+=4;
|
||||
*(acd+len)=7; len++;
|
||||
*(acd+len)=3; len++;
|
||||
*(acd+len)=4; len++;
|
||||
*(acd+len)=1; len++;
|
||||
*(acd+len)=72; len++;
|
||||
/* *(acd+len)=5; len++;
|
||||
*(acd+len)=5; len++;
|
||||
*(acd+len)=6; len++;
|
||||
*(acd+len)=7; len++;
|
||||
*(acd+len)=8; len++;
|
||||
*/
|
||||
|
||||
|
||||
*((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||
len+=4;
|
||||
*((uint32_t*)(acd+len))=htonl((1<<16)|sublen);
|
||||
len+=4;
|
||||
*(acd+len)=7; len++;
|
||||
*(acd+len)=3; len++;
|
||||
*(acd+len)=1; len++;
|
||||
*(acd+len)=72; len++;
|
||||
*(acd+len)=5; len++;
|
||||
*(acd+len)=6; len++;
|
||||
*(acd+len)=7; len++;
|
||||
*(acd+len)=8; len++;
|
||||
|
||||
|
||||
|
||||
|
||||
goto b;
|
||||
|
||||
/* software version subelement */
|
||||
|
||||
/* *((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||
*((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||
len+=4;
|
||||
sublen=strlen((const char*)acinfo->software_version);
|
||||
*((uint32_t*)(acd+len))=htonl((1<<16)|sublen);
|
||||
@ -58,16 +76,16 @@ void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo)
|
||||
memcpy(acd+len,acinfo->software_version,sublen);
|
||||
len+=sublen;
|
||||
|
||||
*/
|
||||
|
||||
/* hardware version subelement */
|
||||
/* *((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||
*((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||
len+=4;
|
||||
sublen=strlen((const char*)acinfo->hardware_version);
|
||||
*((uint32_t*)(acd+len))=htonl((4<<16)|sublen);
|
||||
len+=4;
|
||||
memcpy(acd+len,acinfo->hardware_version,sublen);
|
||||
len+=sublen;
|
||||
*/
|
||||
b:
|
||||
cwmsg_addelem(msg,CWMSGELEM_AC_DESCRIPTOR,acd,len);
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
This file is part of libcapwap.
|
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
libcapwap is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include "capwap.h"
|
||||
#include "cwmsg.h"
|
||||
|
@ -16,6 +16,13 @@
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Defines cwread_change_state_even_request function.
|
||||
*
|
||||
* Full text
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "capwap.h"
|
||||
@ -48,7 +55,9 @@ foundX:
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read elements of a Change State Event Request message.
|
||||
*/
|
||||
int cwread_change_state_event_request(struct wtpinfo * wtpinfo, uint8_t * msg, int len)
|
||||
{
|
||||
int mand[] = {
|
||||
|
@ -32,7 +32,8 @@ static int readelem(void * eparm,int type,uint8_t* msgelem,int len)
|
||||
{
|
||||
|
||||
struct eparm * e = (struct eparm*)eparm;
|
||||
cw_dbg(DBG_CW_MSGELEM,"Reading conf staus req msgelem, type=%d - %s ,len=%d\n",type,cw_msgelemtostr(type),len);
|
||||
// cw_dbg(DBG_CW_MSGELEM,"Reading conf staus req msgelem, type=%d - %s ,len=%d\n",type,cw_msgelemtostr(type),len);
|
||||
cw_dbg_msgelem(CWMSG_CONFIGURATION_STATUS_REQUEST, type, msgelem,len);
|
||||
|
||||
/* mandatory elements */
|
||||
if (cw_readelem_ac_name(&e->wtpinfo->ac_name,type,msgelem,len))
|
||||
|
@ -25,23 +25,23 @@ void cwsend_join_response(struct conn * conn,int seqnum, int rc, struct radioinf
|
||||
|
||||
|
||||
|
||||
// uint8_t buffer[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
// buffer[0]=0; /* Mwar Type */
|
||||
// buffer[1]=1; /* h/w version */
|
||||
// buffer[2]=2; /* h/w Release */
|
||||
// buffer[3]=0; /* h/w Maint */
|
||||
// buffer[4]=3; /* h/w Build */
|
||||
uint8_t buffer[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
buffer[0]=0; /* Mwar Type */
|
||||
buffer[1]=1; /* h/w version */
|
||||
buffer[2]=2; /* h/w Release */
|
||||
buffer[3]=0; /* h/w Maint */
|
||||
buffer[4]=3; /* h/w Build */
|
||||
|
||||
// buffer[5]=5; /* s/w version */
|
||||
// buffer[6]=0; /* s/w Release */
|
||||
// buffer[7]=19; /* s/w Maint */
|
||||
// buffer[8]=3; /* s/w Build */
|
||||
buffer[5]=5; /* s/w version */
|
||||
buffer[6]=0; /* s/w Release */
|
||||
buffer[7]=19; /* s/w Maint */
|
||||
buffer[8]=3; /* s/w Build */
|
||||
|
||||
// *((uint16_t*)(buffer+9))=htons(13); /* Active MS */
|
||||
// *((uint16_t*)(buffer+9+2))=htons(23); /* Supported MS */
|
||||
// *((uint16_t*)(buffer+9+4))=htons(5); /* Active RAD's */
|
||||
// *((uint16_t*)(buffer+9+6))=htons(15); /* Supported RAD's */
|
||||
// cwmsg_addelem_vendor_specific_payload(cwmsg,CW_VENDOR_ID_CISCO, 205, buffer,4);
|
||||
*((uint16_t*)(buffer+9))=htons(13); /* Active MS */
|
||||
*((uint16_t*)(buffer+9+2))=htons(23); /* Supported MS */
|
||||
*((uint16_t*)(buffer+9+4))=htons(5); /* Active RAD's */
|
||||
*((uint16_t*)(buffer+9+6))=htons(15); /* Supported RAD's */
|
||||
cwmsg_addelem_vendor_specific_payload(cwmsg,CW_VENDOR_ID_CISCO, CWVENDOR_CISCO_MWAR, buffer,34);
|
||||
|
||||
|
||||
conn_send_response(conn,cwmsg,seqnum);
|
||||
|
@ -21,11 +21,16 @@
|
||||
/**
|
||||
* Calculate the 16-bit checksum for LWAPP image data message
|
||||
* elements with opcode 3 - used by Cisco also in CAPWAP
|
||||
* (But it's not always correct, the real algo might be another)
|
||||
*/
|
||||
uint16_t lw_checksum(uint8_t * d, int len)
|
||||
{
|
||||
int i;
|
||||
uint32_t cs = 0xffff;
|
||||
// uint32_t cs = 0xffff;
|
||||
if (len==0)
|
||||
return 0xffff;
|
||||
|
||||
uint32_t cs = 0;
|
||||
for (i = 0; i < len; i += 2) {
|
||||
uint16_t w = d[i] << 8;
|
||||
|
||||
@ -36,5 +41,9 @@ uint16_t lw_checksum(uint8_t * d, int len)
|
||||
cs += cs >> 16;
|
||||
cs &= 0xffff;
|
||||
}
|
||||
return (uint16_t) cs;
|
||||
return (uint16_t) cs&0xffff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user