]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* |
3 | * OSPF Sending and Receiving OSPF Packets. | |
4 | * Copyright (C) 1999 Toshiaki Takada | |
718e3744 | 5 | */ |
6 | ||
7 | #ifndef _ZEBRA_OSPF_PACKET_H | |
8 | #define _ZEBRA_OSPF_PACKET_H | |
9 | ||
6c835671 | 10 | #define OSPF_HEADER_SIZE 24U |
11 | #define OSPF_AUTH_SIMPLE_SIZE 8U | |
12 | #define OSPF_AUTH_MD5_SIZE 16U | |
718e3744 | 13 | |
6c835671 | 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 | |
718e3744 | 20 | |
96fad84a | 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. */ | |
718e3744 | 26 | |
27 | #define OSPF_SEND_PACKET_DIRECT 1 | |
28 | #define OSPF_SEND_PACKET_INDIRECT 2 | |
718e3744 | 29 | #define OSPF_SEND_PACKET_LOOP 3 |
718e3744 | 30 | |
31 | #define OSPF_HELLO_REPLY_DELAY 1 | |
32 | ||
75c8eabb DO |
33 | /* Return values of functions involved in packet verification, see ospf6d. */ |
34 | #define MSG_OK 0 | |
35 | #define MSG_NG 1 | |
36 | ||
d62a17ae | 37 | struct ospf_packet { |
38 | struct ospf_packet *next; | |
718e3744 | 39 | |
d62a17ae | 40 | /* Pointer to data stream. */ |
41 | struct stream *s; | |
718e3744 | 42 | |
d62a17ae | 43 | /* IP destination address. */ |
44 | struct in_addr dst; | |
718e3744 | 45 | |
d62a17ae | 46 | /* OSPF packet length. */ |
d7c0a89a | 47 | uint16_t length; |
718e3744 | 48 | }; |
49 | ||
50 | /* OSPF packet queue structure. */ | |
d62a17ae | 51 | struct ospf_fifo { |
52 | unsigned long count; | |
718e3744 | 53 | |
d62a17ae | 54 | struct ospf_packet *head; |
55 | struct ospf_packet *tail; | |
718e3744 | 56 | }; |
57 | ||
58 | /* OSPF packet header structure. */ | |
d62a17ae | 59 | struct ospf_header { |
d7c0a89a QY |
60 | uint8_t version; /* OSPF Version. */ |
61 | uint8_t type; /* Packet Type. */ | |
62 | uint16_t length; /* Packet Length. */ | |
d62a17ae | 63 | struct in_addr router_id; /* Router ID. */ |
64 | struct in_addr area_id; /* Area ID. */ | |
d7c0a89a QY |
65 | uint16_t checksum; /* Check Sum. */ |
66 | uint16_t auth_type; /* Authentication Type. */ | |
d62a17ae | 67 | /* Authentication Data. */ |
68 | union { | |
69 | /* Simple Authentication. */ | |
d7c0a89a | 70 | uint8_t auth_data[OSPF_AUTH_SIMPLE_SIZE]; |
d62a17ae | 71 | /* Cryptographic Authentication. */ |
72 | struct { | |
d7c0a89a QY |
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 | |
d62a17ae | 77 | Number. */ |
78 | } crypt; | |
79 | } u; | |
718e3744 | 80 | }; |
81 | ||
82 | /* OSPF Hello body format. */ | |
d62a17ae | 83 | struct ospf_hello { |
84 | struct in_addr network_mask; | |
d7c0a89a QY |
85 | uint16_t hello_interval; |
86 | uint8_t options; | |
87 | uint8_t priority; | |
88 | uint32_t dead_interval; | |
d62a17ae | 89 | struct in_addr d_router; |
90 | struct in_addr bd_router; | |
91 | struct in_addr neighbors[1]; | |
718e3744 | 92 | }; |
93 | ||
94 | /* OSPF Database Description body format. */ | |
d62a17ae | 95 | struct ospf_db_desc { |
d7c0a89a QY |
96 | uint16_t mtu; |
97 | uint8_t options; | |
98 | uint8_t flags; | |
99 | uint32_t dd_seqnum; | |
718e3744 | 100 | }; |
101 | ||
d62a17ae | 102 | struct ospf_ls_update { |
d7c0a89a | 103 | uint32_t num_lsas; |
4e31de79 | 104 | }; |
718e3744 | 105 | |
106 | /* Macros. */ | |
86f1fd96 | 107 | /* XXX Perhaps obsolete; function in ospf_packet.c */ |
718e3744 | 108 | #define OSPF_PACKET_MAX(oi) ospf_packet_max (oi) |
718e3744 | 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. */ | |
d62a17ae | 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 *); | |
d62a17ae | 126 | |
cc9f21da | 127 | extern void ospf_read(struct thread *thread); |
d62a17ae | 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); | |
046460a1 | 134 | extern void ospf_ls_upd_send(struct ospf_neighbor *, struct list *, int, int); |
d62a17ae | 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 *); | |
139 | ||
cc9f21da DS |
140 | extern void ospf_ls_upd_timer(struct thread *thread); |
141 | extern void ospf_ls_ack_timer(struct thread *thread); | |
142 | extern void ospf_poll_timer(struct thread *thread); | |
143 | extern void ospf_hello_reply_timer(struct thread *thread); | |
718e3744 | 144 | |
272ca1e3 DO |
145 | extern const struct message ospf_packet_type_str[]; |
146 | extern const size_t ospf_packet_type_str_max; | |
147 | ||
d62a17ae | 148 | extern void ospf_proactively_arp(struct ospf_neighbor *); |
8b6912c2 | 149 | |
718e3744 | 150 | #endif /* _ZEBRA_OSPF_PACKET_H */ |