forked from Mirrors/sngrep
support custom Call-ID correlation header via sip.xcid setting
* default value: 'X-Call-ID|X-CID' as previously fixes #218
This commit is contained in:
parent
c5f6b4e31a
commit
8c038c7658
|
@ -100,3 +100,7 @@
|
|||
##-----------------------------------------------------------------------------
|
||||
## Uncomment to display dialogs that does not start with a request method
|
||||
# set sip.noincomplete off
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
## Uncomment to define custom b_leg correlation header
|
||||
# set sip.xcid X-Call-ID|X-CID
|
||||
|
|
|
@ -54,6 +54,7 @@ setting_t settings[SETTING_COUNT] = {
|
|||
{ SETTING_CAPTURE_STORAGE, "capture.storage", SETTING_FMT_ENUM, "memory", SETTING_ENUM_STORAGE },
|
||||
{ SETTING_CAPTURE_ROTATE, "capture.rotate", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_SIP_NOINCOMPLETE, "sip.noincomplete", SETTING_FMT_ENUM, SETTING_ON, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_SIP_HEADER_X_CID, "sip.xcid", SETTING_FMT_STRING, "X-Call-ID|X-CID", NULL },
|
||||
{ SETTING_SIP_CALLS, "sip.calls", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_SAVEPATH, "savepath", SETTING_FMT_STRING, "", NULL },
|
||||
{ SETTING_DISPLAY_ALIAS, "displayalias", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
|
|
|
@ -90,6 +90,7 @@ enum setting_id {
|
|||
SETTING_CAPTURE_STORAGE,
|
||||
SETTING_CAPTURE_ROTATE,
|
||||
SETTING_SIP_NOINCOMPLETE,
|
||||
SETTING_SIP_HEADER_X_CID,
|
||||
SETTING_SIP_CALLS,
|
||||
SETTING_SAVEPATH,
|
||||
SETTING_DISPLAY_ALIAS,
|
||||
|
|
24
src/sip.c
24
src/sip.c
|
@ -139,7 +139,9 @@ sip_code_t sip_codes[] = {
|
|||
void
|
||||
sip_init(int limit, int only_calls, int no_incomplete)
|
||||
{
|
||||
int match_flags;
|
||||
int match_flags, reg_rule_len, reg_rule_err;
|
||||
char reg_rule[SIP_ATTR_MAXLEN];
|
||||
const char *setting = NULL;
|
||||
|
||||
// Store capture limit
|
||||
calls.limit = limit;
|
||||
|
@ -170,7 +172,25 @@ sip_init(int limit, int only_calls, int no_incomplete)
|
|||
match_flags = REG_EXTENDED | REG_ICASE | REG_NEWLINE;
|
||||
regcomp(&calls.reg_method, "^([a-zA-Z]+) [a-zA-Z]+:[^ ]+ SIP/2.0[ ]*\r", match_flags & ~REG_NEWLINE);
|
||||
regcomp(&calls.reg_callid, "^(Call-ID|i):[ ]*([^ ]+)[ ]*\r$", match_flags);
|
||||
regcomp(&calls.reg_xcallid, "^(X-Call-ID|X-CID):[ ]*([^ ]+)[ ]*\r$", match_flags);
|
||||
setting = setting_get_value(SETTING_SIP_HEADER_X_CID);
|
||||
reg_rule_len = strlen(setting) + 22;
|
||||
if (reg_rule_len >= SIP_ATTR_MAXLEN) {
|
||||
setting = "X-Call-ID|X-CID";
|
||||
reg_rule_len = strlen(setting) + 22;
|
||||
fprintf(stderr, "%s setting too long, using default.\n",
|
||||
setting_name(SETTING_SIP_HEADER_X_CID));
|
||||
}
|
||||
snprintf(reg_rule, reg_rule_len, "^(%s):[ ]*([^ ]+)[ ]*\r$", setting);
|
||||
reg_rule_err = regcomp(&calls.reg_xcallid, reg_rule, match_flags);
|
||||
if(reg_rule_err != 0) {
|
||||
regerror(reg_rule_err, &calls.reg_xcallid, reg_rule, SIP_ATTR_MAXLEN);
|
||||
regfree(&calls.reg_xcallid);
|
||||
fprintf(stderr, "%s setting produces regex compilation error: %s"
|
||||
"using default value instead\n",
|
||||
setting_name(SETTING_SIP_HEADER_X_CID), reg_rule);
|
||||
regcomp(&calls.reg_xcallid,
|
||||
"^(X-Call-ID|X-CID):[ ]*([^ ]+)[ ]*\r$", match_flags);
|
||||
}
|
||||
regcomp(&calls.reg_response, "^SIP/2.0[ ]*(([0-9]{3}) [^\r]*)[ ]*\r", match_flags & ~REG_NEWLINE);
|
||||
regcomp(&calls.reg_cseq, "^CSeq:[ ]*([0-9]+) .+\r$", match_flags);
|
||||
regcomp(&calls.reg_from, "^(From|f):[ ]*[^:]*:(([^@>]+)@?[^\r>;]+)", match_flags);
|
||||
|
|
Loading…
Reference in New Issue