summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/if.c24
-rw-r--r--lib/if.h1
-rw-r--r--lib/libospf.h92
4 files changed, 118 insertions, 1 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 44d95bbe..bd210929 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -27,7 +27,7 @@ pkginclude_HEADERS = \
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 \
diff --git a/lib/if.c b/lib/if.c
index e26aa046..6348403b 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -304,6 +304,30 @@ if_lookup_address (struct in_addr src)
return match;
}
+/* Lookup interface by prefix */
+struct interface *
+if_lookup_prefix (struct prefix *prefix)
+{
+ struct listnode *node;
+ struct prefix addr;
+ int bestlen = 0;
+ struct listnode *cnode;
+ struct interface *ifp;
+ struct connected *c;
+
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ {
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
+ {
+ if (prefix_cmp(c->address, prefix) == 0)
+ {
+ return ifp;
+ }
+ }
+ }
+ return NULL;
+}
+
/* Get interface by name if given name interface doesn't exist create
one. */
struct interface *
diff --git a/lib/if.h b/lib/if.h
index 13cc254e..8081be87 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -245,6 +245,7 @@ extern struct interface *if_create (const char *name, int namelen);
extern struct interface *if_lookup_by_index (unsigned int);
extern struct interface *if_lookup_exact_address (struct in_addr);
extern struct interface *if_lookup_address (struct in_addr);
+extern struct interface *if_lookup_prefix (struct prefix *prefix);
/* These 2 functions are to be used when the ifname argument is terminated
by a '\0' character: */
diff --git a/lib/libospf.h b/lib/libospf.h
new file mode 100644
index 00000000..856c76df
--- /dev/null
+++ b/lib/libospf.h
@@ -0,0 +1,92 @@
+/*
+ * 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 Types */
+#define OSPF_IFTYPE_NONE 0
+#define OSPF_IFTYPE_POINTOPOINT 1
+#define OSPF_IFTYPE_BROADCAST 2
+#define OSPF_IFTYPE_NBMA 3
+#define OSPF_IFTYPE_POINTOMULTIPOINT 4
+#define OSPF_IFTYPE_VIRTUALLINK 5
+#define OSPF_IFTYPE_LOOPBACK 6
+#define OSPF_IFTYPE_MAX 7
+
+/* 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 OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT 60
+
+#endif /* _LIBOSPFD_H */