aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-16 02:20:26 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-16 02:49:12 +0800
commit5bac62216e7096e11f846117a59f708a5fe9c59f (patch)
treed3ddecdb48b3354abb6e7147c658c09a0b50a514 /openbsc
parentc93c5238727f7ce7a19bbe8b966ef05551eef0c6 (diff)
[nat] Move the SCCP CREF handling into a new method.
We will need to generate messages with a proper reason and it is easier to do that from a dedicated method.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/nat/bsc_nat.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 3b10b9a3..24233a2f 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -294,6 +294,22 @@ static void bsc_send_data(struct bsc_connection *bsc, const u_int8_t *data, unsi
bsc_write(bsc, msg, proto);
}
+static void bsc_send_con_refuse(struct bsc_connection *bsc,
+ struct bsc_nat_parsed *parsed, int con_type)
+{
+ struct msgb *refuse;
+ refuse = sccp_create_refuse(parsed->src_local_ref, SCCP_REFUSAL_SCCP_FAILURE, NULL, 0);
+ if (!refuse) {
+ LOGP(DNAT, LOGL_ERROR,
+ "Creating refuse msg failed for SCCP 0x%x on BSC Nr: %d.\n",
+ sccp_src_ref_to_int(parsed->src_local_ref), bsc->cfg->nr);
+ return;
+ }
+
+ bsc_write(bsc, refuse, IPAC_PROTO_SCCP);
+}
+
+
static int forward_sccp_to_bts(struct msgb *msg)
{
struct sccp_connections *con;
@@ -575,7 +591,6 @@ static void ipaccess_auth_bsc(struct tlv_parsed *tvp, struct bsc_connection *bsc
static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
{
int con_type;
- struct msgb *refuse;
struct sccp_connections *con;
struct bsc_nat_parsed *parsed;
@@ -679,12 +694,7 @@ exit2:
exit3:
/* send a SCCP Connection Refused */
- refuse = sccp_create_refuse(parsed->src_local_ref, SCCP_REFUSAL_SCCP_FAILURE, NULL, 0);
- if (refuse) {
- bsc_send_data(bsc, refuse->l2h, msgb_l2len(refuse), IPAC_PROTO_SCCP);
- msgb_free(refuse);
- }
-
+ bsc_send_con_refuse(bsc, parsed, con_type);
talloc_free(parsed);
msgb_free(msg);
return -1;