mirror of
https://github.com/reactos/reactos.git
synced 2024-09-09 20:30:04 +00:00
Fixed OskitTCPSend prototype.
sleep: removed blocking. not needed anymore. Made socket non-blocking with respect to oskit. removed unneeded panic in sbflush. removed unneeded stats keeping. This info is better kept by tcpip.sys svn path=/trunk/; revision=10033
This commit is contained in:
parent
494edc04e5
commit
aa565ab062
|
@ -50,12 +50,12 @@ struct connect_args {
|
||||||
#define SEL_ERROR 256
|
#define SEL_ERROR 256
|
||||||
#define SEL_FINOUT 512
|
#define SEL_FINOUT 512
|
||||||
|
|
||||||
typedef void (*OSKITTCP_SOCKET_STATE)
|
typedef int (*OSKITTCP_SOCKET_STATE)
|
||||||
( void *ClientData,
|
( void *ClientData,
|
||||||
void *WhichSocket,
|
void *WhichSocket,
|
||||||
void *WhichConnection,
|
void *WhichConnection,
|
||||||
OSK_UINT SelFlags,
|
OSK_UINT NewState );
|
||||||
OSK_UINT SocketState );
|
|
||||||
typedef int (*OSKITTCP_SEND_PACKET)
|
typedef int (*OSKITTCP_SEND_PACKET)
|
||||||
( void *ClientData,
|
( void *ClientData,
|
||||||
void *WhichSocket,
|
void *WhichSocket,
|
||||||
|
@ -86,6 +86,11 @@ extern int OskitTCPReceive( void *socket,
|
||||||
OSK_UINT Len,
|
OSK_UINT Len,
|
||||||
OSK_UINT *OutLen,
|
OSK_UINT *OutLen,
|
||||||
OSK_UINT Flags );
|
OSK_UINT Flags );
|
||||||
|
extern int OskitTCPSend( void *socket,
|
||||||
|
OSK_PCHAR Data,
|
||||||
|
OSK_UINT Len,
|
||||||
|
OSK_UINT *OutLen,
|
||||||
|
OSK_UINT Flags );
|
||||||
#undef errno
|
#undef errno
|
||||||
|
|
||||||
#define malloc(x,...) fbsd_malloc(x,__FILE__,__LINE__)
|
#define malloc(x,...) fbsd_malloc(x,__FILE__,__LINE__)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
#include <oskittcp.h>
|
#include <oskittcp.h>
|
||||||
#include <oskitdebug.h>
|
#include <oskitdebug.h>
|
||||||
#include <ntddk.h>
|
#include <ntddk.h>
|
||||||
|
@ -79,13 +80,13 @@ int OskitTCPSocket( void *context,
|
||||||
int error = socreate(domain, &so, type, proto);
|
int error = socreate(domain, &so, type, proto);
|
||||||
if( !error ) {
|
if( !error ) {
|
||||||
so->so_connection = context;
|
so->so_connection = context;
|
||||||
|
so->so_state = SS_NBIO;
|
||||||
*aso = so;
|
*aso = so;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OskitTCPRecv( void *connection,
|
int OskitTCPRecv( void *connection,
|
||||||
void *Addr,
|
|
||||||
OSK_PCHAR Data,
|
OSK_PCHAR Data,
|
||||||
OSK_UINT Len,
|
OSK_UINT Len,
|
||||||
OSK_UINT *OutLen,
|
OSK_UINT *OutLen,
|
||||||
|
@ -118,9 +119,6 @@ int OskitTCPRecv( void *connection,
|
||||||
OskitDumpBuffer( m.m_data, uio.uio_resid );
|
OskitDumpBuffer( m.m_data, uio.uio_resid );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( paddr )
|
|
||||||
memcpy( Addr, paddr, min(sizeof(struct sockaddr),paddr->m_len) );
|
|
||||||
|
|
||||||
*OutLen = uio.uio_resid;
|
*OutLen = uio.uio_resid;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -186,22 +184,6 @@ NTSTATUS OskitTCPConnect( PVOID socket, PVOID connection,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = splnet();
|
|
||||||
|
|
||||||
while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
|
|
||||||
error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
|
|
||||||
"connect", 0);
|
|
||||||
if (error)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error == 0) {
|
|
||||||
error = so->so_error;
|
|
||||||
so->so_error = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
splx(s);
|
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
so->so_state &= ~SS_ISCONNECTING;
|
so->so_state &= ~SS_ISCONNECTING;
|
||||||
|
|
||||||
|
@ -219,12 +201,17 @@ DWORD OskitTCPClose( void *socket ) {
|
||||||
soclose( so );
|
soclose( so );
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD OskitTCPSend( void *socket, OSK_PCHAR Data, OSK_UINT Len, int flags ) {
|
int OskitTCPSend( void *socket, OSK_PCHAR Data, OSK_UINT Len,
|
||||||
OskitDumpBuffer( Data, Len );
|
OSK_UINT *OutLen, OSK_UINT flags ) {
|
||||||
struct mbuf mb;
|
struct mbuf mb;
|
||||||
|
struct uio uio = { 0 };
|
||||||
|
int error = 0;
|
||||||
|
OskitDumpBuffer( Data, Len );
|
||||||
mb.m_data = Data;
|
mb.m_data = Data;
|
||||||
mb.m_len = Len;
|
mb.m_len = Len;
|
||||||
return sosend( socket, NULL, NULL, (struct mbuf *)&mb, NULL, 0 );
|
error = sosend( socket, NULL, &uio, (struct mbuf *)&mb, NULL, 0 );
|
||||||
|
*OutLen = uio.uio_resid;
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *OskitTCPAccept( void *socket,
|
void *OskitTCPAccept( void *socket,
|
||||||
|
|
|
@ -64,25 +64,29 @@ void wakeup( struct socket *so, struct selinfo *si, void *token ) {
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
PSLEEPING_THREAD SleepingThread;
|
PSLEEPING_THREAD SleepingThread;
|
||||||
|
UINT flags = 0;
|
||||||
|
|
||||||
OS_DbgPrint
|
OS_DbgPrint
|
||||||
(OSK_MID_TRACE,("XXX Bytes to receive: %d\n", so->so_rcv.sb_cc));
|
(OSK_MID_TRACE,("XXX Bytes to receive: %d\n", so->so_rcv.sb_cc));
|
||||||
|
|
||||||
if( so->so_rcv.sb_cc && si )
|
if( so->so_state & SS_ISCONNECTED ) {
|
||||||
si->si_flags |= SEL_READ;
|
OS_DbgPrint(OSK_MID_TRACE,("Socket connected!\n"));
|
||||||
|
flags |= SEL_CONNECT;
|
||||||
|
}
|
||||||
|
if( so->so_rcv.sb_cc && si ) {
|
||||||
|
OS_DbgPrint(OSK_MID_TRACE,("Socket readable\n"));
|
||||||
|
flags |= SEL_READ;
|
||||||
|
}
|
||||||
|
|
||||||
OS_DbgPrint(OSK_MID_TRACE,("Wakeup %x (socket %x, si_flags %x, state %x)!\n",
|
OS_DbgPrint(OSK_MID_TRACE,("Wakeup %x (socket %x, si_flags %x, state %x)!\n",
|
||||||
token, so, si ? si->si_flags : 0,
|
token, so, si ? si->si_flags : 0,
|
||||||
so->so_state));
|
so->so_state));
|
||||||
|
|
||||||
if( OtcpEvent.SocketState ) {
|
if( OtcpEvent.SocketState )
|
||||||
OS_DbgPrint(OSK_MID_TRACE,("Calling client's socket state fn\n"));
|
|
||||||
OtcpEvent.SocketState( OtcpEvent.ClientData,
|
OtcpEvent.SocketState( OtcpEvent.ClientData,
|
||||||
so,
|
so,
|
||||||
so->so_connection,
|
so ? so->so_connection : 0,
|
||||||
si ? si->si_flags : 0,
|
flags );
|
||||||
so->so_state );
|
|
||||||
}
|
|
||||||
|
|
||||||
ExAcquireFastMutex( &SleepingThreadsLock );
|
ExAcquireFastMutex( &SleepingThreadsLock );
|
||||||
Entry = SleepingThreadsList.Flink;
|
Entry = SleepingThreadsList.Flink;
|
||||||
|
|
|
@ -121,10 +121,11 @@ tcp_reass(tp, ti, m)
|
||||||
* Find a segment which begins after this one does.
|
* Find a segment which begins after this one does.
|
||||||
*/
|
*/
|
||||||
for (q = tp->seg_next; q != (struct tcpiphdr *)tp;
|
for (q = tp->seg_next; q != (struct tcpiphdr *)tp;
|
||||||
q = (struct tcpiphdr *)q->ti_next)
|
q = (struct tcpiphdr *)q->ti_next) {
|
||||||
if (SEQ_GT(q->ti_seq, ti->ti_seq))
|
printf("Finding segment: %x\n", q);
|
||||||
break;
|
if (SEQ_GT(q->ti_seq, ti->ti_seq))
|
||||||
|
break;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* If there is a preceding segment, it may provide some of
|
* If there is a preceding segment, it may provide some of
|
||||||
* our data already. If so, drop the data from the incoming
|
* our data already. If so, drop the data from the incoming
|
||||||
|
@ -760,7 +761,7 @@ findpcb:
|
||||||
*/
|
*/
|
||||||
tp->rcv_adv += min(tp->rcv_wnd, TCP_MAXWIN);
|
tp->rcv_adv += min(tp->rcv_wnd, TCP_MAXWIN);
|
||||||
tcpstat.tcps_connects++;
|
tcpstat.tcps_connects++;
|
||||||
soisconnected(so);
|
//soisconnected(so);
|
||||||
tp->t_timer[TCPT_KEEP] = tcp_keepinit;
|
tp->t_timer[TCPT_KEEP] = tcp_keepinit;
|
||||||
dropsocket = 0; /* committed to socket */
|
dropsocket = 0; /* committed to socket */
|
||||||
tcpstat.tcps_accepts++;
|
tcpstat.tcps_accepts++;
|
||||||
|
@ -853,7 +854,7 @@ findpcb:
|
||||||
goto dropwithreset;
|
goto dropwithreset;
|
||||||
}
|
}
|
||||||
tcpstat.tcps_connects++;
|
tcpstat.tcps_connects++;
|
||||||
soisconnected(so);
|
//soisconnected(so);
|
||||||
/* Do window scaling on this connection? */
|
/* Do window scaling on this connection? */
|
||||||
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
||||||
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
|
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
|
||||||
|
@ -890,6 +891,7 @@ findpcb:
|
||||||
("Socket %x entered ESTABLISHED state\n",
|
("Socket %x entered ESTABLISHED state\n",
|
||||||
so));
|
so));
|
||||||
tp->t_state = TCPS_ESTABLISHED;
|
tp->t_state = TCPS_ESTABLISHED;
|
||||||
|
soisconnected(so);
|
||||||
tp->t_timer[TCPT_KEEP] = tcp_keepidle;
|
tp->t_timer[TCPT_KEEP] = tcp_keepidle;
|
||||||
socwakeup(so);
|
socwakeup(so);
|
||||||
}
|
}
|
||||||
|
@ -1220,7 +1222,7 @@ trimthenstep6:
|
||||||
goto dropwithreset;
|
goto dropwithreset;
|
||||||
|
|
||||||
tcpstat.tcps_connects++;
|
tcpstat.tcps_connects++;
|
||||||
soisconnected(so);
|
//soisconnected(so);
|
||||||
/* Do window scaling? */
|
/* Do window scaling? */
|
||||||
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
||||||
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
|
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
|
||||||
|
|
|
@ -452,7 +452,6 @@ tcp_connect(tp, nam)
|
||||||
|
|
||||||
in_pcbrehash(inp);
|
in_pcbrehash(inp);
|
||||||
|
|
||||||
|
|
||||||
tp->t_template = tcp_template(tp);
|
tp->t_template = tcp_template(tp);
|
||||||
|
|
||||||
if (tp->t_template == 0) {
|
if (tp->t_template == 0) {
|
||||||
|
@ -478,7 +477,6 @@ tcp_connect(tp, nam)
|
||||||
|
|
||||||
tcp_sendseqinit(tp);
|
tcp_sendseqinit(tp);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate a CC value for this connection and
|
* Generate a CC value for this connection and
|
||||||
* check whether CC or CCnew should be used.
|
* check whether CC or CCnew should be used.
|
||||||
|
|
|
@ -74,6 +74,8 @@ socreate(dom, aso, type, proto)
|
||||||
register struct socket *so;
|
register struct socket *so;
|
||||||
register int error;
|
register int error;
|
||||||
|
|
||||||
|
printf("socreate(%d,%x,%d,%d)\n", dom, aso, type, proto);
|
||||||
|
|
||||||
if (proto)
|
if (proto)
|
||||||
prp = pffindproto(dom, proto, type);
|
prp = pffindproto(dom, proto, type);
|
||||||
else
|
else
|
||||||
|
@ -352,7 +354,7 @@ sosend(so, addr, uio, top, control, flags)
|
||||||
dontroute =
|
dontroute =
|
||||||
(flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 &&
|
(flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 &&
|
||||||
(so->so_proto->pr_flags & PR_ATOMIC);
|
(so->so_proto->pr_flags & PR_ATOMIC);
|
||||||
p->p_stats->p_ru.ru_msgsnd++;
|
/* p->p_stats->p_ru.ru_msgsnd++; */
|
||||||
if (control)
|
if (control)
|
||||||
clen = control->m_len;
|
clen = control->m_len;
|
||||||
#define snderr(errno) { error = errno; splx(s); goto release; }
|
#define snderr(errno) { error = errno; splx(s); goto release; }
|
||||||
|
|
|
@ -742,8 +742,10 @@ sbflush(sb)
|
||||||
panic("sbflush");
|
panic("sbflush");
|
||||||
while (sb->sb_mbcnt)
|
while (sb->sb_mbcnt)
|
||||||
sbdrop(sb, (int)sb->sb_cc);
|
sbdrop(sb, (int)sb->sb_cc);
|
||||||
|
#if 0
|
||||||
if (sb->sb_cc || sb->sb_mb)
|
if (sb->sb_cc || sb->sb_mb)
|
||||||
panic("sbflush 2");
|
panic("sbflush 2");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue