netconf client was limited to 8K byte messages. Now limit is 2^32

This commit is contained in:
Olof hagsand 2017-09-13 22:30:35 +02:00
parent 4d82d4f6ea
commit 624b949b3f
11 changed files with 157 additions and 68 deletions

View file

@ -130,8 +130,8 @@ struct clicon_msg *
clicon_msg_encode(char *format, ...)
{
va_list args;
int xmllen;
int len;
uint32_t xmllen;
uint32_t len;
struct clicon_msg *msg = NULL;
int hdrlen = sizeof(*msg);
@ -146,7 +146,7 @@ clicon_msg_encode(char *format, ...)
}
memset(msg, 0, len);
/* hdr */
msg->op_len = htons(len);
msg->op_len = htonl(len);
/* body */
va_start(args, format);
@ -267,7 +267,7 @@ msg_dump(struct clicon_msg *msg)
memset(buf2, 0, sizeof(buf2));
snprintf(buf2, sizeof(buf2), "%s:", __FUNCTION__);
for (i=0; i<ntohs(msg->op_len); i++){
for (i=0; i<ntohl(msg->op_len); i++){
snprintf(buf, sizeof(buf), "%s%02x", buf2, ((char*)msg)[i]&0xff);
if ((i+1)%32==0){
clicon_debug(2, buf);
@ -294,13 +294,13 @@ clicon_msg_send(int s,
int retval = -1;
clicon_debug(2, "%s: send msg len=%d",
__FUNCTION__, ntohs(msg->op_len));
__FUNCTION__, ntohl(msg->op_len));
if (debug > 2)
msg_dump(msg);
if (atomicio((ssize_t (*)(int, void *, size_t))write,
s, msg, ntohs(msg->op_len)) < 0){
s, msg, ntohl(msg->op_len)) < 0){
clicon_err(OE_CFG, errno, "%s", __FUNCTION__);
clicon_log(LOG_WARNING, "%s: write: %s len:%d msg:%s", __FUNCTION__,
clicon_log(LOG_WARNING, "%s: write: %s len:%u msg:%s", __FUNCTION__,
strerror(errno), ntohs(msg->op_len), msg->op_body);
goto done;
}
@ -309,7 +309,6 @@ clicon_msg_send(int s,
return retval;
}
/*! Receive a CLICON message
*
* XXX: timeout? and signals?
@ -333,9 +332,9 @@ clicon_msg_rcv(int s,
int retval = -1;
struct clicon_msg hdr;
int hlen;
int len2;
uint32_t len2;
sigfn_t oldhandler;
uint16_t mlen;
uint32_t mlen;
*eof = 0;
if (0)
@ -354,7 +353,7 @@ clicon_msg_rcv(int s,
clicon_err(OE_CFG, errno, "%s: header too short (%d)", __FUNCTION__, hlen);
goto done;
}
mlen = ntohs(hdr.op_len);
mlen = ntohl(hdr.op_len);
clicon_debug(2, "%s: rcv msg len=%d",
__FUNCTION__, mlen);
if ((*msg = (struct clicon_msg *)malloc(mlen)) == NULL){
@ -533,17 +532,17 @@ clicon_rpc(int s,
int
send_msg_reply(int s,
char *data,
uint16_t datalen)
uint32_t datalen)
{
int retval = -1;
struct clicon_msg *reply = NULL;
uint16_t len;
uint32_t len;
len = sizeof(*reply) + datalen;
if ((reply = (struct clicon_msg *)malloc(len)) == NULL)
goto done;
memset(reply, 0, len);
reply->op_len = htons(len);
reply->op_len = htonl(len);
if (datalen > 0)
memcpy(reply->op_body, data, datalen);
if (clicon_msg_send(s, reply) < 0)