Thomas
Thu Nov 24 18:41:59 CST 2005
"pserge" <pserge@ipnet.kiev.ua> wrote in message
news:dm58e2$7ov$1@news.dg.net.ua...
> Hello, Thomas!
> You wrote on Wed, 23 Nov 2005 21:10:41 -0500:
>
> Please find my comments below.
>
>>> I am trying to develop a NAT server using my NDIS IM driver.
>>>
>>> Within ProtocolReceive() I change packets' IP address and port numbers,
>>> update checksums, and indicate it up.
>>>
>>> But seems like packets are not getting to destination.
>>> Could anybody tell me why this may happen?
>>> I do not change mac adresses - is that a problem?
>>> Or do I need to NdisSend packet instead of indicating it?
>
>> Could be that the packet is malformed. The first buffer must include
>> the MAC header and the lookahead data or it will be ignored. See
>> NDIS.com:
>>
http://www.ndis.com/pcakb/KB01060101.htm
>
> 1) I am using single NDIS_BUFFER for entire packet.
> 2) Tried to set NDIS_STATUS_RESOURCES - no luck.
>
>> It could also be incorrect handling of NDIS Task Offload. See NDIS.com:
>>
http://www.ndis.com/pcakb/KB05280101.htm
>
> I return NDIS_STATUS_NOT_SUPPORTED for OID_TCP_TASK_OFFLOAD...
> Also, UDP packets are not getting to destonation, as well.
>
> Do I need to change only IP and port in order to implement a NAT?
> Should I indicate packet to different adapter instead of that one, I
> received it for?
>
> As for me, such behavior I faced is correct, but not one I want to
> achieve.
>
> (A) --> (B with NAT) --> (C)
>
> TCP stack (B) receives modified packet from (A), checks its destination IP
> addres, that does not belong to the same computer, and drops it. Am I
> right?
>
Well, the received NATed packet must be indicated to TCP on the adapter with
IP address matching the NATed packet's destination IP address.
In addition, for directed receive packets the destination link address must
be the MAC address of the adapter that the NATed packet is being indicated
on.
The rules are a little different for broadcast and multicast packets. Study
broadcast addressing for both the link and the IP level.
Good luck,
Thomas F. Divine, Windows DDK MVP
http://www.rawether.net