diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-16 02:00:40 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-16 02:49:11 +0800 |
commit | 11c17233fea7bc9e59d3718f55620f4044910d41 (patch) | |
tree | 6e20c3cbfe63adf9d48cb5e2ee170d3b7ab94de2 /openbsc/src | |
parent | fceee8779ee072ba1979c99642f770fd112ba333 (diff) |
[nat] Set the connection type/reason as out parameter
We are analyzing each CR message and it is nice to know the
reason these connections were created. Change the nat method.
Diffstat (limited to 'openbsc/src')
-rw-r--r-- | openbsc/src/nat/bsc_nat.c | 3 | ||||
-rw-r--r-- | openbsc/src/nat/bsc_nat_utils.c | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index f1849ec29..59257f4a7 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -574,6 +574,7 @@ 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; @@ -605,7 +606,7 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg) if (parsed->ipa_proto == IPAC_PROTO_SCCP) { switch (parsed->sccp_type) { case SCCP_MSG_TYPE_CR: - if (bsc_nat_filter_sccp_cr(bsc, msg, parsed) != 0) + if (bsc_nat_filter_sccp_cr(bsc, msg, parsed, &con_type) != 0) goto exit3; if (create_sccp_src_ref(bsc, msg, parsed) != 0) goto exit2; diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c index 1e1a9ce74..8083c6ad1 100644 --- a/openbsc/src/nat/bsc_nat_utils.c +++ b/openbsc/src/nat/bsc_nat_utils.c @@ -315,13 +315,15 @@ static int _cr_check_pag_resp(struct bsc_connection *bsc, uint8_t *data, unsigne } /* Filter out CR data... */ -int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, struct bsc_nat_parsed *parsed) +int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, struct bsc_nat_parsed *parsed, int *con_type) { struct tlv_parsed tp; struct gsm48_hdr *hdr48; int hdr48_len; int len; + *con_type = NAT_CON_TYPE_NONE; + if (parsed->gsm_type != BSS_MAP_MSG_COMPLETE_LAYER_3) { LOGP(DNAT, LOGL_ERROR, "Rejecting CR message due wrong GSM Type %d\n", parsed->gsm_type); @@ -357,15 +359,19 @@ int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, struct if (hdr48->proto_discr == GSM48_PDISC_MM && hdr48->msg_type == GSM48_MT_MM_LOC_UPD_REQUEST) { + *con_type = NAT_CON_TYPE_LU; return _cr_check_loc_upd(bsc, &hdr48->data[0], hdr48_len - sizeof(*hdr48)); } else if (hdr48->proto_discr == GSM48_PDISC_MM && hdr48->msg_type == GSM48_MT_MM_CM_SERV_REQ) { + *con_type = NAT_CON_TYPE_CM_SERV_REQ; return _cr_check_cm_serv_req(bsc, &hdr48->data[0], hdr48_len - sizeof(*hdr48)); } else if (hdr48->proto_discr == GSM48_PDISC_RR && hdr48->msg_type == GSM48_MT_RR_PAG_RESP) { + *con_type = NAT_CON_TYPE_PAG_RESP; return _cr_check_pag_resp(bsc, &hdr48->data[0], hdr48_len - sizeof(*hdr48)); } else { /* We only want to filter the above, let other things pass */ + *con_type = NAT_CON_TYPE_OTHER; return 0; } } |