Hi everyone,

I am trying to modify the NDIS packet. Do i need to allocate new buffers?

I want to modify the destination IP address. I am doing the address mapping,
if i receive data for specific destination, i want to redirect that data to
go to another IP address. Do i need to allocate new buffers, copy all the
data from old packet, modify it and then send it again. Can i do the
following?

1. Query the NDIS packet.
2. Get the Virtual Address.
3. Modify the Header, with new IP and checksum.
4. Allocate new packet from my own pool.
5. Copy all the header information and OOB data.
6. Send that packet again.


Can i use the same buffer and packet. Or i will have to allocate new buffer
and packet if i am modifing the data in the packet.

Thanks in Advance

Rajesh

Re: Question about modifing the NDIS packet? by Thomas

Thomas
Wed Jun 23 17:05:30 CDT 2004


"Rajesh Gupta" <guptar@gmail.com> wrote in message
news:u3a6gdWWEHA.212@TK2MSFTNGP11.phx.gbl...
> Hi everyone,
>
> I am trying to modify the NDIS packet. Do i need to allocate new buffers?
>
> I want to modify the destination IP address. I am doing the address
mapping,
> if i receive data for specific destination, i want to redirect that data
to
> go to another IP address. Do i need to allocate new buffers, copy all the
> data from old packet, modify it and then send it again. Can i do the
> following?
>
> 1. Query the NDIS packet.
> 2. Get the Virtual Address.
> 3. Modify the Header, with new IP and checksum.
> 4. Allocate new packet from my own pool.
> 5. Copy all the header information and OOB data.
> 6. Send that packet again.
>

No, you can't do that.

The simple rule is that unless you allocated the packet/buffer/VM youself,
then you cannot mofify it. Packets/buffers/VM that you did not allocate
yourself are logically read-only.

You will have to "clone" the original packet using a packet, buffers and VM
that you allocated yourself. Then modify the clone.

The "NDIS Packet Discussion" at NDIS.com mentions this. See the URL:

http://www.ndis.com/papers/ndispacket/ndispacket1.htm

Good luck,

Thomas F. Divine
>
> Can i use the same buffer and packet. Or i will have to allocate new
buffer
> and packet if i am modifing the data in the packet.
>
> Thanks in Advance
>
> Rajesh
>
>



Re: Question about modifing the NDIS packet? by Maxim

Maxim
Fri Jun 25 07:30:30 CDT 2004

Yes, you must allocate the separate chunk of memory, copy the data,
allocate NDIS_BUFFER to describe it, and allocate your own NDIS_PACKET for this
packet.

You cannot change the data in place.

Note: you will need NDIS_PACKET of your own even if you do not change any
data, unless you will use NDIS5.1 packet stacking.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


"Rajesh Gupta" <guptar@gmail.com> wrote in message
news:u3a6gdWWEHA.212@TK2MSFTNGP11.phx.gbl...
> Hi everyone,
>
> I am trying to modify the NDIS packet. Do i need to allocate new buffers?
>
> I want to modify the destination IP address. I am doing the address mapping,
> if i receive data for specific destination, i want to redirect that data to
> go to another IP address. Do i need to allocate new buffers, copy all the
> data from old packet, modify it and then send it again. Can i do the
> following?
>
> 1. Query the NDIS packet.
> 2. Get the Virtual Address.
> 3. Modify the Header, with new IP and checksum.
> 4. Allocate new packet from my own pool.
> 5. Copy all the header information and OOB data.
> 6. Send that packet again.
>
>
> Can i use the same buffer and packet. Or i will have to allocate new buffer
> and packet if i am modifing the data in the packet.
>
> Thanks in Advance
>
> Rajesh
>
>