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


In reply to Re: loose source and route record by Ernesto81
in thread loose source and route record by Ernesto81

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.