datacommsserver/esockserver/test/TE_ESock/EsockTestSection14.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2001-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 ESock Test cases from section 14
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <in_sock.h>
       
    21 
       
    22 // Test system includes
       
    23 #include "EsockTestSection14.h"
       
    24 
       
    25 
       
    26 // Test step 14.1
       
    27 const TDesC& CEsockTest14_1::GetTestName()
       
    28 	{
       
    29 	// store the name of this test case
       
    30 	_LIT(ret,"Test14.1");
       
    31 	return ret;
       
    32 	}
       
    33 
       
    34 CEsockTest14_1::~CEsockTest14_1()
       
    35 	{
       
    36 	}
       
    37 
       
    38 enum TVerdict CEsockTest14_1::easyTestStepL()
       
    39 	{
       
    40 	
       
    41 	// compare IP address and port (CmpAddr)
       
    42 	
       
    43 	// set up 2 TCP/IP addresses
       
    44 	TInetAddr addr1(INET_ADDR(10, 0, 0, 154), 7);
       
    45 	TInetAddr addr2(INET_ADDR(10, 0, 0, 155), 8);
       
    46 	
       
    47 	// compare the 2 TCP/IP addresses
       
    48 	TESTL(addr1.CmpAddr(addr2)==EFalse);
       
    49 	
       
    50 	// change addr2
       
    51 	addr2.SetAddress(INET_ADDR(10, 0, 0, 154));
       
    52 	
       
    53 	// compare again
       
    54 	TESTL(addr1.CmpAddr(addr2)==EFalse);
       
    55 	
       
    56 	// for addr2 change the port number
       
    57 	addr2.SetPort(7);
       
    58 	
       
    59 	// compare once again - now addresses should match
       
    60 	TESTL(addr1.CmpAddr(addr2)!=EFalse);
       
    61 	
       
    62 	// and the other way round
       
    63 	TESTL(addr2.CmpAddr(addr1)!=EFalse);
       
    64 	
       
    65 	return EPass;
       
    66 	}
       
    67 
       
    68 
       
    69 // Test step 14.2
       
    70 const TDesC& CEsockTest14_2::GetTestName()
       
    71 	{
       
    72 	// store the name of this test case
       
    73 	_LIT(ret,"Test14.2");
       
    74 	return ret;
       
    75 	}
       
    76 
       
    77 CEsockTest14_2::~CEsockTest14_2()
       
    78 	{
       
    79 	}
       
    80 
       
    81 enum TVerdict CEsockTest14_2::easyTestStepL()
       
    82 	{
       
    83 	TInetAddr addr1, addr2;
       
    84 	
       
    85 	// compare IP addresses only (Match)
       
    86 	
       
    87 	// set the IP addresses
       
    88 	addr1.SetAddress(INET_ADDR(10, 0, 0, 254));
       
    89 	addr2.SetAddress(INET_ADDR(10, 0, 0, 253));
       
    90 	
       
    91 	// set the port number
       
    92 	addr2.SetPort(5001);
       
    93 	
       
    94 	// compare IP addresses
       
    95 	TESTL(addr1.Match(addr2)==EFalse);
       
    96 	
       
    97 	// change the IP address for addr2
       
    98 	addr2.SetAddress(INET_ADDR(10, 0, 0, 254));
       
    99 	
       
   100 	// compare again - should now match
       
   101 	TESTL(addr1.Match(addr2)!=EFalse);
       
   102 	
       
   103 	// and the other way round
       
   104 	TESTL(addr2.Match(addr2)!=EFalse);
       
   105 	
       
   106 	return EPass;
       
   107 	}
       
   108 
       
   109 
       
   110 // Test step 14.3
       
   111 const TDesC& CEsockTest14_3::GetTestName()
       
   112 	{
       
   113 	// store the name of this test case
       
   114 	_LIT(ret,"Test14.3");
       
   115 	return ret;
       
   116 	}
       
   117 
       
   118 CEsockTest14_3::~CEsockTest14_3()
       
   119 	{
       
   120 	}
       
   121 
       
   122 enum TVerdict CEsockTest14_3::easyTestStepL()
       
   123 	{
       
   124 	TInetAddr addr;
       
   125 	TInetAddr mask;
       
   126 	TInetAddr addr1, addr2, addr3, addr4, addr5, addr6;
       
   127 	
       
   128 	// Test whether addresses are on the same subnet (Match)
       
   129 	
       
   130 	// set the IP addresses and subnet mask
       
   131 	addr.SetAddress(INET_ADDR(140, 179, 220, 200));
       
   132 	mask.SetAddress(INET_ADDR(255, 255, 224, 0));
       
   133 	
       
   134 	addr1.SetAddress(INET_ADDR(140, 179, 221, 1));
       
   135 	addr2.SetAddress(INET_ADDR(140, 179, 193, 120));
       
   136 	addr3.SetAddress(INET_ADDR(140, 179, 200, 174));
       
   137 	addr4.SetAddress(INET_ADDR(141, 179, 200, 200));
       
   138 	addr5.SetAddress(INET_ADDR(140, 180, 200, 174));
       
   139 	addr6.SetAddress(INET_ADDR(140, 179, 129, 201));
       
   140 	
       
   141 	// match with subnet mask
       
   142 	TESTL(addr.Match(addr1, mask)!=EFalse);
       
   143 	TESTL(addr.Match(addr2, mask)!=EFalse);
       
   144 	TESTL(addr.Match(addr3, mask)!=EFalse);
       
   145 	TESTL(addr.Match(addr4, mask)==EFalse);
       
   146 	TESTL(addr.Match(addr5, mask)==EFalse);
       
   147 	TESTL(addr.Match(addr6, mask)==EFalse);
       
   148 	
       
   149 	return EPass;
       
   150 	}
       
   151 
       
   152 
       
   153 // Test step 14.4
       
   154 const TDesC& CEsockTest14_4::GetTestName()
       
   155 	{
       
   156 	// store the name of this test case
       
   157 	_LIT(ret,"Test14.4");
       
   158 	return ret;
       
   159 	}
       
   160 
       
   161 CEsockTest14_4::~CEsockTest14_4()
       
   162 	{
       
   163 	}
       
   164 
       
   165 enum TVerdict CEsockTest14_4::easyTestStepL()
       
   166 	{
       
   167 	TInetAddr addr;
       
   168 	TInetAddr addr1, addr2, addr3, addr4;
       
   169 	
       
   170 	addr.SetAddress(INET_ADDR(140, 179, 255, 255));
       
   171 	
       
   172 	addr1.SetAddress(INET_ADDR(140, 179, 225, 200));
       
   173 	addr2.SetAddress(INET_ADDR(140, 179, 242, 120));
       
   174 	addr3.SetAddress(INET_ADDR(140, 179, 251, 19));
       
   175 	addr4.SetAddress(INET_ADDR(140, 178, 224, 1));
       
   176 	
       
   177 	// match using a prefix length of 19
       
   178 	TESTL(addr.Match(addr1, 19)!=EFalse);
       
   179 	TESTL(addr.Match(addr2, 19)!=EFalse);
       
   180 	TESTL(addr.Match(addr3, 19)!=EFalse);
       
   181 	TESTL(addr.Match(addr4, 19)==EFalse);
       
   182 	
       
   183 	// match using a prefix length of 20
       
   184 	TESTL(addr.Match(addr1, 20)==EFalse);
       
   185 	TESTL(addr.Match(addr2, 20)!=EFalse);
       
   186 	TESTL(addr.Match(addr3, 20)!=EFalse);
       
   187 	TESTL(addr.Match(addr4, 20)==EFalse);
       
   188 	
       
   189 	// match using a prefix length of 21
       
   190 	TESTL(addr.Match(addr1, 21)==EFalse);
       
   191 	TESTL(addr.Match(addr2, 21)==EFalse);
       
   192 	TESTL(addr.Match(addr3, 21)!=EFalse);
       
   193 	TESTL(addr.Match(addr4, 21)==EFalse);
       
   194 	
       
   195 	// match using a prefix length of 22
       
   196 	TESTL(addr.Match(addr1, 22)==EFalse);
       
   197 	TESTL(addr.Match(addr2, 22)==EFalse);
       
   198 	TESTL(addr.Match(addr3, 22)==EFalse);
       
   199 	TESTL(addr.Match(addr4, 22)==EFalse);
       
   200 	
       
   201 	return EPass;
       
   202 	}
       
   203