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 OSPF6D_H |
| 23 | #define OSPF6D_H |
| 24 | |
Paul Jakma | 0b26f81 | 2006-05-15 10:47:53 +0000 | [diff] [blame] | 25 | #define OSPF6_DAEMON_VERSION "0.9.7r" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 26 | |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 27 | #include "libospf.h" |
| 28 | #include "thread.h" |
| 29 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 30 | /* global variables */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 31 | extern struct thread_master *master; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 32 | |
| 33 | #ifdef INRIA_IPV6 |
| 34 | #ifndef IPV6_PKTINFO |
| 35 | #define IPV6_PKTINFO IPV6_RECVPKTINFO |
| 36 | #endif /* IPV6_PKTINFO */ |
| 37 | #endif /* INRIA_IPV6 */ |
| 38 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 39 | /* Historical for KAME. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | #ifndef IPV6_JOIN_GROUP |
| 41 | #ifdef IPV6_ADD_MEMBERSHIP |
| 42 | #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP |
| 43 | #endif /* IPV6_ADD_MEMBERSHIP. */ |
| 44 | #ifdef IPV6_JOIN_MEMBERSHIP |
| 45 | #define IPV6_JOIN_GROUP IPV6_JOIN_MEMBERSHIP |
| 46 | #endif /* IPV6_JOIN_MEMBERSHIP. */ |
| 47 | #endif /* ! IPV6_JOIN_GROUP*/ |
| 48 | |
| 49 | #ifndef IPV6_LEAVE_GROUP |
| 50 | #ifdef IPV6_DROP_MEMBERSHIP |
| 51 | #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP |
| 52 | #endif /* IPV6_DROP_MEMBERSHIP */ |
| 53 | #endif /* ! IPV6_LEAVE_GROUP */ |
| 54 | |
Denis Ovsienko | ef95122 | 2011-08-20 20:58:15 +0400 | [diff] [blame] | 55 | #define MSG_OK 0 |
| 56 | #define MSG_NG 1 |
| 57 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 58 | /* cast macro: XXX - these *must* die, ick ick. */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 59 | #define OSPF6_PROCESS(x) ((struct ospf6 *) (x)) |
| 60 | #define OSPF6_AREA(x) ((struct ospf6_area *) (x)) |
| 61 | #define OSPF6_INTERFACE(x) ((struct ospf6_interface *) (x)) |
| 62 | #define OSPF6_NEIGHBOR(x) ((struct ospf6_neighbor *) (x)) |
| 63 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 64 | /* operation on timeval structure */ |
| 65 | #ifndef timerclear |
| 66 | #define timerclear(a) (a)->tv_sec = (tvp)->tv_usec = 0 |
| 67 | #endif /*timerclear*/ |
| 68 | #ifndef timersub |
| 69 | #define timersub(a, b, res) \ |
| 70 | do { \ |
| 71 | (res)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ |
| 72 | (res)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ |
| 73 | if ((res)->tv_usec < 0) \ |
| 74 | { \ |
| 75 | (res)->tv_sec--; \ |
| 76 | (res)->tv_usec += 1000000; \ |
| 77 | } \ |
| 78 | } while (0) |
| 79 | #endif /*timersub*/ |
| 80 | #define timerstring(tv, buf, size) \ |
| 81 | do { \ |
| 82 | if ((tv)->tv_sec / 60 / 60 / 24) \ |
| 83 | snprintf (buf, size, "%ldd%02ld:%02ld:%02ld", \ |
| 84 | (tv)->tv_sec / 60 / 60 / 24, \ |
| 85 | (tv)->tv_sec / 60 / 60 % 24, \ |
| 86 | (tv)->tv_sec / 60 % 60, \ |
| 87 | (tv)->tv_sec % 60); \ |
| 88 | else \ |
| 89 | snprintf (buf, size, "%02ld:%02ld:%02ld", \ |
| 90 | (tv)->tv_sec / 60 / 60 % 24, \ |
| 91 | (tv)->tv_sec / 60 % 60, \ |
| 92 | (tv)->tv_sec % 60); \ |
| 93 | } while (0) |
| 94 | #define timerstring_local(tv, buf, size) \ |
| 95 | do { \ |
| 96 | int ret; \ |
| 97 | struct tm *tm; \ |
| 98 | tm = localtime (&(tv)->tv_sec); \ |
| 99 | ret = strftime (buf, size, "%Y/%m/%d %H:%M:%S", tm); \ |
| 100 | if (ret == 0) \ |
| 101 | zlog_warn ("strftime error"); \ |
| 102 | } while (0) |
| 103 | |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame] | 104 | #define threadtimer_string(now, t, buf, size) \ |
| 105 | do { \ |
| 106 | struct timeval result; \ |
| 107 | if (!t) \ |
| 108 | snprintf(buf, size, "inactive"); \ |
| 109 | else { \ |
| 110 | timersub(&t->u.sands, &now, &result); \ |
| 111 | timerstring(&result, buf, size); \ |
| 112 | } \ |
| 113 | } while (0) |
| 114 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 115 | /* for commands */ |
| 116 | #define OSPF6_AREA_STR "Area information\n" |
| 117 | #define OSPF6_AREA_ID_STR "Area ID (as an IPv4 notation)\n" |
| 118 | #define OSPF6_SPF_STR "Shortest Path First tree information\n" |
| 119 | #define OSPF6_ROUTER_ID_STR "Specify Router-ID\n" |
| 120 | #define OSPF6_LS_ID_STR "Specify Link State ID\n" |
| 121 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 122 | #define VNL VTY_NEWLINE |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 123 | #define OSPF6_CMD_CHECK_RUNNING() \ |
| 124 | if (ospf6 == NULL) \ |
| 125 | { \ |
| 126 | vty_out (vty, "OSPFv3 is not running%s", VTY_NEWLINE); \ |
| 127 | return CMD_SUCCESS; \ |
| 128 | } |
| 129 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 130 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | /* Function Prototypes */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 132 | extern struct route_node *route_prev (struct route_node *node); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 133 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 134 | extern void ospf6_debug (void); |
| 135 | extern void ospf6_init (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 136 | |
| 137 | #endif /* OSPF6D_H */ |
| 138 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 139 | |