possible fix for mnettoss

This commit is contained in:
Andrew Pamment 2018-05-26 23:06:57 +10:00
parent e8a7fac9b2
commit 8e1b0f7c91

View File

@ -48,6 +48,14 @@ void msg_to_hl(struct msg_t *msg) {
msg->type = ntohl(msg->type); 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) { int copy_file(char *src, char *dest) {
FILE *src_file; FILE *src_file;
FILE *dest_file; FILE *dest_file;
@ -442,7 +450,15 @@ int import(char *filename) {
} else { } else {
snprintf(buffer2, PATH_MAX, "%s/%d/%d-%s.message", baseoutdir, hubnode, areas[areaid]->links[i], uuid); 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);
} }
} }
} }