RFC4235 tags and attributes in PJSIP NOTIFY event: dialog XML body

Hello,

I’m having a similar issue like in https://issues.asterisk.org/jira/browse/ASTERISK-24601, which makes 15.1.2 unusable with our custom softphone client. We are using the PJSIP stack. We need to receive “call-id” in SIP NOTIFY xml. Something similar to this xml:

<?xml version="1.0"?>\n
        <dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="0" state="full" entity="sip:71010@10.0.3.144:5566;transport=TCP">\n
          <dialog id="a7903edf84034ade9002d839f8e5c090" call-id="a7903edf84034ade9002d839f8e5c090" direction="recipient">\n
            <state>terminated</state>\n
            <remote>\n
              <identity>sip:71010@10.0.3.144:5566</identity>\n
              <target uri="sip:71010@10.0.3.144:5566;transport=TCP"/>\n
            </remote>\n
            <local>\n
              <identity>sip:61003@10.0.3.144</identity>\n
              <target uri="sip:61003@10.0.3.144"/>\n
            </local>\n
          </dialog>\n
        </dialog-info>\n

But in SIP NOTIFY messages appers only:

<?xml version="1.0" encoding="UTF-8"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="0" state="full" entity="sip:71010@10.0.3.144:5566;transport=TCP">
 <dialog id="71010">
  <state>confirmed</state>
 </dialog>
</dialog-info>

How can I to configure/change SIP SUBSCRIBE message or Asterisk configuration… to receive “call-id”.

Or it is need to be change code in “res_pjsip_dialog_info_body_generator.c” (Like in PJSIP Notify BLF )

Thanks,
Denislav

There is no ability to configure it to add a call-id. You would need to extend the module, but you would need to determine what dialogs are involved and in some cases there may not be one (Asterisk isn’t SIP centric). There is no easy or safe way to do this.

Hello, jcolp,

Thanks a lot for quick responce.

Have a nice day,
Denisalv

You can add a local node with identity and target. Here is with remote node, but populated with “0” instead of a real number:

In res/res_pjsip_dialog_info_body_generator.c:

        if (!ast_strlen_zero(statestring) && !strcmp(statestring, "early")) {
                pj_xml_node *dremote, *dri, *drt, *dlocal, *dli, *dlt;
                ast_sip_presence_xml_create_attr(state_data->pool, dialog, "direction", "recipient");

                dremote = ast_sip_presence_xml_create_node(state_data->pool, dialog, "remote");
                dri = ast_sip_presence_xml_create_node(state_data->pool, dremote, "identity");    
                // don't have remote number, so it is "0" at this moment
                ast_sip_presence_xml_create_attr(state_data->pool, dri, "display", "0");
                drt = ast_sip_presence_xml_create_node(state_data->pool, dremote, "target");
                ast_sip_presence_xml_create_attr(state_data->pool, drt, "uri", "0");
                pj_strdup2(state_data->pool, &dri->content, "0");

                dlocal = ast_sip_presence_xml_create_node(state_data->pool, dialog, "local");
                dli = ast_sip_presence_xml_create_node(state_data->pool, dlocal, "identity");
                ast_sip_presence_xml_create_attr(state_data->pool, dli, "display", state_data->exten);
                dlt = ast_sip_presence_xml_create_node(state_data->pool, dlocal, "target");
                ast_sip_presence_xml_create_attr(state_data->pool, dlt, "uri", sanitized);
                pj_strdup2(state_data->pool, &dli->content, sanitized);
        }

After a test call (notify, pickup with update,…):

pbx*CLI> pjsip show history 
No.   Timestamp  (Dir) Address                  SIP Message                        
===== ========== ============================== ===================================
00000 1551451719 * ==> 10.0.10.56:5060          NOTIFY sip:310@10.0.10.56:5060 SIP/2.0
00001 1551451719 * <== 10.0.10.56:5060          SIP/2.0 200 OK
00002 1551451719 * ==> 10.0.10.56:5060          NOTIFY sip:310@10.0.10.56:5060 SIP/2.0
00003 1551451719 * <== 10.0.10.56:5060          SIP/2.0 200 OK
00004 1551451721 * <== 10.0.10.56:5060          INVITE sip:**300@10.0.10.2:5070 SIP/2.0
00005 1551451721 * ==> 10.0.10.56:5060          SIP/2.0 401 Unauthorized
00006 1551451721 * <== 10.0.10.56:5060          ACK sip:**300@10.0.10.2:5070 SIP/2.0
00007 1551451721 * <== 10.0.10.56:5060          INVITE sip:**300@10.0.10.2:5070 SIP/2.0
00008 1551451721 * ==> 10.0.10.56:5060          SIP/2.0 100 Trying
00009 1551451721 * ==> 10.0.10.56:5060          SIP/2.0 200 OK
00010 1551451721 * <== 10.0.10.56:5060          ACK sip:10.0.10.2:5070 SIP/2.0
00011 1551451721 * ==> 10.0.10.56:5060          UPDATE sip:310@10.0.10.56:5060 SIP/2.0
00012 1551451721 * <== 10.0.10.56:5060          SIP/2.0 200 OK
00013 1551451721 * ==> 10.0.10.56:5060          NOTIFY sip:310@10.0.10.56:5060 SIP/2.0
00014 1551451721 * <== 10.0.10.56:5060          SIP/2.0 200 OK
00015 1551451723 * ==> 10.0.10.56:5060          BYE sip:310@10.0.10.56:5060 SIP/2.0
00016 1551451723 * <== 10.0.10.56:5060          SIP/2.0 200 OK

And here is the first Notify:

pbx*CLI> pjsip show history entry 0
<--- History Entry 0 Sent to 10.0.10.56:5060 at 1551451719 --->
NOTIFY sip:310@10.0.10.56:5060 SIP/2.0
Via: SIP/2.0/UDP 10.0.10.2:5070;rport;branch=z9hG4bKPj25fca11e-5965-41ee-a319-082fe453ce54
From: <sip:300@10.0.10.2>;tag=eeedca22-c9f7-441f-9cca-cf87d4e1661b
To: "310" <sip:310@10.0.10.2>;tag=1698880954
Contact: <sip:10.0.10.2:5070>
Call-ID: 0_3257247937@10.0.10.56
CSeq: 31177 NOTIFY
Event: dialog
Subscription-State: active;expires=1779
Allow-Events: presence, dialog, message-summary, refer
Max-Forwards: 70
User-Agent: Asterisk PBX 16.0.1
Content-Type: application/dialog-info+xml
Content-Length:   451

<?xml version="1.0" encoding="UTF-8"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="1" state="full" entity="sip:300@10.0.10.2:5070">
 <dialog id="300" direction="recipient">
  <remote>
   <identity display="0">0</identity>
   <target uri="0" />
  </remote>
  <local>
   <identity display="300">sip:300@10.0.10.2:5070</identity>
   <target uri="sip:300@10.0.10.2:5070" />
  </local>
  <state>early</state>
 </dialog>
</dialog-info>