summaryrefslogtreecommitdiffstats
path: root/src/babel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/babel.h')
-rw-r--r--src/babel.h54
1 files changed, 25 insertions, 29 deletions
diff --git a/src/babel.h b/src/babel.h
index 41db13d..93a3bcd 100644
--- a/src/babel.h
+++ b/src/babel.h
@@ -50,10 +50,6 @@
#define GP_BABEL_SEQNO_REQ_HOP_LIMIT 127
-#define GP_BABEL_UPDATE_FLAG_HAS_PAYLOAD 0x01
-#define GP_BABEL_ANNOUCE_REQ_FLAG_WITH_PAYLOAD 0x01
-
-
struct gmrf_context {
gmrf_t *gmrf;
@@ -62,7 +58,7 @@ struct gmrf_context {
gmrf_iface_state_t *interfaces;
gp_babel_neigh_t *neighbours;
- gp_babel_announce_t *announces;
+ gp_babel_route_t *routes;
};
struct gmrf_iface_state {
@@ -94,12 +90,10 @@ struct gp_babel_neigh {
uint16_t txcost;
};
-struct gp_babel_announce {
- gp_babel_announce_t *next;
+struct gp_babel_route {
+ gp_babel_route_t *next;
gp_babel_node_id_t node;
- uint16_t type;
- uint16_t key;
gp_babel_metric_seqno_t metric;
uint16_t last_metric;
@@ -107,10 +101,6 @@ struct gp_babel_announce {
gp_babel_nexthop_t *selected;
gp_babel_nexthop_t *nexthops;
-
- /* an incomplete announcement is specified by a len value of 0xff with NULL payload */
- uint8_t len;
- uint8_t *payload;
};
struct gp_babel_nexthop {
@@ -130,20 +120,22 @@ void gp_babel_handle_packet(gmrf_context_t *ctx, gmrf_iface_state_t *iface, cons
void gp_babel_send_ack(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, uint16_t nonce);
void gp_babel_send_hellos(gmrf_context_t *ctx);
-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);
+void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh);
+void gp_babel_send_update_for_route(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, gp_babel_route_t *route);
+void gp_babel_send_retract(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node);
-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);
-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);
+void gp_babel_send_route_request(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node);
+void gp_babel_send_seqno_request(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_route_t *route, uint16_t seqno, uint8_t hop_count);
-gp_babel_announce_t* gp_babel_announce_new(gmrf_context_t *ctx);
-gp_babel_announce_t* gp_babel_announce_find(gmrf_context_t *ctx, const gp_babel_node_id_t *node, uint16_t type, uint16_t key);
-gp_babel_announce_t* gp_babel_announce_get(gmrf_context_t *ctx, const gp_babel_node_id_t *node, uint16_t type, uint16_t key);
-void gp_babel_announce_update(gmrf_context_t *ctx, gp_babel_announce_t *announce);
-void gp_babel_announce_free(gmrf_context_t *ctx, gp_babel_announce_t *announce);
+gp_babel_route_t* gp_babel_route_new(gmrf_context_t *ctx);
+gp_babel_route_t* gp_babel_route_find(gmrf_context_t *ctx, const gp_babel_node_id_t *node);
+gp_babel_route_t* gp_babel_route_get(gmrf_context_t *ctx, const gp_babel_node_id_t *node);
+void gp_babel_route_update(gmrf_context_t *ctx, gp_babel_route_t *route);
+void gp_babel_route_free(gmrf_context_t *ctx, gp_babel_route_t *route);
-gp_babel_nexthop_t* gp_babel_announce_nexthop_new(gp_babel_announce_t *announce, gp_babel_neigh_t *neigh);
-gp_babel_nexthop_t* gp_babel_announce_nexthop_find(const gp_babel_announce_t *announce, gp_babel_neigh_t *neigh);
-void gp_babel_announce_update_nexthop(gmrf_context_t *ctx, gp_babel_announce_t *announce, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval);
+gp_babel_nexthop_t* gp_babel_route_nexthop_new(gp_babel_route_t *route, gp_babel_neigh_t *neigh);
+gp_babel_nexthop_t* gp_babel_route_nexthop_find(const gp_babel_route_t *route, gp_babel_neigh_t *neigh);
+void gp_babel_route_update_nexthop(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval);
static inline bool gp_babel_node_id_equal(const gp_babel_node_id_t *id1, const gp_babel_node_id_t *id2) {
@@ -177,18 +169,22 @@ static inline bool gp_babel_is_metric_better(gp_babel_metric_seqno_t ms1, gp_bab
return false;
}
-static inline bool gp_babel_is_feasible(const gp_babel_announce_t *announce, gp_babel_metric_seqno_t ms) {
+static inline bool gp_babel_route_is_reachable(const gp_babel_route_t *route) {
+ return (route->metric.metric != GP_BABEL_INFINITY);
+}
+
+static inline bool gp_babel_is_feasible(const gp_babel_route_t *route, gp_babel_metric_seqno_t ms) {
if (ms.metric == GP_BABEL_INFINITY)
return true;
- return gp_babel_is_metric_better(ms, announce->feasibility_distance);
+ return gp_babel_is_metric_better(ms, route->feasibility_distance);
}
-static inline void gp_babel_send_seqno_request_for(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce) {
- if (announce->feasibility_distance.metric == GP_BABEL_INFINITY)
+static inline void gp_babel_send_seqno_request_for(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_route_t *route) {
+ if (route->feasibility_distance.metric == GP_BABEL_INFINITY)
return;
- gp_babel_send_seqno_request(ctx, neigh, announce, announce->feasibility_distance.seqno+1, GP_BABEL_SEQNO_REQ_HOP_LIMIT);
+ gp_babel_send_seqno_request(ctx, neigh, route, route->feasibility_distance.seqno+1, GP_BABEL_SEQNO_REQ_HOP_LIMIT);
}
#endif /* _GMRF_PROTO_BABEL_BABEL_H_ */