paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 |
| 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 | |
| 27 | #define IS_OPAQUE_LSA(type) \ |
| 28 | ((type) == OSPF_OPAQUE_LINK_LSA || \ |
| 29 | (type) == OSPF_OPAQUE_AREA_LSA || \ |
| 30 | (type) == OSPF_OPAQUE_AS_LSA) |
| 31 | |
| 32 | /* |
| 33 | * Usage of Opaque-LSA administrative flags in "struct ospf". |
| 34 | * |
| 35 | * 7 6 5 4 3 2 1 0 |
| 36 | * +---+---+---+---+---+---+---+---+ |
| 37 | * |///|///|///|///|B11|B10|B09| O | |
| 38 | * +---+---+---+---+---+---+---+---+ |
| 39 | * |<--------->| A |
| 40 | * | +--- Operation status (operational = 1) |
| 41 | * +----------- Blocking status for each LSA type |
| 42 | */ |
| 43 | |
| 44 | #define IS_OPAQUE_LSA_ORIGINATION_BLOCKED(V) \ |
| 45 | CHECK_FLAG((V), (OPAQUE_BLOCK_TYPE_09_LSA_BIT | \ |
| 46 | OPAQUE_BLOCK_TYPE_10_LSA_BIT | \ |
| 47 | OPAQUE_BLOCK_TYPE_11_LSA_BIT)) |
| 48 | |
| 49 | /* |
| 50 | * Opaque LSA's link state ID is redefined as follows. |
| 51 | * |
| 52 | * 24 16 8 0 |
| 53 | * +--------+--------+--------+--------+ |
| 54 | * |tttttttt|........|........|........| |
| 55 | * +--------+--------+--------+--------+ |
| 56 | * |<-Type->|<------- Opaque ID ------>| |
| 57 | */ |
| 58 | #define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */ |
| 59 | #define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */ |
| 60 | |
| 61 | #define GET_OPAQUE_TYPE(lsid) \ |
| 62 | (((u_int32_t)(lsid) & LSID_OPAQUE_TYPE_MASK) >> 24) |
| 63 | |
| 64 | #define GET_OPAQUE_ID(lsid) \ |
| 65 | ((u_int32_t)(lsid) & LSID_OPAQUE_ID_MASK) |
| 66 | |
| 67 | #define SET_OPAQUE_LSID(type, id) \ |
| 68 | ((((type) << 24) & LSID_OPAQUE_TYPE_MASK) \ |
| 69 | | ((id) & LSID_OPAQUE_ID_MASK)) |
| 70 | |
| 71 | /* |
| 72 | * Opaque LSA types will be assigned by IANA. |
| 73 | * <http://www.iana.org/assignments/ospf-opaque-types> |
| 74 | */ |
| 75 | #define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1 |
| 76 | #define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2 |
| 77 | #define OPAQUE_TYPE_GRACE_LSA 3 |
| 78 | |
| 79 | /* Followings types are proposed in internet-draft documents. */ |
| 80 | #define OPAQUE_TYPE_8021_QOSPF 129 |
| 81 | #define OPAQUE_TYPE_SECONDARY_NEIGHBOR_DISCOVERY 224 |
| 82 | #define OPAQUE_TYPE_FLOODGATE 225 |
| 83 | |
| 84 | /* Ugly hack to make use of an unallocated value for wildcard matching! */ |
| 85 | #define OPAQUE_TYPE_WILDCARD 0 |
| 86 | |
| 87 | #define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \ |
| 88 | ( 4 <= (type) && (type) <= 127) |
| 89 | |
| 90 | #define OPAQUE_TYPE_RANGE_RESERVED(type) \ |
| 91 | (127 < (type) && (type) <= 255) |
| 92 | |
| 93 | #define VALID_OPAQUE_INFO_LEN(lsahdr) \ |
| 94 | ((ntohs((lsahdr)->length) >= sizeof (struct lsa_header)) && \ |
| 95 | ((ntohs((lsahdr)->length) % sizeof (u_int32_t)) == 0)) |
| 96 | |
| 97 | /* Prototypes. */ |
| 98 | struct vty; |
| 99 | struct stream; |
| 100 | |
| 101 | extern void ospf_opaque_init (void); |
| 102 | extern void ospf_opaque_term (void); |
| 103 | extern int ospf_opaque_type9_lsa_init (struct ospf_interface *oi); |
| 104 | extern void ospf_opaque_type9_lsa_term (struct ospf_interface *oi); |
| 105 | extern int ospf_opaque_type10_lsa_init (struct ospf_area *area); |
| 106 | extern void ospf_opaque_type10_lsa_term (struct ospf_area *area); |
| 107 | extern int ospf_opaque_type11_lsa_init (struct ospf *ospf); |
| 108 | extern void ospf_opaque_type11_lsa_term (struct ospf *ospf); |
| 109 | |
| 110 | extern int |
| 111 | ospf_register_opaque_functab ( |
| 112 | u_char lsa_type, |
| 113 | u_char opaque_type, |
| 114 | int (* new_if_hook)(struct interface *ifp), |
| 115 | int (* del_if_hook)(struct interface *ifp), |
| 116 | void (* ism_change_hook)(struct ospf_interface *oi, int old_status), |
| 117 | void (* nsm_change_hook)(struct ospf_neighbor *nbr, int old_status), |
| 118 | void (* config_write_router)(struct vty *vty), |
| 119 | void (* config_write_if )(struct vty *vty, struct interface *ifp), |
| 120 | void (* config_write_debug )(struct vty *vty), |
| 121 | void (* show_opaque_info )(struct vty *vty, struct ospf_lsa *lsa), |
| 122 | int (* lsa_originator)(void *arg), |
| 123 | void (* lsa_refresher )(struct ospf_lsa *lsa), |
| 124 | int (* new_lsa_hook)(struct ospf_lsa *lsa), |
| 125 | int (* del_lsa_hook)(struct ospf_lsa *lsa) |
| 126 | ); |
| 127 | extern void ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type); |
| 128 | |
| 129 | extern int ospf_opaque_new_if (struct interface *ifp); |
| 130 | extern int ospf_opaque_del_if (struct interface *ifp); |
| 131 | extern void ospf_opaque_ism_change (struct ospf_interface *oi, int old_status); |
| 132 | extern void ospf_opaque_nsm_change (struct ospf_neighbor *nbr, int old_status); |
| 133 | extern void ospf_opaque_config_write_router (struct vty *vty, struct ospf *); |
| 134 | extern void ospf_opaque_config_write_if (struct vty *vty, struct interface *ifp); |
| 135 | extern void ospf_opaque_config_write_debug (struct vty *vty); |
| 136 | extern void show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa); |
| 137 | extern void ospf_opaque_lsa_dump (struct stream *s, u_int16_t length); |
| 138 | |
| 139 | extern void ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *init_delay); |
| 140 | extern struct ospf_lsa *ospf_opaque_lsa_install (struct ospf_lsa *new, int rt_recalc); |
| 141 | extern void ospf_opaque_lsa_refresh (struct ospf_lsa *lsa); |
| 142 | |
| 143 | extern void ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent, u_char lsa_type, u_char opaque_type); |
| 144 | extern void ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa); |
| 145 | extern void ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa); |
| 146 | |
paul | 87d6f87 | 2004-09-24 08:01:38 +0000 | [diff] [blame] | 147 | extern void ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr, |
| 148 | struct list *lsas); |
| 149 | extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, |
| 150 | struct list *lsas); |
| 151 | extern void ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, |
| 152 | struct list *acks); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 153 | |
| 154 | extern void htonf (float *src, float *dst); |
| 155 | extern void ntohf (float *src, float *dst); |
| 156 | extern struct ospf *oi_to_top (struct ospf_interface *oi); |
| 157 | |
| 158 | #endif /* _ZEBRA_OSPF_OPAQUE_H */ |