2010-04-14 110 views
0

我试图打开一个套接字,它将接收通过Active Sync网络发送到Windows Mobile设备的所有数据包。Windows Mobile 6 - .net Socket建议[Compact Framework 3.5]

我使用代码:CS Network Sniffer for Windows

具体做法是:

//For sniffing the socket to capture the packets has to be a raw socket, with the 
//address family being of type internetwork, and protocol being IP 
mainSocket = new Socket(AddressFamily.InterNetwork, 
    SocketType.Raw, ProtocolType.IP); 

//Bind the socket to All Network Communication 
mainSocket.Bind(new IPEndPoint(IPAddress.Parse("169.254.2.1"), 0)); 

我通过活动同步

特异性结合的IP设置和以下套接字选项不可用在Windows Mobile上,是否有任何其他选项可以在Windows Mobile上使用以获得相同的效果?我看到在MSDN上没有太大的帮助名单 - msdn.microsoft.com/en-us/library/aa926870.aspx

//Set the socket options 
mainSocket.SetSocketOption(SocketOptionLevel.IP, //Applies only to IPv4 packets 
          SocketOptionName.HeaderIncluded, 
          true);       

byte[] byTrue = new byte[4] { 1, 0, 0, 0 }; 
byte[] byOut = new byte[4] { 1, 0, 0, 0 };  //Capture outgoing packets 

//Socket.IOControl is analogous to the WSAIoctl method of Winsock 2 
//IOControlCode.ReceiveAll is equivalent to SIO_RCVALL constant of Winsock 2 
mainSocket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut); 

最后的代码,即可获得:

//Start receiving the packets asynchronously 
mainSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None, 
    new AsyncCallback(OnReceive), null); 

再次,我的目标是通过Active Sync网络在我的Windows Mobile设备上的TCP和UDP的所有端口上接收所有传入数据包。 任何帮助,建议或代码非常感谢,C#,VB.net,C++都很好:)

回答

0

CE真的不能够做你在插座级别。你最好创建并安装一个NDIS Intermediate driver,你可以检查和处理所有通过的数据包。

请注意,ActiveSync连接不是完整的网络连接,而是部分RNDIS连接。某些数据包类型无法通过转发(例如ICMP)。

另外,不要对ActiveSync地址进行硬编码 - 它在过去和未来都会发生变化。而是做一个“ppp-peer”的DNS解析来获取地址。

相关问题