paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 1999-2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3 | * |
| 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 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 25 | #define OSPF6_MESSAGE_BUFSIZ 4096 |
| 26 | |
| 27 | /* Debug option */ |
| 28 | extern 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) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | |
| 38 | /* Type */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 39 | #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 */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 42 | #define OSPF6_MESSAGE_TYPE_LSREQ 0x3 /* Database download request */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 43 | #define OSPF6_MESSAGE_TYPE_LSUPDATE 0x4 /* Database update */ |
| 44 | #define OSPF6_MESSAGE_TYPE_LSACK 0x5 /* Flooding acknowledgment */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 45 | #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 | |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 50 | extern const char *ospf6_message_type_str[]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 51 | #define OSPF6_MESSAGE_TYPE_NAME(T) \ |
| 52 | (ospf6_message_type_str[ OSPF6_MESSAGE_TYPE_CANONICAL (T) ]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 53 | |
| 54 | /* OSPFv3 packet header */ |
Denis Ovsienko | 552563a | 2011-09-26 13:18:51 +0400 | [diff] [blame] | 55 | #define OSPF6_HEADER_SIZE 16U |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 56 | struct ospf6_header |
| 57 | { |
| 58 | u_char version; |
| 59 | u_char type; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 60 | u_int16_t length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | u_int32_t router_id; |
| 62 | u_int32_t area_id; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 63 | u_int16_t checksum; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 64 | u_char instance_id; |
| 65 | u_char reserved; |
| 66 | }; |
| 67 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 68 | #define OSPF6_MESSAGE_END(H) ((caddr_t) (H) + ntohs ((H)->length)) |
| 69 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 70 | /* Hello */ |
Denis Ovsienko | 552563a | 2011-09-26 13:18:51 +0400 | [diff] [blame] | 71 | #define OSPF6_HELLO_MIN_SIZE 20U |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | struct ospf6_hello |
| 73 | { |
| 74 | u_int32_t interface_id; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 75 | u_char priority; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | u_char options[3]; |
| 77 | u_int16_t hello_interval; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 78 | u_int16_t dead_interval; |
| 79 | u_int32_t drouter; |
| 80 | u_int32_t bdrouter; |
| 81 | /* Followed by Router-IDs */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | /* Database Description */ |
Denis Ovsienko | 552563a | 2011-09-26 13:18:51 +0400 | [diff] [blame] | 85 | #define OSPF6_DB_DESC_MIN_SIZE 12U |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 86 | struct ospf6_dbdesc |
| 87 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 88 | u_char reserved1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 89 | u_char options[3]; |
| 90 | u_int16_t ifmtu; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 91 | u_char reserved2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 92 | u_char bits; |
| 93 | u_int32_t seqnum; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 94 | /* Followed by LSA Headers */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 95 | }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 96 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 97 | #define OSPF6_DBDESC_MSBIT (0x01) /* master/slave bit */ |
| 98 | #define OSPF6_DBDESC_MBIT (0x02) /* more bit */ |
| 99 | #define OSPF6_DBDESC_IBIT (0x04) /* initial bit */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 100 | |
| 101 | /* Link State Request */ |
Denis Ovsienko | 552563a | 2011-09-26 13:18:51 +0400 | [diff] [blame] | 102 | #define OSPF6_LS_REQ_MIN_SIZE 0U |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 103 | /* It is just a sequence of entries below */ |
Denis Ovsienko | 552563a | 2011-09-26 13:18:51 +0400 | [diff] [blame] | 104 | #define OSPF6_LSREQ_LSDESC_FIX_SIZE 12U |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 105 | struct ospf6_lsreq_entry |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 106 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 107 | u_int16_t reserved; /* Must Be Zero */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 108 | u_int16_t type; /* LS type */ |
| 109 | u_int32_t id; /* Link State ID */ |
| 110 | u_int32_t adv_router; /* Advertising Router */ |
| 111 | }; |
| 112 | |
| 113 | /* Link State Update */ |
Denis Ovsienko | 552563a | 2011-09-26 13:18:51 +0400 | [diff] [blame] | 114 | #define OSPF6_LS_UPD_MIN_SIZE 4U |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 115 | struct ospf6_lsupdate |
| 116 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 117 | u_int32_t lsa_number; |
| 118 | /* Followed by LSAs */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | /* Link State Acknowledgement */ |
Denis Ovsienko | 552563a | 2011-09-26 13:18:51 +0400 | [diff] [blame] | 122 | #define OSPF6_LS_ACK_MIN_SIZE 0U |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 123 | /* It is just a sequence of LSA Headers */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 124 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 125 | /* Function definition */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 126 | extern void ospf6_hello_print (struct ospf6_header *); |
| 127 | extern void ospf6_dbdesc_print (struct ospf6_header *); |
| 128 | extern void ospf6_lsreq_print (struct ospf6_header *); |
| 129 | extern void ospf6_lsupdate_print (struct ospf6_header *); |
| 130 | extern void ospf6_lsack_print (struct ospf6_header *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 132 | extern int ospf6_iobuf_size (unsigned int size); |
| 133 | extern int ospf6_receive (struct thread *thread); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 135 | extern int ospf6_hello_send (struct thread *thread); |
| 136 | extern int ospf6_dbdesc_send (struct thread *thread); |
| 137 | extern int ospf6_dbdesc_send_newone (struct thread *thread); |
| 138 | extern int ospf6_lsreq_send (struct thread *thread); |
| 139 | extern int ospf6_lsupdate_send_interface (struct thread *thread); |
| 140 | extern int ospf6_lsupdate_send_neighbor (struct thread *thread); |
| 141 | extern int ospf6_lsack_send_interface (struct thread *thread); |
| 142 | extern int ospf6_lsack_send_neighbor (struct thread *thread); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 143 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 144 | extern int config_write_ospf6_debug_message (struct vty *); |
| 145 | extern void install_element_ospf6_debug_message (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | |
| 147 | #endif /* OSPF6_MESSAGE_H */ |
| 148 | |