mirror of
https://github.com/reactos/reactos.git
synced 2025-06-01 07:28:19 +00:00
reapply r64621 aka revert r64628, with various fixes:
[WSHTCPIP] - Fix swapped function parameters [TCPIP] - Re-enable some code which got lost because of me being unable to decipher this indentation mess. svn path=/trunk/; revision=64629
This commit is contained in:
parent
f1065f12f0
commit
7200f7a6ea
10 changed files with 151 additions and 52 deletions
|
@ -156,12 +156,18 @@ WSHGetSockaddrType(
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT
|
static
|
||||||
GetAddressOption(INT Level, INT OptionName)
|
void
|
||||||
|
GetTdiTypeId(
|
||||||
|
_In_ INT Level,
|
||||||
|
_In_ INT OptionName,
|
||||||
|
_Out_ PULONG TdiType,
|
||||||
|
_Out_ PULONG TdiId)
|
||||||
{
|
{
|
||||||
switch (Level)
|
switch (Level)
|
||||||
{
|
{
|
||||||
case SOL_SOCKET:
|
case SOL_SOCKET:
|
||||||
|
*TdiType = INFO_TYPE_ADDRESS_OBJECT;
|
||||||
switch (OptionName)
|
switch (OptionName)
|
||||||
{
|
{
|
||||||
case SO_KEEPALIVE:
|
case SO_KEEPALIVE:
|
||||||
|
@ -174,21 +180,26 @@ GetAddressOption(INT Level, INT OptionName)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IPPROTO_IP:
|
case IPPROTO_IP:
|
||||||
|
*TdiType = INFO_TYPE_ADDRESS_OBJECT;
|
||||||
switch (OptionName)
|
switch (OptionName)
|
||||||
{
|
{
|
||||||
case IP_TTL:
|
case IP_TTL:
|
||||||
return AO_OPTION_TTL;
|
*TdiId = AO_OPTION_TTL;
|
||||||
|
return;
|
||||||
|
|
||||||
case IP_DONTFRAGMENT:
|
case IP_DONTFRAGMENT:
|
||||||
return AO_OPTION_IP_DONTFRAGMENT;
|
*TdiId = AO_OPTION_IP_DONTFRAGMENT;
|
||||||
|
return;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
case IP_RECEIVE_BROADCAST:
|
case IP_RECEIVE_BROADCAST:
|
||||||
return AO_OPTION_BROADCAST;
|
*TdiId = AO_OPTION_BROADCAST;
|
||||||
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case IP_HDRINCL:
|
case IP_HDRINCL:
|
||||||
return AO_OPTION_IP_HDRINCL;
|
*TdiId = AO_OPTION_IP_HDRINCL;
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -198,10 +209,10 @@ GetAddressOption(INT Level, INT OptionName)
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
switch (OptionName)
|
switch (OptionName)
|
||||||
{
|
{
|
||||||
|
*TdiType = INFO_TYPE_CONNECTION;
|
||||||
case TCP_NODELAY:
|
case TCP_NODELAY:
|
||||||
/* FIXME: Return proper option */
|
*TdiId = TCP_SOCKET_NODELAY;
|
||||||
ASSERT(FALSE);
|
return;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +222,8 @@ GetAddressOption(INT Level, INT OptionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Unknown level/option name: %d %d\n", Level, OptionName);
|
DPRINT1("Unknown level/option name: %d %d\n", Level, OptionName);
|
||||||
return 0;
|
*TdiType = 0;
|
||||||
|
*TdiId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT
|
INT
|
||||||
|
@ -642,7 +654,7 @@ WSHSetSocketInformation(
|
||||||
IN INT OptionLength)
|
IN INT OptionLength)
|
||||||
{
|
{
|
||||||
PSOCKET_CONTEXT Context = HelperDllSocketContext;
|
PSOCKET_CONTEXT Context = HelperDllSocketContext;
|
||||||
UINT RealOptionName;
|
ULONG TdiType, TdiId;
|
||||||
INT Status;
|
INT Status;
|
||||||
PTCP_REQUEST_SET_INFORMATION_EX Info;
|
PTCP_REQUEST_SET_INFORMATION_EX Info;
|
||||||
PQUEUED_REQUEST Queued, NextQueued;
|
PQUEUED_REQUEST Queued, NextQueued;
|
||||||
|
@ -697,9 +709,11 @@ WSHSetSocketInformation(
|
||||||
switch (OptionName)
|
switch (OptionName)
|
||||||
{
|
{
|
||||||
case TCP_NODELAY:
|
case TCP_NODELAY:
|
||||||
/* FIXME -- Send this to TCPIP */
|
if (OptionLength < sizeof(CHAR))
|
||||||
DPRINT1("Set: TCP_NODELAY not yet supported\n");
|
{
|
||||||
return 0;
|
return WSAEFAULT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Invalid option */
|
/* Invalid option */
|
||||||
|
@ -714,8 +728,8 @@ WSHSetSocketInformation(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we get here, GetAddressOption must return something valid */
|
/* If we get here, GetAddressOption must return something valid */
|
||||||
RealOptionName = GetAddressOption(Level, OptionName);
|
GetTdiTypeId(Level, OptionName, &TdiType, &TdiId);
|
||||||
ASSERT(RealOptionName != 0);
|
ASSERT((TdiId != 0) && (TdiType != 0));
|
||||||
|
|
||||||
Info = HeapAlloc(GetProcessHeap(), 0, sizeof(*Info) + OptionLength);
|
Info = HeapAlloc(GetProcessHeap(), 0, sizeof(*Info) + OptionLength);
|
||||||
if (!Info)
|
if (!Info)
|
||||||
|
@ -724,8 +738,8 @@ WSHSetSocketInformation(
|
||||||
Info->ID.toi_entity.tei_entity = Context->AddrFileEntityType;
|
Info->ID.toi_entity.tei_entity = Context->AddrFileEntityType;
|
||||||
Info->ID.toi_entity.tei_instance = Context->AddrFileInstance;
|
Info->ID.toi_entity.tei_instance = Context->AddrFileInstance;
|
||||||
Info->ID.toi_class = INFO_CLASS_PROTOCOL;
|
Info->ID.toi_class = INFO_CLASS_PROTOCOL;
|
||||||
Info->ID.toi_type = INFO_TYPE_ADDRESS_OBJECT;
|
Info->ID.toi_type = TdiType;
|
||||||
Info->ID.toi_id = RealOptionName;
|
Info->ID.toi_id = TdiId;
|
||||||
Info->BufferSize = OptionLength;
|
Info->BufferSize = OptionLength;
|
||||||
memcpy(Info->Buffer, OptionValue, OptionLength);
|
memcpy(Info->Buffer, OptionValue, OptionLength);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ list(APPEND SOURCE
|
||||||
datalink/lan.c
|
datalink/lan.c
|
||||||
tcpip/ainfo.c
|
tcpip/ainfo.c
|
||||||
tcpip/buffer.c
|
tcpip/buffer.c
|
||||||
|
tcpip/cinfo.c
|
||||||
tcpip/dispatch.c
|
tcpip/dispatch.c
|
||||||
tcpip/fileobjs.c
|
tcpip/fileobjs.c
|
||||||
tcpip/iinfo.c
|
tcpip/iinfo.c
|
||||||
|
|
|
@ -183,6 +183,11 @@ TDI_STATUS GetAddressFileInfo(TDIObjectID *ID,
|
||||||
PVOID Buffer,
|
PVOID Buffer,
|
||||||
PUINT BufferSize);
|
PUINT BufferSize);
|
||||||
|
|
||||||
|
TDI_STATUS SetConnectionInfo(TDIObjectID *ID,
|
||||||
|
PCONNECTION_ENDPOINT Connection,
|
||||||
|
PVOID Buffer,
|
||||||
|
UINT BufferSize);
|
||||||
|
|
||||||
/* Insert and remove entities */
|
/* Insert and remove entities */
|
||||||
VOID InsertTDIInterfaceEntity( PIP_INTERFACE Interface );
|
VOID InsertTDIInterfaceEntity( PIP_INTERFACE Interface );
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,8 @@ NTSTATUS TCPShutdown(
|
||||||
|
|
||||||
BOOLEAN TCPRemoveIRP( PCONNECTION_ENDPOINT Connection, PIRP Irp );
|
BOOLEAN TCPRemoveIRP( PCONNECTION_ENDPOINT Connection, PIRP Irp );
|
||||||
|
|
||||||
|
NTSTATUS TCPSetNoDelay(PCONNECTION_ENDPOINT Connection, BOOLEAN Set);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
TCPUpdateInterfaceLinkStatus(PIP_INTERFACE IF);
|
TCPUpdateInterfaceLinkStatus(PIP_INTERFACE IF);
|
||||||
|
|
||||||
|
|
32
reactos/drivers/network/tcpip/tcpip/cinfo.c
Normal file
32
reactos/drivers/network/tcpip/tcpip/cinfo.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS TCP/IP protocol driver
|
||||||
|
* FILE: tcpip/cinfo.c
|
||||||
|
* PURPOSE: Per-socket connection information.
|
||||||
|
* PROGRAMMER: Jérôme Gardou
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "precomp.h"
|
||||||
|
|
||||||
|
TDI_STATUS SetConnectionInfo(TDIObjectID *ID,
|
||||||
|
PCONNECTION_ENDPOINT Connection,
|
||||||
|
PVOID Buffer,
|
||||||
|
UINT BufferSize)
|
||||||
|
{
|
||||||
|
ASSERT(ID->toi_type == INFO_TYPE_CONNECTION);
|
||||||
|
switch (ID->toi_id)
|
||||||
|
{
|
||||||
|
case TCP_SOCKET_NODELAY:
|
||||||
|
{
|
||||||
|
BOOLEAN Set;
|
||||||
|
if (BufferSize < sizeof(BOOLEAN))
|
||||||
|
return TDI_INVALID_PARAMETER;
|
||||||
|
Set = *(BOOLEAN*)Buffer;
|
||||||
|
return TCPSetNoDelay(Connection, Set);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
DbgPrint("TCPIP: Unknown connection info ID: %u.\n", ID->toi_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TDI_INVALID_PARAMETER;
|
||||||
|
}
|
|
@ -325,41 +325,59 @@ TDI_STATUS InfoTdiSetInformationEx
|
||||||
|
|
||||||
switch (ID->toi_class)
|
switch (ID->toi_class)
|
||||||
{
|
{
|
||||||
case INFO_CLASS_PROTOCOL:
|
case INFO_CLASS_PROTOCOL:
|
||||||
if (ID->toi_type == INFO_TYPE_ADDRESS_OBJECT)
|
{
|
||||||
{
|
switch (ID->toi_type)
|
||||||
if ((EntityListContext = GetContext(ID->toi_entity)))
|
{
|
||||||
return SetAddressFileInfo(ID, EntityListContext, Buffer, BufferSize);
|
case INFO_TYPE_ADDRESS_OBJECT:
|
||||||
else
|
{
|
||||||
return TDI_INVALID_PARAMETER;
|
if ((EntityListContext = GetContext(ID->toi_entity)))
|
||||||
}
|
return SetAddressFileInfo(ID, EntityListContext, Buffer, BufferSize);
|
||||||
|
else
|
||||||
switch (ID->toi_id)
|
|
||||||
{
|
|
||||||
case IP_MIB_ARPTABLE_ENTRY_ID:
|
|
||||||
if (ID->toi_type != INFO_TYPE_PROVIDER)
|
|
||||||
return TDI_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
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;
|
return TDI_INVALID_PARAMETER;
|
||||||
else
|
}
|
||||||
return TDI_INVALID_PARAMETER;
|
case INFO_TYPE_CONNECTION:
|
||||||
|
{
|
||||||
|
PADDRESS_FILE AddressFile = GetContext(ID->toi_entity);
|
||||||
|
if (AddressFile == NULL)
|
||||||
|
return TDI_INVALID_PARAMETER;
|
||||||
|
return SetConnectionInfo(ID, AddressFile->Connection, Buffer, BufferSize);
|
||||||
|
}
|
||||||
|
case INFO_TYPE_PROVIDER:
|
||||||
|
{
|
||||||
|
switch (ID->toi_id)
|
||||||
|
{
|
||||||
|
case IP_MIB_ARPTABLE_ENTRY_ID:
|
||||||
|
if (ID->toi_type != INFO_TYPE_PROVIDER)
|
||||||
|
return TDI_INVALID_PARAMETER;
|
||||||
|
|
||||||
default:
|
if (ID->toi_entity.tei_entity == AT_ENTITY)
|
||||||
return TDI_INVALID_REQUEST;
|
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;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return TDI_INVALID_REQUEST;
|
return TDI_INVALID_REQUEST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
DbgPrint("TCPIP: IOCTL_TCP_SET_INFORMATION_EX - Unrecognized information type for INFO_CLASS_PROTOCOL: %#x.\n", ID->toi_type);
|
||||||
|
return TDI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
DbgPrint("TCPIP: IOCTL_TCP_SET_INFORMATION_EX - Unrecognized information class %#x.\n", ID->toi_class);
|
||||||
|
return TDI_INVALID_REQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,9 @@
|
||||||
#define AO_OPTION_UNBIND 37
|
#define AO_OPTION_UNBIND 37
|
||||||
#define AO_OPTION_PROTECT 38
|
#define AO_OPTION_PROTECT 38
|
||||||
|
|
||||||
|
/* TCP connection options */
|
||||||
|
#define TCP_SOCKET_NODELAY 1
|
||||||
|
|
||||||
typedef struct IFEntry
|
typedef struct IFEntry
|
||||||
{
|
{
|
||||||
ULONG if_index;
|
ULONG if_index;
|
||||||
|
|
|
@ -674,4 +674,16 @@ BOOLEAN TCPRemoveIRP( PCONNECTION_ENDPOINT Endpoint, PIRP Irp )
|
||||||
return Found;
|
return Found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
TCPSetNoDelay(
|
||||||
|
PCONNECTION_ENDPOINT Connection,
|
||||||
|
BOOLEAN Set)
|
||||||
|
{
|
||||||
|
if (Connection->SocketContext == NULL)
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
LibTCPSetNoDelay(Connection->SocketContext, Set);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -107,10 +107,11 @@ err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const i
|
||||||
err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
|
err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
|
||||||
err_t LibTCPGetHostName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
|
err_t LibTCPGetHostName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port);
|
||||||
void LibTCPAccept(PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg);
|
void LibTCPAccept(PTCP_PCB pcb, struct tcp_pcb *listen_pcb, void *arg);
|
||||||
|
void LibTCPSetNoDelay(PTCP_PCB pcb, BOOLEAN Set);
|
||||||
|
|
||||||
/* IP functions */
|
/* IP functions */
|
||||||
void LibIPInsertPacket(void *ifarg, const void *const data, const u32_t size);
|
void LibIPInsertPacket(void *ifarg, const void *const data, const u32_t size);
|
||||||
void LibIPInitialize(void);
|
void LibIPInitialize(void);
|
||||||
void LibIPShutdown(void);
|
void LibIPShutdown(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -829,3 +829,14 @@ LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr * const ipaddr, u16_t * const por
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LibTCPSetNoDelay(
|
||||||
|
PTCP_PCB pcb,
|
||||||
|
BOOLEAN Set)
|
||||||
|
{
|
||||||
|
if (Set)
|
||||||
|
pcb->flags |= TF_NODELAY;
|
||||||
|
else
|
||||||
|
pcb->flags &= ~TF_NODELAY;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue