Remove traces of meas_feed

Measurement reporting (and the relate feed) are functions of the BSC,
not the MSC.  This code should never have been inherited from OsmoNITB
to OsmoMSC in the first place, let's remove it.

Change-Id: I0d57ac214e574e267fa9752daf76566197b9aa64
changes/19/6019/2
Harald Welte 5 years ago
parent 37382ec2cf
commit a1c5de45c1
  1. 4
      .gitignore
  2. 1
      include/osmocom/msc/Makefile.am
  3. 41
      include/osmocom/msc/meas_feed.h
  4. 2
      src/libmsc/Makefile.am
  5. 168
      src/libmsc/meas_feed.c
  6. 42
      src/libmsc/vty_interface_layer3.c
  7. 18
      tests/vty_test_runner.py

4
.gitignore vendored

@ -40,10 +40,6 @@ m4/*.m4
# apps and app data
src/osmo-msc/osmo-msc
src/libcommon/gsup_test_client
src/utils/meas_vis
src/utils/meas_json
src/utils/osmo-meas-pcap2db
src/utils/osmo-meas-udp2db
src/utils/smpp_mirror
sms.db
src/osmo-msc/*.cfg*

@ -33,7 +33,6 @@ noinst_HEADERS = \
iucs.h \
iucs_ranap.h \
iu_dummy.h \
meas_feed.h \
meas_rep.h \
misdn.h \
mncc.h \

@ -1,41 +0,0 @@
#ifndef _OPENBSC_MEAS_FEED_H
#define _OPENBSC_MEAS_FEED_H
#include <stdint.h>
#include <osmocom/msc/meas_rep.h>
struct meas_feed_hdr {
uint8_t msg_type;
uint8_t reserved;
uint16_t version;
};
struct meas_feed_meas {
struct meas_feed_hdr hdr;
char imsi[15+1];
char name[31+1];
char scenario[31+1];
struct gsm_meas_rep mr;
/* The logical channel type, enum gsm_chan_t */
uint8_t lchan_type;
/* The physical channel type, enum gsm_phys_chan_config */
uint8_t pchan_type;
/* number of ths BTS in network */
uint8_t bts_nr;
/* number of this TRX in the BTS */
uint8_t trx_nr;
/* number of this timeslot at the TRX */
uint8_t ts_nr;
/* The logical subslot number in the TS */
uint8_t ss_nr;
};
enum meas_feed_msgtype {
MEAS_FEED_MEAS = 0,
};
#define MEAS_FEED_VERSION 1
#endif

@ -19,7 +19,6 @@ AM_CFLAGS = \
$(NULL)
noinst_HEADERS = \
meas_feed.h \
$(NULL)
noinst_LIBRARIES = \
@ -49,7 +48,6 @@ libmsc_a_SOURCES = \
transaction.c \
osmo_msc.c \
ctrl_commands.c \
meas_feed.c \
subscr_conn.c \
$(NULL)
if BUILD_IU

