aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/nat/bsc_nat.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-01-19 16:13:03 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-01-21 08:52:40 +0100
commit42b0d6b4948ead0fadfd5085da689687b2fe5e9f (patch)
treed5e2c55c364bf27809e5384505ecf838580112e6 /openbsc/src/nat/bsc_nat.c
parent82d8b0457b888635ffeb8a1c5bb905908042cbd2 (diff)
[nat] Add a bsc_filter.c which will carry out the analysis and filtering
The first part is to analyze the IP Access Header and only forward SCCP messages for now. In the future we might want to do MGCP signalling through this protocol and connection as well and need to update this then.
Diffstat (limited to 'openbsc/src/nat/bsc_nat.c')
-rw-r--r--openbsc/src/nat/bsc_nat.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 6aed7c982..98eaa9794 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -38,11 +38,14 @@
#include <openbsc/debug.h>
#include <openbsc/msgb.h>
#include <openbsc/bsc_msc.h>
+#include <openbsc/bsc_nat.h>
#include <openbsc/ipaccess.h>
#include <openbsc/abis_nm.h>
#include <openbsc/talloc.h>
#include <openbsc/linuxlist.h>
+#include <sccp/sccp.h>
+
static const char *config_file = "openbsc.cfg";
static char *msc_address = "127.0.0.1";
static struct in_addr local_addr;
@@ -65,6 +68,7 @@ struct bsc_connection {
static LLIST_HEAD(bsc_connections);
+
/*
* below are stubs we need to link
*/
@@ -101,6 +105,10 @@ static void forward_sccp_to_bts(struct msgb *msg)
/* filter, drop, patch the message? */
+ /* drop packets with the wrong IPA header */
+ if (bsc_nat_filter_ipa(msg))
+ return;
+
/* currently send this to every BSC connected */
llist_for_each_entry(bsc, &bsc_connections, list_entry) {
write(bsc->bsc_fd.fd, msg->data, msg->len);
@@ -160,6 +168,10 @@ static int forward_sccp_to_msc(struct msgb *msg)
{
/* FIXME: We need to filter out certain messages */
+ /* drop packets with the wrong IPA header */
+ if (bsc_nat_filter_ipa(msg))
+ return 0;
+
/* send the non-filtered but maybe modified msg */
return write(msc_connection.fd, msg->data, msg->len);
}
@@ -168,7 +180,6 @@ static int ipaccess_bsc_cb(struct bsc_fd *bfd, unsigned int what)
{
int error;
struct msgb *msg = ipaccess_read_msg(bfd, &error);
- struct ipaccess_head *hh;
if (!msg) {
if (error == 0) {
@@ -180,16 +191,13 @@ static int ipaccess_bsc_cb(struct bsc_fd *bfd, unsigned int what)
return -1;
}
- DEBUGP(DMSC, "MSG from BSC: %s proto: %d\n", hexdump(msg->data, msg->len), msg->l2h[0]);
- /* handle base message handling */
- hh = (struct ipaccess_head *) msg->data;
+ DEBUGP(DMSC, "MSG from BSC: %s proto: %d\n", hexdump(msg->data, msg->len), msg->l2h[0]);
/* Handle messages from the BSC */
/* FIXME: Currently no PONG is sent to the BSC */
/* FIXME: Currently no ID ACK is sent to the BSC */
- if (hh->proto == IPAC_PROTO_SCCP)
- forward_sccp_to_msc(msg);
+ forward_sccp_to_msc(msg);
return 0;
}