serKey allocated in core (fixes strange crashes iff linking with other stuff)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@923 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent 01ef6df1b5
commit 39131cb061

@ -104,3 +104,11 @@ AmCtrlInterfaceFactory::AmCtrlInterfaceFactory(const string& name)
: AmPluginFactory(name)
{
}
AmCtrlInterface::AmCtrlInterface()
{
}
AmCtrlInterface::~AmCtrlInterface()
{
}

@ -235,17 +235,20 @@ class AmInterfaceHandler;
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;
};
/**

@ -62,9 +62,9 @@ bool AmServer::sendReply(const AmSipReply &reply)
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,

@ -66,7 +66,7 @@ public:
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,

@ -40,6 +40,11 @@ const char* AmSipDialog::status2str[4] = {
"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 @@ int AmSipDialog::cancel()
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 @@ int AmSipDialog::sendRequest(const string& method,
req.body = body;
}
if (AmServer::sendRequest(req, serKey))
if (AmServer::sendRequest(req, serKey, serKeyLen))
return -1;
uac_trans[cseq] = AmSipTransaction(method,cseq);

@ -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 @@ class AmSipDialog
int cseq; // CSeq for next request
string serKey; // opaque string returned by SER, when staring a T
AmSipDialog(AmSipDialogEventHandler* h=0)
: status(Disconnected),cseq(10),hdl(h)
{}
char serKey[MAX_SER_KEY_LEN]; // opaque string returned by SER, when staring a T
unsigned int serKeyLen;
AmSipDialog(AmSipDialogEventHandler* h=0);
~AmSipDialog();
bool getUACTransPending() { return !uac_trans.empty(); }

@ -1120,7 +1120,7 @@ static inline brpc_t *build_request(const AmSipRequest &amReq,
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 @@ int BrpcCtrlInterface::send(const AmSipRequest &amReq, string &serKey)
}
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:

@ -75,7 +75,7 @@ class BrpcCtrlInterface: public AmCtrlInterface
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,

@ -158,8 +158,10 @@ string SipCtrlInterface::getContact(const string &displayName,
}
#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 @@ int SipCtrlInterface::send(const AmSipRequest &req, string &serKey)
}
}
char tid[12];
tl->send_request(msg,tid);
tl->send_request(msg,serKey);
delete msg;
serKey = string(tid,12);
serKeyLen=12;
return 0;
}

@ -81,8 +81,7 @@ public:
/**
* 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

@ -130,7 +130,7 @@ int UnixCtrlInterface::init(const string& socket_name)
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);
}

@ -65,7 +65,7 @@ class UnixCtrlInterface : public AmCtrlInterface
~UnixCtrlInterface();
// AmCtrlInterface
int send(const AmSipRequest &, string &);
int send(const AmSipRequest &, char *, unsigned int &);
int send(const AmSipReply &);
string getContact(const string &displayName,

Loading…
Cancel
Save