blob: f8be627b07042ebf3817d9d4848b00622ea9be1f [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 1999-2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#ifndef OSPF6_MESSAGE_H
23#define OSPF6_MESSAGE_H
24
hasso508e53e2004-05-18 18:57:06 +000025#define OSPF6_MESSAGE_BUFSIZ 4096
26
27/* Debug option */
28extern unsigned char conf_debug_ospf6_message[];
29#define OSPF6_DEBUG_MESSAGE_SEND 0x01
30#define OSPF6_DEBUG_MESSAGE_RECV 0x02
31#define OSPF6_DEBUG_MESSAGE_ON(type, level) \
32 (conf_debug_ospf6_message[type] |= (level))
33#define OSPF6_DEBUG_MESSAGE_OFF(type, level) \
34 (conf_debug_ospf6_message[type] &= ~(level))
35#define IS_OSPF6_DEBUG_MESSAGE(t, e) \
36 (conf_debug_ospf6_message[t] & OSPF6_DEBUG_MESSAGE_ ## e)
paul718e3742002-12-13 20:15:29 +000037
38/* Type */
paul718e3742002-12-13 20:15:29 +000039#define OSPF6_MESSAGE_TYPE_UNKNOWN 0x0
40#define OSPF6_MESSAGE_TYPE_HELLO 0x1 /* Discover/maintain neighbors */
41#define OSPF6_MESSAGE_TYPE_DBDESC 0x2 /* Summarize database contents */
hasso508e53e2004-05-18 18:57:06 +000042#define OSPF6_MESSAGE_TYPE_LSREQ 0x3 /* Database download request */
paul718e3742002-12-13 20:15:29 +000043#define OSPF6_MESSAGE_TYPE_LSUPDATE 0x4 /* Database update */
44#define OSPF6_MESSAGE_TYPE_LSACK 0x5 /* Flooding acknowledgment */
hasso508e53e2004-05-18 18:57:06 +000045#define OSPF6_MESSAGE_TYPE_ALL 0x6 /* For debug option */
46
47#define OSPF6_MESSAGE_TYPE_CANONICAL(T) \
48 ((T) > OSPF6_MESSAGE_TYPE_LSACK ? OSPF6_MESSAGE_TYPE_UNKNOWN : (T))
49
50extern char *ospf6_message_type_str[];
51#define OSPF6_MESSAGE_TYPE_NAME(T) \
52 (ospf6_message_type_str[ OSPF6_MESSAGE_TYPE_CANONICAL (T) ])
paul718e3742002-12-13 20:15:29 +000053
54/* OSPFv3 packet header */
55struct ospf6_header
56{
57 u_char version;
58 u_char type;
hasso508e53e2004-05-18 18:57:06 +000059 u_int16_t length;
paul718e3742002-12-13 20:15:29 +000060 u_int32_t router_id;
61 u_int32_t area_id;
hasso508e53e2004-05-18 18:57:06 +000062 u_int16_t checksum;
paul718e3742002-12-13 20:15:29 +000063 u_char instance_id;
64 u_char reserved;
65};
66
hasso508e53e2004-05-18 18:57:06 +000067#define OSPF6_MESSAGE_END(H) ((caddr_t) (H) + ntohs ((H)->length))
68
paul718e3742002-12-13 20:15:29 +000069/* Hello */
paul718e3742002-12-13 20:15:29 +000070struct ospf6_hello
71{
72 u_int32_t interface_id;
hasso508e53e2004-05-18 18:57:06 +000073 u_char priority;
paul718e3742002-12-13 20:15:29 +000074 u_char options[3];
75 u_int16_t hello_interval;
hasso508e53e2004-05-18 18:57:06 +000076 u_int16_t dead_interval;
77 u_int32_t drouter;
78 u_int32_t bdrouter;
79 /* Followed by Router-IDs */
paul718e3742002-12-13 20:15:29 +000080};
81
82/* Database Description */
83struct ospf6_dbdesc
84{
hasso508e53e2004-05-18 18:57:06 +000085 u_char reserved1;
paul718e3742002-12-13 20:15:29 +000086 u_char options[3];
87 u_int16_t ifmtu;
hasso508e53e2004-05-18 18:57:06 +000088 u_char reserved2;
paul718e3742002-12-13 20:15:29 +000089 u_char bits;
90 u_int32_t seqnum;
hasso508e53e2004-05-18 18:57:06 +000091 /* Followed by LSA Headers */
paul718e3742002-12-13 20:15:29 +000092};
paul718e3742002-12-13 20:15:29 +000093
hasso508e53e2004-05-18 18:57:06 +000094#define OSPF6_DBDESC_MSBIT (0x01) /* master/slave bit */
95#define OSPF6_DBDESC_MBIT (0x02) /* more bit */
96#define OSPF6_DBDESC_IBIT (0x04) /* initial bit */
paul718e3742002-12-13 20:15:29 +000097
98/* Link State Request */
hasso508e53e2004-05-18 18:57:06 +000099/* It is just a sequence of entries below */
100struct ospf6_lsreq_entry
paul718e3742002-12-13 20:15:29 +0000101{
hasso508e53e2004-05-18 18:57:06 +0000102 u_int16_t reserved; /* Must Be Zero */
paul718e3742002-12-13 20:15:29 +0000103 u_int16_t type; /* LS type */
104 u_int32_t id; /* Link State ID */
105 u_int32_t adv_router; /* Advertising Router */
106};
107
108/* Link State Update */
109struct ospf6_lsupdate
110{
hasso508e53e2004-05-18 18:57:06 +0000111 u_int32_t lsa_number;
112 /* Followed by LSAs */
paul718e3742002-12-13 20:15:29 +0000113};
114
115/* Link State Acknowledgement */
hasso508e53e2004-05-18 18:57:06 +0000116/* It is just a sequence of LSA Headers */
paul718e3742002-12-13 20:15:29 +0000117
hasso508e53e2004-05-18 18:57:06 +0000118/* Function definition */
119void ospf6_hello_print (struct ospf6_header *);
120void ospf6_dbdesc_print (struct ospf6_header *);
121void ospf6_lsreq_print (struct ospf6_header *);
122void ospf6_lsupdate_print (struct ospf6_header *);
123void ospf6_lsack_print (struct ospf6_header *);
paul718e3742002-12-13 20:15:29 +0000124
hasso508e53e2004-05-18 18:57:06 +0000125int ospf6_receive (struct thread *thread);
paul718e3742002-12-13 20:15:29 +0000126
hasso508e53e2004-05-18 18:57:06 +0000127int ospf6_hello_send (struct thread *thread);
128int ospf6_dbdesc_send (struct thread *thread);
129int ospf6_dbdesc_send_newone (struct thread *thread);
130int ospf6_lsreq_send (struct thread *thread);
131int ospf6_lsupdate_send_interface (struct thread *thread);
132int ospf6_lsupdate_send_neighbor (struct thread *thread);
133int ospf6_lsack_send_interface (struct thread *thread);
134int ospf6_lsack_send_neighbor (struct thread *thread);
paul718e3742002-12-13 20:15:29 +0000135
hasso508e53e2004-05-18 18:57:06 +0000136int config_write_ospf6_debug_message (struct vty *);
137void install_element_ospf6_debug_message ();
paul718e3742002-12-13 20:15:29 +0000138
139#endif /* OSPF6_MESSAGE_H */
140