Fixes in RPC

This commit is contained in:
7u83 2022-08-28 11:42:11 +02:00
parent a77023165b
commit 4ef1b69f83
9 changed files with 113 additions and 13 deletions

View File

@ -595,13 +595,13 @@ struct cw_Cfg_entry *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *nnkey
const char *d; const char *d;
e = mavliter_get(&(cfi->it)); e = mavliter_get(&(cfi->it));
if (e == NULL) if (e == NULL){
return NULL; return NULL;
}
bl = strlen(cfi->base); bl = strlen(cfi->base);
kl = strlen(e->key); kl = strlen(e->key);
if (bl > kl) if (bl > kl)
return NULL; return NULL;
@ -617,7 +617,6 @@ struct cw_Cfg_entry *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *nnkey
d = strchr(e->key, '.'); d = strchr(e->key, '.');
if (d == NULL) if (d == NULL)
return NULL; return NULL;
if (d - e->key != bl) if (d - e->key != bl)
return NULL; return NULL;
@ -706,7 +705,7 @@ void cw_cfg_set_int(cw_Cfg_t * cfg, const char * key, int val)
} }
int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key) int cw_cfg_get_new_index(cw_Cfg_t * cfg, const char *key)
{ {
char ikey[CW_CFG_MAX_KEY_LEN]; char ikey[CW_CFG_MAX_KEY_LEN];
struct cw_Cfg_entry search, * result; struct cw_Cfg_entry search, * result;
@ -722,7 +721,7 @@ int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key)
return 0; return 0;
} }
d = strchr(result->key,'.'); d = strrchr(result->key,'.');
if (d==NULL){ if (d==NULL){
return 0; return 0;
} }
@ -733,6 +732,46 @@ int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key)
return atoi(d+1)+1; return atoi(d+1)+1;
} }
int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n)
{
char ikey[CW_CFG_MAX_KEY_LEN];
struct cw_Cfg_entry search, * result;
char *d;
sprintf(ikey,"%s.%d",key,n);
search.key=ikey;
result = mavl_get_first(cfg->cfg,&search);
if (result == NULL){
return -1;
}
d = strrchr(result->key,'.');
if (d==NULL){
return -1;
}
if (strncmp(result->key,ikey,d-result->key)!=0)
return -1;
return atoi(d+1);
}
int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n)
{
int r;
while(*cfgs != NULL){
r = cw_cfg_get_first_index(*cfgs,key,n);
if (r!=-1)
return r;
cfgs++;
}
return -1;
}
int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *type, const void * valguard, const uint8_t * data, int len) int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *type, const void * valguard, const uint8_t * data, int len)
{ {
cw_Val_t mdata, *mresult; cw_Val_t mdata, *mresult;

View File

@ -69,7 +69,7 @@ void cw_cfg_set_int(cw_Cfg_t * cfg, const char * key, int val);
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def); uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def);
bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def); bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def);
int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str); int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str);
int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key); int cw_cfg_get_new_index(cw_Cfg_t * cfg, const char *key);
const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def); const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def);
void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst,int dbg_level,const char *dbg_prefix); void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst,int dbg_level,const char *dbg_prefix);
void cw_cfg_destroy(cw_Cfg_t *cfg); void cw_cfg_destroy(cw_Cfg_t *cfg);
@ -86,6 +86,8 @@ void cw_cfg_fdump(FILE *f, cw_Cfg_t * cfg, const char *filter);
int cw_cfg_read_from_string(const char *str, cw_Cfg_t *cfg); int cw_cfg_read_from_string(const char *str, cw_Cfg_t *cfg);
void cw_cfg_del(cw_Cfg_t * cfg, const char *key); void cw_cfg_del(cw_Cfg_t * cfg, const char *key);
int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n);
int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n);

View File

