Fellow Monks,
I've been investigating ways to bypass routing tables using perl sockets. Much in the way Ping can do this. I've found
this is possible using setsocketopt syntax with Socket.pm,
But when using IO::Socket it only seems to work for one type of device. For example.
Using Socket.pm this syntax works with ethernet and PPP devices
use Socket qw( SOCK_DGRAM SOCK_STREAM SOCK_RAW PF_INET SOL_SOCKET inet
+_aton inet_ntoa sockaddr_in );
$host="www.cnet.com";
$port="80";
socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
setsockopt(SOCK, SOL_SOCKET, 25 , pack("Z*","eth0")) || die "error\n";
$iaddr = inet_aton($host);
$paddr = sockaddr_in($port, $iaddr);
connect(SOCK, $paddr);
The code which, from what i can tell for IO::Socket
looks like this
use IO::Socket;
$server = $ARGV[0];
$port = 80;
$socket = IO::Socket::INET->new(
Proto => 'tcp',
PeerAddr => $server,
PeerPort => $port,
Timeout => 10,
);
unless($socket) {
die("Could not connect to $server:$port");
}
$socket->autoflush(1);
$socket->sockopt(25, "eth0") || die "error\n";
And this works with ethernet device but NOT PPP.
when i strace it, it hangs after printing to the socket.
I've also tried packing the device like above but it seems to make little difference, the sockopt returns true and hangs.
any ideas?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.