#!/usr/bin/perl

use constant WNAM_HOST => "127.0.0.1";

use IO::Socket::INET;

$| = 1;

my $sock = new IO::Socket::INET(PeerAddr => WNAM_HOST, PeerPort => 20001, Proto => 'tcp', Timeout => 0.5) or undef $sock;

if (defined $sock) {
 if (defined $ARGV[0]){
  my $type = $ARGV[0];
  my $ip =   $ARGV[1];
  my $mac =  uc $ARGV[2];
  my $name = $ARGV[3];
  if (defined $type and defined $ip and defined $mac) {
   print $sock "DHCP type=$type ip=$ip mac=$mac name=$name\n";
  }
 }
$sock->shutdown(2);
$sock->close;
}

