]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_packet.h
Merge pull request #13677 from LabNConsulting/chopps/bad-abstract
[mirror_frr.git] / ospfd / ospf_packet.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * OSPF Sending and Receiving OSPF Packets.
4 * Copyright (C) 1999 Toshiaki Takada
5 */
6
7 #ifndef _ZEBRA_OSPF_PACKET_H
8 #define _ZEBRA_OSPF_PACKET_H
9
10 #define OSPF_HEADER_SIZE 24U
11 #define OSPF_AUTH_SIMPLE_SIZE 8U
12 #define OSPF_AUTH_MD5_SIZE 16U
13
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
20
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. */
26
27 #define OSPF_SEND_PACKET_DIRECT 1
28 #define OSPF_SEND_PACKET_INDIRECT 2
29 #define OSPF_SEND_PACKET_LOOP 3
30
31 #define OSPF_HELLO_REPLY_DELAY 1
32
33 /* Return values of functions involved in packet verification, see ospf6d. */
34 #define MSG_OK 0
35 #define MSG_NG 1
36
37 struct ospf_packet {
38 struct ospf_packet *next;
39
40 /* Pointer to data stream. */
41 struct stream *s;
42
43 /* IP destination address. */
44 struct in_addr dst;
45
46 /* OSPF packet length. */
47 uint16_t length;
48 };
49
50 /* OSPF packet queue structure. */
51 struct ospf_fifo {
52 unsigned long count;
53
54 struct ospf_packet *head;
55 struct ospf_packet *tail;
56 };
57
58 /* OSPF packet header structure. */
59 struct ospf_header {
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. */
68 union {
69 /* Simple Authentication. */
70 uint8_t auth_data[OSPF_AUTH_SIMPLE_SIZE];
71 /* Cryptographic Authentication. */
72 struct {
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
77 Number. */
78 } crypt;
79 } u;
80 };
81
82 /* OSPF Hello body format. */
83 struct ospf_hello {
84 struct in_addr network_mask;
85 uint16_t hello_interval;
86 uint8_t options;
87 uint8_t priority;
88 uint32_t dead_interval;
89 struct in_addr d_router;
90 struct in_addr bd_router;
91 struct in_addr neighbors[1];
92 };
93
94 /* OSPF Database Description body format. */
95 struct ospf_db_desc {
96 uint16_t mtu;
97 uint8_t options;
98 uint8_t flags;
99 uint32_t dd_seqnum;
100 };
101
102 struct ospf_ls_update {
103 uint32_t num_lsas;
104 };
105
106 /* Macros. */
107 /* XXX Perhaps obsolete; function in ospf_packet.c */
108 #define OSPF_PACKET_MAX(oi) ospf_packet_max (oi)
109
110 #define OSPF_OUTPUT_PNT(S) ((S)->data + (S)->putp)
111 #define OSPF_OUTPUT_LENGTH(S) ((S)->endp)
112
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)
117
118 /* Prototypes. */
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 *);
126
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 *,
133 int);
134 extern void ospf_ls_upd_send(struct ospf_neighbor *, struct list *, int, int);
135 extern void ospf_ls_upd_queue_send(struct ospf_interface *oi,
136 struct list *update, struct in_addr addr,
137 int send_lsupd_now);
138 extern void ospf_ls_ack_send(struct ospf_neighbor *, struct ospf_lsa *);
139 extern void ospf_ls_ack_send_delayed(struct ospf_interface *);
140 extern void ospf_ls_retransmit(struct ospf_interface *, struct ospf_lsa *);
141 extern void ospf_ls_req_event(struct ospf_neighbor *);
142
143 extern void ospf_ls_upd_timer(struct event *thread);
144 extern void ospf_ls_ack_timer(struct event *thread);
145 extern void ospf_poll_timer(struct event *thread);
146 extern void ospf_hello_reply_timer(struct event *thread);
147
148 extern const struct message ospf_packet_type_str[];
149 extern const size_t ospf_packet_type_str_max;
150
151 extern void ospf_proactively_arp(struct ospf_neighbor *);
152
153 #endif /* _ZEBRA_OSPF_PACKET_H */