str.h stream.h table.h thread.h vector.h version.h vty.h zebra.h \
plist.h zclient.h sockopt.h smux.h md5.h if_rmap.h keychain.h \
privs.h sigevent.h pqueue.h jhash.h zassert.h memtypes.h \
- workqueue.h route_types.h
+ workqueue.h route_types.h libospf.h
EXTRA_DIST = \
regex.c regex-gnu.h \
--- /dev/null
+/*
+ * Defines and structures common to OSPFv2 and OSPFv3
+ * Copyright (C) 1998, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
+ *
+ * This file is part of GNU Zebra.
+ *
+ * GNU Zebra is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * GNU Zebra is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Zebra; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _LIBOSPFD_H
+#define _LIBOSPFD_H
+
+/* IP precedence. */
+#ifndef IPTOS_PREC_INTERNETCONTROL
+#define IPTOS_PREC_INTERNETCONTROL 0xC0
+#endif /* IPTOS_PREC_INTERNETCONTROL */
+
+/* Default protocol, port number. */
+#ifndef IPPROTO_OSPFIGP
+#define IPPROTO_OSPFIGP 89
+#endif /* IPPROTO_OSPFIGP */
+
+/* Architectual Constants */
+#ifdef DEBUG
+#define OSPF_LS_REFRESH_TIME 60
+#else
+#define OSPF_LS_REFRESH_TIME 1800
+#endif
+#define OSPF_MIN_LS_INTERVAL 5
+#define OSPF_MIN_LS_ARRIVAL 1
+#define OSPF_LSA_INITIAL_AGE 0 /* useful for debug */
+#define OSPF_LSA_MAXAGE 3600
+#define OSPF_CHECK_AGE 300
+#define OSPF_LSA_MAXAGE_DIFF 900
+#define OSPF_LS_INFINITY 0xffffff
+#define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */
+#define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001
+#define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff
+
+/* OSPF interface default values. */
+#define OSPF_OUTPUT_COST_DEFAULT 10
+#define OSPF_OUTPUT_COST_INFINITE UINT16_MAX
+#define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40
+#define OSPF_ROUTER_DEAD_INTERVAL_MINIMAL 1
+#define OSPF_HELLO_INTERVAL_DEFAULT 10
+#define OSPF_ROUTER_PRIORITY_DEFAULT 1
+#define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5
+#define OSPF_TRANSMIT_DELAY_DEFAULT 1
+#define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */
+
+#define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
+
+#define OSPF_POLL_INTERVAL_DEFAULT 60
+#define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
+
+#define OSPF_MTU_IGNORE_DEFAULT 0
+#define OSPF_FAST_HELLO_DEFAULT 0
+
+#define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */
+
+/* SPF Throttling timer values. */
+#define OSPF_SPF_DELAY_DEFAULT 200
+#define OSPF_SPF_HOLDTIME_DEFAULT 1000
+#define OSPF_SPF_MAX_HOLDTIME_DEFAULT 10000
+
+#define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30
+#define OSFP_LSA_MAXAGE_REMOVE_DELAY_DEFAULT 60
+
+#endif /* _LIBOSPFD_H */
}
/* do not generate if the route cost is greater or equal to LSInfinity */
- if (route->path.cost >= LS_INFINITY)
+ if (route->path.cost >= OSPF_LS_INFINITY)
{
if (is_debug)
zlog_debug ("The cost exceeds LSInfinity, withdraw");
/* ranges are ignored when originate backbone routes to transit area.
Otherwise, if ranges are configured, the route is suppressed. */
if (range && ! CHECK_FLAG (range->flag, OSPF6_ROUTE_REMOVE) &&
- (route->path.area_id != BACKBONE_AREA_ID ||
+ (route->path.area_id != OSPF_AREA_BACKBONE ||
! IS_AREA_TRANSIT (area)))
{
if (is_debug)
}
/* (1) if cost == LSInfinity or if the LSA is MaxAge */
- if (cost == LS_INFINITY)
+ if (cost == OSPF_LS_INFINITY)
{
if (is_debug)
zlog_debug ("cost is LS_INFINITY, ignore");
}
ospf6_route_remove (range, oa->range_table);
+
return CMD_SUCCESS;
}
#define OSPF6_AREA_TRANSIT 0x04 /* TransitCapability */
#define OSPF6_AREA_STUB 0x08
-#define BACKBONE_AREA_ID (htonl (0))
-#define IS_AREA_BACKBONE(oa) ((oa)->area_id == BACKBONE_AREA_ID)
#define IS_AREA_ENABLED(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_ENABLE))
#define IS_AREA_ACTIVE(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_ACTIVE))
#define IS_AREA_TRANSIT(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_TRANSIT))
return;
}
- if (OSPF6_ASBR_METRIC (external) == LS_INFINITY)
+ if (OSPF6_ASBR_METRIC (external) == OSPF_LS_INFINITY)
{
if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
zlog_debug ("Ignore LSA with LSInfinity Metric");
u_int32_t metric;
char *endp;
metric = strtoul (arg, &endp, 0);
- if (metric > LS_INFINITY || *endp != '\0')
+ if (metric > OSPF_LS_INFINITY || *endp != '\0')
return NULL;
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
}
ospf6_lsdb_add (ospf6_lsa_copy (lsa), lsdb_self);
lsa->refresh = thread_add_timer (master, ospf6_lsa_refresh, lsa,
- LS_REFRESH_TIME);
+ OSPF_LS_REFRESH_TIME);
if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) ||
IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type))
quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
if (! OSPF6_LSA_IS_MAXAGE (lsa))
lsa->expire = thread_add_timer (master, ospf6_lsa_expire, lsa,
- MAXAGE + lsa->birth.tv_sec - now.tv_sec);
+ OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec);
else
lsa->expire = NULL;
struct timeval now, res;
quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
timersub (&now, &old->installed, &res);
- if (res.tv_sec < MIN_LS_ARRIVAL)
+ if (res.tv_sec < OSPF_MIN_LS_ARRIVAL)
{
if (is_debug)
zlog_debug ("LSA can't be updated within MinLSArrival, discard");
/* If database copy is in 'Seqnumber Wrapping',
simply discard the received LSA */
if (OSPF6_LSA_IS_MAXAGE (old) &&
- old->header->seqnum == htonl (MAX_SEQUENCE_NUMBER))
+ old->header->seqnum == htonl (OSPF_MAX_SEQUENCE_NUMBER))
{
if (is_debug)
{
oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
oi->priority = OSPF6_INTERFACE_PRIORITY;
- oi->hello_interval = OSPF6_INTERFACE_HELLO_INTERVAL;
- oi->dead_interval = OSPF6_INTERFACE_DEAD_INTERVAL;
- oi->rxmt_interval = OSPF6_INTERFACE_RXMT_INTERVAL;
+ oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
+ oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
+ oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
oi->cost = OSPF6_INTERFACE_COST;
oi->state = OSPF6_INTERFACE_DOWN;
oi->flag = 0;
ospf6_lsa_age_current (lsa1);
ospf6_lsa_age_current (lsa2);
- if (ntohs (lsa1->header->age) == MAXAGE &&
- ntohs (lsa2->header->age) != MAXAGE)
+ if (ntohs (lsa1->header->age) == OSPF_LSA_MAXAGE &&
+ ntohs (lsa2->header->age) != OSPF_LSA_MAXAGE)
return 1;
- if (ntohs (lsa1->header->age) != MAXAGE &&
- ntohs (lsa2->header->age) == MAXAGE)
+ if (ntohs (lsa1->header->age) != OSPF_LSA_MAXAGE &&
+ ntohs (lsa2->header->age) == OSPF_LSA_MAXAGE)
return 1;
/* compare body */
zlog_warn ("LSA: quagga_gettime failed, may fail LSA AGEs: %s",
safe_strerror (errno));
- if (ntohs (lsa->header->age) >= MAXAGE)
+ if (ntohs (lsa->header->age) >= OSPF_LSA_MAXAGE)
{
/* ospf6_lsa_premature_aging () sets age to MAXAGE; when using
relative time, we cannot compare against lsa birth time, so
we catch this special case here. */
- lsa->header->age = htons (MAXAGE);
- return MAXAGE;
+ lsa->header->age = htons (OSPF_LSA_MAXAGE);
+ return OSPF_LSA_MAXAGE;
}
/* calculate age */
ulage = now.tv_sec - lsa->birth.tv_sec;
/* if over MAXAGE, set to it */
- age = (ulage > MAXAGE ? MAXAGE : ulage);
+ age = (ulage > OSPF_LSA_MAXAGE ? OSPF_LSA_MAXAGE : ulage);
lsa->header->age = htons (age);
return age;
unsigned short age;
age = ospf6_lsa_age_current (lsa) + transdelay;
- if (age > MAXAGE)
- age = MAXAGE;
+ if (age > OSPF_LSA_MAXAGE)
+ age = OSPF_LSA_MAXAGE;
lsa->header->age = htons (age);
}
THREAD_OFF (lsa->expire);
THREAD_OFF (lsa->refresh);
- lsa->header->age = htons (MAXAGE);
+ lsa->header->age = htons (OSPF_LSA_MAXAGE);
thread_execute (master, ospf6_lsa_expire, lsa, 0);
}
ageb = ospf6_lsa_age_current (b);
/* MaxAge check */
- if (agea == MAXAGE && ageb != MAXAGE)
+ if (agea == OSPF_LSA_MAXAGE && ageb != OSPF_LSA_MAXAGE)
return -1;
- else if (agea != MAXAGE && ageb == MAXAGE)
+ else if (agea != OSPF_LSA_MAXAGE && ageb == OSPF_LSA_MAXAGE)
return 1;
/* Age check */
- if (agea > ageb && agea - ageb >= MAX_AGE_DIFF)
+ if (agea > ageb && agea - ageb >= OSPF_LSA_MAXAGE_DIFF)
return 1;
- else if (agea < ageb && ageb - agea >= MAX_AGE_DIFF)
+ else if (agea < ageb && ageb - agea >= OSPF_LSA_MAXAGE_DIFF)
return -1;
/* neither recent */
new = ospf6_lsa_create (self->header);
new->lsdb = old->lsdb;
new->refresh = thread_add_timer (master, ospf6_lsa_refresh, new,
- LS_REFRESH_TIME);
+ OSPF_LS_REFRESH_TIME);
/* store it in the LSDB for self-originated LSAs */
ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);
((L)->header->adv_router == (a) && (L)->header->id == (i) && \
(L)->header->type == (t))
#define OSPF6_LSA_IS_DIFFER(L1, L2) ospf6_lsa_is_differ (L1, L2)
-#define OSPF6_LSA_IS_MAXAGE(L) (ospf6_lsa_age_current (L) == MAXAGE)
+#define OSPF6_LSA_IS_MAXAGE(L) (ospf6_lsa_age_current (L) == OSPF_LSA_MAXAGE)
#define OSPF6_LSA_IS_CHANGED(L1, L2) ospf6_lsa_is_changed (L1, L2)
struct ospf6_lsa
/* if current database copy not found, return InitialSequenceNumber */
lsa = ospf6_lsdb_lookup (type, id, adv_router, lsdb);
if (lsa == NULL)
- seqnum = INITIAL_SEQUENCE_NUMBER;
+ seqnum = OSPF_INITIAL_SEQUENCE_NUMBER;
else
seqnum = (signed long) ntohl (lsa->header->seqnum) + 1;
{
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
{
- if (oh->area_id == BACKBONE_AREA_ID)
+ if (oh->area_id == OSPF_AREA_BACKBONE)
zlog_debug ("%s: Message may be via Virtual Link: not supported", __func__);
else
zlog_debug
#include "sockopt.h"
#include "privs.h"
+#include "libospf.h"
#include "ospf6_proto.h"
#include "ospf6_network.h"
/* OSPF protocol version */
#define OSPFV3_VERSION 3
-/* OSPF protocol number. */
-#ifndef IPPROTO_OSPFIGP
-#define IPPROTO_OSPFIGP 89
-#endif
-
/* TOS field normaly null */
#define DEFAULT_TOS_VALUE 0x0
-/* Architectural Constants */
-#define LS_REFRESH_TIME 1800 /* 30 min */
-#define MIN_LS_INTERVAL 5
-#define MIN_LS_ARRIVAL 1
-#define MAXAGE 3600 /* 1 hour */
-#define CHECK_AGE 300 /* 5 min */
-#define MAX_AGE_DIFF 900 /* 15 min */
-#define LS_INFINITY 0xffffff /* 24-bit binary value */
-#define INITIAL_SEQUENCE_NUMBER 0x80000001 /* signed 32-bit integer */
-#define MAX_SEQUENCE_NUMBER 0x7fffffff /* signed 32-bit integer */
-
#define ALLSPFROUTERS6 "ff02::5"
#define ALLDROUTERS6 "ff02::6"
-/* Configurable Constants */
-
-#define DEFAULT_HELLO_INTERVAL 10
-#define DEFAULT_ROUTER_DEAD_INTERVAL 40
-
#define OSPF6_ROUTER_BIT_W (1 << 3)
#define OSPF6_ROUTER_BIT_V (1 << 2)
#define OSPF6_ROUTER_BIT_E (1 << 1)
#define OSPF6_DAEMON_VERSION "0.9.7r"
+#include "libospf.h"
+#include "thread.h"
+
/* global variables */
extern struct thread_master *master;
#define _ZEBRA_OSPFD_H
#include <zebra.h>
+#include "libospf.h"
#include "filter.h"
#include "log.h"
#define OSPF_VERSION 2
-/* Default protocol, port number. */
-#ifndef IPPROTO_OSPFIGP
-#define IPPROTO_OSPFIGP 89
-#endif /* IPPROTO_OSPFIGP */
-
-/* IP precedence. */
-#ifndef IPTOS_PREC_INTERNETCONTROL
-#define IPTOS_PREC_INTERNETCONTROL 0xC0
-#endif /* IPTOS_PREC_INTERNETCONTROL */
-
/* VTY port number. */
#define OSPF_VTY_PORT 2604
/* Default configuration file name for ospfd. */
#define OSPF_DEFAULT_CONFIG "ospfd.conf"
-/* Architectual Constants */
-#ifdef DEBUG
-#define OSPF_LS_REFRESH_TIME 60
-#else
-#define OSPF_LS_REFRESH_TIME 1800
-#endif
-#define OSPF_MIN_LS_INTERVAL 5
-#define OSPF_MIN_LS_ARRIVAL 1
-#define OSPF_LSA_INITIAL_AGE 0 /* useful for debug */
-#define OSPF_LSA_MAXAGE 3600
-#define OSPF_CHECK_AGE 300
-#define OSPF_LSA_MAXAGE_DIFF 900
-#define OSPF_LS_INFINITY 0xffffff
-#define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */
-#define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001
-#define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff
-
#define OSPF_NSSA_TRANS_STABLE_DEFAULT 40
#define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */
#define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */
-#define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */
/* OSPF Authentication Type. */
#define OSPF_AUTH_NULL 0
been given or not in VLink command handlers */
#define OSPF_AUTH_CMD_NOTSEEN -2
-/* OSPF SPF timer values. */
-#define OSPF_SPF_DELAY_DEFAULT 200
-#define OSPF_SPF_HOLDTIME_DEFAULT 1000
-#define OSPF_SPF_MAX_HOLDTIME_DEFAULT 10000
-
-/* OSPF interface default values. */
-#define OSPF_OUTPUT_COST_DEFAULT 10
-#define OSPF_OUTPUT_COST_INFINITE UINT16_MAX
-#define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40
-#define OSPF_ROUTER_DEAD_INTERVAL_MINIMAL 1
-#define OSPF_HELLO_INTERVAL_DEFAULT 10
-#define OSPF_ROUTER_PRIORITY_DEFAULT 1
-#define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5
-#define OSPF_TRANSMIT_DELAY_DEFAULT 1
-#define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */
-
-#define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
-
-#define OSPF_POLL_INTERVAL_DEFAULT 60
-#define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
-
-#define OSPF_MTU_IGNORE_DEFAULT 0
-#define OSPF_FAST_HELLO_DEFAULT 0
-
/* OSPF options. */
#define OSPF_OPTION_T 0x01 /* TOS. */
#define OSPF_OPTION_E 0x02