-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snom patch: Last_ keywords extension #260
Open
pbertera
wants to merge
11
commits into
SIPp:master
Choose a base branch
from
Snomio:snom-last-extensions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
060d7ca
Support for last_XX:value, last_XX:uri, last_XX:param.tag
pbertera 909cae7
Support for last_XX:value, last_XX:uri, last_XX:param.tag
pbertera e755a4c
Merge branch 'snom-last-extensions' of github.com:Snomio/sipp into sn…
pbertera 6a3ec98
Code review
pbertera 3344940
Fixed regtest
pbertera 9442f8d
testcase debugging for travis falure
pbertera a6575cd
travis testcase fix
pbertera b82bfff
fixed regtest
pbertera 8a4ad21
Fixed github-#0260/run
pbertera 9b99ed2
Code review
pbertera e52e597
Unit tests
pbertera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
# This regression test is a part of SIPp. | ||
# Author: Pietro Bertera, Snom Technology AG, 2016 | ||
|
||
. "`dirname "$0"`/../functions"; init | ||
|
||
sippbg -m 1 -sf uas.xml -p 5070 -i 127.0.0.1 \ | ||
-timeout 4 -timeout_error -trace_logs \ | ||
-log_file log.log >/dev/null 2>&1 | ||
|
||
job=$! | ||
|
||
sippfg -m 1 -sf uac.xml -i 127.0.0.1 -p 5060 127.0.0.1:5070 \ | ||
-timeout 4 -timeout_error >/dev/null 2>&1 | ||
|
||
status=$? | ||
wait $job || status=1 | ||
|
||
|
||
if test $status -ne 0; then | ||
fail "process failure" | ||
elif ! grep -qF 'LAST Contact|Contact: <sip:[email protected]:5060>' log.log; then | ||
fail "[last_Contact] header not found" | ||
elif ! grep -qF 'LAST Contact:|Contact: <sip:[email protected]:5060>' log.log; then | ||
fail "[last_Contact:] header not found" | ||
elif ! grep -qF 'LAST From:value|"Tom Jones" <sip:[email protected]>;tag=SIPpTag001' log.log; then | ||
fail "[last_From:value] not found" | ||
elif ! grep -qF 'LAST To:uri|sip:[email protected]' log.log; then | ||
fail "[last_To:uri] not found" | ||
elif ! grep -qF 'LAST From:param.tag|SIPpTag001' log.log; then | ||
fail "[last_From:param.tag] not found" | ||
fi | ||
|
||
ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<!DOCTYPE scenario SYSTEM "sipp.dtd"> | ||
<scenario> | ||
<send retrans="500" start_txn="invite"> | ||
<![CDATA[ | ||
|
||
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0 | ||
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=justafake | ||
From: "Tom Jones" <sip:[email protected]>;tag=SIPpTag00[call_number] | ||
To: "Fromage" <sip:[email protected]> | ||
Call-ID: [call_id] | ||
CSeq: 1 INVITE | ||
Contact: <sip:sipp@[local_ip]:[local_port]> | ||
Content-Length: 0 | ||
|
||
]]> | ||
</send> | ||
|
||
<recv response="200" response_txn="invite" rrs="true"/> | ||
|
||
<send retrans="500" ack_txn="invite"> | ||
<![CDATA[ | ||
|
||
ACK [next_url] SIP/2.0 | ||
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=justafake | ||
From: "Tom Jones" <sip:[email protected]>;tag=SIPpTag00[call_number] | ||
To: "Fromage" <sip:[email protected]>[peer_tag_param] | ||
Call-ID: [call_id] | ||
CSeq: 1 ACK | ||
Contact: sip:sipp@[local_ip]:[local_port] | ||
Content-Length: 0 | ||
|
||
]]> | ||
</send> | ||
|
||
<recv request="BYE"/> | ||
|
||
<send> | ||
<![CDATA[ | ||
|
||
SIP/2.0 200 OK | ||
[last_Via:] | ||
[last_From:] | ||
[last_To:] | ||
[last_Call-ID:] | ||
[last_CSeq:] | ||
Contact: <sip:[local_ip]:[local_port];transport=[transport]> | ||
Content-Length: 0 | ||
|
||
]]> | ||
</send> | ||
|
||
<timewait milliseconds="500"/> | ||
</scenario> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<!DOCTYPE scenario SYSTEM "sipp.dtd"> | ||
<scenario> | ||
<recv request="INVITE"/> | ||
|
||
<send retrans="500"> | ||
<![CDATA[ | ||
|
||
SIP/2.0 200 OK | ||
[last_Contact] | ||
[last_via] | ||
From: [last_From:value] | ||
To: [last_To:value];tag=[pid]SIPpTag00[call_number] | ||
Call-ID: [last_Call-ID:value] | ||
CSeq: [last_CSeq:value] | ||
Contact: sip:sipp@[local_ip]:[local_port] | ||
Content-Length: 0 | ||
|
||
]]> | ||
</send> | ||
|
||
<recv request="ACK" rrs="true"> | ||
<action> | ||
<log message="LAST Contact|[last_Contact]" /> | ||
<log message="LAST Contact:|[last_Contact:]" /> | ||
<log message="LAST Contact:uri|[last_Contact:uri]"/> | ||
<log message="LAST Via:value[last_Via:value]"/> | ||
<log message="LAST From:value|[last_From:value]"/> | ||
<log message="LAST To:value|[last_To:value]"/> | ||
<log message="LAST To:uri|[last_To:uri]"/> | ||
<log message="LAST From:param.tag|[last_From:param.tag]"/> | ||
</action> | ||
</recv> | ||
|
||
<send retrans="500"> | ||
<![CDATA[ | ||
|
||
BYE [next_url] SIP/2.0 | ||
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] | ||
From: [last_To:value] | ||
To: [last_From:value] | ||
Call-ID: [call_id] | ||
CSeq: 2 BYE | ||
Contact: sip:sipp@[local_ip]:[local_port] | ||
Content-Length: 0 | ||
|
||
]]> | ||
</send> | ||
|
||
<recv response="200"/> | ||
|
||
<timewait milliseconds="500"/> | ||
</scenario> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,32 +70,72 @@ static const char *internal_hdrend(const char *ptr); | |
|
||
/*************************** Mini SIP parser (externals) ***************/ | ||
|
||
char * get_peer_tag(const char *msg) | ||
char * get_header_uri(const char *msg, const char *name, const char *shortname) | ||
{ | ||
char * start; | ||
char * end; | ||
const char * hdr; | ||
static char last_request_uri[MAX_HEADER_LEN]; | ||
int uri_len; | ||
|
||
/* Find start of header */ | ||
hdr = internal_find_header(msg, name, shortname, true); | ||
if (!hdr) { | ||
WARNING("No valid %s: header found", name); | ||
return NULL; | ||
} | ||
|
||
start = strchr((char*)hdr, '<'); | ||
if (!start) { | ||
return NULL; | ||
} | ||
start++; | ||
|
||
end = strchr((char*)hdr, '>'); | ||
if (!end) { | ||
return NULL; | ||
} | ||
|
||
uri_len = strlen(start) - strlen(end); | ||
if (uri_len < 0) { | ||
return NULL; | ||
} | ||
|
||
last_request_uri[0] = '\0'; | ||
if (start && (uri_len > 0)) { | ||
strncpy(last_request_uri, start, uri_len); | ||
} | ||
last_request_uri[uri_len] = '\0'; | ||
|
||
return last_request_uri; | ||
} | ||
|
||
char * get_param(const char *msg, const char * param, const char *name, const char *shortname) | ||
{ | ||
static char tag[MAX_HEADER_LEN]; | ||
const char * to_hdr; | ||
const char * hdr; | ||
const char * ptr; | ||
int tag_i = 0; | ||
|
||
/* Find start of header */ | ||
to_hdr = internal_find_header(msg, "To", "t", true); | ||
if (!to_hdr) { | ||
WARNING("No valid To: header in reply"); | ||
hdr = internal_find_header(msg, name, shortname, true); | ||
if (!hdr) { | ||
WARNING("No valid %s: header in reply", name); | ||
return NULL; | ||
} | ||
|
||
/* Skip past display-name */ | ||
/* FIXME */ | ||
|
||
/* Skip past LA/RA-quoted addr-spec if any */ | ||
ptr = internal_hdrchr(to_hdr, '>'); | ||
ptr = internal_hdrchr(hdr, '>'); | ||
if (!ptr) { | ||
/* Maybe an addr-spec without quotes */ | ||
ptr = to_hdr; | ||
ptr = hdr; | ||
} | ||
|
||
/* Find tag in this header */ | ||
ptr = internal_find_param(ptr, "tag"); | ||
ptr = internal_find_param(ptr, param); | ||
if (!ptr) { | ||
return NULL; | ||
} | ||
|
@@ -109,6 +149,11 @@ char * get_peer_tag(const char *msg) | |
return tag; | ||
} | ||
|
||
char * get_peer_tag(const char *msg) | ||
{ | ||
return get_param(msg, "tag", "To", "t"); | ||
} | ||
|
||
char * get_header_content(const char* message, const char * name) | ||
{ | ||
return get_header(message, name, true); | ||
|
@@ -575,4 +620,19 @@ TEST(Parser, get_call_id_github_0101) { // github-#0101 | |
EXPECT_STREQ("[email protected]", get_call_id(input)); | ||
} | ||
|
||
TEST(Parser, get_header_uri) { | ||
EXPECT_STREQ("[email protected]", get_header_uri("...\r\nContact: <[email protected]>;test=123\r\n\r\n", "Contact", "")); | ||
} | ||
|
||
TEST(Parser, get_param) { | ||
EXPECT_STREQ("123", get_param("...\r\nContact: <[email protected]>;test=123\r\n\r\n", "test", "Contact", "")); | ||
} | ||
|
||
TEST(Parser, get_header) { | ||
EXPECT_STREQ("Contact: <[email protected]>;test=123", get_header("...\r\nContact: <[email protected]>;test=123\r\n\r\n", "Contact:", false)); | ||
} | ||
|
||
TEST(Parser, get_header_content) { | ||
EXPECT_STREQ("<[email protected]>;test=123", get_header("...\r\nContact: <[email protected]>;test=123\r\n\r\n", "Contact:", true)); | ||
} | ||
#endif //GTEST |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done without so much nesting with negative tests instead: