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