23#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
41 virtual EncodeStream&
encode(EncodeStream& strm)
const { strm <<
"RequestFilterAsyncMessage(tid=" <<
mTid <<
")";
return strm; }
51 mFilterStore(config.getDataStore()->mFilterStore),
53 mDefaultNoMatchBehavior(config.getConfigData(
"RequestFilterDefaultNoMatchBehavior",
"")),
54 mDefaultDBErrorBehavior(config.getConfigData(
"RequestFilterDefaultDBErrorBehavior",
"500, Server Internal DB Error"))
56#if defined(USE_MYSQL) || defined(USE_POSTGRESQL)
57 const char* databaseParams[] = {
"RequestFilterDatabase",
"RuntimeDatabase",
"DefaultDatabase", 0 };
58 for(
const char** databaseParam = databaseParams; *databaseParam != 0; databaseParam++)
60 int databaseIndex = config.
getConfigInt(*databaseParam, -1);
61 if(databaseIndex >= 0)
71 Data mySQLSettingPrefix(
"RequestFilter");
73 if(mySQLServer.
empty())
77 mySQLSettingPrefix =
"Runtime";
79 if(mySQLServer.
empty())
83 mySQLSettingPrefix.
clear();
88 if(!mySQLServer.
empty())
91 WarningLog(<<
"Using deprecated parameter " << mySQLSettingPrefix <<
"MySQLServer, please update to indexed Database definitions.");
92 mSqlDb =
new MySqlDb(config, mySQLServer,
94 config.
getConfigData(mySQLSettingPrefix +
"MySQLPassword",
""),
95 config.
getConfigData(mySQLSettingPrefix +
"MySQLDatabaseName",
""),
108RequestFilter::parseActionResult(
const Data& result,
Data& rejectReason)
110 Data rejectionStatusCode;
112 const char* anchor = pb.position();
114 pb.data(rejectionStatusCode, anchor);
115 if(pb.position()[0] ==
',')
119 anchor = pb.position();
121 pb.data(rejectReason, anchor);
123 return (
short)rejectionStatusCode.
convertInt();
130 if(!actionResult.
empty())
132 Data rejectionReason;
133 short rejectionStatusCode = parseActionResult(actionResult, rejectionReason);
135 if(rejectionStatusCode >= 400 && rejectionStatusCode < 600)
139 InfoLog(<<
"Request is blocked - responding with a " << rejectionStatusCode <<
", customReason=" << rejectionReason);
154 DebugLog(<<
"Monkey handling request: " << *
this <<
"; reqcontext = " << rc);
172 return applyActionResult(rc, mDefaultDBErrorBehavior);
185 return applyActionResult(rc, actionData);
197 WarningLog(<<
"Request filter with action type SQL Query exists, however there is no MySQL support compiled in, using DefaultDBErrorBehavior");
198 return applyActionResult(rc, mDefaultDBErrorBehavior);
209 return applyActionResult(rc, mDefaultNoMatchBehavior);
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
RequestFilterAsyncMessage(AsyncProcessor &proc, const resip::Data &tid, TransactionUser *passedtu, Data &query)
std::vector< Data > mQueryResultData
virtual EncodeStream & encode(EncodeStream &strm) const
output the entire message to stream
resip::Dispatcher * mAsyncDispatcher
bool process(const resip::SipMessage &request, short &action, resip::Data &actionData)
virtual AbstractDb * getDatabase(int configIndex)
resip::SipMessage & getOriginalRequest()
Returns the SipMessage associated with the server transaction.
resip::Message * getCurrentEvent()
Returns the event that we are currently working on.
void sendResponse(resip::SipMessage &response)
resip::Data getTransactionId() const
virtual bool asyncProcess(AsyncProcessorMessage *msg)
virtual processor_action_t process(RequestContext &)
RequestFilter(ProxyConfig &config, resip::Dispatcher *asyncDispatcher)
virtual int singleResultQuery(const resip::Data &queryCommand, std::vector< resip::Data > &fields) const =0
int getConfigInt(const resip::Data &name, int defaultValue) const
resip::Data getConfigData(const resip::Data &name, const resip::Data &defaultValue, bool useDefaultIfEmpty=false) const
unsigned long getConfigUnsignedLong(const resip::Data &name, unsigned long defaultValue) const
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
bool empty() const noexcept
Checks whether the Data is empty.
int convertInt() const
Takes the contents of the Data and converts them to an integer.
Data & clear()
Clears the contents of this Data.
A generic thread-bank class.
virtual bool post(std::unique_ptr< resip::ApplicationMessage > &work)
Posts a message to this thread bank.
static void makeResponse(SipMessage &response, const SipMessage &request, int responseCode, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty)
Make a response to a provided request.
The base-class used for message-passing.
Provides string-parsing functionality with protection from buffer overflow.
Represents a SIP message.
The base-class for an RFC 3261 Transaction User.
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;