@ -47,6 +47,17 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
// cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); // cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
// cw_cfg_dump(params->cfg); // cw_cfg_dump(params->cfg);
// cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDDUMP"); // cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDDUMP");
//
//
if (!cw_cfg_base_exists(params->cfg_list[0],handler->key)){
cw_dbg(DBG_MSG_COMPOSE," Add Elem: %d %d %d %s %s - (skip)",
params->elemdata->proto,
params->elemdata->vendor,
params->elemdata->id,
handler->name, handler->key);
return 0;
}
start = params->msgset->header_len(handler); start = params->msgset->header_len(handler);
len = ((const cw_Type_t*)(handler->type))-> len = ((const cw_Type_t*)(handler->type))->
@ -118,6 +129,41 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
int radios; int radios;
len =0; len =0;
for (i=0; (i=cw_cfg_get_first_index_l(params->cfg_list,"radio",i))!=-1; i++){
sprintf(key,"radio.%d/%s",i,handler->key);
if (!params->elemdata->mand){
if (!cw_cfg_base_exists(params->cfg_list[0],key)){
cw_dbg(DBG_MSG_COMPOSE," Add Elem: %d %d %d %s %s - (skip)",
params->elemdata->proto,
params->elemdata->vendor,
params->elemdata->id,
handler->name, key);
continue;
}
}
type = (struct cw_Type*)handler->type;
start = params->msgset->header_len(handler)+len;
l = type->write(params->cfg_list, key,dst+start+1,handler->param);
if (l==-1)
continue;
l += cw_put_byte(dst+start,i);
l = params->msgset->write_header(handler,dst+len,l);
len+=l;
}
return len;
radios = cw_cfg_get_byte_l(params->cfg_list,"capwap/wtp-descriptor/max-radios",0); radios = cw_cfg_get_byte_l(params->cfg_list,"capwap/wtp-descriptor/max-radios",0);
for(i=0;i<radios;i++){ for(i=0;i<radios;i++){

View File

@ -26,13 +26,15 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
e = ie->type; e = ie->type;
for(i=0; e[i].name!=NULL; i++) { for(i=0; e[i].name!=NULL; i++) {
int b; int b;
sprintf(key,"%s/%s",handler->key,e[i].name); sprintf(key,"%s/%s",handler->key,e[i].name);
cw_dbg(DBG_X,"Her is the Key: %s %s\n",key,e[i].name); cw_dbg(DBG_X,"Her is the Key: %s %s\n",key,e[i].name);
b = cw_cfg_base_exists_l(params->cfg_list,handler->key); b = cw_cfg_base_exists(params->cfg_list[0],handler->key);
if (!b){ if (!b){
//stop(); //stop();
continue; continue;

View File

@ -139,7 +139,7 @@ int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
//current[0]=0; //current[0]=0;
stop(); //stop();
return 0; return 0;
// return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack); // return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack);

View File

@ -38,7 +38,7 @@ int cw_encode_elements(struct cw_ElemHandlerParams *params, mlist_t elements_lis
} }
continue; continue;
} }
/*
if (!data->mand){ if (!data->mand){
if (!cw_cfg_base_exists(params->cfg_list[0],handler->key)){ if (!cw_cfg_base_exists(params->cfg_list[0],handler->key)){
cw_dbg(DBG_MSG_COMPOSE," Add Elem: %d %d %d %s %s - (skip)", cw_dbg(DBG_MSG_COMPOSE," Add Elem: %d %d %d %s %s - (skip)",
@ -47,7 +47,7 @@ int cw_encode_elements(struct cw_ElemHandlerParams *params, mlist_t elements_lis
continue; continue;
} }
} }
*/
l = handler->put(handler,params,dst+len); l = handler->put(handler,params,dst+len);
cw_dbg(DBG_MSG_COMPOSE," Add Elem: %d %d %d %s - (%d bytes)", cw_dbg(DBG_MSG_COMPOSE," Add Elem: %d %d %d %s - (%d bytes)",

View File

@ -34,7 +34,7 @@ int capwap_in_capwap_control_ip_address(struct cw_ElemHandler *eh,
int idx; int idx;
sprintf(key,"%s/address",eh->key); sprintf(key,"%s/address",eh->key);
idx = cw_cfg_get_next_index(params->cfg,key); idx = cw_cfg_get_new_index(params->cfg,key);
/* printf("SKEY is %s , idx: %d\n",key,idx);*/ /* printf("SKEY is %s , idx: %d\n",key,idx);*/

View File

@ -267,7 +267,7 @@ int cisco_in_ap_regulatory_domain(struct cw_ElemHandler *eh,
int idx; int idx;
void * type; void * type;
idx = cw_cfg_get_next_index(params->cfg,eh->key); idx = cw_cfg_get_new_index(params->cfg,eh->key);
sprintf(key,"%s.%d",eh->key,idx); sprintf(key,"%s.%d",eh->key,idx);
@ -2520,7 +2520,7 @@ static struct cw_ElemDef configuration_update_request_elements[] ={
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_MIN_IOS_VERSION, 0, 0}, {0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_MIN_IOS_VERSION, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_BACKUP_SOFTWARE_VERSION, 0, 0}, {0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_BACKUP_SOFTWARE_VERSION, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_REGULATORY_DOMAIN, 0, 0}, /* {0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_REGULATORY_DOMAIN, 0, 0},*/
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_MODEL, 0, 0}, {0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_MODEL, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_RESET_BUTTON_STATE, 0, 0}, {0, CW_VENDOR_ID_CISCO, CISCO_ELEM_RESET_BUTTON_STATE, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_WTP_RADIO_CONFIGURATION, 0, 0}, {0, CW_VENDOR_ID_CISCO, CISCO_ELEM_WTP_RADIO_CONFIGURATION, 0, 0},

View File

@ -163,6 +163,17 @@ int main (int argc, char **argv)
cw_cfg_destroy(cfg); cw_cfg_destroy(cfg);
/* {
struct cw_Cfg_iter cfi;
struct cw_Cfg_entry *e;
int i;
for (i=0; (i=cw_cfg_get_first_index(global_cfg,"radio",i))!=-1; i++){
printf("Inedx: %d\n", i);
}
goto errX;
}
*/
/* conn->mod=mod;*/ /* conn->mod=mod;*/
conn->detected = 1; conn->detected = 1;