build: massively remove needless checks

Since we have autoconf results from a wide swath of target platforms, we
can go remove checks that have the same result on all systems.

This also removes several "fallback" implementations of functions that,
at some point in the history, weren't available on all target platforms.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2016-11-15 13:37:14 +09:00
parent a89b1641fd
commit 24f5e2fc62
22 changed files with 63 additions and 7148 deletions

View file

@ -26,11 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifdef HAVE_LIBPCREPOSIX #ifdef HAVE_LIBPCREPOSIX
# include <pcreposix.h> # include <pcreposix.h>
#else #else
# ifdef HAVE_GNU_REGEX # include <regex.h>
# include <regex.h>
# else
# include "regex-gnu.h"
# endif /* HAVE_GNU_REGEX */
#endif /* HAVE_LIBPCREPOSIX */ #endif /* HAVE_LIBPCREPOSIX */
extern void bgp_regex_free (regex_t *regex); extern void bgp_regex_free (regex_t *regex);

View file

@ -31,11 +31,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifdef HAVE_LIBPCREPOSIX #ifdef HAVE_LIBPCREPOSIX
# include <pcreposix.h> # include <pcreposix.h>
#else #else
# ifdef HAVE_GNU_REGEX # include <regex.h>
# include <regex.h>
# else
# include "regex-gnu.h"
# endif /* HAVE_GNU_REGEX */
#endif /* HAVE_LIBPCREPOSIX */ #endif /* HAVE_LIBPCREPOSIX */
#include "buffer.h" #include "buffer.h"
#include "sockunion.h" #include "sockunion.h"

View file

@ -181,22 +181,6 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_CHECK_TOOL(AR, ar) AC_CHECK_TOOL(AR, ar)
dnl ---------------------------
dnl We, perhaps unfortunately,
dnl depend on GNU Make specific
dnl constructs.
dnl Give the user a warning if
dnl not GNU Make.
dnl ---------------------------
AC_CACHE_CHECK([if ${MAKE-make} is GNU make], [quagga_cv_gnu_make],
[quagga_cv_gnu_make=no
if ${MAKE-make} --version 2>/dev/null | \
grep '^GNU Make ' >/dev/null ; then
quagga_cv_gnu_make=yes;
fi
]
)
dnl ----------------- dnl -----------------
dnl System extensions dnl System extensions
dnl ----------------- dnl -----------------
@ -521,12 +505,8 @@ dnl Check C keywords and standard types
dnl ------------------------------------ dnl ------------------------------------
AC_C_CONST AC_C_CONST
AC_C_INLINE AC_C_INLINE
AC_C_RESTRICT
AC_C_VOLATILE AC_C_VOLATILE
AC_HEADER_STDC AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_HEADER_STDBOOL
dnl AC_TYPE_PID_T dnl AC_TYPE_PID_T
AC_TYPE_UID_T AC_TYPE_UID_T
AC_TYPE_MODE_T AC_TYPE_MODE_T
@ -536,10 +516,9 @@ AC_STRUCT_TM
dnl ------------------------- dnl -------------------------
dnl Check other header files. dnl Check other header files.
dnl ------------------------- dnl -------------------------
AC_CHECK_HEADERS([stropts.h sys/ksym.h sys/times.h sys/select.h \ AC_CHECK_HEADERS([stropts.h sys/ksym.h \
sys/types.h linux/version.h netdb.h asm/types.h \ linux/version.h asm/types.h \
sys/cdefs.h sys/param.h limits.h signal.h \ sys/cdefs.h])
sys/socket.h netinet/in.h time.h sys/time.h])
dnl Utility macro to avoid retyping includes all the time dnl Utility macro to avoid retyping includes all the time
m4_define([QUAGGA_INCLUDES], m4_define([QUAGGA_INCLUDES],
@ -548,58 +527,21 @@ m4_define([QUAGGA_INCLUDES],
#define __EXTENSIONS__ #define __EXTENSIONS__
#endif #endif
#include <stdio.h> #include <stdio.h>
#if STDC_HEADERS #include <stdlib.h>
# include <stdlib.h> #include <stddef.h>
# include <stddef.h> #include <sys/types.h>
#else
# if HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
/* sys/conf.h depends on param.h on FBSD at least */ /* sys/conf.h depends on param.h on FBSD at least */
#if HAVE_SYS_PARAM_H #include <sys/param.h>
# include <sys/param.h>
#endif
/* Required for MAXSIG */ /* Required for MAXSIG */
#if HAVE_SIGNAL_H #include <signal.h>
# include <signal.h> #include <sys/socket.h>
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef __APPLE__ #ifdef __APPLE__
# define __APPLE_USE_RFC_3542 # define __APPLE_USE_RFC_3542
#endif #endif
#if HAVE_NETINET_IN_H #include <netinet/in.h>
# include <netinet/in.h> #include <sys/time.h>
#endif #include <time.h>
#ifdef TIME_WITH_SYS_TIME #include <net/if.h>
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif /* TIME_WITH_SYS_TIME */
])dnl
dnl HAVE_NET_IF_H must be discovered by the time the longer AC_CHECK_HEADERS
dnl round below execution begins, otherwise it doesn't properly detect
dnl HAVE_NETINET6_IN6_VAR_H, HAVE_NET_IF_VAR_H and HAVE_STRUCT_IN6_ALIASREQ
dnl on FreeBSD (BZ#408).
AC_CHECK_HEADERS([net/if.h], [], [], QUAGGA_INCLUDES)
m4_define([QUAGGA_INCLUDES],
QUAGGA_INCLUDES
[#if HAVE_NET_IF_H
# include <net/if.h>
#endif
])dnl ])dnl
dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and
@ -615,10 +557,9 @@ QUAGGA_INCLUDES
#endif #endif
])dnl ])dnl
AC_CHECK_HEADERS([sys/un.h netinet/in_systm.h netinet/in_var.h \ AC_CHECK_HEADERS([netinet/in_var.h \
net/if_dl.h net/netopt.h net/route.h \ net/if_dl.h net/netopt.h \
inet/nd.h arpa/inet.h netinet/ip_icmp.h \ inet/nd.h netinet/ip_icmp.h \
fcntl.h stddef.h sys/ioctl.h syslog.h wchar.h wctype.h \
sys/sysctl.h sys/sockio.h kvm.h sys/conf.h], sys/sysctl.h sys/sockio.h kvm.h sys/conf.h],
[], [], QUAGGA_INCLUDES) [], [], QUAGGA_INCLUDES)
@ -643,12 +584,9 @@ AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.gregs],
m4_define([QUAGGA_INCLUDES], m4_define([QUAGGA_INCLUDES],
QUAGGA_INCLUDES QUAGGA_INCLUDES
[#if HAVE_SYS_UN_H [
# include <sys/un.h> #include <sys/un.h>
#endif #include <netinet/in_systm.h>
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_VAR_H #if HAVE_NETINET_IN_VAR_H
# include <netinet/in_var.h> # include <netinet/in_var.h>
#endif #endif
@ -658,15 +596,11 @@ QUAGGA_INCLUDES
#if HAVE_NET_NETOPT_H #if HAVE_NET_NETOPT_H
# include <net/netopt.h> # include <net/netopt.h>
#endif #endif
#if HAVE_NET_ROUTE_H #include <net/route.h>
# include <net/route.h>
#endif
#if HAVE_INET_ND_H #if HAVE_INET_ND_H
# include <inet/nd.h> # include <inet/nd.h>
#endif #endif
#if HAVE_ARPA_INET_H #include <arpa/inet.h>
# include <arpa/inet.h>
#endif
/* Required for IDRP */ /* Required for IDRP */
#if HAVE_NETINET_IP_ICMP_H #if HAVE_NETINET_IP_ICMP_H
# include <netinet/ip_icmp.h> # include <netinet/ip_icmp.h>
@ -837,20 +771,10 @@ dnl AC_CHECK_SIZEOF(long)
dnl ---------------------------- dnl ----------------------------
dnl check existance of functions dnl check existance of functions
dnl ---------------------------- dnl ----------------------------
AC_FUNC_CHOWN
AC_FUNC_FNMATCH AC_FUNC_FNMATCH
AC_FUNC_FORK AC_FUNC_FORK
AC_FUNC_MEMCMP
AC_FUNC_MKTIME AC_FUNC_MKTIME
AC_FUNC_STRFTIME
AC_FUNC_STAT AC_FUNC_STAT
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRFTIME
dnl Avoid AC_FUNC_STRNLEN because it pulls in AC_SYSTEM_EXTENSIONS which
dnl can lead to strange side effects. So we just check for strnlen
dnl directly, see below.
dnl AC_FUNC_STRNLENdnl
AC_FUNC_VPRINTF
dnl ------------------------------- dnl -------------------------------
dnl bgpd needs pow() and hence libm dnl bgpd needs pow() and hence libm
@ -873,15 +797,10 @@ AC_SUBST(LIBM)
dnl --------------- dnl ---------------
dnl other functions dnl other functions
dnl --------------- dnl ---------------
AC_CHECK_FUNCS([dup2 ftruncate getcwd gethostbyname getpagesize gettimeofday \ AC_CHECK_FUNCS([ \
inet_ntoa inet_aton strnlen \ strlcat strlcpy \
memchr memmove memset select socket \ getgrouplist \
strcasecmp strchr strcspn strdup strerror \ pledge])
strncasecmp strndup strrchr strspn strstr \
strtol strtoul strlcat strlcpy \
daemon snprintf vsnprintf \
if_nametoindex if_indextoname getifaddrs \
uname fcntl getgrouplist pledge])
AC_CHECK_HEADER([asm-generic/unistd.h], AC_CHECK_HEADER([asm-generic/unistd.h],
[AC_CHECK_DECL(__NR_setns, [AC_CHECK_DECL(__NR_setns,
@ -952,15 +871,9 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#define _XPG4_2 #define _XPG4_2
#define __EXTENSIONS__ #define __EXTENSIONS__
#endif #endif
#ifdef HAVE_STDLIB_H #include <stdlib.h>
# include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
main() main()
{ {
@ -1035,12 +948,8 @@ dnl ---------------------------------------------------------------
AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES) AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES)
AC_CHECK_HEADERS([linux/mroute.h], [], [],[ AC_CHECK_HEADERS([linux/mroute.h], [], [],[
#ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h>
# include <sys/socket.h> #include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#define _LINUX_IN_H /* For Linux <= 2.6.25 */ #define _LINUX_IN_H /* For Linux <= 2.6.25 */
#include <linux/types.h> #include <linux/types.h>
]) ])
@ -1053,18 +962,10 @@ QUAGGA_INCLUDES
])dnl ])dnl
AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[ AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[
#ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h>
# include <sys/socket.h> #include <sys/types.h>
#endif #include <netinet/in.h>
#ifdef HAVE_SYS_TYPES_H #include <net/route.h>
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NET_ROUTE_H
# include <net/route.h>
#endif
]) ])
m4_define([QUAGGA_INCLUDES], m4_define([QUAGGA_INCLUDES],
@ -1075,9 +976,8 @@ QUAGGA_INCLUDES
])dnl ])dnl
AC_MSG_CHECKING([for BSD struct ip_mreq hack]) AC_MSG_CHECKING([for BSD struct ip_mreq hack])
AC_TRY_COMPILE([#ifdef HAVE_SYS_PARAM_H AC_TRY_COMPILE([#include <sys/param.h>],
#include <sys/param.h> [#if (defined(__FreeBSD__) && ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || (defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106010000) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__sun)
#endif],[#if (defined(__FreeBSD__) && ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || (defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106010000) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__sun)
return (0); return (0);
#else #else
#error No support for BSD struct ip_mreq hack detected #error No support for BSD struct ip_mreq hack detected
@ -1097,28 +997,24 @@ AC_MSG_RESULT(no))
dnl --------------------------------------------------------------- dnl ---------------------------------------------------------------
dnl figure out how to check link-state dnl figure out how to check link-state
dnl --------------------------------------------------------------- dnl ---------------------------------------------------------------
AC_CHECK_HEADER([net/if.h], AC_CHECK_HEADER( [net/if_media.h],
[AC_CHECK_HEADER( [net/if_media.h], [m4_define([LINK_DETECT_INCLUDES],
[m4_define([LINK_DETECT_INCLUDES], QUAGGA_INCLUDES
QUAGGA_INCLUDES [#include <net/if_media.h>
[#include <net/if_media.h> ])
]) AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status],
AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status], AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]),
AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]), [], LINK_DETECT_INCLUDES)],
[], LINK_DETECT_INCLUDES)], [],
[], QUAGGA_INCLUDES)
QUAGGA_INCLUDES)],
[], QUAGGA_INCLUDES )
dnl --------------------------------------------------------------- dnl ---------------------------------------------------------------
dnl Additional, newer way to check link-state using ifi_link_state. dnl Additional, newer way to check link-state using ifi_link_state.
dnl Not available in all BSD's when ifmediareq available dnl Not available in all BSD's when ifmediareq available
dnl --------------------------------------------------------------- dnl ---------------------------------------------------------------
AC_CHECK_HEADER([net/if.h], AC_CHECK_MEMBERS([struct if_data.ifi_link_state],
AC_CHECK_MEMBERS([struct if_data.ifi_link_state], AC_DEFINE(HAVE_BSD_IFI_LINK_STATE,,[BSD ifi_link_state available]),
AC_DEFINE(HAVE_BSD_IFI_LINK_STATE,,[BSD ifi_link_state available]), [], QUAGGA_INCLUDES)
[], QUAGGA_INCLUDES),
,)
dnl ------------------------ dnl ------------------------
dnl TCP_MD5SIG socket option dnl TCP_MD5SIG socket option
@ -1169,8 +1065,6 @@ esac])
IPFORWARD=ipforward_${quagga_cv_ipforward_method}.o IPFORWARD=ipforward_${quagga_cv_ipforward_method}.o
AC_SUBST(IPFORWARD) AC_SUBST(IPFORWARD)
AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no])
dnl ---------------------------------------------------------------------------- dnl ----------------------------------------------------------------------------
dnl figure out if domainname is available in the utsname struct (GNU extension). dnl figure out if domainname is available in the utsname struct (GNU extension).
dnl ---------------------------------------------------------------------------- dnl ----------------------------------------------------------------------------
@ -1214,7 +1108,7 @@ AC_DEFINE(HAVE_IPV6,1,IPv6)
dnl ------------------ dnl ------------------
dnl IPv6 header checks dnl IPv6 header checks
dnl ------------------ dnl ------------------
AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h netinet/icmp6.h \ AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h \
netinet6/in6_var.h netinet6/nd6.h], [], [], netinet6/in6_var.h netinet6/nd6.h], [], [],
QUAGGA_INCLUDES) QUAGGA_INCLUDES)
@ -1226,9 +1120,7 @@ QUAGGA_INCLUDES
#if HAVE_NETINET_IN6_VAR_H #if HAVE_NETINET_IN6_VAR_H
#include <netinet/in6_var.h> #include <netinet/in6_var.h>
#endif #endif
#if HAVE_NETINET_ICMP6_H #include <netinet/icmp6.h>
# include <netinet/icmp6.h>
#endif
#if HAVE_NETINET6_IN6_VAR_H #if HAVE_NETINET6_IN6_VAR_H
# include <netinet6/in6_var.h> # include <netinet6/in6_var.h>
#endif #endif
@ -1371,8 +1263,6 @@ AC_SUBST(VTYSH)
AC_SUBST(CURSES) AC_SUBST(CURSES)
AC_SUBST(OSPFCLIENT) AC_SUBST(OSPFCLIENT)
AC_SUBST(OSPFAPI) AC_SUBST(OSPFAPI)
AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP,,inet_ntop)])
AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON,,inet_pton)])
AC_CHECK_LIB(crypt, crypt) AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(resolv, res_init) AC_CHECK_LIB(resolv, res_init)
@ -1383,19 +1273,7 @@ if test "x$enable_pcreposix" = "xyes"; then
AC_CHECK_LIB(pcreposix, pcreposix_regexec, ,[enable_pcreposix=no AC_CHECK_LIB(pcreposix, pcreposix_regexec, ,[enable_pcreposix=no
AC_MSG_WARN([*** falling back to other regex library ***]) ]) AC_MSG_WARN([*** falling back to other regex library ***]) ])
fi fi
if test "x$enable_pcreposix" != "xyes"; then
dnl ---------------------------
dnl check system has GNU regexp
dnl ---------------------------
AC_MSG_CHECKING(whether system has GNU regex)
AC_CHECK_LIB(c, regexec,
[AC_DEFINE(HAVE_GNU_REGEX,,GNU regexp library)
LIB_REGEX=""],
[LIB_REGEX="regex.o"])
fi
AC_SUBST(HAVE_LIBPCREPOSIX) AC_SUBST(HAVE_LIBPCREPOSIX)
AC_SUBST(LIB_REGEX)
dnl ------------------ dnl ------------------
dnl check Net-SNMP library dnl check Net-SNMP library
@ -1438,9 +1316,9 @@ fi
dnl --------------------------- dnl ---------------------------
dnl sockaddr and netinet checks dnl sockaddr and netinet checks
dnl --------------------------- dnl ---------------------------
AC_CHECK_TYPES([struct sockaddr, struct sockaddr_in, AC_CHECK_TYPES([
struct sockaddr_in6, struct sockaddr_un, struct sockaddr_dl, struct sockaddr_dl,
socklen_t, struct vifctl, struct mfcctl, struct sioc_sg_req, struct vifctl, struct mfcctl, struct sioc_sg_req,
vifi_t, struct sioc_vif_req, struct igmpmsg, vifi_t, struct sioc_vif_req, struct igmpmsg,
struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq, struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq,
struct nd_opt_adv_interval, struct rt_addrinfo, struct nd_opt_adv_interval, struct rt_addrinfo,
@ -1449,7 +1327,6 @@ AC_CHECK_TYPES([struct sockaddr, struct sockaddr_in,
AC_CHECK_MEMBERS([struct sockaddr.sa_len, AC_CHECK_MEMBERS([struct sockaddr.sa_len,
struct sockaddr_in.sin_len, struct sockaddr_un.sun_len, struct sockaddr_in.sin_len, struct sockaddr_un.sun_len,
struct sockaddr_in6.sin6_scope_id,
struct sockaddr_dl.sdl_len, struct sockaddr_dl.sdl_len,
struct if6_aliasreq.ifra_lifetime, struct if6_aliasreq.ifra_lifetime,
struct nd_opt_adv_interval.nd_opt_ai_type], struct nd_opt_adv_interval.nd_opt_ai_type],
@ -1535,17 +1412,6 @@ AC_TRY_COMPILE([#include <netinet/in.h>], [
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
]) ])
dnl --------------------------------------
dnl checking for getrusage struct and call
dnl --------------------------------------
if test "${enable_rusage}" != "no"; then
AC_MSG_CHECKING(whether getrusage is available)
AC_TRY_COMPILE([#include <sys/resource.h>],[struct rusage ac_x; getrusage (RUSAGE_SELF, &ac_x);],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_RUSAGE,,rusage)],
AC_MSG_RESULT(no))
fi
dnl -------------------------------------- dnl --------------------------------------
dnl checking for clock_time monotonic struct and call dnl checking for clock_time monotonic struct and call
dnl -------------------------------------- dnl --------------------------------------
@ -1787,10 +1653,3 @@ zebra protobuf enabled : ${have_protobuf:-no}
The above user and group must have read/write access to the state file The above user and group must have read/write access to the state file
directory and to the config files in the config file directory." directory and to the config files in the config file directory."
if test x"$quagga_cv_gnu_make" = x"no"; then echo "
Warning: The ${MAKE-make} programme detected, either in your path or
via the MAKE variable, is not GNU Make. GNU make may be installed as
gmake on some systems. and is required to complete a build of Quagga
" > /dev/stderr
fi

View file

@ -9,7 +9,7 @@ lib_LTLIBRARIES = libzebra.la
libzebra_la_LDFLAGS = -version-info 0:0:0 libzebra_la_LDFLAGS = -version-info 0:0:0
libzebra_la_SOURCES = \ libzebra_la_SOURCES = \
network.c pid_output.c getopt.c getopt1.c daemon.c \ network.c pid_output.c getopt.c getopt1.c \
checksum.c vector.c linklist.c vty.c command.c \ checksum.c vector.c linklist.c vty.c command.c \
sockunion.c prefix.c thread.c if.c buffer.c table.c hash.c \ sockunion.c prefix.c thread.c if.c buffer.c table.c hash.c \
filter.c routemap.c distribute.c stream.c str.c log.c plist.c \ filter.c routemap.c distribute.c stream.c str.c log.c plist.c \
@ -22,9 +22,7 @@ libzebra_la_SOURCES = \
BUILT_SOURCES = route_types.h gitversion.h BUILT_SOURCES = route_types.h gitversion.h
libzebra_la_DEPENDENCIES = @LIB_REGEX@ libzebra_la_LIBADD = @LIBCAP@
libzebra_la_LIBADD = @LIB_REGEX@ @LIBCAP@
pkginclude_HEADERS = \ pkginclude_HEADERS = \
buffer.h checksum.h command.h filter.h getopt.h hash.h \ buffer.h checksum.h command.h filter.h getopt.h hash.h \
@ -43,7 +41,6 @@ noinst_HEADERS = \
plist_int.h plist_int.h
EXTRA_DIST = \ EXTRA_DIST = \
regex.c regex-gnu.h \
queue.h \ queue.h \
route_types.pl route_types.txt \ route_types.pl route_types.txt \
gitversion.pl gitversion.pl

View file

@ -1,81 +0,0 @@
/*
* Daemonize routine
* 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.
*/
#include <zebra.h>
#include <log.h>
#ifndef HAVE_DAEMON
/* Daemonize myself. */
int
daemon (int nochdir, int noclose)
{
pid_t pid;
pid = fork ();
/* In case of fork is error. */
if (pid < 0)
{
zlog_err ("fork failed: %s", safe_strerror(errno));
return -1;
}
/* In case of this is parent process. */
if (pid != 0)
exit (0);
/* Become session leader and get pid. */
pid = setsid();
if (pid == -1)
{
zlog_err ("setsid failed: %s", safe_strerror(errno));
return -1;
}
/* Change directory to root. */
if (! nochdir)
chdir ("/");
/* File descriptor close. */
if (! noclose)
{
int fd;
fd = open ("/dev/null", O_RDWR, 0);
if (fd != -1)
{
dup2 (fd, STDIN_FILENO);
dup2 (fd, STDOUT_FILENO);
dup2 (fd, STDERR_FILENO);
if (fd > 2)
close (fd);
}
}
umask (0027);
return 0;
}
#endif /* HAVE_DAEMON */

View file

@ -1176,30 +1176,6 @@ connected_add_by_prefix (struct interface *ifp, struct prefix *p,
return ifc; return ifc;
} }
#ifndef HAVE_IF_NAMETOINDEX
ifindex_t
if_nametoindex (const char *name)
{
struct interface *ifp;
return ((ifp = if_lookup_by_name_len(name, strnlen(name, IFNAMSIZ))) != NULL)
? ifp->ifindex : 0;
}
#endif
#ifndef HAVE_IF_INDEXTONAME
char *
if_indextoname (ifindex_t ifindex, char *name)
{
struct interface *ifp;
if (!(ifp = if_lookup_by_index(ifindex)))
return NULL;
strncpy (name, ifp->name, IFNAMSIZ);
return ifp->name;
}
#endif
#if 0 /* this route_table of struct connected's is unused #if 0 /* this route_table of struct connected's is unused
* however, it would be good to use a route_table rather than * however, it would be good to use a route_table rather than
* a list.. * a list..

View file

@ -479,13 +479,6 @@ extern struct nbr_connected *nbr_connected_new (void);
extern void nbr_connected_free (struct nbr_connected *); extern void nbr_connected_free (struct nbr_connected *);
struct nbr_connected *nbr_connected_check (struct interface *, struct prefix *); struct nbr_connected *nbr_connected_check (struct interface *, struct prefix *);
#ifndef HAVE_IF_NAMETOINDEX
extern ifindex_t if_nametoindex (const char *);
#endif
#ifndef HAVE_IF_INDEXTONAME
extern char *if_indextoname (ifindex_t, char *);
#endif
/* link parameters */ /* link parameters */
struct if_link_params *if_link_params_get (struct interface *); struct if_link_params *if_link_params_get (struct interface *);
void if_link_params_free (struct interface *); void if_link_params_free (struct interface *);

View file

@ -22,9 +22,9 @@
#include <zebra.h> #include <zebra.h>
/* malloc.h is generally obsolete, however GNU Libc mallinfo wants it. */ /* malloc.h is generally obsolete, however GNU Libc mallinfo wants it. */
#if !defined(HAVE_STDLIB_H) || (defined(GNU_LINUX) && defined(HAVE_MALLINFO)) #if (defined(GNU_LINUX) && defined(HAVE_MALLINFO))
#include <malloc.h> #include <malloc.h>
#endif /* !HAVE_STDLIB_H || HAVE_MALLINFO */ #endif /* HAVE_MALLINFO */
#include "log.h" #include "log.h"
#include "memory.h" #include "memory.h"

View file

@ -27,35 +27,6 @@
#include "network.h" #include "network.h"
#define PIDFILE_MASK 0644 #define PIDFILE_MASK 0644
#ifndef HAVE_FCNTL
pid_t
pid_output (const char *path)
{
FILE *fp;
pid_t pid;
mode_t oldumask;
pid = getpid();
oldumask = umask(0777 & ~PIDFILE_MASK);
fp = fopen (path, "w");
if (fp != NULL)
{
fprintf (fp, "%d\n", (int) pid);
fclose (fp);
umask(oldumask);
return pid;
}
/* XXX Why do we continue instead of exiting? This seems incompatible
with the behavior of the fcntl version below. */
zlog_warn("Can't fopen pid lock file %s (%s), continuing",
path, safe_strerror(errno));
umask(oldumask);
return -1;
}
#else /* HAVE_FCNTL */
pid_t pid_t
pid_output (const char *path) pid_output (const char *path)
@ -107,5 +78,3 @@ pid_output (const char *path)
} }
return pid; return pid;
} }
#endif /* HAVE_FCNTL */

View file

@ -1,542 +0,0 @@
/* Definitions for data structures and routines for the regular
expression library, version 0.12.
Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _REGEX_H
#define _REGEX_H 1
/* Allow the use in C++ code. */
#ifdef __cplusplus
extern "C" {
#endif
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
should be there. */
# include <stddef.h>
#endif
/* The following two types have to be signed and unsigned integer type
wide enough to hold a value of a pointer. For most ANSI compilers
ptrdiff_t and size_t should be likely OK. Still size of these two
types is 2 for Microsoft C. Ugh... */
typedef long int s_reg_t;
typedef unsigned long int active_reg_t;
/* The following bits are used to determine the regexp syntax we
recognize. The set/not-set meanings are chosen so that Emacs syntax
remains the value 0. The bits are given in alphabetical order, and
the definitions shifted by one from the previous bit; thus, when we
add or remove a bit, only one other definition need change. */
typedef unsigned long int reg_syntax_t;
/* If this bit is not set, then \ inside a bracket expression is literal.
If set, then such a \ quotes the following character. */
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
/* If this bit is not set, then + and ? are operators, and \+ and \? are
literals.
If set, then \+ and \? are operators and + and ? are literals. */
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
/* If this bit is set, then character classes are supported. They are:
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
If not set, then character classes are not supported. */
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
/* If this bit is set, then ^ and $ are always anchors (outside bracket
expressions, of course).
If this bit is not set, then it depends:
^ is an anchor if it is at the beginning of a regular
expression or after an open-group or an alternation operator;
$ is an anchor if it is at the end of a regular expression, or
before a close-group or an alternation operator.
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
POSIX draft 11.2 says that * etc. in leading positions is undefined.
We already implemented a previous draft which made those constructs
invalid, though, so we haven't changed the code back. */
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
/* If this bit is set, then special characters are always special
regardless of where they are in the pattern.
If this bit is not set, then special characters are special only in
some contexts; otherwise they are ordinary. Specifically,
* + ? and intervals are only special when not after the beginning,
open-group, or alternation operator. */
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
immediately after an alternation or begin-group operator. */
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
/* If this bit is set, then . matches newline.
If not set, then it doesn't. */
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
/* If this bit is set, then . doesn't match NUL.
If not set, then it does. */
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
/* If this bit is set, nonmatching lists [^...] do not match newline.
If not set, they do. */
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
/* If this bit is set, either \{...\} or {...} defines an
interval, depending on RE_NO_BK_BRACES.
If not set, \{, \}, {, and } are literals. */
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
/* If this bit is set, +, ? and | aren't recognized as operators.
If not set, they are. */
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
/* If this bit is set, newline is an alternation operator.
If not set, newline is literal. */
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
are literals.
If not set, then `\{...\}' defines an interval. */
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
/* If this bit is set, (...) defines a group, and \( and \) are literals.
If not set, \(...\) defines a group, and ( and ) are literals. */
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
/* If this bit is set, then \<digit> matches <digit>.
If not set, then \<digit> is a back-reference. */
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
/* If this bit is set, then | is an alternation operator, and \| is literal.
If not set, then \| is an alternation operator, and | is literal. */
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
/* If this bit is set, then an ending range point collating higher
than the starting range point, as in [z-a], is invalid.
If not set, then when ending range point collates higher than the
starting range point, the range is ignored. */
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
/* If this bit is set, then an unmatched ) is ordinary.
If not set, then an unmatched ) is invalid. */
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
/* If this bit is set, succeed as soon as we match the whole pattern,
without further backtracking. */
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
/* If this bit is set, do not process the GNU regex operators.
If not set, then the GNU regex operators are recognized. */
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
/* If this bit is set, turn on internal regex debugging.
If not set, and debugging was on, turn it off.
This only works if regex.c is compiled -DDEBUG.
We define this bit always, so that all that's needed to turn on
debugging is to recompile regex.c; the calling code can always have
this bit set, and it won't affect anything in the normal case. */
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
/* This global variable defines the particular regexp syntax to use (for
some interfaces). When a regexp is compiled, the syntax used is
stored in the pattern buffer, so changing this does not affect
already-compiled regexps. */
extern reg_syntax_t re_syntax_options;
/* Define combinations of the above bits for the standard possibilities.
(The [[[ comments delimit what gets put into the Texinfo file, so
don't delete them!) */
/* [[[begin syntaxes]]] */
#define RE_SYNTAX_EMACS 0
#define RE_SYNTAX_AWK \
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
#define RE_SYNTAX_GNU_AWK \
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
#define RE_SYNTAX_POSIX_AWK \
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
| RE_INTERVALS | RE_NO_GNU_OPS)
#define RE_SYNTAX_GREP \
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
| RE_NEWLINE_ALT)
#define RE_SYNTAX_EGREP \
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
| RE_NO_BK_VBAR)
#define RE_SYNTAX_POSIX_EGREP \
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
/* Syntax bits common to both basic and extended POSIX regex syntax. */
#define _RE_SYNTAX_POSIX_COMMON \
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
#define RE_SYNTAX_POSIX_BASIC \
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
isn't minimal, since other operators, such as \`, aren't disabled. */
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
#define RE_SYNTAX_POSIX_EXTENDED \
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
| RE_UNMATCHED_RIGHT_PAREN_ORD)
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
/* [[[end syntaxes]]] */
/* Maximum number of duplicates an interval can allow. Some systems
(erroneously) define this in other header files, but we want our
value, so remove any previous define. */
#ifdef RE_DUP_MAX
# undef RE_DUP_MAX
#endif
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
#define RE_DUP_MAX (0x7fff)
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
/* If this bit is set, then use extended regular expression syntax.
If not set, then use basic regular expression syntax. */
#define REG_EXTENDED 1
/* If this bit is set, then ignore case when matching.
If not set, then case is significant. */
#define REG_ICASE (REG_EXTENDED << 1)
/* If this bit is set, then anchors do not match at newline
characters in the string.
If not set, then anchors do match at newlines. */
#define REG_NEWLINE (REG_ICASE << 1)
/* If this bit is set, then report only success or fail in regexec.
If not set, then returns differ between not matching and errors. */
#define REG_NOSUB (REG_NEWLINE << 1)
/* POSIX `eflags' bits (i.e., information for regexec). */
/* If this bit is set, then the beginning-of-line operator doesn't match
the beginning of the string (presumably because it's not the
beginning of a line).
If not set, then the beginning-of-line operator does match the
beginning of the string. */
#define REG_NOTBOL 1
/* Like REG_NOTBOL, except for the end-of-line. */
#define REG_NOTEOL (1 << 1)
/* If any error codes are removed, changed, or added, update the
`re_error_msg' table in regex.c. */
typedef enum
{
#ifdef _XOPEN_SOURCE
REG_ENOSYS = -1, /* This will never happen for this implementation. */
#endif
REG_NOERROR = 0, /* Success. */
REG_NOMATCH, /* Didn't find a match (for regexec). */
/* POSIX regcomp return error codes. (In the order listed in the
standard.) */
REG_BADPAT, /* Invalid pattern. */
REG_ECOLLATE, /* Not implemented. */
REG_ECTYPE, /* Invalid character class name. */
REG_EESCAPE, /* Trailing backslash. */
REG_ESUBREG, /* Invalid back reference. */
REG_EBRACK, /* Unmatched left bracket. */
REG_EPAREN, /* Parenthesis imbalance. */
REG_EBRACE, /* Unmatched \{. */
REG_BADBR, /* Invalid contents of \{\}. */
REG_ERANGE, /* Invalid range end. */
REG_ESPACE, /* Ran out of memory. */
REG_BADRPT, /* No preceding re for repetition op. */
/* Error codes we've added. */
REG_EEND, /* Premature end. */
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
} reg_errcode_t;
/* This data structure represents a compiled pattern. Before calling
the pattern compiler, the fields `buffer', `allocated', `fastmap',
`translate', and `no_sub' can be set. After the pattern has been
compiled, the `re_nsub' field is available. All other fields are
private to the regex routines. */
#ifndef RE_TRANSLATE_TYPE
# define RE_TRANSLATE_TYPE char *
#endif
struct re_pattern_buffer
{
/* [[[begin pattern_buffer]]] */
/* Space that holds the compiled pattern. It is declared as
`unsigned char *' because its elements are
sometimes used as array indexes. */
unsigned char *buffer;
/* Number of bytes to which `buffer' points. */
unsigned long int allocated;
/* Number of bytes actually used in `buffer'. */
unsigned long int used;
/* Syntax setting with which the pattern was compiled. */
reg_syntax_t syntax;
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
the fastmap, if there is one, to skip over impossible
starting points for matches. */
char *fastmap;
/* Either a translate table to apply to all characters before
comparing them, or zero for no translation. The translation
is applied to a pattern when it is compiled and to a string
when it is matched. */
RE_TRANSLATE_TYPE translate;
/* Number of subexpressions found by the compiler. */
size_t re_nsub;
/* Zero if this pattern cannot match the empty string, one else.
Well, in truth it's used only in `re_search_2', to see
whether or not we should use the fastmap, so we don't set
this absolutely perfectly; see `re_compile_fastmap' (the
`duplicate' case). */
unsigned can_be_null : 1;
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
for `max (RE_NREGS, re_nsub + 1)' groups.
If REGS_REALLOCATE, reallocate space if necessary.
If REGS_FIXED, use what's there. */
#define REGS_UNALLOCATED 0
#define REGS_REALLOCATE 1
#define REGS_FIXED 2
unsigned regs_allocated : 2;
/* Set to zero when `regex_compile' compiles a pattern; set to one
by `re_compile_fastmap' if it updates the fastmap. */
unsigned fastmap_accurate : 1;
/* If set, `re_match_2' does not return information about
subexpressions. */
unsigned no_sub : 1;
/* If set, a beginning-of-line anchor doesn't match at the
beginning of the string. */
unsigned not_bol : 1;
/* Similarly for an end-of-line anchor. */
unsigned not_eol : 1;
/* If true, an anchor at a newline matches. */
unsigned newline_anchor : 1;
/* [[[end pattern_buffer]]] */
};
typedef struct re_pattern_buffer regex_t;
/* Type for byte offsets within the string. POSIX mandates this. */
typedef int regoff_t;
/* This is the structure we store register match data in. See
regex.texinfo for a full description of what registers match. */
struct re_registers
{
unsigned num_regs;
regoff_t *start;
regoff_t *end;
};
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
`re_match_2' returns information about at least this many registers
the first time a `regs' structure is passed. */
#ifndef RE_NREGS
# define RE_NREGS 30
#endif
/* POSIX specification for registers. Aside from the different names than
`re_registers', POSIX uses an array of structures, instead of a
structure of arrays. */
typedef struct
{
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
} regmatch_t;
/* Declarations for routines. */
/* To avoid duplicating every routine declaration -- once with a
prototype (if we are ANSI), and once without (if we aren't) -- we
use the following macro to declare argument types. This
unfortunately clutters up the declarations a bit, but I think it's
worth it. */
#if __STDC__
# define _RE_ARGS(args) args
#else /* not __STDC__ */
# define _RE_ARGS(args) ()
#endif /* not __STDC__ */
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the `re_syntax_options' variable. */
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
/* Compile the regular expression PATTERN, with length LENGTH
and syntax given by the global `re_syntax_options', into the buffer
BUFFER. Return NULL if successful, and an error string if not. */
extern const char *re_compile_pattern
_RE_ARGS ((const char *pattern, size_t length,
struct re_pattern_buffer *buffer));
/* 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));
/* Search in the string STRING (with length LENGTH) for the pattern
compiled into BUFFER. Start searching at position START, for RANGE
characters. Return the starting position of the match, -1 for no
match, or -2 for an internal error. Also return register
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
extern int re_search
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, int range, struct re_registers *regs));
/* Like `re_search', but search in the concatenation of STRING1 and
STRING2. Also, stop searching at index START + STOP. */
extern int re_search_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, int range, struct re_registers *regs, int stop));
/* Like `re_search', but return how many characters in STRING the regexp
in BUFFER matched, starting at position START. */
extern int re_match
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
int length, int start, struct re_registers *regs));
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
extern int re_match_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, struct re_registers *regs, int stop));
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
ENDS. Subsequent matches using BUFFER and REGS will use this memory
for recording register information. STARTS and ENDS must be
allocated with malloc, and must each be at least `NUM_REGS * sizeof
(regoff_t)' bytes long.
If NUM_REGS == 0, then subsequent matches should allocate their own
register data.
Unless this function is called, the first search or match using
PATTERN_BUFFER will allocate its own register data, without
freeing the old data. */
extern void re_set_registers
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
unsigned num_regs, regoff_t *starts, regoff_t *ends));
#if defined _REGEX_RE_COMP || defined _LIBC
# ifndef _CRAY
/* 4.2 bsd compatibility. */
extern char *re_comp _RE_ARGS ((const char *));
extern int re_exec _RE_ARGS ((const char *));
# endif
#endif
/* POSIX compatibility. */
extern int regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
int __cflags));
extern int regexec _RE_ARGS ((const regex_t *__preg,
const char *__string, size_t __nmatch,
regmatch_t __pmatch[], int __eflags));
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
char *__errbuf, size_t __errbuf_size));
extern void regfree _RE_ARGS ((regex_t *__preg));
#ifdef __cplusplus
}
#endif /* C++ */
#endif /* regex.h */
/*
Local variables:
make-backup-files: t
version-control: t
trim-versions-without-asking: nil
End:
*/

File diff suppressed because it is too large Load diff

View file

@ -31,93 +31,6 @@
DEFINE_MTYPE_STATIC(LIB, SOCKUNION, "Socket union") DEFINE_MTYPE_STATIC(LIB, SOCKUNION, "Socket union")
#ifndef HAVE_INET_ATON
int
inet_aton (const char *cp, struct in_addr *inaddr)
{
int dots = 0;
register u_long addr = 0;
register u_long val = 0, base = 10;
do
{
register char c = *cp;
switch (c)
{
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 '.':
if (++dots > 3)
return 0;
case '\0':
if (val > 255)
return 0;
addr = addr << 8 | val;
val = 0;
break;
default:
return 0;
}
} while (*cp++) ;
if (dots < 3)
addr <<= 8 * (3 - dots);
if (inaddr)
inaddr->s_addr = htonl (addr);
return 1;
}
#endif /* ! HAVE_INET_ATON */
#ifndef HAVE_INET_PTON
int
inet_pton (int family, const char *strptr, void *addrptr)
{
if (family == AF_INET)
{
struct in_addr in_val;
if (inet_aton (strptr, &in_val))
{
memcpy (addrptr, &in_val, sizeof (struct in_addr));
return 1;
}
return 0;
}
errno = EAFNOSUPPORT;
return -1;
}
#endif /* ! HAVE_INET_PTON */
#ifndef HAVE_INET_NTOP
const char *
inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
{
unsigned char *p = (unsigned char *) addrptr;
if (family == AF_INET)
{
char temp[INET_ADDRSTRLEN];
snprintf(temp, sizeof(temp), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
if (strlen(temp) >= len)
{
errno = ENOSPC;
return NULL;
}
strcpy(strptr, temp);
return strptr;
}
errno = EAFNOSUPPORT;
return NULL;
}
#endif /* ! HAVE_INET_NTOP */
const char * const char *
inet_sutop (const union sockunion *su, char *str) inet_sutop (const union sockunion *su, char *str)
{ {
@ -312,9 +225,7 @@ sockunion_connect (int fd, const union sockunion *peersu, unsigned short port,
#ifdef KAME #ifdef KAME
if (IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr) && ifindex) if (IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr) && ifindex)
{ {
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
su.sin6.sin6_scope_id = ifindex; su.sin6.sin6_scope_id = ifindex;
#endif /* HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID */
SET_IN6_LINKLOCAL_IFINDEX (su.sin6.sin6_addr, ifindex); SET_IN6_LINKLOCAL_IFINDEX (su.sin6.sin6_addr, ifindex);
} }
#endif /* KAME */ #endif /* KAME */

View file

@ -109,17 +109,4 @@ extern union sockunion *sockunion_dup (const union sockunion *);
extern void sockunion_free (union sockunion *); extern void sockunion_free (union sockunion *);
extern void sockunion_init (union sockunion *); extern void sockunion_init (union sockunion *);
#ifndef HAVE_INET_NTOP
extern const char * inet_ntop (int family, const void *addrptr,
char *strptr, size_t len);
#endif /* HAVE_INET_NTOP */
#ifndef HAVE_INET_PTON
extern int inet_pton (int family, const char *strptr, void *addrptr);
#endif /* HAVE_INET_PTON */
#ifndef HAVE_INET_ATON
extern int inet_aton (const char *cp, struct in_addr *inaddr);
#endif
#endif /* _ZEBRA_SOCKUNION_H */ #endif /* _ZEBRA_SOCKUNION_H */

View file

@ -37,22 +37,6 @@
#include <zebra.h> #include <zebra.h>
#ifndef HAVE_SNPRINTF
/*
* snprint() is a real basic wrapper around the standard sprintf()
* without any bounds checking
*/
int
snprintf(char *str, size_t size, const char *format, ...)
{
va_list args;
va_start (args, format);
return vsprintf (str, format, args);
}
#endif
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
/* /*
* Copy string src to buffer dst of size dsize. At most dsize-1 * Copy string src to buffer dst of size dsize. At most dsize-1
@ -109,27 +93,3 @@ strlcat(char *d, const char *s, size_t bufsize)
return ret; return ret;
} }
#endif #endif
#ifndef HAVE_STRNLEN
size_t
strnlen(const char *s, size_t maxlen)
{
const char *p;
return (p = (const char *)memchr(s, '\0', maxlen)) ? (size_t)(p-s) : maxlen;
}
#endif
#ifndef HAVE_STRNDUP
char *
strndup (const char *s, size_t maxlen)
{
size_t len = strnlen (s, maxlen);
char *new = (char *) malloc (len + 1);
if (new == NULL)
return NULL;
new[len] = '\0';
return (char *) memcpy (new, s, len);
}
#endif

View file

@ -5,14 +5,6 @@
#ifndef _ZEBRA_STR_H #ifndef _ZEBRA_STR_H
#define _ZEBRA_STR_H #define _ZEBRA_STR_H
#ifndef HAVE_SNPRINTF
extern int snprintf(char *, size_t, const char *, ...);
#endif
#ifndef HAVE_VSNPRINTF
#define vsnprintf(buf, size, format, args) vsprintf(buf, format, args)
#endif
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
extern size_t strlcpy(char *, const char *, size_t); extern size_t strlcpy(char *, const char *, size_t);
#endif #endif
@ -21,13 +13,5 @@ extern size_t strlcpy(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t);
#endif #endif
#ifndef HAVE_STRNLEN
extern size_t strnlen(const char *s, size_t maxlen);
#endif
#ifndef HAVE_STRNDUP
extern char * strndup (const char *, size_t);
#endif
#endif /* _ZEBRA_STR_H */ #endif /* _ZEBRA_STR_H */

View file

@ -221,16 +221,10 @@ static void
vty_out_cpu_thread_history(struct vty* vty, vty_out_cpu_thread_history(struct vty* vty,
struct cpu_thread_history *a) struct cpu_thread_history *a)
{ {
#ifdef HAVE_RUSAGE
vty_out(vty, "%10ld.%03ld %9d %8ld %9ld %8ld %9ld", vty_out(vty, "%10ld.%03ld %9d %8ld %9ld %8ld %9ld",
a->cpu.total/1000, a->cpu.total%1000, a->total_calls, a->cpu.total/1000, a->cpu.total%1000, a->total_calls,
a->cpu.total/a->total_calls, a->cpu.max, a->cpu.total/a->total_calls, a->cpu.max,
a->real.total/a->total_calls, a->real.max); a->real.total/a->total_calls, a->real.max);
#else
vty_out(vty, "%10ld.%03ld %9d %8ld %9ld",
a->real.total/1000, a->real.total%1000, a->total_calls,
a->real.total/a->total_calls, a->real.max);
#endif
vty_out(vty, " %c%c%c%c%c%c %s%s", vty_out(vty, " %c%c%c%c%c%c %s%s",
a->types & (1 << THREAD_READ) ? 'R':' ', a->types & (1 << THREAD_READ) ? 'R':' ',
a->types & (1 << THREAD_WRITE) ? 'W':' ', a->types & (1 << THREAD_WRITE) ? 'W':' ',
@ -257,11 +251,9 @@ cpu_record_hash_print(struct hash_backet *bucket,
totals->real.total += a->real.total; totals->real.total += a->real.total;
if (totals->real.max < a->real.max) if (totals->real.max < a->real.max)
totals->real.max = a->real.max; totals->real.max = a->real.max;
#ifdef HAVE_RUSAGE
totals->cpu.total += a->cpu.total; totals->cpu.total += a->cpu.total;
if (totals->cpu.max < a->cpu.max) if (totals->cpu.max < a->cpu.max)
totals->cpu.max = a->cpu.max; totals->cpu.max = a->cpu.max;
#endif
} }
static void static void
@ -274,14 +266,10 @@ cpu_record_print(struct vty *vty, thread_type filter)
tmp.funcname = "TOTAL"; tmp.funcname = "TOTAL";
tmp.types = filter; tmp.types = filter;
#ifdef HAVE_RUSAGE
vty_out(vty, "%21s %18s %18s%s", vty_out(vty, "%21s %18s %18s%s",
"", "CPU (user+system):", "Real (wall-clock):", VTY_NEWLINE); "", "CPU (user+system):", "Real (wall-clock):", VTY_NEWLINE);
#endif
vty_out(vty, " Runtime(ms) Invoked Avg uSec Max uSecs"); vty_out(vty, " Runtime(ms) Invoked Avg uSec Max uSecs");
#ifdef HAVE_RUSAGE
vty_out(vty, " Avg uSec Max uSecs"); vty_out(vty, " Avg uSec Max uSecs");
#endif
vty_out(vty, " Type Thread%s", VTY_NEWLINE); vty_out(vty, " Type Thread%s", VTY_NEWLINE);
hash_iterate(cpu_record, hash_iterate(cpu_record,
(void(*)(struct hash_backet*,void*))cpu_record_hash_print, (void(*)(struct hash_backet*,void*))cpu_record_hash_print,
@ -1373,13 +1361,9 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
unsigned long 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. */ /* This is 'user + sys' time. */
*cputime = timeval_elapsed (now->cpu.ru_utime, start->cpu.ru_utime) + *cputime = timeval_elapsed (now->cpu.ru_utime, start->cpu.ru_utime) +
timeval_elapsed (now->cpu.ru_stime, start->cpu.ru_stime); timeval_elapsed (now->cpu.ru_stime, start->cpu.ru_stime);
#else
*cputime = 0;
#endif /* HAVE_RUSAGE */
return timeval_elapsed (now->real, start->real); return timeval_elapsed (now->real, start->real);
} }
@ -1411,9 +1395,7 @@ void
thread_getrusage (RUSAGE_T *r) thread_getrusage (RUSAGE_T *r)
{ {
quagga_get_relative (NULL); quagga_get_relative (NULL);
#ifdef HAVE_RUSAGE
getrusage(RUSAGE_SELF, &(r->cpu)); getrusage(RUSAGE_SELF, &(r->cpu));
#endif
r->real = relative_time; r->real = relative_time;
#ifdef HAVE_CLOCK_MONOTONIC #ifdef HAVE_CLOCK_MONOTONIC
@ -1466,11 +1448,9 @@ thread_call (struct thread *thread)
thread->hist->real.total += realtime; thread->hist->real.total += realtime;
if (thread->hist->real.max < realtime) if (thread->hist->real.max < realtime)
thread->hist->real.max = realtime; thread->hist->real.max = realtime;
#ifdef HAVE_RUSAGE
thread->hist->cpu.total += cputime; thread->hist->cpu.total += cputime;
if (thread->hist->cpu.max < cputime) if (thread->hist->cpu.max < cputime)
thread->hist->cpu.max = cputime; thread->hist->cpu.max = cputime;
#endif
++(thread->hist->total_calls); ++(thread->hist->total_calls);
thread->hist->types |= (1 << thread->add_type); thread->hist->types |= (1 << thread->add_type);

View file

@ -26,9 +26,7 @@
struct rusage_t struct rusage_t
{ {
#ifdef HAVE_RUSAGE
struct rusage cpu; struct rusage cpu;
#endif
struct timeval real; struct timeval real;
}; };
#define RUSAGE_T struct rusage_t #define RUSAGE_T struct rusage_t
@ -121,9 +119,7 @@ struct cpu_thread_history
{ {
unsigned long total, max; unsigned long total, max;
} real; } real;
#ifdef HAVE_RUSAGE
struct time_stats cpu; struct time_stats cpu;
#endif
thread_type types; thread_type types;
const char *funcname; const char *funcname;
}; };

View file

@ -49,8 +49,4 @@
pid_t pid_output (const char *); pid_t pid_output (const char *);
#ifndef HAVE_DAEMON
int daemon(int, int);
#endif
#endif /* _ZEBRA_VERSION_H */ #endif /* _ZEBRA_VERSION_H */

View file

@ -32,10 +32,6 @@ typedef unsigned short u_int16_t;
typedef unsigned char u_int8_t; typedef unsigned char u_int8_t;
#endif /* SUNOS_5 */ #endif /* SUNOS_5 */
#ifndef HAVE_SOCKLEN_T
typedef int socklen_t;
#endif /* HAVE_SOCKLEN_T */
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -50,9 +46,7 @@ typedef int socklen_t;
#ifdef HAVE_STROPTS_H #ifdef HAVE_STROPTS_H
#include <stropts.h> #include <stropts.h>
#endif /* HAVE_STROPTS_H */ #endif /* HAVE_STROPTS_H */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h> #include <sys/select.h>
#endif /* HAVE_SYS_SELECT_H */
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -70,30 +64,14 @@ typedef int socklen_t;
#include <sys/ksym.h> #include <sys/ksym.h>
#endif /* HAVE_SYS_KSYM_H */ #endif /* HAVE_SYS_KSYM_H */
#include <syslog.h> #include <syslog.h>
#ifdef TIME_WITH_SYS_TIME #include <sys/time.h>
# include <sys/time.h> #include <time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif /* TIME_WITH_SYS_TIME */
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#ifdef HAVE_RUSAGE
#include <sys/resource.h> #include <sys/resource.h>
#endif /* HAVE_RUSAGE */
#ifdef HAVE_LIMITS_H
#include <limits.h> #include <limits.h>
#endif /* HAVE_LIMITS_H */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h> #include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#ifdef HAVE_STDBOOL_H
#include <stdbool.h> #include <stdbool.h>
#endif
/* machine dependent includes */ /* machine dependent includes */
#ifdef SUNOS_5 #ifdef SUNOS_5
@ -148,9 +126,7 @@ typedef int socklen_t;
#define __APPLE_USE_RFC_3542 #define __APPLE_USE_RFC_3542
#endif #endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */
#include <netinet/in_systm.h> #include <netinet/in_systm.h>
#include <netinet/ip.h> #include <netinet/ip.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
@ -169,9 +145,7 @@ typedef int socklen_t;
#include <net/if_var.h> #include <net/if_var.h>
#endif /* HAVE_NET_IF_VAR_H */ #endif /* HAVE_NET_IF_VAR_H */
#ifdef HAVE_NET_ROUTE_H
#include <net/route.h> #include <net/route.h>
#endif /* HAVE_NET_ROUTE_H */
#ifdef HAVE_NETLINK #ifdef HAVE_NETLINK
#include <linux/netlink.h> #include <linux/netlink.h>
@ -181,10 +155,7 @@ typedef int socklen_t;
#define RT_TABLE_MAIN 0 #define RT_TABLE_MAIN 0
#endif /* HAVE_NETLINK */ #endif /* HAVE_NETLINK */
#ifdef HAVE_NETDB_H
#include <netdb.h> #include <netdb.h>
#endif /* HAVE_NETDB_H */
#include <arpa/inet.h> #include <arpa/inet.h>
#ifdef HAVE_INET_ND_H #ifdef HAVE_INET_ND_H
@ -212,9 +183,7 @@ typedef int socklen_t;
#include <netinet6/ip6.h> #include <netinet6/ip6.h>
#endif /* HAVE_NETINET6_IP6_H */ #endif /* HAVE_NETINET6_IP6_H */
#ifdef HAVE_NETINET_ICMP6_H
#include <netinet/icmp6.h> #include <netinet/icmp6.h>
#endif /* HAVE_NETINET_ICMP6_H */
#ifdef HAVE_NETINET6_ND6_H #ifdef HAVE_NETINET6_ND6_H
#include <netinet6/nd6.h> #include <netinet6/nd6.h>

View file

@ -226,9 +226,7 @@ ospf6_sendmsg (struct in6_addr *src, struct in6_addr *dst,
dst_sin6.sin6_len = sizeof (struct sockaddr_in6); dst_sin6.sin6_len = sizeof (struct sockaddr_in6);
#endif /*SIN6_LEN*/ #endif /*SIN6_LEN*/
memcpy (&dst_sin6.sin6_addr, dst, sizeof (struct in6_addr)); memcpy (&dst_sin6.sin6_addr, dst, sizeof (struct in6_addr));
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
dst_sin6.sin6_scope_id = *ifindex; dst_sin6.sin6_scope_id = *ifindex;
#endif
/* send control msg */ /* send control msg */
scmsgp->cmsg_level = IPPROTO_IPV6; scmsgp->cmsg_level = IPPROTO_IPV6;

View file

@ -29,10 +29,6 @@
#include "if.h" #include "if.h"
#include "linklist.h" #include "linklist.h"
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#define PIM_MSG_OPTION_TYPE_HOLDTIME (1) #define PIM_MSG_OPTION_TYPE_HOLDTIME (1)
#define PIM_MSG_OPTION_TYPE_LAN_PRUNE_DELAY (2) #define PIM_MSG_OPTION_TYPE_LAN_PRUNE_DELAY (2)
#define PIM_MSG_OPTION_TYPE_DR_PRIORITY (19) #define PIM_MSG_OPTION_TYPE_DR_PRIORITY (19)

View file

@ -36,6 +36,8 @@
#include "zebra/interface.h" #include "zebra/interface.h"
#include "zebra/rib.h" #include "zebra/rib.h"
#include <ifaddrs.h>
/* Interface looking up using infamous SIOCGIFCONF. */ /* Interface looking up using infamous SIOCGIFCONF. */
static int static int
interface_list_ioctl (void) interface_list_ioctl (void)
@ -138,44 +140,7 @@ interface_list_ioctl (void)
static int static int
if_get_index (struct interface *ifp) if_get_index (struct interface *ifp)
{ {
#if defined(HAVE_IF_NAMETOINDEX)
/* Modern systems should have if_nametoindex(3). */
ifp->ifindex = if_nametoindex(ifp->name); ifp->ifindex = if_nametoindex(ifp->name);
#elif defined(SIOCGIFINDEX) && !defined(HAVE_BROKEN_ALIASES)
/* Fall-back for older linuxes. */
int ret;
struct ifreq ifreq;
static int if_fake_index;
ifreq_set_name (&ifreq, ifp);
ret = if_ioctl (SIOCGIFINDEX, (caddr_t) &ifreq);
if (ret < 0)
{
/* Linux 2.0.X does not have interface index. */
ifp->ifindex = if_fake_index++;
return ifp->ifindex;
}
/* OK we got interface index. */
#ifdef ifr_ifindex
ifp->ifindex = ifreq.ifr_ifindex;
#else
ifp->ifindex = ifreq.ifr_index;
#endif
#else
/* Linux 2.2.X does not provide individual interface index
for aliases and we know it. For others issue a warning. */
#if !defined(HAVE_BROKEN_ALIASES)
#warning "Using if_fake_index. You may want to add appropriate"
#warning "mapping from ifname to ifindex for your system..."
#endif
/* This branch probably won't provide usable results, but anyway... */
static int if_fake_index = 1;
ifp->ifindex = if_fake_index++;
#endif
return ifp->ifindex; return ifp->ifindex;
} }
@ -211,9 +176,6 @@ if_get_hwaddr (struct interface *ifp)
} }
#endif /* SIOCGIFHWADDR */ #endif /* SIOCGIFHWADDR */
#ifdef HAVE_GETIFADDRS
#include <ifaddrs.h>
static int static int
if_getaddrs (void) if_getaddrs (void)
{ {
@ -334,93 +296,6 @@ if_getaddrs (void)
return 0; return 0;
} }
#else /* HAVE_GETIFADDRS */
/* Interface address lookup by ioctl. This function only looks up
IPv4 address. */
int
if_get_addr (struct interface *ifp)
{
int ret;
struct ifreq ifreq;
struct sockaddr_in addr;
struct sockaddr_in mask;
struct sockaddr_in dest;
struct in_addr *dest_pnt;
u_char prefixlen;
int flags = 0;
/* Interface's name and address family. */
strncpy (ifreq.ifr_name, ifp->name, IFNAMSIZ);
ifreq.ifr_addr.sa_family = AF_INET;
/* Interface's address. */
ret = if_ioctl (SIOCGIFADDR, (caddr_t) &ifreq);
if (ret < 0)
{
if (errno != EADDRNOTAVAIL)
{
zlog_warn ("SIOCGIFADDR fail: %s", safe_strerror (errno));
return ret;
}
return 0;
}
memcpy (&addr, &ifreq.ifr_addr, sizeof (struct sockaddr_in));
/* Interface's network mask. */
ret = if_ioctl (SIOCGIFNETMASK, (caddr_t) &ifreq);
if (ret < 0)
{
if (errno != EADDRNOTAVAIL)
{
zlog_warn ("SIOCGIFNETMASK fail: %s", safe_strerror (errno));
return ret;
}
return 0;
}
#ifdef ifr_netmask
memcpy (&mask, &ifreq.ifr_netmask, sizeof (struct sockaddr_in));
#else
memcpy (&mask, &ifreq.ifr_addr, sizeof (struct sockaddr_in));
#endif /* ifr_netmask */
prefixlen = ip_masklen (mask.sin_addr);
/* Point to point or borad cast address pointer init. */
dest_pnt = NULL;
ret = if_ioctl (SIOCGIFDSTADDR, (caddr_t) &ifreq);
if (ret < 0)
{
if (errno != EADDRNOTAVAIL)
zlog_warn ("SIOCGIFDSTADDR fail: %s", safe_strerror (errno));
}
else if (!IPV4_ADDR_SAME(&addr.sin_addr, &ifreq.ifr_dstaddr.sin_addr))
{
memcpy (&dest, &ifreq.ifr_dstaddr, sizeof (struct sockaddr_in));
dest_pnt = &dest.sin_addr;
flags = ZEBRA_IFA_PEER;
}
if (!dest_pnt)
{
ret = if_ioctl (SIOCGIFBRDADDR, (caddr_t) &ifreq);
if (ret < 0)
{
if (errno != EADDRNOTAVAIL)
zlog_warn ("SIOCGIFBRDADDR fail: %s", safe_strerror (errno));
}
else if (!IPV4_ADDR_SAME(&addr.sin_addr, &ifreq.ifr_broadaddr.sin_addr))
{
memcpy (&dest, &ifreq.ifr_broadaddr, sizeof (struct sockaddr_in));
dest_pnt = &dest.sin_addr;
}
}
/* Set address to the interface. */
connected_add_ipv4 (ifp, flags, &addr.sin_addr, prefixlen, dest_pnt, NULL);
return 0;
}
#endif /* HAVE_GETIFADDRS */
/* Fetch interface information via ioctl(). */ /* Fetch interface information via ioctl(). */
static void static void
@ -436,9 +311,6 @@ interface_info_ioctl ()
if_get_hwaddr (ifp); if_get_hwaddr (ifp);
#endif /* SIOCGIFHWADDR */ #endif /* SIOCGIFHWADDR */
if_get_flags (ifp); if_get_flags (ifp);
#ifndef HAVE_GETIFADDRS
if_get_addr (ifp);
#endif /* ! HAVE_GETIFADDRS */
if_get_mtu (ifp); if_get_mtu (ifp);
if_get_metric (ifp); if_get_metric (ifp);
} }
@ -462,9 +334,7 @@ interface_list (struct zebra_ns *zns)
interface's information. */ interface's information. */
interface_info_ioctl (); interface_info_ioctl ();
#ifdef HAVE_GETIFADDRS
if_getaddrs (); if_getaddrs ();
#endif /* HAVE_GETIFADDRS */
#if defined(HAVE_IPV6) && defined(HAVE_PROC_NET_IF_INET6) #if defined(HAVE_IPV6) && defined(HAVE_PROC_NET_IF_INET6)
/* Linux provides interface's IPv6 address via /* Linux provides interface's IPv6 address via