aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-12-10 12:27:00 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-12-10 13:22:46 +0100
commitd10a3c1b4abc8850a5275b83973c15573154f6ec (patch)
tree05ac9e4163a15fe01004f845e8d9ed21364ad05d
parent3aad776b280c889a5432e51fbdbe78ef1af624c9 (diff)
mtp: Attempt to fix the SCCP restart logic.
The SST is not necessary. We will have to assume the link is established after having gotten the TRA on the Affected Point Code and we will need to always handle the restart allowed.
-rw-r--r--src/mtp_layer3.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index 78db37c..d71e504 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -321,6 +321,9 @@ static int mtp_link_sign_msg(struct mtp_link *link, struct mtp_level_3_hdr *hdr,
return -1;
mtp_link_submit(link, msg);
+ link->sccp_up = 1;
+ link->was_up = 1;
+ LOGP(DINP, LOGL_INFO, "SCCP traffic allowed. %p\n", link);
return 0;
break;
}
@@ -405,6 +408,7 @@ static int mtp_link_sccp_data(struct mtp_link *link, struct mtp_level_3_hdr *hdr
{
struct msgb *out;
struct sccp_con_ctrl_prt_mgt *prt;
+ struct sccp_parse_result sccp;
msg->l2h = &hdr->data[0];
if (msgb_l2len(msg) != l3_len) {
@@ -412,36 +416,27 @@ static int mtp_link_sccp_data(struct mtp_link *link, struct mtp_level_3_hdr *hdr
return -1;
}
+ if (!link->sccp_up) {
+ LOGP(DINP, LOGL_ERROR, "SCCP traffic is not allowed.\n");
+ return -1;
+ }
- if (link->sccp_up) {
- mtp_link_forward_sccp(link, msg, MTP_LINK_SLS(hdr->addr));
- return 0;
- } else {
- struct sccp_parse_result sccp;
- memset(&sccp, 0, sizeof(sccp));
- if (sccp_parse_header(msg, &sccp) != 0) {
- LOGP(DINP, LOGL_ERROR, "Failed to parsed SCCP header.\n");
- return -1;
- }
-
- if (sccp_determine_msg_type(msg) != SCCP_MSG_TYPE_UDT) {
- LOGP(DINP, LOGL_ERROR, "Dropping sccp data: 0x%x\n",
- sccp_determine_msg_type(msg));
- return -1;
- }
+ memset(&sccp, 0, sizeof(sccp));
+ if (sccp_parse_header(msg, &sccp) != 0) {
+ LOGP(DINP, LOGL_ERROR, "Failed to parsed SCCP header.\n");
+ return -1;
+ }
+ /* check if it is a SST */
+ if (sccp_determine_msg_type(msg) == SCCP_MSG_TYPE_UDT
+ && msg->l3h[0] == SCCP_SST) {
if (msgb_l3len(msg) != 5) {
- LOGP(DINP, LOGL_ERROR, "SCCP UDT msg of unexpected size: %u\n",
+ LOGP(DINP, LOGL_ERROR,
+ "SCCP UDT msg of unexpected size: %u\n",
msgb_l3len(msg));
return -1;
}
- if (msg->l3h[0] != SCCP_SST) {
- LOGP(DINP, LOGL_ERROR, "Expected SCCP SST but got 0x%x\n",
- msg->l3h[0]);
- return -1;
- }
-
prt = (struct sccp_con_ctrl_prt_mgt *) &msg->l3h[0];
if (prt->assn != 254 || prt->apoc != MTP_MAKE_APOC(link->opc)) {
LOGP(DINP, LOGL_ERROR, "Unknown SSN/APOC assn: %u, apoc: %u/%u\n",
@@ -453,11 +448,11 @@ static int mtp_link_sccp_data(struct mtp_link *link, struct mtp_level_3_hdr *hdr
if (!out)
return -1;
- link->sccp_up = 1;
- link->was_up = 1;
- LOGP(DINP, LOGL_INFO, "SCCP is established. %p\n", link);
mtp_link_submit(link, out);
+ return 0;
}
+
+ mtp_link_forward_sccp(link, msg, MTP_LINK_SLS(hdr->addr));
return 0;
}