blob: 2ac9b41efc8dec53b616a1553f24f29b2ee911e3 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
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
19 * along with GNU Zebra; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * 02111-1307, USA.
22 */
23
24#ifndef _ZEBRA_OSPF_OPAQUE_H
25#define _ZEBRA_OSPF_OPAQUE_H
26
paul4dadc292005-05-06 21:37:42 +000027#include "vty.h"
28
paul718e3742002-12-13 20:15:29 +000029#define IS_OPAQUE_LSA(type) \
30 ((type) == OSPF_OPAQUE_LINK_LSA || \
31 (type) == OSPF_OPAQUE_AREA_LSA || \
32 (type) == OSPF_OPAQUE_AS_LSA)
33
34/*
paul718e3742002-12-13 20:15:29 +000035 * Opaque LSA's link state ID is redefined as follows.
36 *
37 * 24 16 8 0
38 * +--------+--------+--------+--------+
39 * |tttttttt|........|........|........|
40 * +--------+--------+--------+--------+
41 * |<-Type->|<------- Opaque ID ------>|
42 */
43#define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */
44#define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */
45
46#define GET_OPAQUE_TYPE(lsid) \
47 (((u_int32_t)(lsid) & LSID_OPAQUE_TYPE_MASK) >> 24)
48
49#define GET_OPAQUE_ID(lsid) \
50 ((u_int32_t)(lsid) & LSID_OPAQUE_ID_MASK)
51
52#define SET_OPAQUE_LSID(type, id) \
53 ((((type) << 24) & LSID_OPAQUE_TYPE_MASK) \
54 | ((id) & LSID_OPAQUE_ID_MASK))
55
56/*
57 * Opaque LSA types will be assigned by IANA.
58 * <http://www.iana.org/assignments/ospf-opaque-types>
59 */
60#define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1
61#define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2
62#define OPAQUE_TYPE_GRACE_LSA 3
Olivier Dugeon29a14012016-04-19 18:42:40 +020063#define OPAQUE_TYPE_L1VPN_LSA 5
64#define OPAQUE_TYPE_ROUTER_INFORMATION_LSA 4
65#define OPAQUE_TYPE_INTER_AS_LSA 6
66#define OPAQUE_TYPE_MAX 6
paul718e3742002-12-13 20:15:29 +000067
68/* Followings types are proposed in internet-draft documents. */
69#define OPAQUE_TYPE_8021_QOSPF 129
70#define OPAQUE_TYPE_SECONDARY_NEIGHBOR_DISCOVERY 224
71#define OPAQUE_TYPE_FLOODGATE 225
72
73/* Ugly hack to make use of an unallocated value for wildcard matching! */
74#define OPAQUE_TYPE_WILDCARD 0
75
76#define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \
Olivier Dugeon29a14012016-04-19 18:42:40 +020077 ( OPAQUE_TYPE_MAX <= (type) && (type) <= 127)
paul718e3742002-12-13 20:15:29 +000078
79#define OPAQUE_TYPE_RANGE_RESERVED(type) \
80 (127 < (type) && (type) <= 255)
81
82#define VALID_OPAQUE_INFO_LEN(lsahdr) \
83 ((ntohs((lsahdr)->length) >= sizeof (struct lsa_header)) && \
84 ((ntohs((lsahdr)->length) % sizeof (u_int32_t)) == 0))
85
86/* Prototypes. */
paul718e3742002-12-13 20:15:29 +000087
88extern void ospf_opaque_init (void);
89extern void ospf_opaque_term (void);
90extern int ospf_opaque_type9_lsa_init (struct ospf_interface *oi);
91extern void ospf_opaque_type9_lsa_term (struct ospf_interface *oi);
92extern int ospf_opaque_type10_lsa_init (struct ospf_area *area);
93extern void ospf_opaque_type10_lsa_term (struct ospf_area *area);
94extern int ospf_opaque_type11_lsa_init (struct ospf *ospf);
95extern void ospf_opaque_type11_lsa_term (struct ospf *ospf);
96
97extern int
98ospf_register_opaque_functab (
99 u_char lsa_type,
100 u_char opaque_type,
101 int (* new_if_hook)(struct interface *ifp),
102 int (* del_if_hook)(struct interface *ifp),
103 void (* ism_change_hook)(struct ospf_interface *oi, int old_status),
104 void (* nsm_change_hook)(struct ospf_neighbor *nbr, int old_status),
105 void (* config_write_router)(struct vty *vty),
106 void (* config_write_if )(struct vty *vty, struct interface *ifp),
107 void (* config_write_debug )(struct vty *vty),
108 void (* show_opaque_info )(struct vty *vty, struct ospf_lsa *lsa),
109 int (* lsa_originator)(void *arg),
Paul Jakmad71ea652011-03-22 15:23:55 +0000110 struct ospf_lsa *(* lsa_refresher )(struct ospf_lsa *lsa),
paul718e3742002-12-13 20:15:29 +0000111 int (* new_lsa_hook)(struct ospf_lsa *lsa),
112 int (* del_lsa_hook)(struct ospf_lsa *lsa)
113);
114extern void ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type);
115
116extern int ospf_opaque_new_if (struct interface *ifp);
117extern int ospf_opaque_del_if (struct interface *ifp);
paul4dadc292005-05-06 21:37:42 +0000118extern void ospf_opaque_ism_change (struct ospf_interface *oi,
119 int old_status);
120extern void ospf_opaque_nsm_change (struct ospf_neighbor *nbr,
121 int old_status);
paul718e3742002-12-13 20:15:29 +0000122extern void ospf_opaque_config_write_router (struct vty *vty, struct ospf *);
paul4dadc292005-05-06 21:37:42 +0000123extern void ospf_opaque_config_write_if (struct vty *vty,
124 struct interface *ifp);
paul718e3742002-12-13 20:15:29 +0000125extern void ospf_opaque_config_write_debug (struct vty *vty);
126extern void show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa);
127extern void ospf_opaque_lsa_dump (struct stream *s, u_int16_t length);
128
paul4dadc292005-05-06 21:37:42 +0000129extern void ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi,
130 int *init_delay);
Paul Jakmadea04442008-02-26 09:16:09 +0000131extern struct ospf_lsa *ospf_opaque_lsa_install (struct ospf_lsa *,
paul4dadc292005-05-06 21:37:42 +0000132 int rt_recalc);
Paul Jakmad71ea652011-03-22 15:23:55 +0000133extern struct ospf_lsa *ospf_opaque_lsa_refresh (struct ospf_lsa *lsa);
paul718e3742002-12-13 20:15:29 +0000134
paul4dadc292005-05-06 21:37:42 +0000135extern void ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
136 u_char lsa_type,
137 u_char opaque_type);
paul718e3742002-12-13 20:15:29 +0000138extern void ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa);
139extern void ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa);
140
paul4dadc292005-05-06 21:37:42 +0000141extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor
142 *nbr,
paul69310a62005-05-11 18:09:59 +0000143 struct ospf_lsa *lsa);
paul718e3742002-12-13 20:15:29 +0000144extern struct ospf *oi_to_top (struct ospf_interface *oi);
145
146#endif /* _ZEBRA_OSPF_OPAQUE_H */