Problems calling build_tcp from Ruby libnet

Hi,
I installed ruby-libnet (SVN):
http://rubyforge.org/projects/ruby-libnet/ and want to send a TCP packet
with it. Building TCP packets is done with build_tcp from ruby-libnet.c
:

/*

    • @param sp source port
    • @param dp destination port
    • @param seq sequence number
    • @param ack acknowledgement number
    • @param control control flags
    • @param win window size
    • @param sum checksum (0 for libnet to autofill)
    • @param urg urgent pointer
    • @parama len total length of the TCP packet (for checksum
      calculation)
    • @param payload_s payload length or 0
    • @param ptag protocol tag to modify an existing header, 0 to build
      a new one
    • @return protocol tag value on success, -1 on error

*/
static VALUE rb_libnet_build_tcp(VALUE self,
VALUE sp,
VALUE dp,
VALUE seq,
VALUE ack,
VALUE control,
VALUE win,
VALUE csum,
VALUE urg,
VALUE len,
VALUE payload,
VALUE payload_s,
VALUE tag)

I wanna send a TCP SYN packet with this code:

#!/usr/bin/ruby -w

require ‘libnet’

l = Libnet.new
l.build_tcp(?!?,7000, 80, 100,0, “SYN”, 4, 0, 0,24,0,0)
l.auto_build_ipv4(Libnet::LIBNET_TCP_H + Libnet::LIBNET_IPV4_H,
Libnet::IPPROTO_TCP, “192.168.0.255”)
l.auto_build_ethernet(l.hex_aton(“00:11:11:94:D4:F5”),Libnet::ETHERTYPE_IP)
ret = l.write

but something goes wrong. I get this error when executing:
SYN.rb:4:in `build_tcp’: can’t convert Fixnum into String (TypeError)
from SYN.rb:4

I think I’m missing this: “VALUE self” as first argument but I don’t
know what it is or where to take it. Can someone help me? I really don’t
know how to set the first argument. But something others most also be
wrong because of the error message you see above. But ruby doesn’t show
which argument is bad. I did them like this:

VALUE sp,
VALUE sp, —>7000
VALUE dp, —> 80
VALUE seq, —>100
VALUE ack, —>0
VALUE control, —> “SYN”
VALUE win, ----> 4
VALUE csum, ----> 0
VALUE urg, ----> 0
VALUE len, ----> 24
VALUE payload, ----> 0
VALUE payload_s, —> falls away if
VALUE payload is set to 0
VALUE tag) -----> 0

any help is welcome :slight_smile:


greets
(
)
(
/\ .-“”“-. /
//\/ , //\
|/| ,;;;;;, |/|
//\;-”“”-;///\
// / . / \
(| ,-| \ | / |-, |)
//__\.-.-./__\
// /.-(() ())-.\ \
(\ |) ‘—’ (| /)
(| |)
jgs ) (/

one must still have chaos in oneself to be able to give birth to a
dancing star