1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _OSPF_H 28*7c478bd9Sstevel@tonic-gate #define _OSPF_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Definitions for parsing OSPF packets (RFC 2328 and RFC 2740) 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #define OSPF_TYPE_UMD 0 /* UMD's special monitoring packets */ 41*7c478bd9Sstevel@tonic-gate #define OSPF_TYPE_HELLO 1 /* Hello */ 42*7c478bd9Sstevel@tonic-gate #define OSPF_TYPE_DB 2 /* Database Description */ 43*7c478bd9Sstevel@tonic-gate #define OSPF_TYPE_LSR 3 /* Link State Request */ 44*7c478bd9Sstevel@tonic-gate #define OSPF_TYPE_LSU 4 /* Link State Update */ 45*7c478bd9Sstevel@tonic-gate #define OSPF_TYPE_LSA 5 /* Link State Ack */ 46*7c478bd9Sstevel@tonic-gate #define OSPF_TYPE_MAX 6 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate extern char *ospf_types[]; 49*7c478bd9Sstevel@tonic-gate struct bits { 50*7c478bd9Sstevel@tonic-gate uint32_t bit; 51*7c478bd9Sstevel@tonic-gate const char *str; 52*7c478bd9Sstevel@tonic-gate }; 53*7c478bd9Sstevel@tonic-gate char *ospf_print_bits(const struct bits *, uchar_t); 54*7c478bd9Sstevel@tonic-gate char *ospf_print_lsa_age(long); 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate /* Options *_options */ 57*7c478bd9Sstevel@tonic-gate #define OSPF_OPTION_T 0x01 /* RFC 2328 T bit: TOS support */ 58*7c478bd9Sstevel@tonic-gate #define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */ 59*7c478bd9Sstevel@tonic-gate #define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */ 60*7c478bd9Sstevel@tonic-gate #define OSPF_OPTION_N 0x08 /* N bit: For type-7 LSA */ 61*7c478bd9Sstevel@tonic-gate #define OSPF_OPTION_R 0x10 /* R bit: Router bit */ 62*7c478bd9Sstevel@tonic-gate #define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuits */ 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate #define OSPF_OPTION_V6 0x01 /* RFC 2740 V6 bit */ 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate /* ospf_authtype */ 67*7c478bd9Sstevel@tonic-gate #define OSPF_AUTH_NONE 0 /* No auth-data */ 68*7c478bd9Sstevel@tonic-gate #define OSPF_AUTH_SIMPLE 1 /* Simple password */ 69*7c478bd9Sstevel@tonic-gate #define OSPF_AUTH_MD5 2 /* MD5 authentication */ 70*7c478bd9Sstevel@tonic-gate #define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate #define OSPF_AUTH_TYPE_MAX 3 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate /* db_flags */ 75*7c478bd9Sstevel@tonic-gate #define OSPF_DB_INIT 0x04 /* "I" */ 76*7c478bd9Sstevel@tonic-gate #define OSPF_DB_MORE 0x02 /* "M" */ 77*7c478bd9Sstevel@tonic-gate #define OSPF_DB_MASTER 0x01 /* "MS" */ 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate /* ls_type */ 81*7c478bd9Sstevel@tonic-gate #define LS_TYPE_ROUTER 1 /* router link */ 82*7c478bd9Sstevel@tonic-gate #define LS_TYPE_NETWORK 2 /* network link */ 83*7c478bd9Sstevel@tonic-gate #define LS_TYPE_SUM_IP 3 /* summary link */ 84*7c478bd9Sstevel@tonic-gate #define LS_TYPE_SUM_ABR 4 /* summary area link */ 85*7c478bd9Sstevel@tonic-gate #define LS_TYPE_ASE 5 /* ASE */ 86*7c478bd9Sstevel@tonic-gate #define LS_TYPE_GROUP 6 /* Group membership (multicast */ 87*7c478bd9Sstevel@tonic-gate /* extensions 23 July 1991) */ 88*7c478bd9Sstevel@tonic-gate #define LS_TYPE_TYPE7 7 /* Type 7 LSA */ 89*7c478bd9Sstevel@tonic-gate #define LS_TYPE_LINK 8 /* Link LSA */ 90*7c478bd9Sstevel@tonic-gate #define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */ 91*7c478bd9Sstevel@tonic-gate #define LS_TYPE_MAX 10 92*7c478bd9Sstevel@tonic-gate #define LS_TYPE_MASK 0x1fff 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate #define LS_TYPE_INTER_AP 3 /* RFC 2740 Inter-Area-Prefix */ 95*7c478bd9Sstevel@tonic-gate #define LS_TYPE_INTER_AR 4 /* RFC 2740 Inter-Area-Router */ 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate #define LS6_SCOPE_LINKLOCAL 0x0000 98*7c478bd9Sstevel@tonic-gate #define LS6_SCOPE_AREA 0x2000 99*7c478bd9Sstevel@tonic-gate #define LS6_SCOPE_AS 0x4000 100*7c478bd9Sstevel@tonic-gate #define LS6_SCOPE_MASK 0x6000 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate /* rla_link.link_type */ 103*7c478bd9Sstevel@tonic-gate #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ 104*7c478bd9Sstevel@tonic-gate #define RLA_TYPE_TRANSIT 2 /* connection to transit network */ 105*7c478bd9Sstevel@tonic-gate #define RLA_TYPE_STUB 3 /* connection to stub network */ 106*7c478bd9Sstevel@tonic-gate #define RLA_TYPE_VIRTUAL 4 /* virtual link */ 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* rla_flags */ 109*7c478bd9Sstevel@tonic-gate #define RLA_FLAG_B 0x01 110*7c478bd9Sstevel@tonic-gate #define RLA_FLAG_E 0x02 111*7c478bd9Sstevel@tonic-gate #define RLA_FLAG_V 0x04 112*7c478bd9Sstevel@tonic-gate #define RLA_FLAG_W 0x08 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate /* sla_tosmetric breakdown */ 116*7c478bd9Sstevel@tonic-gate #define SLA_MASK_TOS 0x7f000000 117*7c478bd9Sstevel@tonic-gate #define SLA_MASK_METRIC 0x00ffffff 118*7c478bd9Sstevel@tonic-gate #define SLA_SHIFT_TOS 24 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* asla_tosmetric breakdown */ 121*7c478bd9Sstevel@tonic-gate #define ASLA_FLAG_EXTERNAL 0x80000000 122*7c478bd9Sstevel@tonic-gate #define ASLA_MASK_TOS 0x7f000000 123*7c478bd9Sstevel@tonic-gate #define ASLA_SHIFT_TOS 24 124*7c478bd9Sstevel@tonic-gate #define ASLA_MASK_METRIC 0x00ffffff 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate /* multicast vertex type */ 127*7c478bd9Sstevel@tonic-gate #define MCLA_VERTEX_ROUTER 1 128*7c478bd9Sstevel@tonic-gate #define MCLA_VERTEX_NETWORK 2 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate /* link state advertisement header */ 131*7c478bd9Sstevel@tonic-gate struct lsa_hdr { 132*7c478bd9Sstevel@tonic-gate ushort_t ls_age; 133*7c478bd9Sstevel@tonic-gate uchar_t ls_options; 134*7c478bd9Sstevel@tonic-gate uchar_t ls_type; 135*7c478bd9Sstevel@tonic-gate struct in_addr ls_stateid; 136*7c478bd9Sstevel@tonic-gate struct in_addr ls_router; 137*7c478bd9Sstevel@tonic-gate uint32_t ls_seq; 138*7c478bd9Sstevel@tonic-gate ushort_t ls_chksum; 139*7c478bd9Sstevel@tonic-gate ushort_t ls_length; 140*7c478bd9Sstevel@tonic-gate }; 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate /* link state advertisement */ 143*7c478bd9Sstevel@tonic-gate struct lsa { 144*7c478bd9Sstevel@tonic-gate struct lsa_hdr ls_hdr; 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate /* Link state types */ 147*7c478bd9Sstevel@tonic-gate union { 148*7c478bd9Sstevel@tonic-gate /* Router links advertisements */ 149*7c478bd9Sstevel@tonic-gate struct { 150*7c478bd9Sstevel@tonic-gate uchar_t rla_flags; 151*7c478bd9Sstevel@tonic-gate uchar_t rla_zero[1]; 152*7c478bd9Sstevel@tonic-gate ushort_t rla_count; 153*7c478bd9Sstevel@tonic-gate struct rlalink { 154*7c478bd9Sstevel@tonic-gate struct in_addr link_id; 155*7c478bd9Sstevel@tonic-gate struct in_addr link_data; 156*7c478bd9Sstevel@tonic-gate uchar_t link_type; 157*7c478bd9Sstevel@tonic-gate uchar_t link_toscount; 158*7c478bd9Sstevel@tonic-gate ushort_t link_tos0metric; 159*7c478bd9Sstevel@tonic-gate } rla_link[1]; /* may repeat */ 160*7c478bd9Sstevel@tonic-gate } un_rla; 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* Network links advertisements */ 163*7c478bd9Sstevel@tonic-gate struct { 164*7c478bd9Sstevel@tonic-gate struct in_addr nla_mask; 165*7c478bd9Sstevel@tonic-gate struct in_addr nla_router[1]; /* may repeat */ 166*7c478bd9Sstevel@tonic-gate } un_nla; 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate /* Summary links advertisements */ 169*7c478bd9Sstevel@tonic-gate struct { 170*7c478bd9Sstevel@tonic-gate struct in_addr sla_mask; 171*7c478bd9Sstevel@tonic-gate uint32_t sla_tosmetric[1]; /* may repeat */ 172*7c478bd9Sstevel@tonic-gate } un_sla; 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate /* AS external links advertisements */ 175*7c478bd9Sstevel@tonic-gate struct { 176*7c478bd9Sstevel@tonic-gate struct in_addr asla_mask; 177*7c478bd9Sstevel@tonic-gate struct aslametric { 178*7c478bd9Sstevel@tonic-gate uint32_t asla_tosmetric; 179*7c478bd9Sstevel@tonic-gate struct in_addr asla_forward; 180*7c478bd9Sstevel@tonic-gate struct in_addr asla_tag; 181*7c478bd9Sstevel@tonic-gate } asla_metric[1]; /* may repeat */ 182*7c478bd9Sstevel@tonic-gate } un_asla; 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate /* Multicast group membership */ 185*7c478bd9Sstevel@tonic-gate struct mcla { 186*7c478bd9Sstevel@tonic-gate uint32_t mcla_vtype; 187*7c478bd9Sstevel@tonic-gate struct in_addr mcla_vid; 188*7c478bd9Sstevel@tonic-gate } un_mcla[1]; 189*7c478bd9Sstevel@tonic-gate } lsa_un; 190*7c478bd9Sstevel@tonic-gate }; 191*7c478bd9Sstevel@tonic-gate 192*7c478bd9Sstevel@tonic-gate /* 193*7c478bd9Sstevel@tonic-gate * TOS metric struct (will be 0 or more in router links update) 194*7c478bd9Sstevel@tonic-gate */ 195*7c478bd9Sstevel@tonic-gate struct tos_metric { 196*7c478bd9Sstevel@tonic-gate uchar_t tos_type; 197*7c478bd9Sstevel@tonic-gate uchar_t tos_zero; 198*7c478bd9Sstevel@tonic-gate ushort_t tos_metric; 199*7c478bd9Sstevel@tonic-gate }; 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate /* 202*7c478bd9Sstevel@tonic-gate * OSPF minimum header sizes 203*7c478bd9Sstevel@tonic-gate */ 204*7c478bd9Sstevel@tonic-gate #define OSPF_AUTH_SIZE 8 205*7c478bd9Sstevel@tonic-gate #define OSPF_MIN_HEADER_SIZE 24 206*7c478bd9Sstevel@tonic-gate #define OSPF6_MIN_HEADER_SIZE 16 207*7c478bd9Sstevel@tonic-gate #define OSPF_MIN_HELLO_HEADER_SIZE 20 208*7c478bd9Sstevel@tonic-gate #define OSPF_MIN_DB_HEADER_SIZE 8 209*7c478bd9Sstevel@tonic-gate #define OSPF6_MIN_DB_HEADER_SIZE 12 210*7c478bd9Sstevel@tonic-gate #define OSPF_MIN_LSR_HEADER_SIZE 12 211*7c478bd9Sstevel@tonic-gate #define OSPF_MIN_LSU_HEADER_SIZE 4 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* 214*7c478bd9Sstevel@tonic-gate * ospf packet header 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate struct ospfhdr { 217*7c478bd9Sstevel@tonic-gate uchar_t ospf_version; 218*7c478bd9Sstevel@tonic-gate uchar_t ospf_type; 219*7c478bd9Sstevel@tonic-gate ushort_t ospf_len; 220*7c478bd9Sstevel@tonic-gate struct in_addr ospf_routerid; 221*7c478bd9Sstevel@tonic-gate struct in_addr ospf_areaid; 222*7c478bd9Sstevel@tonic-gate ushort_t ospf_chksum; 223*7c478bd9Sstevel@tonic-gate ushort_t ospf_authtype; 224*7c478bd9Sstevel@tonic-gate uchar_t ospf_authdata[OSPF_AUTH_SIZE]; 225*7c478bd9Sstevel@tonic-gate union { 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate /* Hello packet */ 228*7c478bd9Sstevel@tonic-gate struct { 229*7c478bd9Sstevel@tonic-gate struct in_addr hello_mask; 230*7c478bd9Sstevel@tonic-gate ushort_t hello_helloint; 231*7c478bd9Sstevel@tonic-gate uchar_t hello_options; 232*7c478bd9Sstevel@tonic-gate uchar_t hello_priority; 233*7c478bd9Sstevel@tonic-gate uint32_t hello_deadint; 234*7c478bd9Sstevel@tonic-gate struct in_addr hello_dr; 235*7c478bd9Sstevel@tonic-gate struct in_addr hello_bdr; 236*7c478bd9Sstevel@tonic-gate struct in_addr hello_neighbor[1]; /* may repeat */ 237*7c478bd9Sstevel@tonic-gate } un_hello; 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate /* Database Description packet */ 240*7c478bd9Sstevel@tonic-gate struct { 241*7c478bd9Sstevel@tonic-gate uchar_t db_zero[2]; 242*7c478bd9Sstevel@tonic-gate uchar_t db_options; 243*7c478bd9Sstevel@tonic-gate uchar_t db_flags; 244*7c478bd9Sstevel@tonic-gate uint32_t db_seq; 245*7c478bd9Sstevel@tonic-gate struct lsa_hdr db_lshdr[1]; /* may repeat */ 246*7c478bd9Sstevel@tonic-gate } un_db; 247*7c478bd9Sstevel@tonic-gate 248*7c478bd9Sstevel@tonic-gate /* Link State Request */ 249*7c478bd9Sstevel@tonic-gate struct lsr { 250*7c478bd9Sstevel@tonic-gate uint32_t ls_type; 251*7c478bd9Sstevel@tonic-gate struct in_addr ls_stateid; 252*7c478bd9Sstevel@tonic-gate struct in_addr ls_router; 253*7c478bd9Sstevel@tonic-gate } un_lsr[1]; /* may repeat */ 254*7c478bd9Sstevel@tonic-gate 255*7c478bd9Sstevel@tonic-gate /* Link State Update */ 256*7c478bd9Sstevel@tonic-gate struct { 257*7c478bd9Sstevel@tonic-gate uint32_t lsu_count; 258*7c478bd9Sstevel@tonic-gate struct lsa lsu_lsa[1]; /* may repeat */ 259*7c478bd9Sstevel@tonic-gate } un_lsu; 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate /* Link State Acknowledgement */ 262*7c478bd9Sstevel@tonic-gate struct { 263*7c478bd9Sstevel@tonic-gate struct lsa_hdr lsa_lshdr[1]; /* may repeat */ 264*7c478bd9Sstevel@tonic-gate } un_lsa; 265*7c478bd9Sstevel@tonic-gate } ospf_un; 266*7c478bd9Sstevel@tonic-gate }; 267*7c478bd9Sstevel@tonic-gate 268*7c478bd9Sstevel@tonic-gate #define ospf_hello ospf_un.un_hello 269*7c478bd9Sstevel@tonic-gate #define ospf_db ospf_un.un_db 270*7c478bd9Sstevel@tonic-gate #define ospf_lsr ospf_un.un_lsr 271*7c478bd9Sstevel@tonic-gate #define ospf_lsu ospf_un.un_lsu 272*7c478bd9Sstevel@tonic-gate #define ospf_lsa ospf_un.un_lsa 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate 275*7c478bd9Sstevel@tonic-gate 276*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 277*7c478bd9Sstevel@tonic-gate } 278*7c478bd9Sstevel@tonic-gate #endif 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate #endif /* _OSPF_H */ 281