]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_packet.h
bgpd: move non-best local path checks outside the function
[mirror_frr.git] / ospfd / ospf_packet.h
CommitLineData
718e3744 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 *
896014f4
DL
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
718e3744 20 */
21
22#ifndef _ZEBRA_OSPF_PACKET_H
23#define _ZEBRA_OSPF_PACKET_H
24
6c835671 25#define OSPF_HEADER_SIZE 24U
26#define OSPF_AUTH_SIMPLE_SIZE 8U
27#define OSPF_AUTH_MD5_SIZE 16U
718e3744 28
6c835671 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
718e3744 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
718e3744 44#define OSPF_SEND_PACKET_LOOP 3
718e3744 45
46#define OSPF_HELLO_REPLY_DELAY 1
47
75c8eabb
DO
48/* Return values of functions involved in packet verification, see ospf6d. */
49#define MSG_OK 0
50#define MSG_NG 1
51
d62a17ae 52struct ospf_packet {
53 struct ospf_packet *next;
718e3744 54
d62a17ae 55 /* Pointer to data stream. */
56 struct stream *s;
718e3744 57
d62a17ae 58 /* IP destination address. */
59 struct in_addr dst;
718e3744 60
d62a17ae 61 /* OSPF packet length. */
d7c0a89a 62 uint16_t length;
718e3744 63};
64
65/* OSPF packet queue structure. */
d62a17ae 66struct ospf_fifo {
67 unsigned long count;
718e3744 68
d62a17ae 69 struct ospf_packet *head;
70 struct ospf_packet *tail;
718e3744 71};
72
73/* OSPF packet header structure. */
d62a17ae 74struct ospf_header {
d7c0a89a
QY
75 uint8_t version; /* OSPF Version. */
76 uint8_t type; /* Packet Type. */
77 uint16_t length; /* Packet Length. */
d62a17ae 78 struct in_addr router_id; /* Router ID. */
79 struct in_addr area_id; /* Area ID. */
d7c0a89a
QY
80 uint16_t checksum; /* Check Sum. */
81 uint16_t auth_type; /* Authentication Type. */
d62a17ae 82 /* Authentication Data. */
83 union {
84 /* Simple Authentication. */
d7c0a89a 85 uint8_t auth_data[OSPF_AUTH_SIMPLE_SIZE];
d62a17ae 86 /* Cryptographic Authentication. */
87 struct {
d7c0a89a
QY
88 uint16_t zero; /* Should be 0. */
89 uint8_t key_id; /* Key ID. */
90 uint8_t auth_data_len; /* Auth Data Length. */
91 uint32_t crypt_seqnum; /* Cryptographic Sequence
d62a17ae 92 Number. */
93 } crypt;
94 } u;
718e3744 95};
96
97/* OSPF Hello body format. */
d62a17ae 98struct ospf_hello {
99 struct in_addr network_mask;
d7c0a89a
QY
100 uint16_t hello_interval;
101 uint8_t options;
102 uint8_t priority;
103 uint32_t dead_interval;
d62a17ae 104 struct in_addr d_router;
105 struct in_addr bd_router;
106 struct in_addr neighbors[1];
718e3744 107};
108
109/* OSPF Database Description body format. */
d62a17ae 110struct ospf_db_desc {
d7c0a89a
QY
111 uint16_t mtu;
112 uint8_t options;
113 uint8_t flags;
114 uint32_t dd_seqnum;
718e3744 115};
116
d62a17ae 117struct ospf_ls_update {
d7c0a89a 118 uint32_t num_lsas;
4e31de79 119};
718e3744 120
121/* Macros. */
86f1fd96 122/* XXX Perhaps obsolete; function in ospf_packet.c */
718e3744 123#define OSPF_PACKET_MAX(oi) ospf_packet_max (oi)
718e3744 124
125#define OSPF_OUTPUT_PNT(S) ((S)->data + (S)->putp)
126#define OSPF_OUTPUT_LENGTH(S) ((S)->endp)
127
128#define IS_SET_DD_MS(X) ((X) & OSPF_DD_FLAG_MS)
129#define IS_SET_DD_M(X) ((X) & OSPF_DD_FLAG_M)
130#define IS_SET_DD_I(X) ((X) & OSPF_DD_FLAG_I)
131#define IS_SET_DD_ALL(X) ((X) & OSPF_DD_FLAG_ALL)
132
133/* Prototypes. */
d62a17ae 134extern void ospf_output_forward(struct stream *, int);
135extern struct ospf_packet *ospf_packet_new(size_t);
136extern void ospf_packet_free(struct ospf_packet *);
137extern struct ospf_fifo *ospf_fifo_new(void);
138extern void ospf_fifo_push(struct ospf_fifo *, struct ospf_packet *);
139extern struct ospf_packet *ospf_fifo_pop(struct ospf_fifo *);
140extern struct ospf_packet *ospf_fifo_head(struct ospf_fifo *);
141extern void ospf_fifo_flush(struct ospf_fifo *);
142extern void ospf_fifo_free(struct ospf_fifo *);
143extern void ospf_packet_add(struct ospf_interface *, struct ospf_packet *);
144extern void ospf_packet_delete(struct ospf_interface *);
145extern struct stream *ospf_stream_dup(struct stream *);
146extern struct ospf_packet *ospf_packet_dup(struct ospf_packet *);
147
148extern int ospf_read(struct thread *);
149extern void ospf_hello_send(struct ospf_interface *);
150extern void ospf_db_desc_send(struct ospf_neighbor *);
151extern void ospf_db_desc_resend(struct ospf_neighbor *);
152extern void ospf_ls_req_send(struct ospf_neighbor *);
153extern void ospf_ls_upd_send_lsa(struct ospf_neighbor *, struct ospf_lsa *,
154 int);
046460a1 155extern void ospf_ls_upd_send(struct ospf_neighbor *, struct list *, int, int);
d62a17ae 156extern void ospf_ls_ack_send(struct ospf_neighbor *, struct ospf_lsa *);
157extern void ospf_ls_ack_send_delayed(struct ospf_interface *);
158extern void ospf_ls_retransmit(struct ospf_interface *, struct ospf_lsa *);
159extern void ospf_ls_req_event(struct ospf_neighbor *);
160
161extern int ospf_ls_upd_timer(struct thread *);
162extern int ospf_ls_ack_timer(struct thread *);
163extern int ospf_poll_timer(struct thread *);
164extern int ospf_hello_reply_timer(struct thread *);
718e3744 165
272ca1e3
DO
166extern const struct message ospf_packet_type_str[];
167extern const size_t ospf_packet_type_str_max;
168
d62a17ae 169extern void ospf_proactively_arp(struct ospf_neighbor *);
8b6912c2 170
718e3744 171#endif /* _ZEBRA_OSPF_PACKET_H */