diff options
author | Andrew Gaffney <agaffney@gentoo.org> | 2007-12-31 16:46:19 +0000 |
---|---|---|
committer | Andrew Gaffney <agaffney@gentoo.org> | 2007-12-31 16:46:19 +0000 |
commit | 00350150fb0e3ebde525caf270d21bb003261eef (patch) | |
tree | bf9cbfdb7eb6c3b41958550fc837a228eec0f9e3 /client | |
parent | add interface config option (diff) | |
download | scire-00350150fb0e3ebde525caf270d21bb003261eef.tar.gz scire-00350150fb0e3ebde525caf270d21bb003261eef.tar.bz2 scire-00350150fb0e3ebde525caf270d21bb003261eef.zip |
add get_interface_info() to get MAC/IP for register_client()
svn path=/branches/new-fu/; revision=290
Diffstat (limited to 'client')
-rwxr-xr-x | client/scireclient.pl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/client/scireclient.pl b/client/scireclient.pl index 8c8bdff..6485bac 100755 --- a/client/scireclient.pl +++ b/client/scireclient.pl @@ -161,8 +161,9 @@ sub read_config_file { } sub register_client { - my $mac = "00:11:22:33:44:55"; - my $ip = "192.168.2.3"; +# my $mac = "00:11:22:33:44:55"; +# my $ip = "192.168.2.3"; + my ($mac, $ip) = get_interface_info(defined $conf{interface} && $conf{interface} ? $conf{interface} : "eth0"); my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip)); die "Could not register client $mac w/ ip $ip. Got: $message" if (! defined $status or $status ne "OK"); debug("Client registered. Status is pending.\n"); @@ -242,3 +243,12 @@ sub debug { print STDERR $msg; } } + +sub get_interface_info { + my $interface = shift; + + my $info = `/sbin/ifconfig ${interface}`; + $info =~ /^.+HWaddr ([a-zA-Z0-9:]+).+inet addr:([0-9.]+).+$/s; + my ($mac, $ip) = ($1, $2); + return ($mac, $ip); +} |