WinSock LSP Problem - Please Help

Hi everyone,

I'm having some difficulty writing a WinSock LSP, I've tried many of the MS samples that are available with different versions of the SDK and while I can get them all to complie and install I can't get them to pass any trafficthrough, its as though I no longer have a network connection.

To get the SDK samples to compile I had to make a few changes in the code which may of effected it, I've also tried running nMake (both the vs6 version and the one that comes with the SDK) and I get the following error from unedited code

makefile(5) : fatal error U1083: target macro '' expands to nothing

Stop.

I was wondering if anyone had any sample code they could send me that may work, an LSP that just passes all calls staight through to the lower layer would be great.

The LSP that I need to write will inject a small binary code into the IP header options field of every packet that passes through.
I'm running XP SP2 and developing in VS6.

I've been trying this for almost a month now and could really do with talking to someone who has managed to do this before.

Thanks in advance, Tom

[1633 byte] By [tomblane] at [2008-2-3]
# 1
Where did you get the LSP sample from? The latest sample and best practices whitepaper can always be obtained by going to the Windows Network Developer Platform (WNDP) Connect site: http://connect.microsoft.com . Join the WNDP program, go to the downlaods section and grab that sample. This works without modification. Also, be sure to grab the latest SDK available from MSDN
MikeFlasko at 2007-9-4 > top of Msdn Tech,Windows Networking Development,Winsock Kernel (WSK)...
# 2

Hi Mike, Thanks for the suggestion, I am a member of the WNDP and I have tried the latest samples with the same problems. At the moment I’m using a modified sample written by Anthony Jones (author of Network Programming for Microsoft Windows) which compiles and runs and does pass traffic through but is unable to modify any traffic that passes through; I can receive debug messages (using DbgView) that show the LSP is running the function I have written but it doesn’t seam to make any changes to the IP header. I’m wondering if I am trying to set the options at the wrong place or if something is silently resetting/disregarding the call to set the options.

This is the function I have written which is called in WSPSend( )

void InjectScent(SOCKET s, LPINT lpErrno){
int retErr=NO_ERROR;

DWORD scent[1]= {69};
dbgprint("in Inject Scent");
dbgprint("Scent 1 = %d",scent);

retErr = WSPSetSockOpt(

s,
IPPROTO_IP,
IP_OPTIONS,
(char *)&scent,
sizeof(scent),
lpErrno);

if (retErr!=NO_ERROR){
dbgprint("~#~#~#~#~# Finishing 1 with errors #~#~#~#~#~");
dbgprint("ERROR = %d",*lpErrno);
}
else
{
dbgprint("~#~#~#~#~# Finishing 1 WITHOUT errors #~#~#~#~#~");
}
}

Any other ideas would be much appreciated, I would be happy to send you the full code if you are interested. I can be contacted directly on Thomas.Blane@HP.com if desired.

Thanks Again, Tom

tomblane at 2007-9-4 > top of Msdn Tech,Windows Networking Development,Winsock Kernel (WSK)...
# 3
I believe that the problem is with setsockopt, not with your LSP. If you're still looking for a solution to this problem, see this web site:

http://www.sockets.com/ws2_stat.htm

The information on that page is very old, but it still seems to be accurate. I ran some tests today on XP with SP2, and it worked exactly the way he described it (i.e. the setsockopt/getsockopt calls succeed, but they don't affect the packet headers). I ran the tests from an LSP and from a normal Windows application, and I couldn't get it to work in either one.

Sean

sponeil at 2007-9-4 > top of Msdn Tech,Windows Networking Development,Winsock Kernel (WSK)...