Add support for extensions submodule.
authorBen Pfaff <blp@nicira.com>
Fri, 29 Aug 2008 00:36:33 +0000 (17:36 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 29 Aug 2008 00:36:33 +0000 (17:36 -0700)
12 files changed:
.gitignore
.gitmodules [new file with mode: 0644]
Make.vars
Makefile.am
acinclude.m4
configure.ac
ext [new submodule]
include/Makefile.am
include/vlog-modules.def [new file with mode: 0644]
include/vlog.h
lib/vlog.c
m4/libopenflow.m4 [new file with mode: 0644]

index ff011f2a793eda9c91b01443c9141bd76134a11a..105f561ee276ddc2ba631e010db987c515cb19aa 100644 (file)
@@ -22,6 +22,7 @@
 /autom4te.cache
 /build-arch-stamp
 /build-indep-stamp
+/compile
 /config.guess
 /config.h
 /config.h.in
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..57d67d1
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "ext"]
+       path = ext
+       url = ../openflowext
index 583d3eb0f9183c6d03dceb75420ba6f1230fa88a..37727732073952cbdd8428a3a8ff4a1fc5dafbc5 100644 (file)
--- a/Make.vars
+++ b/Make.vars
@@ -1,19 +1,20 @@
 # -*- makefile -*-
 
 AM_CPPFLAGS = $(SSL_CFLAGS)
-
-COMMON_FLAGS = -DVERSION=\"$(VERSION)\"
-if NDEBUG
-COMMON_FLAGS += -DNDEBUG -fomit-frame-pointer
+AM_CPPFLAGS += -I $(ofp_top_srcdir)/include
+if HAVE_EXT
+AM_CPPFLAGS += -I $(ofp_top_srcdir)/ext/include
 endif
 
-AM_CFLAGS = $(COMMON_FLAGS)
-AM_CFLAGS += -Wstrict-prototypes -I $(top_srcdir)/include
+AM_CFLAGS = -DVERSION=\"$(VERSION)\"
+AM_CFLAGS += -Wstrict-prototypes
 
 rundir = $(localstatedir)/run
 AM_CFLAGS += -DRUNDIR=\"$(rundir)\"
 
-if !NDEBUG
+if NDEBUG
+AM_CFLAGS += -DNDEBUG -fomit-frame-pointer
+else
 AM_LDFLAGS = -export-dynamic
 endif
 
index 4644b057344da49823a03a0fbf8bb509908ed599..d78bc2c8bb736b8f38090e168b54044919c916b6 100644 (file)
@@ -1,6 +1,12 @@
 AUTOMAKE_OPTIONS=foreign
+ACLOCAL_AMFLAGS = -I m4
 SUBDIRS = lib datapath secchan controller
 if HAVE_IF_PACKET
 SUBDIRS += switch
 endif
 SUBDIRS += utilities tests include third-party
+if HAVE_EXT
+SUBDIRS += ext
+endif
+
+EXTRA_DIST = README.hwtables
index bd16b9973adc7b73ae8c07b9cd52e40c72ef6cf1..4dacae871a4101516a640a8f32a3767d186f7773 100644 (file)
 # advertising or publicity pertaining to the Software or any
 # derivatives without specific, written prior permission.
 
-dnl --
-dnl CHECK_LINUX(OPTION, VERSION, VARIABLE, CONDITIONAL)
+dnl OFP_CHECK_LINUX(OPTION, VERSION, VARIABLE, CONDITIONAL)
 dnl
 dnl Configure linux kernel source tree 
