Permalink
Browse files

Move OFPC_* and OFPAT_* constants into Trema::

  • Loading branch information...
yasuhito committed Apr 3, 2012
1 parent 531adb3 commit f759cc79212b2f0cc8de120525888c8eab3781c1
Showing with 79 additions and 45 deletions.
  1. +0 −23 ruby/trema/controller.c
  2. +23 −0 ruby/trema/trema.c
  3. +0 −22 spec/trema/controller_spec.rb
  4. +56 −0 spec/trema_spec.rb
View
@@ -544,29 +544,6 @@ Init_controller() {
rb_define_const( cController, "OFPP_LOCAL", INT2NUM( OFPP_LOCAL ) );
rb_define_const( cController, "OFPP_NONE", INT2NUM( OFPP_NONE ) );
- rb_define_const( cController, "OFPC_FLOW_STATS", INT2NUM( OFPC_FLOW_STATS ) );
- rb_define_const( cController, "OFPC_TABLE_STATS", INT2NUM( OFPC_TABLE_STATS ) );
- rb_define_const( cController, "OFPC_PORT_STATS", INT2NUM( OFPC_PORT_STATS ) );
- rb_define_const( cController, "OFPC_STP", INT2NUM( OFPC_STP) );
- rb_define_const( cController, "OFPC_RESERVED", INT2NUM( OFPC_RESERVED ) );
- rb_define_const( cController, "OFPC_IP_REASM", INT2NUM( OFPC_IP_REASM ) );
- rb_define_const( cController, "OFPC_QUEUE_STATS", INT2NUM( OFPC_QUEUE_STATS ) );
- rb_define_const( cController, "OFPC_ARP_MATCH_IP", INT2NUM( OFPC_ARP_MATCH_IP ) );
-
- rb_define_const( cController, "OFPAT_OUTPUT", INT2NUM( OFPAT_OUTPUT ) );
- rb_define_const( cController, "OFPAT_SET_VLAN_VID", INT2NUM( OFPAT_SET_VLAN_VID ) );
- rb_define_const( cController, "OFPAT_SET_VLAN_PCP", INT2NUM( OFPAT_SET_VLAN_PCP ) );
- rb_define_const( cController, "OFPAT_STRIP_VLAN", INT2NUM( OFPAT_STRIP_VLAN ) );
- rb_define_const( cController, "OFPAT_SET_DL_SRC", INT2NUM( OFPAT_SET_DL_SRC) );
- rb_define_const( cController, "OFPAT_SET_DL_DST", INT2NUM( OFPAT_SET_DL_DST) );
- rb_define_const( cController, "OFPAT_SET_NW_SRC", INT2NUM( OFPAT_SET_NW_SRC ) );
- rb_define_const( cController, "OFPAT_SET_NW_DST", INT2NUM( OFPAT_SET_NW_DST ) );
- rb_define_const( cController, "OFPAT_SET_NW_TOS", INT2NUM( OFPAT_SET_NW_TOS ) );
- rb_define_const( cController, "OFPAT_SET_TP_SRC", INT2NUM( OFPAT_SET_TP_SRC ) );
- rb_define_const( cController, "OFPAT_SET_TP_DST", INT2NUM( OFPAT_SET_TP_DST ) );
- rb_define_const( cController, "OFPAT_ENQUEUE", INT2NUM( OFPAT_ENQUEUE ) );
- rb_define_const( cController, "OFPAT_VENDOR", INT2NUM( OFPAT_VENDOR ) );
-
rb_define_method( cController, "send_message", controller_send_message, 2 );
rb_define_method( cController, "send_list_switches_request", controller_send_list_switches_request, 0 );
rb_define_method( cController, "send_flow_mod_add", controller_send_flow_mod_add, -1 );
View
@@ -69,6 +69,29 @@ void
Init_trema() {
mTrema = rb_define_module( "Trema" );
+ rb_define_const( mTrema, "OFPC_FLOW_STATS", INT2NUM( OFPC_FLOW_STATS ) );
+ rb_define_const( mTrema, "OFPC_TABLE_STATS", INT2NUM( OFPC_TABLE_STATS ) );
+ rb_define_const( mTrema, "OFPC_PORT_STATS", INT2NUM( OFPC_PORT_STATS ) );
+ rb_define_const( mTrema, "OFPC_STP", INT2NUM( OFPC_STP) );
+ rb_define_const( mTrema, "OFPC_RESERVED", INT2NUM( OFPC_RESERVED ) );
+ rb_define_const( mTrema, "OFPC_IP_REASM", INT2NUM( OFPC_IP_REASM ) );
+ rb_define_const( mTrema, "OFPC_QUEUE_STATS", INT2NUM( OFPC_QUEUE_STATS ) );
+ rb_define_const( mTrema, "OFPC_ARP_MATCH_IP", INT2NUM( OFPC_ARP_MATCH_IP ) );
+
+ rb_define_const( mTrema, "OFPAT_OUTPUT", INT2NUM( OFPAT_OUTPUT ) );
+ rb_define_const( mTrema, "OFPAT_SET_VLAN_VID", INT2NUM( OFPAT_SET_VLAN_VID ) );
+ rb_define_const( mTrema, "OFPAT_SET_VLAN_PCP", INT2NUM( OFPAT_SET_VLAN_PCP ) );
+ rb_define_const( mTrema, "OFPAT_STRIP_VLAN", INT2NUM( OFPAT_STRIP_VLAN ) );
+ rb_define_const( mTrema, "OFPAT_SET_DL_SRC", INT2NUM( OFPAT_SET_DL_SRC) );
+ rb_define_const( mTrema, "OFPAT_SET_DL_DST", INT2NUM( OFPAT_SET_DL_DST) );
+ rb_define_const( mTrema, "OFPAT_SET_NW_SRC", INT2NUM( OFPAT_SET_NW_SRC ) );
+ rb_define_const( mTrema, "OFPAT_SET_NW_DST", INT2NUM( OFPAT_SET_NW_DST ) );
+ rb_define_const( mTrema, "OFPAT_SET_NW_TOS", INT2NUM( OFPAT_SET_NW_TOS ) );
+ rb_define_const( mTrema, "OFPAT_SET_TP_SRC", INT2NUM( OFPAT_SET_TP_SRC ) );
+ rb_define_const( mTrema, "OFPAT_SET_TP_DST", INT2NUM( OFPAT_SET_TP_DST ) );
+ rb_define_const( mTrema, "OFPAT_ENQUEUE", INT2NUM( OFPAT_ENQUEUE ) );
+ rb_define_const( mTrema, "OFPAT_VENDOR", INT2NUM( OFPAT_VENDOR ) );
+
rb_require( "trema/host" );
rb_require( "trema/openflow-switch" );
rb_require( "trema/path" );
@@ -36,28 +36,6 @@ module Trema
it { should include "OFPP_CONTROLLER" }
it { should include "OFPP_LOCAL" }
it { should include "OFPP_NONE" }
-
- it { should include "OFPC_FLOW_STATS" }
- it { should include "OFPC_TABLE_STATS" }
- it { should include "OFPC_PORT_STATS" }
- it { should include "OFPC_STP" }
- it { should include "OFPC_RESERVED" }
- it { should include "OFPC_IP_REASM" }
- it { should include "OFPC_QUEUE_STATS" }
- it { should include "OFPC_ARP_MATCH_IP" }
-
- it { should include "OFPAT_OUTPUT" }
- it { should include "OFPAT_SET_VLAN_VID" }
- it { should include "OFPAT_SET_VLAN_PCP" }
- it { should include "OFPAT_STRIP_VLAN" }
- it { should include "OFPAT_SET_DL_SRC" }
- it { should include "OFPAT_SET_DL_DST" }
- it { should include "OFPAT_SET_NW_SRC" }
- it { should include "OFPAT_SET_NW_DST" }
- it { should include "OFPAT_SET_NW_TOS" }
- it { should include "OFPAT_SET_TP_DST" }
- it { should include "OFPAT_ENQUEUE" }
- it { should include "OFPAT_VENDOR" }
end
View
@@ -0,0 +1,56 @@
+#
+# Author: Yasuhito Takamiya <yasuhito@gmail.com>
+#
+# Copyright (C) 2008-2012 NEC Corporation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License, version 2, as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+
+require File.join( File.dirname( __FILE__ ), "spec_helper" )
+require "trema"
+
+
+describe Trema, ".constants" do
+ subject { Trema.constants }
+
+ it { should include "OFPC_FLOW_STATS" }
+ it { should include "OFPC_TABLE_STATS" }
+ it { should include "OFPC_PORT_STATS" }
+ it { should include "OFPC_STP" }
+ it { should include "OFPC_RESERVED" }
+ it { should include "OFPC_IP_REASM" }
+ it { should include "OFPC_QUEUE_STATS" }
+ it { should include "OFPC_ARP_MATCH_IP" }
+
+ it { should include "OFPAT_OUTPUT" }
+ it { should include "OFPAT_SET_VLAN_VID" }
+ it { should include "OFPAT_SET_VLAN_PCP" }
+ it { should include "OFPAT_STRIP_VLAN" }
+ it { should include "OFPAT_SET_DL_SRC" }
+ it { should include "OFPAT_SET_DL_DST" }
+ it { should include "OFPAT_SET_NW_SRC" }
+ it { should include "OFPAT_SET_NW_DST" }
+ it { should include "OFPAT_SET_NW_TOS" }
+ it { should include "OFPAT_SET_TP_DST" }
+ it { should include "OFPAT_ENQUEUE" }
+ it { should include "OFPAT_VENDOR" }
+end
+
+
+### Local variables:
+### mode: Ruby
+### coding: utf-8-unix
+### indent-tabs-mode: nil
+### End:

0 comments on commit f759cc7

Please sign in to comment.