- Removed alternative contexts / extensions

- New struct for matchs
- On calls originated from an FXS branch, the Endpoint searches for a valid extension (digits sent) after the DTMF '#' or after the timeout (option fxs-digit-timeout). That search is done in the context defined in section <fxs-options>, or if no context configured, the search is done in context defined in context-fxs.
- Added "dialplan" configuration: Name of the dialplan module in use
(default XML)
- Group context enabled. If set, the search for a valid extension is done only in that context.
- Updated documentation
This commit is contained in:
Geovani Ricardo Wiedenhoft committed 2010-10-25 12:07:31 -02:00
1 parent 15070162ff
commit 1ef3fc9a1b
21 files changed
+342 -343

No files matched your search

@@ -85,10 +85,6 @@ struct Board
/******************************** Channel *************************************/
struct KhompPvt
{
// TODO: Here for while, put in right struct, when is ready
typedef std::vector<std::string> ContextListType;
typedef std::vector<std::string> ExtenListType;
typedef SimpleNonBlockLock<25,100> ChanLockType;
typedef enum
@@ -994,29 +990,26 @@ public:
virtual int getActiveChannel(bool invalid_as_not_found);
MatchType matchExtension(std::string &, std::string &, std::string &, bool match_only = false);
MatchType findExtension(std::string &, std::string &, ContextListType &, std::string &, std::string &,
bool default_ctx = true, bool default_ext = true);
/* Let's validate the contexts */
virtual bool validContexts(Board::KhompPvt::ContextListType & contexts, std::string extra_string = "")
virtual bool validContexts(MatchExtension::ContextListType & contexts,
std::string extra_string = "")
{
DBG(FUNC,PVT_FMT(_target,"c"));
if(!_group_context.empty())
{
contexts.push_back(_group_context);
contexts.insert(contexts.begin(), _group_context);
//contexts.push_back(_group_context);
}
for (Board::KhompPvt::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
replaceTemplate((*i), "DD", _target.device);
BEGIN_CONTEXT
{
K3L_DEVICE_CONFIG & dev_cfg = Globals::k3lapi.device_config(_target.device);
for (Board::KhompPvt::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
replaceTemplate((*i), "SSSS", atoi(dev_cfg.SerialNumber));
}
END_CONTEXT
@@ -241,7 +241,8 @@ struct KhompPvtFXO: public KhompPvt
void setAnswerInfo(int answer_info);
bool indicateBusyUnlocked(int cause, bool sent_signaling = false);
void reportFailToReceive(int fail_code);
bool validContexts(Board::KhompPvt::ContextListType & contexts, std::string extra_context = "");
bool validContexts(MatchExtension::ContextListType & contexts,
std::string extra_context = "");
bool isOK(void);
@@ -262,7 +262,8 @@ struct KhompPvtGSM: public KhompPvt
_sms->statistics()->clear();
}
bool validContexts(Board::KhompPvt::ContextListType & contexts, std::string extra_context = "");
bool validContexts(MatchExtension::ContextListType & contexts,
std::string extra_context = "");
SMS * _sms;
@@ -191,7 +191,8 @@ struct KhompPvtE1: public KhompPvt
bool setupConnection();
bool indicateBusyUnlocked(int cause, bool sent_signaling = false);
void setAnswerInfo(int answer_info);
bool validContexts(Board::KhompPvt::ContextListType & contexts, std::string extra_context = "");
bool validContexts(MatchExtension::ContextListType & contexts,
std::string extra_context = "");
bool isOK(void);
bool isPhysicalFree()
@@ -931,7 +932,8 @@ struct KhompPvtFXS: public KhompPvt
bool alloc();
bool indicateBusyUnlocked(int cause, bool sent_signaling = false);
void reportFailToReceive(int fail_code);
bool validContexts(Board::KhompPvt::ContextListType & contexts, std::string extra_context = "");
bool validContexts(MatchExtension::ContextListType & contexts,
std::string extra_context = "");
bool isOK(void);
bool startTransfer();
@@ -126,7 +126,8 @@ struct KhompPvtPassive: public KhompPvt
return ret;
}
bool validContexts(Board::KhompPvt::ContextListType & contexts, std::string extra_context = "");
bool validContexts(MatchExtension::ContextListType & contexts,
std::string extra_context = "");
/*
virtual bool cleanup(CleanupType type = CLN_HARD)
@@ -1 +1 @@
#define MOD_KHOMP_VERSION "1.0 - (rev: 5796)"
#define MOD_KHOMP_VERSION "1.0 - (rev: 5823)"
+17 -96
View File
@@ -601,109 +601,30 @@ static std::string timeToString (time_t time_value)
}
/******************************************************************************/
/******************************* Match functions ******************************/
typedef enum
struct MatchExtension
{
MATCH_NONE,
MATCH_EXACT,
MATCH_MORE
}
MatchType;
typedef std::vector<std::string> ContextListType;
typedef std::vector<std::string> ExtenListType;
static bool canMatch(std::string & context, std::string & exten, std::string & caller_id, bool match_more = false)
{
switch_xml_t xml = NULL;
switch_xml_t xcontext = NULL;
switch_regex_t *re;
int ovector[30];
if (switch_xml_locate("dialplan","context","name",context.c_str(),&xml,&xcontext, NULL,SWITCH_FALSE) == SWITCH_STATUS_SUCCESS)
typedef enum
{
switch_xml_t xexten = NULL;
if(!(xexten = switch_xml_child(xcontext,"extension")))
{
DBG(FUNC,"extension cannot match, returning");
if(xml)
switch_xml_free(xml);
return false;
}
while(xexten)
{
switch_xml_t xcond = NULL;
for (xcond = switch_xml_child(xexten, "condition"); xcond; xcond = xcond->next)
{
std::string expression;
if (switch_xml_child(xcond, "condition"))
{
LOG(ERROR,"Nested conditions are not allowed");
}
switch_xml_t xexpression = switch_xml_child(xcond, "expression");
if ((xexpression = switch_xml_child(xcond, "expression")))
{
expression = switch_str_nil(xexpression->txt);
}
else
{
expression = switch_xml_attr_soft(xcond, "expression");
}
if(expression.empty() || expression == "^(.*)$")
{
/**
* We're not gonna take it
* No, we ain't gonna take it
* We're not gonna take it anymore
**/
continue;
}
int pm = -1;
switch_status_t is_match = SWITCH_STATUS_FALSE;
is_match = switch_regex_match_partial(exten.c_str(),expression.c_str(),&pm);
if(is_match == SWITCH_STATUS_SUCCESS)
{
if(match_more)
{
if(pm == 1)
{
switch_xml_free(xml);
return true;
}
}
else
{
switch_xml_free(xml);
return true;
}
}
else
{
// not match
}
}
xexten = xexten->next;
}
}
else
{
DBG(FUNC,"context cannot match, returning");
MATCH_NONE,
MATCH_EXACT,
MATCH_MORE
}
MatchType;
if(xml)
switch_xml_free(xml);
static bool canMatch(std::string & context, std::string & exten,
std::string & caller_id, bool match_more = false);
return false;
}
static MatchType matchExtension(std::string &, std::string &,
std::string &, bool match_only = false);
static MatchType findExtension(std::string &, std::string &,
ContextListType &, std::string &, std::string &,
bool default_ctx = true, bool default_ext = true);
};
/******************************************************************************/
/************************** Thread helper functions ***************************/
typedef int (HandlerType)(void *);