├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── README ├── acinclude.m4 ├── boot.sh ├── configure.ac ├── debian ├── .gitignore ├── changelog ├── commands │ ├── reconfigure │ └── update ├── compat ├── control.in ├── control.modules.in ├── copyright ├── corekeeper.cron.daily ├── corekeeper.init ├── dirs ├── ofp-switch-setup ├── ofp-switch-setup.8 ├── openflow-common.dirs ├── openflow-common.install ├── openflow-common.manpages ├── openflow-controller.README.Debian ├── openflow-controller.default ├── openflow-controller.dirs ├── openflow-controller.init ├── openflow-controller.install ├── openflow-controller.manpages ├── openflow-controller.postinst ├── openflow-datapath-module-_KVERS_.postinst.modules.in ├── openflow-datapath-source.README.Debian ├── openflow-datapath-source.copyright ├── openflow-datapath-source.dirs ├── openflow-datapath-source.install ├── openflow-pki-server.apache2 ├── openflow-pki-server.dirs ├── openflow-pki-server.install ├── openflow-pki-server.postinst ├── openflow-pki.postinst ├── openflow-switch-config.dirs ├── openflow-switch-config.install ├── openflow-switch-config.manpages ├── openflow-switch-config.overrides ├── openflow-switch-config.templates ├── openflow-switch.README.Debian ├── openflow-switch.dirs ├── openflow-switch.init ├── openflow-switch.install ├── openflow-switch.logrotate ├── openflow-switch.manpages ├── openflow-switch.postinst ├── openflow-switch.postrm ├── openflow-switch.template ├── po │ ├── POTFILES.in │ └── templates.pot └── rules ├── include ├── .gitignore ├── automake.mk └── openflow │ ├── automake.mk │ ├── nicira-ext.h │ ├── of_hw_api.h │ ├── openflow-ext.h │ ├── openflow-netlink.h │ ├── openflow.h │ └── private-ext.h ├── lib ├── .gitignore ├── automake.mk ├── backtrace.c ├── backtrace.h ├── command-line.c ├── command-line.h ├── common.man ├── compiler.h ├── csum.c ├── csum.h ├── daemon.c ├── daemon.h ├── daemon.man ├── dh1024.pem ├── dh2048.pem ├── dh4096.pem ├── dhcp-client.c ├── dhcp-client.h ├── dhcp.c ├── dhcp.h ├── dhparams.h ├── dirs.h ├── dpif.c ├── dpif.h ├── dynamic-string.c ├── dynamic-string.h ├── fatal-signal.c ├── fatal-signal.h ├── fault.c ├── fault.h ├── flow.c ├── flow.h ├── hash.c ├── hash.h ├── hmap.c ├── hmap.h ├── leak-checker.c ├── leak-checker.h ├── leak-checker.man ├── list.c ├── list.h ├── mac-learning.c ├── mac-learning.h ├── netdev.c ├── netdev.h ├── netlink-protocol.h ├── netlink.c ├── netlink.h ├── ofp.c ├── ofp.h ├── ofpbuf.c ├── ofpbuf.h ├── ofpstat.c ├── ofpstat.h ├── packets.h ├── pcap.c ├── pcap.h ├── poll-loop.c ├── poll-loop.h ├── port-array.c ├── port-array.h ├── process.c ├── process.h ├── queue.c ├── queue.h ├── random.c ├── random.h ├── rconn.c ├── rconn.h ├── sat-math.h ├── shash.c ├── shash.h ├── signals.c ├── signals.h ├── socket-util.c ├── socket-util.h ├── stp.c ├── stp.h ├── svec.c ├── svec.h ├── tag.c ├── tag.h ├── timeval.c ├── timeval.h ├── type-props.h ├── util.c ├── util.h ├── vconn-netlink.c ├── vconn-provider.h ├── vconn-ssl.c ├── vconn-ssl.h ├── vconn-stream.c ├── vconn-stream.h ├── vconn-tcp.c ├── vconn-unix.c ├── vconn.c ├── vconn.h ├── vlog-modules.def ├── vlog-socket.c ├── vlog-socket.h ├── vlog.c ├── vlog.h ├── vlog.man └── xtoxll.h ├── m4 ├── libopenflow.m4 └── nx-build.m4 ├── oflib-exp ├── automake.mk ├── ofl-exp-nicira.c ├── ofl-exp-nicira.h ├── ofl-exp-openflow.c ├── ofl-exp-openflow.h ├── ofl-exp.c ├── ofl-exp.h └── vlog-modules.def ├── oflib ├── automake.mk ├── ofl-actions-pack.c ├── ofl-actions-print.c ├── ofl-actions-unpack.c ├── ofl-actions.c ├── ofl-actions.h ├── ofl-log-vlog-cc.h ├── ofl-log-vlog.h ├── ofl-log.h ├── ofl-messages-pack.c ├── ofl-messages-print.c ├── ofl-messages-unpack.c ├── ofl-messages.c ├── ofl-messages.h ├── ofl-packets.h ├── ofl-print.c ├── ofl-print.h ├── ofl-structs-pack.c ├── ofl-structs-print.c ├── ofl-structs-unpack.c ├── ofl-structs.c ├── ofl-structs.h ├── ofl-utils.h ├── ofl.h └── vlog-modules.def ├── secchan ├── .gitignore ├── automake.mk ├── commands │ ├── automake.mk │ └── reboot ├── discovery.c ├── discovery.h ├── failover.c ├── failover.h ├── in-band.c ├── in-band.h ├── ofprotocol.8.in ├── port-watcher.c ├── port-watcher.h ├── ratelimit.c ├── ratelimit.h ├── secchan.c ├── secchan.h ├── status.c ├── status.h ├── stp-secchan.c ├── stp-secchan.h └── vlog-modules.def ├── soexpand.pl ├── udatapath ├── .gitignore ├── action_set.c ├── action_set.h ├── automake.mk ├── crc32.c ├── crc32.h ├── datapath.c ├── datapath.h ├── dp_actions.c ├── dp_actions.h ├── dp_buffers.c ├── dp_buffers.h ├── dp_capabilities.h ├── dp_control.c ├── dp_control.h ├── dp_exp.c ├── dp_exp.h ├── dp_ports.c ├── dp_ports.h ├── flow_entry.c ├── flow_entry.h ├── flow_table.c ├── flow_table.h ├── group_entry.c ├── group_entry.h ├── group_table.c ├── group_table.h ├── match_std.c ├── match_std.h ├── ofdatapath.8.in ├── packet.c ├── packet.h ├── packet_handle_std.c ├── packet_handle_std.h ├── pipeline.c ├── pipeline.h ├── udatapath.c └── vlog-modules.def └── utilities ├── .gitignore ├── automake.mk ├── dpctl.8.in ├── dpctl.c ├── dpctl.h ├── ofp-discover.8.in ├── ofp-discover.c ├── ofp-kill.8.in ├── ofp-kill.c ├── ofp-parse-leaks.in ├── ofp-pki-cgi.in ├── ofp-pki.8.in ├── ofp-pki.in ├── vlog-modules.def ├── vlogconf.8.in └── vlogconf.c /Makefile.am: -------------------------------------------------------------------------------- 1 | # The goal of -Wno-syntax here is just to suppress the Automake warning 2 | # about overriding distdir, below. 3 | AUTOMAKE_OPTIONS = foreign -Wno-syntax subdir-objects 4 | ACLOCAL_AMFLAGS = -I m4 5 | #SUBDIRS = datapath 6 | SUBDIRS = 7 | 8 | if HAVE_DPKG_BUILDPACKAGE 9 | distcheck-hook: 10 | cd $(srcdir) && dpkg-buildpackage -rfakeroot -us -uc 11 | cd $(srcdir) && fakeroot ./debian/rules clean 12 | else 13 | distcheck-hook: 14 | endif 15 | 16 | AM_CPPFLAGS = $(SSL_CFLAGS) -g 17 | AM_CPPFLAGS += -I $(top_srcdir)/include 18 | AM_CPPFLAGS += -I $(top_srcdir)/lib 19 | 20 | AM_CFLAGS = -Wstrict-prototypes 21 | 22 | if NDEBUG 23 | AM_CPPFLAGS += -DNDEBUG 24 | AM_CFLAGS += -fomit-frame-pointer 25 | else 26 | AM_LDFLAGS = -export-dynamic 27 | endif 28 | 29 | CLEANFILES = 30 | DISTCLEANFILES = 31 | EXTRA_DIST = 32 | TESTS = 33 | TESTS_ENVIRONMENT = 34 | bin_PROGRAMS = 35 | bin_SCRIPTS = 36 | dist_commands_DATA = 37 | dist_man_MANS = 38 | dist_pkgdata_SCRIPTS = 39 | dist_sbin_SCRIPTS = 40 | man_MANS = 41 | noinst_HEADERS = 42 | noinst_LIBRARIES = 43 | noinst_PROGRAMS = 44 | noinst_SCRIPTS = 45 | 46 | EXTRA_DIST += README.hwtables soexpand.pl regress 47 | 48 | ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */' 49 | 50 | SUFFIXES = .in 51 | .in: 52 | $(PERL) $(srcdir)/soexpand.pl -I$(srcdir) < $< | \ 53 | sed -e 's,[@]LOGDIR[@],$(LOGDIR),g' \ 54 | -e 's,[@]PKIDIR[@],$(PKIDIR),g' \ 55 | -e 's,[@]RUNDIR[@],$(RUNDIR),g' \ 56 | -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ 57 | -e 's,[@]PERL[@],$(PERL),g' > $@ 58 | 59 | include lib/automake.mk 60 | include oflib/automake.mk 61 | include oflib-exp/automake.mk 62 | include secchan/automake.mk 63 | include utilities/automake.mk 64 | include udatapath/automake.mk 65 | include include/automake.mk 66 | include debian/automake.mk 67 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | OpenFlow 1.1 Software Switch 2 | ---------------------------- 3 | 4 | This is an OpenFlow 1.1 [1] compatible user-space software switch implementation. 5 | The code is based on the original Stanford 1.0.0 reference switch [2], with 6 | the forwarding plane being completely rewritten to support OpenFlow 1.1. 7 | The implementation is feature-complete, and passes the available oftest 1.1 8 | test cases [3]. 9 | 10 | The following components are available in the release: 11 | - ofdatapath: the switch implementation 12 | - ofprotocol: secure channel for connecting the switch to the controller 13 | - oflib: a library for converting to/from 1.1 wire format 14 | - dpctl: a tool for configuring the switch from the console 15 | 16 | [1] http://www.openflow.org/documents/openflow-spec-v1.1.0.pdf 17 | [2] http://yuba.stanford.edu/git/gitweb.cgi?p=openflow.git;a=tree;h=7f09f6a88d86883b516c99eb4058402eb07e5fd0;hb=d90824f0e8c3b6606d04e5a8813f03e89a6d0894 18 | [3] https://github.com/TrafficLab/oftest11 19 | 20 | 21 | Getting Started 22 | --------------- 23 | 24 | To build, run the following commands in the of11softswitch directory: 25 | 26 | ./boot.sh 27 | ./configure 28 | make 29 | 30 | 31 | To start the datapath, run the following commands: 32 | 33 | cd udatapath 34 | sudo ./ofdatapath --datapath-id= --interfaces= ptcp: 35 | 36 | This will start the datapath, with the given datapath id, and interace list, 37 | opening a passive tcp connection on the given port. For a complete list of 38 | options, use the --help argument. 39 | 40 | 41 | To start the secure channel, run the following commands: 42 | 43 | cd secchan 44 | ./ofprotocol tcp:: tcp:: 45 | 46 | This will open tcp connections to both the switch and the controller, relaying 47 | OpenFlow protocol messages between the two. For a complete list of options, 48 | use the --help argument. 49 | 50 | 51 | You can send requests to the switch using the dpctl utility: 52 | 53 | cd utilities 54 | ./dpctl tcp:: stats-flow table=0 55 | 56 | For a complete list of commands and arguments, use the --help argument, and 57 | consult the dpctl.h file [1]. 58 | 59 | [1] https://github.com/TrafficLab/of11softswitch/blob/master/utilities/dpctl.h 60 | 61 | 62 | Contribute 63 | ---------- 64 | 65 | Please submit your bug reports, fixes and suggestions as pull requests on 66 | github, or by contacting us directly. 67 | 68 | 69 | License 70 | ------- 71 | 72 | OpenFlow 1.1 Software Switch is released under the BSD license (BSD-like 73 | for code from the original Stanford switch). 74 | 75 | 76 | References 77 | ---------- 78 | 79 | [1] OpenFlow: http://www.openflow.org/ 80 | [2] ONF: http://www.opennetworkingfoundation.org/ 81 | 82 | 83 | Contact 84 | ------- 85 | 86 | E-mail: Zoltan Lajos Kis (zoltan.lajos.kis@ericsson.com) 87 | 88 | Wiki: https://openflow.stanford.edu/display/of11softswitch 89 | Repo: https://github.com/TrafficLab/of11softswitch 90 | -------------------------------------------------------------------------------- /boot.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | # Generate list of files in debian/ to distribute. 6 | (echo '# Automatically generated by boot.sh (from Git tree).' && 7 | printf 'EXTRA_DIST += \\\n' && 8 | git ls-files debian | grep -v '^debian/\.gitignore$' | 9 | sed -e 's/\(.*\)/ \1 \\/' -e '$s/ \\//') > debian/automake.mk 10 | 11 | cat debian/control.in > debian/control 12 | 13 | # Bootstrap configure system from .ac/.am files 14 | autoreconf --install --force 15 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | # Junior University 3 | # 4 | # We are making the OpenFlow specification and associated documentation 5 | # (Software) available for public use and benefit with the expectation 6 | # that others will use, modify and enhance the Software and contribute 7 | # those enhancements back to the community. However, since we would 8 | # like to make the Software available for broadest use, with as few 9 | # restrictions as possible permission is hereby granted, free of 10 | # charge, to any person obtaining a copy of this Software to deal in 11 | # the Software under the copyrights without restriction, including 12 | # without limitation the rights to use, copy, modify, merge, publish, 13 | # distribute, sublicense, and/or sell copies of the Software, and to 14 | # permit persons to whom the Software is furnished to do so, subject to 15 | # the following conditions: 16 | # 17 | # The above copyright notice and this permission notice shall be 18 | # included in all copies or substantial portions of the Software. 19 | # 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | # SOFTWARE. 28 | # 29 | # The name and trademarks of copyright holder(s) may NOT be used in 30 | # advertising or publicity pertaining to the Software or any 31 | # derivatives without specific, written prior permission. 32 | 33 | AC_PREREQ(2.60) 34 | AC_INIT([openflow], [1.1.0], [openflow-discuss@openflowswitch.org]) 35 | NX_BUILDNR 36 | AC_CONFIG_MACRO_DIR([m4]) 37 | AC_CONFIG_AUX_DIR([build-aux]) 38 | AC_CONFIG_HEADERS([config.h]) 39 | AM_INIT_AUTOMAKE 40 | 41 | AC_PROG_CC 42 | AM_PROG_CC_C_O 43 | AC_PROG_CPP 44 | AC_PROG_RANLIB 45 | AC_PROG_MKDIR_P 46 | 47 | AC_ARG_VAR([PERL], [path to Perl interpreter]) 48 | AC_PATH_PROG([PERL], perl, no) 49 | if test "$PERL" = no; then 50 | AC_MSG_ERROR([Perl interpreter not found in $PATH or $PERL.]) 51 | fi 52 | 53 | OFP_CHECK_LIBOPENFLOW 54 | OFP_CHECK_IF_PACKET 55 | OFP_CHECK_HWTABLES 56 | OFP_CHECK_HWLIBS 57 | AC_SYS_LARGEFILE 58 | 59 | AC_CHECK_FUNCS([strsignal]) 60 | 61 | AC_ARG_VAR(KARCH, [Kernel Architecture String]) 62 | AC_SUBST(KARCH) 63 | #OFP_CHECK_LINUX(l26, 2.6, KBLD26, KSRC26, L26_ENABLED) 64 | 65 | OFP_CHECK_DPKG_BUILDPACKAGE 66 | 67 | OFP_ENABLE_OPTION([-Wall]) 68 | OFP_ENABLE_OPTION([-Wno-sign-compare]) 69 | OFP_ENABLE_OPTION([-Wpointer-arith]) 70 | OFP_ENABLE_OPTION([-Wdeclaration-after-statement]) 71 | OFP_ENABLE_OPTION([-Wformat-security]) 72 | OFP_ENABLE_OPTION([-Wswitch-enum]) 73 | OFP_ENABLE_OPTION([-Wunused-parameter]) 74 | OFP_ENABLE_OPTION([-Wstrict-aliasing]) 75 | OFP_ENABLE_OPTION([-Wbad-function-cast]) 76 | OFP_ENABLE_OPTION([-Wcast-align]) 77 | OFP_ENABLE_OPTION([-Wstrict-prototypes]) 78 | OFP_ENABLE_OPTION([-Wold-style-definition]) 79 | OFP_ENABLE_OPTION([-Wmissing-prototypes]) 80 | OFP_ENABLE_OPTION([-Wmissing-field-initializers]) 81 | OFP_ENABLE_OPTION([-Wno-override-init]) 82 | 83 | AC_CONFIG_FILES([Makefile 84 | ]) 85 | 86 | #AC_CONFIG_FILES([Makefile 87 | #datapath/Makefile 88 | #datapath/linux-2.6/Kbuild 89 | #datapath/linux-2.6/Makefile 90 | #datapath/linux-2.6/Makefile.main 91 | #]) 92 | 93 | AC_OUTPUT 94 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | *.debhelper 2 | *.debhelper.log 3 | *.substvars 4 | /automake.mk 5 | /control 6 | /corekeeper 7 | /files 8 | /nicira-switch 9 | /openflow 10 | /openflow-common 11 | /openflow-common.copyright 12 | /openflow-controller 13 | /openflow-datapath-source 14 | /openflow-dbg 15 | /openflow-monitor 16 | /openflow-monitor.copyright 17 | /openflow-monitor.default 18 | /openflow-monitor.dirs 19 | /openflow-monitor.init 20 | /openflow-monitor.install 21 | /openflow-pki 22 | /openflow-pki-server 23 | /openflow-switch 24 | /openflow-switch-config 25 | /openflow-switch.copyright 26 | /openflow-switchui 27 | /openflow-switchui.copyright 28 | /openflow-switchui.default 29 | /openflow-switchui.dirs 30 | /openflow-switchui.init 31 | /openflow-switchui.install 32 | /openflow-wdt 33 | /openflow-wdt.copyright 34 | /openflow-wdt.default 35 | /openflow-wdt.dirs 36 | /openflow-wdt.init 37 | /openflow-wdt.install 38 | /rules.ext 39 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | openflow (1.0.0) unstable; urgency=low 2 | 3 | * Development version 4 | 5 | -- OpenFlow team Thu, 31 Dec 2009 23:59:59 -0800 6 | 7 | openflow (0.9.0-rev1) unstable; urgency=low 8 | 9 | * Development version. 10 | 11 | -- OpenFlow team Fri, 04 Sep 2009 12:00:00 -0800 12 | 13 | openflow (0.8.9-rev4) unstable; urgency=low 14 | 15 | * Develoment version. 16 | 17 | -- OpenFlow team Tue, 15 Sep 2009 12:00:00 -0800 18 | 19 | openflow (0.8.1) unstable; urgency=low 20 | 21 | * Development version. 22 | 23 | -- OpenFlow team Mon, 19 Nov 2007 14:57:52 -0800 24 | -------------------------------------------------------------------------------- /debian/commands/update: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | set -e 3 | apt-get update -qy 4 | apt-get upgrade -qy 5 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /debian/control.modules.in: -------------------------------------------------------------------------------- 1 | Source: openflow 2 | Section: net 3 | Priority: extra 4 | Maintainer: OpenFlow Team 5 | Build-Depends: debhelper (>= 5.0.37) 6 | Standards-Version: 3.7.3 7 | 8 | Package: openflow-datapath-module-_KVERS_ 9 | Architecture: any 10 | Recommends: kernel-image-_KVERS_, openflow-switch 11 | Provides: openflow-datapath-module 12 | Description: OpenFlow Linux datapath kernel module 13 | This package contains the OpenFlow loadable datapath kernel modules for 14 | the kernel-image-_KVERS_ package. 15 | . 16 | If you compiled a custom kernel, you will most likely need to compile 17 | a custom version of this module as well. The openflow-datapath-source 18 | package has been provided for this purpose. Refer to README.Debian 19 | provided in that package for further instructions. 20 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Upstream Authors: 2 | 3 | The Board of Trustees of The Leland Stanford Junior University 4 | 5 | Copyright: 6 | 7 | Copyright (C) 2008 The Board of Trustees of The Leland Stanford 8 | Junior University 9 | 10 | License: 11 | 12 | We are making the OpenFlow specification and associated documentation 13 | (Software) available for public use and benefit with the expectation 14 | that others will use, modify and enhance the Software and contribute 15 | those enhancements back to the community. However, since we would like 16 | to make the Software available for broadest use, with as few 17 | restrictions as possible permission is hereby granted, free of charge, 18 | to any person obtaining a copy of this Software to deal in the Software 19 | under the copyrights without restriction, including without limitation 20 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 21 | and/or sell copies of the Software, and to permit persons to whom the 22 | Software is furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included 25 | in all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 28 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 30 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 31 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 32 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 33 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 34 | 35 | The name and trademarks of copyright holder(s) may NOT be used in 36 | advertising or publicity pertaining to the Software or any derivatives 37 | without specific, written prior permission. 38 | 39 | -------------------------------------------------------------------------------- /debian/corekeeper.cron.daily: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 4 | 5 | tmpreaper 7d --mtime --all /var/log/core 6 | -------------------------------------------------------------------------------- /debian/corekeeper.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Example init.d script with LSB support. 4 | # 5 | # Please read this init.d carefully and modify the sections to 6 | # adjust it to the program you want to run. 7 | # 8 | # Copyright (c) 2007 Javier Fernandez-Sanguino 9 | # 10 | # This is free software; you may redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as 12 | # published by the Free Software Foundation; either version 2, 13 | # or (at your option) any later version. 14 | # 15 | # This is distributed in the hope that it will be useful, but 16 | # WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License with 21 | # the Debian operating system, in /usr/share/common-licenses/GPL; if 22 | # not, write to the Free Software Foundation, Inc., 59 Temple Place, 23 | # Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | ### BEGIN INIT INFO 26 | # Provides: corekeeper 27 | # Required-Start: 28 | # Required-Stop: 29 | # Should-Start: $syslog 30 | # Should-Stop: 31 | # Default-Start: 2 3 4 5 32 | # Default-Stop: 0 1 6 33 | # Short-Description: Configure core file dump location 34 | ### END INIT INFO 35 | 36 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 37 | 38 | . /lib/lsb/init-functions 39 | 40 | set -e 41 | 42 | case "$1" in 43 | start) 44 | log_daemon_msg "Initializing core dump location..." 45 | if echo "/var/log/core/core.%e.%t" > /proc/sys/kernel/core_pattern 46 | then 47 | log_progress_msg "success" 48 | log_end_msg 0 49 | exit 0 50 | else 51 | log_end_msg 1 52 | exit 1 53 | fi 54 | ;; 55 | stop|restart|force-reload|status|reload) 56 | exit 0 57 | ;; 58 | *) 59 | N=/etc/init.d/$NAME 60 | echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 61 | exit 1 62 | ;; 63 | esac 64 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | usr/bin 2 | usr/sbin 3 | -------------------------------------------------------------------------------- /debian/ofp-switch-setup.8: -------------------------------------------------------------------------------- 1 | .TH ofp-switch-setup 8 "June 2008" "OpenFlow" "OpenFlow Manual" 2 | 3 | .SH NAME 4 | ofp\-switch\-setup \- interactive setup for OpenFlow switch 5 | 6 | .SH SYNOPSIS 7 | .B ofp\-switch\-setup 8 | 9 | .SH DESCRIPTION 10 | The \fBofp\-switch\-setup\fR program is an interactive program that 11 | assists the system administrator in configuring an OpenFlow switch, 12 | including the underlying public key infrastructure (PKI). 13 | 14 | .SH OPTIONS 15 | ofp\-switch\-setup does not accept any command-line options. 16 | 17 | .SH FILES 18 | .IP /etc/default/openflow-switch 19 | Main configuration file for OpenFlow switch. 20 | 21 | .IP /etc/openflow-switch/cacert.pem 22 | Default location of CA certificate for OpenFlow controllers. 23 | 24 | .IP /etc/openflow-switch/of0-cert.pem 25 | Default location of certificate for the OpenFlow switch's private key. 26 | 27 | .IP /etc/openflow-switch/of0-privkey.pem 28 | Default location of the OpenFlow switch's private key. This file 29 | should be readable only by \fBroot\fR. 30 | 31 | .IP /etc/openflow-switch/of0-req.pem 32 | Default location of certificate request for the OpenFlow switch's 33 | certificate. This file is not used after the signed certificate 34 | (typically \fB/etc/openflow-switch/of0-cert.pem\fR, above) has been 35 | obtained from the OpenFlow PKI server. 36 | 37 | .SH "SEE ALSO" 38 | 39 | .BR ofp-pki (8), 40 | .BR dpctl (8), 41 | .BR secchan (8) 42 | -------------------------------------------------------------------------------- /debian/openflow-common.dirs: -------------------------------------------------------------------------------- 1 | var/log/openflow 2 | -------------------------------------------------------------------------------- /debian/openflow-common.install: -------------------------------------------------------------------------------- 1 | _debian/utilities/ofp-parse-leaks usr/bin 2 | _debian/utilities/ofp-pki usr/sbin 3 | _debian/utilities/vlogconf usr/sbin 4 | -------------------------------------------------------------------------------- /debian/openflow-common.manpages: -------------------------------------------------------------------------------- 1 | _debian/utilities/vlogconf.8 2 | _debian/utilities/ofp-pki.8 3 | -------------------------------------------------------------------------------- /debian/openflow-controller.README.Debian: -------------------------------------------------------------------------------- 1 | README.Debian for openflow-controller 2 | ------------------------------------- 3 | 4 | * To (re)configure the controller, edit /etc/default/openflow-controller 5 | and run "/etc/init.d/openflow-controller restart". 6 | 7 | * To enable OpenFlow switches to automatically discover the location 8 | of the controller, you must install and configure a DHCP server. 9 | The secchan(8) manpage (found in the openflow-switch package) gives 10 | a working example configuration file for the ISC DHCP server. 11 | -------------------------------------------------------------------------------- /debian/openflow-controller.default: -------------------------------------------------------------------------------- 1 | # This is a POSIX shell fragment -*- sh -*- 2 | 3 | # LISTEN: What OpenFlow connection methods should the controller listen on? 4 | # 5 | # This is a space-delimited list of connection methods: 6 | # 7 | # * "pssl:[PORT]": Listen for SSL connections on the specified PORT 8 | # (default: 6633). The private key, certificate, and CA certificate 9 | # must be specified below. 10 | # 11 | # * "pctp:[PORT]": Listen for TCP connections on the specified PORT 12 | # (default: 6633). Not recommended for security reasons. 13 | # 14 | # * "nl:DP_IDX": Listen on local datapath DP_IDX. Used only if this 15 | # machine is also an OpenFlow switch and not running the secure 16 | # channel, and only if you know what you're doing. 17 | # 18 | LISTEN="pssl:" 19 | 20 | # PRIVKEY: Name of file containing controller's private key. 21 | # Required if SSL enabled. 22 | PRIVKEY=/etc/openflow-controller/privkey.pem 23 | 24 | # CERT: Name of file containing certificate for private key. 25 | # Required if SSL enabled. 26 | CERT=/etc/openflow-controller/cert.pem 27 | 28 | # CACERT: Name of file containing switch CA certificate. 29 | # Required if SSL enabled. 30 | CACERT=/etc/openflow-controller/cacert.pem 31 | 32 | # Additional options to pass to controller, e.g. "--hub" 33 | DAEMON_OPTS="" 34 | -------------------------------------------------------------------------------- /debian/openflow-controller.dirs: -------------------------------------------------------------------------------- 1 | etc/openflow-controller 2 | -------------------------------------------------------------------------------- /debian/openflow-controller.install: -------------------------------------------------------------------------------- 1 | _debian/controller/controller usr/sbin 2 | -------------------------------------------------------------------------------- /debian/openflow-controller.manpages: -------------------------------------------------------------------------------- 1 | _debian/controller/controller.8 2 | -------------------------------------------------------------------------------- /debian/openflow-controller.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for openflow-controller 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | 21 | case "$1" in 22 | configure) 23 | cd /etc/openflow-controller 24 | if ! test -e cacert.pem; then 25 | ln -s /usr/share/openflow/pki/switchca/cacert.pem cacert.pem 26 | fi 27 | if ! test -e privkey.pem || ! test -e cert.pem; then 28 | oldumask=$(umask) 29 | umask 077 30 | ofp-pki req+sign tmp controller >/dev/null 31 | mv tmp-privkey.pem privkey.pem 32 | mv tmp-cert.pem cert.pem 33 | mv tmp-req.pem req.pem 34 | chmod go+r cert.pem req.pem 35 | umask $oldumask 36 | fi 37 | ;; 38 | 39 | abort-upgrade|abort-remove|abort-deconfigure) 40 | ;; 41 | 42 | *) 43 | echo "postinst called with unknown argument \`$1'" >&2 44 | exit 1 45 | ;; 46 | esac 47 | 48 | #DEBHELPER# 49 | 50 | exit 0 51 | 52 | 53 | -------------------------------------------------------------------------------- /debian/openflow-datapath-module-_KVERS_.postinst.modules.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for #PACKAGE# 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | depmod -a 9 | 10 | #DEBHELPER# 11 | 12 | # If the switch is running, restart it. This ensures that we are using the 13 | # latest kernel module, because the init script will unload and reload the 14 | # module. 15 | # 16 | # (Ideally we'd only want to do this if this package corresponds to the 17 | # running kernel, but I don't know a reliable way to check.) 18 | INIT=/etc/init.d/openflow-switch 19 | if test -x $INIT && $INIT status; then 20 | $INIT restart || true 21 | fi 22 | 23 | exit 0 24 | 25 | 26 | -------------------------------------------------------------------------------- /debian/openflow-datapath-source.README.Debian: -------------------------------------------------------------------------------- 1 | OpenFlow for Debian 2 | ------------------- 3 | 4 | * How do I build this module the Debian way? 5 | 6 | - Building with module-assistant: 7 | 8 | $ module-assistant auto-install openflow 9 | or 10 | $ m-a a-i openflow 11 | 12 | If kernel source or headers are in a non-standard directory, add 13 | the option -k /path/to/kernel/source with the correct path. 14 | 15 | - Building with make-kpkg 16 | 17 | $ cd /usr/src/ 18 | $ tar jxvf openflow.tar.bz2 19 | $ cd /usr/src/kernel-source-2.6.9 20 | $ make-kpkg --added-modules=openflow modules 21 | 22 | - Building without make-kpkg 23 | 24 | $ cd /usr/src/ 25 | $ tar jxvf openflow.tar.bz2 26 | $ cd modules/openflow 27 | $ fakeroot debian/rules kdist_image 28 | 29 | If you run this as root, fakeroot is not needed. 30 | 31 | -- OpenFlow Team , Thu, 12 Jun 2008 16:42:38 -0700 32 | -------------------------------------------------------------------------------- /debian/openflow-datapath-source.copyright: -------------------------------------------------------------------------------- 1 | Upstream Authors: 2 | 3 | The Board of Trustees of The Leland Stanford Junior University 4 | 5 | Copyright: 6 | 7 | Copyright (C) 2008 The Board of Trustees of The Leland Stanford 8 | Junior University 9 | 10 | License: 11 | 12 | Files in the datapath/ and its sub-directories are covered under the GNU 13 | General Public License Version 2. 14 | 15 | On Debian systems, the complete text of the GNU General 16 | Public License can be found in `/usr/share/common-licenses/GPL'. 17 | -------------------------------------------------------------------------------- /debian/openflow-datapath-source.dirs: -------------------------------------------------------------------------------- 1 | usr/src/modules/openflow-datapath/debian 2 | -------------------------------------------------------------------------------- /debian/openflow-datapath-source.install: -------------------------------------------------------------------------------- 1 | debian/changelog usr/src/modules/openflow-datapath/debian 2 | debian/control usr/src/modules/openflow-datapath/debian 3 | debian/compat usr/src/modules/openflow-datapath/debian 4 | debian/*.modules.in usr/src/modules/openflow-datapath/debian 5 | debian/rules usr/src/modules/openflow-datapath/debian 6 | _debian/openflow.tar.gz usr/src/modules/openflow-datapath 7 | -------------------------------------------------------------------------------- /debian/openflow-pki-server.apache2: -------------------------------------------------------------------------------- 1 | Alias /openflow/pki/ /usr/share/openflow/pki/ 2 | -------------------------------------------------------------------------------- /debian/openflow-pki-server.dirs: -------------------------------------------------------------------------------- 1 | etc/apache2/sites-available 2 | -------------------------------------------------------------------------------- /debian/openflow-pki-server.install: -------------------------------------------------------------------------------- 1 | _debian/utilities/ofp-pki-cgi usr/lib/cgi-bin 2 | -------------------------------------------------------------------------------- /debian/openflow-pki-server.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for openflow 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | case "$1" in 21 | configure) 22 | # Enable site under Apache. 23 | a2ensite openflow-pki >/dev/null 24 | if command -v invoke-rc.d >/dev/null 2>&1; then 25 | invoke-rc.d apache2 force-reload || : 26 | else 27 | [ -x /etc/init.d/apache2 ] && /etc/init.d/apache2 force-reload || : 28 | fi 29 | ;; 30 | 31 | abort-upgrade|abort-remove|abort-deconfigure) 32 | ;; 33 | 34 | *) 35 | echo "postinst called with unknown argument \`$1'" >&2 36 | exit 1 37 | ;; 38 | esac 39 | 40 | #DEBHELPER# 41 | 42 | exit 0 43 | 44 | 45 | -------------------------------------------------------------------------------- /debian/openflow-pki.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for openflow 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | case "$1" in 21 | configure) 22 | # Create certificate authorities. 23 | if test ! -d /usr/share/openflow/pki; then 24 | ofp-pki init 25 | fi 26 | ;; 27 | 28 | abort-upgrade|abort-remove|abort-deconfigure) 29 | ;; 30 | 31 | *) 32 | echo "postinst called with unknown argument \`$1'" >&2 33 | exit 1 34 | ;; 35 | esac 36 | 37 | #DEBHELPER# 38 | 39 | exit 0 40 | 41 | 42 | -------------------------------------------------------------------------------- /debian/openflow-switch-config.dirs: -------------------------------------------------------------------------------- 1 | /usr/share/lintian/overrides 2 | -------------------------------------------------------------------------------- /debian/openflow-switch-config.install: -------------------------------------------------------------------------------- 1 | debian/ofp-switch-setup usr/sbin 2 | -------------------------------------------------------------------------------- /debian/openflow-switch-config.manpages: -------------------------------------------------------------------------------- 1 | debian/ofp-switch-setup.8 2 | -------------------------------------------------------------------------------- /debian/openflow-switch-config.overrides: -------------------------------------------------------------------------------- 1 | debconf-is-not-a-registry 2 | -------------------------------------------------------------------------------- /debian/openflow-switch.README.Debian: -------------------------------------------------------------------------------- 1 | README.Debian for openflow-switch 2 | --------------------------------- 3 | 4 | * The switch must be configured before it can be used. To configure 5 | it interactively, install the openflow-switch-config package and run 6 | the ofp-switch-setup program. Alternatively, edit 7 | /etc/default/openflow-switch by hand, then start the switch manually 8 | with "/etc/init.d/openflow-switch start". 9 | 10 | * To use the Linux kernel-based switch implementation, you will need 11 | to build and install the OpenFlow kernel module. To do so, install 12 | the openflow-datapath-source package, then follow the instructions 13 | given in /usr/share/doc/openflow-datapath-source/README.Debian 14 | 15 | * This package does not yet support the userspace datapath-based 16 | switch implementation. 17 | 18 | -- Ben Pfaff , Tue, 6 Jan 2009 13:52:33 -0800 19 | -------------------------------------------------------------------------------- /debian/openflow-switch.dirs: -------------------------------------------------------------------------------- 1 | /etc/openflow-switch 2 | /usr/share/openflow/switch 3 | -------------------------------------------------------------------------------- /debian/openflow-switch.install: -------------------------------------------------------------------------------- 1 | _debian/secchan/ofprotocol usr/sbin 2 | _debian/utilities/dpctl usr/sbin 3 | _debian/utilities/ofp-discover usr/sbin 4 | _debian/utilities/ofp-kill usr/sbin 5 | debian/openflow/usr/share/openflow/commands/* usr/share/openflow/commands 6 | debian/commands/* usr/share/openflow/commands 7 | -------------------------------------------------------------------------------- /debian/openflow-switch.logrotate: -------------------------------------------------------------------------------- 1 | /var/log/openflow/secchan.log { 2 | daily 3 | compress 4 | create 640 root adm 5 | delaycompress 6 | missingok 7 | rotate 30 8 | postrotate 9 | vlogconf --target /var/run/secchan.pid --reopen 10 | endscript 11 | } 12 | -------------------------------------------------------------------------------- /debian/openflow-switch.manpages: -------------------------------------------------------------------------------- 1 | _debian/secchan/ofprotocol.8 2 | _debian/utilities/ofp-discover.8 3 | _debian/utilities/ofp-kill.8 4 | _debian/utilities/dpctl.8 5 | -------------------------------------------------------------------------------- /debian/openflow-switch.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for openflow-switch 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | 21 | case "$1" in 22 | configure) 23 | DEFAULT=/etc/default/openflow-switch 24 | TEMPLATE=/usr/share/openflow/switch/default.template 25 | if ! test -e $DEFAULT; then 26 | cp $TEMPLATE $DEFAULT 27 | else 28 | for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE) 29 | do 30 | if ! grep $var $DEFAULT >/dev/null 2>&1; then 31 | echo >> $DEFAULT 32 | sed -n "/$var:/,/$var=/p" $TEMPLATE >> $DEFAULT 33 | fi 34 | done 35 | fi 36 | ;; 37 | 38 | abort-upgrade|abort-remove|abort-deconfigure) 39 | ;; 40 | 41 | *) 42 | echo "postinst called with unknown argument \`$1'" >&2 43 | exit 1 44 | ;; 45 | esac 46 | 47 | #DEBHELPER# 48 | 49 | exit 0 50 | 51 | 52 | -------------------------------------------------------------------------------- /debian/openflow-switch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postrm script for openflow-switch 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `remove' 10 | # * `purge' 11 | # * `upgrade' 12 | # * `failed-upgrade' 13 | # * `abort-install' 14 | # * `abort-install' 15 | # * `abort-upgrade' 16 | # * `disappear' 17 | # 18 | # for details, see http://www.debian.org/doc/debian-policy/ or 19 | # the debian-policy package 20 | 21 | 22 | case "$1" in 23 | purge) 24 | rm -f /etc/default/openflow-switch 25 | ;; 26 | 27 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 28 | ;; 29 | 30 | *) 31 | echo "postrm called with unknown argument \`$1'" >&2 32 | exit 1 33 | ;; 34 | esac 35 | 36 | # dh_installdeb will replace this with shell code automatically 37 | # generated by other debhelper scripts. 38 | 39 | #DEBHELPER# 40 | 41 | exit 0 42 | 43 | 44 | -------------------------------------------------------------------------------- /debian/po/POTFILES.in: -------------------------------------------------------------------------------- 1 | [type: gettext/rfc822deb] openflow-switch-config.templates 2 | -------------------------------------------------------------------------------- /include/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | -------------------------------------------------------------------------------- /include/automake.mk: -------------------------------------------------------------------------------- 1 | include include/openflow/automake.mk 2 | -------------------------------------------------------------------------------- /include/openflow/automake.mk: -------------------------------------------------------------------------------- 1 | noinst_HEADERS += \ 2 | include/openflow/nicira-ext.h \ 3 | include/openflow/private-ext.h \ 4 | include/openflow/openflow.h \ 5 | include/openflow/openflow-netlink.h 6 | -------------------------------------------------------------------------------- /include/openflow/openflow-netlink.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef OPENFLOW_OPENFLOW_NETLINK_H 35 | #define OPENFLOW_OPENFLOW_NETLINK_H 1 36 | 37 | #define DP_GENL_FAMILY_NAME "OpenFlow" 38 | 39 | /* Attributes that can be attached to the datapath's netlink messages. */ 40 | enum { 41 | DP_GENL_A_UNSPEC, 42 | DP_GENL_A_DP_IDX, /* Datapath device index. */ 43 | DP_GENL_A_PORTNAME, /* Device name for datapath port. */ 44 | DP_GENL_A_MC_GROUP, /* Generic netlink multicast group. */ 45 | DP_GENL_A_OPENFLOW, /* OpenFlow packet. */ 46 | DP_GENL_A_DP_NAME, /* Datapath device name. */ 47 | 48 | __DP_GENL_A_MAX, 49 | DP_GENL_A_MAX = __DP_GENL_A_MAX - 1 50 | }; 51 | 52 | /* Commands that can be executed on the datapath's netlink interface. */ 53 | enum dp_genl_command { 54 | DP_GENL_C_UNSPEC, 55 | DP_GENL_C_ADD_DP, /* Create datapath. */ 56 | DP_GENL_C_DEL_DP, /* Destroy datapath. */ 57 | DP_GENL_C_QUERY_DP, /* Get multicast group for datapath. */ 58 | DP_GENL_C_ADD_PORT, /* Add port to datapath. */ 59 | DP_GENL_C_DEL_PORT, /* Remove port from datapath. */ 60 | DP_GENL_C_OPENFLOW, /* Encapsulated OpenFlow protocol. */ 61 | 62 | __DP_GENL_C_MAX, 63 | DP_GENL_C_MAX = __DP_GENL_C_MAX - 1 64 | }; 65 | 66 | /* Maximum number of datapaths. */ 67 | #define DP_MAX 256 68 | 69 | #endif /* openflow/openflow-netlink.h */ 70 | -------------------------------------------------------------------------------- /include/openflow/private-ext.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008, 2009 3 | * The Board of Trustees of The Leland Stanford Junior University 4 | * 5 | * We are making the OpenFlow specification and associated documentation 6 | * (Software) available for public use and benefit with the expectation that 7 | * others will use, modify and enhance the Software and contribute those 8 | * enhancements back to the community. However, since we would like to make the 9 | * Software available for broadest use, with as few restrictions as possible 10 | * permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this Software to deal in the Software under the copyrights without 12 | * restriction, including without limitation the rights to use, copy, modify, 13 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, 14 | * and to permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 26 | * IN THE SOFTWARE. 27 | * 28 | * The name and trademarks of copyright holder(s) may NOT be used in 29 | * advertising or publicity pertaining to the Software or any derivatives 30 | * without specific, written prior permission. 31 | */ 32 | 33 | #ifndef OPENFLOW_PRIVATE_EXT_H_ 34 | #define OPENFLOW_PRIVATE_EXT_H_ 35 | 36 | #ifdef __KERNEL__ 37 | #include 38 | #endif 39 | 40 | #include "openflow/openflow.h" 41 | 42 | /* 43 | * The following PRIVATE vendor extensions are just sample and may never be 44 | * ready for standardization, so they are not included in openflow.h. 45 | * 46 | * As a sample, we use private OUI (AC-DE-48) for PRIVATE vendor ID. 47 | */ 48 | 49 | #define PRIVATE_VENDOR_ID 0x00acde48 50 | #define PRIVATEOPT_PROTOCOL_STATS_REQUEST 0x0001 51 | #define PRIVATEOPT_PROTOCOL_STATS_REPLY 0x0002 52 | #define PRIVATEOPT_EMERG_FLOW_PROTECTION 0x0003 53 | #define PRIVATEOPT_EMERG_FLOW_RESTORATION 0x0004 54 | 55 | struct private_vxhdr { 56 | struct ofp_header ofp_hdr; /* protocol header */ 57 | uint32_t ofp_vxid; /* vendor extenion ID */ 58 | } __attribute__ ((__packed__)); 59 | 60 | /* TLV encoding */ 61 | struct private_vxopt { 62 | uint16_t pvo_type; /* type of vendor extension option */ 63 | uint16_t pvo_len; /* length of value (octet) */ 64 | /* followed by value */ 65 | /* uint8_t pvo_value[0]; */ 66 | } __attribute__ ((__packed__)); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /dhparams.c 4 | -------------------------------------------------------------------------------- /lib/backtrace.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef BACKTRACE_H 35 | #define BACKTRACE_H 1 36 | 37 | #include 38 | 39 | #define BACKTRACE_MAX_FRAMES 31 40 | 41 | struct backtrace { 42 | int n_frames; 43 | uintptr_t frames[BACKTRACE_MAX_FRAMES]; 44 | }; 45 | 46 | void backtrace_capture(struct backtrace *); 47 | 48 | #endif /* backtrace.h */ 49 | -------------------------------------------------------------------------------- /lib/command-line.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #include 35 | #include "command-line.h" 36 | #include 37 | #include 38 | #include "util.h" 39 | #include "vlog.h" 40 | 41 | /* Given the GNU-style long options in 'options', returns a string that may be 42 | * passed to getopt() with the corresponding short options. The caller is 43 | * responsible for freeing the string. */ 44 | char * 45 | long_options_to_short_options(const struct option options[]) 46 | { 47 | char short_options[UCHAR_MAX * 3 + 1]; 48 | char *p = short_options; 49 | 50 | for (; options->name; options++) { 51 | const struct option *o = options; 52 | if (o->flag == NULL && o->val > 0 && o->val <= UCHAR_MAX) { 53 | *p++ = o->val; 54 | if (o->has_arg == required_argument) { 55 | *p++ = ':'; 56 | } else if (o->has_arg == optional_argument) { 57 | *p++ = ':'; 58 | *p++ = ':'; 59 | } 60 | } 61 | } 62 | *p = '\0'; 63 | 64 | return xstrdup(short_options); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /lib/command-line.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef COMMAND_LINE_H 35 | #define COMMAND_LINE_H 1 36 | 37 | /* Utilities for command-line parsing. */ 38 | 39 | struct option; 40 | char *long_options_to_short_options(const struct option *options); 41 | 42 | #endif /* command-line.h */ 43 | -------------------------------------------------------------------------------- /lib/common.man: -------------------------------------------------------------------------------- 1 | .TP 2 | .BR \-h ", " \-\^\-help 3 | Prints a brief help message to the console. 4 | 5 | .TP 6 | .BR \-V ", " \-\^\-version 7 | Prints version information to the console. 8 | -------------------------------------------------------------------------------- /lib/compiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef COMPILER_H 35 | #define COMPILER_H 1 36 | 37 | #define NO_RETURN __attribute__((__noreturn__)) 38 | #define UNUSED __attribute__((__unused__)) 39 | #define PACKED __attribute__((__packed__)) 40 | #define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1))) 41 | #define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0))) 42 | #define MALLOC_LIKE __attribute__((__malloc__)) 43 | #define likely(x) __builtin_expect((x),1) 44 | #define unlikely(x) __builtin_expect((x),0) 45 | 46 | #endif /* compiler.h */ 47 | -------------------------------------------------------------------------------- /lib/csum.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef CSUM_H 35 | #define CSUM_H 1 36 | 37 | #include 38 | #include 39 | 40 | uint16_t csum(const void *, size_t); 41 | uint32_t csum_add16(uint32_t partial, uint16_t); 42 | uint32_t csum_add32(uint32_t partial, uint32_t); 43 | uint32_t csum_continue(uint32_t partial, const void *, size_t); 44 | uint16_t csum_finish(uint32_t partial); 45 | uint16_t recalc_csum16(uint16_t old_csum, uint16_t old_u16, uint16_t new_u16); 46 | uint16_t recalc_csum32(uint16_t old_csum, uint32_t old_u32, uint32_t new_u32); 47 | 48 | #endif /* csum.h */ 49 | -------------------------------------------------------------------------------- /lib/daemon.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef DAEMON_H 35 | #define DAEMON_H 1 36 | 37 | #include 38 | #include 39 | 40 | #define DAEMON_LONG_OPTIONS \ 41 | {"detach", no_argument, 0, 'D'}, \ 42 | {"force", no_argument, 0, 'f'}, \ 43 | {"pidfile", optional_argument, 0, 'P'} 44 | 45 | #define DAEMON_OPTION_HANDLERS \ 46 | case 'D': \ 47 | set_detach(); \ 48 | break; \ 49 | \ 50 | case 'P': \ 51 | set_pidfile(optarg); \ 52 | break; \ 53 | \ 54 | case 'f': \ 55 | ignore_existing_pidfile(); \ 56 | break; 57 | 58 | char *make_pidfile_name(const char *name); 59 | void set_pidfile(const char *name); 60 | const char *get_pidfile(void); 61 | void set_detach(void); 62 | void daemonize(void); 63 | void die_if_already_running(void); 64 | void ignore_existing_pidfile(void); 65 | void daemon_usage(void); 66 | pid_t read_pidfile(const char *name); 67 | 68 | #endif /* daemon.h */ 69 | -------------------------------------------------------------------------------- /lib/daemon.man: -------------------------------------------------------------------------------- 1 | .TP 2 | \fB-P\fR[\fIpidfile\fR], \fB--pidfile\fR[\fB=\fIpidfile\fR] 3 | Causes a file (by default, \fB\*(PN.pid\fR) to be created indicating 4 | the PID of the running process. If \fIpidfile\fR is not specified, or 5 | if it does not begin with \fB/\fR, then it is created in 6 | \fB@RUNDIR@\fR. 7 | 8 | .TP 9 | \fB-f\fR, \fB--force\fR 10 | By default, when \fB-P\fR or \fB--pidfile\fR is specified and the 11 | specified pidfile already exists and is locked by a running process, 12 | \fB\*(PN\fR refuses to start. Specify \fB-f\fR or \fB--force\fR 13 | to cause it to instead overwrite the pidfile. 14 | 15 | When \fB-P\fR or \fB--pidfile\fR is not specified, this option has no 16 | effect. 17 | 18 | .TP 19 | \fB-D\fR, \fB--detach\fR 20 | Causes \fB\*(PN\fR to detach itself from the foreground session and 21 | run as a background process. 22 | -------------------------------------------------------------------------------- /lib/dh1024.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIGHAoGBAPSI/VhOSdvNILSd5JEHNmszbDgNRR0PfIizHHxbLY7288kjwEPwpVsY 3 | jY67VYy4XTjTNP18F1dDox0YbN4zISy1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6 4 | ypUM2Zafq9AKUJsCRtMIPWakXUGfnHy9iUsiGSa6q6Jew1XpL3jHAgEC 5 | -----END DH PARAMETERS----- 6 | 7 | These are the 1024 bit DH parameters from "Assigned Number for SKIP Protocols" 8 | (http://www.skip-vpn.org/spec/numbers.html). 9 | See there for how they were generated. 10 | Note that g is not a generator, but this is not a problem since p is a safe prime. 11 | -------------------------------------------------------------------------------- /lib/dh2048.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEA9kJXtwh/CBdyorrWqULzBej5UxE5T7bxbrlLOCDaAadWoxTpj0BV 3 | 89AHxstDqZSt90xkhkn4DIO9ZekX1KHTUPj1WV/cdlJPPT2N286Z4VeSWc39uK50 4 | T8X8dryDxUcwYc58yWb/Ffm7/ZFexwGq01uejaClcjrUGvC/RgBYK+X0iP1YTknb 5 | zSC0neSRBzZrM2w4DUUdD3yIsxx8Wy2O9vPJI8BD8KVbGI2Ou1WMuF040zT9fBdX 6 | Q6MdGGzeMyEstSr/POGxKUAYEY18hKcKctaGxAMZyAcpesqVDNmWn6vQClCbAkbT 7 | CD1mpF1Bn5x8vYlLIhkmuquiXsNV6TILOwIBAg== 8 | -----END DH PARAMETERS----- 9 | 10 | These are the 2048 bit DH parameters from "Assigned Number for SKIP Protocols" 11 | (http://www.skip-vpn.org/spec/numbers.html). 12 | See there for how they were generated. 13 | -------------------------------------------------------------------------------- /lib/dh4096.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIICCAKCAgEA+hRyUsFN4VpJ1O8JLcCo/VWr19k3BCgJ4uk+d+KhehjdRqNDNyOQ 3 | l/MOyQNQfWXPeGKmOmIig6Ev/nm6Nf9Z2B1h3R4hExf+zTiHnvVPeRBhjdQi81rt 4 | Xeoh6TNrSBIKIHfUJWBh3va0TxxjQIs6IZOLeVNRLMqzeylWqMf49HsIXqbcokUS 5 | Vt1BkvLdW48j8PPv5DsKRN3tloTxqDJGo9tKvj1Fuk74A+Xda1kNhB7KFlqMyN98 6 | VETEJ6c7KpfOo30mnK30wqw3S8OtaIR/maYX72tGOno2ehFDkq3pnPtEbD2CScxc 7 | alJC+EL7RPk5c/tgeTvCngvc1KZn92Y//EI7G9tPZtylj2b56sHtMftIoYJ9+ODM 8 | sccD5Piz/rejE3Ome8EOOceUSCYAhXn8b3qvxVI1ddd1pED6FHRhFvLrZxFvBEM9 9 | ERRMp5QqOaHJkM+Dxv8Cj6MqrCbfC4u+ZErxodzuusgDgvZiLF22uxMZbobFWyte 10 | OvOzKGtwcTqO/1wV5gKkzu1ZVswVUQd5Gg8lJicwqRWyyNRczDDoG9jVDxmogKTH 11 | AaqLulO7R8Ifa1SwF2DteSGVtgWEN8gDpN3RBmmPTDngyF2DHb5qmpnznwtFKdTL 12 | KWbuHn491xNO25CQWMtem80uKw+pTnisBRF/454n1Jnhub144YRBoN8CAQI= 13 | -----END DH PARAMETERS----- 14 | 15 | These are the 4096 bit DH parameters from "Assigned Number for SKIP Protocols" 16 | (http://www.skip-vpn.org/spec/numbers.html). 17 | See there for how they were generated. 18 | Note that g is not a generator, but this is not a problem since p is a safe prime. 19 | -------------------------------------------------------------------------------- /lib/dhcp-client.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef DHCP_CLIENT_H 35 | #define DHCP_CLIENT_H 1 36 | 37 | #include 38 | #include 39 | 40 | struct dhclient; 41 | struct dhcp_msg; 42 | struct netdev; 43 | int dhclient_create(const char *netdev, 44 | void (*modify_request)(struct dhcp_msg *, void *aux), 45 | bool (*validate_offer)(const struct dhcp_msg *, void *aux), 46 | void *aux, struct dhclient **); 47 | void dhclient_set_max_timeout(struct dhclient *, unsigned int max_timeout); 48 | void dhclient_destroy(struct dhclient *); 49 | 50 | struct netdev *dhclient_get_netdev(struct dhclient *); 51 | 52 | void dhclient_init(struct dhclient *, uint32_t requested_ip); 53 | void dhclient_release(struct dhclient *); 54 | void dhclient_force_renew(struct dhclient *, int deadline); 55 | bool dhclient_is_bound(const struct dhclient *); 56 | bool dhclient_changed(struct dhclient *); 57 | 58 | const char *dhclient_get_state(const struct dhclient *); 59 | unsigned int dhclient_get_state_elapsed(const struct dhclient *); 60 | unsigned int dhclient_get_lease_remaining(const struct dhclient *); 61 | 62 | uint32_t dhclient_get_ip(const struct dhclient *); 63 | uint32_t dhclient_get_netmask(const struct dhclient *); 64 | uint32_t dhclient_get_router(const struct dhclient *); 65 | const struct dhcp_msg *dhclient_get_config(const struct dhclient *); 66 | 67 | int dhclient_configure_netdev(struct dhclient *); 68 | int dhclient_update_resolv_conf(struct dhclient *); 69 | 70 | void dhclient_run(struct dhclient *); 71 | void dhclient_wait(struct dhclient *); 72 | 73 | #endif /* dhcp-client.h */ 74 | -------------------------------------------------------------------------------- /lib/dhparams.h: -------------------------------------------------------------------------------- 1 | #ifndef DHPARAMS_H 2 | #define DHPARAMS_H 1 3 | 4 | #include 5 | 6 | DH *get_dh1024(void); 7 | DH *get_dh2048(void); 8 | DH *get_dh4096(void); 9 | 10 | #endif /* dhparams.h */ 11 | -------------------------------------------------------------------------------- /lib/dirs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef DIRS_H 35 | #define DIRS_H 1 36 | 37 | extern const char ofp_pkgdatadir[]; /* /usr/local/share/openflow */ 38 | extern const char ofp_rundir[]; /* /usr/local/var/run */ 39 | extern const char ofp_logdir[]; /* /usr/local/var/log */ 40 | 41 | #endif /* dirs.h */ 42 | -------------------------------------------------------------------------------- /lib/dpif.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | 35 | #ifndef DPIF_H 36 | #define DPIF_H 1 37 | 38 | /* Operations for the datapath running in the local kernel. The interface can 39 | * generalize to multiple types of local datapaths, but the implementation only 40 | * supports the openflow kernel module via netlink. */ 41 | 42 | #include 43 | #include 44 | 45 | struct ofpbuf; 46 | struct ofp_match; 47 | 48 | /* A datapath interface. Opaque. */ 49 | struct dpif 50 | { 51 | struct nl_sock *sock; 52 | }; 53 | 54 | int dpif_open(int subscribe_dp_idx, struct dpif *); 55 | void dpif_close(struct dpif *); 56 | 57 | /* OpenFlow. */ 58 | int dpif_recv_openflow(struct dpif *, int dp_idx, struct ofpbuf **, bool wait); 59 | int dpif_send_openflow(struct dpif *, int dp_idx, struct ofpbuf *); 60 | 61 | /* Management functions. */ 62 | int dpif_add_dp(struct dpif *, int dp_idx, const char *dp_name); 63 | int dpif_del_dp(struct dpif *, int dp_idx, const char *dp_name); 64 | int dpif_add_port(struct dpif *, int dp_idx, const char *netdev); 65 | int dpif_del_port(struct dpif *, int dp_idx, const char *netdev); 66 | int dpif_get_idx(const char *dp_name); 67 | 68 | #endif /* dpif.h */ 69 | -------------------------------------------------------------------------------- /lib/dynamic-string.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef DYNAMIC_STRING_H 35 | #define DYNAMIC_STRING_H 1 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "compiler.h" 43 | 44 | struct tm; 45 | 46 | struct ds { 47 | char *string; /* Null-terminated string. */ 48 | size_t length; /* Bytes used, not including null terminator. */ 49 | size_t allocated; /* Bytes allocated, not including null terminator. */ 50 | }; 51 | 52 | #define DS_EMPTY_INITIALIZER { NULL, 0, 0 } 53 | 54 | void ds_init(struct ds *); 55 | void ds_clear(struct ds *); 56 | void ds_truncate(struct ds *, size_t new_length); 57 | void ds_reserve(struct ds *, size_t min_length); 58 | char *ds_put_uninit(struct ds *, size_t n); 59 | void ds_put_char(struct ds *, char); 60 | void ds_put_char_multiple(struct ds *, char, size_t n); 61 | void ds_put_buffer(struct ds *, const char *, size_t n); 62 | void ds_put_cstr(struct ds *, const char *); 63 | void ds_put_format(struct ds *, const char *, ...) PRINTF_FORMAT(2, 3); 64 | void ds_put_format_valist(struct ds *, const char *, va_list) 65 | PRINTF_FORMAT(2, 0); 66 | void ds_put_printable(struct ds *, const char *, size_t); 67 | void ds_put_strftime(struct ds *, const char *, const struct tm *) 68 | STRFTIME_FORMAT(2); 69 | void ds_put_hex_dump(struct ds *ds, const void *buf_, size_t size, 70 | uintptr_t ofs, bool ascii); 71 | int ds_get_line(struct ds *, FILE *); 72 | 73 | char *ds_cstr(struct ds *); 74 | void ds_destroy(struct ds *); 75 | 76 | int ds_last(const struct ds *); 77 | void ds_chomp(struct ds *, int c); 78 | 79 | #endif /* dynamic-string.h */ 80 | -------------------------------------------------------------------------------- /lib/fatal-signal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef FATAL_SIGNAL_H 35 | #define FATAL_SIGNAL_H 1 36 | 37 | #include 38 | 39 | /* Basic interface. */ 40 | void fatal_signal_add_hook(void (*)(void *aux), void *aux, bool run_at_exit); 41 | void fatal_signal_block(void); 42 | void fatal_signal_unblock(void); 43 | void fatal_signal_fork(void); 44 | 45 | /* Convenience functions for unlinking files upon termination. 46 | * 47 | * These functions also unlink the files upon normal process termination via 48 | * exit(). */ 49 | void fatal_signal_add_file_to_unlink(const char *); 50 | void fatal_signal_remove_file_to_unlink(const char *); 51 | 52 | /* Interface for other code that catches one of our signals and needs to pass 53 | * it through. */ 54 | void fatal_signal_handler(int sig_nr); 55 | 56 | #endif /* fatal-signal.h */ 57 | -------------------------------------------------------------------------------- /lib/fault.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #include 35 | #include "fault.h" 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "util.h" 43 | 44 | #include "vlog.h" 45 | #define LOG_MODULE VLM_fault 46 | 47 | static void 48 | fault_handler(int sig_nr) 49 | { 50 | VLOG_EMER(LOG_MODULE, "Caught signal %d.", sig_nr); 51 | log_backtrace(); 52 | fflush(stdout); 53 | fflush(stderr); 54 | 55 | signal(sig_nr, SIG_DFL); 56 | raise(sig_nr); 57 | } 58 | 59 | void 60 | log_backtrace(void) 61 | { 62 | /* During the loop: 63 | 64 | frame[0] points to the next frame. 65 | frame[1] points to the return address. */ 66 | void **frame; 67 | #define STACK_DEPTH_LIMIT 128 68 | int stack_depth = 0; 69 | for (frame = __builtin_frame_address(0); 70 | frame != NULL && frame[0] != NULL 71 | && stack_depth < STACK_DEPTH_LIMIT; 72 | frame = frame[0], ++stack_depth) { 73 | Dl_info addrinfo; 74 | if (!dladdr(frame[1], &addrinfo) || !addrinfo.dli_sname) { 75 | fprintf(stderr, " 0x%08"PRIxPTR"\n", (uintptr_t) frame[1]); 76 | } else { 77 | fprintf(stderr, " 0x%08"PRIxPTR" (%s+%zu)\n", 78 | (uintptr_t) frame[1], addrinfo.dli_sname, 79 | (char *) frame[1] - (char *) addrinfo.dli_saddr); 80 | } 81 | } 82 | fflush(stderr); 83 | } 84 | 85 | void 86 | register_fault_handlers(void) 87 | { 88 | signal(SIGABRT, fault_handler); 89 | signal(SIGBUS, fault_handler); 90 | signal(SIGFPE, fault_handler); 91 | signal(SIGILL, fault_handler); 92 | signal(SIGSEGV, fault_handler); 93 | } 94 | -------------------------------------------------------------------------------- /lib/fault.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef FAULT_H 35 | #define FAULT_H 1 36 | 37 | void register_fault_handlers(void); 38 | void log_backtrace(void); 39 | 40 | #endif /* fault.h */ 41 | -------------------------------------------------------------------------------- /lib/hash.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | #ifndef HASH_H 34 | #define HASH_H 1 35 | 36 | #include 37 | #include 38 | 39 | uint32_t hash_words(const uint32_t *, size_t n_word, uint32_t basis); 40 | uint32_t hash_bytes(const void *, size_t n_bytes, uint32_t basis); 41 | 42 | #endif /* hash.h */ 43 | -------------------------------------------------------------------------------- /lib/leak-checker.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef LEAK_CHECKER_H 35 | #define LEAK_CHECKER_H 1 36 | 37 | #include 38 | 39 | #define LEAK_CHECKER_OPTION_ENUMS \ 40 | OPT_CHECK_LEAKS, \ 41 | OPT_LEAK_LIMIT 42 | #define LEAK_CHECKER_LONG_OPTIONS \ 43 | {"check-leaks", required_argument, 0, OPT_CHECK_LEAKS}, \ 44 | {"leak-limit", required_argument, 0, OPT_LEAK_LIMIT} 45 | #define LEAK_CHECKER_OPTION_HANDLERS \ 46 | case OPT_CHECK_LEAKS: \ 47 | leak_checker_start(optarg); \ 48 | break; \ 49 | case OPT_LEAK_LIMIT: \ 50 | leak_checker_set_limit(atol(optarg)); \ 51 | break; 52 | void leak_checker_start(const char *file_name); 53 | void leak_checker_set_limit(off_t limit); 54 | void leak_checker_stop(void); 55 | void leak_checker_claim(const void *); 56 | void leak_checker_usage(void); 57 | 58 | #endif /* leak-checker.h */ 59 | -------------------------------------------------------------------------------- /lib/leak-checker.man: -------------------------------------------------------------------------------- 1 | .TP 2 | \fB--check-leaks=\fIfile\fR 3 | . 4 | Logs information about memory allocation and deallocation to 5 | \fIfile\fR, to allow for debugging memory leaks in \fB\*(PN\fR. This 6 | option slows down \fB\*(PN\fR considerably, so it should only be used 7 | when a memory leak is suspected. 8 | -------------------------------------------------------------------------------- /lib/mac-learning.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef MAC_LEARNING_H 35 | #define MAC_LEARNING_H 1 36 | 37 | #include "packets.h" 38 | #include "tag.h" 39 | 40 | struct mac_learning *mac_learning_create(void); 41 | void mac_learning_destroy(struct mac_learning *); 42 | tag_type mac_learning_learn(struct mac_learning *, 43 | const uint8_t src[ETH_ADDR_LEN], uint16_t vlan, 44 | uint16_t src_port); 45 | uint16_t mac_learning_lookup(const struct mac_learning *, 46 | const uint8_t dst[ETH_ADDR_LEN], uint16_t vlan); 47 | uint32_t mac_learning_lookup_tag(const struct mac_learning *, 48 | const uint8_t dst[ETH_ADDR_LEN], 49 | uint16_t vlan, tag_type *tag); 50 | void mac_learning_flush(struct mac_learning *); 51 | void mac_learning_run(struct mac_learning *, struct tag_set *); 52 | void mac_learning_wait(struct mac_learning *); 53 | 54 | #endif /* mac-learning.h */ 55 | -------------------------------------------------------------------------------- /lib/pcap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef PCAP_H 35 | #define PCAP_H 1 36 | 37 | #include 38 | 39 | struct ofpbuf; 40 | 41 | FILE *pcap_open(const char *file_name, const char *mode); 42 | int pcap_read_header(FILE *); 43 | void pcap_write_header(FILE *); 44 | int pcap_read(FILE *, struct ofpbuf **); 45 | void pcap_write(FILE *, struct ofpbuf *); 46 | 47 | #endif /* dhcp.h */ 48 | -------------------------------------------------------------------------------- /lib/poll-loop.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | /* High-level wrapper around the "poll" system call. 35 | * 36 | * Intended usage is for the program's main loop to go about its business 37 | * servicing whatever events it needs to. Then, when it runs out of immediate 38 | * tasks, it calls each subordinate module's "wait" function, which in turn 39 | * calls one (or more) of the functions poll_fd_wait(), poll_immediate_wake(), 40 | * and poll_timer_wait() to register to be awakened when the appropriate event 41 | * occurs. Then the main loop calls poll_block(), which blocks until one of 42 | * the registered events happens. 43 | * 44 | * There is also some support for autonomous subroutines that are executed by 45 | * poll_block() when a file descriptor becomes ready. To prevent these 46 | * routines from starving if events are continuously ready, the application 47 | * should bound the amount of work it does between poll_block() calls. */ 48 | 49 | #ifndef POLL_LOOP_H 50 | #define POLL_LOOP_H 1 51 | 52 | #include 53 | 54 | struct poll_waiter; 55 | 56 | /* Schedule events to wake up the following poll_block(). */ 57 | struct poll_waiter *poll_fd_wait(int fd, short int events); 58 | void poll_timer_wait(int msec); 59 | void poll_immediate_wake(void); 60 | 61 | /* Wait until an event occurs. */ 62 | void poll_block(void); 63 | 64 | /* Autonomous function callbacks. */ 65 | typedef void poll_fd_func(int fd, short int revents, void *aux); 66 | struct poll_waiter *poll_fd_callback(int fd, short int events, 67 | poll_fd_func *, void *aux); 68 | 69 | /* Cancel a file descriptor callback or event. */ 70 | void poll_cancel(struct poll_waiter *); 71 | 72 | #endif /* poll-loop.h */ 73 | -------------------------------------------------------------------------------- /lib/process.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef PROCESS_H 35 | #define PROCESS_H 1 36 | 37 | #include 38 | #include 39 | 40 | struct process; 41 | void process_init(void); 42 | char *process_escape_args(char **argv); 43 | int process_start(char **argv, 44 | const int *keep_fds, size_t n_keep_fds, 45 | const int *null_fds, size_t n_null_fds, 46 | struct process **); 47 | void process_destroy(struct process *); 48 | int process_kill(const struct process *, int signr); 49 | 50 | int process_run(char **argv, 51 | const int *keep_fds, size_t n_keep_fds, 52 | const int *null_fds, size_t n_null_fds, 53 | int *status); 54 | 55 | pid_t process_pid(const struct process *); 56 | const char *process_name(const struct process *); 57 | bool process_exited(struct process *); 58 | int process_status(const struct process *); 59 | char *process_status_msg(int); 60 | 61 | void process_wait(struct process *); 62 | 63 | #endif /* process.h */ 64 | -------------------------------------------------------------------------------- /lib/queue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef QUEUE_H 35 | #define QUEUE_H 1 36 | 37 | /* Packet queue. */ 38 | struct ofp_queue { 39 | int n; /* Number of queued packets. */ 40 | struct ofpbuf *head; /* First queued packet, null if n == 0. */ 41 | struct ofpbuf *tail; /* Last queued packet, null if n == 0. */ 42 | }; 43 | 44 | void queue_init(struct ofp_queue *); 45 | void queue_destroy(struct ofp_queue *); 46 | void queue_clear(struct ofp_queue *); 47 | void queue_advance_head(struct ofp_queue *, struct ofpbuf *next); 48 | void queue_push_tail(struct ofp_queue *, struct ofpbuf *); 49 | struct ofpbuf *queue_pop_head(struct ofp_queue *); 50 | 51 | #endif /* queue.h */ 52 | -------------------------------------------------------------------------------- /lib/random.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #include 35 | #include "random.h" 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #include "util.h" 42 | 43 | void 44 | random_init(void) 45 | { 46 | static bool inited = false; 47 | if (!inited) { 48 | struct timeval tv; 49 | inited = true; 50 | if (gettimeofday(&tv, NULL) < 0) { 51 | ofp_fatal(errno, "gettimeofday"); 52 | } 53 | srand(tv.tv_sec ^ tv.tv_usec); 54 | } 55 | } 56 | 57 | void 58 | random_bytes(void *p_, size_t n) 59 | { 60 | uint8_t *p = p_; 61 | random_init(); 62 | while (n--) { 63 | *p++ = rand(); 64 | } 65 | } 66 | 67 | uint8_t 68 | random_uint8(void) 69 | { 70 | random_init(); 71 | return rand(); 72 | } 73 | 74 | uint16_t 75 | random_uint16(void) 76 | { 77 | if (RAND_MAX >= UINT16_MAX) { 78 | random_init(); 79 | return rand(); 80 | } else { 81 | uint16_t x; 82 | random_bytes(&x, sizeof x); 83 | return x; 84 | } 85 | } 86 | 87 | uint32_t 88 | random_uint32(void) 89 | { 90 | if (RAND_MAX >= UINT32_MAX) { 91 | random_init(); 92 | return rand(); 93 | } else if (RAND_MAX == INT32_MAX) { 94 | random_init(); 95 | return rand() | ((rand() & 1u) << 31); 96 | } else { 97 | uint32_t x; 98 | random_bytes(&x, sizeof x); 99 | return x; 100 | } 101 | } 102 | 103 | int 104 | random_range(int max) 105 | { 106 | return random_uint32() % max; 107 | } 108 | -------------------------------------------------------------------------------- /lib/random.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef RANDOM_H 35 | #define RANDOM_H 1 36 | 37 | #include 38 | #include 39 | 40 | void random_init(void); 41 | void random_bytes(void *, size_t); 42 | uint8_t random_uint8(void); 43 | uint16_t random_uint16(void); 44 | uint32_t random_uint32(void); 45 | int random_range(int max); 46 | 47 | #endif /* random.h */ 48 | -------------------------------------------------------------------------------- /lib/sat-math.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef SAT_MATH_H 35 | #define SAT_MATH_H 1 36 | 37 | #include 38 | #include 39 | 40 | /* Saturating addition: overflow yields UINT_MAX. */ 41 | static inline unsigned int 42 | sat_add(unsigned int x, unsigned int y) 43 | { 44 | return x + y >= x ? x + y : UINT_MAX; 45 | } 46 | 47 | /* Saturating subtraction: underflow yields 0. */ 48 | static inline unsigned int 49 | sat_sub(unsigned int x, unsigned int y) 50 | { 51 | return x >= y ? x - y : 0; 52 | } 53 | 54 | /* Saturating multiplication: overflow yields UINT_MAX. */ 55 | static inline unsigned int 56 | sat_mul(unsigned int x, unsigned int y) 57 | { 58 | return (!y ? 0 59 | : x <= UINT_MAX / y ? x * y 60 | : UINT_MAX); 61 | } 62 | 63 | #endif /* sat-math.h */ 64 | -------------------------------------------------------------------------------- /lib/shash.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 The Board of Trustees of The Leland Stanford Junior 2 | * University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef SHASH_H 35 | #define SHASH_H 1 36 | 37 | #include "hmap.h" 38 | 39 | struct shash_node { 40 | struct hmap_node node; 41 | char *name; 42 | void *data; 43 | }; 44 | 45 | struct shash { 46 | struct hmap map; 47 | }; 48 | 49 | #define SHASH_INITIALIZER(SHASH) { HMAP_INITIALIZER(&(SHASH)->map) } 50 | 51 | void shash_init(struct shash *); 52 | void shash_destroy(struct shash *); 53 | void shash_clear(struct shash *); 54 | void shash_add(struct shash *, const char *, void *); 55 | void shash_delete(struct shash *, struct shash_node *); 56 | struct shash_node *shash_find(const struct shash *, const char *); 57 | void *shash_find_data(const struct shash *, const char *); 58 | 59 | #endif /* shash.h */ 60 | -------------------------------------------------------------------------------- /lib/signals.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef SIGNALS_H 35 | #define SIGNALS_H 1 36 | 37 | #include 38 | 39 | void signal_init(void); 40 | struct signal *signal_register(int signr); 41 | bool signal_poll(struct signal *); 42 | void signal_wait(struct signal *); 43 | 44 | #endif /* signals.h */ 45 | -------------------------------------------------------------------------------- /lib/socket-util.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef SOCKET_UTIL_H 35 | #define SOCKET_UTIL_H 1 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | int set_nonblocking(int fd); 42 | int set_socket_priority(int fd, int priority); 43 | int get_max_fds(void); 44 | int lookup_ip(const char *host_name, struct in_addr *address); 45 | int get_socket_error(int sock); 46 | int check_connection_completion(int fd); 47 | int drain_rcvbuf(int fd); 48 | void drain_fd(int fd, size_t n_packets); 49 | int make_unix_socket(int style, bool nonblock, bool passcred, 50 | const char *bind_path, const char *connect_path); 51 | int get_unix_name_len(socklen_t sun_len); 52 | 53 | #endif /* socket-util.h */ 54 | -------------------------------------------------------------------------------- /lib/svec.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef SVEC_H 35 | #define SVEC_H 1 36 | 37 | #include 38 | #include 39 | 40 | struct svec { 41 | char **names; 42 | size_t n; 43 | size_t allocated; 44 | }; 45 | 46 | #define SVEC_EMPTY_INITIALIZER { NULL, 0, 0 } 47 | 48 | void svec_init(struct svec *); 49 | void svec_destroy(struct svec *); 50 | void svec_clear(struct svec *); 51 | void svec_add(struct svec *, const char *); 52 | void svec_add_nocopy(struct svec *, char *); 53 | void svec_append(struct svec *, const struct svec *); 54 | void svec_terminate(struct svec *); 55 | void svec_sort(struct svec *); 56 | void svec_sort_unique(struct svec *); 57 | void svec_unique(struct svec *); 58 | void svec_diff(const struct svec *a, const struct svec *b, 59 | struct svec *a_only, struct svec *both, struct svec *b_only); 60 | bool svec_contains(const struct svec *, const char *); 61 | size_t svec_find(const struct svec *, const char *); 62 | bool svec_is_sorted(const struct svec *); 63 | bool svec_is_unique(const struct svec *); 64 | const char *svec_get_duplicate(const struct svec *); 65 | void svec_swap(struct svec *a, struct svec *b); 66 | void svec_print(const struct svec *svec, const char *title); 67 | void svec_parse_words(struct svec *svec, const char *words); 68 | bool svec_equal(const struct svec *, const struct svec *); 69 | char *svec_join(const struct svec *, const char *delimiter); 70 | const char *svec_back(const struct svec *); 71 | void svec_pop_back(struct svec *); 72 | 73 | #endif /* svec.h */ 74 | -------------------------------------------------------------------------------- /lib/timeval.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef TIMEVAL_H 35 | #define TIMEVAL_H 1 36 | 37 | #include 38 | #include "type-props.h" 39 | #include "util.h" 40 | 41 | struct pollfd; 42 | 43 | /* POSIX allows floating-point time_t, but we don't support it. */ 44 | BUILD_ASSERT_DECL(TYPE_IS_INTEGER(time_t)); 45 | 46 | /* We do try to cater to unsigned time_t, but I want to know about it if we 47 | * ever encounter such a platform. */ 48 | BUILD_ASSERT_DECL(TYPE_IS_SIGNED(time_t)); 49 | 50 | #define TIME_MAX TYPE_MAXIMUM(time_t) 51 | #define TIME_MIN TYPE_MINIMUM(time_t) 52 | 53 | /* Interval between updates to the time reported by time_gettimeofday(), in ms. 54 | * This should not be adjusted much below 10 ms or so with the current 55 | * implementation, or too much time will be wasted in signal handlers and calls 56 | * to time(0). */ 57 | #define TIME_UPDATE_INTERVAL 100 58 | 59 | void time_init(void); 60 | void time_refresh(void); 61 | time_t time_now(void); 62 | long long int time_msec(void); 63 | void time_alarm(unsigned int secs); 64 | int time_poll(struct pollfd *, int n_pollfds, int timeout); 65 | 66 | #endif /* timeval.h */ 67 | -------------------------------------------------------------------------------- /lib/type-props.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef TYPE_PROPS_H 35 | #define TYPE_PROPS_H 1 36 | 37 | #include 38 | 39 | #define TYPE_IS_INTEGER(TYPE) ((TYPE) 1.5 == (TYPE) 1) 40 | #define TYPE_IS_SIGNED(TYPE) ((TYPE) 0 > (TYPE) -1) 41 | #define TYPE_VALUE_BITS(TYPE) (sizeof(TYPE) * CHAR_BIT - TYPE_IS_SIGNED(TYPE)) 42 | #define TYPE_MINIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \ 43 | ? ~(TYPE)0 << TYPE_VALUE_BITS(TYPE) \ 44 | : 0) 45 | #define TYPE_MAXIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \ 46 | ? ~(~(TYPE)0 << TYPE_VALUE_BITS(TYPE)) \ 47 | : (TYPE)-1) 48 | 49 | #endif /* type-props.h */ 50 | -------------------------------------------------------------------------------- /lib/vconn-ssl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | #ifndef VCONN_SSL_H 34 | #define VCONN_SSL_H 1 35 | 36 | #include 37 | 38 | #ifdef HAVE_OPENSSL 39 | bool vconn_ssl_is_configured(void); 40 | void vconn_ssl_set_private_key_file(const char *file_name); 41 | void vconn_ssl_set_certificate_file(const char *file_name); 42 | void vconn_ssl_set_ca_cert_file(const char *file_name, bool bootstrap); 43 | void vconn_ssl_set_peer_ca_cert_file(const char *file_name); 44 | 45 | #define VCONN_SSL_LONG_OPTIONS \ 46 | {"private-key", required_argument, 0, 'p'}, \ 47 | {"certificate", required_argument, 0, 'c'}, \ 48 | {"ca-cert", required_argument, 0, 'C'}, 49 | 50 | #define VCONN_SSL_OPTION_HANDLERS \ 51 | case 'p': \ 52 | vconn_ssl_set_private_key_file(optarg); \ 53 | break; \ 54 | \ 55 | case 'c': \ 56 | vconn_ssl_set_certificate_file(optarg); \ 57 | break; \ 58 | \ 59 | case 'C': \ 60 | vconn_ssl_set_ca_cert_file(optarg, false); \ 61 | break; 62 | #else /* !HAVE_OPENSSL */ 63 | static inline bool vconn_ssl_is_configured(void) 64 | { 65 | return false; 66 | } 67 | #define VCONN_SSL_LONG_OPTIONS 68 | #define VCONN_SSL_OPTION_HANDLERS 69 | #endif /* !HAVE_OPENSSL */ 70 | 71 | #endif /* vconn-ssl.h */ 72 | -------------------------------------------------------------------------------- /lib/vconn-stream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef VCONN_STREAM_H 35 | #define VCONN_STREAM_H 1 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | struct vconn; 42 | struct pvconn; 43 | struct sockaddr; 44 | 45 | int new_stream_vconn(const char *name, int fd, int connect_status, 46 | uint32_t ip, bool reconnectable, struct vconn **vconnp); 47 | int new_pstream_pvconn(const char *name, int fd, 48 | int (*accept_cb)(int fd, const struct sockaddr *, 49 | size_t sa_len, struct vconn **), 50 | struct pvconn **pvconnp); 51 | 52 | #endif /* vconn-stream.h */ 53 | -------------------------------------------------------------------------------- /lib/vconn.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef VCONN_H 35 | #define VCONN_H 1 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | struct ofpbuf; 42 | struct flow; 43 | struct ofp_header; 44 | struct ofp_stats_reply; 45 | struct pvconn; 46 | struct vconn; 47 | 48 | void vconn_usage(bool active, bool passive, bool bootstrap); 49 | 50 | /* Active vconns: virtual connections to OpenFlow devices. */ 51 | int vconn_open(const char *name, int min_version, struct vconn **); 52 | void vconn_close(struct vconn *); 53 | const char *vconn_get_name(const struct vconn *); 54 | uint32_t vconn_get_ip(const struct vconn *); 55 | bool vconn_is_reconnectable(const struct vconn *); 56 | int vconn_connect(struct vconn *); 57 | int vconn_recv(struct vconn *, struct ofpbuf **); 58 | int vconn_send(struct vconn *, struct ofpbuf *); 59 | int vconn_recv_xid(struct vconn *, uint32_t xid, struct ofpbuf **); 60 | int vconn_transact(struct vconn *, struct ofpbuf *, struct ofpbuf **); 61 | 62 | int vconn_open_block(const char *name, int min_version, struct vconn **); 63 | int vconn_send_block(struct vconn *, struct ofpbuf *); 64 | int vconn_recv_block(struct vconn *, struct ofpbuf **); 65 | 66 | enum vconn_wait_type { 67 | WAIT_CONNECT, 68 | WAIT_RECV, 69 | WAIT_SEND 70 | }; 71 | void vconn_wait(struct vconn *, enum vconn_wait_type); 72 | void vconn_connect_wait(struct vconn *); 73 | void vconn_recv_wait(struct vconn *); 74 | void vconn_send_wait(struct vconn *); 75 | 76 | /* Passive vconns: virtual listeners for incoming OpenFlow connections. */ 77 | int pvconn_open(const char *name, struct pvconn **); 78 | void pvconn_close(struct pvconn *); 79 | int pvconn_accept(struct pvconn *, int min_version, struct vconn **); 80 | void pvconn_wait(struct pvconn *); 81 | 82 | #endif /* vconn.h */ 83 | -------------------------------------------------------------------------------- /lib/vlog-modules.def: -------------------------------------------------------------------------------- 1 | /* Modules that can emit log messages. */ 2 | 3 | VLOG_MODULE(backtrace) 4 | VLOG_MODULE(daemon) 5 | VLOG_MODULE(dhcp) 6 | VLOG_MODULE(dhcp_client) 7 | VLOG_MODULE(dpif) 8 | VLOG_MODULE(fault) 9 | VLOG_MODULE(flow) 10 | VLOG_MODULE(leak_checker) 11 | VLOG_MODULE(learning_switch) 12 | VLOG_MODULE(mac_learning) 13 | VLOG_MODULE(netdev) 14 | VLOG_MODULE(netlink) 15 | VLOG_MODULE(ofp) 16 | VLOG_MODULE(pcap) 17 | VLOG_MODULE(poll_loop) 18 | VLOG_MODULE(process) 19 | VLOG_MODULE(rconn) 20 | VLOG_MODULE(socket_util) 21 | VLOG_MODULE(stp) 22 | VLOG_MODULE(svec) 23 | VLOG_MODULE(vconn) 24 | VLOG_MODULE(vconn_netlink) 25 | VLOG_MODULE(vconn_ssl) 26 | VLOG_MODULE(vconn_stream) 27 | VLOG_MODULE(vconn_tcp) 28 | VLOG_MODULE(vconn_unix) 29 | VLOG_MODULE(vlog) 30 | VLOG_MODULE(vlog_socket) 31 | 32 | #include "oflib/vlog-modules.def" 33 | #include "oflib-exp/vlog-modules.def" 34 | #include "secchan/vlog-modules.def" 35 | #include "udatapath/vlog-modules.def" 36 | #include "utilities/vlog-modules.def" 37 | 38 | #ifdef HAVE_EXT 39 | #include "ext/vlogext-modules.def" 40 | #endif 41 | 42 | #undef VLOG_MODULE 43 | -------------------------------------------------------------------------------- /lib/vlog-socket.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef VLOG_SOCKET_H 35 | #define VLOG_SOCKET_H 1 36 | 37 | /* Server for Vlog control connection. */ 38 | struct vlog_server; 39 | int vlog_server_listen(const char *path, struct vlog_server **); 40 | void vlog_server_close(struct vlog_server *); 41 | 42 | /* Client for Vlog control connection. */ 43 | struct vlog_client; 44 | int vlog_client_connect(const char *path, struct vlog_client **); 45 | void vlog_client_close(struct vlog_client *); 46 | int vlog_client_send(struct vlog_client *, const char *request); 47 | int vlog_client_recv(struct vlog_client *, char **reply); 48 | int vlog_client_transact(struct vlog_client *, 49 | const char *request, char **reply); 50 | const char *vlog_client_target(const struct vlog_client *); 51 | 52 | #endif /* vlog-socket.h */ 53 | -------------------------------------------------------------------------------- /lib/vlog.man: -------------------------------------------------------------------------------- 1 | .TP 2 | \fB-v\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]], \fB--verbose=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]] 3 | 4 | Sets the logging level for \fImodule\fR in \fIfacility\fR to 5 | \fIlevel\fR: 6 | 7 | .RS 8 | .IP \(bu 9 | \fImodule\fR may be any valid module name (as displayed by the 10 | \fB--list\fR action on \fBvlogconf\fR(8)), or the special name 11 | \fBANY\fR to set the logging levels for all modules. 12 | 13 | .IP \(bu 14 | \fIfacility\fR may be \fBsyslog\fR, \fBconsole\fR, or \fBfile\fR to 15 | set the levels for logging to the system log, the console, or a file 16 | respectively, or \fBANY\fR to set the logging levels for both 17 | facilities. If it is omitted, \fIfacility\fR defaults to \fBANY\fR. 18 | 19 | Regardless of the log levels set for \fBfile\fR, logging to a file 20 | will not take place unless \fB--log-file\fR is also specified (see 21 | below). 22 | 23 | .IP \(bu 24 | \fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, 25 | \fBinfo\fR, or 26 | \fBdbg\fR, designating the minimum severity of a message for it to be 27 | logged. If it is omitted, \fIlevel\fR defaults to \fBdbg\fR. 28 | .RE 29 | 30 | .TP 31 | \fB-v\fR, \fB--verbose\fR 32 | Sets the maximum logging verbosity level, equivalent to 33 | \fB--verbose=ANY:ANY:dbg\fR. 34 | 35 | .TP 36 | \fB-vPATTERN:\fIfacility\fB:\fIpattern\fR, \fB--verbose=PATTERN:\fIfacility\fB:\fIpattern\fR 37 | Sets the log pattern for \fIfacility\fR to \fIpattern\fR. Refer to 38 | \fBvlogconf\fR(8) for a description of the valid syntax for \fIpattern\fR. 39 | 40 | .TP 41 | \fB--log-file\fR[\fB=\fIfile\fR] 42 | Enables logging to a file. If \fIfile\fR is specified, then it is 43 | used as the exact name for the log file. The default log file name 44 | used if \fIfile\fR is omitted is \fB@LOGDIR@/\*(PN.log\fR. 45 | -------------------------------------------------------------------------------- /lib/xtoxll.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | #ifndef XTOXLL_H 34 | #define XTOXLL_H 1 35 | 36 | #include 37 | #include 38 | 39 | static inline uint64_t 40 | htonll(uint64_t n) 41 | { 42 | return htonl(1) == 1 ? n : ((uint64_t) htonl(n) << 32) | htonl(n >> 32); 43 | } 44 | 45 | static inline uint64_t 46 | ntohll(uint64_t n) 47 | { 48 | return htonl(1) == 1 ? n : ((uint64_t) ntohl(n) << 32) | ntohl(n >> 32); 49 | } 50 | 51 | #endif /* xtoxll.h */ 52 | -------------------------------------------------------------------------------- /m4/nx-build.m4: -------------------------------------------------------------------------------- 1 | # -*- autoconf -*- 2 | 3 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford 4 | # Junior University 5 | # 6 | # We are making the OpenFlow specification and associated documentation 7 | # (Software) available for public use and benefit with the expectation 8 | # that others will use, modify and enhance the Software and contribute 9 | # those enhancements back to the community. However, since we would 10 | # like to make the Software available for broadest use, with as few 11 | # restrictions as possible permission is hereby granted, free of 12 | # charge, to any person obtaining a copy of this Software to deal in 13 | # the Software under the copyrights without restriction, including 14 | # without limitation the rights to use, copy, modify, merge, publish, 15 | # distribute, sublicense, and/or sell copies of the Software, and to 16 | # permit persons to whom the Software is furnished to do so, subject to 17 | # the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be 20 | # included in all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 26 | # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 27 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 | # SOFTWARE. 30 | # 31 | # The name and trademarks of copyright holder(s) may NOT be used in 32 | # advertising or publicity pertaining to the Software or any 33 | # derivatives without specific, written prior permission. 34 | 35 | dnl NX_BUILDNR 36 | dnl 37 | dnl If --with-build-number=NUMBER is used, substitutes a Makefile 38 | dnl variable BUILDNR with NUMBER, and sets a C preprocessor variable 39 | dnl BUILDNR to "+buildNUMBER". 40 | dnl 41 | dnl Otherwise, if --with-build-number is not used, substitutes BUILDNR 42 | dnl with 0 and sets C preprocessor variable BUILDNR to "". 43 | AC_DEFUN([NX_BUILDNR], 44 | [AC_ARG_WITH( 45 | [build-number], 46 | [AS_HELP_STRING([--with-build-number=NUMBER], 47 | [Official build number (default is none)])]) 48 | AC_MSG_CHECKING([build number]) 49 | case $with_build_number in # ( 50 | [[0-9]] | \ 51 | [[0-9]][[0-9]] | \ 52 | [[0-9]][[0-9]][[0-9]] | \ 53 | [[0-9]][[0-9]][[0-9]][[0-9]] | \ 54 | [[0-9]][[0-9]][[0-9]][[0-9]][[0-9]]) 55 | BUILDNR=$with_build_number 56 | buildnr='"+build'$BUILDNR'"' 57 | AC_MSG_RESULT([$with_build_number]) 58 | ;; # ( 59 | ''|no) 60 | BUILDNR=0 61 | buildnr='""' 62 | AC_MSG_RESULT([none]) 63 | ;; # ( 64 | *) 65 | AC_MSG_ERROR([invalid build number $with_build_number]) 66 | ;; 67 | esac 68 | AC_SUBST([BUILDNR]) 69 | AC_DEFINE_UNQUOTED([BUILDNR], [$buildnr], 70 | [Official build number as a VERSION suffix string, e.g. "+build123", 71 | or "" if this is not an official build.])]) 72 | -------------------------------------------------------------------------------- /oflib-exp/automake.mk: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES += oflib-exp/liboflib_exp.a 2 | 3 | oflib_exp_liboflib_exp_a_SOURCES = \ 4 | oflib-exp/ofl-exp.c \ 5 | oflib-exp/ofl-exp.h \ 6 | oflib-exp/ofl-exp-nicira.c \ 7 | oflib-exp/ofl-exp-nicira.h \ 8 | oflib-exp/ofl-exp-openflow.c \ 9 | oflib-exp/ofl-exp-openflow.h 10 | 11 | AM_CPPFLAGS += -DOFL_LOG_VLOG 12 | -------------------------------------------------------------------------------- /oflib-exp/ofl-exp-nicira.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef OFL_EXP_NICIRA_H 33 | #define OFL_EXP_NICIRA_H 1 34 | 35 | 36 | #include "../oflib/ofl-structs.h" 37 | #include "../oflib/ofl-messages.h" 38 | 39 | 40 | struct ofl_exp_nicira_msg_header { 41 | struct ofl_msg_experimenter header; /* NX_VENDOR_ID */ 42 | 43 | uint32_t type; 44 | }; 45 | 46 | struct ofl_exp_nicira_msg_role { 47 | struct ofl_exp_nicira_msg_header header; /* NXT_ROLE_REQUEST|REPLY */ 48 | 49 | uint32_t role; 50 | }; 51 | 52 | 53 | 54 | int 55 | ofl_exp_nicira_msg_pack(struct ofl_msg_experimenter *msg, uint8_t **buf, size_t *buf_len); 56 | 57 | ofl_err 58 | ofl_exp_nicira_msg_unpack(struct ofp_header *oh, size_t *len, struct ofl_msg_experimenter **msg); 59 | 60 | int 61 | ofl_exp_nicira_msg_free(struct ofl_msg_experimenter *msg); 62 | 63 | char * 64 | ofl_exp_nicira_msg_to_string(struct ofl_msg_experimenter *msg); 65 | 66 | 67 | #endif /* OFL_EXP_NICIRA_H */ 68 | -------------------------------------------------------------------------------- /oflib-exp/ofl-exp-openflow.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef OFL_EXP_OPENFLOW_H 33 | #define OFL_EXP_OPENFLOW_H 1 34 | 35 | 36 | #include "../oflib/ofl-structs.h" 37 | #include "../oflib/ofl-messages.h" 38 | 39 | 40 | struct ofl_exp_openflow_msg_header { 41 | struct ofl_msg_experimenter header; /* OPENFLOW_VENDOR_ID */ 42 | 43 | uint32_t type; 44 | }; 45 | 46 | struct ofl_exp_openflow_msg_queue { 47 | struct ofl_exp_openflow_msg_header header; /* OFP_EXT_QUEUE_MODIFY|DELETE */ 48 | 49 | uint32_t port_id; 50 | struct ofl_packet_queue *queue; 51 | }; 52 | 53 | 54 | struct ofl_exp_openflow_msg_set_dp_desc { 55 | struct ofl_exp_openflow_msg_header header; /* OFP_EXT_SET_DESC */ 56 | 57 | char *dp_desc; 58 | }; 59 | 60 | 61 | 62 | int 63 | ofl_exp_openflow_msg_pack(struct ofl_msg_experimenter *msg, uint8_t **buf, size_t *buf_len); 64 | 65 | ofl_err 66 | ofl_exp_openflow_msg_unpack(struct ofp_header *oh, size_t *len, struct ofl_msg_experimenter **msg); 67 | 68 | int 69 | ofl_exp_openflow_msg_free(struct ofl_msg_experimenter *msg); 70 | 71 | char * 72 | ofl_exp_openflow_msg_to_string(struct ofl_msg_experimenter *msg); 73 | 74 | 75 | #endif /* OFL_EXP_OPENFLOW_H */ 76 | -------------------------------------------------------------------------------- /oflib-exp/ofl-exp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef OFL_EXP_H 33 | #define OFL_EXP_H 1 34 | 35 | #include "../oflib/ofl-messages.h" 36 | #include "openflow/openflow.h" 37 | 38 | 39 | int 40 | ofl_exp_msg_pack(struct ofl_msg_experimenter *msg, uint8_t **buf, size_t *buf_len); 41 | 42 | ofl_err 43 | ofl_exp_msg_unpack(struct ofp_header *oh, size_t *len, struct ofl_msg_experimenter **msg); 44 | 45 | int 46 | ofl_exp_msg_free(struct ofl_msg_experimenter *msg); 47 | 48 | char * 49 | ofl_exp_msg_to_string(struct ofl_msg_experimenter *msg); 50 | 51 | 52 | #endif /* OFL_EXP_H */ 53 | -------------------------------------------------------------------------------- /oflib-exp/vlog-modules.def: -------------------------------------------------------------------------------- 1 | VLOG_MODULE(ofl_exp) 2 | VLOG_MODULE(ofl_exp_of) 3 | VLOG_MODULE(ofl_exp_nx) 4 | -------------------------------------------------------------------------------- /oflib/automake.mk: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES += oflib/liboflib.a 2 | 3 | oflib_liboflib_a_SOURCES = \ 4 | oflib/ofl.h \ 5 | oflib/ofl-actions.c \ 6 | oflib/ofl-actions.h \ 7 | oflib/ofl-actions-pack.c \ 8 | oflib/ofl-actions-print.c \ 9 | oflib/ofl-actions-unpack.c \ 10 | oflib/ofl-messages.c \ 11 | oflib/ofl-messages.h \ 12 | oflib/ofl-messages-pack.c \ 13 | oflib/ofl-messages-print.c \ 14 | oflib/ofl-messages-unpack.c \ 15 | oflib/ofl-print.c \ 16 | oflib/ofl-print.h \ 17 | oflib/ofl-structs.c \ 18 | oflib/ofl-structs.h \ 19 | oflib/ofl-structs-pack.c \ 20 | oflib/ofl-structs-print.c \ 21 | oflib/ofl-structs-unpack.c \ 22 | oflib/ofl-utils.h 23 | 24 | AM_CPPFLAGS += -DOFL_LOG_VLOG 25 | 26 | -------------------------------------------------------------------------------- /oflib/ofl-log-vlog-cc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef OFL_LOG_VLOG_CC_H 33 | #define OFL_LOG_VLOG_CC_H 34 | 35 | #include "vlog.hh" 36 | 37 | #define VLOG_NAME(NAME) lg_##NAME 38 | 39 | #define OFL_LOG_INIT(MODULE) \ 40 | vigil::Vlog_module VLOG_NAME(MODULE)("MODULE"); 41 | 42 | #define OFL_LOG_DBG(MODULE, ...) \ 43 | VLOG_NAME(MODULE).dbg(__VA_ARGS__) 44 | 45 | #define OFL_LOG_WARN(MODULE, ...) \ 46 | VLOG_NAME(MODULE).warn(__VA_ARGS__) 47 | 48 | #define OFL_LOG_IS_DBG_ENABLED(MODULE) \ 49 | VLOG_NAME(MODULE).is_dbg_enabled() 50 | 51 | #define OFL_LOG_IS_WARN_ENABLED(MODULE) \ 52 | VLOG_NAME(MODULE).is_warn_enabled() 53 | 54 | #endif /* OFL_LOG_VLOG_CC_H */ 55 | -------------------------------------------------------------------------------- /oflib/ofl-log-vlog.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef OFL_LOG_VLOG_H 33 | #define OFL_LOG_VLOG_H 34 | 35 | #include "vlog.h" 36 | 37 | #define VLOG_NAME(NAME) VLM_##NAME 38 | 39 | #define OFL_LOG_INIT(MODULE) 40 | 41 | #define OFL_LOG_DBG(MODULE, ...) \ 42 | VLOG_DBG(VLOG_NAME(MODULE), __VA_ARGS__) 43 | 44 | #define OFL_LOG_WARN(MODULE, ...) \ 45 | VLOG_WARN(VLOG_NAME(MODULE), __VA_ARGS__) 46 | 47 | #define OFL_LOG_IS_DBG_ENABLED(MODULE) \ 48 | VLOG_IS_DBG_ENABLED(VLOG_NAME(MODULE)) 49 | 50 | #define OFL_LOG_IS_WARN_ENABLED(MODULE) \ 51 | VLOG_IS_WARN_ENABLED(VLOG_NAME(MODULE)) 52 | 53 | #endif /* OFL_LOG_VLOG_H */ 54 | -------------------------------------------------------------------------------- /oflib/ofl-log.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef OFL_LOG_H 33 | #define OFL_LOG_H 34 | 35 | #ifdef OFL_LOG_VLOG 36 | #include "ofl-log-vlog.h" 37 | #elif OFL_LOG_VLOG_CC 38 | #include "ofl-log-vlog-cc.h" 39 | #endif 40 | 41 | #endif /* OFL_LOG_H */ 42 | -------------------------------------------------------------------------------- /oflib/ofl-packets.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef OFL_PACKETS_H 33 | #define OFL_PACKETS_H 34 | 35 | #define ETH_TYPE_II_START 0x0600 36 | #define ETH_TYPE_IP 0x0800 37 | #define ETH_TYPE_ARP 0x0806 38 | #define ETH_TYPE_VLAN 0x8100 39 | #define ETH_TYPE_VLAN_PBB 0x88a8 40 | #define ETH_TYPE_MPLS 0x8847 41 | #define ETH_TYPE_MPLS_MCAST 0x8848 42 | 43 | #define ETH_ADDR_LEN 6 44 | 45 | 46 | 47 | #define VLAN_VID_MASK 0x0fff 48 | #define VLAN_VID_SHIFT 0 49 | #define VLAN_PCP_MASK 0xe000 50 | #define VLAN_PCP_SHIFT 13 51 | #define VLAN_PCP_BITMASK 0x0007 /* the least 3-bit is valid */ 52 | 53 | #define VLAN_VID_MAX 4095 54 | #define VLAN_PCP_MAX 7 55 | 56 | 57 | 58 | #define MPLS_TTL_MASK 0x000000ff 59 | #define MPLS_TTL_SHIFT 0 60 | #define MPLS_S_MASK 0x00000100 61 | #define MPLS_S_SHIFT 8 62 | #define MPLS_TC_MASK 0x00000e00 63 | #define MPLS_TC_SHIFT 9 64 | #define MPLS_LABEL_MASK 0xfffff000 65 | #define MPLS_LABEL_SHIFT 12 66 | 67 | #define MPLS_LABEL_MAX 1048575 68 | #define MPLS_TC_MAX 7 69 | 70 | 71 | 72 | #define IP_ECN_MASK 0x03 73 | #define IP_DSCP_MASK 0xfc 74 | 75 | 76 | 77 | 78 | 79 | #endif /* OFL_PACKETS_H */ 80 | -------------------------------------------------------------------------------- /oflib/vlog-modules.def: -------------------------------------------------------------------------------- 1 | VLOG_MODULE(ofl_act) 2 | VLOG_MODULE(ofl_act_p) 3 | VLOG_MODULE(ofl_act_u) 4 | VLOG_MODULE(ofl_conn) 5 | VLOG_MODULE(ofl_msg) 6 | VLOG_MODULE(ofl_msg_d) 7 | VLOG_MODULE(ofl_msg_p) 8 | VLOG_MODULE(ofl_msg_u) 9 | VLOG_MODULE(ofl_str) 10 | VLOG_MODULE(ofl_str_p) 11 | VLOG_MODULE(ofl_str_u) 12 | VLOG_MODULE(ofl_util) 13 | -------------------------------------------------------------------------------- /secchan/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /controller-lite 4 | /ctlpath-lite 5 | /dpctl-lite 6 | /ofprotocol 7 | /ofprotocol.8 8 | -------------------------------------------------------------------------------- /secchan/automake.mk: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS += secchan/ofprotocol 2 | man_MANS += secchan/ofprotocol.8 3 | 4 | secchan_ofprotocol_SOURCES = \ 5 | secchan/discovery.c \ 6 | secchan/discovery.h \ 7 | secchan/failover.c \ 8 | secchan/failover.h \ 9 | secchan/in-band.c \ 10 | secchan/in-band.h \ 11 | secchan/port-watcher.c \ 12 | secchan/port-watcher.h \ 13 | secchan/ratelimit.c \ 14 | secchan/ratelimit.h \ 15 | secchan/secchan.c \ 16 | secchan/secchan.h \ 17 | secchan/status.c \ 18 | secchan/status.h \ 19 | secchan/stp-secchan.c \ 20 | secchan/stp-secchan.h 21 | secchan_ofprotocol_LDADD = lib/libopenflow.a $(FAULT_LIBS) $(SSL_LIBS) 22 | 23 | EXTRA_DIST += secchan/ofprotocol.8.in 24 | DISTCLEANFILES += secchan/ofprotocol.8 25 | 26 | include secchan/commands/automake.mk 27 | -------------------------------------------------------------------------------- /secchan/commands/automake.mk: -------------------------------------------------------------------------------- 1 | commandsdir = ${pkgdatadir}/commands 2 | dist_commands_SCRIPTS = \ 3 | secchan/commands/reboot 4 | -------------------------------------------------------------------------------- /secchan/commands/reboot: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ofp-kill --force --signal=USR1 ofp-switchui.pid 3 | reboot 4 | -------------------------------------------------------------------------------- /secchan/discovery.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef DISCOVERY_H 35 | #define DISCOVERY_H 1 36 | 37 | #include 38 | 39 | struct settings; 40 | struct port_watcher; 41 | struct switch_status; 42 | 43 | struct discovery *discovery_init(const struct settings *, 44 | struct port_watcher *, 45 | struct switch_status *); 46 | void discovery_question_connectivity(struct discovery *); 47 | bool discovery_run(struct discovery *, char **controller_name); 48 | void discovery_wait(struct discovery *); 49 | 50 | #endif /* discovery.h */ 51 | -------------------------------------------------------------------------------- /secchan/failover.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008, 2009 3 | * The Board of Trustees of The Leland Stanford Junior University 4 | * 5 | * We are making the OpenFlow specification and associated documentation 6 | * (Software) available for public use and benefit with the expectation that 7 | * others will use, modify and enhance the Software and contribute those 8 | * enhancements back to the community. However, since we would like to make the 9 | * Software available for broadest use, with as few restrictions as possible 10 | * permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this Software to deal in the Software under the copyrights without 12 | * restriction, including without limitation the rights to use, copy, modify, 13 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, 14 | * and to permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 26 | * IN THE SOFTWARE. 27 | * 28 | * The name and trademarks of copyright holder(s) may NOT be used in 29 | * advertising or publicity pertaining to the Software or any derivatives 30 | * without specific, written prior permission. 31 | */ 32 | 33 | #ifndef FAILOVER_H_ 34 | #define FAILOVER_H_ 1 35 | 36 | struct rconn; 37 | struct secchan; 38 | struct settings; 39 | struct switch_status; 40 | 41 | void failover_start(struct secchan *, const struct settings *, 42 | struct switch_status *, struct rconn *); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /secchan/in-band.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef IN_BAND_H 35 | #define IN_BAND_H 1 36 | 37 | struct port_watcher; 38 | struct rconn; 39 | struct secchan; 40 | struct settings; 41 | struct switch_status; 42 | 43 | void in_band_start(struct secchan *, const struct settings *, 44 | struct switch_status *, struct port_watcher *, 45 | struct rconn *remote); 46 | 47 | #endif /* in-band.h */ 48 | -------------------------------------------------------------------------------- /secchan/port-watcher.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef PORT_WATCHER_H 35 | #define PORT_WATCHER_H 1 36 | 37 | #include 38 | #include "compiler.h" 39 | #include "secchan.h" 40 | 41 | struct ofp_port; 42 | struct port_watcher; 43 | struct secchan; 44 | 45 | void port_watcher_start(struct secchan *, 46 | struct rconn *local, struct rconn *remote, 47 | struct port_watcher **); 48 | bool port_watcher_is_ready(const struct port_watcher *); 49 | uint32_t port_watcher_get_config(const struct port_watcher *, 50 | uint32_t port_no); 51 | const char *port_watcher_get_name(const struct port_watcher *, 52 | uint32_t port_no) UNUSED; 53 | const uint8_t *port_watcher_get_hwaddr(const struct port_watcher *, 54 | uint32_t port_no); 55 | void port_watcher_set_flags(struct port_watcher *, uint32_t port_no, 56 | uint32_t config, uint32_t c_mask, 57 | uint32_t state, uint32_t s_mask); 58 | 59 | typedef void port_changed_cb_func(uint32_t port_no, 60 | const struct ofp_port *old, 61 | const struct ofp_port *new, 62 | void *aux); 63 | 64 | void port_watcher_register_callback(struct port_watcher *, 65 | port_changed_cb_func *port_changed, 66 | void *aux); 67 | 68 | typedef void local_port_changed_cb_func(const struct ofp_port *new, 69 | void *aux); 70 | 71 | void port_watcher_register_local_port_callback(struct port_watcher *pw, 72 | local_port_changed_cb_func *cb, 73 | void *aux); 74 | 75 | void get_port_name(const struct ofp_port *, char *name, size_t name_size); 76 | 77 | #endif /* port-watcher.h */ 78 | -------------------------------------------------------------------------------- /secchan/ratelimit.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef RATELIMIT_H 35 | #define RATELIMIT_H 1 36 | 37 | struct rconn; 38 | struct secchan; 39 | struct settings; 40 | struct switch_status; 41 | 42 | void rate_limit_start(struct secchan *, const struct settings *, 43 | struct switch_status *, struct rconn *remote); 44 | 45 | #endif /* ratelimit.h */ 46 | -------------------------------------------------------------------------------- /secchan/status.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef STATUS_H 35 | #define STATUS_H 1 36 | 37 | #include "secchan.h" 38 | 39 | struct secchan; 40 | struct status_reply; 41 | struct switch_status; 42 | 43 | void switch_status_start(struct secchan *, const struct settings *, 44 | struct switch_status **); 45 | void switch_status_register_category(struct switch_status *, 46 | const char *category, 47 | void (*cb)(struct status_reply *, 48 | void *aux), 49 | void *aux); 50 | 51 | void status_reply_put(struct status_reply *, const char *, ...) 52 | PRINTF_FORMAT(2, 3); 53 | 54 | void rconn_status_cb(struct status_reply *, void *rconn_); 55 | 56 | #endif /* status.h */ 57 | -------------------------------------------------------------------------------- /secchan/stp-secchan.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef STP_SECCHAN_H 35 | #define STP_SECCHAN_H 1 36 | 37 | /* Extra time, in seconds, at boot before going into fail-open, to give the 38 | * spanning tree protocol time to figure out the network layout. */ 39 | #define STP_EXTRA_BOOT_TIME 30 40 | 41 | struct port_watcher; 42 | struct rconn; 43 | struct secchan; 44 | 45 | void stp_start(struct secchan *, struct port_watcher *, 46 | struct rconn *local, struct rconn *remote); 47 | 48 | #endif /* stp-secchan.h */ 49 | -------------------------------------------------------------------------------- /secchan/vlog-modules.def: -------------------------------------------------------------------------------- 1 | VLOG_MODULE(discovery) 2 | VLOG_MODULE(fail_open) 3 | VLOG_MODULE(failover) 4 | VLOG_MODULE(in_band) 5 | VLOG_MODULE(port_watcher) 6 | VLOG_MODULE(protocol_stat) 7 | VLOG_MODULE(secchan) 8 | VLOG_MODULE(status) 9 | VLOG_MODULE(stp_secchan) 10 | -------------------------------------------------------------------------------- /soexpand.pl: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Getopt::Long; 4 | 5 | my ($exit_code) = 0; 6 | my (@include_dirs); 7 | Getopt::Long::Configure ("bundling"); 8 | GetOptions("I|include=s" => \@include_dirs) or exit(1); 9 | @include_dirs = ('.') if !@include_dirs; 10 | OUTER: while () { 11 | if (my ($name) = /^\.so (\S+)$/) { 12 | foreach my $dir (@include_dirs, '.') { 13 | if (open(INNER, "$dir/$name")) { 14 | while () { 15 | print $_; 16 | } 17 | close(INNER); 18 | next OUTER; 19 | } 20 | } 21 | print STDERR "$name not found in: ", join(' ', @include_dirs), "\n"; 22 | $exit_code = 1; 23 | } 24 | print $_; 25 | } 26 | exit $exit_code; 27 | -------------------------------------------------------------------------------- /udatapath/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /ofdatapath 4 | /ofdatapath.8 5 | -------------------------------------------------------------------------------- /udatapath/action_set.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef ACTION_SET_H 33 | #define ACTION_SET_H 1 34 | 35 | #include 36 | #include 37 | #include "datapath.h" 38 | #include "packet.h" 39 | #include "oflib/ofl.h" 40 | #include "oflib/ofl-actions.h" 41 | #include "oflib/ofl-structs.h" 42 | 43 | struct action_set; 44 | struct datapath; 45 | struct packet; 46 | 47 | 48 | /**************************************************************************** 49 | * Implementation of an action set associated with a datapath packet 50 | ****************************************************************************/ 51 | 52 | struct action_set * 53 | action_set_create(struct ofl_exp *exp); 54 | 55 | /* Destroys an action set */ 56 | void 57 | action_set_destroy(struct action_set *set); 58 | 59 | /* Creates a clone of an action set. Used when cloning a datapath packet in 60 | * groups. */ 61 | struct action_set * 62 | action_set_clone(struct action_set *set); 63 | 64 | /* Writes the set of given actions to the set, overwriting existing types as 65 | * defined by the 1.1 spec. */ 66 | void 67 | action_set_write_actions(struct action_set *set, 68 | size_t actions_num, 69 | struct ofl_action_header **actions); 70 | 71 | 72 | /* Clears the actions from the set. */ 73 | void 74 | action_set_clear_actions(struct action_set *set); 75 | 76 | /* Executes the actions in the set on the packet. Packet is the owner of the 77 | * action set right now, but this might be changed in the future. */ 78 | void 79 | action_set_execute(struct action_set *set, struct packet *pkt); 80 | 81 | /* Converts the action set to a string representation. */ 82 | char * 83 | action_set_to_string(struct action_set *set); 84 | 85 | /* Converts the action set to a string representation and appends it to the 86 | * given string. */ 87 | void 88 | action_set_print(FILE *stream, struct action_set *set); 89 | 90 | #endif /* ACTION_SET */ 91 | -------------------------------------------------------------------------------- /udatapath/automake.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Build udatapath as binary 3 | # 4 | 5 | bin_PROGRAMS += udatapath/ofdatapath 6 | man_MANS += udatapath/ofdatapath.8 7 | 8 | udatapath_ofdatapath_SOURCES = \ 9 | udatapath/action_set.c \ 10 | udatapath/action_set.h \ 11 | udatapath/crc32.c \ 12 | udatapath/crc32.h \ 13 | udatapath/datapath.c \ 14 | udatapath/datapath.h \ 15 | udatapath/dp_actions.c \ 16 | udatapath/dp_actions.h \ 17 | udatapath/dp_buffers.c \ 18 | udatapath/dp_buffers.h \ 19 | udatapath/dp_control.c \ 20 | udatapath/dp_control.h \ 21 | udatapath/dp_exp.c \ 22 | udatapath/dp_exp.h \ 23 | udatapath/dp_ports.c \ 24 | udatapath/dp_ports.h \ 25 | udatapath/flow_table.c \ 26 | udatapath/flow_table.h \ 27 | udatapath/flow_entry.c \ 28 | udatapath/flow_entry.h \ 29 | udatapath/group_table.c \ 30 | udatapath/group_table.h \ 31 | udatapath/group_entry.c \ 32 | udatapath/group_entry.h \ 33 | udatapath/match_std.c \ 34 | udatapath/match_std.h \ 35 | udatapath/packet.c \ 36 | udatapath/packet.h \ 37 | udatapath/packet_handle_std.c \ 38 | udatapath/packet_handle_std.h \ 39 | udatapath/pipeline.c \ 40 | udatapath/pipeline.h \ 41 | udatapath/udatapath.c 42 | 43 | udatapath_ofdatapath_LDADD = lib/libopenflow.a oflib/liboflib.a oflib-exp/liboflib_exp.a $(SSL_LIBS) $(FAULT_LIBS) 44 | udatapath_ofdatapath_CPPFLAGS = $(AM_CPPFLAGS) 45 | 46 | EXTRA_DIST += udatapath/ofdatapath.8.in 47 | DISTCLEANFILES += udatapath/ofdatapath.8 48 | 49 | if BUILD_HW_LIBS 50 | 51 | # Options for each platform 52 | if NF2 53 | udatapath_ofdatapath_CPPFLAGS += -DOF_HW_PLAT -DUSE_NETDEV -g 54 | endif 55 | 56 | endif 57 | 58 | if BUILD_HW_LIBS 59 | # 60 | # Build udatapath as a library 61 | # 62 | 63 | noinst_LIBRARIES += udatapath/libudatapath.a 64 | 65 | udatapath_libudatapath_a_SOURCES = \ 66 | udatapath/action_set.c \ 67 | udatapath/action_set.h \ 68 | udatapath/crc32.c \ 69 | udatapath/crc32.h \ 70 | udatapath/datapath.c \ 71 | udatapath/datapath.h \ 72 | udatapath/dp_actions.c \ 73 | udatapath/dp_actions.h \ 74 | udatapath/dp_buffers.c \ 75 | udatapath/dp_buffers.h \ 76 | udatapath/dp_control.c \ 77 | udatapath/dp_control.h \ 78 | udatapath/dp_exp.c \ 79 | udatapath/dp_exp.h \ 80 | udatapath/flow_table.c \ 81 | udatapath/flow_table.h \ 82 | udatapath/flow_entry.c \ 83 | udatapath/flow_entry.h \ 84 | udatapath/group_table.c \ 85 | udatapath/group_table.h \ 86 | udatapath/group_entry.c \ 87 | udatapath/group_entry.h \ 88 | udatapath/match_std.c \ 89 | udatapath/match_std.h \ 90 | udatapath/packet.c \ 91 | udatapath/packet.h \ 92 | udatapath/packet_handle_std.c \ 93 | udatapath/packet_handle_std.h \ 94 | udatapath/pipeline.c \ 95 | udatapath/pipeline.h \ 96 | udatapath/udatapath.c 97 | 98 | udatapath_libudatapath_a_CPPFLAGS = $(AM_CPPFLAGS) 99 | udatapath_libudatapath_a_CPPFLAGS += -DOF_HW_PLAT -DUDATAPATH_AS_LIB -g 100 | 101 | endif 102 | -------------------------------------------------------------------------------- /udatapath/crc32.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #include 35 | #include "crc32.h" 36 | 37 | void 38 | crc32_init(struct crc32 *crc, unsigned int polynomial) 39 | { 40 | int i; 41 | 42 | for (i = 0; i < CRC32_TABLE_SIZE; ++i) { 43 | unsigned int reg = i << 24; 44 | int j; 45 | for (j = 0; j < CRC32_TABLE_BITS; j++) { 46 | int topBit = (reg & 0x80000000) != 0; 47 | reg <<= 1; 48 | if (topBit) 49 | reg ^= polynomial; 50 | } 51 | crc->table[i] = reg; 52 | } 53 | } 54 | 55 | unsigned int 56 | crc32_calculate(const struct crc32 *crc, const void *data_, size_t n_bytes) 57 | { 58 | const uint8_t *data = data_; 59 | unsigned int result = 0; 60 | size_t i; 61 | 62 | for (i = 0; i < n_bytes; i++) { 63 | unsigned int top = result >> 24; 64 | top ^= data[i]; 65 | result = (result << 8) ^ crc->table[top]; 66 | } 67 | return result; 68 | } 69 | -------------------------------------------------------------------------------- /udatapath/crc32.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | #ifndef CRC32_H 35 | #define CRC32_H 1 36 | 37 | #include 38 | #include 39 | 40 | #define CRC32_TABLE_BITS 8 41 | #define CRC32_TABLE_SIZE (1u << CRC32_TABLE_BITS) 42 | 43 | struct crc32 { 44 | unsigned int table[CRC32_TABLE_SIZE]; 45 | }; 46 | 47 | void crc32_init(struct crc32 *, unsigned int polynomial); 48 | unsigned int crc32_calculate(const struct crc32 *, const void *, size_t); 49 | 50 | #endif /* crc32.h */ 51 | -------------------------------------------------------------------------------- /udatapath/dp_actions.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef DP_ACTIONS_H 33 | #define DP_ACTIONS_H 1 34 | 35 | #include 36 | #include "datapath.h" 37 | #include "packet.h" 38 | #include "oflib/ofl-actions.h" 39 | 40 | 41 | /**************************************************************************** 42 | * Datapath action implementations. 43 | ****************************************************************************/ 44 | 45 | /* Executes the action on the given packet. */ 46 | void 47 | dp_execute_action(struct packet *pkt, 48 | struct ofl_action_header *action); 49 | 50 | 51 | /* Executes the list of action on the given packet. */ 52 | void 53 | dp_execute_action_list(struct packet *pkt, 54 | size_t actions_num, struct ofl_action_header **actions); 55 | 56 | /* Outputs the packet on the given port and queue. */ 57 | void 58 | dp_actions_output_port(struct packet *pkt, uint32_t out_port, uint32_t out_queue, uint16_t max_len); 59 | 60 | /* Returns true if the given list of actions has an output action to the port. */ 61 | bool 62 | dp_actions_list_has_out_port(size_t actions_num, struct ofl_action_header **actions, uint32_t port); 63 | 64 | /* Returns true if the given list of actions has an group action to the group. */ 65 | bool 66 | dp_actions_list_has_out_group(size_t actions_num, struct ofl_action_header **actions, uint32_t group); 67 | 68 | /* Validates the set of actions based on the available ports and groups. Returns an OpenFlow 69 | * error if the actions are invalid. */ 70 | ofl_err 71 | dp_actions_validate(struct datapath *dp, size_t actions_num, struct ofl_action_header **actions); 72 | 73 | #endif /* DP_ACTIONS_H */ 74 | -------------------------------------------------------------------------------- /udatapath/dp_buffers.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford 2 | * Junior University 3 | * 4 | * We are making the OpenFlow specification and associated documentation 5 | * (Software) available for public use and benefit with the expectation 6 | * that others will use, modify and enhance the Software and contribute 7 | * those enhancements back to the community. However, since we would 8 | * like to make the Software available for broadest use, with as few 9 | * restrictions as possible permission is hereby granted, free of 10 | * charge, to any person obtaining a copy of this Software to deal in 11 | * the Software under the copyrights without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sublicense, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be 18 | * included in all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | * 29 | * The name and trademarks of copyright holder(s) may NOT be used in 30 | * advertising or publicity pertaining to the Software or any 31 | * derivatives without specific, written prior permission. 32 | */ 33 | 34 | /* The original Stanford code has been modified during the implementation of 35 | * the OpenFlow 1.1 userspace switch. 36 | * 37 | * Author: Zoltán Lajos Kis 38 | */ 39 | 40 | #ifndef DP_BUFFERS_H 41 | #define DP_BUFFERS_H 1 42 | 43 | #include 44 | #include 45 | #include "ofpbuf.h" 46 | 47 | 48 | /* Constant for representing "no buffer" */ 49 | #define NO_BUFFER 0xffffffff 50 | 51 | /**************************************************************************** 52 | * Datapath buffers for storing packets for packet in messages. 53 | ****************************************************************************/ 54 | 55 | struct datapath; 56 | struct packet; 57 | 58 | /* Creates a set of buffers */ 59 | struct dp_buffers * 60 | dp_buffers_create(struct datapath *dp); 61 | 62 | /* Returns the number of buffers */ 63 | size_t 64 | dp_buffers_size(struct dp_buffers *dpb); 65 | 66 | /* Saves the packet into the buffer. Returns the saved buffer ID, or NO_BUFFER 67 | * if saving was not possible. */ 68 | uint32_t 69 | dp_buffers_save(struct dp_buffers *dpb, struct packet *pkt); 70 | 71 | /* Retrieves and removes the packet from the buffer. Returns null if it was not 72 | * found. */ 73 | struct packet * 74 | dp_buffers_retrieve(struct dp_buffers *dpb, uint32_t id); 75 | 76 | /* Returns true if the buffered packet is not timed out. */ 77 | bool 78 | dp_buffers_is_alive(struct dp_buffers *dpb, uint32_t id); 79 | 80 | /* Discards the packet in the given buffer, and destroys the packet if destroy is set. */ 81 | void 82 | dp_buffers_discard(struct dp_buffers *dpb, uint32_t id, bool destroy); 83 | 84 | 85 | #endif /* DP_BUFFERS_H */ 86 | -------------------------------------------------------------------------------- /udatapath/dp_control.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef DP_CONTROL_H 33 | #define DP_CONTROL_H 1 34 | 35 | #include "datapath.h" 36 | #include "oflib/ofl.h" 37 | #include "oflib/ofl-messages.h" 38 | 39 | 40 | /**************************************************************************** 41 | * Datapath control channel related functions. 42 | ****************************************************************************/ 43 | 44 | 45 | struct sender; 46 | 47 | /* Dispatches or handles the incoming OpenFlow messages. */ 48 | ofl_err 49 | handle_control_msg(struct datapath *dp, struct ofl_msg_header *msg, 50 | const struct sender *sender); 51 | 52 | 53 | #endif /* DP_CONTROL_H */ 54 | -------------------------------------------------------------------------------- /udatapath/dp_exp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef DP_EXP_H 33 | #define DP_EXP_H 1 34 | 35 | #include "packet.h" 36 | #include "oflib/ofl-messages.h" 37 | 38 | struct datapath; 39 | struct sender; 40 | 41 | /**************************************************************************** 42 | * Datapath stubs for handling experimenter features. 43 | ****************************************************************************/ 44 | 45 | /* Handles experimenter actions. */ 46 | void 47 | dp_exp_action(struct packet *pkt, struct ofl_action_experimenter *act); 48 | 49 | /* Handles experimenter instructions. */ 50 | void 51 | dp_exp_inst(struct packet *pkt, struct ofl_instruction_experimenter *inst); 52 | 53 | /* Handles experimenter statistics. */ 54 | ofl_err 55 | dp_exp_stats(struct datapath *dp, struct ofl_msg_stats_request_experimenter *msg, 56 | const struct sender *sender); 57 | 58 | /* Handles experimenter messages. */ 59 | ofl_err 60 | dp_exp_message(struct datapath *dp, 61 | struct ofl_msg_experimenter *msg, 62 | const struct sender *sender); 63 | 64 | 65 | #endif /* DP_EXP_H */ 66 | -------------------------------------------------------------------------------- /udatapath/group_entry.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef GROUP_entry_H 33 | #define GROUP_entry_H 1 34 | 35 | #include 36 | #include "hmap.h" 37 | #include "packet.h" 38 | #include "group_table.h" 39 | #include "oflib/ofl-structs.h" 40 | #include "oflib/ofl-messages.h" 41 | 42 | 43 | /**************************************************************************** 44 | * Implementation of a group table entry. 45 | ****************************************************************************/ 46 | 47 | 48 | struct packet; 49 | struct datapath; 50 | struct flow_entry; 51 | 52 | struct group_entry { 53 | struct hmap_node node; 54 | 55 | struct datapath *dp; 56 | struct group_table *table; 57 | struct ofl_group_desc_stats *desc; 58 | struct ofl_group_stats *stats; 59 | 60 | void *data; /* private data for group implementation. */ 61 | 62 | struct list flow_refs; /* references to flows referencing the group. */ 63 | }; 64 | 65 | struct sender; 66 | struct group_table; 67 | 68 | /* Executes the group entry on the packet. */ 69 | void 70 | group_entry_execute(struct group_entry *entry, 71 | struct packet *packet); 72 | 73 | /* Creates a group entry. */ 74 | struct group_entry * 75 | group_entry_create(struct datapath *dp, struct group_table *table, struct ofl_msg_group_mod *mod); 76 | 77 | /* Destroys a group entry. */ 78 | void 79 | group_entry_destroy(struct group_entry *entry); 80 | 81 | /* Returns true if the group entry has an group action to the given group ID. */ 82 | bool 83 | group_entry_has_out_group(struct group_entry *entry, uint32_t group_id); 84 | 85 | /* Adds a flow reference to the group entry. */ 86 | void 87 | group_entry_add_flow_ref(struct group_entry *entry, struct flow_entry *fe); 88 | 89 | /* Removes a flow reference from the group entry. */ 90 | void 91 | group_entry_del_flow_ref(struct group_entry *entry, struct flow_entry *fe); 92 | 93 | #endif /* GROUP_entry_H */ 94 | -------------------------------------------------------------------------------- /udatapath/match_std.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, TrafficLab, Ericsson Research, Hungary 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Ericsson Research nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * 29 | * Author: Zoltán Lajos Kis 30 | */ 31 | 32 | #ifndef MATCH_STD_H 33 | #define MATCH_STD_H 1 34 | 35 | #include 36 | #include "oflib/ofl-structs.h" 37 | 38 | /**************************************************************************** 39 | * Functions for comparing two standard match structures. 40 | ****************************************************************************/ 41 | 42 | /* Returns true if the two matches overlap. */ 43 | bool 44 | match_std_overlap(struct ofl_match_standard *a, struct ofl_match_standard *b); 45 | 46 | 47 | /* Returns true if match a matches match b, in a strict manner. */ 48 | bool 49 | match_std_strict(struct ofl_match_standard *a, struct ofl_match_standard *b); 50 | 51 | /* Returns true if match a matches match b, in a non-strict manner. */ 52 | bool 53 | match_std_nonstrict(struct ofl_match_standard *a, struct ofl_match_standard *b); 54 | 55 | /* Returns true if match a matches match b, where b's wildcards and masks are ignored. */ 56 | bool 57 | match_std_pkt(struct ofl_match_standard *a, struct ofl_match_standard *b); 58 | 59 | 60 | 61 | #endif /* MATCH_STD_H */ 62 | -------------------------------------------------------------------------------- /udatapath/vlog-modules.def: -------------------------------------------------------------------------------- 1 | VLOG_MODULE(dp) 2 | VLOG_MODULE(dp_acts) 3 | VLOG_MODULE(dp_buf) 4 | VLOG_MODULE(dp_ctrl) 5 | VLOG_MODULE(dp_exp) 6 | VLOG_MODULE(dp_ports) 7 | VLOG_MODULE(flow_e) 8 | VLOG_MODULE(flow_t) 9 | VLOG_MODULE(group_e) 10 | VLOG_MODULE(group_t) 11 | VLOG_MODULE(pipeline) 12 | VLOG_MODULE(udatapath) 13 | -------------------------------------------------------------------------------- /utilities/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /dpctl 4 | /dpctl.8 5 | /ofp-discover 6 | /ofp-discover.8 7 | /ofp-kill 8 | /ofp-kill.8 9 | /ofp-pki 10 | /ofp-pki-cgi 11 | /ofp-pki.8 12 | /vlogconf 13 | /vlogconf.8 14 | -------------------------------------------------------------------------------- /utilities/automake.mk: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS += \ 2 | utilities/vlogconf \ 3 | utilities/dpctl \ 4 | utilities/ofp-discover \ 5 | utilities/ofp-kill 6 | bin_SCRIPTS += utilities/ofp-pki 7 | noinst_SCRIPTS += utilities/ofp-pki-cgi utilities/ofp-parse-leaks 8 | 9 | EXTRA_DIST += \ 10 | utilities/dpctl.8.in \ 11 | utilities/ofp-discover.8.in \ 12 | utilities/ofp-kill.8.in \ 13 | utilities/ofp-parse-leaks.in \ 14 | utilities/ofp-pki-cgi.in \ 15 | utilities/ofp-pki.8.in \ 16 | utilities/ofp-pki.in \ 17 | utilities/vlogconf.8.in 18 | DISTCLEANFILES += \ 19 | utilities/dpctl.8 \ 20 | utilities/ofp-discover.8 \ 21 | utilities/ofp-kill.8 \ 22 | utilities/ofp-parse-leaks \ 23 | utilities/ofp-pki \ 24 | utilities/ofp-pki.8 \ 25 | utilities/ofp-pki-cgi \ 26 | utilities/vlogconf.8 27 | 28 | man_MANS += \ 29 | utilities/dpctl.8 \ 30 | utilities/ofp-discover.8 \ 31 | utilities/ofp-kill.8 \ 32 | utilities/ofp-pki.8 \ 33 | utilities/vlogconf.8 34 | 35 | utilities_dpctl_SOURCES = utilities/dpctl.c 36 | utilities_dpctl_LDADD = lib/libopenflow.a oflib/liboflib.a oflib-exp/liboflib_exp.a $(FAULT_LIBS) $(SSL_LIBS) 37 | 38 | utilities_vlogconf_SOURCES = utilities/vlogconf.c 39 | utilities_vlogconf_LDADD = lib/libopenflow.a 40 | 41 | utilities_ofp_discover_SOURCES = utilities/ofp-discover.c 42 | utilities_ofp_discover_LDADD = lib/libopenflow.a 43 | 44 | utilities_ofp_kill_SOURCES = utilities/ofp-kill.c 45 | utilities_ofp_kill_LDADD = lib/libopenflow.a 46 | -------------------------------------------------------------------------------- /utilities/ofp-kill.8.in: -------------------------------------------------------------------------------- 1 | .ds PN ofp\-kill 2 | 3 | .TH ofp\-kill 8 "May 2008" "OpenFlow" "OpenFlow Manual" 4 | 5 | .SH NAME 6 | ofp\-kill \- kills processes given their pidfiles 7 | 8 | .SH SYNOPSIS 9 | .B ofp\-kill 10 | [\fIoptions\fR] \fIpidfile\fR [\fIpidfile\fR...] 11 | 12 | .SH DESCRIPTION 13 | The \fBofp\-kill\fR program reads each \fIpidfile\fR specified on the 14 | command line and sends a signal to the program associated with it, if 15 | any. It reads one line of text from \fIpidfile\fR, which must contain 16 | the PID of the process to kill as a text string. It then uses 17 | \fBfcntl\fR(2) to verify that a process with the PID from the file 18 | owns a lock on \fIpidfile\fR before it sends the signal. 19 | 20 | A \fIpidfile\fR whose name begins with \fB/\fR is used literally. 21 | Otherwise, \fB@RUNDIR@/\fR is prefixed. 22 | 23 | This program exists for use by \fBofp\-switch\-setup\fR, which cannot 24 | easily implement its functionality since Perl has no portable 25 | interface to \fBfcntl\fR-based file locking. 26 | 27 | .SH OPTIONS 28 | .TP 29 | \fB-s \fInumber\fR|\fIname\fR, \fB\-\^\-signal=\fInumber\fR|\fIname\fR 30 | Sets the signal to be sent to each process. Signals may be given by 31 | number (e.g. \fB1\fR) or by name (e.g. \fBHUP\fR or \fBSIGHUP\fR). 32 | By default, \fBSIGTERM\fR is sent. 33 | 34 | .TP 35 | \fB-f\fR, \fB\-\^\-force\fR 36 | Causes \fBofp\-kill\fR to ignore all errors without printing a message 37 | to \fBstderr\fR, and to exit with return code 0. 38 | 39 | .so lib/common.man 40 | 41 | .SH "EXIT CODE" 42 | 43 | Without \fB-f\fR or \fB\-\^\-force\fR, \fBofp\-kill\fR exits with 44 | status 0 if at least one \fIpidfile\fR was given and the process 45 | represented by every \fIpidfile\fR was signaled successfully, 46 | otherwise with status 1. 47 | 48 | With \fB-f\fR or \fB\-\^\-force\fR, \fBofp\-kill\fR always exits with 49 | status 0. 50 | 51 | .SH BUGS 52 | 53 | There is a race between verifying the lock on \fIpidfile\fR and 54 | actually killing the process. 55 | 56 | \fBofp\-kill\fR does not wait for the signaled processes to die before 57 | exiting. 58 | 59 | .SH "SEE ALSO" 60 | 61 | .BR ofp\-switch\-setup (8) 62 | -------------------------------------------------------------------------------- /utilities/ofp-pki-cgi.in: -------------------------------------------------------------------------------- 1 | #! @PERL@ 2 | 3 | use CGI; 4 | use Digest::SHA1; 5 | use Fcntl; 6 | 7 | $CGI::POST_MAX = 65536; # Limit POSTs to 64 kB. 8 | 9 | use strict; 10 | use warnings; 11 | 12 | my $pkidir = '@PKIDIR@'; 13 | my $q = new CGI; 14 | 15 | die unless $q->request_method() eq 'POST'; 16 | 17 | my $type = $q->param('type'); 18 | die unless defined $type; 19 | die unless $type eq 'switch' or $type eq 'controller'; 20 | 21 | my $req = $q->param('req'); 22 | die unless defined $req; 23 | die unless $req =~ /^-----BEGIN CERTIFICATE REQUEST-----$/m; 24 | die unless $req =~ /^-----END CERTIFICATE REQUEST-----$/m; 25 | 26 | my $digest = Digest::SHA1::sha1_hex($req); 27 | my $incoming = "$pkidir/${type}ca/incoming"; 28 | my $dst = "$incoming/$digest-req.pem"; 29 | 30 | sysopen(REQUEST, "$dst.tmp", O_RDWR | O_CREAT | O_EXCL, 0600) 31 | or die "sysopen $dst.tmp: $!"; 32 | print REQUEST $req; 33 | close(REQUEST) or die "close $dst.tmp: $!"; 34 | 35 | rename("$dst.tmp", $dst) or die "rename $dst.tmp to $dst: $!"; 36 | 37 | print $q->header('text/html', '204 No response'); 38 | 39 | # Local Variables: 40 | # mode: perl 41 | # End: 42 | -------------------------------------------------------------------------------- /utilities/vlog-modules.def: -------------------------------------------------------------------------------- 1 | VLOG_MODULE(dpctl) 2 | VLOG_MODULE(ofp_discover) 3 | --------------------------------------------------------------------------------