summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-04-09 07:54:34 +0200
committerHarald Welte <laforge@gnumonks.org>2010-04-09 07:54:34 +0200
commit2bb14aa3bbd7ddfe18ccee0b0e0a5ce608213936 (patch)
treeb61a2264d63f9b7b62ad1fbad614e503dc0c8043 /src/shared/libosmocore
parenta599e1a9caf8f6c08f155072a6a4890bd4c7e175 (diff)
parent1ef041ff1e390adcd0f97075f1ed52177b7ed3e0 (diff)
Merge commit '1ef041ff1e390adcd0f97075f1ed52177b7ed3e0'
Diffstat (limited to 'src/shared/libosmocore')
-rw-r--r--src/shared/libosmocore/include/osmocore/gsm48.h4
-rw-r--r--src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h1
-rw-r--r--src/shared/libosmocore/include/osmocore/write_queue.h1
-rw-r--r--src/shared/libosmocore/src/gsm48.c47
-rw-r--r--src/shared/libosmocore/src/gsm48_ie.c2
-rw-r--r--src/shared/libosmocore/src/write_queue.c3
6 files changed, 55 insertions, 3 deletions
diff --git a/src/shared/libosmocore/include/osmocore/gsm48.h b/src/shared/libosmocore/include/osmocore/gsm48.h
index 1e963573..b752ee00 100644
--- a/src/shared/libosmocore/include/osmocore/gsm48.h
+++ b/src/shared/libosmocore/include/osmocore/gsm48.h
@@ -14,4 +14,8 @@ void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc,
int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi);
int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi);
+/* Convert Mobile Identity (10.5.1.4) to string */
+int gsm48_mi_to_string(char *string, const int str_len,
+ const u_int8_t *mi, const int mi_len);
+
#endif
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h b/src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h
index 801b9b54..47b98b29 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h
+++ b/src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h
@@ -685,6 +685,7 @@ enum chreq_type {
/* Chapter 5.1.2.2 */
#define GSM_CSTATE_NULL 0
#define GSM_CSTATE_INITIATED 1
+#define GSM_CSTATE_MM_CONNECTION_PEND 2 /* see 10.5.4.6 */
#define GSM_CSTATE_MO_CALL_PROC 3
#define GSM_CSTATE_CALL_DELIVERED 4
#define GSM_CSTATE_CALL_PRESENT 6
diff --git a/src/shared/libosmocore/include/osmocore/write_queue.h b/src/shared/libosmocore/include/osmocore/write_queue.h
index 64d4159a..ef244c32 100644
--- a/src/shared/libosmocore/include/osmocore/write_queue.h
+++ b/src/shared/libosmocore/include/osmocore/write_queue.h
@@ -35,6 +35,7 @@ struct write_queue {
int (*read_cb)(struct bsc_fd *fd);
int (*write_cb)(struct bsc_fd *fd, struct msgb *msg);
+ int (*except_cb)(struct bsc_fd *fd);
};
void write_queue_init(struct write_queue *queue, int max_length);
diff --git a/src/shared/libosmocore/src/gsm48.c b/src/shared/libosmocore/src/gsm48.c
index 5761c67b..e0cba15e 100644
--- a/src/shared/libosmocore/src/gsm48.c
+++ b/src/shared/libosmocore/src/gsm48.c
@@ -97,10 +97,10 @@ static const struct value_string rr_cause_names[] = {
};
/* FIXME: convert to value_string */
-static const char *cc_state_names[32] = {
+static const char *cc_state_names[33] = {
"NULL",
"INITIATED",
- "illegal state 2",
+ "MM_CONNECTION_PEND",
"MO_CALL_PROC",
"CALL_DELIVERED",
"illegal state 5",
@@ -261,3 +261,46 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi)
return 2 + buf[1];
}
+
+/* Convert Mobile Identity (10.5.1.4) to string */
+int gsm48_mi_to_string(char *string, const int str_len, const u_int8_t *mi, const int mi_len)
+{
+ int i;
+ u_int8_t mi_type;
+ char *str_cur = string;
+ u_int32_t tmsi;
+
+ mi_type = mi[0] & GSM_MI_TYPE_MASK;
+
+ switch (mi_type) {
+ case GSM_MI_TYPE_NONE:
+ break;
+ case GSM_MI_TYPE_TMSI:
+ /* Table 10.5.4.3, reverse generate_mid_from_tmsi */
+ if (mi_len == GSM48_TMSI_LEN && mi[0] == (0xf0 | GSM_MI_TYPE_TMSI)) {
+ memcpy(&tmsi, &mi[1], 4);
+ tmsi = ntohl(tmsi);
+ return snprintf(string, str_len, "%u", tmsi);
+ }
+ break;
+ case GSM_MI_TYPE_IMSI:
+ case GSM_MI_TYPE_IMEI:
+ case GSM_MI_TYPE_IMEISV:
+ *str_cur++ = bcd2char(mi[0] >> 4);
+
+ for (i = 1; i < mi_len; i++) {
+ if (str_cur + 2 >= string + str_len)
+ return str_cur - string;
+ *str_cur++ = bcd2char(mi[i] & 0xf);
+ /* skip last nibble in last input byte when GSM_EVEN */
+ if( (i != mi_len-1) || (mi[0] & GSM_MI_ODD))
+ *str_cur++ = bcd2char(mi[i] >> 4);
+ }
+ break;
+ default:
+ break;
+ }
+ *str_cur++ = '\0';
+
+ return str_cur - string;
+}
diff --git a/src/shared/libosmocore/src/gsm48_ie.c b/src/shared/libosmocore/src/gsm48_ie.c
index 4ca5fb80..3c2a1f7b 100644
--- a/src/shared/libosmocore/src/gsm48_ie.c
+++ b/src/shared/libosmocore/src/gsm48_ie.c
@@ -2,7 +2,7 @@
* 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
- * (C) 2008-2010 by Andreas Eversberg
+ * (C) 2009-2010 by Andreas Eversberg
*
* All Rights Reserved
*
diff --git a/src/shared/libosmocore/src/write_queue.c b/src/shared/libosmocore/src/write_queue.c
index a0ac2d6f..618a8c0b 100644
--- a/src/shared/libosmocore/src/write_queue.c
+++ b/src/shared/libosmocore/src/write_queue.c
@@ -32,6 +32,9 @@ int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what)
if (what & BSC_FD_READ)
queue->read_cb(fd);
+ if (what & BSC_FD_EXCEPT)
+ queue->except_cb(fd);
+
if (what & BSC_FD_WRITE) {
struct msgb *msg;