1
0
mirror of https://github.com/solemnwarning/ipxwrapper synced 2024-12-30 16:45:37 +01:00
Daniel Collins 5ff0855485 Replace test suite.
Dump most of the old "unit" tests which were more system tests and only tested
a small amount of functionality against the host.

The new test suite is a lot more thorough and tests an arbitrary Windows version
over the network rather than testing within the host's WinSock environment.

More documentation detailing how to run this will follow.
2014-10-04 14:46:11 +01:00

79 lines
1.8 KiB
Perl

# IPXWrapper test suite
# Copyright (C) 2014 Daniel Collins <solemnwarning@solemnwarning.net>
#
# 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.
use strict;
use warnings;
package IPXWrapper::Capture::IPX;
use Net::Pcap;
use NetPacket::Ethernet;
use NetPacket::IPX;
sub new
{
my ($class, $dev) = @_;
my $err;
my $pcap = Net::Pcap::pcap_open_live($dev, 1500, 0, 1, \$err)
or die("Cannot open device $dev: $err");
return bless(\$pcap, $class);
}
sub read_available
{
my ($self) = @_;
my @packets = ();
Net::Pcap::pcap_dispatch($$self, -1, sub
{
my ($user_data, $header, $packet) = @_;
my $ether = NetPacket::Ethernet->decode($packet);
if($ether->{type} == 0x8137)
{
my $ipx = NetPacket::IPX->decode($ether->{data});
my %packet = (
src_mac => $ether->{src_mac},
dst_mac => $ether->{dest_mac},
tc => $ipx->{tc},
type => $ipx->{type},
src_network => $ipx->{src_network},
src_node => $ipx->{src_node},
src_socket => $ipx->{src_socket},
dst_network => $ipx->{dest_network},
dst_node => $ipx->{dest_node},
dst_socket => $ipx->{dest_socket},
data => $ipx->{data},
);
push(@packets, \%packet);
}
}, undef);
return @packets;
}
1;