[Asterisk-cvs] asterisk/channels chan_mgcp.c,1.79.2.8,1.79.2.9
russell at lists.digium.com
russell at lists.digium.com
Mon Jan 3 23:42:41 CST 2005
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv8368/channels
Modified Files:
Tag: v1-0
chan_mgcp.c
Log Message:
lock sooner, fix some formatting (bug #3207)
Index: chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.79.2.8
retrieving revision 1.79.2.9
diff -u -d -r1.79.2.8 -r1.79.2.9
--- chan_mgcp.c 3 Jan 2005 02:38:26 -0000 1.79.2.8
+++ chan_mgcp.c 4 Jan 2005 05:47:49 -0000 1.79.2.9
@@ -686,8 +686,7 @@
if (gettimeofday(&tv, NULL) < 0) {
/* This shouldn't ever happen, but let's be sure */
ast_log(LOG_NOTICE, "gettimeofday() failed!\n");
- }
- else {
+ } else {
msg->expire = tv.tv_sec * 1000 + tv.tv_usec / 1000 + DEFAULT_RETRANS;
if (gw->retransid == -1)
@@ -862,8 +861,9 @@
struct mgcp_subchannel *sub = ast->pvt->pvt;
struct mgcp_endpoint *p = sub->parent;
- if (option_debug)
+ if (option_debug) {
ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name);
+ }
if (!ast->pvt->pvt) {
ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
@@ -872,14 +872,14 @@
ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
return 0;
}
+ ast_mutex_lock(&sub->lock);
if (mgcpdebug) {
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_hangup(%s) on %s@%s\n", ast->name, p->name, p->parent->name);
}
- if ((p->dtmfmode & MGCP_DTMF_INBAND) && (p->dsp != NULL)){
+ if ((p->dtmfmode & MGCP_DTMF_INBAND) && p->dsp) {
/* SC: check whether other channel is active. */
- if (!sub->next->owner)
- {
+ if (!sub->next->owner) {
if (mgcpdebug) {
ast_verbose(VERBOSE_PREFIX_2 "MGCP free dsp on %s@%s\n", p->name, p->parent->name);
}
@@ -887,7 +887,6 @@
p->dsp = NULL;
}
}
- ast_mutex_lock(&sub->lock);
sub->owner = NULL;
if (strlen(sub->cxident)) {
@@ -967,7 +966,7 @@
e = g->endpoints;
ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), g->addr.sin_addr) : ast_inet_ntoa(iabuf, sizeof(iabuf), g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
while(e) {
- // JS: Don't show wilcard endpoint
+ /* JS: Don't show wilcard endpoint */
if (strcmp(e->name, g->wcardep) !=0)
ast_cli(fd, " -- '%s@%s in '%s' is %s\n", e->name, g->name, e->context, e->sub->owner ? "active" : "idle");
hasendpoints = 1;
@@ -1311,7 +1310,8 @@
return tmp;
}
-static char* get_sdp_by_line(char* line, char *name, int nameLen) {
+static char* get_sdp_by_line(char* line, char *name, int nameLen)
+{
if (strncasecmp(line, name, nameLen) == 0 && line[nameLen] == '=') {
char* r = line + nameLen + 1;
while (*r && (*r < 33)) ++r;
@@ -1321,7 +1321,8 @@
return "";
}
-static char *get_sdp(struct mgcp_request *req, char *name) {
+static char *get_sdp(struct mgcp_request *req, char *name)
+{
int x;
int len = strlen(name);
char *r;
@@ -1333,12 +1334,13 @@
return "";
}
-static void sdpLineNum_iterator_init(int* iterator) {
+static void sdpLineNum_iterator_init(int* iterator)
+{
*iterator = 0;
}
-static char* get_sdp_iterate(int* iterator,
- struct mgcp_request *req, char *name) {
+static char* get_sdp_iterate(int* iterator, struct mgcp_request *req, char *name)
+{
int len = strlen(name);
char *r;
while (*iterator < req->lines) {
@@ -1656,7 +1658,7 @@
#if 0
printf("Peer RTP is at port %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
#endif
- // Scan through the RTP payload types specified in a "m=" line:
+ /* Scan through the RTP payload types specified in a "m=" line: */
ast_rtp_pt_clear(sub->rtp);
codecs = m + len;
while(strlen(codecs)) {
@@ -1668,18 +1670,18 @@
codecs += len;
}
- // Next, scan through each "a=rtpmap:" line, noting each
- // specified RTP payload type (with corresponding MIME subtype):
+ /* Next, scan through each "a=rtpmap:" line, noting each
+ specified RTP payload type (with corresponding MIME subtype): */
sdpLineNum_iterator_init(&iterator);
while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') {
char* mimeSubtype = strdup(a); // ensures we have enough space
if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) != 2) continue;
- // Note: should really look at the 'freq' and '#chans' params too
+ /* Note: should really look at the 'freq' and '#chans' params too */
ast_rtp_set_rtpmap_type(sub->rtp, codec, "audio", mimeSubtype);
free(mimeSubtype);
}
- // Now gather all of the codecs that were asked for:
+ /* Now gather all of the codecs that were asked for: */
ast_rtp_get_current_formats(sub->rtp,
&peercapability, &peerNonCodecCapability);
p->capability = capability & peercapability;
@@ -1694,7 +1696,6 @@
return -1;
}
return 0;
-
}
static int add_header(struct mgcp_request *req, char *var, char *value)
@@ -1710,9 +1711,9 @@
req->header[req->headers] = req->data + req->len;
snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s: %s\r\n", var, value);
req->len += strlen(req->header[req->headers]);
- if (req->headers < MGCP_MAX_HEADERS)
+ if (req->headers < MGCP_MAX_HEADERS) {
req->headers++;
- else {
+ } else {
ast_log(LOG_WARNING, "Out of header space\n");
return -1;
}
@@ -1733,9 +1734,9 @@
req->line[req->lines] = req->data + req->len;
snprintf(req->line[req->lines], sizeof(req->data) - req->len, "%s", line);
req->len += strlen(req->line[req->lines]);
- if (req->lines < MGCP_MAX_LINES)
+ if (req->lines < MGCP_MAX_LINES) {
req->lines++;
- else {
+ } else {
ast_log(LOG_WARNING, "Out of line space\n");
return -1;
}
@@ -2113,7 +2114,7 @@
struct mgcp_request resp;
reqprep(&resp, p, "AUEP");
/* SC: removed unknown param VS */
- //add_header(&resp, "F", "A,R,D,S,X,N,I,T,O,ES,E,MD,M");
+ /*add_header(&resp, "F", "A,R,D,S,X,N,I,T,O,ES,E,MD,M");*/
add_header(&resp, "F", "A");
/* SC: fill in new fields */
resp.cmd = MGCP_CMD_AUEP;
@@ -2858,7 +2859,7 @@
if (option_verbose > 2 && (strcmp(p->name, p->parent->wcardep) != 0)) {
ast_verbose(VERBOSE_PREFIX_3 "Resetting interface %s@%s\n", p->name, p->parent->name);
}
- // JS: For RSIP on wildcard we reset all endpoints
+ /* JS: For RSIP on wildcard we reset all endpoints */
if (!strcmp(p->name, p->parent->wcardep)) {
/* Reset all endpoints */
struct mgcp_endpoint *tmp_ep;
@@ -2866,7 +2867,7 @@
g = p->parent;
tmp_ep = g->endpoints;
while (tmp_ep) {
- //if ((strcmp(tmp_ep->name, "*") != 0) && (strcmp(tmp_ep->name, "aaln/*") != 0)) {
+ /*if ((strcmp(tmp_ep->name, "*") != 0) && (strcmp(tmp_ep->name, "aaln/" "*") != 0)) {*/
if (strcmp(tmp_ep->name, g->wcardep) != 0) {
struct mgcp_subchannel *tmp_sub, *first_sub;
if (option_verbose > 2) {
@@ -2926,7 +2927,9 @@
return -1;
}
/* do not let * confrnce two down channels */
- if( sub->owner && sub->owner->_state == AST_STATE_DOWN && !sub->next->owner) return -1;
+ if( sub->owner && sub->owner->_state == AST_STATE_DOWN && !sub->next->owner) {
+ return -1;
+ }
if (p->callwaiting || p->transfer || p->threewaycalling) {
if (option_verbose > 2) {
@@ -3083,11 +3086,9 @@
if (strstr(p->curtone, "wt") && (ev[0] == 'A')) {
memset(p->curtone, 0, sizeof(p->curtone));
}
- }
- else if (!strcasecmp(ev, "T")) {
+ } else if (!strcasecmp(ev, "T")) {
/* Digit timeout -- unimportant */
- }
- else if (!strcasecmp(ev, "ping")) {
+ } else if (!strcasecmp(ev, "ping")) {
/* ping -- unimportant */
} else {
ast_log(LOG_NOTICE, "Received unknown event '%s' from %s@%s\n", ev, p->name, p->parent->name);
@@ -3259,10 +3260,10 @@
/* Lock the network interface */
ast_mutex_lock(&netlock);
+#if 0
/* XXX THIS IS COMPLETELY HOSED */
/* The gateway goes into a state of panic */
/* If the vmwi indicator is sent while it is reseting interfaces */
-#if 0
lastpass = thispass;
thispass = time(NULL);
g = gateways;
@@ -3387,8 +3388,9 @@
return NULL;
}
tmpc = mgcp_new(sub->owner ? sub->next : sub, AST_STATE_DOWN);
- if (!tmpc)
+ if (!tmpc) {
ast_log(LOG_WARNING, "Unable to make channel for '%s'\n", tmp);
+ }
restart_monitor();
return tmpc;
}
@@ -3555,7 +3557,7 @@
e->needaudit = 1;
}
strncpy(gw->wcardep, v->value, sizeof(gw->wcardep)-1);
- //strncpy(e->name, "aaln/*", sizeof(e->name) - 1);
+ /*strncpy(e->name, "aaln/" "*", sizeof(e->name) - 1);*/
/* XXX Should we really check for uniqueness?? XXX */
strncpy(e->context, context, sizeof(e->context) - 1);
strncpy(e->callerid, callerid, sizeof(e->callerid) - 1);
@@ -4228,4 +4230,3 @@
{
return desc;
}
-
More information about the svn-commits
mailing list