Author: cgutman
Date: Sat Oct 24 22:39:41 2009
New Revision: 43723
URL:
http://svn.reactos.org/svn/reactos?rev=43723&view=rev
Log:
- Implement SetIpNetEntry in iphlpapi and InfoTdiSetArptableMIB in tcpip
- Added buffer size checks for InfoTdiSetRoute
- "arp -s" works now
Modified:
trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c
trunk/reactos/dll/win32/iphlpapi/iphlpapi_private.h
trunk/reactos/dll/win32/iphlpapi/route_reactos.c
trunk/reactos/drivers/network/tcpip/include/info.h
trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c
trunk/reactos/drivers/network/tcpip/tcpip/info.c
trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c
Modified: trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/iphlpap…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c [iso-8859-1] Sat Oct 24 22:39:41
2009
@@ -2087,15 +2087,54 @@
* RETURNS
* Success: NO_ERROR
* Failure: error code from winerror.h
- *
- * FIXME
- * Stub, returns NO_ERROR.
*/
DWORD WINAPI SetIpNetEntry(PMIB_IPNETROW pArpEntry)
{
- FIXME("(pArpEntry %p): stub\n", pArpEntry);
- /* same as CreateIpNetEntry here, could use SIOCSARP, not sure I want to */
- return 0;
+ HANDLE tcpFile;
+ NTSTATUS status;
+ TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY req =
+ TCP_REQUEST_SET_INFORMATION_INIT;
+ TDIEntityID id;
+ DWORD returnSize;
+ PMIB_IPNETROW arpBuff;
+
+ if (!pArpEntry)
+ return ERROR_INVALID_PARAMETER;
+
+ if (!NT_SUCCESS(openTcpFile( &tcpFile )))
+ return ERROR_NOT_SUPPORTED;
+
+ if (!NT_SUCCESS(getNthIpEntity( tcpFile, pArpEntry->dwIndex, &id )))
+ {
+ closeTcpFile(tcpFile);
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ req.Req.ID.toi_class = INFO_CLASS_PROTOCOL;
+ req.Req.ID.toi_type = INFO_TYPE_PROVIDER;
+ req.Req.ID.toi_id = IP_MIB_ARPTABLE_ENTRY_ID;
+ req.Req.ID.toi_entity.tei_instance = id.tei_instance;
+ req.Req.ID.toi_entity.tei_entity = AT_ENTITY;
+ req.Req.BufferSize = sizeof(MIB_IPNETROW);
+ arpBuff = (PMIB_IPNETROW)&req.Req.Buffer[0];
+
+ RtlCopyMemory(arpBuff, pArpEntry, sizeof(MIB_IPNETROW));
+
+ status = DeviceIoControl( tcpFile,
+ IOCTL_TCP_SET_INFORMATION_EX,
+ &req,
+ sizeof(req),
+ NULL,
+ 0,
+ &returnSize,
+ NULL );
+
+ closeTcpFile(tcpFile);
+
+ if (status)
+ return NO_ERROR;
+ else
+ return ERROR_INVALID_PARAMETER;
}
Modified: trunk/reactos/dll/win32/iphlpapi/iphlpapi_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/iphlpap…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/iphlpapi_private.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/iphlpapi_private.h [iso-8859-1] Sat Oct 24 22:39:41
2009
@@ -88,12 +88,19 @@
IFEntry ent;
} IFEntrySafelySized;
-typedef union _TCP_REQUEST_SET_INFORMATION_EX_SAFELY_SIZED {
+typedef union _TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY {
CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
sizeof(IPRouteEntry)];
TCP_REQUEST_SET_INFORMATION_EX Req;
-} TCP_REQUEST_SET_INFORMATION_EX_SAFELY_SIZED,
- *PTCP_REQUEST_SET_INFORMATION_EX_SAFELY_SIZED;
+} TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY,
+ *PTCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY;
+
+typedef union _TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY {
+ CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
+ sizeof(MIB_IPNETROW)];
+ TCP_REQUEST_SET_INFORMATION_EX Req;
+} TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY,
+ *PTCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY;
/* Encapsulates information about an interface */
typedef struct _IFInfo {
Modified: trunk/reactos/dll/win32/iphlpapi/route_reactos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/route_r…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/route_reactos.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/route_reactos.c [iso-8859-1] Sat Oct 24 22:39:41
2009
@@ -55,7 +55,7 @@
DWORD createIpForwardEntry( PMIB_IPFORWARDROW pRoute ) {
HANDLE tcpFile;
NTSTATUS status = openTcpFile( &tcpFile );
- TCP_REQUEST_SET_INFORMATION_EX_SAFELY_SIZED req =
+ TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY req =
TCP_REQUEST_SET_INFORMATION_INIT;
IPRouteEntry *rte;
TDIEntityID id;
@@ -120,7 +120,7 @@
DWORD deleteIpForwardEntry( PMIB_IPFORWARDROW pRoute ) {
HANDLE tcpFile;
NTSTATUS status = openTcpFile( &tcpFile );
- TCP_REQUEST_SET_INFORMATION_EX_SAFELY_SIZED req =
+ TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY req =
TCP_REQUEST_SET_INFORMATION_INIT;
IPRouteEntry *rte;
TDIEntityID id;
Modified: trunk/reactos/drivers/network/tcpip/include/info.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/info.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/info.h [iso-8859-1] Sat Oct 24 22:39:41
2009
@@ -160,7 +160,13 @@
PNDIS_BUFFER Buffer,
PUINT BufferSize );
-TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PIPROUTE_ENTRY Route);
+TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF,
+ PVOID Buffer,
+ UINT BufferSize);
+
+TDI_STATUS InfoTdiSetArptableMIB(PIP_INTERFACE IF,
+ PVOID Buffer,
+ UINT BufferSize);
TDI_STATUS InfoTdiQueryGetArptableMIB(TDIEntityID ID,
PIP_INTERFACE Interface,
Modified: trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c [iso-8859-1] Sat Oct 24 22:39:41
2009
@@ -132,6 +132,31 @@
}
return Status;
+}
+
+TDI_STATUS InfoTdiSetArptableMIB(PIP_INTERFACE IF, PVOID Buffer, UINT BufferSize)
+{
+ PIPARP_ENTRY ArpEntry = Buffer;
+ IP_ADDRESS Address;
+ PNEIGHBOR_CACHE_ENTRY NCE;
+
+ if (!Buffer || BufferSize < sizeof(IPARP_ENTRY))
+ return TDI_INVALID_PARAMETER;
+
+ AddrInitIPv4(&Address, ArpEntry->LogAddr);
+
+ if ((NCE = NBLocateNeighbor(&Address)))
+ NBRemoveNeighbor(NCE);
+
+ if (NBAddNeighbor(IF,
+ &Address,
+ ArpEntry->PhysAddr,
+ ArpEntry->AddrSize,
+ NUD_PERMANENT,
+ 0))
+ return TDI_SUCCESS;
+ else
+ return TDI_INVALID_PARAMETER;
}
VOID InsertTDIInterfaceEntity( PIP_INTERFACE Interface ) {
Modified: trunk/reactos/drivers/network/tcpip/tcpip/info.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/info.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/info.c [iso-8859-1] Sat Oct 24 22:39:41
2009
@@ -268,12 +268,18 @@
if (ID->toi_type != INFO_TYPE_PROVIDER)
return TDI_INVALID_PARAMETER;
- if (ID->toi_entity.tei_entity != CL_NL_ENTITY &&
- ID->toi_entity.tei_entity != CO_NL_ENTITY)
- return TDI_INVALID_PARAMETER;
-
- if ((EntityListContext = GetContext(ID->toi_entity)))
- return InfoTdiSetRoute(EntityListContext, (PIPROUTE_ENTRY)Buffer);
+ if (ID->toi_entity.tei_entity == AT_ENTITY)
+ if ((EntityListContext = GetContext(ID->toi_entity)))
+ return InfoTdiSetArptableMIB(EntityListContext,
+ Buffer, BufferSize);
+ else
+ return TDI_INVALID_PARAMETER;
+ else if (ID->toi_entity.tei_entity == CL_NL_ENTITY ||
+ ID->toi_entity.tei_entity == CO_NL_ENTITY)
+ if ((EntityListContext = GetContext(ID->toi_entity)))
+ return InfoTdiSetRoute(EntityListContext, Buffer, BufferSize);
+ else
+ return TDI_INVALID_PARAMETER;
else
return TDI_INVALID_PARAMETER;
Modified: trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c [iso-8859-1] Sat Oct 24 22:39:41
2009
@@ -173,13 +173,17 @@
return Status;
}
-TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PIPROUTE_ENTRY Route)
+TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PVOID Buffer, UINT BufferSize)
{
IP_ADDRESS Address, Netmask, Router;
+ PIPROUTE_ENTRY Route = Buffer;
AddrInitIPv4( &Address, Route->Dest );
AddrInitIPv4( &Netmask, Route->Mask );
AddrInitIPv4( &Router, Route->Gw );
+
+ if (!Buffer || BufferSize < sizeof(IPROUTE_ENTRY))
+ return TDI_INVALID_PARAMETER;
if (IF == Loopback)
{