[asterisk-commits] rizzo: branch rizzo/astobj2 r77752 - /team/rizzo/astobj2/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 30 03:00:18 CDT 2007
Author: rizzo
Date: Mon Jul 30 03:00:18 2007
New Revision: 77752
URL: http://svn.digium.com/view/asterisk?view=rev&rev=77752
Log:
merge from trunk - some flag removal and cli_yesno()
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=77752&r1=77751&r2=77752
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Mon Jul 30 03:00:18 2007
@@ -585,6 +585,15 @@
static int default_maxcallbitrate; /*!< Maximum bitrate for call */
static struct ast_codec_pref default_prefs; /*!< Default codec prefs */
+/*! \brief a place to store all global settings for the sip channel driver */
+struct sip_settings {
+ int peer_rtupdate; /*!< G: Update database with registration data for peer? */
+ int rtsave_sysname; /*!< G: Save system name at registration? */
+ int ignore_regexpire; /*!< G: Ignore expiration of peer */
+};
+
+static struct sip_settings sip_cfg;
+
/* Global settings only apply to the channel */
static int global_directrtpsetup; /*!< Enable support for Direct RTP setup (no re-invites) */
static int global_limitonpeers; /*!< Match call limit on peers only */
@@ -794,7 +803,6 @@
they have a common layout so it is easy to copy them.
*/
#define SIP_OUTGOING (1 << 0) /*!< D: Direction of the last transaction in this dialog */
-#define SIP_NOVIDEO (1 << 1) /*!< D: Didn't get video in invite, don't offer */
#define SIP_RINGING (1 << 2) /*!< D: Have sent 180 ringing */
#define SIP_PROGRESS_SENT (1 << 3) /*!< D: Have sent 183 message progress */
#define SIP_NEEDREINVITE (1 << 4) /*!< D: Do we need to send another reinvite? */
@@ -803,7 +811,6 @@
#define SIP_CALL_LIMIT (1 << 7) /*!< D: Call limit enforced for this call */
#define SIP_INC_COUNT (1 << 8) /*!< D: Did this dialog increment the counter of in-use calls? */
#define SIP_INC_RINGING (1 << 9) /*!< D: Did this connection increment the counter of in-use calls? */
-#define SIP_DIALOG_ANSWEREDELSEWHERE (1 << 10) /*!< D: This call is cancelled due to answer on another channel */
#define SIP_DEFER_BYE_ON_TRANSFER (1 << 11) /*!< D: Do not hangup at first ast_hangup */
#define SIP_PROMISCREDIR (1 << 12) /*!< DP: Promiscuous redirection */
@@ -854,15 +861,9 @@
/*--- a new page of flags (for flags[1] */
/* realtime flags */
#define SIP_PAGE2_RTCACHEFRIENDS (1 << 0) /*!< GP: Should we keep RT objects in memory for extended time? */
-#define SIP_PAGE2_RTUPDATE (1 << 1) /*!< G: Update database with registration data for peer? */
#define SIP_PAGE2_RTAUTOCLEAR (1 << 2) /*!< GP: Should we clean memory from peers after expiry? */
-#define SIP_PAGE2_RT_FROMCONTACT (1 << 4) /*!< P: ... */
-#define SIP_PAGE2_RTSAVE_SYSNAME (1 << 5) /*!< G: Save system name at registration? */
/* Space for addition of other realtime flags in the future */
-#define SIP_PAGE2_IGNOREREGEXPIRE (1 << 10) /*!< G: Ignore expiration of peer */
-#define SIP_PAGE2_DYNAMIC (1 << 13) /*!< P: Dynamic Peers register with Asterisk */
-#define SIP_PAGE2_SELFDESTRUCT (1 << 14) /*!< P: Automatic peers need to destruct themselves */
#define SIP_PAGE2_VIDEOSUPPORT (1 << 15) /*!< DP: Video supported if offered? */
#define SIP_PAGE2_ALLOWSUBSCRIBE (1 << 16) /*!< GP: Allow subscriptions from this peer? */
#define SIP_PAGE2_ALLOWOVERLAP (1 << 17) /*!< DP: Allow overlap dialing ? */
@@ -880,9 +881,7 @@
#define SIP_PAGE2_RFC2833_COMPENSATE (1 << 25) /*!< DP: Compensate for buggy RFC2833 implementations */
#define SIP_PAGE2_BUGGY_MWI (1 << 26) /*!< DP: Buggy CISCO MWI fix */
-#define SIP_PAGE2_NOTEXT (1 << 27) /*!< GDP: Text not supported */
#define SIP_PAGE2_TEXTSUPPORT (1 << 28) /*!< GDP: Global text enable */
-#define SIP_PAGE2_OUTGOING_CALL (1 << 30) /*!< D: Is this an outgoing call? */
#define SIP_PAGE2_FLAGS_TO_COPY \
(SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | \
@@ -1076,6 +1075,10 @@
char do_history; /*!< Set if we want to record history */
char alreadygone; /*!< already destroyed by our peer */
char needdestroy; /*!< need to be destroyed by the monitor thread */
+ char outgoing_call; /*!< this is an outgoing call */
+ char answered_elsewhere; /*!< This call is cancelled due to answer on another channel */
+ char novideo; /*!< Didn't get video in invite, don't offer */
+ char notext; /*!< Text not supported (?) */
int timer_t1; /*!< SIP timer T1, ms rtt */
unsigned int sipoptions; /*!< Supported SIP options on the other end */
@@ -1281,6 +1284,9 @@
/* things that don't belong in flags */
char is_realtime; /*!< this is a 'realtime' peer */
+ char rt_fromcontact; /*!< P: copy fromcontact from realtime */
+ char host_dynamic; /*!< P: Dynamic Peers register with Asterisk */
+ char selfdestruct; /*!< P: Automatic peers need to destruct themselves */
int amaflags; /*!< AMA Flags (for billing) */
int callingpres; /*!< Calling id presentation */
@@ -2876,7 +2882,7 @@
if (ast_strlen_zero(sysname)) /* No system name, disable this */
sysname = NULL;
- else if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTSAVE_SYSNAME))
+ else if (sip_cfg.rtsave_sysname)
syslabel = "regserver";
if (fc)
@@ -2954,7 +2960,7 @@
ast_sched_del(sched, peer->pokeexpire);
register_peer_exten(peer, FALSE);
ast_free_ha(peer->ha);
- if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT))
+ if (peer->selfdestruct)
apeerobjs--;
else if (peer->is_realtime) {
rpeerobjs--;
@@ -2972,7 +2978,7 @@
static void update_peer(struct sip_peer *p, int expiry)
{
int rtcachefriends = ast_test_flag(&p->flags[1], SIP_PAGE2_RTCACHEFRIENDS);
- if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTUPDATE) &&
+ if (sip_cfg.peer_rtupdate &&
(p->is_realtime || rtcachefriends)) {
realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, expiry);
}
@@ -3664,7 +3670,7 @@
{
char name[256];
int *inuse = NULL, *call_limit = NULL, *inringing = NULL;
- int outgoing = ast_test_flag(&fup->flags[1], SIP_PAGE2_OUTGOING_CALL);
+ int outgoing = fup->outgoing_call;
struct sip_user *u = NULL;
struct sip_peer *p = NULL;
@@ -4388,7 +4394,7 @@
ast_moh_stop(ast);
break;
case AST_CONTROL_VIDUPDATE: /* Request a video frame update */
- if (p->vrtp && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
+ if (p->vrtp && !p->novideo) {
transmit_info_with_vidupdate(p);
/* ast_rtcp_send_h261fur(p->vrtp); */
} else
@@ -5590,11 +5596,12 @@
return -1;
}
vhp = hp; /* Copy to video address as default too */
- thp = hp; /* Copy to video address as default too */
+ thp = hp; /* Copy to text address as default too */
iterator = req->sdp_start;
- ast_set_flag(&p->flags[0], SIP_NOVIDEO);
- ast_set_flag(&p->flags[1], SIP_PAGE2_NOTEXT);
+ /* default: novideo and notext set */
+ p->novideo = TRUE;
+ p->notext = TRUE;
if (p->vrtp)
ast_rtp_pt_clear(newvideortp); /* Must be cleared in case no m=video line exists */
@@ -5629,7 +5636,7 @@
} else if ((sscanf(m, "video %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2) ||
(sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1)) {
video = TRUE;
- ast_clear_flag(&p->flags[0], SIP_NOVIDEO);
+ p->novideo = FALSE;
numberofmediastreams++;
vportno = x;
/* Scan through the RTP payload types specified in a "m=" line: */
@@ -5645,7 +5652,7 @@
} else if ((sscanf(m, "text %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2) ||
(sscanf(m, "text %d RTP/AVP %n", &x, &len) == 1)) {
text = TRUE;
- ast_clear_flag(&p->flags[1], SIP_PAGE2_NOTEXT);
+ p->notext = FALSE;
numberofmediastreams++;
tportno = x;
/* Scan through the RTP payload types specified in a "m=" line: */
@@ -5664,7 +5671,7 @@
ast_verbose("Got T.38 offer in SDP in dialog %s\n", p->callid);
udptlportno = x;
numberofmediastreams++;
-
+
if (p->owner && p->lastinvite) {
p->t38.state = T38_PEER_REINVITE; /* T38 Offered in re-invite from remote party */
ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
@@ -7092,10 +7099,11 @@
capability = p->jointcapability;
+ /* XXX note, Video and Text are negated - 'true' means 'no' */
if (option_debug > 1) {
char codecbuf[BUFSIZ];
ast_log(LOG_DEBUG, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability),
- ast_test_flag(&p->flags[0], SIP_NOVIDEO) ? "True" : "False", ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT) ? "True" : "False");
+ p->novideo ? "True" : "False", p->notext ? "True" : "False");
ast_log(LOG_DEBUG, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
}
@@ -7107,7 +7115,7 @@
#endif
/* Check if we need video in this call */
- if ((capability & AST_FORMAT_VIDEO_MASK) && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
+ if ((capability & AST_FORMAT_VIDEO_MASK) && !p->novideo) {
if (p->vrtp) {
needvideo = TRUE;
ast_debug(2, "This call needs video offers!\n");
@@ -7134,7 +7142,7 @@
}
/* Check if we need text in this call */
- if((capability & AST_FORMAT_TEXT_MASK) && !ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT)) {
+ if((capability & AST_FORMAT_TEXT_MASK) && !p->notext) {
if (sipdebug_text)
ast_verbose("We think we can do text\n");
if (p->trtp) {
@@ -8525,8 +8533,8 @@
int realtimeregs = ast_check_realtime("sipregs");
char *tablename = (realtimeregs) ? "sipregs" : "sippeers";
- if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE)) {
- if (ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT))
+ if (!sip_cfg.ignore_regexpire) {
+ if (peer->rt_fromcontact)
ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "username", "", "regserver", "", NULL);
else
ast_db_del("SIP/Registry", peer->name);
@@ -8556,7 +8564,7 @@
if (peer->is_realtime)
ast_debug(3,"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->name, rpeerobjs);
- if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT) ||
+ if (peer->selfdestruct ||
ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
peer = ASTOBJ_CONTAINER_UNLINK(&peerl, peer); /* Remove from peer list */
unref_peer(peer); /* Remove from memory */
@@ -8584,7 +8592,7 @@
int port;
char *scan, *addr, *port_str, *expiry_str, *username, *contact;
- if (ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT))
+ if (peer->rt_fromcontact)
return;
if (ast_db_get("SIP/Registry", peer->name, data, sizeof(data)))
return;
@@ -8816,7 +8824,7 @@
ast_sched_add(sched, (expiry + 10) * 1000, expire_register, peer);
pvt->expiry = expiry;
snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry, peer->username, peer->fullcontact);
- if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT))
+ if (!peer->rt_fromcontact)
ast_db_put("SIP/Registry", peer->name, data);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", peer->name);
@@ -9289,7 +9297,7 @@
ast_rtp_codec_setpref(p->rtp, &peer->prefs);
p->autoframing = peer->autoframing;
}
- if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)) {
+ if (!peer->host_dynamic) {
ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name);
} else {
ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_NAT);
@@ -10610,6 +10618,16 @@
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[])
{
@@ -10645,7 +10663,7 @@
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)
@@ -10772,7 +10790,7 @@
snprintf(srch, sizeof(srch), FORMAT, name,
iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iterator->addr.sin_addr) : "(Unspecified)",
- ast_test_flag(&iterator->flags[1], SIP_PAGE2_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
+ iterator->host_dynamic ? " D " : " ", /* Dynamic or not? */
ast_test_flag(&iterator->flags[0], SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */
iterator->ha ? " A " : " ", /* permit/deny */
ntohs(iterator->addr.sin_port), status,
@@ -10781,7 +10799,7 @@
if (!s) {/* Normal CLI list */
ast_cli(fd, FORMAT, name,
iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iterator->addr.sin_addr) : "(Unspecified)",
- ast_test_flag(&iterator->flags[1], SIP_PAGE2_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
+ iterator->host_dynamic ? " D " : " ", /* Dynamic or not? */
ast_test_flag(&iterator->flags[0], SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */
iterator->ha ? " A " : " ", /* permit/deny */
@@ -10808,7 +10826,7 @@
iterator->name,
iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iterator->addr.sin_addr) : "-none-",
ntohs(iterator->addr.sin_port),
- ast_test_flag(&iterator->flags[1], SIP_PAGE2_DYNAMIC) ? "yes" : "no", /* Dynamic or not? */
+ iterator->host_dynamic ? "yes" : "no", /* Dynamic or not? */
ast_test_flag(&iterator->flags[0], SIP_NAT_ROUTE) ? "yes" : "no", /* NAT=yes? */
ast_test_flag(&iterator->flags[1], SIP_PAGE2_VIDEOSUPPORT) ? "yes" : "no", /* VIDEOSUPPORT=yes? */
ast_test_flag(&iterator->flags[1], SIP_PAGE2_TEXTSUPPORT) ? "yes" : "no", /* TEXTSUPPORT=yes? */
@@ -11233,28 +11251,28 @@
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", (ast_test_flag(&peer->flags[1], SIP_PAGE2_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, " RegisterFrom : %s\n", S_OR(peer->register_from_hdr, ""));
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,
@@ -11290,7 +11308,7 @@
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);
@@ -11330,7 +11348,7 @@
astman_append(s, "Call-limit: %d\r\n", peer->call_limit);
astman_append(s, "Busy-level: %d\r\n", peer->busy_level);
astman_append(s, "MaxCallBR: %d kbps\r\n", peer->maxcallbitrate);
- astman_append(s, "Dynamic: %s\r\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)?"Y":"N"));
+ astman_append(s, "Dynamic: %s\r\n", peer->host_dynamic ? "Y":"N");
astman_append(s, "Callerid: %s\r\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, ""));
astman_append(s, "RegExpire: %ld seconds\r\n", ast_sched_when(sched,peer->expire));
astman_append(s, "SIP-AuthInsecure: %s\r\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE)));
@@ -11422,12 +11440,12 @@
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)
@@ -11519,22 +11537,22 @@
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, " Caller ID: %s\n", default_callerid);
@@ -11550,18 +11568,18 @@
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
@@ -11607,24 +11625,24 @@
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)" : "");
@@ -11634,7 +11652,7 @@
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);
@@ -11645,13 +11663,13 @@
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", ast_test_flag(&global_flags[1], SIP_PAGE2_RTUPDATE) ? "Yes" : "No");
- ast_cli(fd, " Ignore Reg. Expire: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE) ? "Yes" : "No");
- ast_cli(fd, " Save sys. name: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_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");
@@ -11718,7 +11736,7 @@
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
@@ -11975,8 +11993,8 @@
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));
@@ -11994,9 +12012,9 @@
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: ");
@@ -12813,7 +12831,7 @@
} else if (!strcasecmp(colname, "expire")) {
snprintf(buf, len, "%d", peer->expire);
} else if (!strcasecmp(colname, "dynamic")) {
- ast_copy_string(buf, (ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) ? "yes" : "no"), len);
+ ast_copy_string(buf, peer->host_dynamic ? "yes" : "no", len);
} else if (!strcasecmp(colname, "callerid_name")) {
ast_copy_string(buf, peer->cid_name, len);
} else if (!strcasecmp(colname, "callerid_num")) {
@@ -16883,7 +16901,7 @@
return NULL;
}
- ast_set_flag(&p->flags[1], SIP_PAGE2_OUTGOING_CALL);
+ p->outgoing_call = TRUE;
if (!(p->options = ast_calloc(1, sizeof(*p->options)))) {
sip_destroy(p);
@@ -17447,8 +17465,8 @@
ast_copy_string(peer->name, name, sizeof(peer->name));
- ast_set_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT);
- ast_set_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC);
+ peer->selfdestruct = TRUE;
+ peer->host_dynamic = TRUE;
peer->prefs = default_prefs;
reg_source_db(peer);
@@ -17521,7 +17539,7 @@
M_STR("name", peer->name)
M_F("fullcontact", {
ast_copy_string(peer->fullcontact, v->value, sizeof(peer->fullcontact));
- ast_set_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT); } )
+ peer->rt_fromcontact = TRUE; } )
M_END(;)
continue;
}
@@ -17557,7 +17575,7 @@
M_F("host",
if (!strcasecmp(v->value, "dynamic")) {
/* They'll register with us */
- if (!found || !ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)) {
+ if (!found || !peer->host_dynamic) {
/* Initialize stuff if this is a new peer, or if it used to
* not be dynamic before the reload. */
memset(&peer->addr.sin_addr, 0, 4);
@@ -17567,13 +17585,13 @@
peer->addr.sin_port = 0;
}
}
- ast_set_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC);
+ peer->host_dynamic = TRUE;
} else {
/* Non-dynamic. Make sure we become that way if we're not */
if (peer->expire > -1)
ast_sched_del(sched, peer->expire);
peer->expire = -1;
- ast_clear_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC);
+ peer->host_dynamic = FALSE;
if (ast_get_ip_or_srv(&peer->addr, v->value, global_srvlookup ? "_sip._udp" : NULL)) {
unref_peer(peer);
return NULL;
@@ -17592,7 +17610,7 @@
M_F("|permit|deny|", {int ha_error = 0;
peer->ha = ast_append_ha(v->name, v->value, peer->ha, &ha_error); } )
M_F("port", {
- if (!realtime && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC))
+ if (!realtime && peer->host_dynamic)
peer->defaddr.sin_port = htons(atoi(v->value));
else
peer->addr.sin_port = htons(atoi(v->value)); } )
@@ -17639,7 +17657,7 @@
M_END(ast_log(LOG_NOTICE, "sip.conf peer [%s]: unknown option %s = %s\n",
name, v->name, v->value); )
}
- if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE) && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) && realtime) {
+ if (!sip_cfg.ignore_regexpire && peer->host_dynamic && realtime) {
time_t nowtime = time(NULL);
if ((nowtime - regseconds) > 0) {
@@ -17652,7 +17670,7 @@
ast_copy_flags(&peer->flags[1], &peerflags[1], mask[1].flags);
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE))
global_allowsubscribe = TRUE; /* No global ban any more */
- if (!found && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) && !peer->is_realtime)
+ if (!found && peer->host_dynamic && !peer->is_realtime)
reg_source_db(peer);
/* If they didn't request that MWI is sent *only* on subscribe, go ahead and
@@ -17776,7 +17794,7 @@
global_rtautoclear = 120;
ast_set_flag(&global_flags[1], SIP_PAGE2_ALLOWSUBSCRIBE); /* Default for peers, users: TRUE */
ast_set_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP); /* Default for peers, users: TRUE */
- ast_set_flag(&global_flags[1], SIP_PAGE2_RTUPDATE);
+ sip_cfg.peer_rtupdate = TRUE;
/* Initialize some reasonable defaults at SIP reload (used both for channel and as default for peers and users */
ast_copy_string(default_context, DEFAULT_CONTEXT, sizeof(default_context));
@@ -17825,9 +17843,9 @@
M_STR("useragent", global_useragent)
M_F("allowtransfer", global_allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;)
M_F("rtcachefriends", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTCACHEFRIENDS);)
- M_F("rtsavesysname", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTSAVE_SYSNAME);)
- M_F("rtupdate", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTUPDATE);)
- M_F("ignoreregexpire", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_IGNOREREGEXPIRE);)
+ M_BOOL("rtsavesysname", sip_cfg.rtsave_sysname)
+ M_BOOL("rtupdate", sip_cfg.peer_rtupdate)
+ M_BOOL("ignoreregexpire", sip_cfg.ignore_regexpire)
M_F("t1min", global_t1min = atoi(v->value);)
M_F("rtautoclear", {
int i = atoi(v->value);
More information about the asterisk-commits
mailing list