FossilOrigin-Name: 85bcc56e6aca1fbb8c437e74bc6bdc16d378a510e8e48a7fb58b996e919e138fbsdmakefiles
parent
195c76dc88
commit
3ae4f89bea
@ -0,0 +1,35 @@ |
||||
#include "ktv.h" |
||||
#include "dbg.h" |
||||
#include "log.h" |
||||
|
||||
int cw_ktv_write_struct(mavl_t ktv, const cw_KTVStruct_t * stru, const char *pkey,
|
||||
uint8_t * dst) |
||||
{ |
||||
char key[CW_KTV_MAX_KEY_LEN]; |
||||
int pos, i; |
||||
cw_KTV_t * result; |
||||
|
||||
pos=0; i=0; |
||||
for(i=0; stru[i].type != NULL;i++){ |
||||
|
||||
if (stru[i].position!=-1){ |
||||
pos=stru[i].position; |
||||
} |
||||
memset(dst+pos,0,stru[i].len); |
||||
|
||||
sprintf(key,"%s/%s",pkey,stru[i].key); |
||||
result = cw_ktv_get(ktv,key,stru[i].type); |
||||
|
||||
if (result == NULL){ |
||||
cw_log(LOG_ERR,"Can't put %s, no value found",key); |
||||
continue; |
||||
} |
||||
|
||||
result->type->put(result,dst+pos); |
||||
|
||||
pos+=stru[i].len; |
||||
|
||||
} |
||||
|
||||
return pos; |
||||
} |
@ -0,0 +1,30 @@ |
||||
#include "capwap.h" |
||||
#include "msgset.h" |
||||
#include "ktv.h" |
||||
#include "log.h" |
||||
#include "cw.h" |
||||
|
||||
int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params |
||||
, uint8_t * dst) |
||||
{ |
||||
int start; |
||||
int len,l; |
||||
|
||||
start = handler->vendor ? 10 : 4; |
||||
|
||||
if (!handler->type){ |
||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name); |
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT; |
||||
} |
||||
|
||||
len = cw_ktv_write_struct(params->conn->local_cfg,handler->type,handler->key,dst+start); |
||||
|
||||
if (handler->vendor) |
||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len); |
||||
|
||||
l = len + cw_put_elem_hdr(dst, handler->id, len); |
||||
|
||||
return l; |
||||
|
||||
|
||||
} |
@ -1,74 +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/>.
|
||||
|
||||
*/ |
||||
|
||||
|
||||
#include <stdio.h> |
||||
|
||||
#include "cw_util.h" |
||||
#include "log.h" |
||||
#include "capwap.h" |
||||
|
||||
/*
|
||||
void cw_mand_elem_found(int *l,int type) |
||||
{ |
||||
if (!cw_dbg_is_level(DBG_CW_RFC)) |
||||
return; |
||||
|
||||
int i; |
||||
for (i=0; l[i]!=-1; i++){ |
||||
if(l[i]==type){ |
||||
l[i]=0; |
||||
return; |
||||
} |
||||
|
||||
} |
||||
} |
||||
*/ |
||||
|
||||
/*
|
||||
void cw_get_missing_mand_elems(char *dst, int *l) |
||||
{ |
||||
if (!cw_dbg_is_level(DBG_CW_RFC)) |
||||
return; |
||||
|
||||
char *s = dst; |
||||
int i; |
||||
const char * k = ""; |
||||
for (i=0; l[i]!=-1; i++){ |
||||
if(l[i]){ |
||||
s += sprintf(s,"%s[%s]",k,cw_strelem(l[i])); |
||||
k=","; |
||||
} |
||||
|
||||
} |
||||
} |
||||
*/ |
||||
|
||||
/*
|
||||
int cw_is_missing_mand_elems(int *l) |
||||
{ |
||||
int i; |
||||
for (i=0; l[i]!=-1; i++){ |
||||
if(l[i]){ |
||||
return 1; |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
*/ |
@ -1,17 +1,60 @@ |
||||
#include <string.h> |
||||
#include <stdio.h> |
||||
|
||||
#include "mlist.h" |
||||
|
||||
struct mlistelem * mlist_replace(mlist_t list, void *data) |
||||
struct mlistelem * mlist_delete(mlist_t list, void *data) |
||||
{ |
||||
struct mlistelem *e; |
||||
|
||||
e = mlist_get(list,data); |
||||
mlist_foreach(e,list){ |
||||
void *tdata = mlistelem_dataptr(e); |
||||
if (list->cmp(tdata,data)==0){ |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (e == NULL) |
||||
return NULL; |
||||
|
||||
if (e->prev==NULL && e->next==NULL){ |
||||
if (list->del) |
||||
list->del(e); |
||||
free(e); |
||||
list->count=0; |
||||
list->first=NULL; |
||||
list->last=NULL; |
||||
return NULL; |
||||
} |
||||
|
||||
if (e==list->first){ |
||||
list->first=e->next; |
||||
e->next->prev=NULL; |
||||
if (list->del) |
||||
list->del(e); |
||||
list->count--; |
||||
free(e); |
||||
return NULL; |
||||
|
||||
} |
||||
|
||||
if (e==list->last){ |
||||
list->last=e->prev; |
||||
e->prev->next=NULL; |
||||
if (list->del) |
||||
list->del(e); |
||||
list->count--; |
||||
free(e); |
||||
return NULL; |
||||
|
||||
} |
||||
|
||||
return e; |
||||
e->next->prev=e->prev; |
||||
e->prev->next=e->next; |
||||
if (list->del) |
||||
list->del(e); |
||||
list->count--; |
||||
free(e); |
||||
return NULL; |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue