summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/libosmocore/include')
-rw-r--r--src/shared/libosmocore/include/osmocore/Makefile.am2
-rw-r--r--src/shared/libosmocore/include/osmocore/gsm0808.h4
-rw-r--r--src/shared/libosmocore/include/osmocore/msgb.h33
-rw-r--r--src/shared/libosmocore/include/osmocore/panic.h11
-rw-r--r--src/shared/libosmocore/include/osmocore/protocol/Makefile.am3
-rw-r--r--src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h31
-rw-r--r--src/shared/libosmocore/include/osmocore/rsl.h3
7 files changed, 79 insertions, 8 deletions
diff --git a/src/shared/libosmocore/include/osmocore/Makefile.am b/src/shared/libosmocore/include/osmocore/Makefile.am
index 8334f148..ecdc65c9 100644
--- a/src/shared/libosmocore/include/osmocore/Makefile.am
+++ b/src/shared/libosmocore/include/osmocore/Makefile.am
@@ -2,7 +2,7 @@ osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h \
tlv.h bitvec.h comp128.h statistics.h gsm_utils.h utils.h \
gsmtap.h write_queue.h rsl.h gsm48.h rxlev_stat.h mncc.h \
gsm48_ie.h logging.h gsm0808.h rate_ctr.h gsmtap_util.h \
- plugin.h crc16.h
+ plugin.h crc16.h panic.h
if ENABLE_TALLOC
osmocore_HEADERS += talloc.h
diff --git a/src/shared/libosmocore/include/osmocore/gsm0808.h b/src/shared/libosmocore/include/osmocore/gsm0808.h
index 9166e54f..2d609c9e 100644
--- a/src/shared/libosmocore/include/osmocore/gsm0808.h
+++ b/src/shared/libosmocore/include/osmocore/gsm0808.h
@@ -24,14 +24,14 @@
struct msgb;
-struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, int ci);
+struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, uint16_t ci);
struct msgb *gsm0808_create_reset(void);
struct msgb *gsm0808_create_clear_complete(void);
struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id);
struct msgb *gsm0808_create_cipher_reject(uint8_t cause);
struct msgb *gsm0808_create_classmark_update(const uint8_t *classmark, uint8_t length);
struct msgb *gsm0808_create_sapi_reject(uint8_t link_id);
-struct msgb *gsm0808_create_assignment_completed(struct gsm_lchan *lchan, uint8_t rr_cause,
+struct msgb *gsm0808_create_assignment_completed(uint8_t rr_cause,
uint8_t chosen_channel, uint8_t encr_alg_id,
uint8_t speech_mode);
struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause);
diff --git a/src/shared/libosmocore/include/osmocore/msgb.h b/src/shared/libosmocore/include/osmocore/msgb.h
index 2841dc56..354c5d88 100644
--- a/src/shared/libosmocore/include/osmocore/msgb.h
+++ b/src/shared/libosmocore/include/osmocore/msgb.h
@@ -23,6 +23,8 @@
#include <stdint.h>
#include "linuxlist.h"
+#define MSGB_DEBUG
+
struct msgb {
struct llist_head list;
@@ -58,6 +60,14 @@ extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
extern struct msgb *msgb_dequeue(struct llist_head *queue);
extern void msgb_reset(struct msgb *m);
+#ifdef MSGB_DEBUG
+#include <osmocore/panic.h>
+static inline void msgb_abort(struct msgb *msg, const char *text)
+{
+ osmo_panic("%s", text);
+}
+#endif
+
#define msgb_l1(m) ((void *)(m->l1h))
#define msgb_l2(m) ((void *)(m->l2h))
#define msgb_l3(m) ((void *)(m->l3h))
@@ -82,9 +92,24 @@ static inline unsigned int msgb_headlen(const struct msgb *msgb)
{
return msgb->len - msgb->data_len;
}
+
+static inline int msgb_tailroom(const struct msgb *msgb)
+{
+ return (msgb->head + msgb->data_len) - msgb->tail;
+}
+
+static inline int msgb_headroom(const struct msgb *msgb)
+{
+ return (msgb->data - msgb->head);
+}
+
static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len)
{
unsigned char *tmp = msgb->tail;
+#ifdef MSGB_DEBUG
+ if (msgb_tailroom(msgb) < len)
+ msgb_abort(msgb, "Not enough tailroom\n");
+#endif
msgb->tail += len;
msgb->len += len;
return tmp;
@@ -132,6 +157,10 @@ static inline uint32_t msgb_get_u32(struct msgb *msgb)
}
static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len)
{
+#ifdef MSGB_DEBUG
+ if (msgb_headroom(msgb) < len)
+ msgb_abort(msgb, "Not enough headroom\n");
+#endif
msgb->data -= len;
msgb->len += len;
return msgb->data;
@@ -141,10 +170,6 @@ static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len)
msgb->len -= len;
return msgb->data += len;
}
-static inline int msgb_tailroom(const struct msgb *msgb)
-{
- return (msgb->head + msgb->data_len) - msgb->tail;
-}
/* increase the headroom of an empty msgb, reducing the tailroom */
static inline void msgb_reserve(struct msgb *msg, int len)
diff --git a/src/shared/libosmocore/include/osmocore/panic.h b/src/shared/libosmocore/include/osmocore/panic.h
new file mode 100644
index 00000000..cee95358
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocore/panic.h
@@ -0,0 +1,11 @@
+#ifndef OSMOCORE_PANIC_H
+#define OSMOCORE_PANIC_H
+
+#include <stdarg.h>
+
+typedef void (*osmo_panic_handler_t)(const char *fmt, va_list args);
+
+void osmo_panic(const char *fmt, ...);
+void osmo_set_panic_handler(osmo_panic_handler_t *h);
+
+#endif
diff --git a/src/shared/libosmocore/include/osmocore/protocol/Makefile.am b/src/shared/libosmocore/include/osmocore/protocol/Makefile.am
index 557950ec..5df9fe74 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/Makefile.am
+++ b/src/shared/libosmocore/include/osmocore/protocol/Makefile.am
@@ -1,3 +1,4 @@
-osmocore_proto_HEADERS = gsm_04_08.h gsm_04_11.h gsm_04_80.h gsm_08_58.h gsm_12_21.h gsm_08_08.h
+osmocore_proto_HEADERS = gsm_04_08.h gsm_04_11.h gsm_04_80.h gsm_08_58.h \
+ gsm_12_21.h gsm_08_08.h gsm_04_12.h
osmocore_protodir = $(includedir)/osmocore/protocol
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h b/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h
new file mode 100644
index 00000000..bd9e0884
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h
@@ -0,0 +1,31 @@
+#ifndef PROTO_GSM_04_12_H
+#define PROTO_GSM_04_12_H
+
+#include <stdint.h>
+
+/* GSM TS 04.12 definitions for Short Message Service Cell Broadcast */
+
+#define GSM412_SEQ_FST_BLOCK 0x0
+#define GSM412_SEQ_SND_BLOCK 0x1
+#define GSM412_SEQ_TRD_BLOCK 0x2
+#define GSM412_SEQ_FTH_BLOCK 0x3
+#define GSM412_SEQ_FST_SCHED_BLOCK 0x8
+#define GSM413_SEQ_NULL_MSG 0xf
+
+struct gsm412_block_type {
+ uint8_t seq_nr : 4,
+ lb : 1,
+ lpd : 2,
+ spare : 1;
+} __attribute__((packed));
+
+struct gsm413_sched_msg {
+ uint8_t beg_slot_nr : 6,
+ type : 2;
+ uint8_t end_slot_nr : 6,
+ spare1 : 1, spare2: 1;
+ uint8_t cbsms_msg_map[6];
+ uint8_t data[0];
+} __attribute__((packed));
+
+#endif
diff --git a/src/shared/libosmocore/include/osmocore/rsl.h b/src/shared/libosmocore/include/osmocore/rsl.h
index cd84057b..54d67032 100644
--- a/src/shared/libosmocore/include/osmocore/rsl.h
+++ b/src/shared/libosmocore/include/osmocore/rsl.h
@@ -17,6 +17,9 @@ extern const struct tlv_definition rsl_att_tlvdef;
uint8_t rsl_enc_chan_nr(uint8_t type, uint8_t subch, uint8_t timeslot);
/* decode channel number as per Section 9.3.1 */
int rsl_dec_chan_nr(uint8_t chan_nr, uint8_t *type, uint8_t *subch, uint8_t *timeslot);
+/* Turns channel number into a string */
+const char *rsl_chan_nr_str(uint8_t chan_nr);
+
const char *rsl_err_name(uint8_t err);
const char *rsl_rlm_cause_name(uint8_t err);