{"id":85,"date":"2020-01-22T15:25:48","date_gmt":"2020-01-22T14:25:48","guid":{"rendered":"https:\/\/www.collabeer.com\/?p=85"},"modified":"2020-06-08T10:56:12","modified_gmt":"2020-06-08T10:56:12","slug":"cisco-phone-not-receiving-calls-from-a-3rd-party-pbx-via-sip-trunk","status":"publish","type":"post","link":"https:\/\/collabeer.com\/?p=85","title":{"rendered":"Cisco Phone not receiving calls from a 3rd party PBX via SIP-Trunk"},"content":{"rendered":"\n<p>Today I had\nan issue on an incoming SIP Trunk from an Avaya PBX to a CUCM. The calling name\nof the Avaya users included a \u201cgreater as\u201d-sign ( &gt; ). This mixed up the\nContact field on CUCM and the phones were sending back a \u201c400 Bad Request\u201d.<\/p>\n\n\n\n<p>In the incoming INVITE, the Contact field looked like this:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Contact: &#8220;John Doe &gt;1000&#8221; &lt;sip:1000@10.xxx.xxx.xxx:5061;transport=tls;gsid=80b03730-2d3d-4a01-958f-5bff121d0000&gt;<\/p><\/blockquote>\n\n\n\n<p>The CUCM then sent it to the phone like this:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Contact: &lt;sip:1000@10.xxx.xxx.xxx:5060;transport=tcp&gt;1000&#8243; &lt;sip:1000@10.xxx.xxx.xxx:5061;transport=tls;gsid=80644a7a-4f3c-4a01-9830-5bff121d0000&gt;<\/p><\/blockquote>\n\n\n\n<p>The phone came back with a 400:<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>SIP\/2.0 400 Bad Request<br>Via: SIP\/2.0\/TCP 10.xxx.xxx.xxx:5060;branch=z9hG4bK5391c7ca89d90<br>From: &#8220;John Doe &gt;1000&#8221; &lt;sip:1000@10.xxx.xxx.xxx &gt;;tag=2812787~ab46fa2c-6c59-41ed-818f-ce5a53804375-44072776<br>To: &lt;sip:+41xxxxxxxxx@cucm-002.example.com&gt;<br>Call-ID: 545dc800-1eb15a39-4d012-1620ed0a@10.xxx.xxx.xxx<br>Session-ID: 157ee9db00105000a0000072784970f4;remote=9f1f3bd2c18dc694892250dab2812786<br>Date: Wed, 22 Jan 2020 10:11:04 GMT<br>Warning: 399 Cisco-CP8851 &#8220;Bad Request &#8211; &#8216;Malformed\/Missing Contact field'&#8221;<br>CSeq: 101 INVITE<br>Content-Length: 0<\/p><\/blockquote>\n<\/div><\/div>\n\n\n\n<p>As you can see, the CUCM malformed the Contact fiel with putting the \u201c&gt;1000\u201d after the first part:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Contact: &lt;sip:1000@10.xxx.xxx.xxx:5060;transport=tcp&gt;<strong>1000&#8243;<\/strong> &lt;sip:1000@10.xxx.xxx.xxx:5061;transport=tls;gsid=80644a7a-4f3c-4a01-9830-5bff121d0000&gt;<\/p><\/blockquote>\n\n\n\n<p>Because it was not possible to change all the names in the Avaya system because of different reasons, I had to fix it on the CUCM. I decided to create a SIP Normalization script, which removes the calling name from the INVITE coming from the Avaya PBX.<\/p>\n\n\n\n<p>After the normalization, the Contact field looked then like this:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Contact:&lt;sip:1000@10.xxx.xxx.xxx:5061;transport=tls;gsid=80b03730-2d3d-4a01-958f-5bff121d0000&gt;<\/p><\/blockquote>\n\n\n\n<p>The CUCM\ncan now handle the correctly and the phones are receiving the calls.<\/p>\n\n\n\n<p>An interesting thing we saw, the calls which were routed to an MRA-Device via Expressway, could receive the calls despite the issue. Probably the Expressway could handle the malformed INVITE or does not check the Contact Field.<\/p>\n\n\n\n<p>Here the script I\u2019ve created:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>M = {}<br>function M.inbound_ANY(msg)<br>   trace.enable()<br>   trace.format(&#8220;Fix malformed contact&#8221; )<br>&#8212; Get Contact-Info Header. If there was no Call-Info header then return<br>   local contactInfo = msg:getHeader(&#8220;Contact&#8221;)<br>if not contactInfo<br>   then<br>     trace.format(&#8220;Contact is empty, returning&#8221; )<br>     return<br>   end<br>   trace.format(&#8220;ContactInfo is %s&#8221;, contactInfo )<br>&#8212; extract the contact-Info<br>   local start_contact = string.find(contactInfo, &#8220;sip:&#8221;)<br>   local contact_new = string.sub(contactInfo, start_contact-1)<br>trace.format(&#8220;ContactInfo New is %s&#8221;, contact_new )<br>&#8212; replace the header<br>   msg:modifyHeader(&#8220;Contact&#8221;, contact_new)<br>   trace.format(&#8220;header modified&#8221;)<br>end<br> return M<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Today I had an issue on an incoming SIP Trunk from an Avaya PBX to a CUCM. The calling name of the Avaya users included a \u201cgreater as\u201d-sign ( &gt; ). This mixed up the Contact field on CUCM and the phones were sending back a \u201c400 Bad Request\u201d. In the incoming INVITE, the Contact [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,4],"tags":[8,9,10,13,21,22,23],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-cisco","category-cucm","tag-3rdparty","tag-bad-request","tag-calling-name","tag-cucm","tag-normalization","tag-sip","tag-trunk"],"_links":{"self":[{"href":"https:\/\/collabeer.com\/index.php?rest_route=\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/collabeer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/collabeer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/collabeer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/collabeer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":1,"href":"https:\/\/collabeer.com\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":168,"href":"https:\/\/collabeer.com\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions\/168"}],"wp:attachment":[{"href":"https:\/\/collabeer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/collabeer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/collabeer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}