sub ethset { my ($self, %hash) = @_; map { $self->{ethhdr}->$_($hash{$_}) } keys %hash; my $source = $self->{ethhdr}->source; my $dest = $self->{ethhdr}->dest; if ($source =~ /^(\w\w):(\w\w):(\w\w):(\w\w):(\w\w):(\w\w)$/) { $self->{ethhdr}->source( pack("C6",hex($1),hex($2),hex($3),hex($4),hex($5),hex($6)) ); $source = $self->{ethhdr}->source; } if ($dest =~ /^(\w\w):(\w\w):(\w\w):(\w\w):(\w\w):(\w\w)$/) { $self->{ethhdr}->dest( pack("C6", hex($1),hex($2),hex($3),hex($4),hex($5),hex($6)) ); $dest = $self->{ethhdr}->dest; } # host_to_ip returns IP address of target in host byteorder format $self->{ethhdr}->source(mac(host_to_ip($source))) unless($source =~ /[^A-Za-z0-9\-.]/ && length($source) == 6); $self->{ethhdr}->dest(mac(host_to_ip($dest))) unless($dest =~ /[^A-Za-z0-9\-.]/ && length($dest) == 6); my $ipproto = pack ("n1",0x0800); $self->{ethpack}=$self->{ethhdr}->dest.$self->{ethhdr}->source.$ipproto; }