]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 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 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 19 | */ |
20 | ||
21 | #ifndef OSPF6_LSA_H | |
22 | #define OSPF6_LSA_H | |
23 | ||
508e53e2 | 24 | /* Debug option */ |
1e05838a | 25 | #define OSPF6_LSA_DEBUG 0x01 |
26 | #define OSPF6_LSA_DEBUG_ORIGINATE 0x02 | |
27 | #define OSPF6_LSA_DEBUG_EXAMIN 0x04 | |
28 | #define OSPF6_LSA_DEBUG_FLOOD 0x08 | |
29 | ||
30 | #define IS_OSPF6_DEBUG_LSA(name) \ | |
31 | (ospf6_lstype_debug (htons (OSPF6_LSTYPE_ ## name)) & \ | |
32 | OSPF6_LSA_DEBUG) | |
33 | #define IS_OSPF6_DEBUG_ORIGINATE(name) \ | |
34 | (ospf6_lstype_debug (htons (OSPF6_LSTYPE_ ## name)) & \ | |
35 | OSPF6_LSA_DEBUG_ORIGINATE) | |
36 | #define IS_OSPF6_DEBUG_EXAMIN(name) \ | |
37 | (ospf6_lstype_debug (htons (OSPF6_LSTYPE_ ## name)) & \ | |
38 | OSPF6_LSA_DEBUG_EXAMIN) | |
39 | #define IS_OSPF6_DEBUG_LSA_TYPE(type) \ | |
40 | (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG) | |
41 | #define IS_OSPF6_DEBUG_ORIGINATE_TYPE(type) \ | |
42 | (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG_ORIGINATE) | |
43 | #define IS_OSPF6_DEBUG_EXAMIN_TYPE(type) \ | |
44 | (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG_EXAMIN) | |
45 | #define IS_OSPF6_DEBUG_FLOOD_TYPE(type) \ | |
46 | (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG_FLOOD) | |
718e3744 | 47 | |
48 | /* LSA definition */ | |
49 | ||
508e53e2 | 50 | #define OSPF6_MAX_LSASIZE 4096 |
718e3744 | 51 | |
52 | /* Type */ | |
508e53e2 | 53 | #define OSPF6_LSTYPE_UNKNOWN 0x0000 |
54 | #define OSPF6_LSTYPE_ROUTER 0x2001 | |
55 | #define OSPF6_LSTYPE_NETWORK 0x2002 | |
56 | #define OSPF6_LSTYPE_INTER_PREFIX 0x2003 | |
57 | #define OSPF6_LSTYPE_INTER_ROUTER 0x2004 | |
58 | #define OSPF6_LSTYPE_AS_EXTERNAL 0x4005 | |
59 | #define OSPF6_LSTYPE_GROUP_MEMBERSHIP 0x2006 | |
60 | #define OSPF6_LSTYPE_TYPE_7 0x2007 | |
61 | #define OSPF6_LSTYPE_LINK 0x0008 | |
62 | #define OSPF6_LSTYPE_INTRA_PREFIX 0x2009 | |
63 | #define OSPF6_LSTYPE_SIZE 0x000a | |
718e3744 | 64 | |
65 | /* Masks for LS Type : RFC 2740 A.4.2.1 "LS type" */ | |
66 | #define OSPF6_LSTYPE_UBIT_MASK 0x8000 | |
67 | #define OSPF6_LSTYPE_SCOPE_MASK 0x6000 | |
508e53e2 | 68 | #define OSPF6_LSTYPE_FCODE_MASK 0x1fff |
718e3744 | 69 | |
508e53e2 | 70 | /* LSA scope */ |
6452df09 | 71 | #define OSPF6_SCOPE_LINKLOCAL 0x0000 |
72 | #define OSPF6_SCOPE_AREA 0x2000 | |
73 | #define OSPF6_SCOPE_AS 0x4000 | |
74 | #define OSPF6_SCOPE_RESERVED 0x6000 | |
718e3744 | 75 | |
6452df09 | 76 | /* XXX U-bit handling should be treated here */ |
508e53e2 | 77 | #define OSPF6_LSA_SCOPE(type) \ |
78 | (ntohs (type) & OSPF6_LSTYPE_SCOPE_MASK) | |
718e3744 | 79 | |
80 | /* LSA Header */ | |
abc7ef44 | 81 | #define OSPF6_LSA_HEADER_SIZE 20U |
718e3744 | 82 | struct ospf6_lsa_header |
718e3744 | 83 | { |
84 | u_int16_t age; /* LS age */ | |
85 | u_int16_t type; /* LS type */ | |
86 | u_int32_t id; /* Link State ID */ | |
87 | u_int32_t adv_router; /* Advertising Router */ | |
88 | u_int32_t seqnum; /* LS sequence number */ | |
89 | u_int16_t checksum; /* LS checksum */ | |
90 | u_int16_t length; /* LSA length */ | |
91 | }; | |
92 | ||
508e53e2 | 93 | #define OSPF6_LSA_HEADER_END(h) \ |
94 | ((caddr_t)(h) + sizeof (struct ospf6_lsa_header)) | |
95 | #define OSPF6_LSA_SIZE(h) \ | |
96 | (ntohs (((struct ospf6_lsa_header *) (h))->length)) | |
97 | #define OSPF6_LSA_END(h) \ | |
98 | ((caddr_t)(h) + ntohs (((struct ospf6_lsa_header *) (h))->length)) | |
99 | #define OSPF6_LSA_IS_TYPE(t, L) \ | |
100 | ((L)->header->type == htons (OSPF6_LSTYPE_ ## t) ? 1 : 0) | |
101 | #define OSPF6_LSA_IS_SAME(L1, L2) \ | |
102 | ((L1)->header->adv_router == (L2)->header->adv_router && \ | |
103 | (L1)->header->id == (L2)->header->id && \ | |
104 | (L1)->header->type == (L2)->header->type) | |
105 | #define OSPF6_LSA_IS_MATCH(t, i, a, L) \ | |
106 | ((L)->header->adv_router == (a) && (L)->header->id == (i) && \ | |
107 | (L)->header->type == (t)) | |
108 | #define OSPF6_LSA_IS_DIFFER(L1, L2) ospf6_lsa_is_differ (L1, L2) | |
8551e6da | 109 | #define OSPF6_LSA_IS_MAXAGE(L) (ospf6_lsa_age_current (L) == OSPF_LSA_MAXAGE) |
508e53e2 | 110 | #define OSPF6_LSA_IS_CHANGED(L1, L2) ospf6_lsa_is_changed (L1, L2) |
3b220289 DD |
111 | #define OSPF6_LSA_IS_SEQWRAP(L) ((L)->header->seqnum == htonl(OSPF_MAX_SEQUENCE_NUMBER + 1)) |
112 | ||
718e3744 | 113 | |
114 | struct ospf6_lsa | |
115 | { | |
6452df09 | 116 | char name[64]; /* dump string */ |
718e3744 | 117 | |
a765eb93 | 118 | struct route_node *rn; |
718e3744 | 119 | |
6452df09 | 120 | unsigned char lock; /* reference counter */ |
121 | unsigned char flag; /* special meaning (e.g. floodback) */ | |
718e3744 | 122 | |
6452df09 | 123 | struct timeval birth; /* tv_sec when LS age 0 */ |
6452df09 | 124 | struct timeval originated; /* used by MinLSInterval check */ |
ccb59b11 | 125 | struct timeval received; /* used by MinLSArrival check */ |
126 | struct timeval installed; | |
718e3744 | 127 | |
6452df09 | 128 | struct thread *expire; |
129 | struct thread *refresh; /* For self-originated LSA */ | |
718e3744 | 130 | |
6452df09 | 131 | int retrans_count; |
132 | ||
6452df09 | 133 | struct ospf6_lsdb *lsdb; |
718e3744 | 134 | |
508e53e2 | 135 | /* lsa instance */ |
136 | struct ospf6_lsa_header *header; | |
718e3744 | 137 | }; |
138 | ||
6452df09 | 139 | #define OSPF6_LSA_HEADERONLY 0x01 |
140 | #define OSPF6_LSA_FLOODBACK 0x02 | |
141 | #define OSPF6_LSA_DUPLICATE 0x04 | |
142 | #define OSPF6_LSA_IMPLIEDACK 0x08 | |
ca1f4309 | 143 | #define OSPF6_LSA_UNAPPROVED 0x10 |
3b220289 | 144 | #define OSPF6_LSA_SEQWRAPPED 0x20 |
508e53e2 | 145 | |
6452df09 | 146 | struct ospf6_lsa_handler |
508e53e2 | 147 | { |
1e05838a | 148 | u_int16_t type; /* host byte order */ |
0c083ee9 | 149 | const char *name; |
e68a6767 | 150 | const char *short_name; |
508e53e2 | 151 | int (*show) (struct vty *, struct ospf6_lsa *); |
e68a6767 | 152 | char *(*get_prefix_str) (struct ospf6_lsa *, char *buf, int buflen, int pos); |
1e05838a | 153 | u_char debug; |
508e53e2 | 154 | }; |
155 | ||
2680aa2b | 156 | extern struct ospf6_lsa_handler unknown_handler; |
157 | #define OSPF6_LSA_IS_KNOWN(type) \ | |
158 | (ospf6_get_lsa_handler (type) != &unknown_handler ? 1 : 0) | |
159 | ||
4dfd8aff DW |
160 | extern vector ospf6_lsa_handler_vector; |
161 | ||
508e53e2 | 162 | /* Macro for LSA Origination */ |
1e05838a | 163 | /* addr is (struct prefix *) */ |
164 | #define CONTINUE_IF_ADDRESS_LINKLOCAL(debug,addr) \ | |
508e53e2 | 165 | if (IN6_IS_ADDR_LINKLOCAL (&(addr)->u.prefix6)) \ |
166 | { \ | |
4690c7d7 | 167 | char buf[PREFIX2STR_BUFFER]; \ |
508e53e2 | 168 | prefix2str (addr, buf, sizeof (buf)); \ |
1e05838a | 169 | if (debug) \ |
d1db06fa | 170 | zlog_debug ("Filter out Linklocal: %s", buf); \ |
508e53e2 | 171 | continue; \ |
718e3744 | 172 | } |
173 | ||
1e05838a | 174 | #define CONTINUE_IF_ADDRESS_UNSPECIFIED(debug,addr) \ |
508e53e2 | 175 | if (IN6_IS_ADDR_UNSPECIFIED (&(addr)->u.prefix6)) \ |
176 | { \ | |
4690c7d7 | 177 | char buf[PREFIX2STR_BUFFER]; \ |
508e53e2 | 178 | prefix2str (addr, buf, sizeof (buf)); \ |
1e05838a | 179 | if (debug) \ |
d1db06fa | 180 | zlog_debug ("Filter out Unspecified: %s", buf);\ |
508e53e2 | 181 | continue; \ |
718e3744 | 182 | } |
508e53e2 | 183 | |
1e05838a | 184 | #define CONTINUE_IF_ADDRESS_LOOPBACK(debug,addr) \ |
508e53e2 | 185 | if (IN6_IS_ADDR_LOOPBACK (&(addr)->u.prefix6)) \ |
186 | { \ | |
4690c7d7 | 187 | char buf[PREFIX2STR_BUFFER]; \ |
508e53e2 | 188 | prefix2str (addr, buf, sizeof (buf)); \ |
1e05838a | 189 | if (debug) \ |
d1db06fa | 190 | zlog_debug ("Filter out Loopback: %s", buf); \ |
508e53e2 | 191 | continue; \ |
718e3744 | 192 | } |
508e53e2 | 193 | |
1e05838a | 194 | #define CONTINUE_IF_ADDRESS_V4COMPAT(debug,addr) \ |
508e53e2 | 195 | if (IN6_IS_ADDR_V4COMPAT (&(addr)->u.prefix6)) \ |
196 | { \ | |
4690c7d7 | 197 | char buf[PREFIX2STR_BUFFER]; \ |
508e53e2 | 198 | prefix2str (addr, buf, sizeof (buf)); \ |
1e05838a | 199 | if (debug) \ |
d1db06fa | 200 | zlog_debug ("Filter out V4Compat: %s", buf); \ |
508e53e2 | 201 | continue; \ |
718e3744 | 202 | } |
203 | ||
1e05838a | 204 | #define CONTINUE_IF_ADDRESS_V4MAPPED(debug,addr) \ |
508e53e2 | 205 | if (IN6_IS_ADDR_V4MAPPED (&(addr)->u.prefix6)) \ |
206 | { \ | |
4690c7d7 | 207 | char buf[PREFIX2STR_BUFFER]; \ |
508e53e2 | 208 | prefix2str (addr, buf, sizeof (buf)); \ |
1e05838a | 209 | if (debug) \ |
d1db06fa | 210 | zlog_debug ("Filter out V4Mapped: %s", buf); \ |
508e53e2 | 211 | continue; \ |
212 | } | |
718e3744 | 213 | |
6b0655a2 | 214 | |
718e3744 | 215 | /* Function Prototypes */ |
6ac29a51 | 216 | extern const char *ospf6_lstype_name (u_int16_t type); |
e68a6767 | 217 | extern const char *ospf6_lstype_short_name (u_int16_t type); |
6ac29a51 PJ |
218 | extern u_char ospf6_lstype_debug (u_int16_t type); |
219 | extern int ospf6_lsa_is_differ (struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2); | |
220 | extern int ospf6_lsa_is_changed (struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2); | |
221 | extern u_int16_t ospf6_lsa_age_current (struct ospf6_lsa *); | |
222 | extern void ospf6_lsa_age_update_to_send (struct ospf6_lsa *, u_int32_t); | |
223 | extern void ospf6_lsa_premature_aging (struct ospf6_lsa *); | |
224 | extern int ospf6_lsa_compare (struct ospf6_lsa *, struct ospf6_lsa *); | |
225 | ||
226 | extern char *ospf6_lsa_printbuf (struct ospf6_lsa *lsa, char *buf, int size); | |
227 | extern void ospf6_lsa_header_print_raw (struct ospf6_lsa_header *header); | |
228 | extern void ospf6_lsa_header_print (struct ospf6_lsa *lsa); | |
229 | extern void ospf6_lsa_show_summary_header (struct vty *vty); | |
230 | extern void ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa); | |
231 | extern void ospf6_lsa_show_dump (struct vty *vty, struct ospf6_lsa *lsa); | |
232 | extern void ospf6_lsa_show_internal (struct vty *vty, struct ospf6_lsa *lsa); | |
233 | extern void ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa); | |
234 | ||
235 | extern struct ospf6_lsa *ospf6_lsa_create (struct ospf6_lsa_header *header); | |
236 | extern struct ospf6_lsa *ospf6_lsa_create_headeronly (struct ospf6_lsa_header *header); | |
237 | extern void ospf6_lsa_delete (struct ospf6_lsa *lsa); | |
238 | extern struct ospf6_lsa *ospf6_lsa_copy (struct ospf6_lsa *); | |
239 | ||
240 | extern void ospf6_lsa_lock (struct ospf6_lsa *); | |
241 | extern void ospf6_lsa_unlock (struct ospf6_lsa *); | |
242 | ||
243 | extern int ospf6_lsa_expire (struct thread *); | |
244 | extern int ospf6_lsa_refresh (struct thread *); | |
245 | ||
246 | extern unsigned short ospf6_lsa_checksum (struct ospf6_lsa_header *); | |
d8a4e42b | 247 | extern int ospf6_lsa_checksum_valid (struct ospf6_lsa_header *); |
6ac29a51 PJ |
248 | extern int ospf6_lsa_prohibited_duration (u_int16_t type, u_int32_t id, |
249 | u_int32_t adv_router, void *scope); | |
250 | ||
251 | extern void ospf6_install_lsa_handler (struct ospf6_lsa_handler *handler); | |
252 | extern struct ospf6_lsa_handler *ospf6_get_lsa_handler (u_int16_t type); | |
253 | ||
254 | extern void ospf6_lsa_init (void); | |
ae2254aa | 255 | extern void ospf6_lsa_terminate (void); |
6ac29a51 PJ |
256 | |
257 | extern int config_write_ospf6_debug_lsa (struct vty *vty); | |
258 | extern void install_element_ospf6_debug_lsa (void); | |
718e3744 | 259 | |
260 | #endif /* OSPF6_LSA_H */ | |
261 |