nat: Return the SCCP Connection again...
We will reset the multiplex in a DLCX message and then we can reset the multiplex as well...even if the MGCP connection is staying open. or at least this is a theory. The MSC likes to leave a connection open during CallControl when hanging up early enough in the process.
This commit is contained in:
parent
ff9e09b2bc
commit
7897c4446b
|
@ -260,7 +260,7 @@ void bsc_mgcp_free_endpoint(struct bsc_nat *nat, int);
|
||||||
void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
|
void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
|
||||||
int bsc_mgcp_init(struct bsc_nat *nat);
|
int bsc_mgcp_init(struct bsc_nat *nat);
|
||||||
|
|
||||||
struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
|
struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
|
||||||
struct msgb *bsc_mgcp_rewrite(char *input, int length, const char *ip, int port);
|
struct msgb *bsc_mgcp_rewrite(char *input, int length, const char *ip, int port);
|
||||||
void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
|
void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,9 @@ void bsc_mgcp_free_endpoints(struct bsc_nat *nat)
|
||||||
bsc_mgcp_free_endpoint(nat, i);
|
bsc_mgcp_free_endpoint(nat, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
|
struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
|
||||||
{
|
{
|
||||||
struct bsc_connection *bsc = NULL;
|
struct sccp_connections *con = NULL;
|
||||||
struct sccp_connections *sccp;
|
struct sccp_connections *sccp;
|
||||||
|
|
||||||
llist_for_each_entry(sccp, &nat->sccp_connections, list_entry) {
|
llist_for_each_entry(sccp, &nat->sccp_connections, list_entry) {
|
||||||
|
@ -103,11 +103,11 @@ struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
|
||||||
if (mgcp_timeslot_to_endpoint(0, sccp->msc_timeslot) != endpoint)
|
if (mgcp_timeslot_to_endpoint(0, sccp->msc_timeslot) != endpoint)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bsc = sccp->bsc;
|
con = sccp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bsc)
|
if (con)
|
||||||
return bsc;
|
return con;
|
||||||
|
|
||||||
LOGP(DMGCP, LOGL_ERROR, "Failed to find the connection.\n");
|
LOGP(DMGCP, LOGL_ERROR, "Failed to find the connection.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -117,7 +117,7 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||||
{
|
{
|
||||||
struct bsc_nat *nat;
|
struct bsc_nat *nat;
|
||||||
struct bsc_endpoint *bsc_endp;
|
struct bsc_endpoint *bsc_endp;
|
||||||
struct bsc_connection *bsc_con;
|
struct sccp_connections *sccp;
|
||||||
struct mgcp_endpoint *mgcp_endp;
|
struct mgcp_endpoint *mgcp_endp;
|
||||||
struct msgb *bsc_msg;
|
struct msgb *bsc_msg;
|
||||||
|
|
||||||
|
@ -125,9 +125,9 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||||
bsc_endp = &nat->bsc_endpoints[endpoint];
|
bsc_endp = &nat->bsc_endpoints[endpoint];
|
||||||
mgcp_endp = &nat->mgcp_cfg->endpoints[endpoint];
|
mgcp_endp = &nat->mgcp_cfg->endpoints[endpoint];
|
||||||
|
|
||||||
bsc_con = bsc_mgcp_find_con(nat, endpoint);
|
sccp = bsc_mgcp_find_con(nat, endpoint);
|
||||||
|
|
||||||
if (!bsc_con) {
|
if (!sccp) {
|
||||||
LOGP(DMGCP, LOGL_ERROR, "Did not find BSC for a new connection on 0x%x for %d\n", endpoint, state);
|
LOGP(DMGCP, LOGL_ERROR, "Did not find BSC for a new connection on 0x%x for %d\n", endpoint, state);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -163,14 +163,14 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||||
|
|
||||||
|
|
||||||
bsc_endp->transaction_id = talloc_strdup(nat, transaction_id);
|
bsc_endp->transaction_id = talloc_strdup(nat, transaction_id);
|
||||||
bsc_endp->bsc = bsc_con;
|
bsc_endp->bsc = sccp->bsc;
|
||||||
bsc_endp->pending_delete = 0;
|
bsc_endp->pending_delete = 0;
|
||||||
|
|
||||||
/* we need to update some bits */
|
/* we need to update some bits */
|
||||||
if (state == MGCP_ENDP_CRCX) {
|
if (state == MGCP_ENDP_CRCX) {
|
||||||
struct sockaddr_in sock;
|
struct sockaddr_in sock;
|
||||||
socklen_t len = sizeof(sock);
|
socklen_t len = sizeof(sock);
|
||||||
if (getpeername(bsc_con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len) != 0) {
|
if (getpeername(sccp->bsc->write_queue.bfd.fd, (struct sockaddr *) &sock, &len) != 0) {
|
||||||
LOGP(DMGCP, LOGL_ERROR, "Can not get the peername...%d/%s\n",
|
LOGP(DMGCP, LOGL_ERROR, "Can not get the peername...%d/%s\n",
|
||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
|
@ -182,7 +182,7 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||||
mgcp_free_endp(mgcp_endp);
|
mgcp_free_endp(mgcp_endp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bsc_write(bsc_con, bsc_msg, NAT_IPAC_PROTO_MGCP);
|
bsc_write(sccp->bsc, bsc_msg, NAT_IPAC_PROTO_MGCP);
|
||||||
return MGCP_POLICY_DEFER;
|
return MGCP_POLICY_DEFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -432,14 +432,14 @@ static void test_mgcp_find(void)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bsc_mgcp_find_con(nat, 12) != con) {
|
if (bsc_mgcp_find_con(nat, 12) != sccp_con) {
|
||||||
fprintf(stderr, "Didn't find the connection\n");
|
fprintf(stderr, "Didn't find the connection\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
sccp_con->msc_timeslot = 0;
|
sccp_con->msc_timeslot = 0;
|
||||||
sccp_con->bsc_timeslot = 0;
|
sccp_con->bsc_timeslot = 0;
|
||||||
if (bsc_mgcp_find_con(nat, 1) != con) {
|
if (bsc_mgcp_find_con(nat, 1) != sccp_con) {
|
||||||
fprintf(stderr, "Didn't find the connection\n");
|
fprintf(stderr, "Didn't find the connection\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue