[asterisk-commits] oej: branch oej/codename-pineapple r46375 - in /team/oej/codename-pineapple/c...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Oct 28 02:18:20 MST 2006


Author: oej
Date: Sat Oct 28 04:18:18 2006
New Revision: 46375

URL: http://svn.digium.com/view/asterisk?rev=46375&view=rev
Log:
Moving around, moving around...

Added:
    team/oej/codename-pineapple/channels/sip3/sip3_services.c   (with props)
Modified:
    team/oej/codename-pineapple/channels/Makefile
    team/oej/codename-pineapple/channels/chan_sip3.c
    team/oej/codename-pineapple/channels/sip3/Makefile
    team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
    team/oej/codename-pineapple/channels/sip3/sip3funcs.h

Modified: team/oej/codename-pineapple/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/Makefile?rev=46375&r1=46374&r2=46375&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/Makefile (original)
+++ team/oej/codename-pineapple/channels/Makefile Sat Oct 28 04:18:18 2006
@@ -15,7 +15,7 @@
 CC_MODS:=$(filter-out $(MENUSELECT_CHANNELS),$(patsubst %.cc,%,$(wildcard chan_*.cc)))
 SIP3_MODULES=chan_sip3.o sip3/sip3_network.o sip3/sip3_subscribe.o sip3/sip3_refer.o sip3/sip3_domain.o \
 	sip3/sip3_callerid.o sip3/sip3_auth.o sip3/sip3_sdprtp.o sip3/sip3_config.o \
-	sip3/sip3_cliami.o sip3/sip3_dialog.o
+	sip3/sip3_cliami.o sip3/sip3_dialog.o sip3/sip3_services.o
 
 ifeq ($(OSARCH),OpenBSD)
   PTLIB=-lpt_OpenBSD_x86_r

Modified: team/oej/codename-pineapple/channels/chan_sip3.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip3.c?rev=46375&r1=46374&r2=46375&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip3.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip3.c Sat Oct 28 04:18:18 2006
@@ -232,6 +232,7 @@
 	- \b sip3_parse.c	Parsing stuff
 	- \b sip3_refer.c	SIP transfer support
 	- \b sip3_network.c	Networks interface (UDP today)
+	- \b sip3_services.c	Outbound registrations (services)
 		
 */
 			/* -END- documentation pages */
@@ -583,14 +584,12 @@
 static void handle_response(struct sip_dialog *p, int resp, char *rest, struct sip_request *req, int seqno);
 
 /*----- RTP interface functions */
-static int sip_get_codec(struct ast_channel *chan);
 static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_dialog *p, int *faxdetect);
 static void stop_media_flows(struct sip_dialog *p);
 
 /*------ T38 Support --------- */
 static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_dialog *pvt, int reinvite); /*!< T38 negotiation helper function */
 static int transmit_response_with_t38_sdp(struct sip_dialog *p, char *msg, struct sip_request *req, int retrans);
-static int transmit_reinvite_with_t38_sdp(struct sip_dialog *p);
 static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan);
 static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
 
@@ -601,38 +600,22 @@
 	.description = "Session Initiation Protocol (SIP)",
 	.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
 	.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
-	.requester = sip_request_call,
-	.devicestate = sip_devicestate,
-	.call = sip_call,
-	.hangup = sip_hangup,
-	.answer = sip_answer,
-	.read = sip_read,
-	.write = sip_write,
-	.write_video = sip_write,
-	.indicate = sip_indicate,
-	.transfer = sip_transfer,
+	.requester = sip_request_call,		/*!< Where we set up a call, but don't actually activate it */
+	.devicestate = sip_devicestate,		/*!< Checking the status of a known SIP device */
+	.call = sip_call,			/*!< Try calling Bob, says Alice */
+	.hangup = sip_hangup,			/*!< Alice does not want to talk to Bob any more */
+	.answer = sip_answer,			/*!< Bob answers the call */
+	.read = sip_read,			/*!< Deliver media to the PBX */
+	.write = sip_write,			/*!< Get media from the PBX side */
+	.write_video = sip_write,		/*!< Get video media from the PBX side */
+	.indicate = sip_indicate,		/*!< Get indications from the PBX side */
+	.transfer = sip_transfer,		/*!< Transfer a call, severely broken */
 	.fixup = sip_fixup,
