Re: Problem Modifing the NDIS packet

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Maxim S. Shatskih (maxim_at_storagecraft.com)
Date: 07/20/04


Date: Tue, 20 Jul 2004 19:38:01 +0400


    You cannot modify NDIS_PACKET in place.

    You will need to allocate another NDIS_PACKET and another NDIS_BUFFER+the
data area for the update data, and re-link the buffer chain to the new
NDIS_PACKET.

-- 
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
"Rajesh Gupta" <guptar@gmail.com> wrote in message
news:%23gmxgymbEHA.252@TK2MSFTNGP10.phx.gbl...
> Hi All,
>
> I am trying to modify the NDIS packet. I want to redirect the packet from
> destined for 172.10.10.10 to 172.10.10.10.
> steps taken to modify the packets.
>
> 1. Modify the Destination IP address.
> 2. Calculate the Checksum.
> 3. Modify the Destination MAC address.
> 4. Send the packet.
>
> I have used both Network stacking and own NDIS packets.
>
> When i tested my code, it worked on One Ethernet Adapter and it did not work
> on another adapters. I do not know why.
> When i captured the packet with Etherreal, it shows that the Checksum is 0
> at the destination. Everything else is fine. I checked the IP address, MAC
> address, then are updated.
> I am calculating the right checksum and i made sure i am updating the
> checksum after i modified the packet.
> I am not sure, when Checksum became 0.
>
> I do not know, if Miniport driver made it 0. Is that the posibility? if yes
> then why? Is my checksum wrong? I am attaching the code to calculate
> checksum here. Thanks in advance for your help.
>
> Regards
> Rajesh
>
>
> /*
>
> **************************************************************************
>
> Function: FltIPSumCalculation
>
> Description: Calculate the 16 bit IP sum.
>
> ***************************************************************************
>
> */
>
> USHORT FltIPSumCalculation(USHORT len, PUSHORT pbuf)
>
> {
>
> ULONG sum=0;
>
>
> while(len > 1){
>
> sum += *pbuf++;
>
> len -= sizeof(USHORT);
>
> }
>
> if(len)
>
> sum += *(UCHAR*)pbuf;
>
> sum = (sum >> 16) + (sum & 0xffff);
>
> sum += (sum >> 16);
>
> // one's complement the result
>
> sum = ~sum;
>
> return ((USHORT) sum);
>
> }
>
>


Relevant Pages

  • infinite loop with select
    ... change the IP address (for sending it to a tun device) ... it loops forever with the same packet. ... register unsigned short checksum; ... while (sum>> 16) ...
    (comp.lang.c)
  • Problem Modifing the NDIS packet
    ... I am trying to modify the NDIS packet. ... Calculate the Checksum. ... Modify the Destination MAC address. ...
    (microsoft.public.development.device.drivers)
  • checksum offloading
    ... It is about tcp checksum offloading: ... - an incoming packet is handled by the driver ... skb->csum is filled with a sum ...
    (Linux-Kernel)
  • [PATCH 015/148] include/asm-x86/checksum_64.h: checkpatch cleanups - formatting only
    ... sum: 32bit unfolded sum ... Fold a 32bit running checksum to 16bit and invert it. ... the last step before putting a checksum into a packet. ... * Returns the pseudo header checksum the input data. ...
    (Linux-Kernel)
  • Re: Incremental update of TCP Checksum
    ... > To do this right, instead of subtracting a word, you add the ... >>update of the tcp checksum, I set it to 0 and recalculate it from ... All routers modify the IP ... checksum of a tcp packet? ...
    (Linux-Kernel)