From 75cf92117c118f9aca37b39f44ad1e1e759f78bf Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 25 Apr 2008 12:54:59 +0200 Subject: made gtls server driver work in plain tcp mode --- runtime/nsd_ptcp.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'runtime/nsd_ptcp.c') diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c index 584cc93f..2a74e061 100644 --- a/runtime/nsd_ptcp.c +++ b/runtime/nsd_ptcp.c @@ -93,7 +93,6 @@ ENDobjDestruct(nsd_ptcp) /* Provide access to the underlying OS socket. This is primarily * useful for other drivers (like nsd_gtls) who utilize ourselfs * for some of their functionality. -- rgerhards, 2008-04-18 - * TODO: what about the server socket structure? */ static rsRetVal GetSock(nsd_t *pNsd, int *pSock) @@ -110,6 +109,26 @@ GetSock(nsd_t *pNsd, int *pSock) } +/* Provide access to the underlying OS socket. This is primarily + * useful for other drivers (like nsd_gtls) who utilize ourselfs + * for some of their functionality. + * This function sets the socket -- rgerhards, 2008-04-25 + */ +static rsRetVal +SetSock(nsd_t *pNsd, int sock) +{ + nsd_ptcp_t *pThis = (nsd_ptcp_t*) pNsd; + DEFiRet; + + ISOBJ_TYPE_assert((pThis), nsd_ptcp); + assert(sock >= 0); + + pThis->sock = sock; + + RETiRet; +} + + /* abort a connection. This is meant to be called immediately * before the Destruct call. -- rgerhards, 2008-03-24 */ @@ -211,7 +230,6 @@ finalize_it: } - /* accept an incoming connection request * rgerhards, 2008-04-22 */ @@ -397,10 +415,13 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*), * construct a new netstrm obj and hand it over to the upper layers for inclusion * into their socket array. -- rgerhards, 2008-04-23 */ +RUNLOG_VAR("%d", sock); CHKiRet(pNS->Drvr.Construct(&pNewNsd)); - ((nsd_ptcp_t*)pNewNsd)->sock = sock; + CHKiRet(pNS->Drvr.SetSock(pNewNsd, sock)); +RUNLOG; CHKiRet(netstrms.CreateStrm(pNS, &pNewStrm)); pNewStrm->pDrvrData = (nsd_t*) pNewNsd; +RUNLOG; CHKiRet(fAddLstn(pUsr, pNewStrm)); pNewNsd = NULL; pNewStrm = NULL; @@ -587,6 +608,7 @@ CODESTARTobjQueryInterface(nsd_ptcp) pIf->Destruct = (rsRetVal(*)(nsd_t**)) nsd_ptcpDestruct; pIf->Abort = Abort; pIf->GetSock = GetSock; + pIf->SetSock = SetSock; pIf->Rcv = Rcv; pIf->Send = Send; pIf->LstnInit = LstnInit; -- cgit