-	.send_digit_begin = sip_senddigit_begin,
-	.send_digit_end = sip_senddigit_end,
+	.send_digit_begin = sip_senddigit_begin,	/*!< DTMF support */
+	.send_digit_end = sip_senddigit_end,		/*!< DTMF support */
 	.bridge = ast_rtp_bridge,
 	.early_bridge = ast_rtp_early_bridge,
-	.send_text = sip_sendtext,
-};
-
-/*! \brief Interface structure with callbacks used to connect to RTP module */
-static struct ast_rtp_protocol sip_rtp = {
-	type: "SIP",
-	get_rtp_info: sip_get_rtp_peer,
-	get_vrtp_info: sip_get_vrtp_peer,
-	set_rtp_peer: sip_set_rtp_peer,
-	get_codec: sip_get_codec,
-};
-
-/*! \brief Interface structure with callbacks used to connect to UDPTL module*/
-static struct ast_udptl_protocol sip_udptl = {
-	type: "SIP",
-	get_udptl_info: sip_get_udptl_peer,
-	set_udptl_peer: sip_set_udptl_peer,
+	.send_text = sip_sendtext,		/*!< Get text from the PBX to send out */
 };
 
 /*! \brief Initialize the initital request packet in the pvt structure.
@@ -2526,103 +2509,6 @@
 	return __get_header(req, name, &start);
 }
 
-/*! \brief Read RTP from network */
-static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_dialog *p, int *faxdetect)
-{
-	/* Retrieve audio/etc from channel.  Assumes p->lock is already held. */
-	struct ast_frame *f;
-	
-	if (!p->rtp) {
-		/* We have no RTP allocated for this channel */
-		return &ast_null_frame;
-	}
-
-	switch(ast->fdno) {
-	case 0:
-		f = ast_rtp_read(p->rtp);	/* RTP Audio */
-		break;
-	case 1:
-		f = ast_rtcp_read(p->rtp);	/* RTCP Control Channel */
-		break;
-	case 2:
-		f = ast_rtp_read(p->vrtp);	/* RTP Video */
-		break;
-	case 3:
-		f = ast_rtcp_read(p->vrtp);	/* RTCP Control Channel for video */
-		break;
-	case 5:
-		f = ast_udptl_read(p->udptl);	/* UDPTL for T.38 */
-		break;
-	default:
-		f = &ast_null_frame;
-	}
-	/* Don't forward RFC2833 if we're not supposed to */
-	if (f && (f->frametype == AST_FRAME_DTMF) &&
-	    (ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833))
-		return &ast_null_frame;
-
-	if (p->owner) {
-		/* We already hold the channel lock */
-		if (f->frametype == AST_FRAME_VOICE) {
-			if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
-				if (option_debug)
-					ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
-				p->owner->nativeformats = (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
-				ast_set_read_format(p->owner, p->owner->readformat);
-				ast_set_write_format(p->owner, p->owner->writeformat);
-			}
-			if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
-				f = ast_dsp_process(p->owner, p->vad, f);
-				if (f && f->frametype == AST_FRAME_DTMF) {
-					if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
-						if (option_debug)
-							ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
-						*faxdetect = 1;
-					} else if (option_debug) {
-						ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
-					}
-				}
-			}
-		}
-	}
-	return f;
-}
-
-/*! \brief Read SIP RTP from channel */
-static struct ast_frame *sip_read(struct ast_channel *ast)
-{
-	struct ast_frame *fr;
-	struct sip_dialog *p = ast->tech_pvt;
-	int faxdetected = FALSE;
-
-	ast_mutex_lock(&p->lock);
-	fr = sip_rtp_read(ast, p, &faxdetected);
-	p->lastrtprx = time(NULL);
-
-	/* If we are NOT bridged to another channel, and we have detected fax tone we issue T38 re-invite to a peer */
-	/* If we are bridged then it is the responsibility of the SIP device to issue T38 re-invite if it detects CNG or fax preamble */
-	if (faxdetected && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
-		if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
-			if (!p->pendinginvite) {
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
-				p->t38.state = T38_LOCAL_REINVITE;
-				transmit_reinvite_with_t38_sdp(p);
-				if (option_debug > 1)
-					ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
-			}
-		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-			if (option_debug > 2)
-				ast_log(LOG_DEBUG, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
-			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
-		}
-	}
-
-	ast_mutex_unlock(&p->lock);
-	return fr;
-}
-
-
 /*! \brief Generate 32 byte random string for callid's etc */
 static char *generate_random_string(char *buf, size_t size)
 {
@@ -3957,7 +3843,7 @@
        We reinvite so that the T38 processing can take place.
        SIP Signalling stays with * in the path.
 */
-static int transmit_reinvite_with_t38_sdp(struct sip_dialog *p)
+GNURK int transmit_reinvite_with_t38_sdp(struct sip_dialog *p)
 {
 	struct sip_request req;
 
@@ -10650,53 +10536,6 @@
 	return peer;
 }
 
-static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
-{
-	struct sip_dialog *p;
-	struct ast_udptl *udptl = NULL;
-	
-	p = chan->tech_pvt;
-	if (!p)
-		return NULL;
-	
-	ast_mutex_lock(&p->lock);
-	if (p->udptl && ast_test_flag(&p->flags[0], SIP_CAN_REINVITE))
-		udptl = p->udptl;
-	ast_mutex_unlock(&p->lock);
-	return udptl;
-}
-
-static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
-{
-	struct sip_dialog *p;
-	
-	p = chan->tech_pvt;
-	if (!p)
-		return -1;
-	ast_mutex_lock(&p->lock);
-	if (udptl)
-		ast_udptl_get_peer(udptl, &p->udptlredirip);
-	else
-		memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
-	if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
-		if (!p->pendinginvite) {
-			if (option_debug > 2) {
-				ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
-			}
-			transmit_reinvite_with_t38_sdp(p);
-		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-			if (option_debug > 2) {
-				ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
-			}
-			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
-		}
-	}
-	/* Reset lastrtprx timer */
-	p->lastrtprx = p->lastrtptx = time(NULL);
-	ast_mutex_unlock(&p->lock);
-	return 0;
-}
-
 static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_dialog *pvt, int reinvite)
 {
 	struct sip_dialog *p;
@@ -10930,13 +10769,6 @@
 	return -1;
 }
 
