]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_packet.h
Merge branch 'frr/pull/550'
[mirror_frr.git] / ospfd / ospf_packet.h
1 /*
2 * OSPF Sending and Receiving OSPF Packets.
3 * Copyright (C) 1999 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef _ZEBRA_OSPF_PACKET_H
23 #define _ZEBRA_OSPF_PACKET_H
24
25 #define OSPF_HEADER_SIZE 24U
26 #define OSPF_AUTH_SIMPLE_SIZE 8U
27 #define OSPF_AUTH_MD5_SIZE 16U
28
29 #define OSPF_MAX_PACKET_SIZE 65535U /* includes IP Header size. */
30 #define OSPF_HELLO_MIN_SIZE 20U /* not including neighbors */
31 #define OSPF_DB_DESC_MIN_SIZE 8U
32 #define OSPF_LS_REQ_MIN_SIZE 0U
33 #define OSPF_LS_UPD_MIN_SIZE 4U
34 #define OSPF_LS_ACK_MIN_SIZE 0U
35
36 #define OSPF_MSG_HELLO 1 /* OSPF Hello Message. */
37 #define OSPF_MSG_DB_DESC 2 /* OSPF Database Descriptoin Message. */
38 #define OSPF_MSG_LS_REQ 3 /* OSPF Link State Request Message. */
39 #define OSPF_MSG_LS_UPD 4 /* OSPF Link State Update Message. */
40 #define OSPF_MSG_LS_ACK 5 /* OSPF Link State Acknoledgement Message. */
41
42 #define OSPF_SEND_PACKET_DIRECT 1
43 #define OSPF_SEND_PACKET_INDIRECT 2
44 #define OSPF_SEND_PACKET_LOOP 3
45
46 #define OSPF_HELLO_REPLY_DELAY 1
47
48 /* Return values of functions involved in packet verification, see ospf6d. */
49 #define MSG_OK 0
50 #define MSG_NG 1
51
52 struct ospf_packet
53 {
54 struct ospf_packet *next;
55
56 /* Pointer to data stream. */
57 struct stream *s;
58
59 /* IP destination address. */
60 struct in_addr dst;
61
62 /* OSPF packet length. */
63 u_int16_t length;
64 };
65
66 /* OSPF packet queue structure. */
67 struct ospf_fifo
68 {
69 unsigned long count;
70
71 struct ospf_packet *head;
72 struct ospf_packet *tail;
73 };
74
75 /* OSPF packet header structure. */
76 struct ospf_header
77 {
78 u_char version; /* OSPF Version. */
79 u_char type; /* Packet Type. */
80 u_int16_t length; /* Packet Length. */
81 struct in_addr router_id; /* Router ID. */
82 struct in_addr area_id; /* Area ID. */
83 u_int16_t checksum; /* Check Sum. */
84 u_int16_t auth_type; /* Authentication Type. */
85 /* Authentication Data. */
86 union
87 {
88 /* Simple Authentication. */
89 u_char auth_data [OSPF_AUTH_SIMPLE_SIZE];
90 /* Cryptographic Authentication. */
91 struct
92 {
93 u_int16_t zero; /* Should be 0. */
94 u_char key_id; /* Key ID. */
95 u_char auth_data_len; /* Auth Data Length. */
96 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number. */
97 } crypt;
98 } u;
99 };
100
101 /* OSPF Hello body format. */
102 struct ospf_hello
103 {
104 struct in_addr network_mask;
105 u_int16_t hello_interval;
106 u_char options;
107 u_char priority;
108 u_int32_t dead_interval;
109 struct in_addr d_router;
110 struct in_addr bd_router;
111 struct in_addr neighbors[1];
112 };
113
114 /* OSPF Database Description body format. */
115 struct ospf_db_desc
116 {
117 u_int16_t mtu;
118 u_char options;
119 u_char flags;
120 u_int32_t dd_seqnum;
121 };
122
123 struct ospf_ls_update
124 {
125 u_int32_t num_lsas;
126 };
127
128 /* Macros. */
129 /* XXX Perhaps obsolete; function in ospf_packet.c */
130 #define OSPF_PACKET_MAX(oi) ospf_packet_max (oi)
131
132 #define OSPF_OUTPUT_PNT(S) ((S)->data + (S)->putp)
133 #define OSPF_OUTPUT_LENGTH(S) ((S)->endp)
134
135 #define IS_SET_DD_MS(X) ((X) & OSPF_DD_FLAG_MS)
136 #define IS_SET_DD_M(X) ((X) & OSPF_DD_FLAG_M)
137 #define IS_SET_DD_I(X) ((X) & OSPF_DD_FLAG_I)
138 #define IS_SET_DD_ALL(X) ((X) & OSPF_DD_FLAG_ALL)
139
140 /* Prototypes. */
141 extern void ospf_output_forward (struct stream *, int);
142 extern struct ospf_packet *ospf_packet_new (size_t);
143 extern void ospf_packet_free (struct ospf_packet *);
144 extern struct ospf_fifo *ospf_fifo_new (void);
145 extern void ospf_fifo_push (struct ospf_fifo *, struct ospf_packet *);
146 extern struct ospf_packet *ospf_fifo_pop (struct ospf_fifo *);
147 extern struct ospf_packet *ospf_fifo_head (struct ospf_fifo *);
148 extern void ospf_fifo_flush (struct ospf_fifo *);
149 extern void ospf_fifo_free (struct ospf_fifo *);
150 extern void ospf_packet_add (struct ospf_interface *, struct ospf_packet *);
151 extern void ospf_packet_delete (struct ospf_interface *);
152 extern struct stream *ospf_stream_dup (struct stream *);
153 extern struct ospf_packet *ospf_packet_dup (struct ospf_packet *);
154
155 extern int ospf_read (struct thread *);
156 extern void ospf_hello_send (struct ospf_interface *);
157 extern void ospf_db_desc_send (struct ospf_neighbor *);
158 extern void ospf_db_desc_resend (struct ospf_neighbor *);
159 extern void ospf_ls_req_send (struct ospf_neighbor *);
160 extern void ospf_ls_upd_send_lsa (struct ospf_neighbor *, struct ospf_lsa *,
161 int);
162 extern void ospf_ls_upd_send (struct ospf_neighbor *, struct list *, int);
163 extern void ospf_ls_ack_send (struct ospf_neighbor *, struct ospf_lsa *);
164 extern void ospf_ls_ack_send_delayed (struct ospf_interface *);
165 extern void ospf_ls_retransmit (struct ospf_interface *, struct ospf_lsa *);
166 extern void ospf_ls_req_event (struct ospf_neighbor *);
167
168 extern int ospf_ls_upd_timer (struct thread *);
169 extern int ospf_ls_ack_timer (struct thread *);
170 extern int ospf_poll_timer (struct thread *);
171 extern int ospf_hello_reply_timer (struct thread *);
172
173 extern const struct message ospf_packet_type_str[];
174 extern const size_t ospf_packet_type_str_max;
175
176 extern void ospf_proactively_arp (struct ospf_neighbor *);
177
178 #endif /* _ZEBRA_OSPF_PACKET_H */