Remove propriatary internal framing functions
Changed send/rcv API using NETCONF 10 and 11 suffixes
This commit is contained in:
parent
5fa82dcea7
commit
520f8a9a42
6 changed files with 53 additions and 64 deletions
|
|
@ -14,6 +14,7 @@ Expected: March 2024
|
||||||
### Minor features
|
### Minor features
|
||||||
|
|
||||||
* Changed framing between backend and frontend to RFC6242 "chunked-encoding"
|
* Changed framing between backend and frontend to RFC6242 "chunked-encoding"
|
||||||
|
* Previous a propriatary framing method was used
|
||||||
* Added micro-second resolution to logs via stderr/stdout
|
* Added micro-second resolution to logs via stderr/stdout
|
||||||
* New command-line debug mechanism
|
* New command-line debug mechanism
|
||||||
* Separation between subject-area and details
|
* Separation between subject-area and details
|
||||||
|
|
@ -56,6 +57,13 @@ Users may have to change how they access the system
|
||||||
### C/CLI-API changes on existing features
|
### C/CLI-API changes on existing features
|
||||||
Developers may need to change their code
|
Developers may need to change their code
|
||||||
|
|
||||||
|
* Modified msg functions for clearer NETCONF 1.0 vs 1.1 API:
|
||||||
|
* `clicon_rpc1` --> `clixon_rpc10`
|
||||||
|
* `clicon_msg_send1` --> `clixon_msg_send10`
|
||||||
|
* `clicon_msg_rcv` and `clicon_msg_decode` --> `clixon_msg_rcv11`
|
||||||
|
* Rewrite by calling `clixon_msg_rcv11` and explicit xml parsing
|
||||||
|
* `clicon_msg_rcv1` --> `clixon_msg_rcv10`
|
||||||
|
|
||||||
* Added `yspec` parameter to `api_path_fmt2api_path()`:
|
* Added `yspec` parameter to `api_path_fmt2api_path()`:
|
||||||
* `api_path_fmt2api_path(af, c, a, c)` --> `api_path_fmt2api_path(af, c, yspec, a, c)`
|
* `api_path_fmt2api_path(af, c, a, c)` --> `api_path_fmt2api_path(af, c, yspec, a, c)`
|
||||||
* Added flags parameter to default functions:
|
* Added flags parameter to default functions:
|
||||||
|
|
|
||||||
|
|
@ -1560,7 +1560,7 @@ from_client_hello(clixon_handle h,
|
||||||
static int
|
static int
|
||||||
from_client_msg(clixon_handle h,
|
from_client_msg(clixon_handle h,
|
||||||
struct client_entry *ce,
|
struct client_entry *ce,
|
||||||
struct clicon_msg *msg)
|
char *msg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
|
|
@ -1576,7 +1576,7 @@ from_client_msg(clixon_handle h,
|
||||||
yang_stmt *ymod;
|
yang_stmt *ymod;
|
||||||
cxobj *xnacm = NULL;
|
cxobj *xnacm = NULL;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
uint32_t op_id; /* session number from internal NETCONF protocol */
|
uint32_t op_id = 0; /* XXX session number from internal NETCONF protocol */
|
||||||
enum nacm_credentials_t creds;
|
enum nacm_credentials_t creds;
|
||||||
char *rpcname;
|
char *rpcname;
|
||||||
char *rpcprefix;
|
char *rpcprefix;
|
||||||
|
|
@ -1596,10 +1596,10 @@ from_client_msg(clixon_handle h,
|
||||||
/* Decode msg from client -> xml top (ct) and session id
|
/* Decode msg from client -> xml top (ct) and session id
|
||||||
* Bind is a part of the decode function
|
* Bind is a part of the decode function
|
||||||
*/
|
*/
|
||||||
if ((ret = clicon_msg_decode(msg, yspec, &op_id, &xt, &xret)) < 0){
|
if ((ret = clixon_xml_parse_string(msg, YB_RPC, yspec, &xt, &xret)) < 0){
|
||||||
if (netconf_malformed_message(cbret, "XML parse error") < 0)
|
if (netconf_malformed_message(cbret, "XML parse error") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto reply;
|
goto done;
|
||||||
}
|
}
|
||||||
if (ret == 0){
|
if (ret == 0){
|
||||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
||||||
|
|
@ -1847,11 +1847,11 @@ from_client(int s,
|
||||||
void* arg)
|
void* arg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
struct clicon_msg *msg = NULL;
|
|
||||||
struct client_entry *ce = (struct client_entry *)arg;
|
struct client_entry *ce = (struct client_entry *)arg;
|
||||||
clixon_handle h = ce->ce_handle;
|
clixon_handle h = ce->ce_handle;
|
||||||
int eof = 0;
|
int eof = 0;
|
||||||
cbuf *cbce = NULL;
|
cbuf *cbce = NULL;
|
||||||
|
cbuf *cb = NULL;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
|
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
|
||||||
if (s != ce->ce_s){
|
if (s != ce->ce_s){
|
||||||
|
|
@ -1860,22 +1860,21 @@ from_client(int s,
|
||||||
}
|
}
|
||||||
if (ce_client_descr(ce, &cbce) < 0)
|
if (ce_client_descr(ce, &cbce) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (clicon_msg_rcv(ce->ce_s, cbuf_get(cbce), 0, &msg, &eof) < 0)
|
if (clixon_msg_rcv11(s, NULL, &cb, &eof) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (eof){
|
if (eof){
|
||||||
backend_client_rm(h, ce);
|
backend_client_rm(h, ce);
|
||||||
netconf_monitoring_counter_inc(h, "dropped-sessions");
|
netconf_monitoring_counter_inc(h, "dropped-sessions");
|
||||||
}
|
}
|
||||||
else
|
else if (from_client_msg(h, ce, cbuf_get(cb)) < 0)
|
||||||
if (from_client_msg(h, ce, msg) < 0)
|
goto done;
|
||||||
goto done;
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||||
|
if (cb)
|
||||||
|
cbuf_free(cb);
|
||||||
if (cbce)
|
if (cbce)
|
||||||
cbuf_free(cbce);
|
cbuf_free(cbce);
|
||||||
if (msg)
|
|
||||||
free(msg);
|
|
||||||
return retval; /* -1 here terminates backend */
|
return retval; /* -1 here terminates backend */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1403,14 +1403,12 @@ cli_notification_cb(int s,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
struct clicon_msg *reply = NULL;
|
int eof = 0;
|
||||||
int eof;
|
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
enum format_enum format = (enum format_enum)(uintptr_t)arg;
|
enum format_enum format = (enum format_enum)(uintptr_t)arg;
|
||||||
int ret;
|
cbuf *cb = NULL;
|
||||||
|
|
||||||
/* get msg (this is the reason this function is called) */
|
if (clixon_msg_rcv11(s, NULL, &cb, &eof) < 0)
|
||||||
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (eof){
|
if (eof){
|
||||||
clixon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close");
|
clixon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close");
|
||||||
|
|
@ -1419,13 +1417,8 @@ cli_notification_cb(int s,
|
||||||
clixon_event_unreg_fd(s, cli_notification_cb);
|
clixon_event_unreg_fd(s, cli_notification_cb);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* XXX pass yang_spec and use xerr*/
|
if (clixon_xml_parse_string(cbuf_get(cb), YB_NONE, NULL, &xt, NULL) < 0)
|
||||||
if ((ret = clicon_msg_decode(reply, NULL, NULL, &xt, NULL)) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0){ /* will not happen since no yspec ^*/
|
|
||||||
clixon_err(OE_NETCONF, EFAULT, "Notification malformed");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
switch (format){
|
switch (format){
|
||||||
case FORMAT_JSON:
|
case FORMAT_JSON:
|
||||||
if (clixon_json2file(stdout, xt, 1, cligen_output, 1, 1) < 0)
|
if (clixon_json2file(stdout, xt, 1, cligen_output, 1, 1) < 0)
|
||||||
|
|
@ -1443,10 +1436,10 @@ cli_notification_cb(int s,
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (cb)
|
||||||
|
cbuf_free(cb);
|
||||||
if (xt)
|
if (xt)
|
||||||
xml_free(xt);
|
xml_free(xt);
|
||||||
if (reply)
|
|
||||||
free(reply);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -447,21 +447,21 @@ static int
|
||||||
netconf_notification_cb(int s,
|
netconf_notification_cb(int s,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
struct clicon_msg *reply = NULL;
|
int eof;
|
||||||
int eof;
|
int retval = -1;
|
||||||
int retval = -1;
|
cbuf *cb = NULL;
|
||||||
cbuf *cb = NULL;
|
cxobj *xn = NULL; /* event xml */
|
||||||
cxobj *xn = NULL; /* event xml */
|
cxobj *xt = NULL; /* top xml */
|
||||||
cxobj *xt = NULL; /* top xml */
|
clixon_handle h = (clixon_handle)arg;
|
||||||
clixon_handle h = (clixon_handle)arg;
|
yang_stmt *yspec = NULL;
|
||||||
yang_stmt *yspec = NULL;
|
cvec *nsc = NULL;
|
||||||
cvec *nsc = NULL;
|
int ret;
|
||||||
int ret;
|
cxobj *xerr = NULL;
|
||||||
cxobj *xerr = NULL;
|
cbuf *cbmsg = NULL;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_NETCONF, "");
|
clixon_debug(CLIXON_DBG_NETCONF, "");
|
||||||
/* get msg (this is the reason this function is called) */
|
yspec = clicon_dbspec_yang(h);
|
||||||
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
|
if (clixon_msg_rcv11(s, NULL, &cbmsg, &eof) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* handle close from remote end: this will exit the client */
|
/* handle close from remote end: this will exit the client */
|
||||||
if (eof){
|
if (eof){
|
||||||
|
|
@ -471,8 +471,7 @@ netconf_notification_cb(int s,
|
||||||
clixon_event_unreg_fd(s, netconf_notification_cb);
|
clixon_event_unreg_fd(s, netconf_notification_cb);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
yspec = clicon_dbspec_yang(h);
|
if ((ret = clixon_xml_parse_string(cbuf_get(cbmsg), YB_RPC, yspec, &xt, &xerr)) < 0)
|
||||||
if ((ret = clicon_msg_decode(reply, yspec, NULL, &xt, &xerr)) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0){ /* XXX use xerr */
|
if (ret == 0){ /* XXX use xerr */
|
||||||
clixon_err(OE_NETCONF, EFAULT, "Notification malformed");
|
clixon_err(OE_NETCONF, EFAULT, "Notification malformed");
|
||||||
|
|
@ -513,8 +512,8 @@ netconf_notification_cb(int s,
|
||||||
xml_free(xt);
|
xml_free(xt);
|
||||||
if (xerr != NULL)
|
if (xerr != NULL)
|
||||||
xml_free(xerr);
|
xml_free(xerr);
|
||||||
if (reply)
|
if (cbmsg)
|
||||||
free(reply);
|
free(cbmsg);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,22 +205,19 @@ static int
|
||||||
restconf_stream_cb(int s,
|
restconf_stream_cb(int s,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FCGX_Request *r = (FCGX_Request *)arg;
|
FCGX_Request *r = (FCGX_Request *)arg;
|
||||||
int eof;
|
int eof;
|
||||||
struct clicon_msg *reply = NULL;
|
cxobj *xtop = NULL; /* top xml */
|
||||||
cxobj *xtop = NULL; /* top xml */
|
cxobj *xn; /* notification xml */
|
||||||
cxobj *xn; /* notification xml */
|
cbuf *cb = NULL;
|
||||||
cbuf *cb = NULL;
|
int pretty = 0; /* XXX should be via arg */
|
||||||
int pretty = 0; /* XXX should be via arg */
|
cbuf *cbmsg = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_STREAM, "");
|
clixon_debug(CLIXON_DBG_STREAM, "");
|
||||||
/* get msg (this is the reason this function is called) */
|
if (clixon_msg_rcv11(s, NULL, &cbmsg, &eof) < 0)
|
||||||
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0){
|
|
||||||
clixon_debug(CLIXON_DBG_STREAM, "msg_rcv error");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
clixon_debug(CLIXON_DBG_STREAM, "msg: %s", reply?reply->op_body:"null");
|
clixon_debug(CLIXON_DBG_STREAM, "msg: %s", reply?reply->op_body:"null");
|
||||||
/* handle close from remote end: this will exit the client */
|
/* handle close from remote end: this will exit the client */
|
||||||
if (eof){
|
if (eof){
|
||||||
|
|
@ -233,7 +230,7 @@ restconf_stream_cb(int s,
|
||||||
clixon_exit_set(1);
|
clixon_exit_set(1);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((ret = clicon_msg_decode(reply, NULL, NULL, &xtop, NULL)) < 0) /* XXX pass yang_spec */
|
if ((ret = clixon_xml_parse_string(cbuf_get(cbmsg), YB_NONE, NULL, &xt, NULL)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0){
|
if (ret == 0){
|
||||||
clixon_err(OE_XML, EFAULT, "Invalid notification");
|
clixon_err(OE_XML, EFAULT, "Invalid notification");
|
||||||
|
|
@ -271,6 +268,8 @@ restconf_stream_cb(int s,
|
||||||
xml_free(xtop);
|
xml_free(xtop);
|
||||||
if (reply)
|
if (reply)
|
||||||
free(reply);
|
free(reply);
|
||||||
|
if (cbmsg)
|
||||||
|
cbuf_free(cbmsg);
|
||||||
if (cb)
|
if (cb)
|
||||||
cbuf_free(cb);
|
cbuf_free(cb);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -206,12 +206,3 @@
|
||||||
*/
|
*/
|
||||||
#define COMPAT_6_5
|
#define COMPAT_6_5
|
||||||
|
|
||||||
/*! Use 1.1 RFC 6242 chunked encoding framing for internal use
|
|
||||||
*
|
|
||||||
* Replaces internal IPC
|
|
||||||
* clixon_msg_send2() an clixon_msg_rcv2() and some adjustment code in clixon_proto.c
|
|
||||||
* Following things NYI:
|
|
||||||
* - Emulates old clicon_msg API
|
|
||||||
*/
|
|
||||||
#define NETCONF_INPUT_UNIFIED_INTERNAL
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue