Skip to content

Commit e24b13c

Browse files
committed
Trema::IP -> Pio::IPv4Address.
1 parent 030493d commit e24b13c

8 files changed

Lines changed: 29 additions & 191 deletions

File tree

ruby/trema/ip.rb

Lines changed: 0 additions & 111 deletions
This file was deleted.

ruby/trema/match.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ match_nw( VALUE self, uint8_t which ) {
321321
masklen = ( match->wildcards & OFPFW_NW_DST_MASK ) >> OFPFW_NW_DST_SHIFT;
322322
}
323323
uint32_t prefixlen = masklen > 32 ? 0 : 32 - masklen;
324-
return rb_funcall( rb_eval_string( "Trema::IP" ), rb_intern( "new" ), 2, UINT2NUM( nw_addr ), UINT2NUM( prefixlen ) );
324+
VALUE ipv4_addr = rb_funcall( rb_eval_string( "Pio::IPv4Address" ), rb_intern( "new" ), 1, UINT2NUM( nw_addr ) );
325+
return rb_funcall( ipv4_addr, rb_intern( "mask" ), 1, UINT2NUM( prefixlen ) );;
325326
}
326327

327328

@@ -526,7 +527,7 @@ match_init( int argc, VALUE *argv, VALUE self ) {
526527

527528
VALUE nw_src = rb_hash_aref( options, ID2SYM( rb_intern( "nw_src" ) ) );
528529
if ( nw_src != Qnil ) {
529-
VALUE nw_addr = rb_funcall( rb_eval_string( "Trema::IP" ), rb_intern( "new" ), 1, nw_src );
530+
VALUE nw_addr = rb_funcall( rb_eval_string( "Pio::IPv4Address" ), rb_intern( "new" ), 1, nw_src );
530531
uint32_t prefixlen = ( uint32_t ) NUM2UINT( rb_funcall( nw_addr, rb_intern( "prefixlen" ), 0 ) );
531532
if ( prefixlen > 0 ) {
532533
match->nw_src = nw_addr_to_i( nw_addr );
@@ -537,7 +538,7 @@ match_init( int argc, VALUE *argv, VALUE self ) {
537538

538539
VALUE nw_dst = rb_hash_aref( options, ID2SYM( rb_intern( "nw_dst" ) ) );
539540
if ( nw_dst != Qnil ) {
540-
VALUE nw_addr = rb_funcall( rb_eval_string( "Trema::IP" ), rb_intern( "new" ), 1, nw_dst );
541+
VALUE nw_addr = rb_funcall( rb_eval_string( "Pio::IPv4Address" ), rb_intern( "new" ), 1, nw_dst );
541542
uint32_t prefixlen = ( uint32_t ) NUM2UINT( rb_funcall( nw_addr, rb_intern( "prefixlen" ), 0 ) );
542543
if ( prefixlen > 0 ) {
543544
match->nw_dst = nw_addr_to_i( nw_addr );

ruby/trema/packet-in.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ VALUE cPacketIn;
3535
#define PACKET_IN_RETURN_IP( packet_member ) \
3636
{ \
3737
VALUE ret = ULONG2NUM( get_packet_in_info( self )->packet_member ); \
38-
return rb_funcall( rb_eval_string( "Trema::IP" ), rb_intern( "new" ), 1, ret ); \
38+
return rb_funcall( rb_eval_string( "Pio::IPv4Address" ), rb_intern( "new" ), 1, ret ); \
3939
}
4040

4141
#define PACKET_IN_RETURN_NUM( flag, func, packet_member ) \
@@ -391,8 +391,8 @@ packet_in_arp_sha( VALUE self ) {
391391
/*
392392
* The ARP source protocol address of a packet.
393393
*
394-
* @return [Trema::IP, nil]
395-
* the value of ARP source protocol address as a Trema::IP object or nil if
394+
* @return [Pio::IPv4Address, nil]
395+
* the value of ARP source protocol address as a Pio::IPv4Address object or nil if
396396
* packet is not an ARP.
397397
*/
398398
static VALUE
@@ -427,8 +427,8 @@ packet_in_arp_tha( VALUE self ) {
427427
/*
428428
* The ARP target protocol address of a packet.
429429
*
430-
* @return [Trema::IP]
431-
* the value of ARP target protocol address as a Trema::IP object or nil if
430+
* @return [Pio::IPv4Address]
431+
* the value of ARP target protocol address as a Pio::IPv4Address object or nil if
432432
* packet is not an ARP.
433433
*/
434434
static VALUE
@@ -522,8 +522,8 @@ packet_in_rarp_sha( VALUE self ) {
522522
/*
523523
* The RARP source protocol address of a packet.
524524
*
525-
* @return [Trema::IP, nil]
526-
* the value of RARP source protocol address as a Trema::IP object or nil if
525+
* @return [Pio::IPv4Address, nil]
526+
* the value of RARP source protocol address as a Pio::IPv4Address object or nil if
527527
* packet is not an RARP.
528528
*/
529529
static VALUE
@@ -558,8 +558,8 @@ packet_in_rarp_tha( VALUE self ) {
558558
/*
559559
* The ARP target protocol address of a packet.
560560
*
561-
* @return [Trema::IP]
562-
* the value of RARP target protocol address as a Trema::IP object or nil if
561+
* @return [Pio::IPv4Address]
562+
* the value of RARP target protocol address as a Pio::IPv4Address object or nil if
563563
* packet is not an RARP.
564564
*/
565565
static VALUE
@@ -691,8 +691,8 @@ packet_in_ipv4_checksum( VALUE self ) {
691691
/*
692692
* The IPv4 source IP address of a packet.
693693
*
694-
* @return [Trema::IP,nil]
695-
* the value of IPv4 source IP address as a Trema::IP object or nil if
694+
* @return [Pio::IPv4Address,nil]
695+
* the value of IPv4 source IP address as a Pio::IPv4Address object or nil if
696696
* packet is not an IPv4.
697697
*/
698698
static VALUE
@@ -709,8 +709,8 @@ packet_in_ipv4_saddr( VALUE self ) {
709709
/*
710710
* The IPV4 destination IP address of a packet.
711711
*
712-
* @return [Trema::IP, nil]
713-
* the value of IPv4 destination IP address as a Trema::IP object or nil if
712+
* @return [Pio::IPv4Address, nil]
713+
* the value of IPv4 destination IP address as a Pio::IPv4Address object or nil if
714714
* packet is not an IPv4.
715715
*/
716716
static VALUE
@@ -814,8 +814,8 @@ packet_in_icmpv4_seq( VALUE self ) {
814814
/*
815815
* The ICMPv4 redirect message gateway IP address.
816816
*
817-
* @return [Trema::IP, nil]
818-
* the value of ICMPv4 redirect message IP gateway address as a Trema::IP
817+
* @return [Pio::IPv4Address, nil]
818+
* the value of ICMPv4 redirect message IP gateway address as a Pio::IPv4Address
819819
* object or nil if packet is not ICMPv4.
820820
*/
821821
static VALUE
@@ -1009,8 +1009,8 @@ packet_in_igmp_type( VALUE self ) {
10091009
/*
10101010
* The IGMP group address.
10111011
*
1012-
* @return [Trema::IP, nil]
1013-
* the value of IGMP IP group address as a Trema::IP object
1012+
* @return [Pio::IPv4Address, nil]
1013+
* the value of IGMP IP group address as a Pio::IPv4Address object
10141014
* or nil if packet is not IGMP.
10151015
*/
10161016
static VALUE
@@ -1228,7 +1228,7 @@ packet_in_udp_checksum( VALUE self ) {
12281228
*/
12291229
void
12301230
Init_packet_in() {
1231-
rb_require( "trema/ip" );
1231+
rb_require( "pio" );
12321232
rb_require( "trema/mac" );
12331233
mTrema = rb_eval_string( "Trema" );
12341234
cPacketIn = rb_define_class_under( mTrema, "PacketIn", rb_cObject );

ruby/trema/stats-reply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ get_action( const struct ofp_action_header *ah ) {
225225
{
226226
const struct ofp_action_nw_addr *action_nw_addr = ( const struct ofp_action_nw_addr * ) ah;
227227

228-
VALUE ip_address = rb_funcall( rb_eval_string( "Trema::IP " ), rb_intern( "new" ), 1, UINT2NUM( action_nw_addr->nw_addr ) );
228+
VALUE ip_address = rb_funcall( rb_eval_string( "Pio::IPv4Address " ), rb_intern( "new" ), 1, UINT2NUM( action_nw_addr->nw_addr ) );
229229
if ( ah->type == OFPAT_SET_NW_SRC ) {
230230
action = rb_funcall( rb_eval_string( "Trema::SetIpSrcAddr" ), rb_intern( "new" ), 1, rb_funcall( ip_address, rb_intern( "to_s" ), 0 ) );
231231
}

spec/trema/flow-removed_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20+
require "pio"
2021
require "trema"
2122

2223

@@ -112,8 +113,8 @@ class FlowRemovedController < Controller; end
112113
expect( message.match.dl_vlan_pcp ).to eq( 0 )
113114
expect( message.match.nw_tos ).to eq( 0 )
114115
expect( message.match.nw_proto ).to eq( 17 )
115-
expect( Trema::IP.new( message.match.nw_src ).to_s ).to eq( "192.168.0.1" )
116-
expect( Trema::IP.new( message.match.nw_dst ).to_s ).to eq( "192.168.0.2" )
116+
expect( Pio::IPv4Address.new( message.match.nw_src ).to_s ).to eq( "192.168.0.1" )
117+
expect( Pio::IPv4Address.new( message.match.nw_dst ).to_s ).to eq( "192.168.0.2" )
117118
expect( message.match.tp_src ).to eq( 1 )
118119
expect( message.match.tp_dst ).to eq( 1 )
119120
expect( message.cookie ).to eq( 123456789 )

spec/trema/ip_spec.rb

Lines changed: 0 additions & 54 deletions
This file was deleted.

spec/trema/packet-in_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def packet_in datapath_id, message
8686
expect( message.eth_type ).to eq( 0x0800 )
8787
expect( message.ipv4? ).to be_true
8888
expect( message.ipv4_version ).to eq( 4 )
89-
expect( message.ipv4_saddr ).to be_instance_of( Trema::IP )
89+
expect( message.ipv4_saddr ).to be_instance_of( Pio::IPv4Address )
9090
expect( message.ipv4_saddr.to_s ).to eq( "192.168.1.1" )
91-
expect( message.ipv4_daddr ).to be_instance_of( Trema::IP )
91+
expect( message.ipv4_daddr ).to be_instance_of( Pio::IPv4Address )
9292
expect( message.ipv4_daddr.to_s ).to eq( "192.168.1.2" )
9393
end
9494
send_and_wait

trema.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Gem::Specification.new do | gem |
2929
gem.add_dependency "bundler"
3030
gem.add_dependency "gli", "~> 2.8.0"
3131
gem.add_dependency "paper_house", "~> 0.4.0"
32+
gem.add_dependency "pio", "~> 0.2.4"
3233
gem.add_dependency "rake", "~> 10.1.0"
3334
gem.add_dependency "rdoc", "~> 4.0.1"
3435
end

0 commit comments

Comments
 (0)