4 * The secure anycast tunneling protocol (satp) defines a protocol used
5 * for communication between any combination of unicast and anycast
6 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 * mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 * ethernet, ip, arp ...). satp directly includes cryptography and
9 * message authentication based on the methodes used by SRTP. It is
10 * intended to deliver a generic, scaleable and secure solution for
11 * tunneling and relaying of packets of any protocol.
14 * Copyright (C) 2007 anytun.org <satp@wirdorange.org>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2
18 * as published by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program (see the file COPYING included with this
26 * distribution); if not, write to the Free Software Foundation, Inc.,
27 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "threadUtils.hpp"
30 #include "datatypes.h"
32 #include "rtpSessionTable.h"
34 RtpSessionTable
* RtpSessionTable::inst
= NULL
;
35 Mutex
RtpSessionTable::instMutex
;
36 RtpSessionTable
& gRtpSessionTable
= RtpSessionTable::instance();
39 RtpSessionTable
& RtpSessionTable::instance()
42 static instanceCleaner c
;
44 inst
= new RtpSessionTable();
49 RtpSessionTable::RtpSessionTable()
53 RtpSessionTable::~RtpSessionTable()
57 void RtpSessionTable::delSession(const std::string
& call_id
)
61 RtpSessionMap::iterator it
= map_
.find(call_id
);
68 RtpSession
& RtpSessionTable::getOrNewSession(const std::string
& call_id
, bool& is_new
)
71 return getOrNewSessionUnlocked(call_id
, is_new
);
74 RtpSession
& RtpSessionTable::getOrNewSessionUnlocked(const std::string
& call_id
, bool& is_new
)
77 RtpSessionMap::iterator it
= map_
.find(call_id
);
82 std::pair
<RtpSessionMap::iterator
, bool> ret
= map_
.insert(RtpSessionMap::value_type(call_id
, NULL
));
83 ret
.first
->second
= new RtpSession(ret
.first
->first
);
84 return *(ret
.first
->second
);
87 RtpSession
& RtpSessionTable::getSession(const std::string
& call_id
)
89 RtpSessionMap::iterator it
= map_
.find(call_id
);
93 throw std::runtime_error("session not found");
96 RtpSessionMap::iterator
RtpSessionTable::getBeginUnlocked()
101 RtpSessionMap::iterator
RtpSessionTable::getEndUnlocked()
106 void RtpSessionTable::clear()
112 bool RtpSessionTable::empty()
118 Mutex
& RtpSessionTable::getMutex()