This function is behind `$si` variable that is supposed to return plain source ip address. The `[]` around IPv6 is required in URIs, but the IP address itself is without `[]`.
The function is not used from other modules, therefore you use `$si` in your configuration file somewhere. Can you check that?
You can replace do:
``` if(af==INET6) { $var(si) = "[" + $si + "]"; } else { $var(si) = $si; } ```
Then use $var(si) instead of $si. Maybe a variable to get the source ip with square brackets would be useful, but that will be a new feature, $si will stay as it is, because it is useful in many cases.
Anyhow, it looks like an issue in kamailio.cfg, not in code.