[asterisk-commits] trunk r19578 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Apr 12 14:21:46 MST 2006


Author: oej
Date: Wed Apr 12 16:21:44 2006
New Revision: 19578

URL: http://svn.digium.com/view/asterisk?rev=19578&view=rev
Log:
- Adding some refer state definitions from the siptransfer branch
- A bit more URI conversions 
- Changes to sip_dual and the SIP invite structure
- Add Supported: headers to more requests

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=19578&r1=19577&r2=19578&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Apr 12 16:21:44 2006
@@ -539,9 +539,10 @@
 
 /*! \brief structure used in transfers */
 struct sip_dual {
-	struct ast_channel *chan1;
-	struct ast_channel *chan2;
-	struct sip_request req;
+	struct ast_channel *chan1;	/*!< First channel involved */
+	struct ast_channel *chan2;	/*!< Second channel involved */
+	struct sip_request req;		/*!< Request that caused the transfer (REFER) */
+	int seqno;			/*!< Sequence number */
 };
 
 struct sip_pkt;
@@ -555,6 +556,8 @@
 	char *auth;			/*!< Authentication */
 	char *authheader;		/*!< Auth header */
 	enum sip_auth_type auth_type;	/*!< Authentication type */
+	const char *replaces;		/*!< Replaces header for call transfers */
+	int transfer;			/*!< Flag - is this Invite part of a SIP transfer? (invite/replaces) */
 };
 
 /*! \brief Structure to save routing information for a SIP session */
@@ -676,6 +679,34 @@
 #define sipdebug		ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG)
 #define sipdebug_config		ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONFIG)
 #define sipdebug_console	ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE)
+
+/*! \brief Parameters to know status of transfer */
+enum referstatus {
+	REFER_IDLE,		/*!< No REFER is in progress */
+	REFER_SENT,		/*!< Sent REFER to transferee */
+	REFER_RECEIVED,		/*!< Received REFER from transferer */
+	REFER_CONFIRMED,	/*!< Refer confirmed with a 100 TRYING */
+	REFER_ACCEPTED,		/*!< Accepted by transferee */
+	REFER_RINGING,		/*!< Target Ringing */
+	REFER_200OK,		/*!< Answered by transfer target */
+	REFER_FAILED,		/*!< REFER declined - go on */
+	REFER_NOAUTH		/*!< We had no auth for REFER */
+};
+
+static const struct c_referstatusstring {
+	enum referstatus status;
+	char *text;
+} referstatusstrings[] = {
+	{ REFER_IDLE,		"<none>" },
+	{ REFER_SENT,		"Request sent" },
+	{ REFER_RECEIVED,	"Request received" },
+	{ REFER_ACCEPTED,	"Accepted" },
+	{ REFER_RINGING,	"Target ringing" },
+	{ REFER_200OK,		"Done" },
+	{ REFER_FAILED,		"Failed" },
+	{ REFER_NOAUTH,		"Failed - auth failure" }
+} ;
+
 
 /*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe  */
 static struct sip_pvt {
@@ -1083,6 +1114,19 @@
 	get_codec: sip_get_codec,
 };
 
+/*! \brief Convert transfer status to string */
+static char *referstatus2str(enum referstatus rstatus)
+{
+	int i = (sizeof(referstatusstrings) / sizeof(referstatusstrings[0]));
+	int x;
+
+	for (x = 0; x < i; x++) {
+		if (referstatusstrings[x].status ==  rstatus)
+			return (char *) referstatusstrings[x].text;
+	}
+	return "";
+}
+
 
 /*! \brief returns true if 'name' (with optional trailing whitespace)
  * matches the sip method 'id'.
@@ -4806,8 +4850,9 @@
 		reqprep(&req, p, SIP_INVITE, 0, 1);
 	
 	add_header(&req, "Allow", ALLOWED_METHODS);
+	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
 	if (sipdebug)
-		add_header(&req, "X-asterisk-info", "SIP re-invite (RTP bridge)");
+		add_header(&req, "X-asterisk-Info", "SIP re-invite (External RTP bridge)");
 	if (recordhistory)
 		append_history(p, "ReInv", "Re-invite sent");
 	add_sdp(&req, p);
@@ -5102,6 +5147,7 @@
 		add_header(&req, "Alert-Info", p->options->distinctive_ring);
 	}
 	add_header(&req, "Allow", ALLOWED_METHODS);
+	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
 	if (p->options && p->options->addsipheaders ) {
 		struct ast_channel *ast;
 		struct varshead *headp = NULL;
@@ -6669,6 +6715,10 @@
 	uri = get_in_brackets(tmp);
 	
 	ast_copy_string(tmpf, get_header(req, "From"), sizeof(tmpf));
+	if (pedanticsipchecking) {
+		ast_uri_decode(tmp);
+		ast_uri_decode(tmpf);
+	}
 
 	from = get_in_brackets(tmpf);
 	



More information about the asterisk-commits mailing list