]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
049207c3 | 2 | * Common protocol data and data structures. |
508e53e2 | 3 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 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 OSPF6_PROTO_H | |
23 | #define OSPF6_PROTO_H | |
24 | ||
25 | /* OSPF protocol version */ | |
508e53e2 | 26 | #define OSPFV3_VERSION 3 |
718e3744 | 27 | |
718e3744 | 28 | /* TOS field normaly null */ |
508e53e2 | 29 | #define DEFAULT_TOS_VALUE 0x0 |
718e3744 | 30 | |
718e3744 | 31 | #define ALLSPFROUTERS6 "ff02::5" |
32 | #define ALLDROUTERS6 "ff02::6" | |
33 | ||
508e53e2 | 34 | #define OSPF6_ROUTER_BIT_W (1 << 3) |
35 | #define OSPF6_ROUTER_BIT_V (1 << 2) | |
36 | #define OSPF6_ROUTER_BIT_E (1 << 1) | |
37 | #define OSPF6_ROUTER_BIT_B (1 << 0) | |
718e3744 | 38 | |
39 | /* OSPF options */ | |
40 | /* present in HELLO, DD, LSA */ | |
41 | #define OSPF6_OPT_SET(x,opt) ((x)[2] |= (opt)) | |
42 | #define OSPF6_OPT_ISSET(x,opt) ((x)[2] & (opt)) | |
43 | #define OSPF6_OPT_CLEAR(x,opt) ((x)[2] &= ~(opt)) | |
44 | #define OSPF6_OPT_CLEAR_ALL(x) ((x)[0] = (x)[1] = (x)[2] = 0) | |
45 | ||
718e3744 | 46 | #define OSPF6_OPT_DC (1 << 5) /* Demand Circuit handling Capability */ |
508e53e2 | 47 | #define OSPF6_OPT_R (1 << 4) /* Forwarding Capability (Any Protocol) */ |
48 | #define OSPF6_OPT_N (1 << 3) /* Handling Type-7 LSA Capability */ | |
49 | #define OSPF6_OPT_MC (1 << 2) /* Multicasting Capability */ | |
50 | #define OSPF6_OPT_E (1 << 1) /* AS External Capability */ | |
51 | #define OSPF6_OPT_V6 (1 << 0) /* IPv6 forwarding Capability */ | |
52 | ||
53 | /* OSPF6 Prefix */ | |
abc7ef44 | 54 | #define OSPF6_PREFIX_MIN_SIZE 4U /* .length == 0 */ |
d62a17ae | 55 | struct ospf6_prefix { |
d7c0a89a QY |
56 | uint8_t prefix_length; |
57 | uint8_t prefix_options; | |
d62a17ae | 58 | union { |
d7c0a89a QY |
59 | uint16_t _prefix_metric; |
60 | uint16_t _prefix_referenced_lstype; | |
d62a17ae | 61 | } u; |
508e53e2 | 62 | #define prefix_metric u._prefix_metric |
63 | #define prefix_refer_lstype u._prefix_referenced_lstype | |
d62a17ae | 64 | /* followed by one address_prefix */ |
c0f76ddf | 65 | struct in6_addr addr[]; |
508e53e2 | 66 | }; |
67 | ||
68 | #define OSPF6_PREFIX_OPTION_NU (1 << 0) /* No Unicast */ | |
69 | #define OSPF6_PREFIX_OPTION_LA (1 << 1) /* Local Address */ | |
70 | #define OSPF6_PREFIX_OPTION_MC (1 << 2) /* MultiCast */ | |
71 | #define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */ | |
72 | ||
73 | /* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */ | |
74 | #define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof (struct ospf6_prefix)) | |
75 | ||
76 | /* size_t OSPF6_PREFIX_SPACE (int prefixlength); */ | |
77 | #define OSPF6_PREFIX_SPACE(x) ((((x) + 31) / 32) * 4) | |
78 | ||
79 | /* size_t OSPF6_PREFIX_SIZE (struct ospf6_prefix *); */ | |
d62a17ae | 80 | #define OSPF6_PREFIX_SIZE(x) \ |
81 | (OSPF6_PREFIX_SPACE((x)->prefix_length) + sizeof(struct ospf6_prefix)) | |
508e53e2 | 82 | |
83 | /* struct ospf6_prefix *OSPF6_PREFIX_NEXT (struct ospf6_prefix *); */ | |
d62a17ae | 84 | #define OSPF6_PREFIX_NEXT(x) \ |
85 | ((struct ospf6_prefix *)((caddr_t)(x) + OSPF6_PREFIX_SIZE(x))) | |
86 | ||
87 | #define ospf6_prefix_in6_addr(in6, op) \ | |
88 | do { \ | |
89 | memset(in6, 0, sizeof(struct in6_addr)); \ | |
90 | memcpy(in6, (caddr_t)(op) + sizeof(struct ospf6_prefix), \ | |
91 | OSPF6_PREFIX_SPACE((op)->prefix_length)); \ | |
92 | } while (0) | |
93 | ||
94 | extern void ospf6_prefix_apply_mask(struct ospf6_prefix *op); | |
d7c0a89a | 95 | extern void ospf6_prefix_options_printbuf(uint8_t prefix_options, char *buf, |
d62a17ae | 96 | int size); |
97 | extern void ospf6_capability_printbuf(char capability, char *buf, int size); | |
d7c0a89a | 98 | extern void ospf6_options_printbuf(uint8_t *options, char *buf, int size); |
718e3744 | 99 | |
100 | #endif /* OSPF6_PROTO_H */ |