@ -1,168 +0,0 @@
/* UDP-Feed of measurement reports */
#include <unistd.h>
#include <sys/socket.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/vty.h>
#include <osmocom/msc/meas_rep.h>
#include <osmocom/msc/signal.h>
#include <osmocom/msc/gsm_subscriber.h>
#include <osmocom/msc/meas_feed.h>
#include <osmocom/msc/vty.h>
#include <osmocom/msc/vlr.h>
#include "meas_feed.h"
struct meas_feed_state {
struct osmo_wqueue wqueue;
char scenario[31+1];
char *dst_host;
uint16_t dst_port;
};
static struct meas_feed_state g_mfs;
static int process_meas_rep(struct gsm_meas_rep *mr)
{
struct msgb *msg;
struct meas_feed_meas *mfm;
struct vlr_subscr *vsub;
/* ignore measurements as long as we don't know who it is */
if (!mr->lchan || !mr->lchan->conn || !mr->lchan->conn->vsub)
return 0;
vsub = mr->lchan->conn->vsub;
msg = msgb_alloc(sizeof(struct meas_feed_meas), "Meas. Feed");
if (!msg)
return 0;
/* fill in the header */
mfm = (struct meas_feed_meas *) msgb_put(msg, sizeof(*mfm));
mfm->hdr.msg_type = MEAS_FEED_MEAS;
mfm->hdr.version = MEAS_FEED_VERSION;
/* fill in MEAS_FEED_MEAS specific header */
osmo_strlcpy(mfm->imsi, vsub->imsi, sizeof(mfm->imsi));
osmo_strlcpy(mfm->name, vsub->name, sizeof(mfm->name));
osmo_strlcpy(mfm->scenario, g_mfs.scenario, sizeof(mfm->scenario));
/* copy the entire measurement report */
memcpy(&mfm->mr, mr, sizeof(mfm->mr));
/* copy channel information */
/* we assume that the measurement report always belong to some timeslot */
mfm->lchan_type = (uint8_t)mr->lchan->type;
mfm->pchan_type = (uint8_t)mr->lchan->ts->pchan;
mfm->bts_nr = mr->lchan->ts->trx->bts->nr;
mfm->trx_nr = mr->lchan->ts->trx->nr;
mfm->ts_nr = mr->lchan->ts->nr;
mfm->ss_nr = mr->lchan->nr;
/* and send it to the socket */
if (osmo_wqueue_enqueue(&g_mfs.wqueue, msg) != 0)
msgb_free(msg);
return 0;
}
static int meas_feed_sig_cb(unsigned int subsys, unsigned int signal,
void *handler_data, void *signal_data)
{
struct lchan_signal_data *sdata = signal_data;
if (subsys != SS_LCHAN)
return 0;
if (signal == S_LCHAN_MEAS_REP)
process_meas_rep(sdata->mr);
return 0;
}
static int feed_write_cb(struct osmo_fd *ofd, struct msgb *msg)
{
return write(ofd->fd, msgb_data(msg), msgb_length(msg));
}
static int feed_read_cb(struct osmo_fd *ofd)
{
int rc;
char buf[256];
rc = read(ofd->fd, buf, sizeof(buf));
ofd->fd &= ~BSC_FD_READ;
return rc;
}
int meas_feed_cfg_set(const char *dst_host, uint16_t dst_port)
{
int rc;
int already_initialized = 0;
if (g_mfs.wqueue.bfd.fd)
already_initialized = 1;
if (already_initialized &&
!strcmp(dst_host, g_mfs.dst_host) &&
dst_port == g_mfs.dst_port)
return 0;
if (!already_initialized) {
osmo_wqueue_init(&g_mfs.wqueue, 10);
g_mfs.wqueue.write_cb = feed_write_cb;
g_mfs.wqueue.read_cb = feed_read_cb;
osmo_signal_register_handler(SS_LCHAN, meas_feed_sig_cb, NULL);
}
if (already_initialized) {
osmo_wqueue_clear(&g_mfs.wqueue);
osmo_fd_unregister(&g_mfs.wqueue.bfd);
close(g_mfs.wqueue.bfd.fd);
/* don't set to zero, as that would mean 'not yet initialized' */
g_mfs.wqueue.bfd.fd = -1;
}
rc = osmo_sock_init_ofd(&g_mfs.wqueue.bfd, AF_UNSPEC, SOCK_DGRAM,
IPPROTO_UDP, dst_host, dst_port,
OSMO_SOCK_F_CONNECT);
if (rc < 0)
return rc;
g_mfs.wqueue.bfd.when &= ~BSC_FD_READ;
if (g_mfs.dst_host)
talloc_free(g_mfs.dst_host);
g_mfs.dst_host = talloc_strdup(NULL, dst_host);
g_mfs.dst_port = dst_port;
return 0;
}
void meas_feed_cfg_get(char **host, uint16_t *port)
{
*port = g_mfs.dst_port;
*host = g_mfs.dst_host;
}
void meas_feed_scenario_set(const char *name)
{
osmo_strlcpy(g_mfs.scenario, name, sizeof(g_mfs.scenario));
}
const char *meas_feed_scenario_get(void)
{
return g_mfs.scenario;
}

