reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TurnLoadGenAsyncSocketHandler.hxx
Go to the documentation of this file.
1#ifndef TURNLOADGENASYNCSOCKETHANDLER_HXX
2#define TURNLOADGENASYNCSOCKETHANDLER_HXX
3
4#if defined(HAVE_CONFIG_H)
5#include "config.h"
6#endif
7
8#include "../TurnAsyncSocket.hxx"
9#include "../TurnAsyncSocketHandler.hxx"
10#include <rutil/ConfigParse.hxx>
11
12using namespace reTurn;
13using namespace std;
14using namespace resip;
15
17{
18public:
20 int clientNum,
21 asio::io_context& ioService,
22 const Data& localAddress,
23 const Data& turnServerAddress,
24 unsigned short turnServerPort,
25 unsigned short relayPort,
26 const ConfigParse& config);
28
29 void setTurnAsyncSocket(std::shared_ptr<TurnAsyncSocket>& turnAsyncSocket);
30 void connect();
31 void sendBindRequest();
34 void sendPayload();
35
36 virtual void onConnectSuccess(unsigned int socketDesc, const asio::ip::address& address, unsigned short port) override;
37 virtual void onConnectFailure(unsigned int socketDesc, const asio::error_code& e) override;
38 virtual void onSharedSecretSuccess(unsigned int socketDesc, const char* username, unsigned int usernameSize, const char* password, unsigned int passwordSize) override;
39 virtual void onSharedSecretFailure(unsigned int socketDesc, const asio::error_code& e) override;
40 virtual void onBindSuccess(unsigned int socketDesc, const StunTuple& reflexiveTuple, const StunTuple& stunServerTuple) override;
41 virtual void onBindFailure(unsigned int socketDesc, const asio::error_code& e, const StunTuple& stunServerTuple) override;
42 virtual void onAllocationSuccess(unsigned int socketDesc, const StunTuple& reflexiveTuple, const StunTuple& relayTuple, unsigned int lifetime, unsigned int bandwidth, uint64_t reservationToken) override;
43 virtual void onAllocationFailure(unsigned int socketDesc, const asio::error_code& e) override;
44 virtual void onRefreshSuccess(unsigned int socketDesc, unsigned int lifetime) override;
45 virtual void onRefreshFailure(unsigned int socketDesc, const asio::error_code& e) override;
46 virtual void onSetActiveDestinationSuccess(unsigned int socketDesc) override;
47 virtual void onSetActiveDestinationFailure(unsigned int socketDesc, const asio::error_code& e) override;
48 virtual void onClearActiveDestinationSuccess(unsigned int socketDesc) override;
49 virtual void onClearActiveDestinationFailure(unsigned int socketDesc, const asio::error_code& e) override;
50 virtual void onChannelBindRequestSent(unsigned int socketDesc, unsigned short channelNumber) override;
51 virtual void onChannelBindSuccess(unsigned int socketDesc, unsigned short channelNumber) override;
52 virtual void onChannelBindFailure(unsigned int socketDesc, const asio::error_code& e) override;
53 virtual void onSendSuccess(unsigned int socketDesc) override;
54 virtual void onSendFailure(unsigned int socketDesc, const asio::error_code& e) override;
55 virtual void onReceiveSuccess(unsigned int socketDesc, const asio::ip::address& address, unsigned short port, const std::shared_ptr<reTurn::DataBuffer>& data) override;
56 virtual void onReceiveFailure(unsigned int socketDesc, const asio::error_code& e) override;
57 virtual void onIncomingBindRequestProcessed(unsigned int socketDesc, const StunTuple& sourceTuple) override;
58
59private:
60 int mClientNum;
61 asio::steady_timer mTimer;
62 asio::ip::address mLocalAddress;
63 resip::Data mTurnServerAddress;
64 unsigned short mTurnServerPort;
65 unsigned short mRelayPort;
66 const ConfigParse& mConfig;
67 std::shared_ptr<TurnAsyncSocket> mTurnAsyncSocket;
68 unsigned int mNumSends;
69 unsigned int mNumSendFailures;
70 unsigned int mNumReceiveSuccesses;
71 unsigned int mNumReceiveFailures;
72 time_t mStartTime;
73
74 // Config settings
75 int mDelayBetweenClientStartsMs;
76 int mAllocationTimeSecs;
77 int mAllocationLifetimeSecs;
78 int mTimeBetweenAllocationsSecs;
79 int mPayloadIntervalMs;
80};
81
82
83#endif
84
85
86/* ====================================================================
87
88 Copyright (c) 2024 SIP Spectrum, Inc http://www.sipspectrum.com
89 All rights reserved.
90
91 Redistribution and use in source and binary forms, with or without
92 modification, are permitted provided that the following conditions are
93 met:
94
95 1. Redistributions of source code must retain the above copyright
96 notice, this list of conditions and the following disclaimer.
97
98 2. Redistributions in binary form must reproduce the above copyright
99 notice, this list of conditions and the following disclaimer in the
100 documentation and/or other materials provided with the distribution.
101
102 3. Neither the name of Plantronics nor the names of its contributors
103 may be used to endorse or promote products derived from this
104 software without specific prior written permission.
105
106 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
107 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
108 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
109 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
110 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
111 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
112 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
113 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
114 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
116 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
117
118 ==================================================================== */
virtual void onSharedSecretSuccess(unsigned int socketDesc, const char *username, unsigned int usernameSize, const char *password, unsigned int passwordSize) override
virtual void onChannelBindRequestSent(unsigned int socketDesc, unsigned short channelNumber) override
virtual void onConnectSuccess(unsigned int socketDesc, const asio::ip::address &address, unsigned short port) override
virtual void onReceiveSuccess(unsigned int socketDesc, const asio::ip::address &address, unsigned short port, const std::shared_ptr< reTurn::DataBuffer > &data) override
virtual void onRefreshSuccess(unsigned int socketDesc, unsigned int lifetime) override
virtual void onAllocationSuccess(unsigned int socketDesc, const StunTuple &reflexiveTuple, const StunTuple &relayTuple, unsigned int lifetime, unsigned int bandwidth, uint64_t reservationToken) override
virtual void onSendFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onSetActiveDestinationFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onChannelBindSuccess(unsigned int socketDesc, unsigned short channelNumber) override
virtual void onChannelBindFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onAllocationFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onRefreshFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onIncomingBindRequestProcessed(unsigned int socketDesc, const StunTuple &sourceTuple) override
virtual void onSendSuccess(unsigned int socketDesc) override
virtual void onReceiveFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onClearActiveDestinationSuccess(unsigned int socketDesc) override
void setTurnAsyncSocket(std::shared_ptr< TurnAsyncSocket > &turnAsyncSocket)
virtual void onClearActiveDestinationFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onBindFailure(unsigned int socketDesc, const asio::error_code &e, const StunTuple &stunServerTuple) override
virtual void onBindSuccess(unsigned int socketDesc, const StunTuple &reflexiveTuple, const StunTuple &stunServerTuple) override
virtual void onSetActiveDestinationSuccess(unsigned int socketDesc) override
virtual void onConnectFailure(unsigned int socketDesc, const asio::error_code &e) override
virtual void onSharedSecretFailure(unsigned int socketDesc, const asio::error_code &e) override
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
dcm! – add UnusedChecking(_enum) below;
unsigned long long uint64_t
Definition Stun.hxx:39