[Olsr-dev] [olsrd] [PATCH v1 16/29] gateway: add some comments
Ferry Huberts
(spam-protected)
Tue Jul 24 18:09:05 CEST 2012
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
src/gateway.h | 47 ++++++++++++++++++++++++++++++++++-------------
1 file changed, 34 insertions(+), 13 deletions(-)
diff --git a/src/gateway.h b/src/gateway.h
index 60b4e70..57b4e2f 100644
--- a/src/gateway.h
+++ b/src/gateway.h
@@ -14,15 +14,20 @@
#include "olsr.h"
#include "scheduler.h"
+/** used to signal to olsr_delete_gateway_entry to force deletion */
#define FORCE_DELETE_GW_ENTRY 255
+
+/** the interval (in milliseconds) on which to run gateway cleanup */
#define GW_CLEANUP_INTERVAL 30000
/*
- * hack for Vienna network to remove 0.0.0.0/128.0.0.0 and 128.0.0.0/128.0.0.0 routes
- * just set MAXIMUM_GATEWAY_PREFIX_LENGTH to 1
+ * hack for Vienna network:
+ * set MAXIMUM_GATEWAY_PREFIX_LENGTH to 1 to remove 0.0.0.0/128.0.0.0 and
+ * 128.0.0.0/128.0.0.0 routes
*/
// #define MAXIMUM_GATEWAY_PREFIX_LENGTH 1
+/** gateway HNA flags */
enum gateway_hna_flags {
GW_HNA_FLAG_LINKSPEED = 1<<0,
GW_HNA_FLAG_IPV4 = 1<<1,
@@ -31,7 +36,7 @@ enum gateway_hna_flags {
GW_HNA_FLAG_IPV6PREFIX = 1<<4
};
-/* relative to the first zero byte in the netmask (0, 1 or 12) */
+/** gateway HNA field byte offsets in the netmask field of the HNA */
enum gateway_hna_fields {
GW_HNA_PAD = 0,
GW_HNA_FLAGS = 1,
@@ -41,19 +46,31 @@ enum gateway_hna_fields {
GW_HNA_V6PREFIX = 5
};
+/** a gateway entry */
struct gateway_entry {
struct avl_node node;
union olsr_ip_addr originator;
struct olsr_ip_prefix external_prefix;
- uint32_t uplink, downlink;
- bool ipv4, ipv4nat, ipv6;
+ uint32_t uplink;
+ uint32_t downlink;
+ bool ipv4;
+ bool ipv4nat;
+ bool ipv6;
struct timer_entry *cleanup_timer;
uint16_t seqno;
};
+/**
+ * static inline struct gateway_entry * node2gateway (struct avl_node *ptr)
+ *
+ * Converts a node into a gateway entry
+ */
AVLNODE2STRUCT(node2gateway, struct gateway_entry, node);
+/**
+ * Loop over all gateway entries and put the iterated gateway entry in gw
+ */
#define OLSR_FOR_ALL_GATEWAY_ENTRIES(gw) \
{ \
struct avl_node *gw_node, *next_gw_node; \
@@ -63,6 +80,7 @@ AVLNODE2STRUCT(node2gateway, struct gateway_entry, node);
gw = node2gateway(gw_node);
#define OLSR_FOR_ALL_GATEWAY_ENTRIES_END(gw) }}
+/** the gateway tree */
extern struct avl_tree gateway_tree;
int olsr_init_gateways(void);
@@ -74,18 +92,21 @@ void olsr_update_gateway_entry(union olsr_ip_addr *originator, union olsr_ip_add
void olsr_delete_gateway_entry(union olsr_ip_addr *originator, uint8_t prefixlen);
void olsr_print_gateway_entries(void);
+/**
+ * The callback list for a gateway plugin
+ */
+struct olsr_gw_handler {
+ void (* handle_startup)(void); /**< the startup callback */
+ void (* select_gateway) (bool ipv4, bool ipv6); /**< the gateway selection callback */
+ void (* handle_update_gw)(struct gateway_entry *); /**< the gateway update callback */
+ void (* handle_delete_gw)(struct gateway_entry *); /**< the gateway deletion callback */
+};
+
+void olsr_set_inetgw_handler(struct olsr_gw_handler *l);
bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6, bool external);
struct gateway_entry *olsr_get_ipv4_inet_gateway(bool *);
struct gateway_entry *olsr_get_ipv6_inet_gateway(bool *);
bool olsr_is_smart_gateway(struct olsr_ip_prefix *prefix, union olsr_ip_addr *net);
void olsr_modifiy_inetgw_netmask(union olsr_ip_addr *mask, int prefixlen);
-struct olsr_gw_handler {
- void (* handle_startup)(void);
- void (* select_gateway) (bool ipv4, bool ipv6);
- void (* handle_update_gw)(struct gateway_entry *);
- void (* handle_delete_gw)(struct gateway_entry *);
-};
-
-void olsr_set_inetgw_handler(struct olsr_gw_handler *l);
#endif /* GATEWAY_H_ */
--
1.7.10.4
More information about the Olsr-dev
mailing list