Subject: | IP options field -> if no options, not needed for pack in encode |
Incase no option are passed for the IP header, it will give in some
cases problems. As work around for myself, I've assumed I never pass
any options so I removed everything releated to this optional field.
sub encode
...
# construct header to calculate the checksum
$hdr = pack('CCnnnCCna4a4', $tmp, $self->{tos},$self->{len},
$self->{id}, $offset, $self->{ttl}, $self->{proto},
$zero, $src_ip, $dest_ip);
$self->{cksum} = NetPacket::htons(NetPacket::in_cksum($hdr));
# make the entire packet
$packet = pack('CCnnnCCna4a4a*', $tmp, $self->{tos},$self->{len},
$self->{id}, $offset, $self->{ttl}, $self->{proto},
$self->{cksum}, $src_ip, $dest_ip, $self->{data});
A better solution would be to check if options are present, and
depending on the outcome include it in the pack or not.