]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_opaque.h
Update PR #839 following review
[mirror_frr.git] / ospfd / ospf_opaque.h
CommitLineData
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"
27
d62a17ae 28#define IS_OPAQUE_LSA(type) \
29 ((type) == OSPF_OPAQUE_LINK_LSA || (type) == OSPF_OPAQUE_AREA_LSA \
30 || (type) == OSPF_OPAQUE_AS_LSA)
718e3744 31
718e3744 32/*
33 * Opaque LSA's link state ID is redefined as follows.
34 *
35 * 24 16 8 0
36 * +--------+--------+--------+--------+
37 * |tttttttt|........|........|........|
38 * +--------+--------+--------+--------+
39 * |<-Type->|<------- Opaque ID ------>|
40 */
41#define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */
42#define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */
43
d62a17ae 44#define GET_OPAQUE_TYPE(lsid) (((u_int32_t)(lsid)&LSID_OPAQUE_TYPE_MASK) >> 24)
718e3744 45
d62a17ae 46#define GET_OPAQUE_ID(lsid) ((u_int32_t)(lsid)&LSID_OPAQUE_ID_MASK)
718e3744 47
d62a17ae 48#define SET_OPAQUE_LSID(type, id) \
49 ((((type) << 24) & LSID_OPAQUE_TYPE_MASK) | ((id)&LSID_OPAQUE_ID_MASK))
718e3744 50
51/*
52 * Opaque LSA types will be assigned by IANA.
53 * <http://www.iana.org/assignments/ospf-opaque-types>
54 */
55#define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1
56#define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2
57#define OPAQUE_TYPE_GRACE_LSA 3
16f1b9ee
OD
58#define OPAQUE_TYPE_L1VPN_LSA 5
59#define OPAQUE_TYPE_ROUTER_INFORMATION_LSA 4
60#define OPAQUE_TYPE_INTER_AS_LSA 6
61#define OPAQUE_TYPE_MAX 6
718e3744 62
63/* Followings types are proposed in internet-draft documents. */
64#define OPAQUE_TYPE_8021_QOSPF 129
65#define OPAQUE_TYPE_SECONDARY_NEIGHBOR_DISCOVERY 224
66#define OPAQUE_TYPE_FLOODGATE 225
67
68/* Ugly hack to make use of an unallocated value for wildcard matching! */
69#define OPAQUE_TYPE_WILDCARD 0
70
d62a17ae 71#define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \
72 (OPAQUE_TYPE_MAX <= (type) && (type) <= 127)
718e3744 73
d62a17ae 74#define OPAQUE_TYPE_RANGE_RESERVED(type) (127 < (type) && (type) <= 255)
718e3744 75
d62a17ae 76#define VALID_OPAQUE_INFO_LEN(lsahdr) \
77 ((ntohs((lsahdr)->length) >= sizeof(struct lsa_header)) \
78 && ((ntohs((lsahdr)->length) % sizeof(u_int32_t)) == 0))
718e3744 79
ead99d5f
OD
80/*
81 * Following section defines generic TLV (type, length, value) macros,
82 * used for various LSA opaque usage e.g. Traffic Engineering.
83 */
2a39170c 84struct tlv_header {
ead99d5f
OD
85 u_int16_t type; /* Type of Value */
86 u_int16_t length; /* Length of Value portion only, in bytes */
87};
88
89#define TLV_HDR_SIZE \
90 (sizeof (struct tlv_header))
91
92#define TLV_BODY_SIZE(tlvh) \
93 (ROUNDUP (ntohs ((tlvh)->length), sizeof (u_int32_t)))
94
95#define TLV_SIZE(tlvh) \
96 (TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh))
97
98#define TLV_HDR_TOP(lsah) \
99 (struct tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE)
100
101#define TLV_HDR_NEXT(tlvh) \
102 (struct tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh))
103
104#define TLV_HDR_SUBTLV(tlvh) \
105 (struct tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE)
106
107#define TLV_DATA(tlvh) (void *)((char *)(tlvh) + TLV_HDR_SIZE)
108
109#define TLV_TYPE(tlvh) tlvh.header.type
110#define TLV_LEN(tlvh) tlvh.header.length
111#define TLV_HDR(tlvh) tlvh.header
112
113/* Following declaration concerns the Opaque LSA management */
2a39170c 114enum lsa_opcode {
ead99d5f
OD
115 REORIGINATE_THIS_LSA,
116 REFRESH_THIS_LSA,
117 FLUSH_THIS_LSA
2a39170c 118};
ead99d5f 119
718e3744 120/* Prototypes. */
718e3744 121
d62a17ae 122extern void ospf_opaque_init(void);
123extern void ospf_opaque_term(void);
124extern int ospf_opaque_type9_lsa_init(struct ospf_interface *oi);
125extern void ospf_opaque_type9_lsa_term(struct ospf_interface *oi);
126extern int ospf_opaque_type10_lsa_init(struct ospf_area *area);
127extern void ospf_opaque_type10_lsa_term(struct ospf_area *area);
128extern int ospf_opaque_type11_lsa_init(struct ospf *ospf);
129extern void ospf_opaque_type11_lsa_term(struct ospf *ospf);
130
131extern int ospf_register_opaque_functab(
132 u_char lsa_type, u_char opaque_type,
133 int (*new_if_hook)(struct interface *ifp),
134 int (*del_if_hook)(struct interface *ifp),
135 void (*ism_change_hook)(struct ospf_interface *oi, int old_status),
136 void (*nsm_change_hook)(struct ospf_neighbor *nbr, int old_status),
137 void (*config_write_router)(struct vty *vty),
138 void (*config_write_if)(struct vty *vty, struct interface *ifp),
139 void (*config_write_debug)(struct vty *vty),
140 void (*show_opaque_info)(struct vty *vty, struct ospf_lsa *lsa),
141 int (*lsa_originator)(void *arg),
142 struct ospf_lsa *(*lsa_refresher)(struct ospf_lsa *lsa),
143 int (*new_lsa_hook)(struct ospf_lsa *lsa),
144 int (*del_lsa_hook)(struct ospf_lsa *lsa));
145extern void ospf_delete_opaque_functab(u_char lsa_type, u_char opaque_type);
146
147extern int ospf_opaque_new_if(struct interface *ifp);
148extern int ospf_opaque_del_if(struct interface *ifp);
149extern void ospf_opaque_ism_change(struct ospf_interface *oi, int old_status);
150extern void ospf_opaque_nsm_change(struct ospf_neighbor *nbr, int old_status);
151extern void ospf_opaque_config_write_router(struct vty *vty, struct ospf *);
152extern void ospf_opaque_config_write_if(struct vty *vty, struct interface *ifp);
153extern void ospf_opaque_config_write_debug(struct vty *vty);
154extern void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa);
155extern void ospf_opaque_lsa_dump(struct stream *s, u_int16_t length);
156
157extern void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi,
158 int *init_delay);
159extern struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *,
160 int rt_recalc);
161extern struct ospf_lsa *ospf_opaque_lsa_refresh(struct ospf_lsa *lsa);
162
163extern void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
164 u_char lsa_type,
165 u_char opaque_type);
166extern void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa);
167extern void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa);
168
169extern void ospf_opaque_self_originated_lsa_received(struct ospf_neighbor *nbr,
170 struct ospf_lsa *lsa);
171extern struct ospf *oi_to_top(struct ospf_interface *oi);
718e3744 172
173#endif /* _ZEBRA_OSPF_OPAQUE_H */