diff options
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 60 |
1 files changed, 30 insertions, 30 deletions
@@ -31,34 +31,34 @@ #include "tlv_types.h" -static inline bool send_neigh(gmrf_t *gmrf, const gp_babel_neigh_t *neigh, const gp_babel_packet_t *packet) { +static inline bool send_neigh(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh, const gp_babel_packet_t *packet) { if (!neigh->iface) return false; - if (!gmrf_iface_send(gmrf, neigh->iface->gmrf_iface, packet, gp_babel_packet_size(packet), &neigh->addr)) { - gmrf_logf(gmrf, LOG_WARNING, "gmrf_iface_send: %m"); + if (!gmrf_iface_send(ctx->gmrf, neigh->iface->gmrf_iface, packet, gp_babel_packet_size(packet), &neigh->addr)) { + gmrf_logf(ctx->gmrf, LOG_WARNING, "gmrf_iface_send: %m"); return false; } return true; } -static inline bool send_iface(gmrf_t *gmrf, const gp_babel_iface_t *iface, const gp_babel_packet_t *packet) { - if (!gmrf_iface_send_bc(gmrf, iface->gmrf_iface, packet, gp_babel_packet_size(packet))) { - gmrf_logf(gmrf, LOG_WARNING, "gmrf_iface_send_bc: %m"); +static inline bool send_iface(gmrf_context_t *ctx, const gmrf_iface_state_t *iface, const gp_babel_packet_t *packet) { + if (!gmrf_iface_send_bc(ctx->gmrf, iface->gmrf_iface, packet, gp_babel_packet_size(packet))) { + gmrf_logf(ctx->gmrf, LOG_WARNING, "gmrf_iface_send_bc: %m"); return false; } 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; +static inline void send_bc(gmrf_context_t *ctx, const gp_babel_packet_t *packet) { + gmrf_iface_state_t *iface; for (iface = ctx->interfaces; iface; iface = iface->next) - send_iface(gmrf, iface, packet); + send_iface(ctx, iface, packet); } -void gp_babel_send_ack(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_neigh_t *neigh, uint16_t nonce) { +void gp_babel_send_ack(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); gp_babel_tlv_ack_t *ack = gp_babel_tlv_add(buf, TLV_ACK, sizeof(gp_babel_tlv_ack_t)); @@ -67,10 +67,10 @@ void gp_babel_send_ack(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_neigh_t *neig ack->nonce = htons(nonce); - send_neigh(gmrf, neigh, &buf->packet); + send_neigh(ctx, neigh, &buf->packet); } -static void add_ihus(gmrf_t *gmrf, gp_babel_packet_buf_t *buf, const gp_babel_iface_t *iface) { +static void add_ihus(gmrf_context_t *ctx, gp_babel_packet_buf_t *buf, const gmrf_iface_state_t *iface) { const gp_babel_neigh_t *neigh; for (neigh = iface->neighbours; neigh; neigh = neigh->next) { @@ -80,14 +80,14 @@ static void add_ihus(gmrf_t *gmrf, gp_babel_packet_buf_t *buf, const gp_babel_if ihu->ae = ADDR_ENC_GMRF; ihu->reserved = 0; - ihu->rxcost = htons(gp_babel_neigh_get_rxcost(gmrf, neigh)); + ihu->rxcost = htons(gp_babel_neigh_get_rxcost(ctx, neigh)); ihu->interval = htons(GP_BABEL_IHU_INTERVAL); memcpy(ihu->address, &neigh->addr, sizeof(gmrf_addr_t)); } } -void gp_babel_send_hellos(gmrf_t *gmrf, gmrf_context_t *ctx) { - gmrf_logf(gmrf, LOG_DEBUG, "sending hellos..."); +void gp_babel_send_hellos(gmrf_context_t *ctx) { + gmrf_logf(ctx->gmrf, LOG_DEBUG, "sending hellos..."); gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX); @@ -100,14 +100,14 @@ void gp_babel_send_hellos(gmrf_t *gmrf, gmrf_context_t *ctx) { uint16_t len = buf->packet.len; - gp_babel_iface_t *iface; + gmrf_iface_state_t *iface; for (iface = ctx->interfaces; iface; iface = iface->next) { hello->seqno = htons(iface->seqno++); buf->packet.len = len; - add_ihus(gmrf, buf, iface); + add_ihus(ctx, buf, iface); - send_iface(gmrf, iface, &buf->packet); + send_iface(ctx, iface, &buf->packet); } } @@ -169,7 +169,7 @@ static bool add_update(gp_babel_packet_buf_t *buf, gp_babel_node_id_t *node_id, return true; } -void gp_babel_send_update(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_iface_t *iface, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce, bool with_payload) { +void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce, bool with_payload) { gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX); if (announce) { @@ -182,15 +182,15 @@ void gp_babel_send_update(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_iface_t *i for (a = ctx->announces; a; a = a->next) { if (!add_update(buf, &node_id, a, with_payload, neigh)) { if (neigh) - send_neigh(gmrf, neigh, &buf->packet); + send_neigh(ctx, neigh, &buf->packet); else - send_iface(gmrf, iface, &buf->packet); + send_iface(ctx, iface, &buf->packet); node_id = gp_babel_node_id_unspec; buf->packet.len = 0; if (!add_update(buf, &node_id, a, with_payload, neigh)) { - gmrf_logf(gmrf, LOG_ERR, "add_update failed"); + gmrf_logf(ctx->gmrf, LOG_ERR, "add_update failed"); return; } } @@ -199,13 +199,13 @@ void gp_babel_send_update(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_iface_t *i if (buf->packet.len) { if (neigh) - send_neigh(gmrf, neigh, &buf->packet); + send_neigh(ctx, neigh, &buf->packet); else - send_iface(gmrf, iface, &buf->packet); + send_iface(ctx, 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) { +void gp_babel_send_announce_request(gmrf_context_t *ctx, gmrf_iface_state_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)); @@ -222,12 +222,12 @@ void gp_babel_send_announce_request(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_ req->flags |= GP_BABEL_ANNOUCE_REQ_FLAG_WITH_PAYLOAD; if (neigh) - send_neigh(gmrf, neigh, &buf->packet); + send_neigh(ctx, neigh, &buf->packet); else - send_iface(gmrf, iface, &buf->packet); + send_iface(ctx, 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) { +void gp_babel_send_seqno_request(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)); @@ -241,7 +241,7 @@ void gp_babel_send_seqno_request(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_nei req->key = htons(announce->key); if (neigh) - send_neigh(gmrf, neigh, &buf->packet); + send_neigh(ctx, neigh, &buf->packet); else - send_bc(gmrf, ctx, &buf->packet); + send_bc(ctx, &buf->packet); } |