{"id":11531,"date":"2012-02-21T18:12:02","date_gmt":"2012-02-21T17:12:02","guid":{"rendered":"https:\/\/www.saasweb.agency\/blog\/comment-afficher-le-numero-de-telephone-lors-dappels-entre-abonnes-sipgate-et-asterisk-au-lieu-de-lidentifiant-interne-sipgate\/"},"modified":"2026-10-27T08:28:32","modified_gmt":"2026-10-27T07:28:32","slug":"comment-afficher-le-numero-de-telephone-lors-dappels-entre-abonnes-sipgate-et-asterisk-au-lieu-de-lidentifiant-interne-sipgate","status":"publish","type":"post","link":"https:\/\/www.saasweb.agency\/fr\/blog\/comment-afficher-le-numero-de-telephone-lors-dappels-entre-abonnes-sipgate-et-asterisk-au-lieu-de-lidentifiant-interne-sipgate\/","title":{"rendered":"Comment afficher le num\u00e9ro de t\u00e9l\u00e9phone lors d\u2019appels entre abonn\u00e9s Sipgate et Asterisk (au lieu de l\u2019identifiant interne Sipgate) ?"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.saasweb.agency\/wp-content\/uploads\/2012\/02\/asterisk-logo.jpg\" alt=\"Ast\u00e9risque\" title=\"asterisk-logo\" width=\"138\" height=\"79\" class=\"alignleft size-full wp-image-774\" srcset=\"https:\/\/www.saasweb.agency\/wp-content\/uploads\/2012\/02\/asterisk-logo.jpg 138w, https:\/\/www.saasweb.agency\/wp-content\/uploads\/2012\/02\/asterisk-logo-50x29.jpg 50w, https:\/\/www.saasweb.agency\/wp-content\/uploads\/2012\/02\/asterisk-logo-100x57.jpg 100w\" sizes=\"(max-width: 138px) 100vw, 138px\" \/>Les appels entre abonn\u00e9s Sipgate sont automatiquement rout\u00e9s en tant qu\u2019appels SIP, m\u00eame si l\u2019on appelle le num\u00e9ro de t\u00e9l\u00e9phone \u00ab externe \u00bb. Cela pr\u00e9sente l\u2019avantage que les appels entre abonn\u00e9s Sipgate sont gratuits, car les communications passent par Internet. Il serait toutefois appr\u00e9ciable de savoir qui m\u2019appelle \ud83d\ude09  <\/p>\n<p><strong>Probl\u00e8me :<\/strong><br \/>\nDans l\u2019en-t\u00eate <code>From<\/code> ne figure pas le num\u00e9ro de t\u00e9l\u00e9phone de l\u2019appelant, mais l\u2019URL SIP (par ex. <code>&lt;sip:12345e0@sipgate.de&gt;<\/code>). La variable <code>CALLERID(num)<\/code> d\u00e9finie par Asterisk ne contient alors plus que l\u2019identifiant utilisateur SIP de Sipgate, comme par ex. <code>12345e0<\/code>. La plupart du temps, les t\u00e9l\u00e9phones connect\u00e9s \u00e0 Asterisk ne peuvent rien en faire. Si l\u2019identifiant contient une lettre (ici dans l\u2019exemple \u00ab <code>e<\/code> \u00bb), certains t\u00e9l\u00e9phones plus anciens n\u2019affichent aucun num\u00e9ro. Il est particuli\u00e8rement frustrant de manquer un appel et de ne plus pouvoir identifier qui a r\u00e9ellement appel\u00e9.    <\/p>\n<p><strong>Solution :<\/strong><br \/>\nEn examinant les en-t\u00eates SIP, on constate que l\u2019information souhait\u00e9e est contenue dans l\u2019\u00e9l\u00e9ment d\u2019en-t\u00eate <strong>\u00ab P-Asserted-Identity \u00bb<\/strong> :<\/p>\n<div class=\"code-snippet\">\n<code style=\"font-size: 12px;\">INVITE sip:5000@10.0.0.33 SIP\/2.0<br \/>\n...<br \/>\nFrom: &lt;sip:12345e0@sipgate.de&gt;;tag=CAFEBABE<br \/>\nTo: &lt;sip:072198765432@sipgate.de&gt;<br \/>\nContact: &lt;sip:12345e0@12.34.56.78;uniq=CAFEAFFE23&gt;<br \/>\n...<br \/>\n<strong>P-Asserted-Identity<\/strong>: &lt;sip:072112345678@sipgate.de&gt;<\/code><\/div>\n<p>Le format peut varier chez d\u2019autres fournisseurs. Pour en savoir plus, consultez <a href=\"http:\/\/www.ietf.org\/rfc\/rfc3325.txt\" target=\"_blank\" rel=\"noopener\">http:\/\/www.ietf.org\/rfc\/rfc3325.txt<\/a>. <\/p>\n<p>\u00c0 des fins de d\u00e9monstration, j\u2019ai \u00e9crit un petit plan de num\u00e9rotation (dialplan) pour Asterisk :<\/p>\n<div class=\"code-snippet\">\n<code style=\"font-size: 12px;\">; debug<br \/>\nexten =&gt; 5000,1,NoOp(Caller-ID: ${CALLERID(all)})<br \/>\nexten =&gt; 5000,2,NoOp(SIP From: ${SIP_HEADER(From)})<br \/>\nexten =&gt; 5000,3,NoOp(SIP To  : ${SIP_HEADER(TO)})<br \/>\nexten =&gt; 5000,4,NoOp(SIP PAI : ${SIP_HEADER(P-Asserted-Identity)})<\/p>\n<p>; try to extract phone number from sip header P-Asserted-Identity<br \/>\nexten =&gt; 5000,5,Set(FON=$[\"${SIP_HEADER(P-Asserted-Identity)}\" : \"<sip: exten=\"&lt;encoded_tag_closed\"> 5000,6,ExecIf($[${ISNULL(${FON})}=0]?Set(CALLERID(num)=${FON}))<\/p>\n<p>; debug<br \/>\nexten =&gt; 5000,7,NoOp(Caller-ID: ${CALLERID(all)})<br \/>\n...<\/sip:><\/code><\/div>\n<p>Explication :<br \/>\n5 : Nous extrayons le num\u00e9ro avec <em>RegExp<\/em> et enregistrons le r\u00e9sultat dans la variable <code>FON<\/code>.<br \/>\n6 : Si <code>FON<\/code> n\u2019est pas nul, nous rempla\u00e7ons <code>CALLERID(num)<\/code> par la valeur de <code>FON<\/code>.<\/p>\n<p>Voici deux cas d\u2019utilisation et la sortie d\u2019Asterisk :<br \/>\nAbonn\u00e9s pour l\u2019exemple (les num\u00e9ros de t\u00e9l\u00e9phone, les adresses IP ainsi que toutes les balises sont masqu\u00e9s).<br \/>\n<span style=\"color: #0000ff;\">Appel\u00e9<\/span> (<strong>Asterisk<\/strong> avec compte Sipgate) :<br \/>\n&#8211; Num\u00e9ro de t\u00e9l\u00e9phone = <span style=\"color: #0000ff;\">072198765432<\/span><br \/>\n<span style=\"color: #ff0000;\">Appelant 1<\/span> (Fritzbox avec compte Sipgate) :<br \/>\n&#8211; Identifiant Sipgate = <span style=\"color: #ff0000;\">12345e0<\/span><br \/>\n&#8211; Num\u00e9ro de t\u00e9l\u00e9phone = <span style=\"color: #ff0000;\">072112345678<\/span><br \/>\n<span style=\"color: #008000;\">Appelant 2<\/span> (Mobile) :<br \/>\n&#8211; Num\u00e9ro de t\u00e9l\u00e9phone = <span style=\"color: #008000;\">017112345678<\/span><\/p>\n<p><strong>Cas 1 : Appelant 1 (sipgate -&gt; sipgate) :<\/strong><\/p>\n<div class=\"code-snippet\">\n<code style=\"font-size: 12px;\">-- Exec...1] NoOp(\"SIP\/sipgate.de-000000b6\", \"Caller-ID: \"\" <<span style=\"color: #ff0000;\">12345e0<\/span>>\") in new stack<br \/>\n-- Exec...2] NoOp(\"S..b6\", \"SIP From: <<span style=\"color: #ff0000;\">sip:12345e0@sipgate.de<\/span>>;tag=CAFEBABE\") in new stack<br \/>\n-- Exec...3] NoOp(\"S..b6\", \"SIP To  : <<span style=\"color: #0000ff;\">sip:072198765432@sipgate.de<\/span>>\") in new stack<br \/>\n-- Exec...4] NoOp(\"S..b6\", \"SIP PAI : <<span style=\"color: #ff0000;\">sip:072112345678@sipgate.de<\/span>>\") in new stack<br \/>\n-- Exec...5] Set(\"S..b6\", \"FON=<span style=\"color: #ff0000;\">072112345678<\/span>\") in new stack<br \/>\n-- Exec...6] ExecIf(\"S..b6\", \"<strong>1<\/strong>?Set(CALLERID(num)=<span style=\"color: #ff0000;\">072112345678<\/span>)\") in new stack<br \/>\n-- Exec...7] NoOp(\"S..b6\", \"Caller-ID: \"\" <<span style=\"color: #ff0000;\"><strong>072112345678<\/strong><\/span>>\") in new stack<br \/>\n-- Exec...8] ...<\/code><\/div>\n<p>Exec&#8230;5 : Le num\u00e9ro de t\u00e9l\u00e9phone externe de l\u2019appelant a \u00e9t\u00e9 inscrit dans FON<br \/>\nExec&#8230;6 : <code>1?<\/code> =&gt; condition remplie =&gt; remplacer CALLERID(num)<br \/>\nExec&#8230;7 : V\u00e9rification que le num\u00e9ro a \u00e9t\u00e9 remplac\u00e9 (cf. Exec&#8230;1)<\/p>\n<p><strong>Cas 2 : Appelant 2 (mobile -&gt; sipgate) :<\/strong><\/p>\n<div class=\"code-snippet\">\n<code style=\"font-size: 12px;\">-- Exec...1] NoOp(\"S..b8\", \"Caller-ID: \"<span style=\"color: #008000;\">017112345678<\/span>\" <<span style=\"color: #008000;\">017112345678<\/span>>\") in new stack<br \/>\n-- Exec...2] NoOp(\"S..b8\", \"SIP From: \"<span style=\"color: #008000;\">017112345678<\/span>\" <<span style=\"color: #008000;\">sip:017112345678@sipgate.de<\/span>>;tag=cafebabe\") in new stack<br \/>\n-- Exec...3] NoOp(\"S..b8\", \"SIP To  : <<span style=\"color: #0000ff;\">sip:004972198765432@sipgate.de<\/span>>\") in new stack<br \/>\n-- Exec...4] NoOp(\"S..b8\", \"SIP PAI : \") in new stack<br \/>\n-- Exec...5] Set(\"S..b8\", \"FON=\") in new stack<br \/>\n-- Exec...6] ExecIf(\"S..b8\", \"<strong>0<\/strong>?Set(CALLERID(num)=)\") in new stack<br \/>\n-- Exec...7] NoOp(\"S..b8\", \"Caller-ID: \"<span style=\"color: #008000;\">017112345678<\/span>\" <<span style=\"color: #008000;\">017112345678<\/span>>\") in new stack<br \/>\n-- Exec...8] ...<\/code><\/div>\n<p>Exec&#8230;5 : La correspondance de motif (pattern matching) \u00e9choue car l\u2019en-t\u00eate n\u2019est pas d\u00e9fini, la variable <code>FON<\/code> est donc <code>null<\/code>.<br \/>\nExec&#8230;6 : <code>0?<\/code> =&gt; condition non remplie =&gt; ne rien faire<br \/>\nExec&#8230;7 : V\u00e9rification que le num\u00e9ro est rest\u00e9 inchang\u00e9 (cf. Exec&#8230;1)<\/p>\n<p>Les terminaux affichent d\u00e9sormais toujours le num\u00e9ro de t\u00e9l\u00e9phone externe de l\u2019appelant. Ainsi, l\u2019appelant peut \u00e9galement \u00eatre rappel\u00e9 en cas d\u2019appel manqu\u00e9. <\/p>\n<p>Bonne continuation,<\/p>\n<p><em>= C. | Laboratoire technique SaaS Web =<\/em><\/p>\n<p>P.-S. : Il est amusant de constater que l\u2019application de Sipgate n\u2019affiche elle aussi que l\u2019identifiant interne (\u00ab Appel de 12345e0 \u00bb), ce qui pr\u00eate \u00e0 confusion sur l\u2019identit\u00e9 r\u00e9elle de l\u2019appelant&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Les appels entre abonn\u00e9s Sipgate sont automatiquement rout\u00e9s en tant qu\u2019appels SIP, m\u00eame si l\u2019on appelle le num\u00e9ro de t\u00e9l\u00e9phone \u00ab externe \u00bb. Cela pr\u00e9sente l\u2019avantage que les appels entre abonn\u00e9s Sipgate sont gratuits, car les communications passent par Internet. Il serait toutefois appr\u00e9ciable de savoir qui m\u2019appelle \ud83d\ude09 Probl\u00e8me : Dans l\u2019en-t\u00eate From ne \u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[924,816],"tags":[855,911,931,954,945,859,918,1473,977,956,888,858,1017,1426,1067,907,915,849,969,1146],"class_list":["post-11531","post","type-post","status-publish","format-standard","hentry","category-programmation","category-tutoriel","tag-sipgate-de","tag-appel-inter-sipgate","tag-asterisque","tag-callerid","tag-en-tete-sip","tag-entre-les-abonnes-sipgate","tag-execif-identification-de-lappelant","tag-extraire-le-numero-de-telephone","tag-laboratoire-technique","tag-manipulation-du-numero-dappel","tag-msn","tag-numero-de-telephone","tag-numero-de-telephone-incorrect","tag-p-affirme","tag-p-asserted-identity","tag-plan-de-numerotation","tag-rfc-3325","tag-saas-web","tag-sip","tag-sipgate"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/posts\/11531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/comments?post=11531"}],"version-history":[{"count":0,"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/posts\/11531\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/media?parent=11531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/categories?post=11531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.saasweb.agency\/fr\/wp-json\/wp\/v2\/tags?post=11531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}