Add SGs Interface

Add an SGs interface (3GPP TS 29.118) to osmo-msc in order to support
SMS tunneling and Circuit Switched Fallback (CSFB)

Change-Id: I73359925fc1ca72b33a1466e6ac41307f2f0b11d
Related: OS#3615
changes/42/11642/36
Harald Welte 4 years ago committed by Philipp Maier
parent c7de62cc53
commit 0df904dea9
  1. 4
      include/osmocom/msc/Makefile.am
  2. 1
      include/osmocom/msc/debug.h
  3. 1
      include/osmocom/msc/gsm_04_08.h
  4. 5
      include/osmocom/msc/gsm_subscriber.h
  5. 1
      include/osmocom/msc/ran_conn.h
  6. 87
      include/osmocom/msc/sgs_iface.h
  7. 53
      include/osmocom/msc/sgs_server.h
  8. 23
      include/osmocom/msc/sgs_vty.h
  9. 13
      include/osmocom/msc/vlr.h
  10. 107
      include/osmocom/msc/vlr_sgs.h
  11. 1
      include/osmocom/msc/vty.h
  12. 4
      src/libmsc/Makefile.am
  13. 19
      src/libmsc/gsm_04_08.c
  14. 3
      src/libmsc/gsm_04_08_cc.c
  15. 4
      src/libmsc/gsm_04_11.c
  16. 3
      src/libmsc/gsm_09_11.c
  17. 12
      src/libmsc/gsm_subscriber.c
  18. 5
      src/libmsc/msc_ifaces.c
  19. 16
      src/libmsc/msc_vty.c
  20. 24
      src/libmsc/ran_conn.c
  21. 1265
      src/libmsc/sgs_iface.c
  22. 187
      src/libmsc/sgs_server.c
  23. 197
      src/libmsc/sgs_vty.c
  24. 3
      src/libmsc/silent_call.c
  25. 4
      src/libvlr/Makefile.am
  26. 52
      src/libvlr/vlr.c
  27. 7
      src/libvlr/vlr_lu_fsm.c
  28. 331
      src/libvlr/vlr_sgs.c
  29. 386
      src/libvlr/vlr_sgs_fsm.c
  30. 42
      src/libvlr/vlr_sgs_fsm.h
  31. 3
      src/osmo-msc/Makefile.am
  32. 8
      src/osmo-msc/msc_main.c
  33. 1
      tests/msc_vlr/Makefile.am
  34. 1
      tests/msc_vlr/msc_vlr_test_authen_reuse.c
  35. 1
      tests/msc_vlr/msc_vlr_test_call.c
  36. 1
      tests/msc_vlr/msc_vlr_test_gsm_authen.c
  37. 1
      tests/msc_vlr/msc_vlr_test_gsm_ciph.c
  38. 1
      tests/msc_vlr/msc_vlr_test_hlr_reject.c
  39. 1
      tests/msc_vlr/msc_vlr_test_hlr_timeout.c
  40. 1
      tests/msc_vlr/msc_vlr_test_ms_timeout.c
  41. 1
      tests/msc_vlr/msc_vlr_test_no_authen.c
  42. 1
      tests/msc_vlr/msc_vlr_test_reject_concurrency.c
  43. 1
      tests/msc_vlr/msc_vlr_test_rest.c
  44. 1
      tests/msc_vlr/msc_vlr_test_ss.c
  45. 1
      tests/msc_vlr/msc_vlr_test_umts_authen.c
  46. 40
      tests/msc_vlr/stubs.h
  47. 21
      tests/sms_queue/sms_queue_test.c
  48. 16
      tests/test_nodes.vty

@ -23,11 +23,15 @@ noinst_HEADERS = \
a_reset.h \
ran_conn.h \
rrlp.h \
sgs_iface.h \
sgs_server.h \
sgs_vty.h \
signal.h \
silent_call.h \
smpp.h \
sms_queue.h \
transaction.h \
vlr.h \
vlr_sgs.h \
vty.h \
$(NULL)

@ -21,5 +21,6 @@ enum {
DVLR,
DIUCS,
DBSSAP,
DSGS,
Debug_LastEntry,
};

