More flagification (bug #3254)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4685 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Mark Spencer 21 years ago
parent 15307e3978
commit 8e3722ceee

@ -115,16 +115,21 @@ static char *descrip =
use it not only for keeping track of what is in use but use it not only for keeping track of what is in use but
also for keeping track of who we're dialing. */ also for keeping track of who we're dialing. */
#define DIAL_STILLGOING (1 << 0)
#define DIAL_ALLOWREDIRECT_IN (1 << 1)
#define DIAL_ALLOWREDIRECT_OUT (1 << 2)
#define DIAL_ALLOWDISCONNECT_IN (1 << 3)
#define DIAL_ALLOWDISCONNECT_OUT (1 << 4)
#define DIAL_RINGBACKONLY (1 << 5)
#define DIAL_MUSICONHOLD (1 << 6)
#define DIAL_FORCECALLERID (1 << 7)
#define DIAL_MONITOR_IN (1 << 8)
#define DIAL_MONITOR_OUT (1 << 9)
#define DIAL_GO_ON (1 << 10)
struct localuser { struct localuser {
struct ast_channel *chan; struct ast_channel *chan;
int stillgoing; unsigned int flags;
int allowredirect_in;
int allowredirect_out;
int ringbackonly;
int musiconhold;
int allowdisconnect_in;
int allowdisconnect_out;
int forcecallerid;
int forwards; int forwards;
struct localuser *next; struct localuser *next;
}; };
@ -169,7 +174,7 @@ static void hanguptree(struct localuser *outgoing, struct ast_channel *exception
} while(0) } while(0)
static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect_in, int *allowdisconnect_out, int *sentringing, char *status, size_t statussize, int busystart, int nochanstart, int congestionstart) static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, struct ast_flags *locflags, int *sentringing, char *status, size_t statussize, int busystart, int nochanstart, int congestionstart)
{ {
struct localuser *o; struct localuser *o;
int found; int found;
@ -187,7 +192,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
int single; int single;
struct ast_channel *winner; struct ast_channel *winner;
single = (outgoing && !outgoing->next && !outgoing->musiconhold && !outgoing->ringbackonly); single = (outgoing && !outgoing->next && !ast_test_flag(outgoing, DIAL_MUSICONHOLD) && !ast_test_flag(outgoing, DIAL_RINGBACKONLY));
if (single) { if (single) {
/* Turn off hold music, etc */ /* Turn off hold music, etc */
@ -205,7 +210,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
watchers[0] = in; watchers[0] = in;
while(o) { while(o) {
/* Keep track of important channels */ /* Keep track of important channels */
if (o->stillgoing && o->chan) { if (ast_test_flag(o, DIAL_STILLGOING) && o->chan) {
watchers[pos++] = o->chan; watchers[pos++] = o->chan;
found = 1; found = 1;
} }
@ -235,15 +240,12 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
winner = ast_waitfor_n(watchers, pos, to); winner = ast_waitfor_n(watchers, pos, to);
o = outgoing; o = outgoing;
while(o) { while(o) {
if (o->stillgoing && o->chan && (o->chan->_state == AST_STATE_UP)) { if (ast_test_flag(o, DIAL_STILLGOING) && o->chan && (o->chan->_state == AST_STATE_UP)) {
if (!peer) { if (!peer) {
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name); ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
peer = o->chan; peer = o->chan;
*allowredir_in = o->allowredirect_in; ast_copy_flags(locflags, o, DIAL_ALLOWREDIRECT_IN|DIAL_ALLOWREDIRECT_OUT|DIAL_ALLOWDISCONNECT_IN|DIAL_ALLOWDISCONNECT_OUT);
*allowredir_out = o->allowredirect_out;
*allowdisconnect_in = o->allowdisconnect_in;
*allowdisconnect_out = o->allowdisconnect_out;
} }
} else if (o->chan && (o->chan == winner)) { } else if (o->chan && (o->chan == winner)) {
if (!ast_strlen_zero(o->chan->call_forward)) { if (!ast_strlen_zero(o->chan->call_forward)) {
@ -276,7 +278,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
o->chan = NULL; o->chan = NULL;
} }
if (!o->chan) { if (!o->chan) {
o->stillgoing = 0; ast_clear_flag(o, DIAL_STILLGOING);
HANDLE_CAUSE(cause, in); HANDLE_CAUSE(cause, in);
} else { } else {
if (o->chan->cid.cid_num) if (o->chan->cid.cid_num)
@ -286,7 +288,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
free(o->chan->cid.cid_name); free(o->chan->cid.cid_name);
o->chan->cid.cid_name = NULL; o->chan->cid.cid_name = NULL;
if (o->forcecallerid) { if (ast_test_flag(o, DIAL_FORCECALLERID)) {
char *newcid = NULL; char *newcid = NULL;
if (strlen(in->macroexten)) if (strlen(in->macroexten))
@ -330,7 +332,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
o->chan->cid.cid_rdnis = strdup(in->exten); o->chan->cid.cid_rdnis = strdup(in->exten);
if (ast_call(o->chan, tmpchan, 0)) { if (ast_call(o->chan, tmpchan, 0)) {
ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan); ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
o->stillgoing = 0; ast_clear_flag(o, DIAL_STILLGOING);
ast_hangup(o->chan); ast_hangup(o->chan);
o->chan = NULL; o->chan = NULL;
numnochan++; numnochan++;
@ -350,10 +352,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name); ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
peer = o->chan; peer = o->chan;
*allowredir_in = o->allowredirect_in; ast_copy_flags(locflags, o, DIAL_ALLOWREDIRECT_IN|DIAL_ALLOWREDIRECT_OUT|DIAL_ALLOWDISCONNECT_IN|DIAL_ALLOWDISCONNECT_OUT);
*allowredir_out = o->allowredirect_out;
*allowdisconnect_in = o->allowdisconnect_in;
*allowdisconnect_out = o->allowdisconnect_out;
} }
/* If call has been answered, then the eventual hangup is likely to be normal hangup */ /* If call has been answered, then the eventual hangup is likely to be normal hangup */
in->hangupcause = AST_CAUSE_NORMAL_CLEARING; in->hangupcause = AST_CAUSE_NORMAL_CLEARING;
@ -365,7 +364,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
in->hangupcause = o->chan->hangupcause; in->hangupcause = o->chan->hangupcause;
ast_hangup(o->chan); ast_hangup(o->chan);
o->chan = NULL; o->chan = NULL;
o->stillgoing = 0; ast_clear_flag(o, DIAL_STILLGOING);
HANDLE_CAUSE(AST_CAUSE_BUSY, in); HANDLE_CAUSE(AST_CAUSE_BUSY, in);
break; break;
case AST_CONTROL_CONGESTION: case AST_CONTROL_CONGESTION:
@ -374,13 +373,13 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
in->hangupcause = o->chan->hangupcause; in->hangupcause = o->chan->hangupcause;
ast_hangup(o->chan); ast_hangup(o->chan);
o->chan = NULL; o->chan = NULL;
o->stillgoing = 0; ast_clear_flag(o, DIAL_STILLGOING);
HANDLE_CAUSE(AST_CAUSE_CONGESTION, in); HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
break; break;
case AST_CONTROL_RINGING: case AST_CONTROL_RINGING:
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name); ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name);
if (!(*sentringing) && !outgoing->musiconhold) { if (!(*sentringing) && !ast_test_flag(outgoing, DIAL_MUSICONHOLD)) {
ast_indicate(in, AST_CONTROL_RINGING); ast_indicate(in, AST_CONTROL_RINGING);
(*sentringing)++; (*sentringing)++;
} }
@ -388,7 +387,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
case AST_CONTROL_PROGRESS: case AST_CONTROL_PROGRESS:
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose ( VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", o->chan->name,in->name); ast_verbose ( VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", o->chan->name,in->name);
if (!outgoing->ringbackonly) if (!ast_test_flag(outgoing, DIAL_RINGBACKONLY))
ast_indicate(in, AST_CONTROL_PROGRESS); ast_indicate(in, AST_CONTROL_PROGRESS);
break; break;
case AST_CONTROL_OFFHOOK: case AST_CONTROL_OFFHOOK:
@ -396,7 +395,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
/* Ignore going off hook and flash */ /* Ignore going off hook and flash */
break; break;
case -1: case -1:
if (!outgoing->ringbackonly && !outgoing->musiconhold) { if (!ast_test_flag(outgoing, DIAL_RINGBACKONLY) && !ast_test_flag(outgoing, DIAL_MUSICONHOLD)) {
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", o->chan->name); ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", o->chan->name);
ast_indicate(in, -1); ast_indicate(in, -1);
@ -407,11 +406,11 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
} }
} else if (single && (f->frametype == AST_FRAME_VOICE) && } else if (single && (f->frametype == AST_FRAME_VOICE) &&
!(outgoing->ringbackonly || outgoing->musiconhold)) { !(ast_test_flag(outgoing, DIAL_RINGBACKONLY) || ast_test_flag(outgoing, DIAL_MUSICONHOLD))) {
if (ast_write(in, f)) if (ast_write(in, f))
ast_log(LOG_WARNING, "Unable to forward frame\n"); ast_log(LOG_WARNING, "Unable to forward frame\n");
} else if (single && (f->frametype == AST_FRAME_IMAGE) && } else if (single && (f->frametype == AST_FRAME_IMAGE) &&
!(outgoing->ringbackonly || outgoing->musiconhold)) { !(ast_test_flag(outgoing, DIAL_RINGBACKONLY) || ast_test_flag(outgoing, DIAL_MUSICONHOLD))) {
if (ast_write(in, f)) if (ast_write(in, f))
ast_log(LOG_WARNING, "Unable to forward image\n"); ast_log(LOG_WARNING, "Unable to forward image\n");
} }
@ -420,7 +419,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
in->hangupcause = o->chan->hangupcause; in->hangupcause = o->chan->hangupcause;
ast_hangup(o->chan); ast_hangup(o->chan);
o->chan = NULL; o->chan = NULL;
o->stillgoing = 0; ast_clear_flag(o, DIAL_STILLGOING);
} }
} }
o = o->next; o = o->next;
@ -441,7 +440,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
ast_frfree(f); ast_frfree(f);
return NULL; return NULL;
} }
if (f && (f->frametype == AST_FRAME_DTMF) && *allowdisconnect_out && if (f && (f->frametype == AST_FRAME_DTMF) && ast_test_flag(locflags, DIAL_ALLOWDISCONNECT_OUT) &&
(f->subclass == '*')) { (f->subclass == '*')) {
if (option_verbose > 3) if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_3 "User hit %c to disconnect call.\n", f->subclass); ast_verbose(VERBOSE_PREFIX_3 "User hit %c to disconnect call.\n", f->subclass);
@ -474,12 +473,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
struct localuser *outgoing=NULL, *tmp; struct localuser *outgoing=NULL, *tmp;
struct ast_channel *peer; struct ast_channel *peer;
int to; int to;
int allowredir_in=0; struct ast_flags locflags={0};
int allowredir_out=0;
int monitor_in = 0;
int monitor_out = 0;
int allowdisconnect_in=0;
int allowdisconnect_out=0;
int hasmacro = 0; int hasmacro = 0;
int privacy=0; int privacy=0;
int announce=0; int announce=0;
@ -497,7 +491,6 @@ static int dial_exec(struct ast_channel *chan, void *data)
struct ast_var_t *current; struct ast_var_t *current;
struct varshead *headp, *newheadp; struct varshead *headp, *newheadp;
struct ast_var_t *newvar; struct ast_var_t *newvar;
int go_on=0;
unsigned int calldurationlimit=0; unsigned int calldurationlimit=0;
char *cdl; char *cdl;
time_t now; time_t now;
@ -793,33 +786,16 @@ static int dial_exec(struct ast_channel *chan, void *data)
} }
memset(tmp, 0, sizeof(struct localuser)); memset(tmp, 0, sizeof(struct localuser));
if (transfer) { if (transfer) {
if (strchr(transfer, 'w')) ast_set2_flag(tmp, strchr(transfer, 't'), DIAL_ALLOWREDIRECT_IN);
monitor_in = 1; ast_set2_flag(tmp, strchr(transfer, 't'), DIAL_ALLOWREDIRECT_OUT);
if (strchr(transfer, 'W')) ast_set2_flag(tmp, strchr(transfer, 'r'), DIAL_RINGBACKONLY);
monitor_out = 1; ast_set2_flag(tmp, strchr(transfer, 'm'), DIAL_MUSICONHOLD);
if (strchr(transfer, 't')) ast_set2_flag(tmp, strchr(transfer, 'H'), DIAL_ALLOWDISCONNECT_OUT);
tmp->allowredirect_in = 1; ast_set2_flag(tmp, strchr(transfer, 'h'), DIAL_ALLOWDISCONNECT_IN);
else tmp->allowredirect_in = 0; ast_set2_flag(tmp, strchr(transfer, 'f'), DIAL_FORCECALLERID);
if (strchr(transfer, 'T')) ast_set2_flag(tmp, strchr(transfer, 'w'), DIAL_MONITOR_IN);
tmp->allowredirect_out = 1; ast_set2_flag(tmp, strchr(transfer, 'W'), DIAL_MONITOR_OUT);
else tmp->allowredirect_out = 0; ast_set2_flag(tmp, strchr(transfer, 'g'), DIAL_GO_ON);
if (strchr(transfer, 'r'))
tmp->ringbackonly = 1;
else tmp->ringbackonly = 0;
if (strchr(transfer, 'm'))
tmp->musiconhold = 1;
else tmp->musiconhold = 0;
if (strchr(transfer, 'H'))
allowdisconnect_out = tmp->allowdisconnect_out = 1;
else allowdisconnect_out = tmp->allowdisconnect_out = 0;
if(strchr(transfer, 'h'))
allowdisconnect_in = tmp->allowdisconnect_in = 1;
else allowdisconnect_in = tmp->allowdisconnect_in = 0;
if(strchr(transfer, 'g'))
go_on=1;
if (strchr(transfer, 'f'))
tmp->forcecallerid = 1;
else tmp->forcecallerid = 0;
} }
strncpy(numsubst, number, sizeof(numsubst)-1); strncpy(numsubst, number, sizeof(numsubst)-1);
/* If we're dialing by extension, look at the extension to know what to dial */ /* If we're dialing by extension, look at the extension to know what to dial */
@ -977,7 +953,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
/* Put them in the list of outgoing thingies... We're ready now. /* Put them in the list of outgoing thingies... We're ready now.
XXX If we're forcibly removed, these outgoing calls won't get XXX If we're forcibly removed, these outgoing calls won't get
hung up XXX */ hung up XXX */
tmp->stillgoing = -1; ast_set_flag(tmp, DIAL_STILLGOING);
tmp->next = outgoing; tmp->next = outgoing;
outgoing = tmp; outgoing = tmp;
/* If this line is up, don't try anybody else */ /* If this line is up, don't try anybody else */
@ -998,10 +974,10 @@ static int dial_exec(struct ast_channel *chan, void *data)
if (outgoing) { if (outgoing) {
/* Our status will at least be NOANSWER */ /* Our status will at least be NOANSWER */
strncpy(status, "NOANSWER", sizeof(status) - 1); strncpy(status, "NOANSWER", sizeof(status) - 1);
if (outgoing->musiconhold) { if (ast_test_flag(outgoing, DIAL_MUSICONHOLD)) {
moh=1; moh=1;
ast_moh_start(chan, mohclass); ast_moh_start(chan, mohclass);
} else if (outgoing->ringbackonly) { } else if (ast_test_flag(outgoing, DIAL_RINGBACKONLY)) {
ast_indicate(chan, AST_CONTROL_RINGING); ast_indicate(chan, AST_CONTROL_RINGING);
sentringing++; sentringing++;
} }
@ -1009,8 +985,8 @@ static int dial_exec(struct ast_channel *chan, void *data)
strncpy(status, "CHANUNAVAIL", sizeof(status) - 1); strncpy(status, "CHANUNAVAIL", sizeof(status) - 1);
time(&start_time); time(&start_time);
peer = wait_for_answer(chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect_in, &allowdisconnect_out, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion); peer = wait_for_answer(chan, outgoing, &to, &locflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion);
if (!peer) { if (!peer) {
if (to) if (to)
/* Musta gotten hung up */ /* Musta gotten hung up */
@ -1095,13 +1071,13 @@ static int dial_exec(struct ast_channel *chan, void *data)
if (!strcasecmp(macro_result, "BUSY")) { if (!strcasecmp(macro_result, "BUSY")) {
strncpy(status, macro_result, sizeof(status) - 1); strncpy(status, macro_result, sizeof(status) - 1);
if (!ast_goto_if_exists(chan, NULL, NULL, chan->priority + 101)) { if (!ast_goto_if_exists(chan, NULL, NULL, chan->priority + 101)) {
go_on = 1; ast_set_flag(&locflags, DIAL_GO_ON);
} }
res = -1; res = -1;
} }
else if (!strcasecmp(macro_result, "CONGESTION") || !strcasecmp(macro_result, "CHANUNAVAIL")) { else if (!strcasecmp(macro_result, "CONGESTION") || !strcasecmp(macro_result, "CHANUNAVAIL")) {
strncpy(status, macro_result, sizeof(status) - 1); strncpy(status, macro_result, sizeof(status) - 1);
go_on = 1; ast_set_flag(&locflags, DIAL_GO_ON);
res = -1; res = -1;
} }
else if (!strcasecmp(macro_result, "CONTINUE")) { else if (!strcasecmp(macro_result, "CONTINUE")) {
@ -1109,7 +1085,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
the context / exten / priority or perhaps the context / exten / priority or perhaps
the next priority in the current exten is desired. the next priority in the current exten is desired.
*/ */
go_on = 1; ast_set_flag(&locflags, DIAL_GO_ON);
res = -1; res = -1;
} else if (!strcasecmp(macro_result, "ABORT")) { } else if (!strcasecmp(macro_result, "ABORT")) {
/* Hangup both ends unless the caller has the g flag */ /* Hangup both ends unless the caller has the g flag */
@ -1124,8 +1100,8 @@ static int dial_exec(struct ast_channel *chan, void *data)
macro_transfer_dest[res] = '|'; macro_transfer_dest[res] = '|';
if(!ast_parseable_goto(chan, macro_transfer_dest)) if(!ast_parseable_goto(chan, macro_transfer_dest))
go_on = 1; ast_set_flag(&locflags, DIAL_GO_ON);
} }
} }
} }
@ -1147,18 +1123,18 @@ static int dial_exec(struct ast_channel *chan, void *data)
config.features_caller |= AST_FEATURE_PLAY_WARNING; config.features_caller |= AST_FEATURE_PLAY_WARNING;
if (play_to_callee) if (play_to_callee)
config.features_callee |= AST_FEATURE_PLAY_WARNING; config.features_callee |= AST_FEATURE_PLAY_WARNING;
if (allowredir_in) if (ast_test_flag(&locflags, DIAL_ALLOWREDIRECT_IN))
config.features_callee |= AST_FEATURE_REDIRECT; config.features_callee |= AST_FEATURE_REDIRECT;
if (allowredir_out) if (ast_test_flag(&locflags, DIAL_ALLOWREDIRECT_OUT))
config.features_caller |= AST_FEATURE_REDIRECT; config.features_caller |= AST_FEATURE_REDIRECT;
if (monitor_in) if (ast_test_flag(&locflags, DIAL_ALLOWDISCONNECT_IN))
config.features_callee |= AST_FEATURE_AUTOMON;
if (monitor_out)
config.features_caller |= AST_FEATURE_AUTOMON;
if (allowdisconnect_in)
config.features_callee |= AST_FEATURE_DISCONNECT; config.features_callee |= AST_FEATURE_DISCONNECT;
if (allowdisconnect_out) if (ast_test_flag(&locflags, DIAL_ALLOWDISCONNECT_OUT))
config.features_caller |= AST_FEATURE_DISCONNECT; config.features_caller |= AST_FEATURE_DISCONNECT;
if (ast_test_flag(&locflags, DIAL_MONITOR_IN))
config.features_callee |= AST_FEATURE_AUTOMON;
if (ast_test_flag(&locflags, DIAL_MONITOR_OUT))
config.features_caller |= AST_FEATURE_AUTOMON;
config.timelimit = timelimit; config.timelimit = timelimit;
config.play_warning = play_warning; config.play_warning = play_warning;
config.warning_freq = warning_freq; config.warning_freq = warning_freq;
@ -1211,7 +1187,7 @@ out:
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
if((go_on>0) && (!chan->_softhangup)) if((ast_test_flag(&locflags, DIAL_GO_ON)) && (!chan->_softhangup))
res=0; res=0;
return res; return res;

