/[scire]/branches/new-fu/client/scireclient.pl
Gentoo

Diff of /branches/new-fu/client/scireclient.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 289 Revision 290
159 } 159 }
160 close(FH) or die("Couldn't close the config file ${conf_file}: $!"); 160 close(FH) or die("Couldn't close the config file ${conf_file}: $!");
161} 161}
162 162
163sub register_client { 163sub register_client {
164 my $mac = "00:11:22:33:44:55"; 164# my $mac = "00:11:22:33:44:55";
165 my $ip = "192.168.2.3"; 165# my $ip = "192.168.2.3";
166 my ($mac, $ip) = get_interface_info(defined $conf{interface} && $conf{interface} ? $conf{interface} : "eth0");
166 my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip)); 167 my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip));
167 die "Could not register client $mac w/ ip $ip. Got: $message" if (! defined $status or $status ne "OK"); 168 die "Could not register client $mac w/ ip $ip. Got: $message" if (! defined $status or $status ne "OK");
168 debug("Client registered. Status is pending.\n"); 169 debug("Client registered. Status is pending.\n");
169} 170}
170 171
240 my $msg = shift; 241 my $msg = shift;
241 if($conf{debug}) { 242 if($conf{debug}) {
242 print STDERR $msg; 243 print STDERR $msg;
243 } 244 }
244} 245}
246
247sub get_interface_info {
248 my $interface = shift;
249
250 my $info = `/sbin/ifconfig ${interface}`;
251 $info =~ /^.+HWaddr ([a-zA-Z0-9:]+).+inet addr:([0-9.]+).+$/s;
252 my ($mac, $ip) = ($1, $2);
253 return ($mac, $ip);
254}

Legend:
Removed from v.289  
changed lines
  Added in v.290

  ViewVC Help
Powered by ViewVC 1.1.20