From 8e1b0f7c9111919df73e281fd3f0f1a9d5649df6 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 26 May 2018 23:06:57 +1000 Subject: [PATCH] possible fix for mnettoss --- utils/mnettoss/mnettoss.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/utils/mnettoss/mnettoss.c b/utils/mnettoss/mnettoss.c index 18d4d4d..fbb28f8 100644 --- a/utils/mnettoss/mnettoss.c +++ b/utils/mnettoss/mnettoss.c @@ -48,6 +48,14 @@ void msg_to_hl(struct msg_t *msg) { msg->type = ntohl(msg->type); } +void msg_to_nl(struct msg_t *msg) { + msg->area = htonl(msg->area); + msg->timedate = htonl(msg->timedate); + msg->oaddr = htonl(msg->oaddr); + msg->daddr = htonl(msg->daddr); + msg->type = htonl(msg->type); +} + int copy_file(char *src, char *dest) { FILE *src_file; FILE *dest_file; @@ -442,7 +450,15 @@ int import(char *filename) { } else { snprintf(buffer2, PATH_MAX, "%s/%d/%d-%s.message", baseoutdir, hubnode, areas[areaid]->links[i], uuid); } - copy_file(buffer, buffer2); + msg.daddr = areas[areaid]->links[i]; + msg_to_nl(&msg); + + fptr = fopen(buffer2, "wb"); + fwrite(&msg, sizeof(struct msg_t), 1, fptr); + fwrite(body, strlen(body), 1, fptr); + fclose(fptr); + + msg_to_hl(&msg); } } }