@ -212,7 +212,7 @@ struct iax2_user {
char inkeys[80]; /* Key(s) this user can use to authenticate to us */ char inkeys[80]; /* Key(s) this user can use to authenticate to us */
char language[MAX_LANGUAGE]; char language[MAX_LANGUAGE];
int amaflags; int amaflags;
int flags; unsigned int flags;
int capability; int capability;
char cid_num[AST_MAX_EXTENSION]; char cid_num[AST_MAX_EXTENSION];
char cid_name[AST_MAX_EXTENSION]; char cid_name[AST_MAX_EXTENSION];
@ -235,7 +235,7 @@ struct iax2_peer {
struct sockaddr_in addr; struct sockaddr_in addr;
int formats; int formats;
struct in_addr mask; struct in_addr mask;
int flags; unsigned int flags;
/* Dynamic Registration fields */ /* Dynamic Registration fields */
struct sockaddr_in defaddr; /* Default address if there is one */ struct sockaddr_in defaddr; /* Default address if there is one */
@ -450,7 +450,7 @@ struct chan_iax2_pvt {
/* Associated peer for poking */ /* Associated peer for poking */
struct iax2_peer *peerpoke; struct iax2_peer *peerpoke;
/* IAX_ flags */ /* IAX_ flags */
int flags; unsigned int flags;
/* Transferring status */ /* Transferring status */
int transferring; int transferring;

@ -311,7 +311,7 @@ static struct sip_pvt {
unsigned int callgroup; /* Call group */ unsigned int callgroup; /* Call group */
unsigned int pickupgroup; /* Pickup group */ unsigned int pickupgroup; /* Pickup group */
int lastinvite; /* Last Cseq of invite */ int lastinvite; /* Last Cseq of invite */
int flags; /* SIP_ flags */ unsigned int flags; /* SIP_ flags */
int capability; /* Special capability (codec) */ int capability; /* Special capability (codec) */
int jointcapability; /* Supported capability at both ends (codecs ) */ int jointcapability; /* Supported capability at both ends (codecs ) */
int peercapability; /* Supported peer capability */ int peercapability; /* Supported peer capability */
@ -406,7 +406,7 @@ struct sip_pkt {
struct sip_pkt *next; /* Next packet */ struct sip_pkt *next; /* Next packet */
int retrans; /* Retransmission number */ int retrans; /* Retransmission number */
int seqno; /* Sequence number */ int seqno; /* Sequence number */
int flags; /* non-zero if this is a response packet (e.g. 200 OK) */ unsigned int flags; /* non-zero if this is a response packet (e.g. 200 OK) */
struct sip_pvt *owner; /* Owner call */ struct sip_pvt *owner; /* Owner call */
int retransid; /* Retransmission ID */ int retransid; /* Retransmission ID */
int packetlen; /* Length of packet */ int packetlen; /* Length of packet */
@ -429,7 +429,7 @@ struct sip_user {
struct ast_codec_pref prefs; /* codec prefs */ struct ast_codec_pref prefs; /* codec prefs */
unsigned int callgroup; /* Call group */ unsigned int callgroup; /* Call group */
unsigned int pickupgroup; /* Pickup Group */ unsigned int pickupgroup; /* Pickup Group */
int flags; /* SIP_ flags */ unsigned int flags; /* SIP_ flags */
int amaflags; /* AMA flags for billing */ int amaflags; /* AMA flags for billing */
int callingpres; /* Calling id presentation */ int callingpres; /* Calling id presentation */
int capability; /* Codec capability */ int capability; /* Codec capability */
@ -462,7 +462,7 @@ struct sip_peer {
struct ast_codec_pref prefs; /* codec prefs */ struct ast_codec_pref prefs; /* codec prefs */
int lastmsgssent; int lastmsgssent;
time_t lastmsgcheck; /* Last time we checked for MWI */ time_t lastmsgcheck; /* Last time we checked for MWI */
int flags; /* SIP_ flags */ unsigned int flags; /* SIP_ flags */
int expire; /* Registration expiration */ int expire; /* Registration expiration */
int expiry; int expiry;
int capability; /* Codec capability */ int capability; /* Codec capability */
@ -718,10 +718,10 @@ static int retrans_pkt(void *data)
__sip_xmit(pkt->owner, pkt->data, pkt->packetlen); __sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
res = 1; res = 1;
} else { } else {
ast_log(LOG_WARNING, "Maximum retries exceeded on call %s for seqno %d (%s %s)\n", pkt->owner->callid, pkt->seqno, (pkt->flags & FLAG_FATAL) ? "Critical" : "Non-critical", (pkt->flags & FLAG_RESPONSE) ? "Response" : "Request"); ast_log(LOG_WARNING, "Maximum retries exceeded on call %s for seqno %d (%s %s)\n", pkt->owner->callid, pkt->seqno, (ast_test_flag(pkt, FLAG_FATAL)) ? "Critical" : "Non-critical", (ast_test_flag(pkt, FLAG_RESPONSE)) ? "Response" : "Request");
append_history(pkt->owner, "MaxRetries", pkt->flags & FLAG_FATAL ? "(Critical)" : "(Non-critical)"); append_history(pkt->owner, "MaxRetries", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
pkt->retransid = -1; pkt->retransid = -1;
if (pkt->flags & FLAG_FATAL) { if (ast_test_flag(pkt, FLAG_FATAL)) {
while(pkt->owner->owner && ast_mutex_trylock(&pkt->owner->owner->lock)) { while(pkt->owner->owner && ast_mutex_trylock(&pkt->owner->owner->lock)) {
ast_mutex_unlock(&pkt->owner->lock); ast_mutex_unlock(&pkt->owner->lock);
usleep(1); usleep(1);
@ -777,7 +777,7 @@ static int __sip_reliable_xmit(struct sip_pvt *p, int seqno, int resp, char *dat
pkt->flags = resp; pkt->flags = resp;
pkt->data[len] = '\0'; pkt->data[len] = '\0';
if (fatal) if (fatal)
pkt->flags |= FLAG_FATAL; ast_set_flag(pkt, FLAG_FATAL);
/* Schedule retransmission */ /* Schedule retransmission */
pkt->retransid = ast_sched_add(sched, DEFAULT_RETRANS, retrans_pkt, pkt); pkt->retransid = ast_sched_add(sched, DEFAULT_RETRANS, retrans_pkt, pkt);
pkt->next = p->packets; pkt->next = p->packets;
@ -842,8 +842,8 @@ static int __sip_ack(struct sip_pvt *p, int seqno, int resp, const char *msg)
if (!msg) msg = "___NEVER___"; if (!msg) msg = "___NEVER___";
cur = p->packets; cur = p->packets;
while(cur) { while(cur) {
if ((cur->seqno == seqno) && ((cur->flags & FLAG_RESPONSE) == resp) && if ((cur->seqno == seqno) && ((ast_test_flag(cur, FLAG_RESPONSE)) == resp) &&
((cur->flags & FLAG_RESPONSE) || ((ast_test_flag(cur, FLAG_RESPONSE)) ||
(!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) { (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
if (!resp && (seqno == p->pendinginvite)) { if (!resp && (seqno == p->pendinginvite)) {
ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite); ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
@ -872,7 +872,7 @@ static int __sip_ack(struct sip_pvt *p, int seqno, int resp, const char *msg)
static int __sip_pretend_ack(struct sip_pvt *p) static int __sip_pretend_ack(struct sip_pvt *p)
{ {
while(p->packets) { while(p->packets) {
__sip_ack(p, p->packets->seqno, (p->packets->flags & FLAG_RESPONSE), p->packets->data); __sip_ack(p, p->packets->seqno, (ast_test_flag(p->packets, FLAG_RESPONSE)), p->packets->data);
} }
return 0; return 0;
} }
@ -884,8 +884,8 @@ static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, const char *ms
int res = -1; int res = -1;
cur = p->packets; cur = p->packets;
while(cur) { while(cur) {
if ((cur->seqno == seqno) && ((cur->flags & FLAG_RESPONSE) == resp) && if ((cur->seqno == seqno) && ((ast_test_flag(cur, FLAG_RESPONSE)) == resp) &&
((cur->flags & FLAG_RESPONSE) || ((ast_test_flag(cur, FLAG_RESPONSE)) ||
(!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) { (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
/* this is our baby */ /* this is our baby */
if (cur->retransid > -1) if (cur->retransid > -1)

Loading…
Cancel
Save