1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 2002-2012 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Eclipse Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 8 * * 9 * A copy of the License is available at * 10 * http://www.eclipse.org/org/documents/epl-v10.html * 11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12 * * 13 * Information and Software Systems Research * 14 * AT&T Research * 15 * Florham Park NJ * 16 * * 17 * Aman Shaikh <ashaikh@research.att.com> * 18 * * 19 ***********************************************************************/ 20 /***************************************************** 21 * File name : ospf_lsa_can.h 22 * Objective : Defines the canonical structure for 23 * storing OSPF LSAs. 24 *****************************************************/ 25 26 #ifndef _OSPF_LSA_CAN_H_ 27 #define _OSPF_LSA_CAN_H_ 1 28 29 #include "ospf_rfc.h" 30 31 #if defined(__cplusplus) || defined(c_plusplus) 32 extern "C" { 33 #endif 34 35 /* LSA attributes */ 36 #define LSA_LSU_GROUP (1<<1) 37 38 /* LSA instance type */ 39 #define LSA_INST_UNKNOWN 0 40 #define LSA_INST_NEW 1 41 #define LSA_INST_DUP 2 42 #define LSA_INST_OLD 3 43 #define LSA_INST_REQ 4 44 #define LSA_INST_CKSUM_ERR 5 45 #define LSA_INST_BAD_RTR 6 46 #define LSA_INST_ASE_IN_STUB 7 47 #define LSA_INST_TYPE7_IN_NONNSSA 8 48 49 /* Metric type for external LSAs */ 50 #define EXT_LSA_METRIC_TYPE1 1 51 #define EXT_LSA_METRIC_TYPE2 2 52 53 /* Canonical structure for storing LSA records */ 54 typedef struct _ospf_lsa_can_t { 55 uint32_t sec; /* Timestamp - sec part */ 56 uint32_t micro_sec; /* Timestamp - microsec part */ 57 ipaddr_t src_ip_addr; /* Source IP addr */ 58 ipaddr_t dest_ip_addr; /* Dest IP addr */ 59 uint32_t rec_len; /* Length of total record (octects) */ 60 rtid_t lsu_rtid; /* Rtr id of LSU pkt */ 61 areaid_t lsu_areaid; /* Area id of LSU pkt */ 62 uint32_t lsu_no_lsas; /* No of LSAs */ 63 uint32_t lsu_lsa_no; /* No of this LSA in the pkt */ 64 ipaddr_t lsa_id; /* LSA id */ 65 rtid_t lsa_advrt; /* LSA advertising rtr */ 66 seq_t lsa_seq; /* LSA seq no */ 67 uint32_t lsa_data_size; /* Size of 'lsa_data' (bytes) */ 68 uint16_t lsu_len; /* Length of LSU pkt */ 69 uint16_t lsu_cksum; /* Checksum of LSU pkt */ 70 uint16_t lsu_authtype; /* Auth type of LSU pkt */ 71 uint16_t lsa_age; /* LSA age */ 72 uint16_t lsa_cksum; /* LSA cksum */ 73 uint16_t lsa_len; /* LSA length */ 74 uint8_t lsu_version; /* Version of LSU pkt */ 75 uint8_t lsa_options; /* LSA options */ 76 uint8_t lsa_type; /* LSA type: LST_xxx */ 77 uint8_t lsa_inst_type; /* LSA inst type: LSA_INST_xxxx */ 78 uint8_t lsa_attr; /* Misc. LSA attributes */ 79 ospf_pkt_auth_t lsu_auth; /* Auth info of LSU pkt - nw order */ 80 uint8_t *lsa_data_p; /* LSA data -- as sequence of bytes as 81 received on wire */ 82 } ospf_lsa_can_t; 83 84 /* Various types for LSA formats */ 85 extern Dssformat_t *ospf_lsa_formats; 86 extern Dssformat_t can_lsa_format; 87 extern Dssformat_t lsar_lsa_format; 88 extern Dssformat_t lsag_lsa_format; 89 extern Dssformat_t pmcoa_lsa_format; 90 extern Dssformat_t text_lsa_format; 91 92 /* Ordering among formats is defined by these constants. */ 93 #define OSPF_LSA_FIRST_FORMAT (&can_lsa_format) 94 #define OSPF_CAN_LSA_NEXT (&lsag_lsa_format) 95 #define OSPF_LSAG_LSA_NEXT (&pmcoa_lsa_format) 96 #define OSPF_PMCOA_LSA_NEXT (&lsar_lsa_format) 97 #define OSPF_LSAR_LSA_NEXT (&text_lsa_format) 98 #define OSPF_TEXT_LSA_NEXT NULL 99 100 /* 101 * Creates a new canonical LSA record, initializes it, and returns 102 * a pointer to it. 103 */ 104 extern ospf_lsa_can_t *calloc_lsa_can(); 105 106 /* Initializes canonical LSA record */ 107 extern void init_lsa_can(ospf_lsa_can_t *lsa_can_p); 108 109 /* Frees space occupied by '*lsa_can_p' */ 110 extern void free_lsa_can(ospf_lsa_can_t *lsa_can_p); 111 112 /* 113 * Allocates space to store 'lsa_data_len' in 'lsa_can_p'. 114 * If necessary, frees previously allocated space. 115 */ 116 extern void calloc_lsa_can_data(ospf_lsa_can_t *lsa_can_p, 117 uint32_t lsa_data_len); 118 119 /* Frees (previously) allocated space to store LSA data in 'lsa_can_p'. */ 120 extern void free_lsa_can_data(ospf_lsa_can_t *lsa_can_p); 121 122 #if defined(__cplusplus) || defined(c_plusplus) 123 } 124 #endif 125 126 #endif /* _OSPF_LSA_CAN_H_ */ 127