<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.5921" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Verdana color=#000080 size=2><SPAN
class=416295611-25022010>Hi Boaz,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#000080 size=2><SPAN
class=416295611-25022010></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#000080 size=2><SPAN
class=416295611-25022010>you are right!!! What an childish
mistake...!!</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#000080 size=2><SPAN
class=416295611-25022010></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#000080 size=2><SPAN
class=416295611-25022010>I used "sizeof(header->length)" instead of
"header->length". </SPAN></FONT><SPAN
style="MARGIN-TOP: 8px; MARGIN-BOTTOM: 0px; COLOR: #000000"><FONT
style="FONT-SIZE: 8pt; COLOR: #000000"><FONT face=Verdana><FONT
color=#000080><FONT size=2>I<SPAN class=416295611-25022010> tried it, and it
works perfectly!</SPAN></FONT></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN style="MARGIN-TOP: 8px; MARGIN-BOTTOM: 0px; COLOR: #000000"><FONT
style="FONT-SIZE: 8pt; COLOR: #000000"><FONT face=Verdana><FONT
color=#000080><FONT size=2><SPAN
class=416295611-25022010></SPAN></FONT></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN style="MARGIN-TOP: 8px; MARGIN-BOTTOM: 0px; COLOR: #000000"><FONT
style="FONT-SIZE: 8pt; COLOR: #000000"><FONT face=Verdana><FONT
color=#000080><FONT size=2><SPAN class=416295611-25022010>Thanks
again!</SPAN></FONT></FONT></FONT></DIV>
<DIV><BR></DIV></FONT></SPAN>
<DIV> </DIV><BR>
<DIV class=OutlookMessageHeader lang=de dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>Von:</B> winpcap-users-bounces@winpcap.org
[mailto:winpcap-users-bounces@winpcap.org] <B>Im Auftrag von </B>Boaz
Brickner<BR><B>Gesendet:</B> Donnerstag, 25. Februar 2010 12:47<BR><B>An:</B>
winpcap-users@winpcap.org<BR><B>Betreff:</B> Re: [Winpcap-users] pcap_sendpacket
sends only 4 bytes...!<BR></FONT><BR></DIV>
<DIV></DIV>
<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="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<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></BODY></HTML>