Skip to content

Commit

Permalink
Removed Map API (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-higuchi committed Feb 22, 2013
1 parent 52f20dc commit 7610966
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 1,600 deletions.
38 changes: 0 additions & 38 deletions features/examples/topology.change-history.feature

This file was deleted.

167 changes: 0 additions & 167 deletions features/topology/topology.map.feature

This file was deleted.

37 changes: 3 additions & 34 deletions ruby/trema/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ static VALUE
switch_status_to_hash( const topology_switch_status* sw_status ) {
VALUE sw = rb_hash_new();
rb_hash_aset( sw, ID2SYM( rb_intern( "dpid" ) ), ULL2NUM( sw_status->dpid ) );
// rb_hash_aset( sw, ID2SYM( rb_intern( "status" ) ), INT2FIX( (int)sw_status->status ) );

if ( sw_status->status == TD_SWITCH_UP ) {
rb_hash_aset( sw, ID2SYM( rb_intern( "up" ) ), Qtrue );
Expand Down Expand Up @@ -124,8 +123,6 @@ port_status_to_hash( const topology_port_status* port_status ) {
const uint8_t* mac = port_status->mac;
snprintf( macaddr, sizeof(macaddr), "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
rb_hash_aset( port, ID2SYM( rb_intern( "mac" ) ), rb_str_new2( macaddr ) );
// rb_hash_aset( port, ID2SYM( rb_intern( "external" ) ), INT2FIX( (int)port_status->external ) );
// rb_hash_aset( port, ID2SYM( rb_intern( "status" ) ), INT2FIX( (int)port_status->status ) );

if ( port_status->external == TD_PORT_EXTERNAL ) {
rb_hash_aset( port, ID2SYM( rb_intern( "external" ) ), Qtrue );
Expand Down Expand Up @@ -160,7 +157,6 @@ link_status_to_hash( const topology_link_status* link_status ) {
rb_hash_aset( link, ID2SYM( rb_intern( "from_portno" ) ), INT2FIX( (int)link_status->from_portno ) );
rb_hash_aset( link, ID2SYM( rb_intern( "to_dpid" ) ), ULL2NUM( link_status->to_dpid ) );
rb_hash_aset( link, ID2SYM( rb_intern( "to_portno" ) ), INT2FIX( (int)link_status->to_portno ) );
// rb_hash_aset( link, ID2SYM( rb_intern( "status" ) ), INT2FIX( (int)link_status->status ) );

if ( link_status->status != TD_LINK_DOWN ) {
rb_hash_aset( link, ID2SYM( rb_intern( "up" ) ), Qtrue );
Expand Down Expand Up @@ -367,7 +363,7 @@ handle_get_all_link_status_callback( void *tcb, size_t number, const topology_li
* Results will be returned as callback to Block given,
* or as a call to all_link_status_reply handler if no Block was given.
*
* @yieldparam switches [Array<Hash>] Array of Hash including current status.
* @yieldparam link_stats [Array<Hash>] Array of Hash including current status.
*
* @return [Boolean] true if request sent successfully.
*
Expand Down Expand Up @@ -422,7 +418,7 @@ handle_get_all_port_status_callback( void *tcb, size_t number, const topology_po
* Results will be returned as callback to Block given,
* or as a call to all_port_status_reply handler if no Block was given.
*
* @yieldparam ports [Array<Hash>] Array of Hash including current status.
* @yieldparam port_stats [Array<Hash>] Array of Hash including current status.
*
* @return [Boolean] true if request sent successfully.
*
Expand Down Expand Up @@ -478,7 +474,7 @@ handle_get_all_switch_status_callback( void *tcb, size_t number, const topology_
* Results will be returned as callback to Block given,
* or as a call to all_switch_status_reply handler if no Block was given.
*
* @yieldparam switches [Array<Hash>] Array of Hash including current status.
* @yieldparam switche_stats [Array<Hash>] Array of Hash including current status.
*
* @return [Boolean] true if request sent successfully.
*
Expand All @@ -504,33 +500,6 @@ topology_send_all_switch_status( VALUE self ) {
void Init_topology( void ) {
mTopology = rb_define_module_under( mTrema, "Topology" );

/* @!group enum topology_switch_status_type */
/* Same as C API enum topology_switch_status_type */
rb_define_const( mTopology, "TD_SWITCH_DOWN", INT2NUM( TD_SWITCH_DOWN ) );
/* Same as C API enum topology_switch_status_type */
rb_define_const( mTopology, "TD_SWITCH_UP", INT2NUM( TD_SWITCH_UP ) );

/* @!group enum topology_port_status_type */
/* Same as C API enum topology_port_status_type */
rb_define_const( mTopology, "TD_PORT_DOWN", INT2NUM( TD_PORT_DOWN ) );
/* Same as C API enum topology_port_status_type */
rb_define_const( mTopology, "TD_PORT_UP", INT2NUM( TD_PORT_UP ) );

/* @!group enum topology_port_external_type */
/* Same as C API enum topology_port_external_type */
rb_define_const( mTopology, "TD_PORT_INACTIVE", INT2NUM( TD_PORT_INACTIVE ) );
/* Same as C API enum topology_port_external_type */
rb_define_const( mTopology, "TD_PORT_EXTERNAL", INT2NUM( TD_PORT_EXTERNAL ) );

/* @!group enum topology_link_status_type */
/* Same as C API enum topology_link_status_type */
rb_define_const( mTopology, "TD_LINK_DOWN", INT2NUM( TD_LINK_DOWN ) );
/* Same as C API enum topology_link_status_type */
rb_define_const( mTopology, "TD_LINK_UP", INT2NUM( TD_LINK_UP ) );
/* Same as C API enum topology_link_status_type */
rb_define_const( mTopology, "TD_LINK_UNSTABLE", INT2NUM( TD_LINK_UNSTABLE ) );
/* @!endgroup */

rb_define_protected_method( mTopology, "init_libtopology", topology_init_libtopology, 1 );
rb_define_protected_method( mTopology, "finalize_libtopology", topology_finalize_libtopology, 0 );

Expand Down
2 changes: 1 addition & 1 deletion ruby/trema/topology.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def subscribed?
# def start
# init_libtopology "topology"
# send_subscribe_topology if topology_handler_implemented?
#
# send_enable_topology_discovery if respond_to?( :link_status_updated )
# # your application's pre-start_trema() call initialization here.
# end
# end
Expand Down
61 changes: 0 additions & 61 deletions ruby/trema/topology/guarded-property-accessor.rb

This file was deleted.

12 changes: 6 additions & 6 deletions ruby/trema/topology/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def unstable?
end


# @return [Array(Integer,Integer,Integer,Integer)] Link key 4-tuple for this Link instance
# @return [[Integer,Integer,Integer,Integer]] Link key 4-tuple for this Link instance
def key
return [ from_dpid, from_portno, to_dpid, to_portno ]
end
Expand All @@ -82,7 +82,6 @@ def key
# @option link [Integer] :from_portno port number of switch which this link departs from
# @option link [Integer] :to_dpid Switch dpid which this link peer to
# @option link [Integer] :to_portno port number of switch which this link peer to
# @return [Link]
# @example
# link = Link.new( {:from_dpid => 0x1234, :from_portno => 42, :to_dpid => 0x5678, :to_portno => 72 } )
def initialize( link )
Expand Down Expand Up @@ -125,10 +124,11 @@ def to_s


def property_to_s
kvp_ary = @property.select { |key,_| not Link.is_mandatory_key?( key ) }
kvp_ary = kvp_ary.sort_by { |key,_| key.to_s }
s = kvp_ary.map { |key, val| "#{key.to_s}:#{val.inspect}" }.join(", ")
return s
kvp_ary = @property.select { |key,_| not Link.is_mandatory_key?( key ) }.
map { |key, val| [key.to_s, val] }.
sort { |lhs,rhs| lhs.first <=> rhs.first }.
map { |key, val| "#{key}:#{val.inspect}"}
return kvp_ary.join(", ")
end
end
end
Expand Down
Loading

0 comments on commit 7610966

Please sign in to comment.