<div dir="ltr">Hi,<br><br>It seems that your bug is "sizeof(pkt_data_iface1_2) is the buffer size."<br>sizeof is an operator that returns the size of the type and not the length of the buffer.<br><a href="http://msdn.microsoft.com/en-us/library/4s7x1k91%28VS.71%29.aspx">http://msdn.microsoft.com/en-us/library/4s7x1k91%28VS.71%29.aspx</a><br>
<br>You should use the length of the buffer you want to send.<br><br>When you receive a packet, you also receive a packet header (pcap_pkthdr), which contains the length of the packet buffer (caplen).<br>You should use this length and you should not use the sizeof operator.<br>
<br>By the way, the sizeof operator returns 4 when you use it on an int type or a pointer type, so this is why you got only 4 bytes.<br><br>I hope this helps,<br><br>Boaz.<br><br><br><font size="1">Try Pcap.Net in <a href="http://pcapdotnet.codeplex.com">http://pcapdotnet.codeplex.com</a></font><font face="Verdana" size="2"><span><br>
<br></span></font><br><div class="gmail_quote">On Thu, Feb 25, 2010 at 12:39, Valpondi Hereza, Fabio <span dir="ltr"><<a href="mailto:fabio.valpondi_hereza@siemens.com">fabio.valpondi_hereza@siemens.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>
<div><font face="Verdana" size="2"><span>Hi,</span></font></div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span>I am programming a
kind of bridge device, reading from one interface, and forwarding the frame
through another interface. Also in the inverse way.</span></font></div>
<div><font face="Verdana" size="2"><span>The frame capture
using "pcap_loop" happens without problems (I print the frame contents as well
as length for debugging purposes).</span></font></div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span>The problem is
when I try to send the interface via the other interface. I use the following
call for the pcap_sendpacket function:</span></font></div>
<div><font face="Verdana" size="2"><span><b>pcap_sendpacket(iface2,
pkt_data_iface1_2,sizeof(pkt_data_iface1_2));</b></span></font></div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span><i>iface2</i> is
the outgoing interface</span></font></div>
<div><font face="Verdana" size="2"><span><i>pkt_data_iface1_2</i> is the frame received on
Interface 1 and being sent over Interface 2</span></font></div>
<div><font face="Verdana" size="2"><span><i>sizeof(pkt_data_iface1_2)</i> is the buffer
size.</span></font></div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span><span>Only the first four bytes of the frame are sent. The
device that uses wireshark to analyze the frames sent by my program, shows them
as malformed.</span></span></font></div>
<div><font face="Verdana" size="2"><span>I also tried for
the size parameter <i>sizeof(hear_iface1_2->caplen)</i> or the
<b>pcap_inject</b> function: <u><b>The result was the
same.</b></u></span></font></div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span>My question is:
does anybody know, why only the first four bytes are sent?</span></font></div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span>Thanks a lot for
your help!</span></font></div>
<div><font face="Verdana" size="2"><span></span></font> </div>
<div><font face="Verdana" size="2"><span>Best
regards,</span></font></div>
<div><font face="Verdana" size="2"><span>Fabio
Valpondi</span></font></div></div>
<br>_______________________________________________<br>
Winpcap-users mailing list<br>
<a href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</a><br>
<a href="https://www.winpcap.org/mailman/listinfo/winpcap-users" target="_blank">https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br>
<br></blockquote></div><br></div>