aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-06 08:26:54 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-06 08:29:37 +0800
commit4634013cde42402d1ab744986c4c064efc53c080 (patch)
tree3b55c9f8be99175b2a50ee8028036080470766db
parent9c31cfc3a23bf1218800da6ddebd083817ef20d4 (diff)
mgcp: Make the CI uint32_t all the way to avoid mismatch
-rw-r--r--openbsc/include/openbsc/bsc_nat.h2
-rw-r--r--openbsc/include/openbsc/mgcp.h2
-rw-r--r--openbsc/include/openbsc/mgcp_internal.h2
-rw-r--r--openbsc/src/mgcp/mgcp_protocol.c14
-rw-r--r--openbsc/src/nat/bsc_mgcp_utils.c6
5 files changed, 14 insertions, 12 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 140fa6837..6ca22373e 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -263,7 +263,7 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
void bsc_mgcp_clear_endpoints_for(struct bsc_connection *bsc);
int bsc_mgcp_parse_response(const char *str, int *code, char transaction[60]);
-int bsc_mgcp_extract_ci(const char *resp);
+uint32_t bsc_mgcp_extract_ci(const char *resp);
int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id);
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 8f5917003..7f77868a4 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -124,7 +124,7 @@ struct mgcp_config {
void *data;
struct mgcp_endpoint *endpoints;
- unsigned int last_call_id;
+ uint32_t last_call_id;
};
/* config management */
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index 19e8e3f2b..d7be0a244 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -85,7 +85,7 @@ struct mgcp_rtp_tap {
};
struct mgcp_endpoint {
- int ci;
+ uint32_t ci;
char *callid;
char *local_options;
int conn_mode;
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index 743913264..e5f9a145d 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -89,7 +89,7 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg);
static struct msgb *handle_rsip(struct mgcp_config *cfg, struct msgb *msg);
-static int generate_call_id(struct mgcp_config *cfg)
+static uint32_t generate_call_id(struct mgcp_config *cfg)
{
int i;
@@ -170,7 +170,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
addr = endp->cfg->source_addr;
snprintf(sdp_record, sizeof(sdp_record) - 1,
- "I: %d\n\n"
+ "I: %u\n\n"
"v=0\r\n"
"c=IN IP4 %s\r\n"
"m=audio %d RTP/AVP %d\r\n"
@@ -324,11 +324,13 @@ static int verify_call_id(const struct mgcp_endpoint *endp,
}
static int verify_ci(const struct mgcp_endpoint *endp,
- const char *ci)
+ const char *_ci)
{
- if (atoi(ci) != endp->ci) {
- LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 0x%x. %d != %s\n",
- ENDPOINT_NUMBER(endp), endp->ci, ci);
+ uint32_t ci = strtoul(_ci, NULL, 10);
+
+ if (ci != endp->ci) {
+ LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 0x%x. %u != %s\n",
+ ENDPOINT_NUMBER(endp), endp->ci, _ci);
return -1;
}
diff --git a/openbsc/src/nat/bsc_mgcp_utils.c b/openbsc/src/nat/bsc_mgcp_utils.c
index 05963d3df..0455d1b05 100644
--- a/openbsc/src/nat/bsc_mgcp_utils.c
+++ b/openbsc/src/nat/bsc_mgcp_utils.c
@@ -344,16 +344,16 @@ int bsc_mgcp_parse_response(const char *str, int *code, char transaction[60])
return sscanf(str, "%3d %59s\n", code, transaction) != 2;
}
-int bsc_mgcp_extract_ci(const char *str)
+uint32_t bsc_mgcp_extract_ci(const char *str)
{
- int ci;
+ unsigned int ci;
char *res = strstr(str, "I: ");
if (!res) {
LOGP(DMGCP, LOGL_ERROR, "No CI in msg '%s'\n", str);
return CI_UNUSED;
}
- if (sscanf(res, "I: %d", &ci) != 1) {
+ if (sscanf(res, "I: %u", &ci) != 1) {
LOGP(DMGCP, LOGL_ERROR, "Failed to parse CI in msg '%s'\n", str);
return CI_UNUSED;
}