blob: af60eb922ea9862c9368ba31f2492b5204d3039a [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso049207c2004-08-04 20:02:13 +00002 * Common protocol data and data structures.
hasso508e53e2004-05-18 18:57:06 +00003 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00004 *
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 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23#ifndef OSPF6_PROTO_H
24#define OSPF6_PROTO_H
25
26/* OSPF protocol version */
hasso508e53e2004-05-18 18:57:06 +000027#define OSPFV3_VERSION 3
paul718e3742002-12-13 20:15:29 +000028
paul718e3742002-12-13 20:15:29 +000029/* TOS field normaly null */
hasso508e53e2004-05-18 18:57:06 +000030#define DEFAULT_TOS_VALUE 0x0
paul718e3742002-12-13 20:15:29 +000031
paul718e3742002-12-13 20:15:29 +000032#define ALLSPFROUTERS6 "ff02::5"
33#define ALLDROUTERS6 "ff02::6"
34
hasso508e53e2004-05-18 18:57:06 +000035#define OSPF6_ROUTER_BIT_W (1 << 3)
36#define OSPF6_ROUTER_BIT_V (1 << 2)
37#define OSPF6_ROUTER_BIT_E (1 << 1)
38#define OSPF6_ROUTER_BIT_B (1 << 0)
paul718e3742002-12-13 20:15:29 +000039
40/* OSPF options */
41/* present in HELLO, DD, LSA */
42#define OSPF6_OPT_SET(x,opt) ((x)[2] |= (opt))
43#define OSPF6_OPT_ISSET(x,opt) ((x)[2] & (opt))
44#define OSPF6_OPT_CLEAR(x,opt) ((x)[2] &= ~(opt))
45#define OSPF6_OPT_CLEAR_ALL(x) ((x)[0] = (x)[1] = (x)[2] = 0)
46
paul718e3742002-12-13 20:15:29 +000047#define OSPF6_OPT_DC (1 << 5) /* Demand Circuit handling Capability */
hasso508e53e2004-05-18 18:57:06 +000048#define OSPF6_OPT_R (1 << 4) /* Forwarding Capability (Any Protocol) */
49#define OSPF6_OPT_N (1 << 3) /* Handling Type-7 LSA Capability */
50#define OSPF6_OPT_MC (1 << 2) /* Multicasting Capability */
51#define OSPF6_OPT_E (1 << 1) /* AS External Capability */
52#define OSPF6_OPT_V6 (1 << 0) /* IPv6 forwarding Capability */
paul718e3742002-12-13 20:15:29 +000053
hasso508e53e2004-05-18 18:57:06 +000054/* OSPF6 Prefix */
Denis Ovsienkoabc7ef42011-09-26 13:18:51 +040055#define OSPF6_PREFIX_MIN_SIZE 4U /* .length == 0 */
hasso508e53e2004-05-18 18:57:06 +000056struct ospf6_prefix
57{
58 u_int8_t prefix_length;
59 u_int8_t prefix_options;
60 union {
61 u_int16_t _prefix_metric;
62 u_int16_t _prefix_referenced_lstype;
63 } u;
64#define prefix_metric u._prefix_metric
65#define prefix_refer_lstype u._prefix_referenced_lstype
66 /* followed by one address_prefix */
67};
68
69#define OSPF6_PREFIX_OPTION_NU (1 << 0) /* No Unicast */
70#define OSPF6_PREFIX_OPTION_LA (1 << 1) /* Local Address */
71#define OSPF6_PREFIX_OPTION_MC (1 << 2) /* MultiCast */
72#define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */
73
74/* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */
75#define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof (struct ospf6_prefix))
76
77/* size_t OSPF6_PREFIX_SPACE (int prefixlength); */
78#define OSPF6_PREFIX_SPACE(x) ((((x) + 31) / 32) * 4)
79
80/* size_t OSPF6_PREFIX_SIZE (struct ospf6_prefix *); */
81#define OSPF6_PREFIX_SIZE(x) \
82 (OSPF6_PREFIX_SPACE ((x)->prefix_length) + sizeof (struct ospf6_prefix))
83
84/* struct ospf6_prefix *OSPF6_PREFIX_NEXT (struct ospf6_prefix *); */
85#define OSPF6_PREFIX_NEXT(x) \
86 ((struct ospf6_prefix *)((caddr_t)(x) + OSPF6_PREFIX_SIZE (x)))
87
88#define ospf6_prefix_in6_addr(in6, op) \
89do { \
90 memset (in6, 0, sizeof (struct in6_addr)); \
91 memcpy (in6, (caddr_t) (op) + sizeof (struct ospf6_prefix), \
92 OSPF6_PREFIX_SPACE ((op)->prefix_length)); \
93} while (0)
94
Paul Jakma6ac29a52008-08-15 13:45:30 +010095extern void ospf6_prefix_apply_mask (struct ospf6_prefix *op);
96extern void ospf6_prefix_options_printbuf (u_int8_t prefix_options,
97 char *buf, int size);
98extern void ospf6_capability_printbuf (char capability, char *buf, int size);
99extern void ospf6_options_printbuf (u_char *options, char *buf, int size);
paul718e3742002-12-13 20:15:29 +0000100
101#endif /* OSPF6_PROTO_H */