reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Server.cxx
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#ifdef WIN32
6#include <process.h>
7#else
8#include <spawn.h>
9#endif
10
11#include "../UserAgent.hxx"
12#include "Server.hxx"
13#include "AppSubsystem.hxx"
14#include "WebAdmin.hxx"
15#include "WebAdminThread.hxx"
16
17#include <resip/stack/Tuple.hxx>
18#include <rutil/DnsUtil.hxx>
19#include <rutil/Log.hxx>
20#include <rutil/Logger.hxx>
21#include <rutil/ThreadIf.hxx>
23
24#include <utility>
25// sipX includes
26#include <os/OsSysLog.h>
27
28using namespace recon;
29using namespace resip;
30using namespace std;
31
32#define RESIPROCATE_SUBSYSTEM AppSubsystem::MOHPARKSERVER
33
34namespace mohparkserver
35{
36
38{
39public:
41 virtual void decorateMessage(SipMessage &msg,
42 const Tuple &source,
43 const Tuple &destination,
44 const Data& sigcompId)
45 {
46 SdpContents* sdp = dynamic_cast<SdpContents*>(msg.getContents());
47 if(sdp && sdp->session().media().size() > 0 && sdp->session().connection().getAddress() == "0.0.0.0")
48 {
49 // Fill in IP and Port from source
52 DebugLog( << "SdpMessageDecorator: src=" << source << ", dest=" << destination << ", msg=" << endl << msg.brief());
53 }
54 }
55 virtual void rollbackMessage(SipMessage& msg) {} // Nothing to do
56 virtual MessageDecorator* clone() const { return new SdpMessageDecorator; }
57};
58
59class MyUserAgent : public UserAgent
60{
61public:
62 MyUserAgent(Server& server, std::shared_ptr<UserAgentMasterProfile> profile, resip::AfterSocketCreationFuncPtr socketFunc) :
63 UserAgent(&server, profile, socketFunc),
64 mServer(server) {}
65
66 void onApplicationTimer(unsigned int id, std::chrono::duration<double> duration, unsigned int seq) override
67 {
68 if(id == MAXPARKTIMEOUT)
69 {
71 }
72 else
73 {
74 InfoLog(<< "onApplicationTimeout: id=" << id
75 << " dur=" << std::chrono::duration_cast<std::chrono::milliseconds>(duration).count()
76 << " seq=" << seq);
77 }
78
79 }
80
81 void onSubscriptionTerminated(SubscriptionHandle handle, unsigned int statusCode) override
82 {
83 InfoLog(<< "onSubscriptionTerminated: handle=" << handle << " statusCode=" << statusCode);
84 }
85
86 void onSubscriptionNotify(SubscriptionHandle handle, const Data& notifyData) override
87 {
88 InfoLog(<< "onSubscriptionNotify: handle=" << handle << " data=" << endl << notifyData);
89 }
90private:
91 Server& mServer;
92};
93
95{
96public:
99 virtual bool operator()(Log::Level level,
100 const Subsystem& subsystem,
101 const Data& appName,
102 const char* file,
103 int line,
104 const Data& message,
105 const Data& messageWithHeaders,
106 const Data& instanceName)
107 {
108 // Log any warnings/errors to the screen and all MOHParkServer logging messages
110 {
111 resipCout << messageWithHeaders << endl;
112 }
113 return true;
114 }
115};
117
119 ConversationManager(nullptr),
120 mConfig(config),
121 mIsV6Avail(false),
122 mMyUserAgent(0),
123 mWebAdmin(0),
124 mWebAdminThread(0)
125{
126 // Initialize loggers
129 {
130 //enableConsoleOutput(TRUE); // Allow sipX console output
131 OsSysLog::initialize(0, "MOHParkServer");
132 OsSysLog::setOutputFile(0, mConfig.mSipXLogFilename.c_str()) ;
133 }
134
135 setMediaStackAdapter(make_shared<SipXMediaStackAdapter>(*this, false /* local audio? */, SipXMediaStackAdapter::sipXConversationMediaInterfaceMode));
136
137 InfoLog( << "MOHParkServer settings:");
138 ConfigParser::MOHSettingsMap::iterator itMOH = mConfig.mMOHSettingsMap.begin();
139 for (; itMOH != mConfig.mMOHSettingsMap.end(); itMOH++)
140 {
141 InfoLog(<< " MOH" << itMOH->first << " URI = " << itMOH->second.mUri);
142 InfoLog(<< " MOH" << itMOH->first << " Registration Time = " << itMOH->second.mRegistrationTime);
143 InfoLog(<< " MOH" << itMOH->first << " Outbound Proxy = " << itMOH->second.mOutboundProxy);
144 InfoLog(<< " MOH" << itMOH->first << " Filename URL = " << itMOH->second.mMOHFilenameUrl);
145 }
146 ConfigParser::ParkSettingsMap::iterator itPark = mConfig.mParkSettingsMap.begin();
147 for (; itPark != mConfig.mParkSettingsMap.end(); itPark++)
148 {
149 InfoLog(<< " Park" << itPark->first << " URI = " << itPark->second.mUri);
150 InfoLog(<< " Park" << itPark->first << " Registration Time = " << itPark->second.mRegistrationTime);
151 InfoLog(<< " Park" << itPark->first << " Outbound Proxy = " << itPark->second.mOutboundProxy);
152 InfoLog(<< " Park" << itPark->first << " Filename URL = " << itPark->second.mMOHFilenameUrl);
153 InfoLog(<< " Park" << itPark->first << " Orbit Range Start = " << itPark->second.mOrbitRangeStart);
154 InfoLog(<< " Park" << itPark->first << " Number of Orbits = " << itPark->second.mNumOrbits);
155 InfoLog(<< " Park" << itPark->first << " Orbit Registration Time = " << itPark->second.mOrbitRegistrationTime);
156 InfoLog(<< " Park" << itPark->first << " Max Park Time = " << itPark->second.mMaxParkTime);
157 }
158 InfoLog( << " Local IP Address = " << mConfig.mAddress);
159 InfoLog( << " Override DNS Servers = " << mConfig.mDnsServers);
160 InfoLog( << " UDP Port = " << mConfig.mUdpPort);
161 InfoLog( << " TCP Port = " << mConfig.mTcpPort);
162 InfoLog( << " TLS Port = " << mConfig.mTlsPort);
163 InfoLog( << " TLS Domain = " << mConfig.mTlsDomain);
164 InfoLog( << " Certificate Path = " << mConfig.mCertificatePath);
165 InfoLog( << " Keepalives = " << (mConfig.mKeepAlives ? "enabled" : "disabled"));
166 InfoLog( << " Outbound Proxy = " << mConfig.mOutboundProxy);
167 InfoLog( << " Media Port Range Start = " << mConfig.mMediaPortRangeStart);
168 InfoLog( << " Media Port Range Size = " << mConfig.mMediaPortRangeSize);
169 InfoLog( << " Log Level = " << mConfig.mLogLevel);
170
172
173 if(!mConfig.mAddress.empty())
174 {
175 // If address is specified in config file, then just use this address only
177 if(myTuple.ipVersion() == V6)
178 {
179 mIsV6Avail = true;
180 }
181 }
182 else
183 {
184 // If address in config is empty - query network interface info
185 std::list<std::pair<Data,Data> > interfaces = DnsUtil::getInterfaces();
186 std::list<std::pair<Data,Data> >::iterator itInt = interfaces.begin();
187 for(;itInt != interfaces.end(); itInt++)
188 {
189 Tuple myTuple(itInt->second, mConfig.mUdpPort, UDP);
190 if(myTuple.ipVersion() == V6)
191 {
192 mIsV6Avail = true;
193 }
194 }
195 }
196
198 // Setup UserAgentMasterProfile
200
201 auto profile = std::make_shared<UserAgentMasterProfile>();
202
203 // Add transports
204 try
205 {
206 if(mConfig.mUdpPort == (unsigned short)-1
207#ifdef USE_SSL
208 && mConfig.mTlsPort == (unsigned short)-1
209#endif
210 && mConfig.mTcpPort == (unsigned short)-1)
211 {
212 // Ensure there is at least one transport enabled - if all are disabled, then enable UDP on an OS selected port
213 mConfig.mUdpPort = 0;
214 }
215 if(mConfig.mUdpPort != (unsigned short)-1)
216 {
217 profile->addTransport(UDP, mConfig.mUdpPort, V4, StunDisabled, mConfig.mAddress);
218 if(mIsV6Avail)
219 {
220 profile->addTransport(UDP, mConfig.mUdpPort, V6, StunDisabled, mConfig.mAddress);
221 }
222 }
223 if(mConfig.mTcpPort != (unsigned short)-1)
224 {
225 profile->addTransport(TCP, mConfig.mTcpPort, V4, StunDisabled, mConfig.mAddress);
226 if(mIsV6Avail)
227 {
228 profile->addTransport(TCP, mConfig.mTcpPort, V6, StunDisabled, mConfig.mAddress);
229 }
230 }
231#ifdef USE_SSL
232 if(mConfig.mTlsPort != (unsigned short)-1)
233 {
235 if(mIsV6Avail)
236 {
238 }
239 }
240#endif
241 }
242 catch (BaseException& e)
243 {
244 std::cerr << "Cannot start a transport, likely a port is already in use" << endl;
245 InfoLog (<< "Caught: " << e);
246 exit(-1);
247 }
248 profile->certPath() = mConfig.mCertificatePath;
249
250 // DNS Servers
252 Data dnsServer;
253 while(!mConfig.mDnsServers.empty() && !pb.eof())
254 {
255 pb.skipWhitespace();
256 const char *start = pb.position();
257 pb.skipToOneOf(ParseBuffer::Whitespace, ";,"); // allow white space
258 pb.data(dnsServer, start);
259 if(DnsUtil::isIpV4Address(dnsServer))
260 {
261 InfoLog( << "Adding DNS Server: " << dnsServer);
262 profile->addAdditionalDnsServer(dnsServer);
263 }
264 else
265 {
266 ErrLog( << "Tried to add dns server, but invalid format: " << dnsServer);
267 }
268 if(!pb.eof())
269 {
270 pb.skipChar();
271 }
272 }
273
274 // Disable Statisitics Manager
275 profile->statisticsManagerEnabled() = false;
276
278 {
279 profile->setKeepAliveTimeForDatagram(30);
280 profile->setKeepAliveTimeForStream(180);
281 }
282
283 // Support Methods, etc.
284 profile->validateContentEnabled() = false;
285 profile->validateContentLanguageEnabled() = false;
286 profile->validateAcceptEnabled() = false;
287
288 profile->clearSupportedLanguages();
289 profile->addSupportedLanguage(Token("en"));
290
291 profile->clearSupportedMimeTypes();
292 profile->addSupportedMimeType(INVITE, Mime("application", "sdp"));
293 profile->addSupportedMimeType(INVITE, Mime("multipart", "mixed"));
294 profile->addSupportedMimeType(INVITE, Mime("multipart", "signed"));
295 profile->addSupportedMimeType(INVITE, Mime("multipart", "alternative"));
296 profile->addSupportedMimeType(OPTIONS,Mime("application", "sdp"));
297 profile->addSupportedMimeType(OPTIONS,Mime("multipart", "mixed"));
298 profile->addSupportedMimeType(OPTIONS, Mime("multipart", "signed"));
299 profile->addSupportedMimeType(OPTIONS, Mime("multipart", "alternative"));
300 profile->addSupportedMimeType(NOTIFY, Mime("message", "sipfrag"));
301
302 profile->clearSupportedMethods();
303 profile->addSupportedMethod(INVITE);
304 profile->addSupportedMethod(ACK);
305 profile->addSupportedMethod(CANCEL);
306 profile->addSupportedMethod(OPTIONS);
307 profile->addSupportedMethod(BYE);
308 profile->addSupportedMethod(REFER);
309 profile->addSupportedMethod(NOTIFY);
310 profile->addSupportedMethod(SUBSCRIBE);
311
312 profile->clearSupportedOptionTags();
313 profile->addSupportedOptionTag(Token(Symbols::Replaces));
314 profile->addSupportedOptionTag(Token(Symbols::Timer));
315 profile->addSupportedOptionTag(Token(Symbols::NoReferSub));
316 profile->addSupportedOptionTag(Token(Symbols::AnswerMode));
317 profile->addSupportedOptionTag(Token(Symbols::TargetDialog));
318
319 profile->setUacReliableProvisionalMode(MasterProfile::Never);
320
321 profile->clearSupportedSchemes();
322 profile->addSupportedScheme("sip");
323#ifdef USE_SSL
324 profile->addSupportedScheme("sips");
325#endif
326
327 // Have stack add Allow/Supported/Accept headers to INVITE dialog establishment messages
328 profile->clearAdvertisedCapabilities(); // Remove Profile Defaults, then add our preferences
329 profile->addAdvertisedCapability(Headers::Allow);
330 //profile->addAdvertisedCapability(Headers::AcceptEncoding); // This can be misleading - it might specify what is expected in response
331 profile->addAdvertisedCapability(Headers::AcceptLanguage);
332 profile->addAdvertisedCapability(Headers::Supported);
333 profile->setMethodsParamEnabled(true);
334
335 profile->setUserAgent("MOHParkServer");
336 profile->rtpPortRangeMin() = mConfig.mMediaPortRangeStart;
337 profile->rtpPortRangeMax() = mConfig.mMediaPortRangeStart + mConfig.mMediaPortRangeSize-1;
338
339 // Install Sdp Message Decorator
340 profile->setOutboundDecorator(std::make_shared<SdpMessageDecorator>());
341
342 mUserAgentMasterProfile = profile;
343
344 // Create UserAgent
345 mMyUserAgent = new MyUserAgent(*this, profile, mConfig.mSocketFunc);
346
347 if(mConfig.mHttpPort != 0)
348 {
349 // Create WebAdmin
350 mWebAdmin = new WebAdmin(*this, true /* noWebChallenges */, Data::Empty, Data::Empty, mConfig.mHttpPort, resip::V4);
351 mWebAdminThread = new WebAdminThread(*mWebAdmin);
352 resip_assert(mWebAdminThread && mWebAdmin);
353 mWebAdminThread->run();
354 }
355}
356
358{
359 if(mWebAdminThread)
360 {
361 mWebAdminThread->shutdown();
362 mWebAdminThread->join();
363 delete mWebAdminThread;
364 mWebAdminThread = 0;
365 }
366 if(mWebAdmin)
367 {
368 delete mWebAdmin;
369 mWebAdmin = 0;
370 }
371
372 shutdown();
373 delete mMyUserAgent;
374
375 // Should be deleted in shutdown - but done here also for safety
376 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
377 for (; itMOH != mMOHManagerMap.end(); itMOH++)
378 {
379 delete itMOH->second;
380 }
381
382 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
383 for (; itPark != mParkManagerMap.end(); itPark++)
384 {
385 delete itPark->second;
386 }
387}
388
389void
390Server::initializeResipLogging(unsigned int maxByteCount, const Data& level, const Data& resipFilename)
391{
392 // Initialize loggers
393 Log::setMaxByteCount(maxByteCount);
394 Log::initialize("file", level.c_str(), "", resipFilename.c_str(), &g_MOHParkServerLogger);
395}
396
397void
399{
400 resip_assert(mMyUserAgent);
401 mMyUserAgent->startup();
402
403 // Create an MOHManager for each setting in map and call startup
404 resip_assert(mMOHManagerMap.empty());
405 ConfigParser::MOHSettingsMap::iterator itMOH = mConfig.mMOHSettingsMap.begin();
406 for (; itMOH != mConfig.mMOHSettingsMap.end(); itMOH++)
407 {
408 MOHManager* mohManager = new MOHManager(*this);
409 mMOHManagerMap[itMOH->first] = mohManager;
410 mohManager->startup(itMOH->second);
411 }
412
413 // Create a ParkManager for each setting in map can call startup
414 resip_assert(mParkManagerMap.empty());
415 ConfigParser::ParkSettingsMap::iterator itPark = mConfig.mParkSettingsMap.begin();
416 for (; itPark != mConfig.mParkSettingsMap.end(); itPark++)
417 {
418 ParkManager* parkManager = new ParkManager(*this);
419 mParkManagerMap[itPark->first] = parkManager;
420 parkManager->startup(itPark->second);
421 }
422}
423
424void
425Server::process(int timeoutMs)
426{
427 resip_assert(mMyUserAgent);
428 mMyUserAgent->process(timeoutMs);
429}
430
431void
433{
434 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
435 for (; itMOH != mMOHManagerMap.end(); itMOH++)
436 {
437 itMOH->second->shutdown(true /*shuttingDownServer*/);
438 delete itMOH->second;
439 }
440 mMOHManagerMap.clear();
441
442 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
443 for (; itPark != mParkManagerMap.end(); itPark++)
444 {
445 itPark->second->shutdown(true /*shuttingDownServer*/);
446 delete itPark->second;
447 }
448 mParkManagerMap.clear();
449
450 resip_assert(mMyUserAgent);
451 mMyUserAgent->shutdown();
452 OsSysLog::shutdown();
453}
454
455void
456Server::buildSessionCapabilities(resip::SdpContents& sessionCaps)
457{
458 std::vector<unsigned int> codecIds = { SdpCodec::SDP_CODEC_PCMU /* 0 - pcmu */,
459 SdpCodec::SDP_CODEC_PCMA /* 8 - pcma */,
460 SdpCodec::SDP_CODEC_G729A /* 18 - g729 */,
461 SdpCodec::SDP_CODEC_OPUS /* 147 - opus */,
462 SdpCodec::SDP_CODEC_SPEEX /* 96 - speex NB 8,000bps */,
463 SdpCodec::SDP_CODEC_SPEEX_15 /* 98 - speex NB 15,000bps */,
464 SdpCodec::SDP_CODEC_SPEEX_24 /* 99 - speex NB 24,600bps */,
465 SdpCodec::SDP_CODEC_L16_44100_MONO /* PCM 16 bit/sample 44100 samples/sec. */,
466 SdpCodec::SDP_CODEC_G726_16,
467 SdpCodec::SDP_CODEC_G726_24,
468 SdpCodec::SDP_CODEC_G726_32,
469 SdpCodec::SDP_CODEC_G726_40,
470 SdpCodec::SDP_CODEC_ILBC /* 108 - iLBC */,
471 SdpCodec::SDP_CODEC_ILBC_20MS /* 109 - Internet Low Bit Rate Codec, 20ms (RFC3951) */,
472 SdpCodec::SDP_CODEC_SPEEX_5 /* 97 - speex NB 5,950bps */,
473 SdpCodec::SDP_CODEC_GSM /* 3 - GSM */,
474 SdpCodec::SDP_CODEC_TONES /* 110 - telephone-event */};
476}
477
478void
479Server::getActiveCallsInfo(std::list<ActiveCallInfo>& callInfos)
480{
481 callInfos.clear();
482
483 // Get Calls from all the MOH Managers
484 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
485 for (; itMOH != mMOHManagerMap.end(); itMOH++)
486 {
487 itMOH->second->getActiveCallsInfo(callInfos);
488 }
489
490 // Get Calls from all the MOH Managers
491 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
492 for (; itPark != mParkManagerMap.end(); itPark++)
493 {
494 itPark->second->getActiveCallsInfo(callInfos);
495 }
496}
497
498void
500{
501 InfoLog(<< "onConversationDestroyed: handle=" << convHandle);
502}
503
504void
506{
507 InfoLog(<< "onParticipantDestroyed: handle=" << partHandle);
508
509 // Try each manager until participant is found
510 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
511 for (; itMOH != mMOHManagerMap.end(); itMOH++)
512 {
513 if (itMOH->second->removeParticipant(partHandle))
514 {
515 return;
516 }
517 }
518
519 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
520 for (; itPark != mParkManagerMap.end(); itPark++)
521 {
522 if (itPark->second->removeParticipant(partHandle))
523 {
524 return;
525 }
526 }
527}
528
529void
530Server::onDtmfEvent(ParticipantHandle partHandle, int dtmf, int duration, bool up)
531{
532 InfoLog(<< "onDtmfEvent: handle=" << partHandle << " tone=" << dtmf << " dur=" << duration << " up=" << up);
533}
534
535void
536Server::onIncomingParticipant(ParticipantHandle partHandle, const SipMessage& msg, bool autoAnswer, ConversationProfile& conversationProfile)
537{
538 InfoLog(<< "onIncomingParticipant: handle=" << partHandle << " auto=" << autoAnswer << " msg=" << msg.brief());
539
540 // Try each manager until conversationProfile is found
541 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
542 for (; itMOH != mMOHManagerMap.end(); itMOH++)
543 {
544 if (itMOH->second->isMyProfile(conversationProfile))
545 {
546 itMOH->second->addParticipant(partHandle, msg.header(h_From).uri(), msg.header(h_From).uri());
547 return;
548 }
549 }
550
551 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
552 for (; itPark != mParkManagerMap.end(); itPark++)
553 {
554 if (itPark->second->isMyProfile(conversationProfile))
555 {
556 itPark->second->incomingParticipant(partHandle, msg);
557 return;
558 }
559 }
560
561 // Not found anywhere - reject with a 404
562 rejectParticipant(partHandle, 404);
563}
564
565void
567{
568 InfoLog(<< "onRequestOutgoingParticipant: handle=" << partHandle << " msg=" << msg.brief());
569
570 // Try each manager until conversationProfile is found
571 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
572 for (; itMOH != mMOHManagerMap.end(); itMOH++)
573 {
574 if (itMOH->second->isMyProfile(conversationProfile))
575 {
576 itMOH->second->addParticipant(partHandle, msg.header(h_ReferTo).uri().getAorAsUri(), msg.header(h_From).uri());
577 return;
578 }
579 }
580
581 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
582 for (; itPark != mParkManagerMap.end(); itPark++)
583 {
584 if (itPark->second->isMyProfile(conversationProfile))
585 {
586 itPark->second->parkParticipant(partHandle, msg);
587 return;
588 }
589 }
590
591 // Not found anywhere - reject with a 404
592 rejectParticipant(partHandle, 404);
593}
594
595void
596Server::onParticipantTerminated(ParticipantHandle partHandle, unsigned int statusCode)
597{
598 InfoLog(<< "onParticipantTerminated: handle=" << partHandle);
599}
600
601void
603{
604 InfoLog(<< "onParticipantProceeding: handle=" << partHandle << " msg=" << msg.brief());
605}
606
607void
609 ConversationHandle origConvHandle, ParticipantHandle origPartHandle)
610{
611 InfoLog(<< "onRelatedConversation: relatedConvHandle=" << relatedConvHandle << " relatedPartHandle=" << relatedPartHandle
612 << " origConvHandle=" << origConvHandle << " origPartHandle=" << origPartHandle);
613}
614
615void
617{
618 InfoLog(<< "onParticipantAlerting: handle=" << partHandle << " msg=" << msg.brief());
619}
620
621void
623{
624 InfoLog(<< "onParticipantConnected: handle=" << partHandle << " msg=" << msg.brief());
625}
626
627void
629{
630 InfoLog(<< "onParticipantRedirectSuccess: handle=" << partHandle);
631 destroyParticipant(partHandle); // Transfer is successful - end participant
632}
633
634void
635Server::onParticipantRedirectFailure(ParticipantHandle partHandle, unsigned int statusCode)
636{
637 InfoLog(<< "onParticipantRedirectFailure: handle=" << partHandle << " statusCode=" << statusCode);
638}
639
640void
642{
643 InfoLog(<< "onParticipantRequestedHold: handle=" << partHandle << " held=" << held);
644}
645
646void
648{
649 // Pass to ParkManager(s) to see if participant is still around
650 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
651 for (; itPark != mParkManagerMap.end(); itPark++)
652 {
653 if (itPark->second->onMaxParkTimeout(participantHandle))
654 {
655 // Once participant is found, we can stop
656 return;
657 }
658 }
659}
660
661}
662
663/* ====================================================================
664
665 Copyright (c) 2010-2016, SIP Spectrum, Inc.
666 All rights reserved.
667
668 Redistribution and use in source and binary forms, with or without
669 modification, are permitted provided that the following conditions are
670 met:
671
672 1. Redistributions of source code must retain the above copyright
673 notice, this list of conditions and the following disclaimer.
674
675 2. Redistributions in binary form must reproduce the above copyright
676 notice, this list of conditions and the following disclaimer in the
677 documentation and/or other materials provided with the distribution.
678
679 3. Neither the name of SIP Spectrum nor the names of its contributors
680 may be used to endorse or promote products derived from this
681 software without specific prior written permission.
682
683 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
684 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
685 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
686 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
687 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
688 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
689 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
690 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
691 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
692 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
693 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
694
695 ==================================================================== */
696
#define DebugLog(args_)
Definition Logger.hxx:128
#define InfoLog(args_)
Definition Logger.hxx:131
#define ErrLog(args_)
Definition Logger.hxx:137
#define resip_assert(x)
This file needs to work for both C and C++ code.
#define MAXPARKTIMEOUT
Definition Server.hxx:19
static AppSubsystem MOHPARKSERVER
unsigned short mMediaPortRangeSize
resip::AfterSocketCreationFuncPtr mSocketFunc
unsigned short mMediaPortRangeStart
ParkSettingsMap mParkSettingsMap
void startup(ConfigParser::MOHSettings &settings)
virtual bool operator()(Log::Level level, const Subsystem &subsystem, const Data &appName, const char *file, int line, const Data &message, const Data &messageWithHeaders, const Data &instanceName)
return true to also do default logging, false to supress default logging.
Definition Server.cxx:99
MyUserAgent(Server &server, std::shared_ptr< UserAgentMasterProfile > profile, resip::AfterSocketCreationFuncPtr socketFunc)
Definition Server.cxx:62
void onSubscriptionNotify(SubscriptionHandle handle, const Data &notifyData) override
Callback used when a subscription has received an event notification from the server.
Definition Server.cxx:86
void onApplicationTimer(unsigned int id, std::chrono::duration< double > duration, unsigned int seq) override
Callback used when an application timer expires.
Definition Server.cxx:66
void onSubscriptionTerminated(SubscriptionHandle handle, unsigned int statusCode) override
Callback used when a subscription is terminated.
Definition Server.cxx:81
void startup(ConfigParser::ParkSettings &settings)
virtual MessageDecorator * clone() const
Definition Server.cxx:56
virtual void decorateMessage(SipMessage &msg, const Tuple &source, const Tuple &destination, const Data &sigcompId)
Definition Server.cxx:41
virtual void rollbackMessage(SipMessage &msg)
Definition Server.cxx:55
virtual void onRelatedConversation(recon::ConversationHandle relatedConvHandle, recon::ParticipantHandle relatedPartHandle, recon::ConversationHandle origConvHandle, recon::ParticipantHandle origPartHandle)
Notifies an applications that a outbound remote participant request has forked.
Definition Server.cxx:608
virtual void onRequestOutgoingParticipant(recon::ParticipantHandle partHandle, const resip::SipMessage &msg, recon::ConversationProfile &conversationProfile)
Notifies an application about a new remote participant that is trying to be contacted.
Definition Server.cxx:566
virtual void onParticipantRedirectFailure(recon::ParticipantHandle partHandle, unsigned int statusCode)
Notifies an application that a redirect request has failed.
Definition Server.cxx:635
void startup()
Starts the recon thread(s).
Definition Server.cxx:398
virtual void onConversationDestroyed(recon::ConversationHandle convHandle)
Notifies an application when a conversation has been destroyed.
Definition Server.cxx:499
void getActiveCallsInfo(CallInfoList &callInfos)
Definition Server.cxx:479
virtual void onDtmfEvent(recon::ParticipantHandle partHandle, int dtmf, int duration, bool up)
Notifies an application when an RFC2833 DTMF event is received from a particular remote participant.
Definition Server.cxx:530
virtual void onParticipantRedirectSuccess(recon::ParticipantHandle partHandle)
Notifies an application that a redirect request has succeeded.
Definition Server.cxx:628
virtual void onParticipantConnected(recon::ParticipantHandle partHandle, const resip::SipMessage &msg)
Notifies an application that a remote participant call attempt is now connected.
Definition Server.cxx:622
void initializeResipLogging(unsigned int maxByteCount, const resip::Data &level, const resip::Data &resipFilename)
Definition Server.cxx:390
virtual void onParticipantRequestedHold(recon::ParticipantHandle partHandle, bool held)
Definition Server.cxx:641
virtual void onParticipantProceeding(recon::ParticipantHandle partHandle, const resip::SipMessage &msg)
Notifies an application that a remote participant call attempt is proceeding at the first hop.
Definition Server.cxx:602
friend class MOHManager
Definition Server.hxx:92
ConfigParser & mConfig
Definition Server.hxx:72
virtual void onParticipantDestroyed(recon::ParticipantHandle partHandle)
Notifies an application when a Participant has been destroyed.
Definition Server.cxx:505
Server(ConfigParser &config)
Definition Server.cxx:118
virtual void onParticipantTerminated(recon::ParticipantHandle partHandle, unsigned int statusCode)
Notifies an application about a disconnect by a remote participant.
Definition Server.cxx:596
virtual void onParticipantAlerting(recon::ParticipantHandle partHandle, const resip::SipMessage &msg)
Notifies an application that a remote participant call attempt is alerting the remote party.
Definition Server.cxx:616
virtual void onMaxParkTimeout(recon::ParticipantHandle participantHandle)
Definition Server.cxx:647
void shutdown()
Used to initiate a shutdown of the server.
Definition Server.cxx:432
virtual void onIncomingParticipant(recon::ParticipantHandle partHandle, const resip::SipMessage &msg, bool autoAnswer, recon::ConversationProfile &conversationProfile)
Notifies an application about a new remote participant that is attempting to contact it.
Definition Server.cxx:536
friend class ParkManager
Definition Server.hxx:93
This class is one of two main classes of concern to an application using the UserAgent library.
virtual void setMediaStackAdapter(std::shared_ptr< MediaStackAdapter > mediaStackAdapter)
virtual void rejectParticipant(ParticipantHandle partHandle, unsigned int rejectCode)
Rejects an incoming remote participant with the specified code.
MediaStackAdapter & getMediaStackAdapter()
virtual void destroyParticipant(ParticipantHandle partHandle)
Ends connections to the participant and removes it from all active conversations.
This class extends the resip UserProfile to include Conversation Manager specific settings.
virtual void buildSessionCapabilities(const resip::Data &ipaddress, const std::vector< unsigned int > &codecIds, resip::SdpContents &sessionCaps)=0
Builds a session capabilties SDPContents based on the passed in ipaddress and codec ordering.
This class is one of two main classes of concern to an application using the UserAgent library.
Definition UserAgent.hxx:56
virtual void process(int timeoutMs)
This should be called in a loop to give process cycles to the UserAgent.
void shutdown()
Used to initiate a shutdown of the useragent.
void startup()
Starts the SIP stack thread.
The abstract base-class for all exceptions thrown by resip code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
const char * c_str() const
Returns a null-terminated string representing.
Definition Data.cxx:1097
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
static std::list< std::pair< Data, Data > > getInterfaces(const Data &matchingInterface=Data::Empty)
Definition DnsUtil.cxx:460
static bool isIpV4Address(const Data &ipAddress)
Definition DnsUtil.cxx:290
Interface functor for external logging.
Definition Log.hxx:448
static void setMaxByteCount(unsigned int maxByteCount)
Definition Log.cxx:512
@ Warning
Definition Log.hxx:82
static void initialize(Type type, Level level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0, const Data &syslogFacility="LOG_DAEMON", MessageStructure messageStructure=Unstructured, const Data &instanceName="")
Definition Log.cxx:268
virtual Brief brief() const
return a facet for brief encoding of message
Definition Message.cxx:16
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipWhitespace()
CurrentPosition position() const
CurrentPosition skipToOneOf(const char *cs)
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
static const char * Whitespace
const Uri & uri() const
const Data & getAddress() const
returns the connection address
void setAddress(const Data &host, AddrType type=IP4)
set the address for the connection
void setAddress(const Data &host, AddrType type=IP4)
set the address for the session
const Origin & origin() const
return session Origin line
const Connection & connection() const
return session Connection
const MediumContainer & media() const
return session Media lines
Provides an interface to process and generate SDP bodies (MIME content-type application/sdp).
Session & session()
get the parsed SDP
Represents a SIP message.
Contents * getContents() const
Retrieves the body of a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
Class used to specify what sub-system given sections of code belong to, for use by the logging system...
Definition Subsystem.hxx:34
const Data & getSubsystem() const
Definition Subsystem.cxx:23
static const char * Timer
Definition Symbols.hxx:109
static const char * AnswerMode
Definition Symbols.hxx:111
static const char * Replaces
Definition Symbols.hxx:108
static const char * NoReferSub
Definition Symbols.hxx:110
static const char * TargetDialog
Definition Symbols.hxx:112
virtual void shutdown()
Definition ThreadIf.cxx:190
virtual void run()
Definition ThreadIf.cxx:75
Represents the "token" element in the RFC 3261 grammar.
Definition Token.hxx:18
Represents a network address.
Definition Tuple.hxx:59
IpVersion ipVersion() const
Returns V4 or V6 as appropriate.
Definition Tuple.cxx:537
static Data inet_ntop(const Tuple &tuple)
Converts the binary socket address to presentation format, via the DnsUtil::inet_ntop() method.
Definition Tuple.cxx:939
Uri getAorAsUri(TransportType transportTypeToRemoveDefaultPort=UNKNOWN_TRANSPORT) const
Definition Uri.cxx:1103
MOHParkServerLogger g_MOHParkServerLogger
Definition Server.cxx:116
unsigned int ConversationHandle
unsigned int ParticipantHandle
unsigned int SubscriptionHandle
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)
Definition Socket.hxx:107
static void foo()
#define resipCout