Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Thu, 13 Sep 2007 10:08:30 -0700,    group: microsoft.public.platformsdk.networking        back       


LSP AcceptEx and getting the local and remote addresses   
I am having a hard time trying to get the local and remote addresses
in my LSP which intercepts AcceptEx.  When I call GetAcceptExSockaddrs
with the parameters passed to my AcceptEx function I get NULLs for all
the addresses.  Does anyone have any ideas?

This is the basic jist of the code.

BOOL PASCAL FAR
ExtAcceptEx(
	IN SOCKET sListenSocket,
	IN SOCKET sAcceptSocket,
	IN PVOID lpOutputBuffer,
	IN DWORD dwReceiveDataLength,
	IN DWORD dwLocalAddressLength,
	IN DWORD dwRemoteAddressLength,
	OUT LPDWORD lpdwBytesReceived,
	IN LPOVERLAPPED lpOverlapped)
{
  SOCKET_CONTEXT *ListenSocketContext = NULL;
  SOCKET_CONTEXT *AcceptSocketContext = NULL;
  sockaddr_in * localAddr  = 0;
  sockaddr_in * remoteAddr = 0;
  int remote_addr_len = sizeof(sockaddr_in);
  int local_addr_len = sizeof(sockaddr_in);
  int rc = FALSE;

  ListenSocketContext = FindSocketContext( sListenSocket );
...
  AcceptSocketContext = FindSocketContext( sAcceptSocket );
...

  GetAcceptExSockaddrs(lpOutputBuffer, dwReceiveDataLength,
dwLocalAddressLength, dwRemoteAddressLength, (sockaddr **) &localAddr,
&local_addr_len, (sockaddr **) &remoteAddr, &remote_addr_len);

//PROBLEM
//localAddr = 0
//remoteAddr = 0

....
  rc = ListenSocketContext->Provider->NextProcTableExt.lpfnAcceptEx(
				ListenSocketContext->Socket,
				AcceptSocketContext->Socket,
				lpOutputBuffer,
				dwReceiveDataLength,
				dwLocalAddressLength,
				dwRemoteAddressLength,
				lpdwBytesReceived,
				lpOverlapped
				);
...

  return rc;
}
date: Thu, 13 Sep 2007 10:08:30 -0700   author:   unknown

Re: LSP AcceptEx and getting the local and remote addresses   
Just additional question : do  you see any problems with connection when 
your LSP work ? If you succeed to send/receive data, that IP/ports should be 
seen in LSP, OTOH
you can just use GetTcpTable() for that
Arkady

 wrote in message 
news:1189703310.666540.11730@w3g2000hsg.googlegroups.com...
>I am having a hard time trying to get the local and remote addresses
> in my LSP which intercepts AcceptEx.  When I call GetAcceptExSockaddrs
> with the parameters passed to my AcceptEx function I get NULLs for all
> the addresses.  Does anyone have any ideas?
>
> This is the basic jist of the code.
>
> BOOL PASCAL FAR
> ExtAcceptEx(
> IN SOCKET sListenSocket,
> IN SOCKET sAcceptSocket,
> IN PVOID lpOutputBuffer,
> IN DWORD dwReceiveDataLength,
> IN DWORD dwLocalAddressLength,
> IN DWORD dwRemoteAddressLength,
> OUT LPDWORD lpdwBytesReceived,
> IN LPOVERLAPPED lpOverlapped)
> {
>  SOCKET_CONTEXT *ListenSocketContext = NULL;
>  SOCKET_CONTEXT *AcceptSocketContext = NULL;
>  sockaddr_in * localAddr  = 0;
>  sockaddr_in * remoteAddr = 0;
>  int remote_addr_len = sizeof(sockaddr_in);
>  int local_addr_len = sizeof(sockaddr_in);
>  int rc = FALSE;
>
>  ListenSocketContext = FindSocketContext( sListenSocket );
> ...
>  AcceptSocketContext = FindSocketContext( sAcceptSocket );
> ...
>
>  GetAcceptExSockaddrs(lpOutputBuffer, dwReceiveDataLength,
> dwLocalAddressLength, dwRemoteAddressLength, (sockaddr **) &localAddr,
> &local_addr_len, (sockaddr **) &remoteAddr, &remote_addr_len);
>
> //PROBLEM
> //localAddr = 0
> //remoteAddr = 0
>
> ....
>  rc = ListenSocketContext->Provider->NextProcTableExt.lpfnAcceptEx(
> ListenSocketContext->Socket,
> AcceptSocketContext->Socket,
> lpOutputBuffer,
> dwReceiveDataLength,
> dwLocalAddressLength,
> dwRemoteAddressLength,
> lpdwBytesReceived,
> lpOverlapped
> );
> ...
>
>  return rc;
> }
>
date: Fri, 14 Sep 2007 07:29:19 +0300   author:   Arkady Frenkel

Re: LSP AcceptEx and getting the local and remote addresses   
I got the answer from someone at Microsoft.  GetAcceptSockaddrs needs
to be called after the base lpnfAcceptEx is called.  Plus it needs to
be called from the base provider.

But know I must not be understanding something correct.

I am writing an LSP which will deny access to certain remote IP's.
When I am running MS FTP Server and I connect from another machine,
the first time my ExtAcceptEx is called 5 times right when the FTP
client tries to connect.  I then disconnect the ftp client.  If I
connect again, ExtAcceptEx isn't called until AFTER the ftp client is
disconnected.  Note: I am running in debug mode and attaching to
inetinfo.exe with stops in my ExtAcceptEx function to determine this.

How would I intercept every connection everytime when using a server
that is using I/O completion ports, using an LSP?
date: Sat, 15 Sep 2007 22:32:50 -0700   author:   unknown

Re: LSP AcceptEx and getting the local and remote addresses   
You can  close socket after acception too, even without
LSP but in app itself
Arkady

 wrote in message 
news:1189920770.270705.322630@50g2000hsm.googlegroups.com...
>I got the answer from someone at Microsoft.  GetAcceptSockaddrs needs
> to be called after the base lpnfAcceptEx is called.  Plus it needs to
> be called from the base provider.
>
> But know I must not be understanding something correct.
>
> I am writing an LSP which will deny access to certain remote IP's.
> When I am running MS FTP Server and I connect from another machine,
> the first time my ExtAcceptEx is called 5 times right when the FTP
> client tries to connect.  I then disconnect the ftp client.  If I
> connect again, ExtAcceptEx isn't called until AFTER the ftp client is
> disconnected.  Note: I am running in debug mode and attaching to
> inetinfo.exe with stops in my ExtAcceptEx function to determine this.
>
> How would I intercept every connection everytime when using a server
> that is using I/O completion ports, using an LSP?
>
date: Mon, 17 Sep 2007 10:20:38 +0200   author:   Arkady Frenkel

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us