Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
7b6e83aa
Commit
7b6e83aa
authored
Jan 08, 2001
by
Christopher Alfeld
Browse files
Added interface number output for IP addresses.
parent
409f9b6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tbsetup/tbreport.in
View file @
7b6e83aa
...
...
@@ -3,11 +3,17 @@
# tbreport
# This just provides the necessary information from the IR file.
$TBROOT
=
"
@prefix
@
";
my
$TBROOT
=
"
@prefix
@
";
my
$DBNAME
=
"
tbdb
";
push
(
@INC
,"
$TBROOT
/lib/ir
");
require
libir
;
use
DBI
;
$dbh
=
DBI
->
connect
("
DBI:mysql:database=
$DBNAME
;host=localhost
")
||
die
"
Could not connect to DB.
\n
";
if
(
$#ARGV
==
3
)
{
(
$v
,
$pid
,
$eid
,
$irfile
)
=
@ARGV
;
if
(
$v
ne
"
-v
")
{
...
...
@@ -21,6 +27,8 @@ if ($#ARGV == 3) {
exit
(
1
);
}
eval
{
&ir_read
(
$irfile
)};
if
(
$@
)
{
print
STDERR
"
Could not read
$irfile
: $@
\n
";
...
...
@@ -52,6 +60,16 @@ foreach (split("\n",$raw)) {
# $lan = @info[0];
# $lans{$lan} = 1;
# }
$raw
=
eval
{
&ir_get
("
/ip/mac
")};
if
(
$@
)
{
print
STDERR
"
Could not read /ip/mac from IR file!
\n
";
exit
(
1
);
}
foreach
(
split
("
\n
",
$raw
))
{
(
$mac
,
$ip
)
=
split
;
$ipmac
{
$ip
}
=
$mac
;
}
$raw
=
eval
{
&ir_get
("
/ip/map
")};
if
(
$@
)
{
print
STDERR
"
Could not read /ip/map from IR file!
\n
";
...
...
@@ -59,11 +77,21 @@ if ($@) {
}
print
"
\n
";
print
"
IP Addresses:
\n
";
printf
"
%-20s %-20s %-20s
\n
",
"
Node
",
"
Destination
",
"
IP
";
printf
"
%-20s
%-5s
%-20s %-20s
\n
",
"
Node
",
"
IFC
",
"
Destination
",
"
IP
";
print
"
-------------------- -------------------- --------------------
\n
";
foreach
(
split
("
\n
",
$raw
))
{
(
$src
,
$dst
,
$ip
)
=
split
;
printf
"
%-20s %-20s %-20s
\n
",
$src
,
$dst
,
$ip
;
if
(
defined
(
$ipmac
{
$ip
}))
{
$mac
=
$ipmac
{
$ip
};
$sth
=
$dbh
->
prepare
("
SELECT card FROM interfaces WHERE mac =
\"
$mac
\"
");
if
(
$sth
->
execute
!=
0
)
{
(
$ifc
)
=
$sth
->
fetchrow_array
;
}
$sth
->
finish
;
}
else
{
$ifc
=
"
?
";
}
printf
"
%-20s eth%-2s %-20s %-20s
\n
",
$src
,
$ifc
,
$dst
,
$ip
;
}
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment