1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * OSPF Sending and Receiving OSPF Packets.
4 * Copyright (C) 1999 Toshiaki Takada
7 #ifndef _ZEBRA_OSPF_PACKET_H
8 #define _ZEBRA_OSPF_PACKET_H
10 #define OSPF_HEADER_SIZE 24U
11 #define OSPF_AUTH_SIMPLE_SIZE 8U
12 #define OSPF_AUTH_MD5_SIZE 16U
14 #define OSPF_MAX_PACKET_SIZE 65535U /* includes IP Header size. */
15 #define OSPF_HELLO_MIN_SIZE 20U /* not including neighbors */
16 #define OSPF_DB_DESC_MIN_SIZE 8U
17 #define OSPF_LS_REQ_MIN_SIZE 0U
18 #define OSPF_LS_UPD_MIN_SIZE 4U
19 #define OSPF_LS_ACK_MIN_SIZE 0U
21 #define OSPF_MSG_HELLO 1 /* OSPF Hello Message. */
22 #define OSPF_MSG_DB_DESC 2 /* OSPF Database Description Message. */
23 #define OSPF_MSG_LS_REQ 3 /* OSPF Link State Request Message. */
24 #define OSPF_MSG_LS_UPD 4 /* OSPF Link State Update Message. */
25 #define OSPF_MSG_LS_ACK 5 /* OSPF Link State Acknowledgement Message. */
27 #define OSPF_SEND_PACKET_DIRECT 1
28 #define OSPF_SEND_PACKET_INDIRECT 2
29 #define OSPF_SEND_PACKET_LOOP 3
31 #define OSPF_HELLO_REPLY_DELAY 1
33 /* Return values of functions involved in packet verification, see ospf6d. */
38 struct ospf_packet
*next
;
40 /* Pointer to data stream. */
43 /* IP destination address. */
46 /* OSPF packet length. */
50 /* OSPF packet queue structure. */
54 struct ospf_packet
*head
;
55 struct ospf_packet
*tail
;
58 /* OSPF packet header structure. */
60 uint8_t version
; /* OSPF Version. */
61 uint8_t type
; /* Packet Type. */
62 uint16_t length
; /* Packet Length. */
63 struct in_addr router_id
; /* Router ID. */
64 struct in_addr area_id
; /* Area ID. */
65 uint16_t checksum
; /* Check Sum. */
66 uint16_t auth_type
; /* Authentication Type. */
67 /* Authentication Data. */
69 /* Simple Authentication. */
70 uint8_t auth_data
[OSPF_AUTH_SIMPLE_SIZE
];
71 /* Cryptographic Authentication. */
73 uint16_t zero
; /* Should be 0. */
74 uint8_t key_id
; /* Key ID. */
75 uint8_t auth_data_len
; /* Auth Data Length. */
76 uint32_t crypt_seqnum
; /* Cryptographic Sequence
82 /* OSPF Hello body format. */
84 struct in_addr network_mask
;
85 uint16_t hello_interval
;
88 uint32_t dead_interval
;
89 struct in_addr d_router
;
90 struct in_addr bd_router
;
91 struct in_addr neighbors
[1];
94 /* OSPF Database Description body format. */
102 struct ospf_ls_update
{
107 /* XXX Perhaps obsolete; function in ospf_packet.c */
108 #define OSPF_PACKET_MAX(oi) ospf_packet_max (oi)
110 #define OSPF_OUTPUT_PNT(S) ((S)->data + (S)->putp)
111 #define OSPF_OUTPUT_LENGTH(S) ((S)->endp)
113 #define IS_SET_DD_MS(X) ((X) & OSPF_DD_FLAG_MS)
114 #define IS_SET_DD_M(X) ((X) & OSPF_DD_FLAG_M)
115 #define IS_SET_DD_I(X) ((X) & OSPF_DD_FLAG_I)
116 #define IS_SET_DD_ALL(X) ((X) & OSPF_DD_FLAG_ALL)
119 extern void ospf_packet_free(struct ospf_packet
*);
120 extern struct ospf_fifo
*ospf_fifo_new(void);
121 extern void ospf_fifo_push(struct ospf_fifo
*, struct ospf_packet
*);
122 extern struct ospf_packet
*ospf_fifo_pop(struct ospf_fifo
*);
123 extern struct ospf_packet
*ospf_fifo_head(struct ospf_fifo
*);
124 extern void ospf_fifo_flush(struct ospf_fifo
*);
125 extern void ospf_fifo_free(struct ospf_fifo
*);
127 extern void ospf_read(struct event
*thread
);
128 extern void ospf_hello_send(struct ospf_interface
*);
129 extern void ospf_db_desc_send(struct ospf_neighbor
*);
130 extern void ospf_db_desc_resend(struct ospf_neighbor
*);
131 extern void ospf_ls_req_send(struct ospf_neighbor
*);
132 extern void ospf_ls_upd_send_lsa(struct ospf_neighbor
*, struct ospf_lsa
*,
134 extern void ospf_ls_upd_send(struct ospf_neighbor
*, struct list
*, int, int);
135 extern void ospf_ls_ack_send(struct ospf_neighbor
*, struct ospf_lsa
*);
136 extern void ospf_ls_ack_send_delayed(struct ospf_interface
*);
137 extern void ospf_ls_retransmit(struct ospf_interface
*, struct ospf_lsa
*);
138 extern void ospf_ls_req_event(struct ospf_neighbor
*);
140 extern void ospf_ls_upd_timer(struct event
*thread
);
141 extern void ospf_ls_ack_timer(struct event
*thread
);
142 extern void ospf_poll_timer(struct event
*thread
);
143 extern void ospf_hello_reply_timer(struct event
*thread
);
145 extern const struct message ospf_packet_type_str
[];
146 extern const size_t ospf_packet_type_str_max
;
148 extern void ospf_proactively_arp(struct ospf_neighbor
*);
150 #endif /* _ZEBRA_OSPF_PACKET_H */