diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/babel.c | 4 | ||||
-rw-r--r-- | src/packet.h | 6 | ||||
-rw-r--r-- | src/tlv.c | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/babel.c b/src/babel.c index 4002df2..9242d30 100644 --- a/src/babel.c +++ b/src/babel.c @@ -32,8 +32,6 @@ #include <stdlib.h> -#include <arpa/inet.h> - const char *gmrf_protocol_name = "babel"; const char *gmrf_protocol_version = "experimental"; @@ -82,7 +80,7 @@ static void send_hellos(gmrf_t *gmrf, gmrf_context_t *ctx, void *arg) { add_ihus(gmrf, packet, GP_BABEL_PACKET_MAX, iface); - gmrf_iface_send_bc(gmrf, iface->gmrf_iface, packet, sizeof(gp_babel_packet_t)+ntohs(packet->len)); + gmrf_iface_send_bc(gmrf, iface->gmrf_iface, packet, gp_babel_packet_size(packet)); } } diff --git a/src/packet.h b/src/packet.h index a27b644..286192e 100644 --- a/src/packet.h +++ b/src/packet.h @@ -29,6 +29,8 @@ #include "types.h" +#include <arpa/inet.h> + #define GP_BABEL_VERSION 0 @@ -39,5 +41,9 @@ struct __attribute__((packed)) gp_babel_packet { uint8_t tlv[]; }; +static inline size_t gp_babel_packet_size(const gp_babel_packet_t *packet) { + return sizeof(gp_babel_packet_t)+ntohs(packet->len); +} + #endif /* _GMRF_PROTO_BABEL_PACKET_H_ */ @@ -29,8 +29,6 @@ #include <string.h> -#include <arpa/inet.h> - bool gp_babel_tlv_parse(gmrf_t *gmrf, gmrf_context_t *ctx, const gp_babel_packet_t *packet, gp_babel_tlv_cb cb, void *arg) { if (packet->version != htons(GP_BABEL_VERSION)) |