@ -77,5 +77,6 @@ int gsm48_multirate_config(uint8_t *lv, const struct amr_multirate_conf *mr, con
int gsm48_tch_rtp_create(struct gsm_trans *trans);
int gsm48_conn_sendmsg(struct msgb *msg, struct ran_conn *conn, struct gsm_trans *trans);
struct msgb *gsm48_create_mm_info(struct gsm_network *net);
#endif

@ -5,6 +5,7 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/gsm/protocol/gsm_29_118.h>
#include <osmocom/msc/gsm_data.h>
@ -36,8 +37,8 @@ struct subscr_request {
*/
struct subscr_request *subscr_request_conn(struct vlr_subscr *vsub,
gsm_cbfn *cbfn, void *param,
const char *label);
const char *label,
enum sgsap_service_ind serv_ind);
void subscr_remove_request(struct subscr_request *req);
void subscr_paging_cancel(struct vlr_subscr *vsub, enum gsm_paging_event event);

@ -208,6 +208,7 @@ bool ran_conn_in_release(struct ran_conn *conn);
void ran_conn_rx_bssmap_clear_complete(struct ran_conn *conn);
void ran_conn_rx_iu_release_complete(struct ran_conn *conn);
void ran_conn_sgs_release_sent(struct ran_conn *conn);
enum ran_conn_use {
RAN_CONN_USE_UNTRACKED = -1,

@ -0,0 +1,87 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/gsm/protocol/gsm_29_118.h>
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/vlr_sgs.h>
#include <osmocom/core/socket.h>
static const unsigned int sgs_state_timer_defaults[_NUM_SGS_STATE_TIMERS] = {
[SGS_STATE_TS5] = SGS_TS5_DEFAULT,
[SGS_STATE_TS6_2] = SGS_TS6_2_DEFAULT,
[SGS_STATE_TS7] = SGS_TS7_DEFAULT,
[SGS_STATE_TS11] = SGS_TS11_DEFAULT,
[SGS_STATE_TS14] = SGS_TS14_DEFAULT,
[SGS_STATE_TS15] = SGS_TS15_DEFAULT,
};
static const unsigned int sgs_state_counter_defaults[_NUM_SGS_STATE_COUNTERS] = {
[SGS_STATE_NS7] = SGS_NS7_DEFAULT,
[SGS_STATE_NS11] = SGS_NS11_DEFAULT,
};
struct sgs_connection {
/* global list of SGs connections */
struct llist_head entry;
/* back-pointer */
struct sgs_state *sgs;
/* Socket name from osmo_sock_get_name() */
char sockname[OSMO_SOCK_NAME_MAXLEN];
/* MME for this connection, if any. This field is NULL until we
* receive the first "MME name" IE from the MME, which could be part
* of the RESET procedure, but also just a normal LU request. */
struct sgs_mme_ctx *mme;
/* represents the SCTP connection we accept()ed from this MME */
struct osmo_stream_srv *srv;
};
struct sgs_mme_ctx {
/* global list of MME contexts */
struct llist_head entry;
/* back-pointer */
struct sgs_state *sgs;
/* MME name as string representation */
char fqdn[GSM23003_MME_DOMAIN_LEN + 1];
/* current connection for this MME, if any. Can be NULL if the SCTP
* connection to the MME was lost and hasn't been re-established yet */
struct sgs_connection *conn;
/* FSM for the "VLR reset" procedure" */
struct osmo_fsm_inst *fi;
unsigned int ns11_remaining;
};
extern struct sgs_state *g_sgs;
struct sgs_state *sgs_iface_init(void *ctx, struct gsm_network *network);
int sgs_iface_rx(struct sgs_connection *sgc, struct msgb *msg);
int sgs_iface_tx_paging(struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind);
int sgs_iface_tx_dtap_ud(struct msgb *msg);
void sgs_iface_tx_release(struct ran_conn *conn);

@ -0,0 +1,53 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <arpa/inet.h>
#include <osmocom/gsm/protocol/gsm_29_118.h>
#define DEFAULT_SGS_SERVER_IP "0.0.0.0"
#define DEFAULT_SGS_SERVER_VLR_NAME "vlr.example.net"
/* global SGs state */
struct sgs_state {
/* list of MMEs (sgs_mme_ctx) */
struct llist_head mme_list;
/* list of SCTP client connections */
struct llist_head conn_list;
/* SCTP server for inbound SGs connections */
struct osmo_stream_srv_link *srv_link;
struct {
char local_addr[INET6_ADDRSTRLEN];
uint16_t local_port;
/* user-configured VLR name (FQDN) */
char vlr_name[SGS_VLR_NAME_MAXLEN];
/* timers on VLR side */
unsigned int timer[_NUM_SGS_STATE_TIMERS];
/* countrs on VLR side */
unsigned int counter[_NUM_SGS_STATE_COUNTERS];
} cfg;
};
struct sgs_state *sgs_server_alloc(void *ctx);
int sgs_server_open(struct sgs_state *sgs);

@ -0,0 +1,23 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
void sgs_vty_init(void);

@ -13,6 +13,7 @@
#include <osmocom/msc/ran_conn.h>
#include <osmocom/msc/msc_common.h>
#include <osmocom/gsupclient/gsup_client.h>
#include <osmocom/msc/vlr_sgs.h>
#define LOGGSUPP(level, gsup, fmt, args...) \
LOGP(DVLR, level, "GSUP(%s) " fmt, (gsup)->imsi, ## args)
@ -162,6 +163,7 @@ struct vlr_subscr {
struct osmo_fsm_inst *lu_fsm;
struct osmo_fsm_inst *auth_fsm;
struct osmo_fsm_inst *proc_arq_fsm;
struct osmo_fsm_inst *sgs_fsm;
bool lu_complete;
time_t expire_lu;
@ -182,6 +184,17 @@ struct vlr_subscr {
uint8_t lac;
enum osmo_rat_type attached_via_ran;
} cs;
/* SGs (MME) specific parts */
struct {
struct vlr_sgs_cfg cfg;
char mme_name[SGS_MME_NAME_LEN + 1];
struct osmo_location_area_id lai;
vlr_sgs_lu_response_cb_t response_cb;
vlr_sgs_lu_paging_cb_t paging_cb;
vlr_sgs_lu_mminfo_cb_t mminfo_cb;
enum sgsap_service_ind paging_serv_ind;
struct osmo_timer_list Ts5;
} sgs;
struct gsm_classmark classmark;
};

@ -0,0 +1,107 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/gsm/gsm29118.h>
enum vlr_lu_type;
struct vlr_subscr;
struct vlr_instance;
/* See also 3GPP TS 29.118, chapter 4.2.2 States at the VLR */
enum sgs_ue_fsm_state {
SGS_UE_ST_NULL,
SGS_UE_ST_ASSOCIATED,
SGS_UE_ST_LA_UPD_PRES,
};
enum vlr_sgs_state_tmr {
/* Started when sending the SGsAP-PAGING-REQUEST, implemented in vlr_sgs.c */
SGS_STATE_TS5,
/* TMSI reallocation, 5.2.3.5, implemented by fsm in vlr_sgs_fsm.c */
SGS_STATE_TS6_2,
/* Started when SGsAP-ALERT-REQUEST is sent 5.3.2.1, not implemented yet */
SGS_STATE_TS7,
/* Reset ack timeout, implemnted in sgs_iface.c */
SGS_STATE_TS11,
/* Started when SGsAP-SERVICE-REQUEST is received 5.15.1, not implemented yet */
SGS_STATE_TS14,
/* Started when SGsAP-MO-CSFB-INDICATION is received 5.16.3 (UE fallback, not implemented yet) */
SGS_STATE_TS15,
_NUM_SGS_STATE_TIMERS
};
enum vlr_sgs_state_ctr {
/* Alert request retransmit count */
SGS_STATE_NS7,
/* Reset repeat count */
SGS_STATE_NS11,
_NUM_SGS_STATE_COUNTERS
};
extern const struct value_string sgs_state_timer_names[];
static inline const char *vlr_sgs_state_timer_name(enum vlr_sgs_state_tmr Ts)
{
return get_value_string(sgs_state_timer_names, Ts);
}
extern const struct value_string sgs_state_counter_names[];
static inline const char *vlr_sgs_state_counter_name(enum vlr_sgs_state_ctr Ns)
{
return get_value_string(sgs_state_timer_names, Ns);
}
/* This callback function is called when an SGs location update is complete */
struct sgs_lu_response {
bool accepted;
struct vlr_subscr *vsub;
};
typedef void (*vlr_sgs_lu_response_cb_t) (struct sgs_lu_response *response);
/* This callback function is called in cases where a paging request is required
* after the LU is completed */
typedef int (*vlr_sgs_lu_paging_cb_t) (struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind);
/* This callback function is called to send the MM info to the UE. */
typedef void (*vlr_sgs_lu_mminfo_cb_t) (struct vlr_subscr *vsub);
/* Configuration parameters for the SGs FSM */
struct vlr_sgs_cfg {
unsigned int timer[_NUM_SGS_STATE_TIMERS];
unsigned int counter[_NUM_SGS_STATE_COUNTERS];
};
void vlr_sgs_reset(struct vlr_instance *vlr);
int vlr_sgs_loc_update(struct vlr_instance *vlr, struct vlr_sgs_cfg *cfg,
vlr_sgs_lu_response_cb_t response_cb, vlr_sgs_lu_paging_cb_t paging_cb,
vlr_sgs_lu_mminfo_cb_t mminfo_cb, char *mme_name, enum vlr_lu_type type, const char *imsi,
struct osmo_location_area_id *new_lai);
void vlr_sgs_loc_update_acc_sent(struct vlr_subscr *vsub);
void vlr_sgs_loc_update_rej_sent(struct vlr_subscr *vsub);
void vlr_sgs_detach(struct vlr_instance *vlr, const char *imsi, bool eps);
void vlr_sgs_imsi_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_noneps_type type);
void vlr_sgs_eps_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_eps_type type);
void vlr_sgs_tmsi_reall_compl(struct vlr_instance *vlr, const char *imsi);
void vlr_sgs_pag_rej(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause);
void vlr_sgs_pag_ack(struct vlr_instance *vlr, const char *imsi);
void vlr_sgs_ue_unr(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause);
void vlr_sgs_pag(struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind);
bool vlr_sgs_pag_pend(struct vlr_subscr *vsub);

@ -23,6 +23,7 @@ enum bsc_vty_node {
SMPP_NODE,
SMPP_ESME_NODE,
HLR_NODE,
CFG_SGS_NODE,
};
int bsc_vty_init_extra(void);

@ -17,6 +17,7 @@ AM_CFLAGS = \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(LIBOSMORANAP_CFLAGS) \
$(LIBOSMONETIF_CFLAGS) \
$(NULL)
noinst_HEADERS = \
@ -52,6 +53,9 @@ libmsc_a_SOURCES = \
transaction.c \
osmo_msc.c \
ctrl_commands.c \
sgs_iface.c \
sgs_server.c \
sgs_vty.c \
$(NULL)
if BUILD_IU
libmsc_a_SOURCES += \

@ -469,13 +469,12 @@ static uint8_t bcdify(uint8_t value)
return ret;
}
/* Section 9.2.15a */
int gsm48_tx_mm_info(struct ran_conn *conn)
/* Generate a message buffer that contains a valid MM info message,
* See also 3GPP TS 24.008, chapter 9.2.15a */
struct msgb *gsm48_create_mm_info(struct gsm_network *net)
{
struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 MM INF");
struct gsm48_hdr *gh;
struct gsm_network *net = conn->network;
uint8_t *ptr8;
int name_len, name_pad;
@ -617,8 +616,18 @@ int gsm48_tx_mm_info(struct ran_conn *conn)
ptr8[2] = dst;
}
LOG_RAN_CONN(conn, LOGL_DEBUG, "Tx MM INFO\n");
return msg;
}
/* Section 9.2.15a */
int gsm48_tx_mm_info(struct ran_conn *conn)
{
struct gsm_network *net = conn->network;
struct msgb *msg;
msg = gsm48_create_mm_info(net);
LOG_RAN_CONN(conn, LOGL_DEBUG, "Tx MM INFO\n");
return gsm48_conn_sendmsg(msg, conn, NULL);
}

@ -1969,7 +1969,8 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
vsub,
setup_trig_pag_evt,
trans,
"MNCC: establish call");
"MNCC: establish call",
SGSAP_SERV_IND_CS_CALL);
if (!trans->paging_request) {
LOGP(DCC, LOGL_ERROR, "Failed to allocate paging token.\n");
vlr_subscr_put(vsub);

@ -193,7 +193,9 @@ static int gsm411_mmsms_est_req(struct gsm_trans *trans)
LOGP(DLSMS, LOGL_DEBUG, "Initiating Paging procedure "
"for %s due to MMSMS_EST_REQ\n", vlr_subscr_name(trans->vsub));
trans->paging_request = subscr_request_conn(trans->vsub,
paging_cb_mmsms_est_req, trans, "MT SMS");
paging_cb_mmsms_est_req,
trans, "MT SMS",
SGSAP_SERV_IND_SMS);
if (!trans->paging_request) {
LOGP(DLSMS, LOGL_ERROR, "Failed to initiate Paging "
"procedure for %s\n", vlr_subscr_name(trans->vsub));

@ -343,7 +343,8 @@ static struct gsm_trans *establish_nc_ss_trans(struct gsm_network *net,
/* Trigger Paging Request */
trans->paging_request = subscr_request_conn(vsub,
&handle_paging_event, trans, "GSM 09.11 SS/USSD");
&handle_paging_event, trans, "GSM 09.11 SS/USSD",
SGSAP_SERV_IND_CS_CALL);
if (!trans->paging_request) {
LOGP(DMM, LOGL_ERROR, "Failed to allocate paging token\n");
trans_free(trans);

@ -48,6 +48,7 @@
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/msc_ifaces.h>
#include <osmocom/msc/a_iface.h>
#include <osmocom/msc/sgs_iface.h>
void subscr_paging_cancel(struct vlr_subscr *vsub, enum gsm_paging_event event)
{
@ -109,7 +110,9 @@ int subscr_paging_dispatch(unsigned int hooknum, unsigned int event,
return 0;
}
static int msc_paging_request(struct vlr_subscr *vsub)
/* Execute a paging on the currently active RAN. Returns the number of
* delivered paging requests or -EINVAL in case of failure. */
static int msc_paging_request(struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind)
{
/* The subscriber was last seen in subscr->lac. Find out which
* BSCs/RNCs are responsible and send them a paging request via open
@ -122,6 +125,8 @@ static int msc_paging_request(struct vlr_subscr *vsub)
vsub->tmsi == GSM_RESERVED_TMSI?
NULL : &vsub->tmsi,
vsub->cgi.lai.lac);
case OSMO_RAT_EUTRAN_SGS:
return sgs_iface_tx_paging(vsub, serv_ind);
default:
break;
}
@ -142,10 +147,11 @@ static void paging_response_timer_cb(void *data)
* \param cbfn function to call when the conn is established.
* \param param caller defined param to pass to cbfn().
* \param label human readable label of the request kind used for logging.
* \param serv_ind sgsap service indicator (in case SGs interface is used to page).
*/
struct subscr_request *subscr_request_conn(struct vlr_subscr *vsub,
gsm_cbfn *cbfn, void *param,
const char *label)
const char *label, enum sgsap_service_ind serv_ind)
{
int rc;
struct subscr_request *request;
@ -155,7 +161,7 @@ struct subscr_request *subscr_request_conn(struct vlr_subscr *vsub,
if (!vsub->cs.is_paging) {
LOGP(DMM, LOGL_DEBUG, "Subscriber %s not paged yet, start paging.\n",
vlr_subscr_name(vsub));
rc = msc_paging_request(vsub);
rc = msc_paging_request(vsub, serv_ind);
if (rc <= 0) {
LOGP(DMM, LOGL_ERROR, "Subscriber %s paging failed: %d\n",
vlr_subscr_name(vsub), rc);

@ -28,6 +28,7 @@
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/a_iface.h>
#include <osmocom/msc/sgs_iface.h>
#include <osmocom/msc/gsm_04_08.h>
#include <osmocom/msc/msc_mgcp.h>
@ -60,6 +61,10 @@ static int msc_tx(struct ran_conn *conn, struct msgb *msg)
msg->dst = conn->iu.ue_ctx;
return ranap_iu_tx(msg, 0);
case OSMO_RAT_EUTRAN_SGS:
msg->dst = conn;
return sgs_iface_tx_dtap_ud(msg);
default:
LOGP(DMSC, LOGL_ERROR,
"msc_tx(): conn->via_ran invalid (%d)\n",

@ -56,6 +56,8 @@
#include <osmocom/msc/signal.h>
#include <osmocom/msc/mncc_int.h>
#include <osmocom/msc/rrlp.h>
#include <osmocom/msc/vlr_sgs.h>
#include <osmocom/msc/sgs_vty.h>
static struct gsm_network *gsmnet = NULL;
@ -565,7 +567,7 @@ static void vty_dump_one_conn(struct vty *vty, const struct ran_conn *conn)
{
vty_out(vty, "%08x %3s %5u %3u %08x %c /%1u %27s %22s%s",
conn->a.conn_id,
conn->via_ran == OSMO_RAT_UTRAN_IU ? "Iu" : "A",
osmo_rat_type_name(conn->via_ran),
conn->lac,
conn->use_count,
conn->use_tokens,
@ -729,6 +731,15 @@ static void subscr_dump_full_vty(struct vty *vty, struct vlr_subscr *vsub)
reqs += 1;
vty_out(vty, " Paging: %s paging for %d requests%s",
vsub->cs.is_paging ? "is" : "not", reqs, VTY_NEWLINE);
/* SGs related */
vty_out(vty, " SGs-state: %s%s",
osmo_fsm_inst_state_name(vsub->sgs_fsm), VTY_NEWLINE);
if (vsub->sgs.mme_name && strlen(vsub->sgs.mme_name))
vty_out(vty, " SGs-MME: %s%s", vsub->sgs.mme_name, VTY_NEWLINE);
else
vty_out(vty, " SGs-MME: (none)%s", VTY_NEWLINE);
vty_out(vty, " Use count: %u%s", vsub->use_count, VTY_NEWLINE);
/* Connection */
@ -1159,7 +1170,7 @@ DEFUN(subscriber_paging,
return CMD_WARNING;
}
req = subscr_request_conn(vsub, NULL, NULL, "manual Paging from VTY");
req = subscr_request_conn(vsub, NULL, NULL, "manual Paging from VTY", SGSAP_SERV_IND_CS_CALL);
if (req)
vty_out(vty, "%% paging subscriber%s", VTY_NEWLINE);
else
@ -1590,6 +1601,7 @@ void msc_vty_init(struct gsm_network *msc_network)
#ifdef BUILD_IU
ranap_iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc);
#endif
sgs_vty_init();
osmo_fsm_vty_add_cmds();
osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL);

@ -31,6 +31,7 @@
#include <osmocom/msc/transaction.h>
#include <osmocom/msc/signal.h>
#include <osmocom/msc/a_iface.h>
#include <osmocom/msc/sgs_iface.h>
#include <osmocom/msc/iucs.h>
#include "../../bscconfig.h"
@ -338,6 +339,13 @@ static void ran_conn_fsm_releasing_onenter(struct osmo_fsm_inst *fi, uint32_t pr
{
struct ran_conn *conn = fi->priv;
/* The SGs interface needs to access vsub struct members to send the
* release message, however the following release procedures will
* remove conn->vsub, so we need to send the release right now. */
if (conn->via_ran == OSMO_RAT_EUTRAN_SGS) {
sgs_iface_tx_release(conn);
}
/* Use count for either conn->a.waiting_for_clear_complete or
* conn->iu.waiting_for_release_complete. 'get' it early, so we don't deallocate after tearing
* down active transactions. Safeguard against double-get (though it shouldn't happen). */
@ -381,6 +389,12 @@ static void ran_conn_fsm_releasing_onenter(struct osmo_fsm_inst *fi, uint32_t pr
}
conn->iu.waiting_for_release_complete = true;
break;
case OSMO_RAT_EUTRAN_SGS:
/* Release message is already sent at the beginning of this
* functions (see above), but we still need to notify the
* conn that a release has been sent / is in progress. */
ran_conn_sgs_release_sent(conn);
break;
default:
LOGP(DMM, LOGL_ERROR, "%s: Unknown RAN type, cannot tx release/clear\n",
vlr_subscr_name(conn->vsub));
@ -667,6 +681,8 @@ struct ran_conn *ran_conn_alloc(struct gsm_network *network,
case OSMO_RAT_UTRAN_IU:
conn->log_subsys = DRANAP;
break;
case OSMO_RAT_EUTRAN_SGS:
conn->log_subsys = DSGS;
default:
conn->log_subsys = DMSC;
break;
@ -772,3 +788,11 @@ void ran_conn_rx_iu_release_complete(struct ran_conn *conn)
{
rx_close_complete(conn, "Iu Release Complete", &conn->iu.waiting_for_release_complete);
}
void ran_conn_sgs_release_sent(struct ran_conn *conn)
{
bool dummy_waiting_for_release_complete = true;
/* Note: In SGsAP there is no confirmation of a release. */
rx_close_complete(conn, "SGs Release Complete", &dummy_waiting_for_release_complete);
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,187 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <osmocom/msc/sgs_iface.h>
#include <osmocom/msc/debug.h>
#include <osmocom/msc/sgs_server.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/select.h>
#include <osmocom/netif/stream.h>
#include <netinet/sctp.h>
#define LOGSGC(sgc, lvl, fmt, args...) \
LOGP(DSGS, lvl, "%s: " fmt, (sgc)->sockname, ## args)
/* call-back when data arrives on SGs */
static int sgs_conn_readable_cb(struct osmo_stream_srv *conn)
{
struct osmo_fd *ofd = osmo_stream_srv_get_ofd(conn);
struct sgs_connection *sgc = osmo_stream_srv_get_data(conn);
struct msgb *msg = gsm29118_msgb_alloc();
struct sctp_sndrcvinfo sinfo;
int flags = 0;
int rc;
/* we cannot use osmo_stream_srv_recv() here, as we might get some out-of-band info from
* SCTP. FIXME: add something like osmo_stream_srv_recv_sctp() to libosmo-netif and use
* it here as well as in libosmo-sigtran */
rc = sctp_recvmsg(ofd->fd, msgb_data(msg), msgb_tailroom(msg), NULL, NULL, &sinfo, &flags);
if (rc < 0) {
osmo_stream_srv_destroy(conn);
rc = -EBADF;
goto out;
} else if (rc == 0) {
osmo_stream_srv_destroy(conn);
rc = -EBADF;
goto out;
} else {
msgb_put(msg, rc);
}
if (flags & MSG_NOTIFICATION) {
union sctp_notification *notif = (union sctp_notification *)msgb_data(msg);
switch (notif->sn_header.sn_type) {
case SCTP_SHUTDOWN_EVENT:
osmo_stream_srv_destroy(conn);
rc = -EBADF;
break;
case SCTP_ASSOC_CHANGE:
/* FIXME: do we have to notify the SGs code about this? */
break;
default:
break;
}
rc = 0;
goto out;
}
/* set l2 header, as that's what we use in SGs code */
msg->l2h = msgb_data(msg);
if (msgb_sctp_ppid(msg) != 0) {
LOGSGC(sgc, LOGL_NOTICE, "Ignoring SCTP PPID %ld (spec violation)\n", msgb_sctp_ppid(msg));
msgb_free(msg);
return 0;
}
/* handle message */
sgs_iface_rx(sgc, msg);
return 0;
out:
msgb_free(msg);
return rc;
}
/* call-back when new connection is closed ed on SGs */
static int sgs_conn_closed_cb(struct osmo_stream_srv *conn)
{
struct sgs_connection *sgc = osmo_stream_srv_get_data(conn);
LOGSGC(sgc, LOGL_NOTICE, "Connection lost\n");
if (sgc->mme) {
/* unlink ourselves from the MME context */
if (sgc->mme->conn == sgc)
sgc->mme->conn = NULL;
}
llist_del(&sgc->entry);
return 0;
}
/* call-back when new connection is accept() ed on SGs */
static int sgs_accept_cb(struct osmo_stream_srv_link *link, int fd)
{
struct sgs_state *sgs = osmo_stream_srv_link_get_data(link);
struct sgs_connection *sgc = talloc_zero(link, struct sgs_connection);
OSMO_ASSERT(sgc);
sgc->sgs = sgs;
osmo_sock_get_name_buf(sgc->sockname, sizeof(sgc->sockname), fd);
sgc->srv = osmo_stream_srv_create(sgc, link, fd, sgs_conn_readable_cb, sgs_conn_closed_cb, sgc);
if (!sgc->srv) {
talloc_free(sgc);
return -1;
}
LOGSGC(sgc, LOGL_INFO, "Accepted new SGs connection\n");
llist_add_tail(&sgc->entry, &sgs->conn_list);
return 0;
}
static struct sgs_state *sgs_state_alloc(void *ctx)
{
struct sgs_state *sgs = talloc_zero(ctx, struct sgs_state);
INIT_LLIST_HEAD(&sgs->mme_list);
INIT_LLIST_HEAD(&sgs->conn_list);
memcpy(sgs->cfg.timer, sgs_state_timer_defaults, sizeof(sgs->cfg.timer));
memcpy(sgs->cfg.counter, sgs_state_counter_defaults, sizeof(sgs->cfg.counter));
sgs->cfg.local_port = SGS_PORT_DEFAULT;
osmo_strlcpy(sgs->cfg.local_addr, DEFAULT_SGS_SERVER_IP, sizeof(sgs->cfg.local_addr));
osmo_strlcpy(sgs->cfg.vlr_name, DEFAULT_SGS_SERVER_VLR_NAME, sizeof(sgs->cfg.vlr_name));
return sgs;
}
/*! allocate SGs new sgs state
* \param[in] ctx talloc context
* \returns returns allocated sgs state, NULL in case of error. */
struct sgs_state *sgs_server_alloc(void *ctx)
{
struct sgs_state *sgs;
struct osmo_stream_srv_link *link;
sgs = sgs_state_alloc(ctx);
if (!sgs)
return NULL;
sgs->srv_link = link = osmo_stream_srv_link_create(ctx);
if (!sgs->srv_link)
return NULL;
osmo_stream_srv_link_set_nodelay(link, true);
osmo_stream_srv_link_set_addr(link, sgs->cfg.local_addr);
osmo_stream_srv_link_set_port(link, sgs->cfg.local_port);
osmo_stream_srv_link_set_proto(link, IPPROTO_SCTP);
osmo_stream_srv_link_set_data(link, sgs);
osmo_stream_srv_link_set_accept_cb(link, sgs_accept_cb);
return sgs;
}
/*! (re)open SGs interface (SCTP)
* \param[in] sgs associated sgs state
* \returns 0 in case of success, -EINVAL in case of error. */
int sgs_server_open(struct sgs_state *sgs)
{
int rc;
struct osmo_fd *ofd = osmo_stream_srv_link_get_ofd(sgs->srv_link);
rc = osmo_stream_srv_link_open(sgs->srv_link);
if (rc < 0) {
LOGP(DSGS, LOGL_ERROR, "SGs socket cannot be opened: %s\n", strerror(errno));
return -EINVAL;
}
LOGP(DSGS, LOGL_NOTICE, "SGs socket bound to %s\n", osmo_sock_get_name2(ofd->fd));
return 0;
}

@ -0,0 +1,197 @@
/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Harald Welte, Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <string.h>
#include <errno.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h>
#include <osmocom/msc/vty.h>
#include <osmocom/netif/stream.h>
#include <osmocom/msc/sgs_iface.h>
#include <osmocom/msc/sgs_server.h>
#include <osmocom/msc/debug.h>
#include <osmocom/gsm/tlv.h>
struct cmd_node cfg_sgs_node = {
CFG_SGS_NODE,
"%s(config-sgs)# ",
1
};
DEFUN(cfg_sgs, cfg_sgs_cmd,
"sgs",
"Configure the SGs interface\n")
{
vty->index = g_sgs;
vty->node = CFG_SGS_NODE;
return CMD_SUCCESS;
}
DEFUN(cfg_sgs_local_ip, cfg_sgs_local_ip_cmd,
"local-ip A.B.C.D",
"Set the Local IP Address of the SGs interface\n"
"Local IP Address of the SGs interface\n")
{
struct sgs_state *sgs = vty->index;
int rc;
osmo_strlcpy(sgs->cfg.local_addr, argv[0], sizeof(sgs->cfg.local_addr));
osmo_stream_srv_link_set_addr(sgs->srv_link, sgs->cfg.local_addr);
rc = sgs_server_open(sgs);
if (rc < 0) {
vty_out(vty, "%% SGs socket cannot be opened: %s%s", strerror(errno), VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
DEFUN(cfg_sgs_local_port, cfg_sgs_local_port_cmd,
"local-port <0-65535>",
"Set the local SCTP port of the SGs interface\n"
"Local SCTP port of the SGs interface\n")
{
struct sgs_state *sgs = vty->index;
int rc;
sgs->cfg.local_port = atoi(argv[0]);
osmo_stream_srv_link_set_port(sgs->srv_link, sgs->cfg.local_port);
rc = sgs_server_open(sgs);
if (rc < 0) {
vty_out(vty, "%% SGs socket cannot be opened: %s%s", strerror(errno), VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
DEFUN(cfg_sgs_vlr_name, cfg_sgs_vlr_name_cmd,
"vlr-name FQDN",
"Set the SGs VLR Name as per TS 29.118 9.4.22\n"
"Fully-Qualified Domain Name of this VLR\n")
{
struct sgs_state *sgs = vty->index;
osmo_strlcpy(sgs->cfg.vlr_name, argv[0], sizeof(sgs->cfg.vlr_name));
return CMD_SUCCESS;
}
DEFUN(cfg_sgs_timer, cfg_sgs_timer_cmd,
"timer (ts5|ts6-2|ts7|ts11|ts14|ts15) <1-120>",
"Configure SGs Timer\n"
"Paging procedure guard timer\n"
"TMSI reallocation guard timer\n"
"Non-EPS alert procedure guard timer\n"
"VLR reset guard timer\n"
"UE fallback prcoedure timer\n"
"MO UE fallback procedure guard timer\n"
"Time in seconds\n")
{
struct sgs_state *sgs = vty->index;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(sgs->cfg.timer); i++) {
if (!strcasecmp(argv[0], vlr_sgs_state_timer_name(i))) {
sgs->cfg.timer[i] = atoi(argv[1]);
return CMD_SUCCESS;
}
}
return CMD_WARNING;
}
DEFUN(cfg_sgs_counter, cfg_sgs_counter_cmd,
"counter (ns7|ns11) <0-255>",
"Configure SGs Counter\n"
"Non-EPS alert request retry counter\n"
"VLR reset retry counter\n" "Counter value\n")
{
struct sgs_state *sgs = vty->index;
unsigned int i = 0;
for (i = 0; i < ARRAY_SIZE(sgs->cfg.counter); i++) {
if (!strcasecmp(argv[0], vlr_sgs_state_counter_name(i))) {
sgs->cfg.counter[i] = atoi(argv[1]);
return CMD_SUCCESS;
}
}
return CMD_WARNING;
}
DEFUN(show_sgs_conn, show_sgs_conn_cmd,
"show sgs-connections", SHOW_STR
"Show SGs interface connections / MMEs\n")
{
struct sgs_connection *sgc;
llist_for_each_entry(sgc, &g_sgs->conn_list, entry) {
vty_out(vty, " %s %s%s", sgc->sockname, sgc->mme ? sgc->mme->fqdn : "", VTY_NEWLINE);
}
return CMD_SUCCESS;
}
static int config_write_sgs(struct vty *vty)
{
struct sgs_state *sgs = g_sgs;
unsigned int i;
char str_buf[256];
vty_out(vty, "sgs%s", VTY_NEWLINE);
if (sgs->cfg.local_port != SGS_PORT_DEFAULT)
vty_out(vty, " local-port %u%s", sgs->cfg.local_port, VTY_NEWLINE);
if (sgs->cfg.local_addr)
vty_out(vty, " local-ip %s%s", sgs->cfg.local_addr, VTY_NEWLINE);
if (sgs->cfg.vlr_name)
vty_out(vty, " vlr-name %s%s", sgs->cfg.vlr_name, VTY_NEWLINE);
for (i = 0; i < ARRAY_SIZE(sgs->cfg.timer); i++) {
if (sgs->cfg.timer[i] == sgs_state_timer_defaults[i])
continue;
osmo_str_tolower_buf(str_buf, sizeof(str_buf), vlr_sgs_state_timer_name(i));
vty_out(vty, " timer %s %u%s", str_buf, sgs->cfg.timer[i], VTY_NEWLINE);
}
for (i = 0; i < ARRAY_SIZE(sgs->cfg.counter); i++) {
if (sgs->cfg.counter[i] == sgs_state_counter_defaults[i])
continue;
osmo_str_tolower_buf(str_buf, sizeof(str_buf), vlr_sgs_state_counter_name(i));
vty_out(vty, " counter %s %u%s", str_buf, sgs->cfg.counter[i], VTY_NEWLINE);
}
return CMD_SUCCESS;
}
void sgs_vty_init(void)
{
/* configuration commands / nodes */
install_element(CONFIG_NODE, &cfg_sgs_cmd);
install_node(&cfg_sgs_node, config_write_sgs);
install_element(CFG_SGS_NODE, &cfg_sgs_local_ip_cmd);
install_element(CFG_SGS_NODE, &cfg_sgs_local_port_cmd);
install_element(CFG_SGS_NODE, &cfg_sgs_timer_cmd);
install_element(CFG_SGS_NODE, &cfg_sgs_counter_cmd);
install_element(CFG_SGS_NODE, &cfg_sgs_vlr_name_cmd);
install_element_ve(&show_sgs_conn_cmd);
}

@ -128,7 +128,8 @@ int gsm_silent_call_start(struct vlr_subscr *vsub, void *data, int type)
* This doesn't apply to the situation after MSCSPLIT with an
* A-interface. */
req = subscr_request_conn(vsub, paging_cb_silent, data,
"establish silent call");
"establish silent call",
SGSAP_SERV_IND_CS_CALL);
if (!req)
return -ENODEV;
return 0;

@ -8,6 +8,7 @@ AM_CFLAGS= \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
$(LIBOSMORANAP_CFLAGS) \
$(LIBOSMOGSM_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(NULL)
@ -16,6 +17,7 @@ noinst_HEADERS = \
vlr_auth_fsm.h \
vlr_core.h \
vlr_lu_fsm.h \
vlr_sgs_fsm.h \
$(NULL)
noinst_LIBRARIES = libvlr.a
@ -25,4 +27,6 @@ libvlr_a_SOURCES = \
vlr_access_req_fsm.c \
vlr_auth_fsm.c \
vlr_lu_fsm.c \
vlr_sgs.c \
vlr_sgs_fsm.c \
$(NULL)

@ -30,6 +30,7 @@
#include <osmocom/gsm/ipa.h>
#include <osmocom/msc/gsm_subscriber.h>
#include <osmocom/gsupclient/gsup_client.h>
#include <osmocom/msc/vlr_sgs.h>
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/debug.h>
@ -42,6 +43,7 @@
#include "vlr_auth_fsm.h"
#include "vlr_lu_fsm.h"
#include "vlr_access_req_fsm.h"
#include "vlr_sgs_fsm.h"
#define SGSN_SUBSCR_MAX_RETRIES 3
#define SGSN_SUBSCR_RETRY_INTERVAL 10
@ -262,6 +264,11 @@ static struct vlr_subscr *_vlr_subscr_alloc(struct vlr_instance *vlr)
INIT_LLIST_HEAD(&vsub->cs.requests);
INIT_LLIST_HEAD(&vsub->ps.pdp_list);
/* Create an SGs FSM, which is needed to control CSFB,
* in cases where CSFB/SGs is not in use, this FSM will
* just do nothing. (see also: sgs_iface.c) */
vlr_sgs_fsm_create(vsub);
llist_add_tail(&vsub->list, &vlr->subscribers);
return vsub;
}
@ -307,6 +314,13 @@ void vlr_subscr_free(struct vlr_subscr *vsub)
{
llist_del(&vsub->list);
DEBUGP(DREF, "freeing VLR subscr %s\n", vlr_subscr_name(vsub));
/* Make sure SGs timer Ts5 is removed */
osmo_timer_del(&vsub->sgs.Ts5);
/* Remove SGs FSM (see also: sgs_iface.c) */
vlr_sgs_fsm_remove(vsub);
talloc_free(vsub);
}
@ -854,7 +868,13 @@ static int vlr_subscr_handle_isd_req(struct vlr_subscr *vsub,
static int vlr_subscr_handle_lu_res(struct vlr_subscr *vsub,
const struct osmo_gsup_message *gsup)
{
if (!vsub->lu_fsm) {
struct sgs_lu_response sgs_lu_response;
bool sgs_lu_in_progress = false;
if (vsub->sgs_fsm->state == SGS_UE_ST_LA_UPD_PRES)
sgs_lu_in_progress = true;
if (!vsub->lu_fsm && !sgs_lu_in_progress) {
LOGVSUBP(LOGL_ERROR, vsub, "Rx GSUP LU Result "
"without LU in progress\n");
return -ENODEV;
@ -865,7 +885,12 @@ static int vlr_subscr_handle_lu_res(struct vlr_subscr *vsub,
* nested INSERT SUBSCRIBER DATA transaction */
vlr_subscr_gsup_insert_data(vsub, gsup);
osmo_fsm_inst_dispatch(vsub->lu_fsm, VLR_ULA_E_HLR_LU_RES, NULL);
if (sgs_lu_in_progress) {
sgs_lu_response.accepted = true;
sgs_lu_response.vsub = vsub;
vsub->sgs.response_cb(&sgs_lu_response);
} else
osmo_fsm_inst_dispatch(vsub->lu_fsm, VLR_ULA_E_HLR_LU_RES, NULL);
return 0;
}
@ -874,7 +899,13 @@ static int vlr_subscr_handle_lu_res(struct vlr_subscr *vsub,
static int vlr_subscr_handle_lu_err(struct vlr_subscr *vsub,
const struct osmo_gsup_message *gsup)
{
if (!vsub->lu_fsm) {
struct sgs_lu_response sgs_lu_response;
bool sgs_lu_in_progress = false;
if (vsub->sgs_fsm->state == SGS_UE_ST_LA_UPD_PRES)
sgs_lu_in_progress = true;
if (!vsub->lu_fsm && !sgs_lu_in_progress) {
LOGVSUBP(LOGL_ERROR, vsub, "Rx GSUP LU Error "
"without LU in progress\n");
return -ENODEV;
@ -883,9 +914,13 @@ static int vlr_subscr_handle_lu_err(struct vlr_subscr *vsub,
LOGVSUBP(LOGL_DEBUG, vsub, "UpdateLocation failed; gmm_cause: %s\n",
get_value_string(gsm48_gmm_cause_names, gsup->cause));
osmo_fsm_inst_dispatch(vsub->lu_fsm, VLR_ULA_E_HLR_LU_RES,
(void *)&gsup->cause);
if (sgs_lu_in_progress) {
sgs_lu_response.accepted = false;
sgs_lu_response.vsub = vsub;
vsub->sgs.response_cb(&sgs_lu_response);
} else
osmo_fsm_inst_dispatch(vsub->lu_fsm, VLR_ULA_E_HLR_LU_RES,
(void *)&gsup->cause);
return 0;
}
@ -1225,6 +1260,9 @@ int vlr_subscr_rx_imsi_detach(struct vlr_subscr *vsub)
vsub->imsi_detached_flag = true;
vsub->expire_lu = VLR_SUBSCRIBER_NO_EXPIRATION;
/* Inform the UE-SGs FSM that the subscriber has been detached */
osmo_fsm_inst_dispatch(vsub->sgs_fsm, SGS_UE_E_RX_DETACH_IND_FROM_UE, NULL);
vlr_subscr_expire(vsub);
return 0;
@ -1273,6 +1311,8 @@ struct vlr_instance *vlr_alloc(void *ctx, const struct vlr_ops *ops)
vlr_lu_fsm_init();
/* vlr_access_request_fsm.c */
vlr_parq_fsm_init();
/* vlr_sgs_fsm.c */
vlr_sgs_fsm_init();
return vlr;
}

@ -27,6 +27,7 @@
#include "vlr_core.h"
#include "vlr_auth_fsm.h"
#include "vlr_lu_fsm.h"
#include "vlr_sgs_fsm.h"
#define S(x) (1 << (x))
@ -362,6 +363,7 @@ static void vlr_lu_compl_fsm_success(struct osmo_fsm_inst *fi)
vlr_subscr_get(vsub);
}
_vlr_lu_compl_fsm_done(fi, VLR_FSM_RESULT_SUCCESS, 0);
vlr_sgs_fsm_update_id(vsub);
}
static void vlr_lu_compl_fsm_failure(struct osmo_fsm_inst *fi, uint8_t cause)
@ -1055,6 +1057,11 @@ static void lu_fsm_idle(struct osmo_fsm_inst *fi, uint32_t event,
OSMO_ASSERT(lfp->vsub);