Empty yang type. Relaxed yang types for unions, eg two strings with different length.

This commit is contained in:
Olof hagsand 2017-01-09 21:26:50 +01:00
parent bc2b606167
commit 319e7707d8
14 changed files with 64 additions and 113 deletions

View file

@ -63,7 +63,7 @@ enum clicon_msg_type{
2. uint32: length of value string
3. string: name of database to change (eg "running")
4. string: key
5. string: value
5. string: value (can be NULL)
*/
CLICON_MSG_XMLPUT, /* Send database entries as XML to backend daemon
1. uint32: operation: LV_SET/LV_DELETE

View file

@ -200,7 +200,7 @@ clicon_rpc_change(clicon_handle h,
op,
key,
val,
strlen(val)+1,
val?strlen(val)+1:0,
__FUNCTION__)) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, NULL, NULL, NULL, __FUNCTION__) < 0)

View file

@ -199,7 +199,9 @@ clicon_msg_change_encode(char *db,
op, str_len, db, key);
p = 0;
len = sizeof(*msg) + 2*sizeof(uint32_t) + strlen(db) + 1 +
strlen(key) + 1 + str_len;
strlen(key) + str_len;
if (str_len)
len++; /* if str not null add end of string */
if ((msg = (struct clicon_msg *)chunk(len, label)) == NULL){
clicon_err(OE_PROTO, errno, "%s: chunk", __FUNCTION__);
return NULL;
@ -221,8 +223,10 @@ clicon_msg_change_encode(char *db,
p += strlen(db)+1;
strncpy(msg->op_body+p, key, len-p-hdrlen);
p += strlen(key)+1;
memcpy(msg->op_body+p, str, str_len);
p += str_len;
if (str_len){
memcpy(msg->op_body+p, str, str_len);
p += str_len;
}
return msg;
}

View file

@ -221,6 +221,7 @@ yang2xmlkeyfmt(yang_stmt *ys,
* @param[in] cvv cligen variable vector, one for every wildchar in xkfmt
* @param[out] xk XML key, eg /aaa/17. Free after use
* @note first and last elements of cvv are not used,..
* @see cli_dbxml where this function is called
*/
int
xmlkeyfmt2key(char *xkfmt,
@ -247,7 +248,7 @@ xmlkeyfmt2key(char *xkfmt,
j,
cvec_len(cvv),
cv_string_get(cvec_i(cvv, 0)));
// goto done;
goto done;
}
#endif
if ((cb = cbuf_new()) == NULL){
@ -1689,7 +1690,7 @@ xmldb_put_xkey_local(clicon_handle h,
case OP_MERGE:
case OP_REPLACE:
if (y->ys_keyword == Y_LEAF || y->ys_keyword == Y_LEAF_LIST){
if (db_set(filename, xk, val, strlen(val)+1) < 0)
if (db_set(filename, xk, val, val?strlen(val)+1:0) < 0)
goto done;
}
else

View file

@ -1,4 +1,7 @@
/*
* Yang 1.0 parser according to RFC6020.
* It is hopefully useful but not complete
* RFC7950 defines Yang version 1.1
*
***** BEGIN LICENSE BLOCK *****

View file

@ -1,4 +1,7 @@
/*
* Yang 1.0 parser according to RFC6020.
* It is hopefully useful but not complete
* RFC7950 defines Yang version 1.1
*
***** BEGIN LICENSE BLOCK *****

View file

@ -1,4 +1,7 @@
/*
* Yang 1.0 parser according to RFC6020.
* It is hopefully useful but not complete
* RFC7950 defines Yang version 1.1
*
***** BEGIN LICENSE BLOCK *****

View file

@ -104,7 +104,7 @@ static const struct map_str2int ytmap[] = {
{"uint16", CGV_UINT16},
{"uint32", CGV_UINT32},
{"uint64", CGV_UINT64},
{"union", CGV_VOID}, /* Is replaced by actual type */
{"union", CGV_REST}, /* Is replaced by actual type */
{NULL, -1}
};
@ -912,6 +912,7 @@ yang_type_get(yang_stmt *ys,
clicon_err(OE_DB, 0, "%s: mandatory type object is not found", __FUNCTION__);
goto done;
}
/* XXX: here we seem to have some problems if type is union */
type = ytype_id(ytype);
if (origtype)
*origtype = type;