Add gp_babel_packet_size() function
This commit is contained in:
parent
415606c736
commit
5d068fa244
3 changed files with 7 additions and 5 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
Reference in a new issue