]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_message.h
Start of new ospf6d merge from Zebra.
[mirror_frr.git] / ospf6d / ospf6_message.h
CommitLineData
718e3744 1/*
2 * Copyright (C) 1999 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#ifndef OSPF6_MESSAGE_H
23#define OSPF6_MESSAGE_H
24
25#include "ospf6_prefix.h"
26#include "ospf6_lsa.h"
27
28/* Type */
29#define OSPF6_MESSAGE_TYPE_NONE 0x0
30#define OSPF6_MESSAGE_TYPE_UNKNOWN 0x0
31#define OSPF6_MESSAGE_TYPE_HELLO 0x1 /* Discover/maintain neighbors */
32#define OSPF6_MESSAGE_TYPE_DBDESC 0x2 /* Summarize database contents */
33#define OSPF6_MESSAGE_TYPE_LSREQ 0x3 /* Database download */
34#define OSPF6_MESSAGE_TYPE_LSUPDATE 0x4 /* Database update */
35#define OSPF6_MESSAGE_TYPE_LSACK 0x5 /* Flooding acknowledgment */
36#define OSPF6_MESSAGE_TYPE_MAX 0x6
37
38/* OSPFv3 packet header */
39struct ospf6_header
40{
41 u_char version;
42 u_char type;
43 u_int16_t len;
44 u_int32_t router_id;
45 u_int32_t area_id;
46 u_int16_t cksum;
47 u_char instance_id;
48 u_char reserved;
49};
50
51/* Hello */
52#define MAXLISTEDNBR 64
53struct ospf6_hello
54{
55 u_int32_t interface_id;
56 u_char rtr_pri;
57 u_char options[3];
58 u_int16_t hello_interval;
59 u_int16_t router_dead_interval;
60 u_int32_t dr;
61 u_int32_t bdr;
62};
63
64/* Database Description */
65struct ospf6_dbdesc
66{
67 u_char mbz1;
68 u_char options[3];
69 u_int16_t ifmtu;
70 u_char mbz2;
71 u_char bits;
72 u_int32_t seqnum;
73 /* Followed by LSAs */
74};
75#define DEFAULT_INTERFACE_MTU 1500
76
77#define DD_IS_MSBIT_SET(x) ((x) & (1 << 0))
78#define DD_MSBIT_SET(x) ((x) |= (1 << 0))
79#define DD_MSBIT_CLEAR(x) ((x) &= ~(1 << 0))
80#define DD_IS_MBIT_SET(x) ((x) & (1 << 1))
81#define DD_MBIT_SET(x) ((x) |= (1 << 1))
82#define DD_MBIT_CLEAR(x) ((x) &= ~(1 << 1))
83#define DD_IS_IBIT_SET(x) ((x) & (1 << 2))
84#define DD_IBIT_SET(x) ((x) |= (1 << 2))
85#define DD_IBIT_CLEAR(x) ((x) &= ~(1 << 2))
86
87#define DDBIT_IS_MASTER(x) ((x) & (1 << 0))
88#define DDBIT_IS_SLAVE(x) (!((x) & (1 << 0)))
89#define DDBIT_SET_MASTER(x) ((x) |= (1 << 0))
90#define DDBIT_SET_SLAVE(x) ((x) |= ~(1 << 0))
91#define DDBIT_IS_MORE(x) ((x) & (1 << 1))
92#define DDBIT_SET_MORE(x) ((x) |= (1 << 1))
93#define DDBIT_CLR_MORE(x) ((x) |= ~(1 << 1))
94#define DDBIT_IS_INITIAL(x) ((x) & (1 << 2))
95#define DDBIT_SET_INITIAL(x) ((x) |= (1 << 2))
96#define DDBIT_CLR_INITIAL(x) ((x) |= ~(1 << 2))
97
98#define OSPF6_DBDESC_BIT_MASTER 0x01
99#define OSPF6_DBDESC_BIT_MORE 0x02
100#define OSPF6_DBDESC_BIT_INITIAL 0x04
101
102/* Link State Request */
103struct ospf6_lsreq
104{
105 u_int16_t mbz; /* Must Be Zero */
106 u_int16_t type; /* LS type */
107 u_int32_t id; /* Link State ID */
108 u_int32_t adv_router; /* Advertising Router */
109};
110
111/* Link State Update */
112struct ospf6_lsupdate
113{
114 u_int32_t lsupdate_num;
115};
116
117/* Link State Acknowledgement */
118 /* no need for structure,
119 it will include only LSA header in the packet body.*/
120
121/* definition for ospf6_message.c */
122#define OSPF6_MESSAGE_RECEIVE_BUFSIZE 5120
123#define OSPF6_MESSAGE_IOVEC_END 1024
124
125#define IS_OVER_MTU(message,mtu,addsize) \
126 (iov_totallen(message)+(addsize) >= \
127 (mtu)-sizeof(struct ospf6_header))
128
129#define OSPF6_MESSAGE_IOVEC_SIZE 1024
130#define OSPF6_MESSAGE_CLEAR(msg) \
131do { \
132 int x; \
133 for (x = 0; x < OSPF6_MESSAGE_IOVEC_SIZE; x++) \
134 { \
135 (msg)[x].iov_base = NULL; \
136 (msg)[x].iov_len = 0; \
137 } \
138} while (0)
139
140#define OSPF6_MESSAGE_ATTACH(msg,buf,bufsize) \
141do { \
142 int x; \
143 for (x = 0; x < OSPF6_MESSAGE_IOVEC_SIZE; x++) \
144 if ((msg)[x].iov_base == (void *)NULL && (msg)[x].iov_len == 0) \
145 break; \
146 if (x < OSPF6_MESSAGE_IOVEC_SIZE - 1) \
147 { \
148 (msg)[x].iov_base = (void *)(buf); \
149 (msg)[x].iov_len = (bufsize); \
150 } \
151} while (0)
152
153#define OSPF6_MESSAGE_JOIN(msg,join) \
154do { \
155 int x,y; \
156 for (x = 0; x < OSPF6_MESSAGE_IOVEC_SIZE; x++) \
157 if ((msg)[x].iov_base == NULL && (msg)[x].iov_len == 0) \
158 break; \
159 for (y = x; y < OSPF6_MESSAGE_IOVEC_SIZE; y++) \
160 { \
161 (msg)[y].iov_base = (join)[y - x].iov_base; \
162 (msg)[y].iov_len = (join)[y - x].iov_len; \
163 } \
164} while (0)
165
166
167/* Statistics */
168struct ospf6_message_stat
169{
170 u_int32_t send;
171 u_int32_t send_octet;
172 u_int32_t recv;
173 u_int32_t recv_octet;
174};
175
176/* Type string */
177extern char *ospf6_message_type_string[];
178
179/* Function Prototypes */
180int ospf6_receive (struct thread *);
181
182int ospf6_send_hello (struct thread *);
183int ospf6_send_dbdesc_rxmt (struct thread *);
184int ospf6_send_dbdesc (struct thread *);
185int ospf6_send_lsreq (struct thread *);
186
187struct ospf6_neighbor;
188struct ospf6_interface;
189int
190ospf6_send_lsupdate_rxmt (struct thread *);
191void
192ospf6_send_lsupdate_direct (struct ospf6_lsa *, struct ospf6_neighbor *);
193void
194ospf6_send_lsupdate_flood (struct ospf6_lsa *, struct ospf6_interface *);
195
196int ospf6_send_lsack_delayed (struct thread *);
197int ospf6_send_lsack_direct (struct thread *);
198
199void ospf6_message_send (u_char, struct iovec *, struct in6_addr *, u_int);
200
201#endif /* OSPF6_MESSAGE_H */
202