3 * The olsr.org Optimized Link-State Routing daemon(olsrd)
4 * Copyright (c) 2004-2009, the olsr.org team - see HISTORY file
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of olsr.org, olsrd nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * Visit http://www.olsr.org for more information.
36 * If you find this software useful feel free to make a donation
37 * to the project. For more information see the website or contact
38 * the copyright holders.
43 *Values and packet formats as proposed in RFC3626 and misc. values and
44 *data structures used by the olsr.org OLSR daemon.
47 #ifndef _PROTOCOLS_OLSR_H
48 #define _PROTOCOLS_OLSR_H
50 #include "olsr_types.h"
58 /* Default IPv6 multicast addresses */
60 #define OLSR_IPV6_MCAST_SITE_LOCAL "ff05::15"
61 #define OLSR_IPV6_MCAST_GLOBAL "ff0e::1"
63 #define OLSR_HEADERSIZE (sizeof(uint16_t) + sizeof(uint16_t))
65 #define OLSR_MSGHDRSZ_IPV4 12
66 #define OLSR_MSGHDRSZ_IPV6 24
73 #define HELLO_INTERVAL 2000
74 #define REFRESH_INTERVAL 2000
75 #define TC_INTERVAL 5000
76 #define MID_INTERVAL TC_INTERVAL
77 #define HNA_INTERVAL TC_INTERVAL
81 #define HELLO_JITTER 25 /* percent */
82 #define HNA_JITTER 25 /* percent */
83 #define MID_JITTER 25 /* percent */
84 #define TC_JITTER 25 /* percent */
90 #define NEIGHB_HOLD_TIME 3 * REFRESH_INTERVAL
91 #define TOP_HOLD_TIME 3 * TC_INTERVAL
92 #define DUP_HOLD_TIME 30000
93 #define MID_HOLD_TIME 3 * MID_INTERVAL
94 #define HNA_HOLD_TIME 3 * HNA_INTERVAL
100 #define HELLO_MESSAGE 1
102 #define MID_MESSAGE 3
103 #define HNA_MESSAGE 4
104 #define MAX_MESSAGE 4
110 #define UNSPEC_LINK 0
132 #define WILL_DEFAULT 3
134 #define WILL_ALWAYS 7
139 #define TC_REDUNDANCY 2
140 #define MPR_COVERAGE 1
145 #define MAXJITTER HELLO_INTERVAL / 4
152 /* Seqnos are 16 bit values */
154 #define MAXVALUE 0xFFFF
156 /* Macro for checking seqnos "wraparound" */
157 #define SEQNO_GREATER_THAN(s1, s2) \
158 (((s1 > s2) && (s1 - s2 <= (MAXVALUE/2))) \
159 || ((s2 > s1) && (s2 - s1 > (MAXVALUE/2))))
164 * Macros for creating and extracting the neighbor
165 * and link type information from 8bit link_code
166 * data as passed in HELLO messages
169 #define CREATE_LINK_CODE(status, link) (link | (status<<2))
171 #define EXTRACT_STATUS(link_code) ((link_code & 0xC)>>2)
173 #define EXTRACT_LINK(link_code) (link_code & 0x3)
176 /***********************************************
177 * OLSR packet definitions *
178 ***********************************************/
192 uint32_t neigh_addr[1]; /* neighbor IP address(es) */
193 } __attribute__ ((packed));
199 struct hellinfo hell_info[1];
200 } __attribute__ ((packed));
210 struct in6_addr neigh_addr[1]; /* neighbor IP address(es) */
211 } __attribute__ ((packed));
217 struct hellinfo6 hell_info[1];
218 } __attribute__ ((packed));
221 * Topology Control packet
226 } __attribute__ ((packed));
232 struct neigh_info neigh[1];
233 } __attribute__ ((packed));
242 struct in6_addr addr;
243 } __attribute__ ((packed));
249 struct neigh_info6 neigh[1];
250 } __attribute__ ((packed));
257 *Multiple Interface Declaration message
261 * Defined as s struct for further expansion
262 * For example: do we want to tell what type of interface
263 * is associated whit each address?
267 } __attribute__ ((packed));
271 struct midaddr mid_addr[1];
272 } __attribute__ ((packed));
279 struct in6_addr addr;
280 } __attribute__ ((packed));
284 struct midaddr6 mid_addr[1];
285 } __attribute__ ((packed));
293 * Host and Network Association message
298 } __attribute__ ((packed));
301 struct hnapair hna_net[1];
302 } __attribute__ ((packed));
309 struct in6_addr addr;
310 struct in6_addr netmask;
311 } __attribute__ ((packed));
314 struct hnapair6 hna_net[1];
315 } __attribute__ ((packed));
322 * OLSR message (several can exist in one OLSR packet)
326 uint8_t olsr_msgtype;
328 uint16_t olsr_msgsize;
335 struct hellomsg hello;
336 struct olsr_tcmsg tc;
341 } __attribute__ ((packed));
344 * Internal representation of the header.
345 * Used for some code sharing between message parsers.
351 union olsr_ip_addr originator;
355 } __attribute__ ((packed));
362 uint8_t olsr_msgtype;
364 uint16_t olsr_msgsize;
365 struct in6_addr originator;
371 struct hellomsg6 hello;
372 struct olsr_tcmsg6 tc;
377 } __attribute__ ((packed));
382 * Generic OLSR packet
386 uint16_t olsr_packlen; /* packet length */
388 struct olsrmsg olsr_msg[1]; /* variable messages */
389 } __attribute__ ((packed));
393 uint16_t olsr_packlen; /* packet length */
395 struct olsrmsg6 olsr_msg[1]; /* variable messages */
396 } __attribute__ ((packed));
399 /* IPv4 <-> IPv6 compability */
404 } __attribute__ ((packed));
409 } __attribute__ ((packed));
417 * indent-tabs-mode: nil