|
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 20 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <in_sock.h> |
|
21 |
|
22 // Test system includes |
|
23 #include "EsockTestSection20.h" |
|
24 |
|
25 |
|
26 // Test step 20.1 |
|
27 const TDesC& CEsockTest20_1::GetTestName() |
|
28 { |
|
29 // store the name of this test case |
|
30 _LIT(ret,"Test20.1"); |
|
31 return ret; |
|
32 } |
|
33 |
|
34 CEsockTest20_1::~CEsockTest20_1() |
|
35 { |
|
36 } |
|
37 |
|
38 enum TVerdict CEsockTest20_1::easyTestStepL() |
|
39 { |
|
40 TInetAddr addr, addr2; |
|
41 const TIp6Addr KInet6addr1 = {{{ 0xff,0xfe,0,0,0,0,0,0,0,0,0,0,0,0,0x23,0 }}}; |
|
42 const TIp6Addr KInet6addr2 = {{{ 0xff,0xfe,0,0,0,0,0,0,0,0,0,0,0,0,0,0x23 }}}; |
|
43 |
|
44 // set up 2 TCP/IP address |
|
45 addr.SetAddress(KInet6addr1); |
|
46 addr.SetPort(7); |
|
47 |
|
48 addr2.SetAddress(KInet6addr2); |
|
49 addr2.SetPort(8); |
|
50 |
|
51 // compare IP address and port number |
|
52 TESTL(addr.CmpAddr(addr2)==EFalse); |
|
53 |
|
54 // change port number - now equal |
|
55 addr2.SetPort(7); |
|
56 TESTL(addr.CmpAddr(addr2)==EFalse); |
|
57 |
|
58 // change ip address - now equal |
|
59 addr2.SetAddress(KInet6addr1); |
|
60 TESTL(addr.CmpAddr(addr2)!=EFalse); |
|
61 |
|
62 return EPass; |
|
63 } |
|
64 |
|
65 |
|
66 // Test step 20.2 |
|
67 const TDesC& CEsockTest20_2::GetTestName() |
|
68 { |
|
69 // store the name of this test case |
|
70 _LIT(ret,"Test20.2"); |
|
71 return ret; |
|
72 } |
|
73 |
|
74 CEsockTest20_2::~CEsockTest20_2() |
|
75 { |
|
76 } |
|
77 |
|
78 enum TVerdict CEsockTest20_2::easyTestStepL() |
|
79 { |
|
80 TInetAddr addr, addr2; |
|
81 const TIp6Addr KInet6addr1 = {{{ 0xff,0xee,0,0,0,0,0,0,0,0,0,0,0,0,0x25,0x4f }}}; |
|
82 const TIp6Addr KInet6addr2 = {{{ 0xff,0xee,0,0,0,0,0,0,0,0,0,0,0,0,0x25,0x4e }}}; |
|
83 |
|
84 // set up 2 TCP/IP address |
|
85 addr.SetAddress(KInet6addr1); |
|
86 addr.SetPort(5000); |
|
87 |
|
88 addr2.SetAddress(KInet6addr2); |
|
89 addr2.SetPort(5001); |
|
90 |
|
91 // compare the two addresses |
|
92 TESTL(addr.Match(addr2)==EFalse); |
|
93 |
|
94 // change the 2nd address so that the ip addresses are the same |
|
95 addr2.SetAddress(KInet6addr1); |
|
96 |
|
97 // comapre again |
|
98 TESTL(addr.Match(addr2)!=EFalse);; |
|
99 |
|
100 return EPass; |
|
101 } |
|
102 |
|
103 |
|
104 // Test step 20.3 |
|
105 const TDesC& CEsockTest20_3::GetTestName() |
|
106 { |
|
107 // store the name of this test case |
|
108 _LIT(ret,"Test20.3"); |
|
109 return ret; |
|
110 } |
|
111 |
|
112 CEsockTest20_3::~CEsockTest20_3() |
|
113 { |
|
114 } |
|
115 |
|
116 enum TVerdict CEsockTest20_3::easyTestStepL() |
|
117 { |
|
118 TInetAddr addr, mask; |
|
119 TInetAddr addr2, addr3, addr4, addr5, addr6, addr7; |
|
120 |
|
121 // test whether addresses are on the same subnet (Match) |
|
122 |
|
123 const TIp6Addr KInet6addr = {{{ 0xff,0xee,0x29,0x40,0,0x1,0,0x1,0,0,0,0,0,0,0x21,0xaa }}}; |
|
124 const TIp6Addr KInetmask = {{{ 0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0,0,0,0,0,0,0,0,0 }}}; |
|
125 const TIp6Addr KInet6addr2 = {{{ 0xff,0xee,0x29,0x40,0,1,0,1,0,0,0,0,0,1,0x22,0x10 }}}; |
|
126 const TIp6Addr KInet6addr3 = {{{ 0xff,0xee,0x29,0x40,0,1,0,1,0,0,0,0,0,0,0,0x21 }}}; |
|
127 const TIp6Addr KInet6addr4 = {{{ 0xff,0xee,0x29,0x40,0,1,0,1,0,0,0,0,0,0x21,0x3a,0 }}}; |
|
128 const TIp6Addr KInet6addr5 = {{{ 0xff,0xee,0x29,0x40,8,1,0,1,0,0,0,0,0,0,0,0x21 }}}; |
|
129 const TIp6Addr KInet6addr6 = {{{ 0xff,0xee,0x29,0x41,0,1,0,1,0,0,0,0,0,0x21,0,0x3a }}}; |
|
130 const TIp6Addr KInet6addr7 = {{{ 0xff,0xe0,0x29,0x40,0,1,0,1,0,0,0,0,0,0x21,0x3a,0 }}}; |
|
131 |
|
132 // set up ip addresses and subnet mask |
|
133 addr.SetAddress(KInet6addr); |
|
134 mask.SetAddress(KInetmask); |
|
135 addr2.SetAddress(KInet6addr2); |
|
136 addr3.SetAddress(KInet6addr3); |
|
137 addr4.SetAddress(KInet6addr4); |
|
138 addr5.SetAddress(KInet6addr5); |
|
139 addr6.SetAddress(KInet6addr6); |
|
140 addr7.SetAddress(KInet6addr7); |
|
141 |
|
142 // check whether addresses are on the same subnet |
|
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 TESTL(addr.Match(addr7, mask)==EFalse); |
|
149 |
|
150 return EPass; |
|
151 } |
|
152 |
|
153 |
|
154 // Test step 20.4 |
|
155 const TDesC& CEsockTest20_4::GetTestName() |
|
156 { |
|
157 // store the name of this test case |
|
158 _LIT(ret,"Test20.4"); |
|
159 return ret; |
|
160 } |
|
161 |
|
162 CEsockTest20_4::~CEsockTest20_4() |
|
163 { |
|
164 } |
|
165 |
|
166 enum TVerdict CEsockTest20_4::easyTestStepL() |
|
167 { |
|
168 TInetAddr addr; |
|
169 TInetAddr addr2, addr3, addr4, addr5; |
|
170 |
|
171 // match using prefix length |
|
172 |
|
173 const TIp6Addr KInet6addr = {{{ 0xff,0xfe,0x12,0,0xff,0xf0,0,0,0,0,0,0,0,0,0,0 }}}; |
|
174 const TIp6Addr KInet6addr2 = {{{ 0xff,0xfe,0x12,0,0xff,0xf0,0,0,0,0,0,0,0,0,0,0 }}}; |
|
175 const TIp6Addr KInet6addr3 = {{{ 0xff,0xfe,0x12,0,0xff,0xf7,0,0,0,0,0,0,0,0,0,0 }}}; |
|
176 const TIp6Addr KInet6addr4 = {{{ 0xff,0xfe,0x12,0,0xff,0xfb,0,0,0,0,0,0,0,0,0,0 }}}; |
|
177 const TIp6Addr KInet6addr5 = {{{ 0xff,0xff,0x12,0,0xff,0xf0,0,0,0,0,0,0,0,0,0,0 }}}; |
|
178 |
|
179 // set up ip addresses and subnet mask |
|
180 addr.SetAddress(KInet6addr); |
|
181 addr2.SetAddress(KInet6addr2); |
|
182 addr3.SetAddress(KInet6addr3); |
|
183 addr4.SetAddress(KInet6addr4); |
|
184 addr5.SetAddress(KInet6addr5); |
|
185 |
|
186 // call Match using a prefix length of 43 |
|
187 TESTL(addr.Match(addr2, 43)!=EFalse); |
|
188 TESTL(addr.Match(addr3, 43)!=EFalse); |
|
189 TESTL(addr.Match(addr4, 43)!=EFalse); |
|
190 TESTL(addr.Match(addr5, 43)==EFalse); |
|
191 |
|
192 // call Match using a prefix length of 44 |
|
193 TESTL(addr.Match(addr2, 44)!=EFalse); |
|
194 TESTL(addr.Match(addr3, 44)!=EFalse); |
|
195 TESTL(addr.Match(addr4, 44)!=EFalse); |
|
196 TESTL(addr.Match(addr5, 44)==EFalse); |
|
197 |
|
198 // call Match using a prefix length of 45 |
|
199 TESTL(addr.Match(addr2, 45)!=EFalse); |
|
200 TESTL(addr.Match(addr3, 45)!=EFalse); |
|
201 TESTL(addr.Match(addr4, 45)==EFalse); |
|
202 TESTL(addr.Match(addr5, 45)==EFalse); |
|
203 |
|
204 // call Match using a prefix length of 46 |
|
205 TESTL(addr.Match(addr2, 46)!=EFalse); |
|
206 TESTL(addr.Match(addr3, 46)==EFalse); |
|
207 TESTL(addr.Match(addr4, 46)==EFalse); |
|
208 TESTL(addr.Match(addr5, 46)==EFalse); |
|
209 |
|
210 return EPass; |
|
211 } |
|
212 |