#ifndef _OSPF_H
#define _OSPF_H
#ifdef __cplusplus
extern "C" {
#endif
#define OSPF_TYPE_UMD 0
#define OSPF_TYPE_HELLO 1
#define OSPF_TYPE_DB 2
#define OSPF_TYPE_LSR 3
#define OSPF_TYPE_LSU 4
#define OSPF_TYPE_LSA 5
#define OSPF_TYPE_MAX 6
extern char *ospf_types[];
struct bits {
uint32_t bit;
const char *str;
};
char *ospf_print_bits(const struct bits *, uchar_t);
char *ospf_print_lsa_age(long);
#define OSPF_OPTION_T 0x01
#define OSPF_OPTION_E 0x02
#define OSPF_OPTION_MC 0x04
#define OSPF_OPTION_N 0x08
#define OSPF_OPTION_R 0x10
#define OSPF_OPTION_DC 0x20
#define OSPF_OPTION_V6 0x01
#define OSPF_AUTH_NONE 0
#define OSPF_AUTH_SIMPLE 1
#define OSPF_AUTH_MD5 2
#define OSPF_AUTH_MD5_LEN 16
#define OSPF_AUTH_TYPE_MAX 3
#define OSPF_DB_INIT 0x04
#define OSPF_DB_MORE 0x02
#define OSPF_DB_MASTER 0x01
#define LS_TYPE_ROUTER 1
#define LS_TYPE_NETWORK 2
#define LS_TYPE_SUM_IP 3
#define LS_TYPE_SUM_ABR 4
#define LS_TYPE_ASE 5
#define LS_TYPE_GROUP 6
#define LS_TYPE_TYPE7 7
#define LS_TYPE_LINK 8
#define LS_TYPE_INTRA_AP 9
#define LS_TYPE_MAX 10
#define LS_TYPE_MASK 0x1fff
#define LS_TYPE_INTER_AP 3
#define LS_TYPE_INTER_AR 4
#define LS6_SCOPE_LINKLOCAL 0x0000
#define LS6_SCOPE_AREA 0x2000
#define LS6_SCOPE_AS 0x4000
#define LS6_SCOPE_MASK 0x6000
#define RLA_TYPE_ROUTER 1
#define RLA_TYPE_TRANSIT 2
#define RLA_TYPE_STUB 3
#define RLA_TYPE_VIRTUAL 4
#define RLA_FLAG_B 0x01
#define RLA_FLAG_E 0x02
#define RLA_FLAG_V 0x04
#define RLA_FLAG_W 0x08
#define SLA_MASK_TOS 0x7f000000
#define SLA_MASK_METRIC 0x00ffffff
#define SLA_SHIFT_TOS 24
#define ASLA_FLAG_EXTERNAL 0x80000000
#define ASLA_MASK_TOS 0x7f000000
#define ASLA_SHIFT_TOS 24
#define ASLA_MASK_METRIC 0x00ffffff
#define MCLA_VERTEX_ROUTER 1
#define MCLA_VERTEX_NETWORK 2
struct lsa_hdr {
ushort_t ls_age;
uchar_t ls_options;
uchar_t ls_type;
struct in_addr ls_stateid;
struct in_addr ls_router;
uint32_t ls_seq;
ushort_t ls_chksum;
ushort_t ls_length;
};
struct lsa {
struct lsa_hdr ls_hdr;
union {
struct {
uchar_t rla_flags;
uchar_t rla_zero[1];
ushort_t rla_count;
struct rlalink {
struct in_addr link_id;
struct in_addr link_data;
uchar_t link_type;
uchar_t link_toscount;
ushort_t link_tos0metric;
} rla_link[1];
} un_rla;
struct {
struct in_addr nla_mask;
struct in_addr nla_router[1];
} un_nla;
struct {
struct in_addr sla_mask;
uint32_t sla_tosmetric[1];
} un_sla;
struct {
struct in_addr asla_mask;
struct aslametric {
uint32_t asla_tosmetric;
struct in_addr asla_forward;
struct in_addr asla_tag;
} asla_metric[1];
} un_asla;
struct mcla {
uint32_t mcla_vtype;
struct in_addr mcla_vid;
} un_mcla[1];
} lsa_un;
};
struct tos_metric {
uchar_t tos_type;
uchar_t tos_zero;
ushort_t tos_metric;
};
#define OSPF_AUTH_SIZE 8
#define OSPF_MIN_HEADER_SIZE 24
#define OSPF6_MIN_HEADER_SIZE 16
#define OSPF_MIN_HELLO_HEADER_SIZE 20
#define OSPF_MIN_DB_HEADER_SIZE 8
#define OSPF6_MIN_DB_HEADER_SIZE 12
#define OSPF_MIN_LSR_HEADER_SIZE 12
#define OSPF_MIN_LSU_HEADER_SIZE 4
struct ospfhdr {
uchar_t ospf_version;
uchar_t ospf_type;
ushort_t ospf_len;
struct in_addr ospf_routerid;
struct in_addr ospf_areaid;
ushort_t ospf_chksum;
ushort_t ospf_authtype;
uchar_t ospf_authdata[OSPF_AUTH_SIZE];
union {
struct {
struct in_addr hello_mask;
ushort_t hello_helloint;
uchar_t hello_options;
uchar_t hello_priority;
uint32_t hello_deadint;
struct in_addr hello_dr;
struct in_addr hello_bdr;
struct in_addr hello_neighbor[1];
} un_hello;
struct {
uchar_t db_zero[2];
uchar_t db_options;
uchar_t db_flags;
uint32_t db_seq;
struct lsa_hdr db_lshdr[1];
} un_db;
struct lsr {
uint32_t ls_type;
struct in_addr ls_stateid;
struct in_addr ls_router;
} un_lsr[1];
struct {
uint32_t lsu_count;
struct lsa lsu_lsa[1];
} un_lsu;
struct {
struct lsa_hdr lsa_lshdr[1];
} un_lsa;
} ospf_un;
};
#define ospf_hello ospf_un.un_hello
#define ospf_db ospf_un.un_db
#define ospf_lsr ospf_un.un_lsr
#define ospf_lsu ospf_un.un_lsu
#define ospf_lsa ospf_un.un_lsa
#ifdef __cplusplus
}
#endif
#endif