got rid of avltree-stuff
FossilOrigin-Name: 41573b74d0d433b2e62feb78e580cbb351fee08b441e6735237cd3201a49a4e4
This commit is contained in:
parent
e50b8b29b0
commit
cad0c6ab18
@ -22,7 +22,6 @@
|
|||||||
<File Name="src/cw/mavl_get_node.c"/>
|
<File Name="src/cw/mavl_get_node.c"/>
|
||||||
<File Name="src/cw/dtls_openssl_connect.c"/>
|
<File Name="src/cw/dtls_openssl_connect.c"/>
|
||||||
<File Name="src/cw/acpriolist.c"/>
|
<File Name="src/cw/acpriolist.c"/>
|
||||||
<File Name="src/cw/avltree_get_node.c"/>
|
|
||||||
<File Name="src/cw/lw_elem_id_to_str.c"/>
|
<File Name="src/cw/lw_elem_id_to_str.c"/>
|
||||||
<File Name="src/cw/cw_put_elem_radio_administrative_state.c"/>
|
<File Name="src/cw/cw_put_elem_radio_administrative_state.c"/>
|
||||||
<File Name="src/cw/lwapp.h"/>
|
<File Name="src/cw/lwapp.h"/>
|
||||||
@ -38,7 +37,6 @@
|
|||||||
<File Name="src/cw/cw_is_printable.c"/>
|
<File Name="src/cw/cw_is_printable.c"/>
|
||||||
<File Name="src/cw/sock_getifaddr.c"/>
|
<File Name="src/cw/sock_getifaddr.c"/>
|
||||||
<File Name="src/cw/bstr_create.c"/>
|
<File Name="src/cw/bstr_create.c"/>
|
||||||
<File Name="src/cw/avltree_foreach_lr.c"/>
|
|
||||||
<File Name="src/cw/cw_put_mbag_item.c"/>
|
<File Name="src/cw/cw_put_mbag_item.c"/>
|
||||||
<File Name="src/cw/conn_get_response.c"/>
|
<File Name="src/cw/conn_get_response.c"/>
|
||||||
<File Name="src/cw/dtls_bio.c"/>
|
<File Name="src/cw/dtls_bio.c"/>
|
||||||
@ -75,7 +73,6 @@
|
|||||||
<File Name="src/cw/sock_receive.c"/>
|
<File Name="src/cw/sock_receive.c"/>
|
||||||
<File Name="src/cw/capwap_80211_actions.h"/>
|
<File Name="src/cw/capwap_80211_actions.h"/>
|
||||||
<File Name="src/cw/mbag_get_upd.c"/>
|
<File Name="src/cw/mbag_get_upd.c"/>
|
||||||
<File Name="src/cw/avltree.h"/>
|
|
||||||
<File Name="src/cw/acpriolist.h"/>
|
<File Name="src/cw/acpriolist.h"/>
|
||||||
<File Name="src/cw/sock_hwaddrtostr.c"/>
|
<File Name="src/cw/sock_hwaddrtostr.c"/>
|
||||||
<File Name="src/cw/mavliter_next.c"/>
|
<File Name="src/cw/mavliter_next.c"/>
|
||||||
@ -95,7 +92,6 @@
|
|||||||
<File Name="src/cw/lw_readelem_wtp_name.c"/>
|
<File Name="src/cw/lw_readelem_wtp_name.c"/>
|
||||||
<File Name="src/cw/capwap_cisco.h"/>
|
<File Name="src/cw/capwap_cisco.h"/>
|
||||||
<File Name="src/cw/cw_in_wtp_reboot_statistics.c"/>
|
<File Name="src/cw/cw_in_wtp_reboot_statistics.c"/>
|
||||||
<File Name="src/cw/avliter_seek.c"/>
|
|
||||||
<File Name="src/cw/mlist.c"/>
|
<File Name="src/cw/mlist.c"/>
|
||||||
<File Name="src/cw/netconn.c"/>
|
<File Name="src/cw/netconn.c"/>
|
||||||
<File Name="src/cw/mavl_create_conststr.c"/>
|
<File Name="src/cw/mavl_create_conststr.c"/>
|
||||||
@ -134,8 +130,6 @@
|
|||||||
<File Name="src/cw/cw_in_check_join_resp.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/cw_in_80211_mac_operation.c"/>
|
||||||
<File Name="src/cw/capwap_strings_board.c"/>
|
<File Name="src/cw/capwap_strings_board.c"/>
|
||||||
<File Name="src/cw/avltree_foreach_from_lr.c"/>
|
|
||||||
<File Name="src/cw/avliter_next.c"/>
|
|
||||||
<File Name="src/cw/capwap_80211_actions_ac.c"/>
|
<File Name="src/cw/capwap_80211_actions_ac.c"/>
|
||||||
<File Name="src/cw/mbag.h"/>
|
<File Name="src/cw/mbag.h"/>
|
||||||
<File Name="src/cw/sock_addrlen.c"/>
|
<File Name="src/cw/sock_addrlen.c"/>
|
||||||
@ -154,7 +148,6 @@
|
|||||||
<File Name="src/cw/intavltree.h"/>
|
<File Name="src/cw/intavltree.h"/>
|
||||||
<File Name="src/cw/sock_cmpaddr.c"/>
|
<File Name="src/cw/sock_cmpaddr.c"/>
|
||||||
<File Name="src/cw/cw_in_radio_administrative_state.c"/>
|
<File Name="src/cw/cw_in_radio_administrative_state.c"/>
|
||||||
<File Name="src/cw/avltree_get.c"/>
|
|
||||||
<File Name="src/cw/cwmsg_addelem_80211_add_wlan.c"/>
|
<File Name="src/cw/cwmsg_addelem_80211_add_wlan.c"/>
|
||||||
<File Name="src/cw/cw_in_check_generic_req.c"/>
|
<File Name="src/cw/cw_in_check_generic_req.c"/>
|
||||||
<File Name="src/cw/dot11.h"/>
|
<File Name="src/cw/dot11.h"/>
|
||||||
@ -206,7 +199,6 @@
|
|||||||
<File Name="src/cw/dtls_openssl_get_cipher.c"/>
|
<File Name="src/cw/dtls_openssl_get_cipher.c"/>
|
||||||
<File Name="src/cw/cw_addelem_capwap_local_ip_addr.c"/>
|
<File Name="src/cw/cw_addelem_capwap_local_ip_addr.c"/>
|
||||||
<File Name="src/cw/cw_out_generic.c"/>
|
<File Name="src/cw/cw_out_generic.c"/>
|
||||||
<File Name="src/cw/cw_iplist.c"/>
|
|
||||||
<File Name="src/cw/lw_addelem.c"/>
|
<File Name="src/cw/lw_addelem.c"/>
|
||||||
<File Name="src/cw/lw_in_vendor_specific.c"/>
|
<File Name="src/cw/lw_in_vendor_specific.c"/>
|
||||||
<File Name="src/cw/conn_q_add_packet.c"/>
|
<File Name="src/cw/conn_q_add_packet.c"/>
|
||||||
@ -240,11 +232,9 @@
|
|||||||
<File Name="src/cw/wtpinfo_lwreadelem_wtp_descriptor.c"/>
|
<File Name="src/cw/wtpinfo_lwreadelem_wtp_descriptor.c"/>
|
||||||
<File Name="src/cw/dbg_strings.c"/>
|
<File Name="src/cw/dbg_strings.c"/>
|
||||||
<File Name="src/cw/dtls_gnutls.c"/>
|
<File Name="src/cw/dtls_gnutls.c"/>
|
||||||
<File Name="src/cw/avltree_foreach_node.c"/>
|
|
||||||
<File Name="src/cw/conn_prepare_configuration_update_request.c"/>
|
<File Name="src/cw/conn_prepare_configuration_update_request.c"/>
|
||||||
<File Name="src/cw/conn_q_recv_packet.c"/>
|
<File Name="src/cw/conn_q_recv_packet.c"/>
|
||||||
<File Name="src/cw/bstr16_create_from_str.c"/>
|
<File Name="src/cw/bstr16_create_from_str.c"/>
|
||||||
<File Name="src/cw/avltree_foreach.c"/>
|
|
||||||
<File Name="src/cw/format_is_utf8.c"/>
|
<File Name="src/cw/format_is_utf8.c"/>
|
||||||
<File Name="src/cw/conn_create.c"/>
|
<File Name="src/cw/conn_create.c"/>
|
||||||
<File Name="src/cw/cw_in_check_img_data_req_wtp.c"/>
|
<File Name="src/cw/cw_in_check_img_data_req_wtp.c"/>
|
||||||
@ -300,7 +290,6 @@
|
|||||||
<File Name="src/cw/sock_getifinfo.c"/>
|
<File Name="src/cw/sock_getifinfo.c"/>
|
||||||
<File Name="src/cw/capwap_crypto.h"/>
|
<File Name="src/cw/capwap_crypto.h"/>
|
||||||
<File Name="src/cw/capwap_strings_state.c"/>
|
<File Name="src/cw/capwap_strings_state.c"/>
|
||||||
<File Name="src/cw/avltree_foreach_rl.c"/>
|
|
||||||
<File Name="src/cw/cw_out_radio_info.c"/>
|
<File Name="src/cw/cw_out_radio_info.c"/>
|
||||||
<File Name="src/cw/capwap_items.c"/>
|
<File Name="src/cw/capwap_items.c"/>
|
||||||
<File Name="src/cw/message_set.c"/>
|
<File Name="src/cw/message_set.c"/>
|
||||||
@ -328,6 +317,7 @@
|
|||||||
<File Name="src/cw/mavl_cmp_kv.c"/>
|
<File Name="src/cw/mavl_cmp_kv.c"/>
|
||||||
<File Name="src/cw/mavl_add_kv_byte.c"/>
|
<File Name="src/cw/mavl_add_kv_byte.c"/>
|
||||||
<File Name="src/cw/cw_types_mavl_delete.c"/>
|
<File Name="src/cw/cw_types_mavl_delete.c"/>
|
||||||
|
<File Name="src/cw/cw_format_scan_hex_bytes.c"/>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
<Description/>
|
<Description/>
|
||||||
|
@ -28,14 +28,14 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "aciplist.h"
|
#include "aciplist.h"
|
||||||
#include "avltree.h"
|
#include "mavl.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
|
|
||||||
|
|
||||||
static int acip_cmp(const void *x1, const void *x2)
|
static int acip_cmp(const mavldata_t *x1, const mavldata_t *x2)
|
||||||
{
|
{
|
||||||
struct cw_acip *ip1 = (struct cw_acip *) x1;
|
struct cw_acip *ip1 = (struct cw_acip *) x1->ptr;
|
||||||
struct cw_acip *ip2 = (struct cw_acip *) x2;
|
struct cw_acip *ip2 = (struct cw_acip *) x2->ptr;
|
||||||
|
|
||||||
int r = ip1->index - ip2->index;
|
int r = ip1->index - ip2->index;
|
||||||
if (r!=0)
|
if (r!=0)
|
||||||
@ -68,9 +68,9 @@ static int acip_cmp(const void *x1, const void *x2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acip_del(void *d)
|
static void acip_del(mavldata_t *d)
|
||||||
{
|
{
|
||||||
free(d);
|
free(d->ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,6 +79,6 @@ static void acip_del(void *d)
|
|||||||
*/
|
*/
|
||||||
cw_aciplist_t cw_aciplist_create()
|
cw_aciplist_t cw_aciplist_create()
|
||||||
{
|
{
|
||||||
return avltree_create(acip_cmp, acip_del);
|
return mavl_create(acip_cmp, acip_del);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ cw_action_in_t *cw_actionlist_in_add(cw_actionlist_in_t t, struct cw_action_in *
|
|||||||
*/
|
*/
|
||||||
struct cw_action_in *cw_actionlist_in_get(cw_actionlist_in_t t, struct cw_action_in *a)
|
struct cw_action_in *cw_actionlist_in_get(cw_actionlist_in_t t, struct cw_action_in *a)
|
||||||
{
|
{
|
||||||
return avltree_get(t, a);
|
return mavl_get(t, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ int cw_actionlist_out_register_actions(cw_actionlist_out_t t, cw_action_out_t *
|
|||||||
* @param s size of element to add
|
* @param s size of element to add
|
||||||
* @return pointer to added element or NULL if an error has opccured
|
* @return pointer to added element or NULL if an error has opccured
|
||||||
*/
|
*/
|
||||||
void *cw_actionlist_add(struct avltree *t, void *a, size_t s)
|
void *cw_actionlist_add(struct mavl *t, void *a, size_t s)
|
||||||
{
|
{
|
||||||
|
|
||||||
void *r = mavl_replace_data(t, a, s); //sizeof(struct cw_action_in));
|
void *r = mavl_replace_data(t, a, s); //sizeof(struct cw_action_in));
|
||||||
@ -273,7 +273,7 @@ void *cw_actionlist_add(struct avltree *t, void *a, size_t s)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy(an, a, s);
|
memcpy(an, a, s);
|
||||||
return avltree_add(t, an);
|
return mavl_add(t, an);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __AVLTREE_H
|
|
||||||
#define __AVLTREE_H
|
|
||||||
|
|
||||||
#include "mavl.h"
|
|
||||||
|
|
||||||
#define avltree mavl
|
|
||||||
#define avltree_get mavl_get
|
|
||||||
#define avltree_destroy mavl_destroy
|
|
||||||
#define avltree_create mavl_create
|
|
||||||
#define avltree_add mavl_add
|
|
||||||
#define avltree_del mavl_del
|
|
||||||
#define avltree_replace mavl_replace
|
|
||||||
#define avliter_foreach_from mavliter_foreach_from
|
|
||||||
#define avliter_foreach mavliter_foreach
|
|
||||||
#define avltree_foreach_asc mavl_foreach_asc
|
|
||||||
#define avliter_get mavliter_get
|
|
||||||
#define avltree_replace_data mavl_replace_data
|
|
||||||
#define avliter_seek mavliter_seek
|
|
||||||
#define avliter_seek_set mavliter_seek_set
|
|
||||||
#define avliter_next mavliter_next
|
|
||||||
#define avltree_del_all mavl_del_all
|
|
||||||
|
|
||||||
#define DEFINE_AVLITER MAVLITER_DEFINE
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ uint8_t * bstr16_create_from_str(const char *s)
|
|||||||
msize++;
|
msize++;
|
||||||
uint8_t * mem = malloc(2+msize);
|
uint8_t * mem = malloc(2+msize);
|
||||||
*((uint16_t*)mem)=msize;
|
*((uint16_t*)mem)=msize;
|
||||||
format_scan_hex_bytes(mem+2,s+2,l);
|
cw_format_scan_hex_bytes(mem+2,s+2,l);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ uint8_t * bstr_create_from_str(const char *s)
|
|||||||
msize++;
|
msize++;
|
||||||
uint8_t * mem = malloc(1+msize);
|
uint8_t * mem = malloc(1+msize);
|
||||||
*((uint8_t*)mem)=msize;
|
*((uint8_t*)mem)=msize;
|
||||||
format_scan_hex_bytes(mem+2,s+2,l);
|
cw_format_scan_hex_bytes(mem+2,s+2,l);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
|
|||||||
bstrv_set_vendor_id(mem,vendor_id);
|
bstrv_set_vendor_id(mem,vendor_id);
|
||||||
bstrv_set_len(mem,msize);
|
bstrv_set_len(mem,msize);
|
||||||
|
|
||||||
format_scan_hex_bytes(bstrv_data(mem),s+2,l);
|
cw_format_scan_hex_bytes(bstrv_data(mem),s+2,l);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,10 +125,13 @@ struct cw_wlan {
|
|||||||
|
|
||||||
int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||||
|
|
||||||
|
/*
|
||||||
//extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def);
|
//extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def);
|
||||||
|
*/
|
||||||
extern struct cw_strlist_elem capwap_strings_elem80211[];
|
extern struct cw_strlist_elem capwap_strings_elem80211[];
|
||||||
|
/*
|
||||||
//extern int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def);
|
//extern int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def);
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@}
|
*@}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
||||||
uint8_t * data, int len,struct sockaddr *from)
|
uint8_t * data, int len,struct sockaddr *from)
|
||||||
{
|
{
|
||||||
|
cw_acip_t * acip;
|
||||||
cw_aciplist_t list =
|
cw_aciplist_t list =
|
||||||
mbag_get_mavl_c(conn->incomming,a->item_id,cw_aciplist_create);
|
mbag_get_mavl_c(conn->incomming,a->item_id,cw_aciplist_create);
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_acip_t * acip;
|
|
||||||
acip = malloc(sizeof(cw_acip_t));
|
acip = malloc(sizeof(cw_acip_t));
|
||||||
if (!acip) {
|
if (!acip) {
|
||||||
cw_log(LOG_ERR,"Can't allocate memory for acv4ip: %s",strerror(errno));
|
cw_log(LOG_ERR,"Can't allocate memory for acv4ip: %s",strerror(errno));
|
||||||
|
@ -22,9 +22,10 @@ int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in *a,
|
|||||||
as.vendor_id = cw_get_dword(data);
|
as.vendor_id = cw_get_dword(data);
|
||||||
as.elem_id = cw_get_word(data + 4);
|
as.elem_id = cw_get_word(data + 4);
|
||||||
|
|
||||||
|
/*
|
||||||
// TODO XXXX
|
// TODO XXXX
|
||||||
// af = cw_actionlist_in_get(conn->actions->in, &as);
|
// af = cw_actionlist_in_get(conn->actions->in, &as);
|
||||||
af = 0;
|
*/ af = 0;
|
||||||
|
|
||||||
if (!af) {
|
if (!af) {
|
||||||
cw_dbg(DBG_WARN,
|
cw_dbg(DBG_WARN,
|
||||||
|
@ -47,3 +47,4 @@ int cw_in_wtp_reboot_statistics(struct conn *conn, struct cw_action_in *a, uint8
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,24 +32,26 @@
|
|||||||
* The memory allocated returned in data must be freed using free.
|
* The memory allocated returned in data must be freed using free.
|
||||||
*
|
*
|
||||||
* Eexample:
|
* Eexample:
|
||||||
* \code
|
* \code{.c}
|
||||||
#include "capwap/file.h"
|
#include "capwap/file.h"
|
||||||
size_t bytes;
|
size_t bytes;
|
||||||
char * data = cw_load_file("file.txt",&bytes);
|
char * data = cw_load_file("file.txt",&bytes);
|
||||||
if (data){
|
if (data){
|
||||||
// Do something with data ...
|
@startcomment Do something with data ... @endcomment
|
||||||
free (data);
|
free (data);
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
char *cw_load_file(const char *filename, size_t * size)
|
char *cw_load_file(const char *filename, size_t * size)
|
||||||
{
|
{
|
||||||
FILE *infile = fopen(filename, "rb");
|
char *buf;
|
||||||
|
FILE *infile;
|
||||||
|
infile = fopen(filename, "rb");
|
||||||
if (!infile)
|
if (!infile)
|
||||||
return NULL;
|
return NULL;
|
||||||
fseek(infile, 0, SEEK_END);
|
fseek(infile, 0, SEEK_END);
|
||||||
*size = ftell(infile);
|
*size = ftell(infile);
|
||||||
char *buf = malloc(*size);
|
buf = malloc(*size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
goto errX;
|
goto errX;
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
mbag_item_t * item = mbag_get(conn->outgoing,CW_ITEM_IMAGE_FILEHANDLE);
|
mbag_item_t * item = mbag_get(conn->outgoing,CW_ITEM_IMAGE_FILEHANDLE);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
cw_log(LOG_ERR,"Can't put element Image Data, no image filehandle found");
|
cw_log(LOG_ERR,"Can't put element Image Data, no image filehandle found");
|
||||||
@ -51,5 +52,7 @@ int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bytes + cw_put_elem_hdr(dst,a->elem_id,bytes);
|
return bytes + cw_put_elem_hdr(dst,a->elem_id,bytes);
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6elem_id)
|
int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6elem_id)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage a;
|
struct sockaddr_storage a;
|
||||||
|
int id;
|
||||||
|
|
||||||
socklen_t alen = sizeof(struct sockaddr_storage);
|
socklen_t alen = sizeof(struct sockaddr_storage);
|
||||||
int rc = getsockname(sock, (struct sockaddr *) &a, &alen);
|
int rc = getsockname(sock, (struct sockaddr *) &a, &alen);
|
||||||
|
|
||||||
@ -20,7 +22,6 @@ int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6ele
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int id;
|
|
||||||
|
|
||||||
switch (((struct sockaddr *) &a)->sa_family) {
|
switch (((struct sockaddr *) &a)->sa_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
@ -33,8 +34,9 @@ int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6ele
|
|||||||
|
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
{
|
{
|
||||||
|
struct sockaddr_in6 *sain;
|
||||||
id = ipv6elem_id;
|
id = ipv6elem_id;
|
||||||
struct sockaddr_in6 *sain = (struct sockaddr_in6 *) &a;
|
sain = (struct sockaddr_in6 *) &a;
|
||||||
cw_put_data(dst + 4, (uint8_t *) & sain->sin6_addr, 16);
|
cw_put_data(dst + 4, (uint8_t *) & sain->sin6_addr, 16);
|
||||||
return 16 + cw_put_elem_hdr(dst, id, 16);
|
return 16 + cw_put_elem_hdr(dst, id, 16);
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put a message to a buffer
|
* Put a message to a buffer
|
||||||
* This functions assumes, that a message header is
|
* This functions assumes, that a message header is
|
||||||
@ -156,10 +157,10 @@ int cw_put_custom_msg(struct conn *conn, uint8_t * rawout, mavl_conststr_t elems
|
|||||||
|
|
||||||
/// TODO XXXX
|
/// TODO XXXX
|
||||||
// DEFINE_AVLITER(i,conn->actions->out);
|
// DEFINE_AVLITER(i,conn->actions->out);
|
||||||
DEFINE_AVLITER(i,0);
|
MAVLITER_DEFINE(i,0);
|
||||||
cw_action_out_t *am;
|
cw_action_out_t *am;
|
||||||
|
|
||||||
if (! (am=avliter_seek(&i,&as))){
|
if (! (am=mavliter_seek(&i,&as))){
|
||||||
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
|
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
|
||||||
as.msg_id,cw_strmsg(as.msg_id));
|
as.msg_id,cw_strmsg(as.msg_id));
|
||||||
return -1;
|
return -1;
|
||||||
@ -167,7 +168,7 @@ DEFINE_AVLITER(i,0);
|
|||||||
|
|
||||||
cw_action_out_t *ae;
|
cw_action_out_t *ae;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while(NULL != (ae=avliter_next(&i))) {
|
while(NULL != (ae=mavliter_next(&i))) {
|
||||||
|
|
||||||
// DBGX("Put %d %i %p\n",ae->msg_id,ae->elem_id,ae->item_id);
|
// DBGX("Put %d %i %p\n",ae->msg_id,ae->elem_id,ae->item_id);
|
||||||
// DBGX("Elem ID %s",ae->item_id);
|
// DBGX("Elem ID %s",ae->item_id);
|
||||||
|
@ -67,6 +67,8 @@ int cw_rand_r(uint8_t * dst, int len)
|
|||||||
int cw_rand(uint8_t * dst, int len)
|
int cw_rand(uint8_t * dst, int len)
|
||||||
{
|
{
|
||||||
static uint32_t rinit = 0;
|
static uint32_t rinit = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!rinit) {
|
if (!rinit) {
|
||||||
|
|
||||||
int l = cw_rand_r((uint8_t *) (&rinit), sizeof(uint32_t));
|
int l = cw_rand_r((uint8_t *) (&rinit), sizeof(uint32_t));
|
||||||
@ -79,7 +81,7 @@ int cw_rand(uint8_t * dst, int len)
|
|||||||
|
|
||||||
srand(rinit);
|
srand(rinit);
|
||||||
}
|
}
|
||||||
int i;
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
dst[i] = rand();
|
dst[i] = rand();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
*@brief
|
*@brief
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#include <string.h>
|
|
||||||
|
|
||||||
#include "mbag.h"
|
#include "mbag.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
struct dtls_ssl_cert dtls_gnutls_get_peers_cert(struct conn * conn,unsigned int n)
|
struct dtls_ssl_cert dtls_gnutls_get_peers_cert(struct conn * conn,unsigned int n)
|
||||||
{
|
{
|
||||||
struct dtls_gnutls_data *d;
|
struct dtls_gnutls_data *d;
|
||||||
|
const gnutls_datum_t * clist;
|
||||||
|
struct dtls_ssl_cert cert;
|
||||||
|
unsigned int len;
|
||||||
|
|
||||||
|
|
||||||
d=(struct dtls_gnutls_data*)conn->dtls_data;
|
d=(struct dtls_gnutls_data*)conn->dtls_data;
|
||||||
|
|
||||||
const gnutls_datum_t * clist;
|
|
||||||
|
|
||||||
struct dtls_ssl_cert cert;
|
|
||||||
|
|
||||||
unsigned int len;
|
|
||||||
clist = gnutls_certificate_get_peers(d->session,&len);
|
clist = gnutls_certificate_get_peers(d->session,&len);
|
||||||
|
|
||||||
cert.size = clist[n].size;
|
cert.size = clist[n].size;
|
||||||
|
@ -62,55 +62,6 @@ int format_hex_bytes(char *dst, const char *format, const char *delim,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read hex bytes from a string to an uint8_t array
|
|
||||||
* @param dst destination array
|
|
||||||
* @param s string to read
|
|
||||||
* @param len length of string
|
|
||||||
* @return 0 if all was ok \n 1 if an error has occured.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int format_scan_hex_bytes(uint8_t *dst,const char *s, int len)
|
|
||||||
{
|
|
||||||
int rc ;
|
|
||||||
int err=0;
|
|
||||||
int val;
|
|
||||||
int c;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if ( len & 1){
|
|
||||||
rc = sscanf(s,"%01X",&c);
|
|
||||||
if (rc!=1){
|
|
||||||
c=0;
|
|
||||||
err=1;
|
|
||||||
}
|
|
||||||
*dst++=c;
|
|
||||||
s++;
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i=0; i<len; i++){
|
|
||||||
rc = sscanf(s+i,"%01X",&c);
|
|
||||||
if (rc!=1){
|
|
||||||
c=0;
|
|
||||||
err=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!(i&1)) {
|
|
||||||
val = c<<4;
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
val |= c;
|
|
||||||
*dst++=val;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *format_s_hex_bytes(char *dst, const char *format, const char *delim,
|
char *format_s_hex_bytes(char *dst, const char *format, const char *delim,
|
||||||
const uint8_t * src, int len)
|
const uint8_t * src, int len)
|
||||||
|
@ -43,8 +43,9 @@ char *format_s_hex_bytes(char *dst, const char *format, const char *delim,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int format_scan_hex_bytes(uint8_t * dst, const char *s, int len);
|
int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
|
||||||
|
|
||||||
|
struct avltree;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format bytes as a hex string. Hexadecimal letters are lower-case.
|
* Format bytes as a hex string. Hexadecimal letters are lower-case.
|
||||||
|
@ -30,7 +30,7 @@ static struct mbag_item * from_str(const char *src)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*(mem)=msize;
|
*(mem)=msize;
|
||||||
format_scan_hex_bytes(mem+1,src,l);
|
cw_format_scan_hex_bytes(mem+1,src,l);
|
||||||
i->u2.data=mem;
|
i->u2.data=mem;
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
|
@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
//extern const char CW_RADIO_ADMIN_STATE[];
|
//extern const char CW_RADIO_ADMIN_STATE[];
|
||||||
//extern const char CW_RADIO_OPER_STATE[];
|
//extern const char CW_RADIO_OPER_STATE[];
|
||||||
|
*/
|
||||||
|
|
||||||
extern const char CW_RADIO_SUPPORTED_RATES[];
|
extern const char CW_RADIO_SUPPORTED_RATES[];
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ static void del(void* d)
|
|||||||
|
|
||||||
struct avltree * stravltree_create()
|
struct avltree * stravltree_create()
|
||||||
{
|
{
|
||||||
return avltree_create(cmp,del);
|
return mavl_create(cmp,del);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * stravltree_add(struct avltree * t, const char * str)
|
const char * stravltree_add(struct avltree * t, const char * str)
|
||||||
@ -26,5 +26,5 @@ const char * stravltree_add(struct avltree * t, const char * str)
|
|||||||
char * s = strdup(str);
|
char * s = strdup(str);
|
||||||
if (!s)
|
if (!s)
|
||||||
return 0;
|
return 0;
|
||||||
return avltree_add(t,s);
|
return mavl_add(t,s);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef __STRAVLTREE_H
|
#ifndef __STRAVLTREE_H
|
||||||
#define __STRAVLTREE_H
|
#define __STRAVLTREE_H
|
||||||
|
|
||||||
#include "avltree.h"
|
#include "mavl.h"
|
||||||
|
|
||||||
extern struct avltree * stravltree_create();
|
extern struct avltree * stravltree_create();
|
||||||
const char * stravltree_add(struct avltree * t, const char * str);
|
const char * stravltree_add(struct avltree * t, const char * str);
|
||||||
#define stravltree_destroy(t) avltree_destroy(t)
|
#define stravltree_destroy(t) mavl_destroy(t)
|
||||||
#define stravltree_foreach_asc(t,f,p) avltree_foreach_asc(t,f,p)
|
#define stravltree_foreach_asc(t,f,p) avltree_foreach_asc(t,f,p)
|
||||||
#define stravltree_foreach_desc(t,f,p) avltree_foreach_desc(t,f,p)
|
#define stravltree_foreach_desc(t,f,p) avltree_foreach_desc(t,f,p)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ int cw_strheap_register_strings(cw_strheap_t h, struct cw_strlist_elem *s)
|
|||||||
const char * cw_strheap_get(cw_strheap_t h, int id) {
|
const char * cw_strheap_get(cw_strheap_t h, int id) {
|
||||||
struct cw_strlist_elem s;
|
struct cw_strlist_elem s;
|
||||||
s.id=id;
|
s.id=id;
|
||||||
struct cw_strlist_elem *r = avltree_get(h,&s);
|
struct cw_strlist_elem *r = mavl_get(h,&s);
|
||||||
if (r)
|
if (r)
|
||||||
return r->str;
|
return r->str;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
#include "avltree.h"
|
#include "mavl.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct avltree * cw_strheap_t;
|
typedef struct mavl * cw_strheap_t;
|
||||||
|
|
||||||
|
|
||||||
extern cw_strheap_t cw_strheap_create();
|
extern cw_strheap_t cw_strheap_create();
|
||||||
|
Loading…
Reference in New Issue
Block a user