Author: cgutman
Date: Thu Sep 2 04:18:17 2010
New Revision: 48686
URL:
http://svn.reactos.org/svn/reactos?rev=48686&view=rev
Log:
[OSKITTCP]
- Check for a shutdown connection that we missed a few times
- Remove some junk and stop playing with flags behind oskit's back
- Fix an invalid parameter check
- Enable a check to ensure that accept doesn't get called for a socket that isn't
listening
- Use the queue manipulation function instead of manually changing the queue
- Signal that we accepted/connected a socket
[IP]
- Set the network mask and destination address in TCPGetInterfaceData
Modified:
trunk/reactos/lib/drivers/ip/network/ip.c
trunk/reactos/lib/drivers/ip/transport/tcp/if.c
trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c
Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] Thu Sep 2 04:18:17 2010
@@ -163,7 +163,7 @@
TcpipInitializeSpinLock(&IF->Lock);
IF->TCPContext = ExAllocatePoolWithTag
- ( NonPagedPool, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ),
+ ( NonPagedPool, sizeof(OSK_IFADDR) + 3 * sizeof( struct sockaddr_in ),
OSKITTCP_CONTEXT_TAG );
if (!IF->TCPContext) {
ExFreePoolWithTag(IF, IP_INTERFACE_TAG);
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] Thu Sep 2 04:18:17 2010
@@ -35,19 +35,16 @@
POSK_IFADDR ifaddr = IF->TCPContext;
struct sockaddr_in *addr_in;
struct sockaddr_in *dstaddr_in;
+ struct sockaddr_in *netmask_in;
ASSERT(ifaddr);
- RtlZeroMemory(ifaddr, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ));
+ RtlZeroMemory(ifaddr, sizeof(OSK_IFADDR) + 3 * sizeof( struct sockaddr_in ));
addr_in = (struct sockaddr_in *)&ifaddr[1];
dstaddr_in = (struct sockaddr_in *)&addr_in[1];
+ netmask_in = (struct sockaddr_in *)&dstaddr_in[1];
TI_DbgPrint(DEBUG_TCPIF,("Called\n"));
-
- ifaddr->ifa_dstaddr = (struct sockaddr *)dstaddr_in;
-
- /* XXX - Point-to-point interfaces not supported yet */
- memset( &ifaddr->ifa_dstaddr, 0, sizeof( struct sockaddr ) );
ifaddr->ifa_addr = (struct sockaddr *)addr_in;
Status = GetInterfaceIPv4Address( IF,
@@ -56,10 +53,24 @@
ASSERT(NT_SUCCESS(Status));
+ ifaddr->ifa_dstaddr = (struct sockaddr *)dstaddr_in;
+ Status = GetInterfaceIPv4Address(IF,
+ ADE_POINTOPOINT,
+ (PULONG)&dstaddr_in->sin_addr.s_addr );
+
+ ASSERT(NT_SUCCESS(Status));
+
+ ifaddr->ifa_netmask = (struct sockaddr *)netmask_in;
+ Status = GetInterfaceIPv4Address(IF,
+ ADE_ADDRMASK,
+ (PULONG)&netmask_in->sin_addr.s_addr );
+
+ ASSERT(NT_SUCCESS(Status));
+
TI_DbgPrint(DEBUG_TCPIF,("interface %x : addr %x\n",
IF, addr_in->sin_addr.s_addr));
- ifaddr->ifa_flags = 0; /* XXX what goes here? */
+ ifaddr->ifa_flags = 0;
ifaddr->ifa_refcnt = 0; /* Anachronistic */
ifaddr->ifa_metric = 1; /* We can get it like in ninfo.c, if we want */
ifaddr->ifa_mtu = IF->MTU;
Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskit…
==============================================================================
--- trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] Thu Sep 2
04:18:17 2010
@@ -151,6 +151,9 @@
struct iovec iov = { 0 };
int error = 0;
int tcp_flags = 0;
+
+ if (!connection)
+ return OSK_ESHUTDOWN;
OS_DbgPrint(OSK_MID_TRACE,
("so->so_state %x\n", ((struct socket
*)connection)->so_state));
@@ -218,14 +221,12 @@
struct sockaddr addr;
OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", socket));
-
- OSKLock();
- if ((so->so_state & SS_NBIO) && (so->so_state &
SS_ISCONNECTING)) {
- error = EALREADY;
- goto done;
- }
+
+ if (!socket)
+ return OSK_ESHUTDOWN;
OS_DbgPrint(OSK_MIN_TRACE,("Nam: %x\n", nam));
+
if( nam )
addr = *((struct sockaddr *)nam);
@@ -236,26 +237,12 @@
addr.sa_family = addr.sa_len;
addr.sa_len = sizeof(struct sockaddr);
+ OSKLock();
error = soconnect(so, &sabuf);
-
- if (error == EINPROGRESS)
- goto done;
- else if (error)
- goto bad;
-
- if ((so->so_state & SS_NBIO) && (so->so_state &
SS_ISCONNECTING)) {
- error = EINPROGRESS;
- goto done;
- }
-
-bad:
- so->so_state &= ~SS_ISCONNECTING;
-
- if (error == ERESTART)
- error = EINTR;
-
-done:
- OSKUnlock();
+ OSKUnlock();
+
+ if (error == 0) error = OSK_EINPROGRESS;
+
OS_DbgPrint(OSK_MID_TRACE,("Ending: %08x\n", error));
return (error);
}
@@ -347,13 +334,11 @@
if (!socket)
return OSK_ESHUTDOWN;
- if (!new_socket || !AddrOut)
+ if (!new_socket)
return OSK_EINVAL;
OS_DbgPrint(OSK_MID_TRACE,("OSKITTCP: Doing accept (Finish %d)\n",
FinishAccepting));
-
- *OutAddrLen = AddrLen;
if (name)
/* that's a copyin actually */
@@ -363,19 +348,17 @@
s = splnet();
-#if 0
if ((head->so_options & SO_ACCEPTCONN) == 0) {
OS_DbgPrint(OSK_MID_TRACE,("OSKITTCP: head->so_options = %x, wanted bit
%x\n",
head->so_options, SO_ACCEPTCONN));
error = EINVAL;
goto out;
}
-#endif
OS_DbgPrint(OSK_MID_TRACE,("head->so_q = %x, head->so_state = %x\n",
head->so_q, head->so_state));
- if ((head->so_state & SS_NBIO) && head->so_q == NULL) {
+ if (head->so_q == NULL) {
error = EWOULDBLOCK;
goto out;
}
@@ -395,8 +378,6 @@
OS_DbgPrint(OSK_MID_TRACE,("error = %d\n", error));
if( FinishAccepting && so ) {
- head->so_q = so->so_q;
- head->so_qlen--;
mnam.m_data = (char *)&sa;
mnam.m_len = sizeof(sa);
@@ -405,12 +386,9 @@
if (error)
goto out;
- InitializeSocketFlags(so);
- so->so_state |= SS_ISCONNECTED;
- so->so_q = so->so_q0 = NULL;
- so->so_qlen = so->so_q0len = 0;
- so->so_head = 0;
+ soqremque(so, 1);
so->so_connection = context;
+ soisconnected(so);
*newso = so;