summaryrefslogtreecommitdiffstats
path: root/lib/ratp.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-08-31 00:37:20 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-08-31 08:42:00 +0200
commit92e1b1f0ca0249c64186f1017eaade0c79d7c2e6 (patch)
treef166e2719d403723e0817aaa15f3808810273f00 /lib/ratp.c
parentc52168e0fc9991170e80b487277ad307d89ae2e1 (diff)
downloadbarebox-92e1b1f0ca0249c64186f1017eaade0c79d7c2e6.tar.gz
barebox-92e1b1f0ca0249c64186f1017eaade0c79d7c2e6.tar.xz
ratp: fix sending data that won't fit in a single RATP packet
We need to advance the input buffer used to create messages when the data doesn't fit in a single RATP packet. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/ratp.c')
-rw-r--r--lib/ratp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/ratp.c b/lib/ratp.c
index 4c5c748b48..7801cae519 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -1734,11 +1734,12 @@ void ratp_close(struct ratp *ratp)
*
* Return: 0 if successful, a negative error code otherwise.
*/
-int ratp_send_complete(struct ratp *ratp, const void *data, size_t len,
+int ratp_send_complete(struct ratp *ratp, const uint8_t *data, size_t len,
void (*complete)(void *ctx, int status), void *complete_ctx)
{
struct ratp_internal *ri = ratp->internal;
struct ratp_message *msg;
+ int sent = 0;
if (!ri || ri->state != RATP_STATE_ESTABLISHED)
return -ENETDOWN;
@@ -1754,11 +1755,12 @@ int ratp_send_complete(struct ratp *ratp, const void *data, size_t len,
msg = xzalloc(sizeof(*msg));
msg->buf = xzalloc(sizeof(struct ratp_header) + now + 2);
msg->len = now;
- memcpy(msg->buf + sizeof(struct ratp_header), data, now);
+ memcpy(msg->buf + sizeof(struct ratp_header), data + sent, now);
list_add_tail(&msg->list, &ri->sendmsg);
len -= now;
+ sent += now;
}
msg->eor = 1;