Home › Forums › Discussions › Support › Send out modified ip packets, but no reponse ( NAT )
- This topic has 4 replies, 2 voices, and was last updated 20 years, 2 months ago by hoowaycn.
-
AuthorPosts
-
September 10, 2004 at 9:30 am #4876
In the NAT application, I only relay ICMP( ping ) packets
The NAT has 2 interface, one is ethernet connecting local network
, the other is PPP for internet.It can get the packets from the client,
adn when the NAT replace the dest ip address, re-calc the checksum, and
send to MSTCP stack. We never get the response, NO data received
from the PPP adapter. Is there any problem with my code?Another ques: when I call SendPacketToMstcp(), should I also get this packet
at PACKET_FLAG_ON_SEND at the other adapter when MSTCP send it to interface?
I tried, but not get the packet.Below is my code.
….
// set MODE to MSTCP_FLAG_SENT_TUNNEL|MSTCP_FLAG_RECV_TUNNEL to all adapters
….
while (!bAppClose)
{
dwRe=WaitForMultipleObjects(nCount, arrEvents, FALSE , 1000);
if( ( dwRe < WAIT_OBJECT_0 )|| ( dwRe > WAIT_OBJECT_0+nCount-1) )
continue ;hEvent=arrEvents[dwRe-WAIT_OBJECT_0];
ResetEvent(hEvent);/// find associated Adapter
if ( !mapAdapter.Lookup( hEvent, adp ))
continue ;ZeroMemory ( &Request, sizeof(ETH_REQUEST) );
ZeroMemory ( &PacketBuffer, sizeof(INTERMEDIATE_BUFFER) );Request.EthPacket.Buffer = &PacketBuffer;
Request.hAdapterHandle = (HANDLE)adp.hAdpHandle;while(api.ReadPacket(&Request))
{
/// read data
if (PacketBuffer.m_dwDeviceFlags == PACKET_FLAG_ON_SEND)
{
api.SendPacketToAdapter(&Request);
}
else
{
pEthHeader = (ether_header*)PacketBuffer.m_IBuffer;
if(ntohs(pEthHeader->h_proto) == ETH_P_IP)
{
pIpHeader=(iphdr*)(PacketBuffer.m_IBuffer +14 );//// substitute the source ip with nat address
pIpHeader->ip_src=natAddr;
pIpHeader->ip_sum=0;
/// calac the checksum
pIpHeader->ip_sum=ip_checksum((unsigned char*)pIpHeader, 20 );
}
// send packet to MSTCP
api.SendPacketToMstcp(&Request);
}
}}
September 10, 2004 at 11:51 am #5627In order to analyze your code I would also need to analyze the environment it runs in. However, check if you have enable IP routing (forwarding) since it is disabled by the default and TCP/IP will just drop the packets from the interface if they don’t match interface address information.
Another ques: when I call SendPacketToMstcp(), should I also get this packet at PACKET_FLAG_ON_SEND at the other adapter when MSTCP send it to interface? I tried, but not get the packet.
No, this flag has informational purpose only (for you reference if packet was received from the network or from the stack).
September 10, 2004 at 2:07 pm #5628It’s XP. For the PPP, I use RasPPPoE.
Enable IP routing? Do you mean set
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters
IPEnableRouter to 1.Oh, I did it.
And test again, still no response!!
Do you need to see the whole code?
September 13, 2004 at 5:28 am #5629I run a sniffer to monitor the packets
and find that MSTCP doest not send out my nat packets.
What’s reason cause it to drop the packets?Can someone send a NAT sample, so I can whether it computer
configuration problem or my nat problem.September 16, 2004 at 6:59 am #5630Can anyone help me to solve this problem?If I solve this problem in my evaluation, I would purchase one.
-
AuthorPosts
- You must be logged in to reply to this topic.