views:

187

answers:

2

I am working on an very old application right now. I need to make change in this application to listen for coming icmp request and decide to reply or drop the packet (kind of access control on ICMP). The application is Winsock version 1.1 based. I tried different ways to create a socket and capture icmp packet using the socket. But none of my efforts worked.

Can anyone help me out? Or is it totally impossible?

Thank you very much for your answer.

A: 

I don't think you will be able to intercept ICMP packets at the application (Winsock) level, since this is not an application function. You will probably need to write a network filter driver for whichever version of Windows your application runs on.

Greg Hewgill
A: 

You say the application is old, but nothing about the OSes you're running it on. Unless you're running it on 16-bit Windows or NT 3.x, there's no good reason you can't just migrate to Winsock 2. You can download Winsock 2 for Win95, and it comes in all later Win9x OSes, as well as in Windows NT 4 and up.

If you really must run this app on Win16, it may be possible to dig up one of the third-party Winsock stacks from that era that did offer raw sockets support, but that sounds like a huge hassle, if you want to do it legally. Easier to just specify Win98 as a minimum OS version and move on.

EDIT: I'm assuming you can do what you want with raw sockets, which requires moving to Winsock 2 if you must use the built-in Winsock in MS operating systems. Changing your program to use Winsock 2 instead of Winsock 1.1 is easy; one library change, one header file change, and a change to the WSAStartup call, and there you are. Raw ICMP sockets let you construct any ICMP packet you want, and in newer OSes you may be able to listen for ICMP packets, too. If it turns out that the stack won't let you listen for the packets you need via sockets, you can do it with packet capturing techniques instead.

Warren Young