moved unsied files, compiles w/o waringins with clang
FossilOrigin-Name: 1189a474bfcc28195d888d7967ccfc50c812f194e1ee19e99d3cb244d666a19a
This commit is contained in:
parent
c1f1d91b28
commit
847781bf7c
@ -7,7 +7,6 @@
|
||||
<File Name="src/cw/mavliter_seek.c"/>
|
||||
<File Name="src/cw/conn.h"/>
|
||||
<File Name="src/cw/dot11.c"/>
|
||||
<File Name="src/cw/conn_clear_upd.c"/>
|
||||
<File Name="src/cw/sock_getport.c"/>
|
||||
<File Name="src/cw/dtls_gnutls_get_peers_cert.c"/>
|
||||
<File Name="src/cw/conn_process_packet.c"/>
|
||||
@ -44,25 +43,19 @@
|
||||
<File Name="src/cw/conn_init.c"/>
|
||||
<File Name="src/cw/strheap.h"/>
|
||||
<File Name="src/cw/cw_in_check_join_req.c"/>
|
||||
<File Name="src/cw/cw_put_radio_operational_states.c"/>
|
||||
<File Name="src/cw/conn_wait_for_message.c"/>
|
||||
<File Name="src/cw/cw_util.h"/>
|
||||
<File Name="src/cw/radio.h"/>
|
||||
<File Name="src/cw/cw_read_image_data_request.c"/>
|
||||
<File Name="src/cw/cw_read_wtp_descriptor_versions.c"/>
|
||||
<File Name="src/cw/cw_in_wtp_descriptor.c"/>
|
||||
<File Name="src/cw/capwap80211_types.h"/>
|
||||
<File Name="src/cw/dtls.h"/>
|
||||
<File Name="src/cw/dtls_openssl_accept.c"/>
|
||||
<File Name="src/cw/cw_in_wtp_board_data.c"/>
|
||||
<File Name="src/cw/conn_prepare_request.c"/>
|
||||
<File Name="src/cw/cw_put_ac_status.c"/>
|
||||
<File Name="src/cw/conn_wait_for_request.c"/>
|
||||
<File Name="src/cw/capwap_strings_msg.c"/>
|
||||
<File Name="src/cw/bstr_replace.c"/>
|
||||
<File Name="src/cw/sock_receive.c"/>
|
||||
<File Name="src/cw/capwap_80211_actions.h"/>
|
||||
<File Name="src/cw/mbag_get_upd.c"/>
|
||||
<File Name="src/cw/acpriolist.h"/>
|
||||
<File Name="src/cw/sock_hwaddrtostr.c"/>
|
||||
<File Name="src/cw/mavliter_next.c"/>
|
||||
@ -70,21 +63,16 @@
|
||||
<File Name="src/cw/lw_put_cisco_path_mtu.c"/>
|
||||
<File Name="src/cw/conn_get_message.c"/>
|
||||
<File Name="src/cw/cw_readelem_maximum_message_length.c"/>
|
||||
<File Name="src/cw/cw_in_radio_administrative_state_wtp.c"/>
|
||||
<File Name="src/cw/cw_read_descriptor_subelems.c"/>
|
||||
<File Name="src/cw/log_file.c"/>
|
||||
<File Name="src/cw/cw_out_radio_generic.c"/>
|
||||
<File Name="src/cw/cw.h"/>
|
||||
<File Name="src/cw/capwap_strings_elem80211.c"/>
|
||||
<File Name="src/cw/cw_strlist_get_str.c"/>
|
||||
<File Name="src/cw/lw_readelem_wtp_name.c"/>
|
||||
<File Name="src/cw/capwap_cisco.h"/>
|
||||
<File Name="src/cw/cw_in_wtp_reboot_statistics.c"/>
|
||||
<File Name="src/cw/netconn.c"/>
|
||||
<File Name="src/cw/cw_in_capwap_local_ipv6_address.c"/>
|
||||
<File Name="src/cw/cw_out_capwap_local_ip_address.c"/>
|
||||
<File Name="src/cw/cw_out_wtp_descriptor.c"/>
|
||||
<File Name="src/cw/capwap_action_helpers.c"/>
|
||||
<File Name="src/cw/conn_send_data_packet.c"/>
|
||||
<File Name="src/cw/cw_in_capwap_control_ip_address.c"/>
|
||||
<File Name="src/cw/cw_radio_set_admin_state.c"/>
|
||||
@ -101,13 +89,10 @@
|
||||
<File Name="src/cw/cw_in_check_disc_req.c"/>
|
||||
<File Name="src/cw/fragman.h"/>
|
||||
<File Name="src/cw/cw_prepare_configuration_status_request.c"/>
|
||||
<File Name="src/cw/cw_send_echo_response.c"/>
|
||||
<File Name="src/cw/lw_cisco_id_to_str.c"/>
|
||||
<File Name="src/cw/bstr_create_from_cfgstr.c"/>
|
||||
<File Name="src/cw/sock_getifhwaddr.c"/>
|
||||
<File Name="src/cw/conn_send_packet.c"/>
|
||||
<File Name="src/cw/cw_in_check_join_resp.c"/>
|
||||
<File Name="src/cw/cw_in_80211_mac_operation.c"/>
|
||||
<File Name="src/cw/capwap_strings_board.c"/>
|
||||
<File Name="src/cw/capwap_80211_actions_ac.c"/>
|
||||
<File Name="src/cw/sock_addrlen.c"/>
|
||||
@ -117,7 +102,6 @@
|
||||
<File Name="src/cw/cw_setstr.c"/>
|
||||
<File Name="src/cw/cw_readelem_radio_operational_state.c"/>
|
||||
<File Name="src/cw/conn_q_get_packet.c"/>
|
||||
<File Name="src/cw/cw_read_80211_mac_operation.c"/>
|
||||
<File Name="src/cw/cw_in_check_img_data_req_ac.c"/>
|
||||
<File Name="src/cw/log.c"/>
|
||||
<File Name="src/cw/cw_out_init_session_id.c"/>
|
||||
@ -125,10 +109,8 @@
|
||||
<File Name="src/cw/format.c"/>
|
||||
<File Name="src/cw/intavltree.h"/>
|
||||
<File Name="src/cw/sock_cmpaddr.c"/>
|
||||
<File Name="src/cw/cw_in_radio_administrative_state.c"/>
|
||||
<File Name="src/cw/cwmsg_addelem_80211_add_wlan.c"/>
|
||||
<File Name="src/cw/dot11.h"/>
|
||||
<File Name="src/cw/cw_in_check_generic_resp.c"/>
|
||||
<File Name="src/cw/mavl_foreach_lr.c"/>
|
||||
<File Name="src/cw/mavl_get.c"/>
|
||||
<File Name="src/cw/sock_setport.c"/>
|
||||
@ -136,28 +118,22 @@
|
||||
<File Name="src/cw/sock.h"/>
|
||||
<File Name="src/cw/aciplist.c"/>
|
||||
<File Name="src/cw/log_syslog.c"/>
|
||||
<File Name="src/cw/radio.c"/>
|
||||
<File Name="src/cw/lw_put_ac_descriptor.c"/>
|
||||
<File Name="src/cw/conn_destroy.c"/>
|
||||
<File Name="src/cw/mavl_merge.c"/>
|
||||
<File Name="src/cw/cw_readelem_cisco_wtp_radio_cfg.c"/>
|
||||
<File Name="src/cw/cw_put_msg.c"/>
|
||||
<File Name="src/cw/cw_in_check_disc_resp.c"/>
|
||||
<File Name="src/cw/mavl_add.c"/>
|
||||
<File Name="src/cw/dtls_gnutls_get_cipher.c"/>
|
||||
<File Name="src/cw/cw_in_check_cipwap_join_req.c"/>
|
||||
<File Name="src/cw/vendors.h"/>
|
||||
<File Name="src/cw/cw_read_wtp_descriptor_7.c"/>
|
||||
<File Name="src/cw/dbg.h"/>
|
||||
<File Name="src/cw/sock_addrtostr.c"/>
|
||||
<File Name="src/cw/cw_out_80211_supported_rates.c"/>
|
||||
<File Name="src/cw/dtls_openssl.h"/>
|
||||
<File Name="src/cw/cw_addelem_vendor_specific_payload.c"/>
|
||||
<File Name="src/cw/cw_in_radio_generic.c"/>
|
||||
<File Name="src/cw/cw_in_check_cfg_update_req.c"/>
|
||||
<File Name="src/cw/cw_msg_init.c"/>
|
||||
<File Name="src/cw/bstr16_create_from_cfgstr.c"/>
|
||||
<File Name="src/cw/cisco.c"/>
|
||||
<File Name="src/cw/cw_read_wtp_descriptor.c"/>
|
||||
<File Name="src/cw/mlist.h"/>
|
||||
<File Name="src/cw/sock_set_recvtimeout.c"/>
|
||||
@ -169,20 +145,16 @@
|
||||
<File Name="src/cw/cw_addelem_capwap_local_ip_addr.c"/>
|
||||
<File Name="src/cw/cw_out_generic.c"/>
|
||||
<File Name="src/cw/lw_addelem.c"/>
|
||||
<File Name="src/cw/lw_in_vendor_specific.c"/>
|
||||
<File Name="src/cw/conn_q_add_packet.c"/>
|
||||
<File Name="src/cw/sock_getbroadcastaddr.c"/>
|
||||
<File Name="src/cw/cw_save_file.c"/>
|
||||
<File Name="src/cw/bstr_create_from_str.c"/>
|
||||
<File Name="src/cw/capwap_strings_vendor.c"/>
|
||||
<File Name="src/cw/cw_out_capwap_control_ip_addr_list.c"/>
|
||||
<File Name="src/cw/bstrv_create_from_str.c"/>
|
||||
<File Name="src/cw/cw_out_wtp_ip_address.c"/>
|
||||
<File Name="src/cw/dtls_openssl_bio.c"/>
|
||||
<File Name="src/cw/cw_in_generic.c"/>
|
||||
<File Name="src/cw/cw_rand.c"/>
|
||||
<File Name="src/cw/cw_80211.h"/>
|
||||
<File Name="src/cw/capwap80211_type_rateset.c"/>
|
||||
<File Name="src/cw/cw_out_image_data.c"/>
|
||||
<File Name="src/cw/cw_readelem_80211_wtp_radio_info.c"/>
|
||||
<File Name="src/cw/connlist.h"/>
|
||||
@ -191,7 +163,6 @@
|
||||
<File Name="src/cw/fragman.c"/>
|
||||
<File Name="src/cw/lwmsg.h"/>
|
||||
<File Name="src/cw/cw_check_missing_mand.c"/>
|
||||
<File Name="src/cw/format_dot11_fc.c"/>
|
||||
<File Name="src/cw/dbg_strings.c"/>
|
||||
<File Name="src/cw/dtls_gnutls.c"/>
|
||||
<File Name="src/cw/conn_prepare_configuration_update_request.c"/>
|
||||
@ -201,27 +172,22 @@
|
||||
<File Name="src/cw/conn_create.c"/>
|
||||
<File Name="src/cw/cw_in_check_img_data_req_wtp.c"/>
|
||||
<File Name="src/cw/cw_out_radio_administrative_states.c"/>
|
||||
<File Name="src/cw/dot11_beacon.c"/>
|
||||
<File Name="src/cw/cw_send_image_file.c"/>
|
||||
<File Name="src/cw/strlist.h"/>
|
||||
<File Name="src/cw/dtls_gnutls_accept.c"/>
|
||||
<File Name="src/cw/dtls_openssl.c"/>
|
||||
<File Name="src/cw/cwmsg_addelem_mtu_discovery_padding.c"/>
|
||||
<File Name="src/cw/bstr16cfgstr.c"/>
|
||||
<File Name="src/cw/file.h"/>
|
||||
<File Name="src/cw/cw_in_capwap_local_ipv4_address.c"/>
|
||||
<File Name="src/cw/sock_create.c"/>
|
||||
<File Name="src/cw/lw_readelem_wtp_board_data.c"/>
|
||||
<File Name="src/cw/cwmsg_addelem_vendor_cisco_mwar_addr.c"/>
|
||||
<File Name="src/cw/sock_get_primary_if.c"/>
|
||||
<File Name="src/cw/netconn.h"/>
|
||||
<File Name="src/cw/capwap_strings_elem.c"/>
|
||||
<File Name="src/cw/connlist.c"/>
|
||||
<File Name="src/cw/lw_put_80211_wtp_wlan_radio_configuration.c"/>
|
||||
<File Name="src/cw/cw_put_image_data.c"/>
|
||||
<File Name="src/cw/cw_util.c"/>
|
||||
<File Name="src/cw/conn_create_noq.c"/>
|
||||
<File Name="src/cw/cw_addelem_cisco_wtp_radio_cfg.c"/>
|
||||
<File Name="src/cw/mavl_del.c"/>
|
||||
<File Name="src/cw/mavl_create.c"/>
|
||||
<File Name="src/cw/lw.h"/>
|
||||
@ -235,15 +201,12 @@
|
||||
<File Name="src/cw/lwapp_cisco.h"/>
|
||||
<File Name="src/cw/cw_init_data_keep_alive_msg.c"/>
|
||||
<File Name="src/cw/capwap_strings_item.c"/>
|
||||
<File Name="src/cw/cw_out_ac_name_with_priority.c"/>
|
||||
<File Name="src/cw/conn_send_request.c"/>
|
||||
<File Name="src/cw/mavl_del_all.c"/>
|
||||
<File Name="src/cw/cw_out_wtp_reboot_statistics.c"/>
|
||||
<File Name="src/cw/capwap.h"/>
|
||||
<File Name="src/cw/sock_getifinfo.c"/>
|
||||
<File Name="src/cw/capwap_crypto.h"/>
|
||||
<File Name="src/cw/capwap_strings_state.c"/>
|
||||
<File Name="src/cw/cw_out_radio_info.c"/>
|
||||
<File Name="src/cw/cw_filename.c"/>
|
||||
<File Name="src/cw/cw_type_byte.c"/>
|
||||
<File Name="src/cw/cw_type_word.c"/>
|
||||
@ -290,7 +253,6 @@
|
||||
<File Name="src/cw/cw_ktv_get_word.c"/>
|
||||
<File Name="src/cw/cw_ktv_get_byte.c"/>
|
||||
<File Name="src/cw/cw_ktv_std_types.c"/>
|
||||
<File Name="src/cw/dbg_help_strings.c"/>
|
||||
<File Name="src/cw/cw_dbg_set_level.c"/>
|
||||
<File Name="src/cw/cw_dbg_set_level_from_str.c"/>
|
||||
<File Name="src/cw/ansi_colors.h"/>
|
||||
|
@ -4,7 +4,10 @@
|
||||
|
||||
uint8_t * bstr_create_from_str(const char *s)
|
||||
{
|
||||
int l = strlen(s);
|
||||
int msize;
|
||||
uint8_t * mem;
|
||||
int l;
|
||||
l= strlen(s);
|
||||
if (s[0]!='.')
|
||||
return bstr_create((uint8_t*)s,l);
|
||||
|
||||
@ -19,10 +22,10 @@ uint8_t * bstr_create_from_str(const char *s)
|
||||
|
||||
/* the string starts with ".x" - read hexbytes */
|
||||
l-=2;
|
||||
int msize=l/2;
|
||||
msize=l/2;
|
||||
if(l&1)
|
||||
msize++;
|
||||
uint8_t * mem = malloc(1+msize);
|
||||
mem = malloc(1+msize);
|
||||
*((uint8_t*)mem)=msize;
|
||||
cw_format_scan_hex_bytes(mem+2,s+2,l);
|
||||
return mem;
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
This file is part of actube.
|
||||
|
||||
actube 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
|
||||
*/
|
||||
|
||||
#include "bstr.h"
|
||||
#include "format.h"
|
||||
|
||||
/**
|
||||
* Create a bstrv variable from string.
|
||||
* @param vendor_id Vendor ID
|
||||
* @param s string
|
||||
* @return the created bstrv variable or NULL if the
|
||||
* operation was not sucessfull
|
||||
*/
|
||||
uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
|
||||
{
|
||||
/*int l = strlen(s);
|
||||
if (s[0]!='.')
|
||||
return bstrv_create(vendor_id,(uint8_t*)s,l);
|
||||
|
||||
if (l<=2)
|
||||
return bstrv_create(vendor_id,(uint8_t*)s,l);
|
||||
|
||||
if (s[1]=='.')
|
||||
return bstrv_create(vendor_id,(uint8_t*)s+1,l-1);
|
||||
|
||||
if (s[1]!='x')
|
||||
return bstrv_create(vendor_id,(uint8_t*)s,l);
|
||||
|
||||
// the string starts with ".x" - read hexbytes
|
||||
l-=2;
|
||||
int msize=l/2;
|
||||
if(l&1)
|
||||
msize++;
|
||||
|
||||
|
||||
uint8_t * mem = malloc(bstrv_size(msize));
|
||||
if(!mem)
|
||||
return NULL;
|
||||
bstrv_set_vendor_id(mem,vendor_id);
|
||||
bstrv_set_len(mem,msize);
|
||||
|
||||
cw_format_scan_hex_bytes(bstrv_data(mem),s+2,l);
|
||||
return mem;
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
#ifndef __CAPWAP80211_TYPES_H
|
||||
#define __CAPWAP80211_TYPES_H
|
||||
|
||||
|
||||
/*
|
||||
extern const struct mbag_typedef capwap80211_type_rateset;
|
||||
|
||||
#define CAPWAP80211_TYPE_RATESET (&capwap80211_type_rateset)
|
||||
*/
|
||||
|
||||
#endif
|
@ -1,63 +0,0 @@
|
||||
|
||||
|
||||
|
||||
#include "capwap.h"
|
||||
|
||||
/*
|
||||
|
||||
int cw_in_set_state_none(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len)
|
||||
{
|
||||
conn->capwap_state=CW_STATE_NONE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct mbag_item *cw_out_get_outgoing(struct conn *conn, struct cw_action_out *a)
|
||||
{
|
||||
return mbag_get(conn->outgoing, a->item_id);
|
||||
}
|
||||
|
||||
struct mbag_item *cw_out_get_incomming(struct conn *conn, struct cw_action_out *a)
|
||||
{
|
||||
return mbag_get(conn->incomming, a->item_id);
|
||||
}
|
||||
|
||||
struct mbag_item *cw_out_get_local(struct conn *conn, struct cw_action_out *a)
|
||||
{
|
||||
return mbag_get(conn->local,a->item_id);
|
||||
}
|
||||
|
||||
struct mbag_item *cw_out_get_config(struct conn *conn, struct cw_action_out *a)
|
||||
{
|
||||
// printf("cw get config (%d %d %s) %p\n",a->msg_id, a->elem_id,a->item_id, conn->config);
|
||||
return mbag_get(conn->config,a->item_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "capwap.h"
|
||||
#include "capwap_items.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "rand.h"
|
||||
|
||||
struct mbag_item * cw_out_get_session_id(struct conn *conn,struct cw_action_out * a)
|
||||
{
|
||||
uint8_t session_id[16];
|
||||
|
||||
int slen;
|
||||
if ( conn->capwap_mode == CW_MODE_CISCO){
|
||||
slen=2;
|
||||
}
|
||||
else
|
||||
slen=16;
|
||||
|
||||
int l = cw_rand(session_id,slen);
|
||||
if ( l!=slen ) {
|
||||
cw_log(LOG_ERR,"Can't init session ID.");
|
||||
return NULL;
|
||||
}
|
||||
return mbag_set_bstrn(conn->local,CW_ITEM_SESSION_ID,session_id,slen);
|
||||
}
|
||||
|
||||
*/
|
@ -49,7 +49,7 @@ struct cw_action_in;
|
||||
#define CONN_MAX_MSG_LENGTH 65536
|
||||
|
||||
|
||||
#include "netconn.h"
|
||||
|
||||
#include "connlist.h"
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ struct conn * conn_create(int sock, struct sockaddr * addr, int qsize)
|
||||
}
|
||||
|
||||
conn->send_packet = conn_send_packet;
|
||||
// conn->send_data_packet = conn_send_data_packet;
|
||||
/* conn->send_data_packet = conn_send_data_packet;*/
|
||||
|
||||
conn->last_seqnum_received=-1;
|
||||
conn->mtu=1500;
|
||||
@ -97,7 +97,7 @@ struct conn * conn_create(int sock, struct sockaddr * addr, int qsize)
|
||||
conn->write = conn->send_packet;
|
||||
conn->read = conn->recv_packet;
|
||||
|
||||
// conn->write_data = conn->send_data_packet;
|
||||
/* conn->write_data = conn->send_data_packet; */
|
||||
|
||||
conn->dtls_mtu = 1500;
|
||||
|
||||
|
@ -218,7 +218,11 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
mlist_t unrecognized;
|
||||
struct cw_MsgData search;
|
||||
struct cw_MsgData * message;
|
||||
|
||||
int result_code;
|
||||
int *i;
|
||||
uint8_t *elems_ptr;
|
||||
uint8_t *elem;
|
||||
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE]; /**< to hold str from sockaddr2str */
|
||||
|
||||
/*struct cw_action_in as, *af, *afm;*/
|
||||
@ -287,7 +291,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
|
||||
message = mavl_find(conn->msgset->msgdata,&search);
|
||||
|
||||
int result_code = 0;
|
||||
result_code = 0;
|
||||
|
||||
if (!message){
|
||||
/* Message is unknown */
|
||||
@ -315,7 +319,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
}
|
||||
|
||||
/* Check if current state is in state of message */
|
||||
int *i = message->states;
|
||||
i = message->states;
|
||||
for (i=message->states; *i; i++){
|
||||
if(*i==conn->capwap_state)
|
||||
break;
|
||||
@ -346,8 +350,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
*/
|
||||
|
||||
|
||||
uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
||||
uint8_t *elem;
|
||||
elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
||||
|
||||
|
||||
/* Create an avltree to catch the found mandatory elements */
|
||||
/* //conn->mand = stravltree_create();*/
|
||||
@ -503,6 +507,8 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
uint8_t seqnum;
|
||||
int s1,s2,sd;
|
||||
|
||||
uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);
|
||||
|
||||
@ -517,11 +523,11 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
/* It's a request message, check if seqnum is right and if
|
||||
* we have already sent a response message*/
|
||||
|
||||
uint8_t seqnum = cw_get_msg_seqnum(msgptr);
|
||||
seqnum = cw_get_msg_seqnum(msgptr);
|
||||
|
||||
int s1 = conn->last_seqnum_received;
|
||||
int s2 = seqnum;
|
||||
int sd = s2 - s1;
|
||||
s1 = conn->last_seqnum_received;
|
||||
s2 = seqnum;
|
||||
sd = s2 - s1;
|
||||
|
||||
if ((sd > 0 && sd < 128) || (sd < 0 && sd < -128) || s1 < 0) {
|
||||
/* seqnum is ok, normal message processing */
|
||||
@ -557,7 +563,7 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
cw_dbg(DBG_MSG_ERR, "Retransmitting response message to %s, seqnum=%d",
|
||||
sock_addr2str(&conn->addr, sock_buf), s2);
|
||||
|
||||
// XXX untested
|
||||
/*// XXX untested*/
|
||||
conn_send_msg(conn, conn->resp_buffer);
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
@ -574,7 +580,10 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
|
||||
int preamble;
|
||||
int offs;
|
||||
int payloadlen;
|
||||
|
||||
if (len < 8) {
|
||||
/* packet too short */
|
||||
cw_dbg(DBG_PKT_ERR,
|
||||
@ -584,7 +593,7 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int preamble = cw_get_hdr_preamble(packet);
|
||||
preamble = cw_get_hdr_preamble(packet);
|
||||
|
||||
if ((preamble & 0xf0) != (CAPWAP_VERSION << 4)) {
|
||||
/* wrong version */
|
||||
@ -606,10 +615,10 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
}
|
||||
|
||||
|
||||
int offs = cw_get_hdr_msg_offset(packet);
|
||||
offs = cw_get_hdr_msg_offset(packet);
|
||||
|
||||
|
||||
int payloadlen = len - offs;
|
||||
payloadlen = len - offs;
|
||||
if (payloadlen < 0) {
|
||||
/* Eleminate messages with wrong header size */
|
||||
cw_dbg(DBG_PKT_ERR,
|
||||
@ -637,6 +646,8 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
if (cw_get_hdr_flag_f(packet)) {
|
||||
/* fragmented, add the packet to fragman */
|
||||
uint8_t *f;
|
||||
int rc;
|
||||
|
||||
f = fragman_add(conn->fragman, packet, offs, payloadlen);
|
||||
if (f == NULL) {
|
||||
errno = EAGAIN;
|
||||
@ -645,18 +656,18 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
|
||||
|
||||
cw_dbg_pkt(DBG_PKT_IN, conn, f + 4, *(uint32_t *) f, from);
|
||||
// cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from);
|
||||
/*// cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from);*/
|
||||
|
||||
// XXX: Modify fragman to not throw away CAPWAP headers
|
||||
/* // XXX: Modify fragman to not throw away CAPWAP headers*/
|
||||
|
||||
int rc = conn->process_message(conn, f + 4, *(uint32_t *) f, from);
|
||||
rc = conn->process_message(conn, f + 4, *(uint32_t *) f, from);
|
||||
|
||||
free(f);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* not fragmented, we have a complete message */
|
||||
// cw_dbg_msg(DBG_MSG_IN, conn, packet, len, from);
|
||||
/*// cw_dbg_msg(DBG_MSG_IN, conn, packet, len, from);*/
|
||||
return conn->process_message(conn, packet, len, from);
|
||||
}
|
||||
|
||||
@ -713,6 +724,7 @@ int cw_read_messages(struct conn *conn)
|
||||
|
||||
int cw_read_from(struct conn *conn)
|
||||
{
|
||||
int n;
|
||||
struct sockaddr_storage from;
|
||||
uint8_t buf[2024];
|
||||
int len = 2024;
|
||||
@ -726,7 +738,7 @@ int cw_read_from(struct conn *conn)
|
||||
|
||||
|
||||
|
||||
int n = conn->readfrom(conn, buf, len, &from);
|
||||
n = conn->readfrom(conn, buf, len, &from);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
|
@ -44,12 +44,13 @@ int conn_recv_packet_(struct conn *conn, uint8_t * buf, int len, int flags)
|
||||
int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
|
||||
struct sockaddr_storage *from)
|
||||
{
|
||||
int n;
|
||||
socklen_t al;
|
||||
|
||||
al = sizeof(struct sockaddr_storage);
|
||||
memset(from, 0, sizeof(struct sockaddr_storage));
|
||||
|
||||
int n;
|
||||
|
||||
while ((n = recvfrom(conn->sock, (char *) buf, len, 0, (struct sockaddr*)from, &al)) < 0) {
|
||||
if (errno != EINTR) {
|
||||
if (errno == EAGAIN)
|
||||
@ -66,14 +67,16 @@ int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
|
||||
|
||||
int conn_recv_packet_x(struct conn *conn, uint8_t * buf, int len, int flags)
|
||||
{
|
||||
int port;
|
||||
socklen_t al;
|
||||
int n;
|
||||
struct sockaddr_storage from;
|
||||
|
||||
|
||||
al = sizeof(struct sockaddr_storage);
|
||||
memset(&from, 0, sizeof(struct sockaddr_storage));
|
||||
|
||||
int n;
|
||||
|
||||
while ((n = recvfrom(conn->sock, (char *) buf, len, flags, (struct sockaddr*)&from, &al)) < 0) {
|
||||
if (errno != EINTR) {
|
||||
if (errno == EAGAIN)
|
||||
@ -85,10 +88,10 @@ int conn_recv_packet_x(struct conn *conn, uint8_t * buf, int len, int flags)
|
||||
|
||||
|
||||
|
||||
// cw_log(LOG_ERR,"Received a packet from %s, len = %d\n",sock_addr2str_p(&from),n);
|
||||
/*// cw_log(LOG_ERR,"Received a packet from %s, len = %d\n",sock_addr2str_p(&from),n);*/
|
||||
|
||||
|
||||
int port = sock_getport((struct sockaddr*)&from);
|
||||
port = sock_getport((struct sockaddr*)&from);
|
||||
|
||||
if (port == 5247){
|
||||
conn->process_packet(conn,buf,n,(struct sockaddr*)&from);
|
||||
|
@ -32,12 +32,13 @@
|
||||
* released using free.
|
||||
*/
|
||||
char * cw_filename(const char * path, const char * name, const char * ext){
|
||||
|
||||
int name_len;
|
||||
int ext_len;
|
||||
int size=0;
|
||||
|
||||
int path_len;
|
||||
char c;
|
||||
|
||||
char * result;
|
||||
char * slash="";
|
||||
|
||||
path_len = strlen(path);
|
||||
@ -49,10 +50,10 @@ char * cw_filename(const char * path, const char * name, const char * ext){
|
||||
}
|
||||
}
|
||||
|
||||
int name_len = strlen (name);
|
||||
name_len = strlen (name);
|
||||
|
||||
|
||||
int ext_len;
|
||||
|
||||
|
||||
if (ext != NULL){
|
||||
if (ext[0]=='.'){
|
||||
@ -64,7 +65,7 @@ char * cw_filename(const char * path, const char * name, const char * ext){
|
||||
ext_len=-1;
|
||||
|
||||
size = (path_len) + name_len + (ext_len+1) + 1;
|
||||
char * result = malloc(size);
|
||||
result = malloc(size);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
|
||||
#include "capwap.h"
|
||||
#include "intavltree.h"
|
||||
#include "dbg.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "bstr.h"
|
||||
#include "sock.h" //tube
|
||||
|
||||
#include "vendors.h"
|
||||
|
||||
/*
|
||||
void cw_get_wtp_name(struct conn *conn,struct sockaddr *addr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int cw_set_capwap_mode(struct conn *conn,int mode)
|
||||
{
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
cw_dbg(DBG_INFO,"Setting CAPWAP mode to %d for %s",mode,sock_addr2str(&conn->addr,sock_buf));
|
||||
conn->capwap_mode_out=mode;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int cw_detect_capwap(struct conn *conn)
|
||||
{
|
||||
mbag_t is = conn->incomming;
|
||||
|
||||
mbag_item_t * item = mbag_get(is,CW_ITEM_WTP_SOFTWARE_VERSION);
|
||||
if (item) {
|
||||
bstrv_t s = item->u2.data;
|
||||
uint32_t v = bstrv_get_vendor_id(s);
|
||||
|
||||
switch(v) {
|
||||
case CW_VENDOR_ID_CISCO:
|
||||
cw_set_capwap_mode(conn,CW_MODE_CISCO);
|
||||
break;
|
||||
default:
|
||||
cw_set_capwap_mode(conn,CW_MODE_CAPWAP);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cw_in_check_cipwap_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from)
|
||||
{
|
||||
|
||||
|
||||
int rc = cw_in_check_join_req(conn,a,data,len,from);
|
||||
|
||||
|
||||
if ( rc==0 ) {
|
||||
cw_detect_capwap(conn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
*/
|
||||
|
@ -1,57 +0,0 @@
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#include "capwap.h"
|
||||
|
||||
#include "intavltree.h"
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
#include "sock.h"
|
||||
|
||||
int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from)
|
||||
{
|
||||
/*
|
||||
cw_action_in_t *mlist[20];
|
||||
// int n = cw_check_missing_mand(mlist, conn, a);
|
||||
|
||||
//cw_dbg(DBG_INFO,"This response came from: %s",sock_addr2str(&conn->addr));
|
||||
|
||||
|
||||
// if mandatory elements are missing, ignore this response
|
||||
if (n && conn->strict_capwap) {
|
||||
cw_dbg_missing_mand(DBG_MSG_ERR, conn, mlist, n, a);
|
||||
cw_dbg(DBG_MSG_ERR,
|
||||
"Ignoring Discovery Response from %s - missing mandatory elements.",
|
||||
sock_addr2str(from));
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
if (n) {
|
||||
cw_dbg_missing_mand(DBG_RFC, conn, mlist, n, a);
|
||||
}
|
||||
|
||||
// we have all AC information in the incomming buffer
|
||||
mbag_t discs;
|
||||
|
||||
discs = mbag_get_mavl_c(conn->remote, CW_ITEM_DISCOVERIES,
|
||||
mbag_i_create);
|
||||
|
||||
//mavl_del_all(discs);
|
||||
//exit(0);
|
||||
|
||||
if ( !discs ) {
|
||||
cw_log(LOG_ERR,"Can't allocate store for disc resp");
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
mbag_i_set_mavl(discs,discs->count,conn->incomming);
|
||||
|
||||
conn->incomming = mbag_create();
|
||||
|
||||
|
||||
return 0;
|
||||
*/
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "capwap.h"
|
||||
#include "intavltree.h"
|
||||
#include "dbg.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
int cw_in_check_generic_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from)
|
||||
{
|
||||
|
||||
/*
|
||||
//Check if the message contains a result code and
|
||||
if it indicates an errror //
|
||||
mbag_item_t * result = mbag_get(conn->incomming,CW_ITEM_RESULT_CODE);
|
||||
|
||||
if (result ) {
|
||||
if (!cw_result_is_ok(result->u2.dword)){
|
||||
return result->u2.dword;
|
||||
}
|
||||
}
|
||||
|
||||
cw_action_in_t * mlist[60];
|
||||
|
||||
// Check for mandatory elements
|
||||
int n = cw_check_missing_mand(mlist,conn,a);
|
||||
if (n && conn->strict_capwap) {
|
||||
cw_dbg_missing_mand(DBG_MSG_ERR,conn,mlist,n,a);
|
||||
errno=EAGAIN;
|
||||
// return -1; /* CW_RESULT_MISSING_MAND_ELEM
|
||||
}
|
||||
if (n){
|
||||
cw_dbg_missing_mand(DBG_RFC,conn,mlist,n,a);
|
||||
}
|
||||
|
||||
// if we hava a result code, return it
|
||||
if ( result ) {
|
||||
return result->u2.dword;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
@ -99,16 +99,19 @@ int cw_get_hdr_msg_total_len(uint8_t * rawmsg)
|
||||
|
||||
int cw_set_hdr_rmac(uint8_t * th, bstr_t rmac)
|
||||
{
|
||||
int rmac_len;
|
||||
int hlen;
|
||||
|
||||
if (!rmac) {
|
||||
cw_set_hdr_flags(th, CAPWAP_FLAG_HDR_M, 0);
|
||||
cw_set_hdr_hlen(th, 2);
|
||||
return 0;
|
||||
}
|
||||
int rmac_len = bstr_len(rmac);
|
||||
rmac_len = bstr_len(rmac);
|
||||
memcpy(cw_get_hdr_rmac(th), rmac, rmac_len + 1);
|
||||
cw_set_hdr_flags(th, CAPWAP_FLAG_HDR_M, 1);
|
||||
|
||||
int hlen = 4 + rmac_len / 4;
|
||||
hlen = 4 + rmac_len / 4;
|
||||
|
||||
if (rmac_len % 4 != 0) {
|
||||
hlen++;
|
||||
|
@ -1,55 +0,0 @@
|
||||
#include "cw.h"
|
||||
#include "capwap.h"
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
|
||||
/*
|
||||
|
||||
int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
|
||||
if (i + 8 > len) {
|
||||
cw_dbg(DBG_ELEM_ERR,
|
||||
"WTP descriptor subelement to long, length=%d>%d",
|
||||
i + 8, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t vendor_id = cw_get_dword(data + i);
|
||||
uint32_t val = cw_get_dword(data + i + 4);
|
||||
|
||||
int subtype = (val >> 16) & 0xffff;
|
||||
int sublen = val & 0xffff;
|
||||
i += 8;
|
||||
|
||||
if (sublen + i > len) {
|
||||
cw_dbg(DBG_ELEM_ERR,
|
||||
"WTP Descriptor sub-element too long, length = %d",
|
||||
sublen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *dmp;
|
||||
char *dmpmem = NULL;
|
||||
if (cw_dbg_is_level(DBG_SUBELEM_DMP)) {
|
||||
// TODO XXX
|
||||
dmpmem = NULL; //cw_dbg_mkdmp(data + i, sublen);
|
||||
dmp = dmpmem;
|
||||
} else
|
||||
dmp = "";
|
||||
cw_dbg(DBG_SUBELEM, "WTP Descriptor subtype=%d,len=%d%s", subtype,
|
||||
sublen, dmp);
|
||||
|
||||
if (dmpmem)
|
||||
free(dmpmem);
|
||||
|
||||
switch (subtype) {
|
||||
}
|
||||
i += sublen;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
*/
|
@ -100,7 +100,7 @@ static int len ( struct cw_KTV * data ){
|
||||
|
||||
const struct cw_Type cw_type_ipaddress = {
|
||||
"IPAddress", /* name */
|
||||
NULL, /* del */
|
||||
del, /* del */
|
||||
put, /* put */
|
||||
get, /* get */
|
||||
to_str, /* to_str */
|
||||
|
@ -228,7 +228,7 @@ void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
||||
#define cw_dbg_is_level(level)\
|
||||
(cw_dbg_opt_level & (1<<level))
|
||||
*/
|
||||
|
||||
int cw_dbg_is_level(int level);
|
||||
|
||||
/**
|
||||
*@}
|
||||
|
@ -39,6 +39,7 @@
|
||||
*/
|
||||
int dtls_bio_read(struct conn *conn, char *out, int maxlen)
|
||||
{
|
||||
int ret;
|
||||
if (conn->dtls_buffer_len == 0) {
|
||||
int len = conn->recv_packet(conn, conn->dtls_buffer, 2048);
|
||||
if (len < 4)
|
||||
@ -59,7 +60,7 @@ int dtls_bio_read(struct conn *conn, char *out, int maxlen)
|
||||
}
|
||||
|
||||
memcpy(out, conn->dtls_buffer + conn->dtls_buffer_pos, conn->dtls_buffer_len);
|
||||
int ret = conn->dtls_buffer_len;
|
||||
ret = conn->dtls_buffer_len;
|
||||
conn->dtls_buffer_len = 0;
|
||||
cw_dbg(DBG_DTLS_BIO, "SSL BIO read: (maxlen = %d), read %d, remain %d", maxlen,
|
||||
ret, conn->dtls_buffer_len);
|
||||
@ -77,9 +78,10 @@ int dtls_bio_read(struct conn *conn, char *out, int maxlen)
|
||||
int dtls_bio_write(struct conn *conn, const char *data, int len)
|
||||
{
|
||||
uint8_t buffer[2048];
|
||||
int rc;
|
||||
*((uint32_t *) buffer) = htonl(1 << 24);
|
||||
memcpy(buffer + 4, data, len);
|
||||
int rc = conn->send_packet(conn, buffer, len + 4);
|
||||
rc = conn->send_packet(conn, buffer, len + 4);
|
||||
if (rc >= 0)
|
||||
rc -= 4;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
@ -105,6 +106,8 @@ static int verify_cert(gnutls_session_t sess)
|
||||
|
||||
static void dtls_log_cb(int level, const char * str)
|
||||
{
|
||||
char buf[2048];
|
||||
char *c;
|
||||
if (!cw_dbg_is_level(DBG_DTLS_DETAIL))
|
||||
return;
|
||||
|
||||
@ -120,15 +123,18 @@ static void dtls_log_cb(int level, const char * str)
|
||||
|
||||
|
||||
|
||||
char buf[2048];
|
||||
|
||||
strcpy(buf,str);
|
||||
char *c = strchr(buf,'\n');
|
||||
c = strchr(buf,'\n');
|
||||
*c=0;
|
||||
cw_dbg(DBG_DTLS_DETAIL,"%s",buf);
|
||||
}
|
||||
|
||||
struct dtls_gnutls_data *dtls_gnutls_data_create(struct conn *conn,int config)
|
||||
{
|
||||
const char *errpos;
|
||||
int rc;
|
||||
int bits;
|
||||
struct dtls_gnutls_data *d = malloc(sizeof(struct dtls_gnutls_data));
|
||||
if (!d)
|
||||
return 0;
|
||||
@ -139,7 +145,7 @@ struct dtls_gnutls_data *dtls_gnutls_data_create(struct conn *conn,int config)
|
||||
gnutls_certificate_allocate_credentials(&d->x509_cred);
|
||||
|
||||
|
||||
int rc;
|
||||
|
||||
|
||||
/* Set credentials */
|
||||
|
||||
@ -157,7 +163,7 @@ struct dtls_gnutls_data *dtls_gnutls_data_create(struct conn *conn,int config)
|
||||
|
||||
|
||||
|
||||
int bits;
|
||||
|
||||
#if GNUTLS_VERSION_NUMBER >= 0x030100
|
||||
bits = gnutls_sec_param_to_pk_bits(GNUTLS_PK_DH, GNUTLS_SEC_PARAM_INSECURE);
|
||||
#else
|
||||
@ -175,7 +181,7 @@ struct dtls_gnutls_data *dtls_gnutls_data_create(struct conn *conn,int config)
|
||||
|
||||
|
||||
/* Set ciphers */
|
||||
const char *errpos;
|
||||
|
||||
rc = gnutls_priority_init(&d->priority_cache, conn->dtls_cipher, &errpos);
|
||||
if (rc < 0) {
|
||||
cw_log(LOG_ERR, "DTLS - Can't init ciphers '%s' at '%s' : %s", conn->dtls_cipher,
|
||||
|
@ -38,6 +38,7 @@
|
||||
*/
|
||||
int dtls_gnutls_connect(struct conn *conn)
|
||||
{
|
||||
int rc;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
struct dtls_gnutls_data *d;
|
||||
d = dtls_gnutls_data_create(conn,
|
||||
@ -46,7 +47,7 @@ int dtls_gnutls_connect(struct conn *conn)
|
||||
if (!d)
|
||||
return 0;
|
||||
|
||||
// gnutls_dh_set_prime_bits(d->session, 512);
|
||||
/*// gnutls_dh_set_prime_bits(d->session, 512);*/
|
||||
/*#if GNUTLS_VERSION_NUMBER >= 0x030100
|
||||
gnutls_handshake_set_timeout(d->session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
|
||||
|
||||
@ -55,7 +56,7 @@ int dtls_gnutls_connect(struct conn *conn)
|
||||
gnutls_dtls_set_mtu(d->session, 1500);
|
||||
*/
|
||||
|
||||
int rc;
|
||||
|
||||
cw_dbg(DBG_DTLS,"Starting handshake");
|
||||
do {
|
||||
rc = gnutls_handshake(d->session);
|
||||
|
@ -26,18 +26,20 @@
|
||||
|
||||
int dtls_openssl_accept(struct conn *conn)
|
||||
{
|
||||
struct dtls_openssl_data *d;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
int i, rc;
|
||||
|
||||
if (!conn->dtls_data)
|
||||
conn->dtls_data =
|
||||
dtls_openssl_data_create(conn, DTLSv1_server_method(),
|
||||
dtls_openssl_bio_method());
|
||||
|
||||
struct dtls_openssl_data *d = (struct dtls_openssl_data *) conn->dtls_data;
|
||||
d = (struct dtls_openssl_data *) conn->dtls_data;
|
||||
if (!d)
|
||||
return 0;
|
||||
|
||||
int i, rc;
|
||||
|
||||
for (i = 0; i < conn->wait_dtls; i++) {
|
||||
rc = SSL_accept(d->ssl);
|
||||
if (rc == 1) {
|
||||
|
@ -21,10 +21,11 @@ int lw_addelem(uint8_t*dst, uint8_t type, uint8_t *msgelem, uint16_t len)
|
||||
|
||||
int lw_addelem_vendor_specific(uint8_t *dst,uint32_t vendor_id,uint16_t elem_id, uint8_t *value, int len)
|
||||
{
|
||||
int l ;
|
||||
lw_put_dword(dst+3,vendor_id);
|
||||
lw_put_word(dst+7,elem_id);
|
||||
memcpy(dst+9,value,len);
|
||||
int l = len+9;
|
||||
l= len+9;
|
||||
*dst=LW_ELEM_VENDOR_SPECIFIC;
|
||||
lw_put_word(dst+1,l);
|
||||
return l;
|
||||
|
@ -4,12 +4,14 @@
|
||||
|
||||
int lw_put_image_data(uint8_t *dst,FILE *infile)
|
||||
{
|
||||
uint16_t checksum;
|
||||
int bytes;
|
||||
if ( feof(infile)){
|
||||
lw_put_byte(dst+0,1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bytes = fread(dst+3,1,LWAPP_BLOCKSIZE_IMAGE_DATA,infile);
|
||||
bytes = fread(dst+3,1,LWAPP_BLOCKSIZE_IMAGE_DATA,infile);
|
||||
|
||||
if ( ferror(infile)) {
|
||||
lw_put_byte(dst+0,5);
|
||||
@ -18,7 +20,7 @@ int lw_put_image_data(uint8_t *dst,FILE *infile)
|
||||
|
||||
lw_put_byte(dst,3);
|
||||
|
||||
uint16_t checksum = lw_checksum(dst+3,bytes);
|
||||
checksum = lw_checksum(dst+3,bytes);
|
||||
lw_put_word(dst+1,checksum);
|
||||
|
||||
return bytes+3;
|
||||
|
@ -231,13 +231,3 @@ void *mavl_add ( struct mavl *t, const void *data, int *exists )
|
||||
}
|
||||
return (void*)d;
|
||||
}
|
||||
|
||||
/*
|
||||
void *mavl_add ( struct mavl *t, const void *data)
|
||||
{
|
||||
return mavl_add_exists(t,data,NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
@ -238,11 +238,11 @@ void *mavl_del(struct mavl *t, const void *data)
|
||||
if (!t->root)
|
||||
return NULL;
|
||||
|
||||
d = data;
|
||||
d = (void*)data;
|
||||
rc = mavl_del0(t, &t->root, d);
|
||||
if (rc == 2)
|
||||
return NULL;
|
||||
return data;
|
||||
return (void*)data;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "mlist.h"
|
||||
|
||||
struct mlistelem * mlist_replace(mlist_t list, void *data)
|
||||
@ -11,4 +13,4 @@ struct mlistelem * mlist_replace(mlist_t list, void *data)
|
||||
memcpy(mlistelem_dataptr(e), data,list->data_size);
|
||||
return e;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,17 +14,22 @@
|
||||
int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
|
||||
{
|
||||
int packetlen = len;
|
||||
|
||||
int fragoffset;
|
||||
int hlen;
|
||||
|
||||
uint8_t * ptr;
|
||||
int mtu;
|
||||
|
||||
cw_dbg_msg(DBG_MSG_OUT, conn,rawmsg, packetlen,(struct sockaddr*)&conn->addr);
|
||||
|
||||
|
||||
uint8_t * ptr = rawmsg;
|
||||
ptr = rawmsg;
|
||||
|
||||
int fragoffset = 0;
|
||||
fragoffset = 0;
|
||||
|
||||
int hlen = cw_get_hdr_hlen(rawmsg)*4;
|
||||
hlen = cw_get_hdr_hlen(rawmsg)*4;
|
||||
|
||||
int mtu = conn->mtu;
|
||||
mtu = conn->mtu;
|
||||
|
||||
while (packetlen>mtu){
|
||||
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F,1);
|
||||
@ -32,10 +37,10 @@ int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
|
||||
|
||||
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,mtu,(struct sockaddr*)&conn->addr);
|
||||
|
||||
// if (conn->write_data(conn,ptr,mtu)<0)
|
||||
/* if (conn->write_data(conn,ptr,mtu)<0)*/
|
||||
return -1;
|
||||
|
||||
// XXX Fragmentation stuff..
|
||||
/* // XXX Fragmentation stuff..*/
|
||||
ptr +=mtu-hlen;
|
||||
fragoffset+=(mtu-hlen)/8;
|
||||
|
||||
@ -54,9 +59,9 @@ int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
|
||||
|
||||
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
|
||||
|
||||
// return conn->write_data(conn,ptr,packetlen-0);
|
||||
|
||||
/*// return conn->write_data(conn,ptr,packetlen-0);*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -67,6 +72,9 @@ int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
|
||||
|
||||
int cw_send_request(struct conn *conn,int msg_id)
|
||||
{
|
||||
time_t timer;
|
||||
int i;
|
||||
int rc;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
cw_init_request(conn, msg_id);
|
||||
if ( cw_put_msg(conn, conn->req_buffer) == -1 ){
|
||||
@ -76,13 +84,13 @@ int cw_send_request(struct conn *conn,int msg_id)
|
||||
conn_send_msg(conn, conn->req_buffer);
|
||||
|
||||
|
||||
int i;
|
||||
int rc=-1;
|
||||
|
||||
rc=-1;
|
||||
for (i=0; i<conn->max_retransmit && rc<0; i++){
|
||||
if ( i>0 ){
|
||||
cw_log(LOG_WARNING,"Retransmitting request ... %d",i);
|
||||
}
|
||||
time_t timer = cw_timer_start(conn->retransmit_interval);
|
||||
timer = cw_timer_start(conn->retransmit_interval);
|
||||
while (!cw_timer_timeout(timer) && rc<0){
|
||||
|
||||
rc =cw_read_messages(conn);
|
||||
@ -112,7 +120,7 @@ int cw_send_request(struct conn *conn,int msg_id)
|
||||
}
|
||||
|
||||
|
||||
// XXX find a better name for this function
|
||||
/*// XXX find a better name for this function */
|
||||
int cw_send_custom_request_2(struct conn *conn,int msg_id)
|
||||
{
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
||||
*/
|
||||
char *sock_addrtostr(const struct sockaddr *sa, char *s, size_t maxlen, int addport)
|
||||
{
|
||||
char d[maxlen];
|
||||
char d[512];
|
||||
int port;
|
||||
|
||||
|
||||
|
@ -35,11 +35,11 @@
|
||||
int sock_getbroadcastaddr(const struct sockaddr * addr,struct sockaddr * broadcastaddr)
|
||||
{
|
||||
struct ifaddrs *ifap,*ifa;
|
||||
|
||||
int rc;
|
||||
if ( getifaddrs(&ifap)==-1)
|
||||
return 0;
|
||||
|
||||
int rc=0;
|
||||
rc=0;
|
||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
|
||||
if (sock_cmpaddr(addr,ifa->ifa_addr,0))
|
||||
|
@ -28,11 +28,12 @@
|
||||
int sock_getifaddr(const char * ifname,int family, int type,struct sockaddr * sa)
|
||||
{
|
||||
struct ifaddrs *ifap,*ifa;
|
||||
|
||||
int rc;
|
||||
|
||||
if ( getifaddrs(&ifap)==-1)
|
||||
return 0;
|
||||
|
||||
int rc=0;
|
||||
rc = 0;
|
||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (strcmp(ifname,ifa->ifa_name))
|
||||
continue;
|
||||
@ -52,21 +53,21 @@ int sock_getifaddr(const char * ifname,int family, int type,struct sockaddr * sa
|
||||
memcpy (sa, ifa->ifa_addr, sock_addrlen(ifa->ifa_addr));
|
||||
rc=1;
|
||||
break;
|
||||
// case IFF_BROADCAST:
|
||||
/* case IFF_BROADCAST:
|
||||
// memcpy (sa, ifa->ifa_broadaddr, sock_addrlen(ifa->ifa_addr));
|
||||
// rc=1;
|
||||
// break;
|
||||
default:
|
||||
*/ default:
|
||||
break;
|
||||
|
||||
}
|
||||
// rc=1;
|
||||
/* rc=1;*/
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// printf("safam: %i\n",sa->sa_family);
|
||||
/* printf("safam: %i\n",sa->sa_family);*/
|
||||
freeifaddrs(ifap);
|
||||
return rc;
|
||||
}
|
||||
|
@ -36,11 +36,12 @@ int sock_getifinfo(const struct sockaddr *addr, char *ifname, struct sockaddr *b
|
||||
struct sockaddr *netmask)
|
||||
{
|
||||
struct ifaddrs *ifap, *ifa;
|
||||
|
||||
int rc;
|
||||
|
||||
if (getifaddrs(&ifap) == -1)
|
||||
return 0;
|
||||
|
||||
int rc = 0;
|
||||
rc = 0;
|
||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
|
||||
if (sock_cmpaddr(addr, ifa->ifa_addr, 0))
|
||||
@ -56,7 +57,7 @@ int sock_getifinfo(const struct sockaddr *addr, char *ifname, struct sockaddr *b
|
||||
sock_addrlen(ifa->ifa_netmask));
|
||||
}
|
||||
if (ifname)
|
||||
strcpy(ifname, ifa->ifa_name); //, strlen(ifa->ifa_name));
|
||||
strcpy(ifname, ifa->ifa_name); /*, strlen(ifa->ifa_name));*/
|
||||
|
||||
rc = 1;
|
||||
break;
|
||||
|
@ -37,9 +37,10 @@ int cw_strheap_register_strings(cw_strheap_t h, struct cw_StrListElem *s)
|
||||
|
||||
|
||||
const char * cw_strheap_get(cw_strheap_t h, int id) {
|
||||
struct cw_StrListElem *r;
|
||||
struct cw_StrListElem s;
|
||||
s.id=id;
|
||||
struct cw_StrListElem *r = mavl_get(h,&s);
|
||||
r = mavl_get(h,&s);
|
||||
if (r)
|
||||
return r->str;
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user