Robert Craig
01/12/2009 11:32 AM
post19871
|
Can you try replacing "ioctl" with "ioctl_socket" instead? Any of the
ioctl calls which have imbedded pointers need to handled specially.
Robert.
-----Original Message-----
From: Lasse Skov [mailto:community-noreply@qnx.com]
Sent: Saturday, January 10, 2009 10:17 AM
To: general-networking
Subject: Re: Send packet with BPF
Yes here is my example code
-lskov
_______________________________________________
General
http://community.qnx.com/sf/go/post19807
|
|
|
Robert Craig
01/12/2009 11:53 AM
post19878
|
I should be a bit clearer. In your original code (not the code example
using "sendto"), replace ioctl with ioctl_socket. I haven't had a
chance to try it yet, but maybe this example will help:
http://canmore.annwfn.net/freebsd/bpf.html
Robert.
-----Original Message-----
From: Lasse Skov [mailto:community-noreply@qnx.com]
Sent: Saturday, January 10, 2009 10:17 AM
To: general-networking
Subject: Re: Send packet with BPF
Yes here is my example code
-lskov
_______________________________________________
General
http://community.qnx.com/sf/go/post19807
|
|
|
Sean Boudreau(deleted)
01/12/2009 2:00 PM
post19896
|
On Sat, Jan 10, 2009 at 10:17:11AM -0500, Lasse Skov wrote:
> Yes here is my example code
>
> -lskov
You're mixing approaches in that code. Either use socket
with IP_HDRINCL or use the bpf descriptor. The bpf method
wants the ethernet header in the buffer. Attached is
your code slightly modified. When compiled as is you can
see the packets via tcpdump sent out with the IP_HDRINCL
method. When compiled with USEBPF you can see packets
like the following where 00:15:c5:a8:bd:7e is my link
level addr but 45:1b:14:01:01:00 is taken from your
buffer (you didn't include the ethernet header).
-seanb
/home/seanb >op tcpdump -ien0 -n -e
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on en0, link-type EN10MB (Ethernet), capture size 96 bytes
13:50:55.746859 00:15:c5:a8:bd:7e > 45:1b:14:01:01:00, ethertype Unknown (0x0a14), length 276:
0x0000: 0383 0a14 0382 00ff 0009 0100 1b1b 1b1b ................
0x0010: 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b ................
0x0020: 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b ................
0x0030: 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b ................
0x0040: 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b 1b1b ................
0x0050: 1b1b ..
13:50:55.746859 00:15:c5:a8:bd:7e > 45:1b:14:01:01:00, ethertype Unknown (0x0a14), length 276:
0x0000: 0383 0a14 0382 4242 4242 4242 4242 4242 ......BBBBBBBBBB
0x0010: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0020: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0030: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0040: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0050: 4242 BB
13:50:55.746859 00:15:c5:a8:bd:7e > 45:1b:14:01:02:00, ethertype Unknown (0x0a14), length 276:
0x0000: 0383 0a14 0382 00ff 0007 0100 4242 4242 ............BBBB
0x0010: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0020: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0030: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0040: 4242 4242 4242 4242 4242 4242 4242 4242 BBBBBBBBBBBBBBBB
0x0050: 4242 BB
13:50:55.746859 00:15:c5:a8:bd:7e > 45:1b:14:01:02:00, ethertype Unknown (0x0a14), length 276:
0x0000: 0383 0a14 0382 0000 0000 0000 0000 0000 ................
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0050: 0000 ..
|
|
|