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