Stun Server  Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
testmessagehandler.h
Go to the documentation of this file.
1 /*
2  Copyright 2011 John Selbie
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef _TEST_MESSAGE_HANDLER_H
18 #define _TEST_MESSAGE_HANDLER_H
19 
20 
21 
22 
24  public CBasicRefCount,
25  public CObjectFactory<CMockAuthShort>,
26  public IStunAuth
27 {
28 public:
29  virtual HRESULT DoAuthCheck(AuthAttributes* pAuthAttributes, AuthResponse* pResponse);
31 };
32 
33 
34 class CMockAuthLong :
35  public CBasicRefCount,
36  public CObjectFactory<CMockAuthLong>,
37  public IStunAuth
38 {
39 public:
40  virtual HRESULT DoAuthCheck(AuthAttributes* pAuthAttributes, AuthResponse* pResponse);
42 };
43 
44 
45 
46 
47 
49 {
50 private:
53 
54 
61 
62 
66 
67 
68 
69 
70  void ToAddr(const char* pszIP, uint16_t port, CSocketAddress* pAddr);
71 
72  void InitTransportAddressSet(TransportAddressSet& tas, bool fRolePP, bool fRolePA, bool fRoleAP, bool fRoleAA);
73 
74  HRESULT InitBindingRequest(CStunMessageBuilder& builder);
75 
76  HRESULT ValidateMappedAddress(CStunMessageReader& reader, const CSocketAddress& addrExpected, bool fLegacyOnly);
77  HRESULT ValidateResponseOriginAddress(CStunMessageReader& reader, const CSocketAddress& addrExpected);
78 
79  HRESULT ValidateOtherAddress(CStunMessageReader& reader, const CSocketAddress& addrExpected);
80 
81  HRESULT SendHelper(CStunMessageBuilder& builderRequest, CStunMessageReader* pReaderResponse, IStunAuth* pAuth);
82 
83 public:
85  HRESULT Test1();
86  HRESULT Test2();
87  HRESULT Test3();
88  HRESULT Test4();
89  HRESULT Run();
90 
91  UT_DECLARE_TEST_NAME("CTestMessageHandler");
92 };
93 
94 
95 #endif
CSocketAddress _addrMappedExpected
CSocketAddress _addrLocal
CSocketAddress _addrOriginExpected
CSocketAddress _addrServerPA
CSocketAddress _addrMapped
CSocketAddress _addrServerAA
CRefCountedPtr< CMockAuthLong > _spAuthLong
int32_t HRESULT
Definition: hresult.h:22
CRefCountedPtr< CMockAuthShort > _spAuthShort
CSocketAddress _addrServerPP
#define UT_DECLARE_TEST_NAME(testname)
Definition: unittest.h:32
CSocketAddress _addrDestination
virtual HRESULT DoAuthCheck(AuthAttributes *pAuthAttributes, AuthResponse *pResponse)
CSocketAddress _addrServerAP