@ -56,8 +56,6 @@
#include <osmocom/msc/osmo_msc.h>
#include "meas_feed.h"
extern struct gsm_network *gsmnet_from_vty(struct vty *v);
static void subscr_dump_full_vty(struct vty *vty, struct vlr_subscr *vsub)
@ -754,13 +752,6 @@ static const struct value_string tchh_codec_names[] = {
static int config_write_mncc_int(struct vty *vty)
{
uint16_t meas_port;
char *meas_host;
const char *meas_scenario;
meas_feed_cfg_get(&meas_host, &meas_port);
meas_scenario = meas_feed_scenario_get();
vty_out(vty, "mncc-int%s", VTY_NEWLINE);
vty_out(vty, " default-codec tch-f %s%s",
get_value_string(tchf_codec_names, mncc_int.def_codec[0]),
@ -768,13 +759,6 @@ static int config_write_mncc_int(struct vty *vty)
vty_out(vty, " default-codec tch-h %s%s",
get_value_string(tchh_codec_names, mncc_int.def_codec[1]),
VTY_NEWLINE);
if (meas_port)
vty_out(vty, " meas-feed destination %s %u%s",
meas_host, meas_port, VTY_NEWLINE);
if (strlen(meas_scenario) > 0)
vty_out(vty, " meas-feed scenario %s%s",
meas_scenario, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -801,29 +785,6 @@ DEFUN(mnccint_def_codec_h,
return CMD_SUCCESS;
}
#define MEAS_STR "Measurement export related\n"
DEFUN(mnccint_meas_feed, mnccint_meas_feed_cmd,
"meas-feed destination ADDR <0-65535>",
MEAS_STR "destination\n" "address or hostname\n" "port number\n")
{
int rc;
rc = meas_feed_cfg_set(argv[0], atoi(argv[1]));
if (rc < 0)
return CMD_WARNING;
return CMD_SUCCESS;
}
DEFUN(meas_feed_scenario, meas_feed_scenario_cmd,
"meas-feed scenario NAME",
MEAS_STR "scenario\n" "Name up to 31 characters included in report\n")
{
meas_feed_scenario_set(argv[0]);
return CMD_SUCCESS;
}
DEFUN(logging_fltr_imsi,
logging_fltr_imsi_cmd,
@ -924,14 +885,11 @@ int bsc_vty_init_extra(void)
install_element(ENABLE_NODE, &smsqueue_clear_cmd);
install_element(ENABLE_NODE, &smsqueue_fail_cmd);
install_element(ENABLE_NODE, &subscriber_send_pending_sms_cmd);
install_element(ENABLE_NODE, &meas_feed_scenario_cmd);
install_element(CONFIG_NODE, &cfg_mncc_int_cmd);
install_node(&mncc_int_node, config_write_mncc_int);
install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd);
install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd);
install_element(MNCC_INT_NODE, &mnccint_meas_feed_cmd);
install_element(MNCC_INT_NODE, &meas_feed_scenario_cmd);
install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);

@ -225,24 +225,6 @@ class TestVTYMSC(TestVTYBase):
res = self.vty.command("show network")
self.assert_(res.startswith('BSC is on Country Code') >= 0)
def testMeasurementFeed(self):
self.vty.enable()
self.vty.command("configure terminal")
self.vty.command("mncc-int")
res = self.vty.command("write terminal")
self.assertEquals(res.find('meas-feed scenario'), -1)
self.vty.command("meas-feed scenario bla")
res = self.vty.command("write terminal")
self.assert_(res.find('meas-feed scenario bla') > 0)
self.vty.command("meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890")
res = self.vty.command("write terminal")
self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890'), -1)
self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz012345'), -1)
self.assert_(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234') > 0)
def ipa_handle_small(x, verbose = False):
s = data2str(x.recv(4))
if len(s) != 4*2:

Loading…
Cancel
Save