diff options
author | Stefan Sperling <ssperling@sysmocom.de> | 2018-02-22 17:20:16 +0100 |
---|---|---|
committer | Stefan Sperling <ssperling@sysmocom.de> | 2018-02-22 17:20:16 +0100 |
commit | 50fb6f9d64db5a8695cd793d9378eb4c90adf6d2 (patch) | |
tree | 2bbd8f7f278f3b97cb03f3e6e875176ad1e94b37 /src/hnbgw_hnbap.c | |
parent | cc6ed397a63df49316dde1fd5e2385ca83f51aaf (diff) |
destroy hnb context by sending a zero-len msgb after rejecting a HNBstsp/destroy_conn_with_zero_msg
These are the osmo-iuh changes corresponding to the libosmo-netif
branch 'destroy_conn_with_zero_msg'.
Change-Id: I15f90a2e899789320e9329e33b3d294a65cc16b6
Diffstat (limited to 'src/hnbgw_hnbap.c')
-rw-r--r-- | src/hnbgw_hnbap.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c index c9a8807..0d5cb96 100644 --- a/src/hnbgw_hnbap.c +++ b/src/hnbgw_hnbap.c @@ -53,7 +53,7 @@ static int hnbgw_tx_hnb_register_rej(struct hnb_context *ctx) { HNBRegisterReject_t reject_out; HNBRegisterRejectIEs_t reject; - struct msgb *msg; + struct msgb *msg, *msg0; int rc; reject.presenceMask = 0, @@ -69,6 +69,10 @@ static int hnbgw_tx_hnb_register_rej(struct hnb_context *ctx) return rc; } + msg0 = msgb_alloc(0, "zero-length terminating message"); + if (msg0 == NULL) + return -ENOMEM; + /* generate a successfull outcome PDU */ msg = hnbap_generate_unsuccessful_outcome(ProcedureCode_id_HNBRegister, Criticality_reject, @@ -77,7 +81,17 @@ static int hnbgw_tx_hnb_register_rej(struct hnb_context *ctx) ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBRegisterReject, &reject_out); - return hnbgw_hnbap_tx(ctx, msg); + rc = hnbgw_hnbap_tx(ctx, msg); + if (rc == 0) { + /* Enqueue a zero-length message to destroy the connection + * after sending HNB-REGISTER-REJECT. */ + if (hnbgw_hnbap_tx(ctx, msg0) != 0) + LOGP(DHNBAP, LOGL_ERROR, "Failure to send zero-length message after " + "HNB-REGISTER-REJECT to %s: rc=%d; the connection won't be closed " + "from our side\n", ctx->identity_info, rc); + } + + return rc; } static int hnbgw_tx_hnb_register_acc(struct hnb_context *ctx) @@ -393,7 +407,7 @@ static int hnbgw_rx_hnb_deregister(struct hnb_context *ctx, ANY_t *in) hnbap_cause_str(&ies.cause)); hnbap_free_hnbde_registeries(&ies); - hnb_context_release(ctx); + hnb_context_release(ctx, true); return 0; } |