cw_select_ac function is done
FossilOrigin-Name: 664aa92562692cc3d73e2540649b3896fac26401247a2a9d0059aa874c2ef914
This commit is contained in:
parent
4c9d1746c0
commit
6b7b76db84
@ -268,6 +268,7 @@
|
|||||||
<File Name="src/cw/cw_read_radio_generic.c"/>
|
<File Name="src/cw/cw_read_radio_generic.c"/>
|
||||||
<File Name="src/cw/cw_read_from.c"/>
|
<File Name="src/cw/cw_read_from.c"/>
|
||||||
<File Name="src/cw/cw_write_radio_element.c"/>
|
<File Name="src/cw/cw_write_radio_element.c"/>
|
||||||
|
<File Name="src/cw/cw_type_sysptr.c"/>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
<Description/>
|
<Description/>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# If ommited ac_name is build from macaddress.
|
# If ommited ac_name is build from macaddress.
|
||||||
#
|
#
|
||||||
#Default: ac_name = Cisco80
|
#Default: ac_name = Cisco80
|
||||||
ac_name = "CiscAc73"
|
ac_name = "TubesAC"
|
||||||
|
|
||||||
# ac_id
|
# ac_id
|
||||||
# A unique ID for this AC
|
# A unique ID for this AC
|
||||||
|
@ -11,7 +11,7 @@ ac-descriptor/software/version:Bstr16:.x090103
|
|||||||
ac-descriptor/software/vendor:Dword:.1234
|
ac-descriptor/software/vendor:Dword:.1234
|
||||||
ac-descriptor/hardware/vendor:Dword:1234567
|
ac-descriptor/hardware/vendor:Dword:1234567
|
||||||
ac-descriptor/hardware/version:Bstr16:"1.7.3"
|
ac-descriptor/hardware/version:Bstr16:"1.7.3"
|
||||||
ac-name:Bstr16:"actubes name"
|
ac-name:Bstr16:"TubesAC"
|
||||||
|
|
||||||
capwap-control-ip-address/address.0:IPAddress:192.168.0.1
|
capwap-control-ip-address/address.0:IPAddress:192.168.0.1
|
||||||
capwap-control-ip-address/address.1:IPAddress:192.168.0.7
|
capwap-control-ip-address/address.1:IPAddress:192.168.0.7
|
||||||
|
@ -105,6 +105,7 @@ CWSRC=\
|
|||||||
cw_type_dword.c\
|
cw_type_dword.c\
|
||||||
cw_type_ipaddress.c\
|
cw_type_ipaddress.c\
|
||||||
cw_type_word.c\
|
cw_type_word.c\
|
||||||
|
cw_type_sysptr.c\
|
||||||
cw_util.c\
|
cw_util.c\
|
||||||
cw_write_descriptor_subelem.c\
|
cw_write_descriptor_subelem.c\
|
||||||
cw_read_from.c \
|
cw_read_from.c \
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
#include "ktv.h"
|
#include "ktv.h"
|
||||||
|
/**
|
||||||
|
* @brief Default function to compare two values of type #cw_KTV_t.
|
||||||
|
*
|
||||||
|
* @param v1
|
||||||
|
* @param v2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int cw_ktv_mavlcmp(const void *v1, const void *v2)
|
int cw_ktv_mavlcmp(const void *v1, const void *v2)
|
||||||
{
|
{
|
||||||
char *d1,*d2;
|
char *d1,*d2;
|
||||||
|
@ -7,12 +7,14 @@ struct parser {
|
|||||||
int pos;
|
int pos;
|
||||||
int prevpos;
|
int prevpos;
|
||||||
char error[256];
|
char error[256];
|
||||||
|
int quote;
|
||||||
|
FILE *f;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int get_char(FILE * f, struct parser *p)
|
static int get_char(struct parser *p)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
c = fgetc (f);
|
c = fgetc (p->f);
|
||||||
p->pos++;
|
p->pos++;
|
||||||
if (c=='\n'){
|
if (c=='\n'){
|
||||||
p->prevpos=p->pos;
|
p->prevpos=p->pos;
|
||||||
@ -22,8 +24,9 @@ static int get_char(FILE * f, struct parser *p)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unget_char(int c, FILE *f, struct parser *p){
|
|
||||||
ungetc(c,f);
|
static void unget_char(struct parser *p,int c){
|
||||||
|
ungetc(c,p->f);
|
||||||
if (c=='\n'){
|
if (c=='\n'){
|
||||||
p->line--;
|
p->line--;
|
||||||
p->pos=p->prevpos;
|
p->pos=p->prevpos;
|
||||||
@ -32,11 +35,71 @@ static void unget_char(int c, FILE *f, struct parser *p){
|
|||||||
p->pos--;
|
p->pos--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int skip_chars (FILE *f, const char * chars, struct parser * p )
|
|
||||||
|
|
||||||
|
static int get_char_q(struct parser *p)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
c = get_char(p);
|
||||||
|
if (c==EOF || c=='\n')
|
||||||
|
return c;
|
||||||
|
|
||||||
|
if(c=='"' && !p->quote){
|
||||||
|
p->quote=1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(c=='"' && p->quote){
|
||||||
|
p->quote=0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!p->quote)
|
||||||
|
return c;
|
||||||
|
|
||||||
|
if (c!='\\')
|
||||||
|
return c;
|
||||||
|
|
||||||
|
c = get_char(p);
|
||||||
|
switch(c){
|
||||||
|
case EOF:
|
||||||
|
return c;
|
||||||
|
case 'n':
|
||||||
|
return '\n';
|
||||||
|
|
||||||
|
case '\\':
|
||||||
|
return '\\';
|
||||||
|
case '"':
|
||||||
|
return '"';
|
||||||
|
default:
|
||||||
|
unget_char(p,c);
|
||||||
|
return '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We will never reach here */
|
||||||
|
/* return c;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int skip_chars (struct parser *p, const char * chars)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ( (c = get_char (f, p)) != EOF) {
|
while ( (c = get_char (p)) != EOF) {
|
||||||
if (strchr (chars, c))
|
if (strchr (chars, c))
|
||||||
continue;
|
continue;
|
||||||
return c;
|
return c;
|
||||||
@ -44,11 +107,11 @@ static int skip_chars (FILE *f, const char * chars, struct parser * p )
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int skip_to_chars (FILE *f, const char *chars, struct parser * p)
|
static int skip_to_chars (struct parser *p, const char *chars)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ( (c = get_char (f, p)) != EOF) {
|
while ( (c = get_char (p)) != EOF) {
|
||||||
if (strchr (chars, c))
|
if (strchr (chars, c))
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -57,30 +120,32 @@ static int skip_to_chars (FILE *f, const char *chars, struct parser * p)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int read_key (FILE *f, char *key, int max_len, struct parser * p)
|
static int read_key (struct parser *p, char *key, int max_len)
|
||||||
{
|
{
|
||||||
int c,n;
|
int c,n;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
c = skip_chars (f, " \t\n\a\v", p);
|
c = skip_chars (p, " \t\n\a\v");
|
||||||
if (c == '#') {
|
if (c == '#') {
|
||||||
c = skip_to_chars (f, "\n\a",p);
|
c = skip_to_chars (p, "\n\a");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (c != EOF);
|
} while (c != EOF);
|
||||||
|
|
||||||
|
unget_char(p,c);
|
||||||
|
c=get_char_q(p);
|
||||||
|
|
||||||
n=0;
|
n=0;
|
||||||
while(c!=EOF && n<max_len){
|
while(c!=EOF && n<max_len){
|
||||||
if (!isalnum(c) && !strchr("._/-()@#|{}[]",c)/*strchr(": \t\n\a",c)*/){
|
if (!p->quote && !isalnum(c) && !strchr("._/-()@#|{}[]\\",c)/*strchr(": \t\n\a",c)*/){
|
||||||
unget_char(c,f,p);
|
unget_char(p,c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
key[n]=c;
|
key[n]=c;
|
||||||
c=get_char(f,p);
|
c=get_char_q(p);
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -92,10 +157,10 @@ static int read_key (FILE *f, char *key, int max_len, struct parser * p)
|
|||||||
static int skip_to_colon(FILE *f,struct parser * p)
|
static int skip_to_colon(FILE *f,struct parser * p)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
c = skip_chars (f, " \t", p);
|
c = skip_chars (p, " \t");
|
||||||
if (c!=':'){
|
if (c!=':'){
|
||||||
if (c=='\n'){
|
if (c=='\n'){
|
||||||
unget_char(c,f,p);
|
unget_char(p,c);
|
||||||
sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL, collon expected.", p->line, p->pos);
|
sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL, collon expected.", p->line, p->pos);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -106,24 +171,24 @@ static int skip_to_colon(FILE *f,struct parser * p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int read_type(FILE *f, char *type, int max_len, struct parser *p)
|
static int read_type(struct parser *p, char *type, int max_len)
|
||||||
{
|
{
|
||||||
int c,n;
|
int c,n;
|
||||||
|
|
||||||
if (!skip_to_colon(f,p))
|
if (!skip_to_colon(p->f,p))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
c = skip_chars (f, " \t", p);
|
c = skip_chars (p, " \t");
|
||||||
|
|
||||||
if (c==':'){
|
if (c==':'){
|
||||||
unget_char(c,f,p);
|
unget_char(p,c);
|
||||||
sprintf(type,"%s","");
|
sprintf(type,"%s","");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isalpha(c)){
|
if (!isalpha(c)){
|
||||||
if (c=='\n'){
|
if (c=='\n'){
|
||||||
unget_char(c,f,p);
|
unget_char(p,c);
|
||||||
sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL.", p->line, p->pos);
|
sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL.", p->line, p->pos);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -135,26 +200,27 @@ static int read_type(FILE *f, char *type, int max_len, struct parser *p)
|
|||||||
n=0;
|
n=0;
|
||||||
while(c!=EOF && n<max_len){
|
while(c!=EOF && n<max_len){
|
||||||
if (!isalnum(c) && !strchr("_/-.()@#|{}[]",c)/*strchr(": \t\n\a",c)*/){
|
if (!isalnum(c) && !strchr("_/-.()@#|{}[]",c)/*strchr(": \t\n\a",c)*/){
|
||||||
unget_char(c,f,p);
|
unget_char(p,c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
type[n]=c;
|
type[n]=c;
|
||||||
c=get_char(f,p);
|
c=get_char(p);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
type[n]=0;
|
type[n]=0;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_val(FILE *f, char *val, int max_len, struct parser *p){
|
|
||||||
|
static int read_val(struct parser *p, char *val, int max_len){
|
||||||
int c,n,quote;
|
int c,n,quote;
|
||||||
if (!skip_to_colon(f,p))
|
if (!skip_to_colon(p->f,p))
|
||||||
return -1;
|
return -1;
|
||||||
c = skip_chars (f, " \t", p);
|
c = skip_chars (p, " \t");
|
||||||
if (c=='"'){
|
if (c=='"'){
|
||||||
quote=1;
|
quote=1;
|
||||||
c=get_char(f,p);
|
c=get_char(p);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
quote=0;
|
quote=0;
|
||||||
@ -169,7 +235,7 @@ static int read_val(FILE *f, char *val, int max_len, struct parser *p){
|
|||||||
}
|
}
|
||||||
if (quote){
|
if (quote){
|
||||||
if (c=='\\'){
|
if (c=='\\'){
|
||||||
c = get_char(f,p);
|
c = get_char(p);
|
||||||
switch(c){
|
switch(c){
|
||||||
case 'n':
|
case 'n':
|
||||||
c='\n';
|
c='\n';
|
||||||
@ -179,13 +245,13 @@ static int read_val(FILE *f, char *val, int max_len, struct parser *p){
|
|||||||
case '"':
|
case '"':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
unget_char(c,f,p);
|
unget_char(p,c);
|
||||||
c='\\';
|
c='\\';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val[n++]=c;
|
val[n++]=c;
|
||||||
c=get_char(f,p);
|
c=get_char(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,14 +280,16 @@ int cw_ktv_read_line (FILE *f, char * key, char * type, char *val)
|
|||||||
p.line=1;
|
p.line=1;
|
||||||
p.pos=0;
|
p.pos=0;
|
||||||
p.prevpos=0;
|
p.prevpos=0;
|
||||||
|
p.quote=0;
|
||||||
|
p.f=f;
|
||||||
|
|
||||||
n = read_key (f,key,CW_KTV_MAX_KEY_LEN,&p);
|
n = read_key (&p,key,CW_KTV_MAX_KEY_LEN);
|
||||||
n = read_type (f,type,CW_KTV_MAX_KEY_LEN,&p);
|
n = read_type (&p,type,CW_KTV_MAX_KEY_LEN);
|
||||||
if (n==-1){
|
if (n==-1){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = read_val (f,val,CW_KTV_MAX_KEY_LEN,&p);
|
n = read_val (&p,val,CW_KTV_MAX_KEY_LEN);
|
||||||
if (n==-1){
|
if (n==-1){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,6 @@ const cw_Type_t * cw_ktv_std_types[] = {
|
|||||||
CW_TYPE_DWORD,
|
CW_TYPE_DWORD,
|
||||||
CW_TYPE_BSTR16,
|
CW_TYPE_BSTR16,
|
||||||
CW_TYPE_IPADDRESS,
|
CW_TYPE_IPADDRESS,
|
||||||
|
CW_TYPE_SYSPTR,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
75
src/cw/cw_type_sysptr.c
Normal file
75
src/cw/cw_type_sysptr.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
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 <stdio.h>
|
||||||
|
|
||||||
|
#include "format.h"
|
||||||
|
#include "cw.h"
|
||||||
|
#include "ktv.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void del ( struct cw_KTV * data )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
||||||
|
{
|
||||||
|
data->type = &cw_type_sysptr;
|
||||||
|
data->val.ptr = ((void**)(src))[0];
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int put ( const struct cw_KTV *data, uint8_t * dst )
|
||||||
|
{
|
||||||
|
((void**)dst)[0] = data->val.ptr ;
|
||||||
|
return sizeof(void*);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
||||||
|
{
|
||||||
|
return sprintf(dst,"%p",data->val.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
||||||
|
{
|
||||||
|
uint8_t * s;
|
||||||
|
s = bstr16_create_from_str(src);
|
||||||
|
|
||||||
|
if ( !s )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
data->type = &cw_type_bstr16;
|
||||||
|
data->val.ptr = s;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static int len ( struct cw_KTV * data ){
|
||||||
|
return sizeof(void*);
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct cw_Type cw_type_sysptr = {
|
||||||
|
"Sysptr", /* name */
|
||||||
|
del, /* del */
|
||||||
|
put, /* put */
|
||||||
|
get, /* get */
|
||||||
|
to_str, /* to_str */
|
||||||
|
from_str, /* from_str */
|
||||||
|
len /* len */
|
||||||
|
};
|
@ -96,12 +96,14 @@ extern const struct cw_Type cw_type_word;
|
|||||||
extern const struct cw_Type cw_type_dword;
|
extern const struct cw_Type cw_type_dword;
|
||||||
extern const struct cw_Type cw_type_bstr16;
|
extern const struct cw_Type cw_type_bstr16;
|
||||||
extern const struct cw_Type cw_type_ipaddress;
|
extern const struct cw_Type cw_type_ipaddress;
|
||||||
|
extern const struct cw_Type cw_type_sysptr;
|
||||||
|
|
||||||
#define CW_TYPE_BYTE (&cw_type_byte)
|
#define CW_TYPE_BYTE (&cw_type_byte)
|
||||||
#define CW_TYPE_WORD (&cw_type_word)
|
#define CW_TYPE_WORD (&cw_type_word)
|
||||||
#define CW_TYPE_DWORD (&cw_type_dword)
|
#define CW_TYPE_DWORD (&cw_type_dword)
|
||||||
#define CW_TYPE_BSTR16 (&cw_type_bstr16)
|
#define CW_TYPE_BSTR16 (&cw_type_bstr16)
|
||||||
#define CW_TYPE_IPADDRESS (&cw_type_ipaddress)
|
#define CW_TYPE_IPADDRESS (&cw_type_ipaddress)
|
||||||
|
#define CW_TYPE_SYSPTR (&cw_type_sysptr)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void cw_kvstore_mavl_delete(const void *data);
|
void cw_kvstore_mavl_delete(const void *data);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file mavl.h
|
||||||
* @brief MAVL, Mini AVL Tree,
|
* @brief MAVL, Mini AVL Tree,
|
||||||
* Yet another AVL Tree implementation
|
* Yet another AVL Tree implementation
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,7 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
#SRC=$(wildcard *.c)
|
#SRC=$(wildcard *.c)
|
||||||
SRC=wtp_main.c discovery.c
|
SRC=wtp_main.c discovery.c
|
||||||
|
|
||||||
OBJS=$(patsubst %.c,%.o,$(SRC))
|
OBJS=$(patsubst %.c,%.o,$(SRC))
|
||||||
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
capwap/vars/MaxDiscoveries:Word:10
|
||||||
|
capwap/vars/MaxRetransmit:Word:4
|
||||||
|
|
||||||
|
|
||||||
# hallo
|
|
||||||
windows:Word:124
|
windows:Word:124
|
||||||
|
|
||||||
basic/mod:Bstr16:cisco
|
basic/mod:Bstr16:cisco
|
||||||
@ -24,9 +26,17 @@ wtp-descriptor/software/vendor:Dword:906090
|
|||||||
wtp-descriptor/software/version:Bstr16:.x171312
|
wtp-descriptor/software/version:Bstr16:.x171312
|
||||||
wtp-descriptor/bootloader/vendor:Dword:906090
|
wtp-descriptor/bootloader/vendor:Dword:906090
|
||||||
wtp-descriptor/bootloader/version:Bstr16:.x171312
|
wtp-descriptor/bootloader/version:Bstr16:.x171312
|
||||||
wtp-descriptor/max-radios:Byte:2
|
wtp-descriptor/max-radios:Byte:3
|
||||||
|
|
||||||
radio/0/wtp-radio-information:Dword:01
|
radio/0/wtp-radio-information:Dword:01
|
||||||
radio/1/wtp-radio-information:Dword:02
|
radio/1/wtp-radio-information:Dword:02
|
||||||
|
|
||||||
wtp-name:Bstr16:WFAT01
|
wtp-name:Bstr16:WFAT01
|
||||||
|
|
||||||
|
|
||||||
|
wtp-fallback:Byte:1
|
||||||
|
"ac-name-with-priority/TubesAC":Byte:3
|
||||||
|
ac-name-with-priority/"ac2":Byte:01
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,44 +16,80 @@
|
|||||||
#include "wtp.h"
|
#include "wtp.h"
|
||||||
|
|
||||||
|
|
||||||
int cw_select_ac(mlist_t aclist){
|
int cw_select_ac(mavl_t local_cfg,mlist_t aclist){
|
||||||
mlistelem_t * e;
|
mlistelem_t * e;
|
||||||
mavl_t best_ac;
|
int en;
|
||||||
|
mavl_t iplist;
|
||||||
best_ac=NULL;
|
|
||||||
|
|
||||||
|
iplist=cw_ktv_create();
|
||||||
|
if (iplist == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
en=0;
|
||||||
|
|
||||||
|
/* for each discovery response */
|
||||||
mlist_foreach(e,aclist){
|
mlist_foreach(e,aclist){
|
||||||
char str[1024];
|
char str[1024];
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
mavl_t cfg;
|
mavl_t remote_cfg;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
cw_KTV_t * val;
|
cw_KTV_t * val;
|
||||||
cfg = mlistelem_get_ptr(e);
|
int prio;
|
||||||
val = cw_ktv_get(cfg,"ac-name", CW_TYPE_BSTR16);
|
|
||||||
|
remote_cfg = mlistelem_get_ptr(e);
|
||||||
|
|
||||||
|
/* get ac name */
|
||||||
|
val = cw_ktv_get(remote_cfg,"ac-name", CW_TYPE_BSTR16);
|
||||||
if (val==NULL)
|
if (val==NULL)
|
||||||
continue;
|
continue;
|
||||||
if (best_ac==NULL){
|
|
||||||
best_ac=cfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val->type->to_str(val,str,1024);
|
val->type->to_str(val,str,1024);
|
||||||
|
sprintf(key,"ac-name-with-priority/%s",str);
|
||||||
|
|
||||||
|
printf("Get prio: %s\n",key);
|
||||||
|
|
||||||
|
prio = cw_ktv_get_byte(local_cfg,key,255);
|
||||||
|
|
||||||
i=0;
|
i=0;
|
||||||
do {
|
do {
|
||||||
|
cw_KTV_t * ipval;
|
||||||
sprintf(key,"%s.%d","capwap-control-ip-address/wtps",i);
|
sprintf(key,"%s.%d","capwap-control-ip-address/wtps",i);
|
||||||
val = cw_ktv_get(cfg,key,CW_TYPE_WORD);
|
val = cw_ktv_get(remote_cfg,key,CW_TYPE_WORD);
|
||||||
if (val == NULL)
|
if (val == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
sprintf(key,"%s.%d","capwap-control-ip-address/address",i);
|
||||||
|
printf("ipvalkey: %s\n",key);
|
||||||
|
ipval = cw_ktv_get(remote_cfg,key,CW_TYPE_IPADDRESS);
|
||||||
|
|
||||||
|
sprintf(key,"%04d%05d%04d",prio,val->val.word,en);
|
||||||
|
en++;
|
||||||
|
printf("This is the key: %s\n",key);
|
||||||
|
|
||||||
|
cw_ktv_add(iplist,key,CW_TYPE_SYSPTR,(uint8_t*)(&ipval),sizeof(ipval));
|
||||||
|
i++;
|
||||||
}while(1);
|
}while(1);
|
||||||
printf("Here we have an AC: %s\n",str);
|
printf("Here we have an AC: %s\n",str);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cw_dbg_ktv_dump(iplist,DBG_INFO,"=== IP list ===", "IP", "=== END IP List ===");
|
||||||
|
{
|
||||||
|
mavliter_t i;
|
||||||
|
mavliter_init(&i,iplist);
|
||||||
|
|
||||||
|
mavliter_foreach(&i){
|
||||||
|
char ipstr[100];
|
||||||
|
char *rk;
|
||||||
|
cw_KTV_t * val;
|
||||||
|
val = mavliter_get(&i);
|
||||||
|
rk = val->key;
|
||||||
|
val = val->val.ptr;
|
||||||
|
val->type->to_str(val,ipstr,100);
|
||||||
|
printf("PTRVAL(%s): %s - %s\n",rk,val->key,ipstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -100,7 +136,7 @@ static int run_discovery(struct conn *conn)
|
|||||||
conn->remote_cfg=cw_ktv_create();
|
conn->remote_cfg=cw_ktv_create();
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_select_ac(discovery_results);
|
cw_select_ac(conn->local_cfg,discovery_results);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
#include "cw/sock.h"
|
#include "cw/sock.h"
|
||||||
#include "cw/dtls.h"
|
#include "cw/dtls.h"
|
||||||
#include "cw/aciplist.h"
|
#include "cw/aciplist.h"
|
||||||
#include "cw/capwap_items.h"
|
|
||||||
#include "cw/mbag.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define acinfo_log acinfo_log_
|
#define acinfo_log acinfo_log_
|
||||||
@ -96,6 +96,7 @@ acinfo.result_code=99;
|
|||||||
|
|
||||||
int run_join_d(struct sockaddr *sa)
|
int run_join_d(struct sockaddr *sa)
|
||||||
{
|
{
|
||||||
|
char addrstr[SOCK_ADDR_BUFSIZE];
|
||||||
struct conn *conn = get_conn();
|
struct conn *conn = get_conn();
|
||||||
conn->capwap_state = CAPWAP_STATE_JOIN;
|
conn->capwap_state = CAPWAP_STATE_JOIN;
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ int run_join_d(struct sockaddr *sa)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cw_dbg(DBG_DTLS, "Establishing DTLS session with %s", sock_addr2str(sa));
|
cw_dbg(DBG_DTLS, "Establishing DTLS session with %s", sock_addr2str(sa, addrstr));
|
||||||
|
|
||||||
int dtls_conf_ok=0;
|
int dtls_conf_ok=0;
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ int run_join_d(struct sockaddr *sa)
|
|||||||
|
|
||||||
if (!dtls_conf_ok){
|
if (!dtls_conf_ok){
|
||||||
cw_log(LOG_ERR,"Can't establish DTLS connection with %s, neither psk nor cert set in config",
|
cw_log(LOG_ERR,"Can't establish DTLS connection with %s, neither psk nor cert set in config",
|
||||||
sock_addr2str(sa));
|
sock_addr2str(sa,addrstr));
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -157,14 +158,14 @@ int run_join_d(struct sockaddr *sa)
|
|||||||
if (rc != 1) {
|
if (rc != 1) {
|
||||||
dtls_shutdown(conn);
|
dtls_shutdown(conn);
|
||||||
cw_log(LOG_ERR, "Can't establish DTLS connection with %s",
|
cw_log(LOG_ERR, "Can't establish DTLS connection with %s",
|
||||||
sock_addr2str(sa));
|
sock_addr2str(sa,addrstr));
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_DTLS, "DTLS Connection successful established with %s",
|
cw_dbg(DBG_DTLS, "DTLS Connection successful established with %s",
|
||||||
sock_addr2str(sa));
|
sock_addr2str(sa,addrstr));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -172,36 +173,41 @@ int run_join_d(struct sockaddr *sa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int run_join(struct conn *conn)
|
int run_join(struct conn *conn)
|
||||||
{
|
{
|
||||||
|
char addrstr[SOCK_ADDR_BUFSIZE];
|
||||||
|
/*
|
||||||
// cw_init_request(conn, CW_MSG_JOIN_REQUEST);
|
// cw_init_request(conn, CW_MSG_JOIN_REQUEST);
|
||||||
// if ( cw_put_msg(conn, conn->req_buffer) == -1 )
|
// if ( cw_put_msg(conn, conn->req_buffer) == -1 )
|
||||||
// return 0;
|
// return 0;
|
||||||
//
|
//
|
||||||
// conn_send_msg(conn, conn->req_buffer);
|
// conn_send_msg(conn, conn->req_buffer);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* mbag_del_all(conn->incomming);*/
|
||||||
|
|
||||||
mbag_del_all(conn->incomming);
|
/* //mbag_del (conn->incomming,CW_ITEM_RESULT_CODE);*/
|
||||||
|
|
||||||
//mbag_del (conn->incomming,CW_ITEM_RESULT_CODE);
|
|
||||||
|
|
||||||
int rc = cw_send_request(conn, CAPWAP_MSG_JOIN_REQUEST);
|
int rc = cw_send_request(conn, CAPWAP_MSG_JOIN_REQUEST);
|
||||||
|
|
||||||
if (!cw_result_is_ok(rc)) {
|
if (!cw_result_is_ok(rc)) {
|
||||||
if (rc > 0) {
|
if (rc > 0) {
|
||||||
cw_log(LOG_ERR, "Can't Join AC at %s, AC said: %d - %s.",
|
cw_log(LOG_ERR, "Can't Join AC at %s, AC said: %d - %s.",
|
||||||
sock_addr2str(&conn->addr), rc, cw_strerror(rc));
|
sock_addr2str(&conn->addr,addrstr), rc, cw_strerror(rc));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cw_log(LOG_ERR, "Can't Join AC at %s: %d - %s.",
|
cw_log(LOG_ERR, "Can't Join AC at %s: %d - %s.",
|
||||||
sock_addr2str(&conn->addr), errno, cw_strerror(rc));
|
sock_addr2str(&conn->addr,addrstr), errno, cw_strerror(rc));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_dbg(DBG_ELEM_IN, "Joined AC at %s, Join Result: %d - %s",
|
cw_dbg(DBG_ELEM_IN, "Joined AC at %s, Join Result: %d - %s",
|
||||||
sock_addr2str(&conn->addr), rc, cw_strresult(rc));
|
sock_addr2str(&conn->addr,addrstr), rc, cw_strresult(rc));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -211,12 +217,13 @@ int run_join(struct conn *conn)
|
|||||||
int join()
|
int join()
|
||||||
{
|
{
|
||||||
struct conn *conn = get_conn();
|
struct conn *conn = get_conn();
|
||||||
|
mavliter_t ii;
|
||||||
|
char addrstr[SOCK_ADDR_BUFSIZE];
|
||||||
printf("Join\n");
|
printf("Join\n");
|
||||||
|
|
||||||
mbag_del_all(conn->incomming);
|
/*mbag_del_all(conn->incomming);*/
|
||||||
|
|
||||||
cw_aciplist_t iplist =
|
/* cw_aciplist_t iplist =
|
||||||
mbag_get_mavl(conn->local, CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
mbag_get_mavl(conn->local, CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||||
if (!iplist) {
|
if (!iplist) {
|
||||||
cw_log(LOG_ERR, "No IPs to join controller.");
|
cw_log(LOG_ERR, "No IPs to join controller.");
|
||||||
@ -227,16 +234,16 @@ int join()
|
|||||||
cw_log(LOG_ERR, "No IPs to join controller. IP list is empty.");
|
cw_log(LOG_ERR, "No IPs to join controller. IP list is empty.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*DEFINE_AVLITER(ii, iplist);*/
|
||||||
DEFINE_AVLITER(ii, iplist);
|
mavliter_foreach(&ii) {
|
||||||
avliter_foreach(&ii) {
|
|
||||||
|
|
||||||
cw_acip_t *ip = avliter_get(&ii);
|
cw_acip_t *ip = avliter_get(&ii);
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO, "Going to join CAWAP controller on %s",
|
cw_dbg(DBG_INFO, "Going to join CAWAP controller on %s",
|
||||||
sock_addr2str_p(&ip->ip));
|
sock_addr2str_p(&ip->ip,addrstr));
|
||||||
|
|
||||||
int rc = run_join_d((struct sockaddr *) &ip->ip);
|
int rc = run_join_d((struct sockaddr *) &ip->ip);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ extern long conf_echo_interval;
|
|||||||
extern long conf_max_retransmit;
|
extern long conf_max_retransmit;
|
||||||
extern long conf_retransmit_interval;
|
extern long conf_retransmit_interval;
|
||||||
|
|
||||||
//extern long conf_dbg_level;
|
|
||||||
extern int conf_mtu_discovery;
|
extern int conf_mtu_discovery;
|
||||||
extern int conf_mtu;
|
extern int conf_mtu;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker Options="" Required="yes"/>
|
<Linker Options="" Required="yes"/>
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
<ResourceCompiler Options="" Required="no"/>
|
||||||
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/wtp/wtp" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/wtp/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/wtp/wtp" CommandArguments="-dall -mcisco" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/wtp/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
||||||
<![CDATA[LD_LIBRARY_PATH=../../lib]]>
|
<![CDATA[LD_LIBRARY_PATH=../../lib]]>
|
||||||
</Environment>
|
</Environment>
|
||||||
|
Loading…
Reference in New Issue
Block a user