-/*! \brief Return SIP UA's codec (part of the RTP interface) */
-static int sip_get_codec(struct ast_channel *chan)
-{
-	struct sip_dialog *p = chan->tech_pvt;
-	return p->peercapability;	
-}
-
 /*! \brief Send a poke to all known peers 
 	Space them out 100 ms apart
 	XXX We might have a cool algorithm for this or use random - any suggestions?
@@ -11085,11 +10917,8 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
-	/* Tell the RTP subdriver that we're here */
-	ast_rtp_proto_register(&sip_rtp);
-
-	/* Tell the UDPTL subdriver that we're here */
-	ast_udptl_proto_register(&sip_udptl);
+	/* Tell the RTP and UDPTL subdriver that we're here */
+	register_rtp_and_udptl();	/* See sip3_sdprtp.c */
 
 	/* Register dialplan applications */
 	ast_register_application(app_dtmfmode, sip_dtmfmode, synopsis_dtmfmode, descrip_dtmfmode);
@@ -11128,20 +10957,20 @@
 	ast_unregister_application(app_sipaddheader);
 	sip_cli_and_manager_commands_unregister();
 
-	ast_rtp_proto_unregister(&sip_rtp);
-	ast_udptl_proto_unregister(&sip_udptl);
+	unregister_rtp_and_udptl();	/* sip3_sdprtp.c */
 
 	ast_manager_unregister("SIPpeers");
 	ast_manager_unregister("SIPshowpeer");
 
+	/* Hangup all dialogs if they have an owner */
 	dialoglist_lock();
-	/* Hangup all interfaces if they have an owner */
 	for (p = dialoglist; p ; p = p->next) {
 		if (p->owner)
 			ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
 	}
 	dialoglist_unlock();
 
+	/* Kill the monitor thread */
 	ast_mutex_lock(&monlock);
 	if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
 		pthread_cancel(monitor_thread);
