Commit 6719a3db authored by jehan's avatar jehan

re-work BooleanExpression error handling

parent 769f04ff
......@@ -53,13 +53,16 @@ option(ENABLE_TRANSCODER "Build transcoder support" YES)
cmake_dependent_option(ENABLE_SPECIFIC_FEATURES "Enable mediarelay specific features" OFF "ENABLE_TRANSCODER" OFF)
set(XSDCXX_ROOT_PATH "/usr" CACHE STRING "Path of where the bin/xsdcxx executable will be found. Comes from http://www.codesynthesis.com/products/xsd/download.xhtml. On mac use 'brew install xsd'")
set(SYSCONFIGROOT "" CACHE STRING "Config directory, the place where flexisip expects its flexisip.conf file to reside" )
if(APPLE)
list(APPEND XSDCXX_ROOT_PATH "/usr/local")
set(XSDCXX_DEFAULT_ROOT_PATH "/usr/local")
else ()
set(XSDCXX_DEFAULT_ROOT_PATH "/usr")
endif()
set(XSDCXX_ROOT_PATH ${XSDCXX_DEFAULT_ROOT_PATH} CACHE STRING "Path of where the bin/xsdcxx executable will be found. Comes from http://www.codesynthesis.com/products/xsd/download.xhtml. On mac use 'brew install xsd'")
set(SYSCONFIGROOT "" CACHE STRING "Config directory, the place where flexisip expects its flexisip.conf file to reside" )
set(CONFIG_DIR ${SYSCONFIGROOT}/etc)
message(STATUS "Config dir: ${CONFIG_DIR}")
......
......@@ -47,9 +47,15 @@ long BooleanExpression::ptr() {
}
#ifndef NO_SOFIA
bool BooleanExpression::eval(const sip_t *sip) throw() {
SipAttributes attr(sip);
return eval(&attr);
bool BooleanExpression::eval(const sip_t *sip) throw(FlexisipException) {
bool result;
try {
SipAttributes attr(sip);
result = eval(&attr);
} catch (std::exception& e) {
throw FLEXISIP_EXCEPTION << "Cannot evaluate boolean expression for " << sip << " : " << e.what();
}
return result;
}
#endif
......@@ -155,11 +161,7 @@ class Variable : public VariableOrConstant {
LOGPARSE << "Creating variable XX" << val << "XX";
}
virtual const std::string &get(const SipAttributes *args) {
try {
mVal = args->get(mId);
} catch (exception &e) {
throw FLEXISIP_EXCEPTION << "GET " << mId << " : " << e.what();
}
mVal = args->get(mId);
return mVal;
}
};
......
......@@ -25,9 +25,11 @@
#include <string>
#include <memory>
#include "utils/flexisip-exception.hh"
class SipAttributes;
void log_boolean_expression_evaluation(bool value);
void log_boolean_expression_parsing(bool value);
......@@ -38,7 +40,7 @@ class BooleanExpression {
public:
#ifndef NO_SOFIA
bool eval(const sip_t *sip) throw(); // Throws FlexisipException
bool eval(const sip_t *sip) throw(FlexisipException);
#endif
virtual bool eval(const SipAttributes *args) = 0;
virtual ~BooleanExpression();
......
......@@ -36,8 +36,8 @@ class MediaRelay : public Module, protected ModuleToolbox {
~MediaRelay();
virtual void onLoad(const GenericStruct *modconf);
virtual void onUnload();
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
virtual void onIdle();
protected:
......
......@@ -470,7 +470,7 @@ class Authentication : public Module {
return false;
}
void onRequest(shared_ptr<RequestSipEvent> &ev) {
void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
sip_p_preferred_identity_t *ppi = NULL;
......@@ -558,7 +558,7 @@ class Authentication : public Module {
ev->suspendProcessing();
}
}
void onResponse(shared_ptr<ResponseSipEvent> &ev) {
void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){
if (!mNewAuthOn407)
return; /*nop*/
......
......@@ -45,7 +45,7 @@ class ContactRouteInserter : public Module {
mContactMasquerader = unique_ptr<ContactMasquerader>(new ContactMasquerader(mAgent, mCtRtParamName));
}
void onRequest(shared_ptr<RequestSipEvent> &ev) {
void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
const sip_method_t rq_method = sip->sip_request->rq_method;
......@@ -73,7 +73,7 @@ class ContactRouteInserter : public Module {
}
}
}
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) {
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
if (mMasqueradeInvites &&
......
......@@ -144,7 +144,7 @@ class DoSProtection : public Module, ModuleToolbox {
}
}
void onRequest(shared_ptr<RequestSipEvent> &ev) {
void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException) {
shared_ptr<tport_t> inTport = ev->getIncomingTport();
tport_t *tport = inTport.get();
......@@ -223,7 +223,7 @@ class DoSProtection : public Module, ModuleToolbox {
}
}
void onResponse(std::shared_ptr<ResponseSipEvent> &ev){
void onResponse(std::shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){
};
......
......@@ -36,8 +36,8 @@ class ForwardModule : public Module, ModuleToolbox {
ForwardModule(Agent *ag);
virtual void onDeclare(GenericStruct *module_config);
virtual void onLoad(const GenericStruct *root);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
~ForwardModule();
private:
......@@ -136,7 +136,7 @@ static bool isUs(Agent *ag, sip_route_t *r) {
return ag->isUs(r->r_url);
}
void ForwardModule::onRequest(shared_ptr<RequestSipEvent> &ev) {
void ForwardModule::onRequest(shared_ptr<RequestSipEvent> &ev) throw(FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
url_t *dest = NULL;
sip_t *sip = ms->getSip();
......@@ -265,7 +265,7 @@ bool ForwardModule::isLooping(shared_ptr<RequestSipEvent> &ev, const char *branc
return false;
}
void ForwardModule::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void ForwardModule::onResponse(shared_ptr<ResponseSipEvent> &ev) throw(FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
ev->send(ms);
}
......
......@@ -29,7 +29,7 @@ class ModuleGarbageIn : public Module, protected ModuleToolbox {
~ModuleGarbageIn() {
}
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) {
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException){
const sip_t *sip = ev->getMsgSip()->getSip();
if (sip->sip_request->rq_method == sip_method_options) {
ev->reply(200, NULL, TAG_END());
......@@ -40,7 +40,7 @@ class ModuleGarbageIn : public Module, protected ModuleToolbox {
ev->terminateProcessing();
}
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) {
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){
SLOGD << "Garbage: processing terminated";
ev->terminateProcessing();
}
......
......@@ -333,9 +333,9 @@ class GatewayAdapter : public Module {
virtual void onLoad(const GenericStruct *module_config);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
virtual bool isValidNextConfig(const ConfigValue &cv);
......@@ -414,7 +414,7 @@ void GatewayAdapter::onLoad(const GenericStruct *module_config) {
}
}
void GatewayAdapter::onRequest(shared_ptr<RequestSipEvent> &ev) {
void GatewayAdapter::onRequest(shared_ptr<RequestSipEvent> &ev) throw(FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
......@@ -457,7 +457,7 @@ void GatewayAdapter::onRequest(shared_ptr<RequestSipEvent> &ev) {
}
}
void GatewayAdapter::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void GatewayAdapter::onResponse(shared_ptr<ResponseSipEvent> &ev) throw(FlexisipException) {
}
void GatewayAdapter::nua_callback(nua_event_t event, int status, char const *phrase, nua_t *nua, nua_magic_t *ctx,
......
......@@ -29,8 +29,8 @@ class LoadBalancer : public Module, public ModuleToolbox {
virtual ~LoadBalancer();
virtual void onDeclare(GenericStruct *module_config);
virtual void onLoad(const GenericStruct *modconf);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
private:
vector<string> mRoutes;
......@@ -66,7 +66,7 @@ void LoadBalancer::onLoad(const GenericStruct *modconf) {
mRoutesCount = mRoutes.size();
}
void LoadBalancer::onRequest(shared_ptr<RequestSipEvent> &ev) {
void LoadBalancer::onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException){
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
uint32_t call_hash;
sip_t *sip = ms->getSip();
......@@ -87,7 +87,7 @@ void LoadBalancer::onRequest(shared_ptr<RequestSipEvent> &ev) {
}
}
void LoadBalancer::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void LoadBalancer::onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){
/*nothing to do*/
}
......
......@@ -223,7 +223,7 @@ void MediaRelay::configureContext(shared_ptr<RelayedCall> &c) {
#endif
}
void MediaRelay::onRequest(shared_ptr<RequestSipEvent> &ev) {
void MediaRelay::onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException){
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
......@@ -324,7 +324,7 @@ void MediaRelay::processResponseWithSDP(const shared_ptr<RelayedCall> &c,
delete m;
}
void MediaRelay::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void MediaRelay::onResponse(shared_ptr<ResponseSipEvent> &ev) throw(FlexisipException) {
shared_ptr<MsgSip> ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
msg_t *msg = ms->getMsg();
......
......@@ -31,7 +31,7 @@ class NatHelper : public Module, protected ModuleToolbox {
~NatHelper() {
}
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) {
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException) {
shared_ptr<MsgSip> ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
sip_request_t *rq = sip->sip_request;
......@@ -57,7 +57,7 @@ class NatHelper : public Module, protected ModuleToolbox {
// Idea for future: for the case where a natted proxy forwards a REGISTER (which can be detected , we could add
// a Path header corresponding to this proxy
}
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) {
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_status_t *st = ms->getSip()->sip_status;
sip_cseq_t *cseq = ms->getSip()->sip_cseq;
......
......@@ -96,11 +96,11 @@ class ModulePresence : public Module, ModuleToolbox {
}
return false;
}
void onRequest(shared_ptr<RequestSipEvent> &ev) {
void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException){
if (isMessageAPresenceMessage(ev))
route(ev);
}
void onResponse(std::shared_ptr<ResponseSipEvent> &ev){};
void onResponse(std::shared_ptr<ResponseSipEvent> &ev)throw (FlexisipException){};
public:
ModulePresence(Agent *ag) : Module(ag) {
......
......@@ -66,8 +66,8 @@ class PushNotification : public Module, public ModuleToolbox {
PushNotification(Agent *ag);
virtual ~PushNotification();
void onDeclare(GenericStruct *module_config);
virtual void onRequest(std::shared_ptr<RequestSipEvent> &ev);
virtual void onResponse(std::shared_ptr<ResponseSipEvent> &ev);
virtual void onRequest(std::shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(std::shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
virtual void onLoad(const GenericStruct *mc);
PushNotificationService *getService() const {
return mPNS;
......@@ -423,7 +423,7 @@ bool PushNotification::needsPush(const sip_t *sip) {
return false;
}
void PushNotification::onRequest(std::shared_ptr<RequestSipEvent> &ev) {
void PushNotification::onRequest(std::shared_ptr<RequestSipEvent> &ev) throw(FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
if (needsPush(sip)) {
......@@ -440,7 +440,7 @@ void PushNotification::onRequest(std::shared_ptr<RequestSipEvent> &ev) {
}
}
void PushNotification::onResponse(std::shared_ptr<ResponseSipEvent> &ev) {
void PushNotification::onResponse(std::shared_ptr<ResponseSipEvent> &ev) throw(FlexisipException) {
shared_ptr<OutgoingTransaction> transaction = dynamic_pointer_cast<OutgoingTransaction>(ev->getOutgoingAgent());
int code = ev->getMsgSip()->getSip()->sip_status->st_status;
if (transaction != NULL && code >= 180 && code != 503) {
......
......@@ -61,11 +61,11 @@ class ModuleRedirect : public Module, ModuleToolbox {
void onUnload() {
}
void onRequest(shared_ptr<RequestSipEvent> &ev) {
void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException){
ev->reply(SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT(sip_contact_dup(&mHome, mContact)),
SIPTAG_SERVER_STR(getAgent()->getServerString()), TAG_END());
}
void onResponse(std::shared_ptr<ResponseSipEvent> &ev){};
void onResponse(std::shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){};
public:
ModuleRedirect(Agent *ag) : Module(ag) {
......
......@@ -187,9 +187,9 @@ class ModuleRegistrar : public Module, public ModuleToolbox {
}
}
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
template <typename SipEventT, typename ListenerT>
void processUpdateRequest(shared_ptr<SipEventT> &ev, const sip_t *sip);
......@@ -512,7 +512,7 @@ void ModuleRegistrar::processUpdateRequest(shared_ptr<SipEventT> &ev, const sip_
}
}
void ModuleRegistrar::onRequest(shared_ptr<RequestSipEvent> &ev) {
void ModuleRegistrar::onRequest(shared_ptr<RequestSipEvent> &ev) throw(FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
......@@ -604,7 +604,7 @@ void ModuleRegistrar::onRequest(shared_ptr<RequestSipEvent> &ev) {
}
}
void ModuleRegistrar::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void ModuleRegistrar::onResponse(shared_ptr<ResponseSipEvent> &ev) throw(FlexisipException) {
if (!mUpdateOnResponse)
return;
const shared_ptr<MsgSip> &reMs = ev->getMsgSip();
......
......@@ -153,9 +153,9 @@ class ModuleRouter : public Module, public ModuleToolbox, public ForkContextList
virtual void onUnload() {
}
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
virtual void onForkContextFinished(shared_ptr<ForkContext> ctx);
void extractContactByUniqueId(string uid);
......@@ -848,7 +848,7 @@ static vector<string> split(const char *data, const char *delim) {
return res;
}
void ModuleRouter::onRequest(shared_ptr<RequestSipEvent> &ev) {
void ModuleRouter::onRequest(shared_ptr<RequestSipEvent> &ev) throw(FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
......@@ -916,7 +916,7 @@ void ModuleRouter::onRequest(shared_ptr<RequestSipEvent> &ev) {
}
}
void ModuleRouter::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void ModuleRouter::onResponse(shared_ptr<ResponseSipEvent> &ev) throw(FlexisipException) {
ForkContext::processResponse(ev);
}
......
......@@ -29,7 +29,7 @@ class ModuleSanityChecker : public Module, protected ModuleToolbox {
~ModuleSanityChecker() {
}
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) {
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException){
sip_t *sip = ev->getMsgSip()->getSip();
const char *error = checkHeaders(sip);
......@@ -42,7 +42,7 @@ class ModuleSanityChecker : public Module, protected ModuleToolbox {
}
}
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) {
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException){
// don't check our responses ;)
}
......
......@@ -34,8 +34,8 @@ class StatisticsCollector : public Module, ModuleToolbox {
~StatisticsCollector();
virtual void onDeclare(GenericStruct *module_config);
virtual void onLoad(const GenericStruct *root);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
private:
int managePublishContent(const shared_ptr<RequestSipEvent> ev);
......@@ -81,7 +81,7 @@ void StatisticsCollector::onLoad(const GenericStruct *mc) {
LOGI("StatisticsCollector: setup with collector address '%s'", value.c_str());
}
void StatisticsCollector::onRequest(shared_ptr<RequestSipEvent> &ev) {
void StatisticsCollector::onRequest(shared_ptr<RequestSipEvent> &ev) throw(FlexisipException) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
sip_t *sip = ms->getSip();
url_t *url = sip->sip_request->rq_url;
......@@ -98,7 +98,7 @@ void StatisticsCollector::onRequest(shared_ptr<RequestSipEvent> &ev) {
}
}
void StatisticsCollector::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void StatisticsCollector::onResponse(shared_ptr<ResponseSipEvent> &ev) throw(FlexisipException) {
}
/*avoid crash if x is NULL on libc versions <4.5.26 */
......
......@@ -71,8 +71,8 @@ class Transcoder : public Module, protected ModuleToolbox {
Transcoder(Agent *ag);
~Transcoder();
virtual void onLoad(const GenericStruct *module_config);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev);
virtual void onRequest(shared_ptr<RequestSipEvent> &ev) throw (FlexisipException);
virtual void onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException);
virtual void onIdle();
virtual void onDeclare(GenericStruct *mc);
#ifdef ENABLE_TRANSCODER
......@@ -123,10 +123,10 @@ void Transcoder::onLoad(const GenericStruct *mc) {
}
void Transcoder::onIdle() {
}
void Transcoder::onRequest(shared_ptr<RequestSipEvent> &ev) {
void Transcoder::onRequest(shared_ptr<RequestSipEvent> &ev) throw(FlexisipException) {
LOGA("Transcoder support is not compiled");
}
void Transcoder::onResponse(shared_ptr<ResponseSipEvent> &ev) {
void Transcoder::onResponse(shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException) {
LOGA("Transcoder support is not compiled");
}
#endif
......
......@@ -161,8 +161,8 @@ class Module : protected ConfigValueListener {
virtual void onUnload() {
}
virtual void onRequest(std::shared_ptr<RequestSipEvent> &ev) = 0;
virtual void onResponse(std::shared_ptr<ResponseSipEvent> &ev) = 0;
virtual void onRequest(std::shared_ptr<RequestSipEvent> &ev) throw (FlexisipException) = 0;
virtual void onResponse(std::shared_ptr<ResponseSipEvent> &ev) throw (FlexisipException) = 0;
virtual bool doOnConfigStateChanged(const ConfigValue &conf, ConfigState state);
virtual void onIdle() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment