paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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_INTRA_H |
| 23 | #define OSPF6_INTRA_H |
| 24 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 25 | /* Router-LSA */ |
| 26 | struct ospf6_router_lsa |
| 27 | { |
| 28 | u_char bits; |
| 29 | u_char options[3]; |
| 30 | /* followed by ospf6_router_lsdesc(s) */ |
| 31 | }; |
| 32 | |
| 33 | /* Link State Description in Router-LSA */ |
| 34 | struct ospf6_router_lsdesc |
| 35 | { |
| 36 | u_char type; |
| 37 | u_char reserved; |
| 38 | u_int16_t metric; /* output cost */ |
| 39 | u_int32_t interface_id; |
| 40 | u_int32_t neighbor_interface_id; |
| 41 | u_int32_t neighbor_router_id; |
| 42 | }; |
| 43 | |
| 44 | #define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1 |
| 45 | #define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2 |
| 46 | #define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3 |
| 47 | #define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4 |
| 48 | |
| 49 | #define ROUTER_LSDESC_IS_TYPE(t,x) \ |
| 50 | ((((struct ospf6_router_lsdesc *)(x))->type == \ |
| 51 | OSPF6_ROUTER_LSDESC_ ## t) ? 1 : 0) |
| 52 | #define ROUTER_LSDESC_GET_METRIC(x) \ |
| 53 | (ntohs (((struct ospf6_router_lsdesc *)(x))->metric)) |
| 54 | #define ROUTER_LSDESC_GET_IFID(x) \ |
| 55 | (ntohl (((struct ospf6_router_lsdesc *)(x))->interface_id)) |
| 56 | #define ROUTER_LSDESC_GET_NBR_IFID(x) \ |
| 57 | (ntohl (((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id)) |
| 58 | #define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \ |
| 59 | (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id) |
| 60 | |
| 61 | /* Network-LSA */ |
| 62 | struct ospf6_network_lsa |
| 63 | { |
| 64 | u_char reserved; |
| 65 | u_char options[3]; |
| 66 | /* followed by ospf6_netowrk_lsd(s) */ |
| 67 | }; |
| 68 | |
| 69 | /* Link State Description in Router-LSA */ |
| 70 | struct ospf6_network_lsdesc |
| 71 | { |
| 72 | u_int32_t router_id; |
| 73 | }; |
| 74 | #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \ |
| 75 | (((struct ospf6_network_lsdesc *)(x))->router_id) |
| 76 | |
| 77 | /* Link-LSA */ |
| 78 | struct ospf6_link_lsa |
| 79 | { |
| 80 | u_char priority; |
| 81 | u_char options[3]; |
| 82 | struct in6_addr linklocal_addr; |
| 83 | u_int32_t prefix_num; |
| 84 | /* followed by ospf6 prefix(es) */ |
| 85 | }; |
| 86 | |
| 87 | /* Intra-Area-Prefix-LSA */ |
| 88 | struct ospf6_intra_prefix_lsa |
| 89 | { |
| 90 | u_int16_t prefix_num; |
| 91 | u_int16_t ref_type; |
| 92 | u_int32_t ref_id; |
| 93 | u_int32_t ref_adv_router; |
| 94 | /* followed by ospf6 prefix(es) */ |
| 95 | }; |
| 96 | |
| 97 | |
| 98 | #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \ |
| 99 | do { \ |
| 100 | if (! (oa)->thread_router_lsa) \ |
| 101 | (oa)->thread_router_lsa = \ |
| 102 | thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \ |
| 103 | } while (0) |
| 104 | #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \ |
| 105 | do { \ |
| 106 | if (! (oi)->thread_network_lsa) \ |
| 107 | (oi)->thread_network_lsa = \ |
| 108 | thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \ |
| 109 | } while (0) |
| 110 | #define OSPF6_LINK_LSA_SCHEDULE(oi) \ |
| 111 | do { \ |
| 112 | if (! (oi)->thread_link_lsa) \ |
| 113 | (oi)->thread_link_lsa = \ |
| 114 | thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \ |
| 115 | } while (0) |
| 116 | #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \ |
| 117 | do { \ |
| 118 | if (! (oa)->thread_intra_prefix_lsa) \ |
| 119 | (oa)->thread_intra_prefix_lsa = \ |
| 120 | thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \ |
| 121 | oa, 0); \ |
| 122 | } while (0) |
| 123 | #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \ |
| 124 | do { \ |
| 125 | if (! (oi)->thread_intra_prefix_lsa) \ |
| 126 | (oi)->thread_intra_prefix_lsa = \ |
| 127 | thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \ |
| 128 | oi, 0); \ |
| 129 | } while (0) |
| 130 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 131 | #define OSPF6_NETWORK_LSA_EXECUTE(oi) \ |
| 132 | do { \ |
| 133 | THREAD_OFF ((oi)->thread_network_lsa); \ |
| 134 | thread_execute (master, ospf6_network_lsa_originate, oi, 0); \ |
| 135 | } while (0) |
| 136 | #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \ |
| 137 | do { \ |
| 138 | THREAD_OFF ((oi)->thread_intra_prefix_lsa); \ |
| 139 | thread_execute (master, ospf6_intra_prefix_lsa_originate_transit, oi, 0); \ |
| 140 | } while (0) |
| 141 | |
| 142 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 143 | /* Function Prototypes */ |
| 144 | char *ospf6_router_lsdesc_lookup (u_char type, u_int32_t interface_id, |
| 145 | u_int32_t neighbor_interface_id, |
| 146 | u_int32_t neighbor_router_id, |
| 147 | struct ospf6_lsa *lsa); |
| 148 | char *ospf6_network_lsdesc_lookup (u_int32_t router_id, |
| 149 | struct ospf6_lsa *lsa); |
| 150 | |
| 151 | int ospf6_router_lsa_originate (struct thread *); |
| 152 | int ospf6_network_lsa_originate (struct thread *); |
| 153 | int ospf6_link_lsa_originate (struct thread *); |
| 154 | int ospf6_intra_prefix_lsa_originate_transit (struct thread *); |
| 155 | int ospf6_intra_prefix_lsa_originate_stub (struct thread *); |
| 156 | void ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa); |
| 157 | void ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa); |
| 158 | |
| 159 | void ospf6_intra_route_calculation (struct ospf6_area *oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 160 | void ospf6_intra_brouter_calculation (struct ospf6_area *oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | |
| 162 | void ospf6_intra_init (); |
| 163 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 164 | #endif /* OSPF6_LSA_H */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | |