- TODO:
- CMake support to make core/sip/sip_stack.a and link against it in the core.
- merge AmSipRequest/AmSipReply and sip_msg structures.
git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1758 8eb893ce-cfd4-0310-b710-fb5ebe64c474
... | ... |
@@ -109,15 +109,15 @@ AmLoggingFacility::AmLoggingFacility(const string& name) |
109 | 109 |
{ |
110 | 110 |
} |
111 | 111 |
|
112 |
-AmCtrlInterfaceFactory::AmCtrlInterfaceFactory(const string& name) |
|
113 |
- : AmPluginFactory(name) |
|
114 |
-{ |
|
115 |
-} |
|
112 |
+// AmCtrlInterfaceFactory::AmCtrlInterfaceFactory(const string& name) |
|
113 |
+// : AmPluginFactory(name) |
|
114 |
+// { |
|
115 |
+// } |
|
116 | 116 |
|
117 |
-AmCtrlInterface::AmCtrlInterface() |
|
118 |
-{ |
|
119 |
-} |
|
117 |
+// AmCtrlInterface::AmCtrlInterface() |
|
118 |
+// { |
|
119 |
+// } |
|
120 | 120 |
|
121 |
-AmCtrlInterface::~AmCtrlInterface() |
|
122 |
-{ |
|
123 |
-} |
|
121 |
+// AmCtrlInterface::~AmCtrlInterface() |
|
122 |
+// { |
|
123 |
+// } |
... | ... |
@@ -228,47 +228,6 @@ class AmLoggingFacility : public AmPluginFactory |
228 | 228 |
virtual void log(int level, const char* msg) = 0; |
229 | 229 |
}; |
230 | 230 |
|
231 |
-class AmCtrlInterface: public AmThread |
|
232 |
-{ |
|
233 |
- public: |
|
234 |
- AmCtrlInterface(); |
|
235 |
- virtual ~AmCtrlInterface(); |
|
236 |
- |
|
237 |
- //@param serKey [out] An out parameter |
|
238 |
- //@param serKeyLen [out] An out parameter |
|
239 |
- |
|
240 |
- virtual int send(const AmSipRequest &, |
|
241 |
- char* serKey, unsigned int& serKeyLen) = 0; |
|
242 |
- |
|
243 |
- virtual int send(const AmSipReply &) = 0; |
|
244 |
- |
|
245 |
- virtual string getContact(const string &displayName, |
|
246 |
- const string &userName, const string &hostName, |
|
247 |
- const string &uriParams, const string &hdrParams) = 0; |
|
248 |
-}; |
|
249 |
- |
|
250 |
-/** |
|
251 |
- * \brief Interface for plugins that implement a control interface. |
|
252 |
- * |
|
253 |
- * The AmCtrlInterface defines the interface for |
|
254 |
- * SER-SEMS communication interface (unix socket/fifo). |
|
255 |
- * |
|
256 |
- * For sending messages, appropriate methods are exposed (the send()s). |
|
257 |
- * The interface defines a thread that runs, polling on the two listening unix |
|
258 |
- * sockets (one for requests, one for replies). After receiving a message, |
|
259 |
- * AmSipDispatcher shall be used to dispatch the incomming SIP messages |
|
260 |
- * (that end up either opening/updating a UAC session or posting to some |
|
261 |
- * event queue). |
|
262 |
- */ |
|
263 |
-class AmCtrlInterfaceFactory : public AmPluginFactory |
|
264 |
-{ |
|
265 |
- public: |
|
266 |
- AmCtrlInterfaceFactory(const string& name); |
|
267 |
- virtual ~AmCtrlInterfaceFactory() {} |
|
268 |
- |
|
269 |
- virtual AmCtrlInterface* instance() = 0; |
|
270 |
-}; |
|
271 |
- |
|
272 | 231 |
#if __GNUC__ < 3 |
273 | 232 |
#define EXPORT_FACTORY(fctname,class_name,args...) \ |
274 | 233 |
extern "C" void* fctname()\ |
... | ... |
@@ -32,7 +32,7 @@ |
32 | 32 |
#include "AmUtils.h" |
33 | 33 |
#include "AmSdp.h" |
34 | 34 |
#include "AmSipDispatcher.h" |
35 |
-#include "AmServer.h" |
|
35 |
+//#include "AmServer.h" |
|
36 | 36 |
|
37 | 37 |
#include "amci/amci.h" |
38 | 38 |
#include "amci/codecs.h" |
... | ... |
@@ -101,8 +101,8 @@ amci_payload_t _payload_tevent = { |
101 | 101 |
AmPlugIn* AmPlugIn::_instance=0; |
102 | 102 |
|
103 | 103 |
AmPlugIn::AmPlugIn() |
104 |
- : dynamic_pl(DYNAMIC_PAYLOAD_TYPE_START), |
|
105 |
- ctrlIface(NULL) |
|
104 |
+ : dynamic_pl(DYNAMIC_PAYLOAD_TYPE_START) |
|
105 |
+ //ctrlIface(NULL) |
|
106 | 106 |
{ |
107 | 107 |
} |
108 | 108 |
|
... | ... |
@@ -206,14 +206,14 @@ int AmPlugIn::load(const string& directory, const string& plugins) |
206 | 206 |
|
207 | 207 |
DBG("AmPlugIn: Initializing plugins...\n"); |
208 | 208 |
|
209 |
- if (ctrlIface) { |
|
210 |
- if ((err = ctrlIface->onLoad())) { |
|
211 |
- ERROR("failed to initialize control interface.\n"); |
|
212 |
- return err; |
|
213 |
- } else { |
|
214 |
- AmServer::instance()->regIface(ctrlIface->instance()); |
|
215 |
- } |
|
216 |
- } |
|
209 |
+// if (ctrlIface) { |
|
210 |
+// if ((err = ctrlIface->onLoad())) { |
|
211 |
+// ERROR("failed to initialize control interface.\n"); |
|
212 |
+// return err; |
|
213 |
+// } else { |
|
214 |
+// AmServer::instance()->regIface(ctrlIface->instance()); |
|
215 |
+// } |
|
216 |
+// } |
|
217 | 217 |
|
218 | 218 |
// initialize base components |
219 | 219 |
for(std::map<std::string,AmPluginFactory*>::iterator it = name2base.begin(); |
... | ... |
@@ -348,13 +348,13 @@ int AmPlugIn::loadPlugIn(const string& file) |
348 | 348 |
has_sym=true; |
349 | 349 |
} |
350 | 350 |
|
351 |
- // try load a control plugin |
|
352 |
- if ((fc = (FactoryCreate)dlsym(h_dl,FACTORY_CONTROL_INTERFACE_EXPORT_STR))) { |
|
353 |
- if (loadCtrlFacPlugIn((AmPluginFactory*)fc())) |
|
354 |
- goto error; |
|
355 |
- assert(! has_sym); |
|
356 |
- has_sym = true; |
|
357 |
- } |
|
351 |
+// // try load a control plugin |
|
352 |
+// if ((fc = (FactoryCreate)dlsym(h_dl,FACTORY_CONTROL_INTERFACE_EXPORT_STR))) { |
|
353 |
+// if (loadCtrlFacPlugIn((AmPluginFactory*)fc())) |
|
354 |
+// goto error; |
|
355 |
+// assert(! has_sym); |
|
356 |
+// has_sym = true; |
|
357 |
+// } |
|
358 | 358 |
|
359 | 359 |
if(!has_sym){ |
360 | 360 |
ERROR("Plugin type could not be detected (%s)(%s)\n",file.c_str(),dlerror()); |
... | ... |
@@ -669,27 +669,26 @@ int AmPlugIn::loadLogFacPlugIn(AmPluginFactory* f) |
669 | 669 |
return -1; |
670 | 670 |
} |
671 | 671 |
|
672 |
-int AmPlugIn::loadCtrlFacPlugIn(AmPluginFactory* f) |
|
673 |
-{ |
|
674 |
- AmCtrlInterfaceFactory *_ctrlIface = dynamic_cast<AmCtrlInterfaceFactory *>(f); |
|
675 |
- if (! _ctrlIface) { |
|
676 |
- ERROR("invalid control interface plugin.\n"); |
|
677 |
- return -1; |
|
678 |
- } |
|
679 |
- if (ctrlIface) { |
|
680 |
- ERROR("one control interface already loaded (`%s'): can not load a " |
|
681 |
- "second one (`%s').\n", (ctrlIface->getName()).c_str(), |
|
682 |
- (_ctrlIface->getName()).c_str()); |
|
683 |
- return -1; |
|
684 |
- } |
|
685 |
- ctrlIface = _ctrlIface;//->instance(); |
|
686 |
- if (! ctrlIface) { |
|
687 |
- ERROR("BUG: failed to retrieve a control interface instance.\n"); |
|
688 |
- return -1; |
|
689 |
- } |
|
690 |
- |
|
691 |
- return 0; |
|
692 |
-} |
|
672 |
+// int AmPlugIn::loadCtrlFacPlugIn(AmPluginFactory* f) |
|
673 |
+// { |
|
674 |
+// AmCtrlInterfaceFactory *_ctrlIface = dynamic_cast<AmCtrlInterfaceFactory *>(f); |
|
675 |
+// if (! _ctrlIface) { |
|
676 |
+// ERROR("invalid control interface plugin.\n"); |
|
677 |
+// return -1; |
|
678 |
+// } |
|
679 |
+// if (ctrlIface) { |
|
680 |
+// ERROR("one control interface already loaded (`%s'): can not load a " |
|
681 |
+// "second one (`%s').\n", (ctrlIface->getName()).c_str(), |
|
682 |
+// (_ctrlIface->getName()).c_str()); |
|
683 |
+// return -1; |
|
684 |
+// } |
|
685 |
+// ctrlIface = _ctrlIface;//->instance(); |
|
686 |
+// if (! ctrlIface) { |
|
687 |
+// ERROR("BUG: failed to retrieve a control interface instance.\n"); |
|
688 |
+// return -1; |
|
689 |
+// } |
|
690 |
+// return 0; |
|
691 |
+// } |
|
693 | 692 |
|
694 | 693 |
int AmPlugIn::addCodec(amci_codec_t* c) |
695 | 694 |
{ |
... | ... |
@@ -44,7 +44,7 @@ class AmSessionEventHandlerFactory; |
44 | 44 |
class AmDynInvokeFactory; |
45 | 45 |
//class AmSIPEventHandler; |
46 | 46 |
class AmLoggingFacility; |
47 |
-class AmCtrlInterfaceFactory; |
|
47 |
+//class AmCtrlInterfaceFactory; |
|
48 | 48 |
class AmSipRequest; |
49 | 49 |
|
50 | 50 |
struct amci_exports_t; |
... | ... |
@@ -103,7 +103,7 @@ class AmPlugIn : public AmPayloadProviderInterface |
103 | 103 |
std::map<string,AmDynInvokeFactory*> name2di; |
104 | 104 |
std::map<string,AmLoggingFacility*> name2logfac; |
105 | 105 |
|
106 |
- AmCtrlInterfaceFactory *ctrlIface; |
|
106 |
+ //AmCtrlInterfaceFactory *ctrlIface; |
|
107 | 107 |
|
108 | 108 |
int dynamic_pl; // range: 96->127, see RFC 1890 |
109 | 109 |
std::set<string> excluded_payloads; // don't load these payloads (named) |
... | ... |
@@ -120,7 +120,7 @@ class AmPlugIn : public AmPayloadProviderInterface |
120 | 120 |
int loadBasePlugIn(AmPluginFactory* cb); |
121 | 121 |
int loadDiPlugIn(AmPluginFactory* cb); |
122 | 122 |
int loadLogFacPlugIn(AmPluginFactory* f); |
123 |
- int loadCtrlFacPlugIn(AmPluginFactory* f); |
|
123 |
+ //int loadCtrlFacPlugIn(AmPluginFactory* f); |
|
124 | 124 |
|
125 | 125 |
public: |
126 | 126 |
|
127 | 127 |
deleted file mode 100644 |
... | ... |
@@ -1,92 +0,0 @@ |
1 |
-/* |
|
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * Copyright (C) 2002-2003 Fhg Fokus |
|
5 |
- * |
|
6 |
- * This file is part of sems, a free SIP media server. |
|
7 |
- * |
|
8 |
- * sems is free software; you can redistribute it and/or modify |
|
9 |
- * it under the terms of the GNU General Public License as published by |
|
10 |
- * the Free Software Foundation; either version 2 of the License, or |
|
11 |
- * (at your option) any later version |
|
12 |
- * |
|
13 |
- * For a license to use the ser software under conditions |
|
14 |
- * other than those described here, or to purchase support for this |
|
15 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
- * info@iptel.org |
|
17 |
- * |
|
18 |
- * sems is distributed in the hope that it will be useful, |
|
19 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
- * GNU General Public License for more details. |
|
22 |
- * |
|
23 |
- * You should have received a copy of the GNU General Public License |
|
24 |
- * along with this program; if not, write to the Free Software |
|
25 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
- */ |
|
27 |
- |
|
28 |
-#include "log.h" |
|
29 |
-#include "AmServer.h" |
|
30 |
- |
|
31 |
-#include <unistd.h> |
|
32 |
- |
|
33 |
-// |
|
34 |
-// AmServer methods |
|
35 |
-// |
|
36 |
- |
|
37 |
-AmServer* AmServer::_instance; |
|
38 |
-AmCtrlInterface* AmServer::ctrlIface; |
|
39 |
- |
|
40 |
-AmServer* AmServer::instance() |
|
41 |
-{ |
|
42 |
- return _instance ? _instance : ((_instance = new AmServer())); |
|
43 |
-} |
|
44 |
- |
|
45 |
-void AmServer::dispose() |
|
46 |
-{ |
|
47 |
- if(_instance != NULL) { |
|
48 |
- if(_instance->ctrlIface != NULL) { |
|
49 |
- _instance->ctrlIface->join(); |
|
50 |
- } |
|
51 |
- delete _instance; |
|
52 |
- _instance = NULL; |
|
53 |
- } |
|
54 |
-} |
|
55 |
- |
|
56 |
-AmServer::~AmServer() |
|
57 |
-{ |
|
58 |
- INFO("Signaling Server has been recycled.\n"); |
|
59 |
-} |
|
60 |
- |
|
61 |
-void AmServer::run() |
|
62 |
-{ |
|
63 |
- ctrlIface->start(); |
|
64 |
- ctrlIface->join(); |
|
65 |
-} |
|
66 |
- |
|
67 |
-void AmServer::regIface(const AmCtrlInterface *i) |
|
68 |
-{ |
|
69 |
- if (ctrlIface) { |
|
70 |
- ERROR("control interface already registered; aborting second attempt.\n"); |
|
71 |
- return; |
|
72 |
- } |
|
73 |
- ctrlIface = const_cast<AmCtrlInterface *>(i); |
|
74 |
-} |
|
75 |
- |
|
76 |
-bool AmServer::sendReply(const AmSipReply &reply) |
|
77 |
-{ |
|
78 |
- return ctrlIface->send(reply); |
|
79 |
-} |
|
80 |
- |
|
81 |
-bool AmServer::sendRequest(const AmSipRequest &req, char* serKey, unsigned int& serKeyLen) |
|
82 |
-{ |
|
83 |
- return ctrlIface->send(req, serKey, serKeyLen); |
|
84 |
-} |
|
85 |
- |
|
86 |
-string AmServer::getContact(const string &displayName, |
|
87 |
- const string &userName, const string &hostName, |
|
88 |
- const string &uriParams, const string &hdrParams) |
|
89 |
-{ |
|
90 |
- return ctrlIface->getContact(displayName, userName, hostName, uriParams, |
|
91 |
- hdrParams); |
|
92 |
-} |
93 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,84 +0,0 @@ |
1 |
-/* |
|
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * Copyright (C) 2002-2003 Fhg Fokus |
|
5 |
- * |
|
6 |
- * This file is part of sems, a free SIP media server. |
|
7 |
- * |
|
8 |
- * sems is free software; you can redistribute it and/or modify |
|
9 |
- * it under the terms of the GNU General Public License as published by |
|
10 |
- * the Free Software Foundation; either version 2 of the License, or |
|
11 |
- * (at your option) any later version |
|
12 |
- * |
|
13 |
- * For a license to use the ser software under conditions |
|
14 |
- * other than those described here, or to purchase support for this |
|
15 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
- * info@iptel.org |
|
17 |
- * |
|
18 |
- * sems is distributed in the hope that it will be useful, |
|
19 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
- * GNU General Public License for more details. |
|
22 |
- * |
|
23 |
- * You should have received a copy of the GNU General Public License |
|
24 |
- * along with this program; if not, write to the Free Software |
|
25 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
- */ |
|
27 |
-/** @file AmServer.h */ |
|
28 |
-#ifndef _AmServer_h_ |
|
29 |
-#define _AmServer_h_ |
|
30 |
- |
|
31 |
-#include "AmSipMsg.h" |
|
32 |
-#include "AmApi.h" |
|
33 |
- |
|
34 |
- |
|
35 |
-/** |
|
36 |
- * \brief singleton, serve requests from ctrl interface |
|
37 |
- * |
|
38 |
- * The Server polls requests from the control interface and feeds |
|
39 |
- * them to registered handlers. |
|
40 |
- */ |
|
41 |
-class AmServer |
|
42 |
-{ |
|
43 |
-private: |
|
44 |
- /** |
|
45 |
- * Singleton pointer. |
|
46 |
- * @see instance() |
|
47 |
- */ |
|
48 |
- static AmServer* _instance; |
|
49 |
- |
|
50 |
- static AmCtrlInterface *ctrlIface; |
|
51 |
- |
|
52 |
- /** Avoid external instantiation. @see instance(). */ |
|
53 |
- ~AmServer(); |
|
54 |
- |
|
55 |
-public: |
|
56 |
- /** Get a fifo server instance. */ |
|
57 |
- static AmServer* instance(); |
|
58 |
- static void dispose(); |
|
59 |
- |
|
60 |
- /** Runs the fifo server. */ |
|
61 |
- void run(); |
|
62 |
- |
|
63 |
- /** |
|
64 |
- * Register THE interface. |
|
65 |
- * WARNING: only before the server starts up. |
|
66 |
- */ |
|
67 |
- void regIface(const AmCtrlInterface *i); |
|
68 |
- bool hasIface() { return ctrlIface != NULL; }; |
|
69 |
- |
|
70 |
- static bool sendRequest(const AmSipRequest &, char* serKey, unsigned int& serKeyLen); |
|
71 |
- static bool sendReply(const AmSipReply &); |
|
72 |
- static string getContact(const string &displayName, |
|
73 |
- const string &userName, const string &hostName, |
|
74 |
- const string &uriParams, const string &hdrParams); |
|
75 |
-}; |
|
76 |
- |
|
77 |
-#endif |
|
78 |
- |
|
79 |
-// Local Variables: |
|
80 |
-// mode:C++ |
|
81 |
-// End: |
|
82 |
- |
|
83 |
- |
|
84 |
- |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
#include "AmSession.h" |
31 | 31 |
#include "AmUtils.h" |
32 | 32 |
#include "AmSipHeaders.h" |
33 |
-#include "AmServer.h" |
|
33 |
+#include "SipCtrlInterface.h" |
|
34 | 34 |
#include "sems.h" |
35 | 35 |
|
36 | 36 |
const char* AmSipDialog::status2str[4] = { |
... | ... |
@@ -274,45 +274,20 @@ void AmSipDialog::updateStatus(const AmSipReply& reply, bool do_200_ack) |
274 | 274 |
|
275 | 275 |
string AmSipDialog::getContactHdr() |
276 | 276 |
{ |
277 |
- if(!contact_uri.empty()) |
|
278 |
- return contact_uri; |
|
277 |
+ if(contact_uri.empty()) { |
|
279 | 278 |
|
280 |
- string userName; |
|
281 |
- if(user.empty() || !AmConfig::PrefixSep.empty()) |
|
282 |
- userName += CONTACT_USER_PREFIX; |
|
283 |
- |
|
284 |
- if(!AmConfig::PrefixSep.empty()) |
|
285 |
- userName += AmConfig::PrefixSep; |
|
286 |
- |
|
287 |
- if(!user.empty()) |
|
288 |
- userName += user; |
|
289 |
- |
|
290 |
- string hostName; |
|
291 |
- if (! sip_ip.empty()) { |
|
292 |
-#ifdef SUPPORT_IPV6 |
|
293 |
- if(sip_ip.find('.') != string::npos) |
|
294 |
- hostName += sip_ip; |
|
295 |
- else |
|
296 |
- hostName += "[" + sip_ip + "]"; |
|
297 |
-#else |
|
298 |
- hostName += sip_ip; |
|
299 |
-#endif |
|
279 |
+ contact_uri = SIP_HDR_COLSP(SIP_HDR_CONTACT) "<sip:"; |
|
300 | 280 |
|
301 |
- if(! sip_port.empty()) |
|
302 |
- hostName += ":" + sip_port; |
|
281 |
+ if(!user.empty()) { |
|
282 |
+ contact_uri += user + "@"; |
|
283 |
+ } |
|
284 |
+ |
|
285 |
+ contact_uri += AmConfig::LocalSIPIP + ":"; |
|
286 |
+ contact_uri += AmConfig::LocalSIPPort; |
|
287 |
+ contact_uri += CRLF; |
|
303 | 288 |
} |
304 | 289 |
|
305 |
- string uri = AmServer::getContact(/*display name*/"", userName, hostName, |
|
306 |
- /*uri params*/"", /*hdrs params*/""); |
|
307 |
- |
|
308 |
- string res = SIP_HDR_COLSP(SIP_HDR_CONTACT) + uri + CRLF; |
|
309 |
- |
|
310 |
- // save contact_uri for subsequent contact header |
|
311 |
- // only if sip_ip is known |
|
312 |
- if (!sip_ip.empty()) |
|
313 |
- contact_uri = res; |
|
314 |
- |
|
315 |
- return res; |
|
290 |
+ return contact_uri; |
|
316 | 291 |
} |
317 | 292 |
|
318 | 293 |
int AmSipDialog::reply(const AmSipRequest& req, |
... | ... |
@@ -347,13 +322,14 @@ int AmSipDialog::reply(const AmSipRequest& req, |
347 | 322 |
if ((req.method!="CANCEL")&& |
348 | 323 |
!((req.method=="BYE")&&(code<300))) |
349 | 324 |
reply.contact = getContactHdr(); |
325 |
+ |
|
350 | 326 |
reply.content_type = content_type; |
351 | 327 |
reply.body = body; |
352 | 328 |
|
353 | 329 |
if(updateStatusReply(req,code)) |
354 | 330 |
return -1; |
355 | 331 |
|
356 |
- return AmServer::sendReply(reply); |
|
332 |
+ return SipCtrlInterface::send(reply); |
|
357 | 333 |
} |
358 | 334 |
|
359 | 335 |
/* static */ |
... | ... |
@@ -372,7 +348,7 @@ int AmSipDialog::reply_error(const AmSipRequest& req, unsigned int code, |
372 | 348 |
if (AmConfig::Signature.length()) |
373 | 349 |
reply.hdrs += SIP_HDR_COLSP(SIP_HDR_SERVER) + AmConfig::Signature + CRLF; |
374 | 350 |
|
375 |
- return AmServer::sendReply(reply); |
|
351 |
+ return SipCtrlInterface::send(reply); |
|
376 | 352 |
} |
377 | 353 |
|
378 | 354 |
|
... | ... |
@@ -567,7 +543,7 @@ int AmSipDialog::cancel() |
567 | 543 |
req.serKey = string(serKey, serKeyLen); |
568 | 544 |
char empty[MAX_SER_KEY_LEN]; |
569 | 545 |
unsigned int unused = 0; |
570 |
- return AmServer::sendRequest(req, empty, unused) ? 0 : -1; |
|
546 |
+ return SipCtrlInterface::send(req, empty, unused) ? 0 : -1; |
|
571 | 547 |
} |
572 | 548 |
|
573 | 549 |
int AmSipDialog::sendRequest(const string& method, |
... | ... |
@@ -622,7 +598,7 @@ int AmSipDialog::sendRequest(const string& method, |
622 | 598 |
req.body = body; |
623 | 599 |
} |
624 | 600 |
|
625 |
- if (AmServer::sendRequest(req, serKey, serKeyLen)) |
|
601 |
+ if (SipCtrlInterface::send(req, serKey, serKeyLen)) |
|
626 | 602 |
return -1; |
627 | 603 |
|
628 | 604 |
uac_trans[cseq] = AmSipTransaction(method,cseq); |
... | ... |
@@ -749,7 +725,7 @@ int AmSipDialog::send_200_ack(const AmSipTransaction& t, |
749 | 725 |
req.body = body; |
750 | 726 |
} |
751 | 727 |
|
752 |
- if (AmServer::sendRequest(req, serKey, serKeyLen)) |
|
728 |
+ if (SipCtrlInterface::send(req, serKey, serKeyLen)) |
|
753 | 729 |
return -1; |
754 | 730 |
|
755 | 731 |
return 0; |
... | ... |
@@ -33,7 +33,6 @@ SET (sems_SRCS |
33 | 33 |
AmRtpReceiver.cpp |
34 | 34 |
AmRtpStream.cpp |
35 | 35 |
AmSdp.cpp |
36 |
- AmServer.cpp |
|
37 | 36 |
AmSession.cpp |
38 | 37 |
AmSessionContainer.cpp |
39 | 38 |
AmSessionEventHandler.cpp |
... | ... |
@@ -48,6 +47,7 @@ SET (sems_SRCS |
48 | 47 |
LowcFE.cpp |
49 | 48 |
log.cpp |
50 | 49 |
sems.cpp |
50 |
+ SipCtrlInterface.cpp |
|
51 | 51 |
) |
52 | 52 |
|
53 | 53 |
set (audio_files |
... | ... |
@@ -2,16 +2,18 @@ NAME=sems |
2 | 2 |
LIBNAME=sems.so |
3 | 3 |
|
4 | 4 |
PLUGIN_DIR=plug-in |
5 |
+SIP_STACK_DIR=sip |
|
6 |
+ |
|
5 | 7 |
SRCS=$(filter-out $(NAME).cpp, $(wildcard *.cpp)) |
6 | 8 |
HDRS=$(SRCS:.cpp=.h) |
7 |
-OBJS=$(SRCS:.cpp=.o) |
|
9 |
+OBJS=$(SRCS:.cpp=.o) sip/sip_stack.a |
|
8 | 10 |
DEPS=$(SRCS:.cpp=.d) $(NAME).d |
9 | 11 |
AUDIO_FILES=$(notdir $(wildcard wav/*.wav)) |
10 | 12 |
|
11 |
- |
|
12 | 13 |
.PHONY: all |
13 | 14 |
all: ../Makefile.defs |
14 |
- -@$(MAKE) deps && \ |
|
15 |
+ -@$(MAKE) sip_stack && \ |
|
16 |
+ $(MAKE) deps && \ |
|
15 | 17 |
$(MAKE) $(NAME) && \ |
16 | 18 |
$(MAKE) modules |
17 | 19 |
|
... | ... |
@@ -22,9 +24,17 @@ clean: |
22 | 24 |
rm -f lib/*.so compat/getos compat/getarch |
23 | 25 |
$(MAKE) -C $(PLUGIN_DIR) clean |
24 | 26 |
|
27 |
+.PHONY: sip_stack |
|
28 |
+sip_stack: |
|
29 |
+ -@echo "" |
|
30 |
+ -@echo "making SIP stack" |
|
31 |
+ -@cd $(SIP_STACK_DIR); $(MAKE) all |
|
32 |
+ |
|
25 | 33 |
.PHONY: modules |
26 | 34 |
modules: |
27 |
- cd $(PLUGIN_DIR); $(MAKE) modules |
|
35 |
+ -@echo "" |
|
36 |
+ -@echo "making core modules" |
|
37 |
+ -@cd $(PLUGIN_DIR); $(MAKE) modules |
|
28 | 38 |
|
29 | 39 |
.PHONY: deps |
30 | 40 |
deps: $(DEPS) |
... | ... |
@@ -37,15 +47,16 @@ include ../Makefile.defs |
37 | 47 |
%.o : %.cpp %.d ../Makefile.defs |
38 | 48 |
$(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) |
39 | 49 |
|
40 |
-%.d : %.cpp %.h Makefile ../Makefile.defs |
|
50 |
+%.d : %.cpp %.h ../Makefile.defs |
|
41 | 51 |
$(CXX) -MM $< $(CPPFLAGS) $(CXXFLAGS) > $@ |
42 | 52 |
|
43 | 53 |
$(NAME): $(NAME).o $(OBJS) ../Makefile.defs |
54 |
+ -@echo "" |
|
55 |
+ -@echo "making $(NAME) executable" |
|
44 | 56 |
$(LD) -o $(NAME) $(NAME).o $(OBJS) $(LDFLAGS) $(EXTRA_LDFLAGS) |
45 | 57 |
|
46 | 58 |
install: all mk-install-dirs \ |
47 | 59 |
install-audio \ |
48 |
- install-doc \ |
|
49 | 60 |
install-modules-cfg \ |
50 | 61 |
install-cfg \ |
51 | 62 |
install-bin \ |
... | ... |
@@ -101,10 +112,6 @@ install-audio: $(DESTDIR)$(audio-prefix)/$(audio-dir) |
101 | 112 |
fi ; \ |
102 | 113 |
done |
103 | 114 |
|
104 |
-install-doc: $(DESTDIR)$(doc-prefix)/$(doc-dir) |
|
105 |
- $(INSTALL-TOUCH) $(DESTDIR)$(doc-prefix)/$(doc-dir)README |
|
106 |
- $(INSTALL-DOC) ../README $(DESTDIR)$(doc-prefix)/$(doc-dir) |
|
107 |
- |
|
108 | 115 |
dist: tar |
109 | 116 |
|
110 | 117 |
tar: |
111 | 118 |
similarity index 79% |
112 | 119 |
rename from core/plug-in/sipctrl/SipCtrlInterface.cpp |
113 | 120 |
rename to core/SipCtrlInterface.cpp |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
2 |
+ * $Id: SipCtrlInterface.cpp 1648 2010-03-03 19:35:22Z sayer $ |
|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007 Raphael Coeffic |
5 | 5 |
* |
... | ... |
@@ -29,24 +29,21 @@ |
29 | 29 |
#include "AmUtils.h" |
30 | 30 |
#include "AmSipMsg.h" |
31 | 31 |
|
32 |
-#include "trans_layer.h" |
|
33 |
-#include "sip_parser.h" |
|
34 |
-#include "parse_header.h" |
|
35 |
-#include "parse_from_to.h" |
|
36 |
-#include "parse_cseq.h" |
|
37 |
-#include "hash_table.h" |
|
38 |
-#include "sip_trans.h" |
|
39 |
-#include "wheeltimer.h" |
|
40 |
-#include "msg_hdrs.h" |
|
41 |
- |
|
42 |
-#include "udp_trsp.h" |
|
32 |
+#include "sip/trans_layer.h" |
|
33 |
+#include "sip/sip_parser.h" |
|
34 |
+#include "sip/parse_header.h" |
|
35 |
+#include "sip/parse_from_to.h" |
|
36 |
+#include "sip/parse_cseq.h" |
|
37 |
+#include "sip/hash_table.h" |
|
38 |
+#include "sip/sip_trans.h" |
|
39 |
+#include "sip/wheeltimer.h" |
|
40 |
+#include "sip/msg_hdrs.h" |
|
41 |
+#include "sip/udp_trsp.h" |
|
43 | 42 |
|
44 | 43 |
#include "log.h" |
45 | 44 |
|
46 | 45 |
#include <assert.h> |
47 | 46 |
|
48 |
-#ifndef _STANDALONE |
|
49 |
- |
|
50 | 47 |
#include "AmApi.h" |
51 | 48 |
#include "AmConfigReader.h" |
52 | 49 |
#include "AmSipDispatcher.h" |
... | ... |
@@ -55,30 +52,16 @@ |
55 | 52 |
#define MOD_NAME "sipctrl" |
56 | 53 |
#endif |
57 | 54 |
|
58 |
-EXPORT_CONTROL_INTERFACE_FACTORY(SipCtrlInterfaceFactory,MOD_NAME); |
|
59 |
- |
|
60 |
-string SipCtrlInterfaceFactory::outbound_host = ""; |
|
61 |
-unsigned int SipCtrlInterfaceFactory::outbound_port = 0; |
|
62 |
-bool SipCtrlInterfaceFactory::accept_fr_without_totag = false; |
|
63 |
-int SipCtrlInterfaceFactory::log_raw_messages = 3; |
|
64 |
-bool SipCtrlInterfaceFactory::log_parsed_messages = true; |
|
65 |
- |
|
66 |
-AmCtrlInterface* SipCtrlInterfaceFactory::instance() |
|
67 |
-{ |
|
68 |
- SipCtrlInterface* ctrl = new SipCtrlInterface(bind_addr,bind_port); |
|
69 |
- trans_layer::instance()->register_ua(ctrl); |
|
70 |
- |
|
71 |
- return ctrl; |
|
72 |
-} |
|
55 |
+string SipCtrlInterface::outbound_host = ""; |
|
56 |
+unsigned int SipCtrlInterface::outbound_port = 0; |
|
57 |
+bool SipCtrlInterface::accept_fr_without_totag = false; |
|
58 |
+int SipCtrlInterface::log_raw_messages = 3; |
|
59 |
+bool SipCtrlInterface::log_parsed_messages = true; |
|
73 | 60 |
|
74 |
-int SipCtrlInterfaceFactory::onLoad() |
|
61 |
+int SipCtrlInterface::load() |
|
75 | 62 |
{ |
76 |
- |
|
77 |
- bind_addr = AmConfig::LocalSIPIP; |
|
78 |
- bind_port = AmConfig::LocalSIPPort; |
|
79 |
- |
|
80 |
- INFO("SIP bind_addr: `%s'.\n", bind_addr.c_str()); |
|
81 |
- INFO("SIP bind_port: `%i'.\n", bind_port); |
|
63 |
+ INFO("SIP bind_addr: `%s'.\n", AmConfig::LocalSIPIP.c_str()); |
|
64 |
+ INFO("SIP bind_port: `%i'.\n", AmConfig::LocalSIPPort); |
|
82 | 65 |
|
83 | 66 |
if (!AmConfig::OutboundProxy.empty()) { |
84 | 67 |
sip_uri parsed_uri; |
... | ... |
@@ -87,20 +70,20 @@ int SipCtrlInterfaceFactory::onLoad() |
87 | 70 |
ERROR("invalid outbound_proxy specified\n"); |
88 | 71 |
return -1; |
89 | 72 |
} |
90 |
- SipCtrlInterfaceFactory::outbound_host = c2stlstr(parsed_uri.host); |
|
73 |
+ outbound_host = c2stlstr(parsed_uri.host); |
|
91 | 74 |
if (parsed_uri.port) { |
92 |
- SipCtrlInterfaceFactory::outbound_port = parsed_uri.port; |
|
75 |
+ outbound_port = parsed_uri.port; |
|
93 | 76 |
} |
94 | 77 |
} |
95 | 78 |
|
96 | 79 |
AmConfigReader cfg; |
97 |
- string cfgfile = AmConfig::ModConfigPath + string(MOD_NAME ".conf"); |
|
80 |
+ string cfgfile = AmConfig::ConfigurationFile.c_str(); |
|
98 | 81 |
if (file_exists(cfgfile) && !cfg.loadFile(cfgfile)) { |
99 | 82 |
if (cfg.hasParameter("accept_fr_without_totag")) { |
100 | 83 |
accept_fr_without_totag = |
101 | 84 |
cfg.getParameter("accept_fr_without_totag") == "yes"; |
102 | 85 |
} |
103 |
- DBG("sipctrl: accept_fr_without_totag = %s\n", |
|
86 |
+ DBG("accept_fr_without_totag = %s\n", |
|
104 | 87 |
accept_fr_without_totag?"yes":"no"); |
105 | 88 |
|
106 | 89 |
if (cfg.hasParameter("log_raw_messages")) { |
... | ... |
@@ -111,13 +94,13 @@ int SipCtrlInterfaceFactory::onLoad() |
111 | 94 |
else if (msglog == "info") log_raw_messages = 2; |
112 | 95 |
else if (msglog == "debug") log_raw_messages = 3; |
113 | 96 |
} |
114 |
- DBG("sipctrl: log_raw_messages level = %d\n", |
|
97 |
+ DBG("log_raw_messages level = %d\n", |
|
115 | 98 |
log_raw_messages); |
116 | 99 |
|
117 | 100 |
if (cfg.hasParameter("log_parsed_messages")) { |
118 | 101 |
log_parsed_messages = cfg.getParameter("log_parsed_messages")=="yes"; |
119 | 102 |
} |
120 |
- DBG("sipctrl: log_parsed_messages = %s\n", |
|
103 |
+ DBG("log_parsed_messages = %s\n", |
|
121 | 104 |
log_parsed_messages?"yes":"no"); |
122 | 105 |
|
123 | 106 |
} else { |
... | ... |
@@ -128,12 +111,9 @@ int SipCtrlInterfaceFactory::onLoad() |
128 | 111 |
|
129 | 112 |
} |
130 | 113 |
|
131 |
-#endif // #ifndef _STANDALONE |
|
132 |
- |
|
133 |
-SipCtrlInterface::SipCtrlInterface(const string& bind_addr, unsigned short bind_port) |
|
134 |
- : bind_addr(bind_addr), bind_port(bind_port) |
|
114 |
+SipCtrlInterface::SipCtrlInterface() |
|
135 | 115 |
{ |
136 |
- tl = trans_layer::instance(); |
|
116 |
+ trans_layer::instance()->register_ua(this); |
|
137 | 117 |
} |
138 | 118 |
|
139 | 119 |
int SipCtrlInterface::cancel(const AmSipRequest& req) |
... | ... |
@@ -147,61 +127,9 @@ int SipCtrlInterface::cancel(const AmSipRequest& req) |
147 | 127 |
return -1; |
148 | 128 |
} |
149 | 129 |
|
150 |
- return tl->cancel(get_trans_bucket(h),(sip_trans*)t); |
|
130 |
+ return trans_layer::instance()->cancel(get_trans_bucket(h),(sip_trans*)t); |
|
151 | 131 |
} |
152 | 132 |
|
153 |
-#ifndef _STANDALONE |
|
154 |
- |
|
155 |
-string SipCtrlInterface::getContact(const string &displayName, |
|
156 |
- const string &userName, const string &hostName, |
|
157 |
- const string &uriParams, const string &hdrParams) |
|
158 |
-{ |
|
159 |
- string localUri; |
|
160 |
- |
|
161 |
- if (displayName.length()) { |
|
162 |
- // quoting is safer (the check for quote need doesn't really pay off) |
|
163 |
- if (displayName.c_str()[0] == '"') { |
|
164 |
- assert(displayName.c_str()[displayName.length() - 1] == '"'); |
|
165 |
- localUri += displayName; |
|
166 |
- } else { |
|
167 |
- localUri += '"'; |
|
168 |
- localUri += displayName; |
|
169 |
- localUri += '"'; |
|
170 |
- } |
|
171 |
- localUri += " "; |
|
172 |
- } |
|
173 |
- |
|
174 |
- // angular brackets not always needed (unless contact) |
|
175 |
- localUri += "<"; |
|
176 |
- localUri += "sip:"; //TODO: sips|tel|tels |
|
177 |
- if (userName.length()) { |
|
178 |
- localUri += userName; |
|
179 |
- localUri += "@"; |
|
180 |
- } |
|
181 |
- if (hostName.length()) |
|
182 |
- localUri += hostName; |
|
183 |
- else { |
|
184 |
- |
|
185 |
- localUri += AmConfig::LocalSIPIP; |
|
186 |
- localUri += ":" + int2str(AmConfig::LocalSIPPort); |
|
187 |
- } |
|
188 |
- |
|
189 |
- if (uriParams.length()) { |
|
190 |
- if (uriParams.c_str()[0] != ';') |
|
191 |
- localUri += ';'; |
|
192 |
- localUri += uriParams; |
|
193 |
- } |
|
194 |
- localUri += ">"; |
|
195 |
- |
|
196 |
- if (hdrParams.length()) { |
|
197 |
- if (hdrParams.c_str()[0] != ';') |
|
198 |
- localUri += ';'; |
|
199 |
- localUri += hdrParams; |
|
200 |
- } |
|
201 |
- |
|
202 |
- return localUri; |
|
203 |
-} |
|
204 |
-#endif |
|
205 | 133 |
|
206 | 134 |
int SipCtrlInterface::send(const AmSipRequest &req, char* serKey, unsigned int& serKeyLen) |
207 | 135 |
{ |
... | ... |
@@ -326,8 +254,8 @@ int SipCtrlInterface::send(const AmSipRequest &req, char* serKey, unsigned int& |
326 | 254 |
req.next_hop.length()) < 0) { |
327 | 255 |
ERROR("invalid next hop URI '%s'\n", req.next_hop.c_str()); |
328 | 256 |
ERROR("Using default outbound proxy"); |
329 |
- next_hop = SipCtrlInterfaceFactory::outbound_host; |
|
330 |
- next_port_i = SipCtrlInterfaceFactory::outbound_port; |
|
257 |
+ next_hop = SipCtrlInterface::outbound_host; |
|
258 |
+ next_port_i = SipCtrlInterface::outbound_port; |
|
331 | 259 |
} else { |
332 | 260 |
next_hop = c2stlstr(parsed_uri.host); |
333 | 261 |
if (parsed_uri.port) { |
... | ... |
@@ -335,36 +263,34 @@ int SipCtrlInterface::send(const AmSipRequest &req, char* serKey, unsigned int& |
335 | 263 |
next_hop += *(c++); |
336 | 264 |
} |
337 | 265 |
} |
338 |
- else if(!SipCtrlInterfaceFactory::outbound_host.empty()){ |
|
339 |
- next_hop = SipCtrlInterfaceFactory::outbound_host; |
|
340 |
- next_port_i = SipCtrlInterfaceFactory::outbound_port; |
|
266 |
+ else if(!SipCtrlInterface::outbound_host.empty()){ |
|
267 |
+ next_hop = SipCtrlInterface::outbound_host; |
|
268 |
+ next_port_i = SipCtrlInterface::outbound_port; |
|
341 | 269 |
} |
342 | 270 |
|
343 | 271 |
cstring c_next_hop = stl2cstr(next_hop); |
344 |
- if(tl->set_next_hop(msg->route,msg->u.request->ruri_str, |
|
272 |
+ if(trans_layer::instance()->set_next_hop(msg->route,msg->u.request->ruri_str, |
|
345 | 273 |
c_next_hop,(unsigned short)next_port_i, |
346 | 274 |
&msg->remote_ip) < 0){ |
347 |
- // TODO: error handling |
|
275 |
+ |
|
348 | 276 |
DBG("set_next_hop failed\n"); |
349 | 277 |
delete msg; |
350 | 278 |
return -1; |
351 | 279 |
} |
352 | 280 |
|
353 |
- int res = tl->send_request(msg,serKey,serKeyLen); |
|
281 |
+ int res = trans_layer::instance()->send_request(msg,serKey,serKeyLen); |
|
354 | 282 |
delete msg; |
355 | 283 |
|
356 | 284 |
return res; |
357 | 285 |
} |
358 | 286 |
|
359 |
-void SipCtrlInterface::run() |
|
287 |
+void SipCtrlInterface::run(const string& bind_addr, unsigned short bind_port) |
|
360 | 288 |
{ |
361 | 289 |
INFO("Starting SIP control interface\n"); |
362 | 290 |
|
363 |
- udp_trsp* udp_server = new udp_trsp(tl); |
|
364 |
- |
|
365 |
- assert(tl); |
|
366 |
- tl->register_transport(udp_server); |
|
291 |
+ udp_trsp* udp_server = new udp_trsp(trans_layer::instance()); |
|
367 | 292 |
|
293 |
+ trans_layer::instance()->register_transport(udp_server); |
|
368 | 294 |
udp_server->bind(bind_addr,bind_port); |
369 | 295 |
|
370 | 296 |
wheeltimer::instance()->start(); |
... | ... |
@@ -434,7 +360,7 @@ int SipCtrlInterface::send(const AmSipReply &rep) |
434 | 360 |
} |
435 | 361 |
} |
436 | 362 |
|
437 |
- int ret = tl->send_reply(get_trans_bucket(h),(sip_trans*)t, |
|
363 |
+ int ret = trans_layer::instance()->send_reply(get_trans_bucket(h),(sip_trans*)t, |
|
438 | 364 |
rep.code,stl2cstr(rep.reason), |
439 | 365 |
stl2cstr(rep.local_tag), |
440 | 366 |
cstring(hdrs_buf,hdrs_len), stl2cstr(rep.body)); |
... | ... |
@@ -450,7 +376,7 @@ int SipCtrlInterface::send(const AmSipReply &rep) |
450 | 376 |
void SipCtrlInterface::handleSipMsg(AmSipRequest &req) |
451 | 377 |
{ |
452 | 378 |
DBG("Received new request\n"); |
453 |
- if (SipCtrlInterfaceFactory::log_parsed_messages) { |
|
379 |
+ if (SipCtrlInterface::log_parsed_messages) { |
|
454 | 380 |
// DBG_PARAM(req.cmd); |
455 | 381 |
DBG_PARAM(req.method); |
456 | 382 |
// DBG_PARAM(req.user); |
457 | 383 |
similarity index 63% |
458 | 384 |
rename from core/plug-in/sipctrl/SipCtrlInterface.h |
459 | 385 |
rename to core/SipCtrlInterface.h |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
2 |
+ * $Id: SipCtrlInterface.h 1048 2008-07-15 18:48:07Z sayer $ |
|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007 Raphael Coeffic |
5 | 5 |
* |
... | ... |
@@ -27,7 +27,8 @@ |
27 | 27 |
#ifndef _SipCtrlInterface_h_ |
28 | 28 |
#define _SipCtrlInterface_h_ |
29 | 29 |
|
30 |
-#include "sip_ua.h" |
|
30 |
+#include "sip/sip_ua.h" |
|
31 |
+#include "AmThread.h" |
|
31 | 32 |
|
32 | 33 |
#include <string> |
33 | 34 |
#include <list> |
... | ... |
@@ -37,97 +38,53 @@ using std::list; |
37 | 38 |
class AmSipRequest; |
38 | 39 |
class AmSipReply; |
39 | 40 |
|
40 |
-//class udp_trsp; |
|
41 | 41 |
class trans_layer; |
42 | 42 |
class trans_bucket; |
43 | 43 |
struct sip_msg; |
44 | 44 |
struct sip_header; |
45 | 45 |
|
46 |
-#ifndef _STANDALONE |
|
47 |
- |
|
48 |
-#include "AmApi.h" |
|
49 |
- |
|
50 |
-class SipCtrlInterfaceFactory: public AmCtrlInterfaceFactory |
|
51 |
-{ |
|
52 |
- string bind_addr; |
|
53 |
- unsigned short bind_port; |
|
54 |
- |
|
55 |
-public: |
|
56 |
- |
|
57 |
- static string outbound_host; |
|
58 |
- static unsigned int outbound_port; |
|
59 |
- |
|
60 |
- static bool accept_fr_without_totag; |
|
61 |
- static int log_raw_messages; |
|
62 |
- static bool log_parsed_messages; |
|
63 |
- |
|
64 |
- SipCtrlInterfaceFactory(const string& name): AmCtrlInterfaceFactory(name) {} |
|
65 |
- ~SipCtrlInterfaceFactory() {} |
|
66 |
- |
|
67 |
- int onLoad(); |
|
68 |
- |
|
69 |
- AmCtrlInterface* instance(); |
|
70 |
-}; |
|
71 |
- |
|
72 |
-#else |
|
73 |
- |
|
74 |
-#include "AmThread.h" |
|
75 |
- |
|
76 |
-#endif |
|
77 |
- |
|
78 |
- |
|
79 |
-class SipCtrlInterface: |
|
80 |
- |
|
81 |
-#ifndef _STANDALONE |
|
82 |
- public AmCtrlInterface, |
|
83 |
-#else |
|
84 |
- public AmThread, |
|
85 |
-#endif |
|
86 |
- |
|
46 |
+class SipCtrlInterface: |
|
87 | 47 |
public sip_ua |
88 | 48 |
{ |
89 |
- string bind_addr; |
|
90 |
- unsigned short bind_port; |
|
91 |
- |
|
92 |
- //udp_trsp* udp_server; |
|
93 |
- |
|
94 |
- trans_layer* tl; |
|
95 |
- |
|
96 |
- |
|
49 |
+ static string outbound_host; |
|
50 |
+ static unsigned int outbound_port; |
|
51 |
+ static bool log_parsed_messages; |
|
52 |
+ static int log_raw_messages; |
|
53 |
+ static bool accept_fr_without_totag; |
|
54 |
+ |
|
55 |
+ //string bind_addr; |
|
56 |
+ //unsigned short bind_port; |
|
57 |
+ |
|
97 | 58 |
void prepare_routes_uac(const list<sip_header*>& routes, string& route_field); |
98 | 59 |
void prepare_routes_uas(const list<sip_header*>& routes, string& route_field); |
99 |
- int cancel(const AmSipRequest& req); |
|
100 |
- |
|
101 |
-protected: |
|
102 |
- void run(); |
|
103 |
- void on_stop() {} |
|
60 |
+ static int cancel(const AmSipRequest& req); |
|
104 | 61 |
|
105 | 62 |
public: |
106 |
- SipCtrlInterface(const string& bind_addr, unsigned short bind_port); |
|
63 |
+ SipCtrlInterface(); |
|
107 | 64 |
~SipCtrlInterface(){} |
65 |
+ |
|
66 |
+ int load(); |
|
67 |
+ |
|
68 |
+ void run(const string& bind_addr, unsigned short bind_port); |
|
108 | 69 |
|
109 | 70 |
/** |
110 | 71 |
* From AmCtrlInterface |
111 | 72 |
*/ |
112 |
- int send(const AmSipRequest &req, char* serKey, unsigned int& serKeyLen); |
|
113 |
- int send(const AmSipReply &rep); |
|
73 |
+ static int send(const AmSipRequest &req, char* serKey, unsigned int& serKeyLen); |
|
74 |
+ static int send(const AmSipReply &rep); |
|
114 | 75 |
|
115 |
-#ifndef _STANDALONE |
|
116 | 76 |
string getContact(const string &displayName, |
117 | 77 |
const string &userName, const string &hostName, |
118 | 78 |
const string &uriParams, const string &hdrParams); |
119 |
-#endif |
|
120 | 79 |
|
121 | 80 |
void handleSipMsg(AmSipRequest &req); |
122 | 81 |
void handleSipMsg(AmSipReply &rep); |
123 |
- |
|
124 | 82 |
|
125 | 83 |
/** |
126 | 84 |
* From sip_ua |
127 | 85 |
*/ |
128 | 86 |
void handle_sip_request(const char* tid, sip_msg* msg); |
129 | 87 |
void handle_sip_reply(sip_msg* msg); |
130 |
- |
|
131 | 88 |
}; |
132 | 89 |
|
133 | 90 |
|
18 | 17 |
deleted file mode 100644 |
... | ... |
@@ -1,29 +0,0 @@ |
1 |
-set (sipctrl_SRCS |
|
2 |
- SipCtrlInterface.cpp |
|
3 |
- hash.cpp |
|
4 |
- hash_table.cpp |
|
5 |
- main.cpp |
|
6 |
- msg_fline.cpp |
|
7 |
- msg_hdrs.cpp |
|
8 |
- parse_common.cpp |
|
9 |
- parse_cseq.cpp |
|
10 |
- parse_from_to.cpp |
|
11 |
- parse_header.cpp |
|
12 |
- parse_uri.cpp |
|
13 |
- parse_via.cpp |
|
14 |
- resolver.cpp |
|
15 |
- sip_parser.cpp |
|
16 |
- sip_trans.cpp |
|
17 |
- trans_layer.cpp |
|
18 |
- transport.cpp |
|
19 |
- udp_trsp.cpp |
|
20 |
- wheeltimer.cpp |
|
21 |
-) |
|
22 |
- |
|
23 |
-IF(SEMS_USE_IPV6) |
|
24 |
- ADD_DEFINITIONS(-DSUPPORT_IPV6) |
|
25 |
-ENDIF(SEMS_USE_IPV6) |
|
26 |
- |
|
27 |
-SET(sems_module_name sipctrl) |
|
28 |
-INCLUDE(${CMAKE_SOURCE_DIR}/cmake/module.rules.txt) |
|
29 |
-INCLUDE(${CMAKE_SOURCE_DIR}/cmake/config.rules.txt) |
30 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,13 +0,0 @@ |
1 |
-COREPATH =../.. |
|
2 |
-plug_in_name = sipctrl |
|
3 |
- |
|
4 |
-module_ldflags = |
|
5 |
-module_cflags = -DMOD_NAME=\"$(plug_in_name)\" |
|
6 |
- |
|
7 |
-%.o : %.c %.d |
|
8 |
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ |
|
9 |
- |
|
10 |
-%.d : %.c %.h Makefile |
|
11 |
- $(CC) -MM $< $(CFLAGS) $(CPPFLAGS) > $@ |
|
12 |
- |
|
13 |
-include ../Makefile.app_module |
14 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,59 +0,0 @@ |
1 |
- |
|
2 |
-NAME = sip_parser |
|
3 |
- |
|
4 |
-SRCS = main.cpp \ |
|
5 |
- log.cpp \ |
|
6 |
- sip_parser.cpp \ |
|
7 |
- parse_uri.cpp \ |
|
8 |
- parse_header.cpp \ |
|
9 |
- parse_common.cpp \ |
|
10 |
- parse_via.cpp \ |
|
11 |
- parse_from_to.cpp \ |
|
12 |
- parse_cseq.cpp \ |
|
13 |
- msg_fline.cpp \ |
|
14 |
- msg_hdrs.cpp \ |
|
15 |
- hash_table.cpp \ |
|
16 |
- hash.cpp \ |
|
17 |
- trans_layer.cpp \ |
|
18 |
- transport.cpp \ |
|
19 |
- udp_trsp.cpp \ |
|
20 |
- resolver.cpp \ |
|
21 |
- wheeltimer.cpp \ |
|
22 |
- sip_trans.cpp \ |
|
23 |
- SipCtrlInterface.cpp \ |
|
24 |
- ../../AmThread.cpp \ |
|
25 |
- ../../AmUtils.cpp \ |
|
26 |
- ../../AmSipMsg.cpp |
|
27 |
- |
|
28 |
-CORE_PATH ?= ../.. |
|
29 |
- |
|
30 |
-OBJS = $(SRCS:.cpp=.o) |
|
31 |
-DEPS = $(SRCS:.cpp=.d) |
|
32 |
- |
|
33 |
-CXXFLAGS += -g -I $(CORE_PATH) |
|
34 |
-LDFLAGS += -lpthread -g |
|
35 |
-CPPFLAGS += -D_DEBUG -D_STANDALONE |
|
36 |
- |
|
37 |
-all: |
|
38 |
- -@$(MAKE) deps && \ |
|
39 |
- $(MAKE) sip_parser |
|
40 |
- |
|
41 |
-clean: |
|
42 |
- rm -f *.o *.d $(NAME) |
|
43 |
- |
|
44 |
-deps: $(DEPS) |
|
45 |
- |
|
46 |
- |
|
47 |
-$(NAME): $(OBJS) |
|
48 |
- $(CXX) -o $@ $(LDFLAGS) $(OBJS) |
|
49 |
- |
|
50 |
-%.o: %.cpp %.d |
|
51 |
- $(CXX) -o $@ -c $< $(CPPFLAGS) $(CXXFLAGS) |
|
52 |
- |
|
53 |
-%.d: %.cpp Makefile |
|
54 |
- $(CXX) -MM -MT '$@ $(@:.d=.o)' $< $(CPPFLAGS) $(CXXFLAGS) > $@ |
|
55 |
- |
|
56 |
- |
|
57 |
-ifeq '$(MAKECMDGOALS)' '$(NAME)' |
|
58 |
-include $(DEPS) |
|
59 |
-endif |
|
60 | 0 |
\ No newline at end of file |
61 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,16 +0,0 @@ |
1 |
- |
|
2 |
-- (50%) add timers |
|
3 |
- - (99% ?) code timer routine (Mikkel) |
|
4 |
- - (0%) integrate timers into the transaction layer. |
|
5 |
- |
|
6 |
-- (0%) automatically add headers like 'Max-Forward: ' ? |
|
7 |
- |
|
8 |
-- (0%) transport resolver (multiple transports per proto/ip) |
|
9 |
- |
|
10 |
-- (100%) support record-routing |
|
11 |
- -> (100%) copy route header |
|
12 |
- -> (100%) compute next hop (w. RR, RURI, contact) |
|
13 |
- |
|
14 |
-- (100%) generate correct via |
|
15 |
- |
|
16 |
-- (100%) send 200 ACK |
17 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,22 +0,0 @@ |
1 |
-# |
|
2 |
-# Some finer grained SIP stack settings. |
|
3 |
-# |
|
4 |
- |
|
5 |
-# |
|
6 |
-# Accept final replies without To-tag? [yes|no] |
|
7 |
-# |
|
8 |
-#accept_fr_without_totag=yes |
|
9 |
- |
|
10 |
-# |
|
11 |
-# Log raw messages? [no|debug|info|warn|error] |
|
12 |
-# |
|
13 |
-# Default: debug |
|
14 |
-# |
|
15 |
-#log_raw_messages=no |
|
16 |
- |
|
17 |
-# |
|
18 |
-# Log parsed received messages? [yes|no] |
|
19 |
-# |
|
20 |
-# Default: yes |
|
21 |
-# |
|
22 |
-#log_parsed_messages=no |
23 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,160 +0,0 @@ |
1 |
-/* |
|
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * Copyright (C) 2007 Raphael Coeffic |
|
5 |
- * |
|
6 |
- * This file is part of sems, a free SIP media server. |
|
7 |
- * |
|
8 |
- * sems is free software; you can redistribute it and/or modify |
|
9 |
- * it under the terms of the GNU General Public License as published by |
|
10 |
- * the Free Software Foundation; either version 2 of the License, or |
|
11 |
- * (at your option) any later version |
|
12 |
- * |
|
13 |
- * For a license to use the ser software under conditions |
|
14 |
- * other than those described here, or to purchase support for this |
|
15 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
- * info@iptel.org |
|
17 |
- * |
|
18 |
- * sems is distributed in the hope that it will be useful, |
|
19 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
- * GNU General Public License for more details. |
|
22 |
- * |
|
23 |
- * You should have received a copy of the GNU General Public License |
|
24 |
- * along with this program; if not, write to the Free Software |
|
25 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
- */ |
|
27 |
- |
|
28 |
-#include "trans_layer.h" |
|
29 |
-#include "udp_trsp.h" |
|
30 |
- |
|
31 |
-#include "sip_parser.h" |
|
32 |
-#include "parse_header.h" |
|
33 |
-#include "hash_table.h" |
|
34 |
- |
|
35 |
-#include "log.h" |
|
36 |
- |
|
37 |
-#include "SipCtrlInterface.h" |
|
38 |
- |
|
39 |
-#include "AmSipMsg.h" |
|
40 |
-#include "AmUtils.h" |
|
41 |
- |
|
42 |
-#include <signal.h> |
|
43 |
- |
|
44 |
-#define SERVER |
|
45 |
- |
|
46 |
-static void sig_usr(int signo) |
|
47 |
-{ |
|
48 |
- WARN("signal %d received\n", signo); |
|
49 |
- |
|
50 |
- dumps_transactions(); |
|
51 |
- exit(0); |
|
52 |
- |
|
53 |
- return; |
|
54 |
-} |
|
55 |
- |
|
56 |
-int main() |
|
57 |
-{ |
|
58 |
- log_level = 3; |
|
59 |
- log_stderr = 1; |
|
60 |
- |
|
61 |
- //udp_trsp* udp_server = new udp_trsp(tl); |
|
62 |
- SipCtrlInterface* ctrl = new SipCtrlInterface("127.0.0.1",5060); |
|
63 |
- trans_layer::instance()->register_ua(ctrl); |
|
64 |
- |
|
65 |
-#ifndef SERVER |
|
66 |
- char* buf = |
|
67 |
- "REGISTER sip:192.168.0.22 SIP/2.0\r\n" |
|
68 |
- "Via: SIP/2.0/UDP 192.168.0.24:5060;branch=z9hG4bKf3f8ddeb9512414252418e7c18c2f0e;rport\r\n" |
|
69 |
- "From: \"Raphael\" <sip:raf@192.168.0.22>;tag=2239770325\r\n" |
|
70 |
- "To: \"Raphael\" <sip:raf@192.168.0.22>\r\n" |
|
71 |
- "Call-ID: 1199294025@192_168_0_24\r\n" |
|
72 |
- "CSeq: 1 REGISTER\r\n" |
|
73 |
- "Contact: <sip:raf@192.168.0.24:5060>\r\n" |
|
74 |
- "Max-Forwards: 70\r\n" |
|
75 |
- "User-Agent: S450 IP020970000000\r\n" |
|
76 |
- "Expires: 180\r\n" |
|
77 |
- "Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, REFER, SUBSCRIBE, NOTIFY\r\n" |
|
78 |
- "Content-Length: 0\r\n" |
|
79 |
- "\r\n"; |
|
80 |
- |
|
81 |
- char* hdr = "Route: <sip:10.36.2.24;ftag=qvj9pp5vw7;lr=on>\r\n"; |
|
82 |
- |
|
83 |
- char *c = hdr; |
|
84 |
- |
|
85 |
- sip_msg* msg = new sip_msg(); |
|
86 |
- int err = parse_headers(msg,&c); |
|
87 |
- |
|
88 |
- if(err){ |
|
89 |
- ERROR("Route headers parsing failed\n"); |
|
90 |
- ERROR("Faulty headers were: <%s>\n",hdr); |
|
91 |
- return -1; |
|
92 |
- } |
|
93 |
- |
|
94 |
- |
|
95 |
-// char* buf = |
|
96 |
-// "INVITE sip:bob@biloxi.com;user=phone;tti=13;ttl=12?abc=def SIP/2.0\r\n" |
|
97 |
-// "Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\r\n" |
|
98 |
-// "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" |
|
99 |
-// " ;received=192.0.2.1\r\n" |
|
100 |
-// "Max-Forwards: 69\r\n" |
|
101 |
-// "To: Bob <sip:bob@biloxi.com>\r\n" |
|
102 |
-// "From: sip:alice@atlanta.com;tag=1928301774\r\n" |
|
103 |
-// "Call-ID: a84b4c76e66710\r\n" |
|
104 |
-// "CSeq: 314159 INVITE\r\n" |
|
105 |
-// "Contact: <sip:alice@pc33.atlanta.com>\r\n" |
|
106 |
-// "Content-Type: application/sdp\r\n" |
|
107 |
-// "Content-Length: 148\r\n" |
|
108 |
-// "\r\n" |
|
109 |
-// "v=0\r\n" |
|
110 |
-// "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" |
|
111 |
-// "s=-\r\n" |
|
112 |
-// "t=0 0\r\n" |
|
113 |
-// "c=IN IP4 pc33.atlanta.com\r\n" |
|
114 |
-// "m=audio 3456 RTP/AVP 0 1 3 99\r\n" |
|
115 |
-// "a=rtpmap:0 PCMU/8000"; |
|
116 |
- |
|
117 |
- //int buf_len = strlen(buf); |
|
118 |
- //sip_msg* msg = new sip_msg(buf,buf_len); |
|
119 |
- |
|
120 |
- //trans_layer* tl = trans_layer::instance(); |
|
121 |
- //tl->register_ua(ctrl); |
|
122 |
- //tl->received_msg(msg); |
|
123 |
- |
|
124 |
- //delete msg; |
|
125 |
- |
|
126 |
-#else |
|
127 |
- |
|
128 |
- if (signal(SIGINT, sig_usr) == SIG_ERR ) { |
|
129 |
- ERROR("no SIGINT signal handler can be installed\n"); |
|
130 |
- return -1; |
|
131 |
- } |
|
132 |
- |
|
133 |
- ctrl->start(); |
|
134 |
- |
|
135 |
-// sleep(1); |
|
136 |
- |
|
137 |
-// AmSipRequest req; |
|
138 |
-// req.method = "INVITE"; |
|
139 |
-// req.r_uri = "sip:sipp@tinytop:5080"; |
|
140 |
-// req.from = "From: SEMS <sip:sems@tinytop:5060>;tag=" + int2str(getpid()); |
|
141 |
-// //req.from_tag = "12345"; |
|
142 |
-// req.to = "To: SIPP <sip:sipp@tinytop:5070>"; |
|
143 |
-// req.cseq = 10; |
|
144 |
-// req.callid = int2str(getpid()) + "@tinytop"; |
|
145 |
-// req.contact = "Contact: sip:tinytop"; |
|
146 |
-// //req.route = "Route: <sip:localhost:5070;lr=on>;blabla=abc"; |
|
147 |
- |
|
148 |
-// int send_err = ctrl->send(req, req.serKey); |
|
149 |
-// if(send_err < 0) { |
|
150 |
-// ERROR("ctrl->send() failed with error code %i\n",send_err); |
|
151 |
-// } |
|
152 |
- |
|
153 |
- //sleep(10); |
|
154 |
- ctrl->join(); |
|
155 |
- |
|
156 |
-#endif |
|
157 |
- |
|
158 |
- |
|
159 |
- return 0; |
|
160 |
-} |
... | ... |
@@ -30,13 +30,15 @@ |
30 | 30 |
#include "AmConfig.h" |
31 | 31 |
#include "AmPlugIn.h" |
32 | 32 |
#include "AmSessionContainer.h" |
33 |
-#include "AmServer.h" |
|
33 |
+//#include "AmServer.h" |
|
34 | 34 |
#include "AmMediaProcessor.h" |
35 | 35 |
#include "AmRtpReceiver.h" |
36 | 36 |
#include "AmEventDispatcher.h" |
37 | 37 |
|
38 | 38 |
#include "AmZRTP.h" |
39 | 39 |
|
40 |
+#include "SipCtrlInterface.h" |
|
41 |
+ |
|
40 | 42 |
#include "log.h" |
41 | 43 |
|
42 | 44 |
#include <unistd.h> |
... | ... |
@@ -104,7 +106,7 @@ static void sig_usr_un(int signo) |
104 | 106 |
|
105 | 107 |
AmRtpReceiver::dispose(); |
106 | 108 |
|
107 |
- AmServer::dispose(); |
|
109 |
+ //AmServer::dispose(); |
|
108 | 110 |
|
109 | 111 |
AmMediaProcessor::dispose(); |
110 | 112 |
|
... | ... |
@@ -261,7 +263,6 @@ int main(int argc, char* argv[]) |
261 | 263 |
// return -1; |
262 | 264 |
|
263 | 265 |
AmConfig::readConfiguration(); |
264 |
- // semsConfig.warnUnknownParams(); |
|
265 | 266 |
|
266 | 267 |
if(use_args(argv[0], args)){ |
267 | 268 |
print_usage(argv[0]); |
... | ... |
@@ -422,14 +423,10 @@ int main(int argc, char* argv[]) |
422 | 423 |
DBG("Starting RTP receiver\n"); |
423 | 424 |
AmRtpReceiver::instance()->start(); |
424 | 425 |
|
425 |
- if (AmServer::instance()->hasIface()) { |
|
426 |
- AmServer::instance()->run(); |
|
427 |
- } else { |
|
428 |
- ERROR("SEMS cannot start without a control interface plug-in.\n" |
|
429 |
- "The following plug-ins can be used: unixsockctrl, binrpcctrl, and sipctrl.\n" |
|
430 |
- "If SEMS should use its own SIP stack instead of SER's, please load the sipctrl plug-in.\n"); |
|
431 |
- return -1; |
|
432 |
- } |
|
426 |
+ DBG("Starting SIP stack\n"); |
|
427 |
+ SipCtrlInterface sip_ctrl; |
|
428 |
+ sip_ctrl.load(); |
|
429 |
+ sip_ctrl.run(AmConfig::LocalSIPIP,AmConfig::LocalSIPPort); |
|
433 | 430 |
|
434 | 431 |
return 0; |
435 | 432 |
} |
... | ... |
@@ -28,9 +28,9 @@ |
28 | 28 |
#ifndef _ans_machine_h_ |
29 | 29 |
#define _ans_machine_h_ |
30 | 30 |
|
31 |
-#ifndef SEMS_VERSION |
|
32 |
-#include "config.h" |
|
33 |
-#endif |
|
31 |
+#define SEMS_VERSION "1.3.0-dev" |
|
32 |
+#define OS "Darwin" |
|
33 |
+#define ARCH "i386" |
|
34 | 34 |
|
35 | 35 |
#define CONFIG_FILE "/usr/local/etc/sems/sems.conf" |
36 | 36 |
#define MOD_CFG_PATH "/usr/local/etc/sems/etc/" |
... | ... |
@@ -51,6 +51,11 @@ |
51 | 51 |
// session considered dead after 5 minutes no RTP |
52 | 52 |