@@ -11151,8 +10980,8 @@
 	monitor_thread = AST_PTHREADT_STOP;
 	ast_mutex_unlock(&monlock);
 
+	/* Destroy all the dialogs and free their memory */
 	dialoglist_lock();
-	/* Destroy all the interfaces and free their memory */
 	p = dialoglist;
 	while (p) {
 		pl = p;
@@ -11171,14 +11000,18 @@
 	/* Free memory for local network address mask */
 	ast_free_ha(sipnet.localaddr);
 
+	/* Destroy all device configurations in the device list */
 	ASTOBJ_CONTAINER_DESTROYALL(&devicelist, sip_destroy_device);
 	ASTOBJ_CONTAINER_DESTROY(&devicelist);
+
+	/* Destroy all entries in the registry list */
 	ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
 	ASTOBJ_CONTAINER_DESTROY(&regl);
 
 	clear_realm_authentication(authl);
-	clear_sip_domains();
-	close(sipnet.sipsock);
+	clear_sip_domains();				/* Clear the list of hosted domains */
+
+	close(sipnet.sipsock);				/* Close the network socket */
 	sched_context_destroy(sched);
 		
 	return 0;

Modified: team/oej/codename-pineapple/channels/sip3/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/Makefile?rev=46375&r1=46374&r2=46375&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/Makefile (original)
+++ team/oej/codename-pineapple/channels/sip3/Makefile Sat Oct 28 04:18:18 2006
@@ -2,7 +2,7 @@
 # Makefile for chan_sip3 support
 #
 all: sip3_refer.o sip3_subscribe.o sip3_network.o sip3_domain.o sip3_callerid.o sip3_auth.o \
-	sip3_sdprtp.o sip3_config.o sip3_cliami.c sip3_dialog.c
+	sip3_sdprtp.o sip3_config.o sip3_cliami.o sip3_dialog.o sip3_services.o
 
 %.o: %.c sip3funcs.h sip3.h
 	$(CC) $(CFLAGS) -c -o $@ $<

Modified: team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c?rev=46375&r1=46374&r2=46375&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c Sat Oct 28 04:18:18 2006
@@ -84,6 +84,48 @@
 #include "asterisk/compiler.h"
 #include "sip3.h"
 #include "sip3funcs.h"
+
+/* Forward declarations */
+static int sip_get_codec(struct ast_channel *chan);
+static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
+static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan);
+
+/*! \brief Interface structure with callbacks used to connect to RTP module */
+static struct ast_rtp_protocol sip_rtp = {
+	type: "SIP",
+	get_rtp_info: sip_get_rtp_peer,
+	get_vrtp_info: sip_get_vrtp_peer,
+	set_rtp_peer: sip_set_rtp_peer,
+	get_codec: sip_get_codec,
+};
+
+/*! \brief Interface structure with callbacks used to connect to UDPTL module*/
+static struct ast_udptl_protocol sip_udptl = {
+	type: "SIP",
+	get_udptl_info: sip_get_udptl_peer,
+	set_udptl_peer: sip_set_udptl_peer,
+};
+
+/*! \brief Register RTP and UDPTL to the subsystems */
+void register_rtp_and_udptl(void)
+{
+	/* Tell the RTP subdriver that we're here */
+	ast_rtp_proto_register(&sip_rtp);
+
+	/* Tell the UDPTL subdriver that we're here */
+	ast_udptl_proto_register(&sip_udptl);
+}
+
+/*! \brief UNRegister RTP and UDPTL to the subsystems */
+void unregister_rtp_and_udptl(void)
+{
+	/* Tell the RTP subdriver that we're gone */
+	ast_rtp_proto_unregister(&sip_rtp);
+
+	/* Tell the UDPTL subdriver that we're gone */
+	ast_udptl_proto_unregister(&sip_udptl);
+}
+
 
 /*! \brief Reads one line of SIP message body */
 static char *get_body_by_line(const char *line, const char *name, int nameLen)
@@ -1206,3 +1248,154 @@
 	return 0;
 }
 
