aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-03-08 18:53:30 +0100
committerMax <msuraev@sysmocom.de>2017-03-17 17:01:28 +0000
commit0a8fae8d141c2cfa4387ffe9b35402d5b8cc85cd (patch)
tree2e97c91487f941769ae060391d12e9a0ce32c888 /src
parentdb84235a0bca73a4c5f68bd821fa4e2b1a1d7d68 (diff)
Support sending OML Alerts via BTS
* extend BTS <-> PCU protocol with TXT messages * use it to implement OML alerts support * use it to implement version message * add function to transmit both of them them * send alerts for internal encoding problems as an example * send version when BTS socket is connected Note: requires corresponding change If57459c0610f2c7b36d599b13087c8deef8bdd9e in libosmocore. Related: OS#1614, 1615 Change-Id: If4ea5b3f7409df2fb030681ad468df6b711790a7
Diffstat (limited to 'src')
-rw-r--r--src/encoding.cpp26
-rw-r--r--src/osmobts_sock.cpp3
-rw-r--r--src/pcu_l1_if.cpp36
-rw-r--r--src/pcu_l1_if.h3
4 files changed, 58 insertions, 10 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp
index ea38b77f..2f052a48 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -320,6 +320,13 @@ int Encoding::write_immediate_assignment_reject(
return plen;
}
+static inline void log_alert_exit(const char * error)
+{
+ LOGP(DRLCMACUL, LOGL_ERROR, error);
+ pcu_tx_txt_ind(PCU_OML_ALERT, error);
+ exit(1);
+}
+
/*
* Immediate assignment, sent on the CCCH/AGCH
* see GSM 04.08, 9.1.18 and GSM 44.018, 9.1.18 + 10.5.2.16
@@ -374,11 +381,10 @@ int Encoding::write_immediate_assignment(
// A zero-length LV. Just write L=0.
bitvec_write_field(dest, wp,0,8);
- if ((wp % 8)) {
- LOGP(DRLCMACUL, LOGL_ERROR, "Length of IMM.ASS without rest "
- "octets is not multiple of 8 bits, PLEASE FIX!\n");
- exit (0);
- }
+ if ((wp % 8))
+ log_alert_exit("Length of IMM.ASS without rest octets is not "
+ "multiple of 8 bits, PLEASE FIX!\n");
+
plen = wp / 8;
if (downlink)
@@ -618,11 +624,11 @@ int Encoding::write_paging_request(bitvec * dest, uint8_t *ptmsi, uint16_t ptmsi
{
bitvec_write_field(dest, wp,ptmsi[i],8); // PTMSI
}
- if ((wp % 8)) {
- LOGP(DRLCMACUL, LOGL_ERROR, "Length of PAG.REQ without rest "
- "octets is not multiple of 8 bits, PLEASE FIX!\n");
- exit (0);
- }
+
+ if ((wp % 8))
+ log_alert_exit("Length of PAG.REQ without rest octets is not "
+ "multiple of 8 bits, PLEASE FIX!\n");
+
plen = wp / 8;
bitvec_write_field(dest, wp,0x0,1); // "L" NLN(PCH) = off
bitvec_write_field(dest, wp,0x0,1); // "L" Priority1 = off
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index d542b669..d7e55e7c 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -287,6 +287,9 @@ int pcu_l1if_open(void)
pcu_sock_state = state;
+ LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION);
+ pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
+
return 0;
}
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index b8925979..c16ac0c4 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -73,6 +73,42 @@ struct msgb *pcu_msgb_alloc(uint8_t msg_type, uint8_t bts_nr)
return msg;
}
+const struct value_string gsm_pcu_if_text_type_names[] = {
+ OSMO_VALUE_STRING(PCU_VERSION),
+ OSMO_VALUE_STRING(PCU_OML_ALERT),
+ { 0, NULL }
+};
+
+int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...)
+{
+ struct gsm_pcu_if *pcu_prim;
+ struct gsm_pcu_if_txt_ind *txt;
+ va_list ap;
+ char *rep;
+ struct msgb *msg = pcu_msgb_alloc(PCU_IF_MSG_TXT_IND, 0);
+ if (!msg)
+ return -ENOMEM;
+
+ pcu_prim = (struct gsm_pcu_if *) msg->data;
+ txt = &pcu_prim->u.txt_ind;
+ txt->type = t;
+
+ va_start(ap, fmt);
+ rep = talloc_vasprintf(tall_pcu_ctx, fmt, ap);
+ va_end(ap);
+
+ if (!rep)
+ return -ENOMEM;
+
+ osmo_strlcpy(txt->text, rep, TXT_MAX_LEN);
+ talloc_free(rep);
+
+ LOGP(DL1IF, LOGL_INFO, "Sending %s TXT as %s to BTS\n", txt->text,
+ get_value_string(gsm_pcu_if_text_type_names, t));
+
+ return pcu_sock_send(msg);
+}
+
static int pcu_tx_act_req(uint8_t trx, uint8_t ts, uint8_t activate)
{
struct msgb *msg;
diff --git a/src/pcu_l1_if.h b/src/pcu_l1_if.h
index eaa01436..1618260c 100644
--- a/src/pcu_l1_if.h
+++ b/src/pcu_l1_if.h
@@ -29,6 +29,7 @@ extern "C" {
#include <osmocom/core/timer.h>
#include <osmocom/core/bitvec.h>
#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/pcu/pcuif_proto.h>
#ifdef __cplusplus
}
#endif
@@ -131,6 +132,8 @@ void pcu_l1if_tx_agch(bitvec * block, int len);
void pcu_l1if_tx_pch(bitvec * block, int plen, const char *imsi);
+int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...);
+
int pcu_l1if_open(void);
void pcu_l1if_close(void);