Swapped to use chunked framing in internal protocol
This commit is contained in:
parent
e4834b9896
commit
5fa82dcea7
5 changed files with 414 additions and 742 deletions
|
|
@ -188,7 +188,7 @@ clixon_client_lock(clixon_handle h,
|
|||
NETCONF_BASE_NAMESPACE,
|
||||
NETCONF_MESSAGE_ID_ATTR,
|
||||
lock?"":"un", db, lock?"":"un");
|
||||
if (clicon_rpc1(sock, descr, msg, msgret, &eof) < 0)
|
||||
if (clixon_rpc10(sock, descr, msg, msgret, &eof) < 0)
|
||||
goto done;
|
||||
if (eof){
|
||||
close(sock);
|
||||
|
|
@ -242,7 +242,7 @@ clixon_client_hello(int sock,
|
|||
cprintf(msg, "</capabilities>");
|
||||
cprintf(msg, "</hello>");
|
||||
cprintf(msg, "]]>]]>");
|
||||
if (clicon_msg_send1(sock, descr, msg) < 0)
|
||||
if (clixon_msg_send10(sock, descr, msg) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
@ -529,9 +529,9 @@ clixon_client_get_xdata(clixon_handle h,
|
|||
cprintf(msg, "</get-config></rpc>");
|
||||
if (netconf_output_encap(0, msg) < 0) // XXX configurable session
|
||||
goto done;
|
||||
if (clicon_msg_send1(sock, descr, msg) < 0)
|
||||
if (clixon_msg_send10(sock, descr, msg) < 0)
|
||||
goto done;
|
||||
if (clicon_msg_rcv1(sock, descr, msgret, &eof) < 0)
|
||||
if (clixon_msg_rcv10(sock, descr, msgret, &eof) < 0)
|
||||
goto done;
|
||||
if (eof){
|
||||
close(sock);
|
||||
|
|
|
|||
|
|
@ -76,6 +76,43 @@
|
|||
#include "clixon_proto.h"
|
||||
#include "clixon_netconf_input.h"
|
||||
|
||||
/*! Look for a text pattern in an input string, one char at a time
|
||||
*
|
||||
* @param[in] tag What to look for
|
||||
* @param[in] ch New input character
|
||||
* @param[in,out] state A state integer holding how far we have parsed.
|
||||
* @retval 1 Yes, we have detected end tag!
|
||||
* @retval 0 No, we havent detected end tag
|
||||
* @code
|
||||
* int state = 0;
|
||||
* char ch;
|
||||
* while (1) {
|
||||
* // read ch
|
||||
* if (detect_endtag("mypattern", ch, &state)) {
|
||||
* // mypattern is matched
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
int
|
||||
detect_endtag(char *tag,
|
||||
char ch,
|
||||
int *state)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (tag[*state] == ch){
|
||||
(*state)++;
|
||||
if (*state == strlen(tag)){
|
||||
*state = 0;
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
*state = 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*! Read from socket and append to cbuf
|
||||
*
|
||||
* @param[in] s Socket where input arrives. Read from this.
|
||||
|
|
@ -194,9 +231,10 @@ netconf_input_msg2(unsigned char **bufp,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Process incoming frame, ie a char message framed by ]]>]]>
|
||||
/*! Parse incoming frame (independent of framing)
|
||||
*
|
||||
* Parse string to xml, check only one netconf message within a frame
|
||||
* A relatively high-level function.
|
||||
* @param[in] cb Packet buffer
|
||||
* @param[in] yb Yang binding: Y_RPC for server-side, Y_NONE for client-side (for now)
|
||||
* @param[in] yspec Yang spec
|
||||
|
|
@ -268,4 +306,3 @@ netconf_input_frame2(cbuf *cb,
|
|||
retval = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue