<p>My opinion is it is better to just change the existing code, and all existing installations will start working with IPv6 when they upgrade. It is also much simpler.</p>
<p>However, the following has been tested and also works to add a $ function that returns a correct IP string for IPv6:</p>
<p>The following would need to be added to the table in modules/pv/pv.c<br>
{{"sibr", (sizeof("sibr")-1)}, /* */<br>
PVT_OTHER, pv_get_srcip_bracket, 0,<br>
0, 0, 0, 0},</p>
<p>Then a new function in modules/pv/pv.c<br>
/* The following fundtion gets the source IP with brackets for IPv6  */<br>
int pv_get_srcip_bracket(struct sip_msg *msg, pv_param_t *param,<br>
pv_value_t *res)<br>
{<br>
str s;<br>
if(msg==NULL)<br>
return -1;</p>
<pre><code>    s.s = ip_addr2strz(&msg->rcv.src_ip);
    s.len = strlen(s.s);
    return pv_get_strval(msg, param, res, &s);
</code></pre>
<p>}</p>
<p>Finally, a change to the config file line:<br>
append_hf("Path: sip:term@HOSTNAME:"+PORT+";nat=yes;received=sip:$sibr:$sp;$var(ws_transport)lr\r\n")</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1136#issuecomment-310497694">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZQQubVattNvuDhBfI2oO09KFaXvlks5sGtKOgaJpZM4NkKgo">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZXnnQsY2zlk_c9vg3QsrgPUFpE-Fks5sGtKOgaJpZM4NkKgo.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/1136#issuecomment-310497694"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@doncarr in #1136: My opinion is it is better to just change the existing code, and all existing installations will start working with IPv6 when they upgrade. It is also much simpler.\r\n\r\nHowever, the following has been tested and also works to add a $ function that returns a correct IP string for IPv6:\r\n\r\nThe following would need to be added to the table in modules/pv/pv.c \r\n        {{\"sibr\", (sizeof(\"sibr\")-1)}, /* */\r\n                PVT_OTHER, pv_get_srcip_bracket, 0,\r\n                0, 0, 0, 0},\r\n\r\nThen a new function in modules/pv/pv.c \r\n/* The following fundtion gets the source IP with brackets for IPv6  */\r\nint pv_get_srcip_bracket(struct sip_msg *msg, pv_param_t *param,\r\n                pv_value_t *res)\r\n{\r\n        str s;\r\n        if(msg==NULL)\r\n                return -1;\r\n\r\n        s.s = ip_addr2strz(\u0026msg-\u003ercv.src_ip);\r\n        s.len = strlen(s.s);\r\n        return pv_get_strval(msg, param, res, \u0026s);\r\n}\r\n\r\nFinally, a change to the config file line:\r\n               append_hf(\"Path: \u003csip:term@HOSTNAME:\"+PORT+\";nat=yes;received=sip:$sibr:$sp;$var(ws_transport)lr\u003e\\r\\n\")\r\n\r\n"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1136#issuecomment-310497694"}}}</script>