in reply to loose source and route record
Hi again,
Issue is solved and now LSRR works fine (solution posted here, maybe it could help) :
For the first question, why setsockopt fails (solution for 1 hop) :
my $_hop = inet_aton $hop ; my $_end = inet_aton $end ; my $_length = "11"; my $_pointer = "4"; my $_header = pack "C3", &LSRR, $_length, $_pointer; my $_ipOpt = $_header . $_hop . $_end; setsockopt S, IPPROTO_IP, IP_OPTIONS, $ipOpt;
Problem was NOP (used for four-byte boundary alignment). Perl is helping us doing the alignment by itself, BUT, pay attention to length and pointer. Now lenght is 11 bytes, but pointer is 4, otherwise it fails.
If you want to use it, just put it in between socket and connect in a TCP client.
For the second question, how to do the inverse, using getsockopt and unpack, here is one possible solution :
$_ipOpt = getsockopt S, IPPROTO_IP, IP_OPTIONS; ( my $_lsrr, my $_length, my $_ptr, my $_hop1, my $_hop2 ) = unpack "C +3 a4 a4", $_ipOpt; my $hop1 = inet_ntoa $_hop1; my $hop2 = inet_ntoa $_hop2; print STDOUT "### hop1 : $hop1 ; hop2 : $hop2 \n";
Kind regards
Ernesto
|
|---|