diff --git a/utils/mnetsubunsub/mnetsubunsub.c b/utils/mnetsubunsub/mnetsubunsub.c index 16585af..7496aa2 100644 --- a/utils/mnetsubunsub/mnetsubunsub.c +++ b/utils/mnetsubunsub/mnetsubunsub.c @@ -26,14 +26,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)); @@ -42,6 +42,14 @@ int area_count; int mynode = 0; int hubnode = 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); +} + int copy_file(char *src, char *dest) { FILE *src_file; FILE *dest_file; @@ -296,6 +304,8 @@ int main(int argc, char **argv) { fprintf(stderr, "Error creating file %s\n", buffer); return -1; } + + msg_to_nl(&msg); fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite("ADD\r", 4, 1, fptr); @@ -344,6 +354,8 @@ int main(int argc, char **argv) { return -1; } + msg_to_nl(&msg); + fwrite(&msg, sizeof(struct msg_t), 1, fptr); fwrite("REMOVE\r", 7, 1, fptr); fclose(fptr);