[Winpcap-users] Sending packet

Gianluca Varenni gianluca.varenni at cacetech.com
Sun Dec 11 19:11:53 GMT 2005


Just a side note using "precooked" C structures for the protocol headers: be 
careful that 1)by default the fields inside a structure are not byte aligned 
(you should use some special compiler directives to force byte alignment, 
with MSVC you need to use #pragma pack something...) and 2) some headers 
(e.g. the IP and TCP ones) do not have a fixed size (the standard IP header 
size is 20 bytes, but it may be longer in case it contains options).

Have a nice day
GV

----- Original Message ----- 
From: "Deston High" <mqx at low-axs.net>
To: <winpcap-users at winpcap.org>
Sent: Tuesday, December 06, 2005 1:52 PM
Subject: Re: [Winpcap-users] Sending packet


> According your previous post you capture data and want to "block" (in this 
> case: reset) the connection.
> Well, when you capture the data, use pkt_data (see: pcap_next_ex()) and 
> modify the flag bits and send the modified packet.
> Might it help if you insert the data in a header structure of both ip and 
> tcp protocol.
>
> for ethernet it could look like this:
>
> typedef struct HEADER
> {
>    struct
>    {
>       ...
>    } IPHEADER;
>    struct
>    {
>       ...
>    } TCPHEADER;
>
> } HERDER;
>
> ...
> initial pcap...
> set filter...
> ...
> while (pcap_next_ex(handle,&header,&pkt_data) > 0)
> {
>    HEADER *iptcpheader = (HEADER*)(pkt_data+etherheaderlen);
>    iptcpheader->tcpheader.th_flag = 4;
>    ...
>    pcap_sendpacket(handler,pkt_data,sizeof(iptcpheader)+etherheaderlen);
> }
> ...
>
> very snipped example!
>
> hope it gives an idea how to do that.
>
> might helpful: http://de.wikipedia.org/wiki/TCP-Header
> there are some other good sites explaining the header with examples how 
> the header-struct looks like.
>
> D. High
>
>
> cinias at o2.pl wrote:
>
>> Hi Everyone,
>>  Does enybody know how I can send a TCP Packet with RST flag?
>>  Marcin
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Winpcap-users mailing list
>>Winpcap-users at winpcap.org
>>https://www.winpcap.org/mailman/listinfo/winpcap-users
>>
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
> 



More information about the Winpcap-users mailing list