return res;
}
+/*! \brief return Yes or No depending on the argument.
+ * This is used in many places in CLI command, having a function to generate
+ * this helps maintaining a consistent output (and possibly emitting the
+ * output in other languages, at some point).
+ */
+static const char *cli_yesno(int x)
+{
+ return x ? "Yes" : "No";
+}
+
/*! \brief CLI Command 'SIP Show Users' */
static int sip_show_users(int fd, int argc, char *argv[])
{
iterator->secret,
iterator->accountcode,
iterator->context,
- iterator->ha ? "Yes" : "No",
+ cli_yesno(iterator->ha != NULL),
nat2str(ast_test_flag(&iterator->flags[0], SIP_NAT)));
ASTOBJ_UNLOCK(iterator);
} while (0)
ast_cli(fd, " Call limit : %d\n", peer->call_limit);
if (peer->busy_level)
ast_cli(fd, " Busy level : %d\n", peer->busy_level);
- ast_cli(fd, " Dynamic : %s\n", peer->host_dynamic ? "Yes" : "No");
+ ast_cli(fd, " Dynamic : %s\n", cli_yesno(peer->host_dynamic));
ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>"));
ast_cli(fd, " MaxCallBR : %d kbps\n", peer->maxcallbitrate);
ast_cli(fd, " Expire : %ld\n", ast_sched_when(sched, peer->expire));
ast_cli(fd, " Insecure : %s\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE)));
ast_cli(fd, " Nat : %s\n", nat2str(ast_test_flag(&peer->flags[0], SIP_NAT)));
- ast_cli(fd, " ACL : %s\n", (peer->ha?"Yes":"No"));
- ast_cli(fd, " T38 pt UDPTL : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT_UDPTL)?"Yes":"No");
+ ast_cli(fd, " ACL : %s\n", cli_yesno(peer->ha != NULL));
+ ast_cli(fd, " T38 pt UDPTL : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT_UDPTL)));
#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
- ast_cli(fd, " T38 pt RTP : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT_RTP)?"Yes":"No");
- ast_cli(fd, " T38 pt TCP : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT_TCP)?"Yes":"No");
+ ast_cli(fd, " T38 pt RTP : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT_RTP)));
+ ast_cli(fd, " T38 pt TCP : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT_TCP)));
#endif
- ast_cli(fd, " CanReinvite : %s\n", ast_test_flag(&peer->flags[0], SIP_CAN_REINVITE)?"Yes":"No");
- ast_cli(fd, " PromiscRedir : %s\n", ast_test_flag(&peer->flags[0], SIP_PROMISCREDIR)?"Yes":"No");
- ast_cli(fd, " User=Phone : %s\n", ast_test_flag(&peer->flags[0], SIP_USEREQPHONE)?"Yes":"No");
- ast_cli(fd, " Video Support: %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_VIDEOSUPPORT)?"Yes":"No");
- ast_cli(fd, " Text Support : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_TEXTSUPPORT)?"Yes":"No");
- ast_cli(fd, " Trust RPID : %s\n", ast_test_flag(&peer->flags[0], SIP_TRUSTRPID) ? "Yes" : "No");
- ast_cli(fd, " Send RPID : %s\n", ast_test_flag(&peer->flags[0], SIP_SENDRPID) ? "Yes" : "No");
- ast_cli(fd, " Subscriptions: %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE) ? "Yes" : "No");
- ast_cli(fd, " Overlap dial : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWOVERLAP) ? "Yes" : "No");
+ ast_cli(fd, " CanReinvite : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_CAN_REINVITE)));
+ ast_cli(fd, " PromiscRedir : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_PROMISCREDIR)));
+ ast_cli(fd, " User=Phone : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_USEREQPHONE)));
+ ast_cli(fd, " Video Support: %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_VIDEOSUPPORT)));
+ ast_cli(fd, " Text Support : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_TEXTSUPPORT)));
+ ast_cli(fd, " Trust RPID : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_TRUSTRPID)));
+ ast_cli(fd, " Send RPID : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_SENDRPID)));
+ ast_cli(fd, " Subscriptions: %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)));
+ ast_cli(fd, " Overlap dial : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWOVERLAP)));
if (peer->outboundproxy)
ast_cli(fd, " Outb. proxy : %s %s\n", ast_strlen_zero(peer->outboundproxy->name) ? "<not set>" : peer->outboundproxy->name,
peer->outboundproxy->force ? "(forced)" : "");
print_codec_to_cli(fd, &peer->prefs);
ast_cli(fd, ")\n");
- ast_cli(fd, " Auto-Framing: %s \n", peer->autoframing ? "Yes" : "No");
+ ast_cli(fd, " Auto-Framing: %s \n", cli_yesno(peer->autoframing));
ast_cli(fd, " Status : ");
peer_status(peer, status, sizeof(status));
ast_cli(fd, "%s\n",status);
ast_cli(fd, " Pickupgroup : ");
print_group(fd, user->pickupgroup, 0);
ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), user->cid_name, user->cid_num, "<unspecified>"));
- ast_cli(fd, " ACL : %s\n", (user->ha?"Yes":"No"));
+ ast_cli(fd, " ACL : %s\n", cli_yesno(user->ha != NULL));
ast_cli(fd, " Codec Order : (");
print_codec_to_cli(fd, &user->prefs);
ast_cli(fd, ")\n");
- ast_cli(fd, " Auto-Framing: %s \n", user->autoframing ? "Yes" : "No");
+ ast_cli(fd, " Auto-Framing: %s \n", cli_yesno(user->autoframing));
if (user->chanvars) {
ast_cli(fd, " Variables :\n");
for (v = user->chanvars ; v ; v = v->next)
ast_cli(fd, "----------------\n");
ast_cli(fd, " SIP Port: %d\n", ntohs(bindaddr.sin_port));
ast_cli(fd, " Bindaddress: %s\n", ast_inet_ntoa(bindaddr.sin_addr));
- ast_cli(fd, " Videosupport: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_VIDEOSUPPORT) ? "Yes" : "No");
- ast_cli(fd, " Textsupport: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_TEXTSUPPORT) ? "Yes" : "No");
- ast_cli(fd, " AutoCreatePeer: %s\n", autocreatepeer ? "Yes" : "No");
- ast_cli(fd, " MatchAuthUsername: %s\n", global_match_auth_username ? "Yes" : "No");
- ast_cli(fd, " Allow unknown access: %s\n", global_allowguest ? "Yes" : "No");
- ast_cli(fd, " Allow subscriptions: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWSUBSCRIBE) ? "Yes" : "No");
- ast_cli(fd, " Allow overlap dialing: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP) ? "Yes" : "No");
- ast_cli(fd, " Promsic. redir: %s\n", ast_test_flag(&global_flags[0], SIP_PROMISCREDIR) ? "Yes" : "No");
- ast_cli(fd, " SIP domain support: %s\n", AST_LIST_EMPTY(&domain_list) ? "No" : "Yes");
- ast_cli(fd, " Call to non-local dom.: %s\n", allow_external_domains ? "Yes" : "No");
- ast_cli(fd, " URI user is phone no: %s\n", ast_test_flag(&global_flags[0], SIP_USEREQPHONE) ? "Yes" : "No");
+ ast_cli(fd, " Videosupport: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_VIDEOSUPPORT)));
+ ast_cli(fd, " Textsupport: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_TEXTSUPPORT)));
+ ast_cli(fd, " AutoCreatePeer: %s\n", cli_yesno(autocreatepeer));
+ ast_cli(fd, " MatchAuthUsername: %s\n", cli_yesno(global_match_auth_username));
+ ast_cli(fd, " Allow unknown access: %s\n", cli_yesno(global_allowguest));
+ ast_cli(fd, " Allow subscriptions: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)));
+ ast_cli(fd, " Allow overlap dialing: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP)));
+ ast_cli(fd, " Promsic. redir: %s\n", cli_yesno(ast_test_flag(&global_flags[0], SIP_PROMISCREDIR)));
+ ast_cli(fd, " SIP domain support: %s\n", cli_yesno(!AST_LIST_EMPTY(&domain_list)));
+ ast_cli(fd, " Call to non-local dom.: %s\n", cli_yesno(allow_external_domains));
+ ast_cli(fd, " URI user is phone no: %s\n", cli_yesno(ast_test_flag(&global_flags[0], SIP_USEREQPHONE)));
ast_cli(fd, " Our auth realm %s\n", global_realm);
- ast_cli(fd, " Realm. auth: %s\n", authl ? "Yes": "No");
- ast_cli(fd, " Always auth rejects: %s\n", global_alwaysauthreject ? "Yes" : "No");
- ast_cli(fd, " Call limit peers only: %s\n", global_limitonpeers ? "Yes" : "No");
- ast_cli(fd, " Direct RTP setup: %s\n", global_directrtpsetup ? "Yes" : "No");
+ ast_cli(fd, " Realm. auth: %s\n", cli_yesno(authl != NULL));
+ ast_cli(fd, " Always auth rejects: %s\n", cli_yesno(global_alwaysauthreject));
+ ast_cli(fd, " Call limit peers only: %s\n", cli_yesno(global_limitonpeers));
+ ast_cli(fd, " Direct RTP setup: %s\n", cli_yesno(global_directrtpsetup));
ast_cli(fd, " User Agent: %s\n", global_useragent);
ast_cli(fd, " Reg. context: %s\n", S_OR(global_regcontext, "(not set)"));
- ast_cli(fd, " Regexten on Qualify: %s\n", global_regextenonqualify ? "Yes" : "No");
+ ast_cli(fd, " Regexten on Qualify: %s\n", cli_yesno(global_regextenonqualify));
ast_cli(fd, " Caller ID: %s\n", default_callerid);
ast_cli(fd, " From: Domain: %s\n", default_fromdomain);
ast_cli(fd, " Record SIP history: %s\n", recordhistory ? "On" : "Off");
ast_cli(fd, " 802.1p CoS RTP video: %d\n", global_cos_video);
ast_cli(fd, " 802.1p CoS RTP text: %d\n", global_cos_text);
- ast_cli(fd, " T38 fax pt UDPTL: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_UDPTL) ? "Yes" : "No");
+ ast_cli(fd, " T38 fax pt UDPTL: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_UDPTL)));
#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
- ast_cli(fd, " T38 fax pt RTP: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_RTP) ? "Yes" : "No");
- ast_cli(fd, " T38 fax pt TCP: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_TCP) ? "Yes" : "No");
+ ast_cli(fd, " T38 fax pt RTP: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_RTP)));
+ ast_cli(fd, " T38 fax pt TCP: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_TCP)));
#endif
- ast_cli(fd, " RFC2833 Compensation: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_RFC2833_COMPENSATE) ? "Yes" : "No");
- ast_cli(fd, " Jitterbuffer enabled: %s\n", ast_test_flag(&global_jbconf, AST_JB_ENABLED) ? "Yes" : "No");
- ast_cli(fd, " Jitterbuffer forced: %s\n", ast_test_flag(&global_jbconf, AST_JB_FORCED) ? "Yes" : "No");
+ ast_cli(fd, " RFC2833 Compensation: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_RFC2833_COMPENSATE)));
+ ast_cli(fd, " Jitterbuffer enabled: %s\n", cli_yesno(ast_test_flag(&global_jbconf, AST_JB_ENABLED)));
+ ast_cli(fd, " Jitterbuffer forced: %s\n", cli_yesno(ast_test_flag(&global_jbconf, AST_JB_FORCED)));
ast_cli(fd, " Jitterbuffer max size: %ld\n", global_jbconf.max_size);
ast_cli(fd, " Jitterbuffer resync: %ld\n", global_jbconf.resync_threshold);
ast_cli(fd, " Jitterbuffer impl: %s\n", global_jbconf.impl);
- ast_cli(fd, " Jitterbuffer log: %s\n", ast_test_flag(&global_jbconf, AST_JB_LOG) ? "Yes" : "No");
+ ast_cli(fd, " Jitterbuffer log: %s\n", cli_yesno(ast_test_flag(&global_jbconf, AST_JB_LOG)));
if (!realtimepeers && !realtimeusers && !realtimeregs)
ast_cli(fd, " SIP realtime: Disabled\n" );
else
print_codec_to_cli(fd, &default_prefs);
ast_cli(fd, "\n");
ast_cli(fd, " T1 minimum: %d\n", global_t1min);
- ast_cli(fd, " Relax DTMF: %s\n", global_relaxdtmf ? "Yes" : "No");
- ast_cli(fd, " Compact SIP headers: %s\n", compactheaders ? "Yes" : "No");
+ ast_cli(fd, " Relax DTMF: %s\n", cli_yesno(global_relaxdtmf));
+ ast_cli(fd, " Compact SIP headers: %s\n", cli_yesno(compactheaders));
ast_cli(fd, " RTP Keepalive: %d %s\n", global_rtpkeepalive, global_rtpkeepalive ? "" : "(Disabled)" );
ast_cli(fd, " RTP Timeout: %d %s\n", global_rtptimeout, global_rtptimeout ? "" : "(Disabled)" );
ast_cli(fd, " RTP Hold Timeout: %d %s\n", global_rtpholdtimeout, global_rtpholdtimeout ? "" : "(Disabled)");
ast_cli(fd, " MWI NOTIFY mime type: %s\n", default_notifymime);
- ast_cli(fd, " DNS SRV lookup: %s\n", global_srvlookup ? "Yes" : "No");
- ast_cli(fd, " Pedantic SIP support: %s\n", pedanticsipchecking ? "Yes" : "No");
+ ast_cli(fd, " DNS SRV lookup: %s\n", cli_yesno(global_srvlookup));
+ ast_cli(fd, " Pedantic SIP support: %s\n", cli_yesno(pedanticsipchecking));
ast_cli(fd, " Reg. min duration %d secs\n", min_expiry);
ast_cli(fd, " Reg. max duration: %d secs\n", max_expiry);
ast_cli(fd, " Reg. default duration: %d secs\n", default_expiry);
ast_cli(fd, " Outbound reg. timeout: %d secs\n", global_reg_timeout);
ast_cli(fd, " Outbound reg. attempts: %d\n", global_regattempts_max);
- ast_cli(fd, " Notify ringing state: %s\n", global_notifyringing ? "Yes" : "No");
- ast_cli(fd, " Notify hold state: %s\n", global_notifyhold ? "Yes" : "No");
+ ast_cli(fd, " Notify ringing state: %s\n", cli_yesno(global_notifyringing));
+ ast_cli(fd, " Notify hold state: %s\n", cli_yesno(global_notifyhold));
ast_cli(fd, " SIP Transfer mode: %s\n", transfermode2str(global_allowtransfer));
ast_cli(fd, " Max Call Bitrate: %d kbps\n", default_maxcallbitrate);
- ast_cli(fd, " Auto-Framing: %s\n", global_autoframing ? "Yes" : "No");
+ ast_cli(fd, " Auto-Framing: %s\n", cli_yesno(global_autoframing));
ast_cli(fd, " Outb. proxy: %s %s\n", ast_strlen_zero(global_outboundproxy.name) ? "<not set>" : global_outboundproxy.name,
global_outboundproxy.force ? "(forced)" : "");
ast_cli(fd, " Nat: %s\n", nat2str(ast_test_flag(&global_flags[0], SIP_NAT)));
ast_cli(fd, " DTMF: %s\n", dtmfmode2str(ast_test_flag(&global_flags[0], SIP_DTMF)));
ast_cli(fd, " Qualify: %d\n", default_qualify);
- ast_cli(fd, " Use ClientCode: %s\n", ast_test_flag(&global_flags[0], SIP_USECLIENTCODE) ? "Yes" : "No");
+ ast_cli(fd, " Use ClientCode: %s\n", cli_yesno(ast_test_flag(&global_flags[0], SIP_USECLIENTCODE)));
ast_cli(fd, " Progress inband: %s\n", (ast_test_flag(&global_flags[0], SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER) ? "Never" : (ast_test_flag(&global_flags[0], SIP_PROG_INBAND) == SIP_PROG_INBAND_NO) ? "No" : "Yes" );
ast_cli(fd, " Language: %s\n", S_OR(default_language, "(Defaults to English)"));
ast_cli(fd, " MOH Interpret: %s\n", default_mohinterpret);
if (realtimepeers || realtimeusers || realtimeregs) {
ast_cli(fd, "\nRealtime SIP Settings:\n");
ast_cli(fd, "----------------------\n");
- ast_cli(fd, " Realtime Peers: %s\n", realtimepeers ? "Yes" : "No");
- ast_cli(fd, " Realtime Users: %s\n", realtimeusers ? "Yes" : "No");
- ast_cli(fd, " Realtime Regs: %s\n", realtimeregs ? "Yes" : "No");
- ast_cli(fd, " Cache Friends: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS) ? "Yes" : "No");
- ast_cli(fd, " Update: %s\n", sip_cfg.peer_rtupdate ? "Yes" : "No");
- ast_cli(fd, " Ignore Reg. Expire: %s\n", sip_cfg.ignore_regexpire ? "Yes" : "No");
- ast_cli(fd, " Save sys. name: %s\n", sip_cfg.rtsave_sysname ? "Yes" : "No");
+ ast_cli(fd, " Realtime Peers: %s\n", cli_yesno(realtimepeers));
+ ast_cli(fd, " Realtime Users: %s\n", cli_yesno(realtimeusers));
+ ast_cli(fd, " Realtime Regs: %s\n", cli_yesno(realtimeregs));
+ ast_cli(fd, " Cache Friends: %s\n", cli_yesno(ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)));
+ ast_cli(fd, " Update: %s\n", cli_yesno(sip_cfg.peer_rtupdate));
+ ast_cli(fd, " Ignore Reg. Expire: %s\n", cli_yesno(sip_cfg.ignore_regexpire));
+ ast_cli(fd, " Save sys. name: %s\n", cli_yesno(sip_cfg.rtsave_sysname));
ast_cli(fd, " Auto Clear: %d\n", global_rtautoclear);
}
ast_cli(fd, "\n----\n");
cur->callid,
cur->ocseq, cur->icseq,
ast_getformatname(cur->owner ? cur->owner->nativeformats : 0),
- ast_test_flag(&cur->flags[1], SIP_PAGE2_CALL_ONHOLD) ? "Yes" : "No",
+ cli_yesno(ast_test_flag(&cur->flags[1], SIP_PAGE2_CALL_ONHOLD)),
cur->needdestroy ? "(d)" : "",
cur->lastmsg ,
referstatus
ast_cli(fd, " Their Codec Capability: %d\n", cur->peercapability);
ast_cli(fd, " Joint Codec Capability: %d\n", cur->jointcapability);
ast_cli(fd, " Format: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->owner ? cur->owner->nativeformats : 0) );
- ast_cli(fd, " T.38 support %s\n", cur->udptl ? "Yes" : "No");
- ast_cli(fd, " Video support %s\n", cur->vrtp ? "Yes" : "No");
+ ast_cli(fd, " T.38 support %s\n", cli_yesno(cur->udptl != NULL));
+ ast_cli(fd, " Video support %s\n", cli_yesno(cur->vrtp != NULL));
ast_cli(fd, " MaxCallBR: %d kbps\n", cur->maxcallbitrate);
ast_cli(fd, " Theoretical Address: %s:%d\n", ast_inet_ntoa(cur->sa.sin_addr), ntohs(cur->sa.sin_port));
ast_cli(fd, " Received Address: %s:%d\n", ast_inet_ntoa(cur->recv.sin_addr), ntohs(cur->recv.sin_port));
ast_cli(fd, " Original uri: %s\n", cur->uri);
if (!ast_strlen_zero(cur->cid_num))
ast_cli(fd, " Caller-ID: %s\n", cur->cid_num);
- ast_cli(fd, " Need Destroy: %s\n", cur->needdestroy ? "Yes" : "No");
+ ast_cli(fd, " Need Destroy: %s\n", cli_yesno(cur->needdestroy));
ast_cli(fd, " Last Message: %s\n", cur->lastmsg);
- ast_cli(fd, " Promiscuous Redir: %s\n", ast_test_flag(&cur->flags[0], SIP_PROMISCREDIR) ? "Yes" : "No");
+ ast_cli(fd, " Promiscuous Redir: %s\n", cli_yesno(ast_test_flag(&cur->flags[0], SIP_PROMISCREDIR)));
ast_cli(fd, " Route: %s\n", cur->route ? cur->route->hop : "N/A");
ast_cli(fd, " DTMF Mode: %s\n", dtmfmode2str(ast_test_flag(&cur->flags[0], SIP_DTMF)));
ast_cli(fd, " SIP Options: ");