Author: sayer
Date: 2008-04-30 17:02:22 +0200 (Wed, 30 Apr 2008)
New Revision: 923
Modified:
trunk/core/AmApi.cpp
trunk/core/AmApi.h
trunk/core/AmServer.cpp
trunk/core/AmServer.h
trunk/core/AmSipDialog.cpp
trunk/core/AmSipDialog.h
trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp
trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.h
trunk/core/plug-in/sipctrl/SipCtrlInterface.cpp
trunk/core/plug-in/sipctrl/SipCtrlInterface.h
trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.cpp
trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.h
Log:
serKey allocated in core (fixes strange crashes iff linking with other stuff)
Modified: trunk/core/AmApi.cpp
===================================================================
--- trunk/core/AmApi.cpp 2008-04-30 14:48:42 UTC (rev 922)
+++ trunk/core/AmApi.cpp 2008-04-30 15:02:22 UTC (rev 923)
@@ -104,3 +104,11 @@
: AmPluginFactory(name)
{
}
+
+AmCtrlInterface::AmCtrlInterface()
+{
+}
+
+AmCtrlInterface::~AmCtrlInterface()
+{
+}
Modified: trunk/core/AmApi.h
===================================================================
--- trunk/core/AmApi.h 2008-04-30 14:48:42 UTC (rev 922)
+++ trunk/core/AmApi.h 2008-04-30 15:02:22 UTC (rev 923)
@@ -235,17 +235,20 @@
class AmCtrlInterface: public AmThread
{
public:
- AmCtrlInterface() {}
- //virtual ~AmCtrlInterface() = 0;
-
- //@param serKey An out parameter
- virtual int send(const AmSipRequest &, string &serKey) = 0;
-
- virtual int send(const AmSipReply &) = 0;
-
- virtual string getContact(const string &displayName,
- const string &userName, const string &hostName,
- const string &uriParams, const string &hdrParams) = 0;
+ AmCtrlInterface();
+ virtual ~AmCtrlInterface();
+
+ //@param serKey [out] An out parameter
+ //@param serKeyLen [out] An out parameter
+
+ virtual int send(const AmSipRequest &,
+ char* serKey, unsigned int& serKeyLen) = 0;
+
+ virtual int send(const AmSipReply &) = 0;
+
+ virtual string getContact(const string &displayName,
+ const string &userName, const string &hostName,
+ const string &uriParams, const string &hdrParams) =
0;
};
/**
Modified: trunk/core/AmServer.cpp
===================================================================
--- trunk/core/AmServer.cpp 2008-04-30 14:48:42 UTC (rev 922)
+++ trunk/core/AmServer.cpp 2008-04-30 15:02:22 UTC (rev 923)
@@ -62,9 +62,9 @@
return ctrlIface->send(reply);
}
-bool AmServer::sendRequest(const AmSipRequest &req, string &serKey)
+bool AmServer::sendRequest(const AmSipRequest &req, char* serKey, unsigned
int& serKeyLen)
{
- return ctrlIface->send(req, serKey);
+ return ctrlIface->send(req, serKey, serKeyLen);
}
string AmServer::getContact(const string &displayName,
Modified: trunk/core/AmServer.h
===================================================================
--- trunk/core/AmServer.h 2008-04-30 14:48:42 UTC (rev 922)
+++ trunk/core/AmServer.h 2008-04-30 15:02:22 UTC (rev 923)
@@ -66,7 +66,7 @@
void regIface(const AmCtrlInterface *i);
bool hasIface() { return ctrlIface != NULL; };
- static bool sendRequest(const AmSipRequest &, string &);
+ static bool sendRequest(const AmSipRequest &, char* serKey, unsigned int&
serKeyLen);
static bool sendReply(const AmSipReply &);
static string getContact(const string &displayName,
const string &userName, const string &hostName,
Modified: trunk/core/AmSipDialog.cpp
===================================================================
--- trunk/core/AmSipDialog.cpp 2008-04-30 14:48:42 UTC (rev 922)
+++ trunk/core/AmSipDialog.cpp 2008-04-30 15:02:22 UTC (rev 923)
@@ -40,6 +40,11 @@
"Disconnecting" };
+AmSipDialog::AmSipDialog(AmSipDialogEventHandler* h)
+ : status(Disconnected),cseq(10),hdl(h), serKeyLen(0)
+{
+}
+
AmSipDialog::~AmSipDialog()
{
DBG("callid = %s\n",callid.c_str());
@@ -527,9 +532,10 @@
req.callid = callid;
req.cseq = cancel_cseq;
//useful for SER-2.0.0
- req.serKey = serKey;
- string empty;
- return AmServer::sendRequest(req, empty) ? 0 : -1;
+ req.serKey = string(serKey, serKeyLen);
+ char empty[MAX_SER_KEY_LEN];
+ unsigned int unused = 0;
+ return AmServer::sendRequest(req, empty, unused) ? 0 : -1;
}
int AmSipDialog::sendRequest(const string& method,
@@ -584,7 +590,7 @@
req.body = body;
}
- if (AmServer::sendRequest(req, serKey))
+ if (AmServer::sendRequest(req, serKey, serKeyLen))
return -1;
uac_trans[cseq] = AmSipTransaction(method,cseq);
Modified: trunk/core/AmSipDialog.h
===================================================================
--- trunk/core/AmSipDialog.h 2008-04-30 14:48:42 UTC (rev 922)
+++ trunk/core/AmSipDialog.h 2008-04-30 15:02:22 UTC (rev 923)
@@ -35,6 +35,7 @@
#include <map>
using std::string;
+#define MAX_SER_KEY_LEN 30
#define CONTACT_USER_PREFIX "sems"
// flags which may be used when sending request/reply
@@ -137,12 +138,10 @@
int cseq; // CSeq for next request
- string serKey; // opaque string returned by SER, when staring a T
+ char serKey[MAX_SER_KEY_LEN]; // opaque string returned by SER, when
staring a T
+ unsigned int serKeyLen;
- AmSipDialog(AmSipDialogEventHandler* h=0)
- : status(Disconnected),cseq(10),hdl(h)
- {}
-
+ AmSipDialog(AmSipDialogEventHandler* h=0);
~AmSipDialog();
bool getUACTransPending() { return !uac_trans.empty(); }
Modified: trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp
===================================================================
--- trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp 2008-04-30 14:48:42 UTC
(rev 922)
+++ trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp 2008-04-30 15:02:22 UTC
(rev 923)
@@ -1120,7 +1120,7 @@
return req;
}
-int BrpcCtrlInterface::send(const AmSipRequest &amReq, string &serKey)
+int BrpcCtrlInterface::send(const AmSipRequest &amReq, char *serKey, unsigned
int &serKeyLen)
{
int ret = -1;
brpc_t *req, *rpl = NULL;
@@ -1161,7 +1161,8 @@
}
DBG("SER's opaque/reason: `%.*s'.\n", BRPC_STR_FMT(ser_opaque));
//len must be fed, as the opaque could contain 0s
- serKey = string(ser_opaque->val, ser_opaque->len);
+ memcpy(serKey, ser_opaque->val, ser_opaque->len);
+ serKeyLen = ser_opaque->len;
ret = 0;
end:
Modified: trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.h
===================================================================
--- trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.h 2008-04-30 14:48:42 UTC
(rev 922)
+++ trunk/core/plug-in/binrpcctrl/BrpcCtrlInterface.h 2008-04-30 15:02:22 UTC
(rev 923)
@@ -75,7 +75,7 @@
void on_stop() {}
// AmCtrlInterface
- int send(const AmSipRequest &, string &);
+ int send(const AmSipRequest &, char *, unsigned int &);
int send(const AmSipReply &);
string getContact(const string &displayName,
Modified: trunk/core/plug-in/sipctrl/SipCtrlInterface.cpp
===================================================================
--- trunk/core/plug-in/sipctrl/SipCtrlInterface.cpp 2008-04-30 14:48:42 UTC
(rev 922)
+++ trunk/core/plug-in/sipctrl/SipCtrlInterface.cpp 2008-04-30 15:02:22 UTC
(rev 923)
@@ -158,8 +158,10 @@
}
#endif
-int SipCtrlInterface::send(const AmSipRequest &req, string &serKey)
+int SipCtrlInterface::send(const AmSipRequest &req, char* serKey, unsigned
int& serKeyLen)
{
+ serKeyLen = 0;
+
if(req.method == "CANCEL")
return cancel(req);
@@ -269,12 +271,10 @@
}
}
- char tid[12];
-
- tl->send_request(msg,tid);
+ tl->send_request(msg,serKey);
delete msg;
- serKey = string(tid,12);
+ serKeyLen=12;
return 0;
}
Modified: trunk/core/plug-in/sipctrl/SipCtrlInterface.h
===================================================================
--- trunk/core/plug-in/sipctrl/SipCtrlInterface.h 2008-04-30 14:48:42 UTC
(rev 922)
+++ trunk/core/plug-in/sipctrl/SipCtrlInterface.h 2008-04-30 15:02:22 UTC
(rev 923)
@@ -81,8 +81,7 @@
/**
* From AmCtrlInterface
*/
-
- int send(const AmSipRequest &req, string &serKey);
+ int send(const AmSipRequest &req, char* serKey, unsigned int& serKeyLen);
int send(const AmSipReply &rep);
#ifndef _STANDALONE
Modified: trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.cpp
===================================================================
--- trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.cpp 2008-04-30
14:48:42 UTC (rev 922)
+++ trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.cpp 2008-04-30
15:02:22 UTC (rev 923)
@@ -130,7 +130,7 @@
return 0;
}
-int UnixCtrlInterface::send(const AmSipRequest &req, string &_)
+int UnixCtrlInterface::send(const AmSipRequest &req, char *, unsigned int &)
{
return rplAdapt.send(req, reply_socket_name, ser_socket_name);
}
Modified: trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.h
===================================================================
--- trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.h 2008-04-30 14:48:42 UTC
(rev 922)
+++ trunk/core/plug-in/unixsockctrl/UnixCtrlInterface.h 2008-04-30 15:02:22 UTC
(rev 923)
@@ -65,7 +65,7 @@
~UnixCtrlInterface();
// AmCtrlInterface
- int send(const AmSipRequest &, string &);
+ int send(const AmSipRequest &, char *, unsigned int &);
int send(const AmSipReply &);
string getContact(const string &displayName,
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev