paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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_PROTO_H |
| 23 | #define OSPF6_PROTO_H |
| 24 | |
| 25 | /* OSPF protocol version */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 26 | #define OSPFV3_VERSION 3 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 27 | |
| 28 | /* OSPF protocol number. */ |
| 29 | #ifndef IPPROTO_OSPFIGP |
| 30 | #define IPPROTO_OSPFIGP 89 |
| 31 | #endif |
| 32 | |
| 33 | /* TOS field normaly null */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 34 | #define DEFAULT_TOS_VALUE 0x0 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 35 | |
| 36 | /* Architectural Constants */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 37 | #define LS_REFRESH_TIME 1800 /* 30 min */ |
| 38 | #define MIN_LS_INTERVAL 5 |
| 39 | #define MIN_LS_ARRIVAL 1 |
| 40 | #define MAXAGE 3600 /* 1 hour */ |
| 41 | #define CHECK_AGE 300 /* 5 min */ |
| 42 | #define MAX_AGE_DIFF 900 /* 15 min */ |
| 43 | #define LS_INFINITY 0xffffff /* 24-bit binary value */ |
| 44 | #define INITIAL_SEQUENCE_NUMBER 0x80000001 /* signed 32-bit integer */ |
| 45 | #define MAX_SEQUENCE_NUMBER 0x7fffffff /* signed 32-bit integer */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 46 | |
| 47 | #define ALLSPFROUTERS6 "ff02::5" |
| 48 | #define ALLDROUTERS6 "ff02::6" |
| 49 | |
| 50 | /* Configurable Constants */ |
| 51 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 52 | #define DEFAULT_HELLO_INTERVAL 10 |
| 53 | #define DEFAULT_ROUTER_DEAD_INTERVAL 40 |
| 54 | |
| 55 | #define OSPF6_ROUTER_BIT_W (1 << 3) |
| 56 | #define OSPF6_ROUTER_BIT_V (1 << 2) |
| 57 | #define OSPF6_ROUTER_BIT_E (1 << 1) |
| 58 | #define OSPF6_ROUTER_BIT_B (1 << 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | |
| 60 | /* OSPF options */ |
| 61 | /* present in HELLO, DD, LSA */ |
| 62 | #define OSPF6_OPT_SET(x,opt) ((x)[2] |= (opt)) |
| 63 | #define OSPF6_OPT_ISSET(x,opt) ((x)[2] & (opt)) |
| 64 | #define OSPF6_OPT_CLEAR(x,opt) ((x)[2] &= ~(opt)) |
| 65 | #define OSPF6_OPT_CLEAR_ALL(x) ((x)[0] = (x)[1] = (x)[2] = 0) |
| 66 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 67 | #define OSPF6_OPT_DC (1 << 5) /* Demand Circuit handling Capability */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 68 | #define OSPF6_OPT_R (1 << 4) /* Forwarding Capability (Any Protocol) */ |
| 69 | #define OSPF6_OPT_N (1 << 3) /* Handling Type-7 LSA Capability */ |
| 70 | #define OSPF6_OPT_MC (1 << 2) /* Multicasting Capability */ |
| 71 | #define OSPF6_OPT_E (1 << 1) /* AS External Capability */ |
| 72 | #define OSPF6_OPT_V6 (1 << 0) /* IPv6 forwarding Capability */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 74 | /* OSPF6 Prefix */ |
| 75 | struct ospf6_prefix |
| 76 | { |
| 77 | u_int8_t prefix_length; |
| 78 | u_int8_t prefix_options; |
| 79 | union { |
| 80 | u_int16_t _prefix_metric; |
| 81 | u_int16_t _prefix_referenced_lstype; |
| 82 | } u; |
| 83 | #define prefix_metric u._prefix_metric |
| 84 | #define prefix_refer_lstype u._prefix_referenced_lstype |
| 85 | /* followed by one address_prefix */ |
| 86 | }; |
| 87 | |
| 88 | #define OSPF6_PREFIX_OPTION_NU (1 << 0) /* No Unicast */ |
| 89 | #define OSPF6_PREFIX_OPTION_LA (1 << 1) /* Local Address */ |
| 90 | #define OSPF6_PREFIX_OPTION_MC (1 << 2) /* MultiCast */ |
| 91 | #define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */ |
| 92 | |
| 93 | /* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */ |
| 94 | #define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof (struct ospf6_prefix)) |
| 95 | |
| 96 | /* size_t OSPF6_PREFIX_SPACE (int prefixlength); */ |
| 97 | #define OSPF6_PREFIX_SPACE(x) ((((x) + 31) / 32) * 4) |
| 98 | |
| 99 | /* size_t OSPF6_PREFIX_SIZE (struct ospf6_prefix *); */ |
| 100 | #define OSPF6_PREFIX_SIZE(x) \ |
| 101 | (OSPF6_PREFIX_SPACE ((x)->prefix_length) + sizeof (struct ospf6_prefix)) |
| 102 | |
| 103 | /* struct ospf6_prefix *OSPF6_PREFIX_NEXT (struct ospf6_prefix *); */ |
| 104 | #define OSPF6_PREFIX_NEXT(x) \ |
| 105 | ((struct ospf6_prefix *)((caddr_t)(x) + OSPF6_PREFIX_SIZE (x))) |
| 106 | |
| 107 | #define ospf6_prefix_in6_addr(in6, op) \ |
| 108 | do { \ |
| 109 | memset (in6, 0, sizeof (struct in6_addr)); \ |
| 110 | memcpy (in6, (caddr_t) (op) + sizeof (struct ospf6_prefix), \ |
| 111 | OSPF6_PREFIX_SPACE ((op)->prefix_length)); \ |
| 112 | } while (0) |
| 113 | |
| 114 | void ospf6_prefix_apply_mask (struct ospf6_prefix *op); |
| 115 | void ospf6_prefix_options_printbuf (u_int8_t prefix_options, |
| 116 | char *buf, int size); |
| 117 | void ospf6_capability_printbuf (char capability, char *buf, int size); |
| 118 | void ospf6_options_printbuf (char *options, char *buf, int size); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | |
| 120 | #endif /* OSPF6_PROTO_H */ |
| 121 | |