diff --git a/lib/Makefile.villas.inc b/lib/Makefile.villas.inc index 4959036a2..a6f41aa7b 100644 --- a/lib/Makefile.villas.inc +++ b/lib/Makefile.villas.inc @@ -51,7 +51,7 @@ endif # Enable WebSocket support ifndef WITHOUT_WEBSOCKETS ifeq ($(shell pkg-config libwebsockets jansson; echo $$?),0) - LIB_SRCS += lib/nodes/websocket.c + LIB_SRCS += lib/nodes/websocket.c lib/webmsg.c LIB_PKGS += libwebsockets jansson endif endif diff --git a/lib/webmsg.c b/lib/webmsg.c index 489f9cd57..69756bb62 100644 --- a/lib/webmsg.c +++ b/lib/webmsg.c @@ -7,20 +7,20 @@ #include #include "webmsg.h" -#include "msg_format.h" +#include "webmsg_format.h" void webmsg_ntoh(struct webmsg *m) { - msg_hdr_ntoh(m); + webmsg_hdr_ntoh(m); for (int i = 0; i < m->length; i++) - m->data[i].i = ntohl(m->data[i].i); + m->data[i].i = le32toh(m->data[i].i); } -void msg_hton(struct webmsg *m) +void webmsg_hton(struct webmsg *m) { for (int i = 0; i < m->length; i++) - m->data[i].i = htonl(m->data[i].i); + m->data[i].i = htole32(m->data[i].i); webmsg_hdr_hton(m); } @@ -28,17 +28,17 @@ void msg_hton(struct webmsg *m) void webmsg_hdr_hton(struct webmsg *m) { m->length = htole16(m->length); - m->sequence = htonle32(m->sequence); - m->ts.sec = htonle32(m->ts.sec); - m->ts.nsec = htonle32(m->ts.nsec); + m->sequence = htole32(m->sequence); + m->ts.sec = htole32(m->ts.sec); + m->ts.nsec = htole32(m->ts.nsec); } void webmsg_hdr_ntoh(struct webmsg *m) { - m->length = le16tohs(m->length); - m->sequence = le32tohl(m->sequence); - m->ts.sec = le32tohl(m->ts.sec); - m->ts.nsec = le32tohl(m->ts.nsec); + m->length = le16toh(m->length); + m->sequence = le32toh(m->sequence); + m->ts.sec = le32toh(m->ts.sec); + m->ts.nsec = le32toh(m->ts.nsec); } int webmsg_verify(struct webmsg *m) @@ -47,7 +47,7 @@ int webmsg_verify(struct webmsg *m) return -1; else if (m->type != WEBMSG_TYPE_DATA) return -2; - else if ((m->rsvd1 != 0) || (m->rsvd2 != 0)) + else if (m->rsvd1 != 0) return -3; else return 0;