Initial oftest skeleton with wrapper generators and pylibopenflow
diff --git a/doc/Doxyfile b/doc/Doxyfile
new file mode 100644
index 0000000..3def26f
--- /dev/null
+++ b/doc/Doxyfile
@@ -0,0 +1,1418 @@
+# Doxyfile 1.5.6
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = 
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = 
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, 
+# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), 
+# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, 
+# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, 
+# and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Java. For instance, namespaces will be presented as packages, qualified 
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = YES
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
+# to include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter 
+# and setter methods for a property. Setting this option to YES (the default) 
+# will make doxygen to replace the get and set methods by a property in the 
+# documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page.  This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from 
+# the version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = "../src/controller" "../src/dataplane" \
+                       "../src/ofmsg" "../src/packet"
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          = "*.py"
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = "python /usr/bin/doxypy.py"
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.  Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded. For this to work a browser that supports 
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to FRAME, a side panel will be generated
+# containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature. Other possible values 
+# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
+# and Class Hiererachy pages using a tree view instead of an ordered list;
+# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
+# disables this behavior completely. For backwards compatibility with previous
+# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
+# respectively.
+
+GENERATE_TREEVIEW      = NONE
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# By default doxygen will write a font called FreeSans.ttf to the output 
+# directory and reference it in all dot files that doxygen generates. This 
+# font does not include all possible unicode characters however, so when you need 
+# these (or just want a differently looking font) you can specify the font name 
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font, 
+# which can be done by putting it in a standard location or by setting the 
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# By default doxygen will tell dot to use the output directory to look for the 
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a 
+# different font using DOT_FONTNAME you can set the path where dot 
+# can find it using this tag.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
+# doxygen will generate a call dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable call graphs 
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
+# doxygen will generate a caller dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable caller 
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is enabled by default, which results in a transparent 
+# background. Warning: Depending on the platform used, enabling this option 
+# may lead to badly anti-aliased labels on the edges of a graph (i.e. they 
+# become hard to read).
+
+DOT_TRANSPARENT        = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
diff --git a/src/python/oftest/ofmsg/action_list.py b/src/python/oftest/ofmsg/action_list.py
new file mode 100644
index 0000000..83dc850
--- /dev/null
+++ b/src/python/oftest/ofmsg/action_list.py
@@ -0,0 +1,140 @@
+"""
+OpenFlow actions list class
+"""
+
+from action import *
+from ofp import ofp_header
+
+# # Map OFP action identifiers to the actual structures used on the wire
+# action_object_map = {
+#     OFPAT_OUTPUT                        : ofp_action_output,
+#     OFPAT_SET_VLAN_VID                  : ofp_action_vlan_vid,
+#     OFPAT_SET_VLAN_PCP                  : ofp_action_vlan_pcp,
+#     OFPAT_STRIP_VLAN                    : ofp_action_header,
+#     OFPAT_SET_DL_SRC                    : ofp_action_dl_addr,
+#     OFPAT_SET_DL_DST                    : ofp_action_dl_addr,
+#     OFPAT_SET_NW_SRC                    : ofp_action_nw_addr,
+#     OFPAT_SET_NW_DST                    : ofp_action_nw_addr,
+#     OFPAT_SET_NW_TOS                    : ofp_action_nw_tos,
+#     OFPAT_SET_TP_SRC                    : ofp_action_tp_port,
+#     OFPAT_SET_TP_DST                    : ofp_action_tp_port,
+#     OFPAT_ENQUEUE                       : ofp_action_enqueue
+# }
+
+# For debugging
+action_object_map = {
+    OFPAT_OUTPUT                        : action_output,
+    OFPAT_SET_VLAN_VID                  : action_set_vlan_vid,
+    OFPAT_SET_VLAN_PCP                  : action_set_vlan_pcp,
+    OFPAT_STRIP_VLAN                    : action_strip_vlan,
+    OFPAT_SET_DL_SRC                    : action_set_dl_src,
+    OFPAT_SET_DL_DST                    : action_set_dl_dst,
+    OFPAT_SET_NW_SRC                    : action_set_nw_src,
+    OFPAT_SET_NW_DST                    : action_set_nw_dst,
+    OFPAT_SET_NW_TOS                    : action_set_nw_tos,
+    OFPAT_SET_TP_SRC                    : action_set_tp_src,
+    OFPAT_SET_TP_DST                    : action_set_tp_dst,
+    OFPAT_ENQUEUE                       : action_enqueue
+}
+
+class action_list(object):
+    """
+    Maintain a list of actions
+
+    Data members:
+    @arg actions: An array of action objects such as action_output, etc.
+
+    Methods:
+    @arg pack: Pack the structure into a string
+    @arg unpack: Unpack a string to objects, with proper typing
+    @arg add: Add an action to the list; you can directly access
+    the action member, but add will validate that the added object 
+    is an action.
+
+    """
+
+    def __init__(self):
+        self.actions = []
+
+    def pack(self):
+        """
+        Pack a list of actions
+
+        Returns the packed string
+        """
+
+        packed = ""
+        for act in self.actions:
+            packed += act.pack()
+        return packed
+
+    def unpack(self, binary_string, bytes=None):
+        """
+        Unpack a list of actions
+        
+        Unpack actions from a binary string, creating an array
+        of objects of the appropriate type
+
+        @param binary_string The string to be unpacked
+
+        @param bytes The total length of the action list in bytes.  
+        Ignored if decode is True.  If None and decode is false, the
+        list is assumed to extend through the entire string.
+
+        @return The remainder of binary_string that was not parsed
+
+        """
+        if bytes == None:
+            bytes = len(binary_string)
+        bytes_done = 0
+        count = 0
+        cur_string = binary_string
+        while bytes_done < bytes:
+            hdr = ofp_action_header()
+            hdr.unpack(cur_string)
+            if not hdr.type in action_object_map.keys():
+                print "WARNING: Skipping unknown action ", hdr.type
+            else:
+                print "DEBUG: Found action of type ", hdr.type
+                self.actions.append(action_object_map[hdr.type]())
+                self.actions[count].unpack(binary_string)
+                count += 1
+            cur_string = cur_string[hdr.len:]
+            bytes_done += hdr.len
+        return cur_string
+
+    def add(self, action):
+        """
+        Add an action to an action list
+
+        @param action The action to add
+
+        @return True if successful, False if not an action object
+
+        """
+        if isinstance(action, action_class_list):
+            self.actions.append(action)
+            return True
+        return False
+
+    def __len__(self):
+        length = 0
+        for act in self.actions:
+            length += act.__len__()
+        return length
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.actions != other.actions: return False
+        return True
+
+    def __ne__(self, other): return not self.__eq__(other)
+        
+    def show(self, prefix=''):
+        print prefix + "Action List with " + str(len(self.actions)) + \
+            " actions"
+        count = 0
+        for obj in self.actions:
+            count += 1
+            print "  Action " + str(count) + ": "
+            obj.show(prefix + '    ')
diff --git a/src/python/oftest/ofmsg/of_message.py b/src/python/oftest/ofmsg/of_message.py
new file mode 100644
index 0000000..bd6d639
--- /dev/null
+++ b/src/python/oftest/ofmsg/of_message.py
@@ -0,0 +1,127 @@
+
+from message import *
+from error import *
+from action import *
+from action_list import action_list
+from ofp import *
+
+"""
+of_message.py
+Contains wrapper functions and classes for the of_message namespace
+that are generated by hand.  It includes the rest of the wrapper
+function information into the of_message namespace
+"""
+
+# These message types are subclassed
+msg_type_subclassed = [
+    OFPT_STATS_REQUEST,
+    OFPT_STATS_REPLY,
+    OFPT_ERROR
+]
+
+# Maps from sub-types to classes
+stats_reply_to_class_map = {
+    OFPST_DESC                      : desc_stats_reply,
+    OFPST_AGGREGATE                 : aggregate_stats_reply,
+    OFPST_FLOW                      : flow_stats_reply,
+    OFPST_TABLE                     : table_stats_reply,
+    OFPST_PORT                      : port_stats_reply,
+    OFPST_QUEUE                     : queue_stats_reply
+}
+
+stats_request_to_class_map = {
+    OFPST_DESC                      : desc_stats_request,
+    OFPST_AGGREGATE                 : aggregate_stats_request,
+    OFPST_FLOW                      : flow_stats_request,
+    OFPST_TABLE                     : table_stats_request,
+    OFPST_PORT                      : port_stats_request,
+    OFPST_QUEUE                     : queue_stats_request
+}
+
+error_to_class_map = {
+    OFPET_HELLO_FAILED              : hello_failed_error_msg,
+    OFPET_BAD_REQUEST               : bad_request_error_msg,
+    OFPET_BAD_ACTION                : bad_action_error_msg,
+    OFPET_FLOW_MOD_FAILED           : flow_mod_failed_error_msg,
+    OFPET_PORT_MOD_FAILED           : port_mod_failed_error_msg,
+    OFPET_QUEUE_OP_FAILED           : queue_op_failed_error_msg
+}
+
+# Map from header type value to the underlieing message class
+msg_type_to_class_map = {
+    OFPT_HELLO                      : hello,
+    OFPT_ERROR                      : error,
+    OFPT_ECHO_REQUEST               : echo_request,
+    OFPT_ECHO_REPLY                 : echo_reply,
+    OFPT_VENDOR                     : vendor,
+    OFPT_FEATURES_REQUEST           : features_request,
+    OFPT_FEATURES_REPLY             : features_reply,
+    OFPT_GET_CONFIG_REQUEST         : get_config_request,
+    OFPT_GET_CONFIG_REPLY           : get_config_reply,
+    OFPT_SET_CONFIG                 : set_config,
+    OFPT_PACKET_IN                  : packet_in,
+    OFPT_FLOW_REMOVED               : flow_removed,
+    OFPT_PORT_STATUS                : port_status,
+    OFPT_PACKET_OUT                 : packet_out,
+    OFPT_FLOW_MOD                   : flow_mod,
+    OFPT_PORT_MOD                   : port_mod,
+    OFPT_STATS_REQUEST              : stats_request,
+    OFPT_STATS_REPLY                : stats_reply,
+    OFPT_BARRIER_REQUEST            : barrier_request,
+    OFPT_BARRIER_REPLY              : barrier_reply,
+    OFPT_QUEUE_GET_CONFIG_REQUEST   : queue_get_config_request,
+    OFPT_QUEUE_GET_CONFIG_REPLY     : queue_get_config_reply
+}
+
+def _of_message_to_object(binary_string):
+    """
+    Map a binary string to the corresponding class.
+
+    Appropriately resolves subclasses
+    """
+    hdr = ofp_header()
+    hdr.unpack(binary_string)
+    # FIXME: Add error detection
+    if not hdr.type in msg_type_subclassed:
+        return msg_type_to_class_map[hdr.type]()
+    if hdr.type == OFPT_STATS_REQUEST:
+        st_hdr = ofp_stats_request()
+        st_hdr.unpack(binary_string)
+        return stats_request_to_class_map[st_hdr.type]()
+    elif hdr.type == OFPT_STATS_REPLY:
+        st_hdr = ofp_stats_reply()
+        st_hdr.unpack(binary_string)
+        return stats_reply_to_class_map[st_hdr.type]()
+    elif hdr.type == OFPT_STATS_REPLY:
+        st_hdr = ofp_error_msg()
+        st_hdr.unpack(binary_string)
+        return error_to_class_map[st_hdr.type]()
+    else:
+        print "ERROR parsing packet to object"
+        return None
+
+def of_message_parse(binary_string, raw=False):
+    """
+    Parse an OpenFlow packet
+
+    Parses a raw OpenFlow packet into a Python class, with class
+    members fully populated.
+
+    @param binary_string The packet (string) to be parsed
+
+    @param raw If true, interpret the packet as an L2 packet.  Not
+    yet supported.
+
+    @return An object of some message class or None if fails
+
+    """
+
+    if raw:
+        print "raw packet message parsing not supported"
+        return None
+
+    obj = _of_message_to_object(binary_string)
+    if obj != None:
+        obj.unpack(binary_string)
+    return obj
+
diff --git a/tools/munger/Makefile b/tools/munger/Makefile
new file mode 100644
index 0000000..5dd3f5c
--- /dev/null
+++ b/tools/munger/Makefile
@@ -0,0 +1,79 @@
+#
+# Simple make file to generate OpenFlow python files
+#
+# Fixme:  Would like pylibopenflow to be able to run remotely
+# Currently, we have to cd to it's dir and refer back to local
+
+TOP_DIR = ../..
+TOOLS_DIR = ..
+DOC_DIR = ${TOP_DIR}/doc
+
+PYLIBOF_DIR = ${TOOLS_DIR}/pylibopenflow
+
+TARGET_DIR = ${TOP_DIR}/src/python/oftest/ofmsg
+
+# Relative to pyopenflow-pythonize exec location
+OF_HEADER = include/openflow.h
+
+# Relative to here
+ABS_OF_HEADER = ${PYLIBOF_DIR}/${OF_HEADER}
+
+PYTHONIZE = bin/pyopenflow-pythonize.py
+OFP_GEN_CMD = (cd ${PYLIBOF_DIR} && ${PYTHONIZE} -i ${OF_HEADER} \
+	${TARGET_DIR}/ofp.py)
+
+# Dependencies for ofp.py
+OFP_DEP = ${ABS_OF_HEADER} $(wildcard ${PYLIBOF_DIR}/pylib/*.py)
+OFP_DEP = $(wildcard ${PYLIBOF_DIR}/pylib/of/*.py) 
+
+# FIXME:  There are three types of .py files:
+#    ofp.py from pylibopenflow output
+#    %.py generated from %_gen.py
+#    of_message.py and action_list.py -- hand built, already in src dir
+
+GEN_FILES := $(addprefix ${TARGET_DIR}/,ofp.py message.py error.py action.py)
+OTHER_FILES :=  $(addprefix ${TARGET_DIR}/,action_list.py of_message.py)
+LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES}
+LINT_FILES := $(subst .py,.log,${LINT_SOURCE})
+LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES})
+
+all: ${GEN_FILES}
+	@echo "Generated files"
+
+${TARGET_DIR}/ofp.py: ${OFP_DEP}
+	${OFP_GEN_CMD}
+
+# General rule like src/message.py comes from scripts/message_gen.py
+${TARGET_DIR}/%.py: scripts/%_gen.py ${TARGET_DIR}/ofp.py
+	python $< > $@
+
+lint/%.log: ${TARGET_DIR}/%.py
+	(cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@
+
+lint: ${LINT_FILES}
+
+# For now. just local source doc generated
+doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile
+	(cd ${DOC_DIR} && doxygen)
+
+clean:
+	rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/*
+
+help:
+	@echo
+	@echo Makefile for oftest source munger
+	@echo     Default builds python files and installs in ${TARGET_DIR}
+	@echo     make local:  Generate files and put in src/
+	@echo
+	@echo Debug info:
+	@echo
+	@echo Files generated GEN_FILES:  ${GEN_FILES}
+	@echo
+	@echo Dependencies for ofp.py OFP_DEP:  ${OFP_DEP}
+	@echo
+	@echo Already created files OTHER_FILES:  ${OTHER_FILES}
+	@echo
+	@echo LINT_FILES:  ${LINT_FILES}
+
+
+.PHONY: all local install help doc lint clean
diff --git a/tools/munger/scripts/action_gen.py b/tools/munger/scripts/action_gen.py
new file mode 100644
index 0000000..22c7b4b
--- /dev/null
+++ b/tools/munger/scripts/action_gen.py
@@ -0,0 +1,97 @@
+#!/usr/bin/python
+#
+# This python script generates action subclasses
+#
+
+import re
+
+print """
+# Python OpenFlow action wrapper classes
+
+from ofp import *
+
+# This will never happen; done to avoid lint warning
+if __name__ == '__main__':
+    def of_message_parse(msg): return None
+
+"""
+
+################################################################
+#
+# Action subclasses
+#
+################################################################
+
+action_structs = [
+    'output',
+    'vlan_vid',
+    'vlan_pcp',
+    'dl_addr',
+    'nw_addr',
+    'tp_port',
+    'nw_tos',
+    'vendor_header']
+
+action_types = [
+    'output',
+    'set_vlan_vid',
+    'set_vlan_pcp',
+    'strip_vlan',
+    'set_dl_src',
+    'set_dl_dst',
+    'set_nw_src',
+    'set_nw_dst',
+    'set_nw_tos',
+    'set_tp_src',
+    'set_tp_dst',
+    'enqueue',
+    'vendor'
+]
+action_types.sort()
+
+action_class_map = {
+    'output' : 'ofp_action_output',
+    'set_vlan_vid' : 'ofp_action_vlan_vid',
+    'set_vlan_pcp' : 'ofp_action_vlan_pcp',
+    'strip_vlan' : 'ofp_action_header',
+    'set_dl_src' : 'ofp_action_dl_addr',
+    'set_dl_dst' : 'ofp_action_dl_addr',
+    'set_nw_src' : 'ofp_action_nw_addr',
+    'set_nw_dst' : 'ofp_action_nw_addr',
+    'set_nw_tos' : 'ofp_action_nw_tos',
+    'set_tp_src' : 'ofp_action_tp_port',
+    'set_tp_dst' : 'ofp_action_tp_port',
+    'enqueue' : 'ofp_action_enqueue',
+    'vendor' : 'ofp_action_vendor_header'
+}
+
+template = """
+class action_--TYPE--(--PARENT_TYPE--):
+    \"""
+    Wrapper class for --TYPE-- action object
+    \"""
+    def __init__(self):
+        --PARENT_TYPE--.__init__(self)
+        self.type = --ACTION_NAME--
+        self.len = self.__len__()
+    def show(self, prefix=''):
+        print prefix + "action_--TYPE--"
+        --PARENT_TYPE--.show(self, prefix)
+"""
+
+if __name__ == '__main__':
+    for (t, parent) in action_class_map.items():
+        action_name = "OFPAT_" + t.upper()
+        to_print = re.sub('--TYPE--', t, template)
+        to_print = re.sub('--PARENT_TYPE--', parent, to_print)
+        to_print = re.sub('--ACTION_NAME--', action_name, to_print)
+        print to_print
+
+    # Generate a list of action classes
+    print "action_class_list = ("
+    prev = None
+    for (t, parent) in action_class_map.items():
+        if prev:
+            print "    action_" + prev + ","
+        prev = t
+    print "    action_" + prev + ")"
diff --git a/tools/munger/scripts/error_gen.py b/tools/munger/scripts/error_gen.py
new file mode 100644
index 0000000..7dff087
--- /dev/null
+++ b/tools/munger/scripts/error_gen.py
@@ -0,0 +1,75 @@
+#!/usr/bin/python
+#
+# This python script generates error subclasses
+#
+
+import re
+
+print """
+# Python OpenFlow error wrapper classes
+
+from ofp import *
+
+# This will never happen; done to avoid lint warning
+if __name__ == '__main__':
+    def of_message_parse(msg): return None
+
+"""
+
+################################################################
+#
+# Error message subclasses
+#
+################################################################
+
+# Template for error subclasses
+
+template = """
+class --TYPE--_error_msg(ofp_error_msg):
+    \"""
+    Wrapper class for --TYPE-- error message class
+    \"""
+    def __init__(self):
+        ofp_error_msg.__init__(self)
+        self.header = ofp_header()
+        self.header.type = OFPT_ERROR
+        self.type = --ERROR_NAME--
+        self.data = ""
+
+    def pack(self, assertstruct=True):
+        self.header.length = self.__len__()
+        packed = ofp_error_msg.pack(self)
+        packed += self.data
+
+    def unpack(self, binary_string):
+        binary_string = ofp_error_msg.unpack(self, binary_string)
+        self.data = binary_string
+        return []
+
+    def __len__(self):
+        return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
+
+    def show(self, prefix=''):
+        print prefix + "--TYPE--_error_msg"
+        ofp_error_msg.show(self)
+        print prefix + "data is of length " + len(self.data)
+        obj = of_message_parse(self.data)
+        if obj != None:
+            obj.show()
+        else:
+            print prefix + "Unable to parse data"
+"""
+
+error_types = [
+    'hello_failed',
+    'bad_request',
+    'bad_action',
+    'flow_mod_failed',
+    'port_mod_failed',
+    'queue_op_failed']
+
+for t in error_types:
+    error_name = "OFPET_" + t.upper()
+    to_print = re.sub('--TYPE--', t, template)
+    to_print = re.sub('--ERROR_NAME--', error_name, to_print)
+    print to_print
diff --git a/tools/munger/scripts/message_gen.py b/tools/munger/scripts/message_gen.py
new file mode 100644
index 0000000..f065874
--- /dev/null
+++ b/tools/munger/scripts/message_gen.py
@@ -0,0 +1,650 @@
+#!/usr/bin/python
+#
+# This python script generates wrapper functions for OpenFlow messages
+#
+# See the doc string below for more info
+#
+
+# To do:
+#    Default type values for messages
+#    Generate all message objects
+#    Action list objects?
+#    Autogen lengths when possible
+#    Dictionaries for enum strings
+#    Resolve sub struct initializers (see ofp_flow_mod)
+
+
+"""
+Generate wrapper classes for OpenFlow messages
+
+(C) Copyright Stanford University
+Date February 2010
+Created by dtalayco
+
+Attempting to follow http://www.python.org/dev/peps/pep-0008/
+The main exception is that our class names do not use CamelCase
+so as to more closely match the original C code names.
+
+This file is meant to generate a file of_wrapper.py which imports
+the base classes generated form automatic processing of openflow.h
+and produces wrapper classes for each OpenFlow message type.
+
+This file will normally be included in of_message.py which provides
+additional hand-generated work.
+
+There are two types of structures/classes here: base components and
+message classes.
+
+Base components are the base data classes which are fixed
+length structures including:
+    ofp_header
+    Each ofp_action structure
+    ofp_phy_port
+    The array elements of all the stats reply messages
+The base components are to be imported from a file of_header.py.
+
+Message classes define a complete message on the wire.  These are
+comprised of possibly variable length lists of possibly variably
+typed objects from the base component list above.
+
+Each OpenFlow message has a header and zero or more fixed length
+members (the "core members" of the class) followed by zero or more
+variable length lists.
+
+The wrapper classes should live in their own name space, probably
+of_message.  Automatically generated base component and skeletons for
+the message classes are assumed generated and the wrapper classes
+will inherit from those.
+
+Every message class must implement pack and unpack functions to
+convert between the class and a string representing what goes on the
+wire.
+
+For unpacking, the low level (base-component) classes must implement
+their own unpack functions.  A single top level unpack function
+will do the parsing and call the lower layer unpack functions as
+appropriate.
+
+Every base and message class should implement a show function to
+(recursively) display the contents of the object.
+
+Certain OpenFlow message types are further subclassed.  These include
+stats_request, stats_reply and error.
+
+"""
+
+# Don't generate header object in messages
+# Map each message to a body that doesn't include the header
+# The body has does not include variable length info at the end
+
+import re
+import string
+import sys
+
+message_top_matter = """
+# Python OpenFlow message wrapper classes
+
+from ofp import *
+from action_list import action_list
+
+# This will never happen; done to avoid lint warning
+if __name__ == '__main__':
+    def of_message_parse(msg): return None
+
+# Define templates for documentation
+class ofp_template_msg:
+    \"""
+    Sample base class for template_msg; normally auto generated
+    This class should live in the of_header name space and provides the
+    base class for this type of message.  It will be wrapped for the
+    high level API.
+
+    \"""
+    def __init__(self):
+        \"""
+        Constructor for base class
+
+        \"""
+        self.header = ofp_header()
+        # Additional base data members declared here
+    # Normally will define pack, unpack, __len__ functions
+
+class template_msg(ofp_template_msg):
+    \"""
+    Sample class wrapper for template_msg
+    This class should live in the of_message name space and provides the
+    high level API for an OpenFlow message object.  These objects must
+    implement the functions indicated in this template.
+
+    \"""
+    def __init__(self):
+        \"""
+        Constructor
+        Must set the header type value appropriately for the message
+
+        \"""
+        ofp_template_msg.__init__(self)
+        # For a real message, will be set to an integer
+        self.header.type = "TEMPLATE_MSG_VALUE"
+    def pack(self):
+        \"""
+        Pack object into string
+
+        @return The packed string which can go on the wire
+
+        \"""
+        pass
+    def unpack(self, binary_string):
+        \"""
+        Unpack object from a binary string
+
+        @param binary_string The wire protocol byte string holding the object
+        represented as an array of bytes.
+
+        @return Typically returns the remainder of binary_string that
+        was not parsed.  May give a warning if that string is non-empty
+
+        \"""
+        pass
+    def __len__(self):
+        \"""
+        Return the length of this object once packed into a string
+
+        @return An integer representing the number bytes in the packed
+        string.
+
+        \"""
+        pass
+    def show(self, prefix=''):
+        \"""
+        Display the contents of the object in a readable manner
+
+        @param prefix Printed at the beginning of each line.
+
+        \"""
+        pass
+    def __eq__(self, other):
+        \"""
+        Return True if self and other hold the same data
+
+        @param other Other object in comparison
+
+        \"""
+        pass
+    def __ne__(self, other):
+        \"""
+        Return True if self and other do not hold the same data
+
+        @param other Other object in comparison
+
+        \"""
+        pass
+"""
+
+# Dictionary mapping wrapped classes to the auto-generated structure
+# underlieing the class (body only, not header or var-length data)
+message_class_map = {
+    "hello"                         : "ofp_header",
+    "error"                         : "ofp_error_msg",
+    "echo_request"                  : "ofp_header",
+    "echo_reply"                    : "ofp_header",
+    "vendor"                        : "ofp_vendor_header",
+    "features_request"              : "ofp_header",
+    "features_reply"                : "ofp_switch_features",
+    "get_config_request"            : "ofp_header",
+    "get_config_reply"              : "ofp_switch_config",
+    "set_config"                    : "ofp_switch_config",
+    "packet_in"                     : "ofp_packet_in",
+    "flow_removed"                  : "ofp_flow_removed",
+    "port_status"                   : "ofp_port_status",
+    "packet_out"                    : "ofp_packet_out",
+    "flow_mod"                      : "ofp_flow_mod",
+    "port_mod"                      : "ofp_port_mod",
+    "stats_request"                 : "ofp_stats_request",
+    "stats_reply"                   : "ofp_stats_reply",
+    "barrier_request"               : "ofp_header",
+    "barrier_reply"                 : "ofp_header",
+    "queue_get_config_request"      : "ofp_queue_get_config_request",
+    "queue_get_config_reply"        : "ofp_queue_get_config_reply"
+}
+
+# These messages have a string member at the end of the data
+string_members = [
+    "hello",
+    "error",
+    "echo_request",
+    "echo_reply",
+    "vendor",
+    "packet_in",
+    "packet_out"
+]
+
+# These messages have a list (with the given name) in the data,
+# after the core members; the type is given for validation
+list_members = {
+    "features_reply"                : ('ports', None),
+    "packet_out"                    : ('actions', 'action_list'),
+    "flow_mod"                      : ('actions', 'action_list'),
+    "queue_get_config_reply"        : ('queues', None)
+}
+
+_ind = "    "
+
+def _p1(s): print _ind + s
+def _p2(s): print _ind * 2 + s
+def _p3(s): print _ind * 3 + s
+def _p4(s): print _ind * 4 + s
+
+# Okay, this gets kind of ugly:
+# There are three variables:  
+# has_core_members:  If parent class is not ofp_header, has inheritance
+# has_list: Whether class has trailing array or class
+# has_string: Whether class has trailing string
+
+def gen_message_wrapper(msg):
+    """
+    Generate a wrapper for the given message based on above info
+    @param msg String identifying the message name for the class
+    """
+
+    msg_name = "OFPT_" + msg.upper()
+    parent = message_class_map[msg]
+
+    has_list = False    # Has trailing list
+    has_core_members = False
+    has_string = False  # Has trailing string
+    if parent != 'ofp_header':
+        has_core_members = True
+    if msg in list_members.keys():
+        (list_var, list_type) = list_members[msg]
+        has_list = True
+    if msg in string_members:
+        has_string = True
+
+    if has_core_members:
+        print "class " + msg + "(" + parent + "):"
+    else:
+        print "class " + msg + ":"
+    _p1('"""')
+    _p1("Wrapper class for " + msg)
+    print
+    if has_list:
+        if list_type == None:
+            _p1("Has trailing variable array " + list_var);
+        else:
+            _p1("Has trailing object " + list_var + " of type " + list_type);
+        print
+    if has_string:
+        _p1("Has trailing string data")
+        print
+    _p1('"""')
+
+    print
+    _p1("def __init__(self):")
+    if has_core_members:
+        _p2(parent + ".__init__(self)")
+    _p2("self.header = ofp_header()")
+    _p2("self.header.type = " + msg_name)
+    if has_list:
+        if list_type == None:
+            _p2('self.' + list_var + ' = []')
+        else:
+            _p2('self.' + list_var + ' = ' + list_type + '()')
+    if has_string:
+        _p2('self.data = ""')
+
+    print
+    _p1("def pack(self):")
+    _p2("# Fixme:  Calculate length for header, etc, once __len__ fixed")
+    _p2("packed = self.header.pack()")
+    if has_core_members:
+        _p2("packed += " + parent + ".pack()")
+    if has_list:
+        if list_type == None:
+            _p2('for obj in self.' + list_var + ':')
+            _p3('packed += obj.pack()')
+        else:
+            _p2('packed += self.' + list_var + '.pack()')
+    if has_string:
+        _p2('packed += self.data')
+
+    print
+    _p1("def unpack(self, binary_string):")
+    _p2("binary_string = self.header.unpack(binary_string)")
+    if has_core_members:
+        _p2("binary_string = " + parent + ".unpack(self, binary_string)")
+    if has_list:
+        if list_type == None:
+            _p2("for obj in self." + list_var + ":")
+            _p3("binary_string = obj.unpack(binary_string)")
+        elif msg == "packet_out":  # Special case this
+            _p2('binary_string = self.actions.unpack(bytes=self.actions_len)')
+        elif msg == "flow_mod":  # Special case this
+            _p2("ai_len = self.header.length - OFP_FLOW_MOD_BYTES")
+            _p2("binary_string = self.actions.unpack(bytes=ai_len)")
+        else:
+            _p2("binary_string = self." + list_var + ".unpack(binary_string)")
+    if has_string:
+        _p2("self.data = binary_string")
+        _p2("binary_string = ''")
+    else:
+        _p2("# Fixme: If no self.data, add check for data remaining")
+    _p2("return binary_string")
+
+    print
+    _p1("def __len__(self):")
+    _p2("# Fixme:  Do the right thing")
+    _p2("return len(self.pack())")
+
+    print
+    _p1("def show(self, prefix=''):")
+    _p2("print prefix + '" + msg + " (" + msg_name + ")'")
+    _p2("prefix += '  '")
+    _p2("self.header.show(prefix)")
+    if has_core_members:
+        _p2(parent + ".show(self, prefix)")
+    if has_list:
+        if list_type == None:
+            _p2('print prefix + "Array ' + list_var + '"')
+            _p2('for obj in self.' + list_var +':')
+            _p3("obj.show(prefix + '  ')")
+        else:
+            _p2('print prefix + "List ' + list_var + '"')
+            _p2('self.' + list_var + ".show(prefix + '  ')")
+    if has_string:
+        _p2("print prefix + 'data is of length ' + str(len(self.data))")
+        _p2("if len(self.data) > 0:")
+        _p3("obj = of_message_parse(self.data)")
+        _p3("if obj != None:")
+        _p4("obj.show(prefix)")
+        _p3("else:")
+        _p4('print prefix + "Unable to parse data"')
+
+    print
+    _p1("def __eq__(self, other):")
+    _p2("if type(self) != type (other): return False")
+    _p2("if self.header.__ne__(other.header): return False")
+    if has_core_members:
+        _p2("if " + parent + ".__ne__(other." + parent + "): return False")
+    if has_string:
+        _p2("if self.data != other.data: return False")
+    if has_list:
+        _p2("if self." + list_var + " != other." + list_var + ": return False")
+    _p2("return True")
+
+    print
+    _p1("def __ne__(self, other): return not self.__eq__(other)")
+
+
+
+################################################################
+#
+# Stats request subclasses
+# description_request, flow, aggregate, table, port, vendor
+#
+################################################################
+
+# table and desc stats requests are special with empty body
+extra_ofp_stats_req_defs = """
+# Stats request bodies for desc and table stats are not defined in the
+# OpenFlow header;  We define them here.  They are empty classes, really
+
+class ofp_desc_stats_request:
+    \"""
+    Forced definition of ofp_desc_stats_request (empty class)
+    \"""
+    def __init__(self):
+        pass
+    def pack(self, assertstruct=True):
+        return ""
+    def unpack(self, binary_string):
+        return binary_string
+    def __len__(self):
+        return 0
+    def show(self, prefix=''):
+        pass
+    def __eq__(self, other):
+        return type(self) == type(other)
+    def __ne__(self, other):
+        return type(self) != type(other)
+
+OFP_DESC_STATS_REQUEST_BYTES = 0
+
+class ofp_table_stats_request:
+    \"""
+    Forced definition of ofp_table_stats_request (empty class)
+    \"""
+    def __init__(self):
+        pass
+    def pack(self, assertstruct=True):
+        return ""
+    def unpack(self, binary_string):
+        return binary_string
+    def __len__(self):
+        return 0
+    def show(self, prefix=''):
+        pass
+    def __eq__(self, other):
+        return type(self) == type(other)
+    def __ne__(self, other):
+        return type(self) != type(other)
+
+OFP_TABLE_STATS_REQUEST_BYTES = 0
+
+"""
+
+stats_request_template = """
+class --TYPE--_stats_request(ofp_stats_request, ofp_--TYPE--_stats_request):
+    \"""
+    Wrapper class for --TYPE-- stats request message
+    \"""
+    def __init__(self):
+        self.header = ofp_header()
+        ofp_stats_request.__init__(self)
+        ofp_--TYPE--_stats_request.__init__(self)
+        self.header.type = OFPT_STATS_REQUEST
+        self.type = --STATS_NAME--
+
+    def pack(self, assertstruct=True):
+        packed = ofp_stats_request.pack(self)
+        packed += ofp_--TYPE--_stats_request.pack(self)
+
+    def unpack(self, binary_string):
+        binary_string = ofp_stats_request.unpack(self, binary_string)
+        binary_string = ofp_--TYPE--_stats_request.unpack(self, binary_string)
+        if len(binary_string) != 0:
+            print "Error unpacking --TYPE--: extra data"
+        return binary_string
+
+    def __len__(self):
+        return len(self.header) + OFP_STATS_REQUEST_BYTES + \\
+               OFP_--TYPE_UPPER--_STATS_REQUEST_BYTES
+
+    def show(self, prefix=''):
+        print prefix + "--TYPE--_stats_request"
+        ofp_stats_request.show(self)
+        ofp_--TYPE--_stats_request.show(self)
+
+    def __eq__(self, other):
+        return (ofp_stats_request.__eq__(self, other) and
+                ofp_--TYPE--_stats_request.__eq__(self, other))
+
+    def __ne__(self, other): return not self.__eq__(other)
+"""
+
+################################################################
+#
+# Stats replies always have an array at the end.
+# For aggregate and desc, these arrays are always of length 1
+# This array is always called stats
+#
+################################################################
+
+
+# Template for objects stats reply messages
+stats_reply_template = """
+class --TYPE--_stats_reply(ofp_stats_reply):
+    \"""
+    Wrapper class for --TYPE-- stats reply
+    \"""
+    def __init__(self):
+        self.header = ofp_header()
+        ofp_stats_reply.__init__(self)
+        self.header.type = OFPT_STATS_REPLY
+        self.type = --STATS_NAME--
+        # stats: Array of type --TYPE--_stats_entry
+        self.stats = []
+
+    def pack(self, assertstruct=True):
+        packed = ofp_stats_reply.pack(self)
+        for obj in self.stats:
+            packed += obj.pack()
+
+    def unpack(self, binary_string):
+        binary_string = ofp_stats_reply.unpack(self, binary_string)
+        dummy = --TYPE--_stats_entry()
+        while len(binary_string) >= len(dummy):
+            obj = --TYPE--_stats_entry()
+            binary_string = obj.unpack(binary_string)
+            self.stats.append(obj)
+        if len(binary_string) != 0:
+            print "ERROR unpacking --TYPE-- stats string: extra bytes"
+        return binary_string
+
+    def __len__(self):
+        length = len(self.header) + OFP_STATS_REPLY_BYTES
+        for obj in self.stats:
+            length += len(obj)
+        return length
+
+    def show(self, prefix=''):
+        print prefix + "--TYPE--_stats_reply"
+        ofp_stats_reply.show(self)
+        for obj in self.stats:
+            obj.show()
+
+    def __eq__(self, other):
+        if ofp_stats_reply.__ne__(self, other): return False
+        return self.stats == other.stats
+
+    def __ne__(self, other): return not self.__eq__(other)
+"""
+
+#
+# To address variations in stats reply bodies, the following
+# "_entry" classes are defined for each element in the reply
+#
+
+extra_stats_entry_defs = """
+# Stats entries define the content of one element in a stats
+# reply for the indicated type; define _entry for consistency
+
+aggregate_stats_entry = ofp_aggregate_stats_reply
+desc_stats_entry = ofp_desc_stats
+port_stats_entry = ofp_port_stats
+queue_stats_entry = ofp_queue_stats
+table_stats_entry = ofp_table_stats
+"""
+
+# Special case flow_stats to handle actions_list
+
+flow_stats_entry_def = """
+#
+# Flow stats entry contains an action list of variable length, so
+# it is done by hand
+#
+
+class flow_stats_entry(ofp_flow_stats):
+    \"""
+    Special case flow stats entry to handle action list object
+    \"""
+    def __init__(self):
+        ofp_flow_stats.__init__(self)
+        self.actions = action_list()
+
+    def pack(self, assertstruct=True):
+        if self.length < OFP_FLOW_STATS_BYTES:
+            print "ERROR in flow_stats_entry pack: length member is too small"
+            return None
+        packed = ofp_flow_stats.pack(self, assertstruct)
+        packed += self.actions.pack()
+        return packed
+
+    def unpack(self, binary_string):
+        binary_string = ofp_flow_stats.unpack(self, binary_string)
+        ai_len = self.length - OFP_FLOW_STATS_BYTES
+        binary_string = self.actions.unpack(binary_string, bytes=ai_len)
+        return binary_string
+
+    def __len__(self):
+        return OFP_FLOW_STATS_BYTES + len(self.actions)
+
+    def show(self, prefix=''):
+        print prefix + "flow_stats_entry"
+        ofp_flow_stats.show(self, prefix + '  ')
+        self.actions.show(prefix + '  ')
+
+    def __eq__(self, other):
+        return (ofp_flow_stats.__eq__(self, other) and 
+                self.actions == other.actions)
+
+    def __ne__(self, other): return not self.__eq__(other)
+"""
+
+stats_types = [
+    'aggregate',
+    'desc',
+    'flow',
+    'port',
+    'queue',
+    'table']
+
+if __name__ == '__main__':
+
+    print message_top_matter
+
+    print """
+################################################################
+#
+# OpenFlow Message Definitions
+#
+################################################################
+"""
+
+    msg_types = message_class_map.keys()
+    msg_types.sort()
+
+    for t in msg_types:
+        gen_message_wrapper(t)
+        print
+
+    print """
+################################################################
+#
+# Stats request and reply subclass definitions
+#
+################################################################
+"""
+
+    print extra_ofp_stats_req_defs
+    print extra_stats_entry_defs
+    print flow_stats_entry_def
+
+    # Generate stats request and reply subclasses
+    for t in stats_types:
+        stats_name = "OFPST_" + t.upper()
+        to_print = re.sub('--TYPE--', t, stats_request_template)
+        to_print = re.sub('--TYPE_UPPER--', t.upper(), to_print)
+        to_print = re.sub('--STATS_NAME--', stats_name, to_print)
+        print to_print
+        to_print = re.sub('--TYPE--', t, stats_reply_template)
+        to_print = re.sub('--STATS_NAME--', stats_name, to_print)
+        print to_print
+
+
+#
+# OFP match variants
+#  ICMP 0x801 (?) ==> icmp_type/code replace tp_src/dst
+#
+
+
diff --git a/tools/pylibopenflow/.gitignore b/tools/pylibopenflow/.gitignore
new file mode 100644
index 0000000..2f836aa
--- /dev/null
+++ b/tools/pylibopenflow/.gitignore
@@ -0,0 +1,2 @@
+*~
+*.pyc
diff --git a/tools/pylibopenflow/bin/cstruct2py-get-struct.py b/tools/pylibopenflow/bin/cstruct2py-get-struct.py
new file mode 100755
index 0000000..4b8a350
--- /dev/null
+++ b/tools/pylibopenflow/bin/cstruct2py-get-struct.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python2.5
+"""This script reads struct from C/C++ header file and output query
+
+Author ykk
+Date June 2009
+"""
+import sys
+import getopt
+import cheader
+import c2py
+
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> header_files... struct_name\n"+\
+          "Options:\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          "-c/--cstruct\n\tPrint C struct\n"+\
+          "-n/--name\n\tPrint names of struct\n"+\
+          "-s/--size\n\tPrint size of struct\n"+\
+          ""
+          
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hcsn",
+                               ["help","cstruct","size","names"])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+
+#Check there is at least 1 input file and struct name
+if (len(args) < 2):
+    usage()
+    sys.exit(2)
+    
+#Parse options
+##Print C struct
+printc = False
+##Print names
+printname = False
+##Print size
+printsize = False
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    elif (opt in ("-s","--size")): 
+        printsize = True
+    elif (opt in ("-c","--cstruct")): 
+        printc = True
+    elif (opt in ("-n","--names")): 
+        printname = True
+    else:
+        print "Unhandled option :"+opt
+        sys.exit(1)
+
+headerfile = cheader.cheaderfile(args[:-1])
+cstruct = headerfile.structs[args[-1].strip()]
+cs2p = c2py.cstruct2py()
+pattern = cs2p.get_pattern(cstruct)
+
+#Print C struct
+if (printc):
+    print cstruct
+
+#Print pattern
+print "Python pattern = "+pattern
+
+#Print name
+if (printname):
+    print cstruct.get_names()
+
+#Print size
+if (printsize):
+    print "Size = "+str(cs2p.get_size(pattern))
diff --git a/tools/pylibopenflow/bin/cstruct2py-pythonize.py b/tools/pylibopenflow/bin/cstruct2py-pythonize.py
new file mode 100755
index 0000000..47cbffb
--- /dev/null
+++ b/tools/pylibopenflow/bin/cstruct2py-pythonize.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python2.5
+"""This script reads struct
+
+Author ykk
+Date Jan 2010
+"""
+import sys
+import getopt
+import cpythonize
+import cheader
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> header_files... output_file\n"+\
+          "Options:\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          ""
+
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "h",
+                               ["help"])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+   
+#Parse options
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    else:
+        print "Unhandled option :"+opt
+        sys.exit(2)
+
+#Check there is at least 1 input file with 1 output file
+if (len(args) < 2):
+    usage()
+    sys.exit(2)
+
+ch = cheader.cheaderfile(args[:-1])
+py = cpythonize.pythonizer(ch)
+fileRef = open(args[len(args)-1], "w")
+for l in py.pycode():
+    fileRef.write(l+"\n")
+fileRef.close()
+
diff --git a/tools/pylibopenflow/bin/cstruct2py-query-cheader.py b/tools/pylibopenflow/bin/cstruct2py-query-cheader.py
new file mode 100755
index 0000000..3d23ef0
--- /dev/null
+++ b/tools/pylibopenflow/bin/cstruct2py-query-cheader.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python2.5
+"""This script reads C/C++ header file and output query
+
+Author ykk
+Date June 2009
+"""
+import sys
+import getopt
+import cheader
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> header_file_1 header_file_2 ...\n"+\
+          "Options:\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          "-E/--enums\n\tPrint all enumerations\n"+\
+          "-e/--enum\n\tPrint specified enumeration\n"+\
+          "-M/--macros\n\tPrint all macros\n"+\
+          "-m/--macro\n\tPrint value of macro\n"+\
+          "-S/--structs\n\tPrint all structs\n"+\
+          "-s/--struct\n\tPrint struct\n"+\
+          "-n/--name-only\n\tPrint names only\n"+\
+          "-P/--print-no-comment\n\tPrint with comment removed only\n"+\
+          ""
+          
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hMm:Ee:Ss:nP",
+                               ["help","macros","macro=","enums","enum=",
+                                "structs","struct="
+                                "name-only","print-no-comment"])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+
+#Check there is at least input file
+if (len(args) < 1):
+    usage()
+    sys.exit(2)
+
+#Parse options
+##Print names only
+nameOnly = False
+##Print all structs?
+allStructs = False
+##Query specific struct
+struct=""
+##Print all enums?
+allEnums = False
+##Query specific enum
+enum=""
+##Print all macros?
+allMacros = False
+##Query specific macro
+macro=""
+##Print without comment
+printNoComment=False
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    elif (opt in ("-S","--structs")): 
+        allStructs = True
+    elif (opt in ("-s","--struct")): 
+        struct = arg
+    elif (opt in ("-M","--macros")): 
+        allMacros = True
+    elif (opt in ("-m","--macro")): 
+        macro=arg
+    elif (opt in ("-E","--enums")): 
+        allEnums = True
+    elif (opt in ("-e","--enum")): 
+        enum = arg
+    elif (opt in ("-n","--name-only")): 
+        nameOnly = True
+    elif (opt in ("-P","--print-no-comment")): 
+        printNoComment = True
+    else:
+        assert (False,"Unhandled option :"+opt)
+
+headerfile = cheader.cheaderfile(args)
+if (printNoComment):
+    for line in headerfile.content:
+        print line
+    sys.exit(0)
+    
+#Print all macros
+if (allMacros):
+    for (macroname, value) in headerfile.macros.items():
+        if (nameOnly):
+            print macroname
+        else:
+            print macroname+"\t=\t"+str(value)
+#Print specified macro
+if (macro != ""):
+    try:
+        print macro+"="+headerfile.macros[macro]
+    except KeyError:
+        print "Macro "+macro+" not found!"
+
+#Print all structs
+if (allStructs):
+    for (structname, value) in headerfile.structs.items():
+        if (nameOnly):
+            print structname
+        else:
+            print str(value)+"\n"
+
+#Print specified struct
+if (struct != ""):
+    try:
+        print str(headerfile.structs[struct])
+    except KeyError:
+        print "Struct "+struct+" not found!"
+
+#Print all enumerations
+if (allEnums):
+    for (enumname, values) in headerfile.enums.items():
+        print enumname
+        if (not nameOnly):
+            for enumval in values:
+                try:
+                    print "\t"+enumval+"="+\
+                          str(headerfile.enum_values[enumval])
+                except KeyError:
+                    print enumval+" not found in enum!";
+
+#Print specifed enum
+if (enum != ""):
+    try:
+        for enumval in headerfile.enums[enum]:
+            try:
+                print enumval+"="+str(headerfile.enum_values[enumval])
+            except KeyError:
+                print enumval+" not found in enum!";
+    except KeyError:
+        print "Enumeration "+enum+" not found!"
diff --git a/tools/pylibopenflow/bin/pyopenflow-get-struct.py b/tools/pylibopenflow/bin/pyopenflow-get-struct.py
new file mode 100755
index 0000000..78297c5
--- /dev/null
+++ b/tools/pylibopenflow/bin/pyopenflow-get-struct.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python2.5
+"""This script reads struct from OpenFlow header file and output query
+
+(C) Copyright Stanford University
+Author ykk
+Date October 2009
+"""
+import sys
+import getopt
+import openflow
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> struct_name\n"+\
+          "Options:\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          "-c/--cstruct\n\tPrint C struct\n"+\
+          "-n/--name\n\tPrint names of struct\n"+\
+          "-s/--size\n\tPrint size of struct\n"+\
+          ""
+          
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hcsn",
+                               ["help","cstruct","size","names"])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+
+#Check there is only struct name
+if not (len(args) == 1):
+    usage()
+    sys.exit(2)
+    
+#Parse options
+##Print C struct
+printc = False
+##Print names
+printname = False
+##Print size
+printsize = False
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    elif (opt in ("-s","--size")): 
+        printsize = True
+    elif (opt in ("-c","--cstruct")): 
+        printc = True
+    elif (opt in ("-n","--names")): 
+        printname = True
+    else:
+        assert (False,"Unhandled option :"+opt)
+
+pyopenflow = openflow.messages()
+cstruct = pyopenflow.structs[args[0].strip()]
+pattern = pyopenflow.get_pattern(cstruct)
+
+#Print C struct
+if (printc):
+    print cstruct
+
+#Print pattern
+print "Python pattern = "+str(pattern)
+
+#Print name
+if (printname):
+    print cstruct.get_names()
+
+#Print size
+if (printsize):
+    print "Size = "+str(pyopenflow.get_size(pattern))
+
diff --git a/tools/pylibopenflow/bin/pyopenflow-lavi-pythonize.py b/tools/pylibopenflow/bin/pyopenflow-lavi-pythonize.py
new file mode 100755
index 0000000..bb8c180
--- /dev/null
+++ b/tools/pylibopenflow/bin/pyopenflow-lavi-pythonize.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python2.5
+"""This script generate class files for messenger and lavi in NOX, 
+specifically it creates a Python class for each data structure.
+
+(C) Copyright Stanford University
+Author ykk
+Date January 2010
+"""
+import sys
+import os.path
+import getopt
+import cheader
+import lavi.pythonize
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> nox_dir\n"+\
+          "Options:\n"+\
+          "-i/--input-dir\n\tSpecify input directory (nox src directory)\n"+\
+          "-t/--template\n\tSpecify (non-default) template file\n"+\
+          "-n/--no-lavi\n\tSpecify that LAVI's file will not be created\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          ""
+          
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hm:n",
+                               ["help","messenger-template","no-lavi"])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+
+#Check there is only NOX directory given
+if not (len(args) == 1):
+    usage()
+    sys.exit(2)
+
+#Parse options
+##Output LAVI
+outputlavi=True
+##Template file
+templatefile="include/messenger.template.py"
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    elif (opt in ("-t","--template")):
+        templatefile=arg
+    elif (opt in ("-n","--no-lavi")):
+        outputlavi=False
+    else:
+        print "Unhandled option:"+opt
+        sys.exit(2)
+
+#Check for header file in NOX directory
+if not (os.path.isfile(args[0]+"/src/nox/coreapps/messenger/message.hh")):
+    print "Messenger header file not found!"
+    sys.exit(2)
+if (outputlavi):
+    if not (os.path.isfile(args[0]+"/src/nox/netapps/lavi/lavi-message.hh")):
+        print "LAVI message header file not found!"
+        sys.exit(2)
+
+#Get headerfile and pythonizer
+msgheader = cheader.cheaderfile(args[0]+"/src/nox/coreapps/messenger/message.hh")
+mpynizer = lavi.pythonize.msgpythonizer(msgheader)
+if (outputlavi):
+    laviheader = cheader.cheaderfile([args[0]+"/src/nox/coreapps/messenger/message.hh",
+                                      args[0]+"/src/nox/netapps/lavi/lavi-message.hh"])
+    lpynizer = lavi.pythonize.lavipythonizer(laviheader)
+    
+#Generate Python code for messenger
+fileRef = open(args[0]+"/src/nox/coreapps/messenger/messenger.py", "w")
+for x in mpynizer.pycode(templatefile):
+    fileRef.write(x+"\n")
+fileRef.write("\n")
+fileRef.close()
+
+if (outputlavi):
+    fileRef = open(args[0]+"/src/nox/netapps/lavi/lavi.py", "w")
+    for x in lpynizer.pycode(templatefile):
+        fileRef.write(x.replace("def __init__(self,ipAddr,portNo=2603,debug=False):",
+                                "def __init__(self,ipAddr,portNo=2503,debug=False):").\
+                      replace("def __init__(self, ipAddr, portNo=1304,debug=False):",
+                              "def __init__(self, ipAddr, portNo=1305,debug=False):")+\
+                      "\n")
+    fileRef.write("\n")
+    fileRef.close()
diff --git a/tools/pylibopenflow/bin/pyopenflow-load-controller.py b/tools/pylibopenflow/bin/pyopenflow-load-controller.py
new file mode 100755
index 0000000..aef34f7
--- /dev/null
+++ b/tools/pylibopenflow/bin/pyopenflow-load-controller.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python2.5
+"""This script fakes as n OpenFlow switch and
+load the controller with k packets per second.
+
+(C) Copyright Stanford University
+Author ykk
+Date January 2010
+"""
+import sys
+import getopt
+import struct
+import openflow
+import time
+import output
+import of.msg
+import of.simu
+import of.network
+import dpkt.ethernet
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> controller\n"+\
+          "Options:\n"+\
+          "-p/--port\n\tSpecify port number\n"+\
+          "-v/--verbose\n\tPrint message exchange\n"+\
+          "-r/--rate\n\tSpecify rate per switch to send packets (default=1)\n"+\
+          "-d/--duration\n\tSpecify duration of load test in seconds (default=5)\n"+\
+          "-s/--switch\n\tSpecify number of switches (default=1)\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          ""
+          
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hvp:s:d:r:",
+                               ["help","verbose","port=",
+                                "switch=","duration=","rate="])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+
+#Check there is only controller
+if not (len(args) == 1):
+    usage()
+    sys.exit(2)
+    
+#Parse options
+##Duration
+duration = 5
+##Rate
+rate = 1.0
+##Switch number
+swno = 1
+##Port to connect to
+port = 6633
+##Set output mode
+output.set_mode("INFO")
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    elif (opt in ("-v","--verbose")):
+        output.set_mode("DBG")
+    elif (opt in ("-p","--port")):
+        port=int(arg)
+    elif (opt in ("-s","--switch")):
+        swno=int(arg)
+    elif (opt in ("-d","--duration")):
+        duration=int(arg)
+    elif (opt in ("-r","--rate")):
+        rate=float(arg)
+    else:
+        print "Unhandled option :"+opt
+        sys.exit(2)
+
+#Form packet
+pkt = dpkt.ethernet.Ethernet()
+pkt.type = dpkt.ethernet.ETH_MIN
+pkt.dst = '\xFF\xFF\xFF\xFF\xFF\xFF'
+
+#Connect to controller
+ofmsg = openflow.messages()
+parser = of.msg.parser(ofmsg)
+ofnet = of.simu.network()
+for i in range(1,swno+1):
+    ofsw = of.simu.switch(ofmsg, args[0], port,
+                          dpid=i,
+                          parser=parser)
+    ofnet.add_switch(ofsw)
+    ofsw.send_hello()
+    
+output.info("Running "+str(swno)+" switches at "+str(rate)+\
+            " packets per seconds for "+str(duration)+" s")
+
+starttime = time.time()
+running = True
+interval = 1.0/(rate*swno)
+ntime=time.time()+(interval/10.0)
+swindex = 0
+pcount = 0
+rcount = 0
+while running:
+    ctime = time.time()
+    time.sleep(max(0,min(ntime-ctime,interval/10.0)))
+
+    if ((ctime-starttime) <= duration):
+        #Send packet if time's up
+        if (ctime >= ntime):
+            ntime += interval
+            pkt.src = struct.pack("Q",pcount)[:6]
+            ofnet.switches[swindex].send_packet(1,10,pkt.pack()+'A'*3)
+            pcount += 1
+            swno += 1
+            if (swno >= len(ofnet.switches)):
+                swno=0
+
+        #Process any received message
+        (ofsw, msg) = ofnet.connections.msgreceive()
+        while (msg != None):
+            dic = ofmsg.peek_from_front("ofp_header", msg)
+            if (dic["type"][0] == ofmsg.get_value("OFPT_FLOW_MOD")):
+                output.dbg("Received flow mod")
+                rcount += 1
+            ofsw.receive_openflow(msg)
+            (ofsw, msg) = ofnet.connections.msgreceive()
+    else:
+        running = False
+    
+output.info("Sent "+str(pcount)+" packets at rate "+\
+            str(float(pcount)/float(duration))+" and received "+\
+            str(rcount)+" back")
diff --git a/tools/pylibopenflow/bin/pyopenflow-ping-controller.py b/tools/pylibopenflow/bin/pyopenflow-ping-controller.py
new file mode 100755
index 0000000..e5aa030
--- /dev/null
+++ b/tools/pylibopenflow/bin/pyopenflow-ping-controller.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python2.5
+"""This script fakes as an OpenFlow switch to the controller
+
+(C) Copyright Stanford University
+Author ykk
+Date October 2009
+"""
+import sys
+import getopt
+import openflow
+import time
+import output
+import of.msg
+import of.simu
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> controller\n"+\
+          "Options:\n"+\
+          "-p/--port\n\tSpecify port number\n"+\
+          "-v/--verbose\n\tPrint message exchange\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          ""
+          
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hvp:",
+                               ["help","verbose","port="])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+
+#Check there is only controller
+if not (len(args) == 1):
+    usage()
+    sys.exit(2)
+    
+#Parse options
+##Port to connect to
+port = 6633
+##Set output mode
+output.set_mode("INFO")
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    elif (opt in ("-v","--verbose")):
+        output.set_mode("DBG")
+    elif (opt in ("-p","--port")):
+        port=int(arg)
+    else:
+        assert (False,"Unhandled option :"+opt)
+
+#Connect to controller
+ofmsg = openflow.messages()
+parser = of.msg.parser(ofmsg)
+ofsw = of.simu.switch(ofmsg, args[0], port,
+                      dpid=int("0xcafecafe",16),
+                      parser=parser)
+ofsw.send_hello()
+#Send echo and wait
+xid = 22092009
+running = True
+ofsw.send_echo(xid)
+starttime = time.time()
+while running:
+    msg = ofsw.connection.msgreceive(True, 0.00001)
+    pkttime = time.time()
+    dic = ofmsg.peek_from_front("ofp_header", msg)
+    if (dic["type"][0] == ofmsg.get_value("OFPT_ECHO_REPLY") and
+        dic["xid"][0] == xid):
+        #Check reply for echo request
+        output.info("Received echo reply after "+\
+                    str((pkttime-starttime)*1000)+" ms", "ping-controller")
+        running = False
+    else:
+        ofsw.receive_openflow(msg)
diff --git a/tools/pylibopenflow/bin/pyopenflow-pythonize.py b/tools/pylibopenflow/bin/pyopenflow-pythonize.py
new file mode 100755
index 0000000..466c35d
--- /dev/null
+++ b/tools/pylibopenflow/bin/pyopenflow-pythonize.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python2.5
+"""This script generate openflow-packets.py which
+creates Python class for each data structure in openflow.h.
+
+(C) Copyright Stanford University
+Author ykk
+Date December 2009
+"""
+import sys
+sys.path.append('./bin')
+sys.path.append('./pylib')
+import getopt
+import openflow
+import time
+import output
+import of.pythonize
+
+def usage():
+    """Display usage
+    """
+    print "Usage "+sys.argv[0]+" <options> output_file\n"+\
+          "Options:\n"+\
+          "-i/--input\n\tSpecify (non-default) OpenFlow header\n"+\
+          "-t/--template\n\tSpecify (non-default) template file\n"+\
+          "-h/--help\n\tPrint this usage guide\n"+\
+          ""
+          
+#Parse options and arguments
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hi:t:",
+                               ["help","input","template"])
+except getopt.GetoptError:
+    usage()
+    sys.exit(2)
+
+#Check there is only output file
+if not (len(args) == 1):
+    usage()
+    sys.exit(2)
+
+#Parse options
+##Input
+headerfile=None
+##Template file
+templatefile=None
+for opt,arg in opts:
+    if (opt in ("-h","--help")):
+        usage()
+        sys.exit(0)
+    elif (opt in ("-i","--input")):
+        headerfile=arg
+    elif (opt in ("-t","--template")):
+        templatefile=arg
+    else:
+        print "Unhandled option:"+opt
+        sys.exit(2)
+
+#Generate Python code
+ofmsg = openflow.messages(headerfile)
+pynizer = of.pythonize.pythonizer(ofmsg)
+
+fileRef = open(args[0], "w")
+for x in pynizer.pycode(templatefile):
+    fileRef.write(x+"\n")
+fileRef.write("\n")
+fileRef.close()
diff --git a/tools/pylibopenflow/include/Put C header files here... b/tools/pylibopenflow/include/Put C header files here...
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/pylibopenflow/include/Put C header files here...
diff --git a/tools/pylibopenflow/include/messenger.template.py b/tools/pylibopenflow/include/messenger.template.py
new file mode 100644
index 0000000..25e7c76
--- /dev/null
+++ b/tools/pylibopenflow/include/messenger.template.py
@@ -0,0 +1,115 @@
+import socket
+import select
+
+## This module provides library to send and receive messages to NOX's messenger
+#
+# This is a rewrite of noxmsg.py from OpenRoads (OpenFlow Wireless)
+#
+# @author ykk (Stanford University)
+# @date January, 2010
+# @see messenger
+
+def stringarray(string):
+    """Output array of binary values in string.
+    """
+    arrstr = ""
+    if (len(string) != 0):
+        for i in range(0,len(string)):
+            arrstr += "%x " % struct.unpack("=B",string[i])[0]
+    return arrstr
+
+def printarray(string):
+    """Print array of binary values
+    """
+    print "Array of length "+str(len(string))
+    print stringarray(string)
+
+class channel:
+    """TCP channel to communicate to NOX with.
+    """
+    def __init__(self,ipAddr,portNo=2603,debug=False):
+        """Initialize with socket
+        """
+        ##Socket reference for channel
+        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.sock.connect((ipAddr,portNo))
+        self.debug = debug
+        ##Internal buffer for receiving
+        self.__buffer = ""
+        ##Internal reference to header
+        self.__header = messenger_msg()
+
+    def baresend(self, msg):
+        """Send bare message"""
+        self.sock.send(msg)
+
+    def send(self,msg):
+        """Send message
+        """
+        msgh = messenger_msg()
+        remaining = msgh.unpack(msg)
+        if (msgh.length != len(msg)):
+            msgh.length = len(msg)
+            msg = msgh.pack()+remaining
+        self.baresend(msg)
+        if (self.debug):
+            printarray(msg)
+        
+    def receive(self, recvLen=0,timeout=0):
+        """Receive command
+        If length == None, nonblocking receive (return None or message)
+        With nonblocking receive, timeout is used for select statement
+
+        If length is zero, return single message
+        """            
+        if (recvLen==0):
+            #Receive full message
+            msg=""
+            length=len(self.__header)
+            while (len(msg) < length):
+                msg+=self.sock.recv(1)
+                #Get length
+                if (len(msg) == length):
+                    self.__header.unpack(msg)
+                    length=self.__header.length
+            return msg
+        elif (recvLen==None):
+            #Non-blocking receive
+            ready_to_read = select.select([self.sock],[],[],timeout)[0]
+            if (ready_to_read):
+                self.__buffer += self.sock.recv(1)
+            if (len(self.__buffer) >= len(self.__header)):
+                self.__header.unpack(self.__buffer)
+                if (self.__header.length == len(self.__buffer)):
+                    msg = self.__buffer
+                    self.__buffer = ""
+                    return msg
+            return None
+        else:
+            #Fixed length blocking receive
+            return self.sock.recv(recvLen)
+
+    def __del__(self):
+        """Terminate connection
+        """
+        emsg = messenger_msg()
+        emsg.type = MSG_DISCONNECT
+        emsg.length = len(emsg)
+        self.send(emsg.pack())
+        self.sock.shutdown(1)
+        self.sock.close()
+
+class sslChannel(channel):
+    """SSL channel to communicate to NOX with.
+    """
+    def __init__(self, ipAddr, portNo=1304,debug=False):
+        """Initialize with SSL sock
+        """
+        NOXChannel.__init__(self, ipAddr, portNo,debug)
+        ##Reference to SSL socket for channel
+        self.sslsock = socket.ssl(self.sock)
+
+    def baresend(self, msg):
+        """Send bare message"""
+        self.sslsock.write(msg)
+
diff --git a/tools/pylibopenflow/include/openflow.h b/tools/pylibopenflow/include/openflow.h
new file mode 100644
index 0000000..9e662aa
--- /dev/null
+++ b/tools/pylibopenflow/include/openflow.h
@@ -0,0 +1,970 @@
+/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
+ * Junior University
+ *
+ * We are making the OpenFlow specification and associated documentation
+ * (Software) available for public use and benefit with the expectation
+ * that others will use, modify and enhance the Software and contribute
+ * those enhancements back to the community. However, since we would
+ * like to make the Software available for broadest use, with as few
+ * restrictions as possible permission is hereby granted, free of
+ * charge, to any person obtaining a copy of this Software to deal in
+ * the Software under the copyrights without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The name and trademarks of copyright holder(s) may NOT be used in
+ * advertising or publicity pertaining to the Software or any
+ * derivatives without specific, written prior permission.
+ */
+
+/* OpenFlow: protocol between controller and datapath. */
+
+#ifndef OPENFLOW_OPENFLOW_H
+#define OPENFLOW_OPENFLOW_H 1
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#else
+#include <stdint.h>
+#endif
+
+#ifdef SWIG
+#define OFP_ASSERT(EXPR)        /* SWIG can't handle OFP_ASSERT. */
+#elif !defined(__cplusplus)
+/* Build-time assertion for use in a declaration context. */
+#define OFP_ASSERT(EXPR)                                                \
+        extern int (*build_assert(void))[ sizeof(struct {               \
+                    unsigned int build_assert_failed : (EXPR) ? 1 : -1; })]
+#else /* __cplusplus */
+#define OFP_ASSERT(_EXPR) typedef int build_assert_failed[(_EXPR) ? 1 : -1]
+#endif /* __cplusplus */
+
+#ifndef SWIG
+#define OFP_PACKED __attribute__((packed))
+#else
+#define OFP_PACKED              /* SWIG doesn't understand __attribute. */
+#endif
+
+/* Version number:
+ * Non-experimental versions released: 0x01
+ * Experimental versions released: 0x81 -- 0x99
+ */
+/* The most significant bit being set in the version field indicates an
+ * experimental OpenFlow version.
+ */
+#define OFP_VERSION   0x99
+
+#define OFP_MAX_TABLE_NAME_LEN 32
+#define OFP_MAX_PORT_NAME_LEN  16
+
+#define OFP_TCP_PORT  6633
+#define OFP_SSL_PORT  6633
+
+#define OFP_ETH_ALEN 6          /* Bytes in an Ethernet address. */
+
+/* Port numbering.  Physical ports are numbered starting from 1. */
+enum ofp_port {
+    /* Maximum number of physical switch ports. */
+    OFPP_MAX = 0xff00,
+
+    /* Fake output "ports". */
+    OFPP_IN_PORT    = 0xfff8,  /* Send the packet out the input port.  This
+                                  virtual port must be explicitly used
+                                  in order to send back out of the input
+                                  port. */
+    OFPP_TABLE      = 0xfff9,  /* Perform actions in flow table.
+                                  NB: This can only be the destination
+                                  port for packet-out messages. */
+    OFPP_NORMAL     = 0xfffa,  /* Process with normal L2/L3 switching. */
+    OFPP_FLOOD      = 0xfffb,  /* All physical ports except input port and
+                                  those disabled by STP. */
+    OFPP_ALL        = 0xfffc,  /* All physical ports except input port. */
+    OFPP_CONTROLLER = 0xfffd,  /* Send to controller. */
+    OFPP_LOCAL      = 0xfffe,  /* Local openflow "port". */
+    OFPP_NONE       = 0xffff   /* Not associated with a physical port. */
+};
+
+enum ofp_type {
+    /* Immutable messages. */
+    OFPT_HELLO,               /* Symmetric message */
+    OFPT_ERROR,               /* Symmetric message */
+    OFPT_ECHO_REQUEST,        /* Symmetric message */
+    OFPT_ECHO_REPLY,          /* Symmetric message */
+    OFPT_VENDOR,              /* Symmetric message */
+
+    /* Switch configuration messages. */
+    OFPT_FEATURES_REQUEST,    /* Controller/switch message */
+    OFPT_FEATURES_REPLY,      /* Controller/switch message */
+    OFPT_GET_CONFIG_REQUEST,  /* Controller/switch message */
+    OFPT_GET_CONFIG_REPLY,    /* Controller/switch message */
+    OFPT_SET_CONFIG,          /* Controller/switch message */
+
+    /* Asynchronous messages. */
+    OFPT_PACKET_IN,           /* Async message */
+    OFPT_FLOW_REMOVED,        /* Async message */
+    OFPT_PORT_STATUS,         /* Async message */
+
+    /* Controller command messages. */
+    OFPT_PACKET_OUT,          /* Controller/switch message */
+    OFPT_FLOW_MOD,            /* Controller/switch message */
+    OFPT_PORT_MOD,            /* Controller/switch message */
+
+    /* Statistics messages. */
+    OFPT_STATS_REQUEST,       /* Controller/switch message */
+    OFPT_STATS_REPLY,         /* Controller/switch message */
+
+    /* Barrier messages. */
+    OFPT_BARRIER_REQUEST,     /* Controller/switch message */
+    OFPT_BARRIER_REPLY,       /* Controller/switch message */
+
+    /* Queue Configuration messages. */
+    OFPT_QUEUE_GET_CONFIG_REQUEST,  /* Controller/switch message */
+    OFPT_QUEUE_GET_CONFIG_REPLY     /* Controller/switch message */
+
+};
+
+/* Header on all OpenFlow packets. */
+struct ofp_header {
+    uint8_t version;    /* OFP_VERSION. */
+    uint8_t type;       /* One of the OFPT_ constants. */
+    uint16_t length;    /* Length including this ofp_header. */
+    uint32_t xid;       /* Transaction id associated with this packet.
+                           Replies use the same id as was in the request
+                           to facilitate pairing. */
+};
+OFP_ASSERT(sizeof(struct ofp_header) == 8);
+
+/* OFPT_HELLO.  This message has an empty body, but implementations must
+ * ignore any data included in the body, to allow for future extensions. */
+struct ofp_hello {
+    struct ofp_header header;
+};
+
+#define OFP_DEFAULT_MISS_SEND_LEN   128
+
+enum ofp_config_flags {
+    /* Handling of IP fragments. */
+    OFPC_FRAG_NORMAL   = 0,  /* No special handling for fragments. */
+    OFPC_FRAG_DROP     = 1,  /* Drop fragments. */
+    OFPC_FRAG_REASM    = 2,  /* Reassemble (only if OFPC_IP_REASM set). */
+    OFPC_FRAG_MASK     = 3
+};
+
+/* Switch configuration. */
+struct ofp_switch_config {
+    struct ofp_header header;
+    uint16_t flags;             /* OFPC_* flags. */
+    uint16_t miss_send_len;     /* Max bytes of new flow that datapath should
+                                   send to the controller. */
+};
+OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
+
+/* Capabilities supported by the datapath. */
+enum ofp_capabilities {
+    OFPC_FLOW_STATS     = 1 << 0,  /* Flow statistics. */
+    OFPC_TABLE_STATS    = 1 << 1,  /* Table statistics. */
+    OFPC_PORT_STATS     = 1 << 2,  /* Port statistics. */
+    OFPC_STP            = 1 << 3,  /* 802.1d spanning tree. */
+    OFPC_RESERVED       = 1 << 4,  /* Reserved, must be zero. */
+    OFPC_IP_REASM       = 1 << 5,  /* Can reassemble IP fragments. */
+    OFPC_QUEUE_STATS    = 1 << 6,  /* Queue statistics. */
+    OFPC_ARP_MATCH_IP   = 1 << 7   /* Match IP addresses in ARP pkts. */
+};
+
+/* Flags to indicate behavior of the physical port.  These flags are
+ * used in ofp_phy_port to describe the current configuration.  They are
+ * used in the ofp_port_mod message to configure the port's behavior.
+ */
+enum ofp_port_config {
+    OFPPC_PORT_DOWN    = 1 << 0,  /* Port is administratively down. */
+
+    OFPPC_NO_STP       = 1 << 1,  /* Disable 802.1D spanning tree on port. */
+    OFPPC_NO_RECV      = 1 << 2,  /* Drop all packets except 802.1D spanning
+                                     tree packets. */
+    OFPPC_NO_RECV_STP  = 1 << 3,  /* Drop received 802.1D STP packets. */
+    OFPPC_NO_FLOOD     = 1 << 4,  /* Do not include this port when flooding. */
+    OFPPC_NO_FWD       = 1 << 5,  /* Drop packets forwarded to port. */
+    OFPPC_NO_PACKET_IN = 1 << 6   /* Do not send packet-in msgs for port. */
+};
+
+/* Current state of the physical port.  These are not configurable from
+ * the controller.
+ */
+enum ofp_port_state {
+    OFPPS_LINK_DOWN   = 1 << 0, /* No physical link present. */
+
+    /* The OFPPS_STP_* bits have no effect on switch operation.  The
+     * controller must adjust OFPPC_NO_RECV, OFPPC_NO_FWD, and
+     * OFPPC_NO_PACKET_IN appropriately to fully implement an 802.1D spanning
+     * tree. */
+    OFPPS_STP_LISTEN  = 0 << 8, /* Not learning or relaying frames. */
+    OFPPS_STP_LEARN   = 1 << 8, /* Learning but not relaying frames. */
+    OFPPS_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
+    OFPPS_STP_BLOCK   = 3 << 8, /* Not part of spanning tree. */
+    OFPPS_STP_MASK    = 3 << 8  /* Bit mask for OFPPS_STP_* values. */
+};
+
+/* Features of physical ports available in a datapath. */
+enum ofp_port_features {
+    OFPPF_10MB_HD    = 1 << 0,  /* 10 Mb half-duplex rate support. */
+    OFPPF_10MB_FD    = 1 << 1,  /* 10 Mb full-duplex rate support. */
+    OFPPF_100MB_HD   = 1 << 2,  /* 100 Mb half-duplex rate support. */
+    OFPPF_100MB_FD   = 1 << 3,  /* 100 Mb full-duplex rate support. */
+    OFPPF_1GB_HD     = 1 << 4,  /* 1 Gb half-duplex rate support. */
+    OFPPF_1GB_FD     = 1 << 5,  /* 1 Gb full-duplex rate support. */
+    OFPPF_10GB_FD    = 1 << 6,  /* 10 Gb full-duplex rate support. */
+    OFPPF_COPPER     = 1 << 7,  /* Copper medium. */
+    OFPPF_FIBER      = 1 << 8,  /* Fiber medium. */
+    OFPPF_AUTONEG    = 1 << 9,  /* Auto-negotiation. */
+    OFPPF_PAUSE      = 1 << 10, /* Pause. */
+    OFPPF_PAUSE_ASYM = 1 << 11  /* Asymmetric pause. */
+};
+
+/* Description of a physical port */
+struct ofp_phy_port {
+    uint16_t port_no;
+    uint8_t hw_addr[OFP_ETH_ALEN];
+    char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
+
+    uint32_t config;        /* Bitmap of OFPPC_* flags. */
+    uint32_t state;         /* Bitmap of OFPPS_* flags. */
+
+    /* Bitmaps of OFPPF_* that describe features.  All bits zeroed if
+     * unsupported or unavailable. */
+    uint32_t curr;          /* Current features. */
+    uint32_t advertised;    /* Features being advertised by the port. */
+    uint32_t supported;     /* Features supported by the port. */
+    uint32_t peer;          /* Features advertised by peer. */
+};
+OFP_ASSERT(sizeof(struct ofp_phy_port) == 48);
+
+/* Switch features. */
+struct ofp_switch_features {
+    struct ofp_header header;
+    uint64_t datapath_id;   /* Datapath unique ID.  The lower 48-bits are for
+                               a MAC address, while the upper 16-bits are
+                               implementer-defined. */
+
+    uint32_t n_buffers;     /* Max packets buffered at once. */
+
+    uint8_t n_tables;       /* Number of tables supported by datapath. */
+    uint8_t pad[3];         /* Align to 64-bits. */
+
+    /* Features. */
+    uint32_t capabilities;  /* Bitmap of support "ofp_capabilities". */
+    uint32_t actions;       /* Bitmap of supported "ofp_action_type"s. */
+
+    /* Port info.*/
+    struct ofp_phy_port ports[0];  /* Port definitions.  The number of ports
+                                      is inferred from the length field in
+                                      the header. */
+};
+OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
+
+/* What changed about the physical port */
+enum ofp_port_reason {
+    OFPPR_ADD,              /* The port was added. */
+    OFPPR_DELETE,           /* The port was removed. */
+    OFPPR_MODIFY            /* Some attribute of the port has changed. */
+};
+
+/* A physical port has changed in the datapath */
+struct ofp_port_status {
+    struct ofp_header header;
+    uint8_t reason;          /* One of OFPPR_*. */
+    uint8_t pad[7];          /* Align to 64-bits. */
+    struct ofp_phy_port desc;
+};
+OFP_ASSERT(sizeof(struct ofp_port_status) == 64);
+
+/* Modify behavior of the physical port */
+struct ofp_port_mod {
+    struct ofp_header header;
+    uint16_t port_no;
+    uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
+                                      configurable.  This is used to
+                                      sanity-check the request, so it must
+                                      be the same as returned in an
+                                      ofp_phy_port struct. */
+
+    uint32_t config;        /* Bitmap of OFPPC_* flags. */
+    uint32_t mask;          /* Bitmap of OFPPC_* flags to be changed. */
+
+    uint32_t advertise;     /* Bitmap of "ofp_port_features"s.  Zero all
+                               bits to prevent any action taking place. */
+    uint8_t pad[4];         /* Pad to 64-bits. */
+};
+OFP_ASSERT(sizeof(struct ofp_port_mod) == 32);
+
+/* Why is this packet being sent to the controller? */
+enum ofp_packet_in_reason {
+    OFPR_NO_MATCH,          /* No matching flow. */
+    OFPR_ACTION             /* Action explicitly output to controller. */
+};
+
+/* Packet received on port (datapath -> controller). */
+struct ofp_packet_in {
+    struct ofp_header header;
+    uint32_t buffer_id;     /* ID assigned by datapath. */
+    uint16_t total_len;     /* Full length of frame. */
+    uint16_t in_port;       /* Port on which frame was received. */
+    uint8_t reason;         /* Reason packet is being sent (one of OFPR_*) */
+    uint8_t pad;
+    uint8_t data[0];        /* Ethernet frame, halfway through 32-bit word,
+                               so the IP header is 32-bit aligned.  The
+                               amount of data is inferred from the length
+                               field in the header.  Because of padding,
+                               offsetof(struct ofp_packet_in, data) ==
+                               sizeof(struct ofp_packet_in) - 2. */
+};
+OFP_ASSERT(sizeof(struct ofp_packet_in) == 20);
+
+enum ofp_action_type {
+    OFPAT_OUTPUT,           /* Output to switch port. */
+    OFPAT_SET_VLAN_VID,     /* Set the 802.1q VLAN id. */
+    OFPAT_SET_VLAN_PCP,     /* Set the 802.1q priority. */
+    OFPAT_STRIP_VLAN,       /* Strip the 802.1q header. */
+    OFPAT_SET_DL_SRC,       /* Ethernet source address. */
+    OFPAT_SET_DL_DST,       /* Ethernet destination address. */
+    OFPAT_SET_NW_SRC,       /* IP source address. */
+    OFPAT_SET_NW_DST,       /* IP destination address. */
+    OFPAT_SET_NW_TOS,       /* IP ToS (DSCP field, 6 bits). */
+    OFPAT_SET_TP_SRC,       /* TCP/UDP source port. */
+    OFPAT_SET_TP_DST,       /* TCP/UDP destination port. */
+    OFPAT_ENQUEUE,          /* Output to queue.  */
+    OFPAT_VENDOR = 0xffff
+};
+
+/* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
+ * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
+ * number of bytes to send.  A 'max_len' of zero means no bytes of the
+ * packet should be sent.*/
+struct ofp_action_output {
+    uint16_t type;                  /* OFPAT_OUTPUT. */
+    uint16_t len;                   /* Length is 8. */
+    uint16_t port;                  /* Output port. */
+    uint16_t max_len;               /* Max length to send to controller. */
+};
+OFP_ASSERT(sizeof(struct ofp_action_output) == 8);
+
+/* The VLAN id is 12 bits, so we can use the entire 16 bits to indicate
+ * special conditions.  All ones is used to match that no VLAN id was
+ * set. */
+#define OFP_VLAN_NONE      0xffff
+
+/* Action structure for OFPAT_SET_VLAN_VID. */
+struct ofp_action_vlan_vid {
+    uint16_t type;                  /* OFPAT_SET_VLAN_VID. */
+    uint16_t len;                   /* Length is 8. */
+    uint16_t vlan_vid;              /* VLAN id. */
+    uint8_t pad[2];
+};
+OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8);
+
+/* Action structure for OFPAT_SET_VLAN_PCP. */
+struct ofp_action_vlan_pcp {
+    uint16_t type;                  /* OFPAT_SET_VLAN_PCP. */
+    uint16_t len;                   /* Length is 8. */
+    uint8_t vlan_pcp;               /* VLAN priority. */
+    uint8_t pad[3];
+};
+OFP_ASSERT(sizeof(struct ofp_action_vlan_pcp) == 8);
+
+/* Action structure for OFPAT_SET_DL_SRC/DST. */
+struct ofp_action_dl_addr {
+    uint16_t type;                  /* OFPAT_SET_DL_SRC/DST. */
+    uint16_t len;                   /* Length is 16. */
+    uint8_t dl_addr[OFP_ETH_ALEN];  /* Ethernet address. */
+    uint8_t pad[6];
+};
+OFP_ASSERT(sizeof(struct ofp_action_dl_addr) == 16);
+
+/* Action structure for OFPAT_SET_NW_SRC/DST. */
+struct ofp_action_nw_addr {
+    uint16_t type;                  /* OFPAT_SET_TW_SRC/DST. */
+    uint16_t len;                   /* Length is 8. */
+    uint32_t nw_addr;               /* IP address. */
+};
+OFP_ASSERT(sizeof(struct ofp_action_nw_addr) == 8);
+
+/* Action structure for OFPAT_SET_TP_SRC/DST. */
+struct ofp_action_tp_port {
+    uint16_t type;                  /* OFPAT_SET_TP_SRC/DST. */
+    uint16_t len;                   /* Length is 8. */
+    uint16_t tp_port;               /* TCP/UDP port. */
+    uint8_t pad[2];
+};
+OFP_ASSERT(sizeof(struct ofp_action_tp_port) == 8);
+
+/* Action structure for OFPAT_SET_NW_TOS. */
+struct ofp_action_nw_tos {
+    uint16_t type;                  /* OFPAT_SET_TW_SRC/DST. */
+    uint16_t len;                   /* Length is 8. */
+    uint8_t nw_tos;                 /* IP ToS (DSCP field, 6 bits). */
+    uint8_t pad[3];
+};
+OFP_ASSERT(sizeof(struct ofp_action_nw_tos) == 8);
+
+/* Action header for OFPAT_VENDOR. The rest of the body is vendor-defined. */
+struct ofp_action_vendor_header {
+    uint16_t type;                  /* OFPAT_VENDOR. */
+    uint16_t len;                   /* Length is a multiple of 8. */
+    uint32_t vendor;                /* Vendor ID, which takes the same form
+                                       as in "struct ofp_vendor_header". */
+};
+OFP_ASSERT(sizeof(struct ofp_action_vendor_header) == 8);
+
+/* Action header that is common to all actions.  The length includes the
+ * header and any padding used to make the action 64-bit aligned.
+ * NB: The length of an action *must* always be a multiple of eight. */
+struct ofp_action_header {
+    uint16_t type;                  /* One of OFPAT_*. */
+    uint16_t len;                   /* Length of action, including this
+                                       header.  This is the length of action,
+                                       including any padding to make it
+                                       64-bit aligned. */
+    uint8_t pad[4];
+};
+OFP_ASSERT(sizeof(struct ofp_action_header) == 8);
+
+/* Send packet (controller -> datapath). */
+struct ofp_packet_out {
+    struct ofp_header header;
+    uint32_t buffer_id;           /* ID assigned by datapath (-1 if none). */
+    uint16_t in_port;             /* Packet's input port (OFPP_NONE if none). */
+    uint16_t actions_len;         /* Size of action array in bytes. */
+    struct ofp_action_header actions[0]; /* Actions. */
+    /* uint8_t data[0]; */        /* Packet data.  The length is inferred
+                                     from the length field in the header.
+                                     (Only meaningful if buffer_id == -1.) */
+};
+OFP_ASSERT(sizeof(struct ofp_packet_out) == 16);
+
+enum ofp_flow_mod_command {
+    OFPFC_ADD,              /* New flow. */
+    OFPFC_MODIFY,           /* Modify all matching flows. */
+    OFPFC_MODIFY_STRICT,    /* Modify entry strictly matching wildcards */
+    OFPFC_DELETE,           /* Delete all matching flows. */
+    OFPFC_DELETE_STRICT    /* Strictly match wildcards and priority. */
+};
+
+/* Flow wildcards. */
+enum ofp_flow_wildcards {
+    OFPFW_IN_PORT  = 1 << 0,  /* Switch input port. */
+    OFPFW_DL_VLAN  = 1 << 1,  /* VLAN id. */
+    OFPFW_DL_SRC   = 1 << 2,  /* Ethernet source address. */
+    OFPFW_DL_DST   = 1 << 3,  /* Ethernet destination address. */
+    OFPFW_DL_TYPE  = 1 << 4,  /* Ethernet frame type. */
+    OFPFW_NW_PROTO = 1 << 5,  /* IP protocol. */
+    OFPFW_TP_SRC   = 1 << 6,  /* TCP/UDP source port. */
+    OFPFW_TP_DST   = 1 << 7,  /* TCP/UDP destination port. */
+
+    /* IP source address wildcard bit count.  0 is exact match, 1 ignores the
+     * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
+     * the entire field.  This is the *opposite* of the usual convention where
+     * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded. */
+    OFPFW_NW_SRC_SHIFT = 8,
+    OFPFW_NW_SRC_BITS = 6,
+    OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT,
+    OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT,
+
+    /* IP destination address wildcard bit count.  Same format as source. */
+    OFPFW_NW_DST_SHIFT = 14,
+    OFPFW_NW_DST_BITS = 6,
+    OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT,
+    OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT,
+
+    OFPFW_DL_VLAN_PCP = 1 << 20,  /* VLAN priority. */
+    OFPFW_NW_TOS = 1 << 21,  /* IP ToS (DSCP field, 6 bits). */
+
+    /* Wildcard all fields. */
+    OFPFW_ALL = ((1 << 22) - 1)
+};
+
+/* The wildcards for ICMP type and code fields use the transport source
+ * and destination port fields, respectively. */
+#define OFPFW_ICMP_TYPE OFPFW_TP_SRC
+#define OFPFW_ICMP_CODE OFPFW_TP_DST
+
+/* Values below this cutoff are 802.3 packets and the two bytes
+ * following MAC addresses are used as a frame length.  Otherwise, the
+ * two bytes are used as the Ethernet type.
+ */
+#define OFP_DL_TYPE_ETH2_CUTOFF   0x0600
+
+/* Value of dl_type to indicate that the frame does not include an
+ * Ethernet type.
+ */
+#define OFP_DL_TYPE_NOT_ETH_TYPE  0x05ff
+
+/* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
+ * special conditions.  All ones indicates that no VLAN id was set.
+ */
+#define OFP_VLAN_NONE      0xffff
+
+/* Fields to match against flows */
+struct ofp_match {
+    uint32_t wildcards;        /* Wildcard fields. */
+    uint16_t in_port;          /* Input switch port. */
+    uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
+    uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
+    uint16_t dl_vlan;          /* Input VLAN id. */
+    uint8_t dl_vlan_pcp;       /* Input VLAN priority. */
+    uint8_t pad1[1];           /* Align to 64-bits */
+    uint16_t dl_type;          /* Ethernet frame type. */
+    uint8_t nw_tos;            /* IP ToS (actually DSCP field, 6 bits). */
+    uint8_t nw_proto;          /* IP protocol or lower 8 bits of
+                                * ARP opcode. */
+    uint8_t pad2[2];           /* Align to 64-bits */
+    uint32_t nw_src;           /* IP source address. */
+    uint32_t nw_dst;           /* IP destination address. */
+    uint16_t tp_src;           /* TCP/UDP source port. */
+    uint16_t tp_dst;           /* TCP/UDP destination port. */
+};
+OFP_ASSERT(sizeof(struct ofp_match) == 40);
+
+/* The match fields for ICMP type and code use the transport source and
+ * destination port fields, respectively. */
+#define icmp_type tp_src
+#define icmp_code tp_dst
+
+/* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
+ * is permanent. */
+#define OFP_FLOW_PERMANENT 0
+
+/* By default, choose a priority in the middle. */
+#define OFP_DEFAULT_PRIORITY 0x8000
+
+enum ofp_flow_mod_flags {
+    OFPFF_SEND_FLOW_REM = 1 << 0,  /* Send flow removed message when flow
+                                    * expires or is deleted. */
+    OFPFF_CHECK_OVERLAP = 1 << 1,  /* Check for overlapping entries first. */
+    OFPFF_EMERG         = 1 << 2   /* Remark this is for emergency. */
+};
+
+/* Flow setup and teardown (controller -> datapath). */
+struct ofp_flow_mod {
+    struct ofp_header header;
+    struct ofp_match match;      /* Fields to match */
+    uint64_t cookie;             /* Opaque controller-issued identifier. */
+
+    /* Flow actions. */
+    uint16_t command;             /* One of OFPFC_*. */
+    uint16_t idle_timeout;        /* Idle time before discarding (seconds). */
+    uint16_t hard_timeout;        /* Max time before discarding (seconds). */
+    uint16_t priority;            /* Priority level of flow entry. */
+    uint32_t buffer_id;           /* Buffered packet to apply to (or -1).
+                                     Not meaningful for OFPFC_DELETE*. */
+    uint16_t out_port;            /* For OFPFC_DELETE* commands, require
+                                     matching entries to include this as an
+                                     output port.  A value of OFPP_NONE
+                                     indicates no restriction. */
+    uint16_t flags;               /* One of OFPFF_*. */
+    struct ofp_action_header actions[0]; /* The action length is inferred
+                                            from the length field in the
+                                            header. */
+};
+OFP_ASSERT(sizeof(struct ofp_flow_mod) == 72);
+
+/* Why was this flow removed? */
+enum ofp_flow_removed_reason {
+    OFPRR_IDLE_TIMEOUT,         /* Flow idle time exceeded idle_timeout. */
+    OFPRR_HARD_TIMEOUT,         /* Time exceeded hard_timeout. */
+    OFPRR_DELETE                /* Evicted by a DELETE flow mod. */
+};
+
+/* Flow removed (datapath -> controller). */
+struct ofp_flow_removed {
+    struct ofp_header header;
+    struct ofp_match match;   /* Description of fields. */
+    uint64_t cookie;          /* Opaque controller-issued identifier. */
+
+    uint16_t priority;        /* Priority level of flow entry. */
+    uint8_t reason;           /* One of OFPRR_*. */
+    uint8_t pad[1];           /* Align to 32-bits. */
+
+    uint32_t duration_sec;    /* Time flow was alive in seconds. */
+    uint32_t duration_nsec;   /* Time flow was alive in nanoseconds beyond
+                                 duration_sec. */
+    uint16_t idle_timeout;    /* Idle timeout from original flow mod. */
+    uint8_t pad2[2];          /* Align to 64-bits. */
+    uint64_t packet_count;
+    uint64_t byte_count;
+};
+OFP_ASSERT(sizeof(struct ofp_flow_removed) == 88);
+
+/* Values for 'type' in ofp_error_message.  These values are immutable: they
+ * will not change in future versions of the protocol (although new values may
+ * be added). */
+enum ofp_error_type {
+    OFPET_HELLO_FAILED,         /* Hello protocol failed. */
+    OFPET_BAD_REQUEST,          /* Request was not understood. */
+    OFPET_BAD_ACTION,           /* Error in action description. */
+    OFPET_FLOW_MOD_FAILED,      /* Problem modifying flow entry. */
+    OFPET_PORT_MOD_FAILED,      /* Port mod request failed. */
+    OFPET_QUEUE_OP_FAILED       /* Queue operation failed. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_HELLO_FAILED.  'data' contains an
+ * ASCII text string that may give failure details. */
+enum ofp_hello_failed_code {
+    OFPHFC_INCOMPATIBLE,        /* No compatible version. */
+    OFPHFC_EPERM                /* Permissions error. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_BAD_REQUEST.  'data' contains at least
+ * the first 64 bytes of the failed request. */
+enum ofp_bad_request_code {
+    OFPBRC_BAD_VERSION,         /* ofp_header.version not supported. */
+    OFPBRC_BAD_TYPE,            /* ofp_header.type not supported. */
+    OFPBRC_BAD_STAT,            /* ofp_stats_request.type not supported. */
+    OFPBRC_BAD_VENDOR,          /* Vendor not supported (in ofp_vendor_header
+                                 * or ofp_stats_request or ofp_stats_reply). */
+    OFPBRC_BAD_SUBTYPE,         /* Vendor subtype not supported. */
+    OFPBRC_EPERM,               /* Permissions error. */
+    OFPBRC_BAD_LEN,             /* Wrong request length for type. */
+    OFPBRC_BUFFER_EMPTY,        /* Specified buffer has already been used. */
+    OFPBRC_BUFFER_UNKNOWN       /* Specified buffer does not exist. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_BAD_ACTION.  'data' contains at least
+ * the first 64 bytes of the failed request. */
+enum ofp_bad_action_code {
+    OFPBAC_BAD_TYPE,           /* Unknown action type. */
+    OFPBAC_BAD_LEN,            /* Length problem in actions. */
+    OFPBAC_BAD_VENDOR,         /* Unknown vendor id specified. */
+    OFPBAC_BAD_VENDOR_TYPE,    /* Unknown action type for vendor id. */
+    OFPBAC_BAD_OUT_PORT,       /* Problem validating output action. */
+    OFPBAC_BAD_ARGUMENT,       /* Bad action argument. */
+    OFPBAC_EPERM,              /* Permissions error. */
+    OFPBAC_TOO_MANY,           /* Can't handle this many actions. */
+    OFPBAC_BAD_QUEUE           /* Problem validating output queue. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_FLOW_MOD_FAILED.  'data' contains
+ * at least the first 64 bytes of the failed request. */
+enum ofp_flow_mod_failed_code {
+    OFPFMFC_ALL_TABLES_FULL,    /* Flow not added because of full tables. */
+    OFPFMFC_OVERLAP,            /* Attempted to add overlapping flow with
+                                 * CHECK_OVERLAP flag set. */
+    OFPFMFC_EPERM,              /* Permissions error. */
+    OFPFMFC_BAD_EMERG_TIMEOUT,  /* Flow not added because of non-zero idle/hard
+                                 * timeout. */
+    OFPFMFC_BAD_COMMAND,        /* Unknown command. */
+    OFPFMFC_UNSUPPORTED         /* Unsupported action list - cannot process in
+                                 * the order specified. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_PORT_MOD_FAILED.  'data' contains
+ * at least the first 64 bytes of the failed request. */
+enum ofp_port_mod_failed_code {
+    OFPPMFC_BAD_PORT,            /* Specified port does not exist. */
+    OFPPMFC_BAD_HW_ADDR,         /* Specified hardware address is wrong. */
+};
+
+/* ofp_error msg 'code' values for OFPET_QUEUE_OP_FAILED. 'data' contains
+ * at least the first 64 bytes of the failed request */
+enum ofp_queue_op_failed_code {
+    OFPQOFC_BAD_PORT,           /* Invalid port (or port does not exist). */
+    OFPQOFC_BAD_QUEUE,          /* Queue does not exist. */
+    OFPQOFC_EPERM               /* Permissions error. */
+};
+
+/* OFPT_ERROR: Error message (datapath -> controller). */
+struct ofp_error_msg {
+    struct ofp_header header;
+
+    uint16_t type;
+    uint16_t code;
+    uint8_t data[0];          /* Variable-length data.  Interpreted based
+                                 on the type and code. */
+};
+OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
+
+enum ofp_stats_types {
+    /* Description of this OpenFlow switch.
+     * The request body is empty.
+     * The reply body is struct ofp_desc_stats. */
+    OFPST_DESC,
+
+    /* Individual flow statistics.
+     * The request body is struct ofp_flow_stats_request.
+     * The reply body is an array of struct ofp_flow_stats. */
+    OFPST_FLOW,
+
+    /* Aggregate flow statistics.
+     * The request body is struct ofp_aggregate_stats_request.
+     * The reply body is struct ofp_aggregate_stats_reply. */
+    OFPST_AGGREGATE,
+
+    /* Flow table statistics.
+     * The request body is empty.
+     * The reply body is an array of struct ofp_table_stats. */
+    OFPST_TABLE,
+
+    /* Physical port statistics.
+     * The request body is struct ofp_port_stats_request.
+     * The reply body is an array of struct ofp_port_stats. */
+    OFPST_PORT,
+
+    /* Queue statistics for a port
+     * The request body defines the port
+     * The reply body is an array of struct ofp_queue_stats */
+    OFPST_QUEUE,
+
+    /* Vendor extension.
+     * The request and reply bodies begin with a 32-bit vendor ID, which takes
+     * the same form as in "struct ofp_vendor_header".  The request and reply
+     * bodies are otherwise vendor-defined. */
+    OFPST_VENDOR = 0xffff
+};
+
+struct ofp_stats_request {
+    struct ofp_header header;
+    uint16_t type;              /* One of the OFPST_* constants. */
+    uint16_t flags;             /* OFPSF_REQ_* flags (none yet defined). */
+    uint8_t body[0];            /* Body of the request. */
+};
+OFP_ASSERT(sizeof(struct ofp_stats_request) == 12);
+
+enum ofp_stats_reply_flags {
+    OFPSF_REPLY_MORE  = 1 << 0  /* More replies to follow. */
+};
+
+struct ofp_stats_reply {
+    struct ofp_header header;
+    uint16_t type;              /* One of the OFPST_* constants. */
+    uint16_t flags;             /* OFPSF_REPLY_* flags. */
+    uint8_t body[0];            /* Body of the reply. */
+};
+OFP_ASSERT(sizeof(struct ofp_stats_reply) == 12);
+
+#define DESC_STR_LEN   256
+#define SERIAL_NUM_LEN 32
+/* Body of reply to OFPST_DESC request.  Each entry is a NULL-terminated
+ * ASCII string. */
+struct ofp_desc_stats {
+    char mfr_desc[DESC_STR_LEN];       /* Manufacturer description. */
+    char hw_desc[DESC_STR_LEN];        /* Hardware description. */
+    char sw_desc[DESC_STR_LEN];        /* Software description. */
+    char serial_num[SERIAL_NUM_LEN];   /* Serial number. */
+    char dp_desc[DESC_STR_LEN];        /* Human readable description of datapath. */
+};
+OFP_ASSERT(sizeof(struct ofp_desc_stats) == 1056);
+
+/* Body for ofp_stats_request of type OFPST_FLOW. */
+struct ofp_flow_stats_request {
+    struct ofp_match match;   /* Fields to match. */
+    uint8_t table_id;         /* ID of table to read (from ofp_table_stats),
+                                 0xff for all tables or 0xfe for emergency. */
+    uint8_t pad;              /* Align to 32 bits. */
+    uint16_t out_port;        /* Require matching entries to include this
+                                 as an output port.  A value of OFPP_NONE
+                                 indicates no restriction. */
+};
+OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 44);
+
+/* Body of reply to OFPST_FLOW request. */
+struct ofp_flow_stats {
+    uint16_t length;          /* Length of this entry. */
+    uint8_t table_id;         /* ID of table flow came from. */
+    uint8_t pad;
+    struct ofp_match match;   /* Description of fields. */
+    uint32_t duration_sec;    /* Time flow has been alive in seconds. */
+    uint32_t duration_nsec;   /* Time flow has been alive in nanoseconds beyond
+                                 duration_sec. */
+    uint16_t priority;        /* Priority of the entry. Only meaningful
+                                 when this is not an exact-match entry. */
+    uint16_t idle_timeout;    /* Number of seconds idle before expiration. */
+    uint16_t hard_timeout;    /* Number of seconds before expiration. */
+    uint8_t pad2[6];          /* Align to 64-bits. */
+    uint64_t cookie;          /* Opaque controller-issued identifier. */
+    uint64_t packet_count;    /* Number of packets in flow. */
+    uint64_t byte_count;      /* Number of bytes in flow. */
+    struct ofp_action_header actions[0]; /* Actions. */
+};
+OFP_ASSERT(sizeof(struct ofp_flow_stats) == 88);
+
+/* Body for ofp_stats_request of type OFPST_AGGREGATE. */
+struct ofp_aggregate_stats_request {
+    struct ofp_match match;   /* Fields to match. */
+    uint8_t table_id;         /* ID of table to read (from ofp_table_stats)
+                                 0xff for all tables or 0xfe for emergency. */
+    uint8_t pad;              /* Align to 32 bits. */
+    uint16_t out_port;        /* Require matching entries to include this
+                                 as an output port.  A value of OFPP_NONE
+                                 indicates no restriction. */
+};
+OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 44);
+
+/* Body of reply to OFPST_AGGREGATE request. */
+struct ofp_aggregate_stats_reply {
+    uint64_t packet_count;    /* Number of packets in flows. */
+    uint64_t byte_count;      /* Number of bytes in flows. */
+    uint32_t flow_count;      /* Number of flows. */
+    uint8_t pad[4];           /* Align to 64 bits. */
+};
+OFP_ASSERT(sizeof(struct ofp_aggregate_stats_reply) == 24);
+
+/* Body of reply to OFPST_TABLE request. */
+struct ofp_table_stats {
+    uint8_t table_id;        /* Identifier of table.  Lower numbered tables
+                                are consulted first. */
+    uint8_t pad[3];          /* Align to 32-bits. */
+    char name[OFP_MAX_TABLE_NAME_LEN];
+    uint32_t wildcards;      /* Bitmap of OFPFW_* wildcards that are
+                                supported by the table. */
+    uint32_t max_entries;    /* Max number of entries supported. */
+    uint32_t active_count;   /* Number of active entries. */
+    uint64_t lookup_count;   /* Number of packets looked up in table. */
+    uint64_t matched_count;  /* Number of packets that hit table. */
+};
+OFP_ASSERT(sizeof(struct ofp_table_stats) == 64);
+
+/* Body for ofp_stats_request of type OFPST_PORT. */
+struct ofp_port_stats_request {
+    uint16_t port_no;        /* OFPST_PORT message must request statistics
+                              * either for a single port (specified in
+                              * port_no) or for all ports (if port_no ==
+                              * OFPP_NONE). */
+    uint8_t pad[6];
+};
+OFP_ASSERT(sizeof(struct ofp_port_stats_request) == 8);
+
+/* Body of reply to OFPST_PORT request. If a counter is unsupported, set
+ * the field to all ones. */
+struct ofp_port_stats {
+    uint16_t port_no;
+    uint8_t pad[6];          /* Align to 64-bits. */
+    uint64_t rx_packets;     /* Number of received packets. */
+    uint64_t tx_packets;     /* Number of transmitted packets. */
+    uint64_t rx_bytes;       /* Number of received bytes. */
+    uint64_t tx_bytes;       /* Number of transmitted bytes. */
+    uint64_t rx_dropped;     /* Number of packets dropped by RX. */
+    uint64_t tx_dropped;     /* Number of packets dropped by TX. */
+    uint64_t rx_errors;      /* Number of receive errors.  This is a super-set
+                                of more specific receive errors and should be
+                                greater than or equal to the sum of all
+                                rx_*_err values. */
+    uint64_t tx_errors;      /* Number of transmit errors.  This is a super-set
+                                of more specific transmit errors and should be
+                                greater than or equal to the sum of all
+                                tx_*_err values (none currently defined.) */
+    uint64_t rx_frame_err;   /* Number of frame alignment errors. */
+    uint64_t rx_over_err;    /* Number of packets with RX overrun. */
+    uint64_t rx_crc_err;     /* Number of CRC errors. */
+    uint64_t collisions;     /* Number of collisions. */
+};
+OFP_ASSERT(sizeof(struct ofp_port_stats) == 104);
+
+/* Vendor extension. */
+struct ofp_vendor_header {
+    struct ofp_header header;   /* Type OFPT_VENDOR. */
+    uint32_t vendor;            /* Vendor ID:
+                                 * - MSB 0: low-order bytes are IEEE OUI.
+                                 * - MSB != 0: defined by OpenFlow
+                                 *   consortium. */
+    /* Vendor-defined arbitrary additional data. */
+};
+OFP_ASSERT(sizeof(struct ofp_vendor_header) == 12);
+
+/* All ones is used to indicate all queues in a port (for stats retrieval). */
+#define OFPQ_ALL      0xffffffff
+
+/* Min rate > 1000 means not configured. */
+#define OFPQ_MIN_RATE_UNCFG      0xffff
+
+enum ofp_queue_properties {
+    OFPQT_NONE = 0,       /* No property defined for queue (default). */
+    OFPQT_MIN_RATE,       /* Minimum datarate guaranteed. */
+                          /* Other types should be added here
+                           * (i.e. max rate, precedence, etc). */
+};
+
+/* Common description for a queue. */
+struct ofp_queue_prop_header {
+    uint16_t property;    /* One of OFPQT_. */
+    uint16_t len;         /* Length of property, including this header. */
+    uint8_t pad[4];       /* 64-bit alignemnt. */
+};
+OFP_ASSERT(sizeof(struct ofp_queue_prop_header) == 8);
+
+/* Min-Rate queue property description. */
+struct ofp_queue_prop_min_rate {
+    struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MIN, len: 16. */
+    uint16_t rate;        /* In 1/10 of a percent; >1000 -> disabled. */
+    uint8_t pad[6];       /* 64-bit alignment */
+};
+OFP_ASSERT(sizeof(struct ofp_queue_prop_min_rate) == 16);
+
+/* Full description for a queue. */
+struct ofp_packet_queue {
+    uint32_t queue_id;     /* id for the specific queue. */
+    uint16_t len;          /* Length in bytes of this queue desc. */
+    uint8_t pad[2];        /* 64-bit alignment. */
+    struct ofp_queue_prop_header properties[0]; /* List of properties. */
+};
+OFP_ASSERT(sizeof(struct ofp_packet_queue) == 8);
+
+/* Query for port queue configuration. */
+struct ofp_queue_get_config_request {
+    struct ofp_header header;
+    uint16_t port;         /* Port to be queried. Should refer
+                              to a valid physical port (i.e. < OFPP_MAX) */
+    uint8_t pad[2];        /* 32-bit alignment. */
+};
+OFP_ASSERT(sizeof(struct ofp_queue_get_config_request) == 12);
+
+/* Queue configuration for a given port. */
+struct ofp_queue_get_config_reply {
+    struct ofp_header header;
+    uint16_t port;
+    uint8_t pad[6];
+    struct ofp_packet_queue queues[0]; /* List of configured queues. */
+};
+OFP_ASSERT(sizeof(struct ofp_queue_get_config_reply) == 16);
+
+/* OFPAT_ENQUEUE action struct: send packets to given queue on port. */
+struct ofp_action_enqueue {
+    uint16_t type;            /* OFPAT_ENQUEUE. */
+    uint16_t len;             /* Len is 16. */
+    uint16_t port;            /* Port that queue belongs. Should
+                                 refer to a valid physical port
+                                 (i.e. < OFPP_MAX) or OFPP_IN_PORT. */
+    uint8_t pad[6];           /* Pad for 64-bit alignment. */
+    uint32_t queue_id;        /* Where to enqueue the packets. */
+};
+OFP_ASSERT(sizeof(struct ofp_action_enqueue) == 16);
+
+struct ofp_queue_stats_request {
+    uint16_t port_no;        /* All ports if OFPT_ALL. */
+    uint8_t pad[2];          /* Align to 32-bits. */
+    uint32_t queue_id;       /* All queues if OFPQ_ALL. */
+};
+OFP_ASSERT(sizeof(struct ofp_queue_stats_request) == 8);
+
+struct ofp_queue_stats {
+    uint16_t port_no;
+    uint8_t pad[2];          /* Align to 32-bits. */
+    uint32_t queue_id;       /* Queue i.d */
+    uint64_t tx_bytes;       /* Number of transmitted bytes. */
+    uint64_t tx_packets;     /* Number of transmitted packets. */
+    uint64_t tx_errors;      /* Number of packets dropped due to overrun. */
+};
+OFP_ASSERT(sizeof(struct ofp_queue_stats) == 32);
+
+#endif /* openflow/openflow.h */
diff --git a/tools/pylibopenflow/include/pyopenflow.template.py b/tools/pylibopenflow/include/pyopenflow.template.py
new file mode 100644
index 0000000..29b59f4
--- /dev/null
+++ b/tools/pylibopenflow/include/pyopenflow.template.py
@@ -0,0 +1,21 @@
+import socket
+
+class ofsocket:
+	"""OpenFlow scoket
+	"""
+	def __init__(self, socket):
+		"""Initialize with socket
+		"""
+		##Reference to socket
+		self.socket = socket
+
+	def send(self, msg):
+		"""Send message
+		"""
+		ofph = ofp_header()
+		remaining = ofph.unpack(msg)
+		if (ofph.length != len(msg)):
+			ofph.length = len(msg)
+			msg = ofph.pack()+remaining
+		self.socket.send(msg)
+
diff --git a/tools/pylibopenflow/pylib/c2py.py b/tools/pylibopenflow/pylib/c2py.py
new file mode 100644
index 0000000..b699c5e
--- /dev/null
+++ b/tools/pylibopenflow/pylib/c2py.py
@@ -0,0 +1,154 @@
+"""This module converts C types to Python struct pattern string.
+
+Date June 2009
+Created by ykk
+"""
+import cheader
+import struct
+
+class cstruct2py:
+    """Class converts C struct to Python struct pattern string
+
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self):
+        """Initialize
+        """
+        ##Mapping
+        self.structmap = {}
+        self.structmap["char"] = "c"
+        self.structmap["signed char"] = "b"
+        self.structmap["uint8_t"]=\
+            self.structmap["unsigned char"] = "B"
+        self.structmap["short"] = "h"
+        self.structmap["uint16_t"] =\
+            self.structmap["unsigned short"] = "H"
+        self.structmap["int"] = "i"
+        self.structmap["unsigned int"] = "I"
+        self.structmap["long"] = "l"
+        self.structmap["uint32_t"] =\
+            self.structmap["unsigned long"] = "L"
+        self.structmap["long long"] = "q"
+        self.structmap["uint64_t"] =\
+            self.structmap["unsigned long long"] = "Q"
+        self.structmap["float"] = "f"
+        self.structmap["double"] = "d"
+
+    def get_pattern(self,ctype):
+        """Get pattern string for ctype.
+        Return None if ctype is not expanded.
+        """
+        if (ctype.expanded):
+            if (isinstance(ctype, cheader.cprimitive)):
+                return self.structmap[ctype.typename]
+            elif (isinstance(ctype, cheader.cstruct)):
+                string=""
+                for member in ctype.members:
+                    string += self.get_pattern(member)
+                return string
+            elif (isinstance(ctype, cheader.carray)):
+                if (ctype.size == 0):
+                    return ""
+                else:
+                    string = self.get_pattern(ctype.object)
+                    return string * ctype.size
+        return None
+        
+    def get_size(self, ctype, prefix="!"):
+        """Return size of struct or pattern specified
+        """
+        if (isinstance(ctype, str)):
+            return struct.calcsize(ctype)
+        elif (isinstance(ctype, cheader.ctype)):
+            return struct.calcsize(prefix + self.get_pattern(ctype))
+        else:
+            return 0
+
+class structpacker:
+    """Pack/unpack packets with ctype.
+    
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, prefix=""):
+        """Initialize with prefix to struct
+        """
+        ##Reference to prefix
+        self.prefix = prefix
+        
+    def pack(self, ctype, *arg):
+        """Pack packet accordingly ctype or pattern provided.
+        Return struct packed.
+        """
+        if (isinstance(ctype, str)):
+            return struct.pack(self.prefix+ctype, *arg)
+        elif (isinstance(ctype, cheader.ctype)):
+            return struct.pack(self.prefix+cstruct2py.get_pattern(ctype),
+                               *arg)
+        else:
+            return None
+
+    def unpack_from_front(self, ctype, binaryString, returnDictionary=True):
+        """Unpack packet using front of packet,
+        accordingly ctype or pattern provided.
+
+        Return (dictionary of values indexed by arg name, 
+        remaining binary string) if ctype is cheader.ctype
+        and returnDictionary is True, 
+        else return (array of data unpacked, remaining binary string).
+        """
+        pattern = ""
+        if (isinstance(ctype, str)):
+            pattern = ctype
+        elif (isinstance(ctype, cheader.ctype)):
+            pattern = cstruct2py.get_pattern(ctype)
+        else:
+            return None
+        dsize = struct.calcsize(pattern)
+
+        if (dsize > len(binaryString)):
+            return None
+
+        return (structpacker.peek_from_front(self, pattern, binaryString, returnDictionary),
+                binaryString[dsize:])
+
+    def peek_from_front(self, ctype, binaryString, returnDictionary=True):
+        """Unpack packet using front of packet,
+        accordingly ctype or pattern provided.
+
+        Return dictionary of values indexed by arg name,
+        if ctype is cheader.ctype and returnDictionary is True, 
+        else return array of data unpacked.
+        """
+        pattern = self.prefix
+        if (isinstance(ctype, str)):
+            pattern += ctype
+        elif (isinstance(ctype, cheader.ctype)):
+            pattern += cstruct2py.get_pattern(ctype)
+        else:
+            return None
+        dsize = struct.calcsize(pattern)
+        if (dsize > len(binaryString)):
+            return None
+        data = struct.unpack(pattern, binaryString[0:dsize])
+        
+        #Return values
+        if (isinstance(ctype, str) or
+            (not returnDictionary)):
+            return data
+        else:
+            return self.data2dic(data, ctype)
+
+    def data2dic(self,ctype,data):
+        """Convert data to dictionary
+        """
+        valDic = {}
+        names = ctype.get_names()
+        for name in names:
+            valDic[name] = []
+        for d in data:
+            name = names.pop(0)
+            valDic[name].append(d)
+        return valDic
+
diff --git a/tools/pylibopenflow/pylib/cheader.py b/tools/pylibopenflow/pylib/cheader.py
new file mode 100644
index 0000000..a23e1eb
--- /dev/null
+++ b/tools/pylibopenflow/pylib/cheader.py
@@ -0,0 +1,434 @@
+"""This module parse and store a C/C++ header file.
+
+Date June 2009
+Created by ykk
+"""
+import re
+from config import *
+
+class textfile:
+    """Class to handle text file.
+    
+    Date June 2009
+    Created by ykk
+    """
+    def __init__(self, filename):
+        """Initialize filename with no content.
+        """
+        ##Filename
+        if (isinstance(filename, str)):
+            self.filename = []
+            self.filename.append(filename)
+        else:
+            self.filename = filename
+        ##Content
+        self.content = []
+
+    def read(self):
+        """Read file
+        """
+        for filename in self.filename:
+            fileRef = open(filename, "r")
+            for line in fileRef:
+                self.content.append(line)
+            fileRef.close()        
+
+class ctype:
+    """Class to represent types in C
+    """
+    def __init__(self,typename, name=None, expanded=False):
+        """Initialize
+        """
+        ##Name
+        self.name = name
+        ##Type of primitive
+        self.typename = typename
+        ##Expanded
+        self.expanded = expanded
+
+    def expand(self, cheader):
+        """Expand type if applicable
+        """
+        raise NotImplementedError()
+
+    def get_names(self):
+        """Return name of variables
+        """
+        raise NotImplementedError()
+
+class cprimitive(ctype):
+    """Class to represent C primitive
+
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self,typename, name=None):
+        """Initialize and store primitive
+        """
+        ctype.__init__(self, typename, name, True)
+
+    def __str__(self):
+        """Return string representation
+        """
+        if (self.name == None):
+            return self.typename
+        else:
+            return self.typename+" "+str(self.name)
+
+    def expand(self, cheader):
+        """Expand type if applicable
+        """
+        pass
+    
+    def get_names(self):
+        """Return name of variables
+        """
+        namelist = []
+        namelist.append(self.name)
+        return namelist
+
+class cstruct(ctype):
+    """Class to represent C struct
+
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, typename, name=None):
+        """Initialize struct
+        """
+        ctype.__init__(self, typename, name)
+        ##List of members in struct
+        self.members = []
+    
+    def __str__(self):
+        """Return string representation
+        """
+        string = "struct "+self.typename
+        if (self.name != None):
+            string += " "+self.name
+        if (len(self.members) == 0):
+            return string
+        #Add members
+        string +=" {\n"
+        for member in self.members:
+            string += "\t"+str(member)
+            if (not isinstance(member, cstruct)):
+                string += ";"
+            string += "\n"
+        string +="};"
+        return string
+
+    def expand(self, cheader):
+        """Expand struct
+        """
+        self.expanded = True
+        #Expanded each member
+        for member in self.members:
+            if (isinstance(member, cstruct) and 
+                (not member.expanded)):
+                try:
+                    if (not cheader.structs[member.typename].expanded):
+                        cheader.structs[member.typename].expand(cheader)
+                    member.members=cheader.structs[member.typename].members[:]
+                    member.expanded = True
+                except KeyError:
+                    self.expanded=False
+            else:
+                member.expand(cheader)
+
+    def get_names(self):
+        """Return name of variables
+        """
+        namelist = []
+        for member in self.members:
+            if (isinstance(member, cstruct)):
+                tmplist = member.get_names()
+                for item in tmplist:
+                    namelist.append(member.name+"."+item)
+            else:
+                namelist.extend(member.get_names())
+        return namelist
+
+
+class carray(ctype):
+    """Class to represent C array
+
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, typename, name, isPrimitive, size):
+        """Initialize array of object.
+        """
+        ctype.__init__(self, typename, name,
+                       (isinstance(size, int) and isPrimitive))
+        ##Object reference
+        if (isPrimitive):
+            self.object = cprimitive(typename, name)
+        else:
+            self.object = cstruct(typename, name)
+        ##Size of array
+        self.size = size
+        
+    def __str__(self):
+        """Return string representation
+        """
+        return str(self.object)+"["+str(self.size)+"]"
+
+    def expand(self, cheader):
+        """Expand array
+        """
+        self.expanded = True
+        if (not self.object.expanded):
+            if (isinstance(self.object, cstruct)):
+                cheader.structs[self.object.typename].expand(cheader)
+                self.object.members=cheader.structs[self.object.typename].members[:]    
+            else:
+                self.object.expand(cheader)
+
+        if (not isinstance(self.size, int)):
+            val = cheader.get_value(self.size)
+            if (val == None):
+                self.expanded = False
+            else:
+                try:
+                    self.size = int(val)
+                except ValueError:
+                    self.size = val
+                    self.expanded = False
+
+    def get_names(self):
+        """Return name of variables
+        """
+        namelist = []
+        for i in range(0,self.size):
+            namelist.append(self.object.name)
+        return namelist
+
+class ctype_parser:
+    """Class to check c types
+
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self):
+        """Initialize
+        """
+        self.CPrimitives = ["char","signed char","unsigned char",
+                            "short","unsigned short",
+                            "int","unsigned int",
+                            "long","unsigned long",
+                            "long long","unsigned long long",
+                            "float","double",
+                            "uint8_t","uint16_t","uint32_t","uint64_t"]
+
+    def is_primitive(self,type):
+        """Check type given is primitive.
+
+        Return true if valid, and false otherwise
+        """
+        if (type in self.CPrimitives):
+            return True
+        else:
+            return False
+
+    def is_array(self, string):
+        """Check if string declares an array
+        """
+        parts=string.strip().split()
+        if (len(parts) <= 1):
+            return False
+        else:
+            pattern = re.compile("\[.*?\]", re.MULTILINE)
+            values = pattern.findall(string)
+            if (len(values) == 1):
+                return True
+            else:
+                return False
+
+    def parse_array(self, string):
+        """Parse array from string.
+        Return occurrence and name.
+        """
+        pattern = re.compile("\[.*?\]", re.MULTILINE)
+        namepattern = re.compile(".*?\[", re.MULTILINE)
+        values = pattern.findall(string)
+        if (len(values) != 1):
+            return (1,string)
+        else:
+            val = values[0][1:-1]
+            try:
+                sizeval = int(val)
+            except ValueError:
+                if (val==""):
+                    sizeval = 0
+                else:
+                    sizeval = val
+            return (sizeval,
+                    namepattern.findall(string)[0].strip()[0:-1])
+
+    def parse_type(self, string):
+        """Parse string and return cstruct or cprimitive.
+        Else return None
+        """
+        parts=string.strip().split()
+        if (len(parts) >= 2):
+            if (parts[0].strip() == "struct"):
+                typename = " ".join(parts[1:-1])
+            else:
+                typename = " ".join(parts[:-1])
+            (size, name) = self.parse_array(parts[-1])
+            if IGNORE_ZERO_ARRAYS and size == 0:
+                return None
+            #Create appropriate type
+            if (size != 1):
+                #Array
+                return carray(typename, name, 
+                              self.is_primitive(typename),size)
+            else:
+                #Not array
+                if IGNORE_OFP_HEADER and typename == "ofp_header":
+                    return None
+                if (self.is_primitive(typename)):
+                    return cprimitive(typename, name)
+                else:
+                    return cstruct(typename, name)
+        else:
+            return None
+
+class cheaderfile(textfile):
+    """Class to handle C header file.
+    
+    Date June 2009
+    Created by ykk
+    """
+    def __init__(self, filename):
+        """Initialize filename and read from file
+        """
+        textfile.__init__(self,filename)
+        self.read()
+        self.__remove_comments()
+        ##Dictionary of macros
+        self.macros = {}
+        self.__get_macros()
+        ##Dictionary of enumerations
+        self.enums = {}
+        self.enum_values = {}
+        self.__get_enum()
+        self.__get_enum_values()
+        ##Dictionary of structs
+        self.structs = {}
+        self.__get_struct()
+
+    def get_enum_name(self, enum, value):
+        """Return name of variable in enum
+        """
+        for e in self.enums[enum]:
+            if (self.enum_values[e] == value):
+                return e
+
+    def eval_value(self, value):
+        """Evaluate value string
+        """
+        try:
+            return eval(value, self.enum_values)
+        except:
+            return value.strip()
+
+    def get_value(self, name):
+        """Get value for variable name,
+        searching through enum and macros.
+        Else return None
+        """
+        try:
+            return self.enum_values[name]
+        except KeyError:
+            try:
+                return self.macros[name]
+            except KeyError:
+                return None
+
+    def __remove_comments(self):
+        """Remove all comments
+        """
+        fileStr = "".join(self.content)
+        pattern = re.compile("\\\.*?\n", re.MULTILINE)
+        fileStr = pattern.sub("",fileStr)
+        pattern = re.compile(r"/\*.*?\*/", re.MULTILINE|re.DOTALL)
+        fileStr = pattern.sub("",fileStr)
+        pattern = re.compile("//.*$", re.MULTILINE)
+        fileStr = pattern.sub("",fileStr)
+        self.content = fileStr.split('\n')
+
+    def __get_struct(self):
+        """Get all structs
+        """
+        typeparser = ctype_parser()
+        fileStr = "".join(self.content)
+        #Remove attribute
+        attrpattern = re.compile("} __attribute__ \(\((.+?)\)\);", re.MULTILINE)
+        attrmatches = attrpattern.findall(fileStr)
+        for amatch in attrmatches:
+            fileStr=fileStr.replace(" __attribute__ (("+amatch+"));",";")
+        #Find all structs
+        pattern = re.compile("struct[\w\s]*?{.*?};", re.MULTILINE)
+        matches = pattern.findall(fileStr)
+        #Process each struct
+        namepattern = re.compile("struct(.+?)[ {]", re.MULTILINE)
+        pattern = re.compile("{(.+?)};", re.MULTILINE)
+        for match in matches:
+            structname = namepattern.findall(match)[0].strip()
+            if (len(structname) != 0):
+                values = pattern.findall(match)[0].strip().split(";")
+                cstru = cstruct(structname)
+                for val in values:
+                    presult = typeparser.parse_type(val)
+                    if (presult != None):
+                        cstru.members.append(presult)
+                self.structs[structname] = cstru
+        #Expand all structs
+        for (structname, struct) in self.structs.items():
+            struct.expand(self)
+
+    def __get_enum(self):
+        """Get all enumeration
+        """
+        fileStr = "".join(self.content)
+        #Find all enumerations
+        pattern = re.compile("enum[\w\s]*?{.*?}", re.MULTILINE)
+        matches = pattern.findall(fileStr)
+        #Process each enumeration
+        namepattern = re.compile("enum(.+?){", re.MULTILINE)
+        pattern = re.compile("{(.+?)}", re.MULTILINE)
+        for match in matches:
+            values = pattern.findall(match)[0].strip().split(",")
+            #Process each value in enumeration
+            enumList = []
+            value = 0
+            for val in values:
+                if not (val.strip() == ""):
+                    valList=val.strip().split("=")
+                    enumList.append(valList[0].strip())
+                    if (len(valList) == 1):
+                        self.enum_values[valList[0].strip()] = value
+                        value += 1
+                    else:
+                        self.enum_values[valList[0].strip()] = self.eval_value(valList[1].strip())
+                    self.enums[namepattern.findall(match)[0].strip()] = enumList
+
+    def __get_enum_values(self):
+        """Patch unresolved enum values
+        """
+        for name,enumval in self.enum_values.items():
+            if isinstance(enumval,str):
+                self.enum_values[name] = self.eval_value(enumval)
+        
+    def __get_macros(self):
+        """Extract macros
+        """
+        for line in self.content:
+            if (line[0:8] == "#define "):
+                lineList = line[8:].split()
+                if (len(lineList) >= 2):
+                    self.macros[lineList[0]] = self.eval_value("".join(lineList[1:]))
+                else:
+                    self.macros[lineList[0]] = ""
diff --git a/tools/pylibopenflow/pylib/config.py b/tools/pylibopenflow/pylib/config.py
new file mode 100644
index 0000000..bbf1528
--- /dev/null
+++ b/tools/pylibopenflow/pylib/config.py
@@ -0,0 +1,24 @@
+
+# of_message specific controls
+
+# Do not include any arrays marked [0]
+IGNORE_ZERO_ARRAYS = 1
+
+# Do not include the ofp_header as a member in any structure
+# This allows messages to be consistently generated as:
+#   explicit header declaration
+#   core member declaration
+#   variable length data
+IGNORE_OFP_HEADER = 1
+
+# Generate object equality functions
+GEN_OBJ_EQUALITY = 1
+
+# Generate object show functions
+GEN_OBJ_SHOW = 1
+
+# Generate lists of enum values
+GEN_ENUM_VALUES_LIST = 0
+
+# Generate dictionary of enum strings to values
+GEN_ENUM_DICTIONARY = 1
diff --git a/tools/pylibopenflow/pylib/cpythonize.py b/tools/pylibopenflow/pylib/cpythonize.py
new file mode 100644
index 0000000..6a66d7c
--- /dev/null
+++ b/tools/pylibopenflow/pylib/cpythonize.py
@@ -0,0 +1,533 @@
+"""This module generate Python code for C structs.
+
+Date January 2010
+Created by ykk
+"""
+import cheader
+import c2py
+import datetime
+import struct
+import re
+from config import *
+
+def _space_to(n, str):
+    """
+    Generate a string of spaces to achieve width n given string str
+    If length of str >= n, return one space
+    """
+    spaces = n - len(str)
+    if spaces > 0:
+        return " " * spaces
+    return " "
+
+class rules:
+    """Class that specify rules for pythonization
+
+    Date January 2010
+    Created by ykk
+    """
+    def __init__(self):
+        """Initialize rules
+        """
+        ##Default values for members
+        self.default_values = {}
+        #Default values for struct
+        self.struct_default = {}
+        ##What is a tab
+        self.tab = "    "
+        ##Macros to exclude
+        self.excluded_macros = []
+        ##Enforce mapping
+        self.enforced_maps = {}
+
+    def get_enforced_map(self, structname):
+        """Get code to enforce mapping
+        """
+        code = []
+        try:
+            mapping = self.enforced_maps[structname]
+        except KeyError:
+            return None
+        for (x,xlist) in mapping:
+            code.append("if (not (self."+x+" in "+xlist+")):")
+            code.append(self.tab+"return (False, \""+x+" must have values from "+xlist+"\")")
+        return code
+        
+
+    def get_struct_default(self, structname, fieldname):
+        """Get code to set defaults for member struct
+        """
+        try:
+            return "."+fieldname+self.struct_default[(structname, fieldname)]
+        except KeyError:
+            return None
+        
+    def get_default_value(self, structname, fieldname):
+        """Get default value for struct's field
+        """
+        try:
+            return self.default_values[(structname, fieldname)]
+        except KeyError:
+            return 0
+
+    def include_macro(self, name):
+        """Check if macro should be included
+        """
+        return not (name in self.excluded_macros)
+
+class pythonizer:
+    """Class that pythonize C structures
+
+    Date January 2010
+    Created by ykk
+    """
+    def __init__(self, cheaderfile, pyrules = None, tab="    "):
+        """Initialize
+        """
+        ##Rules
+        if (pyrules == None):
+            self.rules = rules()
+        else:
+            self.rules = pyrules
+        ##What is a tab (same as rules)
+        self.tab = str(tab)
+        self.rules.tab = self.tab
+        ##Reference to C header file
+        self.cheader = cheaderfile
+        ##Reference to cstruct2py
+        self.__c2py = c2py.cstruct2py()
+        ##Code for assertion
+        self.__assertcode = []
+
+    def pycode(self,preamble=None):
+        """Return pythonized code
+        """
+        code = []
+        code.append("import struct")
+        code.append("")
+        if (preamble != None):
+            fileRef = open(preamble,"r")
+            for l in fileRef:
+                code.append(l[:-1])
+            fileRef.close()
+        code.append("# Structure definitions")
+        for name,struct in self.cheader.structs.items():
+            code.extend(self.pycode_struct(struct))
+            code.append("")
+        code.append("# Enumerated type definitions")
+        for name,enum in self.cheader.enums.items():
+            code.extend(self.pycode_enum(name,enum))
+            if GEN_ENUM_DICTIONARY:
+                code.extend(self.pycode_enum_map(name,enum))
+            code.append("")
+        code.append("# Values from macro definitions")
+        for name,macro in self.cheader.macros.items():
+            code.extend(self.pycode_macro(name))
+        code.append("")
+        code.append("# Basic structure size definitions.")
+        if IGNORE_OFP_HEADER:
+            code.append("# Does not include ofp_header members.")
+        if IGNORE_ZERO_ARRAYS:
+            code.append("# Does not include variable length arrays.")
+        struct_keys = self.cheader.structs.keys()
+        struct_keys.sort()
+        for name in struct_keys:
+            struct = self.cheader.structs[name]
+            code.append(self.pycode_struct_size(name, struct))
+
+        return code
+
+    def pycode_enum(self, name, enum):
+        """Return Python array for enum
+        """
+        code=[]
+        code.append(name+" = "+str(enum))
+        ev = []
+        for e in enum:
+            v = self.cheader.get_value(e)
+            ev.append(v)
+            code.append(e+"%s= "%_space_to(36,e)+str(v))
+        if GEN_ENUM_VALUES_LIST:
+            code.append(name+"_values = "+str(ev))
+        return code
+
+    def pycode_enum_map(self, name, enum):
+        """Return Python dictionary for enum
+        """
+        code = []
+        code.append(name+"_map = {")
+        first = 1
+        for e in enum:
+            v = self.cheader.get_value(e)
+            if first:
+                prev_e = e
+                prev_v = v
+                first = 0
+            else:
+                code.append(self.tab + "'%s'%s: %s," %
+                            (prev_e, _space_to(30, prev_e), prev_v))
+                prev_e = e
+                prev_v = v
+        code.append(self.tab + "'%s'%s: %s" %
+                            (prev_e, _space_to(30, prev_e), prev_v))
+        code.append("}")
+        return code
+
+    def pycode_macro(self,name):
+        """Return Python dict for macro
+        """
+        code = []
+        if (self.rules.include_macro(name)):
+            code.append(name+" = "+str(self.cheader.get_value(name)))
+        return code
+
+    def pycode_struct_size(self, name, struct):
+        """Return one liner giving the structure size in bytes
+        """
+        pattern = '!' + self.__c2py.get_pattern(struct)
+        bytes = self.__c2py.get_size(pattern)
+        code = name.upper() + "_BYTES = " + str(bytes)
+        return code
+
+    def pycode_struct(self, struct_in):
+        """Return Python class code given C struct.
+
+        Returns None if struct_in is not cheader.cstruct.
+        Else return list of strings that codes Python class.
+        """
+        if (not isinstance(struct_in, cheader.cstruct)):
+            return None
+
+        code=[]
+        self.__assertcode = []
+        code.extend(self.codeheader(struct_in))
+        code.extend(self.codeinit(struct_in))
+        code.append("")
+        code.extend(self.codeassert(struct_in))
+        code.append("")
+        code.extend(self.codepack(struct_in))
+        code.append("")
+        code.extend(self.codeunpack(struct_in))
+        code.append("")
+        code.extend(self.codelen(struct_in))
+        code.append("")
+        if GEN_OBJ_EQUALITY:
+            code.extend(self.codeeq(struct_in))
+            code.append("")
+        if GEN_OBJ_SHOW:
+            code.extend(self.codeshow(struct_in))
+            code.append("")
+        return code
+
+    def codeheader(self, struct_in):
+        """Return Python code for header
+        """
+        code=[]
+        code.append("class "+struct_in.typename+":")
+        code.append(self.tab+"\"\"\"Automatically generated Python class for "+struct_in.typename)
+        code.append("")
+        code.append(self.tab+"Date "+str(datetime.date.today()))
+        code.append(self.tab+"Created by "+self.__module__+"."+self.__class__.__name__)
+        if IGNORE_OFP_HEADER:
+            code.append(self.tab+"Core structure: Messages do not include ofp_header")
+        if IGNORE_ZERO_ARRAYS:
+            code.append(self.tab+"Does not include var-length arrays")
+        code.append(self.tab+"\"\"\"")
+        return code
+
+    def codeinit(self, struct_in):
+        """Return Python code for init function
+        """
+        code = []
+        code.append(self.tab+"def __init__(self):")
+        code.append(self.tab*2+"\"\"\"Initialize")
+        code.append(self.tab*2+"Declare members and default values")
+        code.append(self.tab*2+"\"\"\"")
+        code.extend(self.codemembers(struct_in,self.tab*2+"self"))
+        return code
+
+    def codemembers(self, struct_in, prepend=""):
+        """Return members of class
+        """
+        code = []
+        for member in struct_in.members:
+            if (isinstance(member, cheader.cstruct)):
+                code.append(prepend+"."+member.name+" = "+member.typename+"()")
+                struct_default = self.rules.get_struct_default(struct_in.typename, member.name)
+                if (struct_default != None):
+                    code.append(prepend+struct_default)
+                self.__structassert(member, (prepend+"."+member.name).strip())
+            elif (isinstance(member, cheader.carray)):
+                if (member.typename == "char"):
+                    initvalue = "\"\""
+                    self.__stringassert(member, (prepend+"."+member.name).strip())
+                else:
+                    if (isinstance(member.object, cheader.cprimitive)):
+                        initvalue="0"
+                    else:
+                        initvalue="None"
+                    initvalue=(initvalue+",")*member.size
+                    initvalue="["+initvalue[:-1]+"]"
+                    self.__arrayassert(member, (prepend+"."+member.name).strip())
+                code.append(prepend+"."+member.name+"= "+initvalue)
+            else:
+                code.append(prepend+"."+member.name+" = "+
+                            str(self.rules.get_default_value(struct_in.typename, member.name)))
+        return code
+
+    def __structassert(self, cstruct, cstructname):
+        """Return code to check for C array
+        """
+        self.__assertcode.append(self.tab*2+"if(not isinstance("+cstructname+", "+cstruct.typename+")):")
+        self.__assertcode.append(self.tab*3+"return (False, \""+cstructname+" is not class "+cstruct.typename+" as expected.\")")        
+
+    def __addassert(self, prefix):
+        code = []
+        code.append(prefix+"if(not self.__assert()[0]):")
+        code.append(prefix+self.tab+"return None")        
+        return code
+
+    def __stringassert(self, carray, carrayname):
+        """Return code to check for C array
+        """
+        self.__assertcode.append(self.tab*2+"if(not isinstance("+carrayname+", str)):")
+        self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not string as expected.\")")        
+        self.__assertcode.append(self.tab*2+"if(len("+carrayname+") > "+str(carray.size)+"):")      
+        self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not of size "+str(carray.size)+" as expected.\")")
+
+    def __arrayassert(self, carray, carrayname):
+        """Return code to check for C array
+        """
+        if (carray.size == 0):
+            return
+        self.__assertcode.append(self.tab*2+"if(not isinstance("+carrayname+", list)):")
+        self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not list as expected.\")")
+        self.__assertcode.append(self.tab*2+"if(len("+carrayname+") != "+str(carray.size)+"):")
+        self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not of size "+str(carray.size)+" as expected.\")") 
+
+    def codeassert(self, struct_in):
+        """Return code for sanity checking
+        """
+        code = []
+        code.append(self.tab+"def __assert(self):")
+        code.append(self.tab*2+"\"\"\"Sanity check")
+        code.append(self.tab*2+"\"\"\"")
+        enforce = self.rules.get_enforced_map(struct_in.typename)
+        if (enforce != None):
+            for line in enforce:
+                code.append(self.tab*2+line)
+        code.extend(self.__assertcode)
+        code.append(self.tab*2+"return (True, None)")
+        return code
+
+    def codepack(self, struct_in, prefix="!"):
+        """Return code that pack struct
+        """
+        code = []
+        code.append(self.tab+"def pack(self, assertstruct=True):")
+        code.append(self.tab*2+"\"\"\"Pack message")
+        code.append(self.tab*2+"Packs empty array used as placeholder")
+        code.append(self.tab*2+"\"\"\"")
+        code.append(self.tab*2+"if(assertstruct):")
+        code.extend(self.__addassert(self.tab*3))
+        code.append(self.tab*2+"packed = \"\"")
+        primPattern = ""
+        primMemberNames = []
+        for member in struct_in.members:
+            if (isinstance(member, cheader.cprimitive)):
+                #Primitives
+                primPattern += self.__c2py.structmap[member.typename]
+                primMemberNames.append("self."+member.name)
+            else:
+                (primPattern, primMemberNames) = \
+                              self.__codepackprimitive(code, primPattern,
+                                                       primMemberNames, prefix)
+                if (isinstance(member, cheader.cstruct)):
+                    #Struct
+                    code.append(self.tab*2+"packed += self."+member.name+".pack()")
+                elif (isinstance(member, cheader.carray) and member.typename == "char"):
+                    #String
+                    code.append(self.tab*2+"packed += self."+member.name+".ljust("+\
+                                str(member.size)+",'\\0')")
+                elif (isinstance(member, cheader.carray) and \
+                      isinstance(member.object, cheader.cprimitive)):
+                    #Array of Primitives
+                    expandedarr = ""
+                    if (member.size != 0):
+                        for x in range(0, member.size):
+                            expandedarr += ", self."+member.name+"["+\
+                                           str(x).strip()+"]"
+                        code.append(self.tab*2+"packed += struct.pack(\""+prefix+\
+                                    self.__c2py.structmap[member.object.typename]*member.size+\
+                                    "\""+expandedarr+")")
+                    else:
+                        code.append(self.tab*2+"for i in self."+member.name+":")
+                        code.append(self.tab*3+"packed += struct.pack(\""+\
+                                    prefix+self.__c2py.get_pattern(member.object)+\
+                                    "\",i)")
+                elif (isinstance(member, cheader.carray) and \
+                      isinstance(member.object, cheader.cstruct)):
+                    #Array of struct
+                    if (member.size != 0):
+                        for x in range(0, member.size):
+                            code.append(self.tab*2+"packed += self."+member.name+"["+\
+                                        str(x).strip()+"].pack()")
+                    else:
+                        code.append(self.tab*2+"for i in self."+member.name+":")
+                        code.append(self.tab*3+"packed += i.pack(assertstruct)")
+        #Clear remaining fields
+        (primPattern, primMemberNames) = \
+                      self.__codepackprimitive(code, primPattern,
+                                               primMemberNames, prefix)
+        code.append(self.tab*2+"return packed")
+        return code
+
+    def __codepackprimitive(self, code, primPattern, primMemberNames, prefix):
+        """Return code for packing primitives
+        """
+        if (primPattern != ""):
+            #Clear prior primitives
+            code.append(self.tab*2+"packed += struct.pack(\""+\
+                        prefix+primPattern+"\", "+\
+                        str(primMemberNames).replace("'","")[1:-1]+")")
+        return ("",[])
+
+    def codelen(self, struct_in):
+        """Return code to return length
+        """
+        pattern = "!" + self.__c2py.get_pattern(struct_in)
+        code = []
+        code.append(self.tab+"def __len__(self):")
+        code.append(self.tab*2+"\"\"\"Return length of message")
+        code.append(self.tab*2+"\"\"\"")
+        code.append(self.tab*2+"l = "+str(self.__c2py.get_size(pattern)))
+        for member in struct_in.members:
+            if (isinstance(member, cheader.carray) and member.size == 0):
+                if (isinstance(member.object, cheader.cstruct)):
+                    code.append(self.tab*2+"for i in self."+member.name+":")
+                    code.append(self.tab*3+"l += i.length()")
+                else:
+                    pattern="!"+self.__c2py.get_pattern(member.object)
+                    size=self.__c2py.get_size(pattern)
+                    code.append(self.tab*2+"l += len(self."+member.name+")*"+str(size))
+        code.append(self.tab*2+"return l")
+        return code
+
+    def codeeq(self, struct_in):
+        """Return code to return equality comparisons
+        """
+        code = []
+        code.append(self.tab+"def __eq__(self, other):")
+        code.append(self.tab*2+"\"\"\"Return True if self and other have same values")
+        code.append(self.tab*2+"\"\"\"")
+        code.append(self.tab*2+"if type(self) != type(other): return False")
+        for member in struct_in.members:
+            code.append(self.tab*2 + "if self." + member.name + " !=  other." +
+                        member.name + ": return False")
+        code.append(self.tab*2+"return True")
+        code.append("")
+        code.append(self.tab+"def __ne__(self, other): return not self.__eq__(other)")
+        return code
+
+    def codeshow(self, struct_in):
+        """Return code to print basic members of structure
+        """
+        code = []
+        code.append(self.tab+"def show(self, prefix=''):")
+        code.append(self.tab*2+"\"\"\"" + "Print basic members of structure")
+        code.append(self.tab*2+"\"\"\"")
+        for member in struct_in.members:
+            if re.search('pad', member.name):
+                continue
+            elif (isinstance(member, cheader.cstruct)):
+                code.append(self.tab*2 + "print prefix + '" + 
+                            member.name + ": ' ")
+                code.append(self.tab*2 + "self." + member.name + 
+                            ".show(prefix + '  ')")
+            elif (isinstance(member, cheader.carray) and
+                  not isinstance(member.object, cheader.cprimitive)):
+                code.append(self.tab*2 + "print prefix + '" + member.name +
+                            ": ' ")
+                code.append(self.tab*2 + "for obj in self." + member.name + ":")
+                code.append(self.tab*3 + "obj.show(prefix + '  ')")
+            else:
+                code.append(self.tab*2 + "print prefix + '" + member.name +
+                            ": ' + str(self." + member.name + ")")
+        return code
+
+    def codeunpack(self, struct_in, prefix="!"):
+        """Return code that unpack struct
+        """
+        pattern = self.__c2py.get_pattern(struct_in)
+        structlen = self.__c2py.get_size(prefix + pattern)
+        code = []
+        code.append(self.tab+"def unpack(self, binaryString):")
+        code.append(self.tab*2+"\"\"\"Unpack message")
+        code.append(self.tab*2+"Do not unpack empty array used as placeholder")
+        code.append(self.tab*2+"since they can contain heterogeneous type")
+        code.append(self.tab*2+"\"\"\"")
+        code.append(self.tab*2+"if (len(binaryString) < "+str(structlen)+"):")
+        code.append(self.tab*3+"return binaryString")
+        offset = 0
+        primPattern = ""
+        primMemberNames = []
+        for member in struct_in.members:
+            if (isinstance(member, cheader.cprimitive)):
+                #Primitives
+                primPattern += self.__c2py.structmap[member.typename]
+                primMemberNames.append("self."+member.name)
+            else:
+                (primPattern, primMemberNames, offset) = \
+                              self.__codeunpackprimitive(code, offset, primPattern,
+                                                         primMemberNames, prefix)
+                if (isinstance(member, cheader.cstruct)):
+                    #Struct
+                    code.append(self.tab*2+"self."+member.name+\
+                                ".unpack(binaryString["+str(offset)+":])")
+                    pattern = self.__c2py.get_pattern(member)
+                    offset += self.__c2py.get_size(prefix+pattern)
+                elif (isinstance(member, cheader.carray) and member.typename == "char"):
+                    #String
+                    code.append(self.tab*2+"self."+member.name+\
+                                " = binaryString["+str(offset)+":"+\
+                                str(offset+member.size)+"].replace(\"\\0\",\"\")")
+                    offset += member.size
+                elif (isinstance(member, cheader.carray) and \
+                      isinstance(member.object, cheader.cprimitive)):
+                    #Array of Primitives
+                    expandedarr = ""
+                    if (member.size != 0):
+                        arrpattern = self.__c2py.structmap[member.object.typename]*member.size
+                        for x in range(0, member.size):
+                            expandedarr += "self."+member.name+"["+\
+                                           str(x).strip()+"], "
+                        code.append(self.tab*2+"("+expandedarr[:-2]+") = struct.unpack_from(\""+\
+                                    prefix+arrpattern+\
+                                    "\", binaryString, "+str(offset)+")")
+                        offset += struct.calcsize(prefix + arrpattern)
+                elif (isinstance(member, cheader.carray) and \
+                      isinstance(member.object, cheader.cstruct)):
+                    #Array of struct
+                    astructlen = self.__c2py.get_size("!"+self.__c2py.get_pattern(member.object))
+                    for x in range(0, member.size):
+                        code.append(self.tab*2+"self."+member.name+"["+str(x)+"]"+\
+                                ".unpack(binaryString["+str(offset)+":])")
+                        offset += astructlen
+        #Clear remaining fields
+        (primPattern, primMemberNames, offset) = \
+                      self.__codeunpackprimitive(code, offset, primPattern,
+                                                 primMemberNames, prefix)
+        code.append(self.tab*2+"return binaryString["+str(structlen)+":]");
+        return code
+
+    def __codeunpackprimitive(self, code, offset, primPattern,
+                              primMemberNames, prefix):
+        """Return code for unpacking primitives
+        """
+        if (primPattern != ""):
+            #Clear prior primitives
+            code.append(self.tab*2+"("+str(primMemberNames).replace("'","")[1:-1]+\
+                        ") = struct.unpack_from(\""+\
+                        prefix+primPattern+"\", binaryString, "+str(offset)+")")
+        return ("",[], offset+struct.calcsize(prefix+primPattern))
+
diff --git a/tools/pylibopenflow/pylib/lavi/__init__.py b/tools/pylibopenflow/pylib/lavi/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/pylibopenflow/pylib/lavi/__init__.py
diff --git a/tools/pylibopenflow/pylib/lavi/pythonize.py b/tools/pylibopenflow/pylib/lavi/pythonize.py
new file mode 100644
index 0000000..3c150aa
--- /dev/null
+++ b/tools/pylibopenflow/pylib/lavi/pythonize.py
@@ -0,0 +1,74 @@
+"""This module generate Python code for LAVI and messenger
+
+(C) Copyright Stanford University
+Date January 2010
+Created by ykk
+"""
+import cpythonize
+
+class msgrules(cpythonize.rules):
+    """Class that specify rules for pythonization of messenger
+
+    (C) Copyright Stanford University
+    Date January 2010
+    Created by ykk
+    """
+    def __init__(self):
+        """Initialize rules
+        """
+        cpythonize.rules.__init__(self)
+        ##Default values for members
+        #Default values for struct
+        ##Macros to exclude
+        self.excluded_macros = ['MESSAGE_HH__']
+        ##Enforce mapping
+        self.enforced_maps['messenger_msg'] = [ ('type','msg_type') ]
+
+class lavirules(msgrules):
+    """Class that specify rules for pythonization of LAVI messages
+
+    (C) Copyright Stanford University
+    Date January 2010
+    Created by ykk
+    """
+    def __init__(self, laviheader):
+        """Initialize rules
+        """
+        msgrules.__init__(self)
+        ##Default values for members
+        
+        #Default values for struct
+        self.struct_default[('lavi_poll_message',
+                             'header')] = ".type = "+str(laviheader.get_value('LAVIT_POLL'))
+        self.struct_default[('lavi_poll_stop_message',
+                             'header')] = ".type = "+str(laviheader.get_value('LAVIT_POLL_STOP'))
+        ##Macros to exclude
+        self.excluded_macros = ['LAVI_MSG_HH']
+        ##Enforce mapping
+        self.enforced_maps['lavi_header'] = [ ('type','lavi_type') ]
+
+class msgpythonizer(cpythonize.pythonizer):
+    """Class that pythonize C messenger messages
+
+    (C) Copyright Stanford University
+    Date January 2010
+    Created by ykk
+    """
+    def __init__(self, msgheader):
+        """Initialize
+        """
+        rules =  msgrules()
+        cpythonize.pythonizer.__init__(self, msgheader, rules)
+        
+class lavipythonizer(cpythonize.pythonizer):
+    """Class that pythonize C messenger messages
+
+    (C) Copyright Stanford University
+    Date December 2009
+    Created by ykk
+    """
+    def __init__(self, msgheader):
+        """Initialize
+        """
+        rules =  lavirules(msgheader)
+        cpythonize.pythonizer.__init__(self, msgheader, rules)
diff --git a/tools/pylibopenflow/pylib/of/__init__.py b/tools/pylibopenflow/pylib/of/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/pylibopenflow/pylib/of/__init__.py
diff --git a/tools/pylibopenflow/pylib/of/msg.py b/tools/pylibopenflow/pylib/of/msg.py
new file mode 100644
index 0000000..8617f56
--- /dev/null
+++ b/tools/pylibopenflow/pylib/of/msg.py
@@ -0,0 +1,117 @@
+"""This module parses OpenFlow packets.
+
+Unfortunately, this has to be updated manually for each OpenFlow version
+and packet type.  Ugly.
+
+(C) Copyright Stanford University
+Date October 2009
+Created by ykk
+"""
+class parser:
+    """Parser for  OpenFlow packets
+    
+    (C) Copyright Stanford University
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, messages):
+        """Initialize
+        """
+        ##Internal reference to OpenFlow messages
+        self.__messages = messages
+
+    def describe(self, packet):
+        """Parse OpenFlow packet and return string description
+        """
+        dic = self.__messages.peek_from_front("ofp_header", packet)
+        desc = self.header_describe(dic)
+        if (dic["type"][0] == self.__messages.get_value("OFPT_HELLO")):
+            pass
+        elif (dic["type"][0] == self.__messages.get_value("OFPT_SET_CONFIG")):
+            desc += "\n\t"+self.switch_config_describe(packet)
+        elif (dic["type"][0] == self.__messages.get_value("OFPT_FLOW_MOD")):
+            (fmdic, remaining) = self.__messages.unpack_from_front("ofp_flow_mod", packet)
+            desc += self.flow_mod_describe(fmdic, "\n\t")
+            desc += "\n\twith remaining "+str(len(remaining))+" bytes"
+        else:
+            desc += "\n\tUnparsed..."
+        return desc
+
+    def flow_mod_describe(self, packet, prefix=""):
+        """Parse flow mod and return description
+        """
+        dic = self.__assert_dic(packet, "ofp_flow_mod")
+        if (dic == None):
+            return ""
+        return prefix+\
+               "Flow_mod of command "+self.__messages.get_enum_name("ofp_flow_mod_command", dic["command"][0])+\
+               " idle/hard timeout:"+str(dic["idle_timeout"][0])+"/"+str(dic["hard_timeout"][0])+\
+               self.match_describe(dic, "match.", "\n\t")+\
+               prefix+\
+               "(priority:"+str(dic["priority"][0])+\
+               "/buffer id:"+str(dic["buffer_id"][0])+\
+               "/out port:"+str(dic["out_port"][0])+")"
+
+    def match_describe(self, dic, nameprefix="", prefix=""):
+        """Return description for ofp match
+        """
+        return prefix+"match wildcards:%x" % dic[nameprefix+"wildcards"][0]+\
+               " inport="+str(dic[nameprefix+"in_port"][0])+\
+               prefix+"     "+\
+               " ethertype="+str(dic[nameprefix+"dl_type"][0])+\
+               " vlan="+str(dic[nameprefix+"dl_vlan"][0])+\
+               " "+self.eth_describe(dic[nameprefix+"dl_src"])+"->"+\
+               self.eth_describe(dic[nameprefix+"dl_dst"])+\
+               prefix+"     "+\
+               " ipproto="+str(dic[nameprefix+"nw_proto"][0])+\
+               " "+self.ip_describe(dic[nameprefix+"nw_src"][0])+\
+               "->"+self.ip_describe(dic[nameprefix+"nw_src"][0])+\
+               prefix+"     "+\
+               " transport "+str(dic[nameprefix+"tp_src"][0])+\
+               "->"+str(dic[nameprefix+"tp_dst"][0])
+               
+    def switch_config_describe(self, packet):
+        """Parse OpenFlow switch config and return description
+        """
+        dic = self.__assert_dic(packet, "ofp_switch_config")
+        if (dic == None):
+            return ""
+        return "with flag "+str(self.__messages.get_enum_name("ofp_config_flags", dic["flags"][0]))+\
+               " and miss send length "+str(dic["miss_send_len"][0])
+        
+    def header_describe(self, packet):
+        """Parse OpenFlow header and return string description
+        """
+        dic = self.__assert_dic(packet, "ofp_header")
+        if (dic == None):
+            return ""
+        return self.__messages.get_enum_name("ofp_type", dic["type"][0])+" packet "+\
+               "(length:"+str(dic["length"][0])+\
+               "/xid:"+str(dic["xid"][0])+")"
+
+    def ip_describe(self, value):
+        """Return string for ip address
+        """
+        desc = ""
+        for i in range(0,4):
+            (value, cv) = divmod(value, 256)
+            desc = str(cv).strip() +"." + desc
+        return desc
+    
+    def eth_describe(self, etheraddr):
+        """Return string for ethernet address
+        """
+        desc = ""
+        for value in etheraddr:
+            desc += ":"+("%x" % value).zfill(2)
+        return desc[1:]
+
+    def __assert_dic(self, packet, typename):
+        """Assert and ensure dictionary is given
+        """
+        dic = None
+        if (isinstance(packet, str)):
+            dic = self.__messages.peek_from_front(typename, packet)
+        elif (isinstance(packet, dict)):
+            dic = packet
+        return dic
diff --git a/tools/pylibopenflow/pylib/of/network.py b/tools/pylibopenflow/pylib/of/network.py
new file mode 100644
index 0000000..6765a12
--- /dev/null
+++ b/tools/pylibopenflow/pylib/of/network.py
@@ -0,0 +1,191 @@
+"""This module holds the network.
+
+Copyright(C) 2009, Stanford University
+Date October 2009
+Created by ykk
+"""
+import random
+import openflow
+
+class network:
+    """Class holding information about OpenFlow network
+    """
+    def __init__(self):
+        """Initialize
+        """
+        ##List of switches
+        self.switches = []
+        ##Dictionary of links
+        self.links = {}
+        ##Reference to connections
+        self.connections = openflow.connections()
+
+    def add_switch(self, sw):
+        """Add switch to network
+        """
+        self.switches.append(sw)
+        self.connections.add_connection(sw, sw.connection)
+
+    def add_link(self, link):
+        """Add link to network
+        """
+        try:
+            self.links[link.switch1,link.switch2].append(link)
+        except KeyError:
+            self.links[link.switch1,link.switch2] = []
+            self.links[link.switch1,link.switch2].append(link)
+
+class link:
+    """Class to hold information about link
+
+    Copyright(C) 2009, Stanford University
+    Date November 2009
+    Created by ykk
+    """
+    def __init__(self, switch1, switch2):
+        """Initialize link between specified switches
+        """
+        ##Reference to first switch
+        self.switch1 = switch1
+        ##Reference to second switch
+        self.switch2 = switch2
+
+class switch:
+    """Class holding information about OpenFlow switch
+
+    Copyright(C) 2009, Stanford University
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, miss_send_len=128,
+                 sock=None, dpid=None, n_buffers=100, n_tables=1,
+                 capability=None):
+        """Initialize switch
+        """
+        ##Socket to controller
+        self.sock = sock
+        ##Datapath id of switch
+        if (dpid != None):
+            self.datapath_id = dpid
+        else:
+            self.datapath_id = random.randrange(1, pow(2,64))
+        ##Number of buffers
+        self.n_buffers = n_buffers
+        ##Number of tables
+        self.n_tables= n_tables
+        ##Capabilities
+        if (isinstance(capability, switch_capabilities)):
+            self.capability = capability
+        else:
+            self.capability = switch_capabilities(miss_send_len)
+        ##Valid Actions
+        self.valid_actions = 0
+        ##List of port
+        self.port = []
+
+class switch_capabilities:
+    """Class to hold switch capabilities
+    """
+    def __init__(self, miss_send_len=128):
+        """Initialize
+
+        Copyright(C) 2009, Stanford University
+        Date October 2009
+        Created by ykk
+        """
+        ##Capabilities support by datapath
+        self.flow_stats = True
+        self.table_stats = True
+        self.port_stats = True
+        self.stp = True
+        self.multi_phy_tx = True
+        self.ip_resam = False
+        ##Switch config
+        self.send_exp = None
+        self.ip_frag = 0
+        self.miss_send_len = miss_send_len
+        ##Valid actions
+        self.act_output = True
+        self.act_set_vlan_vid = True
+        self.act_set_vlan_pcp = True
+        self.act_strip_vlan = True
+        self.act_set_dl_src = True
+        self.act_set_dl_dst = True
+        self.act_set_nw_src = True
+        self.act_set_nw_dst = True
+        self.act_set_tp_src = True
+        self.act_set_tp_dst = True
+        self.act_vendor = False
+
+    def get_capability(self, ofmsg):
+        """Return value for uint32_t capability field
+        """
+        value = 0
+        if (self.flow_stats):
+            value += ofmsg.get_value("OFPC_FLOW_STATS")
+        if (self.table_stats):
+            value += ofmsg.get_value("OFPC_TABLE_STATS")
+        if (self.port_stats):
+            value += ofmsg.get_value("OFPC_PORT_STATS")
+        if (self.stp):
+            value += ofmsg.get_value("OFPC_STP")
+        if (self.multi_phy_tx):
+            value += ofmsg.get_value("OFPC_MULTI_PHY_TX")
+        if (self.ip_resam):
+            value += ofmsg.get_value("OFPC_IP_REASM")
+        return value
+
+    def get_actions(self, ofmsg):
+        """Return value for uint32_t action field
+        """
+        value = 0
+        if (self.act_output):
+            value += (1 << (ofmsg.get_value("OFPAT_OUTPUT")+1))
+        if (self.act_set_vlan_vid):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_VLAN_VID")+1))
+        if (self.act_set_vlan_pcp):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_VLAN_PCP")+1))
+        if (self.act_strip_vlan):
+            value += (1 << (ofmsg.get_value("OFPAT_STRIP_VLAN")+1))
+        if (self.act_set_dl_src):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_DL_SRC")+1))
+        if (self.act_set_dl_dst):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_DL_DST")+1))
+        if (self.act_set_nw_src):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_NW_SRC")+1))
+        if (self.act_set_nw_dst):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_NW_DST")+1))
+        if (self.act_set_tp_src):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_TP_SRC")+1))
+        if (self.act_set_tp_dst):
+            value += (1 << (ofmsg.get_value("OFPAT_SET_TP_DST")+1))
+        return value
+
+class port:
+    """Class to hold information about port
+    
+    Copyright(C) 2009, Stanford University
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, port_no, stp=(2 << 8), hw_addr=None, name=""):
+        """Initialize
+        """
+        ##Port properties
+        self.port_no = port_no
+        if (hw_addr != None):
+            self.hw_addr = hw_addr
+        else:
+            self.hw_addr = random.randrange(1, pow(2,48))
+        self.name = name
+        ##Port config
+        self.port_down = False
+        self.no_stp = False
+        self.no_recv = False
+        self.no_recv_stp = False
+        self.no_flood = False
+        self.no_fwd = False
+        self.no_packet_in = False
+        #Port state
+        self.link_down = False
+        self.stp = stp
diff --git a/tools/pylibopenflow/pylib/of/pythonize.py b/tools/pylibopenflow/pylib/of/pythonize.py
new file mode 100644
index 0000000..687512b
--- /dev/null
+++ b/tools/pylibopenflow/pylib/of/pythonize.py
@@ -0,0 +1,57 @@
+"""This module generate Python code for OpenFlow structs.
+
+(C) Copyright Stanford University
+Date December 2009
+Created by ykk
+"""
+import cpythonize
+from config import *
+
+class rules(cpythonize.rules):
+    """Class that specify rules for pythonization of OpenFlow messages
+
+    (C) Copyright Stanford University
+    Date December 2009
+    Created by ykk
+    """
+    def __init__(self, ofmsg):
+        """Initialize rules
+        """
+        cpythonize.rules.__init__(self)
+        ##Reference to ofmsg
+        self.__ofmsg = ofmsg
+        ##Default values for members
+        self.default_values[('ofp_header','version')] = self.__ofmsg.get_value('OFP_VERSION')
+        self.default_values[('ofp_switch_config',\
+                             'miss_send_len')] = self.__ofmsg.get_value('OFP_DEFAULT_MISS_SEND_LEN')
+        for x in ['ofp_flow_mod','ofp_flow_expired','ofp_flow_stats']:
+            self.default_values[(x,'priority')] = self.__ofmsg.get_value('OFP_DEFAULT_PRIORITY')
+        #Default values for struct
+        self.struct_default[('ofp_flow_mod',
+                             'header')] = ".type = OFPT_FLOW_MOD"
+#                             'header')] = ".type = "+str(self.__ofmsg.get_value('OFPT_FLOW_MOD'))
+        ##Macros to exclude
+        self.excluded_macros = ['OFP_ASSERT(EXPR)','OFP_ASSERT(_EXPR)','OFP_ASSERT',
+                                'icmp_type','icmp_code','OFP_PACKED',
+                                'OPENFLOW_OPENFLOW_H']
+        ##Enforce mapping
+        if GEN_ENUM_VALUES_LIST:
+            self.enforced_maps['ofp_header'] = [ ('type','ofp_type_values') ]
+        elif GEN_ENUM_DICTIONARY:
+            self.enforced_maps['ofp_header'] = \
+                [ ('type','ofp_type_map.values()') ]
+        
+class pythonizer(cpythonize.pythonizer):
+    """Class that pythonize C structures of OpenFlow messages
+
+    (C) Copyright Stanford University
+    Date December 2009
+    Created by ykk
+    """
+    def __init__(self, ofmsg):
+        """Initialize
+        """
+        ofrules =  rules(ofmsg)
+        cpythonize.pythonizer.__init__(self, ofmsg, ofrules)
+        ##Reference to OpenFlow message class
+        self.__ofmsg = ofmsg
diff --git a/tools/pylibopenflow/pylib/of/simu.py b/tools/pylibopenflow/pylib/of/simu.py
new file mode 100644
index 0000000..508b076
--- /dev/null
+++ b/tools/pylibopenflow/pylib/of/simu.py
@@ -0,0 +1,144 @@
+"""This module simulates the network.
+
+Copyright(C) 2009, Stanford University
+Date November 2009
+Created by ykk
+"""
+import openflow
+import output
+import of.msg
+import of.network
+
+class network(of.network.network):
+    """Class to simulate OpenFlow network
+
+    Copyright(C) 2009, Stanford University
+    Date November 2009
+    Created by ykk
+    """
+    def __init__(self):
+        """Initialize network
+        """
+        of.network.network.__init__(self)
+        ##Name of use for output
+        self.name = self.__class__.__name__+str(id(self))
+
+class link(of.network.link):
+    """Class to simulate link
+
+    Copyright(C) 2009, Stanford University
+    Date November 2009
+    Created by ykk
+    """
+    def __init__(self, switch1, switch2, isUp=True):
+        """Initialize link
+        """
+        of.network.link.__init__(self, switch1, switch2)
+        ##Name of use for output
+        self.name = self.__class__.__name__+str(id(self))
+        ##Indicate if link is up
+        self.isUp = isUp
+
+class switch(of.network.switch):
+    """Class to simulate OpenFlow switch
+
+    Copyright(C) 2009, Stanford University
+    Date November 2009
+    Created by ykk
+    """
+    def __init__(self,  messages, controller, port, miss_send_len=128,
+                 dpid=None, n_buffers=100, n_tables=1,
+                 capability=None, parser=None, connection=None):
+        """Initialize switch
+        """
+        of.network.switch.__init__(self,  miss_send_len,
+                                   None, dpid, n_buffers, n_tables,
+                                   capability)
+        ##Name of use for output
+        self.name = self.__class__.__name__+str(id(self))
+        ##Reference to OpenFlow messages
+        self.__messages = messages
+        ##Reference to connection
+        self.connection = openflow.tcpsocket(messages, controller, port)
+        self.sock = self.connection.sock
+        ##Reference to Parser
+        self.parser = None
+        if (parser == None):
+            self.parser = of.msg.parser(messages)
+        else:
+            self.parser = parser
+
+    def receive_openflow(self, packet):
+        """Switch receive OpenFlow packet, and respond accordingly
+        """
+        dic = self.__messages.peek_from_front("ofp_header", packet)
+        if (dic["type"][0] == self.__messages.get_value("OFPT_HELLO")):
+            output.dbg("Receive hello", self.name)
+        elif (dic["type"][0] == self.__messages.get_value("OFPT_ECHO_REQUEST")):
+            self.reply_echo(dic["xid"][0])
+        elif (dic["type"][0] == self.__messages.get_value("OFPT_FEATURES_REQUEST")):
+            self.reply_features(dic["xid"][0])
+        elif (dic["type"][0] == self.__messages.get_value("OFPT_FLOW_MOD")):
+            self.handle_flow_mod(packet)
+        else:
+            output.dbg("Unprocessed message "+self.parser.header_describe(dic),
+                       self.name)
+
+    def send_hello(self):
+        """Send hello
+        """
+        self.connection.structsend("ofp_hello",
+                                   0, self.__messages.get_value("OFPT_HELLO"),
+                                   0, 0)
+        output.dbg("Send hello",self.name)
+
+    def send_packet(self, inport, bufferid=None, packet="", xid=0, reason=None):
+        """Send packet in
+        Assume no match as reason, bufferid = 0xFFFFFFFF,
+        and empty packet by default
+        """
+        if (reason == None):
+            reason = self.__messages.get_value("OFPR_NO_MATCH")
+        if (bufferid == None):
+            bufferid = int("0xFFFFFFFF",16)
+        pktin = self.__messages.pack("ofp_packet_in",
+                                     0, self.__messages.get_value("OFPT_PACKET_IN"),
+                                     0, xid, #header
+                                     bufferid, len(packet),
+                                     inport, reason, 0)
+        self.connection.structsend_raw(pktin+packet)
+        output.dbg("Send packet ",self.name)
+
+    def send_echo(self, xid=0):
+        """Send echo
+        """
+        self.connection.structsend_xid("ofp_header",
+                                       0, self.__messages.get_value("OFPT_ECHO_REQUEST"),
+                                       0, xid)
+        output.dbg("Send echo", self.name)
+
+    def reply_echo(self, xid):
+        """Reply to echo request
+        """
+        self.connection.structsend_xid("ofp_header",
+                                       0, self.__messages.get_value("OFPT_ECHO_REPLY"),
+                                       0, xid)                                 
+        output.dbg("Reply echo of xid:"+str(xid),self.name)
+
+    def reply_features(self, xid):
+        """Reply to feature request
+        """
+        self.connection.structsend_xid("ofp_switch_features",
+                                       0, self.__messages.get_value("OFPT_FEATURES_REPLY"),
+                                       0, xid,
+                                       self.datapath_id, self.n_buffers,
+                                       self.n_tables,0,0,0,
+                                       self.capability.get_capability(self.__messages),
+                                       self.capability.get_actions(self.__messages))
+        output.dbg("Replied features request of xid "+str(xid), self.name)
+        
+    def handle_flow_mod(self, packet):
+        """Handle flow mod: just print it here
+        """
+        output.dbg(self.parser.flow_mod_describe(packet), self.name)
+        
diff --git a/tools/pylibopenflow/pylib/openflow.py b/tools/pylibopenflow/pylib/openflow.py
new file mode 100644
index 0000000..25945b9
--- /dev/null
+++ b/tools/pylibopenflow/pylib/openflow.py
@@ -0,0 +1,336 @@
+"""This module exports OpenFlow protocol to Python.
+
+(C) Copyright Stanford University
+Date October 2009
+Created by ykk
+"""
+import c2py
+import cheader
+import os
+import socket
+import select
+import struct
+import time
+
+class messages(cheader.cheaderfile,c2py.cstruct2py,c2py.structpacker):
+    """Class to handle OpenFlow messages
+
+    (C) Copyright Stanford University
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, openflow_headerfile=None):
+        """Initialize with OpenFlow header file
+
+        If filename is not provided, check the environment
+        variable PYLIB_OPENFLOW_HEADER and search for openflow.h
+        """
+        if (openflow_headerfile != None):
+            cheader.cheaderfile.__init__(self, openflow_headerfile)
+        else:
+            #Check environment variable
+            path = os.getenv("PYLIB_OPENFLOW_HEADER")
+            if not path:
+                print "PYLIB_OPENFLOW_HEADER is not set in environment"
+                sys.exit(2)
+            cheader.cheaderfile.__init__(self, path+"/openflow.h")
+        #Initialize cstruct2py
+        c2py.cstruct2py.__init__(self)
+        #Initalize packet
+        c2py.structpacker.__init__(self, "!")
+        ##Cached patterns
+        self.patterns={}
+        for (cstructname, cstruct) in self.structs.items():
+            self.patterns[cstructname] = self.get_pattern(cstruct)
+
+    def get_size(self, ctype):
+        """Get size for ctype or name of type.
+        Return None if ctype is not expanded or
+        type with name is not found.
+        """
+        pattern = self.get_pattern(ctype)
+        if (pattern != None):
+            return c2py.cstruct2py.get_size(self,pattern)
+    
+    def get_pattern(self,ctype):
+        """Get pattern string for ctype or name of type.
+        Return None if ctype is not expanded or
+        type with name is not found.
+        """
+        if (isinstance(ctype, str)):
+            #Is name
+            return self.patterns[ctype]
+        else:
+            return c2py.cstruct2py.get_pattern(self, ctype)
+        
+    def pack(self, ctype, *arg):
+        """Pack packet accordingly ctype or name of type provided.
+        Return struct packed.
+        """
+        if (isinstance(ctype, str)):
+            return struct.pack(self.prefix+self.patterns[ctype], *arg)
+        else:
+            return c2py.structpacker.pack(self, ctype, *arg)
+
+    def peek_from_front(self, ctype, binaryString, returnDictionary=True):
+        """Unpack packet using front of the packet,
+        accordingly ctype or name of ctype provided.
+
+        Return dictionary of values indexed by arg name, 
+        if ctype is known struct/type and returnDictionary is True,
+        else return array of data unpacked.
+        """
+        if (isinstance(ctype,str)):
+            data = c2py.structpacker.peek_from_front(self,
+                                                     self.patterns[ctype],
+                                                     binaryString,
+                                                     returnDictionary)
+            return self.data2dic(self.structs[ctype], data)
+        else:
+            return c2py.structpacker.peek_from_front(self,
+                                                     ctype,
+                                                     binaryString,
+                                                     returnDictionary)
+        
+    def unpack_from_front(self, ctype, binaryString, returnDictionary=True):
+        """Unpack packet using front of packet,
+        accordingly ctype or name of ctype provided.
+
+        Return (dictionary of values indexed by arg name, 
+        remaining binary string) if ctype is known struct/type
+        and returnDictionary is True,
+        else return (array of data unpacked, remaining binary string).
+        """
+        if (isinstance(ctype,str)):
+            (data, remaining) = c2py.structpacker.unpack_from_front(self,
+                                                                    self.patterns[ctype],
+                                                                    binaryString,
+                                                                    returnDictionary)
+            return (self.data2dic(self.structs[ctype], data), remaining)
+        else:
+            return c2py.structpacker.unpack_from_front(self,
+                                                       ctype,
+                                                       binaryString,
+                                                       returnDictionary)
+
+class connection:
+    """Class to hold a connection.
+
+    (C) Copyright Stanford University
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, messages, sock=None):
+        """Initialize
+        """
+        ##Reference to socket
+        self.sock = sock
+        ##Internal reference to OpenFlow messages
+        self._messages = messages
+        ##Buffer
+        self.buffer = ""
+        ##Header length for OpenFlow
+        self.__header_length = self._messages.get_size("ofp_header")
+
+    def send(self, msg):
+        """Send bare message (given as binary string)
+        """
+        raise NotImplementedError()
+
+    def structsend(self, ctype, *arg):
+        """Build and send message.
+        """
+        self.send(self._messages.pack(ctype, *arg))
+
+    def receive(self, maxlength=1024):
+       """Receive raw in non-blocking way.
+
+       Return buffer
+       """
+       if (select.select([self.sock],[],[],0)[0]):
+           self.buffer += self.sock.recv(maxlength)
+       return self.buffer
+
+    def buffer_has_msg(self):
+        """Check if buffer has a complete message
+        """
+        #Check at least ofp_header is received
+        if (len(self.buffer) < self.__header_length):
+            return False
+        values = self._messages.peek_from_front("ofp_header", self.buffer)
+        return (len(self.buffer) >= values["length"][0])
+
+    def get_msg(self):
+        """Get message from current buffer
+        """
+        if (self.buffer_has_msg()):
+            values = self._messages.peek_from_front("ofp_header", self.buffer)
+            msg = self.buffer[:values["length"][0]]
+            self.buffer = self.buffer[values["length"][0]:]
+            return msg
+        else:
+            return None
+
+    def msgreceive(self, blocking=False, pollInterval=0.001):
+        """Receive OpenFlow message.
+
+        If non-blocking, can return None.
+        """
+        self.receive()
+        if (self.buffer_has_msg()):
+            return self.get_msg()
+        if (blocking):
+            while (not self.buffer_has_msg()):
+                time.sleep(pollInterval)
+                self.receive()
+        return self.get_msg()
+
+class safeconnection(connection):
+    """OpenFlow connection with safety checks
+    
+    (C) Copyright Stanford University
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, messages, sock=None, version=None,
+                 xidstart = 0, autoxid=True):
+        """Initialize with OpenFlow version.
+        """
+        connection.__init__(self, messages, sock)
+        ##OpenFlow version
+        if (version != None):
+            self.version = version
+        else:
+            self.version = messages.get_value("OFP_VERSION")
+        ##xid Counter
+        self.nextxid = xidstart
+        ##Automatic xid
+        self.autoxid = autoxid
+        ##Miss auto xid
+        self.skipautoxid = 0
+
+    def skip_auto_xid(self, n):
+        """Miss automatic xid for the next n packets
+        """
+        self.skipautoxid = n
+
+    def structsend_xid(self, ctype, *arg):
+        """Build and send message, populating header automatically.
+        Type and xid of message is not populated.
+        """
+        self.skipautoxid+=1
+        self.structsend(ctype, *arg)
+
+    def structsend(self, ctype, *arg):
+        """Build and send message, populating header automatically.
+        Type of message is not populated
+        """
+        msg = self._messages.pack(ctype, *arg)
+        self.structsend_raw(msg)
+        
+    def structsend_raw(self, msg):
+        """Check ofp_header and ensure correctness before sending.
+        """
+        (dic, remaining) = self._messages.unpack_from_front("ofp_header", msg)
+        #Amend header
+        if (self.version != None):
+            dic["version"][0] = self.version
+        if (self.autoxid and (self.skipautoxid == 0)):
+            dic["xid"][0] = self.nextxid
+            self.nextxid+=1
+        if (self.skipautoxid != 0):
+            self.skipautoxid-=1
+        dic["length"][0] = len(remaining)+8
+        #Send message
+        self.send(self._messages.pack("ofp_header",
+                                      dic["version"][0],
+                                      dic["type"][0],
+                                      dic["length"][0],
+                                      dic["xid"][0])+\
+                  remaining)
+
+class tcpsocket(safeconnection):
+    """Class to hold connection
+
+    (C) Copyright Stanford University
+    Date October 2009
+    Created by ykk
+    """
+    def __init__(self, messages, host, port):
+        """Initialize TCP socket to host and port
+        """
+        safeconnection.__init__(self, messages)
+        ##Reference to socket
+        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.sock.connect((host, port))
+        self.sock.setblocking(False)
+        self.sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 0)
+
+    def __del__(self):
+        """Terminate connection
+        """
+        self.sock.shutdown(1)
+        self.sock.close()
+
+    def send(self, msg):
+        """Send raw message (binary string)
+        """
+        self.sock.sendall(msg)
+
+class connections:
+    """Class to hold multiple connections
+    
+    (C) Copyright Stanford University
+    Date November 2009
+    Created by ykk
+    """
+    def __init__(self):
+        """Initialize
+        """
+        ##List of sockets
+        self.__sockets = []
+        ##Dicionary of sockets to connection
+        self.__connections = {}
+        
+    def add_connection(self, reference, connect):
+        """Add connection with opaque reference object
+        """
+        if (not isinstance(connect,connection)): 
+            raise RuntimeError("Connection must be openflow.connection!")
+        self.__sockets.append(connect.sock)
+        self.__connections[connect.sock] = (reference, connect)
+
+    def receive(self, maxlength=1024):
+        """Receive raw in non-blocking way
+        """
+        read_ready = select.select(self.__sockets,[],[],0)[0]
+        for sock in read_ready:
+            self.__connections[sock][1].receive(maxlength)
+        
+    def has_msg(self):
+        """Check if any of the connections has a message
+
+        Return (reference,connection) with message
+        """
+        for sock, refconnect in self.__connections.items():
+            if (refconnect[1].buffer_has_msg()):
+                return refconnect
+        return None
+
+    def msgreceive(self, blocking=False, pollInterval=0.001):
+        """Receive OpenFlow message.
+
+        If non-blocking, can return None.
+        """
+        self.receive()
+        c = self.has_msg()
+        if (c != None):
+            return (c[0],c[1].get_msg())
+        if (blocking):
+            while (c == None):
+                time.sleep(pollInterval)
+                self.receive()
+                c = self.has_msg()
+        else:
+            return (None, None)
+        return (c[0],c[1].get_msg())
diff --git a/tools/pylibopenflow/pylib/output.py b/tools/pylibopenflow/pylib/output.py
new file mode 100644
index 0000000..64df4f5
--- /dev/null
+++ b/tools/pylibopenflow/pylib/output.py
@@ -0,0 +1,85 @@
+"""This module implements output printing.
+
+Output are divided into 4 levels and
+can be configured for different verbosity
+
+Copyright(C) 2009, Stanford University
+Date August 2009
+Created by ykk
+"""
+
+##Various output modes
+MODE = {}
+MODE["ERR"] = 0
+MODE["WARN"] = 1
+MODE["INFO"] = 2
+MODE["DBG"] = 3
+
+#Global mode
+global output_mode
+output_mode = None
+
+def set_mode(msg_mode, who=None):
+    """Set the message mode for who
+    If who is None, set global mode
+    """
+    global output_mode
+    if (output_mode == None):
+        output_mode = {}
+        output_mode["global"] = MODE["WARN"]
+        output_mode["DBG"] = []
+        output_mode["INFO"] = []
+        output_mode["WARN"] = []
+
+    #Set global mode
+    if (who == None):
+        output_mode["global"] = MODE[msg_mode]
+        return
+    
+    #Individual mode
+    if (msg_mode == "ERR"):
+        return
+    for mode in ["WARN","INFO","DBG"]:
+        if (not (who in mode[mode])):
+            mode[mode].append(who)
+        if (msg_mode == mode):
+            return
+    
+def output(msg_mode, msg, who=None):
+    """Print message
+    """
+    global output_mode
+    if (output_mode == None):
+        raise RuntimeException("Output mode is not set")
+
+    #Indicate who string
+    if (who == None):
+        whostr = ""
+    else:
+        whostr = who+":"
+
+    #Print output 
+    if (MODE[msg_mode] <= output_mode["global"]):
+        print msg_mode.ljust(4, ' ')+"|"+whostr+msg
+    elif (who in output_mode[msg_mode]):
+        print msg_mode.ljust(4, ' ')+"|"+whostr+msg
+        
+def err(msg, who=None):
+    """Print error messages
+    """
+    output("ERR", msg, who)
+
+def warn(msg, who=None):
+    """Print warning messages
+    """
+    output("WARN", msg, who)
+
+def info(msg, who=None):
+    """Print informational messages
+    """
+    output("INFO", msg, who)
+
+def dbg(msg, who=None):
+    """Print debug messages
+    """
+    output("DBG", msg, who)