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: * Following things NYI:
* - Emulates old clicon_msg API * - 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[in,out] frame_size Chunked framing size parameter
* @param[out] eom If frame found in cb? * @param[out] eom If frame found in cb?
* @retval 0 OK * @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 * The routine should be called continuously with more data from input socket in buf
* State of previous reads is saved in: * State of previous reads is saved in:
* - bufp/lenp * - bufp/lenp

View file

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

View file

@ -675,11 +675,11 @@ clixon_msg_rcv2(int s,
cbuf **cb, cbuf **cb,
int *eof) int *eof)
{ {
int retval = -1; int retval = -1;
unsigned char buf[BUFSIZ]; unsigned char buf[BUFSIZ];
ssize_t buflen = sizeof(buf); ssize_t buflen = sizeof(buf);
int frame_state = 0; int frame_state = 0;
size_t frame_size = 0; size_t frame_size = 0;
unsigned char *p = buf; unsigned char *p = buf;
size_t plen; size_t plen;
cbuf *cbmsg=NULL; cbuf *cbmsg=NULL;
@ -705,8 +705,12 @@ clixon_msg_rcv2(int s,
NETCONF_SSH_CHUNKED, NETCONF_SSH_CHUNKED,
&frame_state, &frame_state,
&frame_size, &frame_size,
&eom) < 0) &eom) < 0){
goto done; /* Errors from input are only framing errors, non-fatal, return eof */
*eof = 1;
cbuf_reset(cbmsg);
break;
}
if (eom == 0){ if (eom == 0){
continue; continue;
} }
@ -731,7 +735,7 @@ clixon_msg_rcv2(int s,
} }
#endif /* NETCONF_INPUT_UNIFIED_INTERNAL */ #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] h Clixon handle
* @param[in] msg Internal msg data structure. It has fixed header and variable body. * @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" 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>" 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 if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill