reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
FlowDtlsSocketContext.hxx
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#if !defined(FlowDtlsSocketContext_hxx)
6#define FlowDtlsSocketContext_hxx
7
8#include <asio.hpp>
9#ifdef USE_SSL
10#include <asio/ssl.hpp>
11#endif
12#include "Srtp2Helper.hxx"
13
15#include "Flow.hxx"
16
26namespace flowmanager
27{
28
30{
31public:
32 FlowDtlsSocketContext(Flow& flow, const asio::ip::address& address, unsigned short port);
33 virtual ~FlowDtlsSocketContext();
34
35 // DtlsSocketContext Virtual Fns
36 virtual void write(const unsigned char* data, unsigned int len);
37 virtual void handshakeCompleted();
38 virtual void handshakeFailed(const char *err);
39 virtual std::shared_ptr<std::mutex> timerLock();
40
41 srtp_t* getSrtpSessionIn() { return &mSRTPSessionIn; }
42 srtp_t* getSrtpSessionOut() { return &mSRTPSessionOut; }
43 bool isSrtpInitialized() { return mSrtpInitialized; }
44
45 // Checks the peer's certificate against the remote SDP fingerprint: sets up SRTP if it
46 // matches, and tears it down if it doesn't. Does nothing until the handshake has completed,
47 // or while there is no fingerprint. Called with the Flow's mutex held.
48 void checkRemoteFingerprint(const resip::Data& hashFunction, const resip::Data& fingerprint);
49
50 srtp_err_status_t srtpProtect(void* data, int* size, bool rtcp);
51 srtp_err_status_t srtpUnprotect(void* data, int* size, bool rtcp);
52
53private:
54 bool createSrtpSessions();
55 void destroySrtpSessions();
56
57 Flow& mFlow;
58 asio::ip::address mAddress;
59 unsigned short mPort;
60 srtp_t mSRTPSessionIn;
61 srtp_t mSRTPSessionOut;
62 volatile bool mSrtpInitialized;
63};
64
65}
66
67#endif
68/* ====================================================================
69
70 Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
71 Copyright (c) 2007-2008, Plantronics, Inc.
72 All rights reserved.
73
74 Redistribution and use in source and binary forms, with or without
75 modification, are permitted provided that the following conditions are
76 met:
77
78 1. Redistributions of source code must retain the above copyright
79 notice, this list of conditions and the following disclaimer.
80
81 2. Redistributions in binary form must reproduce the above copyright
82 notice, this list of conditions and the following disclaimer in the
83 documentation and/or other materials provided with the distribution.
84
85 3. Neither the name of Plantronics nor the names of its contributors
86 may be used to endorse or promote products derived from this
87 software without specific prior written permission.
88
89 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
90 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
91 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
92 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
93 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
94 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
95 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
96 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
97 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
98 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
99 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
100
101 ==================================================================== */
srtp_err_status_t srtpUnprotect(void *data, int *size, bool rtcp)
virtual void handshakeFailed(const char *err)
virtual std::shared_ptr< std::mutex > timerLock()
void checkRemoteFingerprint(const resip::Data &hashFunction, const resip::Data &fingerprint)
virtual void write(const unsigned char *data, unsigned int len)
srtp_err_status_t srtpProtect(void *data, int *size, bool rtcp)
This class represents a Flow that is created by the Flow Manager.
Definition Flow.hxx:45
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
This class is used during media sessions that use Dtls-Srtp for a media transport.
Definition ErrorCode.hxx:4
void list()
Definition userAdmin.cxx:66