aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-09-19 04:36:07 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-09-20 02:51:30 +0800
commitf2eedff052bd7f92655a32d5a57206018b310aec (patch)
tree7b8463698949f7db1c5060e961be4c273660ffa5
parentb98ba72e0a413a9d325fa8ed20cb77d28d472e2f (diff)
nat: Send a transcoder reset on start up.
The transcoder RESET is using the same extensions to reset all endpoints on a remote site. This makes sure that all allocations can be made in a properly configured network.
-rw-r--r--openbsc/include/openbsc/mgcp.h1
-rw-r--r--openbsc/src/mgcp/mgcp_protocol.c19
-rw-r--r--openbsc/src/nat/bsc_mgcp_utils.c9
3 files changed, 29 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 4adea96b..850396a8 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -146,6 +146,7 @@ int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg);
int mgcp_vty_init(void);
int mgcp_endpoints_allocate(struct mgcp_config *cfg);
void mgcp_free_endp(struct mgcp_endpoint *endp);
+int mgcp_reset_transcoder(struct mgcp_config *cfg);
/*
* format helper functions
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index f18431aa..5abdeaea 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -951,3 +951,22 @@ static void delete_transcoder(struct mgcp_endpoint *endp)
send_dlcx(endp, in_endp);
send_dlcx(endp, out_endp);
}
+
+int mgcp_reset_transcoder(struct mgcp_config *cfg)
+{
+ struct sockaddr_in addr;
+
+ if (!cfg->transcoder_ip)
+ return -1;
+
+ static const char mgcp_reset[] = {
+ "RSIP 1 13@mgw MGCP 1.0\r\n"
+ };
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr = cfg->transcoder_in;
+ addr.sin_port = htons(2427);
+ return sendto(cfg->gw_fd.bfd.fd, mgcp_reset, sizeof mgcp_reset -1, 0,
+ (struct sockaddr *) &addr, sizeof(addr));
+}
diff --git a/openbsc/src/nat/bsc_mgcp_utils.c b/openbsc/src/nat/bsc_mgcp_utils.c
index 76595276..b84a2623 100644
--- a/openbsc/src/nat/bsc_mgcp_utils.c
+++ b/openbsc/src/nat/bsc_mgcp_utils.c
@@ -663,6 +663,15 @@ int bsc_mgcp_nat_init(struct bsc_nat *nat)
return -1;
}
+ if (mgcp_reset_transcoder(cfg) < 0) {
+ LOGP(DMGCP, LOGL_ERROR, "Failed to send packet to the transcoder.\n");
+ talloc_free(nat->bsc_endpoints);
+ nat->bsc_endpoints = NULL;
+ close(cfg->gw_fd.bfd.fd);
+ cfg->gw_fd.bfd.fd = -1;
+ return -1;
+ }
+
return 0;
}