[prev in list] [next in list] [prev in thread] [next in thread]
List: zebra
Subject: [zebra 149] htonl
From: Magnus Ahltorp <map () stacken ! kth ! se>
Date: 1998-10-20 1:55:31
[Download RAW message or body]
When compiling without -O2 on a linux 2.1.x kernel, htonl and friends
are not defined properly. We have "solved" this in arla by detecting
this and applying some workaround defines. I have created a file
called roken.h (the name roken comes from the libroken package) which
contains the defines. This is a good place to place workarounds for
broken systems.
This is the best solution I can think of, since the Linux people have
done optimization dependent #ifdefs.
Index: acconfig.h
===================================================================
RCS file: /usr/local/cvsroot/alpha/acconfig.h,v
retrieving revision 1.5
diff -u -r1.5 acconfig.h
--- acconfig.h 1998/09/15 09:50:22 1.5
+++ acconfig.h 1998/10/20 01:49:21
@@ -46,6 +46,9 @@
/* Define if you have Linux ipv6 stack. */
#undef LINUX_IPV6
+/* Define this if htnol is broken, but can be fixed with define magic */
+#undef HAVE_REPAIRABLE_HTONL
+
/* PATHS */
#undef PATH_ZEBRA_PID
#undef PATH_RIPD_PID
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/alpha/configure.in,v
retrieving revision 1.58
diff -u -r1.58 configure.in
--- configure.in 1998/10/14 08:55:57 1.58
+++ configure.in 1998/10/20 01:49:23
@@ -34,7 +36,7 @@
dnl -------------------
dnl Check header files.
dnl -------------------
-AC_CHECK_HEADERS(string.h sys/time.h sys/times.h sys/select.h sys/sysctl.h sys/
sockio.h net/if_dl.h linux/version.h kvm.h)
+AC_CHECK_HEADERS(string.h sys/time.h sys/times.h sys/select.h sys/sysctl.h sys/
sockio.h sys/types.h net/if_dl.h linux/version.h kvm.h netdb.h netinet/in.h)
dnl check some types
AC_C_CONST
@@ -303,6 +305,51 @@
AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$ac_piddir/ripngd.pid")
AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$ac_piddir/bgpd.pid")
AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$ac_piddir/ospfd.pid")
+
+AC_MSG_CHECKING(for working htonl)
+AC_CACHE_VAL(ac_cv_htonl_works, [
+AC_TRY_LINK([#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+],
+[htonl(0);],
+ac_cv_htonl_works=yes,
+ac_cv_htonl_works=no)])
+AC_MSG_RESULT($ac_cv_htonl_works)
+
+if test "$ac_cv_htonl_works" = "no"; then
+AC_MSG_CHECKING(if htonl is repairable)
+AC_CACHE_VAL(ac_cv_htonl_hack_works, [
+AC_TRY_LINK(
+[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#define htonl(x) __cpu_to_be32(x)
+],
+[htonl(0);],
+ac_cv_htonl_hack_works=yes,
+ac_cv_htonl_hack_works=no)])
+AC_MSG_RESULT($ac_cv_htonl_hack_works)
+
+if test "$ac_cv_htonl_hack_works" = "no"; then
+AC_MSG_ERROR([Cannot repair htonl])
+else
+AC_DEFINE(HAVE_REPAIRABLE_HTONL)
+fi
+
+fi
AC_OUTPUT(Makefile lib/Makefile zebra/Makefile ripd/Makefile ripngd/Makefile bg
pd/Makefile doc/Makefile)
Index: bgpd/bgp_aspath.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/bgpd/bgp_aspath.c,v
retrieving revision 1.50
diff -u -r1.50 bgp_aspath.c
--- bgp_aspath.c 1998/05/19 04:02:41 1.50
+++ bgp_aspath.c 1998/10/20 01:49:25
@@ -37,6 +37,8 @@
#include "memory.h"
#include "log.h"
+#include <roken.h>
+
/* To fetch and store as segment value. */
struct assegment
{
Index: bgpd/bgp_attr.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/bgpd/bgp_attr.c,v
retrieving revision 1.53
diff -u -r1.53 bgp_attr.c
--- bgp_attr.c 1998/09/01 12:42:02 1.53
+++ bgp_attr.c 1998/10/20 01:49:26
@@ -44,6 +44,8 @@
#include "memory.h"
#include "buffer.h"
+#include <roken.h>
+
/* Attribute string for logging. */
message attr_str [] = {
{ BGP_ATTR_ORIGIN, "ORIGIN" },
Index: bgpd/bgp_community.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/bgpd/bgp_community.c,v
retrieving revision 1.6
diff -u -r1.6 bgp_community.c
--- bgp_community.c 1998/04/30 22:12:28 1.6
+++ bgp_community.c 1998/10/20 01:49:26
@@ -33,6 +33,8 @@
#include "hash.h"
#include "memory.h"
+#include <roken.h>
+
/* Hash of community attribute. */
struct Hash *comhash;
Index: bgpd/bgp_open.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/bgpd/bgp_open.c,v
retrieving revision 1.8
diff -u -r1.8 bgp_open.c
--- bgp_open.c 1998/10/16 01:54:00 1.8
+++ bgp_open.c 1998/10/20 01:49:26
@@ -28,6 +28,8 @@
#include "bgpd.h"
#include "bgp_peer.h"
+#include <roken.h>
+
void capability_parse (caddr_t *pnt, u_char length);
/* Parse open option */
Index: bgpd/bgp_zebra.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/bgpd/bgp_zebra.c,v
retrieving revision 1.9
diff -u -r1.9 bgp_zebra.c
--- bgp_zebra.c 1998/08/18 13:25:09 1.9
+++ bgp_zebra.c 1998/10/20 01:49:26
@@ -34,6 +34,8 @@
#include "zebra.h"
#include "buffer.h"
+#include <roken.h>
+
/* Socket to communicate with zebra daemon */
static zebra_socket;
Index: bgpd/bgpd.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/bgpd/bgpd.c,v
retrieving revision 1.129
diff -u -r1.129 bgpd.c
--- bgpd.c 1998/10/12 15:15:37 1.129
+++ bgpd.c 1998/10/20 01:49:28
@@ -52,6 +52,8 @@
#include "command.h"
#include "sockunion.h"
+#include <roken.h>
+
/* List head of bgp instance list. */
list bgp_list;
Index: lib/client.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/lib/client.c,v
retrieving revision 1.9
diff -u -r1.9 client.c
--- client.c 1998/08/25 12:55:16 1.9
+++ client.c 1998/10/20 01:49:29
@@ -34,6 +34,8 @@
#include "buffer.h"
#include "network.h"
+#include <roken.h>
+
/* Make a IPv4 route add/delete packet and send it to zebra. */
void
zebra_ipv4_route (int command, int sock, int type,struct prefix_ipv4 *p,
Index: lib/sockunion.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/lib/sockunion.c,v
retrieving revision 1.37
diff -u -r1.37 sockunion.c
--- sockunion.c 1998/09/07 06:46:56 1.37
+++ sockunion.c 1998/10/20 01:49:30
@@ -41,6 +41,8 @@
#include "memory.h"
#include "log.h"
+#include <roken.h>
+
#ifndef HAVE_INET_ATON
inet_aton (const char *cp, struct in_addr *inaddr)
{
Index: ripd/rip_announce.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/ripd/rip_announce.c,v
retrieving revision 1.36
diff -u -r1.36 rip_announce.c
--- rip_announce.c 1998/09/07 11:33:27 1.36
+++ rip_announce.c 1998/10/20 01:49:31
@@ -36,6 +36,8 @@
#include "linklist.h"
#include "if.h"
+#include <roken.h>
+
/* RIP routing table radix tree. */
extern struct radix_top *rip_radix;
Index: ripd/rip_interface.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/ripd/rip_interface.c,v
retrieving revision 1.74
diff -u -r1.74 rip_interface.c
--- rip_interface.c 1998/09/07 10:31:14 1.74
+++ rip_interface.c 1998/10/20 01:49:31
@@ -41,6 +41,8 @@
#include "zebra.h"
#include "memory.h"
+#include <roken.h>
+
/* Global rip structure. */
extern struct rip *rip;
Index: ripd/ripd.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/ripd/ripd.c,v
retrieving revision 1.112
diff -u -r1.112 ripd.c
--- ripd.c 1998/09/10 07:38:27 1.112
+++ ripd.c 1998/10/20 01:49:32
@@ -51,6 +51,8 @@
#include "memory.h"
#include "buffer.h"
+#include <roken.h>
+
extern struct thread_master *master;
/* RIP Structure. */
Index: ripngd/ripngd.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/ripngd/ripngd.c,v
retrieving revision 1.84
diff -u -r1.84 ripngd.c
--- ripngd.c 1998/09/15 09:50:27 1.84
+++ ripngd.c 1998/10/20 01:49:34
@@ -51,6 +51,8 @@
#include "buffer.h"
#include "table.h"
+#include <roken.h>
+
/* RIPng structure which includes many parameters related to RIPng
protocol. If ripng couldn't active or ripng doesn't configured,
ripng->fd will be negative value. */
Index: zebra/zebra.c
===================================================================
RCS file: /usr/local/cvsroot/alpha/zebra/zebra.c,v
retrieving revision 1.116
diff -u -r1.116 zebra.c
--- zebra.c 1998/09/02 09:08:46 1.116
+++ zebra.c 1998/10/20 01:49:35
@@ -49,6 +49,8 @@
#include "memory.h"
#include "rib.h"
+#include <roken.h>
+
/* This host's information. */
struct
{
--- /dev/null Tue Jan 1 05:00:00 1980
+++ lib/roken.h Tue Oct 20 03:36:27 1998
@@ -0,0 +1,8 @@
+/* Copyright (C) 1998 by Magnus Ahltorp */
+
+#ifdef HAVE_REPAIRABLE_HTONL
+#define htonl(x) __cpu_to_be32(x)
+#define ntohl(x) __be32_to_cpu(x)
+#define htons(x) __cpu_to_be16(x)
+#define ntohs(x) __be16_to_cpu(x)
+#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic