diff --git a/utils/mnetftn/ftntomnet.c b/utils/mnetftn/ftntomnet.c index 4f41f27..9c36357 100644 --- a/utils/mnetftn/ftntomnet.c +++ b/utils/mnetftn/ftntomnet.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "libuuid/uuid.h" #include "jamlib/jam.h" @@ -35,6 +36,14 @@ int mynode = 0; int hubnode = 0; int imhub = 0; +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); +} + s_JamBase *open_jam_base(char *path) { int ret; s_JamBase *jb; @@ -332,6 +341,8 @@ int export_messages(int area) { continue; } + msg_to_nl(&msg); + fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite(body, strlen(body), 1, fptr); fclose(fptr); @@ -361,6 +372,8 @@ int export_messages(int area) { continue; } + msg_to_nl(&msg); + fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite(body, strlen(body), 1, fptr); fclose(fptr); diff --git a/utils/mnetftn/mnettoftn.c b/utils/mnetftn/mnettoftn.c index 914b3ab..6bce4c6 100644 --- a/utils/mnetftn/mnettoftn.c +++ b/utils/mnetftn/mnettoftn.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "jamlib/jam.h" char *baseindir = NULL; @@ -43,6 +44,14 @@ int area_count; int mynode = 0; int hubnode = 0; +void msg_to_hl(struct msg_t *msg) { + msg->area = ntohl(msg->area); + msg->timedate = ntohl(msg->timedate); + msg->oaddr = ntohl(msg->oaddr); + msg->daddr = ntohl(msg->daddr); + msg->type = ntohl(msg->type); +} + unsigned long generate_msgid() { char buffer[1024]; @@ -375,6 +384,8 @@ int import(char *filename) { fread(&msg, sizeof(struct msg_t), 1, fptr); + msg_to_hl(&msg); + body = malloc(st.st_size - sizeof(struct msg_t) + 1 + strlen(fido_addr)); memset(body, 0, st.st_size - sizeof(struct msg_t) + 1 + strlen(fido_addr)); diff --git a/utils/mnetscan/mnetscan.c b/utils/mnetscan/mnetscan.c index 17574c9..107872b 100644 --- a/utils/mnetscan/mnetscan.c +++ b/utils/mnetscan/mnetscan.c @@ -4,7 +4,7 @@ #include #include #include - +#include #include "jamlib/jam.h" char *baseoutdir = NULL; @@ -18,14 +18,14 @@ struct msgarea_t { }; struct msg_t { - int area; + uint32_t area; char from[32]; char to[32]; char subject[64]; uint32_t timedate; - int oaddr; - int daddr; - int type; + uint32_t oaddr; + uint32_t daddr; + uint32_t type; char reply[36]; } __attribute__ ((packed)); @@ -35,6 +35,14 @@ int mynode = 0; int hubnode = 0; int imhub = 0; +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); +} + s_JamBase *open_jam_base(char *path) { int ret; s_JamBase *jb; @@ -313,6 +321,8 @@ int export_messages(int area) { continue; } + msg_to_nl(&msg); + fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite(body, strlen(body), 1, fptr); fclose(fptr); @@ -341,6 +351,8 @@ int export_messages(int area) { fprintf(stderr, "Error creating file %s\n", buffer); continue; } + + msg_to_nl(&msg); fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite(body, strlen(body), 1, fptr); diff --git a/utils/mnettoss/mnettoss.c b/utils/mnettoss/mnettoss.c index 6a028b4..18d4d4d 100644 --- a/utils/mnettoss/mnettoss.c +++ b/utils/mnettoss/mnettoss.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "jamlib/jam.h" char *baseindir = NULL; @@ -23,14 +24,14 @@ struct msgarea_t { }; struct msg_t { - int area; + uint32_t area; char from[32]; char to[32]; char subject[64]; uint32_t timedate; - int oaddr; - int daddr; - int type; + uint32_t oaddr; + uint32_t daddr; + uint32_t type; char reply[36]; } __attribute__ ((packed)); @@ -39,6 +40,14 @@ int area_count; int mynode = 0; int hubnode = 0; +void msg_to_hl(struct msg_t *msg) { + msg->area = ntohl(msg->area); + msg->timedate = ntohl(msg->timedate); + msg->oaddr = ntohl(msg->oaddr); + msg->daddr = ntohl(msg->daddr); + msg->type = ntohl(msg->type); +} + int copy_file(char *src, char *dest) { FILE *src_file; FILE *dest_file; @@ -339,6 +348,8 @@ int import(char *filename) { } fread(&msg, sizeof(struct msg_t), 1, fptr); + + msg_to_hl(&msg); body = malloc(st.st_size - sizeof(struct msg_t) + 1);