[Openib-windows] RE: Anything new about the IPOIB arp check-in?
Tzachi Dar
tzachid at mellanox.co.il
Wed Nov 9 13:14:20 PST 2005
Hi, I have a test program that has two parameters, using one, it prints
the ip addresses of the machine, and on the other it creates a remote
ARP.
Actually it should also be checked in, I just wanted to make your work
siprints the ip addresses of the machine, and on the other it creates a
remote ARP.
Actually it should also be checked in, I just wanted to make your work
simpler.
Thanks
Tzachi
Index: dirs
===================================================================
--- dirs (revision 713)
+++ dirs (working copy)
@@ -3,4 +3,5 @@
cmtest \
mad_sr_test \
wsd \
+ ipoib \
hello_world
Index: ipoib/dirs
===================================================================
--- ipoib/dirs (revision 0)
+++ ipoib/dirs (revision 0)
@@ -0,0 +1,2 @@
+DIRS=\
+ user
Index: ipoib/user/SOURCES
===================================================================
--- ipoib/user/SOURCES (revision 0)
+++ ipoib/user/SOURCES (revision 0)
@@ -0,0 +1,30 @@
+TARGETNAME=PrintIP
+TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR)
+TARGETTYPE=PROGRAM
+UMTYPE=console
+USE_CRTDLL=1
+
+#!if "a" == "i386"
+
+
+!if "$(_BUILDARCH)" == "x86"
+PsdkArch=""
+!else
+PsdkArch="AMD64"
+!endif
+
+
+SOURCES=\
+ PrintIp.c
+
+TARGETLIBS=\
+ $(SDK_LIB_PATH)\ws2_32.lib\
+ $(PLATFORM_SDK_PATH)\Lib\$(PsdkArch)\Iphlpapi.lib \
+
+
+MSC_WARNING_LEVEL= /W3
+
+INCLUDES=..\..\..\ulp\ipoib;\
+ ..\..\..\inc;\
+ ..\..\..\inc\user;\
+ $(PLATFORM_SDK_PATH)\include;\
Index: ipoib/user/PrintIp.c
===================================================================
--- ipoib/user/PrintIp.c (revision 0)
+++ ipoib/user/PrintIp.c (revision 0)
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: ip_packet.h 47 2005-05-30 18:00:40Z sleybo $
+ */
+#include <windows.h>
+#include <devioctl.h>
+#include <stdio.h>
+#include <Iphlpapi.h>
+#include "iba\\ib_types.h"
+//#include "ipoib_debug.h"
+
+#include <ip_addresses_shared.h>
+
+// Print all ips that are related to infiniband on this computer
+int print_ips()
+{
+ HANDLE hKernelLib;
+ HRESULT hr = S_OK;
+ char temp [1000];
+ char temp1 [1000];
+ struct IOCTL_IPOIB_PORTS_IN ipoib_ports_in;
+ struct IOCTL_IPOIB_PORTS_OUT * pipoib_ports_out;
+ struct IPOIB_AT_PORT_RECORD *ports_records;
+
+ struct IOCTL_IPOIB_IP_ADDRESSES_IN addresses_in;
+ struct IOCTL_IPOIB_IP_ADDRESSES_OUT *addresses_out;
+ struct IP_ADDRESS *ip_addreses;
+
+ BOOL ret;
+ unsigned int i,j;
+ DWORD BytesReturned = 0;
+ printf("Adapters that are known to the ipoib modules are:\n\n");
+
+ hKernelLib =
+ CreateFileW(
+ IPOIB_WIN32_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
// share mode none
+ NULL, // no
security
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL // no
template
+ );
+
+ if (hKernelLib == INVALID_HANDLE_VALUE) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("failed to open the kernel device hr=0x%x\n", hr);
+ return 1;
+ }
+
+ ipoib_ports_in.Version = IPOIB_IOCTL_VERSION;
+ ipoib_ports_in.Size = sizeof temp;
+
+ pipoib_ports_out = (struct IOCTL_IPOIB_PORTS_OUT *)temp;
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_PORTS,
+ &ipoib_ports_in,
+ sizeof(ipoib_ports_in),
+ pipoib_ports_out,
+ sizeof(temp),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_PORTS
hr=0x%x\n", hr);
+ return 1;
+ }
+ if (pipoib_ports_out->Size != 0) {
+ printf("Please call again with a buffer of %d bytes",
pipoib_ports_out->Size);
+ return 1;
+ }
+
+ ports_records = pipoib_ports_out->Ports;
+ printf("Number of devices %d\n", pipoib_ports_out->NumPorts);
+ for (i = 0 ; i < pipoib_ports_out->NumPorts; i++) {
+ printf("%d: ca guid = 0x%I64x port guid=0x%I64x\n", i,
CL_NTOH64(ports_records[i].CaGuid),
CL_NTOH64(ports_records[i].PortGuid));
+
+ // print the ip adresses of this port
+ addresses_in.Version = IPOIB_IOCTL_VERSION;
+ addresses_in.PortGuid = ports_records[i].PortGuid;
+
+ addresses_out = (struct IOCTL_IPOIB_IP_ADDRESSES_OUT *)temp1;
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_IP_ADDRESSES,
+ &addresses_in,
+ sizeof(addresses_in),
+ addresses_out,
+ sizeof(temp1),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_IP_ADDRESSES
hr=0x%x\n", hr);
+ return 1;
+ }
+ if (addresses_out->Size != 0) {
+ printf("Please call again with a buffer of %d bytes",
pipoib_ports_out->Size);
+ return 1;
+ }
+
+ printf(" found %d ips:", addresses_out->NumIps);
+ ip_addreses = addresses_out->Addreses;
+ for (j = 0 ; j < addresses_out->NumIps; j++) {
+ printf(" %d.%d.%d.%d ",
+ ip_addreses[j].Data[12],
+ ip_addreses[j].Data[13],
+ ip_addreses[j].Data[14],
+ ip_addreses[j].Data[15]);
+
+
+ }
+ printf("\n");
+
+ }
+
+ return 0;
+};
+void print_usage(char *argv[])
+{
+ printf("This program is used to print ip adapters and their
addresses or to do arp\n");
+ printf("Usage is: %s <print_ips> \n",argv[0]);
+ printf("or %s <remoteip> <ip> (for example %s remoteip
1.2.3.4)\n", argv[0],argv[0]);
+}
+
+int remote_ip(char *remote_ip)
+{
+ HANDLE hKernelLib;
+ HRESULT hr = S_OK;
+ IPAddr ip;
+ char *pIp = (char *)&ip;
+ int b1,b2,b3,b4;
+ DWORD ret;
+ struct IOCTL_IPOIB_MAC_2_GID_IN mac;
+ struct IOCTL_IPOIB_MAC_2_GID_OUT gid;
+ DWORD BytesReturned = 0;
+
+ ULONG pMacAddr[2], PhyAddrLen ;
+ unsigned char *pMac = (unsigned char *)&pMacAddr;
+ PhyAddrLen = sizeof(pMacAddr);
+
+ hKernelLib =
+ CreateFileW(
+ IPOIB_WIN32_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
// share mode none
+ NULL, // no
security
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL // no
template
+ );
+
+ if (hKernelLib == INVALID_HANDLE_VALUE) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("failed to open the kernel device hr=0x%x\n", hr);
+ return 1;
+ }
+
+ sscanf(remote_ip, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
+ printf("Calling arp for addresses %d.%d.%d.%d\n", b1, b2, b3, b4);
+
+ pIp[0] = (char)b1;
+ pIp[1] = (char)b2;
+ pIp[2] = (char)b3;
+ pIp[3] = (char)b4;
+
+ ret = SendARP(ip ,0 ,pMacAddr, &PhyAddrLen );
+ if (ret != NO_ERROR) {
+ printf("Error in SendARP");
+ return 1;
+ }
+
+ printf("Mac of the remote addresses is %x-%x-%x-%x-%x-%x\n",
+ pMac[0], pMac[1], pMac[2], pMac[3], pMac[4], pMac[5] );
+
+ // quary for the gid
+ memcpy(mac.DestMac, pMac, 6);
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_MAC_2_GID,
+ &mac,
+ sizeof(mac),
+ &gid,
+ sizeof(gid),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_IP_ADDRESSES
hr=0x%x\n", hr);
+ }
+
+ printf("lid of remote ip is = 0x%I64x : 0x%I64x\n",
CL_NTOH64(gid.DestGid.unicast.prefix),
CL_NTOH64(gid.DestGid.unicast.interface_id));
+
+ return 0;
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (argc < 2) {
+ print_usage(argv);
+ return 1;
+ }
+ if (!strcmp(argv[1], "print_ips")) {
+ return print_ips();
+ }
+ if (!strcmp(argv[1], "remoteip")) {
+ return remote_ip(argv[2]);
+ }
+ print_usage(argv);
+ return 1;
+}
Index: ipoib/user/makefile
===================================================================
--- ipoib/user/makefile (revision 0)
+++ ipoib/user/makefile (revision 0)
@@ -0,0 +1,7 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new
source
+# file to this component. This file merely indirects to the real make
file
+# that is shared by all the driver components of the Windows NT DDK
+#
+
+!INCLUDE $(NTMAKEENV)\makefile.def
Index: ipoib/dirs
===================================================================
--- ipoib/dirs (revision 0)
+++ ipoib/dirs (revision 0)
@@ -0,0 +1,2 @@
+DIRS=\
+ user
Index: ipoib/user/SOURCES
===================================================================
--- ipoib/user/SOURCES (revision 0)
+++ ipoib/user/SOURCES (revision 0)
@@ -0,0 +1,30 @@
+TARGETNAME=PrintIP
+TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR)
+TARGETTYPE=PROGRAM
+UMTYPE=console
+USE_CRTDLL=1
+
+#!if "a" == "i386"
+
+
+!if "$(_BUILDARCH)" == "x86"
+PsdkArch=""
+!else
+PsdkArch="AMD64"
+!endif
+
+
+SOURCES=\
+ PrintIp.c
+
+TARGETLIBS=\
+ $(SDK_LIB_PATH)\ws2_32.lib\
+ $(PLATFORM_SDK_PATH)\Lib\$(PsdkArch)\Iphlpapi.lib \
+
+
+MSC_WARNING_LEVEL= /W3
+
+INCLUDES=..\..\..\ulp\ipoib;\
+ ..\..\..\inc;\
+ ..\..\..\inc\user;\
+ $(PLATFORM_SDK_PATH)\include;\
Index: ipoib/user/PrintIp.c
===================================================================
--- ipoib/user/PrintIp.c (revision 0)
+++ ipoib/user/PrintIp.c (revision 0)
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: ip_packet.h 47 2005-05-30 18:00:40Z sleybo $
+ */
+#include <windows.h>
+#include <devioctl.h>
+#include <stdio.h>
+#include <Iphlpapi.h>
+#include "iba\\ib_types.h"
+//#include "ipoib_debug.h"
+
+#include <ip_addresses_shared.h>
+
+// Print all ips that are related to infiniband on this computer
+int print_ips()
+{
+ HANDLE hKernelLib;
+ HRESULT hr = S_OK;
+ char temp [1000];
+ char temp1 [1000];
+ struct IOCTL_IPOIB_PORTS_IN ipoib_ports_in;
+ struct IOCTL_IPOIB_PORTS_OUT * pipoib_ports_out;
+ struct IPOIB_AT_PORT_RECORD *ports_records;
+
+ struct IOCTL_IPOIB_IP_ADDRESSES_IN addresses_in;
+ struct IOCTL_IPOIB_IP_ADDRESSES_OUT *addresses_out;
+ struct IP_ADDRESS *ip_addreses;
+
+ BOOL ret;
+ unsigned int i,j;
+ DWORD BytesReturned = 0;
+ printf("Adapters that are known to the ipoib modules are:\n\n");
+
+ hKernelLib =
+ CreateFileW(
+ IPOIB_WIN32_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
// share mode none
+ NULL, // no
security
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL // no
template
+ );
+
+ if (hKernelLib == INVALID_HANDLE_VALUE) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("failed to open the kernel device hr=0x%x\n", hr);
+ return 1;
+ }
+
+ ipoib_ports_in.Version = IPOIB_IOCTL_VERSION;
+ ipoib_ports_in.Size = sizeof temp;
+
+ pipoib_ports_out = (struct IOCTL_IPOIB_PORTS_OUT *)temp;
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_PORTS,
+ &ipoib_ports_in,
+ sizeof(ipoib_ports_in),
+ pipoib_ports_out,
+ sizeof(temp),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_PORTS
hr=0x%x\n", hr);
+ return 1;
+ }
+ if (pipoib_ports_out->Size != 0) {
+ printf("Please call again with a buffer of %d bytes",
pipoib_ports_out->Size);
+ return 1;
+ }
+
+ ports_records = pipoib_ports_out->Ports;
+ printf("Number of devices %d\n", pipoib_ports_out->NumPorts);
+ for (i = 0 ; i < pipoib_ports_out->NumPorts; i++) {
+ printf("%d: ca guid = 0x%I64x port guid=0x%I64x\n", i,
CL_NTOH64(ports_records[i].CaGuid),
CL_NTOH64(ports_records[i].PortGuid));
+
+ // print the ip adresses of this port
+ addresses_in.Version = IPOIB_IOCTL_VERSION;
+ addresses_in.PortGuid = ports_records[i].PortGuid;
+
+ addresses_out = (struct IOCTL_IPOIB_IP_ADDRESSES_OUT *)temp1;
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_IP_ADDRESSES,
+ &addresses_in,
+ sizeof(addresses_in),
+ addresses_out,
+ sizeof(temp1),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_IP_ADDRESSES
hr=0x%x\n", hr);
+ return 1;
+ }
+ if (addresses_out->Size != 0) {
+ printf("Please call again with a buffer of %d bytes",
pipoib_ports_out->Size);
+ return 1;
+ }
+
+ printf(" found %d ips:", addresses_out->NumIps);
+ ip_addreses = addresses_out->Addreses;
+ for (j = 0 ; j < addresses_out->NumIps; j++) {
+ printf(" %d.%d.%d.%d ",
+ ip_addreses[j].Data[12],
+ ip_addreses[j].Data[13],
+ ip_addreses[j].Data[14],
+ ip_addreses[j].Data[15]);
+
+
+ }
+ printf("\n");
+
+ }
+
+ return 0;
+};
+void print_usage(char *argv[])
+{
+ printf("This program is used to print ip adapters and their
addresses or to do arp\n");
+ printf("Usage is: %s <print_ips> \n",argv[0]);
+ printf("or %s <remoteip> <ip> (for example %s remoteip
1.2.3.4)\n", argv[0],argv[0]);
+}
+
+int remote_ip(char *remote_ip)
+{
+ HANDLE hKernelLib;
+ HRESULT hr = S_OK;
+ IPAddr ip;
+ char *pIp = (char *)&ip;
+ int b1,b2,b3,b4;
+ DWORD ret;
+ struct IOCTL_IPOIB_MAC_2_GID_IN mac;
+ struct IOCTL_IPOIB_MAC_2_GID_OUT gid;
+ DWORD BytesReturned = 0;
+
+ ULONG pMacAddr[2], PhyAddrLen ;
+ unsigned char *pMac = (unsigned char *)&pMacAddr;
+ PhyAddrLen = sizeof(pMacAddr);
+
+ hKernelLib =
+ CreateFileW(
+ IPOIB_WIN32_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
// share mode none
+ NULL, // no
security
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL // no
template
+ );
+
+ if (hKernelLib == INVALID_HANDLE_VALUE) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("failed to open the kernel device hr=0x%x\n", hr);
+ return 1;
+ }
+
+ sscanf(remote_ip, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
+ printf("Calling arp for addresses %d.%d.%d.%d\n", b1, b2, b3, b4);
+
+ pIp[0] = (char)b1;
+ pIp[1] = (char)b2;
+ pIp[2] = (char)b3;
+ pIp[3] = (char)b4;
+
+ ret = SendARP(ip ,0 ,pMacAddr, &PhyAddrLen );
+ if (ret != NO_ERROR) {
+ printf("Error in SendARP");
+ return 1;
+ }
+
+ printf("Mac of the remote addresses is %x-%x-%x-%x-%x-%x\n",
+ pMac[0], pMac[1], pMac[2], pMac[3], pMac[4], pMac[5] );
+
+ // quary for the gid
+ memcpy(mac.DestMac, pMac, 6);
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_MAC_2_GID,
+ &mac,
+ sizeof(mac),
+ &gid,
+ sizeof(gid),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_IP_ADDRESSES
hr=0x%x\n", hr);
+ }
+
+ printf("lid of remote ip is = 0x%I64x : 0x%I64x\n",
CL_NTOH64(gid.DestGid.unicast.prefix),
CL_NTOH64(gid.DestGid.unicast.interface_id));
+
+ return 0;
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (argc < 2) {
+ print_usage(argv);
+ return 1;
+ }
+ if (!strcmp(argv[1], "print_ips")) {
+ return print_ips();
+ }
+ if (!strcmp(argv[1], "remoteip")) {
+ return remote_ip(argv[2]);
+ }
+ print_usage(argv);
+ return 1;
+}
Index: ipoib/user/makefile
===================================================================
--- ipoib/user/makefile (revision 0)
+++ ipoib/user/makefile (revision 0)
@@ -0,0 +1,7 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new
source
+# file to this component. This file merely indirects to the real make
file
+# that is shared by all the driver components of the Windows NT DDK
+#
+
+!INCLUDE $(NTMAKEENV)\makefile.def
Index: ipoib/user/makefile
===================================================================
--- ipoib/user/makefile (revision 0)
+++ ipoib/user/makefile (revision 0)
@@ -0,0 +1,7 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new
source
+# file to this component. This file merely indirects to the real make
file
+# that is shared by all the driver components of the Windows NT DDK
+#
+
+!INCLUDE $(NTMAKEENV)\makefile.def
Index: ipoib/user/PrintIp.c
===================================================================
--- ipoib/user/PrintIp.c (revision 0)
+++ ipoib/user/PrintIp.c (revision 0)
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: ip_packet.h 47 2005-05-30 18:00:40Z sleybo $
+ */
+#include <windows.h>
+#include <devioctl.h>
+#include <stdio.h>
+#include <Iphlpapi.h>
+#include "iba\\ib_types.h"
+//#include "ipoib_debug.h"
+
+#include <ip_addresses_shared.h>
+
+// Print all ips that are related to infiniband on this computer
+int print_ips()
+{
+ HANDLE hKernelLib;
+ HRESULT hr = S_OK;
+ char temp [1000];
+ char temp1 [1000];
+ struct IOCTL_IPOIB_PORTS_IN ipoib_ports_in;
+ struct IOCTL_IPOIB_PORTS_OUT * pipoib_ports_out;
+ struct IPOIB_AT_PORT_RECORD *ports_records;
+
+ struct IOCTL_IPOIB_IP_ADDRESSES_IN addresses_in;
+ struct IOCTL_IPOIB_IP_ADDRESSES_OUT *addresses_out;
+ struct IP_ADDRESS *ip_addreses;
+
+ BOOL ret;
+ unsigned int i,j;
+ DWORD BytesReturned = 0;
+ printf("Adapters that are known to the ipoib modules are:\n\n");
+
+ hKernelLib =
+ CreateFileW(
+ IPOIB_WIN32_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
// share mode none
+ NULL, // no
security
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL // no
template
+ );
+
+ if (hKernelLib == INVALID_HANDLE_VALUE) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("failed to open the kernel device hr=0x%x\n", hr);
+ return 1;
+ }
+
+ ipoib_ports_in.Version = IPOIB_IOCTL_VERSION;
+ ipoib_ports_in.Size = sizeof temp;
+
+ pipoib_ports_out = (struct IOCTL_IPOIB_PORTS_OUT *)temp;
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_PORTS,
+ &ipoib_ports_in,
+ sizeof(ipoib_ports_in),
+ pipoib_ports_out,
+ sizeof(temp),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_PORTS
hr=0x%x\n", hr);
+ return 1;
+ }
+ if (pipoib_ports_out->Size != 0) {
+ printf("Please call again with a buffer of %d bytes",
pipoib_ports_out->Size);
+ return 1;
+ }
+
+ ports_records = pipoib_ports_out->Ports;
+ printf("Number of devices %d\n", pipoib_ports_out->NumPorts);
+ for (i = 0 ; i < pipoib_ports_out->NumPorts; i++) {
+ printf("%d: ca guid = 0x%I64x port guid=0x%I64x\n", i,
CL_NTOH64(ports_records[i].CaGuid),
CL_NTOH64(ports_records[i].PortGuid));
+
+ // print the ip adresses of this port
+ addresses_in.Version = IPOIB_IOCTL_VERSION;
+ addresses_in.PortGuid = ports_records[i].PortGuid;
+
+ addresses_out = (struct IOCTL_IPOIB_IP_ADDRESSES_OUT *)temp1;
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_IP_ADDRESSES,
+ &addresses_in,
+ sizeof(addresses_in),
+ addresses_out,
+ sizeof(temp1),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_IP_ADDRESSES
hr=0x%x\n", hr);
+ return 1;
+ }
+ if (addresses_out->Size != 0) {
+ printf("Please call again with a buffer of %d bytes",
pipoib_ports_out->Size);
+ return 1;
+ }
+
+ printf(" found %d ips:", addresses_out->NumIps);
+ ip_addreses = addresses_out->Addreses;
+ for (j = 0 ; j < addresses_out->NumIps; j++) {
+ printf(" %d.%d.%d.%d ",
+ ip_addreses[j].Data[12],
+ ip_addreses[j].Data[13],
+ ip_addreses[j].Data[14],
+ ip_addreses[j].Data[15]);
+
+
+ }
+ printf("\n");
+
+ }
+
+ return 0;
+};
+void print_usage(char *argv[])
+{
+ printf("This program is used to print ip adapters and their
addresses or to do arp\n");
+ printf("Usage is: %s <print_ips> \n",argv[0]);
+ printf("or %s <remoteip> <ip> (for example %s remoteip
1.2.3.4)\n", argv[0],argv[0]);
+}
+
+int remote_ip(char *remote_ip)
+{
+ HANDLE hKernelLib;
+ HRESULT hr = S_OK;
+ IPAddr ip;
+ char *pIp = (char *)&ip;
+ int b1,b2,b3,b4;
+ DWORD ret;
+ struct IOCTL_IPOIB_MAC_2_GID_IN mac;
+ struct IOCTL_IPOIB_MAC_2_GID_OUT gid;
+ DWORD BytesReturned = 0;
+
+ ULONG pMacAddr[2], PhyAddrLen ;
+ unsigned char *pMac = (unsigned char *)&pMacAddr;
+ PhyAddrLen = sizeof(pMacAddr);
+
+ hKernelLib =
+ CreateFileW(
+ IPOIB_WIN32_NAME,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
// share mode none
+ NULL, // no
security
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL // no
template
+ );
+
+ if (hKernelLib == INVALID_HANDLE_VALUE) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("failed to open the kernel device hr=0x%x\n", hr);
+ return 1;
+ }
+
+ sscanf(remote_ip, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
+ printf("Calling arp for addresses %d.%d.%d.%d\n", b1, b2, b3, b4);
+
+ pIp[0] = (char)b1;
+ pIp[1] = (char)b2;
+ pIp[2] = (char)b3;
+ pIp[3] = (char)b4;
+
+ ret = SendARP(ip ,0 ,pMacAddr, &PhyAddrLen );
+ if (ret != NO_ERROR) {
+ printf("Error in SendARP");
+ return 1;
+ }
+
+ printf("Mac of the remote addresses is %x-%x-%x-%x-%x-%x\n",
+ pMac[0], pMac[1], pMac[2], pMac[3], pMac[4], pMac[5] );
+
+ // quary for the gid
+ memcpy(mac.DestMac, pMac, 6);
+
+ ret = DeviceIoControl(
+ hKernelLib,
+ IOCTL_IPOIB_MAC_2_GID,
+ &mac,
+ sizeof(mac),
+ &gid,
+ sizeof(gid),
+ &BytesReturned,
+ NULL
+ );
+
+ if (ret == 0) {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ printf("DeviceIoControl failed for IOCTL_IPOIB_IP_ADDRESSES
hr=0x%x\n", hr);
+ }
+
+ printf("lid of remote ip is = 0x%I64x : 0x%I64x\n",
CL_NTOH64(gid.DestGid.unicast.prefix),
CL_NTOH64(gid.DestGid.unicast.interface_id));
+
+ return 0;
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (argc < 2) {
+ print_usage(argv);
+ return 1;
+ }
+ if (!strcmp(argv[1], "print_ips")) {
+ return print_ips();
+ }
+ if (!strcmp(argv[1], "remoteip")) {
+ return remote_ip(argv[2]);
+ }
+ print_usage(argv);
+ return 1;
+}
Index: ipoib/user/SOURCES
===================================================================
--- ipoib/user/SOURCES (revision 0)
+++ ipoib/user/SOURCES (revision 0)
@@ -0,0 +1,30 @@
+TARGETNAME=PrintIP
+TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR)
+TARGETTYPE=PROGRAM
+UMTYPE=console
+USE_CRTDLL=1
+
+#!if "a" == "i386"
+
+
+!if "$(_BUILDARCH)" == "x86"
+PsdkArch=""
+!else
+PsdkArch="AMD64"
+!endif
+
+
+SOURCES=\
+ PrintIp.c
+
+TARGETLIBS=\
+ $(SDK_LIB_PATH)\ws2_32.lib\
+ $(PLATFORM_SDK_PATH)\Lib\$(PsdkArch)\Iphlpapi.lib \
+
+
+MSC_WARNING_LEVEL= /W3
+
+INCLUDES=..\..\..\ulp\ipoib;\
+ ..\..\..\inc;\
+ ..\..\..\inc\user;\
+ $(PLATFORM_SDK_PATH)\include;\
>-----Original Message-----
>From: Fab Tillier [mailto:ftillier at silverstorm.com]
>Sent: Wednesday, November 09, 2005 9:28 PM
>To: 'Tzachi Dar'; openib-windows at openib.org
>Cc: Yossi Leybovich; Gilad Shainer
>Subject: RE: Anything new about the IPOIB arp check-in?
>
>Hi Tzachi,
>
>> -----Original Message-----
>> From: Tzachi Dar [mailto:tzachid at mellanox.co.il]
>> Sent: Tuesday, November 08, 2005 8:52 AM
>>
>> As the pressure is down again, I'm sending you the revisad patch
again.
>
>Do you have any unit test code you could share so I can test my changes
and
>whatnot? It would save me from having to duplicate your work if you
>already
>have it.
>
>Thanks,
>
>- Fab
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipoib_tests.diff
Type: application/octet-stream
Size: 30286 bytes
Desc: ipoib_tests.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20051109/5f1d0cd5/attachment.obj>
More information about the ofw
mailing list