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
|
||||
|
||||
* 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
|
||||
* New command-line debug mechanism
|
||||
* 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
|
||||
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()`:
|
||||
* `api_path_fmt2api_path(af, c, a, c)` --> `api_path_fmt2api_path(af, c, yspec, a, c)`
|
||||
* Added flags parameter to default functions:
|
||||
|
|
|
|||
|
|
@ -1560,7 +1560,7 @@ from_client_hello(clixon_handle h,
|
|||
static int
|
||||
from_client_msg(clixon_handle h,
|
||||
struct client_entry *ce,
|
||||
struct clicon_msg *msg)
|
||||
char *msg)
|
||||
{
|
||||
int retval = -1;
|
||||
cxobj *xt = NULL;
|
||||
|
|
@ -1576,7 +1576,7 @@ from_client_msg(clixon_handle h,
|
|||
yang_stmt *ymod;
|
||||
cxobj *xnacm = 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;
|
||||
char *rpcname;
|
||||
char *rpcprefix;
|
||||
|
|
@ -1596,10 +1596,10 @@ from_client_msg(clixon_handle h,
|
|||
/* Decode msg from client -> xml top (ct) and session id
|
||||
* 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)
|
||||
goto done;
|
||||
goto reply;
|
||||
goto done;
|
||||
}
|
||||
if (ret == 0){
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
||||
|
|
@ -1847,11 +1847,11 @@ from_client(int s,
|
|||
void* arg)
|
||||
{
|
||||
int retval = -1;
|
||||
struct clicon_msg *msg = NULL;
|
||||
struct client_entry *ce = (struct client_entry *)arg;
|
||||
clixon_handle h = ce->ce_handle;
|
||||
int eof = 0;
|
||||
cbuf *cbce = NULL;
|
||||
cbuf *cb = NULL;
|
||||
|
||||
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
|
||||
if (s != ce->ce_s){
|
||||
|
|
@ -1860,22 +1860,21 @@ from_client(int s,
|
|||
}
|
||||
if (ce_client_descr(ce, &cbce) < 0)
|
||||
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;
|
||||
if (eof){
|
||||
backend_client_rm(h, ce);
|
||||
netconf_monitoring_counter_inc(h, "dropped-sessions");
|
||||
}
|
||||
else
|
||||
if (from_client_msg(h, ce, msg) < 0)
|
||||
else if (from_client_msg(h, ce, cbuf_get(cb)) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
if (cbce)
|
||||
cbuf_free(cbce);
|
||||
if (msg)
|
||||
free(msg);
|
||||
return retval; /* -1 here terminates backend */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1403,14 +1403,12 @@ cli_notification_cb(int s,
|
|||
void *arg)
|
||||
{
|
||||
int retval = -1;
|
||||
struct clicon_msg *reply = NULL;
|
||||
int eof;
|
||||
int eof = 0;
|
||||
cxobj *xt = NULL;
|
||||
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 (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
|
||||
if (clixon_msg_rcv11(s, NULL, &cb, &eof) < 0)
|
||||
goto done;
|
||||
if (eof){
|
||||
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);
|
||||
goto done;
|
||||
}
|
||||
/* XXX pass yang_spec and use xerr*/
|
||||
if ((ret = clicon_msg_decode(reply, NULL, NULL, &xt, NULL)) < 0)
|
||||
if (clixon_xml_parse_string(cbuf_get(cb), YB_NONE, NULL, &xt, NULL) < 0)
|
||||
goto done;
|
||||
if (ret == 0){ /* will not happen since no yspec ^*/
|
||||
clixon_err(OE_NETCONF, EFAULT, "Notification malformed");
|
||||
goto done;
|
||||
}
|
||||
switch (format){
|
||||
case FORMAT_JSON:
|
||||
if (clixon_json2file(stdout, xt, 1, cligen_output, 1, 1) < 0)
|
||||
|
|
@ -1443,10 +1436,10 @@ cli_notification_cb(int s,
|
|||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
if (xt)
|
||||
xml_free(xt);
|
||||
if (reply)
|
||||
free(reply);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -447,7 +447,6 @@ static int
|
|||
netconf_notification_cb(int s,
|
||||
void *arg)
|
||||
{
|
||||
struct clicon_msg *reply = NULL;
|
||||
int eof;
|
||||
int retval = -1;
|
||||
cbuf *cb = NULL;
|
||||
|
|
@ -458,10 +457,11 @@ netconf_notification_cb(int s,
|
|||
cvec *nsc = NULL;
|
||||
int ret;
|
||||
cxobj *xerr = NULL;
|
||||
cbuf *cbmsg = NULL;
|
||||
|
||||
clixon_debug(CLIXON_DBG_NETCONF, "");
|
||||
/* get msg (this is the reason this function is called) */
|
||||
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
if (clixon_msg_rcv11(s, NULL, &cbmsg, &eof) < 0)
|
||||
goto done;
|
||||
/* handle close from remote end: this will exit the client */
|
||||
if (eof){
|
||||
|
|
@ -471,8 +471,7 @@ netconf_notification_cb(int s,
|
|||
clixon_event_unreg_fd(s, netconf_notification_cb);
|
||||
goto done;
|
||||
}
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
if ((ret = clicon_msg_decode(reply, yspec, NULL, &xt, &xerr)) < 0)
|
||||
if ((ret = clixon_xml_parse_string(cbuf_get(cbmsg), YB_RPC, yspec, &xt, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){ /* XXX use xerr */
|
||||
clixon_err(OE_NETCONF, EFAULT, "Notification malformed");
|
||||
|
|
@ -513,8 +512,8 @@ netconf_notification_cb(int s,
|
|||
xml_free(xt);
|
||||
if (xerr != NULL)
|
||||
xml_free(xerr);
|
||||
if (reply)
|
||||
free(reply);
|
||||
if (cbmsg)
|
||||
free(cbmsg);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,19 +208,16 @@ restconf_stream_cb(int s,
|
|||
int retval = -1;
|
||||
FCGX_Request *r = (FCGX_Request *)arg;
|
||||
int eof;
|
||||
struct clicon_msg *reply = NULL;
|
||||
cxobj *xtop = NULL; /* top xml */
|
||||
cxobj *xn; /* notification xml */
|
||||
cbuf *cb = NULL;
|
||||
int pretty = 0; /* XXX should be via arg */
|
||||
cbuf *cbmsg = NULL;
|
||||
int ret;
|
||||
|
||||
clixon_debug(CLIXON_DBG_STREAM, "");
|
||||
/* get msg (this is the reason this function is called) */
|
||||
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0){
|
||||
clixon_debug(CLIXON_DBG_STREAM, "msg_rcv error");
|
||||
if (clixon_msg_rcv11(s, NULL, &cbmsg, &eof) < 0)
|
||||
goto done;
|
||||
}
|
||||
clixon_debug(CLIXON_DBG_STREAM, "msg: %s", reply?reply->op_body:"null");
|
||||
/* handle close from remote end: this will exit the client */
|
||||
if (eof){
|
||||
|
|
@ -233,7 +230,7 @@ restconf_stream_cb(int s,
|
|||
clixon_exit_set(1);
|
||||
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;
|
||||
if (ret == 0){
|
||||
clixon_err(OE_XML, EFAULT, "Invalid notification");
|
||||
|
|
@ -271,6 +268,8 @@ restconf_stream_cb(int s,
|
|||
xml_free(xtop);
|
||||
if (reply)
|
||||
free(reply);
|
||||
if (cbmsg)
|
||||
cbuf_free(cbmsg);
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
return retval;
|
||||
|
|
|
|||
|
|
@ -206,12 +206,3 @@
|
|||
*/
|
||||
#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