-dnl --
-AC_DEFUN([CHECK_LINUX], [
+AC_DEFUN([OFP_CHECK_LINUX], [
   AC_ARG_WITH([$1],
               [AC_HELP_STRING([--with-$1=/path/to/linux-$3],
                               [Specify the linux $3 kernel sources])],
@@ -66,3 +64,76 @@ AC_DEFUN([CHECK_LINUX], [
   fi
   AM_CONDITIONAL($5, test -n "$path")
 ])
+
+dnl Checks for --enable-hw-tables and substitutes HW_TABLES to any
+dnl requested hardware table modules.
+AC_DEFUN([OFP_CHECK_HWTABLES],
+  [AC_ARG_ENABLE(
+     [hw-tables],
+     [AC_HELP_STRING([--enable-hw-tables=MODULE...],
+                     [Configure and build the specified externally supplied 
+                      hardware table support modules])])
+   case "${enable_hw_tables}" in # (
+     yes) 
+       AC_MSG_ERROR([--enable-hw-tables has a required argument])
+       ;; # (
+     ''|no) 
+       hw_tables=
+       ;; # (
+     *) 
+       hw_tables=`echo "$enable_hw_tables" | sed 's/,/ /g'`
+       ;;
+   esac
+   for d in $hw_tables; do
+       mk=datapath/hwtable_$d/Modules.mk
+       if test ! -e $srcdir/$mk; then
+          AC_MSG_ERROR([--enable-hw-tables=$d specified but $mk is missing])
+       fi
+       HW_TABLES="$HW_TABLES \$(top_srcdir)/$mk"
+   done
+   AC_SUBST(HW_TABLES)])
+
+dnl Checks for net/if_packet.h.
+AC_DEFUN([OFP_CHECK_IF_PACKET],
+  [AC_CHECK_HEADER([net/if_packet.h],
+                   [HAVE_IF_PACKET=yes],
+                   [HAVE_IF_PACKET=no])
+   AM_CONDITIONAL([HAVE_IF_PACKET], [test "$HAVE_IF_PACKET" = yes])
+   if test "$HAVE_IF_PACKET" = yes; then
+      AC_DEFINE([HAVE_IF_PACKET], [1],
+                [Define to 1 if net/if_packet.h is available.])
+   fi])
+
+dnl Enable OpenFlow extension submodule.
+AC_DEFUN([OFP_ENABLE_EXT],
+  [AC_ARG_ENABLE([ext],
+     AS_HELP_STRING([--enable-ext], 
+                    [use OpenFlow extensions
+                     (default is yes if "ext" dir exists)]))
+   case "${enable_ext}" in
+     (yes)
+       HAVE_EXT=yes
+       ;;
+     (no)
+       HAVE_EXT=no
+       ;;
+     (*)
+       if test -d "$srcdir/ext"; then
+         HAVE_EXT=yes
+       else
+         HAVE_EXT=no
+       fi
+       ;;
+   esac
+   if test $HAVE_EXT = yes; then
+     if test -d "$srcdir/ext"; then
+       :
+     else
+       AC_MSG_ERROR([cannot configure extensions without "ext" directory])
+     fi
+     AC_CONFIG_SUBDIRS([ext])
+     AC_DEFINE([HAVE_EXT], [1], 
+               [Whether the OpenFlow extensions submodule is available])
+   fi
+   AC_SUBST([ofp_top_srcdir], ['$(top_srcdir)'])
+   AM_CONDITIONAL([HAVE_EXT], [test $HAVE_EXT = yes])])
index 3f0142e0a8575241551ecf7740e1f42cd3abd439..18dd1af5fbb5da8ff44e0eb31f3002e8411835df 100644 (file)
@@ -32,6 +32,8 @@
 
 AC_PREREQ(2.59)
 AC_INIT(openflow, v0.8.1, info@openflowswitch.org)
+AC_CONFIG_SRCDIR([README.hwtables])
+AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE
 
@@ -45,107 +47,19 @@ if test "$PERL" = no; then
    AC_MSG_ERROR([Perl interpreter not found in $PATH or $PERL.])
 fi
 
-AC_USE_SYSTEM_EXTENSIONS
-
-AC_ARG_ENABLE(
-  [ndebug],
-  [AC_HELP_STRING([--enable-ndebug], 
-                  [Disable debugging features for max performance])],
-  [case "${enableval}" in # (
-     yes) ndebug=true ;; # (
-     no)  ndebug=false ;; # (
-     *) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
-   esac],
-  [ndebug=false])
-AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])
-
-AC_ARG_ENABLE(
-  [hw-tables],
-  [AC_HELP_STRING([--enable-hw-tables=MODULE...],
-                  [Configure and build the specified externally supplied 
-                  hardware table support modules])])
-case "${enable_hw_tables}" in # (
-  yes) 
-    AC_MSG_ERROR([--enable-hw-tables has a required argument])
-    ;; # (
-  ''|no) 
-    hw_tables=
-    ;; # (
-  *) 
-    hw_tables=`echo "$enable_hw_tables" | sed 's/,/ /g'`
-    ;;
-esac
-for d in $hw_tables; do
-    mk=datapath/hwtable_$d/Modules.mk
-    if test ! -e $srcdir/$mk; then
-       AC_MSG_ERROR([--enable-hw-tables=$d specified but $mk is missing])
-    fi
-    HW_TABLES="$HW_TABLES \$(top_srcdir)/$mk"
-done
-AC_SUBST(HW_TABLES)
+OFP_CHECK_LIBOPENFLOW
+OFP_CHECK_IF_PACKET
+OFP_CHECK_HWTABLES
 
 AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)
