2
* Copyright (C) 1999 Yasuhiro Ohara
4
* This file is part of GNU Zebra.
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
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.
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.
22
#ifndef OSPF6_MESSAGE_H
23
#define OSPF6_MESSAGE_H
25
#include "ospf6_prefix.h"
26
#include "ospf6_lsa.h"
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
38
/* OSPFv3 packet header */
52
#define MAXLISTEDNBR 64
55
u_int32_t interface_id;
58
u_int16_t hello_interval;
59
u_int16_t router_dead_interval;
64
/* Database Description */
73
/* Followed by LSAs */
75
#define DEFAULT_INTERFACE_MTU 1500
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))
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))
98
#define OSPF6_DBDESC_BIT_MASTER 0x01
99
#define OSPF6_DBDESC_BIT_MORE 0x02
100
#define OSPF6_DBDESC_BIT_INITIAL 0x04
102
/* Link State Request */
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 */
111
/* Link State Update */
112
struct ospf6_lsupdate
114
u_int32_t lsupdate_num;
117
/* Link State Acknowledgement */
118
/* no need for structure,
119
it will include only LSA header in the packet body.*/
121
/* definition for ospf6_message.c */
122
#define OSPF6_MESSAGE_RECEIVE_BUFSIZE 5120
123
#define OSPF6_MESSAGE_IOVEC_END 1024
125
#define IS_OVER_MTU(message,mtu,addsize) \
126
(iov_totallen(message)+(addsize) >= \
127
(mtu)-sizeof(struct ospf6_header))
129
#define OSPF6_MESSAGE_IOVEC_SIZE 1024
130
#define OSPF6_MESSAGE_CLEAR(msg) \
133
for (x = 0; x < OSPF6_MESSAGE_IOVEC_SIZE; x++) \
135
(msg)[x].iov_base = NULL; \
136
(msg)[x].iov_len = 0; \
140
#define OSPF6_MESSAGE_ATTACH(msg,buf,bufsize) \
143
for (x = 0; x < OSPF6_MESSAGE_IOVEC_SIZE; x++) \
144
if ((msg)[x].iov_base == (void *)NULL && (msg)[x].iov_len == 0) \
146
if (x < OSPF6_MESSAGE_IOVEC_SIZE - 1) \
148
(msg)[x].iov_base = (void *)(buf); \
149
(msg)[x].iov_len = (bufsize); \
153
#define OSPF6_MESSAGE_JOIN(msg,join) \
156
for (x = 0; x < OSPF6_MESSAGE_IOVEC_SIZE; x++) \
157
if ((msg)[x].iov_base == NULL && (msg)[x].iov_len == 0) \
159
for (y = x; y < OSPF6_MESSAGE_IOVEC_SIZE; y++) \
161
(msg)[y].iov_base = (join)[y - x].iov_base; \
162
(msg)[y].iov_len = (join)[y - x].iov_len; \
168
struct ospf6_message_stat
171
u_int32_t send_octet;
173
u_int32_t recv_octet;
177
extern char *ospf6_message_type_string[];
179
/* Function Prototypes */
180
int ospf6_receive (struct thread *);
182
int ospf6_send_hello (struct thread *);
183
int ospf6_send_dbdesc_rxmt (struct thread *);
184
int ospf6_send_dbdesc (struct thread *);
185
int ospf6_send_lsreq (struct thread *);
187
struct ospf6_neighbor;
188
struct ospf6_interface;
190
ospf6_send_lsupdate_rxmt (struct thread *);
192
ospf6_send_lsupdate_direct (struct ospf6_lsa *, struct ospf6_neighbor *);
194
ospf6_send_lsupdate_flood (struct ospf6_lsa *, struct ospf6_interface *);
196
int ospf6_send_lsack_delayed (struct thread *);
197
int ospf6_send_lsack_direct (struct thread *);
199
void ospf6_message_send (u_char, struct iovec *, struct in6_addr *, u_int);
201
#endif /* OSPF6_MESSAGE_H */