2000-06-20 20:50:37 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
#
|
2004-03-06 05:22:54 -05:00
|
|
|
# Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
|
2001-01-09 17:01:04 -05:00
|
|
|
# Copyright (C) 2000, 2001 Internet Software Consortium.
|
2000-07-31 21:33:37 -04:00
|
|
|
#
|
2000-06-20 20:50:37 -04:00
|
|
|
# Permission to use, copy, modify, and distribute this software for any
|
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
2000-07-31 21:33:37 -04:00
|
|
|
#
|
2004-03-06 05:22:54 -05:00
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
|
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
|
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
|
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
|
|
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
|
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
# PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
|
|
# $Id: testsock.pl,v 1.13.206.1 2004/03/06 10:21:48 marka Exp $
|
2000-06-22 18:00:42 -04:00
|
|
|
|
2000-06-20 20:50:37 -04:00
|
|
|
# Test whether the interfaces on 10.53.0.* are up.
|
|
|
|
|
|
2000-06-24 19:09:44 -04:00
|
|
|
require 5.001;
|
|
|
|
|
|
|
|
|
|
use Socket;
|
2000-06-24 21:40:05 -04:00
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
|
|
my $port = 0;
|
2001-02-13 19:09:44 -05:00
|
|
|
my $id = 0;
|
|
|
|
|
GetOptions("p=i" => \$port,
|
|
|
|
|
"i=i" => \$id);
|
2000-06-20 20:50:37 -04:00
|
|
|
|
2001-02-13 19:09:44 -05:00
|
|
|
my @ids;
|
|
|
|
|
if ($id != 0) {
|
2001-04-23 21:23:28 -04:00
|
|
|
@ids = ($id);
|
2001-02-13 19:09:44 -05:00
|
|
|
} else {
|
2001-04-23 21:23:28 -04:00
|
|
|
@ids = (1..5);
|
2001-02-13 19:09:44 -05:00
|
|
|
}
|
2001-04-23 21:52:16 -04:00
|
|
|
|
2001-02-13 19:09:44 -05:00
|
|
|
foreach $id (@ids) {
|
2000-06-24 22:30:18 -04:00
|
|
|
my $addr = pack("C4", 10, 53, 0, $id);
|
|
|
|
|
my $sa = pack_sockaddr_in($port, $addr);
|
2000-06-24 19:09:44 -04:00
|
|
|
socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname("tcp"))
|
|
|
|
|
or die "$0: socket: $!\n";
|
2001-04-23 21:52:16 -04:00
|
|
|
setsockopt(SOCK, SOL_SOCKET, SO_REUSEADDR, pack("l", 1));
|
|
|
|
|
|
2000-06-24 19:09:44 -04:00
|
|
|
bind(SOCK, $sa)
|
2000-06-24 22:30:18 -04:00
|
|
|
or die sprintf("$0: bind(%s, %d): $!\n",
|
|
|
|
|
inet_ntoa($addr), $port);
|
2000-06-26 13:53:25 -04:00
|
|
|
close(SOCK);
|
2001-04-23 21:23:28 -04:00
|
|
|
sleep(1);
|
2000-06-20 20:50:37 -04:00
|
|
|
}
|