diff -Naur quagga-0.99.9/bgpd/bgp_open.h quagga-0.99.9-af/bgpd/bgp_open.h --- quagga-0.99.9/bgpd/bgp_open.h 2007-08-06 08:17:45.000000000 -0700 +++ quagga-0.99.9-af/bgpd/bgp_open.h 2008-12-03 13:42:15.000000000 -0800 @@ -44,7 +44,12 @@ struct { u_char type; u_char mode; +#if ( __GNUC__ == 2) + // did not compile in FreeBSD, gcc 2.95.4 + } orfs[0]; +#else } orfs[]; +#endif } __attribute__ ((packed)); #pragma pack() @@ -58,7 +63,12 @@ struct capability_gr { u_int16_t restart_flag_time; +#if ( __GNUC__ == 2) + // did not compile in FreeBSD, gcc 2.95.4 + struct graceful_restart_af gr[0]; +#else struct graceful_restart_af gr[]; +#endif }; /* Capability Code */ diff -Naur quagga-0.99.9/bgpd/bgp_route.c quagga-0.99.9-af/bgpd/bgp_route.c --- quagga-0.99.9/bgpd/bgp_route.c 2007-08-26 15:44:52.000000000 -0700 +++ quagga-0.99.9-af/bgpd/bgp_route.c 2008-12-03 13:42:15.000000000 -0800 @@ -5802,9 +5802,16 @@ #ifdef HAVE_IPV6 else if (p->family == AF_INET6) { +/* gcc-2.95 won't let asserts before array declarations */ +#if ( __GNUC__ > 2) assert (attr->extra); +#endif char buf[BUFSIZ]; char buf1[BUFSIZ]; +/* Move it here */ +#if ( __GNUC__ == 2) + assert (attr->extra); +#endif if (attr->extra->mp_nexthop_len == 16) vty_out (vty, "%s", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, diff -Naur quagga-0.99.9/configure quagga-0.99.9-af/configure --- quagga-0.99.9/configure 2007-09-07 09:54:55.000000000 -0700 +++ quagga-0.99.9-af/configure 2008-12-03 13:43:27.000000000 -0800 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for Quagga 0.99.9. +# Generated by GNU Autoconf 2.61 for Quagga 0.99.9-ospfv3-addressfamilies-2008-06-02. # # Report bugs to . # @@ -728,8 +728,8 @@ # Identity of this package. PACKAGE_NAME='Quagga' PACKAGE_TARNAME='quagga' -PACKAGE_VERSION='0.99.9' -PACKAGE_STRING='Quagga 0.99.9' +PACKAGE_VERSION='0.99.9-ospfv3-addressfamilies-2008-06-02' +PACKAGE_STRING='Quagga 0.99.9-ospfv3-addressfamilies-2008-06-02' PACKAGE_BUGREPORT='http://bugzilla.quagga.net' ac_unique_file="lib/zebra.h" @@ -1442,7 +1442,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Quagga 0.99.9 to adapt to many kinds of systems. +\`configure' configures Quagga 0.99.9-ospfv3-addressfamilies-2008-06-02 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1513,7 +1513,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Quagga 0.99.9:";; + short | recursive ) echo "Configuration of Quagga 0.99.9-ospfv3-addressfamilies-2008-06-02:";; esac cat <<\_ACEOF @@ -1655,7 +1655,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Quagga configure 0.99.9 +Quagga configure 0.99.9-ospfv3-addressfamilies-2008-06-02 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1669,7 +1669,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Quagga $as_me 0.99.9, which was +It was created by Quagga $as_me 0.99.9-ospfv3-addressfamilies-2008-06-02, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2491,7 +2491,7 @@ # Define the identity of the package. PACKAGE='quagga' - VERSION='0.99.9' + VERSION='0.99.9-ospfv3-addressfamilies-2008-06-02' cat >>confdefs.h <<_ACEOF @@ -21323,6 +21323,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #include <$ac_header> @@ -21415,6 +21418,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif @@ -22871,6 +22877,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -22996,6 +23005,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -27698,6 +27710,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -27803,6 +27818,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -28397,6 +28415,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -29338,6 +29359,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -29481,6 +29505,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -29624,6 +29651,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -29767,6 +29797,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -29910,6 +29943,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -30053,6 +30089,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -30196,6 +30235,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -30339,6 +30381,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -30482,6 +30527,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -30625,6 +30673,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -30768,6 +30819,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -30911,6 +30965,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31054,6 +31111,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31199,6 +31259,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31320,6 +31383,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31464,6 +31530,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31585,6 +31654,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31729,6 +31801,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31850,6 +31925,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -31994,6 +32072,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -32115,6 +32196,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -32259,6 +32343,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -32380,6 +32467,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -32524,6 +32614,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -32645,6 +32738,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -32791,6 +32887,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -32932,6 +33031,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -33866,6 +33968,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -34178,6 +34283,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif #if HAVE_NET_IF_H # include @@ -34699,7 +34807,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Quagga $as_me 0.99.9, which was +This file was extended by Quagga $as_me 0.99.9-ospfv3-addressfamilies-2008-06-02, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -34752,7 +34860,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -Quagga config.status 0.99.9 +Quagga config.status 0.99.9-ospfv3-addressfamilies-2008-06-02 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff -Naur quagga-0.99.9/configure.ac quagga-0.99.9-af/configure.ac --- quagga-0.99.9/configure.ac 2007-09-07 09:54:01.000000000 -0700 +++ quagga-0.99.9-af/configure.ac 2008-12-03 13:42:15.000000000 -0800 @@ -8,7 +8,7 @@ ## $Id: configure.ac,v 1.139 2007/09/07 16:54:01 paul Exp $ AC_PREREQ(2.53) -AC_INIT(Quagga, 0.99.9, [http://bugzilla.quagga.net]) +AC_INIT(Quagga, 0.99.9-ospfv3-addressfamilies-2008-06-02, [http://bugzilla.quagga.net]) AC_CONFIG_SRCDIR(lib/zebra.h) dnl ----------------------------------- @@ -416,6 +416,9 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NET_IF_H +# include +#endif ])dnl AC_CHECK_HEADERS([sys/un.h net/if.h netinet/in_systm.h netinet/in_var.h \ diff -Naur quagga-0.99.9/doc/ospf6d-af.texi quagga-0.99.9-af/doc/ospf6d-af.texi --- quagga-0.99.9/doc/ospf6d-af.texi 1969-12-31 16:00:00.000000000 -0800 +++ quagga-0.99.9-af/doc/ospf6d-af.texi 2008-12-03 13:42:15.000000000 -0800 @@ -0,0 +1,119 @@ +@node OSPFv3 Address Families +@chapter OSPFv3 Address Families + +The following text describes the implementation of a mechanism for supporting +multiple address families in OSPFv3 using multiple instances. It +maps an address family (AF) to an OSPFv3 instance using the Instance ID +field in the OSPFv3 packet header. This approach is fairly simple +and minimizes extensions to OSPFv3 for supporting multiple AFs. + +This implementation also enables OSPF MANET to support IPv4 routing (next +chapter). + +@menu +* Overview-AF:: +* Enabling OSPF-AF:: +* Configuring OSPF-AF:: +* Running OSPF-AF:: +* Open Issues:: +@end menu + +@node Overview-AF +@section Overview + +For now, please see Section 2 of @uref{http://tools.ietf.org/html/draft-ietf-ospf-af-alt-05,, draft-ietf-ospf-af-alt-05}. + +@subsection Draft compliance +Support of Address Families (AF) in OSPFv3 is supported according to +@uref{http://tools.ietf.org/html/draft-ietf-ospf-af-alt-05,, draft-ietf-ospf-af-alt-05}. + +@subsection License and Contributing Code +This software builds on two projects (GTNetS and quagga) that are under +GNU General Public License (GPL). Our modifications are also under GPL. +Therefore, please consider this simulator as GPL'ed software. + +We would like to encourage people to send in bug fixes, extensions, +or to make their simulation scripts available (that produce their +simulation results). By default, we will not include any contributed +code, bug fixes, or patches unless you specify that you want to include +said code in our future releases of this simulator (also under GPL). + +@node Enabling OSPF-AF +@section Enabling OSPF-AF + +Address families is enabled by compiling the flag @code{OSPF6_AF} into the +source code. +By default this flag is compiled into the code. It must be removed from +configure.ac and config.h.in. + +All modified code is found in the directories lib/, zebra/, and ospf6/. +Each modification is flagged with the tag "OSPF6_AF". + +@node Configuring OSPF-AF +@section Configuring OSPF-AF + +Address Families can be configured in one of two ways. + +1. Add the following lines to the ospf6d.conf file + +@verbatim + interface + ipv6 ospf6 instance-id <0-255> +@end verbatim + +2. From the vtysh or telnet terminal type: +@verbatim + > conf t + > interface + > ipv6 ospf6 instance-id <0-255> + > exit + > exit +@end verbatim + +The value of the instance ID should one of the four ranges below. The most +comman ranges are 0 to 31 for unicast IPv6 routing (standard OSPFv3) and +64 to 95 for IPv4 unicast routing. +@verbatim + Instance ID # 0 - # 31 IPv6 unicast AF + Instance ID # 32 - # 63 IPv6 multicast AF + Instance ID # 64 - # 95 IPv4 unicast AF + Instance ID # 96 - # 127 IPv4 multicast AF + Instance ID # 128 - # 255 Unassigned +@end verbatim + +NOTE: The instance-id must be the same on all interfaces. Different Address +Families cannot be used within the same ospf6d process. The router will +fail if different ranges are used. + + +@node Running OSPF-AF +@section Running OSPF-AF + +From a vtysh or telnet terminal type: + +@verbatim +> show ipv6 ospf6 route +@end verbatim + +This should display the OSPFv3 routes. If IPv4 AFs are used then the +route will appear as an IPv6 route with zeros before the IPv4 route. +Next, type the following command for IPv4 or IPv6 + +@verbatim +> show ip route +> show ipv6 route +@end verbatim + +The entries with the "*" are going to be installed in the kernel routing +table. If these tables are correct then the kernel routing table +should be correct. + +@node Open Issues +@section Open Issues + +Enable different AFs to run in the same ospf6d instance. This would require +a IETF draft changes and a sepeartion of LSAs within the database. + +Known Issue: if instance IDs are not consistent on the interfaces then +routing will fail. + diff -Naur quagga-0.99.9/doc/quagga.texi quagga-0.99.9-af/doc/quagga.texi --- quagga-0.99.9/doc/quagga.texi 2006-07-27 15:55:49.000000000 -0700 +++ quagga-0.99.9-af/doc/quagga.texi 2008-12-03 14:33:22.000000000 -0800 @@ -86,6 +86,7 @@ * RIPng:: * OSPFv2:: * OSPFv3:: +* OSPFv3 Address Families:: * BGP:: * Configuring Quagga as a Route Server:: * VTY shell:: @@ -110,6 +111,8 @@ @include ripngd.texi @include ospfd.texi @include ospf6d.texi +@include ospf6d-af.texi +@include ospf6d-manet.texi @include bgpd.texi @include routeserver.texi @include vtysh.texi diff -Naur quagga-0.99.9/lib/buffer.c quagga-0.99.9-af/lib/buffer.c --- quagga-0.99.9/lib/buffer.c 2005-12-02 03:02:17.000000000 -0800 +++ quagga-0.99.9-af/lib/buffer.c 2008-12-03 13:42:15.000000000 -0800 @@ -53,7 +53,12 @@ size_t sp; /* Actual data stream (variable length). */ +#if ( __GNUC__ == 2) + // did not compile in FreeBSD, gcc 2.95.4 + unsigned char data[0]; /* real dimension is buffer->size */ +#else unsigned char data[]; /* real dimension is buffer->size */ +#endif }; /* It should always be true that: 0 <= sp <= cp <= size */ @@ -148,7 +153,8 @@ { struct buffer_data *d; - d = XMALLOC(MTYPE_BUFFER_DATA, offsetof(struct buffer_data, data[b->size])); + d = + XMALLOC (MTYPE_BUFFER_DATA, offsetof (struct buffer_data, data[b->size])); d->cp = d->sp = 0; d->next = NULL; @@ -237,7 +243,8 @@ char more[] = " --More-- "; char erase[] = { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}; + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 + }; struct buffer_data *data; int column; @@ -314,7 +321,8 @@ { zlog_warn("%s: growing iov array to %d; " "width %d, height %d, size %lu", - __func__, iov_alloc, width, height, (u_long)b->size); + __func__, iov_alloc, width, height, + (u_long) b->size); iov = XREALLOC(MTYPE_TMP, iov, iov_alloc*sizeof(*iov)); } else diff -Naur quagga-0.99.9/lib/buffer.h quagga-0.99.9-af/lib/buffer.h --- quagga-0.99.9/lib/buffer.h 2005-05-03 12:05:50.000000000 -0700 +++ quagga-0.99.9-af/lib/buffer.h 2008-12-03 13:42:15.000000000 -0800 @@ -96,7 +96,8 @@ to return -1 (because the logic for handling the erase and more features is too complicated to retry the write later). */ -extern buffer_status_t buffer_flush_window (struct buffer *, int fd, int width, - int height, int erase, int no_more); +extern buffer_status_t buffer_flush_window (struct buffer *, int fd, + int width, int height, int erase, + int no_more); #endif /* _ZEBRA_BUFFER_H */ diff -Naur quagga-0.99.9/lib/checksum.c quagga-0.99.9-af/lib/checksum.c --- quagga-0.99.9/lib/checksum.c 2005-11-03 03:52:14.000000000 -0800 +++ quagga-0.99.9-af/lib/checksum.c 2008-12-03 13:42:15.000000000 -0800 @@ -24,13 +24,15 @@ */ sum = 0; - while (nbytes > 1) { + while (nbytes > 1) + { sum += *ptr++; nbytes -= 2; } /* mop up an odd byte, if necessary */ - if (nbytes == 1) { + if (nbytes == 1) + { oddbyte = 0; /* make sure top half is zero */ *((u_char *) &oddbyte) = *(u_char *)ptr; /* one byte only */ sum += oddbyte; diff -Naur quagga-0.99.9/lib/command.c quagga-0.99.9-af/lib/command.c --- quagga-0.99.9/lib/command.c 2007-04-29 05:40:39.000000000 -0700 +++ quagga-0.99.9-af/lib/command.c 2008-12-03 13:42:15.000000000 -0800 @@ -41,74 +41,88 @@ struct host host; /* Standard command node structures. */ -struct cmd_node auth_node = -{ +struct cmd_node auth_node = { AUTH_NODE, "Password: ", }; -struct cmd_node view_node = -{ +struct cmd_node view_node = { VIEW_NODE, "%s> ", }; -struct cmd_node auth_enable_node = -{ +struct cmd_node auth_enable_node = { AUTH_ENABLE_NODE, "Password: ", }; -struct cmd_node enable_node = -{ +struct cmd_node enable_node = { ENABLE_NODE, "%s# ", }; -struct cmd_node config_node = -{ +struct cmd_node config_node = { CONFIG_NODE, "%s(config)# ", 1 }; /* Default motd string. */ -const char *default_motd = -"\r\n\ +const char *default_motd = "\r\n\ Hello, this is " QUAGGA_PROGNAME " (version " QUAGGA_VERSION ").\r\n\ " QUAGGA_COPYRIGHT "\r\n\ \r\n"; -static struct facility_map { +static struct facility_map +{ int facility; const char *name; size_t match; } syslog_facilities[] = { - { LOG_KERN, "kern", 1 }, - { LOG_USER, "user", 2 }, - { LOG_MAIL, "mail", 1 }, - { LOG_DAEMON, "daemon", 1 }, - { LOG_AUTH, "auth", 1 }, - { LOG_SYSLOG, "syslog", 1 }, - { LOG_LPR, "lpr", 2 }, - { LOG_NEWS, "news", 1 }, - { LOG_UUCP, "uucp", 2 }, - { LOG_CRON, "cron", 1 }, + { + LOG_KERN, "kern", 1}, + { + LOG_USER, "user", 2}, + { + LOG_MAIL, "mail", 1}, + { + LOG_DAEMON, "daemon", 1}, + { + LOG_AUTH, "auth", 1}, + { + LOG_SYSLOG, "syslog", 1}, + { + LOG_LPR, "lpr", 2}, + { + LOG_NEWS, "news", 1}, + { + LOG_UUCP, "uucp", 2}, + { + LOG_CRON, "cron", 1}, #ifdef LOG_FTP - { LOG_FTP, "ftp", 1 }, + { + LOG_FTP, "ftp", 1}, #endif - { LOG_LOCAL0, "local0", 6 }, - { LOG_LOCAL1, "local1", 6 }, - { LOG_LOCAL2, "local2", 6 }, - { LOG_LOCAL3, "local3", 6 }, - { LOG_LOCAL4, "local4", 6 }, - { LOG_LOCAL5, "local5", 6 }, - { LOG_LOCAL6, "local6", 6 }, - { LOG_LOCAL7, "local7", 6 }, - { 0, NULL, 0 }, - }; + { + LOG_LOCAL0, "local0", 6}, + { + LOG_LOCAL1, "local1", 6}, + { + LOG_LOCAL2, "local2", 6}, + { + LOG_LOCAL3, "local3", 6}, + { + LOG_LOCAL4, "local4", 6}, + { + LOG_LOCAL5, "local5", 6}, + { + LOG_LOCAL6, "local6", 6}, + { + LOG_LOCAL7, "local7", 6}, + { +0, NULL, 0},}; static const char * facility_name(int facility) @@ -181,8 +195,7 @@ /* Install top node of command vector. */ void -install_node (struct cmd_node *node, - int (*func) (struct vty *)) +install_node (struct cmd_node *node, int (*func) (struct vty *)) { vector_set_index (cmdvec, node->node, node); node->func = func; @@ -402,7 +415,9 @@ sp = cp; - while (! (isspace ((int) *cp) || *cp == '\r' || *cp == '\n' || *cp == ')' || *cp == '|') && *cp != '\0') + while (! + (isspace ((int) *cp) || *cp == '\r' || *cp == '\n' || *cp == ')' + || *cp == '|') && *cp != '\0') cp++; len = cp - sp; @@ -536,7 +551,8 @@ if (host.password_encrypt) vty_out (vty, "password 8 %s%s", host.password_encrypt, VTY_NEWLINE); if (host.enable_encrypt) - vty_out (vty, "enable password 8 %s%s", host.enable_encrypt, VTY_NEWLINE); + vty_out (vty, "enable password 8 %s%s", host.enable_encrypt, + VTY_NEWLINE); } else { @@ -574,9 +590,11 @@ if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED) vty_out(vty,"no log monitor%s",VTY_NEWLINE); - else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] != zlog_default->default_lvl) + else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] != + zlog_default->default_lvl) vty_out(vty,"log monitor %s%s", - zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]],VTY_NEWLINE); + zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]], + VTY_NEWLINE); if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED) { @@ -605,8 +623,7 @@ vty_out (vty, "service password-encryption%s", VTY_NEWLINE); if (host.lines >= 0) - vty_out (vty, "service terminal-length %d%s", host.lines, - VTY_NEWLINE); + vty_out (vty, "service terminal-length %d%s", host.lines, VTY_NEWLINE); if (host.motdfile) vty_out (vty, "banner motd file %s%s", host.motdfile, VTY_NEWLINE); @@ -638,7 +655,9 @@ lim = strlen (command); while (i < lim) { - if (! (isdigit ((int) command[i]) || command[i] == '.' || command[i] == '/')) + if (! + (isdigit ((int) command[i]) || command[i] == '.' + || command[i] == '/')) return 1; i++; } @@ -650,7 +669,9 @@ lim = strlen (command); while (i < lim) { - if (! (isalpha ((int) command[i]) || command[i] == '_' || command[i] == '-')) + if (! + (isalpha ((int) command[i]) || command[i] == '_' + || command[i] == '-')) return 1; i++; } @@ -1557,13 +1578,13 @@ } static int -cmd_try_do_shortcut (enum node_type node, char* first_word) { +cmd_try_do_shortcut (enum node_type node, char *first_word) +{ if ( first_word != NULL && node != AUTH_NODE && node != VIEW_NODE && node != AUTH_ENABLE_NODE && - node != ENABLE_NODE && - 0 == strcmp( "do", first_word ) ) + node != ENABLE_NODE && 0 == strcmp ("do", first_word)) return 1; return 0; } @@ -1616,7 +1637,8 @@ && (vector_active (cmd_element->strvec))) { descvec = vector_slot (cmd_element->strvec, - vector_active (cmd_element->strvec) - 1); + vector_active (cmd_element->strvec) - + 1); for (k = 0; k < vector_active (descvec); k++) { struct desc *desc = vector_slot (descvec, k); @@ -1725,7 +1747,8 @@ /* use memcpy? */ for (index = 1; index < vector_active (vline); index++) { - vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); + vector_set_index (shifted_vline, index - 1, + vector_lookup (vline, index)); } ret = cmd_describe_command_real (shifted_vline, vty, status); @@ -1948,7 +1971,8 @@ /* use memcpy? */ for (index = 1; index < vector_active (vline); index++) { - vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); + vector_set_index (shifted_vline, index - 1, + vector_lookup (vline, index)); } ret = cmd_complete_command_real (shifted_vline, vty, status); @@ -2090,7 +2114,8 @@ if (CMD_VARARG (desc->cmd)) varflag = 1; - if (varflag || CMD_VARIABLE (desc->cmd) || CMD_OPTION (desc->cmd)) + if (varflag || CMD_VARIABLE (desc->cmd) + || CMD_OPTION (desc->cmd)) argv[argc++] = vector_slot (vline, i); } else @@ -2114,7 +2139,8 @@ int cmd_execute_command (vector vline, struct vty *vty, struct cmd_element **cmd, - int vtysh) { + int vtysh) +{ int ret, saved_ret, tried = 0; enum node_type onode, try_node; @@ -2132,7 +2158,8 @@ /* use memcpy? */ for (index = 1; index < vector_active (vline); index++) { - vector_set_index (shifted_vline, index-1, vector_lookup(vline, index)); + vector_set_index (shifted_vline, index - 1, + vector_lookup (vline, index)); } ret = cmd_execute_command_real (shifted_vline, vty, cmd); @@ -2149,8 +2176,7 @@ return saved_ret; /* This assumes all nodes above CONFIG_NODE are childs of CONFIG_NODE */ - while ( ret != CMD_SUCCESS && ret != CMD_WARNING - && vty->node > CONFIG_NODE ) + while (ret != CMD_SUCCESS && ret != CMD_WARNING && vty->node > CONFIG_NODE) { try_node = node_parent(try_node); vty->node = try_node; @@ -2266,7 +2292,8 @@ if (CMD_VARARG (desc->cmd)) varflag = 1; - if (varflag || CMD_VARIABLE (desc->cmd) || CMD_OPTION (desc->cmd)) + if (varflag || CMD_VARIABLE (desc->cmd) + || CMD_OPTION (desc->cmd)) argv[argc++] = vector_slot (vline, i); } else @@ -2326,14 +2353,14 @@ DEFUN (config_terminal, config_terminal_cmd, "configure terminal", - "Configuration from vty interface\n" - "Configuration terminal\n") + "Configuration from vty interface\n" "Configuration terminal\n") { if (vty_config_lock (vty)) vty->node = CONFIG_NODE; else { - vty_out (vty, "VTY configuration is locked by other VTY%s", VTY_NEWLINE); + vty_out (vty, "VTY configuration is locked by other VTY%s", + VTY_NEWLINE); return CMD_WARNING; } return CMD_SUCCESS; @@ -2341,9 +2368,7 @@ /* Enable command */ DEFUN (enable, - config_enable_cmd, - "enable", - "Turn on privileged mode command\n") + config_enable_cmd, "enable", "Turn on privileged mode command\n") { /* If enable password is NULL, change to ENABLE_NODE */ if ((host.enable == NULL && host.enable_encrypt == NULL) || @@ -2357,9 +2382,7 @@ /* Disable command */ DEFUN (disable, - config_disable_cmd, - "disable", - "Turn off privileged mode command\n") + config_disable_cmd, "disable", "Turn off privileged mode command\n") { if (vty->node == ENABLE_NODE) vty->node = VIEW_NODE; @@ -2369,8 +2392,7 @@ /* Down vty node level. */ DEFUN (config_exit, config_exit_cmd, - "exit", - "Exit current mode and down to previous mode\n") + "exit", "Exit current mode and down to previous mode\n") { switch (vty->node) { @@ -2418,14 +2440,10 @@ /* quit is alias of exit. */ ALIAS (config_exit, config_quit_cmd, - "quit", - "Exit current mode and down to previous mode\n") - + "quit", "Exit current mode and down to previous mode\n") /* End of configuration. */ DEFUN (config_end, - config_end_cmd, - "end", - "End current mode and change to enable mode.") + config_end_cmd, "end", "End current mode and change to enable mode.") { switch (vty->node) { @@ -2463,13 +2481,10 @@ /* Show version. */ DEFUN (show_version, - show_version_cmd, - "show version", - SHOW_STR - "Displays zebra version\n") + show_version_cmd, "show version", SHOW_STR "Displays zebra version\n") { - vty_out (vty, "Quagga %s (%s).%s", QUAGGA_VERSION, host.name?host.name:"", - VTY_NEWLINE); + vty_out (vty, "Quagga %s (%s).%s", QUAGGA_VERSION, + host.name ? host.name : "", VTY_NEWLINE); vty_out (vty, "%s%s", QUAGGA_COPYRIGHT, VTY_NEWLINE); return CMD_SUCCESS; @@ -2478,8 +2493,7 @@ /* Help display function for all node. */ DEFUN (config_help, config_help_cmd, - "help", - "Description of the interactive help system\n") + "help", "Description of the interactive help system\n") { vty_out (vty, "Quagga VTY provides advanced help feature. When you need help,%s\ @@ -2493,17 +2507,12 @@ argument.%s\ 2. Partial help is provided when an abbreviated argument is entered%s\ and you want to know what arguments match the input%s\ - (e.g. 'show me?'.)%s%s", VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, - VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, - VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); + (e.g. 'show me?'.)%s%s", VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); return CMD_SUCCESS; } /* Help display function for all node. */ -DEFUN (config_list, - config_list_cmd, - "list", - "Print command list\n") +DEFUN (config_list, config_list_cmd, "list", "Print command list\n") { unsigned int i; struct cmd_node *cnode = vector_slot (cmdvec, vty->node); @@ -2513,8 +2522,7 @@ if ((cmd = vector_slot (cnode->cmd_vector, i)) != NULL && !(cmd->attr == CMD_ATTR_DEPRECATED || cmd->attr == CMD_ATTR_HIDDEN)) - vty_out (vty, " %s%s", cmd->string, - VTY_NEWLINE); + vty_out (vty, " %s%s", cmd->string, VTY_NEWLINE); return CMD_SUCCESS; } @@ -2584,14 +2592,14 @@ if (unlink (config_file_sav) != 0) if (errno != ENOENT) { - vty_out (vty, "Can't unlink backup configuration file %s.%s", config_file_sav, - VTY_NEWLINE); + vty_out (vty, "Can't unlink backup configuration file %s.%s", + config_file_sav, VTY_NEWLINE); goto finished; } if (link (config_file, config_file_sav) != 0) { - vty_out (vty, "Can't backup old configuration file %s.%s", config_file_sav, - VTY_NEWLINE); + vty_out (vty, "Can't backup old configuration file %s.%s", + config_file_sav, VTY_NEWLINE); goto finished; } sync (); @@ -2616,8 +2624,7 @@ goto finished; } - vty_out (vty, "Configuration saved to %s%s", config_file, - VTY_NEWLINE); + vty_out (vty, "Configuration saved to %s%s", config_file, VTY_NEWLINE); ret = CMD_SUCCESS; finished: @@ -2666,8 +2673,7 @@ } else { - vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE, - VTY_NEWLINE); + vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE, VTY_NEWLINE); vty_out (vty, "!%s", VTY_NEWLINE); for (i = 0; i < vector_active (cmdvec); i++) @@ -2684,16 +2690,11 @@ /* Write current configuration into the terminal. */ ALIAS (config_write_terminal, show_running_config_cmd, - "show running-config", - SHOW_STR - "running configuration\n") - + "show running-config", SHOW_STR "running configuration\n") /* Write startup configuration into the terminal. */ DEFUN (show_startup_config, show_startup_config_cmd, - "show startup-config", - SHOW_STR - "Contentes of startup configuration\n") + "show startup-config", SHOW_STR "Contentes of startup configuration\n") { char buf[BUFSIZ]; FILE *confp; @@ -2726,12 +2727,12 @@ DEFUN (config_hostname, hostname_cmd, "hostname WORD", - "Set system's network name\n" - "This system's network name\n") + "Set system's network name\n" "This system's network name\n") { if (!isalpha((int) *argv[0])) { - vty_out (vty, "Please specify string starting with alphabet%s", VTY_NEWLINE); + vty_out (vty, "Please specify string starting with alphabet%s", + VTY_NEWLINE); return CMD_WARNING; } @@ -2745,9 +2746,7 @@ DEFUN (config_no_hostname, no_hostname_cmd, "no hostname [HOSTNAME]", - NO_STR - "Reset system's network name\n" - "Host name of this router\n") + NO_STR "Reset system's network name\n" "Host name of this router\n") { if (host.name) XFREE (MTYPE_HOST, host.name); @@ -2760,8 +2759,7 @@ "password (8|) WORD", "Assign the terminal connection password\n" "Specifies a HIDDEN password will follow\n" - "dummy string \n" - "The HIDDEN line password string\n") + "dummy string \n" "The HIDDEN line password string\n") { /* Argument check. */ if (argc == 0) @@ -2792,7 +2790,8 @@ if (!isalnum ((int) *argv[0])) { vty_out (vty, - "Please specify string starting with alphanumeric%s", VTY_NEWLINE); + "Please specify string starting with alphanumeric%s", + VTY_NEWLINE); return CMD_WARNING; } @@ -2823,8 +2822,7 @@ "Modify enable password parameters\n" "Assign the privileged level password\n" "Specifies a HIDDEN password will follow\n" - "dummy string \n" - "The HIDDEN 'enable' password string\n") + "dummy string \n" "The HIDDEN 'enable' password string\n") { /* Argument check. */ if (argc == 0) @@ -2858,7 +2856,8 @@ if (!isalnum ((int) *argv[0])) { vty_out (vty, - "Please specify string starting with alphanumeric%s", VTY_NEWLINE); + "Please specify string starting with alphanumeric%s", + VTY_NEWLINE); return CMD_WARNING; } @@ -2907,8 +2906,7 @@ DEFUN (service_password_encrypt, service_password_encrypt_cmd, "service password-encryption", - "Set up miscellaneous service\n" - "Enable encrypted passwords\n") + "Set up miscellaneous service\n" "Enable encrypted passwords\n") { if (host.encrypt) return CMD_SUCCESS; @@ -2934,9 +2932,7 @@ DEFUN (no_service_password_encrypt, no_service_password_encrypt_cmd, "no service password-encryption", - NO_STR - "Set up miscellaneous service\n" - "Enable encrypted passwords\n") + NO_STR "Set up miscellaneous service\n" "Enable encrypted passwords\n") { if (! host.encrypt) return CMD_SUCCESS; @@ -2977,8 +2973,7 @@ DEFUN (config_terminal_no_length, config_terminal_no_length_cmd, "terminal no length", "Set terminal line parameters\n" - NO_STR - "Set number of lines on a screen\n") + NO_STR "Set number of lines on a screen\n") { vty->lines = -1; return CMD_SUCCESS; @@ -3018,13 +3013,13 @@ DEFUN_HIDDEN (do_echo, echo_cmd, "echo .MESSAGE", - "Echo a message back to the vty\n" - "The message to echo\n") + "Echo a message back to the vty\n" "The message to echo\n") { char *message; - vty_out (vty, "%s%s", ((message = argv_concat(argv, argc, 0)) ? message : ""), - VTY_NEWLINE); + vty_out (vty, "%s%s", + ((message = + argv_concat (argv, argc, 0)) ? message : ""), VTY_NEWLINE); if (message) XFREE(MTYPE_TMP, message); return CMD_SUCCESS; @@ -3034,8 +3029,7 @@ config_logmsg_cmd, "logmsg "LOG_LEVELS" .MESSAGE", "Send a message to enabled logging destinations\n" - LOG_LEVEL_DESC - "The message to send\n") + LOG_LEVEL_DESC "The message to send\n") { int level; char *message; @@ -3043,7 +3037,8 @@ if ((level = level_match(argv[0])) == ZLOG_DISABLED) return CMD_ERR_NO_MATCH; - zlog(NULL, level, ((message = argv_concat(argv, argc, 1)) ? message : "")); + zlog (NULL, level, + ((message = argv_concat (argv, argc, 1)) ? message : "")); if (message) XFREE(MTYPE_TMP, message); return CMD_SUCCESS; @@ -3051,9 +3046,7 @@ DEFUN (show_logging, show_logging_cmd, - "show logging", - SHOW_STR - "Show current logging configuration\n") + "show logging", SHOW_STR "Show current logging configuration\n") { struct zlog *zl = zlog_default; @@ -3070,26 +3063,22 @@ if (zl->maxlvl[ZLOG_DEST_STDOUT] == ZLOG_DISABLED) vty_out (vty, "disabled"); else - vty_out (vty, "level %s", - zlog_priority[zl->maxlvl[ZLOG_DEST_STDOUT]]); + vty_out (vty, "level %s", zlog_priority[zl->maxlvl[ZLOG_DEST_STDOUT]]); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "Monitor logging: "); if (zl->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED) vty_out (vty, "disabled"); else - vty_out (vty, "level %s", - zlog_priority[zl->maxlvl[ZLOG_DEST_MONITOR]]); + vty_out (vty, "level %s", zlog_priority[zl->maxlvl[ZLOG_DEST_MONITOR]]); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "File logging: "); - if ((zl->maxlvl[ZLOG_DEST_FILE] == ZLOG_DISABLED) || - !zl->fp) + if ((zl->maxlvl[ZLOG_DEST_FILE] == ZLOG_DISABLED) || !zl->fp) vty_out (vty, "disabled"); else vty_out (vty, "level %s, filename %s", - zlog_priority[zl->maxlvl[ZLOG_DEST_FILE]], - zl->filename); + zlog_priority[zl->maxlvl[ZLOG_DEST_FILE]], zl->filename); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "Protocol name: %s%s", @@ -3104,9 +3093,7 @@ DEFUN (config_log_stdout, config_log_stdout_cmd, - "log stdout", - "Logging control\n" - "Set stdout logging level\n") + "log stdout", "Logging control\n" "Set stdout logging level\n") { zlog_set_level (NULL, ZLOG_DEST_STDOUT, zlog_default->default_lvl); return CMD_SUCCESS; @@ -3115,9 +3102,7 @@ DEFUN (config_log_stdout_level, config_log_stdout_level_cmd, "log stdout "LOG_LEVELS, - "Logging control\n" - "Set stdout logging level\n" - LOG_LEVEL_DESC) + "Logging control\n" "Set stdout logging level\n" LOG_LEVEL_DESC) { int level; @@ -3131,9 +3116,7 @@ no_config_log_stdout_cmd, "no log stdout [LEVEL]", NO_STR - "Logging control\n" - "Cancel logging to stdout\n" - "Logging level\n") + "Logging control\n" "Cancel logging to stdout\n" "Logging level\n") { zlog_set_level (NULL, ZLOG_DEST_STDOUT, ZLOG_DISABLED); return CMD_SUCCESS; @@ -3142,8 +3125,7 @@ DEFUN (config_log_monitor, config_log_monitor_cmd, "log monitor", - "Logging control\n" - "Set terminal line (monitor) logging level\n") + "Logging control\n" "Set terminal line (monitor) logging level\n") { zlog_set_level (NULL, ZLOG_DEST_MONITOR, zlog_default->default_lvl); return CMD_SUCCESS; @@ -3153,8 +3135,7 @@ config_log_monitor_level_cmd, "log monitor "LOG_LEVELS, "Logging control\n" - "Set terminal line (monitor) logging level\n" - LOG_LEVEL_DESC) + "Set terminal line (monitor) logging level\n" LOG_LEVEL_DESC) { int level; @@ -3169,8 +3150,7 @@ "no log monitor [LEVEL]", NO_STR "Logging control\n" - "Disable terminal line (monitor) logging\n" - "Logging level\n") + "Disable terminal line (monitor) logging\n" "Logging level\n") { zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED); return CMD_SUCCESS; @@ -3229,9 +3209,7 @@ DEFUN (config_log_file, config_log_file_cmd, "log file FILENAME", - "Logging control\n" - "Logging to file\n" - "Logging filename\n") + "Logging control\n" "Logging to file\n" "Logging filename\n") { return set_log_file(vty, argv[0], zlog_default->default_lvl); } @@ -3240,9 +3218,7 @@ config_log_file_level_cmd, "log file FILENAME "LOG_LEVELS, "Logging control\n" - "Logging to file\n" - "Logging filename\n" - LOG_LEVEL_DESC) + "Logging to file\n" "Logging filename\n" LOG_LEVEL_DESC) { int level; @@ -3255,9 +3231,7 @@ no_config_log_file_cmd, "no log file [FILENAME]", NO_STR - "Logging control\n" - "Cancel logging to file\n" - "Logging file name\n") + "Logging control\n" "Cancel logging to file\n" "Logging file name\n") { zlog_reset_file (NULL); @@ -3277,12 +3251,9 @@ "Cancel logging to file\n" "Logging file name\n" "Logging level\n") - DEFUN (config_log_syslog, config_log_syslog_cmd, - "log syslog", - "Logging control\n" - "Set syslog logging level\n") + "log syslog", "Logging control\n" "Set syslog logging level\n") { zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl); return CMD_SUCCESS; @@ -3291,9 +3262,7 @@ DEFUN (config_log_syslog_level, config_log_syslog_level_cmd, "log syslog "LOG_LEVELS, - "Logging control\n" - "Set syslog logging level\n" - LOG_LEVEL_DESC) + "Logging control\n" "Set syslog logging level\n" LOG_LEVEL_DESC) { int level; @@ -3325,9 +3294,7 @@ no_config_log_syslog_cmd, "no log syslog [LEVEL]", NO_STR - "Logging control\n" - "Cancel logging to syslog\n" - "Logging level\n") + "Logging control\n" "Cancel logging to syslog\n" "Logging level\n") { zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED); return CMD_SUCCESS; @@ -3346,8 +3313,7 @@ config_log_facility_cmd, "log facility "LOG_FACILITIES, "Logging control\n" - "Facility parameter for syslog messages\n" - LOG_FACILITY_DESC) + "Facility parameter for syslog messages\n" LOG_FACILITY_DESC) { int facility; @@ -3362,8 +3328,7 @@ "no log facility [FACILITY]", NO_STR "Logging control\n" - "Reset syslog facility to default (daemon)\n" - "Syslog facility\n") + "Reset syslog facility to default (daemon)\n" "Syslog facility\n") { zlog_default->facility = LOG_DAEMON; return CMD_SUCCESS; @@ -3394,8 +3359,7 @@ "no log trap [LEVEL]", NO_STR "Logging control\n" - "Permit all logging information\n" - "Logging level\n") + "Permit all logging information\n" "Logging level\n") { zlog_default->default_lvl = LOG_DEBUG; return CMD_SUCCESS; @@ -3427,8 +3391,7 @@ "log timestamp precision <0-6>", "Logging control\n" "Timestamp configuration\n" - "Set the timestamp precision\n" - "Number of subsecond digits\n") + "Set the timestamp precision\n" "Number of subsecond digits\n") { if (argc != 1) { @@ -3456,10 +3419,7 @@ DEFUN (banner_motd_file, banner_motd_file_cmd, "banner motd file [FILE]", - "Set banner\n" - "Banner for motd\n" - "Banner from a file\n" - "Filename\n") + "Set banner\n" "Banner for motd\n" "Banner from a file\n" "Filename\n") { if (host.motdfile) XFREE (MTYPE_HOST, host.motdfile); @@ -3471,9 +3431,7 @@ DEFUN (banner_motd_default, banner_motd_default_cmd, "banner motd default", - "Set banner string\n" - "Strings for motd\n" - "Default string\n") + "Set banner string\n" "Strings for motd\n" "Default string\n") { host.motd = default_motd; return CMD_SUCCESS; @@ -3481,10 +3439,7 @@ DEFUN (no_banner_motd, no_banner_motd_cmd, - "no banner motd", - NO_STR - "Set banner string\n" - "Strings for motd\n") + "no banner motd", NO_STR "Set banner string\n" "Strings for motd\n") { host.motd = NULL; if (host.motdfile) diff -Naur quagga-0.99.9/lib/command.h quagga-0.99.9-af/lib/command.h --- quagga-0.99.9/lib/command.h 2007-05-02 08:28:32.000000000 -0700 +++ quagga-0.99.9-af/lib/command.h 2008-12-03 13:42:15.000000000 -0800 @@ -25,7 +25,11 @@ #include "vector.h" #include "vty.h" -#include "lib/route_types.h" +#include "route_types.h" + +#ifdef __cplusplus +#define vector __quagga_vector +#endif /* __cplusplus */ /* Host configuration variable */ struct host @@ -342,8 +346,10 @@ extern const char *cmd_prompt (enum node_type); extern int config_from_file (struct vty *, FILE *); extern enum node_type node_parent (enum node_type); -extern int cmd_execute_command (vector, struct vty *, struct cmd_element **, int); -extern int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **); +extern int cmd_execute_command (vector, struct vty *, struct cmd_element **, + int); +extern int cmd_execute_command_strict (vector, struct vty *, + struct cmd_element **); extern void config_replace_string (struct cmd_element *, char *, ...); extern void cmd_init (int); @@ -360,4 +366,9 @@ /* struct host global, ick */ extern struct host host; + +#ifdef __cplusplus +#undef vector +#endif /* __cplusplus */ + #endif /* _ZEBRA_COMMAND_H */ diff -Naur quagga-0.99.9/lib/distribute.c quagga-0.99.9-af/lib/distribute.c --- quagga-0.99.9/lib/distribute.c 2005-05-06 07:43:13.000000000 -0700 +++ quagga-0.99.9-af/lib/distribute.c 2008-12-03 13:42:15.000000000 -0800 @@ -385,8 +385,7 @@ "Filter networks in routing updates\n" "Access-list name\n" "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") + "Filter outgoing routing updates\n" "Interface name\n") { enum distribute_type type; struct distribute *dist; @@ -398,7 +397,8 @@ type = DISTRIBUTE_OUT; else { - vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); + vty_out (vty, "distribute list direction must be [in|out]%s", + VTY_NEWLINE); return CMD_WARNING; } @@ -423,8 +423,7 @@ "Filter networks in routing updates\n" "Access-list name\n" "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") + "Filter outgoing routing updates\n" "Interface name\n") { int ret; enum distribute_type type; @@ -436,7 +435,8 @@ type = DISTRIBUTE_OUT; else { - vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); + vty_out (vty, "distribute list direction must be [in|out]%s", + VTY_NEWLINE); return CMD_WARNING; } @@ -547,8 +547,7 @@ "Filter prefixes in routing updates\n" "Name of an IP prefix-list\n" "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") + "Filter outgoing routing updates\n" "Interface name\n") { enum distribute_type type; struct distribute *dist; @@ -587,8 +586,7 @@ "Filter prefixes in routing updates\n" "Name of an IP prefix-list\n" "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") + "Filter outgoing routing updates\n" "Interface name\n") { int ret; enum distribute_type type; @@ -621,11 +619,8 @@ "Filter prefixes in routing updates\n" "Name of an IP prefix-list\n" "Filter incoming routing updates\n" - "Filter outgoing routing updates\n" - "Interface name\n") - -int -config_show_distribute (struct vty *vty) + "Filter outgoing routing updates\n" "Interface name\n") + int config_show_distribute (struct vty *vty) { unsigned int i; struct hash_backet *mp; @@ -645,7 +640,9 @@ vty_out (vty, "%s", VTY_NEWLINE); } else - vty_out (vty, " Outgoing update filter list for all interface is not set%s", VTY_NEWLINE); + vty_out (vty, + " Outgoing update filter list for all interface is not set%s", + VTY_NEWLINE); for (i = 0; i < disthash->size; i++) for (mp = disthash->index[i]; mp; mp = mp->next) @@ -680,7 +677,9 @@ vty_out (vty, "%s", VTY_NEWLINE); } else - vty_out (vty, " Incoming update filter list for all interface is not set%s", VTY_NEWLINE); + vty_out (vty, + " Incoming update filter list for all interface is not set%s", + VTY_NEWLINE); for (i = 0; i < disthash->size; i++) for (mp = disthash->index[i]; mp; mp = mp->next) @@ -721,18 +720,15 @@ { vty_out (vty, " distribute-list %s in %s%s", dist->list[DISTRIBUTE_IN], - dist->ifname ? dist->ifname : "", - VTY_NEWLINE); + dist->ifname ? dist->ifname : "", VTY_NEWLINE); write++; } if (dist->list[DISTRIBUTE_OUT]) { vty_out (vty, " distribute-list %s out %s%s", - dist->list[DISTRIBUTE_OUT], - dist->ifname ? dist->ifname : "", - VTY_NEWLINE); + dist->ifname ? dist->ifname : "", VTY_NEWLINE); write++; } @@ -740,8 +736,7 @@ { vty_out (vty, " distribute-list prefix %s in %s%s", dist->prefix[DISTRIBUTE_IN], - dist->ifname ? dist->ifname : "", - VTY_NEWLINE); + dist->ifname ? dist->ifname : "", VTY_NEWLINE); write++; } @@ -749,8 +744,7 @@ { vty_out (vty, " distribute-list prefix %s out %s%s", dist->prefix[DISTRIBUTE_OUT], - dist->ifname ? dist->ifname : "", - VTY_NEWLINE); + dist->ifname ? dist->ifname : "", VTY_NEWLINE); write++; } } @@ -771,7 +765,8 @@ disthash = hash_create ((unsigned int (*) (void *)) distribute_hash_make, (int (*) (void *, void *)) distribute_cmp); - if(node==RIP_NODE) { + if (node == RIP_NODE) + { install_element (RIP_NODE, &distribute_list_all_cmd); install_element (RIP_NODE, &no_distribute_list_all_cmd); install_element (RIP_NODE, &distribute_list_cmd); @@ -780,7 +775,9 @@ install_element (RIP_NODE, &no_distribute_list_prefix_all_cmd); install_element (RIP_NODE, &distribute_list_prefix_cmd); install_element (RIP_NODE, &no_distribute_list_prefix_cmd); - } else { + } + else + { install_element (RIPNG_NODE, &ipv6_distribute_list_all_cmd); install_element (RIPNG_NODE, &no_ipv6_distribute_list_all_cmd); install_element (RIPNG_NODE, &ipv6_distribute_list_cmd); diff -Naur quagga-0.99.9/lib/distribute.h quagga-0.99.9-af/lib/distribute.h --- quagga-0.99.9/lib/distribute.h 2005-05-03 10:26:11.000000000 -0700 +++ quagga-0.99.9-af/lib/distribute.h 2008-12-03 13:42:15.000000000 -0800 @@ -51,7 +51,9 @@ extern int config_write_distribute (struct vty *); extern int config_show_distribute (struct vty *); -extern enum filter_type distribute_apply_in (struct interface *, struct prefix *); -extern enum filter_type distribute_apply_out (struct interface *, struct prefix *); +extern enum filter_type distribute_apply_in (struct interface *, + struct prefix *); +extern enum filter_type distribute_apply_out (struct interface *, + struct prefix *); #endif /* _ZEBRA_DISTRIBUTE_H */ diff -Naur quagga-0.99.9/lib/filter.c quagga-0.99.9-af/lib/filter.c --- quagga-0.99.9/lib/filter.c 2005-09-29 07:41:06.000000000 -0700 +++ quagga-0.99.9-af/lib/filter.c 2008-12-03 13:42:15.000000000 -0800 @@ -92,8 +92,7 @@ }; /* Static structure for IPv4 access_list's master. */ -static struct access_master access_master_ipv4 = -{ +static struct access_master access_master_ipv4 = { {NULL, NULL}, {NULL, NULL}, NULL, @@ -102,8 +101,7 @@ #ifdef HAVE_IPV6 /* Static structure for IPv6 access_list's master. */ -static struct access_master access_master_ipv6 = -{ +static struct access_master access_master_ipv6 = { {NULL, NULL}, {NULL, NULL}, NULL, @@ -577,8 +575,7 @@ access = access_list_lookup (afi, name); if (! access) { - vty_out (vty, "%% access-list %s doesn't exist%s", name, - VTY_NEWLINE); + vty_out (vty, "%% access-list %s doesn't exist%s", name, VTY_NEWLINE); return CMD_WARNING; } @@ -624,16 +621,14 @@ ret = inet_aton (addr_str, &addr); if (ret <= 0) { - vty_out (vty, "%%Inconsistent address and mask%s", - VTY_NEWLINE); + vty_out (vty, "%%Inconsistent address and mask%s", VTY_NEWLINE); return CMD_WARNING; } ret = inet_aton (addr_mask_str, &addr_mask); if (ret <= 0) { - vty_out (vty, "%%Inconsistent address and mask%s", - VTY_NEWLINE); + vty_out (vty, "%%Inconsistent address and mask%s", VTY_NEWLINE); return CMD_WARNING; } @@ -642,16 +637,14 @@ ret = inet_aton (mask_str, &mask); if (ret <= 0) { - vty_out (vty, "%%Inconsistent address and mask%s", - VTY_NEWLINE); + vty_out (vty, "%%Inconsistent address and mask%s", VTY_NEWLINE); return CMD_WARNING; } ret = inet_aton (mask_mask_str, &mask_mask); if (ret <= 0) { - vty_out (vty, "%%Inconsistent address and mask%s", - VTY_NEWLINE); + vty_out (vty, "%%Inconsistent address and mask%s", VTY_NEWLINE); return CMD_WARNING; } } @@ -702,9 +695,7 @@ "IP standard access list\n" "IP standard access list (expanded range)\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Address to match\n" - "Wildcard bits\n") + "Specify packets to forward\n" "Address to match\n" "Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3], NULL, NULL, 0, 1); @@ -717,8 +708,7 @@ "IP standard access list\n" "IP standard access list (expanded range)\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Address to match\n") + "Specify packets to forward\n" "Address to match\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", NULL, NULL, 0, 1); @@ -732,8 +722,7 @@ "IP standard access list (expanded range)\n" "Specify packets to reject\n" "Specify packets to forward\n" - "A single host address\n" - "Address to match\n") + "A single host address\n" "Address to match\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", NULL, NULL, 0, 1); @@ -746,8 +735,7 @@ "IP standard access list\n" "IP standard access list (expanded range)\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Any source host\n") + "Specify packets to forward\n" "Any source host\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", "255.255.255.255", NULL, NULL, 0, 1); @@ -761,9 +749,7 @@ "IP standard access list\n" "IP standard access list (expanded range)\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Address to match\n" - "Wildcard bits\n") + "Specify packets to forward\n" "Address to match\n" "Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3], NULL, NULL, 0, 0); @@ -777,8 +763,7 @@ "IP standard access list\n" "IP standard access list (expanded range)\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Address to match\n") + "Specify packets to forward\n" "Address to match\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", NULL, NULL, 0, 0); @@ -793,8 +778,7 @@ "IP standard access list (expanded range)\n" "Specify packets to reject\n" "Specify packets to forward\n" - "A single host address\n" - "Address to match\n") + "A single host address\n" "Address to match\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0", NULL, NULL, 0, 0); @@ -808,8 +792,7 @@ "IP standard access list\n" "IP standard access list (expanded range)\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Any source host\n") + "Specify packets to forward\n" "Any source host\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", "255.255.255.255", NULL, NULL, 0, 0); @@ -827,8 +810,7 @@ "Any Internet Protocol\n" "Source address\n" "Source wildcard bits\n" - "Destination address\n" - "Destination Wildcard bits\n") + "Destination address\n" "Destination Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], 1 ,1); @@ -843,13 +825,10 @@ "Specify packets to reject\n" "Specify packets to forward\n" "Any Internet Protocol\n" - "Source address\n" - "Source wildcard bits\n" - "Any destination host\n") + "Source address\n" "Source wildcard bits\n" "Any destination host\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], "0.0.0.0", - "255.255.255.255", 1, 1); + argv[3], "0.0.0.0", "255.255.255.255", 1, 1); } DEFUN (access_list_extended_any_mask, @@ -862,12 +841,10 @@ "Specify packets to forward\n" "Any Internet Protocol\n" "Any source host\n" - "Destination address\n" - "Destination Wildcard bits\n") + "Destination address\n" "Destination Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], - argv[3], 1, 1); + "255.255.255.255", argv[2], argv[3], 1, 1); } DEFUN (access_list_extended_any_any, @@ -878,9 +855,7 @@ "IP extended access list (expanded range)\n" "Specify packets to reject\n" "Specify packets to forward\n" - "Any Internet Protocol\n" - "Any source host\n" - "Any destination host\n") + "Any Internet Protocol\n" "Any source host\n" "Any destination host\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", "255.255.255.255", "0.0.0.0", @@ -898,12 +873,10 @@ "Any Internet Protocol\n" "Source address\n" "Source wildcard bits\n" - "A single destination host\n" - "Destination address\n") + "A single destination host\n" "Destination address\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], argv[4], - "0.0.0.0", 1, 1); + argv[3], argv[4], "0.0.0.0", 1, 1); } DEFUN (access_list_extended_host_mask, @@ -917,12 +890,10 @@ "Any Internet Protocol\n" "A single source host\n" "Source address\n" - "Destination address\n" - "Destination Wildcard bits\n") + "Destination address\n" "Destination Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], - argv[4], 1, 1); + "0.0.0.0", argv[3], argv[4], 1, 1); } DEFUN (access_list_extended_host_host, @@ -936,12 +907,10 @@ "Any Internet Protocol\n" "A single source host\n" "Source address\n" - "A single destination host\n" - "Destination address\n") + "A single destination host\n" "Destination address\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], - "0.0.0.0", 1, 1); + "0.0.0.0", argv[3], "0.0.0.0", 1, 1); } DEFUN (access_list_extended_any_host, @@ -954,12 +923,10 @@ "Specify packets to forward\n" "Any Internet Protocol\n" "Any source host\n" - "A single destination host\n" - "Destination address\n") + "A single destination host\n" "Destination address\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], - "0.0.0.0", 1, 1); + "255.255.255.255", argv[2], "0.0.0.0", 1, 1); } DEFUN (access_list_extended_host_any, @@ -971,13 +938,10 @@ "Specify packets to reject\n" "Specify packets to forward\n" "Any Internet Protocol\n" - "A single source host\n" - "Source address\n" - "Any destination host\n") + "A single source host\n" "Source address\n" "Any destination host\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", "0.0.0.0", - "255.255.255.255", 1, 1); + "0.0.0.0", "0.0.0.0", "255.255.255.255", 1, 1); } DEFUN (no_access_list_extended, @@ -992,8 +956,7 @@ "Any Internet Protocol\n" "Source address\n" "Source wildcard bits\n" - "Destination address\n" - "Destination Wildcard bits\n") + "Destination address\n" "Destination Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], 1, 0); @@ -1009,13 +972,10 @@ "Specify packets to reject\n" "Specify packets to forward\n" "Any Internet Protocol\n" - "Source address\n" - "Source wildcard bits\n" - "Any destination host\n") + "Source address\n" "Source wildcard bits\n" "Any destination host\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], "0.0.0.0", - "255.255.255.255", 1, 0); + argv[3], "0.0.0.0", "255.255.255.255", 1, 0); } DEFUN (no_access_list_extended_any_mask, @@ -1029,12 +989,10 @@ "Specify packets to forward\n" "Any Internet Protocol\n" "Any source host\n" - "Destination address\n" - "Destination Wildcard bits\n") + "Destination address\n" "Destination Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], - argv[3], 1, 0); + "255.255.255.255", argv[2], argv[3], 1, 0); } DEFUN (no_access_list_extended_any_any, @@ -1046,9 +1004,7 @@ "IP extended access list (expanded range)\n" "Specify packets to reject\n" "Specify packets to forward\n" - "Any Internet Protocol\n" - "Any source host\n" - "Any destination host\n") + "Any Internet Protocol\n" "Any source host\n" "Any destination host\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", "255.255.255.255", "0.0.0.0", @@ -1067,12 +1023,10 @@ "Any Internet Protocol\n" "Source address\n" "Source wildcard bits\n" - "A single destination host\n" - "Destination address\n") + "A single destination host\n" "Destination address\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - argv[3], argv[4], - "0.0.0.0", 1, 0); + argv[3], argv[4], "0.0.0.0", 1, 0); } DEFUN (no_access_list_extended_host_mask, @@ -1087,12 +1041,10 @@ "Any Internet Protocol\n" "A single source host\n" "Source address\n" - "Destination address\n" - "Destination Wildcard bits\n") + "Destination address\n" "Destination Wildcard bits\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], - argv[4], 1, 0); + "0.0.0.0", argv[3], argv[4], 1, 0); } DEFUN (no_access_list_extended_host_host, @@ -1107,12 +1059,10 @@ "Any Internet Protocol\n" "A single source host\n" "Source address\n" - "A single destination host\n" - "Destination address\n") + "A single destination host\n" "Destination address\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", argv[3], - "0.0.0.0", 1, 0); + "0.0.0.0", argv[3], "0.0.0.0", 1, 0); } DEFUN (no_access_list_extended_any_host, @@ -1126,12 +1076,10 @@ "Specify packets to forward\n" "Any Internet Protocol\n" "Any source host\n" - "A single destination host\n" - "Destination address\n") + "A single destination host\n" "Destination address\n") { return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0", - "255.255.255.255", argv[2], - "0.0.0.0", 1, 0); + "255.255.255.255", argv[2], "0.0.0.0", 1, 0); } DEFUN (no_access_list_extended_host_any, @@ -1144,13 +1092,10 @@ "Specify packets to reject\n" "Specify packets to forward\n" "Any Internet Protocol\n" - "A single source host\n" - "Source address\n" - "Any destination host\n") + "A single source host\n" "Source address\n" "Any destination host\n") { return filter_set_cisco (vty, argv[0], argv[1], argv[2], - "0.0.0.0", "0.0.0.0", - "255.255.255.255", 1, 0); + "0.0.0.0", "0.0.0.0", "255.255.255.255", 1, 0); } static int @@ -1241,8 +1186,7 @@ "Add an access list entry\n" "IP zebra access-list name\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Prefix to match. e.g. 10.0.0.0/8\n") + "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 0, 1); } @@ -1254,8 +1198,7 @@ "IP zebra access-list name\n" "Specify packets to reject\n" "Specify packets to forward\n" - "Prefix to match. e.g. 10.0.0.0/8\n" - "Exact match of the prefixes\n") + "Prefix to match. e.g. 10.0.0.0/8\n" "Exact match of the prefixes\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 1, 1); } @@ -1266,8 +1209,7 @@ "Add an access list entry\n" "IP zebra access-list name\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Prefix to match. e.g. 10.0.0.0/8\n") + "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, "0.0.0.0/0", 0, 1); } @@ -1279,8 +1221,7 @@ "Add an access list entry\n" "IP zebra access-list name\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Prefix to match. e.g. 10.0.0.0/8\n") + "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 0, 0); } @@ -1293,8 +1234,7 @@ "IP zebra access-list name\n" "Specify packets to reject\n" "Specify packets to forward\n" - "Prefix to match. e.g. 10.0.0.0/8\n" - "Exact match of the prefixes\n") + "Prefix to match. e.g. 10.0.0.0/8\n" "Exact match of the prefixes\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 1, 0); } @@ -1306,8 +1246,7 @@ "Add an access list entry\n" "IP zebra access-list name\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Prefix to match. e.g. 10.0.0.0/8\n") + "Specify packets to forward\n" "Prefix to match. e.g. 10.0.0.0/8\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, "0.0.0.0/0", 0, 0); } @@ -1356,8 +1295,7 @@ "IP standard access list (expanded range)\n" "IP extended access list (expanded range)\n" "IP zebra access-list\n" - "Access list entry comment\n" - "Comment up to 100 characters\n") + "Access list entry comment\n" "Comment up to 100 characters\n") { struct access_list *access; @@ -1382,8 +1320,7 @@ "IP extended access list\n" "IP standard access list (expanded range)\n" "IP extended access list (expanded range)\n" - "IP zebra access-list\n" - "Access list entry comment\n") + "IP zebra access-list\n" "Access list entry comment\n") { return vty_access_list_remark_unset (vty, AFI_IP, argv[0]); } @@ -1398,9 +1335,7 @@ "IP standard access list (expanded range)\n" "IP extended access list (expanded range)\n" "IP zebra access-list\n" - "Access list entry comment\n" - "Comment up to 100 characters\n") - + "Access list entry comment\n" "Comment up to 100 characters\n") #ifdef HAVE_IPV6 DEFUN (ipv6_access_list, ipv6_access_list_cmd, @@ -1409,8 +1344,7 @@ "Add an access list entry\n" "IPv6 zebra access-list\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Prefix to match. e.g. 3ffe:506::/32\n") + "Specify packets to forward\n" "Prefix to match. e.g. 3ffe:506::/32\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 0, 1); } @@ -1436,8 +1370,7 @@ "Add an access list entry\n" "IPv6 zebra access-list\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Any prefixi to match\n") + "Specify packets to forward\n" "Any prefixi to match\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, "::/0", 0, 1); } @@ -1450,8 +1383,7 @@ "Add an access list entry\n" "IPv6 zebra access-list\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Prefix to match. e.g. 3ffe:506::/32\n") + "Specify packets to forward\n" "Prefix to match. e.g. 3ffe:506::/32\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 0, 0); } @@ -1479,8 +1411,7 @@ "Add an access list entry\n" "IPv6 zebra access-list\n" "Specify packets to reject\n" - "Specify packets to forward\n" - "Any prefixi to match\n") + "Specify packets to forward\n" "Any prefixi to match\n") { return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, "::/0", 0, 0); } @@ -1490,9 +1421,7 @@ no_ipv6_access_list_all_cmd, "no ipv6 access-list WORD", NO_STR - IPV6_STR - "Add an access list entry\n" - "IPv6 zebra access-list\n") + IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n") { struct access_list *access; struct access_master *master; @@ -1524,8 +1453,7 @@ IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n" - "Access list entry comment\n" - "Comment up to 100 characters\n") + "Access list entry comment\n" "Comment up to 100 characters\n") { struct access_list *access; @@ -1547,8 +1475,7 @@ NO_STR IPV6_STR "Add an access list entry\n" - "IPv6 zebra access-list\n" - "Access list entry comment\n") + "IPv6 zebra access-list\n" "Access list entry comment\n") { return vty_access_list_remark_unset (vty, AFI_IP6, argv[0]); } @@ -1560,16 +1487,13 @@ IPV6_STR "Add an access list entry\n" "IPv6 zebra access-list\n" - "Access list entry comment\n" - "Comment up to 100 characters\n") + "Access list entry comment\n" "Comment up to 100 characters\n") #endif /* HAVE_IPV6 */ - void config_write_access_zebra (struct vty *, struct filter *); void config_write_access_cisco (struct vty *, struct filter *); /* show access-list command. */ -static int -filter_show (struct vty *vty, const char *name, afi_t afi) + static int filter_show (struct vty *vty, const char *name, afi_t afi) { struct access_list *access; struct access_master *master; @@ -1602,8 +1526,7 @@ vty_out (vty, "%s IP%s access list %s%s", mfilter->cisco ? (filter->extended ? "Extended" : "Standard") : "Zebra", - afi == AFI_IP6 ? "v6" : "", - access->name, VTY_NEWLINE); + afi == AFI_IP6 ? "v6" : "", access->name, VTY_NEWLINE); write = 0; } @@ -1622,7 +1545,8 @@ { vty_out (vty, " %s", inet_ntoa (filter->addr)); if (filter->addr_mask.s_addr != 0) - vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask)); + vty_out (vty, ", wildcard bits %s", + inet_ntoa (filter->addr_mask)); vty_out (vty, "%s", VTY_NEWLINE); } } @@ -1645,8 +1569,7 @@ vty_out (vty, "%s IP%s access list %s%s", mfilter->cisco ? (filter->extended ? "Extended" : "Standard") : "Zebra", - afi == AFI_IP6 ? "v6" : "", - access->name, VTY_NEWLINE); + afi == AFI_IP6 ? "v6" : "", access->name, VTY_NEWLINE); write = 0; } @@ -1665,7 +1588,8 @@ { vty_out (vty, " %s", inet_ntoa (filter->addr)); if (filter->addr_mask.s_addr != 0) - vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask)); + vty_out (vty, ", wildcard bits %s", + inet_ntoa (filter->addr_mask)); vty_out (vty, "%s", VTY_NEWLINE); } } @@ -1676,10 +1600,7 @@ DEFUN (show_ip_access_list, show_ip_access_list_cmd, - "show ip access-list", - SHOW_STR - IP_STR - "List IP access lists\n") + "show ip access-list", SHOW_STR IP_STR "List IP access lists\n") { return filter_show (vty, NULL, AFI_IP); } @@ -1693,8 +1614,7 @@ "IP standard access list\n" "IP extended access list\n" "IP standard access list (expanded range)\n" - "IP extended access list (expanded range)\n" - "IP zebra access-list\n") + "IP extended access list (expanded range)\n" "IP zebra access-list\n") { return filter_show (vty, argv[0], AFI_IP); } @@ -1702,10 +1622,7 @@ #ifdef HAVE_IPV6 DEFUN (show_ipv6_access_list, show_ipv6_access_list_cmd, - "show ipv6 access-list", - SHOW_STR - IPV6_STR - "List IPv6 access lists\n") + "show ipv6 access-list", SHOW_STR IPV6_STR "List IPv6 access lists\n") { return filter_show (vty, NULL, AFI_IP6); } @@ -1714,9 +1631,7 @@ show_ipv6_access_list_name_cmd, "show ipv6 access-list WORD", SHOW_STR - IPV6_STR - "List IPv6 access lists\n" - "IPv6 zebra access-list\n") + IPV6_STR "List IPv6 access lists\n" "IPv6 zebra access-list\n") { return filter_show (vty, argv[0], AFI_IP6); } @@ -1782,8 +1697,7 @@ else vty_out (vty, " %s/%d%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), - p->prefixlen, - filter->exact ? " exact-match" : ""); + p->prefixlen, filter->exact ? " exact-match" : ""); vty_out (vty, "%s", VTY_NEWLINE); } @@ -1806,8 +1720,7 @@ { vty_out (vty, "%saccess-list %s remark %s%s", afi == AFI_IP ? "" : "ipv6 ", - access->name, access->remark, - VTY_NEWLINE); + access->name, access->remark, VTY_NEWLINE); write++; } @@ -1815,8 +1728,7 @@ { vty_out (vty, "%saccess-list %s %s", afi == AFI_IP ? "" : "ipv6 ", - access->name, - filter_type_str (mfilter)); + access->name, filter_type_str (mfilter)); if (mfilter->cisco) config_write_access_cisco (vty, mfilter); @@ -1833,8 +1745,7 @@ { vty_out (vty, "%saccess-list %s remark %s%s", afi == AFI_IP ? "" : "ipv6 ", - access->name, access->remark, - VTY_NEWLINE); + access->name, access->remark, VTY_NEWLINE); write++; } @@ -1842,8 +1753,7 @@ { vty_out (vty, "%saccess-list %s %s", afi == AFI_IP ? "" : "ipv6 ", - access->name, - filter_type_str (mfilter)); + access->name, filter_type_str (mfilter)); if (mfilter->cisco) config_write_access_cisco (vty, mfilter); @@ -1857,8 +1767,7 @@ } /* Access-list node. */ -struct cmd_node access_node = -{ +struct cmd_node access_node = { ACCESS_NODE, "", /* Access list has no interface. */ 1 @@ -1953,8 +1862,7 @@ } #ifdef HAVE_IPV6 -struct cmd_node access_ipv6_node = -{ +struct cmd_node access_ipv6_node = { ACCESS_IPV6_NODE, "", 1 diff -Naur quagga-0.99.9/lib/getopt1.c quagga-0.99.9-af/lib/getopt1.c --- quagga-0.99.9/lib/getopt1.c 2005-05-15 07:32:03.000000000 -0700 +++ quagga-0.99.9-af/lib/getopt1.c 2008-12-03 13:42:15.000000000 -0800 @@ -112,8 +112,7 @@ { int this_option_optind = optind ? optind : 1; int option_index = 0; - static struct option long_options[] = - { + static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, diff -Naur quagga-0.99.9/lib/getopt.c quagga-0.99.9-af/lib/getopt.c --- quagga-0.99.9/lib/getopt.c 2005-08-13 03:55:48.000000000 -0700 +++ quagga-0.99.9-af/lib/getopt.c 2008-12-03 13:42:15.000000000 -0800 @@ -270,8 +270,7 @@ is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void -__attribute__ ((unused)) -store_args_and_env (int argc, char *const *argv) + __attribute__ ((unused)) store_args_and_env (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ @@ -638,7 +637,9 @@ if (longopts != NULL && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + || (long_only + && (argv[optind][2] + || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; @@ -704,12 +705,14 @@ if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), + _ + ("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), + _ + ("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } @@ -786,11 +789,9 @@ { if (posixly_correct) /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: illegal option -- %c\n"), - argv[0], c); + fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else - fprintf (stderr, _("%s: invalid option -- %c\n"), - argv[0], c); + fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; @@ -837,7 +838,8 @@ /* optarg is now the argument, see if it's in the table of longopts. */ - for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + for (nextchar = nameend = optarg; *nameend && *nameend != '='; + nameend++) /* Do nothing. */ ; /* Test all long options for either exact match @@ -885,8 +887,7 @@ { if (opterr) fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); +%s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; @@ -978,9 +979,7 @@ const char *optstring; { return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); + (const struct option *) 0, (int *) 0, 0); } #endif /* REALLY_NEED_PLAIN_GETOPT */ diff -Naur quagga-0.99.9/lib/getopt.h quagga-0.99.9-af/lib/getopt.h --- quagga-0.99.9/lib/getopt.h 2005-08-13 03:55:48.000000000 -0700 +++ quagga-0.99.9-af/lib/getopt.h 2008-12-03 13:42:15.000000000 -0800 @@ -35,7 +35,8 @@ */ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif /* For communication from `getopt' to the caller. diff -Naur quagga-0.99.9/lib/if.c quagga-0.99.9-af/lib/if.c --- quagga-0.99.9/lib/if.c 2006-12-12 14:12:06.000000000 -0800 +++ quagga-0.99.9-af/lib/if.c 2008-12-03 13:42:15.000000000 -0800 @@ -36,6 +36,8 @@ #include "str.h" #include "log.h" + + /* Master list of interfaces. */ struct list *iflist; @@ -65,7 +67,8 @@ p1 = ifp1->name; p2 = ifp2->name; - while (*p1 && *p2) { + while (*p1 && *p2) + { /* look up to any number */ l1 = strcspn(p1, "0123456789"); l2 = strcspn(p2, "0123456789"); @@ -164,7 +167,8 @@ void if_add_hook (int type, int (*func)(struct interface *ifp)) { - switch (type) { + switch (type) + { case IF_NEW_HOOK: if_master.if_new_hook = func; break; @@ -196,8 +200,7 @@ { struct interface *ifp; - return ((ifp = if_lookup_by_index(index)) != NULL) ? - ifp->name : "unknown"; + return ((ifp = if_lookup_by_index (index)) != NULL) ? ifp->name : "unknown"; } unsigned int @@ -266,6 +269,33 @@ return NULL; } +/* Lookup interface by IPv6 address. */ +struct interface * +if_lookup_exact_address_ipv6 (struct in6_addr src) +{ + struct listnode *node; + struct listnode *cnode; + struct interface *ifp; + struct prefix *p; + struct connected *c; + + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) + { + for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c)) + { + p = c->address; + + if (p && p->family == AF_INET6) + { + if (IPV6_ADDR_SAME (&p->u.prefix6, &src)) + return ifp; + } + } + } + return NULL; +} + + /* Lookup interface by IPv4 address. */ struct interface * if_lookup_address (struct in_addr src) @@ -340,7 +370,8 @@ if_is_operative (struct interface *ifp) { return ((ifp->flags & IFF_UP) && - (ifp->flags & IFF_RUNNING || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))); + (ifp->flags & IFF_RUNNING + || !CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_LINKDETECTION))); } /* Is this loopback interface ? */ @@ -431,8 +462,7 @@ #ifdef HAVE_IPV6 "mtu6 %d " #endif /* HAVE_IPV6 */ - "%s", - ifp->name, ifp->ifindex, ifp->metric, ifp->mtu, + "%s", ifp->name, ifp->ifindex, ifp->metric, ifp->mtu, #ifdef HAVE_IPV6 ifp->mtu6, #endif /* HAVE_IPV6 */ @@ -474,9 +504,7 @@ DEFUN (no_interface_desc, no_interface_desc_cmd, - "no description", - NO_STR - "Interface specific description\n") + "no description", NO_STR "Interface specific description\n") { struct interface *ifp; @@ -533,8 +561,7 @@ DEFUN (interface, interface_cmd, "interface IFNAME", - "Select an interface to configure\n" - "Interface's name\n") + "Select an interface to configure\n" "Interface's name\n") { struct interface *ifp; size_t sl; @@ -542,8 +569,7 @@ if ((sl = strlen(argv[0])) > INTERFACE_NAMSIZ) { vty_out (vty, "%% Interface name %s is invalid: length exceeds " - "%d characters%s", - argv[0], INTERFACE_NAMSIZ, VTY_NEWLINE); + "%d characters%s", argv[0], INTERFACE_NAMSIZ, VTY_NEWLINE); return CMD_WARNING; } @@ -590,11 +616,7 @@ } /* For debug purpose. */ -DEFUN (show_address, - show_address_cmd, - "show address", - SHOW_STR - "address\n") +DEFUN (show_address, show_address_cmd, "show address", SHOW_STR "address\n") { struct listnode *node; struct listnode *node2; @@ -620,7 +642,8 @@ struct connected * connected_new (void) { - struct connected *new = XMALLOC (MTYPE_CONNECTED, sizeof (struct connected)); + struct connected *new = + XMALLOC (MTYPE_CONNECTED, sizeof (struct connected)); memset (new, 0, sizeof (struct connected)); return new; } @@ -655,8 +678,7 @@ snprintf (logbuf, BUFSIZ, "%s interface %s %s %s/%d ", str, ifp->name, prefix_family_str (p), - inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), - p->prefixlen); + inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); p = connected->destination; if (p) @@ -765,8 +787,11 @@ { struct interface *ifp; - return ((ifp = if_lookup_by_name_len(name, strnlen(name, IFNAMSIZ))) != NULL) - ? ifp->ifindex : 0; + return ((ifp = + if_lookup_by_name_len (name, + strnlen (name, + IFNAMSIZ))) != + NULL) ? ifp->ifindex : 0; } #endif @@ -871,7 +896,8 @@ ifaddr_ipv4_table = route_table_init (); #endif /* ifaddr_ipv4_table */ - if (iflist) { + if (iflist) + { iflist->cmp = (int (*)(void *, void *))if_cmp_func; return; } diff -Naur quagga-0.99.9/lib/if.h quagga-0.99.9-af/lib/if.h --- quagga-0.99.9/lib/if.h 2007-05-09 13:59:34.000000000 -0700 +++ quagga-0.99.9-af/lib/if.h 2008-12-03 13:42:15.000000000 -0800 @@ -23,6 +23,10 @@ #include "linklist.h" +#ifdef __cplusplus +#define list __quagga_list +#endif /* __cplusplus */ + /* Interface name length. @@ -233,6 +237,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_exact_address_ipv6 (struct in6_addr); extern struct interface *if_lookup_address (struct in_addr); /* These 2 functions are to be used when the ifname argument is terminated @@ -245,7 +250,8 @@ In most cases, strnlen should be used to calculate the namelen value. */ extern struct interface *if_lookup_by_name_len(const char *ifname, size_t namelen); -extern struct interface *if_get_by_name_len(const char *ifname, size_t namelen); +extern struct interface *if_get_by_name_len (const char *ifname, + size_t namelen); /* Delete the interface, but do not free the structure, and leave it in the @@ -308,4 +314,8 @@ extern struct cmd_element no_interface_pseudo_cmd; extern struct cmd_element show_address_cmd; +#ifdef __cplusplus +#undef list +#endif /* __cplusplus */ + #endif /* _ZEBRA_IF_H */ diff -Naur quagga-0.99.9/lib/if_rmap.c quagga-0.99.9-af/lib/if_rmap.c --- quagga-0.99.9/lib/if_rmap.c 2005-10-25 22:05:45.000000000 -0700 +++ quagga-0.99.9-af/lib/if_rmap.c 2008-12-03 13:42:15.000000000 -0800 @@ -209,8 +209,7 @@ "Route map set\n" "Route map name\n" "Route map set for input filtering\n" - "Route map set for output filtering\n" - "Route map interface name\n") + "Route map set for output filtering\n" "Route map interface name\n") { enum if_rmap_type type; struct if_rmap *if_rmap; @@ -246,8 +245,7 @@ "Route map unset\n" "Route map name\n" "Route map for input filtering\n" - "Route map for output filtering\n" - "Route map interface name\n") + "Route map for output filtering\n" "Route map interface name\n") { int ret; enum if_rmap_type type; @@ -271,19 +269,15 @@ return CMD_SUCCESS; } -ALIAS (no_if_rmap, - no_if_ipv6_rmap_cmd, +ALIAS (no_if_rmap, no_if_ipv6_rmap_cmd, "no route-map ROUTEMAP_NAME (in|out) IFNAME", NO_STR "Route map unset\n" "Route map name\n" "Route map for input filtering\n" - "Route map for output filtering\n" - "Route map interface name\n") - + "Route map for output filtering\n" "Route map interface name\n") /* Configuration write function. */ -int -config_write_if_rmap (struct vty *vty) + int config_write_if_rmap (struct vty *vty) { unsigned int i; struct hash_backet *mp; @@ -300,8 +294,7 @@ { vty_out (vty, " route-map %s in %s%s", if_rmap->routemap[IF_RMAP_IN], - if_rmap->ifname, - VTY_NEWLINE); + if_rmap->ifname, VTY_NEWLINE); write++; } @@ -309,8 +302,7 @@ { vty_out (vty, " route-map %s out %s%s", if_rmap->routemap[IF_RMAP_OUT], - if_rmap->ifname, - VTY_NEWLINE); + if_rmap->ifname, VTY_NEWLINE); write++; } } @@ -327,10 +319,13 @@ if_rmap_init (int node) { ifrmaphash = hash_create (if_rmap_hash_make, if_rmap_hash_cmp); - if (node == RIPNG_NODE) { + if (node == RIPNG_NODE) + { install_element (RIPNG_NODE, &if_ipv6_rmap_cmd); install_element (RIPNG_NODE, &no_if_ipv6_rmap_cmd); - } else if (node == RIP_NODE) { + } + else if (node == RIP_NODE) + { install_element (RIP_NODE, &if_rmap_cmd); install_element (RIP_NODE, &no_if_rmap_cmd); } diff -Naur quagga-0.99.9/lib/jhash.h quagga-0.99.9-af/lib/jhash.h --- quagga-0.99.9/lib/jhash.h 2005-05-03 12:06:44.000000000 -0700 +++ quagga-0.99.9-af/lib/jhash.h 2008-12-03 13:42:15.000000000 -0800 @@ -37,7 +37,8 @@ * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally * done at the end is not done here. */ -extern u_int32_t jhash_3words(u_int32_t a, u_int32_t b, u_int32_t c, u_int32_t initval); +extern u_int32_t jhash_3words (u_int32_t a, u_int32_t b, u_int32_t c, + u_int32_t initval); extern u_int32_t jhash_2words(u_int32_t a, u_int32_t b, u_int32_t initval); extern u_int32_t jhash_1word(u_int32_t a, u_int32_t initval); diff -Naur quagga-0.99.9/lib/keychain.c quagga-0.99.9-af/lib/keychain.c --- quagga-0.99.9/lib/keychain.c 2005-05-03 11:13:23.000000000 -0700 +++ quagga-0.99.9-af/lib/keychain.c 2008-12-03 13:42:15.000000000 -0800 @@ -237,8 +237,7 @@ key_chain_cmd, "key chain WORD", "Authentication key management\n" - "Key-chain management\n" - "Key-chain name\n") + "Key-chain management\n" "Key-chain name\n") { struct keychain *keychain; @@ -254,8 +253,7 @@ "no key chain WORD", NO_STR "Authentication key management\n" - "Key-chain management\n" - "Key-chain name\n") + "Key-chain management\n" "Key-chain name\n") { struct keychain *keychain; @@ -274,9 +272,7 @@ DEFUN (key, key_cmd, - "key <0-2147483647>", - "Configure a key\n" - "Key identifier number\n") + "key <0-2147483647>", "Configure a key\n" "Key identifier number\n") { struct keychain *keychain; struct key *key; @@ -295,9 +291,7 @@ DEFUN (no_key, no_key_cmd, "no key <0-2147483647>", - NO_STR - "Delete a key\n" - "Key identifier number\n") + NO_STR "Delete a key\n" "Key identifier number\n") { struct keychain *keychain; struct key *key; @@ -321,10 +315,7 @@ } DEFUN (key_string, - key_string_cmd, - "key-string LINE", - "Set key string\n" - "The key\n") + key_string_cmd, "key-string LINE", "Set key string\n" "The key\n") { struct key *key; @@ -339,10 +330,7 @@ DEFUN (no_key_string, no_key_string_cmd, - "no key-string [LINE]", - NO_STR - "Unset key string\n" - "The key\n") + "no key-string [LINE]", NO_STR "Unset key string\n" "The key\n") { struct key *key; @@ -360,8 +348,8 @@ /* Convert HH:MM:SS MON DAY YEAR to time_t value. -1 is returned when given string is malformed. */ static time_t -key_str2time (const char *time_str, const char *day_str, const char *month_str, - const char *year_str) +key_str2time (const char *time_str, const char *day_str, + const char *month_str, const char *year_str) { int i = 0; char *colon; @@ -370,8 +358,7 @@ unsigned int sec, min, hour; unsigned int day, month, year; - const char *month_name[] = - { + const char *month_name[] = { "January", "February", "March", @@ -484,7 +471,8 @@ if (time_end <= time_start) { - vty_out (vty, "Expire time is not later than start time%s", VTY_NEWLINE); + vty_out (vty, "Expire time is not later than start time%s", + VTY_NEWLINE); return CMD_WARNING; } @@ -548,8 +536,7 @@ "Year to start\n" "Time to expire\n" "Day of th month to expire\n" - "Month of the year to expire\n" - "Year to expire\n") + "Month of the year to expire\n" "Year to expire\n") { struct key *key; @@ -569,8 +556,7 @@ "Year to start\n" "Time to expire\n" "Month of the year to expire\n" - "Day of th month to expire\n" - "Year to expire\n") + "Day of th month to expire\n" "Year to expire\n") { struct key *key; @@ -590,8 +576,7 @@ "Year to start\n" "Time to expire\n" "Day of th month to expire\n" - "Month of the year to expire\n" - "Year to expire\n") + "Month of the year to expire\n" "Year to expire\n") { struct key *key; @@ -611,8 +596,7 @@ "Year to start\n" "Time to expire\n" "Month of the year to expire\n" - "Day of th month to expire\n" - "Year to expire\n") + "Day of th month to expire\n" "Year to expire\n") { struct key *key; @@ -628,9 +612,7 @@ "Set accept lifetime of the key\n" "Time to start\n" "Day of th month to start\n" - "Month of the year to start\n" - "Year to start\n" - "Never expires") + "Month of the year to start\n" "Year to start\n" "Never expires") { struct key *key; @@ -646,9 +628,7 @@ "Set accept lifetime of the key\n" "Time to start\n" "Month of the year to start\n" - "Day of th month to start\n" - "Year to start\n" - "Never expires") + "Day of th month to start\n" "Year to start\n" "Never expires") { struct key *key; @@ -665,9 +645,7 @@ "Time to start\n" "Day of th month to start\n" "Month of the year to start\n" - "Year to start\n" - "Duration of the key\n" - "Duration seconds\n") + "Year to start\n" "Duration of the key\n" "Duration seconds\n") { struct key *key; @@ -684,9 +662,7 @@ "Time to start\n" "Month of the year to start\n" "Day of th month to start\n" - "Year to start\n" - "Duration of the key\n" - "Duration seconds\n") + "Year to start\n" "Duration of the key\n" "Duration seconds\n") { struct key *key; @@ -706,15 +682,14 @@ "Year to start\n" "Time to expire\n" "Day of th month to expire\n" - "Month of the year to expire\n" - "Year to expire\n") + "Month of the year to expire\n" "Year to expire\n") { struct key *key; key = vty->index_sub; - return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], argv[3], - argv[4], argv[5], argv[6], argv[7]); + return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], + argv[3], argv[4], argv[5], argv[6], argv[7]); } DEFUN (send_lifetime_day_month_month_day, @@ -727,15 +702,14 @@ "Year to start\n" "Time to expire\n" "Month of the year to expire\n" - "Day of th month to expire\n" - "Year to expire\n") + "Day of th month to expire\n" "Year to expire\n") { struct key *key; key = vty->index_sub; - return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], argv[3], - argv[4], argv[6], argv[5], argv[7]); + return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], + argv[3], argv[4], argv[6], argv[5], argv[7]); } DEFUN (send_lifetime_month_day_day_month, @@ -748,15 +722,14 @@ "Year to start\n" "Time to expire\n" "Day of th month to expire\n" - "Month of the year to expire\n" - "Year to expire\n") + "Month of the year to expire\n" "Year to expire\n") { struct key *key; key = vty->index_sub; - return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], argv[3], - argv[4], argv[5], argv[6], argv[7]); + return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], + argv[3], argv[4], argv[5], argv[6], argv[7]); } DEFUN (send_lifetime_month_day_month_day, @@ -769,15 +742,14 @@ "Year to start\n" "Time to expire\n" "Month of the year to expire\n" - "Day of th month to expire\n" - "Year to expire\n") + "Day of th month to expire\n" "Year to expire\n") { struct key *key; key = vty->index_sub; - return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], argv[3], - argv[4], argv[6], argv[5], argv[7]); + return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], + argv[3], argv[4], argv[6], argv[5], argv[7]); } DEFUN (send_lifetime_infinite_day_month, @@ -786,16 +758,14 @@ "Set send lifetime of the key\n" "Time to start\n" "Day of th month to start\n" - "Month of the year to start\n" - "Year to start\n" - "Never expires") + "Month of the year to start\n" "Year to start\n" "Never expires") { struct key *key; key = vty->index_sub; - return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[1], argv[2], - argv[3]); + return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[1], + argv[2], argv[3]); } DEFUN (send_lifetime_infinite_month_day, @@ -804,16 +774,14 @@ "Set send lifetime of the key\n" "Time to start\n" "Month of the year to start\n" - "Day of th month to start\n" - "Year to start\n" - "Never expires") + "Day of th month to start\n" "Year to start\n" "Never expires") { struct key *key; key = vty->index_sub; - return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[2], argv[1], - argv[3]); + return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[2], + argv[1], argv[3]); } DEFUN (send_lifetime_duration_day_month, @@ -823,16 +791,14 @@ "Time to start\n" "Day of th month to start\n" "Month of the year to start\n" - "Year to start\n" - "Duration of the key\n" - "Duration seconds\n") + "Year to start\n" "Duration of the key\n" "Duration seconds\n") { struct key *key; key = vty->index_sub; - return key_lifetime_duration_set (vty, &key->send, argv[0], argv[1], argv[2], - argv[3], argv[4]); + return key_lifetime_duration_set (vty, &key->send, argv[0], argv[1], + argv[2], argv[3], argv[4]); } DEFUN (send_lifetime_duration_month_day, @@ -842,27 +808,23 @@ "Time to start\n" "Month of the year to start\n" "Day of th month to start\n" - "Year to start\n" - "Duration of the key\n" - "Duration seconds\n") + "Year to start\n" "Duration of the key\n" "Duration seconds\n") { struct key *key; key = vty->index_sub; - return key_lifetime_duration_set (vty, &key->send, argv[0], argv[2], argv[1], - argv[3], argv[4]); + return key_lifetime_duration_set (vty, &key->send, argv[0], argv[2], + argv[1], argv[3], argv[4]); } -struct cmd_node keychain_node = -{ +struct cmd_node keychain_node = { KEYCHAIN_NODE, "%s(config-keychain)# ", 1 }; -struct cmd_node keychain_key_node = -{ +struct cmd_node keychain_key_node = { KEYCHAIN_KEY_NODE, "%s(config-keychain-key)# ", 1 @@ -927,7 +889,8 @@ if (key->send.end == -1) vty_out (vty, " infinite"); else if (key->send.duration) - vty_out (vty, " duration %ld", (long)(key->send.end - key->send.start)); + vty_out (vty, " duration %ld", + (long) (key->send.end - key->send.start)); else { keychain_strftime (buf, BUFSIZ, &key->send.end); @@ -970,14 +933,22 @@ install_element (KEYCHAIN_KEY_NODE, &key_cmd); install_element (KEYCHAIN_KEY_NODE, &no_key_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_day_month_day_month_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_day_month_month_day_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_month_day_day_month_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_month_day_month_day_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_infinite_day_month_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_infinite_month_day_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_duration_day_month_cmd); - install_element (KEYCHAIN_KEY_NODE, &accept_lifetime_duration_month_day_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_day_month_day_month_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_day_month_month_day_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_month_day_day_month_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_month_day_month_day_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_infinite_day_month_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_infinite_month_day_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_duration_day_month_cmd); + install_element (KEYCHAIN_KEY_NODE, + &accept_lifetime_duration_month_day_cmd); install_element (KEYCHAIN_KEY_NODE, &send_lifetime_day_month_day_month_cmd); install_element (KEYCHAIN_KEY_NODE, &send_lifetime_day_month_month_day_cmd); diff -Naur quagga-0.99.9/lib/keychain.h quagga-0.99.9-af/lib/keychain.h --- quagga-0.99.9/lib/keychain.h 2005-05-03 10:51:36.000000000 -0700 +++ quagga-0.99.9-af/lib/keychain.h 2008-12-03 13:42:15.000000000 -0800 @@ -50,7 +50,8 @@ extern void keychain_init (void); extern struct keychain *keychain_lookup (const char *); extern struct key *key_lookup_for_accept (const struct keychain *, u_int32_t); -extern struct key *key_match_for_accept (const struct keychain *, const char *); +extern struct key *key_match_for_accept (const struct keychain *, + const char *); extern struct key *key_lookup_for_send (const struct keychain *); #endif /* _ZEBRA_KEYCHAIN_H */ diff -Naur quagga-0.99.9/lib/linklist.h quagga-0.99.9-af/lib/linklist.h --- quagga-0.99.9/lib/linklist.h 2005-05-03 12:07:24.000000000 -0700 +++ quagga-0.99.9-af/lib/linklist.h 2008-12-03 13:42:15.000000000 -0800 @@ -22,6 +22,10 @@ #ifndef _ZEBRA_LINKLIST_H #define _ZEBRA_LINKLIST_H +#ifdef __cplusplus +#define list __quagga_list +#endif /* __cplusplus */ + /* listnodes must always contain data to be valid. Adding an empty node * to a list is invalid */ @@ -100,9 +104,9 @@ * of previous macro. */ #define ALL_LIST_ELEMENTS_RO(list,node,data) \ - (node) = listhead(list); \ - (node) != NULL && ((data) = listgetdata(node), 1); \ - (node) = listnextnode(node) + (node) = (typeof(node))listhead(list); \ + (node) != NULL && ((data) = (typeof(data))listgetdata(node), 1); \ + (node) = (typeof(node))listnextnode(node) /* these *do not* cleanup list nodes and referenced data, as the functions * do - these macros simply {de,at}tach a listnode from/to a list. @@ -145,4 +149,8 @@ for (ALL_LIST_ELEMENTS_RO (L,N,V)) #endif /* QUAGGA_NO_DEPRECATED_INTERFACES */ +#ifdef __cplusplus +#undef list +#endif /* __cplusplus */ + #endif /* _ZEBRA_LINKLIST_H */ diff -Naur quagga-0.99.9/lib/log.c quagga-0.99.9-af/lib/log.c --- quagga-0.99.9/lib/log.c 2007-08-06 08:21:45.000000000 -0700 +++ quagga-0.99.9-af/lib/log.c 2008-12-03 13:42:15.000000000 -0800 @@ -803,7 +803,7 @@ DESC_ENTRY (ZEBRA_ROUTE_RIP, "rip", 'R' ), DESC_ENTRY (ZEBRA_ROUTE_RIPNG, "ripng", 'R' ), DESC_ENTRY (ZEBRA_ROUTE_OSPF, "ospf", 'O' ), - DESC_ENTRY (ZEBRA_ROUTE_OSPF6, "ospf6", 'O' ), + DESC_ENTRY (ZEBRA_ROUTE_OSPF6, "ospf6", 'o' ), DESC_ENTRY (ZEBRA_ROUTE_ISIS, "isis", 'I' ), DESC_ENTRY (ZEBRA_ROUTE_BGP, "bgp", 'B' ), DESC_ENTRY (ZEBRA_ROUTE_HSLS, "hsls", 'H' ), diff -Naur quagga-0.99.9/lib/log.h quagga-0.99.9-af/lib/log.h --- quagga-0.99.9/lib/log.h 2007-04-29 05:40:40.000000000 -0700 +++ quagga-0.99.9-af/lib/log.h 2008-12-03 13:42:15.000000000 -0800 @@ -111,13 +111,16 @@ #endif /* __GNUC__ */ /* Generic function for zlog. */ -extern void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); +extern void +zlog (struct zlog *zl, int priority, const char *format, ...) +PRINTF_ATTRIBUTE (3, 4); /* Handy zlog functions. */ extern void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); + extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE (1, + 2); extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); /* For bgpd's peer oriented log. */ @@ -134,7 +137,8 @@ extern void zlog_set_level (struct zlog *zl, zlog_dest_t, int log_level); /* Set logging to the given filename at the specified level. */ -extern int zlog_set_file (struct zlog *zl, const char *filename, int log_level); + extern int zlog_set_file (struct zlog *zl, const char *filename, + int log_level); /* Disable file logging. */ extern int zlog_reset_file (struct zlog *zl); @@ -145,7 +149,8 @@ #define LOOKUP(x, y) mes_lookup(x, x ## _max, y) extern const char *lookup (struct message *, int); -extern const char *mes_lookup (struct message *meslist, int max, int index); + extern const char *mes_lookup (struct message *meslist, int max, + int index); extern const char *zlog_priority[]; extern const char *zlog_proto_names[]; @@ -175,11 +180,13 @@ It caches the most recent localtime result and can therefore avoid multiple calls within the same second. If buflen is too small, *buf will be set to '\0', and 0 will be returned. */ -extern size_t quagga_timestamp(int timestamp_precision /* # subsecond digits */, + extern size_t quagga_timestamp (int timestamp_precision + /* # subsecond digits */ , char *buf, size_t buflen); /* structure useful for avoiding repeated rendering of the same timestamp */ -struct timestamp_control { + struct timestamp_control + { size_t len; /* length of rendered timestamp */ int precision; /* configuration parameter */ int already_rendered; /* should be initialized to 0 */ diff -Naur quagga-0.99.9/lib/md5.c quagga-0.99.9-af/lib/md5.c --- quagga-0.99.9/lib/md5.c 2006-01-31 12:55:52.000000000 -0800 +++ quagga-0.99.9-af/lib/md5.c 2008-12-03 13:42:15.000000000 -0800 @@ -135,7 +135,8 @@ static void md5_calc (const uint8_t *, md5_ctxt *); -void md5_init(md5_ctxt *ctxt) +void +md5_init (md5_ctxt * ctxt) { ctxt->md5_n = 0; ctxt->md5_i = 0; @@ -146,7 +147,8 @@ memset (ctxt->md5_buf, 0, sizeof(ctxt->md5_buf)); } -void md5_loop(md5_ctxt *ctxt, const void *vinput, uint len) +void +md5_loop (md5_ctxt * ctxt, const void *vinput, uint len) { uint gap, i; const uint8_t *input = vinput; @@ -154,32 +156,40 @@ ctxt->md5_n += len * 8; /* byte to bit */ gap = MD5_BUFLEN - ctxt->md5_i; - if (len >= gap) { + if (len >= gap) + { memcpy (ctxt->md5_buf + ctxt->md5_i, input, gap); md5_calc(ctxt->md5_buf, ctxt); - for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) { + for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) + { md5_calc((input + i), ctxt); } ctxt->md5_i = len - i; memcpy (ctxt->md5_buf, (input + i), ctxt->md5_i); - } else { + } + else + { memcpy (ctxt->md5_buf + ctxt->md5_i, input, len); ctxt->md5_i += len; } } -void md5_pad(md5_ctxt *ctxt) +void +md5_pad (md5_ctxt * ctxt) { uint gap; /* Don't count up padding. Keep md5_n. */ gap = MD5_BUFLEN - ctxt->md5_i; - if (gap > 8) { + if (gap > 8) + { memcpy (ctxt->md5_buf + ctxt->md5_i, md5_paddat, gap - sizeof(ctxt->md5_n)); - } else { + } + else + { /* including gap == 8 */ memcpy (ctxt->md5_buf + ctxt->md5_i, md5_paddat, gap); md5_calc (ctxt->md5_buf, ctxt); @@ -204,25 +214,35 @@ md5_calc(ctxt->md5_buf, ctxt); } -void md5_result(uint8_t *digest, md5_ctxt *ctxt) +void +md5_result (uint8_t * digest, md5_ctxt * ctxt) { /* 4 byte words */ if (BYTE_ORDER == LITTLE_ENDIAN) memcpy (digest, &ctxt->md5_st8[0], 16); else if (BYTE_ORDER == BIG_ENDIAN) { - digest[ 0] = ctxt->md5_st8[ 3]; digest[ 1] = ctxt->md5_st8[ 2]; - digest[ 2] = ctxt->md5_st8[ 1]; digest[ 3] = ctxt->md5_st8[ 0]; - digest[ 4] = ctxt->md5_st8[ 7]; digest[ 5] = ctxt->md5_st8[ 6]; - digest[ 6] = ctxt->md5_st8[ 5]; digest[ 7] = ctxt->md5_st8[ 4]; - digest[ 8] = ctxt->md5_st8[11]; digest[ 9] = ctxt->md5_st8[10]; - digest[10] = ctxt->md5_st8[ 9]; digest[11] = ctxt->md5_st8[ 8]; - digest[12] = ctxt->md5_st8[15]; digest[13] = ctxt->md5_st8[14]; - digest[14] = ctxt->md5_st8[13]; digest[15] = ctxt->md5_st8[12]; + digest[0] = ctxt->md5_st8[3]; + digest[1] = ctxt->md5_st8[2]; + digest[2] = ctxt->md5_st8[1]; + digest[3] = ctxt->md5_st8[0]; + digest[4] = ctxt->md5_st8[7]; + digest[5] = ctxt->md5_st8[6]; + digest[6] = ctxt->md5_st8[5]; + digest[7] = ctxt->md5_st8[4]; + digest[8] = ctxt->md5_st8[11]; + digest[9] = ctxt->md5_st8[10]; + digest[10] = ctxt->md5_st8[9]; + digest[11] = ctxt->md5_st8[8]; + digest[12] = ctxt->md5_st8[15]; + digest[13] = ctxt->md5_st8[14]; + digest[14] = ctxt->md5_st8[13]; + digest[15] = ctxt->md5_st8[12]; } } -static void md5_calc(const uint8_t *b64, md5_ctxt * ctxt) +static void +md5_calc (const uint8_t * b64, md5_ctxt * ctxt) { uint32_t A = ctxt->md5_sta; uint32_t B = ctxt->md5_stb; @@ -238,59 +258,139 @@ /* 4 byte words */ /* what a brute force but fast! */ uint8_t *y = (uint8_t *)X; - y[ 0] = b64[ 3]; y[ 1] = b64[ 2]; y[ 2] = b64[ 1]; y[ 3] = b64[ 0]; - y[ 4] = b64[ 7]; y[ 5] = b64[ 6]; y[ 6] = b64[ 5]; y[ 7] = b64[ 4]; - y[ 8] = b64[11]; y[ 9] = b64[10]; y[10] = b64[ 9]; y[11] = b64[ 8]; - y[12] = b64[15]; y[13] = b64[14]; y[14] = b64[13]; y[15] = b64[12]; - y[16] = b64[19]; y[17] = b64[18]; y[18] = b64[17]; y[19] = b64[16]; - y[20] = b64[23]; y[21] = b64[22]; y[22] = b64[21]; y[23] = b64[20]; - y[24] = b64[27]; y[25] = b64[26]; y[26] = b64[25]; y[27] = b64[24]; - y[28] = b64[31]; y[29] = b64[30]; y[30] = b64[29]; y[31] = b64[28]; - y[32] = b64[35]; y[33] = b64[34]; y[34] = b64[33]; y[35] = b64[32]; - y[36] = b64[39]; y[37] = b64[38]; y[38] = b64[37]; y[39] = b64[36]; - y[40] = b64[43]; y[41] = b64[42]; y[42] = b64[41]; y[43] = b64[40]; - y[44] = b64[47]; y[45] = b64[46]; y[46] = b64[45]; y[47] = b64[44]; - y[48] = b64[51]; y[49] = b64[50]; y[50] = b64[49]; y[51] = b64[48]; - y[52] = b64[55]; y[53] = b64[54]; y[54] = b64[53]; y[55] = b64[52]; - y[56] = b64[59]; y[57] = b64[58]; y[58] = b64[57]; y[59] = b64[56]; - y[60] = b64[63]; y[61] = b64[62]; y[62] = b64[61]; y[63] = b64[60]; - } - - ROUND1(A, B, C, D, 0, Sa, 1); ROUND1(D, A, B, C, 1, Sb, 2); - ROUND1(C, D, A, B, 2, Sc, 3); ROUND1(B, C, D, A, 3, Sd, 4); - ROUND1(A, B, C, D, 4, Sa, 5); ROUND1(D, A, B, C, 5, Sb, 6); - ROUND1(C, D, A, B, 6, Sc, 7); ROUND1(B, C, D, A, 7, Sd, 8); - ROUND1(A, B, C, D, 8, Sa, 9); ROUND1(D, A, B, C, 9, Sb, 10); - ROUND1(C, D, A, B, 10, Sc, 11); ROUND1(B, C, D, A, 11, Sd, 12); - ROUND1(A, B, C, D, 12, Sa, 13); ROUND1(D, A, B, C, 13, Sb, 14); - ROUND1(C, D, A, B, 14, Sc, 15); ROUND1(B, C, D, A, 15, Sd, 16); - - ROUND2(A, B, C, D, 1, Se, 17); ROUND2(D, A, B, C, 6, Sf, 18); - ROUND2(C, D, A, B, 11, Sg, 19); ROUND2(B, C, D, A, 0, Sh, 20); - ROUND2(A, B, C, D, 5, Se, 21); ROUND2(D, A, B, C, 10, Sf, 22); - ROUND2(C, D, A, B, 15, Sg, 23); ROUND2(B, C, D, A, 4, Sh, 24); - ROUND2(A, B, C, D, 9, Se, 25); ROUND2(D, A, B, C, 14, Sf, 26); - ROUND2(C, D, A, B, 3, Sg, 27); ROUND2(B, C, D, A, 8, Sh, 28); - ROUND2(A, B, C, D, 13, Se, 29); ROUND2(D, A, B, C, 2, Sf, 30); - ROUND2(C, D, A, B, 7, Sg, 31); ROUND2(B, C, D, A, 12, Sh, 32); - - ROUND3(A, B, C, D, 5, Si, 33); ROUND3(D, A, B, C, 8, Sj, 34); - ROUND3(C, D, A, B, 11, Sk, 35); ROUND3(B, C, D, A, 14, Sl, 36); - ROUND3(A, B, C, D, 1, Si, 37); ROUND3(D, A, B, C, 4, Sj, 38); - ROUND3(C, D, A, B, 7, Sk, 39); ROUND3(B, C, D, A, 10, Sl, 40); - ROUND3(A, B, C, D, 13, Si, 41); ROUND3(D, A, B, C, 0, Sj, 42); - ROUND3(C, D, A, B, 3, Sk, 43); ROUND3(B, C, D, A, 6, Sl, 44); - ROUND3(A, B, C, D, 9, Si, 45); ROUND3(D, A, B, C, 12, Sj, 46); - ROUND3(C, D, A, B, 15, Sk, 47); ROUND3(B, C, D, A, 2, Sl, 48); - - ROUND4(A, B, C, D, 0, Sm, 49); ROUND4(D, A, B, C, 7, Sn, 50); - ROUND4(C, D, A, B, 14, So, 51); ROUND4(B, C, D, A, 5, Sp, 52); - ROUND4(A, B, C, D, 12, Sm, 53); ROUND4(D, A, B, C, 3, Sn, 54); - ROUND4(C, D, A, B, 10, So, 55); ROUND4(B, C, D, A, 1, Sp, 56); - ROUND4(A, B, C, D, 8, Sm, 57); ROUND4(D, A, B, C, 15, Sn, 58); - ROUND4(C, D, A, B, 6, So, 59); ROUND4(B, C, D, A, 13, Sp, 60); - ROUND4(A, B, C, D, 4, Sm, 61); ROUND4(D, A, B, C, 11, Sn, 62); - ROUND4(C, D, A, B, 2, So, 63); ROUND4(B, C, D, A, 9, Sp, 64); + y[0] = b64[3]; + y[1] = b64[2]; + y[2] = b64[1]; + y[3] = b64[0]; + y[4] = b64[7]; + y[5] = b64[6]; + y[6] = b64[5]; + y[7] = b64[4]; + y[8] = b64[11]; + y[9] = b64[10]; + y[10] = b64[9]; + y[11] = b64[8]; + y[12] = b64[15]; + y[13] = b64[14]; + y[14] = b64[13]; + y[15] = b64[12]; + y[16] = b64[19]; + y[17] = b64[18]; + y[18] = b64[17]; + y[19] = b64[16]; + y[20] = b64[23]; + y[21] = b64[22]; + y[22] = b64[21]; + y[23] = b64[20]; + y[24] = b64[27]; + y[25] = b64[26]; + y[26] = b64[25]; + y[27] = b64[24]; + y[28] = b64[31]; + y[29] = b64[30]; + y[30] = b64[29]; + y[31] = b64[28]; + y[32] = b64[35]; + y[33] = b64[34]; + y[34] = b64[33]; + y[35] = b64[32]; + y[36] = b64[39]; + y[37] = b64[38]; + y[38] = b64[37]; + y[39] = b64[36]; + y[40] = b64[43]; + y[41] = b64[42]; + y[42] = b64[41]; + y[43] = b64[40]; + y[44] = b64[47]; + y[45] = b64[46]; + y[46] = b64[45]; + y[47] = b64[44]; + y[48] = b64[51]; + y[49] = b64[50]; + y[50] = b64[49]; + y[51] = b64[48]; + y[52] = b64[55]; + y[53] = b64[54]; + y[54] = b64[53]; + y[55] = b64[52]; + y[56] = b64[59]; + y[57] = b64[58]; + y[58] = b64[57]; + y[59] = b64[56]; + y[60] = b64[63]; + y[61] = b64[62]; + y[62] = b64[61]; + y[63] = b64[60]; + } + + ROUND1 (A, B, C, D, 0, Sa, 1); + ROUND1 (D, A, B, C, 1, Sb, 2); + ROUND1 (C, D, A, B, 2, Sc, 3); + ROUND1 (B, C, D, A, 3, Sd, 4); + ROUND1 (A, B, C, D, 4, Sa, 5); + ROUND1 (D, A, B, C, 5, Sb, 6); + ROUND1 (C, D, A, B, 6, Sc, 7); + ROUND1 (B, C, D, A, 7, Sd, 8); + ROUND1 (A, B, C, D, 8, Sa, 9); + ROUND1 (D, A, B, C, 9, Sb, 10); + ROUND1 (C, D, A, B, 10, Sc, 11); + ROUND1 (B, C, D, A, 11, Sd, 12); + ROUND1 (A, B, C, D, 12, Sa, 13); + ROUND1 (D, A, B, C, 13, Sb, 14); + ROUND1 (C, D, A, B, 14, Sc, 15); + ROUND1 (B, C, D, A, 15, Sd, 16); + + ROUND2 (A, B, C, D, 1, Se, 17); + ROUND2 (D, A, B, C, 6, Sf, 18); + ROUND2 (C, D, A, B, 11, Sg, 19); + ROUND2 (B, C, D, A, 0, Sh, 20); + ROUND2 (A, B, C, D, 5, Se, 21); + ROUND2 (D, A, B, C, 10, Sf, 22); + ROUND2 (C, D, A, B, 15, Sg, 23); + ROUND2 (B, C, D, A, 4, Sh, 24); + ROUND2 (A, B, C, D, 9, Se, 25); + ROUND2 (D, A, B, C, 14, Sf, 26); + ROUND2 (C, D, A, B, 3, Sg, 27); + ROUND2 (B, C, D, A, 8, Sh, 28); + ROUND2 (A, B, C, D, 13, Se, 29); + ROUND2 (D, A, B, C, 2, Sf, 30); + ROUND2 (C, D, A, B, 7, Sg, 31); + ROUND2 (B, C, D, A, 12, Sh, 32); + + ROUND3 (A, B, C, D, 5, Si, 33); + ROUND3 (D, A, B, C, 8, Sj, 34); + ROUND3 (C, D, A, B, 11, Sk, 35); + ROUND3 (B, C, D, A, 14, Sl, 36); + ROUND3 (A, B, C, D, 1, Si, 37); + ROUND3 (D, A, B, C, 4, Sj, 38); + ROUND3 (C, D, A, B, 7, Sk, 39); + ROUND3 (B, C, D, A, 10, Sl, 40); + ROUND3 (A, B, C, D, 13, Si, 41); + ROUND3 (D, A, B, C, 0, Sj, 42); + ROUND3 (C, D, A, B, 3, Sk, 43); + ROUND3 (B, C, D, A, 6, Sl, 44); + ROUND3 (A, B, C, D, 9, Si, 45); + ROUND3 (D, A, B, C, 12, Sj, 46); + ROUND3 (C, D, A, B, 15, Sk, 47); + ROUND3 (B, C, D, A, 2, Sl, 48); + + ROUND4 (A, B, C, D, 0, Sm, 49); + ROUND4 (D, A, B, C, 7, Sn, 50); + ROUND4 (C, D, A, B, 14, So, 51); + ROUND4 (B, C, D, A, 5, Sp, 52); + ROUND4 (A, B, C, D, 12, Sm, 53); + ROUND4 (D, A, B, C, 3, Sn, 54); + ROUND4 (C, D, A, B, 10, So, 55); + ROUND4 (B, C, D, A, 1, Sp, 56); + ROUND4 (A, B, C, D, 8, Sm, 57); + ROUND4 (D, A, B, C, 15, Sn, 58); + ROUND4 (C, D, A, B, 6, So, 59); + ROUND4 (B, C, D, A, 13, Sp, 60); + ROUND4 (A, B, C, D, 4, Sm, 61); + ROUND4 (D, A, B, C, 11, Sn, 62); + ROUND4 (C, D, A, B, 2, So, 63); + ROUND4 (B, C, D, A, 9, Sp, 64); ctxt->md5_sta += A; ctxt->md5_stb += B; diff -Naur quagga-0.99.9/lib/md5.h quagga-0.99.9-af/lib/md5.h --- quagga-0.99.9/lib/md5.h 2006-01-31 12:55:52.000000000 -0800 +++ quagga-0.99.9-af/lib/md5.h 2008-12-03 13:42:15.000000000 -0800 @@ -44,8 +44,10 @@ #define MD5_BUFLEN 64 -typedef struct { - union { +typedef struct +{ + union + { uint32_t md5_state32[4]; uint8_t md5_state8[16]; } md5_st; @@ -56,7 +58,8 @@ #define md5_std md5_st.md5_state32[3] #define md5_st8 md5_st.md5_state8 - union { + union + { uint64_t md5_count64; uint8_t md5_count8[8]; } md5_count; diff -Naur quagga-0.99.9/lib/memory.c quagga-0.99.9-af/lib/memory.c --- quagga-0.99.9/lib/memory.c 2007-03-20 11:23:00.000000000 -0700 +++ quagga-0.99.9-af/lib/memory.c 2008-12-03 13:42:15.000000000 -0800 @@ -33,8 +33,7 @@ static void alloc_dec (int); static void log_memstats(int log_priority); -static struct message mstr [] = -{ +static struct message mstr[] = { { MTYPE_THREAD, "thread" }, { MTYPE_THREAD_MASTER, "thread_master" }, { MTYPE_VECTOR, "vector" }, @@ -140,7 +139,8 @@ static void mtype_log (char *func, void *memory, const char *file, int line, int type) { - zlog_debug ("%s: %s %p %s %d", func, lookup (mstr, type), memory, file, line); + zlog_debug ("%s: %s %p %s %d", func, lookup (mstr, type), memory, file, + line); } void * @@ -249,7 +249,8 @@ zlog (NULL, pri, "Memory utilization in module %s:", ml->name); for (m = ml->list; m->index >= 0; m++) if (m->index && mstat[m->index].alloc) - zlog (NULL, pri, " %-30s: %10ld", m->format, mstat[m->index].alloc); + zlog (NULL, pri, " %-30s: %10ld", m->format, + mstat[m->index].alloc); } } @@ -291,32 +292,23 @@ vty_out (vty, "System allocator statistics:%s", VTY_NEWLINE); vty_out (vty, " Total heap allocated: %s%s", - mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.arena), - VTY_NEWLINE); + mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.arena), VTY_NEWLINE); vty_out (vty, " Holding block headers: %s%s", - mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.hblkhd), - VTY_NEWLINE); + mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.hblkhd), VTY_NEWLINE); vty_out (vty, " Used small blocks: %s%s", - mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.usmblks), - VTY_NEWLINE); + mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.usmblks), VTY_NEWLINE); vty_out (vty, " Used ordinary blocks: %s%s", - mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.uordblks), - VTY_NEWLINE); + mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.uordblks), VTY_NEWLINE); vty_out (vty, " Free small blocks: %s%s", - mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fsmblks), - VTY_NEWLINE); + mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fsmblks), VTY_NEWLINE); vty_out (vty, " Free ordinary blocks: %s%s", - mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fordblks), - VTY_NEWLINE); + mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fordblks), VTY_NEWLINE); vty_out (vty, " Ordinary blocks: %ld%s", - (unsigned long)minfo.ordblks, - VTY_NEWLINE); + (unsigned long) minfo.ordblks, VTY_NEWLINE); vty_out (vty, " Small blocks: %ld%s", - (unsigned long)minfo.smblks, - VTY_NEWLINE); + (unsigned long) minfo.smblks, VTY_NEWLINE); vty_out (vty, " Holding blocks: %ld%s", - (unsigned long)minfo.hblks, - VTY_NEWLINE); + (unsigned long) minfo.hblks, VTY_NEWLINE); vty_out (vty, "(see system documentation for 'mallinfo' for meaning)%s", VTY_NEWLINE); return 1; @@ -327,8 +319,7 @@ show_memory_all_cmd, "show memory all", "Show running system information\n" - "Memory statistics\n" - "All memory statistics\n") + "Memory statistics\n" "All memory statistics\n") { struct mlist *ml; int needsep = 0; @@ -352,13 +343,9 @@ "show memory", "Show running system information\n" "Memory statistics\n") - DEFUN (show_memory_lib, show_memory_lib_cmd, - "show memory lib", - SHOW_STR - "Memory statistics\n" - "Library memory\n") + "show memory lib", SHOW_STR "Memory statistics\n" "Library memory\n") { show_memory_vty (vty, memory_list_lib); return CMD_SUCCESS; @@ -366,10 +353,7 @@ DEFUN (show_memory_zebra, show_memory_zebra_cmd, - "show memory zebra", - SHOW_STR - "Memory statistics\n" - "Zebra memory\n") + "show memory zebra", SHOW_STR "Memory statistics\n" "Zebra memory\n") { show_memory_vty (vty, memory_list_zebra); return CMD_SUCCESS; @@ -377,10 +361,7 @@ DEFUN (show_memory_rip, show_memory_rip_cmd, - "show memory rip", - SHOW_STR - "Memory statistics\n" - "RIP memory\n") + "show memory rip", SHOW_STR "Memory statistics\n" "RIP memory\n") { show_memory_vty (vty, memory_list_rip); return CMD_SUCCESS; @@ -388,10 +369,7 @@ DEFUN (show_memory_ripng, show_memory_ripng_cmd, - "show memory ripng", - SHOW_STR - "Memory statistics\n" - "RIPng memory\n") + "show memory ripng", SHOW_STR "Memory statistics\n" "RIPng memory\n") { show_memory_vty (vty, memory_list_ripng); return CMD_SUCCESS; @@ -399,10 +377,7 @@ DEFUN (show_memory_bgp, show_memory_bgp_cmd, - "show memory bgp", - SHOW_STR - "Memory statistics\n" - "BGP memory\n") + "show memory bgp", SHOW_STR "Memory statistics\n" "BGP memory\n") { show_memory_vty (vty, memory_list_bgp); return CMD_SUCCESS; @@ -410,10 +385,7 @@ DEFUN (show_memory_ospf, show_memory_ospf_cmd, - "show memory ospf", - SHOW_STR - "Memory statistics\n" - "OSPF memory\n") + "show memory ospf", SHOW_STR "Memory statistics\n" "OSPF memory\n") { show_memory_vty (vty, memory_list_ospf); return CMD_SUCCESS; @@ -421,10 +393,7 @@ DEFUN (show_memory_ospf6, show_memory_ospf6_cmd, - "show memory ospf6", - SHOW_STR - "Memory statistics\n" - "OSPF6 memory\n") + "show memory ospf6", SHOW_STR "Memory statistics\n" "OSPF6 memory\n") { show_memory_vty (vty, memory_list_ospf6); return CMD_SUCCESS; @@ -432,10 +401,7 @@ DEFUN (show_memory_isis, show_memory_isis_cmd, - "show memory isis", - SHOW_STR - "Memory statistics\n" - "ISIS memory\n") + "show memory isis", SHOW_STR "Memory statistics\n" "ISIS memory\n") { show_memory_vty (vty, memory_list_isis); return CMD_SUCCESS; diff -Naur quagga-0.99.9/lib/memory.h quagga-0.99.9-af/lib/memory.h --- quagga-0.99.9/lib/memory.h 2006-06-15 05:28:59.000000000 -0700 +++ quagga-0.99.9-af/lib/memory.h 2008-12-03 13:42:15.000000000 -0800 @@ -28,12 +28,13 @@ const char *format; }; -struct mlist { +struct mlist +{ struct memory_list *list; const char *name; }; -#include "lib/memtypes.h" +#include "memtypes.h" extern struct mlist mlists[]; @@ -67,7 +68,8 @@ extern void zfree (int type, void *ptr); extern char *zstrdup (int type, const char *str); -extern void *mtype_zmalloc (const char *file, int line, int type, size_t size); +extern void *mtype_zmalloc (const char *file, int line, int type, + size_t size); extern void *mtype_zcalloc (const char *file, int line, int type, size_t num, size_t size); @@ -75,8 +77,7 @@ extern void *mtype_zrealloc (const char *file, int line, int type, void *ptr, size_t size); -extern void mtype_zfree (const char *file, int line, int type, - void *ptr); +extern void mtype_zfree (const char *file, int line, int type, void *ptr); extern char *mtype_zstrdup (const char *file, int line, int type, const char *str); diff -Naur quagga-0.99.9/lib/memtypes.c quagga-0.99.9-af/lib/memtypes.c --- quagga-0.99.9/lib/memtypes.c 2007-05-04 13:15:47.000000000 -0700 +++ quagga-0.99.9-af/lib/memtypes.c 2008-12-03 13:42:15.000000000 -0800 @@ -12,8 +12,7 @@ #include "zebra.h" #include "memory.h" -struct memory_list memory_list_lib[] = -{ +struct memory_list memory_list_lib[] = { { MTYPE_TMP, "Temporary memory" }, { MTYPE_STRVEC, "String vector" }, { MTYPE_VECTOR, "Vector" }, @@ -75,8 +74,7 @@ { -1, NULL }, }; -struct memory_list memory_list_zebra[] = -{ +struct memory_list memory_list_zebra[] = { { MTYPE_RTADV_PREFIX, "Router Advertisement Prefix" }, { MTYPE_VRF, "VRF" }, { MTYPE_VRF_NAME, "VRF name" }, @@ -88,8 +86,7 @@ { -1, NULL }, }; -struct memory_list memory_list_bgp[] = -{ +struct memory_list memory_list_bgp[] = { { MTYPE_BGP, "BGP instance" }, { MTYPE_BGP_PEER, "BGP peer" }, { MTYPE_BGP_PEER_HOST, "BGP peer hostname" }, @@ -151,8 +148,7 @@ { -1, NULL } }; -struct memory_list memory_list_rip[] = -{ +struct memory_list memory_list_rip[] = { { MTYPE_RIP, "RIP structure" }, { MTYPE_RIP_INFO, "RIP route info" }, { MTYPE_RIP_INTERFACE, "RIP interface" }, @@ -162,8 +158,7 @@ { -1, NULL } }; -struct memory_list memory_list_ripng[] = -{ +struct memory_list memory_list_ripng[] = { { MTYPE_RIPNG, "RIPng structure" }, { MTYPE_RIPNG_ROUTE, "RIPng route info" }, { MTYPE_RIPNG_AGGREGATE, "RIPng aggregate" }, @@ -173,8 +168,7 @@ { -1, NULL } }; -struct memory_list memory_list_ospf[] = -{ +struct memory_list memory_list_ospf[] = { { MTYPE_OSPF_TOP, "OSPF top" }, { MTYPE_OSPF_AREA, "OSPF area" }, { MTYPE_OSPF_AREA_RANGE, "OSPF area range" }, @@ -203,8 +197,7 @@ { -1, NULL }, }; -struct memory_list memory_list_ospf6[] = -{ +struct memory_list memory_list_ospf6[] = { { MTYPE_OSPF6_TOP, "OSPF6 top" }, { MTYPE_OSPF6_AREA, "OSPF6 area" }, { MTYPE_OSPF6_IF, "OSPF6 interface" }, @@ -223,8 +216,7 @@ { -1, NULL }, }; -struct memory_list memory_list_isis[] = -{ +struct memory_list memory_list_isis[] = { { MTYPE_ISIS, "ISIS" }, { MTYPE_ISIS_TMP, "ISIS TMP" }, { MTYPE_ISIS_CIRCUIT, "ISIS circuit" }, @@ -242,21 +234,29 @@ { -1, NULL }, }; -struct memory_list memory_list_vtysh[] = -{ +struct memory_list memory_list_vtysh[] = { { MTYPE_VTYSH_CONFIG, "Vtysh configuration", }, { MTYPE_VTYSH_CONFIG_LINE, "Vtysh configuration line" }, { -1, NULL }, }; -struct mlist mlists[] __attribute__ ((unused)) = { - { memory_list_lib, "LIB" }, - { memory_list_zebra, "ZEBRA" }, - { memory_list_rip, "RIP" }, - { memory_list_ripng, "RIPNG" }, - { memory_list_ospf, "OSPF" }, - { memory_list_ospf6, "OSPF6" }, - { memory_list_isis, "ISIS" }, - { memory_list_bgp, "BGP" }, - { NULL, NULL}, -}; +struct mlist mlists[] __attribute__ ((unused)) = +{ + { + memory_list_lib, "LIB"}, + { + memory_list_zebra, "ZEBRA"}, + { + memory_list_rip, "RIP"}, + { + memory_list_ripng, "RIPNG"}, + { + memory_list_ospf, "OSPF"}, + { + memory_list_ospf6, "OSPF6"}, + { + memory_list_isis, "ISIS"}, + { + memory_list_bgp, "BGP"}, + { +NULL, NULL},}; diff -Naur quagga-0.99.9/lib/network.c quagga-0.99.9-af/lib/network.c --- quagga-0.99.9/lib/network.c 2005-02-16 10:27:08.000000000 -0800 +++ quagga-0.99.9-af/lib/network.c 2008-12-03 13:42:15.000000000 -0800 @@ -39,8 +39,7 @@ if (nread < 0) return (nread); - else - if (nread == 0) + else if (nread == 0) break; nleft -= nread; diff -Naur quagga-0.99.9/lib/plist.c quagga-0.99.9-af/lib/plist.c --- quagga-0.99.9/lib/plist.c 2006-05-12 16:16:00.000000000 -0700 +++ quagga-0.99.9-af/lib/plist.c 2008-12-03 13:42:15.000000000 -0800 @@ -80,8 +80,7 @@ }; /* Static structure of IPv4 prefix_list's master. */ -static struct prefix_master prefix_master_ipv4 = -{ +static struct prefix_master prefix_master_ipv4 = { {NULL, NULL}, {NULL, NULL}, 1, @@ -91,8 +90,7 @@ #ifdef HAVE_IPV6 /* Static structure of IPv6 prefix-list's master. */ -static struct prefix_master prefix_master_ipv6 = -{ +static struct prefix_master prefix_master_ipv6 = { {NULL, NULL}, {NULL, NULL}, 1, @@ -102,8 +100,7 @@ #endif /* HAVE_IPV6*/ /* Static structure of BGP ORF prefix_list's master. */ -static struct prefix_master prefix_master_orf = -{ +static struct prefix_master prefix_master_orf = { {NULL, NULL}, {NULL, NULL}, 1, @@ -432,8 +429,7 @@ static void prefix_list_entry_delete (struct prefix_list *plist, - struct prefix_list_entry *pentry, - int update_list) + struct prefix_list_entry *pentry, int update_list) { if (plist == NULL || pentry == NULL) return; @@ -640,8 +636,7 @@ if (prefix_same (&pentry->prefix, &new->prefix) && pentry->type == new->type && pentry->le == new->le - && pentry->ge == new->ge - && pentry->seq != seq) + && pentry->ge == new->ge && pentry->seq != seq) return pentry; } return NULL; @@ -650,7 +645,8 @@ static int vty_invalid_prefix_range (struct vty *vty, const char *prefix) { - vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s", + vty_out (vty, + "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s", prefix, VTY_NEWLINE); return CMD_WARNING; } @@ -949,8 +945,7 @@ vty_out (vty, " count: %d, range entries: %d, sequences: %d - %d%s", plist->count, plist->rangecount, plist->head ? plist->head->seq : 0, - plist->tail ? plist->tail->seq : 0, - VTY_NEWLINE); + plist->tail ? plist->tail->seq : 0, VTY_NEWLINE); } if (dtype != summary_display) @@ -1023,7 +1018,8 @@ if (dtype == detail_display || dtype == summary_display) { if (master->recent) - vty_out (vty, "Prefix-list with the last deletion/insertion: %s%s", + vty_out (vty, + "Prefix-list with the last deletion/insertion: %s%s", master->recent->name, VTY_NEWLINE); } @@ -1076,8 +1072,7 @@ if (match) { vty_out (vty, " seq %d %s ", - pentry->seq, - prefix_list_type_str (pentry)); + pentry->seq, prefix_list_type_str (pentry)); if (pentry->any) vty_out (vty, "any"); @@ -1190,8 +1185,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], argv[3], NULL); @@ -1208,8 +1202,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], argv[3], argv[4]); @@ -1224,8 +1217,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], NULL, argv[3]); @@ -1242,8 +1234,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], argv[4], argv[3]); @@ -1277,8 +1268,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], argv[4], NULL); @@ -1297,8 +1287,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); @@ -1315,8 +1304,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], NULL, argv[4]); @@ -1335,8 +1323,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], argv[5], argv[4]); @@ -1345,10 +1332,7 @@ DEFUN (no_ip_prefix_list, no_ip_prefix_list_cmd, "no ip prefix-list WORD", - NO_STR - IP_STR - PREFIX_LIST_STR - "Name of a prefix list\n") + NO_STR IP_STR PREFIX_LIST_STR "Name of a prefix list\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, NULL, NULL, NULL, NULL); @@ -1380,8 +1364,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], argv[3], NULL); @@ -1399,8 +1382,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], argv[3], argv[4]); @@ -1416,8 +1398,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], NULL, argv[3]); @@ -1435,8 +1416,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1], argv[2], argv[4], argv[3]); @@ -1472,8 +1452,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], argv[4], NULL); @@ -1493,8 +1472,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); @@ -1512,8 +1490,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IP prefix /, e.g., 35.0.0.0/8\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], NULL, argv[4]); @@ -1533,8 +1510,7 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2], argv[3], argv[5], argv[4]); @@ -1543,9 +1519,7 @@ DEFUN (ip_prefix_list_sequence_number, ip_prefix_list_sequence_number_cmd, "ip prefix-list sequence-number", - IP_STR - PREFIX_LIST_STR - "Include/exclude sequence numbers in NVGEN\n") + IP_STR PREFIX_LIST_STR "Include/exclude sequence numbers in NVGEN\n") { prefix_master_ipv4.seqnum = 1; return CMD_SUCCESS; @@ -1555,9 +1529,7 @@ no_ip_prefix_list_sequence_number_cmd, "no ip prefix-list sequence-number", NO_STR - IP_STR - PREFIX_LIST_STR - "Include/exclude sequence numbers in NVGEN\n") + IP_STR PREFIX_LIST_STR "Include/exclude sequence numbers in NVGEN\n") { prefix_master_ipv4.seqnum = 0; return CMD_SUCCESS; @@ -1592,8 +1564,7 @@ NO_STR IP_STR PREFIX_LIST_STR - "Name of a prefix list\n" - "Prefix-list specific description\n") + "Name of a prefix list\n" "Prefix-list specific description\n") { return vty_prefix_list_desc_unset (vty, AFI_IP, argv[0]); } @@ -1607,13 +1578,9 @@ "Name of a prefix list\n" "Prefix-list specific description\n" "Up to 80 characters describing this prefix-list\n") - DEFUN (show_ip_prefix_list, show_ip_prefix_list_cmd, - "show ip prefix-list", - SHOW_STR - IP_STR - PREFIX_LIST_STR) + "show ip prefix-list", SHOW_STR IP_STR PREFIX_LIST_STR) { return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, normal_display); } @@ -1621,10 +1588,7 @@ DEFUN (show_ip_prefix_list_name, show_ip_prefix_list_name_cmd, "show ip prefix-list WORD", - SHOW_STR - IP_STR - PREFIX_LIST_STR - "Name of a prefix list\n") + SHOW_STR IP_STR PREFIX_LIST_STR "Name of a prefix list\n") { return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, normal_display); } @@ -1636,10 +1600,10 @@ IP_STR PREFIX_LIST_STR "Name of a prefix list\n" - "sequence number of an entry\n" - "Sequence number\n") + "sequence number of an entry\n" "Sequence number\n") { - return vty_show_prefix_list (vty, AFI_IP, argv[0], argv[1], sequential_display); + return vty_show_prefix_list (vty, AFI_IP, argv[0], argv[1], + sequential_display); } DEFUN (show_ip_prefix_list_prefix, @@ -1651,7 +1615,8 @@ "Name of a prefix list\n" "IP prefix /, e.g., 35.0.0.0/8\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], normal_display); + return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], + normal_display); } DEFUN (show_ip_prefix_list_prefix_longer, @@ -1664,7 +1629,8 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "Lookup longer prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], longer_display); + return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], + longer_display); } DEFUN (show_ip_prefix_list_prefix_first_match, @@ -1677,16 +1643,14 @@ "IP prefix /, e.g., 35.0.0.0/8\n" "First matched prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], first_match_display); + return vty_show_prefix_list_prefix (vty, AFI_IP, argv[0], argv[1], + first_match_display); } DEFUN (show_ip_prefix_list_summary, show_ip_prefix_list_summary_cmd, "show ip prefix-list summary", - SHOW_STR - IP_STR - PREFIX_LIST_STR - "Summary of prefix lists\n") + SHOW_STR IP_STR PREFIX_LIST_STR "Summary of prefix lists\n") { return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, summary_display); } @@ -1696,9 +1660,7 @@ "show ip prefix-list summary WORD", SHOW_STR IP_STR - PREFIX_LIST_STR - "Summary of prefix lists\n" - "Name of a prefix list\n") + PREFIX_LIST_STR "Summary of prefix lists\n" "Name of a prefix list\n") { return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, summary_display); } @@ -1707,10 +1669,7 @@ DEFUN (show_ip_prefix_list_detail, show_ip_prefix_list_detail_cmd, "show ip prefix-list detail", - SHOW_STR - IP_STR - PREFIX_LIST_STR - "Detail of prefix lists\n") + SHOW_STR IP_STR PREFIX_LIST_STR "Detail of prefix lists\n") { return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, detail_display); } @@ -1720,19 +1679,14 @@ "show ip prefix-list detail WORD", SHOW_STR IP_STR - PREFIX_LIST_STR - "Detail of prefix lists\n" - "Name of a prefix list\n") + PREFIX_LIST_STR "Detail of prefix lists\n" "Name of a prefix list\n") { return vty_show_prefix_list (vty, AFI_IP, argv[0], NULL, detail_display); } DEFUN (clear_ip_prefix_list, clear_ip_prefix_list_cmd, - "clear ip prefix-list", - CLEAR_STR - IP_STR - PREFIX_LIST_STR) + "clear ip prefix-list", CLEAR_STR IP_STR PREFIX_LIST_STR) { return vty_clear_prefix_list (vty, AFI_IP, NULL, NULL); } @@ -1740,10 +1694,7 @@ DEFUN (clear_ip_prefix_list_name, clear_ip_prefix_list_name_cmd, "clear ip prefix-list WORD", - CLEAR_STR - IP_STR - PREFIX_LIST_STR - "Name of a prefix list\n") + CLEAR_STR IP_STR PREFIX_LIST_STR "Name of a prefix list\n") { return vty_clear_prefix_list (vty, AFI_IP, argv[0], NULL); } @@ -1785,8 +1736,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], argv[3], NULL); @@ -1803,9 +1753,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") - + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], argv[3], argv[4]); @@ -1820,8 +1768,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], NULL, argv[3]); @@ -1838,8 +1785,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], argv[4], argv[3]); @@ -1873,8 +1819,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], argv[4], NULL); @@ -1893,8 +1838,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); @@ -1911,8 +1855,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], NULL, argv[4]); @@ -1931,8 +1874,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_install (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], argv[5], argv[4]); @@ -1941,10 +1883,7 @@ DEFUN (no_ipv6_prefix_list, no_ipv6_prefix_list_cmd, "no ipv6 prefix-list WORD", - NO_STR - IPV6_STR - PREFIX_LIST_STR - "Name of a prefix list\n") + NO_STR IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, NULL, NULL, NULL, NULL); @@ -1976,8 +1915,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], argv[3], NULL); @@ -1995,8 +1933,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], argv[3], argv[4]); @@ -2012,8 +1949,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], NULL, argv[3]); @@ -2031,8 +1967,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], NULL, argv[1], argv[2], argv[4], argv[3]); @@ -2068,8 +2003,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], argv[4], NULL); @@ -2089,8 +2023,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Minimum prefix length to be matched\n" "Minimum prefix length\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); @@ -2108,8 +2041,7 @@ "Specify packets to reject\n" "Specify packets to forward\n" "IPv6 prefix /, e.g., 3ffe::/16\n" - "Maximum prefix length to be matched\n" - "Maximum prefix length\n") + "Maximum prefix length to be matched\n" "Maximum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], NULL, argv[4]); @@ -2129,8 +2061,7 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Maximum prefix length to be matched\n" "Maximum prefix length\n" - "Minimum prefix length to be matched\n" - "Minimum prefix length\n") + "Minimum prefix length to be matched\n" "Minimum prefix length\n") { return vty_prefix_list_uninstall (vty, AFI_IP6, argv[0], argv[1], argv[2], argv[3], argv[5], argv[4]); @@ -2139,9 +2070,7 @@ DEFUN (ipv6_prefix_list_sequence_number, ipv6_prefix_list_sequence_number_cmd, "ipv6 prefix-list sequence-number", - IPV6_STR - PREFIX_LIST_STR - "Include/exclude sequence numbers in NVGEN\n") + IPV6_STR PREFIX_LIST_STR "Include/exclude sequence numbers in NVGEN\n") { prefix_master_ipv6.seqnum = 1; return CMD_SUCCESS; @@ -2151,9 +2080,7 @@ no_ipv6_prefix_list_sequence_number_cmd, "no ipv6 prefix-list sequence-number", NO_STR - IPV6_STR - PREFIX_LIST_STR - "Include/exclude sequence numbers in NVGEN\n") + IPV6_STR PREFIX_LIST_STR "Include/exclude sequence numbers in NVGEN\n") { prefix_master_ipv6.seqnum = 0; return CMD_SUCCESS; @@ -2188,8 +2115,7 @@ NO_STR IPV6_STR PREFIX_LIST_STR - "Name of a prefix list\n" - "Prefix-list specific description\n") + "Name of a prefix list\n" "Prefix-list specific description\n") { return vty_prefix_list_desc_unset (vty, AFI_IP6, argv[0]); } @@ -2203,13 +2129,9 @@ "Name of a prefix list\n" "Prefix-list specific description\n" "Up to 80 characters describing this prefix-list\n") - DEFUN (show_ipv6_prefix_list, show_ipv6_prefix_list_cmd, - "show ipv6 prefix-list", - SHOW_STR - IPV6_STR - PREFIX_LIST_STR) + "show ipv6 prefix-list", SHOW_STR IPV6_STR PREFIX_LIST_STR) { return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, normal_display); } @@ -2217,10 +2139,7 @@ DEFUN (show_ipv6_prefix_list_name, show_ipv6_prefix_list_name_cmd, "show ipv6 prefix-list WORD", - SHOW_STR - IPV6_STR - PREFIX_LIST_STR - "Name of a prefix list\n") + SHOW_STR IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n") { return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, normal_display); } @@ -2232,10 +2151,10 @@ IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n" - "sequence number of an entry\n" - "Sequence number\n") + "sequence number of an entry\n" "Sequence number\n") { - return vty_show_prefix_list (vty, AFI_IP6, argv[0], argv[1], sequential_display); + return vty_show_prefix_list (vty, AFI_IP6, argv[0], argv[1], + sequential_display); } DEFUN (show_ipv6_prefix_list_prefix, @@ -2247,7 +2166,8 @@ "Name of a prefix list\n" "IPv6 prefix /, e.g., 3ffe::/16\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], normal_display); + return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], + normal_display); } DEFUN (show_ipv6_prefix_list_prefix_longer, @@ -2260,7 +2180,8 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "Lookup longer prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], longer_display); + return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], + longer_display); } DEFUN (show_ipv6_prefix_list_prefix_first_match, @@ -2273,16 +2194,14 @@ "IPv6 prefix /, e.g., 3ffe::/16\n" "First matched prefix\n") { - return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], first_match_display); + return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[0], argv[1], + first_match_display); } DEFUN (show_ipv6_prefix_list_summary, show_ipv6_prefix_list_summary_cmd, "show ipv6 prefix-list summary", - SHOW_STR - IPV6_STR - PREFIX_LIST_STR - "Summary of prefix lists\n") + SHOW_STR IPV6_STR PREFIX_LIST_STR "Summary of prefix lists\n") { return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, summary_display); } @@ -2292,9 +2211,7 @@ "show ipv6 prefix-list summary WORD", SHOW_STR IPV6_STR - PREFIX_LIST_STR - "Summary of prefix lists\n" - "Name of a prefix list\n") + PREFIX_LIST_STR "Summary of prefix lists\n" "Name of a prefix list\n") { return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, summary_display); } @@ -2302,10 +2219,7 @@ DEFUN (show_ipv6_prefix_list_detail, show_ipv6_prefix_list_detail_cmd, "show ipv6 prefix-list detail", - SHOW_STR - IPV6_STR - PREFIX_LIST_STR - "Detail of prefix lists\n") + SHOW_STR IPV6_STR PREFIX_LIST_STR "Detail of prefix lists\n") { return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, detail_display); } @@ -2315,19 +2229,14 @@ "show ipv6 prefix-list detail WORD", SHOW_STR IPV6_STR - PREFIX_LIST_STR - "Detail of prefix lists\n" - "Name of a prefix list\n") + PREFIX_LIST_STR "Detail of prefix lists\n" "Name of a prefix list\n") { return vty_show_prefix_list (vty, AFI_IP6, argv[0], NULL, detail_display); } DEFUN (clear_ipv6_prefix_list, clear_ipv6_prefix_list_cmd, - "clear ipv6 prefix-list", - CLEAR_STR - IPV6_STR - PREFIX_LIST_STR) + "clear ipv6 prefix-list", CLEAR_STR IPV6_STR PREFIX_LIST_STR) { return vty_clear_prefix_list (vty, AFI_IP6, NULL, NULL); } @@ -2335,10 +2244,7 @@ DEFUN (clear_ipv6_prefix_list_name, clear_ipv6_prefix_list_name_cmd, "clear ipv6 prefix-list WORD", - CLEAR_STR - IPV6_STR - PREFIX_LIST_STR - "Name of a prefix list\n") + CLEAR_STR IPV6_STR PREFIX_LIST_STR "Name of a prefix list\n") { return vty_clear_prefix_list (vty, AFI_IP6, argv[0], NULL); } @@ -2389,8 +2295,7 @@ for (pentry = plist->head; pentry; pentry = pentry->next) { vty_out (vty, "ip%s prefix-list %s ", - afi == AFI_IP ? "" : "v6", - plist->name); + afi == AFI_IP ? "" : "v6", plist->name); if (master->seqnum) vty_out (vty, "seq %d ", pentry->seq); @@ -2432,8 +2337,7 @@ for (pentry = plist->head; pentry; pentry = pentry->next) { vty_out (vty, "ip%s prefix-list %s ", - afi == AFI_IP ? "" : "v6", - plist->name); + afi == AFI_IP ? "" : "v6", plist->name); if (master->seqnum) vty_out (vty, "seq %d ", pentry->seq); @@ -2478,8 +2382,7 @@ u_char flag = init_flag; struct prefix *p = &pentry->prefix; - flag |= (pentry->type == PREFIX_PERMIT ? - permit_flag : deny_flag); + flag |= (pentry->type == PREFIX_PERMIT ? permit_flag : deny_flag); stream_putc (s, flag); stream_putl (s, (u_int32_t)pentry->seq); stream_putc (s, (u_char)pentry->ge); @@ -2529,8 +2432,9 @@ else { pentry = prefix_list_entry_lookup (plist, &orfp->p, - (permit ? PREFIX_PERMIT : PREFIX_DENY), - orfp->seq, orfp->le, orfp->ge); + (permit ? PREFIX_PERMIT : + PREFIX_DENY), orfp->seq, orfp->le, + orfp->ge); if (! pentry) return CMD_WARNING; @@ -2566,8 +2470,7 @@ return plist->count; vty_out (vty, "ip%s prefix-list %s: %d entries%s", - afi == AFI_IP ? "" : "v6", - plist->name, plist->count, VTY_NEWLINE); + afi == AFI_IP ? "" : "v6", plist->name, plist->count, VTY_NEWLINE); for (pentry = plist->head; pentry; pentry = pentry->next) { @@ -2623,8 +2526,7 @@ /* Prefix-list node. */ -struct cmd_node prefix_node = -{ +struct cmd_node prefix_node = { PREFIX_NODE, "", /* Prefix list has no interface. */ 1 @@ -2732,8 +2634,7 @@ #ifdef HAVE_IPV6 /* Prefix-list node. */ -struct cmd_node prefix_ipv6_node = -{ +struct cmd_node prefix_ipv6_node = { PREFIX_IPV6_NODE, "", /* Prefix list has no interface. */ 1 @@ -2828,7 +2729,8 @@ install_element (ENABLE_NODE, &show_ipv6_prefix_list_name_seq_cmd); install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_cmd); install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_first_match_cmd); + install_element (ENABLE_NODE, + &show_ipv6_prefix_list_prefix_first_match_cmd); install_element (ENABLE_NODE, &show_ipv6_prefix_list_summary_cmd); install_element (ENABLE_NODE, &show_ipv6_prefix_list_summary_name_cmd); install_element (ENABLE_NODE, &show_ipv6_prefix_list_detail_cmd); diff -Naur quagga-0.99.9/lib/prefix.c quagga-0.99.9-af/lib/prefix.c --- quagga-0.99.9/lib/prefix.c 2005-07-28 17:14:23.000000000 -0700 +++ quagga-0.99.9-af/lib/prefix.c 2008-12-03 13:42:15.000000000 -0800 @@ -30,7 +30,8 @@ /* Maskbit. */ static u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, - 0xf8, 0xfc, 0xfe, 0xff}; + 0xf8, 0xfc, 0xfe, 0xff +}; /* Number of bits in prefix type. */ #ifndef PNBBY @@ -512,8 +513,7 @@ /* Utility function of convert between struct prefix <=> union sockunion. * FIXME This function isn't used anywhere. */ struct prefix * -sockunion2prefix (const union sockunion *dest, - const union sockunion *mask) +sockunion2prefix (const union sockunion *dest, const union sockunion *mask) { if (dest->sa.sa_family == AF_INET) { @@ -646,7 +646,8 @@ } /* Utility function to convert ipv4 prefixes to Classful prefixes */ -void apply_classful_mask_ipv4 (struct prefix_ipv4 *p) +void +apply_classful_mask_ipv4 (struct prefix_ipv4 *p) { u_int32_t destination; diff -Naur quagga-0.99.9/lib/privs.c quagga-0.99.9-af/lib/privs.c --- quagga-0.99.9/lib/privs.c 2006-03-30 05:21:35.000000000 -0800 +++ quagga-0.99.9-af/lib/privs.c 2008-12-03 13:42:15.000000000 -0800 @@ -40,7 +40,8 @@ */ #ifdef HAVE_LCAPS /* Linux doesn't have a 'set' type: a set of related privileges */ -struct _pset { +struct _pset +{ int num; cap_value_t *caps; }; @@ -100,38 +101,101 @@ } cap_map [ZCAP_MAX] = { #ifdef HAVE_LCAPS /* Quagga -> Linux capabilities mappings */ - [ZCAP_SETID] = { 2, (pvalue_t []) { CAP_SETGID, - CAP_SETUID }, }, - [ZCAP_BIND] = { 2, (pvalue_t []) { CAP_NET_BIND_SERVICE, - CAP_NET_BROADCAST }, }, - [ZCAP_NET_ADMIN] = { 1, (pvalue_t []) { CAP_NET_ADMIN }, }, - [ZCAP_NET_RAW] = { 1, (pvalue_t []) { CAP_NET_RAW }, }, - [ZCAP_CHROOT] = { 1, (pvalue_t []) { CAP_SYS_CHROOT, }, }, - [ZCAP_NICE] = { 1, (pvalue_t []) { CAP_SYS_NICE }, }, - [ZCAP_PTRACE] = { 1, (pvalue_t []) { CAP_SYS_PTRACE }, }, - [ZCAP_DAC_OVERRIDE] = { 1, (pvalue_t []) { CAP_DAC_OVERRIDE }, }, - [ZCAP_READ_SEARCH] = { 1, (pvalue_t []) { CAP_DAC_READ_SEARCH }, }, - [ZCAP_SYS_ADMIN] = { 1, (pvalue_t []) { CAP_SYS_ADMIN }, }, - [ZCAP_FOWNER] = { 1, (pvalue_t []) { CAP_FOWNER }, }, + [ZCAP_SETID] = + { + 2, (pvalue_t[]) + { + CAP_SETGID, CAP_SETUID},},[ZCAP_BIND] = + { + 2, (pvalue_t[]) + { + CAP_NET_BIND_SERVICE, CAP_NET_BROADCAST},},[ZCAP_NET_ADMIN] = + { + 1, (pvalue_t[]) + { + CAP_NET_ADMIN},},[ZCAP_NET_RAW] = + { + 1, (pvalue_t[]) + { + CAP_NET_RAW},},[ZCAP_CHROOT] = + { + 1, (pvalue_t[]) + { + CAP_SYS_CHROOT,},},[ZCAP_NICE] = + { + 1, (pvalue_t[]) + { + CAP_SYS_NICE},},[ZCAP_PTRACE] = + { + 1, (pvalue_t[]) + { + CAP_SYS_PTRACE},},[ZCAP_DAC_OVERRIDE] = + { + 1, (pvalue_t[]) + { + CAP_DAC_OVERRIDE},},[ZCAP_READ_SEARCH] = + { + 1, (pvalue_t[]) + { + CAP_DAC_READ_SEARCH},},[ZCAP_SYS_ADMIN] = + { + 1, (pvalue_t[]) + { + CAP_SYS_ADMIN},},[ZCAP_FOWNER] = + { + 1, (pvalue_t[]) + { + CAP_FOWNER},}, #elif defined(HAVE_SOLARIS_CAPABILITIES) /* HAVE_LCAPS */ /* Quagga -> Solaris privilege mappings */ - [ZCAP_SETID] = { 1, (pvalue_t []) { PRIV_PROC_SETID }, }, - [ZCAP_BIND] = { 1, (pvalue_t []) { PRIV_NET_PRIVADDR }, }, - [ZCAP_NET_ADMIN] = { 1, (pvalue_t []) { PRIV_SYS_NET_CONFIG }, }, - [ZCAP_NET_RAW] = { 2, (pvalue_t []) { PRIV_NET_RAWACCESS, - PRIV_NET_ICMPACCESS }, }, - [ZCAP_CHROOT] = { 1, (pvalue_t []) { PRIV_PROC_CHROOT }, }, - [ZCAP_NICE] = { 1, (pvalue_t []) { PRIV_PROC_PRIOCNTL }, }, - [ZCAP_PTRACE] = { 1, (pvalue_t []) { PRIV_PROC_SESSION }, }, - [ZCAP_DAC_OVERRIDE] = { 2, (pvalue_t []) { PRIV_FILE_DAC_EXECUTE, + [ZCAP_SETID] = + { + 1, (pvalue_t[]) + { + PRIV_PROC_SETID},},[ZCAP_BIND] = + { + 1, (pvalue_t[]) + { + PRIV_NET_PRIVADDR},},[ZCAP_NET_ADMIN] = + { + 1, (pvalue_t[]) + { + PRIV_SYS_NET_CONFIG},},[ZCAP_NET_RAW] = + { + 2, (pvalue_t[]) + { + PRIV_NET_RAWACCESS, PRIV_NET_ICMPACCESS},},[ZCAP_CHROOT] = + { + 1, (pvalue_t[]) + { + PRIV_PROC_CHROOT},},[ZCAP_NICE] = + { + 1, (pvalue_t[]) + { + PRIV_PROC_PRIOCNTL},},[ZCAP_PTRACE] = + { + 1, (pvalue_t[]) + { + PRIV_PROC_SESSION},},[ZCAP_DAC_OVERRIDE] = + { + 2, (pvalue_t[]) + { + PRIV_FILE_DAC_EXECUTE, PRIV_FILE_DAC_READ, PRIV_FILE_DAC_SEARCH, - PRIV_FILE_DAC_WRITE, - PRIV_FILE_DAC_SEARCH }, }, - [ZCAP_READ_SEARCH] = { 2, (pvalue_t []) { PRIV_FILE_DAC_SEARCH, - PRIV_FILE_DAC_READ }, }, - [ZCAP_SYS_ADMIN] = { 1, (pvalue_t []) { PRIV_SYS_ADMIN }, }, - [ZCAP_FOWNER] = { 1, (pvalue_t []) { PRIV_FILE_OWNER }, }, + PRIV_FILE_DAC_WRITE, PRIV_FILE_DAC_SEARCH},},[ZCAP_READ_SEARCH] = + { + 2, (pvalue_t[]) + { + PRIV_FILE_DAC_SEARCH, PRIV_FILE_DAC_READ},},[ZCAP_SYS_ADMIN] = + { + 1, (pvalue_t[]) + { + PRIV_SYS_ADMIN},},[ZCAP_FOWNER] = + { + 1, (pvalue_t[]) + { + PRIV_FILE_OWNER},}, #endif /* HAVE_SOLARIS_CAPABILITIES */ }; @@ -197,8 +261,7 @@ if ( !cap_set_flag (zprivs_state.caps, CAP_EFFECTIVE, zprivs_state.syscaps_p->num, - zprivs_state.syscaps_p->caps, - cflag)) + zprivs_state.syscaps_p->caps, cflag)) return cap_set_proc (zprivs_state.caps); return -1; } @@ -277,16 +340,14 @@ /* set permitted caps */ cap_set_flag(zprivs_state.caps, CAP_PERMITTED, zprivs_state.syscaps_p->num, - zprivs_state.syscaps_p->caps, - CAP_SET); + zprivs_state.syscaps_p->caps, CAP_SET); /* set inheritable caps, if any */ if (zprivs_state.syscaps_i && zprivs_state.syscaps_i->num) { cap_set_flag(zprivs_state.caps, CAP_INHERITABLE, zprivs_state.syscaps_i->num, - zprivs_state.syscaps_i->caps, - CAP_SET); + zprivs_state.syscaps_i->caps, CAP_SET); } /* apply caps. CAP_EFFECTIVE is cleared. we'll raise the caps as @@ -444,8 +505,7 @@ if (!zprivs_state.syscaps_p) { fprintf (stderr, "%s: capabilities enabled, " - "but no valid capabilities supplied\n", - __func__); + "but no valid capabilities supplied\n", __func__); } /* We retain the basic set in our permitted set, as Linux has no diff -Naur quagga-0.99.9/lib/privs.h quagga-0.99.9-af/lib/privs.h --- quagga-0.99.9/lib/privs.h 2005-09-29 07:41:07.000000000 -0700 +++ quagga-0.99.9-af/lib/privs.h 2008-12-03 13:42:15.000000000 -0800 @@ -64,10 +64,8 @@ const char *group; const char *vty_group; /* group to chown vty socket to */ /* methods */ - int - (*change) (zebra_privs_ops_t); /* change privileges, 0 on success */ - zebra_privs_current_t - (*current_state) (void); /* current privilege state */ + int (*change) (zebra_privs_ops_t); /* change privileges, 0 on success */ + zebra_privs_current_t (*current_state) (void); /* current privilege state */ }; struct zprivs_ids_t diff -Naur quagga-0.99.9/lib/regex.c quagga-0.99.9-af/lib/regex.c --- quagga-0.99.9/lib/regex.c 2006-01-31 12:55:53.000000000 -0800 +++ quagga-0.99.9-af/lib/regex.c 2008-12-03 13:42:15.000000000 -0800 @@ -734,8 +734,7 @@ assert (p + *p < pend); for (c = 0; c < 256; c++) - if (c / 8 < *p - && (p[1 + (c/8)] & (1 << (c % 8)))) + if (c / 8 < *p && (p[1 + (c / 8)] & (1 << (c % 8)))) { /* Are we starting a range? */ if (last + 1 == c && ! in_range) @@ -1011,14 +1010,11 @@ #ifdef _LIBC weak_alias (__re_set_syntax, re_set_syntax) #endif - /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. POSIX doesn't require that we do anything for REG_NOERROR, but why not be nice? */ - -static const char re_error_msgid[] = - { + static const char re_error_msgid[] = { #define REG_NOERROR_IDX 0 gettext_noop ("Success") /* REG_NOERROR */ "\0" @@ -1071,8 +1067,7 @@ gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */ }; -static const size_t re_error_msgid_idx[] = - { +static const size_t re_error_msgid_idx[] = { REG_NOERROR_IDX, REG_NOMATCH_IDX, REG_BADPAT_IDX, @@ -1558,25 +1553,25 @@ /* Subroutine declarations and macros for regex_compile. */ -static reg_errcode_t regex_compile _RE_ARGS ((const char *pattern, size_t size, - reg_syntax_t syntax, +static reg_errcode_t regex_compile +_RE_ARGS ((const char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp)); -static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg)); -static void store_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, - int arg1, int arg2)); -static void insert_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, - int arg, unsigned char *end)); -static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, - int arg1, int arg2, unsigned char *end)); -static boolean at_begline_loc_p _RE_ARGS ((const char *pattern, const char *p, - reg_syntax_t syntax)); -static boolean at_endline_loc_p _RE_ARGS ((const char *p, const char *pend, - reg_syntax_t syntax)); -static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr, - const char *pend, - char *translate, - reg_syntax_t syntax, - unsigned char *b)); +static void store_op1 +_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg)); +static void store_op2 +_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg1, int arg2)); +static void insert_op1 +_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg, unsigned char *end)); +static void insert_op2 +_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg1, int arg2, + unsigned char *end)); +static boolean at_begline_loc_p +_RE_ARGS ((const char *pattern, const char *p, reg_syntax_t syntax)); +static boolean at_endline_loc_p +_RE_ARGS ((const char *p, const char *pend, reg_syntax_t syntax)); +static reg_errcode_t compile_range +_RE_ARGS ((const char **p_ptr, const char *pend, char *translate, + reg_syntax_t syntax, unsigned char *b)); /* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant @@ -1990,7 +1985,8 @@ { /* Caller did not allocate a buffer. Do it for them. */ bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); } - if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); + if (!bufp->buffer) + FREE_STACK_RETURN (REG_ESPACE); bufp->allocated = INIT_BUF_SIZE; } @@ -2036,8 +2032,7 @@ case '+': case '?': - if ((syntax & RE_BK_PLUS_QM) - || (syntax & RE_LIMITED_OPS)) + if ((syntax & RE_BK_PLUS_QM) || (syntax & RE_LIMITED_OPS)) goto normal_char; handle_plus: case '*': @@ -2078,7 +2073,8 @@ else if (syntax & RE_BK_PLUS_QM && c == '\\') { - if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); + if (p == pend) + FREE_STACK_RETURN (REG_EESCAPE); PATFETCH (c1); if (!(c1 == '+' || c1 == '?')) @@ -2147,8 +2143,7 @@ end of the buffer after this jump is inserted. */ GET_BUFFER_SPACE (3); INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump - : on_failure_jump, - laststart, b + 3); + : on_failure_jump, laststart, b + 3); pending_exact = 0; b += 3; @@ -2177,7 +2172,8 @@ { boolean had_char_class = false; - if (p == pend) FREE_STACK_RETURN (REG_EBRACK); + if (p == pend) + FREE_STACK_RETURN (REG_EBRACK); /* Ensure that we have enough space to push a charset: the opcode, the length count, and the bitset; 34 bytes in all. */ @@ -2208,14 +2204,16 @@ /* Read in characters and ranges, setting map bits. */ for (;;) { - if (p == pend) FREE_STACK_RETURN (REG_EBRACK); + if (p == pend) + FREE_STACK_RETURN (REG_EBRACK); PATFETCH (c); /* \ might escape characters inside [...] and [^...]. */ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') { - if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); + if (p == pend) + FREE_STACK_RETURN (REG_EESCAPE); PATFETCH (c1); SET_LIST_BIT (c1); @@ -2244,7 +2242,8 @@ { reg_errcode_t ret = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); + if (ret != REG_NOERROR) + FREE_STACK_RETURN (ret); } else if (p[0] == '-' && p[1] != ']') @@ -2255,7 +2254,8 @@ PATFETCH (c1); ret = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); + if (ret != REG_NOERROR) + FREE_STACK_RETURN (ret); } /* See if we're at the beginning of a possible character @@ -2269,7 +2269,8 @@ c1 = 0; /* If pattern is `[[:'. */ - if (p == pend) FREE_STACK_RETURN (REG_EBRACK); + if (p == pend) + FREE_STACK_RETURN (REG_EBRACK); for (;;) { @@ -2303,7 +2304,8 @@ class. */ PATFETCH (c); - if (p == pend) FREE_STACK_RETURN (REG_EBRACK); + if (p == pend) + FREE_STACK_RETURN (REG_EBRACK); for (ch = 0; ch < 1 << BYTEWIDTH; ++ch) { @@ -2343,7 +2345,8 @@ class. */ PATFETCH (c); - if (p == pend) FREE_STACK_RETURN (REG_EBRACK); + if (p == pend) + FREE_STACK_RETURN (REG_EBRACK); for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { @@ -2433,7 +2436,8 @@ case '\\': - if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); + if (p == pend) + FREE_STACK_RETURN (REG_EESCAPE); /* Do not translate the character after the \, so that we can distinguish, e.g., \B from \b, even if we normally would @@ -2454,7 +2458,8 @@ { RETALLOC (compile_stack.stack, compile_stack.size << 1, compile_stack_elt_t); - if (compile_stack.stack == NULL) return REG_ESPACE; + if (compile_stack.stack == NULL) + return REG_ESPACE; compile_stack.size <<= 1; } @@ -2492,7 +2497,8 @@ case ')': - if (syntax & RE_NO_BK_PARENS) goto normal_backslash; + if (syntax & RE_NO_BK_PARENS) + goto normal_backslash; if (COMPILE_STACK_EMPTY) { @@ -2537,8 +2543,7 @@ begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; fixup_alt_jump = COMPILE_STACK_TOP.fixup_alt_jump - ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 - : 0; + ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 : 0; laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; this_group_regnum = COMPILE_STACK_TOP.regnum; /* If we've reached MAX_REGNUM groups, then this open @@ -2637,7 +2642,8 @@ if (c == ',') { GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) upper_bound = RE_DUP_MAX; + if (upper_bound < 0) + upper_bound = RE_DUP_MAX; } else /* Interval such as `{1}' => match exactly once. */ @@ -2654,7 +2660,8 @@ if (!(syntax & RE_NO_BK_BRACES)) { - if (c != '\\') FREE_STACK_RETURN (REG_EBRACE); + if (c != '\\') + FREE_STACK_RETURN (REG_EBRACE); PATFETCH (c); } @@ -2712,8 +2719,7 @@ because `re_compile_fastmap' needs to know. Jump to the `jump_n' we might insert below. */ INSERT_JUMP2 (succeed_n, laststart, - b + 5 + (upper_bound > 1) * 5, - lower_bound); + b + 5 + (upper_bound > 1) * 5, lower_bound); b += 5; /* Code to initialize the lower bound. Insert @@ -2848,8 +2854,15 @@ BUF_PUSH (endbuf); break; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': if (syntax & RE_NO_BK_REFS) goto normal_char; @@ -2904,8 +2917,7 @@ : (*p == '+' || *p == '?')) || ((syntax & RE_INTERVALS) && ((syntax & RE_NO_BK_BRACES) - ? *p == '{' - : (p[0] == '\\' && p[1] == '{')))) + ? *p == '{' : (p[0] == '\\' && p[1] == '{')))) { /* Start building a new exactn. */ @@ -3113,8 +3125,7 @@ int this_element; for (this_element = compile_stack.avail - 1; - this_element >= 0; - this_element--) + this_element >= 0; this_element--) if (compile_stack.stack[this_element].regnum == regnum) return true; @@ -3484,7 +3495,6 @@ #ifdef _LIBC weak_alias (__re_compile_fastmap, re_compile_fastmap) #endif - /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use this memory for recording register information. STARTS and ENDS @@ -3497,9 +3507,7 @@ Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ - -void -re_set_registers (bufp, regs, num_regs, starts, ends) + void re_set_registers (bufp, regs, num_regs, starts, ends) struct re_pattern_buffer *bufp; struct re_registers *regs; unsigned num_regs; @@ -3522,14 +3530,10 @@ #ifdef _LIBC weak_alias (__re_set_registers, re_set_registers) #endif - /* Searching routines. */ - /* Like re_search_2, below, but only one string is specified, and doesn't let you say where to stop matching. */ - -int -re_search (bufp, string, size, startpos, range, regs) + int re_search (bufp, string, size, startpos, range, regs) struct re_pattern_buffer *bufp; const char *string; int size, startpos, range; @@ -3563,9 +3567,9 @@ We return either the position in the strings at which the match was found, -1 if no match, or -2 if error (such as failure stack overflow). */ - int -re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) + re_search_2 (bufp, string1, size1, string2, size2, startpos, range, + regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; @@ -3594,11 +3598,10 @@ /* If the search isn't to be a backwards one, don't waste time in a search for a pattern that must be anchored. */ - if (bufp->used > 0 && range > 0 - && ((re_opcode_t) bufp->buffer[0] == begbuf + if (bufp->used > 0 && range > 0 && ((re_opcode_t) bufp->buffer[0] == begbuf /* `begline' is like `begbuf' if it cannot match at newlines. */ - || ((re_opcode_t) bufp->buffer[0] == begline - && !bufp->newline_anchor))) + || ((re_opcode_t) bufp->buffer[0] == + begline && !bufp->newline_anchor))) { if (startpos > 0) return -1; @@ -3704,7 +3707,6 @@ #ifdef _LIBC weak_alias (__re_search_2, re_search_2) #endif - /* This converts PTR, a pointer into one of the search strings `string1' and `string2' into an offset from the beginning of that string. */ #define POINTER_TO_OFFSET(ptr) \ @@ -3783,14 +3785,10 @@ to actually save any registers when none are active. */ #define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) - /* Matching routines. */ - #ifndef emacs /* Emacs never uses this. */ /* re_match is like re_match_2 except it takes only a single string. */ - -int -re_match (bufp, string, size, pos, regs) + int re_match (bufp, string, size, pos, regs) struct re_pattern_buffer *bufp; const char *string; int size, pos; @@ -3809,18 +3807,18 @@ weak_alias (__re_match, re_match) # endif #endif /* not emacs */ - static boolean group_match_null_string_p _RE_ARGS ((unsigned char **p, unsigned char *end, + register_info_type * + reg_info)); + static boolean alt_match_null_string_p + _RE_ARGS ((unsigned char *p, unsigned char *end, register_info_type *reg_info)); -static boolean alt_match_null_string_p _RE_ARGS ((unsigned char *p, - unsigned char *end, + static boolean common_op_match_null_string_p + _RE_ARGS ((unsigned char **p, unsigned char *end, register_info_type *reg_info)); -static boolean common_op_match_null_string_p _RE_ARGS ((unsigned char **p, - unsigned char *end, - register_info_type *reg_info)); -static int bcmp_translate _RE_ARGS ((const char *s1, const char *s2, - int len, char *translate)); + static int bcmp_translate + _RE_ARGS ((const char *s1, const char *s2, int len, char *translate)); /* re_match_2 matches the compiled pattern in BUFP against the the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 @@ -3835,8 +3833,7 @@ failure stack overflowing). Otherwise, we return the length of the matched substring. */ -int -re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) + int re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; @@ -3860,7 +3857,8 @@ /* This is a separate function so that we can force an alloca cleanup afterwards. */ static int -re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) + re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, + stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; @@ -4261,8 +4259,7 @@ DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); mcnt = d - pos - (MATCHING_IN_FIRST_STRING - ? string1 - : string2 - size1); + ? string1 : string2 - size1); DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); @@ -4308,7 +4305,8 @@ do { PREFETCH (); - if (*d++ != (char) *p++) goto fail; + if (*d++ != (char) *p++) + goto fail; } while (--mcnt); } @@ -4351,7 +4349,8 @@ p += 1 + *p; - if (!not) goto fail; + if (!not) + goto fail; SET_REGS_MATCHED (); d++; @@ -4370,9 +4369,10 @@ /* Find out if this group can match the empty string. */ p1 = p; /* To send to group_match_null_string_p. */ - if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[*p]) - = group_match_null_string_p (&p1, pend, reg_info); + if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == + MATCH_NULL_UNSET_VALUE) + REG_MATCH_NULL_STRING_P (reg_info[*p]) = + group_match_null_string_p (&p1, pend, reg_info); /* Save the position in the string where we were the last time we were at this open-group operator in case the group is @@ -4380,8 +4380,7 @@ against `ab'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regstart[*p]) ? d : regstart[*p] - : regstart[*p]; + ? REG_UNSET (regstart[*p]) ? d : regstart[*p] : regstart[*p]; DEBUG_PRINT2 (" old_regstart: %d\n", POINTER_TO_OFFSET (old_regstart[*p])); @@ -4421,8 +4420,7 @@ against `aba'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regend[*p]) ? d : regend[*p] - : regend[*p]; + ? REG_UNSET (regend[*p]) ? d : regend[*p] : regend[*p]; DEBUG_PRINT2 (" old_regend: %d\n", POINTER_TO_OFFSET (old_regend[*p])); @@ -4473,8 +4471,7 @@ information for this group that we had before trying this last match. */ if ((!MATCHED_SOMETHING (reg_info[*p]) - || just_past_start_mem == p - 1) - && (p + 2) < pend) + || just_past_start_mem == p - 1) && (p + 2) < pend) { boolean is_a_jump_n = false; @@ -4575,15 +4572,18 @@ contents. */ while (d2 == dend2) { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; + if (dend2 == end_match_2) + break; + if (dend2 == regend[regno]) + break; /* End of string1 => advance to string2. */ d2 = string2; dend2 = regend[regno]; } /* At end of register contents => success */ - if (d2 == dend2) break; + if (d2 == dend2) + break; /* If necessary, advance to next segment in data. */ PREFETCH (); @@ -4619,7 +4619,8 @@ if (AT_STRINGS_BEG (d)) { - if (!bufp->not_bol) break; + if (!bufp->not_bol) + break; } else if (d[-1] == '\n' && bufp->newline_anchor) { @@ -4635,7 +4636,8 @@ if (AT_STRINGS_END (d)) { - if (!bufp->not_eol) break; + if (!bufp->not_eol) + break; } /* We have to ``prefetch'' the next character. */ @@ -4805,7 +4807,8 @@ } else if ((re_opcode_t) *p2 == exactn - || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) + || (bufp->newline_anchor + && (re_opcode_t) * p2 == endline)) { register unsigned char c = *p2 == (unsigned char) endline ? '\n' : p2[2]; @@ -4882,8 +4885,7 @@ /* We win if the charset inside the loop has no overlap with the one after the loop. */ for (idx = 0; - idx < (int) p2[1] && idx < (int) p1[4]; - idx++) + idx < (int) p2[1] && idx < (int) p1[4]; idx++) if ((p2[2 + idx] & p1[5 + idx]) != 0) break; @@ -5006,7 +5008,8 @@ #ifdef _LIBC DEBUG_PRINT2 (" Setting two bytes from %p to no_op.\n", p+2); #else - DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); + DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", + p + 2); #endif p[2] = (unsigned char) no_op; p[3] = (unsigned char) no_op; @@ -5313,8 +5316,7 @@ is, including the ending `jump_past_alt' and its number. */ - if (!alt_match_null_string_p (p1, p1 + mcnt - 3, - reg_info)) + if (!alt_match_null_string_p (p1, p1 + mcnt - 3, reg_info)) return false; /* Move to right after this alternative, including the @@ -5444,7 +5446,8 @@ /* Have to set this here in case we're checking a group which contains a group and a back reference to it. */ - if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) + if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == + MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; if (!ret) @@ -5506,7 +5509,8 @@ register const unsigned char *p2 = (const unsigned char *) s2; while (len) { - if (translate[*p1++] != translate[*p2++]) return 1; + if (translate[*p1++] != translate[*p2++]) + return 1; len--; } return 0; @@ -5552,12 +5556,9 @@ #ifdef _LIBC weak_alias (__re_compile_pattern, re_compile_pattern) #endif - /* Entry points compatible with 4.2 BSD regex library. We don't define them unless specifically requested. */ - #if defined _REGEX_RE_COMP || defined _LIBC - /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; @@ -5718,7 +5719,8 @@ /* POSIX doesn't distinguish between an unmatched open-group and an unmatched close-group: both are REG_EPAREN. */ - if (ret == REG_ERPAREN) ret = REG_EPAREN; + if (ret == REG_ERPAREN) + ret = REG_EPAREN; if (ret == REG_NOERROR && preg->fastmap) { @@ -5753,9 +5755,7 @@ string; if REG_NOTEOL is set, then $ does not match at the end. We return 0 if we find a match and REG_NOMATCH if not. */ - -int -regexec (preg, string, nmatch, pmatch, eflags) + int regexec (preg, string, nmatch, pmatch, eflags) const regex_t *preg; const char *string; size_t nmatch; @@ -5864,12 +5864,8 @@ #ifdef _LIBC weak_alias (__regerror, regerror) #endif - - /* Free dynamically allocated space used by PREG. */ - -void -regfree (preg) + void regfree (preg) regex_t *preg; { if (preg->buffer != NULL) diff -Naur quagga-0.99.9/lib/regex-gnu.h quagga-0.99.9-af/lib/regex-gnu.h --- quagga-0.99.9/lib/regex-gnu.h 2002-12-13 12:15:29.000000000 -0800 +++ quagga-0.99.9-af/lib/regex-gnu.h 2008-12-03 13:42:15.000000000 -0800 @@ -25,7 +25,8 @@ /* Allow the use in C++ code. */ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif /* POSIX says that must be included (by the caller) before @@ -454,7 +455,8 @@ /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); + extern int re_compile_fastmap + _RE_ARGS ((struct re_pattern_buffer * buffer)); /* Search in the string STRING (with length LENGTH) for the pattern diff -Naur quagga-0.99.9/lib/routemap.c quagga-0.99.9-af/lib/routemap.c --- quagga-0.99.9/lib/routemap.c 2007-05-02 08:28:32.000000000 -0700 +++ quagga-0.99.9-af/lib/routemap.c 2008-12-03 13:42:15.000000000 -0800 @@ -67,11 +67,9 @@ static struct route_map_list route_map_master = { NULL, NULL, NULL, NULL }; static void -route_map_rule_delete (struct route_map_rule_list *, - struct route_map_rule *); +route_map_rule_delete (struct route_map_rule_list *, struct route_map_rule *); -static void -route_map_index_delete (struct route_map_index *, int); +static void route_map_index_delete (struct route_map_index *, int); /* New route map allocation. Please note route map's name must be specified. */ @@ -334,8 +332,7 @@ struct route_map_index *index; for (index = map->head; index; index = index->next) - if ((index->type == type || type == RMAP_ANY) - && index->pref == pref) + if ((index->type == type || type == RMAP_ANY) && index->pref == pref) return index; return NULL; } @@ -386,8 +383,7 @@ /* Execute event hook. */ if (route_map_master.event_hook) - (*route_map_master.event_hook) (RMAP_EVENT_INDEX_ADDED, - map->name); + (*route_map_master.event_hook) (RMAP_EVENT_INDEX_ADDED, map->name); return index; } @@ -574,8 +570,7 @@ if (route_map_master.event_hook) (*route_map_master.event_hook) (replaced ? RMAP_EVENT_MATCH_REPLACED: - RMAP_EVENT_MATCH_ADDED, - index->map->name); + RMAP_EVENT_MATCH_ADDED, index->map->name); return 0; } @@ -661,8 +656,7 @@ if (route_map_master.event_hook) (*route_map_master.event_hook) (replaced ? RMAP_EVENT_SET_REPLACED: - RMAP_EVENT_SET_ADDED, - index->map->name); + RMAP_EVENT_SET_ADDED, index->map->name); return 0; } @@ -944,16 +938,14 @@ no_route_map_all_cmd, "no route-map WORD", NO_STR - "Create route-map or enter route-map command mode\n" - "Route map tag\n") + "Create route-map or enter route-map command mode\n" "Route map tag\n") { struct route_map *map; map = route_map_lookup_by_name (argv[0]); if (map == NULL) { - vty_out (vty, "%% Could not find route-map %s%s", - argv[0], VTY_NEWLINE); + vty_out (vty, "%% Could not find route-map %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } @@ -1007,8 +999,7 @@ map = route_map_lookup_by_name (argv[0]); if (map == NULL) { - vty_out (vty, "%% Could not find route-map %s%s", - argv[0], VTY_NEWLINE); + vty_out (vty, "%% Could not find route-map %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } @@ -1033,9 +1024,7 @@ DEFUN (rmap_onmatch_next, rmap_onmatch_next_cmd, - "on-match next", - "Exit policy on matches\n" - "Next clause\n") + "on-match next", "Exit policy on matches\n" "Next clause\n") { struct route_map_index *index; @@ -1049,10 +1038,7 @@ DEFUN (no_rmap_onmatch_next, no_rmap_onmatch_next_cmd, - "no on-match next", - NO_STR - "Exit policy on matches\n" - "Next clause\n") + "no on-match next", NO_STR "Exit policy on matches\n" "Next clause\n") { struct route_map_index *index; @@ -1067,9 +1053,7 @@ DEFUN (rmap_onmatch_goto, rmap_onmatch_goto_cmd, "on-match goto <1-65535>", - "Exit policy on matches\n" - "Goto Clause number\n" - "Number\n") + "Exit policy on matches\n" "Goto Clause number\n" "Number\n") { struct route_map_index *index = vty->index; int d = 0; @@ -1084,8 +1068,7 @@ if (d <= index->pref) { /* Can't allow you to do that, Dave */ - vty_out (vty, "can't jump backwards in route-maps%s", - VTY_NEWLINE); + vty_out (vty, "can't jump backwards in route-maps%s", VTY_NEWLINE); return CMD_WARNING; } else @@ -1100,9 +1083,7 @@ DEFUN (no_rmap_onmatch_goto, no_rmap_onmatch_goto_cmd, "no on-match goto", - NO_STR - "Exit policy on matches\n" - "Goto Clause number\n") + NO_STR "Exit policy on matches\n" "Goto Clause number\n") { struct route_map_index *index; @@ -1123,9 +1104,7 @@ ALIAS (no_rmap_onmatch_goto, no_rmap_continue_cmd, "no continue", - NO_STR - "Continue on a different entry within the route-map\n") - + NO_STR "Continue on a different entry within the route-map\n") /* GNU Zebra compatible */ ALIAS (rmap_onmatch_goto, rmap_continue_seq_cmd, @@ -1143,9 +1122,7 @@ DEFUN (rmap_show_name, rmap_show_name_cmd, "show route-map [WORD]", - SHOW_STR - "route-map information\n" - "route-map name\n") + SHOW_STR "route-map information\n" "route-map name\n") { const char *name = NULL; if (argc) @@ -1179,9 +1156,7 @@ DEFUN (no_rmap_call, no_rmap_call_cmd, - "no call", - NO_STR - "Jump to another Route-Map after match+set\n") + "no call", NO_STR "Jump to another Route-Map after match+set\n") { struct route_map_index *index; @@ -1199,8 +1174,7 @@ DEFUN (rmap_description, rmap_description_cmd, "description .LINE", - "Route-map comment\n" - "Comment describing this route-map rule\n") + "Route-map comment\n" "Comment describing this route-map rule\n") { struct route_map_index *index; @@ -1216,9 +1190,7 @@ DEFUN (no_rmap_description, no_rmap_description_cmd, - "no description", - NO_STR - "Route-map comment\n") + "no description", NO_STR "Route-map comment\n") { struct route_map_index *index; @@ -1252,21 +1224,18 @@ vty_out (vty, "route-map %s %s %d%s", map->name, - route_map_type_str (index->type), - index->pref, VTY_NEWLINE); + route_map_type_str (index->type), index->pref, VTY_NEWLINE); if (index->description) vty_out (vty, " description %s%s", index->description, VTY_NEWLINE); for (rule = index->match_list.head; rule; rule = rule->next) vty_out (vty, " match %s %s%s", rule->cmd->str, - rule->rule_str ? rule->rule_str : "", - VTY_NEWLINE); + rule->rule_str ? rule->rule_str : "", VTY_NEWLINE); for (rule = index->set_list.head; rule; rule = rule->next) vty_out (vty, " set %s %s%s", rule->cmd->str, - rule->rule_str ? rule->rule_str : "", - VTY_NEWLINE); + rule->rule_str ? rule->rule_str : "", VTY_NEWLINE); if (index->nextrm) vty_out (vty, " call %s%s", index->nextrm, VTY_NEWLINE); if (index->exitpolicy == RMAP_GOTO) @@ -1280,8 +1249,7 @@ } /* Route map node structure. */ -struct cmd_node rmap_node = -{ +struct cmd_node rmap_node = { RMAP_NODE, "%s(config-route-map)# ", 1 diff -Naur quagga-0.99.9/lib/routemap.h quagga-0.99.9-af/lib/routemap.h --- quagga-0.99.9/lib/routemap.h 2007-05-02 08:28:32.000000000 -0700 +++ quagga-0.99.9-af/lib/routemap.h 2008-12-03 13:42:15.000000000 -0800 @@ -166,13 +166,11 @@ /* Add route-map set statement to the route map. */ extern int route_map_add_set (struct route_map_index *index, - const char *set_name, - const char *set_arg); + const char *set_name, const char *set_arg); /* Delete route map set rule. */ extern int route_map_delete_set (struct route_map_index *index, - const char *set_name, - const char *set_arg); + const char *set_name, const char *set_arg); /* Install rule command to the match list. */ extern void route_map_install_match (struct route_map_rule_cmd *cmd); @@ -191,6 +189,7 @@ extern void route_map_add_hook (void (*func) (const char *)); extern void route_map_delete_hook (void (*func) (const char *)); -extern void route_map_event_hook (void (*func) (route_map_event_t, const char *)); +extern void +route_map_event_hook (void (*func) (route_map_event_t, const char *)); #endif /* _ZEBRA_ROUTEMAP_H */ diff -Naur quagga-0.99.9/lib/route_types.h quagga-0.99.9-af/lib/route_types.h --- quagga-0.99.9/lib/route_types.h 2006-06-27 03:43:51.000000000 -0700 +++ quagga-0.99.9-af/lib/route_types.h 2008-12-03 13:42:15.000000000 -0800 @@ -38,24 +38,29 @@ "Border Gateway Protocol (BGP)\n" /* ospfd */ + #define QUAGGA_REDIST_STR_OSPFD \ -"(kernel|connected|static|rip|isis|bgp)" +"(kernel|connected|static|rip|ospf|ospf6|isis|bgp)" #define QUAGGA_REDIST_HELP_STR_OSPFD \ "Kernel routes (not installed via the zebra RIB)\n" \ "Connected routes (directly attached subnet or host)\n" \ "Statically configured routes\n" \ "Routing Information Protocol (RIP)\n" \ + "Open Shortest Path First v2 (OSPFv2)\n" \ + "Open Shortest Path First v3 (OSPFv3)\n" \ "Intermediate System to Intermediate System (IS-IS)\n" \ "Border Gateway Protocol (BGP)\n" /* ospf6d */ #define QUAGGA_REDIST_STR_OSPF6D \ -"(kernel|connected|static|ripng|isis|bgp)" +"(kernel|connected|static|ripng|ospf|ospf6|isis|bgp)" #define QUAGGA_REDIST_HELP_STR_OSPF6D \ "Kernel routes (not installed via the zebra RIB)\n" \ "Connected routes (directly attached subnet or host)\n" \ "Statically configured routes\n" \ "Routing Information Protocol next-generation (IPv6) (RIPng)\n" \ + "Open Shortest Path First v2 (OSPFv2)\n" \ + "Open Shortest Path First v3 (OSPFv3)\n" \ "Intermediate System to Intermediate System (IS-IS)\n" \ "Border Gateway Protocol (BGP)\n" diff -Naur quagga-0.99.9/lib/sigevent.c quagga-0.99.9-af/lib/sigevent.c --- quagga-0.99.9/lib/sigevent.c 2005-05-03 11:02:06.000000000 -0700 +++ quagga-0.99.9-af/lib/sigevent.c 2008-12-03 13:42:15.000000000 -0800 @@ -130,7 +130,8 @@ int i; sigm = THREAD_ARG (t); - sigm->t = thread_add_timer (sigm->t->master, quagga_signal_timer, &sigmaster, + sigm->t = + thread_add_timer (sigm->t->master, quagga_signal_timer, &sigmaster, QUAGGA_SIGNAL_TIMER_INTERVAL); return quagga_sigevent_process (); } @@ -148,11 +149,14 @@ sig.sa_handler = &quagga_signal_handler; sigfillset (&sig.sa_mask); sig.sa_flags = 0; - if (signo == SIGALRM) { + if (signo == SIGALRM) + { #ifdef SA_INTERRUPT sig.sa_flags |= SA_INTERRUPT; /* SunOS */ #endif - } else { + } + else + { #ifdef SA_RESTART sig.sa_flags |= SA_RESTART; #endif /* SA_RESTART */ @@ -185,10 +189,10 @@ #endif /* SA_SIGINFO */ -static void __attribute__ ((noreturn)) -exit_handler(int signo +static void __attribute__ ((noreturn)) exit_handler (int signo #ifdef SA_SIGINFO - , siginfo_t *siginfo, void *context + , siginfo_t * siginfo, + void *context #endif ) { @@ -200,10 +204,10 @@ _exit(128+signo); } -static void __attribute__ ((noreturn)) -core_handler(int signo +static void __attribute__ ((noreturn)) core_handler (int signo #ifdef SA_SIGINFO - , siginfo_t *siginfo, void *context + , siginfo_t * siginfo, + void *context #endif ) { @@ -257,7 +261,8 @@ static const int ignore_signals[] = { SIGPIPE, }; - static const struct { + static const struct + { const int *sigs; u_int nsigs; void (*handler)(int signo @@ -265,11 +270,20 @@ , siginfo_t *info, void *context #endif ); - } sigmap[] = { - { core_signals, sizeof(core_signals)/sizeof(core_signals[0]), core_handler}, - { exit_signals, sizeof(exit_signals)/sizeof(exit_signals[0]), exit_handler}, - { ignore_signals, sizeof(ignore_signals)/sizeof(ignore_signals[0]), NULL}, - }; + } sigmap[] = + { + { + core_signals, sizeof (core_signals) / sizeof (core_signals[0]), + core_handler} + , + { + exit_signals, sizeof (exit_signals) / sizeof (exit_signals[0]), + exit_handler} + , + { + ignore_signals, sizeof (ignore_signals) / sizeof (ignore_signals[0]), + NULL} + ,}; u_int i; for (i = 0; i < sizeof(sigmap)/sizeof(sigmap[0]); i++) diff -Naur quagga-0.99.9/lib/smux.c quagga-0.99.9-af/lib/smux.c --- quagga-0.99.9/lib/smux.c 2007-05-09 13:59:34.000000000 -0700 +++ quagga-0.99.9-af/lib/smux.c 2008-12-03 13:42:15.000000000 -0800 @@ -40,7 +40,8 @@ #define min(A,B) ((A) < (B) ? (A) : (B)) -enum smux_event {SMUX_SCHEDULE, SMUX_CONNECT, SMUX_READ}; +enum smux_event +{ SMUX_SCHEDULE, SMUX_CONNECT, SMUX_READ }; void smux_event (enum smux_event, int); @@ -71,8 +72,7 @@ int fail = 0; /* SMUX node. */ -struct cmd_node smux_node = -{ +struct cmd_node smux_node = { SMUX_NODE, "" /* SMUX has no interface. */ }; @@ -252,7 +252,8 @@ sockopt_reuseaddr (sock); sockopt_reuseport (sock); - ret = connect (sock, (struct sockaddr *) &serv, sizeof (struct sockaddr_in)); + ret = + connect (sock, (struct sockaddr *) &serv, sizeof (struct sockaddr_in)); if (ret < 0) { close (sock); @@ -308,15 +309,15 @@ h2 = ptr; /* Place holder h2 for one variable */ ptr = asn_build_sequence (ptr, &len, - (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), - 0); + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), 0); h2e = ptr; ptr = snmp_build_var_op (ptr, objid, &objid_len, val_type, arg_len, arg, &len); /* Now variable size is known, fill in size */ - asn_build_sequence(h2,&length,(u_char)(ASN_SEQUENCE|ASN_CONSTRUCTOR),ptr-h2e); + asn_build_sequence (h2, &length, (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), + ptr - h2e); /* Fill in size of whole sequence */ asn_build_sequence(h1,&length,(u_char)SMUX_GETRSP,ptr-h1e); @@ -329,9 +330,7 @@ char * smux_var (char *ptr, size_t len, oid objid[], size_t *objid_len, - size_t *var_val_len, - u_char *var_val_type, - void **var_value) + size_t * var_val_len, u_char * var_val_type, void **var_value) { u_char type; u_char val_type; @@ -689,8 +688,9 @@ if (debug_smux) zlog_debug ("SMUX SET(%s) message parse: len %ld", - (RESERVE1 == action) ? "RESERVE1" : ((FREE == action) ? "FREE" : "COMMIT"), - len); + (RESERVE1 == + action) ? "RESERVE1" : ((FREE == + action) ? "FREE" : "COMMIT"), len); /* Parse SET message header. */ ptr = smux_parse_get_header (ptr, &len, &reqid); @@ -810,11 +810,13 @@ if (sout_save_len > 0) { - smux_parse_set (sout_save_buff, sout_save_len, rollback ? FREE : COMMIT); + smux_parse_set (sout_save_buff, sout_save_len, + rollback ? FREE : COMMIT); sout_save_len = 0; } else - zlog_warn ("SMUX_SOUT sout_save_len=%d - invalid", (int) sout_save_len); + zlog_warn ("SMUX_SOUT sout_save_len=%d - invalid", + (int) sout_save_len); if (len_income > 3) { @@ -1043,14 +1045,13 @@ /* Timeticks timestamp. */ val = 0; ptr = asn_build_unsigned_int (ptr, &len, - (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_TIMETICKS), - &val, sizeof (val)); + (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | + ASN_TIMETICKS), &val, sizeof (val)); /* Variables. */ h1 = ptr; ptr = asn_build_sequence (ptr, &len, - (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), - 0); + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), 0); /* Iteration for each objects. */ @@ -1075,7 +1076,8 @@ else { oid_copy (oid, name, namelen); - oid_copy (oid + namelen, trapobj[i].name, trapobj[i].namelen * (-1)); + oid_copy (oid + namelen, trapobj[i].name, + trapobj[i].namelen * (-1)); oid_len = namelen + trapobj[i].namelen * (-1) ; } @@ -1106,8 +1108,7 @@ /* Now variable size is known, fill in size */ asn_build_sequence(h1, &length, - (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), - ptr - h1e); + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), ptr - h1e); /* Fill in size of whole sequence */ len = BUFSIZ; @@ -1147,18 +1148,21 @@ /* Priority. */ priority = -1; ptr = asn_build_int (ptr, &len, - (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - &priority, sizeof (priority)); + (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | + ASN_INTEGER), &priority, + sizeof (priority)); /* Operation. */ operation = 2; /* Register R/W */ ptr = asn_build_int (ptr, &len, - (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - &operation, sizeof (operation)); + (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | + ASN_INTEGER), &operation, + sizeof (operation)); if (debug_smux) { - smux_oid_dump ("SMUX register oid", subtree->name, subtree->name_len); + smux_oid_dump ("SMUX register oid", subtree->name, + subtree->name_len); zlog_debug ("SMUX register priority: %ld", priority); zlog_debug ("SMUX register operation: %ld", operation); } @@ -1209,7 +1213,8 @@ ret = smux_register (smux_sock); if (ret < 0) { - zlog_warn ("SMUX register message send failed: %s", safe_strerror (errno)); + zlog_warn ("SMUX register message send failed: %s", + safe_strerror (errno)); close (smux_sock); smux_sock = -1; if (++fail < SMUX_MAX_FAILURE) @@ -1353,8 +1358,8 @@ } int -smux_header_generic (struct variable *v, oid *name, size_t *length, int exact, - size_t *var_len, WriteMethod **write_method) +smux_header_generic (struct variable *v, oid * name, size_t * length, + int exact, size_t * var_len, WriteMethod ** write_method) { oid fulloid[MAX_OID_LEN]; int ret; @@ -1401,8 +1406,7 @@ smux_peer_cmd, "smux peer OID", "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n" - "Object ID used in SMUX peering\n") + "SNMP MUX peer settings\n" "Object ID used in SMUX peering\n") { if (smux_peer_oid (vty, argv[0], NULL) == 0) { @@ -1418,8 +1422,7 @@ "smux peer OID PASSWORD", "SNMP MUX protocol settings\n" "SNMP MUX peer settings\n" - "SMUX peering object ID\n" - "SMUX peering password\n") + "SMUX peering object ID\n" "SMUX peering password\n") { if (smux_peer_oid (vty, argv[0], argv[1]) == 0) { @@ -1433,9 +1436,7 @@ DEFUN (no_smux_peer, no_smux_peer_cmd, "no smux peer", - NO_STR - "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n") + NO_STR "SNMP MUX protocol settings\n" "SNMP MUX peer settings\n") { smux_stop(); return smux_peer_default (); @@ -1455,11 +1456,8 @@ NO_STR "SNMP MUX protocol settings\n" "SNMP MUX peer settings\n" - "SMUX peering object ID\n" - "SMUX peering password\n") - -int -config_write_smux (struct vty *vty) + "SMUX peering object ID\n" "SMUX peering password\n") + int config_write_smux (struct vty *vty) { int first = 1; unsigned int i; @@ -1480,8 +1478,7 @@ /* Register subtree to smux master tree. */ void smux_register_mib (const char *descr, struct variable *var, - size_t width, int num, - oid name[], size_t namelen) + size_t width, int num, oid name[], size_t namelen) { struct subtree *tree; diff -Naur quagga-0.99.9/lib/smux.h quagga-0.99.9-af/lib/smux.h --- quagga-0.99.9/lib/smux.h 2005-10-03 07:20:30.000000000 -0700 +++ quagga-0.99.9-af/lib/smux.h 2008-12-03 13:42:15.000000000 -0800 @@ -67,9 +67,7 @@ u_char var_val_type, size_t var_val_len, u_char *statP, - oid *name, - size_t length, - struct variable *v); + oid * name, size_t length, struct variable * v); typedef u_char *(FindVarMethod)(struct variable *v, oid *name, diff -Naur quagga-0.99.9/lib/sockopt.c quagga-0.99.9-af/lib/sockopt.c --- quagga-0.99.9/lib/sockopt.c 2007-08-22 09:22:54.000000000 -0700 +++ quagga-0.99.9-af/lib/sockopt.c 2008-12-03 13:42:15.000000000 -0800 @@ -72,8 +72,7 @@ void *ptr = NULL; for (cmsg = ZCMSG_FIRSTHDR(msgh); - cmsg != NULL; - cmsg = CMSG_NXTHDR(msgh, cmsg)) + cmsg != NULL; cmsg = CMSG_NXTHDR (msgh, cmsg)) if (cmsg->cmsg_level == level && cmsg->cmsg_type) return (ptr = CMSG_DATA(cmsg)); @@ -90,7 +89,8 @@ #ifdef IPV6_RECVPKTINFO /*2292bis-01*/ ret = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)); if (ret < 0) - zlog_warn ("can't setsockopt IPV6_RECVPKTINFO : %s", safe_strerror (errno)); + zlog_warn ("can't setsockopt IPV6_RECVPKTINFO : %s", + safe_strerror (errno)); #else /*RFC2292*/ ret = setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &val, sizeof(val)); if (ret < 0) @@ -121,7 +121,8 @@ { int ret; - ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &val, sizeof(val)); + ret = + setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &val, sizeof (val)); if (ret < 0) zlog_warn ("can't setsockopt IPV6_MULTICAST_HOPS"); return ret; @@ -133,7 +134,8 @@ { int ret; - ret = setsockopt(sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &val, sizeof(val)); + ret = + setsockopt (sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &val, sizeof (val)); if (ret < 0) zlog_warn ("can't setsockopt IPV6_UNICAST_HOPS"); return ret; @@ -145,7 +147,8 @@ int ret; #ifdef IPV6_RECVHOPLIMIT /*2292bis-01*/ - ret = setsockopt (sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &val, sizeof(val)); + ret = + setsockopt (sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &val, sizeof (val)); if (ret < 0) zlog_warn ("can't setsockopt IPV6_RECVHOPLIMIT"); #else /*RFC2292*/ @@ -206,12 +209,11 @@ setsockopt_multicast_ipv4(int sock, int optname, struct in_addr if_addr /* required */, - unsigned int mcast_addr, - unsigned int ifindex /* optional: if non-zero, may be + unsigned int mcast_addr, unsigned int ifindex /* optional: if non-zero, may be used instead of if_addr */) { -#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX +#ifdef GNU_LINUX /* This is better because it uses ifindex directly */ struct ip_mreqn mreqn; int ret; @@ -233,7 +235,8 @@ ret = setsockopt(sock, IPPROTO_IP, optname, (void *)&mreqn, sizeof(mreqn)); - if ((ret < 0) && (optname == IP_ADD_MEMBERSHIP) && (errno == EADDRINUSE)) + if ((ret < 0) && (optname == IP_ADD_MEMBERSHIP) + && (errno == EADDRINUSE)) { /* see above: handle possible problem when interface comes back up */ char buf[2][INET_ADDRSTRLEN]; @@ -263,6 +266,95 @@ /* #elif defined(BOGON_NIX) && EXAMPLE_VERSION_CODE > -100000 */ /* Add your favourite OS here! */ +#elif __FreeBSD__ == 7 + + struct ip_mreqn mreqn; + struct group_req gr; + struct sockaddr_in *si; + int ret; + + switch (optname) + { + case IP_MULTICAST_IF: + memset (&mreqn, 0, sizeof (mreqn)); + + if (mcast_addr) + mreqn.imr_multiaddr.s_addr = mcast_addr; + + if (ifindex) + mreqn.imr_ifindex = ifindex; + else + mreqn.imr_address = if_addr; + + ret = setsockopt (sock, IPPROTO_IP, optname, + (void *) &mreqn, sizeof (mreqn)); + return ret; + break; + + case IP_ADD_MEMBERSHIP: + case IP_DROP_MEMBERSHIP: + if (ifindex) + { + memset (&gr, 0, sizeof (gr)); + si = (struct sockaddr_in *) &gr.gr_group; + gr.gr_interface = ifindex; + if (mcast_addr) + si->sin_family = AF_INET; + si->sin_len = sizeof (struct sockaddr_in); + si->sin_addr.s_addr = mcast_addr; + if (optname == IP_ADD_MEMBERSHIP) + ret = setsockopt (sock, IPPROTO_IP, MCAST_JOIN_GROUP, + (void *) &gr, sizeof (gr)); + else + ret = setsockopt (sock, IPPROTO_IP, MCAST_LEAVE_GROUP, + (void *) &gr, sizeof (gr)); + } + else + { + memset (&mreqn, 0, sizeof (mreqn)); + if (mcast_addr) + mreqn.imr_multiaddr.s_addr = mcast_addr; + mreqn.imr_address = if_addr; + + ret = setsockopt (sock, IPPROTO_IP, optname, + (void *) &mreqn, sizeof (mreqn)); + } + if ((ret < 0) && (optname == IP_ADD_MEMBERSHIP) + && (errno == EADDRINUSE)) + { + /* see above: handle possible problem when interface comes back up */ + char buf[2][INET_ADDRSTRLEN]; + zlog_info ("setsockopt_multicast_ipv4 attempting to drop and " + "re-add (fd %d, ifaddr %s, mcast %s, ifindex %u)", + sock, + inet_ntop (AF_INET, &if_addr, buf[0], sizeof (buf[0])), + inet_ntop (AF_INET, &mcast_addr, buf[1], + sizeof (buf[1])), ifindex); + if (ifindex) + { + setsockopt (sock, IPPROTO_IP, MCAST_LEAVE_GROUP, + (void *) &gr, sizeof (gr)); + ret = setsockopt (sock, IPPROTO_IP, MCAST_JOIN_GROUP, + (void *) &gr, sizeof (gr)); + } + else + { + setsockopt (sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, + (void *) &mreqn, sizeof (mreqn)); + ret = setsockopt (sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, + (void *) &mreqn, sizeof (mreqn)); + } + } + return ret; + break; + + default: + /* Can out and give an understandable error */ + errno = EINVAL; + return -1; + break; + } + #else /* #if OS_TYPE */ /* standard BSD API */ @@ -289,8 +381,10 @@ mreq.imr_multiaddr.s_addr = mcast_addr; mreq.imr_interface = m; - ret = setsockopt (sock, IPPROTO_IP, optname, (void *)&mreq, sizeof(mreq)); - if ((ret < 0) && (optname == IP_ADD_MEMBERSHIP) && (errno == EADDRINUSE)) + ret = + setsockopt (sock, IPPROTO_IP, optname, (void *) &mreq, sizeof (mreq)); + if ((ret < 0) && (optname == IP_ADD_MEMBERSHIP) + && (errno == EADDRINUSE)) { /* see above: handle possible problem when interface comes back up */ char buf[2][INET_ADDRSTRLEN]; @@ -324,13 +418,15 @@ int ret; #if defined (IP_PKTINFO) - if ((ret = setsockopt (sock, IPPROTO_IP, IP_PKTINFO, &val, sizeof (val))) < 0) - zlog_warn ("Can't set IP_PKTINFO option for fd %d to %d: %s", - sock,val,safe_strerror(errno)); + if ((ret = + setsockopt (sock, IPPROTO_IP, IP_PKTINFO, &val, sizeof (val))) < 0) + zlog_warn ("Can't set IP_PKTINFO option for fd %d to %d: %s", sock, val, + safe_strerror (errno)); #elif defined (IP_RECVIF) - if ((ret = setsockopt (sock, IPPROTO_IP, IP_RECVIF, &val, sizeof (val))) < 0) - zlog_warn ("Can't set IP_RECVIF option for fd %d to %d: %s", - sock,val,safe_strerror(errno)); + if ((ret = + setsockopt (sock, IPPROTO_IP, IP_RECVIF, &val, sizeof (val))) < 0) + zlog_warn ("Can't set IP_RECVIF option for fd %d to %d: %s", sock, val, + safe_strerror (errno)); #else #warning "Neither IP_PKTINFO nor IP_RECVIF is available." #warning "Will not be able to receive link info." diff -Naur quagga-0.99.9/lib/sockunion.c quagga-0.99.9-af/lib/sockunion.c --- quagga-0.99.9/lib/sockunion.c 2007-05-09 13:59:34.000000000 -0700 +++ quagga-0.99.9-af/lib/sockunion.c 2008-12-03 13:42:15.000000000 -0800 @@ -42,8 +42,16 @@ switch (c) { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': val = (val * base) + (c - '0'); break; case '.': @@ -58,7 +66,8 @@ default: return 0; } - } while (*cp++) ; + } + while (*cp++); if (dots < 3) addr <<= 8 * (3 - dots); @@ -236,7 +245,8 @@ sock = socket (su->sa.sa_family, SOCK_STREAM, 0); if (sock < 0) { - zlog (NULL, LOG_WARNING, "Can't make socket : %s", safe_strerror (errno)); + zlog (NULL, LOG_WARNING, "Can't make socket : %s", + safe_strerror (errno)); return -1; } @@ -307,7 +317,8 @@ #ifdef HAVE_IPV6 case AF_INET6: snprintf (buf, SU_ADDRSTRLEN, "%s", - inet_ntop (AF_INET6, &(su->sin6.sin6_addr), buf, SU_ADDRSTRLEN)); + inet_ntop (AF_INET6, &(su->sin6.sin6_addr), buf, + SU_ADDRSTRLEN)); break; #endif /* HAVE_IPV6 */ default: @@ -459,7 +470,8 @@ (void *) &on, sizeof (on)); if (ret < 0) { - zlog (NULL, LOG_WARNING, "can't set sockopt SO_REUSEADDR to socket %d", sock); + zlog (NULL, LOG_WARNING, "can't set sockopt SO_REUSEADDR to socket %d", + sock); return -1; } return 0; @@ -476,7 +488,8 @@ (void *) &on, sizeof (on)); if (ret < 0) { - zlog (NULL, LOG_WARNING, "can't set sockopt SO_REUSEPORT to socket %d", sock); + zlog (NULL, LOG_WARNING, "can't set sockopt SO_REUSEPORT to socket %d", + sock); return -1; } return 0; @@ -501,7 +514,8 @@ (void *) &ttl, sizeof (int)); if (ret < 0) { - zlog (NULL, LOG_WARNING, "can't set sockopt IP_TTL %d to socket %d", ttl, sock); + zlog (NULL, LOG_WARNING, "can't set sockopt IP_TTL %d to socket %d", + ttl, sock); return -1; } return 0; @@ -514,8 +528,9 @@ (void *) &ttl, sizeof (int)); if (ret < 0) { - zlog (NULL, LOG_WARNING, "can't set sockopt IPV6_UNICAST_HOPS %d to socket %d", - ttl, sock); + zlog (NULL, LOG_WARNING, + "can't set sockopt IPV6_UNICAST_HOPS %d to socket %d", ttl, + sock); return -1; } return 0; @@ -662,8 +677,7 @@ } /* Print sockunion structure */ -static void __attribute__ ((unused)) -sockunion_print (union sockunion *su) +static void __attribute__ ((unused)) sockunion_print (union sockunion *su) { if (su == NULL) return; @@ -731,7 +745,8 @@ if (su1->sa.sa_family == AF_INET) { - if (ntohl (su1->sin.sin_addr.s_addr) == ntohl (su2->sin.sin_addr.s_addr)) + if (ntohl (su1->sin.sin_addr.s_addr) == + ntohl (su2->sin.sin_addr.s_addr)) return 0; if (ntohl (su1->sin.sin_addr.s_addr) > ntohl (su2->sin.sin_addr.s_addr)) return 1; diff -Naur quagga-0.99.9/lib/sockunion.h quagga-0.99.9-af/lib/sockunion.h --- quagga-0.99.9/lib/sockunion.h 2005-05-03 12:14:13.000000000 -0700 +++ quagga-0.99.9-af/lib/sockunion.h 2008-12-03 13:42:15.000000000 -0800 @@ -24,8 +24,10 @@ #define _ZEBRA_SOCKUNION_H #if 0 -union sockunion { - struct sockinet { +union sockunion +{ + struct sockinet + { u_char si_len; u_char si_family; u_short si_port; diff -Naur quagga-0.99.9/lib/str.c quagga-0.99.9-af/lib/str.c --- quagga-0.99.9/lib/str.c 2005-09-19 06:12:02.000000000 -0700 +++ quagga-0.99.9-af/lib/str.c 2008-12-03 13:42:15.000000000 -0800 @@ -49,7 +49,8 @@ { size_t len = strlen(s); size_t ret = len; - if (bufsize > 0) { + if (bufsize > 0) + { if (len >= bufsize) len = bufsize-1; memcpy(d, s, len); @@ -74,7 +75,8 @@ size_t len2 = strlen(s); size_t ret = len1 + len2; - if (len1 < bufsize - 1) { + if (len1 < bufsize - 1) + { if (len2 >= bufsize - len1) len2 = bufsize - len1 - 1; memcpy(d+len1, s, len2); @@ -89,7 +91,9 @@ strnlen(const char *s, size_t maxlen) { const char *p; - return (p = (const char *)memchr(s, '\0', maxlen)) ? (size_t)(p-s) : maxlen; + return (p = + (const char *) memchr (s, '\0', + maxlen)) ? (size_t) (p - s) : maxlen; } #endif diff -Naur quagga-0.99.9/lib/stream.c quagga-0.99.9-af/lib/stream.c --- quagga-0.99.9/lib/stream.c 2006-02-03 06:47:24.000000000 -0800 +++ quagga-0.99.9-af/lib/stream.c 2008-12-03 13:42:15.000000000 -0800 @@ -760,7 +760,8 @@ /* Error: was it transient (return -2) or fatal (return -1)? */ if (ERRNO_IO_RETRY(errno)) return -2; - zlog_warn("%s: read failed on fd %d: %s", __func__, fd, safe_strerror(errno)); + zlog_warn ("%s: read failed on fd %d: %s", __func__, fd, + safe_strerror (errno)); return -1; } @@ -792,7 +793,8 @@ /* Error: was it transient (return -2) or fatal (return -1)? */ if (ERRNO_IO_RETRY(errno)) return -2; - zlog_warn("%s: read failed on fd %d: %s", __func__, fd, safe_strerror(errno)); + zlog_warn ("%s: read failed on fd %d: %s", __func__, fd, + safe_strerror (errno)); return -1; } diff -Naur quagga-0.99.9/lib/stream.h quagga-0.99.9-af/lib/stream.h --- quagga-0.99.9/lib/stream.h 2006-01-10 18:01:10.000000000 -0800 +++ quagga-0.99.9-af/lib/stream.h 2008-12-03 13:42:15.000000000 -0800 @@ -25,6 +25,10 @@ #include "prefix.h" +#ifdef __cplusplus +#define new __quagga_new +#endif /* __cplusplus */ + /* * A stream is an arbitrary buffer, whose contents generally are assumed to * be in network order. @@ -218,4 +222,8 @@ extern void stream_fifo_clean (struct stream_fifo *fifo); extern void stream_fifo_free (struct stream_fifo *fifo); +#ifdef __cplusplus +#undef new +#endif /* __cplusplus */ + #endif /* _ZEBRA_STREAM_H */ diff -Naur quagga-0.99.9/lib/table.c quagga-0.99.9-af/lib/table.c --- quagga-0.99.9/lib/table.c 2005-05-03 10:11:25.000000000 -0700 +++ quagga-0.99.9-af/lib/table.c 2008-12-03 13:42:15.000000000 -0800 @@ -125,8 +125,7 @@ } /* Utility mask array. */ -static u_char maskbit[] = -{ +static u_char maskbit[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; @@ -220,8 +219,7 @@ } /* Dump routing table. */ -static void __attribute__ ((unused)) -route_dump_node (struct route_table *t) +static void __attribute__ ((unused)) route_dump_node (struct route_table *t) { struct route_node *node; char buf[46]; diff -Naur quagga-0.99.9/lib/thread.c quagga-0.99.9-af/lib/thread.c --- quagga-0.99.9/lib/thread.c 2006-08-26 23:40:36.000000000 -0700 +++ quagga-0.99.9-af/lib/thread.c 2008-12-03 13:42:15.000000000 -0800 @@ -30,6 +30,8 @@ #include "command.h" #include "sigevent.h" + + /* Recent absolute time of day */ struct timeval recent_time; static struct timeval last_recent_time; @@ -82,8 +84,7 @@ static long timeval_cmp (struct timeval a, struct timeval b) { - return (a.tv_sec == b.tv_sec - ? a.tv_usec - b.tv_usec : a.tv_sec - b.tv_sec); + return (a.tv_sec == b.tv_sec ? a.tv_usec - b.tv_usec : a.tv_sec - b.tv_sec); } static unsigned long @@ -240,8 +241,7 @@ } static inline void -vty_out_cpu_thread_history(struct vty* vty, - struct cpu_thread_history *a) +vty_out_cpu_thread_history (struct vty *vty, struct cpu_thread_history *a) { #ifdef HAVE_RUSAGE vty_out(vty, "%7ld.%03ld %9d %8ld %9ld %8ld %9ld", @@ -264,8 +264,7 @@ } static void -cpu_record_hash_print(struct hash_backet *bucket, - void *args[]) +cpu_record_hash_print (struct hash_backet *bucket, void *args[]) { struct cpu_thread_history *totals = args[0]; struct vty *vty = args[1]; @@ -307,8 +306,8 @@ #endif vty_out(vty, " Type Thread%s", VTY_NEWLINE); hash_iterate(cpu_record, - (void(*)(struct hash_backet*,void*))cpu_record_hash_print, - args); + (void (*)(struct hash_backet *, void *)) + cpu_record_hash_print, args); if (tmp.total_calls > 0) vty_out_cpu_thread_history(vty, &tmp); @@ -319,8 +318,7 @@ "show thread cpu [FILTER]", SHOW_STR "Thread information\n" - "Thread CPU usage\n" - "Display filter (rwtexb)\n") + "Thread CPU usage\n" "Display filter (rwtexb)\n") { int i = 0; unsigned char filter = 0xff; @@ -409,7 +407,8 @@ { if (cpu_record == NULL) cpu_record - = hash_create_size (1011, (unsigned int (*) (void *))cpu_record_hash_key, + = + hash_create_size (1011, (unsigned int (*)(void *)) cpu_record_hash_key, (int (*) (void *, void *))cpu_record_hash_cmp); return (struct thread_master *) XCALLOC (MTYPE_THREAD_MASTER, @@ -433,8 +432,7 @@ /* Add a new thread just before the point. */ static void thread_list_add_before (struct thread_list *list, - struct thread *point, - struct thread *thread) + struct thread *point, struct thread *thread) { thread->next = point; thread->prev = point->prev; @@ -594,7 +592,8 @@ /* Add new read thread. */ struct thread * funcname_thread_add_read (struct thread_master *m, - int (*func) (struct thread *), void *arg, int fd, const char* funcname) + int (*func) (struct thread *), void *arg, int fd, + const char *funcname) { struct thread *thread; @@ -617,7 +616,8 @@ /* Add new write thread. */ struct thread * funcname_thread_add_write (struct thread_master *m, - int (*func) (struct thread *), void *arg, int fd, const char* funcname) + int (*func) (struct thread *), void *arg, int fd, + const char *funcname) { struct thread *thread; @@ -716,8 +716,7 @@ struct thread * funcname_thread_add_background (struct thread_master *m, int (*func) (struct thread *), - void *arg, long delay, - const char *funcname) + void *arg, long delay, const char *funcname) { struct timeval trel; @@ -741,7 +740,8 @@ /* Add simple event thread. */ struct thread * funcname_thread_add_event (struct thread_master *m, - int (*func) (struct thread *), void *arg, int val, const char* funcname) + int (*func) (struct thread *), void *arg, int val, + const char *funcname) { struct thread *thread; @@ -973,7 +973,8 @@ } unsigned long -thread_consumed_time (RUSAGE_T *now, RUSAGE_T *start, unsigned long *cputime) +thread_consumed_time (RUSAGE_T * now, RUSAGE_T * start, + unsigned long *cputime) { #ifdef HAVE_RUSAGE /* This is 'user + sys' time. */ @@ -1085,9 +1086,7 @@ struct thread * funcname_thread_execute (struct thread_master *m, int (*func)(struct thread *), - void *arg, - int val, - const char* funcname) + void *arg, int val, const char *funcname) { struct thread dummy; diff -Naur quagga-0.99.9/lib/thread.h quagga-0.99.9-af/lib/thread.h --- quagga-0.99.9/lib/thread.h 2006-08-26 23:40:36.000000000 -0700 +++ quagga-0.99.9-af/lib/thread.h 2008-12-03 13:42:15.000000000 -0800 @@ -67,7 +67,8 @@ struct thread_master *master; /* pointer to the struct thread_master. */ int (*func) (struct thread *); /* event function */ void *arg; /* event argument */ - union { + union + { int val; /* second argument of the event. */ int fd; /* file descriptor in case of read/write. */ struct timeval sands; /* rest of time sands value. */ @@ -93,7 +94,8 @@ }; /* Clocks supported by Quagga */ -enum quagga_clkid { +enum quagga_clkid +{ QUAGGA_CLK_REALTIME = 0, /* ala gettimeofday() */ QUAGGA_CLK_MONOTONIC, /* monotonic, against an indeterminate base */ QUAGGA_CLK_REALTIME_STABILISED, /* like realtime, but non-decrementing */ @@ -172,15 +174,18 @@ int (*)(struct thread *), void *, long, const char*); extern struct thread *funcname_thread_add_timer_msec (struct thread_master *, - int (*)(struct thread *), - void *, long, const char*); + int (*)(struct thread + *), void *, + long, const char *); extern struct thread *funcname_thread_add_event (struct thread_master *, int (*)(struct thread *), void *, int, const char*); extern struct thread *funcname_thread_add_background (struct thread_master *, - int (*func)(struct thread *), + int (*func) (struct + thread *), void *arg, - long milliseconds_to_delay, + long + milliseconds_to_delay, const char *funcname); extern struct thread *funcname_thread_execute (struct thread_master *, int (*)(struct thread *), @@ -204,7 +209,8 @@ extern time_t quagga_time (time_t *); /* Returns elapsed real (wall clock) time. */ -extern unsigned long thread_consumed_time(RUSAGE_T *after, RUSAGE_T *before, +extern unsigned long thread_consumed_time (RUSAGE_T * after, + RUSAGE_T * before, unsigned long *cpu_time_elapsed); /* Global variable containing a recent result from gettimeofday. This can diff -Naur quagga-0.99.9/lib/vector.h quagga-0.99.9-af/lib/vector.h --- quagga-0.99.9/lib/vector.h 2005-05-03 12:17:01.000000000 -0700 +++ quagga-0.99.9-af/lib/vector.h 2008-12-03 13:42:15.000000000 -0800 @@ -23,6 +23,10 @@ #ifndef _ZEBRA_VECTOR_H #define _ZEBRA_VECTOR_H +#ifdef __cplusplus +#define vector __quagga_vector +#endif /* __cplusplus */ + /* struct for vector */ struct _vector { @@ -60,4 +64,8 @@ extern void *vector_lookup (vector, unsigned int); extern void *vector_lookup_ensure (vector, unsigned int); +#ifdef __cplusplus +#undef vector +#endif /* __cplusplus */ + #endif /* _ZEBRA_VECTOR_H */ diff -Naur quagga-0.99.9/lib/version.h quagga-0.99.9-af/lib/version.h --- quagga-0.99.9/lib/version.h 2007-09-07 09:56:18.000000000 -0700 +++ quagga-0.99.9-af/lib/version.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,43 +0,0 @@ -/* lib/version.h. Generated from version.h.in by configure. - * - * Quagga version - * Copyright (C) 1997, 1999 Kunihiro Ishiguro - * - * 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 _ZEBRA_VERSION_H -#define _ZEBRA_VERSION_H - -#define QUAGGA_PROGNAME "Quagga" - -#define QUAGGA_VERSION "0.99.9" - -#define ZEBRA_BUG_ADDRESS "http://bugzilla.quagga.net" - -#define QUAGGA_URL "http://www.quagga.net" - -#define QUAGGA_COPYRIGHT "Copyright 1996-2005 Kunihiro Ishiguro, et al." - -pid_t pid_output (const char *); - -#ifndef HAVE_DAEMON -int daemon(int, int); -#endif - -#endif /* _ZEBRA_VERSION_H */ diff -Naur quagga-0.99.9/lib/vty.c quagga-0.99.9-af/lib/vty.c --- quagga-0.99.9/lib/vty.c 2007-05-09 13:59:34.000000000 -0700 +++ quagga-0.99.9-af/lib/vty.c 2008-12-03 13:42:15.000000000 -0800 @@ -157,7 +157,8 @@ if (!ctl->already_rendered) { - ctl->len = quagga_timestamp(ctl->precision, ctl->buf, sizeof(ctl->buf)); + ctl->len = + quagga_timestamp (ctl->precision, ctl->buf, sizeof (ctl->buf)); ctl->already_rendered = 1; } if (ctl->len+1 >= sizeof(buf)) @@ -167,7 +168,8 @@ buf[len] = '\0'; if (level) - ret = snprintf(buf+len, sizeof(buf)-len, "%s: %s: ", level, proto_str); + ret = + snprintf (buf + len, sizeof (buf) - len, "%s: %s: ", level, proto_str); else ret = snprintf(buf+len, sizeof(buf)-len, "%s: ", proto_str); if ((ret < 0) || ((size_t)(len += ret) >= sizeof(buf))) @@ -235,8 +237,8 @@ { char *s; /* work backwards to ignore trailling isspace() */ - for (s = buf + strlen (buf); (s > buf) && isspace ((int)*(s - 1)); - s--); + for (s = buf + strlen (buf); + (s > buf) && isspace ((int) *(s - 1)); s--); *s = '\0'; vty_out (vty, "%s%s", buf, VTY_NEWLINE); } @@ -375,14 +377,16 @@ { if (vty->node == AUTH_NODE) { - vty_out (vty, "%% Bad passwords, too many failures!%s", VTY_NEWLINE); + vty_out (vty, "%% Bad passwords, too many failures!%s", + VTY_NEWLINE); vty->status = VTY_CLOSE; } else { /* AUTH_ENABLE_NODE */ vty->fail = 0; - vty_out (vty, "%% Bad enable passwords, too many failures!%s", VTY_NEWLINE); + vty_out (vty, "%% Bad enable passwords, too many failures!%s", + VTY_NEWLINE); vty->node = VIEW_NODE; } } @@ -441,7 +445,8 @@ vty_out (vty, "%% Ambiguous command.%s", VTY_NEWLINE); break; case CMD_ERR_NO_MATCH: - vty_out (vty, "%% [%s] Unknown command: %s%s", protocolname, buf, VTY_NEWLINE); + vty_out (vty, "%% [%s] Unknown command: %s%s", protocolname, buf, + VTY_NEWLINE); break; case CMD_ERR_INCOMPLETE: vty_out (vty, "%% Command incomplete.%s", VTY_NEWLINE); @@ -980,8 +985,7 @@ vline = vector_init (1); vector_set (vline, '\0'); } - else - if (isspace ((int) vty->buf[vty->length - 1])) + else if (isspace ((int) vty->buf[vty->length - 1])) vector_set (vline, '\0'); describe = cmd_describe_command (vline, vty, &ret); @@ -1240,9 +1244,10 @@ vty->width = ((vty->sb_buf[1] << 8)|vty->sb_buf[2]); vty->height = ((vty->sb_buf[3] << 8)|vty->sb_buf[4]); #ifdef TELNET_OPTION_DEBUG - vty_out(vty, "TELNET NAWS window size negotiation completed: " - "width %d, height %d%s", - vty->width, vty->height, VTY_NEWLINE); + vty_out (vty, + "TELNET NAWS window size negotiation completed: " + "width %d, height %d%s", vty->width, vty->height, + VTY_NEWLINE); #endif } break; @@ -1568,14 +1573,12 @@ else flushrc = buffer_flush_window(vty->obuf, vty->fd, vty->width, vty->lines >= 0 ? vty->lines : - vty->height, - erase, 0); + vty->height, erase, 0); switch (flushrc) { case BUFFER_ERROR: vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ - zlog_warn("buffer_flush failed on vty client fd %d, closing", - vty->fd); + zlog_warn ("buffer_flush failed on vty client fd %d, closing", vty->fd); buffer_reset(vty->obuf); vty_close(vty); return 0; @@ -1653,7 +1656,8 @@ /* Say hello to the world. */ vty_hello (vty); if (! no_password_check) - vty_out (vty, "%sUser Access Verification%s%s", VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); + vty_out (vty, "%sUser Access Verification%s%s", VTY_NEWLINE, VTY_NEWLINE, + VTY_NEWLINE); /* Setting up terminal. */ vty_will_echo (vty); @@ -1798,7 +1802,8 @@ ) continue; - sock = socket (ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol); + sock = + socket (ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol); if (sock < 0) continue; @@ -1857,7 +1862,8 @@ naddr=NULL; break; case 0: - zlog_err("error translating address %s: %s",addr,safe_strerror(errno)); + zlog_err ("error translating address %s: %s", addr, + safe_strerror (errno)); naddr=NULL; } @@ -1916,7 +1922,8 @@ sock = socket (AF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - zlog_err("Cannot create unix stream socket: %s", safe_strerror(errno)); + zlog_err ("Cannot create unix stream socket: %s", + safe_strerror (errno)); return; } @@ -2310,8 +2317,7 @@ /* Read up configuration file from file_name. */ void -vty_read_config (char *config_file, - char *config_default_dir) +vty_read_config (char *config_file, char *config_default_dir) { char cwd[MAXPATHLEN]; FILE *confp = NULL; @@ -2324,8 +2330,7 @@ if (! IS_DIRECTORY_SEP (config_file[0])) { getcwd (cwd, MAXPATHLEN); - tmp = XMALLOC (MTYPE_TMP, - strlen (cwd) + strlen (config_file) + 2); + tmp = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (config_file) + 2); sprintf (tmp, "%s/%s", cwd, config_file); fullpath = tmp; } @@ -2537,10 +2542,7 @@ } } -DEFUN (config_who, - config_who_cmd, - "who", - "Display who is on vty\n") +DEFUN (config_who, config_who_cmd, "who", "Display who is on vty\n") { unsigned int i; struct vty *v; @@ -2548,17 +2550,14 @@ for (i = 0; i < vector_active (vtyvec); i++) if ((v = vector_slot (vtyvec, i)) != NULL) vty_out (vty, "%svty[%d] connected from %s.%s", - v->config ? "*" : " ", - i, v->address, VTY_NEWLINE); + v->config ? "*" : " ", i, v->address, VTY_NEWLINE); return CMD_SUCCESS; } /* Move to vty configuration mode. */ DEFUN (line_vty, line_vty_cmd, - "line vty", - "Configure a terminal line\n" - "Virtual terminal\n") + "line vty", "Configure a terminal line\n" "Virtual terminal\n") { vty->node = VTY_NODE; return CMD_SUCCESS; @@ -2591,8 +2590,7 @@ DEFUN (exec_timeout_min, exec_timeout_min_cmd, "exec-timeout <0-35791>", - "Set timeout value\n" - "Timeout value in minutes\n") + "Set timeout value\n" "Timeout value in minutes\n") { return exec_timeout (vty, argv[0], NULL); } @@ -2600,18 +2598,14 @@ DEFUN (exec_timeout_sec, exec_timeout_sec_cmd, "exec-timeout <0-35791> <0-2147483>", - "Set the EXEC timeout\n" - "Timeout in minutes\n" - "Timeout in seconds\n") + "Set the EXEC timeout\n" "Timeout in minutes\n" "Timeout in seconds\n") { return exec_timeout (vty, argv[0], argv[1]); } DEFUN (no_exec_timeout, no_exec_timeout_cmd, - "no exec-timeout", - NO_STR - "Set the EXEC timeout\n") + "no exec-timeout", NO_STR "Set the EXEC timeout\n") { return exec_timeout (vty, NULL, NULL); } @@ -2620,8 +2614,7 @@ DEFUN (vty_access_class, vty_access_class_cmd, "access-class WORD", - "Filter connections based on an IP access list\n" - "IP access list\n") + "Filter connections based on an IP access list\n" "IP access list\n") { if (vty_accesslist_name) XFREE(MTYPE_VTY, vty_accesslist_name); @@ -2636,8 +2629,7 @@ no_vty_access_class_cmd, "no access-class [WORD]", NO_STR - "Filter connections based on an IP access list\n" - "IP access list\n") + "Filter connections based on an IP access list\n" "IP access list\n") { if (! vty_accesslist_name || (argc && strcmp(vty_accesslist_name, argv[0]))) { @@ -2659,8 +2651,7 @@ vty_ipv6_access_class_cmd, "ipv6 access-class WORD", IPV6_STR - "Filter connections based on an IP access list\n" - "IPv6 access list\n") + "Filter connections based on an IP access list\n" "IPv6 access list\n") { if (vty_ipv6_accesslist_name) XFREE(MTYPE_VTY, vty_ipv6_accesslist_name); @@ -2676,8 +2667,7 @@ "no ipv6 access-class [WORD]", NO_STR IPV6_STR - "Filter connections based on an IP access list\n" - "IPv6 access list\n") + "Filter connections based on an IP access list\n" "IPv6 access list\n") { if (! vty_ipv6_accesslist_name || (argc && strcmp(vty_ipv6_accesslist_name, argv[0]))) @@ -2696,20 +2686,14 @@ #endif /* HAVE_IPV6 */ /* vty login. */ -DEFUN (vty_login, - vty_login_cmd, - "login", - "Enable password checking\n") +DEFUN (vty_login, vty_login_cmd, "login", "Enable password checking\n") { no_password_check = 0; return CMD_SUCCESS; } DEFUN (no_vty_login, - no_vty_login_cmd, - "no login", - NO_STR - "Enable password checking\n") + no_vty_login_cmd, "no login", NO_STR "Enable password checking\n") { no_password_check = 1; return CMD_SUCCESS; @@ -2750,8 +2734,7 @@ terminal_no_monitor_cmd, "terminal no monitor", "Set terminal line parameters\n" - NO_STR - "Copy debug output to the current terminal line\n") + NO_STR "Copy debug output to the current terminal line\n") { vty->monitor = 0; return CMD_SUCCESS; @@ -2763,12 +2746,9 @@ NO_STR "Set terminal line parameters\n" "Copy debug output to the current terminal line\n") - DEFUN (show_history, show_history_cmd, - "show history", - SHOW_STR - "Display the session command history\n") + "show history", SHOW_STR "Display the session command history\n") { int index; @@ -2796,8 +2776,7 @@ vty_out (vty, "line vty%s", VTY_NEWLINE); if (vty_accesslist_name) - vty_out (vty, " access-class %s%s", - vty_accesslist_name, VTY_NEWLINE); + vty_out (vty, " access-class %s%s", vty_accesslist_name, VTY_NEWLINE); if (vty_ipv6_accesslist_name) vty_out (vty, " ipv6 access-class %s%s", @@ -2806,8 +2785,7 @@ /* exec-timeout */ if (vty_timeout_val != VTY_TIMEOUT_DEFAULT) vty_out (vty, " exec-timeout %ld %ld%s", - vty_timeout_val / 60, - vty_timeout_val % 60, VTY_NEWLINE); + vty_timeout_val / 60, vty_timeout_val % 60, VTY_NEWLINE); /* login */ if (no_password_check) @@ -2818,8 +2796,7 @@ return CMD_SUCCESS; } -struct cmd_node vty_node = -{ +struct cmd_node vty_node = { VTY_NODE, "%s(config-line)# ", 1, diff -Naur quagga-0.99.9/lib/vty.h quagga-0.99.9-af/lib/vty.h --- quagga-0.99.9/lib/vty.h 2007-04-29 05:40:40.000000000 -0700 +++ quagga-0.99.9-af/lib/vty.h 2008-12-03 13:42:15.000000000 -0800 @@ -24,6 +24,11 @@ #include "thread.h" #include "log.h" + +#ifdef __cplusplus +#define vector __quagga_vector +#endif /* __cplusplus */ + #define VTY_BUFSIZ 512 #define VTY_MAXHIST 20 @@ -34,7 +39,8 @@ int fd; /* Is this vty connect to file or not */ - enum {VTY_TERM, VTY_FILE, VTY_SHELL, VTY_SHELL_SERV} type; + enum + { VTY_TERM, VTY_FILE, VTY_SHELL, VTY_SHELL_SERV } type; /* Node status of this vty */ int node; @@ -80,7 +86,8 @@ unsigned char escape; /* Current vty status. */ - enum {VTY_NORMAL, VTY_CLOSE, VTY_MORE, VTY_MORELINE} status; + enum + { VTY_NORMAL, VTY_CLOSE, VTY_MORE, VTY_MORELINE } status; /* IAC handling: was the last character received the IAC (interpret-as-command) escape character (and therefore the next @@ -205,14 +212,17 @@ extern void vty_init_vtysh (void); extern void vty_reset (void); extern struct vty *vty_new (void); -extern int vty_out (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3); +extern int +vty_out (struct vty *, const char *, ...) +PRINTF_ATTRIBUTE (2, 3); extern void vty_read_config (char *, char *); extern void vty_time_print (struct vty *, int); extern void vty_serv_sock (const char *, unsigned short, const char *); extern void vty_close (struct vty *); extern char *vty_get_cwd (void); extern void vty_log (const char *level, const char *proto, - const char *fmt, struct timestamp_control *, va_list); + const char *fmt, struct timestamp_control *, + va_list); extern int vty_config_lock (struct vty *); extern int vty_config_unlock (struct vty *); extern int vty_shell (struct vty *); @@ -223,4 +233,9 @@ an async-signal-safe function. */ extern void vty_log_fixed (const char *buf, size_t len); + +#ifdef __cplusplus +#undef vector +#endif /* __cplusplus */ + #endif /* _ZEBRA_VTY_H */ diff -Naur quagga-0.99.9/lib/workqueue.c quagga-0.99.9-af/lib/workqueue.c --- quagga-0.99.9/lib/workqueue.c 2006-03-30 06:43:49.000000000 -0800 +++ quagga-0.99.9-af/lib/workqueue.c 2008-12-03 13:42:15.000000000 -0800 @@ -40,8 +40,7 @@ struct work_queue_item *item; assert (wq); - item = XCALLOC (MTYPE_WORK_QUEUE_ITEM, - sizeof (struct work_queue_item)); + item = XCALLOC (MTYPE_WORK_QUEUE_ITEM, sizeof (struct work_queue_item)); return item; } @@ -104,8 +103,7 @@ { /* if appropriate, schedule work queue thread */ if ( (wq->flags == WQ_UNPLUGGED) - && (wq->thread == NULL) - && (listcount (wq->items) > 0) ) + && (wq->thread == NULL) && (listcount (wq->items) > 0)) { wq->thread = thread_add_background (wq->master, work_queue_run, wq, delay); @@ -162,26 +160,19 @@ DEFUN(show_work_queues, show_work_queues_cmd, - "show work-queues", - SHOW_STR - "Work Queue information\n") + "show work-queues", SHOW_STR "Work Queue information\n") { struct listnode *node; struct work_queue *wq; vty_out (vty, "%c %8s %5s %8s %21s%s", - ' ', "List","(ms) ","Q. Runs","Cycle Counts ", - VTY_NEWLINE); + ' ', "List", "(ms) ", "Q. Runs", "Cycle Counts ", VTY_NEWLINE); vty_out (vty, "%c %8s %5s %8s %7s %6s %6s %s%s", 'P', "Items", - "Hold", - "Total", - "Best","Gran.","Avg.", - "Name", - VTY_NEWLINE); + "Hold", "Total", "Best", "Gran.", "Avg.", "Name", VTY_NEWLINE); for (ALL_LIST_ELEMENTS_RO ((&work_queues), node, wq)) { @@ -193,8 +184,7 @@ wq->cycles.best, wq->cycles.granularity, (wq->runs) ? (unsigned int) (wq->cycles.total / wq->runs) : 0, - wq->name, - VTY_NEWLINE); + wq->name, VTY_NEWLINE); } return CMD_SUCCESS; @@ -285,8 +275,7 @@ ret = wq->spec.workfunc (wq, item->data); item->ran++; } - while ((ret == WQ_RETRY_NOW) - && (item->ran < wq->spec.max_retries)); + while ((ret == WQ_RETRY_NOW) && (item->ran < wq->spec.max_retries)); switch (ret) { @@ -326,8 +315,7 @@ cycles++; /* test if we should yield */ - if ( !(cycles % wq->cycles.granularity) - && thread_should_yield (thread)) + if (!(cycles % wq->cycles.granularity) && thread_should_yield (thread)) { yielded = 1; goto stats; diff -Naur quagga-0.99.9/lib/workqueue.h quagga-0.99.9-af/lib/workqueue.h --- quagga-0.99.9/lib/workqueue.h 2006-03-30 06:20:39.000000000 -0800 +++ quagga-0.99.9-af/lib/workqueue.h 2008-12-03 13:42:15.000000000 -0800 @@ -65,7 +65,8 @@ /* Specification for this work queue. * Public, must be set before use by caller. May be modified at will. */ - struct { + struct + { /* optional opaque user data, global to the queue. */ void *data; @@ -94,7 +95,8 @@ struct list *items; /* queue item list */ unsigned long runs; /* runs count */ - struct { + struct + { unsigned int best; unsigned int granularity; unsigned long total; diff -Naur quagga-0.99.9/lib/zclient.c quagga-0.99.9-af/lib/zclient.c --- quagga-0.99.9/lib/zclient.c 2007-05-09 13:59:34.000000000 -0700 +++ quagga-0.99.9-af/lib/zclient.c 2008-12-03 13:42:15.000000000 -0800 @@ -34,7 +34,8 @@ #include "table.h" /* Zebra client events. */ -enum event {ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT}; +enum event +{ ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT }; /* Prototype for event manager. */ static void zclient_event (enum event, struct zclient *); @@ -232,7 +233,8 @@ switch (buffer_flush_available(zclient->wb, zclient->sock)) { case BUFFER_ERROR: - zlog_warn("%s: buffer_flush_available failed on zclient fd %d, closing", + zlog_warn + ("%s: buffer_flush_available failed on zclient fd %d, closing", __func__, zclient->sock); return zclient_failed(zclient); break; @@ -251,7 +253,8 @@ { if (zclient->sock < 0) return -1; - switch (buffer_write(zclient->wb, zclient->sock, STREAM_DATA(zclient->obuf), + switch (buffer_write + (zclient->wb, zclient->sock, STREAM_DATA (zclient->obuf), stream_get_endp(zclient->obuf))) { case BUFFER_ERROR: @@ -613,7 +616,8 @@ stream_get (ifname_tmp, s, INTERFACE_NAMSIZ); /* Lookup/create interface by name. */ - ifp = if_get_by_name_len (ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ)); + ifp = + if_get_by_name_len (ifname_tmp, strnlen (ifname_tmp, INTERFACE_NAMSIZ)); /* Read interface's index. */ ifp->ifindex = stream_getl (s); @@ -777,8 +781,10 @@ if (type == ZEBRA_INTERFACE_ADDRESS_ADD) { /* N.B. NULL destination pointers are encoded as all zeroes */ - ifc = connected_add_by_prefix(ifp, &p,(memconstant(&d.u.prefix,0,plen) ? - NULL : &d)); + ifc = + connected_add_by_prefix (ifp, &p, + (memconstant (&d.u.prefix, 0, plen) ? NULL : + &d)); if (ifc != NULL) { ifc->flags = ifc_flags; @@ -819,7 +825,8 @@ (nbyte == -1)) { if (zclient_debug) - zlog_debug ("zclient connection closed socket [%d].", zclient->sock); + zlog_debug ("zclient connection closed socket [%d].", + zclient->sock); return zclient_failed(zclient); } if (nbyte != (ssize_t)(ZEBRA_HEADER_SIZE-already)) @@ -875,7 +882,8 @@ (nbyte == -1)) { if (zclient_debug) - zlog_debug("zclient connection closed socket [%d].", zclient->sock); + zlog_debug ("zclient connection closed socket [%d].", + zclient->sock); return zclient_failed(zclient); } if (nbyte != (ssize_t)(length-already)) diff -Naur quagga-0.99.9/lib/zclient.h quagga-0.99.9-af/lib/zclient.h --- quagga-0.99.9/lib/zclient.h 2006-01-31 12:55:54.000000000 -0800 +++ quagga-0.99.9-af/lib/zclient.h 2008-12-03 13:42:15.000000000 -0800 @@ -151,8 +151,10 @@ extern struct interface *zebra_interface_add_read (struct stream *); extern struct interface *zebra_interface_state_read (struct stream *s); extern struct connected *zebra_interface_address_read (int, struct stream *); -extern void zebra_interface_if_set_value (struct stream *, struct interface *); -extern void zebra_router_id_update_read (struct stream *s, struct prefix *rid); +extern void zebra_interface_if_set_value (struct stream *, + struct interface *); +extern void zebra_router_id_update_read (struct stream *s, + struct prefix *rid); extern int zapi_ipv4_route (u_char, struct zclient *, struct prefix_ipv4 *, struct zapi_ipv4 *); diff -Naur quagga-0.99.9/ospf6d/ospf6_abr.c quagga-0.99.9-af/ospf6d/ospf6_abr.c --- quagga-0.99.9/ospf6d/ospf6_abr.c 2006-05-15 03:43:52.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_abr.c 2008-12-03 13:42:15.000000000 -0800 @@ -206,7 +206,8 @@ ! CHECK_FLAG (route->path.router_bits, OSPF6_ROUTER_BIT_E))) { if (is_debug) - zlog_debug ("Route type is none of network, range nor ASBR, withdraw"); + zlog_debug + ("Route type is none of network, range nor ASBR, withdraw"); if (summary) ospf6_route_remove (summary, summary_table); if (old) @@ -346,8 +347,7 @@ if (EXPORT_NAME (area)) { if (EXPORT_LIST (area) == NULL) - EXPORT_LIST (area) = - access_list_lookup (AFI_IP6, EXPORT_NAME (area)); + EXPORT_LIST (area) = access_list_lookup (AFI_IP6, EXPORT_NAME (area)); if (EXPORT_LIST (area)) if (access_list_apply (EXPORT_LIST (area), @@ -678,7 +678,8 @@ if (PREFIX_NAME_IN (oa)) { if (PREFIX_LIST_IN (oa) == NULL) - PREFIX_LIST_IN (oa) = prefix_list_lookup (AFI_IP6, PREFIX_NAME_IN (oa)); + PREFIX_LIST_IN (oa) = + prefix_list_lookup (AFI_IP6, PREFIX_NAME_IN (oa)); if (PREFIX_LIST_IN (oa)) if (prefix_list_apply (PREFIX_LIST_IN (oa), &prefix) != PREFIX_PERMIT) @@ -809,11 +810,7 @@ /* Debug commands */ DEFUN (debug_ospf6_abr, debug_ospf6_abr_cmd, - "debug ospf6 abr", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 ABR function\n" - ) + "debug ospf6 abr", DEBUG_STR OSPF6_STR "Debug OSPFv3 ABR function\n") { OSPF6_DEBUG_ABR_ON (); return CMD_SUCCESS; @@ -822,11 +819,7 @@ DEFUN (no_debug_ospf6_abr, no_debug_ospf6_abr_cmd, "no debug ospf6 abr", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 ABR function\n" - ) + NO_STR DEBUG_STR OSPF6_STR "Debug OSPFv3 ABR function\n") { OSPF6_DEBUG_ABR_OFF (); return CMD_SUCCESS; @@ -849,15 +842,13 @@ install_element (CONFIG_NODE, &no_debug_ospf6_abr_cmd); } -struct ospf6_lsa_handler inter_prefix_handler = -{ +struct ospf6_lsa_handler inter_prefix_handler = { OSPF6_LSTYPE_INTER_PREFIX, "Inter-Prefix", ospf6_inter_area_prefix_lsa_show }; -struct ospf6_lsa_handler inter_router_handler = -{ +struct ospf6_lsa_handler inter_router_handler = { OSPF6_LSTYPE_INTER_ROUTER, "Inter-Router", ospf6_inter_area_router_lsa_show diff -Naur quagga-0.99.9/ospf6d/ospf6_area.c quagga-0.99.9-af/ospf6d/ospf6_area.c --- quagga-0.99.9/ospf6d/ospf6_area.c 2006-05-15 03:43:52.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_area.c 2008-12-03 13:42:15.000000000 -0800 @@ -3,20 +3,19 @@ * * 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 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. + * 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. + * 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. */ #include @@ -164,9 +163,14 @@ oa->summary_router->scope = oa; /* set default options */ - OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6); - OSPF6_OPT_SET (oa->options, OSPF6_OPT_E); - OSPF6_OPT_SET (oa->options, OSPF6_OPT_R); + OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6, 2); + OSPF6_OPT_SET (oa->options, OSPF6_OPT_E, 2); + OSPF6_OPT_SET (oa->options, OSPF6_OPT_R, 2); + + //AF draft 05 Sec 2.2 .1 + // When a router supports AF, it MUST set this new bit in the Options + // field of Hello Packets, DD packets and LSAs + OSPF6_OPT_SET (oa->options, OSPF6_OPT_AF, 1); oa->ospf6 = o; listnode_add_sort (o->area_list, oa); @@ -314,10 +318,7 @@ area_range_cmd, "area A.B.C.D range X:X::X:X/M", "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Configured address range\n" - "Specify IPv6 prefix\n" - ) + OSPF6_AREA_ID_STR "Configured address range\n" "Specify IPv6 prefix\n") { int ret; struct ospf6_area *oa; @@ -362,18 +363,13 @@ "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)", "OSPF area parameters\n" OSPF6_AREA_ID_STR - "Configured address range\n" - "Specify IPv6 prefix\n" - ); + "Configured address range\n" "Specify IPv6 prefix\n"); DEFUN (no_area_range, no_area_range_cmd, "no area A.B.C.D range X:X::X:X/M", "OSPF area parameters\n" - OSPF6_AREA_ID_STR - "Configured address range\n" - "Specify IPv6 prefix\n" - ) + OSPF6_AREA_ID_STR "Configured address range\n" "Specify IPv6 prefix\n") { int ret; struct ospf6_area *oa; @@ -614,10 +610,7 @@ show_ipv6_ospf6_spf_tree_cmd, "show ipv6 ospf6 spf tree", SHOW_STR - IP6_STR - OSPF6_STR - "Shortest Path First caculation\n" - "Show SPF tree\n") + IP6_STR OSPF6_STR "Shortest Path First caculation\n" "Show SPF tree\n") { struct listnode *node; struct ospf6_area *oa; @@ -650,9 +643,7 @@ IP6_STR OSPF6_STR OSPF6_AREA_STR - OSPF6_AREA_ID_STR - "Shortest Path First caculation\n" - "Show SPF tree\n") + OSPF6_AREA_ID_STR "Shortest Path First caculation\n" "Show SPF tree\n") { u_int32_t area_id; struct ospf6_area *oa; @@ -745,6 +736,194 @@ return CMD_SUCCESS; } +static int +ospf6_area_linklog_timestampstr (char *buf, size_t bufsize) +{ + struct timeval tv; + struct tm tm; + size_t len; + + if (gettimeofday (&tv, NULL)) + { + zlog_warn ("%s: gettimeofday() failed", __func__); + return -1; + } + if (gmtime_r (&tv.tv_sec, &tm) == NULL) + { + zlog_warn ("%s: gmtime_r() failed", __func__); + return -1; + } + if ((len = strftime (buf, bufsize, "%T", &tm)) == 0) + { + zlog_warn ("%s: timestampstr() failed", __func__); + return -1; + } + if (bufsize - len == 1) + { + zlog_warn ("%s: time stamp string exceeds bufsize", __func__); + return -1; + } + buf += len; + bufsize -= len; + if (snprintf (buf, bufsize, ".%06d", tv.tv_usec) >= bufsize) + { + zlog_warn ("%s: snprintf() failed", __func__); + return -1; + } + return 0; +} + +static int +ospf6_area_linklog (struct ospf6_area *area) +{ + char timestr[16]; + u_int16_t type; + struct ospf6_lsa *lsa; + + if (!area->linklog_stream) + { + zlog_warn ("%s: no linklog output file", __func__); + return -1; + } + if (ospf6_area_linklog_timestampstr (timestr, sizeof (timestr))) + return -1; + + fprintf (area->linklog_stream, "Routing-Links List: %s\n", timestr); + + type = ntohs (OSPF6_LSTYPE_ROUTER); + for (lsa = ospf6_lsdb_type_head (type, area->lsdb); + lsa; lsa = ospf6_lsdb_type_next (type, lsa)) + { + char *start, *end, *current; + struct ospf6_router_lsa *router_lsa; + char adv_router[64]; + + inet_ntop (AF_INET, &lsa->header->adv_router, + adv_router, sizeof (adv_router)); + + router_lsa = (struct ospf6_router_lsa *) + ((char *) lsa->header + sizeof (struct ospf6_lsa_header)); + start = (char *) router_lsa + sizeof (struct ospf6_router_lsa); + end = (char *) lsa->header + ntohs (lsa->header->length); + + for (current = start; + current + sizeof (struct ospf6_router_lsdesc) <= end; + current += sizeof (struct ospf6_router_lsdesc)) + { + struct ospf6_router_lsdesc *lsdesc; + char neighbor_router[64]; + + lsdesc = (struct ospf6_router_lsdesc *) current; + + inet_ntop (AF_INET, &lsdesc->neighbor_router_id, + neighbor_router, sizeof (neighbor_router)); + + fprintf (area->linklog_stream, "%s -> %s\n", adv_router, + neighbor_router); + } + } + + fprintf (area->linklog_stream, "End of Routing-Links List.\n"); + fflush (area->linklog_stream); + + return 0; +} + +static int +ospf6_area_linklog_timer (struct thread *thread) +{ + struct ospf6_area *area; + struct listnode *i; + char timestr[16]; + + area = (struct ospf6_area *) THREAD_ARG (thread); + assert (area); + + ospf6_area_linklog (area); + + area->linklog_thread = thread_add_timer (master, ospf6_area_linklog_timer, + area, area->linklog_interval); + + return 0; +} + +static void +ospf6_area_start_linklog (struct ospf6_area *area) +{ + THREAD_TIMER_ON (master, area->linklog_thread, + ospf6_area_linklog_timer, area, 0); + return; +} + +static void +ospf6_area_stop_linklog (struct ospf6_area *area) +{ + if (area->linklog_thread) + THREAD_TIMER_OFF (area->linklog_thread); + area->linklog_interval = 0; + return; +} + +DEFUN (area_linklog_file, + area_linklog_file_cmd, + "area A.B.C.D linklog-file FILENAME", + "OSPFv6 area parameters\n" + OSPF6_AREA_ID_STR "filename to log links to\n" "filename\n") +{ + struct ospf6_area *area; + + OSPF6_CMD_AREA_GET (argv[0], area); + + if (area->linklog_stream) + fclose (area->linklog_stream); + + if ((area->linklog_stream = fopen (argv[1], "a")) == NULL) + { + vty_out (vty, "%s: fopen('%s') failed: %s%s", + __func__, argv[1], strerror (errno), VNL); + return CMD_SUCCESS; + } + if (area->linklog_interval && !area->linklog_thread) + ospf6_area_start_linklog (area); + + return CMD_SUCCESS; +} + +DEFUN (area_linklog_interval, + area_linklog_interval_cmd, + "area A.B.C.D linklog-interval <0-255>", + "OSPFv6 area parameters\n" + OSPF6_AREA_ID_STR "minimum time between logging links\n" "seconds\n") +{ + struct ospf6_area *area; + + OSPF6_CMD_AREA_GET (argv[0], area); + + area->linklog_interval = strtol (argv[1], NULL, 10); + + if (area->linklog_interval && area->linklog_stream && !area->linklog_thread) + ospf6_area_start_linklog (area); + else if (!area->linklog_interval && area->linklog_thread) + ospf6_area_stop_linklog (area); + + return CMD_SUCCESS; +} + +DEFUN (no_area_linklog, + no_area_linklog_cmd, + "no area A.B.C.D linklog", + NO_STR + "OSPF area parameters\n" OSPF6_AREA_ID_STR "disable logging links\n") +{ + struct ospf6_area *area; + + OSPF6_CMD_AREA_GET (argv[0], area); + + ospf6_area_stop_linklog (area); + + return CMD_SUCCESS; +} + void ospf6_area_init () { @@ -768,6 +947,8 @@ install_element (OSPF6_NODE, &area_filter_list_cmd); install_element (OSPF6_NODE, &no_area_filter_list_cmd); -} - + install_element (OSPF6_NODE, &area_linklog_file_cmd); + install_element (OSPF6_NODE, &area_linklog_interval_cmd); + install_element (OSPF6_NODE, &no_area_linklog_cmd); +} diff -Naur quagga-0.99.9/ospf6d/ospf6_area.h quagga-0.99.9-af/ospf6d/ospf6_area.h --- quagga-0.99.9/ospf6d/ospf6_area.h 2005-06-27 16:55:57.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_area.h 2008-12-03 13:42:15.000000000 -0800 @@ -97,6 +97,10 @@ #define PREFIX_NAME_OUT(A) (A)->plist_out.name #define PREFIX_LIST_OUT(A) (A)->plist_out.list + u_char linklog_interval; + FILE *linklog_stream; + struct thread *linklog_thread; + }; #define OSPF6_AREA_ENABLE 0x01 @@ -126,5 +130,5 @@ void ospf6_area_config_write (struct vty *vty); void ospf6_area_init (); -#endif /* OSPF_AREA_H */ +#endif /* OSPF_AREA_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_asbr.c quagga-0.99.9-af/ospf6d/ospf6_asbr.c --- quagga-0.99.9/ospf6d/ospf6_asbr.c 2006-05-15 03:46:39.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_asbr.c 2008-12-03 13:42:15.000000000 -0800 @@ -325,14 +325,6 @@ u_int16_t type; u_int32_t router; - if (! CHECK_FLAG (asbr_entry->flag, OSPF6_ROUTE_BEST)) - { - char buf[16]; - inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (&asbr_entry->prefix), - buf, sizeof (buf)); - zlog_info ("ignore non-best path: lsentry %s remove", buf); - return; - } type = htons (OSPF6_LSTYPE_AS_EXTERNAL); router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix); @@ -415,7 +407,8 @@ void ospf6_asbr_redistribute_add (int type, int ifindex, struct prefix *prefix, - u_int nexthop_num, struct in6_addr *nexthop) + u_int nexthop_num, struct in6_addr *nexthop, + u_int32_t metric) { int ret; struct ospf6_route troute; @@ -456,6 +449,7 @@ memset (&troute, 0, sizeof (troute)); memset (&tinfo, 0, sizeof (tinfo)); troute.route_option = &tinfo; + troute.path.cost = metric; ret = route_map_apply (ospf6->rmap[type].map, prefix, RMAP_OSPF6, &troute); @@ -487,7 +481,8 @@ info->type = type; match->nexthop[0].ifindex = ifindex; if (nexthop_num && nexthop) - memcpy (&match->nexthop[0].address, nexthop, sizeof (struct in6_addr)); + memcpy (&match->nexthop[0].address, nexthop, + sizeof (struct in6_addr)); /* create/update binding in external_id_table */ prefix_id.family = AF_INET; @@ -511,6 +506,8 @@ route = ospf6_route_create (); route->type = OSPF6_DEST_TYPE_NETWORK; memcpy (&route->prefix, prefix, sizeof (struct prefix)); + route->path.metric_type = 1; + route->path.cost = metric; info = (struct ospf6_external_info *) XMALLOC (MTYPE_OSPF6_EXTERNAL_INFO, sizeof (struct ospf6_external_info)); @@ -626,14 +623,12 @@ DEFUN (ospf6_redistribute, ospf6_redistribute_cmd, - "redistribute (static|kernel|connected|ripng|bgp)", + "redistribute (ospf|ospf6|static|kernel|connected|ripng|bgp)", "Redistribute\n" + "OSPF route\n" + "OSPF6 route\n" "Static route\n" - "Kernel route\n" - "Connected route\n" - "RIPng route\n" - "BGP route\n" - ) + "Kernel route\n" "Connected route\n" "RIPng route\n" "BGP route\n") { int type = 0; @@ -647,6 +642,10 @@ type = ZEBRA_ROUTE_RIPNG; else if (strncmp (argv[0], "bgp", 3) == 0) type = ZEBRA_ROUTE_BGP; + else if (strncmp (argv[0], "ospf6", 5) == 0) + type = ZEBRA_ROUTE_OSPF6; + else if (strncmp (argv[0], "ospf", 4) == 0) + type = ZEBRA_ROUTE_OSPF; ospf6_asbr_redistribute_unset (type); ospf6_asbr_routemap_unset (type); @@ -656,16 +655,15 @@ DEFUN (ospf6_redistribute_routemap, ospf6_redistribute_routemap_cmd, - "redistribute (static|kernel|connected|ripng|bgp) route-map WORD", + "redistribute (ospf|ospf6|static|kernel|connected|ripng|bgp) route-map WORD", "Redistribute\n" + "OSPF route\n" + "OSPF6 route\n" "Static routes\n" "Kernel route\n" "Connected route\n" "RIPng route\n" - "BGP route\n" - "Route map reference\n" - "Route map name\n" - ) + "BGP route\n" "Route map reference\n" "Route map name\n") { int type = 0; @@ -679,6 +677,10 @@ type = ZEBRA_ROUTE_RIPNG; else if (strncmp (argv[0], "bgp", 3) == 0) type = ZEBRA_ROUTE_BGP; + else if (strncmp (argv[0], "ospf6", 5) == 0) + type = ZEBRA_ROUTE_OSPF6; + else if (strncmp (argv[0], "ospf", 4) == 0) + type = ZEBRA_ROUTE_OSPF; ospf6_asbr_redistribute_unset (type); ospf6_asbr_routemap_set (type, argv[1]); @@ -688,15 +690,13 @@ DEFUN (no_ospf6_redistribute, no_ospf6_redistribute_cmd, - "no redistribute (static|kernel|connected|ripng|bgp)", + "no redistribute (ospf|ospf6|static|kernel|connected|ripng|bgp)", NO_STR "Redistribute\n" + "OSPF route\n" + "OSPF6 route\n" "Static route\n" - "Kernel route\n" - "Connected route\n" - "RIPng route\n" - "BGP route\n" - ) + "Kernel route\n" "Connected route\n" "RIPng route\n" "BGP route\n") { int type = 0; @@ -710,6 +710,10 @@ type = ZEBRA_ROUTE_RIPNG; else if (strncmp (argv[0], "bgp", 3) == 0) type = ZEBRA_ROUTE_BGP; + else if (strncmp (argv[0], "ospf6", 5) == 0) + type = ZEBRA_ROUTE_OSPF6; + else if (strncmp (argv[0], "ospf", 4) == 0) + type = ZEBRA_ROUTE_OSPF; ospf6_asbr_redistribute_unset (type); ospf6_asbr_routemap_unset (type); @@ -733,8 +737,7 @@ vty_out (vty, " redistribute %s route-map %s%s", ZROUTE_NAME (type), ospf6->rmap[type].name, VNL); else - vty_out (vty, " redistribute %s%s", - ZROUTE_NAME (type), VNL); + vty_out (vty, " redistribute %s%s", ZROUTE_NAME (type), VNL); } return 0; @@ -771,11 +774,9 @@ if (ospf6->rmap[type].name) vty_out (vty, " %d: %s with route-map \"%s\"%s%s", nroute[type], ZROUTE_NAME (type), ospf6->rmap[type].name, - (ospf6->rmap[type].map ? "" : " (not found !)"), - VNL); + (ospf6->rmap[type].map ? "" : " (not found !)"), VNL); else - vty_out (vty, " %d: %s%s", nroute[type], - ZROUTE_NAME (type), VNL); + vty_out (vty, " %d: %s%s", nroute[type], ZROUTE_NAME (type), VNL); } vty_out (vty, "Total %d routes%s", total, VNL); } @@ -814,9 +815,7 @@ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); } -struct route_map_rule_cmd -ospf6_routemap_rule_match_address_prefixlist_cmd = -{ +struct route_map_rule_cmd ospf6_routemap_rule_match_address_prefixlist_cmd = { "ipv6 address prefix-list", ospf6_routemap_rule_match_address_prefixlist, ospf6_routemap_rule_match_address_prefixlist_compile, @@ -855,9 +854,7 @@ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); } -struct route_map_rule_cmd -ospf6_routemap_rule_set_metric_type_cmd = -{ +struct route_map_rule_cmd ospf6_routemap_rule_set_metric_type_cmd = { "metric-type", ospf6_routemap_rule_set_metric_type, ospf6_routemap_rule_set_metric_type_compile, @@ -895,9 +892,7 @@ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); } -struct route_map_rule_cmd -ospf6_routemap_rule_set_metric_cmd = -{ +struct route_map_rule_cmd ospf6_routemap_rule_set_metric_cmd = { "metric", ospf6_routemap_rule_set_metric, ospf6_routemap_rule_set_metric_compile, @@ -939,9 +934,7 @@ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); } -struct route_map_rule_cmd -ospf6_routemap_rule_set_forwarding_cmd = -{ +struct route_map_rule_cmd ospf6_routemap_rule_set_forwarding_cmd = { "forwarding-address", ospf6_routemap_rule_set_forwarding, ospf6_routemap_rule_set_forwarding_compile, @@ -976,8 +969,7 @@ "Match values\n" IPV6_STR "Match address of route\n" - "Match entries of prefix-lists\n" - "IPv6 prefix-list name\n") + "Match entries of prefix-lists\n" "IPv6 prefix-list name\n") { int ret = route_map_add_match ((struct route_map_index *) vty->index, "ipv6 address prefix-list", argv[0]); @@ -992,8 +984,7 @@ "Match values\n" IPV6_STR "Match address of route\n" - "Match entries of prefix-lists\n" - "IPv6 prefix-list name\n") + "Match entries of prefix-lists\n" "IPv6 prefix-list name\n") { int ret = route_map_delete_match ((struct route_map_index *) vty->index, "ipv6 address prefix-list", argv[0]); @@ -1006,8 +997,7 @@ "set metric-type (type-1|type-2)", "Set value\n" "Type of metric\n" - "OSPF6 external type 1 metric\n" - "OSPF6 external type 2 metric\n") + "OSPF6 external type 1 metric\n" "OSPF6 external type 2 metric\n") { int ret = route_map_add_set ((struct route_map_index *) vty->index, "metric-type", argv[0]); @@ -1021,8 +1011,7 @@ NO_STR "Set value\n" "Type of metric\n" - "OSPF6 external type 1 metric\n" - "OSPF6 external type 2 metric\n") + "OSPF6 external type 1 metric\n" "OSPF6 external type 2 metric\n") { int ret = route_map_delete_set ((struct route_map_index *) vty->index, "metric-type", argv[0]); @@ -1033,9 +1022,7 @@ DEFUN (set_metric, set_metric_cmd, "set metric <0-4294967295>", - "Set value\n" - "Metric value\n" - "Metric value\n") + "Set value\n" "Metric value\n" "Metric value\n") { int ret = route_map_add_set ((struct route_map_index *) vty->index, "metric", argv[0]); @@ -1046,10 +1033,7 @@ DEFUN (no_set_metric, no_set_metric_cmd, "no set metric <0-4294967295>", - NO_STR - "Set value\n" - "Metric\n" - "METRIC value\n") + NO_STR "Set value\n" "Metric\n" "METRIC value\n") { int ret = route_map_delete_set ((struct route_map_index *) vty->index, "metric", argv[0]); @@ -1060,9 +1044,7 @@ DEFUN (ospf6_routemap_set_forwarding, ospf6_routemap_set_forwarding_cmd, "set forwarding-address X:X::X:X", - "Set value\n" - "Forwarding Address\n" - "IPv6 Address\n") + "Set value\n" "Forwarding Address\n" "IPv6 Address\n") { int ret = route_map_add_set ((struct route_map_index *) vty->index, "forwarding-address", argv[0]); @@ -1073,10 +1055,7 @@ DEFUN (ospf6_routemap_no_set_forwarding, ospf6_routemap_no_set_forwarding_cmd, "no set forwarding-address X:X::X:X", - NO_STR - "Set value\n" - "Forwarding Address\n" - "IPv6 Address\n") + NO_STR "Set value\n" "Forwarding Address\n" "IPv6 Address\n") { int ret = route_map_delete_set ((struct route_map_index *) vty->index, "forwarding-address", argv[0]); @@ -1098,7 +1077,8 @@ /* Match address prefix-list */ install_element (RMAP_NODE, &ospf6_routemap_match_address_prefixlist_cmd); - install_element (RMAP_NODE, &ospf6_routemap_no_match_address_prefixlist_cmd); + install_element (RMAP_NODE, + &ospf6_routemap_no_match_address_prefixlist_cmd); /* ASE Metric Type (e.g. Type-1/Type-2) */ install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd); @@ -1128,9 +1108,11 @@ /* bits */ snprintf (buf, sizeof (buf), "%c%c%c", - (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_E) ? 'E' : '-'), - (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F) ? 'F' : '-'), - (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T' : '-')); + (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_E) ? 'E' : + '-'), (CHECK_FLAG (external->bits_metric, + OSPF6_ASBR_BIT_F) ? 'F' : '-'), + (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T' : + '-')); vty_out (vty, " Bits: %s%s", buf, VNL); vty_out (vty, " Metric: %5lu%s", (u_long) OSPF6_ASBR_METRIC (external), @@ -1138,12 +1120,10 @@ ospf6_prefix_options_printbuf (external->prefix.prefix_options, buf, sizeof (buf)); - vty_out (vty, " Prefix Options: %s%s", buf, - VNL); + vty_out (vty, " Prefix Options: %s%s", buf, VNL); vty_out (vty, " Referenced LSType: %d%s", - ntohs (external->prefix.prefix_refer_lstype), - VNL); + ntohs (external->prefix.prefix_refer_lstype), VNL); ospf6_prefix_in6_addr (&in6, &external->prefix); inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); @@ -1190,11 +1170,7 @@ DEFUN (show_ipv6_ospf6_redistribute, show_ipv6_ospf6_redistribute_cmd, "show ipv6 ospf6 redistribute", - SHOW_STR - IP6_STR - OSPF6_STR - "redistributing External information\n" - ) + SHOW_STR IP6_STR OSPF6_STR "redistributing External information\n") { struct ospf6_route *route; @@ -1207,8 +1183,7 @@ return CMD_SUCCESS; } -struct ospf6_lsa_handler as_external_handler = -{ +struct ospf6_lsa_handler as_external_handler = { OSPF6_LSTYPE_AS_EXTERNAL, "AS-External", ospf6_as_external_lsa_show @@ -1232,11 +1207,7 @@ DEFUN (debug_ospf6_asbr, debug_ospf6_asbr_cmd, - "debug ospf6 asbr", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 ASBR function\n" - ) + "debug ospf6 asbr", DEBUG_STR OSPF6_STR "Debug OSPFv3 ASBR function\n") { OSPF6_DEBUG_ASBR_ON (); return CMD_SUCCESS; @@ -1245,11 +1216,7 @@ DEFUN (no_debug_ospf6_asbr, no_debug_ospf6_asbr_cmd, "no debug ospf6 asbr", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 ASBR function\n" - ) + NO_STR DEBUG_STR OSPF6_STR "Debug OSPFv3 ASBR function\n") { OSPF6_DEBUG_ASBR_OFF (); return CMD_SUCCESS; diff -Naur quagga-0.99.9/ospf6d/ospf6_asbr.h quagga-0.99.9-af/ospf6d/ospf6_asbr.h --- quagga-0.99.9/ospf6d/ospf6_asbr.h 2004-05-18 14:27:50.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_asbr.h 2008-12-03 13:42:15.000000000 -0800 @@ -71,7 +71,9 @@ int ospf6_asbr_is_asbr (struct ospf6 *o); void ospf6_asbr_redistribute_add (int type, int ifindex, struct prefix *prefix, - u_int nexthop_num, struct in6_addr *nexthop); + u_int nexthop_num, struct in6_addr *nexthop, + u_int32_t metric); + void ospf6_asbr_redistribute_remove (int type, int ifindex, struct prefix *prefix); diff -Naur quagga-0.99.9/ospf6d/ospf6d.c quagga-0.99.9-af/ospf6d/ospf6d.c --- quagga-0.99.9/ospf6d/ospf6d.c 2006-05-15 03:36:47.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6d.c 2008-12-03 13:42:15.000000000 -0800 @@ -86,19 +86,14 @@ /* show database functions */ DEFUN (show_version_ospf6, show_version_ospf6_cmd, - "show version ospf6", - SHOW_STR - "Displays ospf6d version\n" - ) + "show version ospf6", SHOW_STR "Displays ospf6d version\n") { - vty_out (vty, "Zebra OSPF6d Version: %s%s", - ospf6_daemon_version, VNL); + vty_out (vty, "Zebra OSPF6d Version: %s%s", ospf6_daemon_version, VNL); return CMD_SUCCESS; } -struct cmd_node debug_node = -{ +struct cmd_node debug_node = { DEBUG_NODE, "", 1 /* VTYSH */ @@ -172,11 +167,7 @@ DEFUN (show_ipv6_ospf6_database, show_ipv6_ospf6_database_cmd, "show ipv6 ospf6 database", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Link state database\n" - ) + SHOW_STR IPV6_STR OSPF6_STR "Display Link state database\n") { int level; struct listnode *i, *j; @@ -219,9 +210,7 @@ OSPF6_STR "Display Link state database\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_type, show_ipv6_ospf6_database_type_cmd, @@ -239,9 +228,7 @@ "Display As-External LSAs\n" "Display Group-Membership LSAs\n" "Display Type-7 LSAs\n" - "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - ) + "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n") { int level; struct listnode *i, *j; @@ -313,9 +300,7 @@ "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_id_cmd, @@ -325,8 +310,7 @@ OSPF6_STR "Display Link state database\n" "Any Link state Type\n" - "Specify Link state ID as IPv4 address notation\n" - ) + "Specify Link state ID as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -339,8 +323,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link State ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link State ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -382,9 +365,7 @@ "Any Link state Type\n" "Specify Link state ID as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); ALIAS (show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_linkstate_id_cmd, @@ -394,8 +375,7 @@ OSPF6_STR "Display Link state database\n" "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - ); + "Specify Link state ID as IPv4 address notation\n"); ALIAS (show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_linkstate_id_detail_cmd, @@ -408,9 +388,7 @@ "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_router_cmd, @@ -421,8 +399,7 @@ "Display Link state database\n" "Any Link state Type\n" "Any Link state ID\n" - "Specify Advertising Router as IPv4 address notation\n" - ) + "Specify Advertising Router as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -435,8 +412,7 @@ if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Advertising Router is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -479,9 +455,7 @@ "Any Link state ID\n" "Specify Advertising Router as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); ALIAS (show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_adv_router_cmd, @@ -491,8 +465,7 @@ OSPF6_STR "Display Link state database\n" "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - ); + "Specify Advertising Router as IPv4 address notation\n"); ALIAS (show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_adv_router_detail_cmd, @@ -505,9 +478,7 @@ "Search by Advertising Router\n" "Specify Advertising Router as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_id_cmd, @@ -527,8 +498,7 @@ "Display Type-7 LSAs\n" "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" - "Specify Link state ID as IPv4 address notation\n" - ) + "Specify Link state ID as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -546,8 +516,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link state ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -612,9 +581,7 @@ "Display Intra-Area-Prefix LSAs\n" "Specify Link state ID as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); ALIAS (show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_linkstate_id_cmd, @@ -635,8 +602,7 @@ "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - ); + "Specify Link state ID as IPv4 address notation\n"); ALIAS (show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_linkstate_id_detail_cmd, @@ -660,9 +626,7 @@ "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_type_router, show_ipv6_ospf6_database_type_router_cmd, @@ -683,8 +647,7 @@ "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Any Link state ID\n" - "Specify Advertising Router as IPv4 address notation\n" - ) + "Specify Advertising Router as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -702,8 +665,7 @@ if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Advertising Router is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -728,7 +690,8 @@ { vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, oi->interface->name, oa->name, VNL, VNL); - ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb); + ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, + oi->lsdb); } } break; @@ -769,9 +732,7 @@ "Any Link state ID\n" "Specify Advertising Router as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); ALIAS (show_ipv6_ospf6_database_type_router, show_ipv6_ospf6_database_type_adv_router_cmd, @@ -792,8 +753,7 @@ "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Search by Advertising Router\n" - "Specify Advertising Router as IPv4 address notation\n" - ); + "Specify Advertising Router as IPv4 address notation\n"); ALIAS (show_ipv6_ospf6_database_type_router, show_ipv6_ospf6_database_type_adv_router_detail_cmd, @@ -817,9 +777,7 @@ "Search by Advertising Router\n" "Specify Advertising Router as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_id_router, show_ipv6_ospf6_database_id_router_cmd, @@ -830,8 +788,7 @@ "Display Link state database\n" "Any Link state Type\n" "Specify Link state ID as IPv4 address notation\n" - "Specify Advertising Router as IPv4 address notation\n" - ) + "Specify Advertising Router as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -845,8 +802,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link state ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -855,8 +811,7 @@ if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Advertising Router is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -899,9 +854,7 @@ "Specify Link state ID as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, show_ipv6_ospf6_database_adv_router_linkstate_id_cmd, @@ -913,8 +866,7 @@ "Search by Advertising Router\n" "Specify Advertising Router as IPv4 address notation\n" "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - ) + "Specify Link state ID as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -928,8 +880,7 @@ if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Advertising Router is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -938,8 +889,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link state ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -983,9 +933,7 @@ "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_type_id_router, show_ipv6_ospf6_database_type_id_router_cmd, @@ -1006,8 +954,7 @@ "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Specify Link state ID as IPv4 address notation\n" - "Specify Advertising Router as IPv4 address notation\n" - ) + "Specify Advertising Router as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -1026,8 +973,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link state ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -1036,8 +982,7 @@ if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Advertising Router is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -1102,9 +1047,7 @@ "Display Intra-Area-Prefix LSAs\n" "Specify Link state ID as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd, @@ -1128,8 +1071,7 @@ "Search by Advertising Router\n" "Specify Advertising Router as IPv4 address notation\n" "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - ) + "Specify Link state ID as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -1148,8 +1090,7 @@ if ((inet_pton (AF_INET, argv[0], &adv_router)) != 1) { - vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Advertising Router is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -1158,8 +1099,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link state ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link state ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -1227,18 +1167,12 @@ "Specify Advertising Router as IPv4 address notation\n" "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_self_originated, show_ipv6_ospf6_database_self_originated_cmd, "show ipv6 ospf6 database self-originated", - SHOW_STR - IPV6_STR - OSPF6_STR - "Display Self-originated LSAs\n" - ) + SHOW_STR IPV6_STR OSPF6_STR "Display Self-originated LSAs\n") { int level; struct listnode *i, *j; @@ -1286,9 +1220,7 @@ "Display Self-originated LSAs\n" "Display details of LSAs\n" "Dump LSAs\n" - "Display LSA's internal information\n" - ) - + "Display LSA's internal information\n") DEFUN (show_ipv6_ospf6_database_type_self_originated, show_ipv6_ospf6_database_type_self_originated_cmd, "show ipv6 ospf6 database " @@ -1306,9 +1238,7 @@ "Display Group-Membership LSAs\n" "Display Type-7 LSAs\n" "Display Link LSAs\n" - "Display Intra-Area-Prefix LSAs\n" - "Display Self-originated LSAs\n" - ) + "Display Intra-Area-Prefix LSAs\n" "Display Self-originated LSAs\n") { int level; struct listnode *i, *j; @@ -1344,7 +1274,8 @@ { vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, oi->interface->name, oa->name, VNL, VNL); - ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb); + ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, + oi->lsdb); } } break; @@ -1384,9 +1315,7 @@ "Display Intra-Area-Prefix LSAs\n" "Display Self-originated LSAs\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd, @@ -1409,8 +1338,7 @@ "Display Intra-Area-Prefix LSAs\n" "Display Self-originated LSAs\n" "Search by Link state ID\n" - "Specify Link state ID as IPv4 address notation\n" - ) + "Specify Link state ID as IPv4 address notation\n") { int level; struct listnode *i, *j; @@ -1429,8 +1357,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link State ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link State ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -1499,9 +1426,7 @@ "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_database_type_id_self_originated, show_ipv6_ospf6_database_type_id_self_originated_cmd, @@ -1522,8 +1447,7 @@ "Display Link LSAs\n" "Display Intra-Area-Prefix LSAs\n" "Specify Link state ID as IPv4 address notation\n" - "Display Self-originated LSAs\n" - ) + "Display Self-originated LSAs\n") { int level; struct listnode *i, *j; @@ -1542,8 +1466,7 @@ if ((inet_pton (AF_INET, argv[0], &id)) != 1) { - vty_out (vty, "Link State ID is not parsable: %s%s", - argv[0], VNL); + vty_out (vty, "Link State ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -1612,19 +1535,13 @@ "Search by Link state ID\n" "Specify Link state ID as IPv4 address notation\n" "Display details of LSAs\n" - "Dump LSAs\n" - "Display LSA's internal information\n" - ); + "Dump LSAs\n" "Display LSA's internal information\n"); DEFUN (show_ipv6_ospf6_border_routers, show_ipv6_ospf6_border_routers_cmd, "show ipv6 ospf6 border-routers", - SHOW_STR - IP6_STR - OSPF6_STR - "Display routing table for ABR and ASBR\n" - ) + SHOW_STR IP6_STR OSPF6_STR "Display routing table for ABR and ASBR\n") { u_int32_t adv_router; void (*showfunc) (struct vty *, struct ospf6_route *); @@ -1673,18 +1590,12 @@ IP6_STR OSPF6_STR "Display routing table for ABR and ASBR\n" - "Specify Router-ID\n" - "Display Detail\n" - ); + "Specify Router-ID\n" "Display Detail\n"); DEFUN (show_ipv6_ospf6_linkstate, show_ipv6_ospf6_linkstate_cmd, "show ipv6 ospf6 linkstate", - SHOW_STR - IP6_STR - OSPF6_STR - "Display linkstate routing table\n" - ) + SHOW_STR IP6_STR OSPF6_STR "Display linkstate routing table\n") { struct listnode *node; struct ospf6_area *oa; @@ -1708,8 +1619,7 @@ OSPF6_STR "Display linkstate routing table\n" "Display Router Entry\n" - "Specify Router ID as IPv4 address notation\n" - ); + "Specify Router ID as IPv4 address notation\n"); ALIAS (show_ipv6_ospf6_linkstate, show_ipv6_ospf6_linkstate_network_cmd, @@ -1720,17 +1630,12 @@ "Display linkstate routing table\n" "Display Network Entry\n" "Specify Router ID as IPv4 address notation\n" - "Specify Link state ID as IPv4 address notation\n" - ); + "Specify Link state ID as IPv4 address notation\n"); DEFUN (show_ipv6_ospf6_linkstate_detail, show_ipv6_ospf6_linkstate_detail_cmd, "show ipv6 ospf6 linkstate detail", - SHOW_STR - IP6_STR - OSPF6_STR - "Display linkstate routing table\n" - ) + SHOW_STR IP6_STR OSPF6_STR "Display linkstate routing table\n") { const char *sargv[CMD_ARGC_MAX]; int i, sargc; @@ -1788,6 +1693,7 @@ install_element_ospf6_debug_asbr (); install_element_ospf6_debug_abr (); install_element_ospf6_debug_flood (); + install_element_ospf6_debug_database (); install_element (VIEW_NODE, &show_version_ospf6_cmd); install_element (ENABLE_NODE, &show_version_ospf6_cmd); @@ -1888,4 +1794,36 @@ thread_add_read (master, ospf6_receive, NULL, ospf6_sock); } +char * +ip2str (u_int32_t addr) +{ + static char str[16]; + unsigned char *ip; + ip = (unsigned char *) &addr; + sprintf (str, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); + return str; +} +void +set_time (struct timeval *t) +{ + struct timeval now; + + gettimeofday (&now, (struct timezone *) NULL); + t->tv_sec = now.tv_sec; + t->tv_usec = now.tv_usec; + return; +} + +float +elapsed_time (struct timeval *t) +{ + struct timeval now; + float T; + + gettimeofday (&now, (struct timezone *) NULL); + T = (float) (now.tv_sec - t->tv_sec) + + (float) (now.tv_usec - t->tv_usec) / 1000000; + + return T; +} diff -Naur quagga-0.99.9/ospf6d/ospf6d.conf.sample quagga-0.99.9-af/ospf6d/ospf6d.conf.sample --- quagga-0.99.9/ospf6d/ospf6d.conf.sample 2004-05-18 14:28:01.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6d.conf.sample 2008-12-03 13:42:15.000000000 -0800 @@ -9,16 +9,30 @@ ! debug ospf6 neighbor state ! -interface fxp0 - ipv6 ospf6 cost 1 - ipv6 ospf6 hello-interval 10 - ipv6 ospf6 dead-interval 40 - ipv6 ospf6 retransmit-interval 5 - ipv6 ospf6 priority 0 + interface eth0 + ip address 10.0.0.10/32 + ipv6 address a::a/128 + ipv6 ospf6 priority 1 ipv6 ospf6 transmit-delay 1 ipv6 ospf6 instance-id 0 + ipv6 ospf6 ifmtu 1500 + ipv6 ospf6 cost 1 + ipv6 ospf6 hello-interval 2 + ipv6 ospf6 dead-interval 6 + ipv6 ospf6 retransmit-interval 5 + ipv6 ospf6 network manet-designated-router + ipv6 ospf6 ackinterval 1800 + ipv6 ospf6 diffhellos + ipv6 ospf6 backupwaitinterval 2000 + ipv6 ospf6 twohoprefresh 3 + ipv6 ospf6 hellorepeatcount 3 + ipv6 ospf6 adjacencyconnectivity biconnected + ipv6 ospf6 lsafullness mincostlsa + ipv6 ospf6 flood-delay 100 + ipv6 ospf6 smf_mdr_talk ! interface lo0 + ipv6 address 5f0a::/128 ipv6 ospf6 cost 1 ipv6 ospf6 hello-interval 10 ipv6 ospf6 dead-interval 40 @@ -26,11 +40,12 @@ ipv6 ospf6 priority 1 ipv6 ospf6 transmit-delay 1 ipv6 ospf6 instance-id 0 + ipv6 ospf6 network loopback ! router ospf6 router-id 255.1.1.1 redistribute static route-map static-ospf6 - interface fxp0 area 0.0.0.0 + interface eth0 area 0.0.0.0 ! access-list access4 permit 127.0.0.1/32 ! diff -Naur quagga-0.99.9/ospf6d/ospf6d.h quagga-0.99.9-af/ospf6d/ospf6d.h --- quagga-0.99.9/ospf6d/ospf6d.h 2007-02-05 06:15:17.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6d.h 2008-12-03 13:42:15.000000000 -0800 @@ -117,6 +117,12 @@ void ospf6_debug (); void ospf6_init (); -#endif /* OSPF6D_H */ +char *ip2str (u_int32_t addr); +void set_time (struct timeval *t); +float elapsed_time (struct timeval *t); +typedef char boolean; +#define false 0 +#define true 1 +#endif /* OSPF6D_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_flood.c quagga-0.99.9-af/ospf6d/ospf6_flood.c --- quagga-0.99.9/ospf6d/ospf6_flood.c 2005-01-26 04:46:48.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6_flood.c 2008-12-03 13:42:15.000000000 -0800 @@ -42,6 +42,9 @@ #include "ospf6_flood.h" + +#include "ospf6d.h" //for settime() + unsigned char conf_debug_ospf6_flooding; struct ospf6_lsdb * @@ -108,10 +111,18 @@ return; } + set_time (&lsa->originated); + + /* store it in the LSDB for self-originated LSAs */ lsdb_self = ospf6_get_scoped_lsdb_self (lsa); ospf6_lsdb_add (ospf6_lsa_copy (lsa), lsdb_self); + if (IS_OSPF6_DEBUG_DATABASE (DATABASE_DETAIL)) + ospf6_debug_lsdb_show (OSPF6_DEBUG_DATABASE_DETAIL, lsdb_self); + else if (IS_OSPF6_DEBUG_DATABASE (DATABASE)) + ospf6_debug_lsdb_show (OSPF6_DEBUG_DATABASE, lsdb_self); + lsa->refresh = thread_add_timer (master, ospf6_lsa_refresh, lsa, LS_REFRESH_TIME); @@ -129,16 +140,14 @@ } void -ospf6_lsa_originate_process (struct ospf6_lsa *lsa, - struct ospf6 *process) +ospf6_lsa_originate_process (struct ospf6_lsa *lsa, struct ospf6 *process) { lsa->lsdb = process->lsdb; ospf6_lsa_originate (lsa); } void -ospf6_lsa_originate_area (struct ospf6_lsa *lsa, - struct ospf6_area *oa) +ospf6_lsa_originate_area (struct ospf6_lsa *lsa, struct ospf6_area *oa) { lsa->lsdb = oa->lsdb; ospf6_lsa_originate (lsa); @@ -236,6 +245,11 @@ lsa->installed = now; ospf6_lsdb_add (lsa, lsa->lsdb); + + if (IS_OSPF6_DEBUG_DATABASE (DATABASE_DETAIL)) + ospf6_debug_lsdb_show (OSPF6_DEBUG_DATABASE_DETAIL, lsa->lsdb); + else if (IS_OSPF6_DEBUG_DATABASE (DATABASE)) + ospf6_debug_lsdb_show (OSPF6_DEBUG_DATABASE, lsa->lsdb); return; } @@ -251,6 +265,10 @@ int retrans_added = 0; int is_debug = 0; + if (oi->type == OSPF6_IFTYPE_LOOPBACK) + return; + + if (IS_OSPF6_DEBUG_FLOODING || IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) { @@ -301,7 +319,8 @@ if (ospf6_lsa_compare (lsa, req) == 0) { if (is_debug) - zlog_debug ("Requesting the same, remove it, next neighbor"); + zlog_debug + ("Requesting the same, remove it, next neighbor"); ospf6_lsdb_remove (req, on->request_list); continue; } @@ -330,6 +349,8 @@ if (is_debug) zlog_debug ("Add retrans-list of this neighbor"); ospf6_increment_retrans_count (lsa); + + //thread_add_timer must be used for delayed events ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list); if (on->thread_send_lsupdate == NULL) on->thread_send_lsupdate = @@ -364,11 +385,18 @@ zlog_debug ("Received is from the I/F, itself BDR, next interface"); return; } + if (from && from->ospf6_if == oi) + SET_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK); /* (5) flood the LSA out the interface. */ if (is_debug) zlog_debug ("Schedule flooding for the interface"); - if (if_is_broadcast (oi->interface)) + + + if (oi->type == OSPF6_IFTYPE_BROADCAST || + oi->type == OSPF6_IFTYPE_MDR || + oi->type == OSPF6_IFTYPE_POINTOMULTIPOINT || + oi->type == OSPF6_IFTYPE_NBMA) { ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsupdate_list); if (oi->thread_send_lsupdate == NULL) @@ -441,7 +469,8 @@ } void -ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi) +ospf6_flood_clear_interface (struct ospf6_lsa *lsa, + struct ospf6_interface *oi) { struct listnode *node, *nnode; struct ospf6_neighbor *on; @@ -522,6 +551,7 @@ { struct ospf6_interface *oi; int is_debug = 0; + struct ospf6_lsa *lsa_ack; if (IS_OSPF6_DEBUG_FLOODING || IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type)) @@ -548,7 +578,8 @@ if (oi->drouter == from->router_id) { if (is_debug) - zlog_debug ("Delayed acknowledgement (BDR & MoreRecent & from DR)"); + zlog_debug + ("Delayed acknowledgement (BDR & MoreRecent & from DR)"); /* Delayed acknowledgement */ ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); if (oi->thread_send_lsack == NULL) @@ -572,7 +603,8 @@ if (oi->drouter == from->router_id) { if (is_debug) - zlog_debug ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)"); + zlog_debug + ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)"); /* Delayed acknowledgement */ ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); if (oi->thread_send_lsack == NULL) @@ -582,7 +614,8 @@ else { if (is_debug) - zlog_debug ("No acknowledgement (BDR & Duplicate & ImpliedAck & ! from DR)"); + zlog_debug + ("No acknowledgement (BDR & Duplicate & ImpliedAck & ! from DR)"); } return; } @@ -766,7 +799,8 @@ OSPF6_LSA_SCOPE (new->header->type) == OSPF6_SCOPE_AS) { if (is_debug) - zlog_debug ("AS-External-LSA (or AS-scope LSA) in stub area, discard"); + zlog_debug + ("AS-External-LSA (or AS-scope LSA) in stub area, discard"); ospf6_lsa_delete (new); return; } @@ -839,10 +873,11 @@ struct timeval now, res; gettimeofday (&now, (struct timezone *) NULL); timersub (&now, &old->installed, &res); - if (res.tv_sec < MIN_LS_ARRIVAL) + if (res.tv_sec < from->ospf6_if->area->ospf6->minLSArrival) { if (is_debug) - zlog_debug ("LSA can't be updated within MinLSArrival, discard"); + zlog_debug + ("LSA can't be updated within MinLSArrival, discard"); ospf6_lsa_delete (new); return; /* examin next lsa */ } @@ -897,7 +932,8 @@ if (is_debug) { - zlog_debug ("Received is not newer, on the neighbor's request-list"); + zlog_debug + ("Received is not newer, on the neighbor's request-list"); zlog_debug ("BadLSReq, discard the received LSA"); } @@ -967,7 +1003,14 @@ /* XXX, MinLSArrival check !? RFC 2328 13 (8) */ + ospf6_lsdb_add (ospf6_lsa_copy (old), from->lsupdate_list); + + //should respond to lsa immediately if not a duplicate, but + //this code could respond to lsa before MinLSArrival passes + //RFC 2328 13 (8) + THREAD_OFF (from->thread_send_lsupdate); + from->thread_send_lsupdate = NULL; if (from->thread_send_lsupdate == NULL) from->thread_send_lsupdate = thread_add_event (master, ospf6_lsupdate_send_neighbor, from, 0); @@ -982,10 +1025,7 @@ DEFUN (debug_ospf6_flooding, debug_ospf6_flooding_cmd, "debug ospf6 flooding", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 flooding function\n" - ) + DEBUG_STR OSPF6_STR "Debug OSPFv3 flooding function\n") { OSPF6_DEBUG_FLOODING_ON (); return CMD_SUCCESS; @@ -994,11 +1034,7 @@ DEFUN (no_debug_ospf6_flooding, no_debug_ospf6_flooding_cmd, "no debug ospf6 flooding", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 flooding function\n" - ) + NO_STR DEBUG_STR OSPF6_STR "Debug OSPFv3 flooding function\n") { OSPF6_DEBUG_FLOODING_OFF (); return CMD_SUCCESS; diff -Naur quagga-0.99.9/ospf6d/ospf6_flood.h quagga-0.99.9-af/ospf6d/ospf6_flood.h --- quagga-0.99.9/ospf6d/ospf6_flood.h 2004-09-02 02:27:59.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_flood.h 2008-12-03 13:42:15.000000000 -0800 @@ -39,8 +39,7 @@ void ospf6_lsa_originate (struct ospf6_lsa *lsa); void ospf6_lsa_originate_process (struct ospf6_lsa *lsa, struct ospf6 *process); -void ospf6_lsa_originate_area (struct ospf6_lsa *lsa, - struct ospf6_area *oa); +void ospf6_lsa_originate_area (struct ospf6_lsa *lsa, struct ospf6_area *oa); void ospf6_lsa_originate_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi); void ospf6_lsa_purge (struct ospf6_lsa *lsa); diff -Naur quagga-0.99.9/ospf6d/ospf6_ghc.c quagga-0.99.9-af/ospf6d/ospf6_ghc.c --- quagga-0.99.9/ospf6d/ospf6_ghc.c 1969-12-31 16:00:00.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6_ghc.c 2008-12-03 13:42:15.000000000 -0800 @@ -0,0 +1,6 @@ +/* + * Copyright (C) Boeing Co. + */ + +#include + diff -Naur quagga-0.99.9/ospf6d/ospf6_ghc.h quagga-0.99.9-af/ospf6d/ospf6_ghc.h --- quagga-0.99.9/ospf6d/ospf6_ghc.h 1969-12-31 16:00:00.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6_ghc.h 2008-12-03 13:42:15.000000000 -0800 @@ -0,0 +1,9 @@ +/* + * Copyright (C) 2005 Boeing + */ + +#ifndef OSPF6_GHC_H +#define OSPF6_GHC_H + + +#endif /* OSPF6_GHC_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_interface.c quagga-0.99.9-af/ospf6d/ospf6_interface.c --- quagga-0.99.9/ospf6d/ospf6_interface.c 2006-05-15 03:43:52.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_interface.c 2008-12-03 13:42:15.000000000 -0800 @@ -42,10 +42,12 @@ #include "ospf6_spf.h" #include "ospf6d.h" + + + unsigned char conf_debug_ospf6_interface = 0; -const char *ospf6_interface_state_str[] = -{ +const char *ospf6_interface_state_str[] = { "None", "Down", "Loopback", @@ -79,7 +81,8 @@ { case OSPF6_LSTYPE_LINK: if (OSPF6_INTERFACE (lsa->lsdb->data)->state == OSPF6_INTERFACE_DR) - OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE (lsa->lsdb->data)); + OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE + (lsa->lsdb->data)); ospf6_spf_schedule (OSPF6_INTERFACE (lsa->lsdb->data)->area); break; @@ -121,6 +124,21 @@ oi->state = OSPF6_INTERFACE_DOWN; oi->flag = 0; + + + + + + + if (if_is_broadcast (ifp)) + oi->type = OSPF6_IFTYPE_BROADCAST; + else if (if_is_pointopoint (ifp)) + oi->type = OSPF6_IFTYPE_POINTOPOINT; + else if (if_is_loopback (ifp)) + oi->type = OSPF6_IFTYPE_LOOPBACK; + else + oi->type = OSPF6_IFTYPE_BROADCAST; + /* Try to adjust I/O buffer size with IfMtu */ oi->ifmtu = ifp->mtu6; iobuflen = ospf6_iobuf_size (ifp->mtu6); @@ -139,7 +157,8 @@ oi->lsdb->hook_remove = ospf6_interface_lsdb_hook; oi->lsdb_self = ospf6_lsdb_create (oi); - oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES); + oi->route_connected = + OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES); oi->route_connected->scope = oi; /* link both */ @@ -191,8 +210,7 @@ { UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE); - oi->thread_send_hello = - thread_add_event (master, ospf6_hello_send, oi, 0); + oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0); } void @@ -233,7 +251,10 @@ /* linklocal scope check */ if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6)) + { l = &c->address->u.prefix6; + break; + } } return l; } @@ -322,6 +343,8 @@ /* reset linklocal pointer */ oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp); + oi->linklocal_addr_ipv4 = oi->linklocal_addr; + /* if area is null, do not make connected-route list */ if (oi->area == NULL) return; @@ -331,11 +354,62 @@ for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c)) { - if (c->address->family != AF_INET6) + +//IPv4 Address Family + if (is_af_ipv4_unicast (oi) || is_af_ipv4_multicast (oi)) + { + if (c->address->family != AF_INET) //AF_INET = 2 continue; - CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address); - CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address); + //remove loopback interfaces + CONTINUE_IF_V4_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, + c->address); + + /* apply filter */ + if (oi->plist_name) + { + struct prefix_list *plist; + enum prefix_list_type ret; + char buf[128]; + + prefix2str (c->address, buf, sizeof (buf)); + plist = prefix_list_lookup (AFI_IP, oi->plist_name); + ret = prefix_list_apply (plist, (void *) c->address); + if (ret == PREFIX_DENY) + { + if (IS_OSPF6_DEBUG_INTERFACE) + zlog_debug ("%s on %s filtered by prefix-list %s ", + buf, oi->interface->name, oi->plist_name); + continue; + } + } + route = ospf6_route_create (); + + af_ipv4_to_ipv6 ((struct prefix_ipv6 *) &route->prefix, + (struct prefix_ipv4 *) c->address); + + //AF draft 05 Sec 2.5 - linklocal address should be the IPv4 address + //Set the linklocal address used in the link_lsa. + oi->linklocal_addr_ipv4 = &route->prefix.u.prefix6; + + route->type = OSPF6_DEST_TYPE_NETWORK; + route->path.area_id = oi->area->area_id; + route->path.type = OSPF6_PATH_TYPE_INTRA; + route->path.cost = oi->cost; + route->nexthop[0].ifindex = oi->interface->ifindex; + inet_pton (AF_INET6, "::127.0.0.1", &route->nexthop[0].address); + ospf6_route_add (route, oi->route_connected); + } +//IPv6 Address Family + else if (is_af_ipv6_unicast (oi) || is_af_ipv6_multicast (oi)) + { + if (c->address->family != AF_INET6) //AF_INET6 = 10 + continue; + + CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, + c->address); + CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, + c->address); CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address); CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address); CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address); @@ -358,10 +432,8 @@ continue; } } - route = ospf6_route_create (); memcpy (&route->prefix, c->address, sizeof (struct prefix)); - apply_mask (&route->prefix); route->type = OSPF6_DEST_TYPE_NETWORK; route->path.area_id = oi->area->area_id; route->path.type = OSPF6_PATH_TYPE_INTRA; @@ -370,6 +442,7 @@ inet_pton (AF_INET6, "::1", &route->nexthop[0].address); ospf6_route_add (route, oi->route_connected); } + } /* create new Link-LSA */ OSPF6_LINK_LSA_SCHEDULE (oi); @@ -398,13 +471,11 @@ if ((prev_state == OSPF6_INTERFACE_DR || prev_state == OSPF6_INTERFACE_BDR) && - (next_state != OSPF6_INTERFACE_DR && - next_state != OSPF6_INTERFACE_BDR)) + (next_state != OSPF6_INTERFACE_DR && next_state != OSPF6_INTERFACE_BDR)) ospf6_leave_alldrouters (oi->interface->ifindex); if ((prev_state != OSPF6_INTERFACE_DR && prev_state != OSPF6_INTERFACE_BDR) && - (next_state == OSPF6_INTERFACE_DR || - next_state == OSPF6_INTERFACE_BDR)) + (next_state == OSPF6_INTERFACE_DR || next_state == OSPF6_INTERFACE_BDR)) ospf6_join_alldrouters (oi->interface->ifindex); OSPF6_ROUTER_LSA_SCHEDULE (oi->area); @@ -591,8 +662,7 @@ assert (oi && oi->interface); if (IS_OSPF6_DEBUG_INTERFACE) - zlog_debug ("Interface Event %s: [InterfaceUp]", - oi->interface->name); + zlog_debug ("Interface Event %s: [InterfaceUp]", oi->interface->name); /* check physical interface is up */ if (! if_is_up (oi->interface)) @@ -607,8 +677,7 @@ if (oi->state > OSPF6_INTERFACE_DOWN) { if (IS_OSPF6_DEBUG_INTERFACE) - zlog_debug ("Interface %s already enabled", - oi->interface->name); + zlog_debug ("Interface %s already enabled", oi->interface->name); return 0; } @@ -623,7 +692,9 @@ thread_add_event (master, ospf6_hello_send, oi, 0); /* decide next interface state */ - if (if_is_pointopoint (oi->interface)) + if (oi->type == OSPF6_IFTYPE_POINTOPOINT || + + oi->type == OSPF6_IFTYPE_POINTOMULTIPOINT) ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi); else if (oi->priority == 0) ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi); @@ -645,8 +716,7 @@ assert (oi && oi->interface); if (IS_OSPF6_DEBUG_INTERFACE) - zlog_debug ("Interface Event %s: [WaitTimer]", - oi->interface->name); + zlog_debug ("Interface Event %s: [WaitTimer]", oi->interface->name); if (oi->state == OSPF6_INTERFACE_WAITING) ospf6_interface_state_change (dr_election (oi), oi); @@ -663,8 +733,7 @@ assert (oi && oi->interface); if (IS_OSPF6_DEBUG_INTERFACE) - zlog_debug ("Interface Event %s: [BackupSeen]", - oi->interface->name); + zlog_debug ("Interface Event %s: [BackupSeen]", oi->interface->name); if (oi->state == OSPF6_INTERFACE_WAITING) ospf6_interface_state_change (dr_election (oi), oi); @@ -681,12 +750,10 @@ assert (oi && oi->interface); if (IS_OSPF6_DEBUG_INTERFACE) - zlog_debug ("Interface Event %s: [NeighborChange]", - oi->interface->name); + zlog_debug ("Interface Event %s: [NeighborChange]", oi->interface->name); if (oi->state == OSPF6_INTERFACE_DROTHER || - oi->state == OSPF6_INTERFACE_BDR || - oi->state == OSPF6_INTERFACE_DR) + oi->state == OSPF6_INTERFACE_BDR || oi->state == OSPF6_INTERFACE_DR) ospf6_interface_state_change (dr_election (oi), oi); return 0; @@ -701,8 +768,7 @@ assert (oi && oi->interface); if (IS_OSPF6_DEBUG_INTERFACE) - zlog_debug ("Interface Event %s: [LoopInd]", - oi->interface->name); + zlog_debug ("Interface Event %s: [LoopInd]", oi->interface->name); /* XXX not yet */ @@ -720,8 +786,7 @@ assert (oi && oi->interface); if (IS_OSPF6_DEBUG_INTERFACE) - zlog_debug ("Interface Event %s: [InterfaceDown]", - oi->interface->name); + zlog_debug ("Interface Event %s: [InterfaceDown]", oi->interface->name); /* Leave AllSPFRouters */ if (oi->state > OSPF6_INTERFACE_DOWN) @@ -764,8 +829,7 @@ type = "UNKNOWN"; vty_out (vty, "%s is %s, type %s%s", - ifp->name, updown[if_is_up (ifp)], type, - VNL); + ifp->name, updown[if_is_up (ifp)], type, VNL); vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL); if (ifp->info == NULL) @@ -776,6 +840,20 @@ else oi = (struct ospf6_interface *) ifp->info; + if (oi->type == OSPF6_IFTYPE_BROADCAST) + type = "BROADCAST"; + else if (oi->type == OSPF6_IFTYPE_LOOPBACK) + type = "LOOPBACK"; + else if (oi->type == OSPF6_IFTYPE_NBMA) + type = "NBMA"; + else if (oi->type == OSPF6_IFTYPE_POINTOMULTIPOINT) + type = "POINT TO MULTIPOINT"; + + else if (oi->type == OSPF6_IFTYPE_POINTOPOINT) + type = "POINT TO POINT"; + vty_out (vty, " OSPF6 type %s%s", type, VTY_NEWLINE); + + vty_out (vty, " Internet Address:%s", VNL); for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c)) @@ -785,16 +863,13 @@ switch (p->family) { case AF_INET: - vty_out (vty, " inet : %s%s", strbuf, - VNL); + vty_out (vty, " inet : %s%s", strbuf, VNL); break; case AF_INET6: - vty_out (vty, " inet6: %s%s", strbuf, - VNL); + vty_out (vty, " inet6: %s%s", strbuf, VNL); break; default: - vty_out (vty, " ??? : %s%s", strbuf, - VNL); + vty_out (vty, " ??? : %s%s", strbuf, VNL); break; } } @@ -803,29 +878,24 @@ { vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s", oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); - inet_ntop (AF_INET, &oi->area->area_id, - strbuf, sizeof (strbuf)); - vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost, - VNL); + inet_ntop (AF_INET, &oi->area->area_id, strbuf, sizeof (strbuf)); + vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost, VNL); } else vty_out (vty, " Not Attached to Area%s", VNL); vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s", ospf6_interface_state_str[oi->state], - oi->transdelay, oi->priority, - VNL); + oi->transdelay, oi->priority, VNL); vty_out (vty, " Timer intervals configured:%s", VNL); vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s", - oi->hello_interval, oi->dead_interval, oi->rxmt_interval, - VNL); + oi->hello_interval, oi->dead_interval, oi->rxmt_interval, VNL); inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter)); inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter)); vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); - vty_out (vty, " Number of I/F scoped LSAs is %u%s", - oi->lsdb->count, VNL); + vty_out (vty, " Number of I/F scoped LSAs is %u%s", oi->lsdb->count, VNL); gettimeofday (&now, (struct timezone *) NULL); @@ -835,8 +905,7 @@ timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", oi->lsupdate_list->count, duration, - (oi->thread_send_lsupdate ? "on" : "off"), - VNL); + (oi->thread_send_lsupdate ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); @@ -847,8 +916,7 @@ timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", oi->lsack_list->count, duration, - (oi->thread_send_lsack ? "on" : "off"), - VNL); + (oi->thread_send_lsack ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); @@ -860,12 +928,7 @@ DEFUN (show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_ifname_cmd, "show ipv6 ospf6 interface IFNAME", - SHOW_STR - IP6_STR - OSPF6_STR - INTERFACE_STR - IFNAME_STR - ) + SHOW_STR IP6_STR OSPF6_STR INTERFACE_STR IFNAME_STR) { struct interface *ifp; struct listnode *i; @@ -875,8 +938,7 @@ ifp = if_lookup_by_name (argv[0]); if (ifp == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[0], - VNL); + vty_out (vty, "No such Interface: %s%s", argv[0], VNL); return CMD_WARNING; } ospf6_interface_show (vty, ifp); @@ -892,12 +954,7 @@ ALIAS (show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_cmd, - "show ipv6 ospf6 interface", - SHOW_STR - IP6_STR - OSPF6_STR - INTERFACE_STR - ); + "show ipv6 ospf6 interface", SHOW_STR IP6_STR OSPF6_STR INTERFACE_STR); DEFUN (show_ipv6_ospf6_interface_ifname_prefix, show_ipv6_ospf6_interface_ifname_prefix_cmd, @@ -905,10 +962,7 @@ SHOW_STR IP6_STR OSPF6_STR - INTERFACE_STR - IFNAME_STR - "Display connected prefixes to advertise\n" - ) + INTERFACE_STR IFNAME_STR "Display connected prefixes to advertise\n") { struct interface *ifp; struct ospf6_interface *oi; @@ -944,9 +998,7 @@ IFNAME_STR "Display connected prefixes to advertise\n" OSPF6_ROUTE_ADDRESS_STR - OSPF6_ROUTE_PREFIX_STR - "Dispaly details of the prefixes\n" - ); + OSPF6_ROUTE_PREFIX_STR "Dispaly details of the prefixes\n"); ALIAS (show_ipv6_ospf6_interface_ifname_prefix, show_ipv6_ospf6_interface_ifname_prefix_match_cmd, @@ -958,19 +1010,14 @@ IFNAME_STR "Display connected prefixes to advertise\n" OSPF6_ROUTE_PREFIX_STR - OSPF6_ROUTE_MATCH_STR - "Dispaly details of the prefixes\n" - ); + OSPF6_ROUTE_MATCH_STR "Dispaly details of the prefixes\n"); DEFUN (show_ipv6_ospf6_interface_prefix, show_ipv6_ospf6_interface_prefix_cmd, "show ipv6 ospf6 interface prefix", SHOW_STR IP6_STR - OSPF6_STR - INTERFACE_STR - "Display connected prefixes to advertise\n" - ) + OSPF6_STR INTERFACE_STR "Display connected prefixes to advertise\n") { struct listnode *i; struct ospf6_interface *oi; @@ -997,9 +1044,7 @@ INTERFACE_STR "Display connected prefixes to advertise\n" OSPF6_ROUTE_ADDRESS_STR - OSPF6_ROUTE_PREFIX_STR - "Dispaly details of the prefixes\n" - ); + OSPF6_ROUTE_PREFIX_STR "Dispaly details of the prefixes\n"); ALIAS (show_ipv6_ospf6_interface_prefix, show_ipv6_ospf6_interface_prefix_match_cmd, @@ -1010,20 +1055,14 @@ INTERFACE_STR "Display connected prefixes to advertise\n" OSPF6_ROUTE_PREFIX_STR - OSPF6_ROUTE_MATCH_STR - "Dispaly details of the prefixes\n" - ); + OSPF6_ROUTE_MATCH_STR "Dispaly details of the prefixes\n"); /* interface variable set command */ DEFUN (ipv6_ospf6_ifmtu, ipv6_ospf6_ifmtu_cmd, "ipv6 ospf6 ifmtu <1-65535>", - IP6_STR - OSPF6_STR - "Interface MTU\n" - "OSPFv3 Interface MTU\n" - ) + IP6_STR OSPF6_STR "Interface MTU\n" "OSPFv3 Interface MTU\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1078,12 +1117,7 @@ DEFUN (no_ipv6_ospf6_ifmtu, no_ipv6_ospf6_ifmtu_cmd, - "no ipv6 ospf6 ifmtu", - NO_STR - IP6_STR - OSPF6_STR - "Interface MTU\n" - ) + "no ipv6 ospf6 ifmtu", NO_STR IP6_STR OSPF6_STR "Interface MTU\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1128,10 +1162,7 @@ ipv6_ospf6_cost_cmd, "ipv6 ospf6 cost <1-65535>", IP6_STR - OSPF6_STR - "Interface cost\n" - "Outgoing metric of this interface\n" - ) + OSPF6_STR "Interface cost\n" "Outgoing metric of this interface\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1177,11 +1208,7 @@ DEFUN (ipv6_ospf6_hellointerval, ipv6_ospf6_hellointerval_cmd, "ipv6 ospf6 hello-interval <1-65535>", - IP6_STR - OSPF6_STR - "Interval time of Hello packets\n" - SECONDS_STR - ) + IP6_STR OSPF6_STR "Interval time of Hello packets\n" SECONDS_STR) { struct ospf6_interface *oi; struct interface *ifp; @@ -1204,9 +1231,7 @@ "ipv6 ospf6 dead-interval <1-65535>", IP6_STR OSPF6_STR - "Interval time after which a neighbor is declared down\n" - SECONDS_STR - ) + "Interval time after which a neighbor is declared down\n" SECONDS_STR) { struct ospf6_interface *oi; struct interface *ifp; @@ -1227,11 +1252,7 @@ DEFUN (ipv6_ospf6_transmitdelay, ipv6_ospf6_transmitdelay_cmd, "ipv6 ospf6 transmit-delay <1-3600>", - IP6_STR - OSPF6_STR - "Transmit delay of this interface\n" - SECONDS_STR - ) + IP6_STR OSPF6_STR "Transmit delay of this interface\n" SECONDS_STR) { struct ospf6_interface *oi; struct interface *ifp; @@ -1255,8 +1276,7 @@ IP6_STR OSPF6_STR "Time between retransmitting lost link state advertisements\n" - SECONDS_STR - ) + SECONDS_STR) { struct ospf6_interface *oi; struct interface *ifp; @@ -1277,11 +1297,7 @@ DEFUN (ipv6_ospf6_priority, ipv6_ospf6_priority_cmd, "ipv6 ospf6 priority <0-255>", - IP6_STR - OSPF6_STR - "Router priority\n" - "Priority value\n" - ) + IP6_STR OSPF6_STR "Router priority\n" "Priority value\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1306,13 +1322,11 @@ ipv6_ospf6_instance_cmd, "ipv6 ospf6 instance-id <0-255>", IP6_STR - OSPF6_STR - "Instance ID for this interface\n" - "Instance ID value\n" - ) + OSPF6_STR "Instance ID for this interface\n" "Instance ID value\n") { struct ospf6_interface *oi; struct interface *ifp; + u_char instance_id; ifp = (struct interface *)vty->index; assert (ifp); @@ -1322,7 +1336,25 @@ oi = ospf6_interface_create (ifp); assert (oi); - oi->instance_id = strtol (argv[0], NULL, 10); + instance_id = (u_char) strtol (argv[0], NULL, 10); + + if (instance_id == oi->instance_id) + { + if (IS_OSPF6_DEBUG_INTERFACE) + zlog_warn + ("%s: ignoring new instance id (same as current instance id): %d", + __func__, instance_id); + } + else + { + oi->instance_id = instance_id; + if (oi->state > OSPF6_INTERFACE_DOWN) + { + thread_execute (master, interface_down, oi, 0); + thread_execute (master, interface_up, oi, 0); + } + } + return CMD_SUCCESS; } @@ -1331,8 +1363,7 @@ "ipv6 ospf6 passive", IP6_STR OSPF6_STR - "passive interface, No adjacency will be formed on this interface\n" - ) + "passive interface, No adjacency will be formed on this interface\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1365,8 +1396,7 @@ NO_STR IP6_STR OSPF6_STR - "passive interface: No Adjacency will be formed on this I/F\n" - ) + "passive interface: No Adjacency will be formed on this I/F\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1381,8 +1411,7 @@ UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); THREAD_OFF (oi->thread_send_hello); - oi->thread_send_hello = - thread_add_event (master, ospf6_hello_send, oi, 0); + oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0); return CMD_SUCCESS; } @@ -1393,9 +1422,7 @@ IP6_STR OSPF6_STR "Advertising options\n" - "Filter prefix using prefix-list\n" - "Prefix list name\n" - ) + "Filter prefix using prefix-list\n" "Prefix list name\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1424,15 +1451,92 @@ return CMD_SUCCESS; } +DEFUN (ipv6_ospf6_network, + ipv6_ospf6_network_cmd, + "ipv6 ospf6 network (broadcast|non-broadcast|point-to-multipoint|point-to-point|loopback|manet-designated-router|manet-broadcast)", + "IPv6 Information\n" + "OSPF6 interface commands\n" + "Network type\n" + "Specify OSPF6 broadcast multi-access network\n" + "Specify OSPF6 NBMA network\n" + "Specify OSPF6 point-to-multipoint network\n" + "Specify OSPF6 point-to-point network\n" + "Specify OSPF6 loopback\n" + "Specify OSPF6 manet-designated-router (MDR) network\n" + "Specify OSPF6 manet-broadcast network\n" ) +{ + + struct ospf6_interface *oi; + struct interface *ifp; + int old_type; + + ifp = (struct interface *) vty->index; + assert (ifp); + oi = (struct ospf6_interface *) ifp->info; + if (!oi) + oi = ospf6_interface_create (ifp); + assert (oi); + old_type = oi->type; + + if (strncmp (argv[0], "b", 1) == 0) + oi->type = OSPF6_IFTYPE_BROADCAST; + else if (strncmp (argv[0], "n", 1) == 0) + oi->type = OSPF6_IFTYPE_NBMA; + else if (strncmp (argv[0], "point-to-m", 10) == 0) + oi->type = OSPF6_IFTYPE_POINTOMULTIPOINT; + else if (strncmp (argv[0], "point-to-p", 10) == 0) + oi->type = OSPF6_IFTYPE_POINTOPOINT; + else if (strncmp (argv[0], "l", 1) == 0) + oi->type = OSPF6_IFTYPE_LOOPBACK; + + return CMD_SUCCESS; +} + +ALIAS (ipv6_ospf6_network, + ospf6_network_cmd, + "ospf6 network (broadcast|non-broadcast|point-to-multipoint|point-to-point|loopback|manet-designated-router)", + "OSPF interface commands\n" + "Network type\n" + "Specify OSPF6 broadcast multi-access network\n" + "Specify OSPF6 NBMA network\n" + "Specify OSPF6 point-to-multipoint network\n" + "Specify OSPF6 point-to-point network\n" + "Specify OSPF6 loopback\n" + "Specify OSPF6 manet-designated-router (MDR) network\n" + "Specify OSPF6 manet-broadcast network\n" ) +DEFUN (no_ipv6_ospf6_network, + no_ipv6_ospf6_network_cmd, + "no ipv6 ospf6 network", + NO_STR + "IP Information\n" "OSPF6 interface commands\n" "Network type\n") +{ + struct ospf6_interface *oi; + struct interface *ifp; + int old_type; + + ifp = (struct interface *) vty->index; + assert (ifp); + oi = (struct ospf6_interface *) ifp->info; + if (!oi) + oi = ospf6_interface_create (ifp); + assert (oi); + old_type = oi->type; + + oi->type = OSPF6_IFTYPE_NONE; + + return CMD_SUCCESS; +} + +ALIAS (no_ipv6_ospf6_network, + no_ospf6_network_cmd, + "no ospf6 network", + NO_STR "OSPF6 interface commands\n" "Network type\n") DEFUN (no_ipv6_ospf6_advertise_prefix_list, no_ipv6_ospf6_advertise_prefix_list_cmd, "no ipv6 ospf6 advertise prefix-list", NO_STR IP6_STR - OSPF6_STR - "Advertising options\n" - "Filter prefix using prefix-list\n" - ) + OSPF6_STR "Advertising options\n" "Filter prefix using prefix-list\n") { struct ospf6_interface *oi; struct interface *ifp; @@ -1476,28 +1580,42 @@ if (oi == NULL) continue; - vty_out (vty, "interface %s%s", - oi->interface->name, VNL); + vty_out (vty, "interface %s%s", oi->interface->name, VNL); if (ifp->desc) vty_out (vty, " description %s%s", ifp->desc, VNL); if (ifp->mtu6 != oi->ifmtu) vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL); - vty_out (vty, " ipv6 ospf6 cost %d%s", - oi->cost, VNL); + vty_out (vty, " ipv6 ospf6 cost %d%s", oi->cost, VNL); vty_out (vty, " ipv6 ospf6 hello-interval %d%s", oi->hello_interval, VNL); - vty_out (vty, " ipv6 ospf6 dead-interval %d%s", - oi->dead_interval, VNL); + vty_out (vty, " ipv6 ospf6 dead-interval %d%s", oi->dead_interval, VNL); vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s", oi->rxmt_interval, VNL); - vty_out (vty, " ipv6 ospf6 priority %d%s", - oi->priority, VNL); - vty_out (vty, " ipv6 ospf6 transmit-delay %d%s", - oi->transdelay, VNL); - vty_out (vty, " ipv6 ospf6 instance-id %d%s", - oi->instance_id, VNL); + vty_out (vty, " ipv6 ospf6 priority %d%s", oi->priority, VNL); + vty_out (vty, " ipv6 ospf6 transmit-delay %d%s", oi->transdelay, VNL); + vty_out (vty, " ipv6 ospf6 instance-id %d%s", oi->instance_id, VNL); + switch (oi->type) + { + case OSPF6_IFTYPE_BROADCAST: + vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL); + break; + case OSPF6_IFTYPE_NBMA: + vty_out (vty, " ipv6 ospf6 network non-broadcast%s", VNL); + break; + case OSPF6_IFTYPE_POINTOMULTIPOINT: + vty_out (vty, " ipv6 ospf6 network point-to-multipoint%s", VNL); + break; + case OSPF6_IFTYPE_POINTOPOINT: + vty_out (vty, " ipv6 ospf6 network point-to-point %s", VNL); + break; + case OSPF6_IFTYPE_LOOPBACK: + vty_out (vty, " ipv6 ospf6 network loopback%s", VNL); + break; + } + + if (oi->plist_name) vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s", @@ -1511,8 +1629,7 @@ return 0; } -struct cmd_node interface_node = -{ +struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", 1 /* VTYSH */ @@ -1530,16 +1647,20 @@ install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); + install_element (VIEW_NODE, + &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); + install_element (VIEW_NODE, + &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); + install_element (ENABLE_NODE, + &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); + install_element (ENABLE_NODE, + &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); install_element (CONFIG_NODE, &interface_cmd); install_default (INTERFACE_NODE); @@ -1560,15 +1681,21 @@ install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd); install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd); + + install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd); + install_element (INTERFACE_NODE, &ospf6_network_cmd); + install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd); + install_element (INTERFACE_NODE, &no_ospf6_network_cmd); + + + + } DEFUN (debug_ospf6_interface, debug_ospf6_interface_cmd, "debug ospf6 interface", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 Interface\n" - ) + DEBUG_STR OSPF6_STR "Debug OSPFv3 Interface\n") { OSPF6_DEBUG_INTERFACE_ON (); return CMD_SUCCESS; @@ -1577,11 +1704,7 @@ DEFUN (no_debug_ospf6_interface, no_debug_ospf6_interface_cmd, "no debug ospf6 interface", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 Interface\n" - ) + NO_STR DEBUG_STR OSPF6_STR "Debug OSPFv3 Interface\n") { OSPF6_DEBUG_INTERFACE_OFF (); return CMD_SUCCESS; diff -Naur quagga-0.99.9/ospf6d/ospf6_interface.h quagga-0.99.9-af/ospf6d/ospf6_interface.h --- quagga-0.99.9/ospf6d/ospf6_interface.h 2005-04-04 21:48:42.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_interface.h 2008-12-03 13:42:15.000000000 -0800 @@ -48,6 +48,9 @@ /* linklocal address of this I/F */ struct in6_addr *linklocal_addr; + /* IPv4 linklocal address of this I/F */ + struct in6_addr *linklocal_addr_ipv4; + /* Interface ID; use interface->ifindex */ /* ospf6 instance id */ @@ -102,8 +105,29 @@ /* prefix-list name to filter connected prefix */ char *plist_name; + + + /* OSPF6 Interface Type */ + u_char type; + + + + + }; + +#define OSPF6_IFTYPE_NONE 0 +#define OSPF6_IFTYPE_POINTOPOINT 1 +#define OSPF6_IFTYPE_BROADCAST 2 +#define OSPF6_IFTYPE_NBMA 3 +#define OSPF6_IFTYPE_POINTOMULTIPOINT 4 +#define OSPF6_IFTYPE_VIRTUALLINK 5 +#define OSPF6_IFTYPE_LOOPBACK 6 +#define OSPF6_IFTYPE_MDR 7 +#define OSPF6_IFTYPE_MB 8 +#define OSPF6_IFTYPE_MAX 9 + /* interface state */ #define OSPF6_INTERFACE_NONE 0 #define OSPF6_INTERFACE_DOWN 1 @@ -148,5 +172,8 @@ int config_write_ospf6_debug_interface (struct vty *vty); void install_element_ospf6_debug_interface (); -#endif /* OSPF6_INTERFACE_H */ + + + +#endif /* OSPF6_INTERFACE_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_intra.c quagga-0.99.9-af/ospf6d/ospf6_intra.c --- quagga-0.99.9/ospf6d/ospf6_intra.c 2006-05-15 03:43:52.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_intra.c 2008-12-03 13:42:15.000000000 -0800 @@ -48,6 +48,8 @@ #include "ospf6d.h" +#include "ospf6_flood.h" + unsigned char conf_debug_ospf6_brouter = 0; u_int32_t conf_debug_ospf6_brouter_specific_router_id; u_int32_t conf_debug_ospf6_brouter_specific_area_id; @@ -135,12 +137,14 @@ router_lsa = (struct ospf6_router_lsa *) ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); - OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_V6); - OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_E); - OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_MC); - OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_N); - OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_R); - OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_DC); + OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_AF, 2); + + OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_V6, 2); + OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_E, 2); + OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_MC, 2); + OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_N, 2); + OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_R, 2); + OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_DC, 2); if (ospf6_is_router_abr (ospf6)) SET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_B); @@ -215,7 +219,8 @@ } /* Point-to-Point interfaces */ - if (if_is_pointopoint (oi->interface)) + if (oi->type == OSPF6_IFTYPE_POINTOPOINT || + oi->type == OSPF6_IFTYPE_POINTOMULTIPOINT) { for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) { @@ -233,7 +238,7 @@ } /* Broadcast and NBMA interfaces */ - if (if_is_broadcast (oi->interface)) + if (oi->type == OSPF6_IFTYPE_BROADCAST || oi->type == OSPF6_IFTYPE_NBMA) { /* If this router is not DR, and If this router not fully adjacent with DR, @@ -380,7 +385,8 @@ } if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK)) - zlog_debug ("Originate Network-LSA for Interface %s", oi->interface->name); + zlog_debug ("Originate Network-LSA for Interface %s", + oi->interface->name); /* If none of neighbor is adjacent to us */ count = 0; @@ -470,7 +476,7 @@ int prefixnum; char buf[128], options[32]; struct ospf6_prefix *prefix; - const char *p, *mc, *la, *nu; + const char *p, *la, *nu; struct in6_addr in6; link_lsa = (struct ospf6_link_lsa *) @@ -496,21 +502,19 @@ p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ? "P" : "--"); - mc = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) ? - "MC" : "--"); la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ? "LA" : "--"); nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? "NU" : "--"); - vty_out (vty, " Prefix Options: %s|%s|%s|%s%s", - p, mc, la, nu, VNL); + //AF draft 05 Sec 2.2.2 + //The MC bit is not used in other AF's introduced in this document. + vty_out (vty, " Prefix Options: %s|**|%s|%s%s", p, la, nu, VNL); memset (&in6, 0, sizeof (in6)); memcpy (&in6, OSPF6_PREFIX_BODY (prefix), OSPF6_PREFIX_SPACE (prefix->prefix_length)); inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); - vty_out (vty, " Prefix: %s/%d%s", - buf, prefix->prefix_length, VNL); + vty_out (vty, " Prefix: %s/%d%s", buf, prefix->prefix_length, VNL); } return 0; @@ -569,8 +573,16 @@ /* Fill Link-LSA */ link_lsa->priority = oi->priority; memcpy (link_lsa->options, oi->area->options, 3); + + //AF draft 05 Sec 2.5 - linklocal address should be the IPv4 address + //for the link_lsa. + if (is_af_ipv4_unicast (oi) || is_af_ipv4_multicast (oi)) + memcpy (&link_lsa->linklocal_addr, oi->linklocal_addr_ipv4, + sizeof (struct in6_addr)); + else memcpy (&link_lsa->linklocal_addr, oi->linklocal_addr, sizeof (struct in6_addr)); + link_lsa->prefix_num = htonl (oi->route_connected->count); op = (struct ospf6_prefix *) @@ -624,7 +636,8 @@ char buf[128]; struct ospf6_prefix *prefix; char id[16], adv_router[16]; - const char *p, *mc, *la, *nu; + const char *p, *la, *nu; + struct in6_addr in6; intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) @@ -652,21 +665,17 @@ p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ? "P" : "--"); - mc = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) ? - "MC" : "--"); la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ? "LA" : "--"); nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? "NU" : "--"); - vty_out (vty, " Prefix Options: %s|%s|%s|%s%s", - p, mc, la, nu, VNL); + vty_out (vty, " Prefix Options: %s|**|%s|%s%s", p, la, nu, VNL); memset (&in6, 0, sizeof (in6)); memcpy (&in6, OSPF6_PREFIX_BODY (prefix), OSPF6_PREFIX_SPACE (prefix->prefix_length)); inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); - vty_out (vty, " Prefix: %s/%d%s", - buf, prefix->prefix_length, VNL); + vty_out (vty, " Prefix: %s/%d%s", buf, prefix->prefix_length, VNL); } return 0; @@ -721,14 +730,17 @@ intra_prefix_lsa->ref_id = htonl (0); intra_prefix_lsa->ref_adv_router = oa->ospf6->router_id; - route_advertise = ospf6_route_table_create (0, 0); + prefix_num = 0; + op = (struct ospf6_prefix *) + ((caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa)); for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi)) { if (oi->state == OSPF6_INTERFACE_DOWN) { if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) - zlog_debug (" Interface %s is down, ignore", oi->interface->name); + zlog_debug (" Interface %s is down, ignore", + oi->interface->name); continue; } @@ -739,8 +751,7 @@ full_count++; if (oi->state != OSPF6_INTERFACE_LOOPBACK && - oi->state != OSPF6_INTERFACE_POINTTOPOINT && - full_count != 0) + oi->state != OSPF6_INTERFACE_POINTTOPOINT && full_count != 0) { if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) zlog_debug (" Interface %s is not stub, ignore", @@ -760,35 +771,26 @@ prefix2str (&route->prefix, buf, sizeof (buf)); zlog_debug (" include %s", buf); } - ospf6_route_add (ospf6_route_copy (route), route_advertise); - } - } - - if (route_advertise->count == 0) - { - if (old) - ospf6_lsa_purge (old); - ospf6_route_table_delete (route_advertise); - return 0; - } - - /* put prefixes to advertise */ - prefix_num = 0; - op = (struct ospf6_prefix *) - ((caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa)); - for (route = ospf6_route_head (route_advertise); route; - route = ospf6_route_best_next (route)) - { +//RFC 2740 3.4.3.7 Bullet 5 -- + if (oi->type == OSPF6_IFTYPE_POINTOMULTIPOINT) + op->prefix_length = 128; + else op->prefix_length = route->prefix.prefixlen; op->prefix_options = route->path.prefix_options; + op->prefix_options |= OSPF6_PREFIX_OPTION_LA; op->prefix_metric = htons (route->path.cost); memcpy (OSPF6_PREFIX_BODY (op), &route->prefix.u.prefix6, OSPF6_PREFIX_SPACE (op->prefix_length)); + //must add mask application here because it was removed + //in ospf6_interface.c, ospf6_interface_connected_route_update() + ospf6_prefix_apply_mask (op); op = OSPF6_PREFIX_NEXT (op); prefix_num++; } + } - ospf6_route_table_delete (route_advertise); + if (prefix_num == 0 && old) + ospf6_lsa_purge (old); if (prefix_num == 0) { @@ -943,6 +945,9 @@ route->prefix.family = AF_INET6; route->prefix.prefixlen = op->prefix_length; memset (&route->prefix.u.prefix6, 0, sizeof (struct in6_addr)); + //must add mask application here because it was removed + //in ospf6_interface.c, ospf6_interface_connected_route_update() + ospf6_prefix_apply_mask (op); memcpy (&route->prefix.u.prefix6, OSPF6_PREFIX_BODY (op), OSPF6_PREFIX_SPACE (op->prefix_length)); @@ -1065,9 +1070,14 @@ return; } + //There is no need to add my own networks because the kernel routing + //table already installs them + if ((is_af_ipv6_unicast (NULL) || is_af_ipv6_multicast (NULL)) && + (lsa->header->adv_router == oa->ospf6->router_id)) + return; + prefix_num = ntohs (intra_prefix_lsa->prefix_num); - start = (caddr_t) intra_prefix_lsa + - sizeof (struct ospf6_intra_prefix_lsa); + start = (caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa); end = OSPF6_LSA_END (lsa->header); for (current = start; current < end; current += OSPF6_PREFIX_SIZE (op)) { @@ -1092,13 +1102,62 @@ route->path.area_id = oa->area_id; route->path.type = OSPF6_PATH_TYPE_INTRA; route->path.metric_type = 1; - route->path.cost = ls_entry->path.cost + - ntohs (op->prefix_metric); + route->path.cost = ls_entry->path.cost + ntohs (op->prefix_metric); + + { + boolean directly_connected = false; + struct prefix_ipv6 addr6; + if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) + { + char ipv6[128]; + inet_ntop (AF_INET6, &route->prefix.u.prefix6, ipv6, + sizeof (ipv6)); + zlog_debug ("route %s/%d", ipv6, route->prefix.prefixlen); + } for (i = 0; ospf6_nexthop_is_set (&ls_entry->nexthop[i]) && i < OSPF6_MULTI_PATH_LIMIT; i++) + { ospf6_nexthop_copy (&route->nexthop[i], &ls_entry->nexthop[i]); + addr6.family = AF_INET6; + addr6.prefixlen = route->prefix.prefixlen; + memcpy (&addr6.prefix, &route->nexthop[i].address, + sizeof (addr6)); + apply_mask_ipv6 (&addr6); + + if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) + { + char ipv6[128]; + inet_ntop (AF_INET6, &addr6.prefix, ipv6, sizeof (ipv6)); + zlog_debug ("nexthop %s", ipv6); + } + + if (IN6_ARE_ADDR_EQUAL (&addr6.prefix, &route->prefix.u.prefix6)) + { + if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) + zlog_debug (" match"); + directly_connected = true; + } + if (lsa->header->adv_router == oa->ospf6->router_id) + //This is the router's own lsa + route->nexthop[i].directly_connected = true; + //See ospf6_nexthop_calc() for settting nexthop->ifindex + //this check assumes that ifindex is being set for directly + //connected nexthops + else if (ls_entry->nexthop[i].ifindex && + (IN6_IS_ADDR_UNSPECIFIED (&ls_entry->nexthop[i].address) + || IN6_IS_ADDR_LINKLOCAL (&ls_entry->nexthop[i]. + address))) + route->nexthop[i].directly_connected = true; + else if (directly_connected) + //This is a one-hop neighbor - cost_e2 is hopcount + route->nexthop[i].directly_connected = true; + else + route->nexthop[i].directly_connected = false; + } + } + if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) { prefix2str (&route->prefix, buf, sizeof (buf)); @@ -1134,8 +1193,7 @@ OSPF6_LSA_HEADER_END (lsa->header); prefix_num = ntohs (intra_prefix_lsa->prefix_num); - start = (caddr_t) intra_prefix_lsa + - sizeof (struct ospf6_intra_prefix_lsa); + start = (caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa); end = OSPF6_LSA_END (lsa->header); for (current = start; current < end; current += OSPF6_PREFIX_SIZE (op)) { @@ -1191,6 +1249,7 @@ struct ospf6_lsa *lsa; void (*hook_add) (struct ospf6_route *) = NULL; void (*hook_remove) (struct ospf6_route *) = NULL; + int pass; if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) zlog_debug ("Re-examin intra-routes for area %s", oa->name); @@ -1212,26 +1271,101 @@ oa->route_table->hook_add = hook_add; oa->route_table->hook_remove = hook_remove; + for (pass = 0; pass < 2; pass++) + { + int skipped = 0; + for (route = ospf6_route_head (oa->route_table); route; route = ospf6_route_next (route)) { if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE) && CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD)) { - UNSET_FLAG (route->flag, OSPF6_ROUTE_REMOVE); - UNSET_FLAG (route->flag, OSPF6_ROUTE_ADD); + /* route unchanged */ + route->flag = 0; } - - if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE)) + else if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE)) + { + /* remove route */ ospf6_route_remove (route, oa->route_table); + route->flag = 0; + } else if (CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD) || CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE)) { + /* add route */ + int i; + + for (i = 0; ospf6_nexthop_is_set (&route->nexthop[i]) && + i < OSPF6_MULTI_PATH_LIMIT; i++) + { + int routablenexthop = 0; + + if (route->nexthop[i].ifindex && + IN6_IS_ADDR_UNSPECIFIED (&route->nexthop[i].address)) + routablenexthop = 1; + else if (route->nexthop[i].directly_connected) + routablenexthop = 1; + else + { + struct prefix prefix; + struct ospf6_route *nhroute; + + memset (&prefix, 0, sizeof (prefix)); + prefix.family = AF_INET6; + prefix.prefixlen = IPV6_MAX_PREFIXLEN; + IPV6_ADDR_COPY (&prefix.u.prefix6, + &route->nexthop[i].address); + + nhroute = + ospf6_route_lookup_bestmatch (&prefix, + oa->route_table); + + /* nhroute->flag == 0 implies that nhroute has already + * been processed since route->flag is cleared in each + * case. route is skipped if nhroute has not been + * processed yet because zebra or the kernel can reject + * routes with unreachable nexthops. If skipped, route + * will get added in the second pass since any + * prerequisite nexthops should have been added during the + * first pass. + */ + if (nhroute && nhroute->flag == 0) + routablenexthop = 1; + } + + if (routablenexthop) + { if (hook_add) (*hook_add) (route); - } route->flag = 0; + break; + } + else + { + if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX) || pass > 0) + { + char buf[INET6_ADDRSTRLEN]; + + inet_ntop (AF_INET6, &route->prefix.u.prefix6, buf, + sizeof (buf)); + zlog_debug + ("%s: pass %d skipping route to %s/%d because nexthop is not routable%s", + __func__, pass, buf, route->prefix.prefixlen, + pass > 0 ? "; this shouldn't happen" : ""); + } + skipped++; + } + } + } + else if (route->flag) + zlog_warn ("%s: unknown route flag(s): 0x%x", __func__, + route->flag); + } + + if (skipped == 0) + break; } if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) @@ -1248,7 +1382,7 @@ char installed[16], changed[16]; struct timeval now, res; char id[16], adv_router[16]; - char capa[16], options[16]; + char capa[16], options[OSPF6OPTSTRLEN]; brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); @@ -1283,8 +1417,7 @@ (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-")); zlog_info (" path type: %s ls-origin %s id: %s adv-router %s", OSPF6_PATH_TYPE_NAME (brouter->path.type), - ospf6_lstype_name (brouter->path.origin.type), - id, adv_router); + ospf6_lstype_name (brouter->path.origin.type), id, adv_router); zlog_info (" options: %s router-bits: %s metric-type: %d metric: %d/%d", options, capa, brouter->path.metric_type, brouter->path.cost, brouter->path.cost_e2); @@ -1413,29 +1546,25 @@ zlog_info ("border-router calculation for area %s: done", oa->name); } -struct ospf6_lsa_handler router_handler = -{ +struct ospf6_lsa_handler router_handler = { OSPF6_LSTYPE_ROUTER, "Router", ospf6_router_lsa_show }; -struct ospf6_lsa_handler network_handler = -{ +struct ospf6_lsa_handler network_handler = { OSPF6_LSTYPE_NETWORK, "Network", ospf6_network_lsa_show }; -struct ospf6_lsa_handler link_handler = -{ +struct ospf6_lsa_handler link_handler = { OSPF6_LSTYPE_LINK, "Link", ospf6_link_lsa_show }; -struct ospf6_lsa_handler intra_prefix_handler = -{ +struct ospf6_lsa_handler intra_prefix_handler = { OSPF6_LSTYPE_INTRA_PREFIX, "Intra-Prefix", ospf6_intra_prefix_lsa_show @@ -1450,13 +1579,152 @@ ospf6_install_lsa_handler (&intra_prefix_handler); } +//prevent LSAs from being originated before MinLSInterval +void +ospf6_lsa_schedule (struct ospf6_area *oa, struct ospf6_interface *oi, + int type, boolean stub) +{ + struct ospf6 *o = NULL; + struct ospf6_lsa *old; + int link_state_id; + long time_msec = -1; + + switch (type) + { + case OSPF6_LSTYPE_ROUTER: + link_state_id = 0; + o = oa->ospf6; + old = ospf6_lsdb_lookup (htons (type), link_state_id, + o->router_id, oa->lsdb); + break; + case OSPF6_LSTYPE_NETWORK: + link_state_id = oi->interface->ifindex; + o = oi->area->ospf6; + old = ospf6_lsdb_lookup (htons (type), htonl (link_state_id), + o->router_id, oi->area->lsdb); + break; + case OSPF6_LSTYPE_LINK: + link_state_id = oi->interface->ifindex; + o = oi->area->ospf6; + old = ospf6_lsdb_lookup (htons (type), htonl (link_state_id), + o->router_id, oi->lsdb); + break; + case OSPF6_LSTYPE_INTRA_PREFIX: + if (stub) + { + link_state_id = 0; + o = oa->ospf6; + old = ospf6_lsdb_lookup (htons (type), link_state_id, + o->router_id, oa->lsdb); + } + else + { + link_state_id = oi->interface->ifindex; + o = oi->area->ospf6; + old = ospf6_lsdb_lookup (htons (type), htonl (link_state_id), + o->router_id, oi->area->lsdb); + } + break; + default: + zlog_warn ("No such LSA type"); + return; + break; + } + if (old) + { + time_msec = + (long) (((float) o->minLSInterval - + elapsed_time (&old->originated)) * 1000); + } + switch (type) + { + case OSPF6_LSTYPE_ROUTER: + if (time_msec > 0) + { + THREAD_OFF (oa->thread_router_lsa); + oa->thread_router_lsa = + thread_add_timer_msec (master, ospf6_router_lsa_originate, oa, + time_msec); + } + else + { + oa->thread_router_lsa = + thread_add_event (master, ospf6_router_lsa_originate, oa, 0); + } + break; + case OSPF6_LSTYPE_NETWORK: + if (time_msec > 0) + { + THREAD_OFF (oi->thread_network_lsa); + oi->thread_network_lsa = + thread_add_timer_msec (master, ospf6_network_lsa_originate, oi, + time_msec); + } + else + { + oi->thread_network_lsa = + thread_add_event (master, ospf6_network_lsa_originate, oi, 0); + } + break; + case OSPF6_LSTYPE_LINK: + if (time_msec > 0) + { + THREAD_OFF (oi->thread_link_lsa); + oi->thread_link_lsa = + thread_add_timer_msec (master, ospf6_link_lsa_originate, oi, + time_msec); + } + else + { + oi->thread_link_lsa = + thread_add_event (master, ospf6_link_lsa_originate, oi, 0); + } + break; + case OSPF6_LSTYPE_INTRA_PREFIX: + if (stub) + { + if (time_msec > 0) + { + THREAD_OFF (oa->thread_intra_prefix_lsa); + oa->thread_intra_prefix_lsa = + thread_add_timer_msec (master, + ospf6_intra_prefix_lsa_originate_stub, + oa, time_msec); + } + else + { + oa->thread_intra_prefix_lsa = + thread_add_event (master, + ospf6_intra_prefix_lsa_originate_stub, oa, + 0); + } + } + else + { + if (time_msec > 0) + { + THREAD_OFF (oi->thread_intra_prefix_lsa); + oi->thread_intra_prefix_lsa = + thread_add_timer_msec (master, + ospf6_intra_prefix_lsa_originate_transit, + oi, time_msec); + } + else + { + oi->thread_intra_prefix_lsa = + thread_add_event (master, + ospf6_intra_prefix_lsa_originate_transit, + oi, 0); + } + } + break; + } +} + DEFUN (debug_ospf6_brouter, debug_ospf6_brouter_cmd, "debug ospf6 border-routers", - DEBUG_STR - OSPF6_STR - "Debug border router\n" - ) + DEBUG_STR OSPF6_STR "Debug border router\n") { OSPF6_DEBUG_BROUTER_ON (); return CMD_SUCCESS; @@ -1465,11 +1733,7 @@ DEFUN (no_debug_ospf6_brouter, no_debug_ospf6_brouter_cmd, "no debug ospf6 border-routers", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug border router\n" - ) + NO_STR DEBUG_STR OSPF6_STR "Debug border router\n") { OSPF6_DEBUG_BROUTER_OFF (); return CMD_SUCCESS; @@ -1481,9 +1745,7 @@ DEBUG_STR OSPF6_STR "Debug border router\n" - "Debug specific border router\n" - "Specify border-router's router-id\n" - ) + "Debug specific border router\n" "Specify border-router's router-id\n") { u_int32_t router_id; inet_pton (AF_INET, argv[0], &router_id); @@ -1496,10 +1758,7 @@ "no debug ospf6 border-routers router-id", NO_STR DEBUG_STR - OSPF6_STR - "Debug border router\n" - "Debug specific border router\n" - ) + OSPF6_STR "Debug border router\n" "Debug specific border router\n") { OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF (); return CMD_SUCCESS; @@ -1511,9 +1770,7 @@ DEBUG_STR OSPF6_STR "Debug border router\n" - "Debug border routers in specific Area\n" - "Specify Area-ID\n" - ) + "Debug border routers in specific Area\n" "Specify Area-ID\n") { u_int32_t area_id; inet_pton (AF_INET, argv[0], &area_id); @@ -1527,9 +1784,7 @@ NO_STR DEBUG_STR OSPF6_STR - "Debug border router\n" - "Debug border routers in specific Area\n" - ) + "Debug border router\n" "Debug border routers in specific Area\n") { OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF (); return CMD_SUCCESS; diff -Naur quagga-0.99.9/ospf6d/ospf6_intra.h quagga-0.99.9-af/ospf6d/ospf6_intra.h --- quagga-0.99.9/ospf6d/ospf6_intra.h 2006-05-15 03:36:47.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_intra.h 2008-12-03 13:42:15.000000000 -0800 @@ -22,6 +22,9 @@ #ifndef OSPF6_INTRA_H #define OSPF6_INTRA_H +#include "ospf6d.h" +#include "ospf6_area.h" + /* Debug option */ extern unsigned char conf_debug_ospf6_brouter; extern u_int32_t conf_debug_ospf6_brouter_specific_router_id; @@ -140,38 +143,33 @@ /* followed by ospf6 prefix(es) */ }; - +struct ospf6_interface; +void ospf6_lsa_schedule (struct ospf6_area *oa, struct ospf6_interface *oi, + int type, boolean stub); #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \ do { \ if (! (oa)->thread_router_lsa) \ - (oa)->thread_router_lsa = \ - thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \ + ospf6_lsa_schedule(oa, NULL, OSPF6_LSTYPE_ROUTER, false); \ } while (0) #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \ do { \ if (! (oi)->thread_network_lsa) \ - (oi)->thread_network_lsa = \ - thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \ + ospf6_lsa_schedule(NULL, oi, OSPF6_LSTYPE_NETWORK, false); \ } while (0) #define OSPF6_LINK_LSA_SCHEDULE(oi) \ do { \ if (! (oi)->thread_link_lsa) \ - (oi)->thread_link_lsa = \ - thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \ + ospf6_lsa_schedule(NULL, oi, OSPF6_LSTYPE_LINK, false); \ } while (0) #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \ do { \ if (! (oa)->thread_intra_prefix_lsa) \ - (oa)->thread_intra_prefix_lsa = \ - thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \ - oa, 0); \ + ospf6_lsa_schedule(oa, NULL, OSPF6_LSTYPE_INTRA_PREFIX, true); \ } while (0) #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \ do { \ if (! (oi)->thread_intra_prefix_lsa) \ - (oi)->thread_intra_prefix_lsa = \ - thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \ - oi, 0); \ + ospf6_lsa_schedule(NULL, oi, OSPF6_LSTYPE_INTRA_PREFIX, false); \ } while (0) #define OSPF6_NETWORK_LSA_EXECUTE(oi) \ diff -Naur quagga-0.99.9/ospf6d/ospf6_lsa.c quagga-0.99.9-af/ospf6d/ospf6_lsa.c --- quagga-0.99.9/ospf6d/ospf6_lsa.c 2007-06-14 03:02:14.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_lsa.c 2008-12-03 13:42:15.000000000 -0800 @@ -70,8 +70,7 @@ return 0; } -struct ospf6_lsa_handler unknown_handler = -{ +struct ospf6_lsa_handler unknown_handler = { OSPF6_LSTYPE_UNKNOWN, "Unknown", ospf6_unknown_lsa_show, @@ -127,8 +126,7 @@ /* RFC2328: Section 13.2 */ int -ospf6_lsa_is_differ (struct ospf6_lsa *lsa1, - struct ospf6_lsa *lsa2) +ospf6_lsa_is_differ (struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2) { int len; @@ -154,8 +152,7 @@ } int -ospf6_lsa_is_changed (struct ospf6_lsa *lsa1, - struct ospf6_lsa *lsa2) +ospf6_lsa_is_changed (struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2) { int length; @@ -313,8 +310,7 @@ { char id[16], adv_router[16]; inet_ntop (AF_INET, &header->id, id, sizeof (id)); - inet_ntop (AF_INET, &header->adv_router, adv_router, - sizeof (adv_router)); + inet_ntop (AF_INET, &header->adv_router, adv_router, sizeof (adv_router)); zlog_debug (" [%s Id:%s Adv:%s]", ospf6_lstype_name (header->type), id, adv_router); zlog_debug (" Age: %4hu SeqNum: %#08lx Cksum: %04hx Len: %d", @@ -409,8 +405,7 @@ vty_out (vty, "LS Sequence Number: %#010lx%s", (u_long) ntohl (lsa->header->seqnum), VNL); vty_out (vty, "CheckSum: %#06hx Length: %hu%s", - ntohs (lsa->header->checksum), - ntohs (lsa->header->length), VNL); + ntohs (lsa->header->checksum), ntohs (lsa->header->length), VNL); vty_out (vty, " Prev: %p This: %p Next: %p%s", lsa->prev, lsa, lsa->next, VNL); vty_out (vty, "%s", VNL); @@ -436,8 +431,7 @@ vty_out (vty, "LS Sequence Number: %#010lx%s", (u_long) ntohl (lsa->header->seqnum), VNL); vty_out (vty, "CheckSum: %#06hx Length: %hu%s", - ntohs (lsa->header->checksum), - ntohs (lsa->header->length), VNL); + ntohs (lsa->header->checksum), ntohs (lsa->header->length), VNL); handler = ospf6_get_lsa_handler (lsa->header->type); if (handler->show == NULL) @@ -594,12 +588,12 @@ if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY)) return 0; /* dbexchange will do something ... */ - /* reflood lsa */ - ospf6_flood (NULL, lsa); - /* reinstall lsa */ ospf6_install_lsa (lsa); + /* reflood lsa */ + ospf6_flood (NULL, lsa); + /* schedule maxage remover */ ospf6_maxage_remove (ospf6); @@ -644,6 +638,11 @@ /* store it in the LSDB for self-originated LSAs */ ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self); + if (IS_OSPF6_DEBUG_DATABASE (DATABASE_DETAIL)) + ospf6_debug_lsdb_show (OSPF6_DEBUG_DATABASE_DETAIL, lsdb_self); + else if (IS_OSPF6_DEBUG_DATABASE (DATABASE)) + ospf6_debug_lsdb_show (OSPF6_DEBUG_DATABASE, lsdb_self); + if (IS_OSPF6_DEBUG_LSA_TYPE (new->header->type)) { zlog_debug ("LSA Refresh:"); @@ -717,8 +716,7 @@ unsigned int i; unsigned int size = strlen (h->name); - if (!strcmp(h->name, "Unknown") && - h->type != OSPF6_LSTYPE_UNKNOWN) + if (!strcmp (h->name, "Unknown") && h->type != OSPF6_LSTYPE_UNKNOWN) { snprintf (buf, sizeof (buf), "%#04hx", h->type); return buf; @@ -741,8 +739,7 @@ DEBUG_STR OSPF6_STR "Debug Link State Advertisements (LSAs)\n" - "Specify LS type as Hexadecimal\n" - ) + "Specify LS type as Hexadecimal\n") { unsigned int i; struct ospf6_lsa_handler *handler = NULL; @@ -809,8 +806,7 @@ DEBUG_STR OSPF6_STR "Debug Link State Advertisements (LSAs)\n" - "Specify LS type as Hexadecimal\n" - ) + "Specify LS type as Hexadecimal\n") { u_int i; struct ospf6_lsa_handler *handler = NULL; diff -Naur quagga-0.99.9/ospf6d/ospf6_lsa.h quagga-0.99.9-af/ospf6d/ospf6_lsa.h --- quagga-0.99.9/ospf6d/ospf6_lsa.h 2004-12-15 09:14:20.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6_lsa.h 2008-12-03 13:42:15.000000000 -0800 @@ -203,6 +203,15 @@ zlog_debug ("Filter out V4Mapped: %s", buf); \ continue; \ } +#define CONTINUE_IF_V4_ADDRESS_LOOPBACK(debug,addr) \ + if (((ntohl((long int) (addr->u.prefix4.s_addr))) & 0xff000000)==0x7f000000) \ + { \ + char buf[64]; \ + prefix2str (addr, buf, sizeof (buf)); \ + if (debug) \ + zlog_debug ("Filter out Loopback: %s", buf); \ + continue; \ + } /* Function Prototypes */ @@ -225,7 +234,8 @@ void ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa); struct ospf6_lsa *ospf6_lsa_create (struct ospf6_lsa_header *header); -struct ospf6_lsa *ospf6_lsa_create_headeronly (struct ospf6_lsa_header *header); +struct ospf6_lsa *ospf6_lsa_create_headeronly (struct ospf6_lsa_header + *header); void ospf6_lsa_delete (struct ospf6_lsa *lsa); struct ospf6_lsa *ospf6_lsa_copy (struct ospf6_lsa *); @@ -248,5 +258,6 @@ int config_write_ospf6_debug_lsa (struct vty *vty); void install_element_ospf6_debug_lsa (); -#endif /* OSPF6_LSA_H */ + +#endif /* OSPF6_LSA_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_lsdb.c quagga-0.99.9-af/ospf6d/ospf6_lsdb.c --- quagga-0.99.9/ospf6d/ospf6_lsdb.c 2005-01-26 03:21:05.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6_lsdb.c 2008-12-03 13:42:15.000000000 -0800 @@ -33,6 +33,9 @@ #include "ospf6_lsdb.h" #include "ospf6d.h" +#include "ospf6_intra.h" +unsigned char conf_debug_ospf6_database = 0; + struct ospf6_lsdb * ospf6_lsdb_create (void *data) { @@ -64,8 +67,7 @@ { assert (key->prefixlen % 8 == 0); - memcpy ((caddr_t) &key->prefix + key->prefixlen / 8, - (caddr_t) value, len); + memcpy ((caddr_t) & key->prefix + key->prefixlen / 8, (caddr_t) value, len); key->family = AF_INET6; key->prefixlen += len * 8; } @@ -76,8 +78,7 @@ { struct ospf6_lsa *debug; unsigned int num = 0; - for (debug = ospf6_lsdb_head (lsdb); debug; - debug = ospf6_lsdb_next (debug)) + for (debug = ospf6_lsdb_head (lsdb); debug; debug = ospf6_lsdb_next (debug)) num++; if (num == lsdb->count) @@ -85,8 +86,7 @@ zlog_debug ("PANIC !! lsdb[%p]->count = %d, real = %d", lsdb, lsdb->count, num); - for (debug = ospf6_lsdb_head (lsdb); debug; - debug = ospf6_lsdb_next (debug)) + for (debug = ospf6_lsdb_head (lsdb); debug; debug = ospf6_lsdb_next (debug)) zlog_debug ("%p %p %s lsdb[%p]", debug->prev, debug->next, debug->name, debug->lsdb); zlog_debug ("DUMP END"); @@ -130,9 +130,11 @@ /* next link */ nextnode = current; route_lock_node (nextnode); - do { + do + { nextnode = route_next (nextnode); - } while (nextnode && nextnode->info == NULL); + } + while (nextnode && nextnode->info == NULL); if (nextnode == NULL) lsa->next = NULL; else @@ -146,9 +148,11 @@ /* prev link */ prevnode = current; route_lock_node (prevnode); - do { + do + { prevnode = route_prev (prevnode); - } while (prevnode && prevnode->info == NULL); + } + while (prevnode && prevnode->info == NULL); if (prevnode == NULL) lsa->prev = NULL; else @@ -187,6 +191,14 @@ (*lsdb->hook_add) (lsa); } } + //We are trying to catch a premature aged LSA. + //The pointers to lsa and old are the same because premature aging + //doesn't create a new LSA (it just changes the age value) + else if (old == lsa && OSPF6_LSA_IS_MAXAGE (lsa)) + { + if (lsdb->hook_remove) + (*lsdb->hook_remove) (lsa); + } } else if (OSPF6_LSA_IS_MAXAGE (lsa)) { @@ -228,6 +240,17 @@ node->info = NULL; lsdb->count--; + if (lsa->expire) + { + THREAD_OFF (lsa->expire); + lsa->expire = 0; + } + if (lsa->refresh) + { + THREAD_OFF (lsa->refresh); + lsa->refresh = 0; + } + if (lsdb->hook_remove) (*lsdb->hook_remove) (lsa); @@ -579,4 +602,300 @@ return ((u_int32_t) htonl (seqnum)); } +DEFUN (debug_ospf6_database, + debug_ospf6_database_cmd, + "debug ospf6 database", DEBUG_STR OSPF6_STR "Dump ospf6 database\n") +{ + unsigned char level = 0; + level = OSPF6_DEBUG_DATABASE; + OSPF6_DEBUG_DATABASE_ON (level); + return CMD_SUCCESS; +} + +DEFUN (no_debug_ospf6_database, + no_debug_ospf6_database_cmd, + "no debug ospf6 database", + NO_STR DEBUG_STR OSPF6_STR "Dump ospf6 database\n") +{ + unsigned char level = 0; + level = OSPF6_DEBUG_DATABASE; + OSPF6_DEBUG_DATABASE_OFF (level); + return CMD_SUCCESS; +} + +DEFUN (debug_ospf6_database_detail, + debug_ospf6_database_detail_cmd, + "debug ospf6 database detail", + DEBUG_STR OSPF6_STR "Dump ospf6 database\n" "High detail\n") +{ + unsigned char level = 0; + level = OSPF6_DEBUG_DATABASE_DETAIL; + OSPF6_DEBUG_DATABASE_ON (level); + return CMD_SUCCESS; +} + +DEFUN (no_debug_ospf6_database_detail, + no_debug_ospf6_database_detail_cmd, + "no debug ospf6 database detail", + NO_STR DEBUG_STR OSPF6_STR "Dump ospf6 database\n" "High detail\n") +{ + unsigned char level = 0; + level = OSPF6_DEBUG_DATABASE_DETAIL; + OSPF6_DEBUG_DATABASE_OFF (level); + return CMD_SUCCESS; +} + +void +install_element_ospf6_debug_database () +{ + install_element (ENABLE_NODE, &debug_ospf6_database_cmd); + install_element (ENABLE_NODE, &debug_ospf6_database_detail_cmd); + install_element (CONFIG_NODE, &debug_ospf6_database_cmd); + install_element (CONFIG_NODE, &debug_ospf6_database_detail_cmd); + install_element (ENABLE_NODE, &no_debug_ospf6_database_cmd); + install_element (ENABLE_NODE, &no_debug_ospf6_database_detail_cmd); + install_element (CONFIG_NODE, &no_debug_ospf6_database_cmd); + install_element (CONFIG_NODE, &no_debug_ospf6_database_detail_cmd); +} + +void +ospf6_debug_lsdb_show (int level, struct ospf6_lsdb *lsdb) +{ + struct ospf6_lsa *lsa; + char adv_router[16], id[16]; + struct timeval now, res; + char duration[16]; + int count = 0; + zlog_debug ("DUMPING DATABASE %p", lsdb); + lsa = ospf6_lsdb_head (lsdb); + while (lsa) + { + assert (lsa); + assert (lsa->header); + + inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id)); + inet_ntop (AF_INET, &lsa->header->adv_router, adv_router, + sizeof (adv_router)); + gettimeofday (&now, NULL); + timersub (&now, &lsa->installed, &res); + timerstring (&res, duration, sizeof (duration)); + + if (level == OSPF6_DEBUG_DATABASE) + { + zlog_debug ("%-12s %-15s %-15s %4hu %8lx %04hx %4hu %8s", + ospf6_lstype_name (lsa->header->type), + id, adv_router, ospf6_lsa_age_current (lsa), + (u_long) ntohl (lsa->header->seqnum), + ntohs (lsa->header->checksum), + ntohs (lsa->header->length), duration); + } + else if (level == OSPF6_DEBUG_DATABASE_DETAIL) + { + zlog_debug ("LSA %d", ++count); + zlog_debug (" Age: %4hu Type: %s", ospf6_lsa_age_current (lsa), + ospf6_lstype_name (lsa->header->type)); + zlog_debug (" Link State ID: %s", id); + zlog_debug (" Advertising Router: %s", adv_router); + zlog_debug (" LS Sequence Number: %#010lx", + (u_long) ntohl (lsa->header->seqnum)); + zlog_debug (" CheckSum: %#06hx Length: %hu", + ntohs (lsa->header->checksum), + ntohs (lsa->header->length)); + switch (ntohs (lsa->header->type)) + { + case OSPF6_LSTYPE_ROUTER: + ospf6_debug_router_lsa_show (lsa); + break; + case OSPF6_LSTYPE_NETWORK: + ospf6_debug_network_lsa_show (lsa); + break; + case OSPF6_LSTYPE_LINK: + ospf6_debug_link_lsa_show (lsa); + break; + case OSPF6_LSTYPE_INTRA_PREFIX: + ospf6_debug_intra_prefix_lsa_show (lsa); + break; + default: + zlog_debug (" logging not implemented for LSA %s", lsa->name); + break; + } + } + else + { + zlog_debug ("bad level when displaying database"); + } + lsa = ospf6_lsdb_next (lsa); + } +} + +int +ospf6_debug_router_lsa_show (struct ospf6_lsa *lsa) +{ + char *start, *end, *current; + char buf[32], name[32], bits[16], options[32]; + struct ospf6_router_lsa *router_lsa; + struct ospf6_router_lsdesc *lsdesc; + + router_lsa = (struct ospf6_router_lsa *) + ((char *) lsa->header + sizeof (struct ospf6_lsa_header)); + + ospf6_capability_printbuf (router_lsa->bits, bits, sizeof (bits)); + ospf6_options_printbuf (router_lsa->options, options, sizeof (options)); + zlog_debug (" Bits: %s Options: %s", bits, options); + + start = (char *) router_lsa + sizeof (struct ospf6_router_lsa); + end = (char *) lsa->header + ntohs (lsa->header->length); + for (current = start; current + sizeof (struct ospf6_router_lsdesc) <= end; + current += sizeof (struct ospf6_router_lsdesc)) + { + lsdesc = (struct ospf6_router_lsdesc *) current; + + if (lsdesc->type == OSPF6_ROUTER_LSDESC_POINTTOPOINT) + snprintf (name, sizeof (name), "Point-To-Point"); + else if (lsdesc->type == OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK) + snprintf (name, sizeof (name), "Transit-Network"); + else if (lsdesc->type == OSPF6_ROUTER_LSDESC_STUB_NETWORK) + snprintf (name, sizeof (name), "Stub-Network"); + else if (lsdesc->type == OSPF6_ROUTER_LSDESC_VIRTUAL_LINK) + snprintf (name, sizeof (name), "Virtual-Link"); + else + snprintf (name, sizeof (name), "Unknown (%#x)", lsdesc->type); + + zlog_debug (" Type: %s Metric: %d", name, ntohs (lsdesc->metric)); + zlog_debug (" Interface ID: %s", + inet_ntop (AF_INET, &lsdesc->interface_id, + buf, sizeof (buf))); + zlog_debug (" Neighbor Interface ID: %s", + inet_ntop (AF_INET, &lsdesc->neighbor_interface_id, + buf, sizeof (buf))); + zlog_debug (" Neighbor Router ID: %s", + inet_ntop (AF_INET, &lsdesc->neighbor_router_id, + buf, sizeof (buf))); + } + return 0; +} + +int +ospf6_debug_network_lsa_show (struct ospf6_lsa *lsa) +{ + char *start, *end, *current; + struct ospf6_network_lsa *network_lsa; + struct ospf6_network_lsdesc *lsdesc; + char buf[128], options[32]; + + network_lsa = (struct ospf6_network_lsa *) + ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); + + ospf6_options_printbuf (network_lsa->options, options, sizeof (options)); + zlog_debug (" Options: %s", options); + + start = (char *) network_lsa + sizeof (struct ospf6_network_lsa); + end = (char *) lsa->header + ntohs (lsa->header->length); + for (current = start; current + sizeof (struct ospf6_network_lsdesc) <= end; + current += sizeof (struct ospf6_network_lsdesc)) + { + lsdesc = (struct ospf6_network_lsdesc *) current; + inet_ntop (AF_INET, &lsdesc->router_id, buf, sizeof (buf)); + zlog_debug (" Attached Router: %s", buf); + } + return 0; +} + +int +ospf6_debug_link_lsa_show (struct ospf6_lsa *lsa) +{ + char *start, *end, *current; + struct ospf6_link_lsa *link_lsa; + int prefixnum; + char buf[128], options[32]; + struct ospf6_prefix *prefix; + const char *p, *la, *nu; + struct in6_addr in6; + + link_lsa = (struct ospf6_link_lsa *) + ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); + + ospf6_options_printbuf (link_lsa->options, options, sizeof (options)); + inet_ntop (AF_INET6, &link_lsa->linklocal_addr, buf, sizeof (buf)); + prefixnum = ntohl (link_lsa->prefix_num); + + zlog_debug (" Priority: %d Options: %s", link_lsa->priority, options); + zlog_debug (" LinkLocal Address: %s", buf); + zlog_debug (" Number of Prefix: %d", prefixnum); + + start = (char *) link_lsa + sizeof (struct ospf6_link_lsa); + end = (char *) lsa->header + ntohs (lsa->header->length); + for (current = start; current < end; current += OSPF6_PREFIX_SIZE (prefix)) + { + prefix = (struct ospf6_prefix *) current; + if (prefix->prefix_length == 0 || + current + OSPF6_PREFIX_SIZE (prefix) > end) + break; + p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ? + "P" : "--"); + la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ? + "LA" : "--"); + nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? + "NU" : "--"); + zlog_debug (" Prefix Options: %s|**|%s|%s", p, la, nu); + + memset (&in6, 0, sizeof (in6)); + memcpy (&in6, OSPF6_PREFIX_BODY (prefix), + OSPF6_PREFIX_SPACE (prefix->prefix_length)); + inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); + zlog_debug (" Prefix: %s/%d", buf, prefix->prefix_length); + } + return 0; +} + +int +ospf6_debug_intra_prefix_lsa_show (struct ospf6_lsa *lsa) +{ + char *start, *end, *current; + struct ospf6_intra_prefix_lsa *intra_prefix_lsa; + int prefixnum; + char buf[128]; + struct ospf6_prefix *prefix; + char id[16], adv_router[16]; + const char *p, *la, *nu; + struct in6_addr in6; + + intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) + ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); + + prefixnum = ntohs (intra_prefix_lsa->prefix_num); + + zlog_debug (" Number of Prefix: %d", prefixnum); + + inet_ntop (AF_INET, &intra_prefix_lsa->ref_id, id, sizeof (id)); + inet_ntop (AF_INET, &intra_prefix_lsa->ref_adv_router, + adv_router, sizeof (adv_router)); + zlog_debug (" Reference: %s Id: %s Adv: %s", + ospf6_lstype_name (intra_prefix_lsa->ref_type), id, adv_router); + + start = (char *) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa); + end = (char *) lsa->header + ntohs (lsa->header->length); + for (current = start; current < end; current += OSPF6_PREFIX_SIZE (prefix)) + { + prefix = (struct ospf6_prefix *) current; + if (prefix->prefix_length == 0 || + current + OSPF6_PREFIX_SIZE (prefix) > end) + break; + + p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ? + "P" : "--"); + la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ? + "LA" : "--"); + nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? + "NU" : "--"); + zlog_debug (" Prefix Options: %s|**|%s|%s", p, la, nu); + + memset (&in6, 0, sizeof (in6)); + memcpy (&in6, OSPF6_PREFIX_BODY (prefix), + OSPF6_PREFIX_SPACE (prefix->prefix_length)); + inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); + zlog_debug (" Prefix: %s/%d", buf, prefix->prefix_length); + } + return 0; +} diff -Naur quagga-0.99.9/ospf6d/ospf6_lsdb.h quagga-0.99.9-af/ospf6d/ospf6_lsdb.h --- quagga-0.99.9/ospf6d/ospf6_lsdb.h 2004-12-15 09:14:21.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6_lsdb.h 2008-12-03 13:42:15.000000000 -0800 @@ -25,6 +25,8 @@ #include "prefix.h" #include "table.h" +#include "ospf6_lsa.h" + struct ospf6_lsdb { void *data; /* data structure that holds this lsdb */ @@ -53,12 +55,12 @@ struct ospf6_lsdb *ospf6_lsdb_create (void *data); void ospf6_lsdb_delete (struct ospf6_lsdb *lsdb); -struct ospf6_lsa * -ospf6_lsdb_lookup (u_int16_t type, u_int32_t id, u_int32_t adv_router, +struct ospf6_lsa *ospf6_lsdb_lookup (u_int16_t type, u_int32_t id, + u_int32_t adv_router, + struct ospf6_lsdb *lsdb); +struct ospf6_lsa *ospf6_lsdb_lookup_next (u_int16_t type, u_int32_t id, + u_int32_t adv_router, struct ospf6_lsdb *lsdb); -struct ospf6_lsa * -ospf6_lsdb_lookup_next (u_int16_t type, u_int32_t id, - u_int32_t adv_router, struct ospf6_lsdb *lsdb); void ospf6_lsdb_add (struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb); void ospf6_lsdb_remove (struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb); @@ -93,8 +95,26 @@ u_int32_t ospf6_new_ls_id (u_int16_t type, u_int32_t adv_router, struct ospf6_lsdb *lsdb); u_int32_t ospf6_new_ls_seqnum - (u_int16_t type, u_int32_t id, u_int32_t adv_router, struct ospf6_lsdb *lsdb); - -#endif /* OSPF6_LSDB_H */ + (u_int16_t type, u_int32_t id, u_int32_t adv_router, + struct ospf6_lsdb *lsdb); +/* Debug option */ +extern unsigned char conf_debug_ospf6_database; +#define OSPF6_DEBUG_DATABASE 0x01 +#define OSPF6_DEBUG_DATABASE_DETAIL 0x02 +#define OSPF6_DEBUG_DATABASE_ON(level) \ + (conf_debug_ospf6_database |= (level)) +#define OSPF6_DEBUG_DATABASE_OFF(level) \ + (conf_debug_ospf6_database &= ~(level)) +#define IS_OSPF6_DEBUG_DATABASE(level) \ + (conf_debug_ospf6_database & OSPF6_DEBUG_ ## level) + +void install_element_ospf6_debug_database (); +void ospf6_debug_lsdb_show (int level, struct ospf6_lsdb *lsdb); + +int ospf6_debug_router_lsa_show (struct ospf6_lsa *lsa); +int ospf6_debug_network_lsa_show (struct ospf6_lsa *lsa); +int ospf6_debug_link_lsa_show (struct ospf6_lsa *lsa); +int ospf6_debug_intra_prefix_lsa_show (struct ospf6_lsa *lsa); +#endif /* OSPF6_LSDB_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_main.c quagga-0.99.9-af/ospf6d/ospf6_main.c --- quagga-0.99.9/ospf6d/ospf6_main.c 2006-10-15 16:34:48.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_main.c 2008-12-03 13:42:15.000000000 -0800 @@ -44,14 +44,12 @@ #define OSPF6_VTY_PORT 2606 /* ospf6d privileges */ -zebra_capabilities_t _caps_p [] = -{ +zebra_capabilities_t _caps_p[] = { ZCAP_NET_RAW, ZCAP_BIND }; -struct zebra_privs_t ospf6d_privs = -{ +struct zebra_privs_t ospf6d_privs = { #if defined(QUAGGA_USER) .user = QUAGGA_USER, #endif @@ -67,8 +65,7 @@ }; /* ospf6d options, we use GNU getopt library. */ -struct option longopts[] = -{ +struct option longopts[] = { { "daemon", no_argument, NULL, 'd'}, { "config_file", required_argument, NULL, 'f'}, { "pid_file", required_argument, NULL, 'i'}, @@ -155,8 +152,7 @@ zlog_rotate (NULL); } -struct quagga_signal_t ospf6_signals[] = -{ +struct quagga_signal_t ospf6_signals[] = { { .signal = SIGHUP, .handler = &sighup, @@ -256,8 +252,7 @@ /* Initializations. */ zlog_default = openzlog (progname, ZLOG_OSPF6, - LOG_CONS|LOG_NDELAY|LOG_PID, - LOG_DAEMON); + LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); zprivs_init (&ospf6d_privs); /* initialize zebra libraries */ signal_init (master, Q_SIGC(ospf6_signals), ospf6_signals); diff -Naur quagga-0.99.9/ospf6d/ospf6_message.c quagga-0.99.9-af/ospf6d/ospf6_message.c --- quagga-0.99.9/ospf6d/ospf6_message.c 2006-05-15 03:43:52.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_message.c 2008-12-03 13:42:15.000000000 -0800 @@ -101,7 +101,7 @@ ospf6_dbdesc_print (struct ospf6_header *oh) { struct ospf6_dbdesc *dbdesc; - char options[16]; + char options[OSPF6OPTSTRLEN]; char *p; ospf6_header_print (oh); @@ -289,6 +289,24 @@ hello = (struct ospf6_hello *) ((caddr_t) oh + sizeof (struct ospf6_header)); + /* AF draft 05 Sec 2.4 + When a router participates in an AF (sets the AF-bit in Options + field) it MUST discard Hello packets having the AF-bit clear in + the Options field. The only exception is IPv6 unicast AF, where + this check MUST NOT be done (for backward compatibility). */ + /* Address Family check */ + if (OSPF6_OPT_ISSET (oi->area->options, OSPF6_OPT_AF, 1) && + oi->instance_id >= 32) + { + if (!OSPF6_OPT_ISSET (hello->options, OSPF6_OPT_AF, 1)) + { + if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) + zlog_debug ("Address Family Bit mismatch"); + return; + } + } + + /* HelloInterval check */ if (ntohs (hello->hello_interval) != oi->hello_interval) { @@ -306,8 +324,8 @@ } /* E-bit check */ - if (OSPF6_OPT_ISSET (hello->options, OSPF6_OPT_E) != - OSPF6_OPT_ISSET (oi->area->options, OSPF6_OPT_E)) + if (OSPF6_OPT_ISSET (hello->options, OSPF6_OPT_E, 2) != + OSPF6_OPT_ISSET (oi->area->options, OSPF6_OPT_E, 2)) { if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) zlog_debug ("E-bit mismatch"); @@ -375,7 +393,8 @@ { if (hello->bdrouter == on->router_id) backupseen++; - else if (hello->drouter == on->router_id && hello->bdrouter == htonl (0)) + else if (hello->drouter == on->router_id + && hello->bdrouter == htonl (0)) backupseen++; } @@ -394,8 +413,7 @@ } static void -ospf6_dbdesc_recv_master (struct ospf6_header *oh, - struct ospf6_neighbor *on) +ospf6_dbdesc_recv_master (struct ospf6_header *oh, struct ospf6_neighbor *on) { struct ospf6_dbdesc *dbdesc; char *p; @@ -605,8 +623,7 @@ } static void -ospf6_dbdesc_recv_slave (struct ospf6_header *oh, - struct ospf6_neighbor *on) +ospf6_dbdesc_recv_slave (struct ospf6_header *oh, struct ospf6_neighbor *on) { struct ospf6_dbdesc *dbdesc; char *p; @@ -842,8 +859,7 @@ if (dbdesc->reserved1 || dbdesc->reserved2) { if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) - zlog_debug ("Non-0 reserved field in %s's DbDesc, correct", - on->name); + zlog_debug ("Non-0 reserved field in %s's DbDesc, correct", on->name); dbdesc->reserved1 = 0; dbdesc->reserved2 = 0; } @@ -881,8 +897,7 @@ } if (on->state != OSPF6_NEIGHBOR_EXCHANGE && - on->state != OSPF6_NEIGHBOR_LOADING && - on->state != OSPF6_NEIGHBOR_FULL) + on->state != OSPF6_NEIGHBOR_LOADING && on->state != OSPF6_NEIGHBOR_FULL) { if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) zlog_debug ("Neighbor state less than Exchange, ignore"); @@ -1020,8 +1035,11 @@ on->state == OSPF6_NEIGHBOR_LOADING)) { THREAD_OFF (on->thread_send_lsreq); - on->thread_send_lsreq = - thread_add_event (master, ospf6_lsreq_send, on, 0); + // this was causing a flood of requests and updates because the + // LSA was not being accepted until after minLSArrival passed + on->thread_send_lsreq = thread_add_timer (master, ospf6_lsreq_send, on, + oi->area->ospf6-> + minLSArrival); } } @@ -1047,8 +1065,7 @@ } if (on->state != OSPF6_NEIGHBOR_EXCHANGE && - on->state != OSPF6_NEIGHBOR_LOADING && - on->state != OSPF6_NEIGHBOR_FULL) + on->state != OSPF6_NEIGHBOR_LOADING && on->state != OSPF6_NEIGHBOR_FULL) { if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) zlog_debug ("Neighbor state less than Exchange, ignore"); @@ -1116,8 +1133,7 @@ } if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) - zlog_debug ("Acknowledged, remove from %s's retrans-list", - on->name); + zlog_debug ("Acknowledged, remove from %s's retrans-list", on->name); ospf6_decrement_retrans_count (mine); if (OSPF6_LSA_IS_MAXAGE (mine)) @@ -1226,7 +1242,8 @@ zlog_debug (" src: %s", srcname); zlog_debug (" dst: %s", dstname); if (len != ntohs (oh->length)) - zlog_debug ("Message length does not match actually received: %d", len); + zlog_debug ("Message length does not match actually received: %d", + len); switch (oh->type) { @@ -1297,10 +1314,13 @@ int len; char srcname[64], dstname[64]; struct iovec iovector[2]; + int length; /* initialize */ iovector[0].iov_base = (caddr_t) oh; + length = ntohs (oh->length); // not in original code iovector[0].iov_len = ntohs (oh->length); + iovector[1].iov_base = NULL; iovector[1].iov_len = 0; @@ -1352,11 +1372,16 @@ } /* send message */ + len = ospf6_sendmsg (src, dst, &oi->interface->ifindex, iovector); if (len != ntohs (oh->length)) - zlog_err ("Could not send entire message"); + zlog_err ("Could not send entire message length %d != %d", oh->length, + len); } + + + int ospf6_hello_send (struct thread *thread) { @@ -1378,13 +1403,18 @@ return 0; } + if (oi->type == OSPF6_IFTYPE_LOOPBACK) + return 0; + + /* set next thread */ oi->thread_send_hello = thread_add_timer (master, ospf6_hello_send, oi, oi->hello_interval); memset (sendbuf, 0, iobuflen); oh = (struct ospf6_header *) sendbuf; - hello = (struct ospf6_hello *)((caddr_t) oh + sizeof (struct ospf6_header)); + hello = + (struct ospf6_hello *) ((caddr_t) oh + sizeof (struct ospf6_header)); hello->interface_id = htonl (oi->interface->ifindex); hello->priority = oi->priority; @@ -1580,7 +1610,8 @@ lsa = ospf6_lsdb_next (lsa)) { /* MTU check */ - if (p - sendbuf + sizeof (struct ospf6_lsreq_entry) > on->ospf6_if->ifmtu) + if (p - sendbuf + sizeof (struct ospf6_lsreq_entry) > + on->ospf6_if->ifmtu) { ospf6_lsa_unlock (lsa); break; @@ -1626,8 +1657,7 @@ } /* if we have nothing to send, return */ - if (on->lsupdate_list->count == 0 && - on->retrans_list->count == 0) + if (on->lsupdate_list->count == 0 && on->retrans_list->count == 0) { if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) zlog_debug ("Quit to send (nothing to send)"); @@ -1689,8 +1719,7 @@ ospf6_send (on->ospf6_if->linklocal_addr, &on->linklocal_addr, on->ospf6_if, oh); - if (on->lsupdate_list->count != 0 || - on->retrans_list->count != 0) + if (on->lsupdate_list->count != 0 || on->retrans_list->count != 0) { if (on->lsupdate_list->count != 0) on->thread_send_lsupdate = @@ -1721,7 +1750,8 @@ { if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) zlog_debug ("Quit to send LSUpdate to interface %s state %s", - oi->interface->name, ospf6_interface_state_str[oi->state]); + oi->interface->name, + ospf6_interface_state_str[oi->state]); return 0; } @@ -1762,8 +1792,14 @@ oh->type = OSPF6_MESSAGE_TYPE_LSUPDATE; oh->length = htons (p - sendbuf); - if (oi->state == OSPF6_INTERFACE_DR || - oi->state == OSPF6_INTERFACE_BDR) + if (oi->type == OSPF6_IFTYPE_BROADCAST || oi->type == OSPF6_IFTYPE_NBMA) + { + if (oi->state == OSPF6_INTERFACE_DR || oi->state == OSPF6_INTERFACE_BDR) + ospf6_send (oi->linklocal_addr, &allspfrouters6, oi, oh); + else + ospf6_send (oi->linklocal_addr, &alldrouters6, oi, oh); + } + else if (oi->type == OSPF6_IFTYPE_POINTOMULTIPOINT) ospf6_send (oi->linklocal_addr, &allspfrouters6, oi, oh); else ospf6_send (oi->linklocal_addr, &alldrouters6, oi, oh); @@ -1809,7 +1845,8 @@ lsa = ospf6_lsdb_next (lsa)) { /* MTU check */ - if (p - sendbuf + sizeof (struct ospf6_lsa_header) > on->ospf6_if->ifmtu) + if (p - sendbuf + sizeof (struct ospf6_lsa_header) > + on->ospf6_if->ifmtu) { /* if we run out of packet size/space here, better to try again soon. */ @@ -1852,7 +1889,8 @@ { if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_LSACK, SEND)) zlog_debug ("Quit to send LSAck to interface %s state %s", - oi->interface->name, ospf6_interface_state_str[oi->state]); + oi->interface->name, + ospf6_interface_state_str[oi->state]); return 0; } @@ -1892,11 +1930,15 @@ oh->type = OSPF6_MESSAGE_TYPE_LSACK; oh->length = htons (p - sendbuf); - if (oi->state == OSPF6_INTERFACE_DR || - oi->state == OSPF6_INTERFACE_BDR) + if (oi->type == OSPF6_IFTYPE_BROADCAST || oi->type == OSPF6_IFTYPE_NBMA) + { + if (oi->state == OSPF6_INTERFACE_DR || oi->state == OSPF6_INTERFACE_BDR) ospf6_send (oi->linklocal_addr, &allspfrouters6, oi, oh); else ospf6_send (oi->linklocal_addr, &alldrouters6, oi, oh); + } + else + ospf6_send (oi->linklocal_addr, &allspfrouters6, oi, oh); if (oi->thread_send_lsack == NULL && oi->lsack_list->count > 0) { @@ -1907,7 +1949,6 @@ return 0; } - /* Commands */ DEFUN (debug_ospf6_message, debug_ospf6_message_cmd, @@ -1920,9 +1961,7 @@ "Debug Database Description message\n" "Debug Link State Request message\n" "Debug Link State Update message\n" - "Debug Link State Acknowledgement message\n" - "Debug All message\n" - ) + "Debug Link State Acknowledgement message\n" "Debug All message\n") { unsigned char level = 0; int type = 0; @@ -1977,9 +2016,7 @@ "Debug Link State Update message\n" "Debug Link State Acknowledgement message\n" "Debug All message\n" - "Debug only sending message\n" - "Debug only receiving message\n" - ); + "Debug only sending message\n" "Debug only receiving message\n"); DEFUN (no_debug_ospf6_message, @@ -1994,9 +2031,7 @@ "Debug Database Description message\n" "Debug Link State Request message\n" "Debug Link State Update message\n" - "Debug Link State Acknowledgement message\n" - "Debug All message\n" - ) + "Debug Link State Acknowledgement message\n" "Debug All message\n") { unsigned char level = 0; int type = 0; @@ -2053,15 +2088,14 @@ "Debug Link State Update message\n" "Debug Link State Acknowledgement message\n" "Debug All message\n" - "Debug only sending message\n" - "Debug only receiving message\n" - ); + "Debug only sending message\n" "Debug only receiving message\n"); int config_write_ospf6_debug_message (struct vty *vty) { const char *type_str[] = {"unknown", "hello", "dbdesc", - "lsreq", "lsupdate", "lsack"}; + "lsreq", "lsupdate", "lsack" + }; unsigned char s = 0, r = 0; int i; @@ -2105,11 +2139,9 @@ IS_OSPF6_DEBUG_MESSAGE (i, RECV)) vty_out (vty, "debug ospf6 message %s%s", type_str[i], VNL); else if (IS_OSPF6_DEBUG_MESSAGE (i, SEND)) - vty_out (vty, "debug ospf6 message %s send%s", type_str[i], - VNL); + vty_out (vty, "debug ospf6 message %s send%s", type_str[i], VNL); else if (IS_OSPF6_DEBUG_MESSAGE (i, RECV)) - vty_out (vty, "debug ospf6 message %s recv%s", type_str[i], - VNL); + vty_out (vty, "debug ospf6 message %s recv%s", type_str[i], VNL); } return 0; diff -Naur quagga-0.99.9/ospf6d/ospf6_message.h quagga-0.99.9-af/ospf6d/ospf6_message.h --- quagga-0.99.9/ospf6d/ospf6_message.h 2004-10-11 09:21:34.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_message.h 2008-12-03 13:42:15.000000000 -0800 @@ -137,5 +137,11 @@ int config_write_ospf6_debug_message (struct vty *); void install_element_ospf6_debug_message (); -#endif /* OSPF6_MESSAGE_H */ + + + + + + +#endif /* OSPF6_MESSAGE_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_neighbor.c quagga-0.99.9-af/ospf6d/ospf6_neighbor.c --- quagga-0.99.9/ospf6d/ospf6_neighbor.c 2007-03-08 09:47:47.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/ospf6_neighbor.c 2008-12-03 13:42:15.000000000 -0800 @@ -39,12 +39,14 @@ #include "ospf6_intra.h" #include "ospf6_flood.h" #include "ospf6d.h" +#include "ospf6d.h" unsigned char conf_debug_ospf6_neighbor = 0; const char *ospf6_neighbor_state_str[] = { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange", - "Loading", "Full", NULL }; + "Loading", "Full", NULL +}; int ospf6_neighbor_cmp (void *va, void *vb) @@ -55,8 +57,7 @@ } struct ospf6_neighbor * -ospf6_neighbor_lookup (u_int32_t router_id, - struct ospf6_interface *oi) +ospf6_neighbor_lookup (u_int32_t router_id, struct ospf6_interface *oi) { struct listnode *n; struct ospf6_neighbor *on; @@ -85,8 +86,7 @@ memset (on, 0, sizeof (struct ospf6_neighbor)); inet_ntop (AF_INET, &router_id, buf, sizeof (buf)); - snprintf (on->name, sizeof (on->name), "%s%%%s", - buf, oi->interface->name); + snprintf (on->name, sizeof (on->name), "%s%%%s", buf, oi->interface->name); on->ospf6_if = oi; on->state = OSPF6_NEIGHBOR_DOWN; gettimeofday (&on->last_changed, (struct timezone *) NULL); @@ -143,7 +143,8 @@ XFREE (MTYPE_OSPF6_NEIGHBOR, on); } -static void +static + void ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on) { u_char prev_state; @@ -189,7 +190,9 @@ if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT || on->ospf6_if->state == OSPF6_INTERFACE_DR || on->ospf6_if->state == OSPF6_INTERFACE_BDR) + { return 1; + } if (on->ospf6_if->drouter == on->router_id || on->ospf6_if->bdrouter == on->router_id) @@ -399,8 +402,7 @@ thread_add_event (master, ospf6_dbdesc_send, on, 0); } - else if (on->state >= OSPF6_NEIGHBOR_EXSTART && - ! need_adjacency (on)) + else if (on->state >= OSPF6_NEIGHBOR_EXSTART && !need_adjacency (on)) { ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on); ospf6_lsdb_remove_all (on->summary_list); @@ -547,8 +549,6 @@ return 0; } - - /* vty functions */ /* show neighbor structure */ void @@ -574,7 +574,8 @@ h = m = s = 0; if (on->inactivity_timer) { - s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec; + s = + on->inactivity_timer->u.sands.tv_sec - recent_relative_time ().tv_sec; h = s / 3600; s -= h * 3600; m = s / 60; @@ -583,7 +584,8 @@ snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s); /* Neighbor State */ - if (if_is_pointopoint (on->ospf6_if->interface)) + if (on->ospf6_if->type == OSPF6_IFTYPE_POINTOMULTIPOINT || + on->ospf6_if->type == OSPF6_IFTYPE_POINTOPOINT) snprintf (nstate, sizeof (nstate), "PointToPoint"); else { @@ -637,8 +639,7 @@ vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", router_id, ospf6_neighbor_state_str[on->state], duration, drouter, bdrouter, on->ospf6_if->interface->name, - ospf6_interface_state_str[on->ospf6_if->state], - VNL); + ospf6_interface_state_str[on->ospf6_if->state], VNL); } void @@ -658,43 +659,36 @@ timersub (&now, &on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " Neighbor %s%s", on->name, - VNL); + vty_out (vty, " Neighbor %s%s", on->name, VNL); vty_out (vty, " Area %s via interface %s (ifindex %d)%s", on->ospf6_if->area->name, on->ospf6_if->interface->name, - on->ospf6_if->interface->ifindex, - VNL); + on->ospf6_if->interface->ifindex, VNL); vty_out (vty, " His IfIndex: %d Link-local address: %s%s", - on->ifindex, linklocal_addr, - VNL); + on->ifindex, linklocal_addr, VNL); vty_out (vty, " State %s for a duration of %s%s", - ospf6_neighbor_state_str[on->state], duration, - VNL); + ospf6_neighbor_state_str[on->state], duration, VNL); vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s", - drouter, bdrouter, on->priority, - VNL); + drouter, bdrouter, on->priority, VNL); vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s", - (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""), - (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""), - (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ? - "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum), - VNL); + (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : + ""), (CHECK_FLAG (on->dbdesc_bits, + OSPF6_DBDESC_MBIT) ? "More " : ""), + (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ? "Master" : + "Slave"), (u_long) ntohl (on->dbdesc_seqnum), VNL); + - vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count, - VNL); + vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count, VNL); for (lsa = ospf6_lsdb_head (on->summary_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); - vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count, - VNL); + vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count, VNL); for (lsa = ospf6_lsdb_head (on->request_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); - vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count, - VNL); + vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count, VNL); for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); @@ -705,8 +699,7 @@ timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s", on->dbdesc_list->count, duration, - (on->thread_send_dbdesc ? "on" : "off"), - VNL); + (on->thread_send_dbdesc ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); @@ -717,8 +710,7 @@ timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s", on->lsreq_list->count, duration, - (on->thread_send_lsreq ? "on" : "off"), - VNL); + (on->thread_send_lsreq ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->lsreq_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); @@ -729,8 +721,7 @@ timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", on->lsupdate_list->count, duration, - (on->thread_send_lsupdate ? "on" : "off"), - VNL); + (on->thread_send_lsupdate ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); @@ -741,8 +732,7 @@ timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", on->lsack_list->count, duration, - (on->thread_send_lsack ? "on" : "off"), - VNL); + (on->thread_send_lsack ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->lsack_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); @@ -752,11 +742,7 @@ DEFUN (show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd, "show ipv6 ospf6 neighbor", - SHOW_STR - IP6_STR - OSPF6_STR - "Neighbor list\n" - ) + SHOW_STR IP6_STR OSPF6_STR "Neighbor list\n") { struct ospf6_neighbor *on; struct ospf6_interface *oi; @@ -798,10 +784,7 @@ SHOW_STR IP6_STR OSPF6_STR - "Neighbor list\n" - "Display details\n" - "Display DR choices\n" - ); + "Neighbor list\n" "Display details\n" "Display DR choices\n"); DEFUN (show_ipv6_ospf6_neighbor_one, show_ipv6_ospf6_neighbor_one_cmd, @@ -809,9 +792,7 @@ SHOW_STR IP6_STR OSPF6_STR - "Neighbor list\n" - "Specify Router-ID as IPv4 address notation\n" - ) + "Neighbor list\n" "Specify Router-ID as IPv4 address notation\n") { struct ospf6_neighbor *on; struct ospf6_interface *oi; @@ -825,8 +806,7 @@ if ((inet_pton (AF_INET, argv[0], &router_id)) != 1) { - vty_out (vty, "Router-ID is not parsable: %s%s", argv[0], - VNL); + vty_out (vty, "Router-ID is not parsable: %s%s", argv[0], VNL); return CMD_SUCCESS; } @@ -849,11 +829,7 @@ DEFUN (debug_ospf6_neighbor, debug_ospf6_neighbor_cmd, - "debug ospf6 neighbor", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 Neighbor\n" - ) + "debug ospf6 neighbor", DEBUG_STR OSPF6_STR "Debug OSPFv3 Neighbor\n") { unsigned char level = 0; if (argc) @@ -877,17 +853,12 @@ OSPF6_STR "Debug OSPFv3 Neighbor\n" "Debug OSPFv3 Neighbor State Change\n" - "Debug OSPFv3 Neighbor Event\n" - ); + "Debug OSPFv3 Neighbor Event\n"); DEFUN (no_debug_ospf6_neighbor, no_debug_ospf6_neighbor_cmd, "no debug ospf6 neighbor", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 Neighbor\n" - ) + NO_STR DEBUG_STR OSPF6_STR "Debug OSPFv3 Neighbor\n") { unsigned char level = 0; if (argc) @@ -912,14 +883,12 @@ OSPF6_STR "Debug OSPFv3 Neighbor\n" "Debug OSPFv3 Neighbor State Change\n" - "Debug OSPFv3 Neighbor Event\n" - ); + "Debug OSPFv3 Neighbor Event\n"); int config_write_ospf6_debug_neighbor (struct vty *vty) { - if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) && - IS_OSPF6_DEBUG_NEIGHBOR (EVENT)) + if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) && IS_OSPF6_DEBUG_NEIGHBOR (EVENT)) vty_out (vty, "debug ospf6 neighbor%s", VNL); else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE)) vty_out (vty, "debug ospf6 neighbor state%s", VNL); diff -Naur quagga-0.99.9/ospf6d/ospf6_neighbor.h quagga-0.99.9-af/ospf6d/ospf6_neighbor.h --- quagga-0.99.9/ospf6d/ospf6_neighbor.h 2004-10-11 09:21:34.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_neighbor.h 2008-12-03 13:42:15.000000000 -0800 @@ -22,6 +22,11 @@ #ifndef OSPF6_NEIGHBOR_H #define OSPF6_NEIGHBOR_H +#include "ospf6_message.h" + + + + /* Debug option */ extern unsigned char conf_debug_ospf6_neighbor; #define OSPF6_DEBUG_NEIGHBOR_STATE 0x01 @@ -107,7 +112,6 @@ const extern char *ospf6_neighbor_state_str[]; - /* Function Prototypes */ int ospf6_neighbor_cmp (void *va, void *vb); void ospf6_neighbor_dbex_init (struct ospf6_neighbor *on); @@ -134,5 +138,8 @@ int config_write_ospf6_debug_neighbor (struct vty *vty); void install_element_ospf6_debug_neighbor (); -#endif /* OSPF6_NEIGHBOR_H */ + + + +#endif /* OSPF6_NEIGHBOR_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_network.c quagga-0.99.9-af/ospf6d/ospf6_network.c --- quagga-0.99.9/ospf6d/ospf6_network.c 2006-05-15 03:43:52.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_network.c 2008-12-03 13:42:15.000000000 -0800 @@ -70,7 +70,8 @@ #ifndef DISABLE_IPV6_CHECKSUM if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_CHECKSUM, &offset, sizeof (offset)) < 0) - zlog_warn ("Network: set IPV6_CHECKSUM failed: %s", safe_strerror (errno)); + zlog_warn ("Network: set IPV6_CHECKSUM failed: %s", + safe_strerror (errno)); #else zlog_warn ("Network: Don't set IPV6_CHECKSUM"); #endif /* DISABLE_IPV6_CHECKSUM */ @@ -119,8 +120,7 @@ assert (ifindex); mreq6.ipv6mr_interface = ifindex; - memcpy (&mreq6.ipv6mr_multiaddr, &allspfrouters6, - sizeof (struct in6_addr)); + memcpy (&mreq6.ipv6mr_multiaddr, &allspfrouters6, sizeof (struct in6_addr)); retval = setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, sizeof (mreq6)); @@ -141,8 +141,7 @@ assert (ifindex); mreq6.ipv6mr_interface = ifindex; - memcpy (&mreq6.ipv6mr_multiaddr, &allspfrouters6, - sizeof (struct in6_addr)); + memcpy (&mreq6.ipv6mr_multiaddr, &allspfrouters6, sizeof (struct in6_addr)); if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mreq6, sizeof (mreq6)) < 0) @@ -161,8 +160,7 @@ assert (ifindex); mreq6.ipv6mr_interface = ifindex; - memcpy (&mreq6.ipv6mr_multiaddr, &alldrouters6, - sizeof (struct in6_addr)); + memcpy (&mreq6.ipv6mr_multiaddr, &alldrouters6, sizeof (struct in6_addr)); if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, sizeof (mreq6)) < 0) @@ -181,8 +179,7 @@ assert (ifindex); mreq6.ipv6mr_interface = ifindex; - memcpy (&mreq6.ipv6mr_multiaddr, &alldrouters6, - sizeof (struct in6_addr)); + memcpy (&mreq6.ipv6mr_multiaddr, &alldrouters6, sizeof (struct in6_addr)); if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mreq6, sizeof (mreq6)) < 0) diff -Naur quagga-0.99.9/ospf6d/ospf6_network.h quagga-0.99.9-af/ospf6d/ospf6_network.h --- quagga-0.99.9/ospf6d/ospf6_network.h 2004-05-18 14:27:57.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_network.h 2008-12-03 13:48:39.000000000 -0800 @@ -22,8 +22,6 @@ #ifndef OSPF6_NETWORK_H #define OSPF6_NETWORK_H - - extern int ospf6_sock; extern struct in6_addr allspfrouters6; extern struct in6_addr alldrouters6; diff -Naur quagga-0.99.9/ospf6d/ospf6_proto.c quagga-0.99.9-af/ospf6d/ospf6_proto.c --- quagga-0.99.9/ospf6d/ospf6_proto.c 2004-10-11 09:21:34.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_proto.c 2008-12-03 13:42:15.000000000 -0800 @@ -73,13 +73,24 @@ ospf6_options_printbuf (u_char *options, char *buf, int size) { const char *dc, *r, *n, *mc, *e, *v6; - dc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_DC) ? "DC" : "--"); - r = (OSPF6_OPT_ISSET (options, OSPF6_OPT_R) ? "R" : "-" ); - n = (OSPF6_OPT_ISSET (options, OSPF6_OPT_N) ? "N" : "-" ); - mc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_MC) ? "MC" : "--"); - e = (OSPF6_OPT_ISSET (options, OSPF6_OPT_E) ? "E" : "-" ); - v6 = (OSPF6_OPT_ISSET (options, OSPF6_OPT_V6) ? "V6" : "--"); - snprintf (buf, size, "%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6); -} + const char *AF; + int tmp; + + + AF = (OSPF6_OPT_ISSET (options, OSPF6_OPT_AF, 1) ? "AF" : "--"); + tmp = snprintf (buf, size, "%s|", AF); + if (tmp < 0 || tmp >= size) + return; + buf += tmp; + size -= tmp; + dc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_DC, 2) ? "DC" : "--"); + r = (OSPF6_OPT_ISSET (options, OSPF6_OPT_R, 2) ? "R" : "-"); + n = (OSPF6_OPT_ISSET (options, OSPF6_OPT_N, 2) ? "N" : "-"); + mc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_MC, 2) ? "MC" : "--"); + e = (OSPF6_OPT_ISSET (options, OSPF6_OPT_E, 2) ? "E" : "-"); + v6 = (OSPF6_OPT_ISSET (options, OSPF6_OPT_V6, 2) ? "V6" : "--"); + + snprintf (buf, size, "--|--|%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6); +} diff -Naur quagga-0.99.9/ospf6d/ospf6_proto.h quagga-0.99.9-af/ospf6d/ospf6_proto.h --- quagga-0.99.9/ospf6d/ospf6_proto.h 2004-09-29 18:37:29.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_proto.h 2008-12-03 13:42:15.000000000 -0800 @@ -60,11 +60,18 @@ /* OSPF options */ /* present in HELLO, DD, LSA */ -#define OSPF6_OPT_SET(x,opt) ((x)[2] |= (opt)) -#define OSPF6_OPT_ISSET(x,opt) ((x)[2] & (opt)) -#define OSPF6_OPT_CLEAR(x,opt) ((x)[2] &= ~(opt)) +#define OSPF6_OPT_SET(x,opt,i) ((x)[(i)] |= (opt)) +#define OSPF6_OPT_ISSET(x,opt,i) ((x)[(i)] & (opt)) +#define OSPF6_OPT_CLEAR(x,opt,i) ((x)[(i)] &= ~(opt)) #define OSPF6_OPT_CLEAR_ALL(x) ((x)[0] = (x)[1] = (x)[2] = 0) + + /* AF draft 05 Sec 2.4 + When a router supports AF, it MUST set this new AF bit in the Options + field of Hello Packets, DD packets and LSAs. + */ +#define OSPF6_OPT_AF (1 << 0) /* Indicates usage of address families */ + #define OSPF6_OPT_DC (1 << 5) /* Demand Circuit handling Capability */ #define OSPF6_OPT_R (1 << 4) /* Forwarding Capability (Any Protocol) */ #define OSPF6_OPT_N (1 << 3) /* Handling Type-7 LSA Capability */ @@ -77,7 +84,8 @@ { u_int8_t prefix_length; u_int8_t prefix_options; - union { + union + { u_int16_t _prefix_metric; u_int16_t _prefix_referenced_lstype; } u; @@ -88,7 +96,6 @@ #define OSPF6_PREFIX_OPTION_NU (1 << 0) /* No Unicast */ #define OSPF6_PREFIX_OPTION_LA (1 << 1) /* Local Address */ -#define OSPF6_PREFIX_OPTION_MC (1 << 2) /* MultiCast */ #define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */ /* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */ @@ -112,6 +119,8 @@ OSPF6_PREFIX_SPACE ((op)->prefix_length)); \ } while (0) +#define OSPF6OPTSTRLEN 32 + void ospf6_prefix_apply_mask (struct ospf6_prefix *op); void ospf6_prefix_options_printbuf (u_int8_t prefix_options, char *buf, int size); diff -Naur quagga-0.99.9/ospf6d/ospf6_route.c quagga-0.99.9-af/ospf6d/ospf6_route.c --- quagga-0.99.9/ospf6d/ospf6_route.c 2006-05-15 03:43:52.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_route.c 2008-12-03 13:42:15.000000000 -0800 @@ -72,16 +72,13 @@ switch (table->table_type) { case OSPF6_TABLE_TYPE_SPF_RESULTS: - snprintf (name, sizeof (name), - "area %s spf table", oa->name); + snprintf (name, sizeof (name), "area %s spf table", oa->name); break; case OSPF6_TABLE_TYPE_ROUTES: - snprintf (name, sizeof (name), - "area %s route table", oa->name); + snprintf (name, sizeof (name), "area %s route table", oa->name); break; case OSPF6_TABLE_TYPE_PREFIX_RANGES: - snprintf (name, sizeof (name), - "area %s range table", oa->name); + snprintf (name, sizeof (name), "area %s range table", oa->name); break; case OSPF6_TABLE_TYPE_SUMMARY_PREFIXES: snprintf (name, sizeof (name), @@ -92,8 +89,7 @@ "area %s summary router table", oa->name); break; default: - snprintf (name, sizeof (name), - "area %s unknown table", oa->name); + snprintf (name, sizeof (name), "area %s unknown table", oa->name); break; } } @@ -259,8 +255,7 @@ } struct ospf6_route * -ospf6_route_lookup (struct prefix *prefix, - struct ospf6_route_table *table) +ospf6_route_lookup (struct prefix *prefix, struct ospf6_route_table *table) { struct route_node *node; struct ospf6_route *route; @@ -351,10 +346,8 @@ #else #define ospf6_route_table_assert(t) ((void) 0) #endif /*NDEBUG*/ - struct ospf6_route * -ospf6_route_add (struct ospf6_route *route, - struct ospf6_route_table *table) +ospf6_route_add (struct ospf6_route *route, struct ospf6_route_table *table) { struct route_node *node, *nextnode, *prevnode; struct ospf6_route *current = NULL; @@ -424,8 +417,7 @@ zlog_debug ("%s %p: route add %p: update of %p", ospf6_route_table_name (table), table, route, old); else if (IS_OSPF6_DEBUG_ROUTE (TABLE)) - zlog_debug ("%s: route add: update", - ospf6_route_table_name (table)); + zlog_debug ("%s: route add: update", ospf6_route_table_name (table)); /* replace old one if exists */ if (node->info == old) @@ -527,9 +519,11 @@ /* lookup real existing next route */ nextnode = node; route_lock_node (nextnode); - do { + do + { nextnode = route_next (nextnode); - } while (nextnode && nextnode->info == NULL); + } + while (nextnode && nextnode->info == NULL); /* set next link */ if (nextnode == NULL) @@ -546,9 +540,11 @@ /* lookup real existing prev route */ prevnode = node; route_lock_node (prevnode); - do { + do + { prevnode = route_prev (prevnode); - } while (prevnode && prevnode->info == NULL); + } + while (prevnode && prevnode->info == NULL); /* set prev link */ if (prevnode == NULL) @@ -739,8 +735,7 @@ } struct ospf6_route * -ospf6_route_match_next (struct prefix *prefix, - struct ospf6_route *route) +ospf6_route_match_next (struct prefix *prefix, struct ospf6_route *route) { struct ospf6_route *next; @@ -807,8 +802,7 @@ prefix2str (&route->prefix, destination, sizeof (destination)); /* nexthop */ - inet_ntop (AF_INET6, &route->nexthop[0].address, nexthop, - sizeof (nexthop)); + inet_ntop (AF_INET6, &route->nexthop[0].address, nexthop, sizeof (nexthop)); if (! if_indextoname (route->nexthop[0].ifindex, ifname)) snprintf (ifname, sizeof (ifname), "%d", route->nexthop[0].ifindex); @@ -836,7 +830,7 @@ ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route) { char destination[64], nexthop[64], ifname[IFNAMSIZ]; - char area_id[16], id[16], adv_router[16], capa[16], options[16]; + char area_id[16], id[16], adv_router[16], capa[16], options[OSPF6OPTSTRLEN]; struct timeval now, res; char duration[16]; int i; @@ -856,8 +850,7 @@ /* destination type */ vty_out (vty, "Destination type: %s%s", - OSPF6_DEST_TYPE_NAME (route->type), - VNL); + OSPF6_DEST_TYPE_NAME (route->type), VNL); /* Time */ timersub (&now, &route->installed, &res); @@ -873,8 +866,7 @@ (CHECK_FLAG (route->flag, OSPF6_ROUTE_BEST) ? "B" : "-"), (CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD) ? "A" : "-"), (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE) ? "R" : "-"), - (CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-"), - VNL); + (CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-"), VNL); vty_out (vty, "Memory: prev: %p this: %p next: %p%s", route->prev, route, route->next, VNL); @@ -893,8 +885,7 @@ inet_ntop (AF_INET, &route->path.origin.adv_router, adv_router, sizeof (adv_router)); vty_out (vty, "LS Origin: %s Id: %s Adv: %s%s", - ospf6_lstype_name (route->path.origin.type), - id, adv_router, VNL); + ospf6_lstype_name (route->path.origin.type), id, adv_router, VNL); /* Options */ ospf6_options_printbuf (route->path.options, options, sizeof (options)); @@ -908,8 +899,7 @@ vty_out (vty, "Prefix Options: xxx%s", VNL); /* Metrics */ - vty_out (vty, "Metric Type: %d%s", route->path.metric_type, - VNL); + vty_out (vty, "Metric Type: %d%s", route->path.metric_type, VNL); vty_out (vty, "Metric: %d (%d)%s", route->path.cost, route->path.cost_e2, VNL); @@ -1184,7 +1174,7 @@ ospf6_linkstate_show (struct vty *vty, struct ospf6_route *route) { u_int32_t router, id; - char routername[16], idname[16], rbits[16], options[16]; + char routername[16], idname[16], rbits[16], options[OSPF6OPTSTRLEN]; router = ospf6_linkstate_prefix_adv_router (&route->prefix); inet_ntop (AF_INET, &router, routername, sizeof (routername)); @@ -1321,7 +1311,7 @@ ospf6_brouter_show (struct vty *vty, struct ospf6_route *route) { u_int32_t adv_router; - char adv[16], rbits[16], options[16], area[16]; + char adv[16], rbits[16], options[OSPF6OPTSTRLEN], area[16]; adv_router = ospf6_linkstate_prefix_adv_router (&route->prefix); inet_ntop (AF_INET, &adv_router, adv, sizeof (adv)); @@ -1344,8 +1334,7 @@ "Debug route table calculation\n" "Debug detail\n" "Debug intra-area route calculation\n" - "Debug inter-area route calculation\n" - ) + "Debug inter-area route calculation\n") { unsigned char level = 0; diff -Naur quagga-0.99.9/ospf6d/ospf6_route.h quagga-0.99.9-af/ospf6d/ospf6_route.h --- quagga-0.99.9/ospf6d/ospf6_route.h 2006-05-15 03:43:53.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_route.h 2008-12-03 13:42:15.000000000 -0800 @@ -37,6 +37,8 @@ #define IS_OSPF6_DEBUG_ROUTE(e) \ (conf_debug_ospf6_route & OSPF6_DEBUG_ROUTE_ ## e) +#include "ospf6d.h" //for boolean + /* Nexthop */ struct ospf6_nexthop { @@ -45,6 +47,8 @@ /* IP address, if any */ struct in6_addr address; + + boolean directly_connected; }; #define ospf6_nexthop_is_set(x) \ @@ -257,21 +261,20 @@ void ospf6_route_lock (struct ospf6_route *route); void ospf6_route_unlock (struct ospf6_route *route); -struct ospf6_route * -ospf6_route_lookup (struct prefix *prefix, +struct ospf6_route *ospf6_route_lookup (struct prefix *prefix, struct ospf6_route_table *table); -struct ospf6_route * -ospf6_route_lookup_identical (struct ospf6_route *route, +struct ospf6_route *ospf6_route_lookup_identical (struct ospf6_route *route, + struct ospf6_route_table + *table); +struct ospf6_route *ospf6_route_lookup_bestmatch (struct prefix *prefix, + struct ospf6_route_table + *table); + +struct ospf6_route *ospf6_route_add (struct ospf6_route *route, struct ospf6_route_table *table); -struct ospf6_route * -ospf6_route_lookup_bestmatch (struct prefix *prefix, +void ospf6_route_remove (struct ospf6_route *route, struct ospf6_route_table *table); -struct ospf6_route * -ospf6_route_add (struct ospf6_route *route, struct ospf6_route_table *table); -void -ospf6_route_remove (struct ospf6_route *route, struct ospf6_route_table *table); - struct ospf6_route *ospf6_route_head (struct ospf6_route_table *table); struct ospf6_route *ospf6_route_next (struct ospf6_route *route); struct ospf6_route *ospf6_route_best_next (struct ospf6_route *route); diff -Naur quagga-0.99.9/ospf6d/ospf6_snmp.c quagga-0.99.9-af/ospf6d/ospf6_snmp.c --- quagga-0.99.9/ospf6d/ospf6_snmp.c 2007-04-29 05:40:40.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_snmp.c 2008-12-03 13:42:15.000000000 -0800 @@ -114,9 +114,7 @@ #define STRING ASN_OCTET_STR /* For return values e.g. SNMP_INTEGER macro */ -SNMP_LOCAL_VARIABLES - -static struct in_addr tmp; +SNMP_LOCAL_VARIABLES static struct in_addr tmp; #define INT32_INADDR(x) \ (tmp.s_addr = (x), tmp) @@ -131,8 +129,7 @@ static u_char *ospfv3AreaEntry (); static u_char *ospfv3AreaLsdbEntry (); -struct variable ospfv3_variables[] = -{ +struct variable ospfv3_variables[] = { /* OSPF general variables */ {OSPFv3ROUTERID, IPADDRESS, RWRITE, ospfv3GeneralGroup, 3, {1, 1, 1}}, @@ -202,7 +199,8 @@ 4, {1, 2, 1, 11}}, {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry, 4, {1, 2, 1, 12}}, - {OSPFv3AREANSSATRANSLATORSTABILITYINTERVAL, INTEGER, RWRITE, ospfv3AreaEntry, + {OSPFv3AREANSSATRANSLATORSTABILITYINTERVAL, INTEGER, RWRITE, + ospfv3AreaEntry, 4, {1, 2, 1, 13}}, {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry, 4, {1, 2, 1, 14}}, diff -Naur quagga-0.99.9/ospf6d/ospf6_spf.c quagga-0.99.9-af/ospf6d/ospf6_spf.c --- quagga-0.99.9/ospf6d/ospf6_spf.c 2005-04-05 01:45:16.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_spf.c 2008-12-03 14:06:17.000000000 -0800 @@ -41,6 +41,10 @@ #include "ospf6_interface.h" #include "ospf6d.h" + + +#include "ospf6_proto.h" + unsigned char conf_debug_ospf6_spf = 0; int @@ -284,8 +288,7 @@ struct listnode *node, *nnode; if (IS_OSPF6_DEBUG_SPF (PROCESS)) - zlog_debug ("SPF install %s hops %d cost %d", - v->name, v->hops, v->cost); + zlog_debug ("SPF install %s hops %d cost %d", v->name, v->hops, v->cost); route = ospf6_route_lookup (&v->vertex_id, result_table); if (route && route->path.cost < v->cost) @@ -331,8 +334,9 @@ listnode_delete (prev->parent->child_list, prev); listnode_add_sort (v->parent->child_list, v); - ospf6_vertex_delete (prev); + //ospf6_vertex_delete (prev); //HACK route->route_option = v; + } else ospf6_vertex_delete (v); @@ -414,13 +418,33 @@ /* construct root vertex */ lsa = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_ROUTER), htonl (0), router_id, oa->lsdb); + //The router should not use a maxaged LSA as the root. A maxaged LSA + //should be treated as NULL + if ((lsa != NULL) && OSPF6_LSA_IS_MAXAGE (lsa)) + lsa = NULL; + if (lsa == NULL) + { + //candidate list was not being deleted when returning on NULL + pqueue_delete (candidate_list); return; + } root = ospf6_vertex_create (lsa); root->area = oa; root->cost = 0; root->hops = 0; + root->nexthop[0].ifindex = 0; /* loopbak I/F is better ... */ + if (is_af_ipv4_unicast (NULL) || is_af_ipv4_multicast (NULL)) + { + struct interface *ifp; + struct in_addr ipv4_addr; + inet_pton (AF_INET, "127.0.0.1", &ipv4_addr); + ifp = if_lookup_exact_address (ipv4_addr); + root->nexthop[0].ifindex = ifp->ifindex; + inet_pton (AF_INET6, "::127.0.0.1", &root->nexthop[0].address); + } + else inet_pton (AF_INET6, "::1", &root->nexthop[0].address); /* Actually insert root to the candidate-list as the only candidate */ @@ -587,10 +611,7 @@ debug_ospf6_spf_process_cmd, "debug ospf6 spf process", DEBUG_STR - OSPF6_STR - "Debug SPF Calculation\n" - "Debug Detailed SPF Process\n" - ) + OSPF6_STR "Debug SPF Calculation\n" "Debug Detailed SPF Process\n") { unsigned char level = 0; level = OSPF6_DEBUG_SPF_PROCESS; @@ -603,9 +624,7 @@ "debug ospf6 spf time", DEBUG_STR OSPF6_STR - "Debug SPF Calculation\n" - "Measure time taken by SPF Calculation\n" - ) + "Debug SPF Calculation\n" "Measure time taken by SPF Calculation\n") { unsigned char level = 0; level = OSPF6_DEBUG_SPF_TIME; @@ -619,8 +638,7 @@ DEBUG_STR OSPF6_STR "Debug SPF Calculation\n" - "Log number of LSAs at SPF Calculation time\n" - ) + "Log number of LSAs at SPF Calculation time\n") { unsigned char level = 0; level = OSPF6_DEBUG_SPF_DATABASE; @@ -635,8 +653,7 @@ DEBUG_STR OSPF6_STR "Quit Debugging SPF Calculation\n" - "Quit Debugging Detailed SPF Process\n" - ) + "Quit Debugging Detailed SPF Process\n") { unsigned char level = 0; level = OSPF6_DEBUG_SPF_PROCESS; @@ -651,8 +668,7 @@ DEBUG_STR OSPF6_STR "Quit Debugging SPF Calculation\n" - "Quit Measuring time taken by SPF Calculation\n" - ) + "Quit Measuring time taken by SPF Calculation\n") { unsigned char level = 0; level = OSPF6_DEBUG_SPF_TIME; @@ -667,8 +683,7 @@ DEBUG_STR OSPF6_STR "Debug SPF Calculation\n" - "Quit Logging number of LSAs at SPF Calculation time\n" - ) + "Quit Logging number of LSAs at SPF Calculation time\n") { unsigned char level = 0; level = OSPF6_DEBUG_SPF_DATABASE; diff -Naur quagga-0.99.9/ospf6d/ospf6_top.c quagga-0.99.9-af/ospf6d/ospf6_top.c --- quagga-0.99.9/ospf6d/ospf6_top.c 2006-05-15 03:43:53.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_top.c 2008-12-03 13:42:15.000000000 -0800 @@ -126,6 +126,9 @@ o->lsdb->hook_add = ospf6_top_lsdb_hook_add; o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove; + o->minLSInterval = MIN_LS_INTERVAL; + o->minLSArrival = MIN_LS_ARRIVAL; + o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES); o->route_table->scope = o; o->route_table->hook_add = ospf6_top_route_hook_add; @@ -240,15 +243,45 @@ ospf6_maxage_remove (struct ospf6 *o) { if (o && ! o->maxage_remover) - o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0); + { + //Delay the purging of LSAs by 60 seconds + if (o->maxage_remover == NULL) + o->maxage_remover = + thread_add_timer (master, ospf6_maxage_remover, o, 60); + } } +DEFUN (ospf6_router_minlsinterval, + ospf6_router_minlsinterval_cmd, + "router minls-interval <0-65535>", + ROUTER_STR "minimum time to originate an LSA\n" SECONDS_STR) +{ + struct ospf6 *o; + + o = (struct ospf6 *) vty->index; + o->minLSInterval = strtol (argv[0], NULL, 10); + + return CMD_SUCCESS; +} + +DEFUN (ospf6_router_minlsarrival, + ospf6_router_minlsarrival_cmd, + "router minls-arrival <0-65535>", + ROUTER_STR "minimum time to receive an LSA\n" SECONDS_STR) +{ + struct ospf6 *o; + + o = (struct ospf6 *) vty->index; + + o->minLSArrival = strtol (argv[0], NULL, 10); + + return CMD_SUCCESS; +} + + + /* start ospf6 */ -DEFUN (router_ospf6, - router_ospf6_cmd, - "router ospf6", - ROUTER_STR - OSPF6_STR) +DEFUN (router_ospf6, router_ospf6_cmd, "router ospf6", ROUTER_STR OSPF6_STR) { if (ospf6 == NULL) ospf6 = ospf6_create (); @@ -264,10 +297,7 @@ /* stop ospf6 */ DEFUN (no_router_ospf6, - no_router_ospf6_cmd, - "no router ospf6", - NO_STR - OSPF6_ROUTER_STR) + no_router_ospf6_cmd, "no router ospf6", NO_STR OSPF6_ROUTER_STR) { if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) vty_out (vty, "OSPFv3 is not running%s", VNL); @@ -284,9 +314,7 @@ /* change Router_ID commands. */ DEFUN (ospf6_router_id, ospf6_router_id_cmd, - "router-id A.B.C.D", - "Configure OSPF Router-ID\n" - V4NOTATION_STR) + "router-id A.B.C.D", "Configure OSPF Router-ID\n" V4NOTATION_STR) { int ret; u_int32_t router_id; @@ -314,8 +342,7 @@ "Enable routing on an IPv6 interface\n" IFNAME_STR "Specify the OSPF6 area ID\n" - "OSPF6 area ID in IPv4 address notation\n" - ) + "OSPF6 area ID in IPv4 address notation\n") { struct ospf6 *o; struct ospf6_area *oa; @@ -372,8 +399,7 @@ "Disable routing on an IPv6 interface\n" IFNAME_STR "Specify the OSPF6 area ID\n" - "OSPF6 area ID in IPv4 address notation\n" - ) + "OSPF6 area ID in IPv4 address notation\n") { struct ospf6 *o; struct ospf6_interface *oi; @@ -450,8 +476,7 @@ /* XXX */ /* LSAs */ - vty_out (vty, " Number of AS scoped LSAs is %u%s", - o->lsdb->count, VNL); + vty_out (vty, " Number of AS scoped LSAs is %u%s", o->lsdb->count, VNL); /* Areas */ vty_out (vty, " Number of areas in this router is %u%s", @@ -463,11 +488,7 @@ /* show top level structures */ DEFUN (show_ipv6_ospf6, - show_ipv6_ospf6_cmd, - "show ipv6 ospf6", - SHOW_STR - IP6_STR - OSPF6_STR) + show_ipv6_ospf6_cmd, "show ipv6 ospf6", SHOW_STR IP6_STR OSPF6_STR) { OSPF6_CMD_CHECK_RUNNING (); @@ -477,12 +498,7 @@ DEFUN (show_ipv6_ospf6_route, show_ipv6_ospf6_route_cmd, - "show ipv6 ospf6 route", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - ) + "show ipv6 ospf6 route", SHOW_STR IP6_STR OSPF6_STR ROUTE_STR) { ospf6_route_table_show (vty, argc, argv, ospf6->route_table); return CMD_SUCCESS; @@ -497,9 +513,7 @@ ROUTE_STR "Specify IPv6 address\n" "Specify IPv6 prefix\n" - "Detailed information\n" - "Summary of route table\n" - ); + "Detailed information\n" "Summary of route table\n"); DEFUN (show_ipv6_ospf6_route_match, show_ipv6_ospf6_route_match_cmd, @@ -509,8 +523,7 @@ OSPF6_STR ROUTE_STR "Specify IPv6 prefix\n" - "Display routes which match the specified route\n" - ) + "Display routes which match the specified route\n") { const char *sargv[CMD_ARGC_MAX]; int i, sargc; @@ -535,8 +548,7 @@ ROUTE_STR "Specify IPv6 prefix\n" "Display routes which match the specified route\n" - "Detailed information\n" - ) + "Detailed information\n") { const char *sargv[CMD_ARGC_MAX]; int i, sargc; @@ -561,8 +573,7 @@ OSPF6_STR ROUTE_STR "Specify IPv6 prefix\n" - "Display routes longer than the specified route\n" - ); + "Display routes longer than the specified route\n"); DEFUN (show_ipv6_ospf6_route_match_detail, show_ipv6_ospf6_route_longer_detail_cmd, @@ -573,8 +584,7 @@ ROUTE_STR "Specify IPv6 prefix\n" "Display routes longer than the specified route\n" - "Detailed information\n" - ); + "Detailed information\n"); ALIAS (show_ipv6_ospf6_route, show_ipv6_ospf6_route_type_cmd, @@ -585,9 +595,7 @@ ROUTE_STR "Dispaly Intra-Area routes\n" "Dispaly Inter-Area routes\n" - "Dispaly Type-1 External routes\n" - "Dispaly Type-2 External routes\n" - ); + "Dispaly Type-1 External routes\n" "Dispaly Type-2 External routes\n"); DEFUN (show_ipv6_ospf6_route_type_detail, show_ipv6_ospf6_route_type_detail_cmd, @@ -599,9 +607,7 @@ "Dispaly Intra-Area routes\n" "Dispaly Inter-Area routes\n" "Dispaly Type-1 External routes\n" - "Dispaly Type-2 External routes\n" - "Detailed information\n" - ) + "Dispaly Type-2 External routes\n" "Detailed information\n") { const char *sargv[CMD_ARGC_MAX]; int i, sargc; @@ -632,7 +638,8 @@ if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) return CMD_SUCCESS; - inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id)); + inet_ntop (AF_INET, &ospf6->router_id_static, router_id, + sizeof (router_id)); vty_out (vty, "router ospf6%s", VNL); if (ospf6->router_id_static != 0) vty_out (vty, " router-id %s%s", router_id, VNL); @@ -651,8 +658,7 @@ } /* OSPF6 node structure. */ -struct cmd_node ospf6_node = -{ +struct cmd_node ospf6_node = { OSPF6_NODE, "%s(config-ospf6)# ", 1 /* VTYSH */ @@ -691,6 +697,170 @@ install_element (OSPF6_NODE, &ospf6_interface_area_cmd); install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd); install_element (OSPF6_NODE, &no_router_ospf6_cmd); + install_element (OSPF6_NODE, &ospf6_router_minlsinterval_cmd); + install_element (OSPF6_NODE, &ospf6_router_minlsarrival_cmd); + } + + +void +ospf6_af_check_range () +{ + struct ospf6_area *oa; + struct ospf6_interface *oi; + struct listnode *i, *j; + int r = -1, range; + + if (!ospf6) + return; + + for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa)) + { + for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) + { + if (oi->instance_id == 0 + || (oi->instance_id >= 1 && oi->instance_id <= 31)) + range = OSPF6_AF_IPV6_UNICAST; + else if (oi->instance_id >= 32 && oi->instance_id <= 63) + range = OSPF6_AF_IPV6_MULTICAST; + else if (oi->instance_id >= 64 && oi->instance_id <= 95) + range = OSPF6_AF_IPV4_UNICAST; + else if (oi->instance_id >= 96 && oi->instance_id <= 127) + range = OSPF6_AF_IPV4_MULTICAST; + else + range = OSPF6_AF_UNASSIGNED; + + if (r == -1) + r = range; + else if (r != range) + { + zlog_warn + ("%s: Error: interfaces have differing instance ID ranges %d and %d", + __func__, r, range); + return; + } + + if (r == OSPF6_AF_UNASSIGNED) + { + zlog_warn ("%s: Error: instance_id %d is reserved", __func__, + oi->instance_id); + return; + } + } + } +} + +int +ospf6_af_get_range (struct ospf6_interface *oi) +{ + int range; + struct listnode *node; + + ospf6_af_check_range (); + + if (!oi) + { + struct ospf6_area *oa = NULL; + if (!ospf6 || ospf6->area_list->count == 0) + { + zlog_warn ("%s: Could not obtain address family range", __func__); + return OSPF6_AF_FAILED; + } + ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa); //get first element + if (!oa || oa->if_list->count == 0) + { + zlog_warn ("%s: Could not obtain address family range", __func__); + return OSPF6_AF_FAILED; + } + ALL_LIST_ELEMENTS_RO (oa->if_list, node, oi); //get first element + } + + if (oi->instance_id == 0 || (oi->instance_id >= 1 && oi->instance_id <= 31)) + range = OSPF6_AF_IPV6_UNICAST; + else if (oi->instance_id >= 32 && oi->instance_id <= 63) + range = OSPF6_AF_IPV6_MULTICAST; + else if (oi->instance_id >= 64 && oi->instance_id <= 95) + range = OSPF6_AF_IPV4_UNICAST; + else if (oi->instance_id >= 96 && oi->instance_id <= 127) + range = OSPF6_AF_IPV4_MULTICAST; + else + range = OSPF6_AF_UNASSIGNED; + return range; +} + +boolean +is_af_ipv4_unicast (struct ospf6_interface * oi) +{ + int range = ospf6_af_get_range (oi); + if (range == OSPF6_AF_IPV4_UNICAST) + return true; + return false; +} + +boolean +is_af_ipv4_multicast (struct ospf6_interface * oi) +{ + int range = ospf6_af_get_range (oi); + if (range == OSPF6_AF_IPV4_MULTICAST) + return true; + return false; +} + +boolean +is_af_ipv6_unicast (struct ospf6_interface * oi) +{ + int range = ospf6_af_get_range (oi); + if (range == OSPF6_AF_IPV6_UNICAST) + return true; + return false; +} + +boolean +is_af_ipv6_multicast (struct ospf6_interface * oi) +{ + int range = ospf6_af_get_range (oi); + if (range == OSPF6_AF_IPV6_MULTICAST) + return true; + return false; +} + +/* convert an IPv6 prefix to IPv4 */ +int +af_ipv6_to_ipv4 (struct prefix_ipv4 *p4, struct prefix_ipv6 *p6) +{ + memset (p4, 0, sizeof (*p4)); + + /* the prefix length must be at least 96 bits and the prefix must be + IPv4 compatible */ + if (p6->prefixlen < 96 || !IN6_IS_ADDR_V4COMPAT (&(p6->prefix))) + { + char buf[64]; + + prefix2str ((struct prefix *) p6, buf, sizeof (buf)); + zlog_warn ("%s: invalid ipv4 af address: %s", __func__, buf); + return -1; + } + + p4->family = AF_INET; + p4->prefixlen = 32 - (128 - p6->prefixlen); + p4->prefix.s_addr = IN6_ADDR_V4COMPAT (&(p6->prefix)); + + return 0; +} + +/* convert an IPv4 prefix to IPv6 */ +int +af_ipv4_to_ipv6 (struct prefix_ipv6 *p6, struct prefix_ipv4 *p4) +{ + memset (p6, 0, sizeof (*p6)); + + p6->family = AF_INET6; + p6->prefixlen = 128 - (32 - p4->prefixlen); + + IN6_ADDR_V4COMPAT (&(p6->prefix)) = p4->prefix.s_addr; + + return 0; +} + diff -Naur quagga-0.99.9/ospf6d/ospf6_top.h quagga-0.99.9-af/ospf6d/ospf6_top.h --- quagga-0.99.9/ospf6d/ospf6_top.h 2004-10-11 16:00:06.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_top.h 2008-12-03 13:42:15.000000000 -0800 @@ -23,6 +23,9 @@ #define OSPF6_TOP_H #include "routemap.h" +#include "ospf6d.h" //for boolean + + /* OSPFv3 top level data structure */ struct ospf6 @@ -60,6 +63,9 @@ u_char flag; struct thread *maxage_remover; + int minLSInterval; + int minLSArrival; + }; #define OSPF6_DISABLED 0x01 @@ -72,6 +78,34 @@ void ospf6_maxage_remove (struct ospf6 *o); -#endif /* OSPF6_TOP_H */ + +struct ospf6_neighbor; +struct ospf6_lsa; +struct ospf6_interface; + + + +int ospf6_af_get_range (struct ospf6_interface *oi); +void ospf6_af_check_range (); +boolean is_af_ipv4_unicast (struct ospf6_interface *oi); +boolean is_af_ipv4_multicast (struct ospf6_interface *oi); +boolean is_af_ipv6_unicast (struct ospf6_interface *oi); +boolean is_af_ipv6_multicast (struct ospf6_interface *oi); + +#define OSPF6_AF_FAILED 0 +#define OSPF6_AF_IPV6_UNICAST 1 +#define OSPF6_AF_IPV6_MULTICAST 2 +#define OSPF6_AF_IPV4_UNICAST 3 +#define OSPF6_AF_IPV4_MULTICAST 4 +#define OSPF6_AF_UNASSIGNED 5 + +int af_ipv6_to_ipv4 (struct prefix_ipv4 *p4, struct prefix_ipv6 *p6); +int af_ipv4_to_ipv6 (struct prefix_ipv6 *p6, struct prefix_ipv4 *p4); + +#define IN6_ADDR_V4COMPAT(addr6) ((uint32_t *)((addr6)->s6_addr))[3] + + + +#endif /* OSPF6_TOP_H */ diff -Naur quagga-0.99.9/ospf6d/ospf6_zebra.c quagga-0.99.9-af/ospf6d/ospf6_zebra.c --- quagga-0.99.9/ospf6d/ospf6_zebra.c 2005-10-03 07:20:32.000000000 -0700 +++ quagga-0.99.9-af/ospf6d/ospf6_zebra.c 2008-12-03 13:42:15.000000000 -0800 @@ -39,6 +39,9 @@ #include "ospf6_zebra.h" #include "ospf6d.h" +#include "ospf6_neighbor.h" + + unsigned char conf_debug_ospf6_zebra = 0; /* information about zebra. */ @@ -110,7 +113,8 @@ return 0; if (if_is_up (ifp)) - zlog_warn ("Zebra: got delete of %s, but interface is still up", ifp->name); + zlog_warn ("Zebra: got delete of %s, but interface is still up", + ifp->name); if (IS_OSPF6_DEBUG_ZEBRA (RECV)) zlog_debug ("Zebra Interface delete: %s index %d mtu %d", @@ -148,7 +152,8 @@ struct connected *c; char buf[128]; - c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, zclient->ibuf); + c = + zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, zclient->ibuf); if (c == NULL) return 0; @@ -158,9 +163,11 @@ inet_ntop (c->address->family, &c->address->u.prefix, buf, sizeof (buf)), c->address->prefixlen); - if (c->address->family == AF_INET6) + if (c->address->family == AF_INET6 || c->address->family == AF_INET) + //enable updating of IPv4 addresses when using AF ospf6_interface_connected_route_update (c->ifp); + return 0; } @@ -171,7 +178,9 @@ struct connected *c; char buf[128]; - c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, zclient->ibuf); + c = + zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, + zclient->ibuf); if (c == NULL) return 0; @@ -181,13 +190,123 @@ inet_ntop (c->address->family, &c->address->u.prefix, buf, sizeof (buf)), c->address->prefixlen); - if (c->address->family == AF_INET6) + if (c->address->family == AF_INET6 || c->address->family == AF_INET) + //enable updating of IPv4 addresses when using AF ospf6_interface_connected_route_update (c->ifp); return 0; } int +ospf6_zebra_read_ipv4 (int command, struct zclient *zclient, + zebra_size_t length) +{ + int i; + struct stream *s; + struct zapi_ipv6 api; + unsigned long ifindex; + struct prefix_ipv6 p; + struct in6_addr *nexthop; + + struct zapi_ipv4 api_ipv4; + struct in_addr nexthop_ipv4; + struct prefix_ipv4 p_ipv4; + + if (!is_af_ipv4_unicast (NULL) && !is_af_ipv4_multicast (NULL)) + return 0; + + s = zclient->ibuf; + ifindex = 0; + nexthop = NULL; + memset (&api_ipv4, 0, sizeof (api_ipv4)); + + /* Type, flags, message. */ + api_ipv4.type = stream_getc (s); + api_ipv4.flags = stream_getc (s); + api_ipv4.message = stream_getc (s); + + /* IPv4 prefix. */ + memset (&p_ipv4, 0, sizeof (struct prefix_ipv4)); + p_ipv4.family = AF_INET; + p_ipv4.prefixlen = stream_getc (s); + stream_get (&p_ipv4.prefix, s, PSIZE (p_ipv4.prefixlen)); + + if (IPV4_NET127 (ntohl (p_ipv4.prefix.s_addr))) + return 0; + + /* Nexthop, ifindex, distance, metric. */ + if (CHECK_FLAG (api_ipv4.message, ZAPI_MESSAGE_NEXTHOP)) + { + api_ipv4.nexthop_num = stream_getc (s); + nexthop_ipv4.s_addr = stream_get_ipv4 (s); + } + if (CHECK_FLAG (api_ipv4.message, ZAPI_MESSAGE_IFINDEX)) + { + api_ipv4.ifindex_num = stream_getc (s); + ifindex = stream_getl (s); + } + if (CHECK_FLAG (api_ipv4.message, ZAPI_MESSAGE_DISTANCE)) + api_ipv4.distance = stream_getc (s); + if (CHECK_FLAG (api_ipv4.message, ZAPI_MESSAGE_METRIC)) + api_ipv4.metric = stream_getl (s); + + //Convert to IPv6 + /* IPv6 prefix. */ + if (af_ipv4_to_ipv6 (&p, &p_ipv4)) + { + /* something's wrong so just give up */ + return -1; + } + + api.type = api_ipv4.type; + api.flags = api_ipv4.flags; + api.message = api_ipv4.message; + api.nexthop_num = api_ipv4.nexthop_num; + api.ifindex_num = api_ipv4.ifindex_num; + api.ifindex = api_ipv4.ifindex; + api.distance = api_ipv4.distance; + api.metric = api_ipv4.metric; + + if (api.nexthop_num > 0) + { + nexthop = (struct in6_addr *) + malloc (api.nexthop_num * sizeof (struct in6_addr)); + memset (nexthop, 0, api.nexthop_num * sizeof (struct in6_addr)); + } + + for (i = 0; i < api.nexthop_num; i++) + { + IN6_ADDR_V4COMPAT (&nexthop[i]) = nexthop_ipv4.s_addr; + } + + if (IS_OSPF6_DEBUG_ZEBRA (RECV)) + { + char prefixstr[128], nexthopstr[128]; + prefix2str ((struct prefix *) &p, prefixstr, sizeof (prefixstr)); + if (nexthop) + inet_ntop (AF_INET6, nexthop, nexthopstr, sizeof (nexthopstr)); + else + snprintf (nexthopstr, sizeof (nexthopstr), "::"); + + zlog_debug ("Zebra Receive route %s: %s %s nexthop %s ifindex %ld", + (command == ZEBRA_IPV4_ROUTE_ADD ? "add" : "delete"), + zebra_route_string (api.type), prefixstr, nexthopstr, + ifindex); + } + + if (command == ZEBRA_IPV4_ROUTE_ADD) + ospf6_asbr_redistribute_add (api.type, ifindex, (struct prefix *) &p, + api.nexthop_num, nexthop, api.metric); + else + ospf6_asbr_redistribute_remove (api.type, ifindex, (struct prefix *) &p); + + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) + free (nexthop); + + return 0; +} + +int ospf6_zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length) { @@ -197,6 +316,9 @@ struct prefix_ipv6 p; struct in6_addr *nexthop; + if (!is_af_ipv6_unicast (NULL) && !is_af_ipv6_multicast (NULL)) + return 0; + s = zclient->ibuf; ifindex = 0; nexthop = NULL; @@ -246,12 +368,13 @@ zlog_debug ("Zebra Receive route %s: %s %s nexthop %s ifindex %ld", (command == ZEBRA_IPV6_ROUTE_ADD ? "add" : "delete"), - zebra_route_string(api.type), prefixstr, nexthopstr, ifindex); + zebra_route_string (api.type), prefixstr, nexthopstr, + ifindex); } if (command == ZEBRA_IPV6_ROUTE_ADD) ospf6_asbr_redistribute_add (api.type, ifindex, (struct prefix *) &p, - api.nexthop_num, nexthop); + api.nexthop_num, nexthop, api.metric); else ospf6_asbr_redistribute_remove (api.type, ifindex, (struct prefix *) &p); @@ -265,10 +388,7 @@ DEFUN (show_zebra, - show_zebra_cmd, - "show zebra", - SHOW_STR - "Zebra information\n") + show_zebra_cmd, "show zebra", SHOW_STR "Zebra information\n") { int i; if (zclient == NULL) @@ -280,8 +400,7 @@ vty_out (vty, "Zebra Infomation%s", VNL); vty_out (vty, " enable: %d fail: %d%s", zclient->enable, zclient->fail, VNL); - vty_out (vty, " redistribute default: %d%s", zclient->redist_default, - VNL); + vty_out (vty, " redistribute default: %d%s", zclient->redist_default, VNL); vty_out (vty, " redistribute:"); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { @@ -295,8 +414,7 @@ DEFUN (router_zebra, router_zebra_cmd, "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") + "Enable a routing process\n" "Make connection to zebra daemon\n") { vty->node = ZEBRA_NODE; zclient->enable = 1; @@ -308,8 +426,7 @@ no_router_zebra_cmd, "no router zebra", NO_STR - "Configure routing process\n" - "Disable connection to zebra daemon\n") + "Configure routing process\n" "Disable connection to zebra daemon\n") { zclient->enable = 0; zclient_stop (zclient); @@ -335,8 +452,7 @@ } /* Zebra node structure. */ -struct cmd_node zebra_node = -{ +struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-zebra)# ", }; @@ -353,12 +469,15 @@ unsigned int *ifindexes; int i, ret = 0; struct prefix_ipv6 *dest; + struct prefix_ipv4 dest_ipv4; + struct zapi_ipv4 api_ipv4; + struct in_addr **nexthops_ipv4; + int ifcount = 0; if (IS_OSPF6_DEBUG_ZEBRA (SEND)) { prefix2str (&request->prefix, buf, sizeof (buf)); - zlog_debug ("Send %s route: %s", - (type == REM ? "remove" : "add"), buf); + zlog_debug ("Send %s route: %s", (type == REM ? "remove" : "add"), buf); } if (zclient->sock < 0) @@ -400,7 +519,11 @@ nhcount = 0; for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++) if (ospf6_nexthop_is_set (&request->nexthop[i])) + { nhcount++; + if (request->nexthop[i].directly_connected) + ifcount++; + } if (nhcount == 0) { @@ -409,6 +532,107 @@ return; } + if (is_af_ipv4_unicast (NULL)) //IPv4 + { + char nh[BUFSIZ]; + char dst[BUFSIZ]; + int j = 0, k = 0; + + nhcount = nhcount - ifcount; + + /* allocate memory for nexthop_list */ + if (nhcount) + { + nexthops_ipv4 = XCALLOC (MTYPE_OSPF6_OTHER, + nhcount * sizeof (struct in4_addr *)); + if (nexthops_ipv4 == NULL) + { + zlog_warn ("Can't send route to zebra: malloc failed"); + return; + } + } + + /* allocate memory for ifindex_list */ + if (ifcount) + { + ifindexes = XCALLOC (MTYPE_OSPF6_OTHER, + nhcount * sizeof (unsigned int)); + if (ifindexes == NULL) + { + zlog_warn ("Can't send route to zebra: malloc failed"); + if (nhcount) + XFREE (MTYPE_OSPF6_OTHER, nexthops_ipv4); + return; + } + } + + api_ipv4.type = ZEBRA_ROUTE_OSPF6; + api_ipv4.flags = 0; + api_ipv4.message = 0; + SET_FLAG (api_ipv4.message, ZAPI_MESSAGE_NEXTHOP); + + api_ipv4.nexthop_num = nhcount; + api_ipv4.nexthop = nexthops_ipv4; + api_ipv4.ifindex_num = ifcount; + + SET_FLAG (api_ipv4.message, ZAPI_MESSAGE_DISTANCE); + api_ipv4.distance = 0; + SET_FLAG (api_ipv4.message, ZAPI_MESSAGE_METRIC); + api_ipv4.metric = (request->path.metric_type == 2 ? + request->path.cost_e2 : request->path.cost); + + for (i = 0; i < nhcount + ifcount; i++) + { + if (request->nexthop[i].directly_connected) + { + //since the path is directly connected just use the interface as + //the nexthop + ifindexes[j++] = request->nexthop[i].ifindex; + SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); + api_ipv4.ifindex = ifindexes; + } + else + { + //nexthop is not directly connected + nexthops_ipv4[k++] = (struct in_addr *) &IN6_ADDR_V4COMPAT (&request->nexthop[i].address); + api_ipv4.nexthop = nexthops_ipv4; + } + } + + //convert IPv6 dest to IPv4 + if (af_ipv6_to_ipv4 + (&dest_ipv4, (struct prefix_ipv6 *) &request->prefix)) + { + /* something's wrong so just give up */ + if (nhcount) + XFREE (MTYPE_OSPF6_OTHER, nexthops_ipv4); + if (ifcount) + XFREE (MTYPE_OSPF6_OTHER, ifindexes); + return; + } + + if (CHECK_FLAG (api_ipv4.message, ZAPI_MESSAGE_DISTANCE)) + api_ipv4.distance = 0; + if (CHECK_FLAG (api_ipv4.message, ZAPI_MESSAGE_METRIC)) + { + api_ipv4.metric = (request->path.metric_type == 2 ? + request->path.cost_e2 : request->path.cost); + } + + if (type == REM) + ret = zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, + &dest_ipv4, &api_ipv4); + else + ret = zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient, + &dest_ipv4, &api_ipv4); + + if (nhcount) + XFREE (MTYPE_OSPF6_OTHER, nexthops_ipv4); + if (ifcount) + XFREE (MTYPE_OSPF6_OTHER, ifindexes); + } + else + { /* allocate memory for nexthop_list */ nexthops = XCALLOC (MTYPE_OSPF6_OTHER, nhcount * sizeof (struct in6_addr *)); @@ -463,12 +687,9 @@ else ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, &api); - if (ret < 0) - zlog_err ("zapi_ipv6_route() %s failed: %s", - (type == REM ? "delete" : "add"), safe_strerror (errno)); - XFREE (MTYPE_OSPF6_OTHER, nexthops); XFREE (MTYPE_OSPF6_OTHER, ifindexes); + } return; } @@ -499,9 +720,7 @@ DEFUN (redistribute_ospf6, redistribute_ospf6_cmd, - "redistribute ospf6", - "Redistribute control\n" - "OSPF6 route\n") + "redistribute ospf6", "Redistribute control\n" "OSPF6 route\n") { struct ospf6_route *route; @@ -527,9 +746,7 @@ DEFUN (no_redistribute_ospf6, no_redistribute_ospf6_cmd, "no redistribute ospf6", - NO_STR - "Redistribute control\n" - "OSPF6 route\n") + NO_STR "Redistribute control\n" "OSPF6 route\n") { struct ospf6_route *route; @@ -565,8 +782,8 @@ zclient->interface_down = ospf6_zebra_if_state_update; zclient->interface_address_add = ospf6_zebra_if_address_update_add; zclient->interface_address_delete = ospf6_zebra_if_address_update_delete; - zclient->ipv4_route_add = NULL; - zclient->ipv4_route_delete = NULL; + zclient->ipv4_route_add = ospf6_zebra_read_ipv4; + zclient->ipv4_route_delete = ospf6_zebra_read_ipv4; zclient->ipv6_route_add = ospf6_zebra_read_ipv6; zclient->ipv6_route_delete = ospf6_zebra_read_ipv6; @@ -597,9 +814,7 @@ DEBUG_STR OSPF6_STR "Debug connection between zebra\n" - "Debug Sending zebra\n" - "Debug Receiving zebra\n" - ) + "Debug Sending zebra\n" "Debug Receiving zebra\n") { unsigned char level = 0; @@ -620,10 +835,7 @@ ALIAS (debug_ospf6_zebra_sendrecv, debug_ospf6_zebra_cmd, "debug ospf6 zebra", - DEBUG_STR - OSPF6_STR - "Debug connection between zebra\n" - ); + DEBUG_STR OSPF6_STR "Debug connection between zebra\n"); DEFUN (no_debug_ospf6_zebra_sendrecv, @@ -633,9 +845,7 @@ DEBUG_STR OSPF6_STR "Debug connection between zebra\n" - "Debug Sending zebra\n" - "Debug Receiving zebra\n" - ) + "Debug Sending zebra\n" "Debug Receiving zebra\n") { unsigned char level = 0; @@ -656,11 +866,7 @@ ALIAS (no_debug_ospf6_zebra_sendrecv, no_debug_ospf6_zebra_cmd, "no debug ospf6 zebra", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug connection between zebra\n" - ); + NO_STR DEBUG_STR OSPF6_STR "Debug connection between zebra\n"); int config_write_ospf6_debug_zebra (struct vty *vty) @@ -688,6 +894,6 @@ install_element (CONFIG_NODE, &no_debug_ospf6_zebra_cmd); install_element (CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd); -} +} diff -Naur quagga-0.99.9/ospf6d/README.AddressFamilies quagga-0.99.9-af/ospf6d/README.AddressFamilies --- quagga-0.99.9/ospf6d/README.AddressFamilies 1969-12-31 16:00:00.000000000 -0800 +++ quagga-0.99.9-af/ospf6d/README.AddressFamilies 2008-12-03 13:42:15.000000000 -0800 @@ -0,0 +1,73 @@ +The folowoing text describes the implementation of a mechanism for supporting +multiple address families in OSPFv3 using multiple instances. It +maps an address family (AF) to an OSPFv3 instance using the Instance ID +field in the OSPFv3 packet header. This approach is fairly simple +and minimizes extensions to OSPFv3 for supporting multiple AFs. + +IETF DRAFT VERSION SUPPORTED +Support of Address Families (AF) in OSPFv3 is supported according to +draft-ietf-ospf-af-alt-05.txt. + + +HOW TO ENABLE ADDRESS FAMILIES +Address families is enabled by compiling the flag OSPF6_AF into the source code. +By default this flag is compiled into the code. It must be removed from +configure.ac and config.h.in. + + +HOW TO CONFIGURE ADDRESS FAMILIES +Address Families can be configured in one of two ways. + +1. Add the following lines to the ospf6d.conf file + interface + ipv6 ospf6 instance-id <0-255> + +2. From the vtysh or telnet terminal type: + > conf t + > interface + > ipv6 ospf6 instance-id <0-255> + > exit + > exit + +The value of the instance ID should one of the four ranges below. The most +comman ranges are 0 to 31 for unicast IPv6 routing (standard OSPFv3) and +64 to 95 for IPv4 unicast routing. + Instance ID # 0 - # 31 IPv6 unicast AF + Instance ID # 32 - # 63 IPv6 multicast AF + Instance ID # 64 - # 95 IPv4 unicast AF + Instance ID # 96 - # 127 IPv4 multicast AF + Instance ID # 128 - # 255 Unassigned + +NOTE: The instance-id must be the same on all interfaces. Different Address +Families cannot be used within the same ospf6d process. The router will +fail if different ranges are used. + + +HOW TO VERIFY ROUTING IS WORKING +From a vtysh or telnet terminal type: + +> show ipv6 ospf6 route + +This should display the OSPFv3 routes. If IPv4 AFs are used then the +route will appear as an IPv6 route with zeros before the IPv4 route. +Next, type the following command for IPv4 or IPv6 + +> show ip route +> show ipv6 route + +The entries with the "*" are going to be installed in the kernel routing +table. If these tables are correct then the kernel routing table +should be correct. + + +SOURCE CODE INFORMATION +All modified code is found in the directories lib/, zebra/, and ospf6/. +Each modification is flagged with the tag "OSPF6_AF". + + +POSSIBLE FUTURE WORK +Enable different AFs to run in the same ospf6d instance. This would require +a IETF draft changes and a sepeartion of LSAs within the database. + +Known Issues +-If instance IDs are not consistent on the interfaces then routing will fail. diff -Naur quagga-0.99.9/ospfd/ospf_asbr.c quagga-0.99.9-af/ospfd/ospf_asbr.c --- quagga-0.99.9/ospfd/ospf_asbr.c 2006-05-12 16:00:31.000000000 -0700 +++ quagga-0.99.9-af/ospfd/ospf_asbr.c 2008-12-03 13:42:15.000000000 -0800 @@ -136,7 +136,7 @@ /* Add an External info for AS-external-LSA. */ struct external_info * ospf_external_info_add (u_char type, struct prefix_ipv4 p, - unsigned int ifindex, struct in_addr nexthop) + unsigned int ifindex, struct in_addr nexthop, unsigned int metric) { struct external_info *new; struct route_node *rn; @@ -164,6 +164,7 @@ new->ifindex = ifindex; new->nexthop = nexthop; new->tag = 0; + new->metric = metric; rn->info = new; diff -Naur quagga-0.99.9/ospfd/ospf_asbr.h quagga-0.99.9-af/ospfd/ospf_asbr.h --- quagga-0.99.9/ospfd/ospf_asbr.h 2006-05-12 16:00:31.000000000 -0700 +++ quagga-0.99.9-af/ospfd/ospf_asbr.h 2008-12-03 13:42:15.000000000 -0800 @@ -44,6 +44,9 @@ /* Nexthop address. */ struct in_addr nexthop; + /* Route metric */ + unsigned int metric; + /* Additional Route tag. */ u_int32_t tag; @@ -59,10 +62,11 @@ extern void ospf_reset_route_map_set_values (struct route_map_set_values *); extern int ospf_route_map_set_compare (struct route_map_set_values *, struct route_map_set_values *); -extern struct external_info *ospf_external_info_add (u_char, - struct prefix_ipv4, - unsigned int, - struct in_addr); +extern struct external_info * ospf_external_info_add (u_char type, + struct prefix_ipv4 p, + unsigned int ifindex, + struct in_addr nexthop, + unsigned int metric); extern void ospf_external_info_delete (u_char, struct prefix_ipv4); extern struct external_info *ospf_external_info_lookup (u_char, struct prefix_ipv4 *); diff -Naur quagga-0.99.9/ospfd/ospf_lsa.c quagga-0.99.9-af/ospfd/ospf_lsa.c --- quagga-0.99.9/ospfd/ospf_lsa.c 2007-08-06 10:10:36.000000000 -0700 +++ quagga-0.99.9-af/ospfd/ospf_lsa.c 2008-12-03 13:42:15.000000000 -0800 @@ -1677,8 +1677,22 @@ mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ? ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type); - mvalue = (ROUTEMAP_METRIC (ei) != -1) ? - ROUTEMAP_METRIC (ei) : metric_value (ospf, type); + if (mtype == EXTERNAL_METRIC_TYPE_2) + { + if (ROUTEMAP_METRIC (ei) != -1) + mvalue = ROUTEMAP_METRIC (ei); + else + mvalue = metric_value(ospf,type); + } + else + { + if (ROUTEMAP_METRIC (ei) != -1) + mvalue = ROUTEMAP_METRIC (ei); + else if (ospf->dmetric[type].value >= 0) + mvalue = ospf->dmetric[type].value; + else + mvalue = ei->metric; + } /* Put type of external metric. */ stream_putc (s, (mtype == EXTERNAL_METRIC_TYPE_2 ? 0x80 : 0)); @@ -2246,7 +2260,7 @@ /* If there is no default route via redistribute, then originate AS-external-LSA with nexthop 0 (self). */ nexthop.s_addr = 0; - ospf_external_info_add (DEFAULT_ROUTE, p, 0, nexthop); + ospf_external_info_add (DEFAULT_ROUTE, p, 0, nexthop, 0); } if ((ei = ospf_default_external_info (ospf))) diff -Naur quagga-0.99.9/ospfd/ospf_vty.c quagga-0.99.9-af/ospfd/ospf_vty.c --- quagga-0.99.9/ospfd/ospf_vty.c 2007-05-09 19:48:32.000000000 -0700 +++ quagga-0.99.9-af/ospfd/ospf_vty.c 2008-12-03 13:42:15.000000000 -0800 @@ -109,6 +109,10 @@ *source = ZEBRA_ROUTE_RIP; else if (strncmp (str, "b", 1) == 0) *source = ZEBRA_ROUTE_BGP; + else if (strncmp (str, "ospf6", 5) == 0) + *source = ZEBRA_ROUTE_OSPF6; + else if (strncmp (str, "ospf", 4) == 0) + *source = ZEBRA_ROUTE_OSPF; else return 0; diff -Naur quagga-0.99.9/ospfd/ospf_zebra.c quagga-0.99.9-af/ospfd/ospf_zebra.c --- quagga-0.99.9/ospfd/ospf_zebra.c 2007-03-15 12:14:13.000000000 -0700 +++ quagga-0.99.9-af/ospfd/ospf_zebra.c 2008-12-03 13:42:15.000000000 -0800 @@ -853,7 +853,7 @@ * return 0; */ - ei = ospf_external_info_add (api.type, p, ifindex, nexthop); + ei = ospf_external_info_add (api.type, p, ifindex, nexthop, api.metric); if (ospf->router_id.s_addr == 0) /* Set flags to generate AS-external-LSA originate event diff -Naur quagga-0.99.9/redhat/quagga.spec quagga-0.99.9-af/redhat/quagga.spec --- quagga-0.99.9/redhat/quagga.spec 2007-09-07 09:56:18.000000000 -0700 +++ quagga-0.99.9-af/redhat/quagga.spec 1969-12-31 16:00:00.000000000 -0800 @@ -1,595 +0,0 @@ -# configure options -# -# Some can be overriden on rpmbuild commandline with: -# rpmbuild --define 'variable value' -# - -####################### Quagga configure options ######################### -# with-feature options -%{!?with_snmp: %define with_snmp 1 } -%{!?with_vtysh: %define with_vtysh 1 } -%{!?with_ospf_te: %define with_ospf_te 1 } -%{!?with_nssa: %define with_nssa 1 } -%{!?with_opaque_lsa: %define with_opaque_lsa 1 } -%{!?with_tcp_zebra: %define with_tcp_zebra 0 } -%{!?with_vtysh: %define with_vtysh 1 } -%{!?with_pam: %define with_pam 1 } -%{!?with_ipv6: %define with_ipv6 1 } -%{!?with_ospfclient: %define with_ospfclient 1 } -%{!?with_ospfapi: %define with_ospfapi 1 } -%{!?with_irdp: %define with_irdp 1 } -%{!?with_rtadv: %define with_rtadv 1 } -%{!?with_isisd: %define with_isisd 1 } -%{!?with_shared: %define with_shared 1 } -%{!?with_multipath: %define with_multipath 64 } -%{!?quagga_user: %define quagga_user quagga } -%{!?vty_group: %define vty_group quaggavty } - -# path defines -%define _sysconfdir /etc/quagga -%define zeb_src %{_builddir}/%{name}-%{version} -%define zeb_rh_src %{zeb_src}/redhat -%define zeb_docs %{zeb_src}/doc - -# defines for configure -%define _libexecdir %{_exec_prefix}/libexec/quagga -%define _libdir %{_exec_prefix}/%{_lib}/quagga -%define _includedir %{_prefix}/include -%define _localstatedir /var/run/quagga -############################################################################ - -####################### distro specific tweaks ############################# -# default distro. Override with rpmbuild -D "dist XXX" -%{expand: %%define default_dist %(rpm -q --qf 'fc%%{VERSION}' fedora-release | grep -v 'not installed')} -%{!?dist: %define dist %{default_dist}} - -# as distros change packages we depend on, our Requires have to change, sadly. -%define quagga_buildreqs texinfo tetex autoconf pam-devel -%define quagga_buildreqs %{quagga_buildreqs} patch libcap-devel - -# FC4 and 5 split texi2html out of tetex package. -%if "%dist" == "fc4" || "%dist" == "fc5" -%define quagga_buildreqs %{quagga_buildreqs} texi2html -%endif - -# pam_stack is deprecated in FC5 -# default to pam_stack, default should be changed later. -%if "%dist" == "fc5" -%define quagga_pam_source quagga.pam -%else -%define quagga_pam_source quagga.pam.stack -%endif -############################################################################ - - -# misc internal defines -%{!?quagga_uid: %define quagga_uid 92 } -%{!?quagga_gid: %define quagga_gid 92 } -%define daemon_list zebra ripd ospfd bgpd - -%if %{with_ipv6} -%define daemonv6_list ripngd ospf6d -%else -%define daemonv6_list "" -%endif - -%if %{with_isisd} -%define daemon_other isisd -%else -%define daemon_other "" -%endif - -%define all_daemons %{daemon_list} %{daemonv6_list} %{daemon_other} watchquagga - -# allow build dir to be kept -%{!?keep_build: %define keep_build 0 } - -#release sub-revision (the two digits after the CONFDATE) -%{!?release_rev: %define release_rev 01 } - -Summary: Routing daemon -Name: quagga -Version: 0.99.9 -Release: 20070907%{release_rev} -License: GPL -Group: System Environment/Daemons -Source0: http://www.quagga.net/snapshots/cvs/%{name}-%{version}.tar.gz -URL: http://www.quagga.net -%if %{with_snmp} -BuildRequires: net-snmp-devel -Prereq: net-snmp -%endif -%if %{with_vtysh} -BuildRequires: readline readline-devel ncurses ncurses-devel -Prereq: ncurses -%endif -BuildRequires: texinfo tetex autoconf pam-devel patch libcap-devel tetex -# Initscripts > 5.60 is required for IPv6 support -Prereq: initscripts >= 5.60 -Prereq: ncurses pam -Prereq: /sbin/install-info -Provides: routingdaemon -BuildRoot: %{_tmppath}/%{name}-%{version}-root -Obsoletes: bird gated mrt zebra - -%description -Quagga is a free software that manages TCP/IP based routing -protocol. It takes multi-server and multi-thread approach to resolve -the current complexity of the Internet. - -Quagga supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1, RIPv2, and RIPng. - -Quagga is intended to be used as a Route Server and a Route Reflector. It is -not a toolkit, it provides full routing power under a new architecture. -Quagga by design has a process for each protocol. - -Quagga is a fork of GNU Zebra. - -%package contrib -Summary: contrib tools for quagga -Group: System Environment/Daemons - -%description contrib -Contributed/3rd party tools which may be of use with quagga. - -%package devel -Summary: Header and object files for quagga development -Group: System Environment/Daemons - -%description devel -The quagga-devel package contains the header and object files neccessary for -developing OSPF-API and quagga applications. - -%prep -%setup -q - -%build - -# For standard gcc verbosity, uncomment these lines: -#CFLAGS="%{optflags} -Wall -Wsign-compare -Wpointer-arith" -#CFLAGS="${CFLAGS} -Wbad-function-cast -Wwrite-strings" - -# For ultra gcc verbosity, uncomment these lines also: -#CFLAGS="${CFLAGS} -W -Wcast-qual -Wstrict-prototypes" -#CFLAGS="${CFLAGS} -Wmissing-declarations -Wmissing-noreturn" -#CFLAGS="${CFLAGS} -Wmissing-format-attribute -Wunreachable-code" -#CFLAGS="${CFLAGS} -Wpacked -Wpadded" - -%configure \ -%if !%{with_shared} - --disable-shared \ -%endif -%if %{with_ipv6} - --enable-ipv6 \ -%endif -%if %{with_snmp} - --enable-snmp \ -%endif -%if %{with_multipath} - --enable-multipath=%{with_multipath} \ -%endif -%if %{with_tcp_zebra} - --enable-tcp-zebra \ -%endif -%if %{with_nssa} - --enable-nssa \ -%endif -%if %{with_opaque_lsa} - --enable-opaque-lsa \ -%endif -%if %{with_ospf_te} - --enable-ospf-te \ -%endif -%if %{with_vtysh} - --enable-vtysh \ -%endif -%if %{with_ospfclient} - --enable-ospfclient=yes \ -%else - --enable-ospfclient=no\ -%endif -%if %{with_ospfapi} - --enable-ospfapi=yes \ -%else - --enable-ospfapi=no \ -%endif -%if %{with_irdp} - --enable-irdp=yes \ -%else - --enable-irdp=no \ -%endif -%if %{with_rtadv} - --enable-rtadv=yes \ -%else - --enable-rtadv=no \ -%endif -%if %{with_isisd} - --enable-isisd \ -%else - --disable-isisd \ -%endif -%if %{with_pam} - --with-libpam \ -%endif -%if %quagga_user - --enable-user=%quagga_user \ - --enable-group=%quagga_user \ -%endif -%if %vty_group - --enable-vty-group=%vty_group \ -%endif ---enable-netlink --enable-gcc-rdynamic - -make %{?_smp_mflags} MAKEINFO="makeinfo --no-split" - -pushd doc -texi2html -number quagga.texi -popd - -%install -rm -rf $RPM_BUILD_ROOT - -install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig,logrotate.d,pam.d} \ - $RPM_BUILD_ROOT/var/log/quagga $RPM_BUILD_ROOT%{_infodir} - -make install \ - DESTDIR=$RPM_BUILD_ROOT - -# Remove this file, as it is uninstalled and causes errors when building on RH9 -rm -rf $RPM_BUILD_ROOT/usr/share/info/dir - -# install etc sources -for daemon in %{all_daemons} ; do - if [ x"${daemon}" != x"" ] ; then - install %{zeb_rh_src}/${daemon}.init \ - $RPM_BUILD_ROOT/etc/rc.d/init.d/${daemon} - fi -done -install -m644 %{zeb_rh_src}/%{quagga_pam_source} \ - $RPM_BUILD_ROOT/etc/pam.d/quagga -install -m644 %{zeb_rh_src}/quagga.logrotate \ - $RPM_BUILD_ROOT/etc/logrotate.d/quagga -install -m644 %{zeb_rh_src}/quagga.sysconfig \ - $RPM_BUILD_ROOT/etc/sysconfig/quagga -install -d -m750 $RPM_BUILD_ROOT/var/run/quagga - -%pre -# add vty_group -%if %vty_group -if getent group %vty_group > /dev/null ; then : ; else \ - /usr/sbin/groupadd -r %vty_group > /dev/null || : ; fi -%endif - -# add quagga user and group -%if %quagga_user -# Ensure that quagga_gid gets correctly allocated -if getent group %quagga_user >/dev/null; then : ; else \ - /usr/sbin/groupadd -g %quagga_gid %quagga_user > /dev/null || : ; \ -fi -if getent passwd %quagga_user >/dev/null ; then : ; else \ - /usr/sbin/useradd -u %quagga_uid -g %quagga_gid \ - -M -r -s /sbin/nologin -c "Quagga routing suite" \ - -d %_localstatedir %quagga_user 2> /dev/null || : ; \ -fi -%endif - -%post -# zebra_spec_add_service -# e.g. zebra_spec_add_service zebrasrv 2600/tcp "zebra service" - -zebra_spec_add_service () -{ - # Add port /etc/services entry if it isn't already there - if [ -f /etc/services ] && \ - ! %__sed -e 's/#.*$//' /etc/services | %__grep -wq $1 ; then - echo "$1 $2 # $3" >> /etc/services - fi -} - -zebra_spec_add_service zebrasrv 2600/tcp "zebra service" -zebra_spec_add_service zebra 2601/tcp "zebra vty" -zebra_spec_add_service ripd 2602/tcp "RIPd vty" -%if %{with_ipv6} -zebra_spec_add_service ripngd 2603/tcp "RIPngd vty" -%endif -zebra_spec_add_service ospfd 2604/tcp "OSPFd vty" -zebra_spec_add_service bgpd 2605/tcp "BGPd vty" -%if %{with_ipv6} -zebra_spec_add_service ospf6d 2606/tcp "OSPF6d vty" -%endif -%if %{with_ospfapi} -zebra_spec_add_service ospfapi 2607/tcp "OSPF-API" -%endif -%if %{with_isisd} -zebra_spec_add_service isisd 2608/tcp "ISISd vty" -%endif - -for daemon in %daemon_list ; do - /sbin/chkconfig --add ${daemon} -done - -/sbin/install-info %{_infodir}/quagga.info.gz %{_infodir}/dir - -# Create dummy files if they don't exist so basic functions can be used. -if [ ! -e %{_sysconfdir}/zebra.conf ]; then - echo "hostname `hostname`" > %{_sysconfdir}/zebra.conf -%if %{quagga_user} - chown %quagga_user:%quagga_user %{_sysconfdir}/zebra.conf -%endif - chmod 640 %{_sysconfdir}/zebra.conf -fi -if [ ! -e %{_sysconfdir}/vtysh.conf ]; then - touch %{_sysconfdir}/vtysh.conf - chmod 640 %{_sysconfdir}/vtysh.conf -fi - -%postun -if [ "$1" -ge 1 ]; then - # Find out which daemons need to be restarted. - for daemon in %all_daemons ; do - if [ -f /var/lock/subsys/$daemon ]; then - eval restart_$daemon=yes - else - eval restart_$daemon=no - fi - done - # Rename restart flags for daemons handled specially. - running_zebra="$restart_zebra" - restart_zebra=no - running_watchquagga="$restart_watchquagga" - restart_watchquagga=no - # Stop watchquagga first. - [ "$running_watchquagga" = yes ] && \ - /etc/rc.d/init.d/watchquagga stop >/dev/null 2>&1 - # Stop all daemons other than zebra and watchquagga. - for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/$daemon stop >/dev/null 2>&1 - done - # Restart zebra. - [ "$running_zebra" = yes ] && \ - /etc/rc.d/init.d/zebra restart >/dev/null 2>&1 - # Start all daemons other than zebra and watchquagga. - for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/$daemon start >/dev/null 2>&1 - done - # Start watchquagga last. - # Avoid postun scriptlet error if watchquagga is not running. - [ "$running_watchquagga" = yes ] && \ - /etc/rc.d/init.d/watchquagga start >/dev/null 2>&1 || : -fi -/sbin/install-info --delete %{_infodir}/quagga.info.gz %{_infodir}/dir - -%preun -if [ "$1" = "0" ]; then - for daemon in %all_daemons ; do - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 - /sbin/chkconfig --del ${daemon} - done - /sbin/install-info --delete %{_infodir}/quagga.info.gz %{_infodir}/dir -fi - -%clean -%if !%{keep_build} -rm -rf $RPM_BUILD_ROOT -%endif - -%files -%defattr(-,root,root) -%doc */*.sample* AUTHORS COPYING -%doc doc/quagga.html -%doc doc/mpls -%doc ChangeLog INSTALL NEWS README REPORTING-BUGS SERVICES TODO -%if %{quagga_user} -%dir %attr(751,%quagga_user,%quagga_user) %{_sysconfdir} -%dir %attr(750,%quagga_user,%quagga_user) /var/log/quagga -%dir %attr(751,%quagga_user,%quagga_user) /var/run/quagga -%else -%dir %attr(750,root,root) %{_sysconfdir} -%dir %attr(750,root,root) /var/log/quagga -%dir %attr(755,root,root) /usr/share/info -%dir %attr(750,root,root) /var/run/quagga -%endif -%if %{vty_group} -%attr(750,%quagga_user,%vty_group) %{_sysconfdir}/vtysh.conf.sample -%endif -%{_infodir}/*info* -%{_mandir}/man*/* -%{_sbindir}/zebra -%{_sbindir}/ospfd -%{_sbindir}/ripd -%{_sbindir}/bgpd -%{_sbindir}/watchquagga -%if %{with_ipv6} -%{_sbindir}/ripngd -%{_sbindir}/ospf6d -%endif -%if %{with_isisd} -%{_sbindir}/isisd -%endif -%dir %attr(755,root,root) %{_libdir} -%if %{with_shared} -%dir %{_libdir} -%{_libdir}/lib*.so -%{_libdir}/lib*.so.* -%endif -%if %{with_vtysh} -%{_bindir}/* -%endif -%config /etc/quagga/[!v]* -%config /etc/rc.d/init.d/* -%config(noreplace) /etc/sysconfig/quagga -%config(noreplace) /etc/pam.d/quagga -%config(noreplace) %attr(640,root,root) /etc/logrotate.d/* - -%files contrib -%defattr(-,root,root) -%doc tools - -%files devel -%defattr(-,root,root) -%if %{with_ospfclient} -%{_sbindir}/ospfclient -%endif -%{_libdir}/*.a -%{_libdir}/*.la -%dir %attr(755,root,root) %{_includedir}/%{name} -%{_includedir}/%name/*.h -%dir %attr(755,root,root) %{_includedir}/%{name}/ospfd -%{_includedir}/%name/ospfd/*.h -%if %{with_ospfapi} -%dir %attr(755,root,root) %{_includedir}/%{name}/ospfapi -%{_includedir}/%name/ospfapi/*.h -%endif - -%changelog -* Thu Sep 12 2005 Paul Jakma -- Steal some changes from Fedora spec file: -- Add with_rtadv variable -- Test for groups/users with getent before group/user adding -- Readline need not be an explicit prerequisite -- install-info delete should be postun, not preun - -* Wed Jan 12 2005 Andrew J. Schorr -- on package upgrade, implement careful, phased restart logic -- use gcc -rdynamic flag when linking for better backtraces - -* Wed Dec 22 2004 Andrew J. Schorr -- daemonv6_list should contain only IPv6 daemons - -* Wed Dec 22 2004 Andrew J. Schorr -- watchquagga added -- on upgrade, all daemons should be condrestart'ed -- on removal, all daemons should be stopped - -* Mon Nov 08 2004 Paul Jakma -- Use makeinfo --html to generate quagga.html - -* Sun Nov 07 2004 Paul Jakma -- Fix with_ipv6 set to 0 build - -* Sat Oct 23 2004 Paul Jakma -- Update to 0.97.2 - -* Sat Oct 23 2004 Andrew J. Schorr -- Make directories be owned by the packages concerned -- Update logrotate scripts to use correct path to killall and use pid files - -* Fri Oct 08 2004 Paul Jakma -- Update to 0.97.0 - -* Wed Sep 15 2004 Paul Jakma -- build snmp support by default -- build irdp support -- build with shared libs -- devel subpackage for archives and headers - -* Thu Jan 08 2004 Paul Jakma -- updated sysconfig files to specify local dir -- added ospf_dump.c crash quick fix patch -- added ospfd persistent interface configuration patch - -* Tue Dec 30 2003 Paul Jakma -- sync to CVS -- integrate RH sysconfig patch to specify daemon options (RH) -- default to have vty listen only to 127.1 (RH) -- add user with fixed UID/GID (RH) -- create user with shell /sbin/nologin rather than /bin/false (RH) -- stop daemons on uninstall (RH) -- delete info file on %preun, not %postun to avoid deletion on upgrade. (RH) -- isisd added -- cleanup tasks carried out for every daemon - -* Sun Nov 2 2003 Paul Jakma -- Fix -devel package to include all files -- Sync to 0.96.4 - -* Tue Aug 12 2003 Paul Jakma -- Renamed to Quagga -- Sync to Quagga release 0.96 - -* Tue Mar 20 2003 Paul Jakma -- zebra privileges support - -* Mon Mar 18 2003 Paul Jakma -- Fix mem leak in 'show thread cpu' -- Ralph Keller's OSPF-API -- Amir: Fix configure.ac for net-snmp - -* Sat Mar 1 2003 Paul Jakma -- ospfd IOS prefix to interface matching for 'network' statement -- temporary fix for PtP and IPv6 -- sync to zebra.org CVS - -* Mon Jan 20 2003 Paul Jakma -- update to latest cvs -- Yon's "show thread cpu" patch - 17217 -- walk up tree - 17218 -- ospfd NSSA fixes - 16681 -- ospfd nsm fixes - 16824 -- ospfd OLSA fixes and new feature - 16823 -- KAME and ifindex fixes - 16525 -- spec file changes to allow redhat files to be in tree - -* Sat Dec 28 2002 Alexander Hoogerhuis -- Added conditionals for building with(out) IPv6, vtysh, RIP, BGP -- Fixed up some build requirements (patch) -- Added conditional build requirements for vtysh / snmp -- Added conditional to %files for %_bindir depending on vtysh - -* Mon Nov 11 2002 Paul Jakma -- update to latest CVS -- add Greg Troxel's md5 buffer copy/dup fix -- add RIPv1 fix -- add Frank's multicast flag fix - -* Wed Oct 09 2002 Paul Jakma -- update to latest CVS -- timestamped crypt_seqnum patch -- oi->on_write_q fix - -* Mon Sep 30 2002 Paul Jakma -- update to latest CVS -- add vtysh 'write-config (integrated|daemon)' patch -- always 'make rebuild' in vtysh/ to catch new commands - -* Fri Sep 13 2002 Paul Jakma -- update to 0.93b - -* Wed Sep 11 2002 Paul Jakma -- update to latest CVS -- add "/sbin/ip route flush proto zebra" to zebra RH init on startup - -* Sat Aug 24 2002 Paul Jakma -- update to current CVS -- add OSPF point to multipoint patch -- add OSPF bugfixes -- add BGP hash optimisation patch - -* Fri Jun 14 2002 Paul Jakma -- update to 0.93-pre1 / CVS -- add link state detection support -- add generic PtP and RFC3021 support -- various bug fixes - -* Thu Aug 09 2001 Elliot Lee 0.91a-6 -- Fix bug #51336 - -* Wed Aug 1 2001 Trond Eivind Glomsrød 0.91a-5 -- Use generic initscript strings instead of initscript specific - ( "Starting foo: " -> "Starting $prog:" ) - -* Fri Jul 27 2001 Elliot Lee 0.91a-4 -- Bump the release when rebuilding into the dist. - -* Tue Feb 6 2001 Tim Powers -- built for Powertools - -* Sun Feb 4 2001 Pekka Savola -- Hacked up from PLD Linux 0.90-1, Mandrake 0.90-1mdk and one from zebra.org. -- Update to 0.91a -- Very heavy modifications to init.d/*, .spec, pam, i18n, logrotate, etc. -- Should be quite Red Hat'isque now. diff -Naur quagga-0.99.9/vtysh/extract.pl quagga-0.99.9-af/vtysh/extract.pl --- quagga-0.99.9/vtysh/extract.pl 2007-09-07 09:56:19.000000000 -0700 +++ quagga-0.99.9-af/vtysh/extract.pl 1969-12-31 16:00:00.000000000 -0800 @@ -1,201 +0,0 @@ -#! -## -## vtysh/extract.pl. Generated from extract.pl.in by configure. -## -## Virtual terminal interface shell command extractor. -## Copyright (C) 2000 Kunihiro Ishiguro -## -## 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. -## - -print < -#include "command.h" -#include "vtysh.h" - -EOF - -$ignore{'"interface IFNAME"'} = "ignore"; -$ignore{'"ip vrf NAME"'} = "ignore"; -$ignore{'"router rip"'} = "ignore"; -$ignore{'"router ripng"'} = "ignore"; -$ignore{'"router ospf"'} = "ignore"; -$ignore{'"router ospf <0-65535>"'} = "ignore"; -$ignore{'"router ospf6"'} = "ignore"; -$ignore{'"router bgp <1-65535>"'} = "ignore"; -$ignore{'"router bgp <1-65535> view WORD"'} = "ignore"; -$ignore{'"router isis WORD"'} = "ignore"; -$ignore{'"router zebra"'} = "ignore"; -$ignore{'"address-family ipv4"'} = "ignore"; -$ignore{'"address-family ipv4 (unicast|multicast)"'} = "ignore"; -$ignore{'"address-family ipv6"'} = "ignore"; -$ignore{'"address-family ipv6 unicast"'} = "ignore"; -$ignore{'"address-family vpnv4"'} = "ignore"; -$ignore{'"address-family vpnv4 unicast"'} = "ignore"; -$ignore{'"address-family ipv4 vrf NAME"'} = "ignore"; -$ignore{'"exit-address-family"'} = "ignore"; -$ignore{'"key chain WORD"'} = "ignore"; -$ignore{'"key <0-2147483647>"'} = "ignore"; -$ignore{'"route-map WORD (deny|permit) <1-65535>"'} = "ignore"; -$ignore{'"show route-map"'} = "ignore"; -$ignore{'"line vty"'} = "ignore"; -$ignore{'"who"'} = "ignore"; -$ignore{'"terminal monitor"'} = "ignore"; -$ignore{'"terminal no monitor"'} = "ignore"; -$ignore{'"show history"'} = "ignore"; - -foreach (@ARGV) { - $file = $_; - - open (FH, "cpp -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -DHAVE_IPV6 -I.. -I../../../vtysh/ -I../../../vtysh/.. -I../../../lib -I../../../isisd/topology $file |"); - local $/; undef $/; - $line = ; - close (FH); - - @defun = ($line =~ /(?:DEFUN|ALIAS)\s*\((.+?)\);?\s?\s?\n/sg); - @install = ($line =~ /install_element \(\s*[0-9A-Z_]+,\s*&[^;]*;\s*\n/sg); - - # DEFUN process - foreach (@defun) { - my (@defun_array); - @defun_array = split (/,/); - $defun_array[0] = ''; - - - # Actual input command string. - $str = "$defun_array[2]"; - $str =~ s/^\s+//g; - $str =~ s/\s+$//g; - - # Get VTY command structure. This is needed for searching - # install_element() command. - $cmd = "$defun_array[1]"; - $cmd =~ s/^\s+//g; - $cmd =~ s/\s+$//g; - - # $protocol is VTYSH_PROTO format for redirection of user input - if ($file =~ /lib/) { - if ($file =~ /keychain.c/) { - $protocol = "VTYSH_RIPD"; - } - if ($file =~ /routemap.c/) { - $protocol = "VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA"; - } - if ($file =~ /filter.c/) { - $protocol = "VTYSH_ALL"; - } - if ($file =~ /plist.c/) { - if ($defun_array[1] =~ m/ipv6/) { - $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA"; - } else { - $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA"; - } - } - if ($file =~ /distribute.c/) { - if ($defun_array[1] =~ m/ipv6/) { - $protocol = "VTYSH_RIPNGD"; - } else { - $protocol = "VTYSH_RIPD"; - } - } - if ($file =~ /if_rmap.c/) { - if ($defun_array[1] =~ m/ipv6/) { - $protocol = "VTYSH_RIPNGD"; - } else { - $protocol = "VTYSH_RIPD"; - } - } - if ($file =~ /vty.c/) { - $protocol = "VTYSH_ALL"; - } - } else { - ($protocol) = ($file =~ /^.*\/([a-z0-9]+)\/[a-zA-Z0-9_\-]+\.c$/); - $protocol = "VTYSH_" . uc $protocol; - } - - # Append _vtysh to structure then build DEFUN again - $defun_array[1] = $cmd . "_vtysh"; - $defun_body = join (", ", @defun_array); - - # $cmd -> $str hash for lookup - $cmd2str{$cmd} = $str; - $cmd2defun{$cmd} = $defun_body; - $cmd2proto{$cmd} = $protocol; - } - - # install_element() process - foreach (@install) { - my (@element_array); - @element_array = split (/,/); - - # Install node - $enode = $element_array[0]; - $enode =~ s/^\s+//g; - $enode =~ s/\s+$//g; - ($enode) = ($enode =~ /([0-9A-Z_]+)$/); - - # VTY command structure. - ($ecmd) = ($element_array[1] =~ /&([^\)]+)/); - $ecmd =~ s/^\s+//g; - $ecmd =~ s/\s+$//g; - - # Register $ecmd - if (defined ($cmd2str{$ecmd}) - && ! defined ($ignore{$cmd2str{$ecmd}})) { - my ($key); - $key = $enode . "," . $cmd2str{$ecmd}; - $ocmd{$key} = $ecmd; - $odefun{$key} = $cmd2defun{$ecmd}; - push (@{$oproto{$key}}, $cmd2proto{$ecmd}); - } - } -} - -# Check finaly alive $cmd; -foreach (keys %odefun) { - my ($node, $str) = (split (/,/)); - my ($cmd) = $ocmd{$_}; - $live{$cmd} = $_; -} - -# Output DEFSH -foreach (keys %live) { - my ($proto); - my ($key); - $key = $live{$_}; - $proto = join ("|", @{$oproto{$key}}); - printf "DEFSH ($proto$odefun{$key})\n\n"; -} - -# Output install_element -print <ifm_addrs, cp); RTA_ATTR_GET (NULL, RTA_NETMASK, ifm->ifm_addrs, cp); RTA_ADDR_GET (NULL, RTA_GENMASK, ifm->ifm_addrs, cp); + sdl = (struct sockaddr_dl *)cp; RTA_NAME_GET (ifname, RTA_IFP, ifm->ifm_addrs, cp, ifnlen); RTA_ADDR_GET (NULL, RTA_IFA, ifm->ifm_addrs, cp); RTA_ADDR_GET (NULL, RTA_AUTHOR, ifm->ifm_addrs, cp); @@ -435,6 +437,19 @@ #endif /* __bsdi__ */ if_get_metric (ifp); + /* + * ifp->sdl should be set because it might be used by + * rtm_write() when gate is NULL. sdl should be valid if we get + * here since RTA_NAME_GET() already did a bunch of checks. + */ + + /* + * XXX sockaddr_dl contents can be larger than the structure + * definition, so the user of the stored structure must be + * careful not to read off the end. + */ + memcpy (&ifp->sdl, sdl, sizeof (struct sockaddr_dl)); + if_add_update (ifp); } else @@ -889,6 +904,11 @@ struct prefix_ipv6 p; unsigned int ifindex = 0; + /* Catch self originated messages */ + if (rtm->rtm_type != RTM_GET && + (rtm->rtm_pid == pid || rtm->rtm_pid == old_pid)) + return; + p.family = AF_INET6; p.prefix = dest.sin6.sin6_addr; if (flags & RTF_HOST) diff -Naur quagga-0.99.9/zebra/rt_ioctl.c quagga-0.99.9-af/zebra/rt_ioctl.c --- quagga-0.99.9/zebra/rt_ioctl.c 2007-05-09 13:59:35.000000000 -0700 +++ quagga-0.99.9-af/zebra/rt_ioctl.c 2008-12-03 13:42:15.000000000 -0800 @@ -31,6 +31,9 @@ #include "zebra/debug.h" #include "zebra/rt.h" +#include "privs.h" +extern struct zebra_privs_t zserv_privs; + /* Initialize of kernel interface. There is no kernel communication support under ioctl(). So this is dummy stub function. */ void @@ -172,6 +175,7 @@ struct nexthop *nexthop; int nexthop_num = 0; struct interface *ifp; + int save_errno; memset (&rtentry, 0, sizeof (struct rtentry)); @@ -307,11 +311,23 @@ return -1; } + /* Bind the socket to the netlink structure for anything. */ + if (zserv_privs.change (ZPRIVS_RAISE)) + { + zlog (NULL, LOG_ERR, "Can't raise privileges"); + return -1; + } + /* Send message by ioctl(). */ ret = ioctl (sock, cmd, &rtentry); + + save_errno = errno; + if (zserv_privs.change (ZPRIVS_LOWER)) + zlog (NULL, LOG_ERR, "Can't lower privileges"); + if (ret < 0) { - switch (errno) + switch (save_errno) { case EEXIST: close (sock); @@ -328,7 +344,7 @@ } close (sock); - zlog_warn ("write : %s (%d)", safe_strerror (errno), errno); + zlog_warn ("write : %s (%d)", safe_strerror (save_errno), save_errno); return ret; } close (sock); diff -Naur quagga-0.99.9/zebra/rt_netlink.c quagga-0.99.9-af/zebra/rt_netlink.c --- quagga-0.99.9/zebra/rt_netlink.c 2007-08-13 09:35:14.000000000 -0700 +++ quagga-0.99.9-af/zebra/rt_netlink.c 2008-12-03 13:42:15.000000000 -0800 @@ -1466,15 +1466,24 @@ { for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) { - +// Modified by MJH 2/19/2007 to force delete if state is _ACTIVE || _FIB */ if ((cmd == RTM_NEWROUTE && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) || (cmd == RTM_DELROUTE - && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))) + && (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) || + CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)))) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) { + /* direct (single hop) routes should have link scope */ + if (nexthop->rtype == NEXTHOP_TYPE_IFINDEX + || nexthop->rtype == NEXTHOP_TYPE_IFNAME + || nexthop->rtype == NEXTHOP_TYPE_IPV4_IFINDEX + || nexthop->rtype == NEXTHOP_TYPE_IPV6_IFINDEX + || nexthop->rtype == NEXTHOP_TYPE_IPV6_IFNAME) + req.r.rtm_scope = RT_SCOPE_LINK; + if (IS_ZEBRA_DEBUG_KERNEL) { zlog_debug @@ -1541,6 +1550,14 @@ } else { + /* direct (single hop) routes should have link scope */ + if (nexthop->type == NEXTHOP_TYPE_IFINDEX + || nexthop->type == NEXTHOP_TYPE_IFNAME + || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX + || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX + || nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) + req.r.rtm_scope = RT_SCOPE_LINK; + if (IS_ZEBRA_DEBUG_KERNEL) { zlog_debug diff -Naur quagga-0.99.9/zebra/rt_socket.c quagga-0.99.9-af/zebra/rt_socket.c --- quagga-0.99.9/zebra/rt_socket.c 2007-08-13 09:35:14.000000000 -0700 +++ quagga-0.99.9-af/zebra/rt_socket.c 2008-12-03 13:42:15.000000000 -0800 @@ -98,8 +98,8 @@ /* Make gateway. */ for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) { - gate = 0; char gate_buf[INET_ADDRSTRLEN] = "NULL"; + gate = 0; /* * XXX We need to refrain from kernel operations in some cases, @@ -207,6 +207,9 @@ case ZEBRA_ERR_RTNOEXIST: case ZEBRA_ERR_RTUNREACH: default: + if (!IS_ZEBRA_DEBUG_RIB) + inet_ntop (AF_INET, &p->u.prefix, prefix_buf, INET_ADDRSTRLEN); + zlog_err ("%s: %s/%d: rtm_write() unexpectedly returned %d for command %s", __func__, prefix_buf, p->prefixlen, error, LOOKUP (rtm_type_str, cmd)); break; diff -Naur quagga-0.99.9/zebra/zebra_rib.c quagga-0.99.9-af/zebra/zebra_rib.c --- quagga-0.99.9/zebra/zebra_rib.c 2007-08-22 09:22:57.000000000 -0700 +++ quagga-0.99.9-af/zebra/zebra_rib.c 2008-12-03 13:42:15.000000000 -0800 @@ -369,10 +369,17 @@ while (rn) { route_unlock_node (rn); - - /* If lookup self prefix return immidiately. */ + /* If lookup self prefix return immidiately, but + * do not return for ospf6. The host routes + * installed by ospf6 should be kept. */ if (rn == top) + { + match = rn->info; + //force the installation of OSPF and OSPF6 host routes + if (!match || !(match->type == ZEBRA_ROUTE_OSPF6 || + match->type == ZEBRA_ROUTE_OSPF)) return 0; + } /* Pick up selected route. */ for (match = rn->info; match; match = match->next) @@ -401,6 +408,18 @@ return 1; } + //Enable the use of OSPF and OSPF6 routes as the nexthop + //this is important when allowing host routes. + else if (match->type == ZEBRA_ROUTE_OSPF6 || + match->type == ZEBRA_ROUTE_OSPF) + { + /* OSPF point connected route. */ + newhop = match->nexthop; + if (newhop && nexthop->type == NEXTHOP_TYPE_IPV4) + nexthop->ifindex = newhop->ifindex; + + return 1; + } else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL)) { for (newhop = match->nexthop; newhop; newhop = newhop->next) @@ -953,7 +972,7 @@ #ifdef HAVE_IPV6 case AF_INET6: if (IS_ZEBRA_DEBUG_RIB) - zlog_debug ("%s: calling kernel_delete_ipv4 (%p, %p)", __func__, rn, rib); + zlog_debug ("%s: calling kernel_delete_ipv6 (%p, %p)", __func__, rn, rib); ret = kernel_delete_ipv6 (&rn->p, rib); break; #endif /* HAVE_IPV6 */ @@ -992,12 +1011,12 @@ struct route_node *rn = data; int installed = 0; struct nexthop *nexthop = NULL; - char buf[INET_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; assert (rn); if (IS_ZEBRA_DEBUG_RIB || IS_ZEBRA_DEBUG_RIB_Q) - inet_ntop (AF_INET, &rn->p.u.prefix, buf, INET_ADDRSTRLEN); + inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf)); for (rib = rn->info; rib; rib = next) { @@ -1033,7 +1052,12 @@ /* Skip unreachable nexthop. */ if (! nexthop_active_update (rn, rib, 0)) + { + if (IS_ZEBRA_DEBUG_RIB) + zlog_debug("%s: skipping %s/%d because nexthop is not active", + __func__, buf, rn->p.prefixlen); continue; + } /* Infinit distance. */ if (rib->distance == DISTANCE_INFINITY) @@ -1186,11 +1210,11 @@ static void rib_queue_add (struct zebra_t *zebra, struct route_node *rn) { - char buf[INET_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; assert (zebra && rn); if (IS_ZEBRA_DEBUG_RIB_Q) - inet_ntop (AF_INET, &rn->p.u.prefix, buf, INET_ADDRSTRLEN); + inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf)); /* Pointless to queue a route_node with no RIB entries to add or remove */ if (!rn->info) @@ -1300,7 +1324,7 @@ rib_link (struct route_node *rn, struct rib *rib) { struct rib *head; - char buf[INET_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; assert (rib && rn); @@ -1308,7 +1332,7 @@ if (IS_ZEBRA_DEBUG_RIB) { - inet_ntop (AF_INET, &rn->p.u.prefix, buf, INET_ADDRSTRLEN); + inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf)); zlog_debug ("%s: %s/%d: rn %p, rib %p", __func__, buf, rn->p.prefixlen, rn, rib); } @@ -1338,8 +1362,8 @@ { if (IS_ZEBRA_DEBUG_RIB) { - char buf[INET_ADDRSTRLEN]; - inet_ntop (AF_INET, &rn->p.u.prefix, buf, INET_ADDRSTRLEN); + char buf[INET6_ADDRSTRLEN]; + inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf)); zlog_debug ("%s: %s/%d: rn %p, un-removed rib %p", __func__, buf, rn->p.prefixlen, rn, rib); } @@ -1353,13 +1377,13 @@ rib_unlink (struct route_node *rn, struct rib *rib) { struct nexthop *nexthop, *next; - char buf[INET_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; assert (rn && rib); if (IS_ZEBRA_DEBUG_RIB) { - inet_ntop (AF_INET, &rn->p.u.prefix, buf, INET_ADDRSTRLEN); + inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf)); zlog_debug ("%s: %s/%d: rn %p, rib %p", __func__, buf, rn->p.prefixlen, rn, rib); } @@ -1398,8 +1422,8 @@ { if (IS_ZEBRA_DEBUG_RIB) { - char buf[INET_ADDRSTRLEN]; - inet_ntop (AF_INET, &rn->p.u.prefix, buf, INET_ADDRSTRLEN); + char buf[INET6_ADDRSTRLEN]; + inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf)); zlog_debug ("%s: %s/%d: rn %p, rib %p, removing", __func__, buf, rn->p.prefixlen, rn, rib); } diff -Naur quagga-0.99.9/zebra/zebra_vty.c quagga-0.99.9-af/zebra/zebra_vty.c --- quagga-0.99.9/zebra/zebra_vty.c 2007-06-14 03:02:15.000000000 -0700 +++ quagga-0.99.9-af/zebra/zebra_vty.c 2008-12-03 13:42:15.000000000 -0800 @@ -556,6 +556,7 @@ #define ONE_WEEK_SECOND 60*60*24*7 if (rib->type == ZEBRA_ROUTE_RIP || rib->type == ZEBRA_ROUTE_OSPF + || rib->type == ZEBRA_ROUTE_OSPF6 || rib->type == ZEBRA_ROUTE_ISIS || rib->type == ZEBRA_ROUTE_BGP) { @@ -774,6 +775,7 @@ if (rib->type == ZEBRA_ROUTE_RIP || rib->type == ZEBRA_ROUTE_OSPF + || rib->type == ZEBRA_ROUTE_OSPF6 || rib->type == ZEBRA_ROUTE_ISIS || rib->type == ZEBRA_ROUTE_BGP) { @@ -804,7 +806,7 @@ #define SHOW_ROUTE_V4_HEADER "Codes: K - kernel route, C - connected, " \ "S - static, R - RIP, O - OSPF,%s I - ISIS, B - BGP, " \ - "> - selected route, * - FIB route%s%s" + "> - selected route, * - FIB route, o - OSPFv3%s%s" DEFUN (show_ip_route, show_ip_route_cmd, @@ -922,7 +924,7 @@ DEFUN (show_ip_route_protocol, show_ip_route_protocol_cmd, - "show ip route (bgp|connected|isis|kernel|ospf|rip|static)", + "show ip route (bgp|connected|isis|kernel|ospf|ospf6|rip|static)", SHOW_STR IP_STR "IP routing table\n" @@ -931,6 +933,7 @@ "ISO IS-IS (ISIS)\n" "Kernel\n" "Open Shortest Path First (OSPF)\n" + "Open Shortest Path First version 3 (OSPFv3)\n" "Routing Information Protocol (RIP)\n" "Static routes\n") { @@ -946,7 +949,9 @@ type = ZEBRA_ROUTE_CONNECT; else if (strncmp (argv[0], "k", 1) ==0) type = ZEBRA_ROUTE_KERNEL; - else if (strncmp (argv[0], "o", 1) == 0) + else if (strncmp (argv[0], "ospf6", 5) == 0) + type = ZEBRA_ROUTE_OSPF6; + else if (strncmp (argv[0], "ospf", 4) == 0) type = ZEBRA_ROUTE_OSPF; else if (strncmp (argv[0], "i", 1) == 0) type = ZEBRA_ROUTE_ISIS; @@ -1734,7 +1739,8 @@ } } -#define SHOW_ROUTE_V6_HEADER "Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3,%s I - ISIS, B - BGP, * - FIB route.%s%s" +#define SHOW_ROUTE_V6_HEADER "Codes: K - kernel route, C - connected, S - static, R - RIPng, o - OSPFv3,%s I - ISIS, B - BGP, * - FIB route.%s%s" + DEFUN (show_ipv6_route, show_ipv6_route_cmd, diff -Naur quagga-0.99.9/zebra/zserv.c quagga-0.99.9-af/zebra/zserv.c --- quagga-0.99.9/zebra/zserv.c 2007-05-09 13:59:35.000000000 -0700 +++ quagga-0.99.9-af/zebra/zserv.c 2008-12-03 13:42:15.000000000 -0800 @@ -758,6 +758,12 @@ memset (&p, 0, sizeof (struct prefix_ipv4)); p.family = AF_INET; p.prefixlen = stream_getc (s); + if (p.prefixlen > IPV4_MAX_PREFIXLEN) + { + zlog_warn("%s: invalid ipv4 prefixlen: %d", __func__, p.prefixlen); + XFREE(MTYPE_RIB, rib); + return -1; + } stream_get (&p.prefix, s, PSIZE (p.prefixlen)); /* Nexthop parse. */ @@ -834,6 +840,11 @@ memset (&p, 0, sizeof (struct prefix_ipv4)); p.family = AF_INET; p.prefixlen = stream_getc (s); + if (p.prefixlen > IPV4_MAX_PREFIXLEN) + { + zlog_warn("%s: invalid ipv4 prefixlen: %d", __func__, p.prefixlen); + return -1; + } stream_get (&p.prefix, s, PSIZE (p.prefixlen)); /* Nexthop, ifindex, distance, metric. */ @@ -929,6 +940,11 @@ memset (&p, 0, sizeof (struct prefix_ipv6)); p.family = AF_INET6; p.prefixlen = stream_getc (s); + if (p.prefixlen > IPV6_MAX_PREFIXLEN) + { + zlog_warn("%s: invalid ipv6 prefixlen: %d", __func__, p.prefixlen); + return -1; + } stream_get (&p.prefix, s, PSIZE (p.prefixlen)); /* Nexthop, ifindex, distance, metric. */ @@ -996,6 +1012,11 @@ memset (&p, 0, sizeof (struct prefix_ipv6)); p.family = AF_INET6; p.prefixlen = stream_getc (s); + if (p.prefixlen > IPV6_MAX_PREFIXLEN) + { + zlog_warn("%s: invalid ipv6 prefixlen: %d", __func__, p.prefixlen); + return -1; + } stream_get (&p.prefix, s, PSIZE (p.prefixlen)); /* Nexthop, ifindex, distance, metric. */