]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_opaque.h
Merge branch 'stable/3.0'
[mirror_frr.git] / ospfd / ospf_opaque.h
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.
12 *
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 *
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
21 */
22
23 #ifndef _ZEBRA_OSPF_OPAQUE_H
24 #define _ZEBRA_OSPF_OPAQUE_H
25
26 #include "vty.h"
27
28 #define IS_OPAQUE_LSA(type) \
29 ((type) == OSPF_OPAQUE_LINK_LSA || \
30 (type) == OSPF_OPAQUE_AREA_LSA || \
31 (type) == OSPF_OPAQUE_AS_LSA)
32
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
45 #define GET_OPAQUE_TYPE(lsid) \
46 (((u_int32_t)(lsid) & LSID_OPAQUE_TYPE_MASK) >> 24)
47
48 #define GET_OPAQUE_ID(lsid) \
49 ((u_int32_t)(lsid) & LSID_OPAQUE_ID_MASK)
50
51 #define SET_OPAQUE_LSID(type, id) \
52 ((((type) << 24) & LSID_OPAQUE_TYPE_MASK) \
53 | ((id) & LSID_OPAQUE_ID_MASK))
54
55 /*
56 * Opaque LSA types will be assigned by IANA.
57 * <http://www.iana.org/assignments/ospf-opaque-types>
58 */
59 #define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1
60 #define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2
61 #define OPAQUE_TYPE_GRACE_LSA 3
62 #define OPAQUE_TYPE_L1VPN_LSA 5
63 #define OPAQUE_TYPE_ROUTER_INFORMATION_LSA 4
64 #define OPAQUE_TYPE_INTER_AS_LSA 6
65 #define OPAQUE_TYPE_MAX 6
66
67 /* Followings types are proposed in internet-draft documents. */
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
75 #define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \
76 ( OPAQUE_TYPE_MAX <= (type) && (type) <= 127)
77
78 #define OPAQUE_TYPE_RANGE_RESERVED(type) \
79 (127 < (type) && (type) <= 255)
80
81 #define VALID_OPAQUE_INFO_LEN(lsahdr) \
82 ((ntohs((lsahdr)->length) >= sizeof (struct lsa_header)) && \
83 ((ntohs((lsahdr)->length) % sizeof (u_int32_t)) == 0))
84
85 /* Prototypes. */
86
87 extern void ospf_opaque_init (void);
88 extern void ospf_opaque_term (void);
89 extern int ospf_opaque_type9_lsa_init (struct ospf_interface *oi);
90 extern void ospf_opaque_type9_lsa_term (struct ospf_interface *oi);
91 extern int ospf_opaque_type10_lsa_init (struct ospf_area *area);
92 extern void ospf_opaque_type10_lsa_term (struct ospf_area *area);
93 extern int ospf_opaque_type11_lsa_init (struct ospf *ospf);
94 extern void ospf_opaque_type11_lsa_term (struct ospf *ospf);
95
96 extern int
97 ospf_register_opaque_functab (
98 u_char lsa_type,
99 u_char opaque_type,
100 int (* new_if_hook)(struct interface *ifp),
101 int (* del_if_hook)(struct interface *ifp),
102 void (* ism_change_hook)(struct ospf_interface *oi, int old_status),
103 void (* nsm_change_hook)(struct ospf_neighbor *nbr, int old_status),
104 void (* config_write_router)(struct vty *vty),
105 void (* config_write_if )(struct vty *vty, struct interface *ifp),
106 void (* config_write_debug )(struct vty *vty),
107 void (* show_opaque_info )(struct vty *vty, struct ospf_lsa *lsa),
108 int (* lsa_originator)(void *arg),
109 struct ospf_lsa *(* lsa_refresher )(struct ospf_lsa *lsa),
110 int (* new_lsa_hook)(struct ospf_lsa *lsa),
111 int (* del_lsa_hook)(struct ospf_lsa *lsa)
112 );
113 extern void ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type);
114
115 extern int ospf_opaque_new_if (struct interface *ifp);
116 extern int ospf_opaque_del_if (struct interface *ifp);
117 extern void ospf_opaque_ism_change (struct ospf_interface *oi,
118 int old_status);
119 extern void ospf_opaque_nsm_change (struct ospf_neighbor *nbr,
120 int old_status);
121 extern void ospf_opaque_config_write_router (struct vty *vty, struct ospf *);
122 extern void ospf_opaque_config_write_if (struct vty *vty,
123 struct interface *ifp);
124 extern void ospf_opaque_config_write_debug (struct vty *vty);
125 extern void show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa);
126 extern void ospf_opaque_lsa_dump (struct stream *s, u_int16_t length);
127
128 extern void ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi,
129 int *init_delay);
130 extern struct ospf_lsa *ospf_opaque_lsa_install (struct ospf_lsa *,
131 int rt_recalc);
132 extern struct ospf_lsa *ospf_opaque_lsa_refresh (struct ospf_lsa *lsa);
133
134 extern void ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
135 u_char lsa_type,
136 u_char opaque_type);
137 extern void ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa);
138 extern void ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa);
139
140 extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor
141 *nbr,
142 struct ospf_lsa *lsa);
143 extern struct ospf *oi_to_top (struct ospf_interface *oi);
144
145 #endif /* _ZEBRA_OSPF_OPAQUE_H */