summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_route.h
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_route.h')
-rw-r--r--ospf6d/ospf6_route.h294
1 files changed, 173 insertions, 121 deletions
diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h
index 71b2562b..834774c3 100644
--- a/ospf6d/ospf6_route.h
+++ b/ospf6d/ospf6_route.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1999 Yasuhiro Ohara
+ * Copyright (C) 2003 Yasuhiro Ohara
*
* This file is part of GNU Zebra.
*
@@ -22,40 +22,49 @@
#ifndef OSPF6_ROUTE_H
#define OSPF6_ROUTE_H
-#include "ospf6_hook.h"
-#include "ospf6_linklist.h"
+#define OSPF6_MULTI_PATH_LIMIT 4
-struct ospf6_route_table
-{
- char name[128];
-
- int freeze;
-
- /* radix tree */
- struct route_table *table;
-
- /* list of hooks */
- struct linklist *hook_list[3];
- void (*hook_add) (void *);
- void (*hook_change) (void *);
- void (*hook_remove) (void *);
-
- u_int32_t route_id;
-};
-
-
+/* Debug option */
+extern unsigned char conf_debug_ospf6_route;
+#define OSPF6_DEBUG_ROUTE_TABLE 0x01
+#define OSPF6_DEBUG_ROUTE_INTRA 0x02
+#define OSPF6_DEBUG_ROUTE_INTER 0x04
+#define OSPF6_DEBUG_ROUTE_ON(level) \
+ (conf_debug_ospf6_route |= (level))
+#define OSPF6_DEBUG_ROUTE_OFF(level) \
+ (conf_debug_ospf6_route &= ~(level))
+#define IS_OSPF6_DEBUG_ROUTE(e) \
+ (conf_debug_ospf6_route & OSPF6_DEBUG_ROUTE_ ## e)
-struct ospf6_route
+/* Nexthop */
+struct ospf6_nexthop
{
- /* Destination ID */
- struct prefix prefix;
+ /* Interface index */
+ unsigned int ifindex;
- /* Destination Type */
- u_char type;
+ /* IP address, if any */
+ struct in6_addr address;
};
+#define ospf6_nexthop_is_set(x) \
+ ((x)->ifindex || ! IN6_IS_ADDR_UNSPECIFIED (&(x)->address))
+#define ospf6_nexthop_is_same(a,b) \
+ ((a)->ifindex == (b)->ifindex && \
+ IN6_ARE_ADDR_EQUAL (&(a)->address, &(b)->address))
+#define ospf6_nexthop_clear(x) \
+ do { \
+ (x)->ifindex = 0; \
+ memset (&(x)->address, 0, sizeof (struct in6_addr)); \
+ } while (0)
+#define ospf6_nexthop_copy(a, b) \
+ do { \
+ (a)->ifindex = (b)->ifindex; \
+ memcpy (&(a)->address, &(b)->address, \
+ sizeof (struct in6_addr)); \
+ } while (0)
+
/* Path */
-struct ls_origin
+struct ospf6_ls_origin
{
u_int16_t type;
u_int32_t id;
@@ -65,13 +74,13 @@ struct ls_origin
struct ospf6_path
{
/* Link State Origin */
- struct ls_origin origin;
+ struct ospf6_ls_origin origin;
/* Router bits */
u_char router_bits;
/* Optional Capabilities */
- u_char capability[3];
+ u_char options[3];
/* Prefix Options */
u_char prefix_options;
@@ -88,122 +97,165 @@ struct ospf6_path
u_int32_t cost_e2;
};
-/* Nexthop */
-struct ospf6_nexthop
-{
- /* Interface index */
- unsigned int ifindex;
+#define OSPF6_PATH_TYPE_NONE 0
+#define OSPF6_PATH_TYPE_INTRA 1
+#define OSPF6_PATH_TYPE_INTER 2
+#define OSPF6_PATH_TYPE_EXTERNAL1 3
+#define OSPF6_PATH_TYPE_EXTERNAL2 4
+#define OSPF6_PATH_TYPE_MAX 5
- /* IP address, if any */
- struct in6_addr address;
-};
+#include "prefix.h"
+#include "table.h"
-struct ospf6_route_node
+struct ospf6_route
{
- struct ospf6_route_table *table;
- int count;
- u_int32_t route_id;
+ struct route_node *rnode;
- struct route_node *route_node;
- struct ospf6_route route;
- struct linklist *path_list;
-};
+ struct ospf6_route *prev;
+ struct ospf6_route *next;
-struct ospf6_path_node
-{
- struct ospf6_route_node *route_node;
- struct ospf6_path path;
- struct linklist *nexthop_list;
-};
+ unsigned int lock;
-struct ospf6_nexthop_node
-{
- int flag;
+ /* Destination Type */
+ u_char type;
+
+ /* Destination ID */
+ struct prefix prefix;
+
+ /* Time */
struct timeval installed;
+ struct timeval changed;
- struct ospf6_path_node *path_node;
- struct ospf6_nexthop nexthop;
-};
+ /* flag */
+ u_char flag;
-struct ospf6_route_req
-{
- struct ospf6_route_table *table;
- struct route_node *route_node;
- struct linklist_node path_lnode;
- struct linklist_node nexthop_lnode;
- u_int32_t route_id;
-
- int count;
- struct ospf6_route route;
- struct ospf6_path path;
- struct ospf6_nexthop nexthop;
+ /* path */
+ struct ospf6_path path;
+
+ /* nexthop */
+ struct ospf6_nexthop nexthop[OSPF6_MULTI_PATH_LIMIT];
+
+ /* route option */
+ void *route_option;
};
#define OSPF6_DEST_TYPE_NONE 0
#define OSPF6_DEST_TYPE_ROUTER 1
#define OSPF6_DEST_TYPE_NETWORK 2
#define OSPF6_DEST_TYPE_DISCARD 3
-#define OSPF6_DEST_TYPE_MAX 4
+#define OSPF6_DEST_TYPE_LINKSTATE 4
+#define OSPF6_DEST_TYPE_MAX 5
-#define OSPF6_PATH_TYPE_NONE 0
-#define OSPF6_PATH_TYPE_INTRA 1
-#define OSPF6_PATH_TYPE_INTER 2
-#define OSPF6_PATH_TYPE_EXTERNAL1 3
-#define OSPF6_PATH_TYPE_EXTERNAL2 4
-#define OSPF6_PATH_TYPE_ZOFFSET 5
-#define OSPF6_PATH_TYPE_ZSYSTEM (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_SYSTEM)
-#define OSPF6_PATH_TYPE_ZKERNEL (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_KERNEL)
-#define OSPF6_PATH_TYPE_ZCONNECT (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_CONNECT)
-#define OSPF6_PATH_TYPE_ZSTATIC (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_STATIC)
-#define OSPF6_PATH_TYPE_ZRIP (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_RIP)
-#define OSPF6_PATH_TYPE_ZRIPNG (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_RIPNG)
-#define OSPF6_PATH_TYPE_ZOSPF (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_OSPF)
-#define OSPF6_PATH_TYPE_ZOSPF6 (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_OSPF6)
-#define OSPF6_PATH_TYPE_ZBGP (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_BGP)
-#define OSPF6_PATH_TYPE_MAX (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_MAX)
-
-#define OSPF6_ROUTE_FLAG_ROUTE_CHANGE 0x01
-#define OSPF6_ROUTE_FLAG_PATH_CHANGE 0x02
-#define OSPF6_ROUTE_FLAG_ADD 0x04
-#define OSPF6_ROUTE_FLAG_REMOVE 0x08
-#define OSPF6_ROUTE_FLAG_CHANGE 0x10
-
-int ospf6_route_lookup (struct ospf6_route_req *request,
- struct prefix *prefix,
- struct ospf6_route_table *table);
-void ospf6_route_head (struct ospf6_route_req *request,
- struct ospf6_route_table *table);
-int ospf6_route_end (struct ospf6_route_req *request);
-void ospf6_route_next (struct ospf6_route_req *request);
-
-void ospf6_route_add (struct ospf6_route_req *, struct ospf6_route_table *);
-void ospf6_route_remove (struct ospf6_route_req *, struct ospf6_route_table *);
-void ospf6_route_remove_all (struct ospf6_route_table *);
+#define OSPF6_ROUTE_CHANGE 0x01
+#define OSPF6_ROUTE_ADD 0x02
+#define OSPF6_ROUTE_REMOVE 0x04
+#define OSPF6_ROUTE_BEST 0x08
-struct ospf6_route_table *ospf6_route_table_create ();
-void ospf6_route_table_delete (struct ospf6_route_table *);
+struct ospf6_route_table
+{
+ /* patricia tree */
+ struct route_table *table;
-void ospf6_route_table_freeze (struct ospf6_route_table *);
-void ospf6_route_table_thaw (struct ospf6_route_table *);
+ u_int32_t count;
-void ospf6_route_log_request (char *what, char *where,
- struct ospf6_route_req *request);
+ /* hooks */
+ void (*hook_add) (struct ospf6_route *);
+ void (*hook_change) (struct ospf6_route *);
+ void (*hook_remove) (struct ospf6_route *);
+};
+extern char *ospf6_dest_type_str[OSPF6_DEST_TYPE_MAX];
+extern char *ospf6_dest_type_substr[OSPF6_DEST_TYPE_MAX];
+#define OSPF6_DEST_TYPE_NAME(x) \
+ (0 < (x) && (x) < OSPF6_DEST_TYPE_MAX ? \
+ ospf6_dest_type_str[(x)] : ospf6_dest_type_str[0])
+#define OSPF6_DEST_TYPE_SUBSTR(x) \
+ (0 < (x) && (x) < OSPF6_DEST_TYPE_MAX ? \
+ ospf6_dest_type_substr[(x)] : ospf6_dest_type_substr[0])
+
+extern char *ospf6_path_type_str[OSPF6_PATH_TYPE_MAX];
+extern char *ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX];
+#define OSPF6_PATH_TYPE_NAME(x) \
+ (0 < (x) && (x) < OSPF6_PATH_TYPE_MAX ? \
+ ospf6_path_type_str[(x)] : ospf6_path_type_str[0])
+#define OSPF6_PATH_TYPE_SUBSTR(x) \
+ (0 < (x) && (x) < OSPF6_PATH_TYPE_MAX ? \
+ ospf6_path_type_substr[(x)] : ospf6_path_type_substr[0])
+
+#define OSPF6_ROUTE_ADDRESS_STR "Display the route bestmatches the address\n"
+#define OSPF6_ROUTE_PREFIX_STR "Display the route\n"
+#define OSPF6_ROUTE_MATCH_STR "Display the route matches the prefix\n"
+
+#define ospf6_route_is_prefix(p, r) \
+ (memcmp (p, &(r)->prefix, sizeof (struct prefix)) == 0)
+#define ospf6_route_is_same(ra, rb) \
+ (prefix_same (&(ra)->prefix, &(rb)->prefix))
+#define ospf6_route_is_same_origin(ra, rb) \
+ ((ra)->path.area_id == (rb)->path.area_id && \
+ memcmp (&(ra)->path.origin, &(rb)->path.origin, \
+ sizeof (struct ospf6_ls_origin)) == 0)
+#define ospf6_route_is_identical(ra, rb) \
+ ((ra)->type == (rb)->type && \
+ memcmp (&(ra)->prefix, &(rb)->prefix, sizeof (struct prefix)) == 0 && \
+ memcmp (&(ra)->path, &(rb)->path, sizeof (struct ospf6_path)) == 0 && \
+ memcmp (&(ra)->nexthop, &(rb)->nexthop, \
+ sizeof (struct ospf6_nexthop) * OSPF6_MULTI_PATH_LIMIT) == 0)
+#define ospf6_route_is_best(r) (CHECK_FLAG ((r)->flag, OSPF6_ROUTE_BEST))
+
+#define ospf6_linkstate_prefix_adv_router(x) \
+ (*(u_int32_t *)(&(x)->u.prefix6.s6_addr[0]))
+#define ospf6_linkstate_prefix_id(x) \
+ (*(u_int32_t *)(&(x)->u.prefix6.s6_addr[4]))
+
+/* Function prototype */
+void ospf6_linkstate_prefix (u_int32_t adv_router, u_int32_t id,
+ struct prefix *prefix);
+void ospf6_linkstate_prefix2str (struct prefix *prefix, char *buf, int size);
+
+struct ospf6_route *ospf6_route_create ();
+void ospf6_route_delete (struct ospf6_route *);
+struct ospf6_route *ospf6_route_copy (struct ospf6_route *route);
+
+void ospf6_route_lock (struct ospf6_route *route);
+void ospf6_route_unlock (struct ospf6_route *route);
+
+struct ospf6_route *
+ospf6_route_lookup (struct prefix *prefix,
+ struct ospf6_route_table *table);
+struct ospf6_route *
+ospf6_route_lookup_identical (struct ospf6_route *route,
+ struct ospf6_route_table *table);
+struct ospf6_route *
+ospf6_route_lookup_bestmatch (struct prefix *prefix,
+ struct ospf6_route_table *table);
+
+struct ospf6_route *
+ospf6_route_add (struct ospf6_route *route, struct ospf6_route_table *table);
void
-ospf6_route_hook_register (void (*add) (struct ospf6_route_req *),
- void (*change) (struct ospf6_route_req *),
- void (*remove) (struct ospf6_route_req *),
- struct ospf6_route_table *table);
-void
-ospf6_route_hook_unregister (void (*add) (struct ospf6_route_req *),
- void (*change) (struct ospf6_route_req *),
- void (*remove) (struct ospf6_route_req *),
- struct ospf6_route_table *table);
+ospf6_route_remove (struct ospf6_route *route, struct ospf6_route_table *table);
-void ospf6_route_init ();
+struct ospf6_route *ospf6_route_head (struct ospf6_route_table *table);
+struct ospf6_route *ospf6_route_next (struct ospf6_route *route);
+struct ospf6_route *ospf6_route_best_next (struct ospf6_route *route);
+
+struct ospf6_route *ospf6_route_match_head (struct prefix *prefix,
+ struct ospf6_route_table *table);
+struct ospf6_route *ospf6_route_match_next (struct prefix *prefix,
+ struct ospf6_route *route);
+
+void ospf6_route_remove_all (struct ospf6_route_table *);
+struct ospf6_route_table *ospf6_route_table_create ();
+void ospf6_route_table_delete (struct ospf6_route_table *);
+void ospf6_route_dump (struct ospf6_route_table *table);
int ospf6_route_table_show (struct vty *, int, char **,
struct ospf6_route_table *);
+int ospf6_lsentry_table_show (struct vty *, int, char **,
+ struct ospf6_route_table *);
+
+int config_write_ospf6_debug_route (struct vty *vty);
+void install_element_ospf6_debug_route ();
+void ospf6_route_init ();
#endif /* OSPF6_ROUTE_H */