]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_message.h
Merge pull request #12105 from opensourcerouting/fix/bgp_list_sequence_handling_frr...
[mirror_frr.git] / ospf6d / ospf6_message.h
1 /*
2 * Copyright (C) 1999-2003 Yasuhiro Ohara
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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef OSPF6_MESSAGE_H
22 #define OSPF6_MESSAGE_H
23
24 #define OSPF6_MESSAGE_BUFSIZ 4096
25
26 /* Debug option */
27 extern unsigned char conf_debug_ospf6_message[];
28
29 #define OSPF6_ACTION_SEND 0x01
30 #define OSPF6_ACTION_RECV 0x02
31 #define OSPF6_DEBUG_MESSAGE_SEND 0x01
32 #define OSPF6_DEBUG_MESSAGE_RECV 0x02
33 #define OSPF6_DEBUG_MESSAGE_SEND_HDR 0x04
34 #define OSPF6_DEBUG_MESSAGE_RECV_HDR 0x08
35 #define OSPF6_DEBUG_MESSAGE_SEND_BOTH \
36 OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_SEND_HDR
37 #define OSPF6_DEBUG_MESSAGE_RECV_BOTH \
38 OSPF6_DEBUG_MESSAGE_RECV | OSPF6_DEBUG_MESSAGE_RECV_HDR
39
40 #define OSPF6_DEBUG_MESSAGE_ON(type, level) \
41 (conf_debug_ospf6_message[type] |= (level))
42 #define OSPF6_DEBUG_MESSAGE_OFF(type, level) \
43 (conf_debug_ospf6_message[type] &= ~(level))
44
45 #define IS_OSPF6_DEBUG_MESSAGE(t, e) \
46 (((OSPF6_DEBUG_MESSAGE_##e) == OSPF6_DEBUG_MESSAGE_RECV_HDR) \
47 ? (conf_debug_ospf6_message[t] \
48 & (OSPF6_DEBUG_MESSAGE_RECV_BOTH)) \
49 : (((OSPF6_DEBUG_MESSAGE_##e) == OSPF6_DEBUG_MESSAGE_SEND_HDR) \
50 ? (conf_debug_ospf6_message[t] \
51 & (OSPF6_DEBUG_MESSAGE_SEND_BOTH)) \
52 : (conf_debug_ospf6_message[t] \
53 & (OSPF6_DEBUG_MESSAGE_##e))))
54
55 #define IS_OSPF6_DEBUG_MESSAGE_ENABLED(type, e) \
56 (conf_debug_ospf6_message[type] & (OSPF6_DEBUG_MESSAGE_##e))
57
58 /* Type */
59 #define OSPF6_MESSAGE_TYPE_UNKNOWN 0x0
60 #define OSPF6_MESSAGE_TYPE_HELLO 0x1 /* Discover/maintain neighbors */
61 #define OSPF6_MESSAGE_TYPE_DBDESC 0x2 /* Summarize database contents */
62 #define OSPF6_MESSAGE_TYPE_LSREQ 0x3 /* Database download request */
63 #define OSPF6_MESSAGE_TYPE_LSUPDATE 0x4 /* Database update */
64 #define OSPF6_MESSAGE_TYPE_LSACK 0x5 /* Flooding acknowledgment */
65 #define OSPF6_MESSAGE_TYPE_ALL 0x6 /* For debug option */
66 #define OSPF6_MESSAGE_TYPE_MAX 0x6 /* same as OSPF6_MESSAGE_TYPE_ALL */
67
68 struct ospf6_packet {
69 struct ospf6_packet *next;
70
71 /* Pointer to data stream. */
72 struct stream *s;
73
74 /* IP destination address. */
75 struct in6_addr dst;
76
77 /* OSPF6 packet length. */
78 uint16_t length;
79 };
80
81 /* OSPF packet queue structure. */
82 struct ospf6_fifo {
83 unsigned long count;
84
85 struct ospf6_packet *head;
86 struct ospf6_packet *tail;
87 };
88
89 /* OSPFv3 packet header */
90 #define OSPF6_HEADER_SIZE 16U
91 struct ospf6_header {
92 uint8_t version;
93 uint8_t type;
94 uint16_t length;
95 in_addr_t router_id;
96 in_addr_t area_id;
97 uint16_t checksum;
98 uint8_t instance_id;
99 uint8_t reserved;
100 };
101
102 #define OSPF6_MESSAGE_END(H) ((caddr_t) (H) + ntohs ((H)->length))
103
104 /* Hello */
105 #define OSPF6_HELLO_MIN_SIZE 20U
106 struct ospf6_hello {
107 ifindex_t interface_id;
108 uint8_t priority;
109 uint8_t options[3];
110 uint16_t hello_interval;
111 uint16_t dead_interval;
112 in_addr_t drouter;
113 in_addr_t bdrouter;
114 /* Followed by Router-IDs */
115 };
116
117 /* Database Description */
118 #define OSPF6_DB_DESC_MIN_SIZE 12U
119 struct ospf6_dbdesc {
120 uint8_t reserved1;
121 uint8_t options[3];
122 uint16_t ifmtu;
123 uint8_t reserved2;
124 uint8_t bits;
125 uint32_t seqnum;
126 /* Followed by LSA Headers */
127 };
128
129 #define OSPF6_DBDESC_MSBIT (0x01) /* master/slave bit */
130 #define OSPF6_DBDESC_MBIT (0x02) /* more bit */
131 #define OSPF6_DBDESC_IBIT (0x04) /* initial bit */
132
133 /* Link State Request */
134 #define OSPF6_LS_REQ_MIN_SIZE 0U
135 /* It is just a sequence of entries below */
136 #define OSPF6_LSREQ_LSDESC_FIX_SIZE 12U
137 struct ospf6_lsreq_entry {
138 uint16_t reserved; /* Must Be Zero */
139 uint16_t type; /* LS type */
140 in_addr_t id; /* Link State ID */
141 in_addr_t adv_router; /* Advertising Router */
142 };
143
144 /* Link State Update */
145 #define OSPF6_LS_UPD_MIN_SIZE 4U
146 struct ospf6_lsupdate {
147 uint32_t lsa_number;
148 /* Followed by LSAs */
149 };
150
151 /* LLS is not supported, but used to derive
152 * offset of Auth_trailer
153 */
154 struct ospf6_lls_hdr {
155 uint16_t checksum;
156 uint16_t length;
157 };
158
159 /* Link State Acknowledgement */
160 #define OSPF6_LS_ACK_MIN_SIZE 0U
161 /* It is just a sequence of LSA Headers */
162
163 /* Function definition */
164 extern void ospf6_hello_print(struct ospf6_header *, int action);
165 extern void ospf6_dbdesc_print(struct ospf6_header *, int action);
166 extern void ospf6_lsreq_print(struct ospf6_header *, int action);
167 extern void ospf6_lsupdate_print(struct ospf6_header *, int action);
168 extern void ospf6_lsack_print(struct ospf6_header *, int action);
169
170 extern struct ospf6_fifo *ospf6_fifo_new(void);
171 extern void ospf6_fifo_flush(struct ospf6_fifo *fifo);
172 extern void ospf6_fifo_free(struct ospf6_fifo *fifo);
173
174 extern int ospf6_iobuf_size(unsigned int size);
175 extern void ospf6_message_terminate(void);
176 extern void ospf6_receive(struct thread *thread);
177
178 extern void ospf6_hello_send(struct thread *thread);
179 extern void ospf6_dbdesc_send(struct thread *thread);
180 extern void ospf6_dbdesc_send_newone(struct thread *thread);
181 extern void ospf6_lsreq_send(struct thread *thread);
182 extern void ospf6_lsupdate_send_interface(struct thread *thread);
183 extern void ospf6_lsupdate_send_neighbor(struct thread *thread);
184 extern void ospf6_lsack_send_interface(struct thread *thread);
185 extern void ospf6_lsack_send_neighbor(struct thread *thread);
186
187 extern int config_write_ospf6_debug_message(struct vty *);
188 extern void install_element_ospf6_debug_message(void);
189 extern const char *ospf6_message_type(int type);
190 #endif /* OSPF6_MESSAGE_H */