Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 89465) +++ channels/chan_sip.c (working copy) @@ -12963,7 +12963,13 @@ { struct sip_peer *peer; char *colname; + static int deprecation_warning = 0; + if (!deprecation_warning) { + deprecation_warning = 1; + ast_log(LOG_WARNING, "The SIPPEER function has been DEPRECATED in favor of the CHANNEL dialplan function!\n"); + } + if ((colname = strchr(data, ':'))) { /*! \todo Will be deprecated after 1.4 */ static int deprecation_warning = 0; *colname++ = '\0'; @@ -15753,6 +15759,8 @@ static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen) { struct sip_pvt *p = chan->tech_pvt; + struct sip_peer *peer; + char *all = "", *parse = ast_strdupa(preparse); int res = 0; AST_DECLARE_APP_ARGS(args, @@ -15768,9 +15776,66 @@ return 0; } + if (!(peer = find_peer(args.field, NULL, 1))) + return -1; + memset(buf, 0, buflen); - if (!strcasecmp(args.param, "rtpdest")) { + if (!strcasecmp(args.param, "sip_peerinfo")) { + if (!strcasecmp(args.type, "ip")) { + ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "", buflen); + } else if (!strcasecmp(args.type, "port")) { + snprintf(buf, buflen, "%d", ntohs(peer->addr.sin_port)); + } else if (!strcasecmp(args.type, "mailbox")) { + struct ast_str *mailbox_str = ast_str_alloca(512); + peer_mailboxes_to_str(&mailbox_str, peer); + ast_copy_string(buf, mailbox_str->str, buflen); + } else if (!strcasecmp(args.type, "context")) { + ast_copy_string(buf, peer->context, buflen); + } else if (!strcasecmp(args.type, "expire")) { + snprintf(buf, buflen, "%d", peer->expire); + } else if (!strcasecmp(args.type, "dynamic")) { + ast_copy_string(buf, peer->host_dynamic ? "yes" : "no", buflen); + } else if (!strcasecmp(args.type, "callerid_name")) { + ast_copy_string(buf, peer->cid_name, buflen); + } else if (!strcasecmp(args.type, "callerid_num")) { + ast_copy_string(buf, peer->cid_num, buflen); + } else if (!strcasecmp(args.type, "callgroup")) { + ast_print_group(buf, buflen, peer->callgroup); + } else if (!strcasecmp(args.type, "pickupgroup")) { + ast_print_group(buf, buflen, peer->pickupgroup); + } else if (!strcasecmp(args.type, "codecs")) { + ast_getformatname_multiple(buf, buflen -1, peer->capability); + } else if (!strcasecmp(args.type, "status")) { + peer_status(peer, buf, buflen); + } else if (!strcasecmp(args.type, "regexten")) { + ast_copy_string(buf, peer->regexten, buflen); + } else if (!strcasecmp(args.type, "limit")) { + snprintf(buf, buflen, "%d", peer->call_limit); + } else if (!strcasecmp(args.type, "busylevel")) { + snprintf(buf, buflen, "%d", peer->busy_level); + } else if (!strcasecmp(args.type, "curcalls")) { + snprintf(buf, buflen, "%d", peer->inUse); + } else if (!strcasecmp(args.type, "language")) { + ast_copy_string(buf, peer->language, buflen); + } else if (!strcasecmp(args.type, "accountcode")) { + ast_copy_string(buf, peer->accountcode, buflen); + } else if (!strcasecmp(args.type, "useragent")) { + ast_copy_string(buf, peer->useragent, buflen); + } else if (!strncasecmp(args.type, "codec[", 6)) { + char *codecnum; + int index = 0, codec = 0; + + codecnum = args.type + 6; /* move past the '[' */ + codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */ + index = atoi(codecnum); + if((codec = ast_codec_pref_index(&peer->prefs, index))) { + ast_copy_string(buf, ast_getformatname(codec), buflen); + } + } else { + ast_log(LOG_WARNING, "Invalid argument '%s' to sip_peerinfo item\n", args.type); + } + } else if (!strcasecmp(args.param, "rtpdest")) { struct sockaddr_in sin; if (ast_strlen_zero(args.type)) @@ -15829,6 +15894,9 @@ } else { res = -1; } + + unref_peer(peer); + return res; } Index: UPGRADE.txt =================================================================== --- UPGRADE.txt (revision 89465) +++ UPGRADE.txt (working copy) @@ -82,8 +82,11 @@ Dialplan Functions: * QUEUE_MEMBER_COUNT() has been deprecated in favor of the QUEUE_MEMBER() function. For - more information, issue a "show function QUEUE_MEMBER" from the CLI. + more information, issue a "core show function QUEUE_MEMBER" from the CLI. +* SIPPEER() has been deprecated in favor of the CHANNEL() function. For more information, + issue a "core show function CHANNEL" from the CLI. + CDR: * The cdr_sqlite module has been marked as deprecated in favor of Index: funcs/func_channel.c =================================================================== --- funcs/func_channel.c (revision 89465) +++ funcs/func_channel.c (working copy) @@ -180,6 +180,32 @@ " Argument 1:\n" " audio Get audio destination\n" " video Get video destination\n" + "R/O sip_peerinfo\n" + " This option takes two additional arguments:\n" + " Argument 1:\n" + " ip The IP address.\n" + " port The port number\n" + " mailbox The configured mailbox.\n" + " context The configured context.\n" + " expire The epoch time of the next expire.\n" + " dynamic Is it dynamic? (yes/no).\n" + " callerid_name The configured Caller ID name.\n" + " callerid_num The configured Caller ID number.\n" + " callgroup The configured Callgroup.\n" + " pickupgroup The configured Pickupgroup.\n" + " codecs The configured codecs.\n" + " status Status (if qualify=yes).\n" + " regexten Registration extension\n" + " limit Call limit (call-limit)\n" + " busylevel Configured call level for signalling busy\n" + " curcalls Current amount of calls \n" + " Only available if call-limit is set\n" + " language Default language for peer\n" + " accountcode Account code for this peer\n" + " useragent Current user agent id for peer\n" + " codec[x] Preferred codec index number 'x' (beginning with zero).\n" + " Argument 2:\n" + " The name of the peer you wish to get info about\n" "\n" "chan_iax2 provides the following additional options:\n" "R/W osptoken Get or set the OSP token information for a call\n"