[asterisk-commits] rizzo: branch rizzo/astobj2 r51278 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Jan 19 01:46:17 MST 2007
Author: rizzo
Date: Fri Jan 19 02:46:16 2007
New Revision: 51278
URL: http://svn.digium.com/view/asterisk?view=rev&rev=51278
Log:
merge from trunk 49080:
Add version number to useragent string - Issue #8700, blanchet
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=51278&r1=51277&r2=51278
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Jan 19 02:46:16 2007
@@ -142,6 +142,7 @@
#include "asterisk/compiler.h"
#include "asterisk/threadstorage.h"
#include "asterisk/translate.h"
+#include "asterisk/version.h"
#ifndef FALSE
#define FALSE 0
@@ -1533,10 +1534,6 @@
static int sip_notify(int fd, int argc, char *argv[]);
static int sip_do_history(int fd, int argc, char *argv[]);
static int sip_no_history(int fd, int argc, char *argv[]);
-static int func_header_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
-static int func_check_sipdomain(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
-static int function_sippeer(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
-static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
static int sip_dtmfmode(struct ast_channel *chan, void *data);
static int sip_addheader(struct ast_channel *chan, void *data);
static int sip_reload(int fd, int argc, char *argv[]);
@@ -1652,7 +1649,6 @@
static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
static void handle_request_info(struct sip_pvt *p, struct sip_request *req);
static int handle_request_options(struct sip_pvt *p, struct sip_request *req);
-static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin);
static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin);
static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *current, struct sip_request *req, int seqno);
@@ -5837,21 +5833,25 @@
break;
if (!copied) { /* Only check for empty rport in topmost via header */
- char *rport;
+ char leftmost[256], *others, *rport;
+
+ /* Only work on leftmost value */
+ ast_copy_string(leftmost, oh, sizeof(leftmost));
+ others = strchr(leftmost, ',');
+ if (others)
+ *others++ = '\0';
/* Find ;rport; (empty request) */
- rport = strstr(oh, ";rport");
+ rport = strstr(leftmost, ";rport");
if (rport && *(rport+6) == '=')
rport = NULL; /* We already have a parameter to rport */
/* Check rport if NAT=yes or NAT=rfc3581 (which is the default setting) */
if (rport && ((ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_ALWAYS) || (ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_RFC3581))) {
/* We need to add received port - rport */
- char tmp[256], *end;
-
- ast_copy_string(tmp, oh, sizeof(tmp));
-
- rport = strstr(tmp, ";rport");
+ char *end;
+
+ rport = strstr(leftmost, ";rport");
if (rport) {
end = strchr(rport + 1, ';');
@@ -5862,13 +5862,15 @@
}
/* Add rport to first VIA header if requested */
- snprintf(new, sizeof(new), "%s;received=%s;rport=%d",
- tmp, ast_inet_ntoa(p->recv.sin_addr),
- ntohs(p->recv.sin_port));
+ snprintf(new, sizeof(new), "%s;received=%s;rport=%d%s%s",
+ leftmost, ast_inet_ntoa(p->recv.sin_addr),
+ ntohs(p->recv.sin_port),
+ others ? "," : "", others ? others : "");
} else {
/* We should *always* add a received to the topmost via */
- snprintf(new, sizeof(new), "%s;received=%s",
- oh, ast_inet_ntoa(p->recv.sin_addr));
+ snprintf(new, sizeof(new), "%s;received=%s%s%s",
+ leftmost, ast_inet_ntoa(p->recv.sin_addr),
+ others ? "," : "", others ? others : "");
}
oh = new; /* the header to copy */
} /* else add the following via headers untouched */
@@ -7296,7 +7298,7 @@
pidfnote = "On the phone";
break;
case AST_EXTENSION_UNAVAILABLE:
- statestring = "confirmed";
+ statestring = "terminated";
local_state = NOTIFY_CLOSED;
pidfstate = "away";
pidfnote = "Unavailable";
@@ -8572,7 +8574,7 @@
/* If they put someone on hold, increment the value... otherwise decrement it */
if (hold)
peer->onHold++;
- else if (hold > 0)
+ else
peer->onHold--;
/* Request device state update */
@@ -9318,6 +9320,11 @@
ast_copy_string(via, get_header(req, "Via"), sizeof(via));
+ /* Work on the leftmost value of the topmost Via header */
+ c = strchr(via, ',');
+ if (c)
+ *c = '\0';
+
/* Check for rport */
c = strstr(via, ";rport");
if (c && (c[6] != '=')) /* rport query, not answer */
@@ -13274,12 +13281,17 @@
return -1;
}
if ((d = ast_calloc(1, sizeof(*d)))) {
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
/* Save original request for followup */
copy_request(&d->req, req);
d->chan1 = transferee; /* Transferee */
d->chan2 = transferer; /* Transferer */
d->seqno = seqno;
- if (ast_pthread_create_background(&th, NULL, sip_park_thread, d) < 0) {
+ if (ast_pthread_create_background(&th, &attr, sip_park_thread, d) < 0) {
/* Could not start thread */
free(d); /* We don't need it anymore. If thread is created, d will be free'd
by sip_park_thread() */
@@ -16110,7 +16122,6 @@
return res;
}
-
/*!
\brief Handle flag-type options common to configuration of devices - users and peers
\param flags array of two struct ast_flags
@@ -16460,6 +16471,7 @@
} else {
user->amaflags = format;
} })
+ /* XXX need to merge error handling in ast_parse_allow_disallow() , see svn 49093 */
M_F("allow", ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 1))
M_F("disallow", ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 0))
M_BOOL("autoframing", user->autoframing)
@@ -16817,7 +16829,7 @@
global_notifyhold = FALSE; /*!< Keep track of hold status for a peer */
global_alwaysauthreject = 0;
global_allowsubscribe = FALSE;
- ast_copy_string(global_useragent, DEFAULT_USERAGENT, sizeof(global_useragent));
+ snprintf(global_useragent, sizeof(global_useragent), "%s %s", DEFAULT_USERAGENT, ASTERISK_VERSION);
ast_copy_string(default_notifymime, DEFAULT_NOTIFYMIME, sizeof(default_notifymime));
ast_copy_string(global_realm, S_OR(ast_config_AST_SYSTEM_NAME, DEFAULT_REALM), sizeof(global_realm));
ast_copy_string(default_callerid, DEFAULT_CALLERID, sizeof(default_callerid));
More information about the asterisk-commits
mailing list