8 if (!eval "require Socket") {
9 print "1..0 # no Socket\n"; exit 0;
11 if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
12 print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
14 $INC{'Socket.pm'} = 1;
22 *{ $pkg . '::inet_aton' } = \&inet_aton;
23 *{ $pkg . '::inet_ntoa' } = \&inet_ntoa;
35 my $num = unpack('N', pack('C*', split(/\./, $_[0])));
48 (my $libnet_t = __FILE__) =~ s/config.t/libnet_t.pl/;
54 ok( exists $INC{'Net/Config.pm'}, 'Net::Config should have been used' );
55 ok( keys %NetConfig, '%NetConfig should be imported' );
58 undef $NetConfig{'ftp_firewall'};
59 is( Net::Config->requires_firewall(), 0,
60 'requires_firewall() should return 0 without ftp_firewall defined' );
62 $NetConfig{'ftp_firewall'} = 1;
63 is( Net::Config->requires_firewall('a.host.not.there'), -1,
64 '... should return -1 without a valid hostname' );
67 delete $NetConfig{'local_netmask'};
68 is( Net::Config->requires_firewall('127.0.0.1'), 0,
69 '... should return 0 without local_netmask defined' );
71 $NetConfig{'local_netmask'} = '127.0.0.1/24';
72 is( Net::Config->requires_firewall('127.0.0.1'), 0,
73 '... should return false if host is within netmask' );
74 is( Net::Config->requires_firewall('192.168.10.0'), 1,
75 '... should return true if host is outside netmask' );
77 # now try more netmasks
78 $NetConfig{'local_netmask'} = [ '127.0.0.1/24', '10.0.0.0/8' ];
79 is( Net::Config->requires_firewall('10.10.255.254'), 0,
80 '... should find success with mutiple local netmasks' );
81 is( Net::Config->requires_firewall('192.168.10.0'), 1,
82 '... should handle failure with multiple local netmasks' );
84 is( \&Net::Config::is_external, \&Net::Config::requires_firewall,
85 'is_external() should be an alias for requires_firewall()' );