aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorjim <jim@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-19 18:19:22 +0000
committerjim <jim@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-19 18:19:22 +0000
commit235be5c78591e55354e1f9ce818ff59c21ebe150 (patch)
tree8896c3d2095116bb874253a39fbb8b933264a8cd /channels/chan_iax2.c
parent58818426d60d583c4becc6a99b398cbac1b7b12f (diff)
Allow for obtaining IAX2 call peer (endpoint) IP address with IAXPEER(CURRENTCHAN) function
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6833 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rwxr-xr-xchannels/chan_iax2.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 6bd6ea566..4e50b31d3 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -9133,6 +9133,13 @@ static char *function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, c
return ret;
}
+ /* if our channel, return the IP address of the endpoint of current channel */
+ if (!strcmp(peername,"CURRENTCHANNEL")) {
+ unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
+ ast_copy_string(buf, iaxs[callno]->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[callno]->addr.sin_addr) : "", len);
+ return buf;
+ }
+
if ((colname = strchr(peername, ':'))) {
*colname = '\0';
colname++;
@@ -9181,9 +9188,9 @@ static char *function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, c
struct ast_custom_function iaxpeer_function = {
.name = "IAXPEER",
.synopsis = "Gets IAX peer information",
- .syntax = "IAXPEER(<peername>[:item])",
+ .syntax = "IAXPEER(<peername|CURRENTCHANNEL>[:item])",
.read = function_iaxpeer,
- .desc = "Valid items are:\n"
+ .desc = "If peername specified, valid items are:\n"
"- ip (default) The IP address.\n"
"- mailbox The configured mailbox.\n"
"- context The configured context.\n"
@@ -9194,6 +9201,8 @@ struct ast_custom_function iaxpeer_function = {
"- codecs The configured codecs.\n"
"- codec[x] Preferred codec index number 'x' (beginning with zero).\n"
"\n"
+ "If CURRENTCHANNEL specified, returns IP address of current channel\n"
+ "\n"
};