+/*! \brief Return SIP UA's codec (part of the RTP interface) */
+static int sip_get_codec(struct ast_channel *chan)
+{
+	struct sip_dialog *p = chan->tech_pvt;
+	return p->peercapability;	
+}
+
+/*! \brief Read RTP from network */
+static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_dialog *p, int *faxdetect)
+{
+	/* Retrieve audio/etc from channel.  Assumes p->lock is already held. */
+	struct ast_frame *f;
+	
+	if (!p->rtp) {
+		/* We have no RTP allocated for this channel */
+		return &ast_null_frame;
+	}
+
+	switch(ast->fdno) {
+	case 0:
+		f = ast_rtp_read(p->rtp);	/* RTP Audio */
+		break;
+	case 1:
+		f = ast_rtcp_read(p->rtp);	/* RTCP Control Channel */
+		break;
+	case 2:
+		f = ast_rtp_read(p->vrtp);	/* RTP Video */
+		break;
+	case 3:
+		f = ast_rtcp_read(p->vrtp);	/* RTCP Control Channel for video */
+		break;
+	case 5:
+		f = ast_udptl_read(p->udptl);	/* UDPTL for T.38 */
+		break;
+	default:
+		f = &ast_null_frame;
+	}
+	/* Don't forward RFC2833 if we're not supposed to */
+	if (f && (f->frametype == AST_FRAME_DTMF) &&
+	    (ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833))
+		return &ast_null_frame;
+
+	if (p->owner) {
+		/* We already hold the channel lock */
+		if (f->frametype == AST_FRAME_VOICE) {
+			if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+				p->owner->nativeformats = (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
+				ast_set_read_format(p->owner, p->owner->readformat);
+				ast_set_write_format(p->owner, p->owner->writeformat);
+			}
+			if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
+				f = ast_dsp_process(p->owner, p->vad, f);
+				if (f && f->frametype == AST_FRAME_DTMF) {
+					if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
+						if (option_debug)
+							ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
+						*faxdetect = 1;
+					} else if (option_debug) {
+						ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+					}
+				}
+			}
+		}
+	}
+	return f;
+}
+
+/*! \brief Read SIP RTP from channel */
+static struct ast_frame *sip_read(struct ast_channel *ast)
+{
+	struct ast_frame *fr;
+	struct sip_dialog *p = ast->tech_pvt;
+	int faxdetected = FALSE;
+
+	ast_mutex_lock(&p->lock);
+	fr = sip_rtp_read(ast, p, &faxdetected);
+	p->lastrtprx = time(NULL);
+
+	/* If we are NOT bridged to another channel, and we have detected fax tone we issue T38 re-invite to a peer */
+	/* If we are bridged then it is the responsibility of the SIP device to issue T38 re-invite if it detects CNG or fax preamble */
+	if (faxdetected && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
+		if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
+			if (!p->pendinginvite) {
+				if (option_debug > 2)
+					ast_log(LOG_DEBUG, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
+				p->t38.state = T38_LOCAL_REINVITE;
+				transmit_reinvite_with_t38_sdp(p);
+				if (option_debug > 1)
+					ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
+			}
+		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
+			if (option_debug > 2)
+				ast_log(LOG_DEBUG, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
+			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
+		}
+	}
+
+	ast_mutex_unlock(&p->lock);
+	return fr;
+}
+
+/*! \brief Get UDPTL peer address (part of UDPTL interface) */
+static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
+{
+	struct sip_dialog *p;
+	struct ast_udptl *udptl = NULL;
+	
+	p = chan->tech_pvt;
+	if (!p)
+		return NULL;
+	
+	ast_mutex_lock(&p->lock);
+	if (p->udptl && ast_test_flag(&p->flags[0], SIP_CAN_REINVITE))
+		udptl = p->udptl;
+	ast_mutex_unlock(&p->lock);
+	return udptl;
+}
+
+/*! \brief Determine UDPTL peer address for re-invite (part of UDPTL interface) */
+static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
+{
+	struct sip_dialog *p;
+	
+	p = chan->tech_pvt;
+	if (!p)
+		return -1;
+	ast_mutex_lock(&p->lock);
+	if (udptl)
+		ast_udptl_get_peer(udptl, &p->udptlredirip);
+	else
+		memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
+	if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
+		if (!p->pendinginvite) {
+			if (option_debug > 2) {
+				ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
+			}
+			transmit_reinvite_with_t38_sdp(p);
+		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
+			if (option_debug > 2) {
+				ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
+			}
+			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
+		}
+	}
+	/* Reset lastrtprx timer */
+	p->lastrtprx = p->lastrtptx = time(NULL);
+	ast_mutex_unlock(&p->lock);
+	return 0;
+}

