aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-02-15 21:14:09 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-02-17 19:34:27 +0100
commit3d4d8c7b5098776867b7b2192b00d02ab1e9da7f (patch)
tree42c84a92efcc882d9429b8346ac2dab6e7eed41a
parent84ec8714b21a766471129282b98a8bcbfef799f0 (diff)
msc: Move the nat handling into the sccp_state for now
-rw-r--r--include/msc_connection.h4
-rw-r--r--src/msc_conn.c43
-rw-r--r--src/sccp_state.c45
3 files changed, 50 insertions, 42 deletions
diff --git a/include/msc_connection.h b/include/msc_connection.h
index 3770452..9690906 100644
--- a/include/msc_connection.h
+++ b/include/msc_connection.h
@@ -81,4 +81,8 @@ int msc_connection_start(struct msc_connection *msc);
/* MGCP */
void mgcp_forward(struct msc_connection *msc, const uint8_t *data, unsigned int length);
+/* Called by the MSC Connection */
+void msc_dispatch_sccp(struct msc_connection *msc, struct msgb *msg);
+
+
#endif
diff --git a/src/msc_conn.c b/src/msc_conn.c
index 7eb18aa..a384290 100644
--- a/src/msc_conn.c
+++ b/src/msc_conn.c
@@ -162,48 +162,7 @@ static int ipaccess_a_fd_cb(struct bsc_fd *bfd)
bsc_del_timer(&fw->pong_timeout);
}
} else if (hh->proto == IPAC_PROTO_SCCP) {
- struct sccp_parse_result result;
- int rc;
-
- /* we can not forward it right now */
- if (fw->forward_only) {
- if (fw->target_link->sccp_up && send_or_queue_bsc_msg(fw->target_link, -1, msg) == 1)
- return 0;
-
- msgb_free(msg);
- return 0;
- }
-
-
- rc = bss_patch_filter_msg(msg, &result);
-
- if (rc == BSS_FILTER_RESET_ACK) {
- LOGP(DMSC, LOGL_NOTICE, "Filtering reset ack from the MSC\n");
- } else if (rc == BSS_FILTER_RLSD) {
- LOGP(DMSC, LOGL_DEBUG, "Filtering RLSD from the MSC\n");
- update_con_state(fw, rc, &result, msg, 1, 0);
- } else if (rc == BSS_FILTER_RLC) {
- /* if we receive this we have forwarded a RLSD to the network */
- LOGP(DMSC, LOGL_ERROR, "RLC from the network. BAD!\n");
- } else if (rc == BSS_FILTER_CLEAR_COMPL) {
- LOGP(DMSC, LOGL_ERROR, "Clear Complete from the network.\n");
- } else if (fw->target_link->sccp_up) {
- unsigned int sls;
-
- update_con_state(fw, rc, &result, msg, 1, 0);
- sls = sls_for_src_ref(fw, result.destination_local_reference);
-
- /* Check for Location Update Accept */
- bsc_ussd_handle_in_msg(fw, &result, msg);
-
- /* patch a possible PC */
- bss_rewrite_header_to_bsc(msg, fw->target_link->opc, fw->target_link->dpc);
-
- /* we can not forward it right now */
- if (send_or_queue_bsc_msg(fw->target_link, sls, msg) == 1)
- return 0;
-
- }
+ msc_dispatch_sccp(fw, msg);
} else if (hh->proto == NAT_MUX) {
mgcp_forward(fw, msg->l2h, msgb_l2len(msg));
} else {
diff --git a/src/sccp_state.c b/src/sccp_state.c
index 3457756..74f571d 100644
--- a/src/sccp_state.c
+++ b/src/sccp_state.c
@@ -27,6 +27,7 @@
#include <bsc_data.h>
#include <cellmgr_debug.h>
#include <bsc_sccp.h>
+#include <bsc_ussd.h>
#include <osmocore/talloc.h>
@@ -521,3 +522,47 @@ static void send_reset_ack(struct mtp_link_set *link, int sls)
mtp_link_set_submit_sccp_data(link, sls, reset_ack, sizeof(reset_ack));
}
+
+void msc_dispatch_sccp(struct msc_connection *msc, struct msgb *msg)
+{
+ /* we can not forward it right now */
+ if (msc->forward_only) {
+ if (!msc->target_link->sccp_up)
+ return;
+ mtp_link_set_submit_sccp_data(msc->target_link, -1,
+ msg->l2h, msgb_l2len(msg));
+ } else {
+ struct sccp_parse_result result;
+ int rc;
+
+ rc = bss_patch_filter_msg(msg, &result);
+
+ if (rc == BSS_FILTER_RESET_ACK) {
+ LOGP(DMSC, LOGL_NOTICE, "Filtering reset ack from the MSC\n");
+ } else if (rc == BSS_FILTER_RLSD) {
+ LOGP(DMSC, LOGL_DEBUG, "Filtering RLSD from the MSC\n");
+ update_con_state(msc, rc, &result, msg, 1, 0);
+ } else if (rc == BSS_FILTER_RLC) {
+ /* if we receive this we have forwarded a RLSD to the network */
+ LOGP(DMSC, LOGL_ERROR, "RLC from the network. BAD!\n");
+ } else if (rc == BSS_FILTER_CLEAR_COMPL) {
+ LOGP(DMSC, LOGL_ERROR, "Clear Complete from the network.\n");
+ } else if (msc->target_link->sccp_up) {
+ unsigned int sls;
+
+ update_con_state(msc, rc, &result, msg, 1, 0);
+ sls = sls_for_src_ref(msc, result.destination_local_reference);
+
+ /* Check for Location Update Accept */
+ bsc_ussd_handle_in_msg(msc, &result, msg);
+
+ /* patch a possible PC */
+ bss_rewrite_header_to_bsc(msg, msc->target_link->opc,
+ msc->target_link->dpc);
+
+ /* we can not forward it right now */
+ mtp_link_set_submit_sccp_data(msc->target_link, sls,
+ msg->l2h, msgb_l2len(msg));
+ }
+ }
+}