1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

smaller fixes for websocket message code

This commit is contained in:
Steffen Vogel 2017-04-24 14:19:12 +02:00
parent 483bfd286a
commit 86ec387b9a
2 changed files with 14 additions and 14 deletions

View file

@ -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

View file

@ -7,20 +7,20 @@
#include <endian.h>
#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;