Stun Server  Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
stunbuilder.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 
18 
19 #ifndef STUN_MESSAGE_H
20 #define STUN_MESSAGE_H
21 
22 
23 #include "datastream.h"
24 #include "socketaddress.h"
25 #include "stuntypes.h"
26 
27 
28 
30 {
31 public:
32 
33 private:
37 
38  HRESULT AddMappedAddressImpl(uint16_t attribute, const CSocketAddress& addr);
39 
40  HRESULT AddMessageIntegrityImpl(uint8_t* key, size_t keysize);
41 
42 
43 public:
45 
46  void SetLegacyMode(bool fLegacyMode);
47 
50  HRESULT AddBindingResponseHeader(bool fSuccess);
51 
54 
55  HRESULT AddAttributeHeader(uint16_t attribType, uint16_t size);
56  HRESULT AddAttribute(uint16_t attribType, const void* data, uint16_t size);
57  HRESULT AddStringAttribute(uint16_t attribType, const char* pstr);
58 
63 
64  HRESULT AddResponsePort(uint16_t port);
65  HRESULT AddPaddingAttribute(uint16_t paddingSize);
66 
68  HRESULT AddErrorCode(uint16_t errorNumber, const char* pszReason);
69  HRESULT AddUnknownAttributes(const uint16_t* arrAttributeIds, size_t count);
70 
72 
73  HRESULT AddUserName(const char* pszUserName);
74  HRESULT AddRealm(const char* pszRealm);
75  HRESULT AddNonce(const char* pszNonce);
76 
77 
78  HRESULT AddMessageIntegrityShortTerm(const char* pszPassword);
79  HRESULT AddMessageIntegrityLongTerm(const char* pszUserName, const char* pszRealm, const char* pszPassword);
80 
82 
84 
86 };
87 
88 #endif
StunTransactionId _transactionid
Definition: stunbuilder.h:35
HRESULT AddUnknownAttributes(const uint16_t *arrAttributeIds, size_t count)
HRESULT AddPaddingAttribute(uint16_t paddingSize)
HRESULT AddStringAttribute(uint16_t attribType, const char *pstr)
HRESULT AddRandomTransactionId(StunTransactionId *pTransId)
Definition: stunbuilder.cpp:93
HRESULT AddRealm(const char *pszRealm)
HRESULT FixLengthField()
HRESULT AddXorMappedAddress(const CSocketAddress &addr)
HRESULT AddAttributeHeader(uint16_t attribType, uint16_t size)
HRESULT AddBindingRequestHeader()
Definition: stunbuilder.cpp:76
HRESULT AddMappedAddressImpl(uint16_t attribute, const CSocketAddress &addr)
HRESULT AddMappedAddress(const CSocketAddress &addr)
void SetLegacyMode(bool fLegacyMode)
Definition: stunbuilder.cpp:49
HRESULT AddAttribute(uint16_t attribType, const void *data, uint16_t size)
HRESULT AddHeader(StunMessageType msgType, StunMessageClass msgClass)
Definition: stunbuilder.cpp:55
HRESULT AddTransactionId(const StunTransactionId &transid)
Definition: stunbuilder.cpp:86
HRESULT AddBindingResponseHeader(bool fSuccess)
Definition: stunbuilder.cpp:81
HRESULT AddResponseOriginAddress(const CSocketAddress &other)
HRESULT AddMessageIntegrityLongTerm(const char *pszUserName, const char *pszRealm, const char *pszPassword)
HRESULT AddFingerprintAttribute()
HRESULT AddNonce(const char *pszNonce)
int32_t HRESULT
Definition: hresult.h:22
HRESULT AddResponsePort(uint16_t port)
StunMessageClass
Definition: stuntypes.h:93
HRESULT GetResult(CRefCountedBuffer *pspBuffer)
HRESULT AddErrorCode(uint16_t errorNumber, const char *pszReason)
HRESULT AddMessageIntegrityShortTerm(const char *pszPassword)
StunMessageType
Definition: stuntypes.h:102
HRESULT AddChangeRequest(const StunChangeRequestAttribute &changeAttrib)
CDataStream _stream
Definition: stunbuilder.h:34
boost::shared_ptr< CBuffer > CRefCountedBuffer
Definition: buffer.h:65
HRESULT AddMessageIntegrityImpl(uint8_t *key, size_t keysize)
CDataStream & GetStream()
HRESULT AddUserName(const char *pszUserName)
HRESULT AddOtherAddress(const CSocketAddress &other)