10 modified files
reactos/drivers/net/afd/afd
diff -u -r1.7 -r1.8
--- connect.c 4 Dec 2004 23:29:54 -0000 1.7
+++ connect.c 11 Dec 2004 14:59:31 -0000 1.8
@@ -1,4 +1,4 @@
-/* $Id: connect.c,v 1.7 2004/12/04 23:29:54 arty Exp $
+/* $Id: connect.c,v 1.8 2004/12/11 14:59:31 navaraf Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/connect.c
@@ -191,7 +191,7 @@
TdiBuildConnectionInfo
( &TargetAddress,
- ((PTRANSPORT_ADDRESS)&ConnectReq->RemoteAddress) );
+ &ConnectReq->RemoteAddress );
if( TargetAddress ) {
Status = TdiConnect( &FCB->PendingTdiIrp,
reactos/drivers/net/afd/afd
diff -u -r1.5 -r1.6
--- info.c 4 Dec 2004 23:29:54 -0000 1.5
+++ info.c 11 Dec 2004 14:59:31 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Id: info.c,v 1.5 2004/12/04 23:29:54 arty Exp $
+/* $Id: info.c,v 1.6 2004/12/11 14:59:31 navaraf Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/info.c
@@ -60,3 +60,53 @@
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL, FALSE );
}
+
+NTSTATUS STDCALL
+AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp ) {
+ NTSTATUS Status = STATUS_SUCCESS;
+ PFILE_OBJECT FileObject = IrpSp->FileObject;
+ PAFD_FCB FCB = FileObject->FsContext;
+ PMDL Mdl;
+
+ AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
+
+ if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, FALSE );
+
+ if( FCB->AddressFile.Object == NULL) {
+ return UnlockAndMaybeComplete( FCB, STATUS_UNSUCCESSFUL, Irp, 0,
+ NULL, FALSE );
+ }
+
+ Mdl = IoAllocateMdl
+ ( Irp->UserBuffer,
+ IrpSp->Parameters.DeviceIoControl.OutputBufferLength,
+ FALSE,
+ FALSE,
+ NULL );
+
+ if( Mdl != NULL ) {
+ _SEH_TRY {
+ MmProbeAndLockPages( Mdl, Irp->RequestorMode, IoModifyAccess );
+ } _SEH_HANDLE {
+ AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
+ Status = _SEH_GetExceptionCode();
+ } _SEH_END;
+
+ if( NT_SUCCESS(Status) ) {
+ Status = TdiQueryInformation
+ ( FCB->AddressFile.Object,
+ TDI_QUERY_ADDRESS_INFO,
+ Mdl );
+ }
+
+ /* MmUnlockPages( Mdl ); */
+ IoFreeMdl( Mdl );
+ } else {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
+
+ return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL, FALSE );
+}
reactos/drivers/net/afd/afd
diff -u -r1.15 -r1.16
--- main.c 4 Dec 2004 23:29:54 -0000 1.15
+++ main.c 11 Dec 2004 14:59:31 -0000 1.16
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.15 2004/12/04 23:29:54 arty Exp $
+/* $Id: main.c,v 1.16 2004/12/11 14:59:31 navaraf Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/main.c
@@ -359,6 +359,9 @@
case IOCTL_AFD_DISCONNECT:
return AfdDisconnect( DeviceObject, Irp, IrpSp );
+ case IOCTL_AFD_GET_SOCK_NAME:
+ return AfdGetSockName( DeviceObject, Irp, IrpSp );
+
case IOCTL_AFD_GET_TDI_HANDLES:
AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_TDI_HANDLES\n"));
break;
reactos/drivers/net/afd/afd
diff -u -r1.5 -r1.6
--- tdiconn.c 15 Nov 2004 18:24:57 -0000 1.5
+++ tdiconn.c 11 Dec 2004 14:59:31 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Id: tdiconn.c,v 1.5 2004/11/15 18:24:57 arty Exp $
+/* $Id: tdiconn.c,v 1.6 2004/12/11 14:59:31 navaraf Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/tdiconn.c
@@ -16,6 +16,7 @@
case AF_INET:
return sizeof(TA_IP_ADDRESS);
default:
+ AFD_DbgPrint(MID_TRACE,("TdiAddressSizeFromType - invalid type: %x\n", AddressType));
KeBugCheck( 0 );
}
return 0;
reactos/drivers/net/afd/include
diff -u -r1.26 -r1.27
--- afd.h 25 Nov 2004 23:36:36 -0000 1.26
+++ afd.h 11 Dec 2004 14:59:31 -0000 1.27
@@ -1,4 +1,4 @@
-/* $Id: afd.h,v 1.26 2004/11/25 23:36:36 arty Exp $
+/* $Id: afd.h,v 1.27 2004/12/11 14:59:31 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -178,6 +178,10 @@
AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp );
+NTSTATUS STDCALL
+AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp );
+
/* listen.c */
NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
reactos/drivers/net/afd/include
diff -u -r1.4 -r1.5
--- tdi_proto.h 4 Dec 2004 23:29:55 -0000 1.4
+++ tdi_proto.h 11 Dec 2004 14:59:31 -0000 1.5
@@ -24,4 +24,9 @@
PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
PTDI_CONNECTION_INFORMATION ReturnConnectionInfo );
+NTSTATUS TdiQueryInformation(
+ PFILE_OBJECT FileObject,
+ LONG QueryType,
+ PMDL MdlBuffer);
+
#endif/*_TDI_PROTO_H*/
reactos/drivers/net/tcpip/tcpip
diff -u -r1.30 -r1.31
--- dispatch.c 4 Dec 2004 23:29:55 -0000 1.30
+++ dispatch.c 11 Dec 2004 14:59:32 -0000 1.31
@@ -554,7 +554,8 @@
}
if (MmGetMdlByteCount(Irp->MdlAddress) <
- (sizeof(TDI_ADDRESS_INFO) + sizeof(TDI_ADDRESS_IP))) {
+ (FIELD_OFFSET(TDI_ADDRESS_INFO, Address.Address[0].Address) +
+ sizeof(TDI_ADDRESS_IP))) {
TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
return STATUS_BUFFER_OVERFLOW;
}
reactos/include/afd
diff -u -r1.13 -r1.14
--- shared.h 25 Nov 2004 23:35:06 -0000 1.13
+++ shared.h 11 Dec 2004 14:59:32 -0000 1.14
@@ -194,6 +194,7 @@
#define AFD_SEND_DATAGRAM 8
#define AFD_SELECT 9
#define AFD_DISCONNECT 10
+#define AFD_GET_SOCK_NAME 11
#define AFD_GET_TDI_HANDLES 13
#define AFD_SET_INFO 14
#define AFD_GET_CONTEXT 16
@@ -240,6 +241,8 @@
_AFD_CONTROL_CODE(AFD_SELECT, METHOD_BUFFERED )
#define IOCTL_AFD_DISCONNECT \
_AFD_CONTROL_CODE(AFD_DISCONNECT, METHOD_NEITHER)
+#define IOCTL_AFD_GET_SOCK_NAME \
+ _AFD_CONTROL_CODE(AFD_GET_SOCK_NAME, METHOD_NEITHER)
#define IOCTL_AFD_GET_TDI_HANDLES \
_AFD_CONTROL_CODE(AFD_GET_TDI_HANDLES, METHOD_NEITHER)
#define IOCTL_AFD_SET_INFO \
@@ -389,17 +392,6 @@
INT Status;
} FILE_REPLY_CONNECT, *PFILE_REPLY_CONNECT;
-
-typedef struct _FILE_REQUEST_GETNAME {
- BOOL Peer;
-} FILE_REQUEST_GETNAME, *PFILE_REQUEST_GETNAME;
-
-typedef struct _FILE_REPLY_GETNAME {
- INT Status;
- SOCKADDR Name;
- INT NameSize;
-} FILE_REPLY_GETNAME, *PFILE_REPLY_GETNAME;
-
#endif /*__AFD_SHARED_H */
/* EOF */
reactos/lib/msafd/misc
diff -u -r1.21 -r1.22
--- dllmain.c 4 Dec 2004 23:29:55 -0000 1.21
+++ dllmain.c 11 Dec 2004 14:59:32 -0000 1.22
@@ -335,9 +335,10 @@
/* Set up Address in TDI Format */
BindData->Address.TAAddressCount = 1;
BindData->Address.Address[0].AddressLength = SocketAddressLength - sizeof(SocketAddress->sa_family);
- RtlCopyMemory (&BindData->Address.Address[0].AddressType,
- SocketAddress,
- SocketAddressLength);
+ BindData->Address.Address[0].AddressType = SocketAddress->sa_family;
+ RtlCopyMemory (BindData->Address.Address[0].Address,
+ SocketAddress->sa_data,
+ SocketAddressLength - sizeof(SocketAddress->sa_family));
/* Get Address Information */
Socket->HelperData->WSHGetSockaddrType ((PSOCKADDR)SocketAddress,
@@ -519,7 +520,7 @@
/* Wait for Completition */
if (Status == STATUS_PENDING) {
- WaitForSingleObject(SockEvent, 0);
+ WaitForSingleObject(SockEvent, INFINITE);
}
/* Clear the Structures */
@@ -881,9 +882,10 @@
/* Set up Address in TDI Format */
ConnectInfo->RemoteAddress.TAAddressCount = 1;
ConnectInfo->RemoteAddress.Address[0].AddressLength = SocketAddressLength - sizeof(SocketAddress->sa_family);
- RtlCopyMemory (&ConnectInfo->RemoteAddress.Address[0].AddressType,
- SocketAddress,
- SocketAddressLength);
+ ConnectInfo->RemoteAddress.Address[0].AddressType = SocketAddress->sa_family;
+ RtlCopyMemory (ConnectInfo->RemoteAddress.Address[0].Address,
+ SocketAddress->sa_data,
+ SocketAddressLength - sizeof(SocketAddress->sa_family));
/* Tell AFD that we want Connection Data back, have it allocate a buffer */
if (lpCalleeData != NULL) {
@@ -997,7 +999,7 @@
/* Wait for return */
if (Status == STATUS_PENDING) {
- WaitForSingleObject(SockEvent, 0);
+ WaitForSingleObject(SockEvent, INFINITE);
}
AFD_DbgPrint(MID_TRACE,("Ending\n"));
@@ -1011,12 +1013,78 @@
INT
WSPAPI
WSPGetSockName(
- IN SOCKET s,
- OUT LPSOCKADDR name,
- IN OUT LPINT namelen,
+ IN SOCKET Handle,
+ OUT LPSOCKADDR Name,
+ IN OUT LPINT NameLength,
OUT LPINT lpErrno)
{
- return 0;
+ IO_STATUS_BLOCK IOSB;
+ ULONG TdiAddressSize;
+ PTDI_ADDRESS_INFO TdiAddress;
+ PTRANSPORT_ADDRESS SocketAddress;
+ PSOCKET_INFORMATION Socket = NULL;
+ NTSTATUS Status;
+ HANDLE SockEvent;
+
+ Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
+ NULL, 1, FALSE );
+
+ if( !NT_SUCCESS(Status) ) return SOCKET_ERROR;
+
+ /* Get the Socket Structure associate to this Socket*/
+ Socket = GetSocketStructure(Handle);
+
+ /* Allocate a buffer for the address */
+ TdiAddressSize = FIELD_OFFSET(TDI_ADDRESS_INFO,
+ Address.Address[0].Address) +
+ Socket->SharedData.SizeOfLocalAddress;
+ TdiAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize);
+
+ if ( TdiAddress == NULL ) {
+ NtClose( SockEvent );
+ *lpErrno = WSAENOBUFS;
+ return SOCKET_ERROR;
+ }
+
+ SocketAddress = &TdiAddress->Address;
+
+ /* Send IOCTL */
+ Status = NtDeviceIoControlFile( (HANDLE)Socket->Handle,
+ SockEvent,
+ NULL,
+ NULL,
+ &IOSB,
+ IOCTL_AFD_GET_SOCK_NAME,
+ NULL,
+ 0,
+ TdiAddress,
+ TdiAddressSize);
+
+ /* Wait for return */
+ if (Status == STATUS_PENDING) {
+ WaitForSingleObject(SockEvent, INFINITE);
+ Status = IOSB.Status;
+ }
+
+ NtClose( SockEvent );
+
+ if (NT_SUCCESS(Status)) {
+ if (*NameLength >= SocketAddress->Address[0].AddressLength) {
+ Name->sa_family = SocketAddress->Address[0].AddressType;
+ RtlCopyMemory (Name->sa_data,
+ SocketAddress->Address[0].Address,
+ SocketAddress->Address[0].AddressLength);
+ HeapFree(GlobalHeap, 0, TdiAddress);
+ return 0;
+ } else {
+ HeapFree(GlobalHeap, 0, TdiAddress);
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
+ }
+
+ return MsafdReturnWithErrno
+ ( IOSB.Status, lpErrno, 0, NULL );
}
@@ -1193,7 +1261,7 @@
/* Wait for return */
if (Status == STATUS_PENDING) {
- WaitForSingleObject(SockEvent, 0);
+ WaitForSingleObject(SockEvent, INFINITE);
}
/* Return Information */
@@ -1249,7 +1317,7 @@
/* Wait for return */
if (Status == STATUS_PENDING) {
- WaitForSingleObject(SockEvent, 0);
+ WaitForSingleObject(SockEvent, INFINITE);
}
NtClose( SockEvent );
@@ -1308,7 +1376,7 @@
/* Wait for Completition */
if (Status == STATUS_PENDING) {
- WaitForSingleObject(SockEvent, 0);
+ WaitForSingleObject(SockEvent, INFINITE);
}
NtClose( SockEvent );
reactos/lib/msafd/misc
diff -u -r1.15 -r1.16
--- sndrcv.c 5 Dec 2004 08:39:09 -0000 1.15
+++ sndrcv.c 11 Dec 2004 14:59:32 -0000 1.16
@@ -321,7 +321,7 @@
/* Wait for completition of not overlapped */
if (Status == STATUS_PENDING && lpOverlapped == NULL) {
- WaitForSingleObject(SockEvent, 0); // BUGBUG, shouldn wait infintely for receive...
+ WaitForSingleObject(SockEvent, INFINITE); // BUGBUG, shouldn wait infintely for receive...
Status = IOSB->Status;
}
@@ -437,7 +437,7 @@
/* Wait for completition of not overlapped */
if (Status == STATUS_PENDING && lpOverlapped == NULL) {
- WaitForSingleObject(SockEvent, 0); // BUGBUG, shouldn wait infintely for send...
+ WaitForSingleObject(SockEvent, INFINITE); // BUGBUG, shouldn wait infintely for send...
Status = IOSB->Status;
}
@@ -563,7 +563,7 @@
/* Wait for completition of not overlapped */
if (Status == STATUS_PENDING && lpOverlapped == NULL) {
- WaitForSingleObject(SockEvent, 0); // BUGBUG, shouldn wait infintely for send...
+ WaitForSingleObject(SockEvent, INFINITE); // BUGBUG, shouldn wait infintely for send...
Status = IOSB->Status;
}
CVSspam 0.2.8