aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-31 16:02:35 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-31 16:02:35 +0000
commitd00a87e2dcf7407f81d62d682474784cedb5a141 (patch)
treea68849754dc76ec2867e6eebb33224400bf76e38 /channels
parenta7ee1fb601453b0ce8cd7f78f4e903a7627a69fa (diff)
- Moving two session (PVT) flags to peer PAGE2 (DYNAMIC and SELFDESTRUCT) to make room for more session-related flags
This is needed for integrating patches in the bug tracker - Adding doxygen comments git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8991 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 132b551d8..d0a8ed24b 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -34,6 +34,7 @@
* \todo Better support of forking
*
* \ingroup channel_drivers
+ *
*/
@@ -487,11 +488,13 @@ struct sip_invite_param {
enum sip_auth_type auth_type; /*!< Authentication type */
};
+/*! \brief Structure to save routing information for a SIP session */
struct sip_route {
struct sip_route *next;
char hop[0];
};
+/*! \brief Modes for SIP domain handling in the PBX */
enum domain_mode {
SIP_DOMAIN_AUTO, /*!< This domain is auto-configured */
SIP_DOMAIN_CONFIG, /*!< This domain is from configuration */
@@ -524,7 +527,9 @@ struct sip_auth {
struct sip_auth *next; /*!< Next auth structure in list */
};
-/*--- Various flags for the flags field in the pvt structure */
+/*--- Various flags for the flags field in the pvt structure
+ Peer only flags should be set in PAGE2 below
+*/
#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 */
@@ -539,14 +544,13 @@ struct sip_auth {
#define SIP_REALTIME (1 << 11) /*!< Flag for realtime users */
#define SIP_USECLIENTCODE (1 << 12) /*!< Trust X-ClientCode info message */
#define SIP_OUTGOING (1 << 13) /*!< Is this an outgoing call? */
-#define SIP_SELFDESTRUCT (1 << 14)
-#define SIP_DYNAMIC (1 << 15) /*!< Is this a dynamic peer? */
-/* --- Choices for DTMF support in SIP channel */
-#define SIP_DTMF (3 << 16) /*!< three settings, uses two bits */
-#define SIP_DTMF_RFC2833 (0 << 16) /*!< RTP DTMF */
-#define SIP_DTMF_INBAND (1 << 16) /*!< Inband audio, only for ULAW/ALAW */
-#define SIP_DTMF_INFO (2 << 16) /*!< SIP Info messages */
-#define SIP_DTMF_AUTO (3 << 16) /*!< AUTO switch between rfc2833 and in-band DTMF */
+#define SIP_FREEBIT (1 << 14) /*!< Free for session-related use */
+#define SIP_FREEBIT3 (1 << 15) /*!< Free for session-related use */
+#define SIP_DTMF (3 << 16) /*!< DTMF Support: four settings, uses two bits */
+#define SIP_DTMF_RFC2833 (0 << 16) /*!< DTMF Support: RTP DTMF - "rfc2833" */
+#define SIP_DTMF_INBAND (1 << 16) /*!< DTMF Support: Inband audio, only for ULAW/ALAW - "inband" */
+#define SIP_DTMF_INFO (2 << 16) /*!< DTMF Support: SIP Info messages - "info" */
+#define SIP_DTMF_AUTO (3 << 16) /*!< DTMF Support: AUTO switch between rfc2833 and in-band DTMF */
/* NAT settings */
#define SIP_NAT (3 << 18) /*!< four settings, uses two bits */
#define SIP_NAT_NEVER (0 << 18) /*!< No nat support */
@@ -584,7 +588,7 @@ struct sip_auth {
SIP_PROG_INBAND | SIP_OSPAUTH | SIP_USECLIENTCODE | SIP_NAT | \
SIP_INSECURE_PORT | SIP_INSECURE_INVITE)
-/* a new page of flags for peer */
+/* a new page of flags for peers */
#define SIP_PAGE2_RTCACHEFRIENDS (1 << 0)
#define SIP_PAGE2_RTUPDATE (1 << 1)
#define SIP_PAGE2_RTAUTOCLEAR (1 << 2)
@@ -593,6 +597,8 @@ struct sip_auth {
#define SIP_PAGE2_DEBUG (3 << 5)
#define SIP_PAGE2_DEBUG_CONFIG (1 << 5)
#define SIP_PAGE2_DEBUG_CONSOLE (1 << 6)
+#define SIP_PAGE2_DYNAMIC (1 << 7) /*!< Dynamic Peers register with Asterisk */
+#define SIP_PAGE2_SELFDESTRUCT (1 << 8) /*!< Automatic peers need to destruct themselves */
/* SIP packet flags */
#define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */
@@ -1313,7 +1319,9 @@ static int retrans_pkt(void *data)
return 0;
}
-/*! \brief Transmit packet with retransmits */
+/*! \brief Transmit packet with retransmits
+ \return 0 on success, -1 on failure to allocate packet
+*/
static int __sip_reliable_xmit(struct sip_pvt *p, int seqno, int resp, char *data, int len, int fatal, int sipmethod)
{
struct sip_pkt *pkt;
@@ -1680,7 +1688,7 @@ static void sip_destroy_peer(struct sip_peer *peer)
ast_sched_del(sched, peer->pokeexpire);
register_peer_exten(peer, 0);
ast_free_ha(peer->ha);
- if (ast_test_flag(peer, SIP_SELFDESTRUCT))
+ if (ast_test_flag((&peer->flags_page2), SIP_PAGE2_SELFDESTRUCT))
apeerobjs--;
else if (ast_test_flag(peer, SIP_REALTIME))
rpeerobjs--;
@@ -5758,7 +5766,7 @@ static int expire_register(void *data)
register_peer_exten(peer, 0);
peer->expire = -1;
ast_device_state_changed("SIP/%s", peer->name);
- if (ast_test_flag(peer, SIP_SELFDESTRUCT) || ast_test_flag((&peer->flags_page2), SIP_PAGE2_RTAUTOCLEAR)) {
+ if (ast_test_flag((&peer->flags_page2), SIP_PAGE2_SELFDESTRUCT) || ast_test_flag((&peer->flags_page2), SIP_PAGE2_RTAUTOCLEAR)) {
peer = ASTOBJ_CONTAINER_UNLINK(&peerl, peer);
ASTOBJ_UNREF(peer, sip_destroy_peer);
}
@@ -6490,7 +6498,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
ASTOBJ_UNREF(peer, sip_destroy_peer);
}
if (peer) {
- if (!ast_test_flag(peer, SIP_DYNAMIC)) {
+ if (!ast_test_flag((&peer->flags_page2), SIP_PAGE2_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, peer, SIP_NAT);
@@ -7650,7 +7658,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
snprintf(srch, sizeof(srch), FORMAT, name,
iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "(Unspecified)",
- ast_test_flag(iterator, SIP_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
+ ast_test_flag((&iterator->flags_page2), SIP_PAGE2_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
(ast_test_flag(iterator, SIP_NAT) & SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */
iterator->ha ? " A " : " ", /* permit/deny */
ntohs(iterator->addr.sin_port), status);
@@ -7658,7 +7666,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
if (!s) {/* Normal CLI list */
ast_cli(fd, FORMAT, name,
iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "(Unspecified)",
- ast_test_flag(iterator, SIP_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
+ ast_test_flag((&iterator->flags_page2), SIP_PAGE2_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
(ast_test_flag(iterator, SIP_NAT) & SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */
iterator->ha ? " A " : " ", /* permit/deny */
@@ -7680,7 +7688,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
iterator->name,
iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "-none-",
ntohs(iterator->addr.sin_port),
- ast_test_flag(iterator, SIP_DYNAMIC) ? "yes" : "no", /* Dynamic or not? */
+ ast_test_flag((&iterator->flags_page2), SIP_PAGE2_DYNAMIC) ? "yes" : "no", /* Dynamic or not? */
(ast_test_flag(iterator, SIP_NAT) & SIP_NAT_ROUTE) ? "yes" : "no", /* NAT=yes? */
iterator->ha ? "yes" : "no", /* permit/deny */
status);
@@ -8053,7 +8061,7 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
ast_cli(fd, " VM Extension : %s\n", peer->vmexten);
ast_cli(fd, " LastMsgsSent : %d\n", peer->lastmsgssent);
ast_cli(fd, " Call limit : %d\n", peer->call_limit);
- ast_cli(fd, " Dynamic : %s\n", (ast_test_flag(peer, SIP_DYNAMIC)?"Yes":"No"));
+ ast_cli(fd, " Dynamic : %s\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC)?"Yes":"No"));
ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>"));
ast_cli(fd, " Expire : %d\n", peer->expire);
ast_cli(fd, " Insecure : %s\n", insecure2str(ast_test_flag(peer, SIP_INSECURE_PORT), ast_test_flag(peer, SIP_INSECURE_INVITE)));
@@ -8129,7 +8137,7 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
ast_cli(fd, "VoiceMailbox: %s\r\n", peer->mailbox);
ast_cli(fd, "LastMsgsSent: %d\r\n", peer->lastmsgssent);
ast_cli(fd, "Call limit: %d\r\n", peer->call_limit);
- ast_cli(fd, "Dynamic: %s\r\n", (ast_test_flag(peer, SIP_DYNAMIC)?"Y":"N"));
+ ast_cli(fd, "Dynamic: %s\r\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC)?"Y":"N"));
ast_cli(fd, "Callerid: %s\r\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, ""));
ast_cli(fd, "RegExpire: %ld seconds\r\n", ast_sched_when(sched,peer->expire));
ast_cli(fd, "SIP-AuthInsecure: %s\r\n", insecure2str(ast_test_flag(peer, SIP_INSECURE_PORT), ast_test_flag(peer, SIP_INSECURE_INVITE)));
@@ -9368,7 +9376,7 @@ static char *function_sippeer(struct ast_channel *chan, char *cmd, char *data, c
} else if (!strcasecmp(colname, "expire")) {
snprintf(buf, len, "%d", peer->expire);
} else if (!strcasecmp(colname, "dynamic")) {
- ast_copy_string(buf, (ast_test_flag(peer, SIP_DYNAMIC) ? "yes" : "no"), len);
+ ast_copy_string(buf, (ast_test_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC) ? "yes" : "no"), len);
} else if (!strcasecmp(colname, "callerid_name")) {
ast_copy_string(buf, peer->cid_name, len);
} else if (!strcasecmp(colname, "callerid_num")) {
@@ -12069,8 +12077,8 @@ static struct sip_peer *temp_peer(const char *name)
peer->rtptimeout = global_rtptimeout;
peer->rtpholdtimeout = global_rtpholdtimeout;
peer->rtpkeepalive = global_rtpkeepalive;
- ast_set_flag(peer, SIP_SELFDESTRUCT);
- ast_set_flag(peer, SIP_DYNAMIC);
+ ast_set_flag((&peer->flags_page2), SIP_PAGE2_SELFDESTRUCT);
+ ast_set_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC);
peer->prefs = default_prefs;
reg_source_db(peer);
@@ -12196,7 +12204,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
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 */
- ast_set_flag(peer, SIP_DYNAMIC);
+ ast_set_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC);
if (!found) {
/* Initialize stuff iff we're not found, otherwise
we keep going with what we had */
@@ -12213,7 +12221,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
if (peer->expire > -1)
ast_sched_del(sched, peer->expire);
peer->expire = -1;
- ast_clear_flag(peer, SIP_DYNAMIC);
+ ast_clear_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC);
if (!obproxyfound || !strcasecmp(v->name, "outboundproxy")) {
if (ast_get_ip_or_srv(&peer->addr, v->value, "_sip._udp")) {
ASTOBJ_UNREF(peer, sip_destroy_peer);
@@ -12236,7 +12244,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
} else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
peer->ha = ast_append_ha(v->name, v->value, peer->ha);
} else if (!strcasecmp(v->name, "port")) {
- if (!realtime && ast_test_flag(peer, SIP_DYNAMIC))
+ if (!realtime && ast_test_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC))
peer->defaddr.sin_port = htons(atoi(v->value));
else
peer->addr.sin_port = htons(atoi(v->value));
@@ -12318,7 +12326,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
*/
v=v->next;
}
- if (!ast_test_flag((&global_flags_page2), SIP_PAGE2_IGNOREREGEXPIRE) && ast_test_flag(peer, SIP_DYNAMIC) && realtime) {
+ if (!ast_test_flag((&global_flags_page2), SIP_PAGE2_IGNOREREGEXPIRE) && ast_test_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC) && realtime) {
time_t nowtime;
time(&nowtime);
@@ -12330,7 +12338,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
}
}
ast_copy_flags(peer, &peerflags, mask.flags);
- if (!found && ast_test_flag(peer, SIP_DYNAMIC) && !ast_test_flag(peer, SIP_REALTIME))
+ if (!found && ast_test_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC) && !ast_test_flag(peer, SIP_REALTIME))
reg_source_db(peer);
ASTOBJ_UNMARK(peer);
ast_free_ha(oldha);