[asterisk-bugs] [JIRA] (ASTERISK-24807) Missing mandatory field Max-Forwards

Asterisk Team (JIRA) noreply at issues.asterisk.org
Wed Jul 27 10:26:08 CDT 2016


     [ https://issues.asterisk.org/jira/browse/ASTERISK-24807?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Asterisk Team updated ASTERISK-24807:
-------------------------------------

    Target Release Version/s: 14.0.0

> Missing mandatory field Max-Forwards
> ------------------------------------
>
>                 Key: ASTERISK-24807
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-24807
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: pjproject/pjsip
>    Affects Versions: 13.2.0
>         Environment: OS: Ubuntu 12.04 inside VirtualBox, with all updates
> Kernel: 3.8.0-29-generic
> pjsip: 2.3 from http://www.pjsip.org/release/2.3/pjproject-2.3.tar.bz2 (./configure --prefix=/usr --enable-shared --enable-epoll; make; sudo make install)
> Asterisk: 13.2.0 from http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.2.0.tar.gz (./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var; make; sudo make install)
>            Reporter: Anatoli
>            Assignee: Richard Mudgett
>            Severity: Critical
>      Target Release: 13.3.0, 14.0.0
>
>
> While evaluating the latest Asterisk and PJSIP (both compiled from sources), when calling to/from softphones (in particular the latest Linphone v.3.7.0) the INVITE messages from Asterisk are rejected due to the specification violation.
> Here are more people having the same problem: http://comments.gmane.org/gmane.comp.telephony.pbx.asterisk.user/281228 and http://lists.digium.com/pipermail/asterisk-dev/2003-July/001114.html.
> Linphone has a debug option: {{linphone.exe --logfile "c:\Temp\logs.txt"}} and in the generated logfile one can see something like:
> {code}[error] Missing mandatory header [Max-Forwards] for message [INVITE]{code}
> \\
> And this is what Asterisk sends to it:
> {code}
> INVITE sip:6002 at 192.168.56.102 SIP/2.0
> Via: SIP/2.0/UDP 192.168.56.3:5060;rport;branch=z9hG4bKPjbf53c93c-a424-4b9e-9e6a-b50d0e606965
> From: <sip:6001 at 192.168.56.3>;tag=deeff9b9-50ab-410e-b683-94fdeb9f87b3
> To: <sip:6002 at 192.168.56.102>
> Contact: <sip:9426fd27-7ccd-4e1e-ab7a-e6c27fc59a5c at 192.168.56.3:5060>
> Call-ID: 5b517cda-634b-4036-bb81-95a43379c09d
> CSeq: 6848 INVITE
> Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
> Supported: 100rel, timer, replaces, norefersub
> Session-Expires: 1800
> Min-SE: 90
> Content-Type: application/sdp
> Content-Length:   254
> {code}
> So indeed, there is no "Max-Forwards" header sent with the INVITE requests, but, according to the SIP RFC 3261: "A valid SIP request formulated by a UAC MUST, at a minimum, contain the following header fields: To, From, CSeq, Call-ID, Max-Forwards, and Via; all of these header fields are mandatory in all SIP requests."
> \\
> After researching a bit the source code of pjsip, I found that actually almost all messages originating from it don't have Max-Forwards fields.
> I've tried to add the header manually and it solves the problem (this is not a definitive solution; it has some minor issues):
> {code}
> --- pjproject-2.3/pjsip/src/pjsip/sip_util.c.orig  2014-08-18 05:54:43.000000000 -0300
> +++ pjproject-2.3/pjsip/src/pjsip/sip_util.c        2015-02-17 10:52:23.839673699 -0300
> @@ -465,6 +465,8 @@ PJ_DEF(pj_status_t) pjsip_endpt_create_r
>      }
>      PJ_END;
> +             pjsip_msg_add_hdr(tdata->msg, pjsip_max_fwd_hdr_create(tdata->pool, 70)); 
> +
>      *p_tdata = tdata;
>      return PJ_SUCCESS;
> {code}
> But then I've discussed it with people at pjsip at lists.pjsip.org (here is the thread: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2015-February/018120.html) and they suggest that the issue is actually within the code that integrates pjsip with asterisk (e.g. {{res/res_pjsip/config_global.c}}) and suggested filling an issue here.
> \\
> This problem is a show-stopper when there are softphones among the endpoints.
> \\
> \\
> \\
> *UPDATE*: Harald Radke pointed out in the discussion at pjsip at lists.pjsip.org:
> {quote}having a quick look at res_pjsip.c of the asterisk res(ource?):
> {noformat}
>     /* PJSIP will automatically try to add a Max-Forwards header. Since we want to control that,
>      * we need to stop PJSIP from doing it automatically
>      */
>     remove_request_headers(ast_pjsip_endpoint);
> {noformat}
> Thus this asterisk code clearly modifies the default behaviour of PJSIP thus it is up to either the user to configure it properly (maybe there is a Max-Forwards option in a config file which, if not set, will result in not putting in a max-forwards header field with a default value) or it is a bug in res-pjsip.
> {quote}
> So indeed, it looks like a bug in res_pjsip.
> \\
> \\
> ----
> \\
> \\
> STEPS TO REPRODUCE
> *extensions.conf*
> {code}
> [general]
> language=en
> static=yes
> writeprotect=no
> autofallthrough=yes
> [internal]
> exten => 6001,1,Dial(PJSIP/6001,20)
> same => n,Hangup()
> exten => 6002,1,Dial(PJSIP/6002,20)
> same => n,Hangup()
> {code}
> *pjsip.conf*
> {code}
> [transport-udp]
> type=transport
> protocol=udp
> bind=192.168.56.3
> [6001]
> type=endpoint
> transport=transport-udp
> context=internal
> allow=ulaw
> allow=gsm
> auth=6001
> aors=6001
> device_state_busy_at=1
> allow_subscribe=yes
> sub_min_expiry=30
> [6001]
> type=auth
> auth_type=userpass
> password=6001
> username=6001
> [6001]
> type=aor
> max_contacts=1
> contact=sip:6001 at 192.168.56.101
> [6002]
> type=endpoint
> transport=transport-udp
> context=internal
> allow=ulaw
> allow=gsm
> auth=6002
> aors=6002
> device_state_busy_at=1
> allow_subscribe=yes
> sub_min_expiry=30
> [6002]
> type=auth
> auth_type=userpass
> password=6002
> username=6002
> [6002]
> type=aor
> max_contacts=1
> contact=sip:6002 at 192.168.56.102
> {code}
> Start asterisk:
> {{# /usr/sbin/asterisk}}
> Then configure the extensions in 2 Linphones (in wizard: user/pass =
> 600x/600x and domain: 192.168.56.3) and try to make a call from one Linphone to another.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list