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