[asterisk-commits] rizzo: branch rizzo/astobj2 r77683 - /team/rizzo/astobj2/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jul 29 04:35:33 CDT 2007
Author: rizzo
Date: Sun Jul 29 04:35:32 2007
New Revision: 77683
URL: http://svn.digium.com/view/asterisk?view=rev&rev=77683
Log:
more merge from trunk
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=77683&r1=77682&r2=77683
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Sun Jul 29 04:35:32 2007
@@ -664,26 +664,15 @@
#define DEC_CALL_RINGING 2
#define INC_CALL_RINGING 3
-/*!
- * Incoming packet, or outgoing one (for the time being)
- * For incoming packets, we first store the data from the socket in data[],
+/*! \brief sip_request: The data grabbed from the UDP socket
+ *
+ * Incoming messages: we first store the data from the socket in data[],
* adding a trailing \0 to make string parsing routines happy.
* Then call parse_request() and req.method = find_sip_method();
- * to initialize the other fields. The \r\n at the end of line is
- * replaced by \0, so that data[] is not a conforming one anymore.
- * rlPart1 is set to remember that we can run get_header()
- * on this kind of packet.
- *
- * For outgoing packets, we initialize the fields with init_req() or init_resp()
- * (which fills the first line to "METHOD uri SIP/2.0" or "SIP/2.0 code text"),
- * and then fill the rest with add_header() and add_line().
- * The \r\n at the end of the line are still there, so the get_header()
- * and so on functions don't work on these packets.
- *
- * Note that in all cases, len is the total number of bytes used in data[]
- * excluding the trailing \0. It is rarely used.
- * According to the SIP spec, header and body should be separated by an
- * empty line, which we store as the last of the headers.
+ * to initialize the other fields. The \r\n at the end of each line is
+ * replaced by \0, so that data[] is not a conforming SIP message anymore.
+ * After this processing, rlPart1 is set to non-NULL to remember
+ * that we can run get_header() on this kind of packet.
*
* parse_request() splits the first line as follows:
* Requests have in the first line method uri SIP/2.0
@@ -691,11 +680,10 @@
* Responses have in the first line SIP/2.0 NNN description
* rlPart1 = SIP/2.0; rlPart2 = NNN + description;
*/
-
struct sip_request {
char *rlPart1; /*!< SIP Method Name or "SIP/2.0" protocol version */
char *rlPart2; /*!< The Request URI or Response Status */
- int len; /*!< Length */
+ int len; /*!< bytes used in data[], excluding trailing '\0'. Rarely used. */
int headers; /*!< # of SIP Headers */
int method; /*!< Method of this request */
int lines; /*!< Body Content */
@@ -709,11 +697,20 @@
char data[SIP_MAX_PACKET];
};
-/*!
- * Storage for outgoing packets.
+/*! \brief Storage for outgoing SIP messages.
* It makes sense to use a different data structure than the one for incoming
* packets as the internal format is not the same (e.g. no '\0' between
* the various lines).
+ * Outgoing packets, we initialize the fields with init_req() or init_resp()
+ * (which fills the first line to "METHOD uri SIP/2.0" or "SIP/2.0 code text"),
+ * and then fill the rest with add_header() and add_line().
+ * The \r\n at the end of the line are still there, so the get_header()
+ * and so on functions don't work on these packets.
+ *
+ * Note that in all cases, len is the total number of bytes used in data[]
+ * excluding the trailing \0. It is rarely used.
+ * According to the SIP spec, header and body should be separated by an
+ * empty line, which we store as the last of the headers.
*/
struct sip_msg_out {
int len; /*!< Length (also, offset for writing) */
@@ -796,22 +793,23 @@
When flags are used by multiple structures, it is important that
they have a common layout so it is easy to copy them.
*/
-#define __SIP_ALREADYGONE (1 << 0) /*!< D: Whether or not we've already been destroyed by our peer */
-#define __SIP_NEEDDESTROY (1 << 1) /*!< D: if we need to be destroyed by the monitor thread */
-#define SIP_NOVIDEO (1 << 2) /*!< D: Didn't get video in invite, don't offer */
-#define SIP_RINGING (1 << 3) /*!< D: Have sent 180 ringing */
-#define SIP_PROGRESS_SENT (1 << 4) /*!< D: Have sent 183 message progress */
-#define SIP_NEEDREINVITE (1 << 5) /*!< D: Do we need to send another reinvite? */
-#define SIP_PENDINGBYE (1 << 6) /*!< D: Need to send bye after we ack? */
-#define SIP_GOTREFER (1 << 7) /*!< D: Got a refer? */
-#define SIP_PROMISCREDIR (1 << 8) /*!< DP: Promiscuous redirection */
-#define SIP_TRUSTRPID (1 << 9) /*!< DP: Trust RPID headers? */
-#define SIP_USEREQPHONE (1 << 10) /*!< DP: Add user=phone to numeric URI. Default off */
-#define __SIP_REALTIME (1 << 11) /*!< P: Flag for realtime users */
-#define SIP_USECLIENTCODE (1 << 12) /*!< DP: Trust X-ClientCode info message */
-#define SIP_OUTGOING (1 << 13) /*!< D: Direction of the last transaction in this dialog */
-#define SIP_FREE_BIT (1 << 14) /*!< ---- */
-#define SIP_DEFER_BYE_ON_TRANSFER (1 << 15) /*!< D: Do not hangup at first ast_hangup */
+#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? */
+#define SIP_PENDINGBYE (1 << 5) /*!< D: Need to send bye after we ack? */
+#define SIP_GOTREFER (1 << 6) /*!< D: Got a refer? */
+#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 */
+#define SIP_TRUSTRPID (1 << 13) /*!< DP: Trust RPID headers? */
+#define SIP_USEREQPHONE (1 << 14) /*!< DP: Add user=phone to numeric URI. Default off */
+#define SIP_USECLIENTCODE (1 << 15) /*!< DP: Trust X-ClientCode info message */
/* DTMF flags - see str2dtmfmode() and dtmfmode2str() */
#define SIP_DTMF (3 << 16) /*!< DP: DTMF Support: four settings, uses two bits */
@@ -820,7 +818,7 @@
#define SIP_DTMF_INFO (2 << 16) /*!< DP: DTMF Support: SIP Info messages - "info" */
#define SIP_DTMF_AUTO (3 << 16) /*!< DP: DTMF Support: AUTO switch between rfc2833 and in-band DTMF */
-/* NAT settings */
+/* NAT settings - see nat2str() */
#define SIP_NAT (3 << 18) /*!< DP: four settings, uses two bits */
#define SIP_NAT_NEVER (0 << 18) /*!< DP: No nat support */
#define SIP_NAT_RFC3581 (1 << 18) /*!< DP: NAT RFC3581 */
@@ -833,7 +831,7 @@
#define SIP_CAN_REINVITE_NAT (2 << 20) /*!< DP: allow media reinvite when new peer is behind NAT */
#define SIP_REINVITE_UPDATE (4 << 20) /*!< DP: use UPDATE (RFC3311) when reinviting this peer */
-/* "insecure" settings, see insecure2str() */
+/* "insecure" settings - see insecure2str() */
#define SIP_INSECURE (3 << 23) /*!< DP: two bits used */
#define SIP_INSECURE_PORT (1 << 23) /*!< DP: don't require matching port for incoming requests */
#define SIP_INSECURE_INVITE (1 << 24) /*!< DP: don't require authentication for incoming INVITEs */
@@ -844,12 +842,10 @@
#define SIP_PROG_INBAND_NO (1 << 25)
#define SIP_PROG_INBAND_YES (2 << 25)
-#define __SIP_NO_HISTORY (1 << 27) /*!< Suppress recording request/response history */
-#define SIP_CALL_LIMIT (1 << 28) /*!< Call limit enforced for this call */
-#define SIP_SENDRPID (1 << 29) /*!< Remote Party-ID Support */
-#define SIP_INC_COUNT (1 << 30) /*!< Did this connection increment the counter of in-use calls? */
-#define SIP_G726_NONSTANDARD (1 << 31) /*!< Use non-standard packing for G726-32 data */
-
+#define SIP_SENDRPID (1 << 29) /*!< DP: Remote Party-ID Support */
+#define SIP_G726_NONSTANDARD (1 << 31) /*!< DP: Use non-standard packing for G726-32 data */
+
+/*! \brief Flags to copy from peer/user to dialog */
#define SIP_FLAGS_TO_COPY \
(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
SIP_PROG_INBAND | SIP_USECLIENTCODE | SIP_NAT | SIP_G726_NONSTANDARD | \
@@ -857,37 +853,36 @@
/*--- a new page of flags (for flags[1] */
/* realtime flags */
-#define SIP_PAGE2_RTCACHEFRIENDS (1 << 0)
-#define SIP_PAGE2_RTUPDATE (1 << 1)
-#define SIP_PAGE2_RTAUTOCLEAR (1 << 2)
-#define SIP_PAGE2_RT_FROMCONTACT (1 << 4)
-#define SIP_PAGE2_RTSAVE_SYSNAME (1 << 5)
+#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)
-#define __SIP_PAGE2_DEBUG (3 << 11)
-#define __SIP_PAGE2_DEBUG_CONFIG (1 << 11)
-#define __SIP_PAGE2_DEBUG_CONSOLE (1 << 12)
-#define SIP_PAGE2_DYNAMIC (1 << 13) /*!< Dynamic Peers register with Asterisk */
-#define SIP_PAGE2_SELFDESTRUCT (1 << 14) /*!< Automatic peers need to destruct themselves */
-#define SIP_PAGE2_VIDEOSUPPORT (1 << 15)
-#define SIP_PAGE2_ALLOWSUBSCRIBE (1 << 16) /*!< Allow subscriptions from this peer? */
-#define SIP_PAGE2_ALLOWOVERLAP (1 << 17) /*!< Allow overlap dialing ? */
-#define SIP_PAGE2_SUBSCRIBEMWIONLY (1 << 18) /*!< Only issue MWI notification if subscribed to */
-#define SIP_PAGE2_INC_RINGING (1 << 19) /*!< Did this connection increment the counter of in-use calls? */
-#define SIP_PAGE2_T38SUPPORT (7 << 20) /*!< T38 Fax Passthrough Support */
-#define SIP_PAGE2_T38SUPPORT_UDPTL (1 << 20) /*!< 20: T38 Fax Passthrough Support */
-#define SIP_PAGE2_T38SUPPORT_RTP (2 << 20) /*!< 21: T38 Fax Passthrough Support (not implemented) */
-#define SIP_PAGE2_T38SUPPORT_TCP (4 << 20) /*!< 22: T38 Fax Passthrough Support (not implemented) */
-#define SIP_PAGE2_CALL_ONHOLD (3 << 23) /*!< Call states */
-#define SIP_PAGE2_CALL_ONHOLD_ACTIVE (1 << 23) /*!< 23: Active hold */
-#define SIP_PAGE2_CALL_ONHOLD_ONEDIR (2 << 23) /*!< 23: One directional hold */
-#define SIP_PAGE2_CALL_ONHOLD_INACTIVE (3 << 23) /*!< 23: Inactive hold */
-#define SIP_PAGE2_RFC2833_COMPENSATE (1 << 25) /*!< 25: Compensate for buggy RFC2833 implementations */
-#define SIP_PAGE2_BUGGY_MWI (1 << 26) /*!< 26: Buggy CISCO MWI fix */
-#define SIP_PAGE2_NOTEXT (1 << 27) /*!< 27: Text not supported */
-#define SIP_PAGE2_TEXTSUPPORT (1 << 28) /*!< 28: Global text enable */
-#define __SIP_PAGE2_DEBUG_TEXT (1 << 29) /*!< 29: Global text debug */
-#define SIP_PAGE2_OUTGOING_CALL (1 << 30) /*!< 30: Is this an outgoing call? */
+
+#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 ? */
+#define SIP_PAGE2_SUBSCRIBEMWIONLY (1 << 18) /*!< GP: Only issue MWI notification if subscribed to */
+
+#define SIP_PAGE2_T38SUPPORT (7 << 20) /*!< GDP: T38 Fax Passthrough Support */
+#define SIP_PAGE2_T38SUPPORT_UDPTL (1 << 20) /*!< GDP: T38 Fax Passthrough Support */
+#define SIP_PAGE2_T38SUPPORT_RTP (2 << 20) /*!< GDP: T38 Fax Passthrough Support (not implemented) */
+#define SIP_PAGE2_T38SUPPORT_TCP (4 << 20) /*!< GDP: T38 Fax Passthrough Support (not implemented) */
+
+#define SIP_PAGE2_CALL_ONHOLD (3 << 23) /*!< D: Call hold states: */
+#define SIP_PAGE2_CALL_ONHOLD_ACTIVE (1 << 23) /*!< D: Active hold */
+#define SIP_PAGE2_CALL_ONHOLD_ONEDIR (2 << 23) /*!< D: One directional hold */
+#define SIP_PAGE2_CALL_ONHOLD_INACTIVE (3 << 23) /*!< D: Inactive hold */
+
+#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 | \
@@ -1785,7 +1780,7 @@
static const struct ast_channel_tech sip_tech = {
.type = "SIP",
.description = "Session Initiation Protocol (SIP)",
- .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
+ .capabilities = AST_FORMAT_AUDIO_MASK, /* all audio formats */
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
.requester = sip_request_call, /* called with chan unlocked */
.devicestate = sip_devicestate, /* called with chan unlocked (not chan-specific) */
@@ -1813,7 +1808,7 @@
static const struct ast_channel_tech sip_tech_info = {
.type = "SIP",
.description = "Session Initiation Protocol (SIP)",
- .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
+ .capabilities = AST_FORMAT_AUDIO_MASK, /* all audio formats */
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
.requester = sip_request_call,
.devicestate = sip_devicestate,
@@ -3728,9 +3723,9 @@
} else if (inuse)
*inuse = 0;
/* Decrement ringing count if applicable */
- if (inringing && ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
+ if (inringing && ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
ast_atomic_fetchadd_int(inringing, -1);
- ast_clear_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
+ ast_clear_flag(&fup->flags[0], SIP_INC_RINGING);
}
/* Decrement onhold count if applicable */
if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && global_notifyhold)
@@ -3753,9 +3748,9 @@
}
}
if (inringing && (event == INC_CALL_RINGING)) {
- if (!ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
+ if (!ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
ast_atomic_fetchadd_int(inringing, +1);
- ast_set_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
+ ast_set_flag(&fup->flags[0], SIP_INC_RINGING);
}
}
/* Continue */
@@ -3767,9 +3762,9 @@
break;
case DEC_CALL_RINGING:
- if (inringing && ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
+ if (inringing && ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
ast_atomic_fetchadd_int(inringing, -1);
- ast_clear_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
+ ast_clear_flag(&fup->flags[0], SIP_INC_RINGING);
}
break;
@@ -16886,7 +16881,15 @@
char *dest = data;
oldformat = format;
- if (!(format &= ((AST_FORMAT_MAX_AUDIO << 1) - 1))) {
+ /* mask request with some set of allowed formats.
+ * XXX this needs to be fixed.
+ * The original code uses AST_FORMAT_AUDIO_MASK, but it is
+ * unclear what to use here. We have global_capabilities, which is
+ * configured from sip.conf, and sip_tech.capabilities, which is
+ * hardwired to all audio formats.
+ */
+ format &= AST_FORMAT_AUDIO_MASK;
+ if (!format) {
ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format %s while capability is %s\n", ast_getformatname(oldformat), ast_getformatname(global_capability));
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; /* Can't find codec to connect to host */
return NULL;
More information about the asterisk-commits
mailing list