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