Some code re-organisation.

FossilOrigin-Name: 22587c59c55ef6ceff826dd8056ed18f39a223e6d722664b4205e045daaf4903
This commit is contained in:
7u83@mail.ru
2015-03-16 20:41:33 +00:00
parent e8723340c8
commit 177eb36115
16 changed files with 99 additions and 40 deletions

View File

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

View File

@ -37,7 +37,7 @@
/* macro to convert our client ip to a string */
#define CLIENT_IP (sock_addrtostr((struct sockaddr*)&wtpman->conn->addr, (char[64]){0},64))
/*
int conn_handle_echo_request(void * d)
{
struct conn * conn = (struct conn *)d;
@ -45,6 +45,7 @@ int conn_handle_echo_request(void * d)
cwsend_echo_response(conn,cwrmsg->seqnum,0);
return 0;
}
*/
void conn_handle_change_state_event_request(struct conn * conn)
@ -52,7 +53,7 @@ void conn_handle_change_state_event_request(struct conn * conn)
}
static struct cwrmsg * conn_wait_for_message(struct conn * conn, time_t timer)
static struct cwrmsg * xconn_wait_for_message(struct conn * conn, time_t timer)
{
struct cwrmsg * cwrmsg;
@ -158,7 +159,7 @@ static struct cwrmsg * conn_wait_for_request(struct conn * conn, int *msglist, t
struct cwrmsg * conn_send_request(struct conn * conn)
struct cwrmsg * xconn_send_request(struct conn * conn)
{
int i;
@ -201,7 +202,7 @@ int wtpman_handle_request(void *p)
struct cwrmsg * cwrmsg = &conn->cwrmsg;
switch(conn->cwrmsg.type){
case CWMSG_ECHO_REQUEST:
conn_handle_echo_request(conn);
cw_handle_echo_request(conn);
break;
case CWMSG_CHANGE_STATE_EVENT_REQUEST:
cwread_change_state_event_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
@ -237,7 +238,7 @@ void send_image_file(struct conn * conn,const char * filename)
data.data = buffer;
conn->request_handler = conn_handle_echo_request;
conn->request_handler = cw_handle_echo_request;
conn->request_handler_param = conn;
int bl=0;
@ -616,7 +617,6 @@ static void wtpman_run(void *arg)
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.",
@ -624,7 +624,7 @@ printf("Have a message (con status req)\n");
wtpman_remove(wtpman);
return;
}
printf("Con Stat Req waitr\n");
printf("Have Masseg %d\n",cwrmsg->type);
cwread_configuration_status_request(&wtpman->wtpinfo,cwrmsg->msgelems, cwrmsg->msgelems_len);
int result_code=0;
struct ac_info *acinfo = get_acinfo();
@ -634,7 +634,7 @@ printf("Send the respi but sleep\n");
printf("Next thoing\n");
int change_status_msgs[] = { CWMSG_CHANGE_STATE_EVENT_REQUEST, -1 };
int change_status_msgs[] = { CWMSG_IMAGE_DATA_REQUEST,CWMSG_CHANGE_STATE_EVENT_REQUEST, -1 };
cwrmsg = conn_wait_for_request(wtpman->conn, change_status_msgs, timer);
printf("Done\n");

View File

@ -88,8 +88,10 @@ CAPWAPOBJS= \
cwsend_join_request.o \
cwsend_join_response.o \
cwread_join_response.o \
cwsend_echo_request.o \
cwsend_echo_response.o \
cwsend_echo_request.o \
cw_send_echo_response.o \
cw_send_image_file.o \
cw_handle_echo_request.o \
cwsend_conf_status_response.o\
cwread_configuration_status_request.o\
cwread_discovery_request.o\
@ -185,7 +187,11 @@ CONNOBJS= conn.o \
conn_get_response.o \
conn_prepare_configuration_update_request.o \
conn_prepare_request.o \
conn_prepare_image_data_request.o
conn_prepare_image_data_request.o \
conn_send_request.o \
conn_wait_for_message.o
BSTROBJS= bstr_create.o \
bstr_create_from_cfgstr.o \

View File

@ -40,6 +40,7 @@ int acinfo_readelem_ac_name(struct ac_info * acinfo,int type, uint8_t *msgelem,
}
*/
int acinfo_readelem_ac_descriptor(struct ac_info * acinfo,int type, uint8_t *msgelem, int len)
{
if (type != CWMSGELEM_AC_DESCRIPTOR)

View File

@ -393,7 +393,6 @@ extern void process_join_request(struct wtpinfo * wtpinfo, uint8_t * msg, int le
extern void process_conf_status_request(struct wtpinfo * wtpinfo, uint8_t * msg, int len);
extern void cwread_discovery_response(struct ac_info * acinfo, uint8_t * msg, int len);
extern int cwsend_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo); //,struct wtpinfo * wtpinfo
extern void cwread_image_data_request(struct ac_info * acinfo, uint8_t * msg, int len);
extern void cwsend_image_data_response(struct conn * conn,int seqnum, int rc);
extern int cwsend_image_data_request(struct conn * conn, struct image_data * data, struct image_identifier *id );
@ -406,10 +405,7 @@ extern void cwsend_conf_status_response(struct conn * conn,int seqnum, int rc, s
extern void cwsend_unknown_response(struct conn * conn,int seqnum, int unknow_request);
extern const char * cw_msgelemtostr(int elem);
extern const char * cw_msgtostr(int type);
extern const char * cw_ianavendoridtostr(int id);
extern int hdr_print(char *str, uint8_t *packet, int len);
extern int cw_readelem_ecn_support(uint8_t *ecn_support, int type, uint8_t * msgelem, int len);
@ -480,4 +476,12 @@ extern int cw_readelem_vendor_specific_payload(void * data, int msgtype, int ele
*/
extern int cw_readelem_ac_descriptor(struct ac_info * acinfo,int type, uint8_t *msgelem, int len);
extern int cw_readelem_capwap_local_ip_addr(struct sockaddr * local_ip, int type, uint8_t * msgelem, int len);
extern int cw_send_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo);
extern int cw_handle_echo_request(void * d);
#endif

View File

@ -186,6 +186,10 @@ 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 );
extern void conn_detect_capwap(struct conn * conn, struct wtpinfo * wtpinfo);
struct cwrmsg * conn_send_request(struct conn * conn);
struct cwrmsg * conn_wait_for_message(struct conn * conn, time_t timer);
#define conn_is_error(conn) (conn->dtls_error)

View File

@ -9,6 +9,7 @@
#include "cw_log.h"
#include "capwap.h"
#include "sock.h"
#include "cw_util.h"
struct args {
struct conn *conn;

View File

@ -16,10 +16,21 @@
*/
/**
* @file
* @brief cw_iananvendoridtostr
*/
#include "capwap.h"
/* definition of some iana assigned vendor id's */
/**
* Convert IANA vendor ID to string
* @param id the ID
* @return a pointer to the string
*
* Defines of only a view number of IDs. If the ID is unknown
* the string "Unknown" is returned.
*/
const char * cw_ianavendoridtostr(int id){
switch(id){
case CW_VENDOR_ID_ZYXEL:

View File

@ -33,18 +33,19 @@
* @{
*/
#define DBG_CW_MSG 0x00000001
#define DBG_CW_MSGELEM 0x00000002
#define DBG_CW_MSGELEM_DMP 0x00000004
#define DBG_CW_INFO 0x00000008
#define DBG_CW_RFC 0x00000010
#define DBG_CW_MSG 0x00000001 /* CAPWAP messages */
#define DBG_CW_MSGELEM 0x00000002 /* CAPWAP message elements */
#define DBG_CW_MSGELEM_DMP 0x00000004 /* Dump CAPWAP message elements */
#define DBG_CW_INFO 0x00000008
#define DBG_CW_RFC 0x00000010 /* RCF-realted CAPWAP errors */
#define DBG_CW_STRICT 0x00000010
#define DBG_CW_PKT_IN 0x00000020
#define DBG_CW_PKT_OUT 0x00000040
#define DBG_CW_PKT_DMP 0x00000080
#define DBG_CW_PKT_DTL 0x00000100
#define DBG_CW_PKT_IN 0x00000020 /* Headers of incoming CAPWAP packets */
#define DBG_CW_PKT_OUT 0x00000040 /* Headers of outgoing CAPWAP packets */
#define DBG_CW_PKT_DMP 0x00000080 /* Dump packts */
#define DBG_CW_PKT_DTL 0x00000100
#define DBG_CW_PKT_ERR 0x00000200
#define DBG_CW_MSG_ERR 0x00000400
#define DBG_CW_MSG_ERR 0x00000400 /* Errors in CAPWAP messages */
#define DBG_CW_IMG_DTL 0x00000800 /* Detail about image transfer */
/* driver specific debugs */
#define DBG_DRV 0x00010000

View File

@ -35,6 +35,7 @@ struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
{"pkt_dmp",DBG_CW_PKT_DMP},
{"pkt_err",DBG_CW_PKT_ERR},
{"msg_err",DBG_CW_MSG_ERR},
{"img_dtl",DBG_CW_IMG_DTL},
{"dtls",DBG_DTLS},
{"dtls_dietail",DBG_DTLS_DETAIL},

View File

@ -3,7 +3,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#
#include "capwap.h"
int cw_readelem_capwap_local_ip_addr(struct sockaddr * local_ip, int type, uint8_t * msgelem, int len)

View File

@ -1,17 +1,40 @@
#include "capwap.h"
#include "conn.h"
#include "cwmsg.h"
/*
This file is part of libcapwap.
int cwsend_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo) //,struct wtpinfo * wtpinfo)
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/>.
*/
/**
* @file
* @brief Implnts send echo response
*/
#include "capwap.h"
/**
* Send an echo response message
* @param conn connection, see #conn
* @param seqnum sequence number to use
* @param radioinfo radioinfo to use, should me NULL
* @return 1=Success\nOtherwise Error.
*/
int cw_send_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo)
{
//uint8_t buffer[CWMSG_MAX_SIZE];
struct cwmsg * cwmsg = &conn->resp_msg;
cwmsg_init(cwmsg,conn->resp_buffer,CWMSG_ECHO_RESPONSE,seqnum,radioinfo);
conn_send_response(conn,cwmsg,seqnum);
return 1;
//cwmsg_init(&cwmsg,buffer,CWMSG_ECHO_REQUEST,conn_get_next_seqnum(conn),radioinfo);
// return conn_send_cwmsg(conn,&cwmsg);
}

View File

@ -31,6 +31,7 @@
extern int cw_format_version(char *s, bstr_t version, uint32_t vendor, char * def);
extern int cw_is_printable(const uint8_t * s,int len);
extern const char * cw_ianavendoridtostr(int id);
@ -59,4 +60,9 @@ void cw_mand_elem_found(int *l,int type);
int cw_is_missing_mand_elems(int *l);
void cw_get_missing_mand_elems(char *dst, int *l);
extern const char * cw_msgelemtostr(int elem);
extern const char * cw_msgtostr(int type);
#endif

View File

@ -22,6 +22,8 @@
#include <stdint.h>
#include <arpa/inet.h>
#include "wtpinfo.h"
/* version */
#define LW_VERSION 0

View File

@ -70,7 +70,7 @@ static int process_elem(void *eparm,int type,uint8_t* msgelem,int len)
if (wtpinfo_readelem_ecn_support(wtpinfo,type,msgelem,len))
goto foundX;
if (cw_readelem_capwap_local_ip_addr(&wtpinfo->local_ip,type,msgelem,len)){
if (cw_readelem_capwap_local_ip_addr((struct sockaddr*)&wtpinfo->local_ip,type,msgelem,len)){
cw_mand_elem_found(e->mand, XCWMSGELEM_CAPWAP_LOCAL_IP_ADDRESS);
return 1;
}