Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.591 diff -u -r1.591 chan_sip.c --- channels/chan_sip.c 13 Dec 2004 15:26:26 -0000 1.591 +++ channels/chan_sip.c 18 Dec 2004 05:51:09 -0000 @@ -254,6 +254,24 @@ struct sip_history *next; }; +#define SIP_ALREADYGONE (1 << 0) /* Whether or not we've already been destroyed by our peer */ +#define SIP_NEEDDESTROY (1 << 1) /* if we need to be destroyed */ +#define SIP_NOVIDEO (1 << 2) /* Didn't get video in invite, don't offer */ +#define SIP_RINGING (1 << 3) /* Have sent 180 ringing */ +#define SIP_PROGRESS (1 << 4) /* Have sent 183 message progress */ +#define SIP_NEEDREINVITE (1 << 5) /* Do we need to send another reinvite? */ +#define SIP_PENDINGBYE (1 << 6) /* Need to send bye after we ack? */ +#define SIP_GOTREFER (1 << 7) /* Got a refer? */ +#define SIP_PROMISCREDIR (1 << 8) /* Promiscuous redirection */ +#define SIP_TRUSTRPID (1 << 9) /* Trust RPID headers? */ +#define SIP_USEREQPHONE (1 << 10) /* Add user=phone to numeric URI. Default off */ +#define SIP_TEMPONLY (1 << 11) /* Flag for temporary users (realtime) */ +#define SIP_USECLIENTCODE (1 << 12) /* Trust X-ClientCode info message */ +#define SIP_OUTGOING (1 << 13) /* Is this an outgoing call? */ +#define SIP_DELME (1 << 14) +#define SIP_SELFDESTRUCT (1 << 15) +#define SIP_DYNAMIC (1 << 16) /* Is this a dynamic peer? */ + /* sip_pvt: PVT structures are used for each SIP conversation, ie. a call */ static struct sip_pvt { ast_mutex_t lock; /* Channel private lock */ @@ -265,24 +283,18 @@ unsigned int callgroup; /* Call group */ unsigned int pickupgroup; /* Pickup group */ int lastinvite; /* Last Cseq of invite */ - int alreadygone; /* Whether or not we've already been destroyed by or peer */ - int needdestroy; /* if we need to be destroyed */ + int flags; /* SIP_ flags */ int capability; /* Special capability (codec) */ - int novideo; /* Didn't get video in invite, don't offer */ int jointcapability; /* Supported capability at both ends (codecs ) */ int peercapability; /* Supported peer capability */ int prefcodec; /* Preferred codec (outbound only) */ int noncodeccapability; int callingpres; /* Calling presentation */ - int outgoing; /* Outgoing or incoming call? */ int authtries; /* Times we've tried to authenticate */ int insecure; /* Don't check source port/ip */ int expiry; /* How long we take to expire */ int branch; /* One random number */ int canreinvite; /* Do we support reinvite */ - int ringing; /* Have sent 180 ringing */ - int progress; /* Have sent 183 message progress */ - int useclientcode; /* Trust X-ClientCode info message */ int tag; /* Another random number */ int nat; /* Whether to try to support NAT */ int sessionid; /* SDP Session ID */ @@ -331,9 +343,6 @@ char lastmsg[256]; /* Last Message sent/received */ int amaflags; /* AMA Flags */ int pendinginvite; /* Any pending invite */ - int needreinvite; /* Do we need to send another reinvite? */ - int pendingbye; /* Need to send bye after we ack? */ - int gotrefer; /* Got a refer? */ #ifdef OSP_SUPPORT int ospauth; /* Allow OSP Authentication */ int osphandle; /* OSP Handle for call */ @@ -351,10 +360,7 @@ int subscribed; /* Is this call a subscription? */ int stateid; int dialogver; - int promiscredir; /* Promiscuous redirection */ - int usereqphone; /* Add user=phone to numeric URI. Default off */ - int trustrpid; /* Trust RPID headers? */ int progressinband; int dtmfmode; /* DTMF to use for this call */ @@ -401,6 +407,7 @@ struct ast_codec_pref prefs; /* codec prefs */ unsigned int callgroup; /* Call group */ unsigned int pickupgroup; /* Pickup Group */ + int flags; /* SIP_ flags */ int nat; /* NAT setting */ int amaflags; /* AMA flags for billing */ int callingpres; /* Calling id presentation */ @@ -415,12 +422,8 @@ int incominglimit; int outUse; int outgoinglimit; - int promiscredir; /* Support of 302 redirect */ - int useclientcode; /* SNOM clientcode support */ - int trustrpid; /* Trust remote party ID from this UA */ int progressinband; struct ast_ha *ha; /* ACL setting */ - int temponly; /* Flag for temporary users (realtime) */ struct ast_variable *vars; struct sip_user *next; }; @@ -446,7 +449,7 @@ struct ast_codec_pref prefs; /* codec prefs */ int lastmsgssent; time_t lastmsgcheck; /* Last time we checked for MWI */ - int dynamic; /* Dynamic? Yes or no. Dynamic hosts register with us */ + int flags; /* SIP_ flags */ int expire; /* Registration expiration */ int expiry; int capability; /* Codec capability */ @@ -460,12 +463,8 @@ int canreinvite; /* Does the peer support re-invites? */ unsigned int callgroup; /* Call group */ unsigned int pickupgroup; /* Pickup group */ - int promiscredir; /* Support of 302 redirect? */ int dtmfmode; /* DTMF mode */ - int trustrpid; /* Trust Remote Party ID headers? */ - int useclientcode; /* SNOM clientcode support */ int progressinband; - int usereqphone; /* Add user=phone to URI. Default off */ struct sockaddr_in addr; /* IP address of peer */ struct in_addr mask; @@ -478,10 +477,7 @@ struct sockaddr_in defaddr; /* Default IP address, used until registration */ struct ast_ha *ha; /* Access control list */ - int delme; - int selfdestruct; int lastmsg; - int temponly; struct sip_peer *next; }; @@ -713,12 +709,12 @@ ast_mutex_lock(&pkt->owner->lock); } if (pkt->owner->owner) { - pkt->owner->alreadygone=1; + ast_set_flag(pkt->owner, SIP_ALREADYGONE); ast_queue_hangup(pkt->owner->owner); ast_mutex_unlock(&pkt->owner->owner->lock); } else { /* If no owner, destroy now */ - pkt->owner->needdestroy = 1; + ast_set_flag(pkt->owner, SIP_NEEDDESTROY); } } /* In any case, go ahead and remove the packet */ @@ -1080,7 +1076,7 @@ /*--- update_peer: Update peer data in database (if used) ---*/ static void update_peer(struct sip_peer *p, int expiry) { - if (p->temponly) + if (ast_test_flag(p, SIP_TEMPONLY)) realtime_update_peer(p->name, &p->addr, p->username, expiry); } @@ -1105,7 +1101,7 @@ peer = build_peer(peername, var, 1); if (peer) { /* Add some finishing touches, addresses, etc */ - peer->temponly = 1; + ast_set_flag(peer, SIP_TEMPONLY); tmp = var; while(tmp) { if (!strcasecmp(tmp->name, "type")) { @@ -1199,7 +1195,7 @@ user = build_user(username, var); if (user) { /* Add some finishing touches, addresses, etc */ - user->temponly = 1; + ast_set_flag(user, SIP_TEMPONLY); tmp = var; while(tmp) { if (!strcasecmp(tmp->name, "type")) { @@ -1308,8 +1304,8 @@ else r->noncodeccapability &= ~AST_RTP_DTMF; } - r->promiscredir = p->promiscredir; - r->usereqphone = p->usereqphone; + ast_set2_flag(r, ast_test_flag(p, SIP_PROMISCREDIR), SIP_PROMISCREDIR); + ast_set2_flag(r, ast_test_flag(p, SIP_USEREQPHONE), SIP_USEREQPHONE); strncpy(r->context, p->context,sizeof(r->context)-1); if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) && (!p->maxms || ((p->lastms >= 0) && (p->lastms <= p->maxms)))) { @@ -1322,7 +1318,7 @@ } memcpy(&r->recv, &r->sa, sizeof(r->recv)); } else { - if (p->temponly) { + if (ast_test_flag(p, SIP_TEMPONLY)) { destroy_peer(p); } p = NULL; @@ -1360,7 +1356,7 @@ } else if (!p) return -1; else { - if (p->temponly) { + if (ast_test_flag(p, SIP_TEMPONLY)) { destroy_peer(p); } return 0; @@ -1434,7 +1430,7 @@ } res = 0; - p->outgoing = 1; + ast_set_flag(p, SIP_OUTGOING); #ifdef OSP_SUPPORT if (!osptoken || !osphandle || (sscanf(osphandle, "%i", &p->osphandle) != 1)) { /* Force Disable OSP support */ @@ -1576,7 +1572,7 @@ u->inUse++; } ast_mutex_unlock(&userl.lock); - if (u->temponly) { + if (ast_test_flag(u, SIP_TEMPONLY)) { destroy_user(u); } return -1; @@ -1611,7 +1607,7 @@ ast_log(LOG_ERROR, "update_user_counter(%s,%d) called with no event!\n",u->name,event); } ast_mutex_unlock(&userl.lock); - if (u->temponly) { + if (ast_test_flag(u, SIP_TEMPONLY)) { destroy_user(u); } return 0; @@ -1684,7 +1680,7 @@ ast_osp_terminate(p->osphandle, AST_CAUSE_NORMAL, p->ospstart, time(NULL) - p->ospstart); } #endif - if ( p->outgoing ) { + if (ast_test_flag(p, SIP_OUTGOING)) { ast_log(LOG_DEBUG, "update_user_counter(%s) - decrement outUse counter\n", p->username); update_user_counter(p, DEC_OUT_USE); } else { @@ -1714,9 +1710,9 @@ needdestroy = 1; /* Start the process if it's not already started */ - if (!p->alreadygone && !ast_strlen_zero(p->initreq.data)) { + if (!ast_test_flag(p, SIP_ALREADYGONE) && !ast_strlen_zero(p->initreq.data)) { if (needcancel) { - if (p->outgoing) { + if (ast_test_flag(p, SIP_OUTGOING)) { transmit_request_with_auth(p, "CANCEL", p->ocseq, 1, 0); /* Actually don't destroy us yet, wait for the 487 on our original INVITE, but do set an autodestruct just in case we never get it. */ @@ -1725,7 +1721,7 @@ if ( p->initid != -1 ) { /* channel still up - reverse dec of inUse counter only if the channel is not auto-congested */ - if ( p->outgoing ) { + if (ast_test_flag(p, SIP_OUTGOING)) { update_user_counter(p, INC_OUT_USE); } else { @@ -1746,12 +1742,12 @@ } else { /* Note we will need a BYE when this all settles out but we can't send one while we have "INVITE" outstanding. */ - p->pendingbye = 1; - p->needreinvite = 0; + ast_set_flag(p, SIP_PENDINGBYE); + ast_clear_flag(p, SIP_NEEDREINVITE); } } } - p->needdestroy = needdestroy; + ast_set2_flag(p, needdestroy, SIP_NEEDDESTROY); ast_mutex_unlock(&p->lock); return 0; } @@ -1805,9 +1801,9 @@ if (p) { ast_mutex_lock(&p->lock); if (p->rtp) { - if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) { + if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS) && !ast_test_flag(p, SIP_OUTGOING)) { transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0); - p->progress = 1; + ast_set_flag(p, SIP_PROGRESS); } res = ast_rtp_write(p->rtp, frame); } @@ -1817,9 +1813,9 @@ if (p) { ast_mutex_lock(&p->lock); if (p->vrtp) { - if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) { + if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS) && !ast_test_flag(p, SIP_OUTGOING)) { transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0); - p->progress = 1; + ast_set_flag(p, SIP_PROGRESS); } res = ast_rtp_write(p->vrtp, frame); } @@ -1887,10 +1883,10 @@ switch(condition) { case AST_CONTROL_RINGING: if (ast->_state == AST_STATE_RING) { - if (!p->progress || !p->progressinband) { + if (!ast_test_flag(p, SIP_PROGRESS) || !p->progressinband) { /* Send 180 ringing if out-of-band seems reasonable */ transmit_response(p, "180 Ringing", &p->initreq); - p->ringing = 1; + ast_set_flag(p, SIP_RINGING); if (p->progressinband < 2) break; } else { @@ -1901,7 +1897,7 @@ case AST_CONTROL_BUSY: if (ast->_state != AST_STATE_UP) { transmit_response(p, "486 Busy Here", &p->initreq); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV); break; } @@ -1909,16 +1905,16 @@ case AST_CONTROL_CONGESTION: if (ast->_state != AST_STATE_UP) { transmit_response(p, "503 Service Unavailable", &p->initreq); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV); break; } return -1; case AST_CONTROL_PROGRESS: case AST_CONTROL_PROCEEDING: - if ((ast->_state != AST_STATE_UP) && !p->progress && !p->outgoing) { + if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS) && !ast_test_flag(p, SIP_OUTGOING)) { transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0); - p->progress = 1; + ast_set_flag(p, SIP_PROGRESS); break; } return -1; @@ -2320,8 +2316,8 @@ /* Assign default music on hold class */ strncpy(p->musicclass, global_musicclass, sizeof(p->musicclass) - 1); p->dtmfmode = global_dtmfmode; - p->promiscredir = global_promiscredir; - p->trustrpid = global_trustrpid; + ast_set2_flag(p, global_promiscredir, SIP_PROMISCREDIR); + ast_set2_flag(p, global_trustrpid, SIP_TRUSTRPID); p->progressinband = global_progressinband; #ifdef OSP_SUPPORT p->ospauth = global_ospauth; @@ -2641,7 +2637,7 @@ return -1; } sdpLineNum_iterator_init(&iterator); - p->novideo = 1; + ast_set_flag(p, SIP_NOVIDEO); while ((m = get_sdp_iterate(&iterator, req, "m"))[0] != '\0') { if ((sscanf(m, "audio %d RTP/AVP %n", &x, &len) == 1) || (sscanf(m, "audio %d/%d RTP/AVP %n", &x, &y, &len) == 2)) { @@ -2666,7 +2662,7 @@ ast_rtp_pt_clear(p->vrtp); /* Must be cleared in case no m=video line exists */ if (p->vrtp && (sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1)) { - p->novideo = 0; + ast_clear_flag(p, SIP_NOVIDEO); vportno = x; /* Scan through the RTP payload types specified in a "m=" line: */ codecs = m + len; @@ -3077,9 +3073,9 @@ if (!strstr(ot, "tag=")) { /* Add the proper tag if we don't have it already. If they have specified their tag, use it. Otherwise, use our own tag */ - if (!ast_strlen_zero(p->theirtag) && p->outgoing) + if (!ast_strlen_zero(p->theirtag) && ast_test_flag(p, SIP_OUTGOING)) snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->theirtag); - else if (p->tag && !p->outgoing) + else if (p->tag && !ast_test_flag(p, SIP_OUTGOING)) snprintf(newto, sizeof(newto), "%s;tag=as%08x", ot, p->tag); else { strncpy(newto, ot, sizeof(newto) - 1); @@ -3139,7 +3135,7 @@ } else if (!ast_strlen_zero(p->uri)) { c = p->uri; } else { - if (p->outgoing) + if (ast_test_flag(p, SIP_OUTGOING)) strncpy(stripped, get_header(orig, "To"), sizeof(stripped) - 1); else strncpy(stripped, get_header(orig, "From"), sizeof(stripped) - 1); @@ -3174,16 +3170,16 @@ if (!strstr(ot, "tag=") && strcasecmp(msg, "CANCEL")) { /* Add the proper tag if we don't have it already. If they have specified their tag, use it. Otherwise, use our own tag */ - if (p->outgoing && !ast_strlen_zero(p->theirtag)) + if (ast_test_flag(p, SIP_OUTGOING) && !ast_strlen_zero(p->theirtag)) snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->theirtag); - else if (!p->outgoing) + else if (!ast_test_flag(p, SIP_OUTGOING)) snprintf(newto, sizeof(newto), "%s;tag=as%08x", ot, p->tag); else snprintf(newto, sizeof(newto), "%s", ot); ot = newto; } - if (p->outgoing) { + if (ast_test_flag(p, SIP_OUTGOING)) { add_header(req, "From", of); add_header(req, "To", ot); } else { @@ -3473,7 +3469,7 @@ if ((sizeof(m) <= strlen(m) - 2) || (sizeof(m2) <= strlen(m2) - 2) || (sizeof(a) == strlen(a)) || (sizeof(a2) == strlen(a2))) ast_log(LOG_WARNING, "SIP SDP may be truncated due to undersized buffer!!\n"); len = strlen(v) + strlen(s) + strlen(o) + strlen(c) + strlen(t) + strlen(m) + strlen(a); - if ((p->vrtp) && (!p->novideo) && (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */ + if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */ len += strlen(m2) + strlen(a2); snprintf(costr, sizeof(costr), "%d", len); add_header(resp, "Content-Type", "application/sdp"); @@ -3485,7 +3481,7 @@ add_line(resp, t); add_line(resp, m); add_line(resp, a); - if ((p->vrtp) && (!p->novideo) && (capability & VIDEO_CODEC_MASK)) { /* only if video response is appropriate */ + if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) { /* only if video response is appropriate */ add_line(resp, m2); add_line(resp, a2); } @@ -3605,7 +3601,7 @@ ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines); determine_firstline_parts(&p->initreq); p->lastinvite = p->ocseq; - p->outgoing = 1; + ast_set_flag(p, SIP_OUTGOING); return send_request(p, &req, 1, p->ocseq); } @@ -3653,7 +3649,7 @@ int x; char urioptions[256]=""; - if (p->usereqphone) { + if (ast_test_flag(p, SIP_USEREQPHONE)) { char onlydigits = 1; x=0; @@ -4085,7 +4081,7 @@ p = r->call; p->registry = NULL; r->call = NULL; - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); /* Pretend to ACK anything just in case */ __sip_pretend_ack(p); } @@ -4146,7 +4142,7 @@ strncpy(r->callid, p->callid, sizeof(r->callid) - 1); if (r->portno) p->sa.sin_port = htons(r->portno); - p->outgoing = 1; /* Registration is outgoing call */ + ast_set_flag(p, SIP_OUTGOING); /* Registration is outgoing call */ r->call=p; /* Save pointer to SIP packet */ p->registry=r; /* Add pointer to registry in packet */ if (!ast_strlen_zero(r->secret)) /* Secret (password) */ @@ -4280,7 +4276,7 @@ char from[256]; char *of, *c; char referto[256]; - if (p->outgoing) + if (ast_test_flag(p, SIP_OUTGOING)) of = get_header(&p->initreq, "To"); else of = get_header(&p->initreq, "From"); @@ -4363,8 +4359,8 @@ register_peer_exten(p, 0); p->expire = -1; ast_device_state_changed("SIP/%s", p->name); - if (p->selfdestruct) { - p->delme = 1; + if (ast_test_flag(p, SIP_SELFDESTRUCT)) { + ast_set_flag(p, SIP_DELME); prune_peers(); } return 0; @@ -4541,7 +4537,7 @@ ast_sched_del(sched, p->expire); if ((expiry < 1) || (expiry > max_expiry)) expiry = max_expiry; - if (!p->temponly) + if (!ast_test_flag(p, SIP_TEMPONLY)) p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p); else p->expire = -1; @@ -4901,7 +4897,7 @@ ast_mutex_lock(&peerl.lock); peer = find_peer(name, NULL); if (!(peer && ast_apply_ha(peer->ha, sin))) { - if (peer && peer->temponly) { + if (peer && ast_test_flag(peer, SIP_TEMPONLY)) { destroy_peer(peer); } peer = NULL; @@ -4909,7 +4905,7 @@ ast_mutex_unlock(&peerl.lock); if (peer) { - if (!peer->dynamic) { + if (!ast_test_flag(peer, SIP_DYNAMIC)) { ast_log(LOG_NOTICE, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name); } else { p->nat = peer->nat; @@ -4954,7 +4950,7 @@ } if (res < 0) transmit_response(p, "403 Forbidden", &p->initreq); - if (peer && peer->temponly) { + if (peer && ast_test_flag(peer, SIP_TEMPONLY)) { destroy_peer(peer); } return res; @@ -5434,11 +5430,11 @@ #ifdef OSP_SUPPORT p->ospauth = user->ospauth; #endif - p->trustrpid = user->trustrpid; - p->useclientcode = user->useclientcode; + ast_set2_flag(p, ast_test_flag(user, SIP_TRUSTRPID), SIP_TRUSTRPID); + ast_set2_flag(p, ast_test_flag(user, SIP_USECLIENTCODE), SIP_USECLIENTCODE); p->progressinband = user->progressinband; /* replace callerid if rpid found, and not restricted */ - if(!ast_strlen_zero(rpid_num) && p->trustrpid) { + if(!ast_strlen_zero(rpid_num) && ast_test_flag(p, SIP_TRUSTRPID)) { if (*calleridname) strncpy(p->cid_name, calleridname, sizeof(p->cid_name) - 1); strncpy(p->cid_num, rpid_num, sizeof(p->cid_num) - 1); @@ -5478,7 +5474,7 @@ p->jointcapability = user->capability; if (p->peercapability) p->jointcapability &= p->peercapability; - p->promiscredir = user->promiscredir; + ast_set2_flag(p, ast_test_flag(user, SIP_PROMISCREDIR), SIP_PROMISCREDIR); if (user->dtmfmode) { p->dtmfmode = user->dtmfmode; if (p->dtmfmode & SIP_DTMF_RFC2833) @@ -5493,7 +5489,7 @@ if (user) { if (debug) ast_verbose("Found user '%s', but fails host access\n", user->name); - if (user->temponly) + if (ast_test_flag(user, SIP_TEMPONLY)) destroy_user(user); } user = NULL; @@ -5513,11 +5509,11 @@ ast_verbose("Found peer '%s'\n", peer->name); /* Take the peer */ p->nat = peer->nat; - p->trustrpid = peer->trustrpid; - p->useclientcode = peer->useclientcode; + ast_set2_flag(p, ast_test_flag(peer, SIP_TRUSTRPID), SIP_TRUSTRPID); + ast_set2_flag(p, ast_test_flag(peer, SIP_USECLIENTCODE), SIP_USECLIENTCODE); p->progressinband = peer->progressinband; /* replace callerid if rpid found, and not restricted */ - if(!ast_strlen_zero(rpid_num) && p->trustrpid) { + if(!ast_strlen_zero(rpid_num) && ast_test_flag(p, SIP_TRUSTRPID)) { if (*calleridname) strncpy(p->cid_name, calleridname, sizeof(p->cid_name) - 1); strncpy(p->cid_num, rpid_num, sizeof(p->cid_num) - 1); @@ -5571,7 +5567,7 @@ p->jointcapability = peer->capability; if (p->peercapability) p->jointcapability &= p->peercapability; - p->promiscredir = peer->promiscredir; + ast_set2_flag(p, ast_test_flag(peer, SIP_PROMISCREDIR), SIP_PROMISCREDIR); if (peer->dtmfmode) { p->dtmfmode = peer->dtmfmode; if (p->dtmfmode & SIP_DTMF_RFC2833) @@ -5580,7 +5576,7 @@ p->noncodeccapability &= ~AST_RTP_DTMF; } } - if (peer->temponly) + if (ast_test_flag(peer, SIP_TEMPONLY)) destroy_peer(peer); } else if (debug) @@ -5589,7 +5585,7 @@ } - if (user && user->temponly) + if (user && ast_test_flag(user, SIP_TEMPONLY)) destroy_user(user); return res; @@ -5780,7 +5776,7 @@ snprintf(srch, sizeof(srch), FORMAT, name, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)", - peer->dynamic ? " D " : " ", /* Dynamic or not? */ + ast_test_flag(peer, SIP_DYNAMIC) ? " D " : " ", /* Dynamic or not? */ (peer->nat & SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */ peer->ha ? " A " : " ", /* permit/deny */ nm, ntohs(peer->addr.sin_port), status); @@ -5800,7 +5796,7 @@ if (print_line) { ast_cli(fd, FORMAT, name, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)", - peer->dynamic ? " D " : " ", /* Dynamic or not? */ + ast_test_flag(peer, SIP_DYNAMIC) ? " D " : " ", /* Dynamic or not? */ (peer->nat & SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */ peer->ha ? " A " : " ", /* permit/deny */ nm, @@ -5864,7 +5860,7 @@ print_group(fd, peer->pickupgroup); ast_cli(fd, " Mailbox : %s\n", peer->mailbox); ast_cli(fd, " LastMsgsSent : %d\n", peer->lastmsgssent); - ast_cli(fd, " Dynamic : %s\n", (peer->dynamic?"Yes":"No")); + ast_cli(fd, " Dynamic : %s\n", (ast_test_flag(peer, SIP_DYNAMIC)?"Yes":"No")); ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "")); ast_cli(fd, " Expire : %d\n", peer->expire); ast_cli(fd, " Expiry : %d\n", peer->expiry); @@ -5872,8 +5868,8 @@ ast_cli(fd, " Nat : %s\n", nat2str(peer->nat)); ast_cli(fd, " ACL : %s\n", (peer->ha?"Yes":"No")); ast_cli(fd, " CanReinvite : %s\n", (peer->canreinvite?"Yes":"No")); - ast_cli(fd, " PromiscRedir : %s\n", (peer->promiscredir?"Yes":"No")); - ast_cli(fd, " User=Phone : %s\n", (peer->usereqphone?"Yes":"No")); + ast_cli(fd, " PromiscRedir : %s\n", (ast_test_flag(peer, SIP_PROMISCREDIR)?"Yes":"No")); + ast_cli(fd, " User=Phone : %s\n", (ast_test_flag(peer, SIP_USEREQPHONE)?"Yes":"No")); /* - is enumerated */ ast_cli(fd, " DTMFmode : "); @@ -5927,7 +5923,7 @@ ast_mutex_unlock(&peerl.lock); - if (peer && peer->temponly) { + if (peer && ast_test_flag(peer, SIP_TEMPONLY)) { destroy_peer(peer); } return RESULT_SUCCESS; @@ -5993,7 +5989,7 @@ ast_strlen_zero(cur->username) ? ( ast_strlen_zero(cur->cid_num) ? "(None)" : cur->cid_num ) : cur->username, cur->callid, cur->ocseq, cur->icseq, - ast_getformatname(cur->owner ? cur->owner->nativeformats : 0), cur->needdestroy ? "(d)" : "" ); + ast_getformatname(cur->owner ? cur->owner->nativeformats : 0), ast_test_flag(cur, SIP_NEEDDESTROY) ? "(d)" : "" ); numchans++; } if (cur->subscribed && subscriptions) { @@ -6058,7 +6054,7 @@ ast_cli(fd, " * Subscription\n"); else ast_cli(fd, " * SIP Call\n"); - ast_cli(fd, " Direction: %s\n", cur->outgoing?"Outgoing":"Incoming"); + ast_cli(fd, " Direction: %s\n", ast_test_flag(cur, SIP_OUTGOING)?"Outgoing":"Incoming"); ast_cli(fd, " Call-ID: %s\n", cur->callid); ast_cli(fd, " Our Codec Capability: %d\n", cur->capability); ast_cli(fd, " Non-Codec Capability: %d\n", cur->noncodeccapability); @@ -6079,9 +6075,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: %d\n", cur->needdestroy); + ast_cli(fd, " Need Destroy: %d\n", ast_test_flag(cur, SIP_NEEDDESTROY)); ast_cli(fd, " Last Message: %s\n", cur->lastmsg); - ast_cli(fd, " Promiscuous Redir: %s\n", cur->promiscredir ? "Yes" : "No"); + ast_cli(fd, " Promiscuous Redir: %s\n", ast_test_flag(cur, SIP_PROMISCREDIR) ? "Yes" : "No"); ast_cli(fd, " Route: %s\n", cur->route ? cur->route->hop : "N/A"); tmp[0] = '\0'; if (cur->dtmfmode & SIP_DTMF_RFC2833) @@ -6199,12 +6195,12 @@ return; } else { transmit_response(p, "481 Call leg/transaction does not exist", req); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } return; } else if ((c = get_header(req, "X-ClientCode"))) { /* Client code (from SNOM phone) */ - if (p->useclientcode) { + if (ast_test_flag(p, SIP_USECLIENTCODE)) { if (p->owner && p->owner->cdr) ast_cdr_setuserfield(p->owner, c); if (p->owner && ast_bridged_channel(p->owner) && ast_bridged_channel(p->owner)->cdr) @@ -6278,7 +6274,7 @@ sipdebug = 1; } else ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[3]); - if (peer->temponly) + if (ast_test_flag(peer, SIP_TEMPONLY)) destroy_peer(peer); peer = NULL; } else @@ -6633,7 +6629,7 @@ e = strchr(s, ';'); if (e) *e = '\0'; - if (p->promiscredir) { + if (ast_test_flag(p, SIP_PROMISCREDIR)) { if (!strncasecmp(s, "sip:", 4)) s += 4; e = strchr(s, '/'); @@ -6660,15 +6656,15 @@ static void check_pendings(struct sip_pvt *p) { /* Go ahead and send bye at this point */ - if (p->pendingbye) { + if (ast_test_flag(p, SIP_PENDINGBYE)) { transmit_request_with_auth(p, "BYE", 0, 1, 1); - p->needdestroy = 1; - p->needreinvite = 0; - } else if (p->needreinvite) { + ast_set_flag(p, SIP_NEEDDESTROY); + ast_clear_flag(p, SIP_NEEDREINVITE); + } else if (ast_test_flag(p, SIP_NEEDREINVITE)) { ast_log(LOG_DEBUG, "Sending pending reinvite on '%s'\n", p->callid); /* Didn't get to reinvite yet, so do it now */ transmit_reinvite_with_sdp(p); - p->needreinvite = 0; + ast_clear_flag(p, SIP_NEEDREINVITE); } } @@ -6751,14 +6747,14 @@ ast_sched_del(sched, peer->pokeexpire); if (!strcasecmp(msg, "INVITE")) transmit_request(p, "ACK", seqno, 0, 0); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); /* Try again eventually */ if ((peer->lastms < 0) || (peer->lastms > peer->maxms)) peer->pokeexpire = ast_sched_add(sched, DEFAULT_FREQ_NOTOK, sip_poke_peer_s, peer); else peer->pokeexpire = ast_sched_add(sched, DEFAULT_FREQ_OK, sip_poke_peer_s, peer); } - } else if (p->outgoing) { + } else if (ast_test_flag(p, SIP_OUTGOING)) { /* Acknowledge sequence number */ if (p->initid > -1) { /* Don't auto congest anymore since we've gotten something useful back */ @@ -6800,7 +6796,7 @@ ast_queue_hangup(p->owner); } else { if (!p->subscribed) { - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } } else if (!strcasecmp(msg, "INVITE")) { @@ -6822,7 +6818,7 @@ } } else /* It's possible we're getting an ACK after we've tried to disconnect by sending CANCEL */ - p->pendingbye = 1; + ast_set_flag(p, SIP_PENDINGBYE); p->authtries = 0; /* If I understand this right, the branch is different for a non-200 ACK only */ transmit_request(p, "ACK", seqno, 0, 1); @@ -6843,7 +6839,7 @@ r->timeout=-1; r->call = NULL; p->registry = NULL; - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); /* set us up for re-registering */ /* figure out how long we got registered for */ if (r->expire > -1) @@ -6900,15 +6896,15 @@ /* Then we AUTH */ if ((p->authtries > 1) || do_proxy_auth(p, req, "WWW-Authenticate", "Authorization", "INVITE", 1)) { ast_log(LOG_NOTICE, "Failed to authenticate on INVITE to '%s'\n", get_header(&p->initreq, "From")); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } else if (p->registry && !strcasecmp(msg, "REGISTER")) { if ((p->authtries > 1) || do_register_auth(p, req, "WWW-Authenticate", "Authorization")) { ast_log(LOG_NOTICE, "Failed to authenticate on REGISTER to '%s'\n", get_header(&p->initreq, "From")); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } else - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); break; case 403: /* Forbidden - we failed authentication */ if (!strcasecmp(msg, "INVITE")) { @@ -6917,10 +6913,10 @@ ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for INVITE to '%s'\n", get_header(&p->initreq, "From")); if (owner) ast_queue_control(p->owner, AST_CONTROL_CONGESTION); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } else if (p->registry && !strcasecmp(msg, "REGISTER")) { ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", p->registry->username, p->registry->hostname); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } else { ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for %s\n", msg); } @@ -6934,7 +6930,7 @@ if(!ignore){ if ((p->authtries > 1) || do_proxy_auth(p, req, "Proxy-Authenticate", "Proxy-Authorization", "INVITE", 1)) { ast_log(LOG_NOTICE, "Failed to authenticate on INVITE to '%s'\n", get_header(&p->initreq, "From")); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } } else if (!strcasecmp(msg, "BYE") || !strcasecmp(msg, "REFER")) { @@ -6943,15 +6939,15 @@ msg, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port)); if ((p->authtries > 1) || do_proxy_auth(p, req, "Proxy-Authenticate", "Proxy-Authorization", msg, 0)) { ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From")); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } else if (p->registry && !strcasecmp(msg, "REGISTER")) { if ((p->authtries > 1) || do_register_auth(p, req, "Proxy-Authenticate", "Proxy-Authorization")) { ast_log(LOG_NOTICE, "Failed to authenticate on REGISTER to '%s' (tries '%d')\n", get_header(&p->initreq, "From"), p->authtries); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } else - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); break; case 501: /* Not Implemented */ @@ -6965,7 +6961,7 @@ if ((resp >= 300) && (resp < 700)) { if ((option_verbose > 2) && (resp != 487)) ast_verbose(VERBOSE_PREFIX_3 "Got SIP response %d \"%s\" back from %s\n", resp, rest, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr)); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); if (p->rtp) { /* Immediately stop RTP */ ast_rtp_stop(p->rtp); @@ -6986,7 +6982,7 @@ break; case 487: /* channel now destroyed - dec the inUse counter */ - if ( p->outgoing ) { + if (ast_test_flag(p, SIP_OUTGOING)) { update_user_counter(p, DEC_OUT_USE); } else { @@ -7025,9 +7021,9 @@ /* ACK on invite */ if (!strcasecmp(msg, "INVITE")) transmit_request(p, "ACK", seqno, 0, 0); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); if (!p->owner) - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } else if ((resp >= 100) && (resp < 200)) { if (!strcasecmp(msg, "INVITE")) { sip_cancel_destroy(p); @@ -7057,7 +7053,7 @@ msg, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port)); if ((p->authtries > 1) || do_proxy_auth(p, req, "Proxy-Authenticate", "Proxy-Authorization", msg, 0)) { ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From")); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } break; @@ -7287,7 +7283,7 @@ if (p->icseq && (p->icseq > seqno)) { ast_log(LOG_DEBUG, "Ignoring too old packet packet %d (expecting >= %d)\n", seqno, p->icseq); return -1; - } else if (p->icseq && (p->icseq == seqno) && (strcasecmp(cmd, "CANCEL") || p->alreadygone)) { + } else if (p->icseq && (p->icseq == seqno) && (strcasecmp(cmd, "CANCEL") || ast_test_flag(p, SIP_ALREADYGONE))) { /* ignore means "don't do anything with it" but still have to respond appropriately. We do this if we receive a repeat of the last sequence number */ @@ -7309,7 +7305,7 @@ /* Response to our request -- Do some sanity checks */ if (!p->initreq.headers) { ast_log(LOG_DEBUG, "That's odd... Got a response on a call we dont know about.\n"); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); return 0; } else if (p->ocseq && (p->ocseq < seqno)) { ast_log(LOG_DEBUG, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq); @@ -7343,9 +7339,9 @@ /* Destroy if this OPTIONS was the opening request, but not if it's in the middle of a normal call flow. */ if (!p->lastinvite) - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } else if (!strcasecmp(cmd, "INVITE")) { - if (p->outgoing && p->owner && (p->owner->_state != AST_STATE_UP)) { + if (ast_test_flag(p, SIP_OUTGOING) && p->owner && (p->owner->_state != AST_STATE_UP)) { /* This is a call to ourself. Send ourselves an error code and stop processing immediately, as SIP really has no good mechanism for being able to call yourself */ @@ -7360,7 +7356,7 @@ ast_verbose("Using latest request as basis request\n"); sip_cancel_destroy(p); /* This call is no longer outgoing if it ever was */ - p->outgoing = 0; + ast_clear_flag(p, SIP_OUTGOING); /* This also counts as a pending invite */ p->pendinginvite = seqno; copy_request(&p->initreq, req); @@ -7387,7 +7383,7 @@ transmit_response(p, "403 Forbidden", req); else transmit_response_reliable(p, "403 Forbidden", req, 1); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } return 0; } @@ -7400,7 +7396,7 @@ if (res) { if (res < 0) { ast_log(LOG_DEBUG, "Failed to place call for user %s, too many calls\n", p->username); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } return 0; } @@ -7424,7 +7420,7 @@ transmit_response_reliable(p, "484 Address Incomplete", req, 1); update_user_counter(p,DEC_IN_USE); } - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } else { /* If no extension was specified, use the s one */ if (ast_strlen_zero(p->exten)) @@ -7473,7 +7469,7 @@ transmit_response(p, "503 Unavailable", req); else transmit_response_reliable(p, "503 Unavailable", req, 1); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); /* Unlock locks so ast_hangup can do its magic */ ast_mutex_unlock(&p->lock); ast_hangup(c); @@ -7502,13 +7498,13 @@ transmit_response(p, "100 Trying", req); } } else { - if (p && !p->needdestroy) { + if (p && !ast_test_flag(p, SIP_NEEDDESTROY)) { ast_log(LOG_NOTICE, "Unable to create/find channel\n"); if (ignore) transmit_response(p, "503 Unavailable", req); else transmit_response_reliable(p, "503 Unavailable", req, 1); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } } else if (!strcasecmp(cmd, "REFER")) { @@ -7530,7 +7526,7 @@ ast_mutex_unlock(&p->refer_call->owner->lock); ast_mutex_unlock(&p->refer_call->lock); p->refer_call = NULL; - p->gotrefer = 1; + ast_set_flag(p, SIP_GOTREFER); } else { ast_log(LOG_DEBUG,"202 Accepted (blind)\n"); c = p->owner; @@ -7556,20 +7552,20 @@ ast_queue_hangup(p->owner); } } - p->gotrefer = 1; + ast_set_flag(p, SIP_GOTREFER); } transmit_response(p, "202 Accepted", req); transmit_notify_with_sipfrag(p, seqno); /* Always increment on a BYE */ if (!nobye) { transmit_request_with_auth(p, "BYE", 0, 1, 1); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); } } } } else if (!strcasecmp(cmd, "CANCEL")) { check_via(p, req); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); if (p->rtp) { /* Immediately stop RTP */ ast_rtp_stop(p->rtp); @@ -7581,7 +7577,7 @@ if (p->owner) ast_queue_hangup(p->owner); else - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); if (p->initreq.len > 0) { if (!ignore) transmit_response_reliable(p, "487 Request Terminated", &p->initreq, 1); @@ -7592,7 +7588,7 @@ } else if (!strcasecmp(cmd, "BYE")) { copy_request(&p->initreq, req); check_via(p, req); - p->alreadygone = 1; + ast_set_flag(p, SIP_ALREADYGONE); if (p->rtp) { /* Immediately stop RTP */ ast_rtp_stop(p->rtp); @@ -7625,7 +7621,7 @@ } else if (p->owner) ast_queue_hangup(p->owner); else - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); transmit_response(p, "200 OK", req); } else if (!strcasecmp(cmd, "MESSAGE")) { if (!ignore) { @@ -7640,7 +7636,7 @@ if (debug) ast_verbose("Using latest SUBSCRIBE request as basis request\n"); /* This call is no longer outgoing if it ever was */ - p->outgoing = 0; + ast_clear_flag(p, SIP_OUTGOING); copy_request(&p->initreq, req); check_via(p, req); } else if (debug) @@ -7655,7 +7651,7 @@ if (res) { if (res < 0) { ast_log(LOG_NOTICE, "Failed to authenticate user %s for SUBSCRIBE\n", get_header(req, "From")); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } return 0; } @@ -7670,7 +7666,7 @@ transmit_response(p, "404 Not Found", req); else transmit_response(p, "484 Address Incomplete", req); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } else { /* Initialize tag */ p->tag = rand(); @@ -7690,7 +7686,7 @@ transmit_response(p, "200 OK", req); else { transmit_response(p, "403 Forbidden", req); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } } else @@ -7704,10 +7700,10 @@ if (!ignore && p) p->lastinvite = seqno; - if (p && !p->needdestroy) { + if (p && !ast_test_flag(p, SIP_NEEDDESTROY)) { if (!(p->expiry = atoi(get_header(req, "Expires")))) { transmit_response(p, "200 OK", req); - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); return 0; } /* The next line can be removed if the SNOM200 Expires bug is fixed */ @@ -7731,7 +7727,8 @@ /* XXX we get NOTIFY's from some servers. WHY?? Maybe we should look into this someday XXX */ transmit_response(p, "200 OK", req); - if (!p->lastinvite) p->needdestroy = 1; + if (!p->lastinvite) + ast_set_flag(p, SIP_NEEDDESTROY); } else if (!strcasecmp(cmd, "REGISTER")) { /* Use this as the basis */ if (debug) @@ -7757,7 +7754,7 @@ check_pendings(p); } if (!p->lastinvite && ast_strlen_zero(p->randdata)) - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } else if (!strcasecmp(cmd, "SIP/2.0")) { extract_uri(p, req); while(*e && (*e < 33)) e++; @@ -7772,7 +7769,7 @@ cmd, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr)); /* If this is some new method, and we don't have a call, destroy it now */ if (!p->initreq.headers) - p->needdestroy = 1; + ast_set_flag(p, SIP_NEEDDESTROY); } return 0; } @@ -7892,7 +7889,7 @@ snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch); build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain); /* Send MWI */ - p->outgoing = 1; + ast_set_flag(p, SIP_OUTGOING); transmit_notify_with_mwi(p, newmsgs, oldmsgs); sip_scheddestroy(p, 15000); return 0; @@ -7960,7 +7957,7 @@ } } } - if (sip->needdestroy && !sip->packets && !sip->owner) { + if (ast_test_flag(sip, SIP_NEEDDESTROY) && !sip->packets && !sip->owner) { ast_mutex_unlock(&sip->lock); __sip_destroy(sip, 1); goto restartsearch; @@ -8125,7 +8122,7 @@ if (peer->pokeexpire > -1) ast_sched_del(sched, peer->pokeexpire); p->peerpoke = peer; - p->outgoing = 1; + ast_set_flag(p, SIP_OUTGOING); #ifdef VOCAL_DATA_HACK strncpy(p->username, "__VOCAL_DATA_SHOULD_READ_THE_SIP_SPEC__", sizeof(p->username) - 1); transmit_invite(p, "INVITE", 0, NULL, NULL, NULL,NULL,NULL, 0, 1); @@ -8181,7 +8178,7 @@ res = AST_DEVICE_UNKNOWN; } - if (p && p->temponly) { + if (p && ast_test_flag(p, SIP_TEMPONLY)) { destroy_peer(p); } return res; @@ -8291,7 +8288,7 @@ user->outUse = 0; user->capability = global_capability; user->canreinvite = global_canreinvite; - user->trustrpid = global_trustrpid; + ast_set2_flag(user, global_trustrpid, SIP_TRUSTRPID); user->dtmfmode = global_dtmfmode; user->progressinband = global_progressinband; user->prefs = prefs; @@ -8324,7 +8321,7 @@ } else if (!strcasecmp(v->name, "md5secret")) { strncpy(user->md5secret, v->value, sizeof(user->md5secret)-1); } else if (!strcasecmp(v->name, "promiscredir")) { - user->promiscredir = ast_true(v->value); + ast_set2_flag(user, ast_true(v->value), SIP_PROMISCREDIR); } else if (!strcasecmp(v->name, "dtmfmode")) { if (!strcasecmp(v->value, "inband")) user->dtmfmode=SIP_DTMF_INBAND; @@ -8386,9 +8383,9 @@ } else if (!strcasecmp(v->name, "callingpres")) { user->callingpres = atoi(v->value); } else if (!strcasecmp(v->name, "trustrpid")) { - user->trustrpid = ast_true(v->value); + ast_set2_flag(user, ast_true(v->value), SIP_TRUSTRPID); } else if (!strcasecmp(v->name, "useclientcode")) { - user->useclientcode = ast_true(v->value); + ast_set2_flag(user, ast_true(v->value), SIP_USECLIENTCODE); } else if (!strcasecmp(v->name, "progressinband")) { if (!strcasecmp(v->value, "never")) user->progressinband = 0; @@ -8438,14 +8435,14 @@ /* Assume can reinvite */ peer->canreinvite = global_canreinvite; peer->dtmfmode = global_dtmfmode; - peer->promiscredir = global_promiscredir; - peer->usereqphone = global_usereqphone; + ast_set2_flag(peer, global_promiscredir, SIP_PROMISCREDIR); + ast_set2_flag(peer, global_usereqphone, SIP_USEREQPHONE); peer->nat = global_nat; peer->rtptimeout = global_rtptimeout; peer->rtpholdtimeout = global_rtpholdtimeout; - peer->selfdestruct = 1; - peer->dynamic = 1; - peer->trustrpid = global_trustrpid; + ast_set_flag(peer, SIP_SELFDESTRUCT); + ast_set_flag(peer, SIP_DYNAMIC); + ast_set2_flag(peer, global_trustrpid, SIP_TRUSTRPID); peer->progressinband = global_progressinband; peer->prefs = prefs; #ifdef OSP_SUPPORT @@ -8509,7 +8506,7 @@ peer->addr.sin_family = AF_INET; peer->defaddr.sin_family = AF_INET; peer->expiry = expiry; - peer->usereqphone = global_usereqphone; + ast_set2_flag(peer, global_usereqphone, SIP_USEREQPHONE); } peer->prefs = prefs; oldha = peer->ha; @@ -8521,8 +8518,8 @@ peer->rtptimeout = global_rtptimeout; peer->rtpholdtimeout = global_rtpholdtimeout; peer->dtmfmode = global_dtmfmode; - peer->promiscredir = global_promiscredir; - peer->trustrpid = global_trustrpid; + ast_set2_flag(peer, global_promiscredir, SIP_PROMISCREDIR); + ast_set2_flag(peer, global_trustrpid, SIP_TRUSTRPID); peer->progressinband = global_progressinband; #ifdef OSP_SUPPORT peer->ospauth = global_ospauth; @@ -8555,9 +8552,9 @@ else if (!strcasecmp(v->name, "fromdomain")) strncpy(peer->fromdomain, v->value, sizeof(peer->fromdomain)-1); else if (!strcasecmp(v->name, "usereqphone")) - peer->usereqphone = ast_true(v->value); + ast_set2_flag(peer, ast_true(v->value), SIP_USEREQPHONE); else if (!strcasecmp(v->name, "promiscredir")) - peer->promiscredir = ast_true(v->value); + ast_set2_flag(peer, ast_true(v->value), SIP_PROMISCREDIR); else if (!strcasecmp(v->name, "fromuser")) strncpy(peer->fromuser, v->value, sizeof(peer->fromuser)-1); else if (!strcasecmp(v->name, "dtmfmode")) { @@ -8577,7 +8574,7 @@ ast_log(LOG_WARNING, "You can't have a dynamic outbound proxy, you big silly head at line %d.\n", v->lineno); } else { /* They'll register with us */ - peer->dynamic = 1; + ast_set_flag(peer, SIP_DYNAMIC); if (!found) { /* Initialize stuff iff we're not found, otherwise we keep going with what we had */ @@ -8594,7 +8591,7 @@ if (peer->expire > -1) ast_sched_del(sched, peer->expire); peer->expire = -1; - peer->dynamic = 0; + ast_clear_flag(peer, SIP_DYNAMIC); if (!obproxyfound || !strcasecmp(v->name, "outboundproxy")) { if (ast_get_ip_or_srv(&peer->addr, v->value, "_sip._udp")) { destroy_peer(peer); @@ -8620,7 +8617,7 @@ maskfound++; inet_aton(v->value, &peer->mask); } else if (!strcasecmp(v->name, "port")) { - if (peer->dynamic) + if (ast_test_flag(peer, SIP_DYNAMIC)) peer->defaddr.sin_port = htons(atoi(v->value)); else peer->addr.sin_port = htons(atoi(v->value)); @@ -8669,9 +8666,9 @@ peer->maxms = 0; } } else if (!strcasecmp(v->name, "useclientcode")) { - peer->useclientcode = ast_true(v->value); + ast_set2_flag(peer, ast_true(v->value), SIP_USECLIENTCODE); } else if (!strcasecmp(v->name, "trustrpid")) { - peer->trustrpid = ast_true(v->value); + ast_set2_flag(peer, ast_true(v->value), SIP_TRUSTRPID); } else if (!strcasecmp(v->name, "progressinband")) { if (!strcasecmp(v->value, "never")) peer->progressinband = 0; @@ -8694,9 +8691,9 @@ */ v=v->next; } - if (!found && peer->dynamic) + if (!found && ast_test_flag(peer, SIP_DYNAMIC)) reg_source_db(peer); - peer->delme = 0; + ast_clear_flag(peer, SIP_DELME); } ast_free_ha(oldha); return peer; @@ -9086,12 +9083,12 @@ else memset(&p->vredirip, 0, sizeof(p->vredirip)); p->redircodecs = codecs; - if (!p->gotrefer) { + if (!ast_test_flag(p, SIP_GOTREFER)) { if (!p->pendinginvite) transmit_reinvite_with_sdp(p); - else if (!p->pendingbye) { + else if (!ast_test_flag(p, SIP_PENDINGBYE)) { ast_log(LOG_DEBUG, "Deferring reinvite on '%s'\n", p->callid); - p->needreinvite = 1; + ast_set_flag(p, SIP_NEEDREINVITE); } } /* Reset lastrtprx timer */ @@ -9312,7 +9309,7 @@ ast_mutex_lock(&peerl.lock); for (peer=peerl.peers;peer;) { /* Assume all will be deleted, and we'll find out for sure later */ - peer->delme = 1; + ast_set_flag(peer, SIP_DELME); peer = peer->next; } ast_mutex_unlock(&peerl.lock); @@ -9327,7 +9324,7 @@ peerlast = NULL; for (peer=peerl.peers;peer;) { peernext = peer->next; - if (peer->delme) { + if (ast_test_flag(peer, SIP_DELME)) { destroy_peer(peer); if (peerlast) peerlast->next = peernext;