From: tzachid Date: Mon, 21 Nov 2005 12:26:22 +0000 (+0000) Subject: Implement ARP mechanism as well as a mechanism for the local port. (Rev 428) X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=3959957bbe468f65a40919abfe6a0a175393ecb2;p=~shefty%2Frdma-win.git Implement ARP mechanism as well as a mechanism for the local port. (Rev 428) git-svn-id: svn://openib.tc.cornell.edu/gen1@177 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/ulp/sdp/include/SdpShared.h b/trunk/ulp/sdp/include/SdpShared.h index 6638927d..36215b55 100644 --- a/trunk/ulp/sdp/include/SdpShared.h +++ b/trunk/ulp/sdp/include/SdpShared.h @@ -31,10 +31,15 @@ struct WspSocketOut { VOID *pSocket; }; +const int MAC_ADDR_SIZE = 6; +typedef char MAC_ADDR[MAC_ADDR_SIZE] ; + struct WspConnectIn { - VOID *pSocket; - ULONG IP; - USHORT Port; + VOID *pSocket; + ULONG SrcIP; + MAC_ADDR DestMac; + ULONG DestIP; + USHORT DestPort; }; struct WspConnectOut { diff --git a/trunk/ulp/sdp/kernel/Precompile.h b/trunk/ulp/sdp/kernel/Precompile.h index 55ac814a..0fca28d9 100644 --- a/trunk/ulp/sdp/kernel/Precompile.h +++ b/trunk/ulp/sdp/kernel/Precompile.h @@ -14,6 +14,7 @@ class SdpSocket; class SdpArp; #include "ib_al.h" +#include "..\..\ipoib\ip_addresses_shared.h" #include "sdpMsgs.h" #include "SdpGenUtils.h" diff --git a/trunk/ulp/sdp/kernel/SdpArp.cpp b/trunk/ulp/sdp/kernel/SdpArp.cpp index 3eb115ab..43bced95 100644 --- a/trunk/ulp/sdp/kernel/SdpArp.cpp +++ b/trunk/ulp/sdp/kernel/SdpArp.cpp @@ -4,11 +4,331 @@ #pragma warning(disable: 4244 ) +NTSTATUS +SdpArp::Init() +{ + SDP_PRINT(SDP_TRACE, SDP_SOCKET,("Entering")); + + NTSTATUS rc = STATUS_SUCCESS; + UNICODE_STRING DevName; + IO_STATUS_BLOCK ioStatus; + m_DeviceObject = NULL; + + OBJECT_ATTRIBUTES objectAttributes; + + RtlInitUnicodeString( &DevName, IPOIB_DEV_NAME ); + + InitializeObjectAttributes( &objectAttributes, + &DevName, + OBJ_KERNEL_HANDLE, + (HANDLE) NULL, + (PSECURITY_DESCRIPTOR) NULL ); + + // Try to open the IPOIB device object + // + // The reason for using ZwOpenFile instead of IoGetDeviceObjectPointer + // is to keep the handle around because the NDISPROT makes an assumption + // that there is no I/O requests between Cleanup and Close requests. + // + rc = ZwOpenFile( &m_FileHandle, + STANDARD_RIGHTS_ALL, + &objectAttributes, + &ioStatus, + 0, + FILE_NON_DIRECTORY_FILE ); + if (!NT_SUCCESS( rc )) { + SDP_PRINT(SDP_ERR, SDP_ARP, ("ZwOpenFile failed rc = 0x%x\n", rc )); + goto Cleanup; + } + + // + // obtain a pointer to the device object for the handle. + // + rc = ObReferenceObjectByHandle(m_FileHandle, + THREAD_ALL_ACCESS, + *IoFileObjectType, + KernelMode, + (PVOID *) &m_FileObject, + NULL ); + if (!NT_SUCCESS( rc )) { + SDP_PRINT(SDP_ERR, SDP_ARP, ("ObReferenceObjectByHandle failed rc = 0x%x\n", rc )); + goto Cleanup; + } + + // This is what we are looking for + m_DeviceObject = IoGetRelatedDeviceObject(m_FileObject); + +Cleanup: + if (!NT_SUCCESS( rc )) { + if (m_FileHandle) { + ZwClose(m_FileHandle); + m_FileHandle = NULL; + } + if (m_FileObject) { + ObDereferenceObject(m_FileObject); + m_FileObject = NULL; + } + } + return rc; + +} + +VOID +SdpArp::Shutdown() +{ + SDP_PRINT(SDP_TRACE, SDP_SOCKET,("this = %p\n", this)); + if (m_FileHandle) { + ZwClose(m_FileHandle); + m_FileHandle = NULL; + } + if (m_FileObject) { + ObDereferenceObject(m_FileObject); + m_FileObject = NULL; + } + m_DeviceObject = NULL; // Not valid any more +} + + +NTSTATUS +SdpArp::SourcePortGidFromIP( + IN ULONG SourceAddr, + OUT ib_net64_t *SrcPortGuid, + OUT ib_net64_t *SrcCaGuid + ) +{ + SDP_PRINT(SDP_TRACE, SDP_SOCKET,("IP = %d.%d.%d.%d\n", + (SourceAddr & 0xff000000) >> 24, + (SourceAddr & 0xff0000) >> 16, + (SourceAddr & 0xff00) >> 8 , + SourceAddr & 0xff + )); + NTSTATUS rc = STATUS_SUCCESS; + KEVENT event; + PIRP irp; + IO_STATUS_BLOCK ioStatus; + char temp [1000]; // BUGBUG: Handle the case of more IPs + + IOCTL_IPOIB_PORTS_IN ipoib_ports_in; + IOCTL_IPOIB_PORTS_OUT *pipoib_ports_out; + IPOIB_AT_PORT_RECORD *ports_records; + + ipoib_ports_in.Version = IPOIB_IOCTL_VERSION; + ipoib_ports_in.Size = sizeof temp; + + pipoib_ports_out = (IOCTL_IPOIB_PORTS_OUT *)temp; + + ASSERT(m_DeviceObject != NULL); + + KeInitializeEvent(&event, NotificationEvent, FALSE); + irp = IoBuildDeviceIoControlRequest( + IOCTL_IPOIB_PORTS , + m_DeviceObject, + &ipoib_ports_in, + sizeof ipoib_ports_in, + pipoib_ports_out, + sizeof temp, + TRUE, + &event, + &ioStatus + ); + + if(NULL == irp) { + rc = STATUS_INSUFFICIENT_RESOURCES; + SDP_PRINT(SDP_ERR, SDP_ARP, ("IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc )); + goto Cleanup; + } + + rc = IoCallDriver(m_DeviceObject, irp); + if(STATUS_PENDING == rc) { + KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); + } + else { + ioStatus.Status = rc; + } + + if(!NT_SUCCESS(rc)) { + SDP_PRINT(SDP_ERR, SDP_ARP, ("IoCallDriver failed rc = 0x%x\n", rc )); + goto Cleanup; + } + if (pipoib_ports_out->Size != 0) { + // The number of bytes that we have allocated wasn't enough + SDP_PRINT(SDP_ERR, SDP_ARP, ("pipoib_ports_out.Size = %d\n", pipoib_ports_out->Size )); + rc = STATUS_INSUFFICIENT_RESOURCES; + goto Cleanup; + // BUGBUG: We should try again, with a bigger buffer + } + + rc = SourcePortGidFromPorts(SourceAddr, pipoib_ports_out, SrcPortGuid, SrcCaGuid); + if(!NT_SUCCESS(rc)) { + SDP_PRINT(SDP_ERR, SDP_ARP, ("SourcePortGidFromPorts failed rc = 0x%x\n", rc )); + goto Cleanup; + } + +Cleanup: + return rc; +} + +NTSTATUS +SdpArp::SourcePortGidFromPorts( + IN ULONG SourceAddr, + IN IOCTL_IPOIB_PORTS_OUT *pPorts, + OUT ib_net64_t *SrcPortGuid, + OUT ib_net64_t *SrcCaGuid + ) +{ + SDP_PRINT(SDP_TRACE, SDP_SOCKET,("Entered\n")); + NTSTATUS rc = STATUS_SUCCESS; + KEVENT event; + PIRP irp; + IO_STATUS_BLOCK ioStatus; + + unsigned int i = 0, j = 0; + + struct IOCTL_IPOIB_IP_ADDRESSES_IN addresses_in; + struct IOCTL_IPOIB_IP_ADDRESSES_OUT *addresses_out; + char temp[1000]; + addresses_out = (struct IOCTL_IPOIB_IP_ADDRESSES_OUT *)temp; + + addresses_in.Version = IPOIB_IOCTL_VERSION; + + for (i = 0 ; i < pPorts->NumPorts; i++) { + SDP_PRINT(SDP_TRACE, SDP_SOCKET, ( + "%d: ca guid = 0x%I64x port guid=0x%I64x\n", + i, CL_NTOH64(pPorts->Ports[i].CaGuid), CL_NTOH64(pPorts->Ports[i].PortGuid))); + + // Do a quary to find out if this is the correct port + ASSERT(m_DeviceObject != NULL); + + addresses_in.PortGuid = pPorts->Ports[i].PortGuid; + + KeInitializeEvent(&event, NotificationEvent, FALSE); + irp = IoBuildDeviceIoControlRequest( + IOCTL_IPOIB_IP_ADDRESSES , + m_DeviceObject, + &addresses_in, + sizeof addresses_in, + addresses_out, + sizeof temp, + TRUE, + &event, + &ioStatus + ); + + if(NULL == irp) { + rc = STATUS_INSUFFICIENT_RESOURCES; + SDP_PRINT(SDP_ERR, SDP_ARP, ("IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc )); + goto Cleanup; + } + + rc = IoCallDriver(m_DeviceObject, irp); + if(STATUS_PENDING == rc) { + KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); + } + else { + ioStatus.Status = rc; + } + + if(!NT_SUCCESS(rc)) { + SDP_PRINT(SDP_ERR, SDP_ARP, ("IoCallDriver failed rc = 0x%x\n", rc )); + goto Cleanup; + } + if (addresses_out->Size != 0) { + // The number of bytes that we have allocated wasn't enough + SDP_PRINT(SDP_ERR, SDP_ARP, ("addresses_out.Size = %d\n", addresses_out->Size )); + rc = STATUS_INSUFFICIENT_RESOURCES; + goto Cleanup; + // BUGBUG: We should try again, with a bigger buffer + } + + + // We now have the addreses, we can check if this is what we need + for (j = 0 ; j < addresses_out->NumIps; j++) { + ULONG *pIp; + ASSERT(addresses_out->Addreses[j].IpVersion == 4); + pIp = (ULONG *) (&addresses_out->Addreses[j].Data[12]); + if (*pIp == CL_NTOH32(SourceAddr)) { + SDP_PRINT(SDP_TRACE, SDP_ARP, + ("Found the IP: ca guid = 0x%I64x port guid=0x%I64x\n", + CL_NTOH64(pPorts->Ports[i].CaGuid), CL_NTOH64(pPorts->Ports[i].PortGuid))); + ASSERT(rc == STATUS_SUCCESS); + *SrcPortGuid = pPorts->Ports[i].PortGuid; + *SrcCaGuid = pPorts->Ports[i].CaGuid; + goto Cleanup; + } + + } + + } + // If we have reached here the data was not found + rc = STATUS_NOT_FOUND; + +Cleanup: + return rc; + +} + + +NTSTATUS +SdpArp::DestPortGidFromMac( + IN MAC_ADDR DestMac, + OUT ib_gid_t *pDestPortGid) +{ + SDP_PRINT(SDP_TRACE, SDP_SOCKET,("MAC = ????")); + NTSTATUS rc = STATUS_SUCCESS; + + KEVENT event; + PIRP irp; + IO_STATUS_BLOCK ioStatus; + + IOCTL_IPOIB_MAC_2_GID_IN ipoib_mac2gid_in; + IOCTL_IPOIB_MAC_2_GID_OUT ipoib_mac2gid_out; + + C_ASSERT(MAC_ADDR_SIZE == sizeof (ipoib_mac2gid_in.DestMac)); + memcpy(ipoib_mac2gid_in.DestMac, DestMac, MAC_ADDR_SIZE); + + ASSERT(m_DeviceObject != NULL); + + KeInitializeEvent(&event, NotificationEvent, FALSE); + irp = IoBuildDeviceIoControlRequest( + IOCTL_IPOIB_MAC_2_GID , + m_DeviceObject, + &ipoib_mac2gid_in, + sizeof ipoib_mac2gid_in, + &ipoib_mac2gid_out, + sizeof ipoib_mac2gid_out, + TRUE, + &event, + &ioStatus + ); + + if(NULL == irp) { + rc = STATUS_INSUFFICIENT_RESOURCES; + SDP_PRINT(SDP_ERR, SDP_ARP, ("IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc )); + goto Cleanup; + } + + rc = IoCallDriver(m_DeviceObject, irp); + if(STATUS_PENDING == rc) { + KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); + } + else { + ioStatus.Status = rc; + } + + if(!NT_SUCCESS(rc)) { + SDP_PRINT(SDP_ERR, SDP_ARP, ("IoCallDriver failed rc = 0x%x\n", rc )); + goto Cleanup; + } + + *pDestPortGid = ipoib_mac2gid_out.DestGid; +Cleanup: + return rc; +} NTSTATUS SdpArp::QueryPathRecord( IN ib_net64_t SrcPortGuid, - IN ib_net64_t DestPortGuid, + IN ib_gid_t DestPortGid, OUT ib_path_rec_t *path_rec ) { NTSTATUS rc = STATUS_SUCCESS; @@ -28,13 +348,13 @@ SdpArp::QueryPathRecord( query_req.pfn_query_cb = SdpArp::query_pr_callback; ib_gid_set_default( &user_query.src_gid, SrcPortGuid ); - ib_gid_set_default( &user_query.dest_gid, DestPortGuid ); + + user_query.dest_gid = DestPortGid; query_context.path_rec = path_rec; - SDP_PRINT( SDP_TRACE, SDP_ARP, - ("Query for path from %I64x to %I64x\n", - SrcPortGuid, DestPortGuid) ); + SDP_PRINT( SDP_TRACE, SDP_ARP, ("Query for path from %I64x to %I64x\n", + SrcPortGuid, DestPortGid.unicast.interface_id) ); ib_status = ib_query( g_pSdpDriver->m_al_handle, &query_req, &query_handle ); diff --git a/trunk/ulp/sdp/kernel/SdpArp.h b/trunk/ulp/sdp/kernel/SdpArp.h index 2b433b1b..e8eb2028 100644 --- a/trunk/ulp/sdp/kernel/SdpArp.h +++ b/trunk/ulp/sdp/kernel/SdpArp.h @@ -11,70 +11,22 @@ class SdpArp { public: + SdpArp() { + m_DeviceObject = NULL; + m_FileObject = NULL; + m_FileHandle = NULL; + + } + struct query_pr_context { ib_api_status_t status; ib_path_rec_t *path_rec; }; - NTSTATUS Init() { return STATUS_SUCCESS;} - - NTSTATUS SourceAddrFromDestAddr( - IN ULONG DestIp, - OUT ULONG *SrcIp - ) - { - NTSTATUS rc = STATUS_SUCCESS; - if (DestIp == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 57) { - *SrcIp = 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 159; - return STATUS_SUCCESS; - } - - if (DestIp == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 63) { - *SrcIp = 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 159; - return STATUS_SUCCESS; - } - - if (DestIp == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 157) { - *SrcIp = 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 154; - return STATUS_SUCCESS; - } - - if (DestIp == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 152) { - *SrcIp = 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 151; - return STATUS_SUCCESS; - } - - - ASSERT(FALSE); - *SrcIp = 0; - return STATUS_UNEXPECTED_IO_ERROR; + NTSTATUS Init(); - } + VOID Shutdown(); NTSTATUS GetPort( IN ULONG SourceAddr, @@ -93,134 +45,11 @@ public: IN ULONG SourceAddr, OUT ib_net64_t *SrcPortGuid, OUT ib_net64_t *SrcCaGuid - ) - { - if (SourceAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 159) { -// *SrcPortGuid = CL_NTOH64(0x2c90200002001);//????? swlab120 -// *SrcCaGuid = CL_NTOH64(0x2c90200002000); - - *SrcPortGuid = CL_NTOH64(0x2c9010b7c4361);//????? swlab159 - *SrcCaGuid = CL_NTOH64(0x2c9010b7c4360); - return STATUS_SUCCESS; - } - if (SourceAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 63) { - - *SrcPortGuid = CL_NTOH64(0x2c901093d8432);//????? swlab63 - *SrcCaGuid = CL_NTOH64(0x2c901093d8430); - return STATUS_SUCCESS; - } - - if (SourceAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 154) { - - *SrcPortGuid = CL_NTOH64(0x2c9000100d151);//????? swlab63 - *SrcCaGuid = CL_NTOH64(0x2c9000100d150); - return STATUS_SUCCESS; - } - - if (SourceAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 157) { - - *SrcPortGuid = CL_NTOH64(0x2c9000100d051);//????? swlab63 - *SrcCaGuid = CL_NTOH64(0x2c9000100d050); - return STATUS_SUCCESS; - } - - if (SourceAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 151) { - - *SrcPortGuid = CL_NTOH64(0x2c9010a66d25a);//????? swlab63 - *SrcCaGuid = CL_NTOH64(0x2c9010a66d259); - return STATUS_SUCCESS; - } - - if (SourceAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 152) { - - *SrcPortGuid = CL_NTOH64(0x2c9010b29b661);//????? swlab63 - *SrcCaGuid = CL_NTOH64(0x2c9010b29b660); - return STATUS_SUCCESS; - } - - ASSERT(FALSE); - *SrcPortGuid = 0; - *SrcCaGuid = 0; - return STATUS_UNEXPECTED_IO_ERROR; - - } + ); + NTSTATUS DestPortGidFromMac( + IN MAC_ADDR DestMac, + OUT ib_gid_t *pDestPortGid); - - // Get the remote GID based on it's IP addresses - NTSTATUS DestPortGidFromIP( - IN ULONG DestAddr, - OUT ib_net64_t *DestPortGuid) - { - if (DestAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 170) { - //*DestPortGuid = CL_NTOH64(0x0000c900012a3a41);//????? swlab124 - //*DestPortGuid = CL_NTOH64(0x0002c90200400301);//????? swlab170 - *DestPortGuid = CL_NTOH64(0x0002c902004002fe);//????? swlab170 - - return STATUS_SUCCESS; - } - if (DestAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 63) { - *DestPortGuid = CL_NTOH64(0x2c901093d8432);//????? swlab63 - - return STATUS_SUCCESS; - } - - if (DestAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 57) { - *DestPortGuid = CL_NTOH64(0x2c90108a03611);//????? swlab57 - - return STATUS_SUCCESS; - } - - if (DestAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 157) { - *DestPortGuid = CL_NTOH64(0x2c9000100d051);//????? swlab57 - - return STATUS_SUCCESS; - } - - if (DestAddr == 11 * 256*256*256 + - 4 * 256*256 + - 8 * 256 + - + 152) { - *DestPortGuid = CL_NTOH64(0x2c9010b29b661);//????? swlab57 - - return STATUS_SUCCESS; - } - - - ASSERT(FALSE); - *DestPortGuid = 0; - return STATUS_UNEXPECTED_IO_ERROR; - - } /* Synchronously query the SA for a GUID. (started from wsd - query_pr) */ @@ -231,12 +60,29 @@ Synchronously query the SA for a GUID. (started from wsd - query_pr) NTSTATUS QueryPathRecord( IN ib_net64_t SrcPortGuid, - IN ib_net64_t DestPortGuid, + IN ib_gid_t DestPortGid, OUT ib_path_rec_t *path_rec ); static void AL_API query_pr_callback( IN ib_query_rec_t *p_query_rec); + + private : + PDEVICE_OBJECT m_DeviceObject; + PFILE_OBJECT m_FileObject; + HANDLE m_FileHandle; + + + + NTSTATUS + SourcePortGidFromPorts( + IN ULONG SourceAddr, + IN IOCTL_IPOIB_PORTS_OUT *pPorts, + OUT ib_net64_t *SrcPortGuid, + OUT ib_net64_t *SrcCaGuid + ); + + }; diff --git a/trunk/ulp/sdp/kernel/SdpDriver.cpp b/trunk/ulp/sdp/kernel/SdpDriver.cpp index cff0f6d5..1ad412f4 100644 --- a/trunk/ulp/sdp/kernel/SdpDriver.cpp +++ b/trunk/ulp/sdp/kernel/SdpDriver.cpp @@ -12,7 +12,7 @@ VOID DriverUnload ( SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("called pDriverObject = 0x%x\n", pDriverObject )); ib_api_status_t ib_status; - g_pSdpDriver->WaitForAllThreadsToDie(); + g_pSdpDriver->Shutdown(); ib_status = ib_close_al(g_pSdpDriver->m_al_handle); @@ -53,8 +53,6 @@ extern "C" NTSTATUS DriverEntry ( pDriverObject->MajorFunction[i] = SdpDriver::Dispatch; } - - // Create the device that will be used for comunication with the user mode // Now create the device @@ -332,6 +330,13 @@ Cleanup: return rc; } +VOID +SdpDriver::Shutdown() +{ + m_pSdpArp->Shutdown(); + WaitForAllThreadsToDie(); + +} NTSTATUS SdpDriver::DispatchDeviceIoControl( diff --git a/trunk/ulp/sdp/kernel/SdpDriver.h b/trunk/ulp/sdp/kernel/SdpDriver.h index 057e2921..41d5224c 100644 --- a/trunk/ulp/sdp/kernel/SdpDriver.h +++ b/trunk/ulp/sdp/kernel/SdpDriver.h @@ -23,6 +23,8 @@ public: } NTSTATUS Init(PDEVICE_OBJECT pDevObj); + + VOID Shutdown(); PDEVICE_OBJECT GetDeviceObject() { return m_pDevObj; diff --git a/trunk/ulp/sdp/kernel/SdpSocket.cpp b/trunk/ulp/sdp/kernel/SdpSocket.cpp index bd3b1e50..59a31b13 100644 --- a/trunk/ulp/sdp/kernel/SdpSocket.cpp +++ b/trunk/ulp/sdp/kernel/SdpSocket.cpp @@ -439,19 +439,22 @@ NTSTATUS SdpSocket::WSPConnect( { NTSTATUS rc = STATUS_SUCCESS; ib_api_status_t ib_status; - ib_net64_t DestPortGuid; + ib_gid_t DestPortGid; + ib_path_rec_t path_rec; SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p remote addresses ip=%d.%d.%d.%d:%d\n", this, - (pWspConnectIn->IP & 0XFF000000) >> 24, - (pWspConnectIn->IP & 0XFF0000) >> 16, - (pWspConnectIn->IP & 0XFF00) >> 8, - (pWspConnectIn->IP & 0XFF), - pWspConnectIn->Port + (pWspConnectIn->DestIP & 0XFF000000) >> 24, + (pWspConnectIn->DestIP & 0XFF0000) >> 16, + (pWspConnectIn->DestIP & 0XFF00) >> 8, + (pWspConnectIn->DestIP & 0XFF), + pWspConnectIn->DestPort )); - if((pWspConnectIn->IP == 0) || (pWspConnectIn->Port == 0)) { + if((pWspConnectIn->DestIP == 0) || + (pWspConnectIn->DestPort == 0) || + (pWspConnectIn->SrcIP == 0)) { SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Invalid Addresses")); pWspConnectOut->Errno = WSAEADDRNOTAVAIL; goto Cleanup; @@ -477,15 +480,8 @@ NTSTATUS SdpSocket::WSPConnect( // IP address into gid. // if (m_SrcIp == 0) { - // This means that we need to do an implicit bind to get the source - // address - rc = g_pSdpDriver->m_pSdpArp->SourceAddrFromDestAddr(pWspConnectIn->IP , &m_SrcIp); - if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->SourceAddrFromDestAddr failed rc = 0x%x\n", rc )); - pWspConnectOut->Errno = WSAENETUNREACH; - m_Lock.Unlock(); // Error ignored as this is already an error pass - goto Cleanup; - } + // No explicit bind was done, we use the default addresses + m_SrcIp = pWspConnectIn->SrcIP; } // Now that we know the source IP we can decide about the src port @@ -511,7 +507,7 @@ NTSTATUS SdpSocket::WSPConnect( goto Cleanup; } - rc = g_pSdpDriver->m_pSdpArp->DestPortGidFromIP(pWspConnectIn->IP, &DestPortGuid); + rc = g_pSdpDriver->m_pSdpArp->DestPortGidFromMac(pWspConnectIn->DestMac, &DestPortGid); if (!NT_SUCCESS(rc)) { SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->DestPortGidFromIP failed rc = 0x%x\n", rc )); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error @@ -527,7 +523,7 @@ NTSTATUS SdpSocket::WSPConnect( m_state = SS_CONNECTING_QPR_SENT; m_Lock.Unlock(); //????? - rc = g_pSdpDriver->m_pSdpArp->QueryPathRecord( m_SrcPortGuid, DestPortGuid, &path_rec ); + rc = g_pSdpDriver->m_pSdpArp->QueryPathRecord( m_SrcPortGuid, DestPortGid, &path_rec ); if (!NT_SUCCESS(rc)) { SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->QueryPathRecord failed rc = 0x%x\n", rc )); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error @@ -551,13 +547,13 @@ NTSTATUS SdpSocket::WSPConnect( // We need to prepare the hello mesage for the CM sdp_msg_hello hello_msg; - CreateHelloHeader(&hello_msg, pWspConnectIn->IP); + CreateHelloHeader(&hello_msg, pWspConnectIn->DestIP); // We can now update the number of buffers that we have m_RecvBufferPool.SetLocaleAdvertisedBuffers(CL_NTOH16(hello_msg.bsdh.recv_bufs)); // Create the CM request ib_cm_req_t cm_req; - CreateCmRequest(&cm_req, &hello_msg, &path_rec, pWspConnectIn->Port); + CreateCmRequest(&cm_req, &hello_msg, &path_rec, pWspConnectIn->DestPort); // Create the event to wait on to the connection request to end: KeInitializeEvent(&m_ConnectCmCompleteEvent, NotificationEvent , FALSE );