]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * This is an implementation of rfc2370. | |
3 | * Copyright (C) 2001 KDD R&D Laboratories, Inc. | |
4 | * http://www.kddlabs.co.jp/ | |
5 | * | |
6 | * This file is part of GNU Zebra. | |
7 | * | |
8 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
896014f4 | 12 | * |
718e3744 | 13 | * GNU Zebra is distributed in the hope that it will be useful, but |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
896014f4 DL |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; see the file COPYING; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 21 | */ |
22 | ||
23 | #ifndef _ZEBRA_OSPF_OPAQUE_H | |
24 | #define _ZEBRA_OSPF_OPAQUE_H | |
25 | ||
4dadc291 | 26 | #include "vty.h" |
f328dc60 | 27 | #include <lib/json.h> |
4dadc291 | 28 | |
d62a17ae | 29 | #define IS_OPAQUE_LSA(type) \ |
30 | ((type) == OSPF_OPAQUE_LINK_LSA || (type) == OSPF_OPAQUE_AREA_LSA \ | |
31 | || (type) == OSPF_OPAQUE_AS_LSA) | |
718e3744 | 32 | |
718e3744 | 33 | /* |
34 | * Opaque LSA's link state ID is redefined as follows. | |
35 | * | |
36 | * 24 16 8 0 | |
37 | * +--------+--------+--------+--------+ | |
38 | * |tttttttt|........|........|........| | |
39 | * +--------+--------+--------+--------+ | |
40 | * |<-Type->|<------- Opaque ID ------>| | |
41 | */ | |
42 | #define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */ | |
43 | #define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */ | |
44 | ||
d7c0a89a | 45 | #define GET_OPAQUE_TYPE(lsid) (((uint32_t)(lsid)&LSID_OPAQUE_TYPE_MASK) >> 24) |
718e3744 | 46 | |
d7c0a89a | 47 | #define GET_OPAQUE_ID(lsid) ((uint32_t)(lsid)&LSID_OPAQUE_ID_MASK) |
718e3744 | 48 | |
d62a17ae | 49 | #define SET_OPAQUE_LSID(type, id) \ |
937652c6 | 50 | ((((unsigned)(type) << 24) & LSID_OPAQUE_TYPE_MASK) \ |
996c9314 | 51 | | ((id)&LSID_OPAQUE_ID_MASK)) |
718e3744 | 52 | |
53 | /* | |
54 | * Opaque LSA types will be assigned by IANA. | |
55 | * <http://www.iana.org/assignments/ospf-opaque-types> | |
56 | */ | |
57 | #define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1 | |
58 | #define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2 | |
59 | #define OPAQUE_TYPE_GRACE_LSA 3 | |
16f1b9ee OD |
60 | #define OPAQUE_TYPE_L1VPN_LSA 5 |
61 | #define OPAQUE_TYPE_ROUTER_INFORMATION_LSA 4 | |
62 | #define OPAQUE_TYPE_INTER_AS_LSA 6 | |
cf9b9f77 OD |
63 | #define OPAQUE_TYPE_EXTENDED_PREFIX_LSA 7 |
64 | #define OPAQUE_TYPE_EXTENDED_LINK_LSA 8 | |
65 | #define OPAQUE_TYPE_MAX 8 | |
718e3744 | 66 | |
78dfa0c7 | 67 | /* Following types are proposed in internet-draft documents. */ |
718e3744 | 68 | #define OPAQUE_TYPE_8021_QOSPF 129 |
69 | #define OPAQUE_TYPE_SECONDARY_NEIGHBOR_DISCOVERY 224 | |
70 | #define OPAQUE_TYPE_FLOODGATE 225 | |
71 | ||
72 | /* Ugly hack to make use of an unallocated value for wildcard matching! */ | |
73 | #define OPAQUE_TYPE_WILDCARD 0 | |
74 | ||
d62a17ae | 75 | #define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \ |
76 | (OPAQUE_TYPE_MAX <= (type) && (type) <= 127) | |
718e3744 | 77 | |
d62a17ae | 78 | #define OPAQUE_TYPE_RANGE_RESERVED(type) (127 < (type) && (type) <= 255) |
718e3744 | 79 | |
cf680c38 DS |
80 | #define OSPF_OPAQUE_LSA_MIN_SIZE 4U |
81 | ||
d62a17ae | 82 | #define VALID_OPAQUE_INFO_LEN(lsahdr) \ |
83 | ((ntohs((lsahdr)->length) >= sizeof(struct lsa_header)) \ | |
8db278b5 | 84 | && ((ntohs((lsahdr)->length) < OSPF_MAX_LSA_SIZE)) \ |
d7c0a89a | 85 | && ((ntohs((lsahdr)->length) % sizeof(uint32_t)) == 0)) |
718e3744 | 86 | |
ead99d5f OD |
87 | /* |
88 | * Following section defines generic TLV (type, length, value) macros, | |
89 | * used for various LSA opaque usage e.g. Traffic Engineering. | |
90 | */ | |
2a39170c | 91 | struct tlv_header { |
d7c0a89a QY |
92 | uint16_t type; /* Type of Value */ |
93 | uint16_t length; /* Length of Value portion only, in bytes */ | |
ead99d5f OD |
94 | }; |
95 | ||
a6df2b80 | 96 | #define TLV_HDR_SIZE (sizeof(struct tlv_header)) |
ead99d5f | 97 | |
d7c0a89a | 98 | #define TLV_BODY_SIZE(tlvh) (ROUNDUP(ntohs((tlvh)->length), sizeof(uint32_t))) |
ead99d5f | 99 | |
72327cf3 | 100 | #define TLV_SIZE(tlvh) (uint32_t)(TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh)) |
ead99d5f | 101 | |
996c9314 | 102 | #define TLV_HDR_TOP(lsah) \ |
a6df2b80 | 103 | (struct tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE) |
ead99d5f | 104 | |
996c9314 | 105 | #define TLV_HDR_NEXT(tlvh) \ |
a6df2b80 | 106 | (struct tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh)) |
ead99d5f | 107 | |
996c9314 | 108 | #define TLV_HDR_SUBTLV(tlvh) \ |
a6df2b80 | 109 | (struct tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE) |
ead99d5f | 110 | |
a6df2b80 | 111 | #define TLV_DATA(tlvh) (void *)((char *)(tlvh) + TLV_HDR_SIZE) |
ead99d5f | 112 | |
a6df2b80 OD |
113 | #define TLV_TYPE(tlvh) tlvh.header.type |
114 | #define TLV_LEN(tlvh) tlvh.header.length | |
115 | #define TLV_HDR(tlvh) tlvh.header | |
ead99d5f OD |
116 | |
117 | /* Following declaration concerns the Opaque LSA management */ | |
996c9314 | 118 | enum lsa_opcode { REORIGINATE_THIS_LSA, REFRESH_THIS_LSA, FLUSH_THIS_LSA }; |
ead99d5f | 119 | |
718e3744 | 120 | /* Prototypes. */ |
718e3744 | 121 | |
d62a17ae | 122 | extern void ospf_opaque_init(void); |
123 | extern void ospf_opaque_term(void); | |
bcf4475e | 124 | extern void ospf_opaque_finish(void); |
d62a17ae | 125 | extern int ospf_opaque_type9_lsa_init(struct ospf_interface *oi); |
126 | extern void ospf_opaque_type9_lsa_term(struct ospf_interface *oi); | |
127 | extern int ospf_opaque_type10_lsa_init(struct ospf_area *area); | |
128 | extern void ospf_opaque_type10_lsa_term(struct ospf_area *area); | |
129 | extern int ospf_opaque_type11_lsa_init(struct ospf *ospf); | |
130 | extern void ospf_opaque_type11_lsa_term(struct ospf *ospf); | |
131 | ||
132 | extern int ospf_register_opaque_functab( | |
d7c0a89a | 133 | uint8_t lsa_type, uint8_t opaque_type, |
d62a17ae | 134 | int (*new_if_hook)(struct interface *ifp), |
135 | int (*del_if_hook)(struct interface *ifp), | |
136 | void (*ism_change_hook)(struct ospf_interface *oi, int old_status), | |
137 | void (*nsm_change_hook)(struct ospf_neighbor *nbr, int old_status), | |
138 | void (*config_write_router)(struct vty *vty), | |
139 | void (*config_write_if)(struct vty *vty, struct interface *ifp), | |
140 | void (*config_write_debug)(struct vty *vty), | |
3e63092b RW |
141 | void (*show_opaque_info)(struct vty *vty, struct json_object *json, |
142 | struct ospf_lsa *lsa), | |
d62a17ae | 143 | int (*lsa_originator)(void *arg), |
144 | struct ospf_lsa *(*lsa_refresher)(struct ospf_lsa *lsa), | |
145 | int (*new_lsa_hook)(struct ospf_lsa *lsa), | |
146 | int (*del_lsa_hook)(struct ospf_lsa *lsa)); | |
d7c0a89a | 147 | extern void ospf_delete_opaque_functab(uint8_t lsa_type, uint8_t opaque_type); |
d62a17ae | 148 | |
149 | extern int ospf_opaque_new_if(struct interface *ifp); | |
150 | extern int ospf_opaque_del_if(struct interface *ifp); | |
151 | extern void ospf_opaque_ism_change(struct ospf_interface *oi, int old_status); | |
152 | extern void ospf_opaque_nsm_change(struct ospf_neighbor *nbr, int old_status); | |
a6df2b80 | 153 | extern void ospf_opaque_config_write_router(struct vty *vty, struct ospf *ospf); |
d62a17ae | 154 | extern void ospf_opaque_config_write_if(struct vty *vty, struct interface *ifp); |
155 | extern void ospf_opaque_config_write_debug(struct vty *vty); | |
f328dc60 | 156 | extern void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa, |
157 | json_object *json); | |
d7c0a89a | 158 | extern void ospf_opaque_lsa_dump(struct stream *s, uint16_t length); |
d62a17ae | 159 | |
160 | extern void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, | |
161 | int *init_delay); | |
a6df2b80 | 162 | extern struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, |
d62a17ae | 163 | int rt_recalc); |
164 | extern struct ospf_lsa *ospf_opaque_lsa_refresh(struct ospf_lsa *lsa); | |
165 | ||
166 | extern void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, | |
d7c0a89a QY |
167 | uint8_t lsa_type, |
168 | uint8_t opaque_type); | |
d62a17ae | 169 | extern void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa); |
170 | extern void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa); | |
171 | ||
172 | extern void ospf_opaque_self_originated_lsa_received(struct ospf_neighbor *nbr, | |
173 | struct ospf_lsa *lsa); | |
174 | extern struct ospf *oi_to_top(struct ospf_interface *oi); | |
718e3744 | 175 | |
5349121b CH |
176 | extern int ospf_opaque_is_owned(struct ospf_lsa *lsa); |
177 | ||
718e3744 | 178 | #endif /* _ZEBRA_OSPF_OPAQUE_H */ |