diff options
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -52,6 +52,12 @@ static inline bool send_iface(gmrf_t *gmrf, const gp_babel_iface_t *iface, const return true; } +static inline void send_bc(gmrf_t *gmrf, gmrf_context_t *ctx, const gp_babel_packet_t *packet) { + gp_babel_iface_t *iface; + for (iface = ctx->interfaces; iface; iface = iface->next) + send_iface(gmrf, iface, packet); +} + void gp_babel_send_ack(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_neigh_t *neigh, uint16_t nonce) { gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX); @@ -198,3 +204,44 @@ void gp_babel_send_update(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_iface_t *i send_iface(gmrf, iface, &buf->packet); } } + +void gp_babel_send_announce_request(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_iface_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node, uint16_t type, uint16_t key, bool with_payload) { + gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX); + + gp_babel_tlv_announce_req_t *req = gp_babel_tlv_add(buf, TLV_ANNOUNCE_REQ, sizeof(gp_babel_tlv_announce_req_t)); + if (!req) + return; + + req->node = *node; + req->flags = 0; + req->reserved = 0; + req->type = htons(type); + req->key = htons(key); + + if (with_payload) + req->flags |= GP_BABEL_ANNOUCE_REQ_FLAG_WITH_PAYLOAD; + + if (neigh) + send_neigh(gmrf, neigh, &buf->packet); + else + send_iface(gmrf, iface, &buf->packet); +} + +void gp_babel_send_seqno_request(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce, uint16_t seqno, uint8_t hop_count) { + gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX); + + gp_babel_tlv_seqno_req_t *req = gp_babel_tlv_add(buf, TLV_SEQNO_REQ, sizeof(gp_babel_tlv_seqno_req_t)); + if (!req) + return; + + req->seqno = htons(seqno); + req->hop_count = hop_count; + req->node = announce->node; + req->type = htons(announce->type); + req->key = htons(announce->key); + + if (neigh) + send_neigh(gmrf, neigh, &buf->packet); + else + send_bc(gmrf, ctx, &buf->packet); +} |