[asterisk-commits] oej: branch oej/pinetree-trunk r216918 - in /team/oej/pinetree-trunk: ./ chan...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 7 13:40:30 CDT 2009
Author: oej
Date: Mon Sep 7 13:40:28 2009
New Revision: 216918
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=216918
Log:
Reset branch after all of oej's stupid commits trashed it... tss. Keep the mess, keep the mess.
Modified:
team/oej/pinetree-trunk/ (props changed)
team/oej/pinetree-trunk/channels/chan_sip.c
Propchange: team/oej/pinetree-trunk/
------------------------------------------------------------------------------
automerge = http://www.codename-pineapple.org/
Propchange: team/oej/pinetree-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Sep 7 13:40:28 2009
@@ -1,1 +1,1 @@
-/trunk:1-216872
+/trunk:1-216917
Modified: team/oej/pinetree-trunk/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/oej/pinetree-trunk/channels/chan_sip.c?view=diff&rev=216918&r1=216917&r2=216918
==============================================================================
--- team/oej/pinetree-trunk/channels/chan_sip.c (original)
+++ team/oej/pinetree-trunk/channels/chan_sip.c Mon Sep 7 13:40:28 2009
@@ -717,6 +717,19 @@
MWI_NOTIFICATION
};
+/*! \brief The number of media types in enum \ref media_type below. */
+#define OFFERED_MEDIA_COUNT 4
+
+/*! \brief Media types generate different "dummy answers" for not accepting the offer of
+ a media stream. We need to add definitions for each RTP profile. Secure RTP is not
+ the same as normal RTP and will require a new definition */
+enum media_type {
+ SDP_AUDIO, /*!< RTP/AVP Audio */
+ SDP_VIDEO, /*!< RTP/AVP Video */
+ SDP_IMAGE, /*!< Image udptl, not TCP or RTP */
+ SDP_TEXT, /*!< RTP/AVP Realtime Text */
+};
+
/*! \brief Subscription types that we support. We support
- dialoginfo updates (really device status, not dialog info as was the original intent of the standard)
- SIMPLE presence used for device status
@@ -1145,13 +1158,13 @@
configuring devices
*/
/*@{*/
-static char default_language[MAX_LANGUAGE]; /*! Default language setting for new channels */
-static char default_callerid[AST_MAX_EXTENSION];
-static char default_mwi_from[80];
-static char default_fromdomain[AST_MAX_EXTENSION];
-static char default_notifymime[AST_MAX_EXTENSION];
+static char default_language[MAX_LANGUAGE]; /*!< Default language setting for new channels */
+static char default_callerid[AST_MAX_EXTENSION]; /*!< Default caller ID for sip messages */
+static char default_mwi_from[80]; /*!< Default caller ID for MWI updates */
+static char default_fromdomain[AST_MAX_EXTENSION]; /*!< Default domain on outound messages */
+static char default_notifymime[AST_MAX_EXTENSION]; /*!< Default MIME media type for MWI notify messages */
+static char default_vmexten[AST_MAX_EXTENSION]; /*!< Default From Username on MWI updates */
static int default_qualify; /*!< Default Qualify= setting */
-static char default_vmexten[AST_MAX_EXTENSION];
static char default_mohinterpret[MAX_MUSICCLASS]; /*!< Global setting for moh class to use when put on hold */
static char default_mohsuggest[MAX_MUSICCLASS]; /*!< Global setting for moh class to suggest when putting
* a bridged channel on hold */
@@ -1170,6 +1183,7 @@
*/
/*@{*/
/*! \brief a place to store all global settings for the sip channel driver
+
These are settings that will be possibly to apply on a group level later on.
\note Do not add settings that only apply to the channel itself and can't
be applied to devices (trunks, services, phones)
@@ -1335,10 +1349,8 @@
char debug; /*!< print extra debugging if non zero */
char has_to_tag; /*!< non-zero if packet has To: tag */
char ignore; /*!< if non-zero This is a re-transmit, ignore it */
- /* Array of offsets into the request string of each SIP header*/
- ptrdiff_t header[SIP_MAX_HEADERS];
- /* Array of offsets into the request string of each SDP line*/
- ptrdiff_t line[SIP_MAX_LINES];
+ ptrdiff_t header[SIP_MAX_HEADERS]; /*!< Array of offsets into the request string of each SIP header*/
+ ptrdiff_t line[SIP_MAX_LINES]; /*!< Array of offsets into the request string of each SDP line*/
struct ast_str *data;
/* XXX Do we need to unref socket.ser when the request goes away? */
struct sip_socket socket; /*!< The socket used for this request */
@@ -1659,9 +1671,11 @@
int st_max_se; /*!< Highest threshold for session refresh interval */
};
+/*! \brief Structure for remembering offered media in an INVITE, to make sure we reply
+ to all media streams. In theory. In practise, we try our best. */
struct offered_media {
int offered;
- char text[128];
+ char codecs[128];
};
/*! \brief Structure used for each SIP dialog, ie. a call, a registration, a subscribe.
@@ -1836,17 +1850,18 @@
* By doing this, even if we don't want to answer a particular media stream with something meaningful, we can
* still put an m= line in our answer with the port set to 0.
*
- * The reason for the length being 4 is that in this branch of Asterisk, the only media types supported are
+ * The reason for the length being 4 (OFFERED_MEDIA_COUNT) is that in this branch of Asterisk, the only media types supported are
* image, audio, text, and video. Therefore we need to keep track of which types of media were offered.
+ * Note that secure RTP defines new types of SDP media.
*
- * Note that if we wanted to be 100% correct, we would keep a list of all media streams offered. That way we could respond
+ * If we wanted to be 100% correct, we would keep a list of all media streams offered. That way we could respond
* even to unknown media types, and we could respond to multiple streams of the same type. Such large-scale changes
* are not a good idea for released branches, though, so we're compromising by just making sure that for the common cases:
* audio and video, audio and T.38, and audio and text, we give the appropriate response to both media streams.
*
* The large-scale changes would be a good idea for implementing during an SDP rewrite.
*/
- struct offered_media offered_media[4];
+ struct offered_media offered_media[OFFERED_MEDIA_COUNT];
};
@@ -1990,6 +2005,7 @@
* or respect the other endpoint's request for frame sizes (on)
* for incoming calls
*/
+ unsigned short deprecated_username:1; /*!< If it's a realtime peer, are they using the deprecated "username" instead of "defaultuser" */
struct sip_auth *auth; /*!< Realm authentication list */
enum devicematchrules matchrule; /*!< Match rule for this peer */
int amaflags; /*!< AMA Flags (for billing) */
@@ -2008,7 +2024,7 @@
/*! Mailboxes that this peer cares about */
AST_LIST_HEAD_NOLOCK(, sip_mailbox) mailboxes;
- int maxcallbitrate; /*!< Maximum Bitrate for a video call */
+ int maxcallbitrate; /*!< Maximum Bitrate for a video call */
int expire; /*!< When to expire this peer registration */
int capability; /*!< Codec capability */
int rtptimeout; /*!< RTP timeout */
@@ -2019,13 +2035,12 @@
struct sip_proxy *outboundproxy; /*!< Outbound proxy for this peer */
struct ast_dnsmgr_entry *dnsmgr;/*!< DNS refresh manager for peer */
struct sockaddr_in addr; /*!< IP address of peer */
- /* Qualification */
struct sip_pvt *call; /*!< Call pointer */
- int pokeexpire; /*!< When to expire poke (qualify= checking) */
- int lastms; /*!< How long last response took (in ms), or -1 for no response */
- int maxms; /*!< Max ms we will accept for the host to be up, 0 to not monitor */
- int qualifyfreq; /*!< Qualification: How often to check for the host to be up */
- struct timeval ps; /*!< Time for sending SIP OPTION in sip_pke_peer() */
+ int pokeexpire; /*!< Qualification: When to expire poke (qualify= checking) */
+ int lastms; /*!< Qualification: How long last response took (in ms), or -1 for no response */
+ int maxms; /*!< Qualification: Max ms we will accept for the host to be up, 0 to not monitor */
+ int qualifyfreq; /*!< Qualification: Qualification: How often to check for the host to be up */
+ struct timeval ps; /*!< Qualification: Time for sending SIP OPTION in sip_pke_peer() */
struct sockaddr_in defaddr; /*!< Default IP address, used until registration */
struct ast_ha *ha; /*!< Access control list */
struct ast_ha *contactha; /*!< Restrict what IPs are allowed in the Contact header (for registration) */
@@ -2034,7 +2049,6 @@
struct sip_st_cfg stimer; /*!< SIP Session-Timers */
int timer_t1; /*!< The maximum T1 value for the peer */
int timer_b; /*!< The maximum timer B (transaction timeouts) */
- int deprecated_username; /*!< If it's a realtime peer, are they using the deprecated "username" instead of "defaultuser" */
/*XXX Seems like we suddenly have two flags with the same content. Why? To be continued... */
enum sip_peer_type type; /*!< Distinguish between "user" and "peer" types. This is used solely for CLI and manager commands */
@@ -2070,7 +2084,6 @@
AST_STRING_FIELD(secret); /*!< Password in clear text */
AST_STRING_FIELD(md5secret); /*!< Password in md5 */
AST_STRING_FIELD(callback); /*!< Contact extension */
- AST_STRING_FIELD(random);
AST_STRING_FIELD(peername); /*!< Peer registering to */
);
enum sip_transport transport; /*!< Transport for this registration UDP, TCP or TLS */
@@ -2139,7 +2152,7 @@
static struct ao2_container *peers;
static struct ao2_container *peers_by_ip;
-/*! \brief The register list: Other SIP proxies we register with and place calls to */
+/*! \brief The register list: Other SIP proxies we register with and receive calls from */
static struct ast_register_list {
ASTOBJ_CONTAINER_COMPONENTS(struct sip_registry);
int recheck;
@@ -2314,7 +2327,7 @@
static char externhost[MAXHOSTNAMELEN]; /*!< External host name */
static time_t externexpire; /*!< Expiration counter for re-resolving external host name in dynamic DNS */
-static int externrefresh = 10;
+static int externrefresh = 10; /*!< Refresh timer for DNS-based external address (dyndns) */
static struct sockaddr_in stunaddr; /*!< stun server address */
/*! \brief List of local networks
@@ -2491,39 +2504,6 @@
static int attempt_transfer(struct sip_dual *transferer, struct sip_dual *target);
static int do_magic_pickup(struct ast_channel *channel, const char *extension, const char *context);
static void create_sockaddr(const char *hostname, const char *port, struct sockaddr_in *addr);
-
-
-/*!
- * \brief generic function for determining if a correct transport is being
- * used to contact a peer
- *
- * this is done as a macro so that the "tmpl" var can be passed either a
- * sip_request or a sip_peer
- */
-#define check_request_transport(peer, tmpl) ({ \
- int ret = 0; \
- if (peer->socket.type == tmpl->socket.type) \
- ; \
- else if (!(peer->transports & tmpl->socket.type)) {\
- ast_log(LOG_ERROR, \
- "'%s' is not a valid transport for '%s'. we only use '%s'! ending call.\n", \
- get_transport(tmpl->socket.type), peer->name, get_transport_list(peer->transports) \
- ); \
- ret = 1; \
- } else if (peer->socket.type & SIP_TRANSPORT_TLS) { \
- ast_log(LOG_WARNING, \
- "peer '%s' HAS NOT USED (OR SWITCHED TO) TLS in favor of '%s' (but this was allowed in sip.conf)!\n", \
- peer->name, get_transport(tmpl->socket.type) \
- ); \
- } else { \
- ast_debug(1, \
- "peer '%s' has contacted us over %s even though we prefer %s.\n", \
- peer->name, get_transport(tmpl->socket.type), get_transport(peer->socket.type) \
- ); \
- }\
- (ret); \
-})
-
/*--- Device monitoring and Device/extension state/event handling */
static int cb_extensionstate(char *context, char* exten, int state, void *data);
@@ -2588,11 +2568,6 @@
static void sip_dump_history(struct sip_pvt *dialog); /* Dump history to debuglog at end of dialog, before destroying data */
static inline int sip_debug_test_addr(const struct sockaddr_in *addr);
static inline int sip_debug_test_pvt(struct sip_pvt *p);
-
-
-/*! \brief Append to SIP dialog history
- \return Always returns 0 */
-#define append_history(p, event, fmt , args... ) append_history_full(p, "%-15s " fmt, event, ## args)
static void append_history_full(struct sip_pvt *p, const char *fmt, ...);
static void sip_dump_history(struct sip_pvt *dialog);
@@ -2614,7 +2589,7 @@
static void set_socket_transport(struct sip_socket *socket, int transport);
/* Realtime device support */
-static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, const char *useragent, int expirey, int deprecated_username, int lastms);
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, const char *useragent, int expirey, unsigned short deprecated_username, int lastms);
static void update_peer(struct sip_peer *p, int expire);
static struct ast_variable *get_insecure_variable_from_config(struct ast_config *config);
static const char *get_name_from_variable(struct ast_variable *var, const char *newpeername);
@@ -2830,6 +2805,10 @@
/* wrapper macro to tell whether t points to one of the sip_tech descriptors */
#define IS_SIP_TECH(t) ((t) == &sip_tech || (t) == &sip_tech_info)
+/*! \brief Append to SIP dialog history
+ \return Always returns 0 */
+#define append_history(p, event, fmt , args... ) append_history_full(p, "%-15s " fmt, event, ## args)
+
/*! \brief map from an integer value to a string.
* If no match is found, return errorstring
*/
@@ -2857,6 +2836,37 @@
}
/*!
+ * \brief generic function for determining if a correct transport is being
+ * used to contact a peer
+ *
+ * this is done as a macro so that the "tmpl" var can be passed either a
+ * sip_request or a sip_peer
+ */
+#define check_request_transport(peer, tmpl) ({ \
+ int ret = 0; \
+ if (peer->socket.type == tmpl->socket.type) \
+ ; \
+ else if (!(peer->transports & tmpl->socket.type)) {\
+ ast_log(LOG_ERROR, \
+ "'%s' is not a valid transport for '%s'. we only use '%s'! ending call.\n", \
+ get_transport(tmpl->socket.type), peer->name, get_transport_list(peer->transports) \
+ ); \
+ ret = 1; \
+ } else if (peer->socket.type & SIP_TRANSPORT_TLS) { \
+ ast_log(LOG_WARNING, \
+ "peer '%s' HAS NOT USED (OR SWITCHED TO) TLS in favor of '%s' (but this was allowed in sip.conf)!\n", \
+ peer->name, get_transport(tmpl->socket.type) \
+ ); \
+ } else { \
+ ast_debug(1, \
+ "peer '%s' has contacted us over %s even though we prefer %s.\n", \
+ peer->name, get_transport(tmpl->socket.type), get_transport(peer->socket.type) \
+ ); \
+ }\
+ (ret); \
+})
+
+/*! \brief
* duplicate a list of channel variables, \return the copy.
*/
static struct ast_variable *copy_vars(struct ast_variable *src)
@@ -3871,9 +3881,11 @@
}
}
- if (p->subscribed == MWI_NOTIFICATION)
- if (p->relatedpeer)
+ if (p->subscribed == MWI_NOTIFICATION) {
+ if (p->relatedpeer) {
p->relatedpeer = unref_peer(p->relatedpeer, "__sip_autodestruct: unref peer p->relatedpeer"); /* Remove link to peer. If it's realtime, make sure it's gone from memory) */
+ }
+ }
/* Reset schedule ID */
p->autokillid = -1;
@@ -4518,7 +4530,7 @@
that name and store that in the "regserver" field in the sippeers
table to facilitate multi-server setups.
*/
-static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *defaultuser, const char *fullcontact, const char *useragent, int expirey, int deprecated_username, int lastms)
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *defaultuser, const char *fullcontact, const char *useragent, int expirey, unsigned short deprecated_username, int lastms)
{
char port[10];
char ipaddr[INET_ADDRSTRLEN];
@@ -8056,12 +8068,6 @@
return FALSE;
}
-enum media_type {
- SDP_AUDIO,
- SDP_VIDEO,
- SDP_IMAGE,
- SDP_TEXT,
-};
static int get_ip_and_port_from_sdp(struct sip_request *req, const enum media_type media, struct sockaddr_in *sin)
{
@@ -8318,7 +8324,7 @@
portno = x;
/* Scan through the RTP payload types specified in a "m=" line: */
codecs = m + len;
- ast_copy_string(p->offered_media[SDP_AUDIO].text, codecs, sizeof(p->offered_media[SDP_AUDIO].text));
+ ast_copy_string(p->offered_media[SDP_AUDIO].codecs, codecs, sizeof(p->offered_media[SDP_AUDIO].codecs));
for (; !ast_strlen_zero(codecs); codecs = ast_skip_blanks(codecs + len)) {
if (sscanf(codecs, "%30d%n", &codec, &len) != 1) {
ast_log(LOG_WARNING, "Error in codec string '%s'\n", codecs);
@@ -8338,7 +8344,7 @@
vportno = x;
/* Scan through the RTP payload types specified in a "m=" line: */
codecs = m + len;
- ast_copy_string(p->offered_media[SDP_VIDEO].text, codecs, sizeof(p->offered_media[SDP_VIDEO].text));
+ ast_copy_string(p->offered_media[SDP_VIDEO].codecs, codecs, sizeof(p->offered_media[SDP_VIDEO].codecs));
for (; !ast_strlen_zero(codecs); codecs = ast_skip_blanks(codecs + len)) {
if (sscanf(codecs, "%30d%n", &codec, &len) != 1) {
ast_log(LOG_WARNING, "Error in codec string '%s'\n", codecs);
@@ -8357,7 +8363,7 @@
tportno = x;
/* Scan through the RTP payload types specified in a "m=" line: */
codecs = m + len;
- ast_copy_string(p->offered_media[SDP_TEXT].text, codecs, sizeof(p->offered_media[SDP_TEXT].text));
+ ast_copy_string(p->offered_media[SDP_TEXT].codecs, codecs, sizeof(p->offered_media[SDP_TEXT].codecs));
for (; !ast_strlen_zero(codecs); codecs = ast_skip_blanks(codecs + len)) {
if (sscanf(codecs, "%30d%n", &codec, &len) != 1) {
ast_log(LOG_WARNING, "Error in codec string '%s'\n", codecs);
@@ -10548,7 +10554,7 @@
add_line(resp, a_audio->str);
add_line(resp, hold);
} else if (p->offered_media[SDP_AUDIO].offered) {
- snprintf(dummy_answer, sizeof(dummy_answer), "m=audio 0 RTP/AVP %s\r\n", p->offered_media[SDP_AUDIO].text);
+ snprintf(dummy_answer, sizeof(dummy_answer), "m=audio 0 RTP/AVP %s\r\n", p->offered_media[SDP_AUDIO].codecs);
add_line(resp, dummy_answer);
}
if (needvideo) { /* only if video response is appropriate */
@@ -10556,7 +10562,7 @@
add_line(resp, a_video->str);
add_line(resp, hold); /* Repeat hold for the video stream */
} else if (p->offered_media[SDP_VIDEO].offered) {
- snprintf(dummy_answer, sizeof(dummy_answer), "m=video 0 RTP/AVP %s\r\n", p->offered_media[SDP_VIDEO].text);
+ snprintf(dummy_answer, sizeof(dummy_answer), "m=video 0 RTP/AVP %s\r\n", p->offered_media[SDP_VIDEO].codecs);
add_line(resp, dummy_answer);
}
if (needtext) { /* only if text response is appropriate */
@@ -10564,7 +10570,7 @@
add_line(resp, a_text->str);
add_line(resp, hold); /* Repeat hold for the text stream */
} else if (p->offered_media[SDP_TEXT].offered) {
- snprintf(dummy_answer, sizeof(dummy_answer), "m=text 0 RTP/AVP %s\r\n", p->offered_media[SDP_TEXT].text);
+ snprintf(dummy_answer, sizeof(dummy_answer), "m=text 0 RTP/AVP %s\r\n", p->offered_media[SDP_TEXT].codecs);
add_line(resp, dummy_answer);
}
if (add_t38) {
More information about the asterisk-commits
mailing list