-
-CHECK_LINUX(l26, 2.6, 2.6, KSRC26, L26_ENABLED)
-CHECK_LINUX(l24, 2.4, 2.4, KSRC24, L24_ENABLED)
-
-AC_CHECK_HEADER([linux/netlink.h],
-                [HAVE_NETLINK=yes],
-                [HAVE_NETLINK=no],
-                [#include <sys/socket.h>
-#include <linux/types.h>])
-AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
-if test "$HAVE_NETLINK" = yes; then
-   AC_DEFINE([HAVE_NETLINK], [1],
-             [Define to 1 if Netlink protocol is available.])
-fi
-
-AC_CHECK_HEADER([net/if_packet.h],
-                [HAVE_IF_PACKET=yes],
-                [HAVE_IF_PACKET=no])
-AM_CONDITIONAL([HAVE_IF_PACKET], [test "$HAVE_IF_PACKET" = yes])
-if test "$HAVE_IF_PACKET" = yes; then
-   AC_DEFINE([HAVE_IF_PACKET], [1],
-             [Define to 1 if net/if_packet.h is available.])
-fi
-
-AC_ARG_ENABLE(
-  [ssl],
-  [AC_HELP_STRING([--enable-ssl], 
-                  [Enable ssl support (requires libssl)])],
-  [case "${enableval}" in # (
-     yes) ssl=true ;;  # (
-     no)  ssl=false ;; # (
-     *) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
-   esac],
-  [ssl=false])
-
-if test "$ssl" = true; then
-dnl Make sure that pkg-config is installed.
-m4_pattern_forbid([PKG_CHECK_MODULES])
-PKG_CHECK_MODULES([SSL], [libssl], 
-  [HAVE_OPENSSL=yes],
-  [HAVE_OPENSSL=no
-   AC_MSG_WARN([Cannot find libssl:
-
-$SSL_PKG_ERRORS
-
-OpenFlow will not support SSL connections.])])
-
-fi
-AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
-if test "$HAVE_OPENSSL" = yes; then
-   AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
-fi
-
-AC_CHECK_LIB([socket], [connect])
-AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])
-AC_CHECK_LIB([dl], [dladdr], [FAULT_LIBS=-ldl])
-AC_SUBST([FAULT_LIBS])
+OFP_CHECK_LINUX(l26, 2.6, 2.6, KSRC26, L26_ENABLED)
+OFP_CHECK_LINUX(l24, 2.4, 2.4, KSRC24, L24_ENABLED)
 
 CFLAGS="$CFLAGS -Wall -Wno-sign-compare"
 
