Pull OpenFlow TCP port, version number, and miss send len default in tests and dissector

This commit is contained in:
Brandon Heller committed 2008-12-01 05:12:44 -08:00
1 parent 7da34aa10c
commit 87a101788e
10 files changed
+51 -26

No files matched your search

+1 -1
View File
@@ -68,7 +68,7 @@
#define OFP_MAX_TABLE_NAME_LEN 32
#define OFP_MAX_PORT_NAME_LEN 16
#define OFP_TCP_PORT 975
#define OFP_TCP_PORT 6633
#define OFP_SSL_PORT 6633
#define OFP_ETH_ALEN 6 /* Bytes in an Ethernet address. */
+2 -1
View File
@@ -23,7 +23,8 @@ setup_pcap_interfaces();
`snmpset -v2c -c public 10.9.8.9 iso.org.dod.internet.private.enterprises.11.2.14.11.5.1.7.1.5.10.0 i 18`;
# set controller string
`snmpset -v2c -c public 10.9.8.9 iso.org.dod.internet.private.enterprises.11.2.14.11.5.1.7.1.5.11.0 s tcp:10.9.8.4:975`;
my $of_port = get_of_port();
`snmpset -v2c -c public 10.9.8.9 iso.org.dod.internet.private.enterprises.11.2.14.11.5.1.7.1.5.11.0 s tcp:10.9.8.4:$of_port`;
# enable OF module
`snmpset -v2c -c public 10.9.8.9 iso.org.dod.internet.private.enterprises.11.2.14.11.5.1.7.1.5.9.0 i 1`
+3 -1
View File
@@ -10,6 +10,7 @@
use OF::Base;
use Test::RegressTest;
use strict;
use OF::OFUtil;
# check vars are set.
check_OF_vars_set();
@@ -21,6 +22,7 @@ sub INT_Handler {
exit(1);
}
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=hp", "--controller=10.9.8.4:975", "--port_base=1";
my $of_port = get_of_port();
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=hp", "--controller=10.9.8.4:$of_port", "--port_base=1";
run_regress_test( \&INT_Handler, @ARGV );
+3 -1
View File
@@ -10,6 +10,7 @@
use OF::Base;
use Test::RegressTest;
use strict;
use OF::OFUtil;
# check vars are set.
check_OF_vars_set();
@@ -21,6 +22,7 @@ sub INT_Handler {
exit(1);
}
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=kmod", "--controller=localhost:975";
my $of_port = get_of_port();
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=kmod", "--controller=localhost:$of_port";
run_regress_test( \&INT_Handler, @ARGV );
+3 -1
View File
@@ -10,6 +10,7 @@
use OF::Base;
use Test::RegressTest;
use strict;
use OF::OFUtil;
# check vars are set.
check_OF_vars_set();
@@ -21,6 +22,7 @@ sub INT_Handler {
exit(1);
}
push @ARGV, "--map=$ENV{'OFT_ROOT'}/bin/veth.map", "--root=$ENV{'OFT_ROOT'}", "--common-st-args=kmod_veth", "--controller=localhost:975";
my $of_port = get_of_port();
push @ARGV, "--map=$ENV{'OFT_ROOT'}/bin/veth.map", "--root=$ENV{'OFT_ROOT'}", "--common-st-args=kmod_veth", "--controller=localhost:$of_port";
run_regress_test( \&INT_Handler, @ARGV );
+3 -1
View File
@@ -10,6 +10,7 @@
use OF::Base;
use Test::RegressTest;
use strict;
use OF::OFUtil;
# check vars are set.
check_OF_vars_set();
@@ -21,6 +22,7 @@ sub INT_Handler {
exit(1);
}
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--map=$ENV{'OFT_ROOT'}/bin/nf2.map", "--common-st-args=nf2", "--controller=localhost:975", "--port_base=0";
my $of_port = get_of_port();
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--map=$ENV{'OFT_ROOT'}/bin/nf2.map", "--common-st-args=nf2", "--controller=localhost:$of_util", "--port_base=0";
run_regress_test( \&INT_Handler, @ARGV );
+3 -1
View File
@@ -10,6 +10,7 @@
use OF::Base;
use Test::RegressTest;
use strict;
use OF::OFUtil;
# check vars are set.
check_OF_vars_set();
@@ -21,6 +22,7 @@ sub INT_Handler {
exit(1);
}
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=user", "--controller=localhost:975";
my $of_port = get_of_port();
push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=user", "--controller=localhost:$of_port";
run_regress_test( \&INT_Handler, @ARGV );
+3 -1
View File
@@ -10,6 +10,7 @@
use OF::Base;
use Test::RegressTest;
use strict;
use OF::OFUtil;
# check vars are set.
check_OF_vars_set();
@@ -21,6 +22,7 @@ sub INT_Handler {
exit(1);
}
push @ARGV, "--map=$ENV{'OFT_ROOT'}/bin/veth.map", "--root=$ENV{'OFT_ROOT'}", "--common-st-args=user_veth", "--controller=localhost:975";
my $of_port = get_of_port();
push @ARGV, "--map=$ENV{'OFT_ROOT'}/bin/veth.map", "--root=$ENV{'OFT_ROOT'}", "--common-st-args=user_veth", "--controller=localhost:$of_port";
run_regress_test( \&INT_Handler, @ARGV );
+29 -17
View File
@@ -51,6 +51,7 @@ use Time::HiRes qw(sleep gettimeofday tv_interval usleep);
&wait_for_one_packet_in
&verify_header
&get_of_ver
&get_of_port
&get_of_miss_send_len_default
&enable_flow_expirations
&get_default_black_box_pkt
@@ -70,10 +71,17 @@ if (! -e "$openflow_dir/include/openflow/openflow.h") {
die "please set OF_ROOT in path so that OFUtil.pm can extract constants"
}
use constant CURRENT_OF_VER => 0x96;
sub get_define {
my $val = shift;
my $retval = `grep \"#define $val \" \$OF_ROOT/include/openflow/openflow.h | awk '{print \$3}'`;
chomp $retval;
return $retval;
}
# data length forwarded to the controller if miss (used in do_hello_sequence)
use constant MISS_SEND_LEN_DEFAULT => 0x80;
# extract #defines from openflow.h
my $of_ver = get_define('OFP_VERSION');
my $of_port = get_define('OFP_TCP_PORT');
my $of_miss_send_len = get_define('OFP_DEFAULT_MISS_SEND_LEN');
# sending/receiving interfaces - NOT OpenFlow ones
my @interfaces = ( "eth1", "eth2", "eth3", "eth4" );
@@ -435,7 +443,7 @@ sub do_hello_sequence {
my ( $ofp, $sock ) = @_;
my $hdr_args_hello = {
version => CURRENT_OF_VER,
version => $of_ver,
type => $enums{'OFPT_HELLO'},
length => $ofp->sizeof('ofp_header'),
xid => 0
@@ -477,7 +485,7 @@ sub get_switch_features {
my ( $ofp, $sock ) = @_;
my $hdr_args_features_request = {
version => CURRENT_OF_VER,
version => $of_ver,
type => $enums{'OFPT_FEATURES_REQUEST'},
length => $ofp->sizeof('ofp_header'), # should generate automatically!
xid => 0x00000000
@@ -515,7 +523,7 @@ sub get_config {
my ( $ofp, $sock ) = @_;
my $hdr_args_get_config_request = {
version => CURRENT_OF_VER,
version => $of_ver,
type => $enums{'OFPT_GET_CONFIG_REQUEST'},
length => $ofp->sizeof('ofp_header'),
xid => 0x0000000
@@ -554,7 +562,7 @@ sub set_config {
my ( $ofp, $sock, $flags, $miss_send_len ) = @_;
my $hdr_args = {
version => CURRENT_OF_VER,
version => $of_ver,
type => $enums{'OFPT_SET_CONFIG'},
length => $ofp->sizeof('ofp_switch_config'),
xid => 0x0000000
@@ -579,7 +587,7 @@ sub run_black_box_test {
my %options = nftest_init( $argv_ref, \@interfaces, );
my $host = 'localhost';
my $port = 975;
my $port = $of_port;
# extract host and port from controller string if passed in
if (defined $options{'controller'}) {
($host, $port) = split(/:/,$options{'controller'});
@@ -662,7 +670,7 @@ sub create_flow_mod_from_udp_action {
}
my $hdr_args = {
version => CURRENT_OF_VER,
version => $of_ver,
type => $enums{'OFPT_FLOW_MOD'},
length => $ofp->sizeof('ofp_flow_mod') + $ofp->sizeof('ofp_action_output'),
xid => 0x0000000
@@ -787,7 +795,7 @@ sub wait_for_flow_expired_total_bytes {
#print Dumper($msg);
# Verify fields
compare( "header version", $$msg{'header'}{'version'}, '==', CURRENT_OF_VER );
compare( "header version", $$msg{'header'}{'version'}, '==', $of_ver );
compare( "header type", $$msg{'header'}{'type'}, '==', $enums{'OFPT_FLOW_EXPIRED'} );
compare( "header length", $$msg{'header'}{'length'}, '==', $msg_size );
compare( "byte_count", $$msg{'byte_count'}, '==', $bytes );
@@ -804,13 +812,13 @@ sub wait_for_one_packet_in {
my ( $ofp, $sock, $pkt_len, $pkt ) = @_;
my $pkt_in_msg_size; # read size from socket
if ( $pkt_len < MISS_SEND_LEN_DEFAULT ) {
if ( $pkt_len < $of_miss_send_len ) {
# Due to padding, the size of ofp_packet_in header is $ofp->sizeof('ofp_packet_in')-2
$pkt_in_msg_size = ( $ofp->sizeof('ofp_packet_in') - 2 ) + $pkt_len;
}
else {
$pkt_in_msg_size = ( $ofp->sizeof('ofp_packet_in') - 2 ) + MISS_SEND_LEN_DEFAULT;
$pkt_in_msg_size = ( $ofp->sizeof('ofp_packet_in') - 2 ) + $of_miss_send_len;
}
my $recvd_mesg;
@@ -827,7 +835,7 @@ sub wait_for_one_packet_in {
# print Dumper($msg);
# Verify fields
compare( "header version", $$msg{'header'}{'version'}, '==', CURRENT_OF_VER );
compare( "header version", $$msg{'header'}{'version'}, '==', $of_ver );
compare( "header type", $$msg{'header'}{'type'}, '==', $enums{'OFPT_PACKET_IN'} );
compare( "header length", $$msg{'header'}{'length'}, '==', $msg_size );
compare( "header length", $$msg{'total_len'}, '==', $pkt_len );
@@ -848,17 +856,21 @@ sub verify_header {
my ( $msg, $ofpt, $msg_size ) = @_;
compare( "header version", $$msg{'header'}{'version'}, '==', CURRENT_OF_VER );
compare( "header version", $$msg{'header'}{'version'}, '==', $of_ver );
compare( "header type", $$msg{'header'}{'type'}, '==', $enums{$ofpt} );
compare( "header length", $$msg{'header'}{'length'}, '==', $msg_size );
}
sub get_of_ver {
return CURRENT_OF_VER;
return $of_ver;
}
sub get_of_port {
return $of_port;
}
sub get_of_miss_send_len_default {
return MISS_SEND_LEN_DEFAULT;
return $of_miss_send_len;
}
sub enable_flow_expirations {
@@ -866,7 +878,7 @@ sub enable_flow_expirations {
my ( $ofp, $sock ) = @_;
my $flags = 1; # OFPC_SEND_FLOW_EXP = 0x0001;
my $miss_send_len = MISS_SEND_LEN_DEFAULT;
my $miss_send_len = $of_miss_send_len;
set_config( $ofp, $sock, $flags, $miss_send_len );
}
@@ -33,7 +33,7 @@ else
endif
# specify the port on which event capture packets will be destined
DISSECT_PORT = -DOPENFLOW_DST_TCP_PORT=975
DISSECT_PORT = -DOPENFLOW_DST_TCP_PORT=6633
OSTYPE = $(shell uname)
ifeq ($(OSTYPE),Linux)