NETCONF internal: Enable RFC 6242 chunked encoding

This commit is contained in:
Olof hagsand 2024-02-27 13:22:50 +01:00
parent db11b5ef99
commit e4834b9896
5 changed files with 25 additions and 11 deletions

View file

@ -213,5 +213,5 @@
* Following things NYI:
* - Emulates old clicon_msg API
*/
#undef NETCONF_INPUT_UNIFIED_INTERNAL
#define NETCONF_INPUT_UNIFIED_INTERNAL

View file

@ -124,7 +124,7 @@ netconf_input_read2(int s,
* @param[in,out] frame_size Chunked framing size parameter
* @param[out] eom If frame found in cb?
* @retval 0 OK
* @retval -1 Error
* @retval -1 Error (from chunked framing)
* The routine should be called continuously with more data from input socket in buf
* State of previous reads is saved in:
* - bufp/lenp

View file

@ -2226,7 +2226,7 @@ netconf_output_encap(netconf_framing_type framing,
* @retval 2 End-of-frame
* @retval 1 Chunk-data
* @retval 0 Framing char, not data
* @retval -1 Error
* @retval -1 Framing error
* Example:
C: \n#4\n
C: <rpc

View file

@ -705,8 +705,12 @@ clixon_msg_rcv2(int s,
NETCONF_SSH_CHUNKED,
&frame_state,
&frame_size,
&eom) < 0)
goto done;
&eom) < 0){
/* Errors from input are only framing errors, non-fatal, return eof */
*eof = 1;
cbuf_reset(cbmsg);
break;
}
if (eom == 0){
continue;
}
@ -731,7 +735,7 @@ clixon_msg_rcv2(int s,
}
#endif /* NETCONF_INPUT_UNIFIED_INTERNAL */
/*! Connect to server, send a clicon_msg message and wait for result using unix socket
/*! Connect to server using unix socket
*
* @param[in] h Clixon handle
* @param[in] msg Internal msg data structure. It has fixed header and variable body.

View file

@ -74,6 +74,16 @@ EOF
new "hello session-id 2"
expecteof "$clixon_util_socket -a $family -s $sock -D $DBG" 0 "<hello $DEFAULTONLY/>" "<hello $DEFAULTONLY><session-id>4</session-id></hello>"
if [ $family = UNIX -a -n "$netcat" ]; then
new "Unix socket garbage test"
echo "garbage" | netcat -U $sock
new "Check backend alive"
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend pid" "backend dead"
fi
fi
if [ $BE -ne 0 ]; then
new "Kill backend"
# Check if premature kill