mgcp: Make the CI uint32_t all the way to avoid mismatch

This commit is contained in:
Holger Hans Peter Freyther 2010-08-06 08:26:54 +08:00
parent 9c31cfc3a2
commit 4634013cde
5 changed files with 14 additions and 12 deletions

View File

@ -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); 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_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); int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id);

View File

@ -124,7 +124,7 @@ struct mgcp_config {
void *data; void *data;
struct mgcp_endpoint *endpoints; struct mgcp_endpoint *endpoints;
unsigned int last_call_id; uint32_t last_call_id;
}; };
/* config management */ /* config management */

View File

@ -85,7 +85,7 @@ struct mgcp_rtp_tap {
}; };
struct mgcp_endpoint { struct mgcp_endpoint {
int ci; uint32_t ci;
char *callid; char *callid;
char *local_options; char *local_options;
int conn_mode; int conn_mode;

View File

@ -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_modify_con(struct mgcp_config *cfg, struct msgb *msg);
static struct msgb *handle_rsip(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; int i;
@ -170,7 +170,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
addr = endp->cfg->source_addr; addr = endp->cfg->source_addr;
snprintf(sdp_record, sizeof(sdp_record) - 1, snprintf(sdp_record, sizeof(sdp_record) - 1,
"I: %d\n\n" "I: %u\n\n"
"v=0\r\n" "v=0\r\n"
"c=IN IP4 %s\r\n" "c=IN IP4 %s\r\n"
"m=audio %d RTP/AVP %d\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, static int verify_ci(const struct mgcp_endpoint *endp,
const char *ci) const char *_ci)
{ {
if (atoi(ci) != endp->ci) { uint32_t ci = strtoul(_ci, NULL, 10);
LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 0x%x. %d != %s\n",
ENDPOINT_NUMBER(endp), endp->ci, ci); 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; return -1;
} }

View File

@ -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; 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: "); char *res = strstr(str, "I: ");
if (!res) { if (!res) {
LOGP(DMGCP, LOGL_ERROR, "No CI in msg '%s'\n", str); LOGP(DMGCP, LOGL_ERROR, "No CI in msg '%s'\n", str);
return CI_UNUSED; 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); LOGP(DMGCP, LOGL_ERROR, "Failed to parse CI in msg '%s'\n", str);
return CI_UNUSED; return CI_UNUSED;
} }