pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42536?usp=email )
Change subject: m3ua: m3ua_gen_error_msg(): include Routing Context IE in cause Invalid Routing Context ......................................................................
m3ua: m3ua_gen_error_msg(): include Routing Context IE in cause Invalid Routing Context
As per RFC4666 3.8.1: """ The "Invalid Routing Context" error is sent if a message is received from a peer with an invalid (unconfigured) Routing Context value. For this error, the invalid Routing Context(s) MUST be included in the Error message." """
Hence add the originating Routing Context IE so the error message can be further originated. For the same reason, also add the Diagnostic Information for the specific cases in the switch statement, and make them more robust about possible null pointer dereference.
Change-Id: If821109701e315d17f5334c680670ea6c7bce3bd --- M src/m3ua.c 1 file changed, 15 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/36/42536/1
diff --git a/src/m3ua.c b/src/m3ua.c index 3980bd3..368d4c3 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -383,7 +383,6 @@ { struct xua_msg *err = m3ua_gen_error(err_code); struct xua_msg *xua; - struct xua_msg_part *na_ie; unsigned int len_max_40;
if (!err) @@ -393,18 +392,26 @@ case M3UA_ERR_INVAL_NET_APPEAR: /* Include NA IE in Error message. */ xua = xua_from_msg(M3UA_VERSION, msgb_length(msg), msgb_data(msg)); - na_ie = xua_msg_find_tag(xua, M3UA_IEI_NET_APPEAR); - xua_msg_add_data(err, M3UA_IEI_NET_APPEAR, na_ie->len, na_ie->dat); + if (xua) + xua_msg_copy_part(err, M3UA_IEI_NET_APPEAR, xua, M3UA_IEI_NET_APPEAR); + xua_msg_free(xua); + break; + case M3UA_ERR_INVAL_ROUT_CTX: + /* Include Routing Context IE if available: */ + xua = xua_from_msg(M3UA_VERSION, msgb_length(msg), msgb_data(msg)); + if (xua) + xua_msg_copy_part(err, M3UA_IEI_ROUTE_CTX, xua, M3UA_IEI_ROUTE_CTX); xua_msg_free(xua); break; default: - len_max_40 = msgb_length(msg); - if (len_max_40 > 40) - len_max_40 = 40; - - xua_msg_add_data(err, M3UA_IEI_DIAG_INFO, len_max_40, msgb_data(msg)); }
+ len_max_40 = msgb_length(msg); + if (len_max_40 > 40) + len_max_40 = 40; + + xua_msg_add_data(err, M3UA_IEI_DIAG_INFO, len_max_40, msgb_data(msg)); + return err; }