Skip to content
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

Via branch non RFC 3261 compliant #145

Closed
procedurallygenerated opened this issue Dec 2, 2013 · 8 comments
Closed

Via branch non RFC 3261 compliant #145

procedurallygenerated opened this issue Dec 2, 2013 · 8 comments
Assignees
Labels
Milestone

Comments

@procedurallygenerated
Copy link

Options packet sent from opensips to oversip,

OPTIONS sip:1001@df7jal23ls0d.invalid;rtcweb-breaker=yes;transport=ws;ov-ob=6bce984846 SIP/2.0
Via: SIP/2.0/UDP 10.238.201.229:5060;branch=0
Route: <sip:10.0.0.161:5060;transport=udp;lr;ovid=3869ae8a>,<sip:6bce984846@10.0.0.161:10080;transport=ws;lr;ovid=3869ae8a;ob>
From: sip:pinger@XXX.XXX.XXX.XXX;tag=c1c23161
To: sip:1001@df7jal23ls0d.invalid;rtcweb-breaker=yes;transport=ws;ov-ob=6bce984846
Call-ID: 11693e73-d6...@10.238.201.229
CSeq: 1 OPTIONS
Max-Forwards: 70
Content-Length: 0

Response from oversip to opensips,

SIP/2.0 400 Via branch non RFC 3261 compliant
Via: SIP/2.0/UDP 10.238.201.229:5060;branch=0;received=XXX.XXX.XXX.XXX
From: sip:pinger@XXX.XXX.XXX.XXX;tag=c1c23161
To: sip:1001@df7jal23ls0d.invalid;rtcweb-breaker=yes;transport=ws;ov-ob=6bce984846;tag=a360ead4.29d19ef0
Call-ID: 11693e73-d6...@10.238.201.229
CSeq: 1 OPTIONS
Content-Length: 0
Server: OverSIP/1.4.1

When sending the options packet to non-webrtc clients there is no problem, but when sending it to webrtc clients through oversip, oversip expects the branch tag to have a value.

@procedurallygenerated
Copy link
Author

Since this is an options packet it will not need to be re-transmitted so i generated a random 7 digit number for each option packet and appended it to the RFC 3261 string "z9hG4bK". My C skills are not great but this is what i did to fix this for myself, if someone can come up with a better method and commit to the code that will be great.

In modules/nathelper/sip_pinger.h

Line 31:

#include<string.h>

Line 145:

const long MAX_BRANCHID = 9999999;
const long MIN_BRANCHID = 1000000;
long result=(long)(rand()/(float)2147483647 * (MAX_BRANCHID-MIN_BRANCHID) + MIN_BRANCHID);
char branch_id[7];
sprintf(branch_id, "%ld", result);
char branch[22]=";branch=z9hG4bK";
strcat(branch,branch_id);
if ( sipping_method.len + 1 + curi->len + s_len(" SIP/2.0"CRLF) +
    s_len("Via: SIP/2.0/") + st.len + s->address_str.len +
    1 + s->port_no_str.len + strlen(branch) +

Line 180:

append_fix( p, branch);
append_fix( p, CRLF"Route: ");

Line 185:

append_fix( p, branch);
append_fix( p, CRLF"From: ");

@ibc
Copy link
Contributor

ibc commented Dec 2, 2013

2013/12/2 Varun notifications@github.com

When sending the options packet to non-webrtc clients there is no problem,
but when sending it to webrtc clients through oversip, oversip expects the
branch tag to have a value.

Yes, that 's a bug in OpenSIPS as it sets ;branch=0 which is not RFC 3261
compliant.

Iñaki Baz Castillo
ibc@aliax.net

@bogdan-iancu
Copy link
Member

Point taken ! varunvairavan idea is ok, I will integrate it into the code.

Thank too all for report and comments.

@ghost ghost assigned bogdan-iancu Dec 5, 2013
@saghul
Copy link
Member

saghul commented Dec 5, 2013

FWIW, I think nat_traversal does the same. @ibc shouldn't OverSIP be gentle in what it accepts? ;-)

@bogdan-iancu
Copy link
Member

Hi, the fix was uploaded on trunk. I tested the nathelper part, but I would appreciate @saghul if you could test the nat_traversal part too.
Once you ( @varunvairavan and @saghul ) can confirm the fix, I will make the backports.

Thanks,
Bogdan

@saghul
Copy link
Member

saghul commented Dec 6, 2013

I have not tested the code, but looks good to me :-)

@procedurallygenerated
Copy link
Author

1f18541 The int2bstr took a fews mins to wrap around my head. Looks good. Thank you for the fast turn around.

bogdan-iancu added a commit that referenced this issue Dec 10, 2013
Credits go to Varun (varunvairavan on GITHUB)
Closes #145

(cherry picked from commit 1f18541)
bogdan-iancu added a commit that referenced this issue Dec 10, 2013
Credits go to Varun (varunvairavan on GITHUB)
Closes #145

(cherry picked from commit 1f18541)
bogdan-iancu added a commit that referenced this issue Dec 10, 2013
Credits go to Varun (varunvairavan on GITHUB)
Closes #145

(cherry picked from commit 1f18541)

Conflicts:
	modules/nathelper/sip_pinger.h
@bogdan-iancu
Copy link
Member

Backport done, closing....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants