Home > Archive > Tcl > August 2006 > Building packets in Tcl
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Building packets in Tcl
|
|
| Christopher Nelson 2006-08-22, 7:02 pm |
| I'm doing some funky network stuff with Tcl and I've started writing
horrible procs like:
# src and dst are MAC addresses, represented as 6-element lists
# data is the string to send.
proc buildFrame { dst src data {type NA} } {
if {"$type" == "NA"} {
set tl [string length $data]
} else {
set tl $type
}
set frame [binary format c6c6Sa* $dst $src $tl $data]
return $frame
}
(Horrible because I'm sure someone else has done this and I hate
reinventing the wheel.)
I wonder if there isn't a better way. I use libnet, a little, and was
looking for a Tcl binding. I didn't find it. Maybe SWIG would help
but I Googled "libnet tcl" and found
http://marc2.theaimsgroup.com/?l=li...17350204370&w=2 which
says:
scripting language extensions:
Perl Net::RawIP module - http://quake.skif.net/RawIP/
Sun packet shell (for tcl) - http://playground.sun.com/psh/
But the psh link leads to an empty directory. Does anyone know if psh
moved? Any other suggestions?
| |
| George Peter Staplin 2006-08-22, 10:01 pm |
| Christopher Nelson wrote:
> I'm doing some funky network stuff with Tcl and I've started writing
> horrible procs like:
>
> # src and dst are MAC addresses, represented as 6-element lists
> # data is the string to send.
> proc buildFrame { dst src data {type NA} } {
> if {"$type" == "NA"} {
> set tl [string length $data]
> } else {
> set tl $type
> }
> set frame [binary format c6c6Sa* $dst $src $tl $data]
> return $frame
> }
>
> (Horrible because I'm sure someone else has done this and I hate
> reinventing the wheel.)
>
> I wonder if there isn't a better way. I use libnet, a little, and was
> looking for a Tcl binding.
You might find this interesting:
http://www.hping.org/
The author of Hping is somewhat well known in the Tcl community.
-George
|
|
|
|
|