+OFP_ENABLE_EXT
+
 AC_CONFIG_FILES([Makefile 
 datapath/Makefile 
 lib/Makefile
diff --git a/ext b/ext
new file mode 160000 (submodule)
index 0000000..b322740
--- /dev/null
+++ b/ext
@@ -0,0 +1 @@
+Subproject commit b3227406a713f5cae10d31a7be7249c6ebe16bff
index 5af741e79dfea262e3bba71dcbd5bfeca762470f..741618a36592ae65d7458e653e423dce5710c2ef 100644 (file)
@@ -35,5 +35,6 @@ noinst_HEADERS = \
        vconn-ssl.h \
        vconn-stream.h \
        vlog-socket.h \
+       vlog-modules.def \
        vlog.h \
        xtoxll.h
diff --git a/include/vlog-modules.def b/include/vlog-modules.def
new file mode 100644 (file)
index 0000000..22553de
--- /dev/null
@@ -0,0 +1,36 @@
+/* Modules that can emit log messages. */
+VLOG_MODULE(chain)
+VLOG_MODULE(controller)
+VLOG_MODULE(ctlpath)
+VLOG_MODULE(daemon)
+VLOG_MODULE(datapath)
+VLOG_MODULE(dhcp)
+VLOG_MODULE(dhcp_client)
+VLOG_MODULE(dpif)
+VLOG_MODULE(dpctl)
+VLOG_MODULE(fault)
+VLOG_MODULE(flow)
+VLOG_MODULE(learning_switch)
+VLOG_MODULE(mac_learning)
+VLOG_MODULE(netdev)
+VLOG_MODULE(netlink)
+VLOG_MODULE(ofp_discover)
+VLOG_MODULE(poll_loop)
+VLOG_MODULE(secchan)
+VLOG_MODULE(rconn)
+VLOG_MODULE(switch)
+VLOG_MODULE(terminal)
+VLOG_MODULE(socket_util)
+VLOG_MODULE(vconn_netlink)
+VLOG_MODULE(vconn_tcp)
+VLOG_MODULE(vconn_ssl)
+VLOG_MODULE(vconn_stream)
+VLOG_MODULE(vconn_unix)
+VLOG_MODULE(vconn)
+VLOG_MODULE(vlog)
+
+#ifdef HAVE_EXT
+#include "ext/vlogext-modules.def"
+#endif
+
+#undef VLOG_MODULE
index 3196743621054a2e3fb1ebbe091e3a27b2a19ffc..7582681a8797de0b3ce205854d2c925269a0e828 100644 (file)
@@ -63,42 +63,10 @@ enum vlog_facility {
 const char *vlog_get_facility_name(enum vlog_facility);
 enum vlog_facility vlog_get_facility_val(const char *name);
 
-/* Modules that can emit log messages. */
-#define VLOG_MODULES                            \
-        VLOG_MODULE(chain)                      \
-        VLOG_MODULE(controller)                 \
-        VLOG_MODULE(ctlpath)                    \
-        VLOG_MODULE(daemon)                     \
-        VLOG_MODULE(datapath)                   \
-        VLOG_MODULE(dhcp)                       \
-        VLOG_MODULE(dhcp_client)                \
-        VLOG_MODULE(dpif)                       \
-        VLOG_MODULE(dpctl)                      \
-        VLOG_MODULE(fault)                      \
-        VLOG_MODULE(flow)                       \
-        VLOG_MODULE(learning_switch)            \
-        VLOG_MODULE(mac_learning)               \
-        VLOG_MODULE(netdev)                     \
-        VLOG_MODULE(netlink)                    \
-        VLOG_MODULE(ofp_discover)               \
-        VLOG_MODULE(poll_loop)                  \
-        VLOG_MODULE(secchan)                    \
-        VLOG_MODULE(rconn)                      \
-        VLOG_MODULE(switch)                     \
-        VLOG_MODULE(socket_util)                \
-        VLOG_MODULE(vconn_netlink)              \
-        VLOG_MODULE(vconn_tcp)                  \
-        VLOG_MODULE(vconn_ssl)                  \
-        VLOG_MODULE(vconn_stream)               \
-        VLOG_MODULE(vconn_unix)                 \
-        VLOG_MODULE(vconn)                      \
-        VLOG_MODULE(vlog)                       \
-
 /* VLM_ constant for each vlog module. */
 enum vlog_module {
 #define VLOG_MODULE(NAME) VLM_##NAME,
-    VLOG_MODULES
-#undef VLOG_MODULE
+#include "vlog-modules.def"
     VLM_N_MODULES,
     VLM_ANY_MODULE = -1
 };
index 663b3df04566ba0f5715b82a129a4a45e1aef090..7eeb98208f73d75105355276df1d34510e2d316c 100644 (file)
@@ -66,8 +66,7 @@ static const char *facility_names[VLF_N_FACILITIES] = {
 /* Name for each logging module */
 static const char *module_names[VLM_N_MODULES] = { 
 #define VLOG_MODULE(NAME) #NAME,
-    VLOG_MODULES
-#undef VLOG_MODULES
+#include "vlog-modules.def"
 };
 
 static int levels[VLM_N_MODULES][VLF_N_FACILITIES];
diff --git a/m4/libopenflow.m4 b/m4/libopenflow.m4
new file mode 100644 (file)
index 0000000..5c8520d
--- /dev/null
@@ -0,0 +1,111 @@
+# Copyright (c) 2008 The Board of Trustees of The Leland Stanford
+# Junior University
+#
+# We are making the OpenFlow specification and associated documentation
+# (Software) available for public use and benefit with the expectation
+# that others will use, modify and enhance the Software and contribute
+# those enhancements back to the community. However, since we would
+# like to make the Software available for broadest use, with as few
+# restrictions as possible permission is hereby granted, free of
+# charge, to any person obtaining a copy of this Software to deal in
+# the Software under the copyrights without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+# The name and trademarks of copyright holder(s) may NOT be used in
+# advertising or publicity pertaining to the Software or any
+# derivatives without specific, written prior permission.
+
+dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
+AC_DEFUN([OFP_CHECK_NDEBUG],
+  [AC_ARG_ENABLE(
+     [ndebug],
+     [AC_HELP_STRING([--enable-ndebug], 
+                     [Disable debugging features for max performance])],
+     [case "${enableval}" in
+        (yes) ndebug=true ;;
+        (no)  ndebug=false ;;
+        (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
+      esac],
+     [ndebug=false])
+   AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
+
+dnl Checks for Netlink support.
+AC_DEFUN([OFP_CHECK_NETLINK],
+  [AC_CHECK_HEADER([linux/netlink.h],
+                   [HAVE_NETLINK=yes],
+                   [HAVE_NETLINK=no],
+                   [#include <sys/socket.h>
+   #include <linux/types.h>
+   ])
+   AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
+   if test "$HAVE_NETLINK" = yes; then
+      AC_DEFINE([HAVE_NETLINK], [1],
+                [Define to 1 if Netlink protocol is available.])
+   fi])
+
+dnl Checks for OpenSSL, if --enable-ssl is passed in.
+AC_DEFUN([OFP_CHECK_OPENSSL],
+  [AC_ARG_ENABLE(
+     [ssl],
+     [AC_HELP_STRING([--enable-ssl], 
+                     [Enable ssl support (requires libssl)])],
+     [case "${enableval}" in
+        (yes) ssl=true ;;
+        (no)  ssl=false ;;
+        (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
+      esac],
+     [ssl=false])
+
+   if test "$ssl" = true; then
+   dnl Make sure that pkg-config is installed.
+   m4_pattern_forbid([PKG_CHECK_MODULES])
+   PKG_CHECK_MODULES([SSL], [libssl], 
+     [HAVE_OPENSSL=yes],
+     [HAVE_OPENSSL=no
+      AC_MSG_WARN([Cannot find libssl:
+
+   $SSL_PKG_ERRORS
+
+   OpenFlow will not support SSL connections.])])
+
+   fi
+   AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
+   if test "$HAVE_OPENSSL" = yes; then
+      AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
+   fi])
+
+dnl Checks for libraries needed by lib/fault.c.
+AC_DEFUN([OFP_CHECK_FAULT_LIBS],
+  [AC_CHECK_LIB([dl], [dladdr], [FAULT_LIBS=-ldl])
+   AC_SUBST([FAULT_LIBS])])
+
+dnl Checks for libraries needed by lib/socket-util.c.
+AC_DEFUN([OFP_CHECK_SOCKET_LIBS],
+  [AC_CHECK_LIB([socket], [connect])
+   AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
+
+dnl Runs the checks required to include the headers in include/ and
+dnl link against lib/libopenflow.a.
+AC_DEFUN([OFP_CHECK_LIBOPENFLOW],
+  [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+   AC_REQUIRE([OFP_CHECK_NDEBUG])
+   AC_REQUIRE([OFP_CHECK_NETLINK])
+   AC_REQUIRE([OFP_CHECK_OPENSSL])
+   AC_REQUIRE([OFP_CHECK_FAULT_LIBS])
+   AC_REQUIRE([OFP_CHECK_SOCKET_LIBS])])
+