Added: team/oej/codename-pineapple/channels/sip3/sip3_services.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_services.c?rev=46375&view=auto
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_services.c (added)
+++ team/oej/codename-pineapple/channels/sip3/sip3_services.c Sat Oct 28 04:18:18 2006
@@ -1,0 +1,94 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2006, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Various SIP functions for services, registrations for SIP service with other providers/servers
+ * Version 3 of chan_sip
+ *
+ * \author Mark Spencer <markster at digium.com>
+ * \author Olle E. Johansson <oej at edvina.net> (all the chan_sip3 changes)
+ *
+ * See Also:
+ * \arg \ref AstCREDITS
+ * \arg \ref Chan_sip3_00index
+ *
+ *
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <signal.h>
+#include <sys/signal.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <arpa/inet.h>
+#include <netinet/ip.h>
+#include <regex.h>
+
+#include "asterisk/lock.h"
+#include "asterisk/channel.h"
+#include "asterisk/config.h"
+#include "asterisk/logger.h"
+#include "asterisk/module.h"
+#include "asterisk/pbx.h"
+#include "asterisk/options.h"
+#include "asterisk/lock.h"
+#include "asterisk/sched.h"
+#include "asterisk/io.h"
+#include "asterisk/rtp.h"
+#include "asterisk/udptl.h"
+#include "asterisk/acl.h"
+#include "asterisk/manager.h"
+#include "asterisk/callerid.h"
+#include "asterisk/cli.h"
+#include "asterisk/app.h"
+#include "asterisk/musiconhold.h"
+#include "asterisk/dsp.h"
+#include "asterisk/features.h"
+#include "asterisk/acl.h"
+#include "asterisk/srv.h"
+#include "asterisk/astdb.h"
+#include "asterisk/causes.h"
+#include "asterisk/utils.h"
+#include "asterisk/file.h"
+#include "asterisk/astobj.h"
+#include "asterisk/dnsmgr.h"
+#include "asterisk/devicestate.h"
+#include "asterisk/linkedlists.h"
+#include "asterisk/stringfields.h"
+#include "asterisk/monitor.h"
+#include "asterisk/localtime.h"
+#include "asterisk/abstract_jb.h"
+#include "asterisk/compiler.h"
+#include "sip3.h"
+#include "sip3funcs.h"
+

Propchange: team/oej/codename-pineapple/channels/sip3/sip3_services.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/oej/codename-pineapple/channels/sip3/sip3_services.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/oej/codename-pineapple/channels/sip3/sip3_services.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/oej/codename-pineapple/channels/sip3/sip3funcs.h
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3funcs.h?rev=46375&r1=46374&r2=46375&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3funcs.h (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3funcs.h Sat Oct 28 04:18:18 2006
@@ -78,6 +78,7 @@
 GNURK int transmit_response_with_auth(struct sip_dialog *p, const char *msg, const struct sip_request *req, const char *rand, enum xmittype reliable, const char *header, int stale);
 GNURK int transmit_register(struct sip_registry *r, int sipmethod, const char *auth, const char *authheader);
 GNURK int transmit_invite(struct sip_dialog *p, int sipmethod, int sdp, int init);
+GNURK int transmit_reinvite_with_t38_sdp(struct sip_dialog *p);
 GNURK void sip_scheddestroy(struct sip_dialog *p, int ms);
 
 /*! sip3_refer.c */
@@ -131,6 +132,8 @@
 GNURK int build_reply_digest(struct sip_dialog *p, int method, char* digest, int digest_len);
 
 /* sip3_sdprtp.c */
+GNURK void register_rtp_and_udptl(void);
+GNURK void unregister_rtp_and_udptl(void);
 GNURK char *get_body(struct sip_request *req, char *name);
 GNURK int process_sdp(struct sip_dialog *p, struct sip_request *req);
 GNURK int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active);



More information about the asterisk-commits mailing list