datacommsserver/esockserver/test/TE_ESock/TestStepEsock.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This contains CTestCase which is the base class for all the TestCase DLLs
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 
       
    21 // Test system includes
       
    22 #include "TestStepEsock.h"
       
    23 
       
    24 TVerdict CTestStepEsock::easyTestStepPostambleL()
       
    25 	{
       
    26 	// For a failed OOM loop, all sockets that have been added to the socket container
       
    27 	// will be closed here.  Otherwise, let Test1.15 handle closures.
       
    28 	
       
    29 	if (TestStepResult() == EFail)
       
    30 		{
       
    31 		CloseSockets();
       
    32 		}
       
    33 	
       
    34 	return EPass;
       
    35 	}
       
    36 
       
    37 /**
       
    38 Gets the (INI file) section name
       
    39 @param aSectName	section name to use if none specified in script
       
    40 @return section name
       
    41  */
       
    42 const TDesC& CTestStepEsock::SectionName(const TDesC& aSectName)
       
    43 	{
       
    44 	const TDesC &sectName = ConfigSection();
       
    45 	if (sectName.Length() > 0)
       
    46 		return sectName;
       
    47 	else
       
    48 		return aSectName;
       
    49 	}
       
    50 
       
    51 TBool CTestStepEsock::GetIpAddressFromConfig(const TDesC &aSectName,const TDesC &aKeyName,TInetAddr &anAddr)
       
    52 	{
       
    53 	TPtrC result;
       
    54 	TBool bRet;
       
    55 	TInt nRet;
       
    56 	
       
    57 	// get string from config file
       
    58 	bRet = GetStringFromConfig(aSectName, aKeyName, result);
       
    59 	
       
    60 	if (bRet) // string was retrieved successfully
       
    61 		{
       
    62 		// convert to IP address
       
    63 		nRet = anAddr.Input(result);
       
    64 		
       
    65 		// if IP address is invalid
       
    66 		if (nRet != KErrNone)
       
    67 			{
       
    68 			// display error message
       
    69 			Logger().WriteFormat(_L("Invalid IP address, section:%S key:%S "), &aSectName, &aKeyName );
       
    70 			bRet = EFalse;
       
    71 			}
       
    72 		}
       
    73 	
       
    74 	return bRet;
       
    75 	}
       
    76 
       
    77 void CTestStepEsock::StripeMem32(TUint *aBuf, TInt aStartPos, TInt aEndPos)
       
    78 //
       
    79 // Mark a buffer with repeating byte pattern
       
    80 //
       
    81 	{
       
    82 	aStartPos >>= 2;
       
    83 	aEndPos >>= 2;
       
    84 	
       
    85 	for (TInt i=aStartPos;i<aEndPos;i++)
       
    86 		{
       
    87 		aBuf[i]=i<<2;
       
    88 		}
       
    89 	}
       
    90 
       
    91 void CTestStepEsock::StripeDes32(TDes8 &aBuf, TInt aStartPos, TInt anEndPos)
       
    92 	{
       
    93 	StripeMem32((TUint*)aBuf.Ptr(), aStartPos, anEndPos);
       
    94 	}
       
    95 
       
    96 void CTestStepEsock::StripeMem(TUint8 *aBuf, TInt aStartPos, TInt anEndPos, TUint aStartChar, TUint anEndChar, TInt aOffset)
       
    97 //
       
    98 // Mark a buffer with repeating byte pattern
       
    99 //
       
   100 	{
       
   101 	TUint character=aStartChar+(aOffset%((anEndChar+1)-aStartChar));
       
   102 	
       
   103 	for (TInt i=aStartPos;i<anEndPos;i++)
       
   104 		{
       
   105 		aBuf[i]=(TText8)character;
       
   106 		if(++character>anEndChar)
       
   107 			character=aStartChar;
       
   108 		}
       
   109 	}
       
   110 
       
   111 void CTestStepEsock::StripeDes(TDes8 &aBuf, TInt aStartPos, TInt anEndPos, TUint aStartChar, TUint anEndChar, TInt aOffset)
       
   112 	{
       
   113 	StripeMem((TUint8 *)aBuf.Ptr(), aStartPos, anEndPos, aStartChar, anEndChar, aOffset);
       
   114 	}
       
   115 
       
   116 
       
   117 
       
   118 TInt CTestStepEsock::OpenListeningSocketL(TInetAddr anAddr, TInt &aSockIndex, 
       
   119 										   TInt aPort, TInt aSize)
       
   120 	{
       
   121 	TInt nRet;
       
   122 	
       
   123 	RSocket sock;
       
   124 	CleanupClosePushL(sock);
       
   125 	
       
   126 	// open a TCP socket
       
   127 	nRet = sock.Open(iEsockSuite->iSocketServer,
       
   128 		KAfInet,KSockStream, KProtocolInetTcp);
       
   129 	
       
   130 	if (nRet != KErrNone)
       
   131 		{
       
   132 		Logger().WriteFormat(_L("Failed to open listening socket: return value = %d"), nRet);
       
   133 		CleanupStack::PopAndDestroy();
       
   134 		return nRet;
       
   135 		}
       
   136 	
       
   137 	// bind the socket
       
   138 	anAddr.SetPort(aPort);
       
   139 	nRet = sock.Bind(anAddr);
       
   140 	
       
   141 	if (nRet != KErrNone)
       
   142 		{
       
   143 		Logger().WriteFormat(_L("Failed to bind socket: return value = %d"), nRet);
       
   144 		CleanupStack::PopAndDestroy();
       
   145 		return nRet;
       
   146 		}
       
   147 	
       
   148 	// listen on the socket
       
   149 	nRet = sock.Listen(aSize);
       
   150 	
       
   151 	if (nRet != KErrNone)
       
   152 		{
       
   153 		Logger().WriteFormat(_L("Failed to listen on socket: return value = %d"), nRet);
       
   154 		CleanupStack::PopAndDestroy();
       
   155 		return nRet;
       
   156 		}
       
   157 	
       
   158 	// store socket handle
       
   159 	aSockIndex = iEsockSuite->AddSocketToListL(sock);
       
   160 	CleanupStack::Pop();
       
   161 	Logger().WriteFormat(_L("Socket %d listening..."), aSockIndex);
       
   162 	return nRet;
       
   163 	}
       
   164 
       
   165 
       
   166 
       
   167 TInt CTestStepEsock::OpenActiveSocketL(TInetAddr anAddr, TInt &aSockIndex,
       
   168 										TInt aPort)
       
   169 	{
       
   170 	TInt nRet;
       
   171 	TRequestStatus stat;
       
   172 	
       
   173 	RSocket sock;
       
   174 	CleanupClosePushL(sock);
       
   175 	
       
   176 	// open a TCP socket
       
   177 	nRet = sock.Open(iEsockSuite->iSocketServer,
       
   178 		KAfInet,KSockStream, KProtocolInetTcp);
       
   179 	
       
   180 	if (nRet != KErrNone)
       
   181 		{
       
   182 		Logger().WriteFormat(_L("Failed to open active socket: return value = %d"), nRet);
       
   183 		CleanupStack::PopAndDestroy();
       
   184 		return nRet;
       
   185 		}
       
   186 	
       
   187 	// set port number
       
   188 	anAddr.SetPort(aPort);
       
   189 	
       
   190 	// make connect request
       
   191 	sock.Connect(anAddr, stat);
       
   192 	User::WaitForRequest(stat);
       
   193 
       
   194 	nRet = stat.Int();
       
   195 	if (nRet != KErrNone)
       
   196 		{
       
   197 		Logger().WriteFormat(_L("Failed to connect: return value = %d"), nRet);
       
   198 		CleanupStack::PopAndDestroy();
       
   199 		return nRet;
       
   200 		}
       
   201 	
       
   202 	// store socket handle
       
   203 	aSockIndex = iEsockSuite->AddSocketToListL(sock);
       
   204 	CleanupStack::Pop();
       
   205 	Logger().WriteFormat(_L("Socket %d making connection..."), aSockIndex);
       
   206 	return nRet;
       
   207 	}
       
   208 
       
   209 
       
   210 TBool CTestStepEsock::AcceptConnectionL(TInt &aSockIndex, TInt aListenIndex)
       
   211 	{
       
   212 	TInt nRet;
       
   213 	TRequestStatus stat;
       
   214 	
       
   215 	RSocket sock;
       
   216 	CleanupClosePushL(sock);
       
   217 	
       
   218 	// open a blank socket
       
   219 	nRet = sock.Open(iEsockSuite->iSocketServer);
       
   220 	
       
   221 	if (nRet != KErrNone)
       
   222 		{
       
   223 		Logger().WriteFormat(_L("Failed to open blank socket: return value = %d"), nRet);
       
   224 		CleanupStack::PopAndDestroy();
       
   225 		return nRet;
       
   226 		}
       
   227 	
       
   228 	// accept the connection on the listening socket, pass
       
   229 	// the blank socket as parameter
       
   230 	(iEsockSuite->GetSocketHandle(aListenIndex)).Accept(sock, stat);
       
   231 	
       
   232 	User::WaitForRequest(stat);
       
   233 	nRet = stat.Int();
       
   234 	
       
   235 	if (nRet != KErrNone)
       
   236 		{
       
   237 		Logger().WriteFormat(_L("Failed to accept connection: return value = %d"), nRet);
       
   238 		CleanupStack::PopAndDestroy();
       
   239 		return nRet;
       
   240 		}
       
   241 	
       
   242 	// store socket handle
       
   243 	aSockIndex = iEsockSuite->AddSocketToListL(sock);
       
   244 	CleanupStack::Pop();
       
   245 	Logger().WriteFormat(_L("Socket %d accepting..."), aSockIndex);
       
   246 	return nRet;
       
   247 	}
       
   248 
       
   249 /**
       
   250 Closes all sockets in the socket container.
       
   251 @param aLoglevel	Specifies level of detail for logging of socket closures;
       
   252 					0 => no logging
       
   253  */ 
       
   254 void CTestStepEsock::CloseSockets(TUint aLoglevel)
       
   255 	{
       
   256 	TInt nSockets = iEsockSuite->GetSocketListCount();
       
   257 	
       
   258 	for(TInt i=nSockets; i>0; i--)
       
   259 		{
       
   260 		if (aLoglevel > 1)
       
   261 			Logger().WriteFormat(_L("Closing socket #%d"), i);
       
   262 		iEsockSuite->CloseSocket(i);
       
   263 		}
       
   264 	
       
   265 	if ((aLoglevel > 1) || (aLoglevel > 0 && nSockets > 0))
       
   266 		Logger().WriteFormat(_L("Closed %d socket(s)"), nSockets);
       
   267 	}
       
   268 
       
   269 /**
       
   270 Attempts to open aNumSockets sockets with the supplied parameters and
       
   271 stores the successfully opened sockets in the socket container.
       
   272 @param addrFamily	a valid address constant for a protocol family
       
   273 @param aSockType	a valid socket type for the protocol
       
   274 @param aProtocol	a constant which identifies a specific protocol
       
   275 @param aNumSockets	the integral quantity of sockets to open
       
   276 @return Error code of last attempted socket open: KErrNone if open succeeded, 
       
   277 		otherwise one of the other system wide error codes.
       
   278  */ 
       
   279 TInt CTestStepEsock::OpenSockets(TUint addrFamily, TUint aSockType, TUint aProtocol, TUint aNumSockets)
       
   280 	{
       
   281 	TInt nRet;
       
   282 	TInt i;
       
   283 	for (i = 0; i < aNumSockets; i++)
       
   284 		{
       
   285 		// open a TCP socket
       
   286 		RSocket sock;
       
   287 		nRet = sock.Open(iEsockSuite->iSocketServer, addrFamily, aSockType, aProtocol);
       
   288 		if (KErrNone == nRet)
       
   289 			{
       
   290 			// store socket handle
       
   291 			nRet = iEsockSuite->AddSocketToList(sock);
       
   292 			}
       
   293 		if (nRet != KErrNone)
       
   294 			{
       
   295 			sock.Close();
       
   296 			break;
       
   297 			}
       
   298 		}
       
   299 	
       
   300 	return nRet;
       
   301 	}
       
   302 
       
   303 /**
       
   304 Attempts to open aNumSockets sockets with the supplied protocol name and
       
   305 stores the successfully opened sockets in the socket container.
       
   306 @param aName		Name of a protocol
       
   307 @param aNumSockets	the integral quantity of sockets to open
       
   308 @return Error code of last attempted socket open: KErrNone if open succeeded, 
       
   309 		otherwise one of the other system wide error codes.
       
   310  */ 
       
   311 TInt CTestStepEsock::OpenSockets(const TDesC &aName, TUint aNumSockets)
       
   312 	{
       
   313 	TInt nRet;
       
   314 	TInt i;
       
   315 	for (i = 0; i < aNumSockets; i++)
       
   316 		{
       
   317 		// open a TCP socket
       
   318 		RSocket sock;
       
   319 		nRet = sock.Open(iEsockSuite->iSocketServer, aName);
       
   320 		if (KErrNone == nRet)
       
   321 			{
       
   322 			// store socket handle
       
   323 			nRet = iEsockSuite->AddSocketToList(sock);
       
   324 			}
       
   325 		if (nRet != KErrNone)
       
   326 			{
       
   327 			sock.Close();
       
   328 			break;
       
   329 			}
       
   330 		}
       
   331 	
       
   332 	return nRet;
       
   333 	}
       
   334 
       
   335 /**
       
   336 Attempts to open aNumSockets null sockets and stores the successfully opened sockets
       
   337 in the socket container.
       
   338 @param aNumSockets	the integral quantity of sockets to open
       
   339 @return Error code of last attempted socket open: KErrNone if open succeeded, 
       
   340 		otherwise one of the other system wide error codes.
       
   341  */ 
       
   342 TInt CTestStepEsock::OpenSockets(TUint aNumSockets)
       
   343 	{
       
   344 	TInt nRet;
       
   345 	TInt i;
       
   346 	for (i = 0; i < aNumSockets; i++)
       
   347 		{
       
   348 		// open a TCP socket
       
   349 		RSocket sock;
       
   350 		nRet = sock.Open(iEsockSuite->iSocketServer);
       
   351 		if (KErrNone == nRet)
       
   352 			{
       
   353 			// store socket handle
       
   354 			nRet = iEsockSuite->AddSocketToList(sock);
       
   355 			}
       
   356 		if (nRet != KErrNone)
       
   357 			{
       
   358 			sock.Close();
       
   359 			break;
       
   360 			}
       
   361 		}
       
   362 	
       
   363 	return nRet;
       
   364 	}
       
   365 
       
   366 /**
       
   367 Attempts to open a minimum number of sockets with the supplied parameters and
       
   368 stores the successfully opened sockets in the socket container.
       
   369 @param aSectName	an INI file section name
       
   370 @param addrFamily	a valid address constant for a protocol family
       
   371 @param aSockType	a valid socket type for the protocol
       
   372 @param aProtocol	a constant which identifies a specific protocol
       
   373 @param aNumSockets	the integral quantity of sockets to open
       
   374 @return Number of sockets opened; 
       
   375 		otherwise one of the other system wide error codes.
       
   376  */ 
       
   377 TInt CTestStepEsock::OpenMinSockets(const TDesC &aSectName, TUint addrFamily, TUint aSockType, TUint aProtocol, TUint aMinSockets)
       
   378 	{
       
   379 	TInt ret = KErrNone;
       
   380     TInt nSockets;
       
   381 	if (!GetIntFromConfig(SectionName(aSectName), _L("numSockets"), nSockets))
       
   382 		{
       
   383     	nSockets = aMinSockets;
       
   384     	}
       
   385     nSockets = (nSockets > aMinSockets) ? nSockets : aMinSockets;
       
   386 
       
   387     nSockets -= iEsockSuite->GetSocketListCount();
       
   388     if (nSockets > 0)
       
   389     	{
       
   390     	ret = OpenSockets(addrFamily, aSockType, aProtocol, nSockets);
       
   391     	}
       
   392 
       
   393     return ret;
       
   394 	}
       
   395 
       
   396 /**
       
   397 Attempts to open the required number of connections.
       
   398 @param aSectName	an INI file section name, that may have an entry for the
       
   399 					number of client sockets to use.
       
   400 					If there is no entry, then one client socket is assumed.
       
   401 @param iSockIndex2	index to 1st client connection end-point
       
   402 @param iSockIndex3	index to 1st server connection end-point
       
   403 @return Number of connections opened;
       
   404 		otherwise one of the other system wide error codes.
       
   405  */
       
   406 TInt CTestStepEsock::OpenConnectionsL(const TDesC &aSectName, TInt &aSockIndex2, TInt &aSockIndex3)
       
   407 	{
       
   408 	TInt nConnections;
       
   409 	const TDesC &sectName = SectionName(aSectName);
       
   410 	// get number of client sockets to open
       
   411 	if (!GetIntFromConfig(sectName, _L("numSockets"), nConnections))
       
   412 		{
       
   413 		nConnections = 1;
       
   414 		}
       
   415 	
       
   416 	if (iEsockSuite->GetSocketListCount() != 2 * nConnections + 1)
       
   417 		{
       
   418 		CloseSockets();
       
   419 		
       
   420 		TInetAddr addrLocal, addrRemote;
       
   421 		// get local ip address
       
   422 		if (!GetIpAddressFromConfig(sectName, _L("ipAddressLocal"), addrLocal))
       
   423 			{
       
   424 			return KErrNotFound;
       
   425 			}
       
   426 		
       
   427 		// get ip address to connect to (usually loopback)
       
   428 		if (!GetIpAddressFromConfig(sectName, _L("ipAddressRemote"), addrRemote))
       
   429 			{
       
   430 			return KErrNotFound;
       
   431 			}
       
   432 		
       
   433 		// get port number
       
   434 		TInt port;
       
   435 		if (!GetIntFromConfig(sectName, _L("port"), port))
       
   436 			{
       
   437 			port = 1;
       
   438 			}
       
   439 		
       
   440 		User::After(1000000);
       
   441 		// open socket and listen for connect requests
       
   442 		TInt sockIndex1;
       
   443 		TInt nRet = OpenListeningSocketL(addrLocal, sockIndex1, port);
       
   444 		if (KErrNone != nRet)
       
   445 			{
       
   446 			return nRet;
       
   447 			}
       
   448 		
       
   449 		// save indices for client and server sockets
       
   450 		aSockIndex2 = sockIndex1 + 1;
       
   451 		aSockIndex3 = aSockIndex2 + 1;
       
   452 		
       
   453 		// for each client socket
       
   454 		TInt sockIndexIgnore;
       
   455 		for (TInt i = 0; i < nConnections; i++)
       
   456 			{
       
   457 			// open active socket and make connect request
       
   458 			nRet = OpenActiveSocketL(addrRemote, sockIndexIgnore, port);
       
   459 			if (KErrNone != nRet)
       
   460 				{
       
   461 				return nRet;
       
   462 				}
       
   463 			
       
   464 			// accept connect request
       
   465 			nRet = AcceptConnectionL(sockIndexIgnore, sockIndex1);
       
   466 			if (KErrNone != nRet)
       
   467 				{
       
   468 				return nRet;
       
   469 				}
       
   470 			}
       
   471 		}
       
   472 	
       
   473 	return nConnections;
       
   474 	}
       
   475 
       
   476 TInt CTestStepEsock::SetRoute(TInt aOp, TUint32 aDest, TUint32 aNetMask, TUint32 aGateway, TUint32 aInterface, TInt aMetric)
       
   477 	{
       
   478 	
       
   479 	TPckgBuf<TSoInetRouteInfo> info;
       
   480 	info().iType = ERtUser;
       
   481 	info().iState = ERtReady;
       
   482 	info().iMetric = aMetric;
       
   483 	info().iDstAddr.SetAddress(aDest);
       
   484 	info().iNetMask.SetAddress(aNetMask);
       
   485 	info().iGateway.SetAddress(aGateway);
       
   486 	info().iIfAddr.SetAddress(aInterface);
       
   487 	
       
   488 	return iEsockSuite->GetSocketHandle(1).SetOpt(aOp, KSolInetRtCtrl, info);
       
   489 	}
       
   490 
       
   491 TInt CTestStepEsock::ListRoutes()
       
   492 	{
       
   493 	TPckgBuf<TSoInetRouteInfo> opt;
       
   494 	TInt ret;
       
   495 	TBuf<39> ia, ga, da, nm;// changed from 16 AJH
       
   496 	
       
   497 	ret = iEsockSuite->GetSocketHandle(1).SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl);
       
   498 	if (ret!=KErrNone)
       
   499 		return ret;
       
   500 	
       
   501 	Logger().WriteFormat(_L("  Destination      NetMask        Gateway      Interface"));
       
   502 	while (ret==KErrNone)
       
   503 		{
       
   504 		ret = iEsockSuite->GetSocketHandle(1).GetOpt(KSoInetNextRoute, KSolInetRtCtrl, opt);
       
   505 		if (ret!=KErrNone)
       
   506 			continue;
       
   507 		opt().iDstAddr.OutputWithScope(da);
       
   508 		opt().iNetMask.OutputWithScope(nm);
       
   509 		opt().iGateway.OutputWithScope(ga);
       
   510 		opt().iIfAddr.OutputWithScope(ia);
       
   511 		
       
   512 		Logger().WriteFormat(_L("%15S %15S %15S %15S\n"), &da, &nm, &ga, &ia);
       
   513 		}
       
   514 	return ret==KErrEof ? KErrNone : ret;
       
   515 	}
       
   516 
       
   517 
       
   518 TBool CTestStepEsock::GetAppendixB1()
       
   519 	{
       
   520 	TBool bRet;
       
   521 	TInetAddr addrLocal;
       
   522 	
       
   523 	appendixInArray.Reset();
       
   524 
       
   525 	// get ip address
       
   526 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress1"), addrLocal);
       
   527 	if (!bRet)
       
   528 		{
       
   529 		// failed to get ipAddress
       
   530 		return EFalse;
       
   531 		}
       
   532 	// Set IP to Class A Network
       
   533 	appendixInArray.Insert(addrLocal, 0);
       
   534 	
       
   535 	// get ip address
       
   536 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress2"), addrLocal);
       
   537 	if (!bRet)
       
   538 		{
       
   539 		// failed to get ipAddress
       
   540 		return EFalse;
       
   541 		}
       
   542 	// Set IP to Class B Network
       
   543 	appendixInArray.Insert(addrLocal, 1);
       
   544 	
       
   545 	// get ip address
       
   546 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress3"), addrLocal);
       
   547 	if (!bRet)
       
   548 		{
       
   549 		// failed to get ipAddress
       
   550 		return EFalse;
       
   551 		}
       
   552 	// Set IP to Class C Network
       
   553 	appendixInArray.Insert(addrLocal, 2);
       
   554 	
       
   555 	// get ip address
       
   556 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress4"), addrLocal);
       
   557 	if (!bRet)
       
   558 		{
       
   559 		// failed to get ipAddress
       
   560 		return EFalse;
       
   561 		}
       
   562 	// Set IP to Class D Network
       
   563 	appendixInArray.Insert(addrLocal, 3);
       
   564 	
       
   565 	// get ip address
       
   566 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress5"), addrLocal);
       
   567 	if (!bRet)
       
   568 		{
       
   569 		// failed to get ipAddress
       
   570 		return EFalse;
       
   571 		}
       
   572 	// Set IP to Class E Network
       
   573 	appendixInArray.Insert(addrLocal, 4);
       
   574 	
       
   575 	// get ip address
       
   576 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress6"), addrLocal);
       
   577 	if (!bRet)
       
   578 		{
       
   579 		// failed to get ipAddress
       
   580 		return EFalse;
       
   581 		}
       
   582 	// Set IP to Loopback
       
   583 	appendixInArray.Insert(addrLocal, 5);
       
   584 	
       
   585 	// get ip address
       
   586 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress7"), addrLocal);
       
   587 	if (!bRet)
       
   588 		{
       
   589 		// failed to get ipAddress
       
   590 		return EFalse;
       
   591 		}
       
   592 	// Set IP to IsUnspecified - 0.0.0.0
       
   593 	appendixInArray.Insert(addrLocal, 6);
       
   594 	
       
   595 	// get ip address
       
   596 	bRet = GetIpAddressFromConfig(_L("AppendixB1"), _L("ipAddress8"), addrLocal);
       
   597 	if (!bRet)
       
   598 		{
       
   599 		// failed to get ipAddress
       
   600 		return EFalse;
       
   601 		}
       
   602 	// Broadcast Address
       
   603 	// Set IP to Broadcast - 255.255.255.255
       
   604 	appendixInArray.Insert(addrLocal, 7);
       
   605 	
       
   606 	return ETrue;
       
   607 	}
       
   608 
       
   609 TBool CTestStepEsock::GetAppendixB2()
       
   610 	{
       
   611 	TBool bRet;
       
   612 	TInetAddr addrLocal;
       
   613 	
       
   614 	appendixOutArray.Reset();
       
   615 	
       
   616 	// get address
       
   617 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet1"), addrLocal);
       
   618 	if (!bRet)
       
   619 		{
       
   620 		// failed to get Address
       
   621 		return EFalse;
       
   622 		}
       
   623 	appendixOutArray.Insert(addrLocal, 0);
       
   624 	
       
   625 	// get address
       
   626 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet2"), addrLocal);
       
   627 	if (!bRet)
       
   628 		{
       
   629 		// failed to get Address
       
   630 		return EFalse;
       
   631 		}
       
   632 	appendixOutArray.Insert(addrLocal, 1);
       
   633 	
       
   634 	// get address
       
   635 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet3"), addrLocal);
       
   636 	if (!bRet)
       
   637 		{
       
   638 		// failed to get Address
       
   639 		return EFalse;
       
   640 		}
       
   641 	appendixOutArray.Insert(addrLocal, 2);
       
   642 	
       
   643 	// get address
       
   644 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet4"), addrLocal);
       
   645 	if (!bRet)
       
   646 		{
       
   647 		// failed to get Address
       
   648 		return EFalse;
       
   649 		}
       
   650 	appendixOutArray.Insert(addrLocal, 3);
       
   651 	
       
   652 	// get address
       
   653 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet5"), addrLocal);
       
   654 	if (!bRet)
       
   655 		{
       
   656 		// failed to get Address
       
   657 		return EFalse;
       
   658 		}
       
   659 	appendixOutArray.Insert(addrLocal, 4);
       
   660 	
       
   661 	// get address
       
   662 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet6"), addrLocal);
       
   663 	if (!bRet)
       
   664 		{
       
   665 		// failed to get Address
       
   666 		return EFalse;
       
   667 		}
       
   668 	appendixOutArray.Insert(addrLocal, 5);
       
   669 	
       
   670 	// get address
       
   671 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet7"), addrLocal);
       
   672 	if (!bRet)
       
   673 		{
       
   674 		// failed to get Address
       
   675 		return EFalse;
       
   676 		}
       
   677 	appendixOutArray.Insert(addrLocal, 6);
       
   678 	
       
   679 	// get address
       
   680 	bRet = GetIpAddressFromConfig(_L("AppendixB2"), _L("subnet8"), addrLocal);
       
   681 	if (!bRet)
       
   682 		{
       
   683 		// failed to get Address
       
   684 		return EFalse;
       
   685 		}
       
   686 	appendixOutArray.Insert(addrLocal, 7);
       
   687 	
       
   688 	return ETrue;
       
   689 	}
       
   690 
       
   691 TBool CTestStepEsock::GetAppendixB3()
       
   692 	{
       
   693 	TBool bRet;
       
   694 	TInetAddr addrLocal;
       
   695 	
       
   696 	appendixOutArray.Reset();
       
   697 	
       
   698 	// get address
       
   699 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId1"), addrLocal);
       
   700 	if (!bRet)
       
   701 		{
       
   702 		// failed to get Address
       
   703 		return EFalse;
       
   704 		}
       
   705 	appendixOutArray.Insert(addrLocal, 0);
       
   706 	
       
   707 	// get address
       
   708 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId2"), addrLocal);
       
   709 	if (!bRet)
       
   710 		{
       
   711 		// failed to get Address
       
   712 		return EFalse;
       
   713 		}
       
   714 	appendixOutArray.Insert(addrLocal, 1);
       
   715 	
       
   716 	// get address
       
   717 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId3"), addrLocal);
       
   718 	if (!bRet)
       
   719 		{
       
   720 		// failed to get Address
       
   721 		return EFalse;
       
   722 		}
       
   723 	appendixOutArray.Insert(addrLocal, 2);
       
   724 	
       
   725 	// get address
       
   726 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId4"), addrLocal);
       
   727 	if (!bRet)
       
   728 		{
       
   729 		// failed to get Address
       
   730 		return EFalse;
       
   731 		}
       
   732 	appendixOutArray.Insert(addrLocal, 3);
       
   733 	
       
   734 	// get address
       
   735 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId5"), addrLocal);
       
   736 	if (!bRet)
       
   737 		{
       
   738 		// failed to get Address
       
   739 		return EFalse;
       
   740 		}
       
   741 	appendixOutArray.Insert(addrLocal, 4);
       
   742 	
       
   743 	// get address
       
   744 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId6"), addrLocal);
       
   745 	if (!bRet)
       
   746 		{
       
   747 		// failed to get Address
       
   748 		return EFalse;
       
   749 		}
       
   750 	appendixOutArray.Insert(addrLocal, 5);
       
   751 	
       
   752 	// get address
       
   753 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId7"), addrLocal);
       
   754 	if (!bRet)
       
   755 		{
       
   756 		// failed to get Address
       
   757 		return EFalse;
       
   758 		}
       
   759 	appendixOutArray.Insert(addrLocal, 6);
       
   760 	
       
   761 	// get address
       
   762 	bRet = GetIpAddressFromConfig(_L("AppendixB3"), _L("networkId8"), addrLocal);
       
   763 	if (!bRet)
       
   764 		{
       
   765 		// failed to get Address
       
   766 		return EFalse;
       
   767 		}
       
   768 	appendixOutArray.Insert(addrLocal, 7);
       
   769 	
       
   770 	return ETrue;
       
   771 	}
       
   772 
       
   773 TBool CTestStepEsock::GetAppendixB4()
       
   774 	{
       
   775 	TBool bRet;
       
   776 	TInetAddr addrLocal;
       
   777 	
       
   778 	appendixOutArray.Reset();
       
   779 	
       
   780 	// get address
       
   781 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId1"), addrLocal);
       
   782 	if (!bRet)
       
   783 		{
       
   784 		// failed to get Address
       
   785 		return EFalse;
       
   786 		}
       
   787 	appendixOutArray.Insert(addrLocal, 0);
       
   788 	
       
   789 	// get address
       
   790 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId2"), addrLocal);
       
   791 	if (!bRet)
       
   792 		{
       
   793 		// failed to get Address
       
   794 		return EFalse;
       
   795 		}
       
   796 	appendixOutArray.Insert(addrLocal, 1);
       
   797 	
       
   798 	// get address
       
   799 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId3"), addrLocal);
       
   800 	if (!bRet)
       
   801 		{
       
   802 		// failed to get Address
       
   803 		return EFalse;
       
   804 		}
       
   805 	appendixOutArray.Insert(addrLocal, 2);
       
   806 	
       
   807 	// get address
       
   808 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId4"), addrLocal);
       
   809 	if (!bRet)
       
   810 		{
       
   811 		// failed to get Address
       
   812 		return EFalse;
       
   813 		}
       
   814 	appendixOutArray.Insert(addrLocal, 3);
       
   815 	
       
   816 	// get address
       
   817 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId5"), addrLocal);
       
   818 	if (!bRet)
       
   819 		{
       
   820 		// failed to get Address
       
   821 		return EFalse;
       
   822 		}
       
   823 	appendixOutArray.Insert(addrLocal, 4);
       
   824 	
       
   825 	// get address
       
   826 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId6"), addrLocal);
       
   827 	if (!bRet)
       
   828 		{
       
   829 		// failed to get Address
       
   830 		return EFalse;
       
   831 		}
       
   832 	appendixOutArray.Insert(addrLocal, 5);
       
   833 	
       
   834 	// get address
       
   835 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId7"), addrLocal);
       
   836 	if (!bRet)
       
   837 		{
       
   838 		// failed to get Address
       
   839 		return EFalse;
       
   840 		}
       
   841 	appendixOutArray.Insert(addrLocal, 6);
       
   842 	
       
   843 	// get address
       
   844 	bRet = GetIpAddressFromConfig(_L("AppendixB4"), _L("networkIdHostId8"), addrLocal);
       
   845 	if (!bRet)
       
   846 		{
       
   847 		// failed to get Address
       
   848 		return EFalse;
       
   849 		}
       
   850 	appendixOutArray.Insert(addrLocal, 7);
       
   851 	
       
   852 	return ETrue;
       
   853 	}
       
   854 
       
   855 TBool CTestStepEsock::GetAppendixB5()
       
   856 	{
       
   857 	TBool bRet;
       
   858 	TInetAddr addrLocal;
       
   859 	
       
   860 	appendixOutArray.Reset();
       
   861 	
       
   862 	// get address
       
   863 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast1"), addrLocal);
       
   864 	if (!bRet)
       
   865 		{
       
   866 		// failed to get Address
       
   867 		return EFalse;
       
   868 		}
       
   869 	appendixOutArray.Insert(addrLocal, 0);
       
   870 	
       
   871 	// get address
       
   872 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast2"), addrLocal);
       
   873 	if (!bRet)
       
   874 		{
       
   875 		// failed to get Address
       
   876 		return EFalse;
       
   877 		}
       
   878 	appendixOutArray.Insert(addrLocal, 1);
       
   879 	
       
   880 	// get address
       
   881 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast3"), addrLocal);
       
   882 	if (!bRet)
       
   883 		{
       
   884 		// failed to get Address
       
   885 		return EFalse;
       
   886 		}
       
   887 	appendixOutArray.Insert(addrLocal, 2);
       
   888 	
       
   889 	// get address
       
   890 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast4"), addrLocal);
       
   891 	if (!bRet)
       
   892 		{
       
   893 		// failed to get Address
       
   894 		return EFalse;
       
   895 		}
       
   896 	appendixOutArray.Insert(addrLocal, 3);
       
   897 	
       
   898 	// get address
       
   899 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast5"), addrLocal);
       
   900 	if (!bRet)
       
   901 		{
       
   902 		// failed to get Address
       
   903 		return EFalse;
       
   904 		}
       
   905 	appendixOutArray.Insert(addrLocal, 4);
       
   906 	
       
   907 	// get address
       
   908 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast6"), addrLocal);
       
   909 	if (!bRet)
       
   910 		{
       
   911 		// failed to get Address
       
   912 		return EFalse;
       
   913 		}
       
   914 	appendixOutArray.Insert(addrLocal, 5);
       
   915 	
       
   916 	// get address
       
   917 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast7"), addrLocal);
       
   918 	if (!bRet)
       
   919 		{
       
   920 		// failed to get Address
       
   921 		return EFalse;
       
   922 		}
       
   923 	appendixOutArray.Insert(addrLocal, 6);
       
   924 	
       
   925 	// get address
       
   926 	bRet = GetIpAddressFromConfig(_L("AppendixB5"), _L("networkIdHostBroadcast8"), addrLocal);
       
   927 	if (!bRet)
       
   928 		{
       
   929 		// failed to get Address
       
   930 		return EFalse;
       
   931 		}
       
   932 	appendixOutArray.Insert(addrLocal, 7);
       
   933 	
       
   934 	return ETrue;
       
   935 	}
       
   936 
       
   937 TBool CTestStepEsock::GetAppendixB6()
       
   938 	{
       
   939 	TBool bRet;
       
   940 	TInetAddr addrLocal;
       
   941 	
       
   942 	appendixOutArray.Reset();
       
   943 	
       
   944 	// get address
       
   945 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast1"), addrLocal);
       
   946 	if (!bRet)
       
   947 		{
       
   948 		// failed to get Address
       
   949 		return EFalse;
       
   950 		}
       
   951 	appendixOutArray.Insert(addrLocal, 0);
       
   952 	
       
   953 	// get address
       
   954 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast2"), addrLocal);
       
   955 	if (!bRet)
       
   956 		{
       
   957 		// failed to get Address
       
   958 		return EFalse;
       
   959 		}
       
   960 	appendixOutArray.Insert(addrLocal, 1);
       
   961 	
       
   962 	// get address
       
   963 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast3"), addrLocal);
       
   964 	if (!bRet)
       
   965 		{
       
   966 		// failed to get Address
       
   967 		return EFalse;
       
   968 		}
       
   969 	appendixOutArray.Insert(addrLocal, 2);
       
   970 	
       
   971 	// get address
       
   972 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast4"), addrLocal);
       
   973 	if (!bRet)
       
   974 		{
       
   975 		// failed to get Address
       
   976 		return EFalse;
       
   977 		}
       
   978 	appendixOutArray.Insert(addrLocal, 3);
       
   979 	
       
   980 	// get address
       
   981 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast5"), addrLocal);
       
   982 	if (!bRet)
       
   983 		{
       
   984 		// failed to get Address
       
   985 		return EFalse;
       
   986 		}
       
   987 	appendixOutArray.Insert(addrLocal, 4);
       
   988 	
       
   989 	// get address
       
   990 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast6"), addrLocal);
       
   991 	if (!bRet)
       
   992 		{
       
   993 		// failed to get Address
       
   994 		return EFalse;
       
   995 		}
       
   996 	appendixOutArray.Insert(addrLocal, 5);
       
   997 	
       
   998 	// get address
       
   999 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast7"), addrLocal);
       
  1000 	if (!bRet)
       
  1001 		{
       
  1002 		// failed to get Address
       
  1003 		return EFalse;
       
  1004 		}
       
  1005 	appendixOutArray.Insert(addrLocal, 6);
       
  1006 	
       
  1007 	// get address
       
  1008 	bRet = GetIpAddressFromConfig(_L("AppendixB6"), _L("networkIdHostIdSubnetBroadcast8"), addrLocal);
       
  1009 	if (!bRet)
       
  1010 		{
       
  1011 		// failed to get Address
       
  1012 		return EFalse;
       
  1013 		}
       
  1014 	appendixOutArray.Insert(addrLocal, 7);
       
  1015 	
       
  1016 	return ETrue;
       
  1017 	}
       
  1018 
       
  1019 TBool CTestStepEsock::GetAppendixC1()
       
  1020 	{
       
  1021 	TBool bRet;
       
  1022 	TInetAddr addrLocal;
       
  1023 	
       
  1024 	appendixInArray.Reset();
       
  1025 	
       
  1026 	// get ip address
       
  1027 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress1"), addrLocal);
       
  1028 	if (!bRet)
       
  1029 		{
       
  1030 		// failed to get ipAddress
       
  1031 		return EFalse;
       
  1032 		}
       
  1033 	// add to array
       
  1034 	appendixInArray.Insert(addrLocal, ipAddress1);
       
  1035 	
       
  1036 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress2"), addrLocal);
       
  1037 	if (!bRet)
       
  1038 		{
       
  1039 		return EFalse;
       
  1040 		}
       
  1041 	appendixInArray.Insert(addrLocal, ipAddress2);
       
  1042 	
       
  1043 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress3"), addrLocal);
       
  1044 	if (!bRet)
       
  1045 		{
       
  1046 		return EFalse;
       
  1047 		}
       
  1048 	appendixInArray.Insert(addrLocal, ipAddress3);
       
  1049 	
       
  1050 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress4"), addrLocal);
       
  1051 	if (!bRet)
       
  1052 		{
       
  1053 		return EFalse;
       
  1054 		}
       
  1055 	appendixInArray.Insert(addrLocal, ipAddress4);
       
  1056 	
       
  1057 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress5"), addrLocal);
       
  1058 	if (!bRet)
       
  1059 		{
       
  1060 		return EFalse;
       
  1061 		}
       
  1062 	appendixInArray.Insert(addrLocal, ipAddress5);
       
  1063 	
       
  1064 	
       
  1065 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress7"), addrLocal);
       
  1066 	if (!bRet)
       
  1067 		{
       
  1068 		return EFalse;
       
  1069 		}
       
  1070 	appendixInArray.Insert(addrLocal, ipAddress7);
       
  1071 	
       
  1072 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress8"), addrLocal);
       
  1073 	if (!bRet)
       
  1074 		{
       
  1075 		return EFalse;
       
  1076 		}
       
  1077 	appendixInArray.Insert(addrLocal, ipAddress8);
       
  1078 	
       
  1079 	bRet = GetIpAddressFromConfig(_L("AppendixC1"), _L("ipAddress9"), addrLocal);
       
  1080 	if (!bRet)
       
  1081 		{
       
  1082 		return EFalse;
       
  1083 		}
       
  1084 	appendixInArray.Insert(addrLocal, ipAddress9);
       
  1085 	
       
  1086 	return ETrue;
       
  1087 	}
       
  1088 
       
  1089 void CTestStepEsock::GetAppendixC2()
       
  1090 	{
       
  1091 	
       
  1092 	}
       
  1093 
       
  1094 TBool CTestStepEsock::GetAppendixC3()
       
  1095 	{
       
  1096 	TBool bRet;
       
  1097 	TInetAddr addrLocal;
       
  1098 	
       
  1099 	appendixOutArray.Reset();
       
  1100 	
       
  1101 	// get ip address
       
  1102 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress1"), addrLocal);
       
  1103 	if (!bRet)
       
  1104 		{
       
  1105 		// failed to get ipAddress
       
  1106 		return EFalse;
       
  1107 		}
       
  1108 	// add to array
       
  1109 	appendixOutArray.Insert(addrLocal, ipAddress1);
       
  1110 	
       
  1111 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress2"), addrLocal);
       
  1112 	if (!bRet)
       
  1113 		{
       
  1114 		return EFalse;
       
  1115 		}
       
  1116 	appendixOutArray.Insert(addrLocal, ipAddress2);
       
  1117 	
       
  1118 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress3"), addrLocal);
       
  1119 	if (!bRet)
       
  1120 		{
       
  1121 		return EFalse;
       
  1122 		}
       
  1123 	appendixOutArray.Insert(addrLocal, ipAddress3);
       
  1124 	
       
  1125 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress4"), addrLocal);
       
  1126 	if (!bRet)
       
  1127 		{
       
  1128 		return EFalse;
       
  1129 		}
       
  1130 	appendixOutArray.Insert(addrLocal, ipAddress4);
       
  1131 	
       
  1132 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress5"), addrLocal);
       
  1133 	if (!bRet)
       
  1134 		{
       
  1135 		return EFalse;
       
  1136 		}
       
  1137 	appendixOutArray.Insert(addrLocal, ipAddress5);
       
  1138 	
       
  1139 	
       
  1140 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress7"), addrLocal);
       
  1141 	if (!bRet)
       
  1142 		{
       
  1143 		return EFalse;
       
  1144 		}
       
  1145 	appendixOutArray.Insert(addrLocal, ipAddress7);
       
  1146 	
       
  1147 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress8"), addrLocal);
       
  1148 	if (!bRet)
       
  1149 		{
       
  1150 		return EFalse;
       
  1151 		}
       
  1152 	appendixOutArray.Insert(addrLocal, ipAddress8);
       
  1153 	
       
  1154 	bRet = GetIpAddressFromConfig(_L("AppendixC3"), _L("ipAddress9"), addrLocal);
       
  1155 	if (!bRet)
       
  1156 		{
       
  1157 		return EFalse;
       
  1158 		}
       
  1159 	appendixOutArray.Insert(addrLocal, ipAddress9);
       
  1160 	
       
  1161 	return ETrue;
       
  1162 	}
       
  1163 
       
  1164 void CTestStepEsock::GetHostByNameL(TNameRecord& aRecord, const TDesC& aHost)
       
  1165 	{
       
  1166 	RHostResolver hr;
       
  1167 	CleanupClosePushL(hr);
       
  1168 	TInt ret = hr.Open(iEsockSuite->iSocketServer, KAfInet, KProtocolInetUdp);
       
  1169 	TESTEL(KErrNone == ret, ret);
       
  1170 	
       
  1171 	aRecord.iName = _L("");
       
  1172 	TInetAddr::Cast(aRecord.iAddr) = TInetAddr(0);
       
  1173 	aRecord.iFlags = 0;
       
  1174 	TNameEntry hostent(aRecord);
       
  1175 	
       
  1176 	TRequestStatus stat;
       
  1177 	hr.GetByName(aHost, hostent, stat);
       
  1178 	User::WaitForRequest(stat);
       
  1179 	Logger().WriteFormat(_L("Lookup returned %d"), stat.Int());
       
  1180 	TESTL(stat==KErrNone);
       
  1181 	
       
  1182 	// wait for 0.1 seconds
       
  1183 	User::After(100000);
       
  1184 	
       
  1185 	aRecord = hostent();
       
  1186 	do
       
  1187 		{
       
  1188 		if(stat==KErrNone)
       
  1189 			{
       
  1190 			THostName name;
       
  1191 			TInetAddr::Cast(hostent().iAddr).OutputWithScope(name);
       
  1192 			Logger().WriteFormat(_L(" Name= \"%S\", Addr= %S Flags "), &hostent().iName, &name);
       
  1193 			}
       
  1194 		else
       
  1195 			{
       
  1196 			Logger().WriteFormat(_L("Lookup failed %d\n"), stat.Int());
       
  1197 			break;
       
  1198 			}
       
  1199 		} while((stat=hr.Next(hostent))!=KErrEof);
       
  1200 		
       
  1201 	CleanupStack::PopAndDestroy(1, &hr);	
       
  1202 	}
       
  1203 
       
  1204 
       
  1205 void CTestStepEsock::GetHostByAddrL(TNameRecord& aRecord, const TInetAddr& aAddr)
       
  1206 	{
       
  1207 	THostName addr;
       
  1208 	aAddr.OutputWithScope(addr);
       
  1209 	
       
  1210 	RHostResolver hr;
       
  1211 	CleanupClosePushL(hr);
       
  1212 	TInt ret = hr.Open(iEsockSuite->iSocketServer, KAfInet, KProtocolInetUdp);
       
  1213 	TESTEL(KErrNone == ret, ret);
       
  1214 	
       
  1215 	TNameEntry hostent(aRecord);
       
  1216 	
       
  1217 	TRequestStatus stat;
       
  1218 	hr.GetByAddress(aAddr, hostent, stat);
       
  1219 	User::WaitForRequest(stat);
       
  1220 	Logger().WriteFormat(_L("Lookup returned %d"), stat.Int());
       
  1221 	TESTL(stat==KErrNone);
       
  1222 	
       
  1223 	// wait for 0.1 seconds
       
  1224 	User::After(100000);
       
  1225 	
       
  1226 	aRecord = hostent();
       
  1227 	do
       
  1228 		{
       
  1229 		if(stat==KErrNone)
       
  1230 			{
       
  1231 			THostName name;
       
  1232 			TInetAddr::Cast(hostent().iAddr).OutputWithScope(name);
       
  1233 			Logger().WriteFormat(_L(" Name= \"%S\", Addr= %S Flags "), &hostent().iName, &name);
       
  1234 			}
       
  1235 		else
       
  1236 			{
       
  1237 			Logger().WriteFormat(_L("Lookup failed %d\n"), stat.Int());
       
  1238 			break;
       
  1239 			} 
       
  1240 		} while((stat=hr.Next(hostent))!=KErrEof);
       
  1241 		
       
  1242 	CleanupStack::PopAndDestroy(1, &hr);	
       
  1243 	}
       
  1244 
       
  1245 
       
  1246 void CTestStepEsock::GetHostNameL()
       
  1247 //
       
  1248 // Return this host's machine name
       
  1249 //
       
  1250 	{
       
  1251 	RHostResolver hr;
       
  1252 	CleanupClosePushL(hr);
       
  1253 	TInt ret = hr.Open(iEsockSuite->iSocketServer, KAfInet, KProtocolInetUdp);
       
  1254 	TESTEL(KErrNone == ret, ret);
       
  1255 	
       
  1256 	TRequestStatus stat;
       
  1257 	THostName name;
       
  1258 	hr.GetHostName(name, stat);
       
  1259 	User::WaitForRequest(stat);
       
  1260 	Logger().WriteFormat(_L("Lookup returned %d"), stat.Int());
       
  1261 	TESTL(stat==KErrNone);
       
  1262 	
       
  1263 	Logger().WriteFormat(_L(" Name= \"%S\"\r"), &name);
       
  1264 	
       
  1265 	CleanupStack::PopAndDestroy(1, &hr);	
       
  1266 	}
       
  1267 
       
  1268 void CTestStepEsock::SetHostNameL(const TDesC& aHost)
       
  1269 	{
       
  1270 	RHostResolver hr;
       
  1271 	CleanupClosePushL(hr);
       
  1272 	TInt ret = hr.Open(iEsockSuite->iSocketServer, KAfInet, KProtocolInetUdp);
       
  1273 	TESTEL(KErrNone == ret, ret);
       
  1274 
       
  1275 	ret = hr.SetHostName(aHost);
       
  1276 	TESTEL(KErrNone == ret, ret);
       
  1277 	
       
  1278 	CleanupStack::PopAndDestroy(1, &hr);	
       
  1279 	}
       
  1280 
       
  1281 void CTestStepEsock::GetHostByNameCancelL(TNameRecord& aRecord, const TDesC& aHost)
       
  1282 	{
       
  1283 	RHostResolver hr;
       
  1284 	CleanupClosePushL(hr);
       
  1285 	TInt ret = hr.Open(iEsockSuite->iSocketServer, KAfInet, KProtocolInetUdp);
       
  1286 	TESTL(ret==KErrNone);
       
  1287 	
       
  1288 	aRecord.iName = _L("");
       
  1289 	TInetAddr::Cast(aRecord.iAddr) = TInetAddr(0);
       
  1290 	aRecord.iFlags = 0;
       
  1291 	TNameEntry hostent(aRecord);
       
  1292 	
       
  1293 	TRequestStatus stat;
       
  1294 	hr.GetByName(aHost, hostent, stat);
       
  1295 	hr.Cancel();
       
  1296 	User::WaitForRequest(stat);
       
  1297 	
       
  1298 	//???? Check 
       
  1299 	//TESTL(ret==KErrCancel);
       
  1300 	
       
  1301 	
       
  1302 	Logger().WriteFormat(_L("Status of Cancel lookup return address = %d"), stat.Int());
       
  1303 	
       
  1304 	CleanupStack::PopAndDestroy(1, &hr);	
       
  1305 	}
       
  1306