From c3a6a1dbe5432e792103916291fd837ea96e0937 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 21 Apr 2010 15:38:16 +0800 Subject: [sccp] Parse the error message and add a unit test for it. --- openbsc/src/sccp/sccp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'openbsc/src') diff --git a/openbsc/src/sccp/sccp.c b/openbsc/src/sccp/sccp.c index e0fd02e0e..d869bfaeb 100644 --- a/openbsc/src/sccp/sccp.c +++ b/openbsc/src/sccp/sccp.c @@ -490,6 +490,23 @@ static int _sccp_parse_it(struct msgb *msgb, struct sccp_parse_result *result) return 0; } +static int _sccp_parse_err(struct msgb *msgb, struct sccp_parse_result *result) +{ + static const u_int32_t header_size = sizeof(struct sccp_proto_err); + + struct sccp_proto_err *err; + + if (msgb_l2len(msgb) < header_size) { + LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n", + msgb_l2len(msgb), header_size); + return -1; + } + + err = (struct sccp_proto_err *) msgb->l2h; + result->data_len = 0; + result->destination_local_reference = &err->destination_local_reference; + return 0; +} /* * Send UDT. Currently we have a fixed address... @@ -1318,6 +1335,9 @@ int sccp_parse_header(struct msgb *msg, struct sccp_parse_result *result) case SCCP_MSG_TYPE_IT: return _sccp_parse_it(msg, result); break; + case SCCP_MSG_TYPE_ERR: + return _sccp_parse_err(msg, result); + break; }; LOGP(DSCCP, LOGL_ERROR, "Unimplemented MSG Type: 0x%x\n", type); -- cgit v1.2.3