paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1999 Yasuhiro Ohara |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | * Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #ifndef OSPF6_ROUTE_H |
| 23 | #define OSPF6_ROUTE_H |
| 24 | |
| 25 | #include "ospf6_hook.h" |
| 26 | #include "ospf6_linklist.h" |
| 27 | |
| 28 | struct ospf6_route_table |
| 29 | { |
| 30 | char name[128]; |
| 31 | |
| 32 | int freeze; |
| 33 | |
| 34 | /* radix tree */ |
| 35 | struct route_table *table; |
| 36 | |
| 37 | /* list of hooks */ |
| 38 | struct linklist *hook_list[3]; |
| 39 | void (*hook_add) (void *); |
| 40 | void (*hook_change) (void *); |
| 41 | void (*hook_remove) (void *); |
| 42 | |
| 43 | u_int32_t route_id; |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | |
| 48 | struct ospf6_route |
| 49 | { |
| 50 | /* Destination ID */ |
| 51 | struct prefix prefix; |
| 52 | |
| 53 | /* Destination Type */ |
| 54 | u_char type; |
| 55 | }; |
| 56 | |
| 57 | /* Path */ |
| 58 | struct ls_origin |
| 59 | { |
| 60 | u_int16_t type; |
| 61 | u_int32_t id; |
| 62 | u_int32_t adv_router; |
| 63 | }; |
| 64 | |
| 65 | struct ospf6_path |
| 66 | { |
| 67 | /* Link State Origin */ |
| 68 | struct ls_origin origin; |
| 69 | |
| 70 | /* Router bits */ |
| 71 | u_char router_bits; |
| 72 | |
| 73 | /* Optional Capabilities */ |
| 74 | u_char capability[3]; |
| 75 | |
| 76 | /* Prefix Options */ |
| 77 | u_char prefix_options; |
| 78 | |
| 79 | /* Associated Area */ |
| 80 | u_int32_t area_id; |
| 81 | |
| 82 | /* Path-type */ |
| 83 | u_char type; |
| 84 | |
| 85 | /* Cost */ |
| 86 | u_int8_t metric_type; |
| 87 | u_int32_t cost; |
| 88 | u_int32_t cost_e2; |
| 89 | }; |
| 90 | |
| 91 | /* Nexthop */ |
| 92 | struct ospf6_nexthop |
| 93 | { |
| 94 | /* Interface index */ |
| 95 | unsigned int ifindex; |
| 96 | |
| 97 | /* IP address, if any */ |
| 98 | struct in6_addr address; |
| 99 | }; |
| 100 | |
| 101 | struct ospf6_route_node |
| 102 | { |
| 103 | struct ospf6_route_table *table; |
| 104 | int count; |
| 105 | u_int32_t route_id; |
| 106 | |
| 107 | struct route_node *route_node; |
| 108 | struct ospf6_route route; |
| 109 | struct linklist *path_list; |
| 110 | }; |
| 111 | |
| 112 | struct ospf6_path_node |
| 113 | { |
| 114 | struct ospf6_route_node *route_node; |
| 115 | struct ospf6_path path; |
| 116 | struct linklist *nexthop_list; |
| 117 | }; |
| 118 | |
| 119 | struct ospf6_nexthop_node |
| 120 | { |
| 121 | int flag; |
| 122 | struct timeval installed; |
| 123 | |
| 124 | struct ospf6_path_node *path_node; |
| 125 | struct ospf6_nexthop nexthop; |
| 126 | }; |
| 127 | |
| 128 | struct ospf6_route_req |
| 129 | { |
| 130 | struct ospf6_route_table *table; |
| 131 | struct route_node *route_node; |
| 132 | struct linklist_node path_lnode; |
| 133 | struct linklist_node nexthop_lnode; |
| 134 | u_int32_t route_id; |
| 135 | |
| 136 | int count; |
| 137 | struct ospf6_route route; |
| 138 | struct ospf6_path path; |
| 139 | struct ospf6_nexthop nexthop; |
| 140 | }; |
| 141 | |
| 142 | #define OSPF6_DEST_TYPE_NONE 0 |
| 143 | #define OSPF6_DEST_TYPE_ROUTER 1 |
| 144 | #define OSPF6_DEST_TYPE_NETWORK 2 |
| 145 | #define OSPF6_DEST_TYPE_DISCARD 3 |
| 146 | #define OSPF6_DEST_TYPE_MAX 4 |
| 147 | |
| 148 | #define OSPF6_PATH_TYPE_NONE 0 |
| 149 | #define OSPF6_PATH_TYPE_INTRA 1 |
| 150 | #define OSPF6_PATH_TYPE_INTER 2 |
| 151 | #define OSPF6_PATH_TYPE_EXTERNAL1 3 |
| 152 | #define OSPF6_PATH_TYPE_EXTERNAL2 4 |
| 153 | #define OSPF6_PATH_TYPE_ZOFFSET 5 |
| 154 | #define OSPF6_PATH_TYPE_ZSYSTEM (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_SYSTEM) |
| 155 | #define OSPF6_PATH_TYPE_ZKERNEL (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_KERNEL) |
| 156 | #define OSPF6_PATH_TYPE_ZCONNECT (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_CONNECT) |
| 157 | #define OSPF6_PATH_TYPE_ZSTATIC (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_STATIC) |
| 158 | #define OSPF6_PATH_TYPE_ZRIP (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_RIP) |
| 159 | #define OSPF6_PATH_TYPE_ZRIPNG (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_RIPNG) |
| 160 | #define OSPF6_PATH_TYPE_ZOSPF (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_OSPF) |
| 161 | #define OSPF6_PATH_TYPE_ZOSPF6 (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_OSPF6) |
| 162 | #define OSPF6_PATH_TYPE_ZBGP (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_BGP) |
| 163 | #define OSPF6_PATH_TYPE_MAX (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_MAX) |
| 164 | |
| 165 | #define OSPF6_ROUTE_FLAG_ROUTE_CHANGE 0x01 |
| 166 | #define OSPF6_ROUTE_FLAG_PATH_CHANGE 0x02 |
| 167 | #define OSPF6_ROUTE_FLAG_ADD 0x04 |
| 168 | #define OSPF6_ROUTE_FLAG_REMOVE 0x08 |
| 169 | #define OSPF6_ROUTE_FLAG_CHANGE 0x10 |
| 170 | |
| 171 | int ospf6_route_lookup (struct ospf6_route_req *request, |
| 172 | struct prefix *prefix, |
| 173 | struct ospf6_route_table *table); |
| 174 | void ospf6_route_head (struct ospf6_route_req *request, |
| 175 | struct ospf6_route_table *table); |
| 176 | int ospf6_route_end (struct ospf6_route_req *request); |
| 177 | void ospf6_route_next (struct ospf6_route_req *request); |
| 178 | |
| 179 | void ospf6_route_add (struct ospf6_route_req *, struct ospf6_route_table *); |
| 180 | void ospf6_route_remove (struct ospf6_route_req *, struct ospf6_route_table *); |
| 181 | void ospf6_route_remove_all (struct ospf6_route_table *); |
| 182 | |
| 183 | struct ospf6_route_table *ospf6_route_table_create (); |
| 184 | void ospf6_route_table_delete (struct ospf6_route_table *); |
| 185 | |
| 186 | void ospf6_route_table_freeze (struct ospf6_route_table *); |
| 187 | void ospf6_route_table_thaw (struct ospf6_route_table *); |
| 188 | |
| 189 | void ospf6_route_log_request (char *what, char *where, |
| 190 | struct ospf6_route_req *request); |
| 191 | |
| 192 | void |
| 193 | ospf6_route_hook_register (void (*add) (struct ospf6_route_req *), |
| 194 | void (*change) (struct ospf6_route_req *), |
| 195 | void (*remove) (struct ospf6_route_req *), |
| 196 | struct ospf6_route_table *table); |
| 197 | void |
| 198 | ospf6_route_hook_unregister (void (*add) (struct ospf6_route_req *), |
| 199 | void (*change) (struct ospf6_route_req *), |
| 200 | void (*remove) (struct ospf6_route_req *), |
| 201 | struct ospf6_route_table *table); |
| 202 | |
| 203 | void ospf6_route_init (); |
| 204 | |
| 205 | int ospf6_route_table_show (struct vty *, int, char **, |
| 206 | struct ospf6_route_table *); |
| 207 | |
| 208 | #endif /* OSPF6_ROUTE_H */ |
| 209 | |