summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore/src
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-11-13 22:48:15 +0100
committerSylvain Munaut <tnt@246tNt.com>2010-11-13 22:48:15 +0100
commit11316da173cc0caff14445a159c968ff87204001 (patch)
tree35af21cda48aebb84390601c9b130cf2a480e0b9 /src/shared/libosmocore/src
parent6f2b172780195e0af780ecd0a4fff0fac9b8438b (diff)
parent7f6615a37df0dadbe86fdfc980e0a8a15013a80e (diff)
Merge commit '7f6615a37df0dadbe86fdfc980e0a8a15013a80e'
Diffstat (limited to 'src/shared/libosmocore/src')
-rw-r--r--src/shared/libosmocore/src/gsm0808.c56
-rw-r--r--src/shared/libosmocore/src/gsm_utils.c11
-rw-r--r--src/shared/libosmocore/src/msgfile.c4
-rw-r--r--src/shared/libosmocore/src/panic.c4
-rw-r--r--src/shared/libosmocore/src/select.c5
5 files changed, 75 insertions, 5 deletions
diff --git a/src/shared/libosmocore/src/gsm0808.c b/src/shared/libosmocore/src/gsm0808.c
index 636c2117..dc450cc4 100644
--- a/src/shared/libosmocore/src/gsm0808.c
+++ b/src/shared/libosmocore/src/gsm0808.c
@@ -108,6 +108,19 @@ struct msgb *gsm0808_create_clear_complete(void)
return msg;
}
+struct msgb *gsm0808_create_clear_command(uint8_t reason)
+{
+ struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
+ "bssmap: clear command");
+ if (!msg)
+ return NULL;
+
+ msg->l3h = msgb_tv_put(msg, BSSAP_MSG_BSS_MANAGEMENT, 4);
+ msgb_v_put(msg, BSS_MAP_MSG_CLEAR_CMD);
+ msgb_tlv_put(msg, GSM0808_IE_CAUSE, 1, &reason);
+ return msg;
+}
+
struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id)
{
struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
@@ -271,6 +284,26 @@ struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause)
return msg;
}
+struct msgb *gsm0808_create_clear_rqst(uint8_t cause)
+{
+ struct msgb *msg;
+
+ msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
+ "bssmap: clear rqst");
+ if (!msg)
+ return NULL;
+
+ msg->l3h = msgb_put(msg, 2 + 4);
+ msg->l3h[0] = BSSAP_MSG_BSS_MANAGEMENT;
+ msg->l3h[1] = 4;
+
+ msg->l3h[2] = BSS_MAP_MSG_CLEAR_RQST;
+ msg->l3h[3] = GSM0808_IE_CAUSE;
+ msg->l3h[4] = 1;
+ msg->l3h[5] = cause;
+ return msg;
+}
+
void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id)
{
uint8_t *hh = msgb_push(msg, 3);
@@ -279,6 +312,29 @@ void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id)
hh[2] = msg->len - 3;
}
+struct msgb *gsm0808_create_dtap(struct msgb *msg_l3, uint8_t link_id)
+{
+ struct dtap_header *header;
+ uint8_t *data;
+ struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
+ "dtap");
+ if (!msg)
+ return NULL;
+
+ /* DTAP header */
+ msg->l3h = msgb_put(msg, sizeof(*header));
+ header = (struct dtap_header *) &msg->l3h[0];
+ header->type = BSSAP_MSG_DTAP;
+ header->link_id = link_id;
+ header->length = msgb_l3len(msg_l3);
+
+ /* Payload */
+ data = msgb_put(msg, header->length);
+ memcpy(data, msg_l3->l3h, header->length);
+
+ return msg;
+}
+
static const struct tlv_definition bss_att_tlvdef = {
.def = {
[GSM0808_IE_IMSI] = { TLV_TYPE_TLV },
diff --git a/src/shared/libosmocore/src/gsm_utils.c b/src/shared/libosmocore/src/gsm_utils.c
index 4b4e2c60..31e3cd69 100644
--- a/src/shared/libosmocore/src/gsm_utils.c
+++ b/src/shared/libosmocore/src/gsm_utils.c
@@ -359,7 +359,11 @@ void generate_backtrace()
enum gsm_band gsm_arfcn2band(uint16_t arfcn)
{
- if (arfcn & ARFCN_PCS)
+ int is_pcs = arfcn & ARFCN_PCS;
+
+ arfcn &= ~ARFCN_FLAG_MASK;
+
+ if (is_pcs)
return GSM_BAND_1900;
else if (arfcn <= 124)
return GSM_BAND_900;
@@ -386,8 +390,11 @@ uint16_t gsm_arfcn2freq10(uint16_t arfcn, int uplink)
{
uint16_t freq10_ul;
uint16_t freq10_dl;
+ int is_pcs = arfcn & ARFCN_PCS;
+
+ arfcn &= ~ARFCN_FLAG_MASK;
- if (arfcn & ARFCN_PCS) {
+ if (is_pcs) {
/* DCS 1900 */
arfcn &= ~ARFCN_PCS;
freq10_ul = 18502 + 2 * (arfcn-512);
diff --git a/src/shared/libosmocore/src/msgfile.c b/src/shared/libosmocore/src/msgfile.c
index 051f5b75..68f05813 100644
--- a/src/shared/libosmocore/src/msgfile.c
+++ b/src/shared/libosmocore/src/msgfile.c
@@ -70,6 +70,10 @@ static void handle_line(struct msg_entries *entries, char *line)
char *items[3];
int last_item = 0;
+ /* Skip comments from the file */
+ if (line[0] == '#')
+ return;
+
for (i = 0; i < len; ++i) {
if (line[i] == '\n' || line[i] == '\r')
line[i] = '\0';
diff --git a/src/shared/libosmocore/src/panic.c b/src/shared/libosmocore/src/panic.c
index a25067de..5fb7b565 100644
--- a/src/shared/libosmocore/src/panic.c
+++ b/src/shared/libosmocore/src/panic.c
@@ -20,6 +20,7 @@
*
*/
+#include <osmocore/gsm_utils.h>
#include <osmocore/panic.h>
#include "../config.h"
@@ -36,6 +37,7 @@ static osmo_panic_handler_t osmo_panic_handler = (void*)0;
static void osmo_panic_default(const char *fmt, va_list args)
{
vfprintf(stderr, fmt, args);
+ generate_backtrace();
abort();
}
@@ -64,7 +66,7 @@ void osmo_panic(const char *fmt, ...)
}
-void osmo_set_panic_handler(osmo_panic_handler_t *h)
+void osmo_set_panic_handler(osmo_panic_handler_t h)
{
osmo_panic_handler = h;
}
diff --git a/src/shared/libosmocore/src/select.c b/src/shared/libosmocore/src/select.c
index f52b0a0c..5aa2beb5 100644
--- a/src/shared/libosmocore/src/select.c
+++ b/src/shared/libosmocore/src/select.c
@@ -5,8 +5,9 @@
* (C) 2000-2009 by Harald Welte <laforge@gnumonks.org>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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