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>