C# supports only LAN packet sniffing

N

Nuno Magalhaes

Why does C# only supports LAN packet sniffing?
Should I have to use WinPCap if I want to capture the outgoing packets
on xp pro also?
Why this limitation?

Here's the source for capturing the packets (with dial-up and xp pro
connections it also gets me the incoming packets):

public void Run()
{
int len_receive_buf=4096;
int len_send_buf=4096;
byte[] receive_buf=new byte[len_receive_buf];
byte[] send_buf=new byte[len_send_buf];
int cout_receive_bytes;
Socket socket=new
Socket(AddressFamily.InterNetwork,SocketType.Raw,ProtocolType.IP);
socket.Blocking=false;
socket.Bind(new IPEndPoint(IPAddress.Parse(DefaultIPComboBox.Text),0));
socket.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.HeaderIncluded,1);
byte[] IN=new byte[4]{1,0,0,0};
byte[] OUT=new byte[4];
int SIO_RCVALL=unchecked((int)0x98000001);
int ret_code=socket.IOControl(SIO_RCVALL,IN,OUT);
while(true)
{
IAsyncResult
ar=socket.BeginReceive(receive_buf,0,len_receive_buf,SocketFlags.None,null,this);
cout_receive_bytes=socket.EndReceive(ar);
Receive(receive_buf);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top