Hi Boaz, you are right!!! What an childish mistake...!!
I used "sizeof(header->length)" instead of "header->length". I tried it, and it works perfectly! Thanks again! ________________________________ Von: [email protected] [mailto:[email protected]] Im Auftrag von Boaz Brickner Gesendet: Donnerstag, 25. Februar 2010 12:47 An: [email protected] Betreff: Re: [Winpcap-users] pcap_sendpacket sends only 4 bytes...! Hi, It seems that your bug is "sizeof(pkt_data_iface1_2) is the buffer size." sizeof is an operator that returns the size of the type and not the length of the buffer. http://msdn.microsoft.com/en-us/library/4s7x1k91%28VS.71%29.aspx You should use the length of the buffer you want to send. When you receive a packet, you also receive a packet header (pcap_pkthdr), which contains the length of the packet buffer (caplen). You should use this length and you should not use the sizeof operator. 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. I hope this helps, Boaz. Try Pcap.Net in http://pcapdotnet.codeplex.com On Thu, Feb 25, 2010 at 12:39, Valpondi Hereza, Fabio <[email protected]<mailto:[email protected]>> wrote: Hi, I am programming a kind of bridge device, reading from one interface, and forwarding the frame through another interface. Also in the inverse way. The frame capture using "pcap_loop" happens without problems (I print the frame contents as well as length for debugging purposes). The problem is when I try to send the interface via the other interface. I use the following call for the pcap_sendpacket function: pcap_sendpacket(iface2, pkt_data_iface1_2,sizeof(pkt_data_iface1_2)); iface2 is the outgoing interface pkt_data_iface1_2 is the frame received on Interface 1 and being sent over Interface 2 sizeof(pkt_data_iface1_2) is the buffer size. 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. I also tried for the size parameter sizeof(hear_iface1_2->caplen) or the pcap_inject function: The result was the same. My question is: does anybody know, why only the first four bytes are sent? Thanks a lot for your help! Best regards, Fabio Valpondi _______________________________________________ Winpcap-users mailing list [email protected]<mailto:[email protected]> https://www.winpcap.org/mailman/listinfo/winpcap-users
_______________________________________________ Winpcap-users mailing list [email protected] https://www.winpcap.org/mailman/listinfo/winpcap-users
