]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6d.h
ospfd: prevent from crashing when processing external lsa
[mirror_frr.git] / ospf6d / ospf6d.h
CommitLineData
718e3744 1/*
508e53e2 2 * Copyright (C) 2003 Yasuhiro Ohara
718e3744 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 *
896014f4
DL
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
718e3744 19 */
20
21#ifndef OSPF6D_H
22#define OSPF6D_H
23
8551e6da
DD
24#include "libospf.h"
25#include "thread.h"
30043e4c 26#include "memory.h"
8551e6da 27
30043e4c 28DECLARE_MGROUP(OSPF6D);
4a1ab8e4 29
718e3744 30/* global variables */
718e3744 31extern struct thread_master *master;
718e3744 32
508e53e2 33/* Historical for KAME. */
718e3744 34#ifndef IPV6_JOIN_GROUP
35#ifdef IPV6_ADD_MEMBERSHIP
36#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
37#endif /* IPV6_ADD_MEMBERSHIP. */
38#ifdef IPV6_JOIN_MEMBERSHIP
39#define IPV6_JOIN_GROUP IPV6_JOIN_MEMBERSHIP
40#endif /* IPV6_JOIN_MEMBERSHIP. */
41#endif /* ! IPV6_JOIN_GROUP*/
42
43#ifndef IPV6_LEAVE_GROUP
44#ifdef IPV6_DROP_MEMBERSHIP
45#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
46#endif /* IPV6_DROP_MEMBERSHIP */
47#endif /* ! IPV6_LEAVE_GROUP */
48
ef95122e
DO
49#define MSG_OK 0
50#define MSG_NG 1
51
4dc43886
MR
52#define OSPF6_SUCCESS 1
53#define OSPF6_FAILURE 0
54#define OSPF6_INVALID -1
55
1eb8ef25 56/* cast macro: XXX - these *must* die, ick ick. */
6452df09 57#define OSPF6_PROCESS(x) ((struct ospf6 *) (x))
58#define OSPF6_AREA(x) ((struct ospf6_area *) (x))
59#define OSPF6_INTERFACE(x) ((struct ospf6_interface *) (x))
60#define OSPF6_NEIGHBOR(x) ((struct ospf6_neighbor *) (x))
61
508e53e2 62/* operation on timeval structure */
d62a17ae 63#define timerstring(tv, buf, size) \
64 do { \
65 if ((tv)->tv_sec / 60 / 60 / 24) \
66 snprintf(buf, size, "%lldd%02lld:%02lld:%02lld", \
67 (tv)->tv_sec / 60LL / 60 / 24, \
68 (tv)->tv_sec / 60LL / 60 % 24, \
69 (tv)->tv_sec / 60LL % 60, \
70 (tv)->tv_sec % 60LL); \
71 else \
72 snprintf(buf, size, "%02lld:%02lld:%02lld", \
73 (tv)->tv_sec / 60LL / 60 % 24, \
74 (tv)->tv_sec / 60LL % 60, \
75 (tv)->tv_sec % 60LL); \
76 } while (0)
77
78#define threadtimer_string(now, t, buf, size) \
79 do { \
7fe96307 80 struct timeval _result; \
d62a17ae 81 if (!t) \
82 snprintf(buf, size, "inactive"); \
83 else { \
7fe96307
A
84 timersub(&t->u.sands, &now, &_result); \
85 timerstring(&_result, buf, size); \
d62a17ae 86 } \
87 } while (0)
a0edf674 88
508e53e2 89/* for commands */
90#define OSPF6_AREA_STR "Area information\n"
91#define OSPF6_AREA_ID_STR "Area ID (as an IPv4 notation)\n"
92#define OSPF6_SPF_STR "Shortest Path First tree information\n"
93#define OSPF6_ROUTER_ID_STR "Specify Router-ID\n"
94#define OSPF6_LS_ID_STR "Specify Link State ID\n"
95
d6b901ac 96#define OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6) \
97 do { \
98 if (uj == false && all_vrf == false && ospf6 == NULL) { \
99 vty_out(vty, "%% OSPFv3 instance not found\n"); \
100 return CMD_SUCCESS; \
101 } \
102 } while (0)
103
b8212e03 104#define IS_OSPF6_ASBR(O) ((O)->flag & OSPF6_FLAG_ASBR)
d48ef099 105#define OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \
d6b901ac 106 do { \
107 if (argv_find(argv, argc, "vrf", &idx_vrf)) { \
108 vrf_name = argv[idx_vrf + 1]->arg; \
109 all_vrf = strmatch(vrf_name, "all"); \
110 } else { \
111 vrf_name = VRF_DEFAULT_NAME; \
112 } \
113 } while (0)
d48ef099 114
59790f52 115#define OSPF6_FALSE false
116#define OSPF6_TRUE true
117#define OSPF6_SUCCESS 1
118#define OSPF6_FAILURE 0
119#define OSPF6_INVALID -1
120
101dc9bc 121extern struct zebra_privs_t ospf6d_privs;
6b0655a2 122
718e3744 123/* Function Prototypes */
d62a17ae 124extern struct route_node *route_prev(struct route_node *node);
718e3744 125
d62a17ae 126extern void ospf6_debug(void);
beadc736 127extern void ospf6_init(struct thread_master *master);
718e3744 128
129#endif /* OSPF6D_H */