summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-03-19 03:44:27 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-03-19 03:44:27 +0100
commit5d068fa244f65c7df2cd6a8e5c6e04dc7e2c9f15 (patch)
treef909de7ea843bbc2eedd600bf1169e18c8b65b34 /src
parent415606c73661aa9788a6a16dfc8a75b305246992 (diff)
downloadbabel-5d068fa244f65c7df2cd6a8e5c6e04dc7e2c9f15.tar
babel-5d068fa244f65c7df2cd6a8e5c6e04dc7e2c9f15.zip
Add gp_babel_packet_size() function
Diffstat (limited to 'src')
-rw-r--r--src/babel.c4
-rw-r--r--src/packet.h6
-rw-r--r--src/tlv.c2
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_ */
diff --git a/src/tlv.c b/src/tlv.c
index b43156c..488f775 100644
--- a/src/tlv.c
+++ b/src/tlv.c
@@ -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))