summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2011-01-05 23:48:06 +0100
committerSteve Markgraf <steve@steve-m.de>2011-01-05 23:48:06 +0100
commitd6ab52aa9a43a2fe19c3c3970a6329231da1e218 (patch)
tree53ba89ec79a1354ed116e9b978998159bec938a0 /src/shared/libosmocore
parent34bbb12b7a020865fc10d0a27b42c19ef11abcc2 (diff)
parent4a4f96d1f67441e2902a0806f1d7c4b29a072ca3 (diff)
Merge commit '4a4f96d1f67441e2902a0806f1d7c4b29a072ca3'
Diffstat (limited to 'src/shared/libosmocore')
-rw-r--r--src/shared/libosmocore/.gitignore1
-rw-r--r--src/shared/libosmocore/configure.in1
-rw-r--r--src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h23
-rw-r--r--src/shared/libosmocore/src/rate_ctr.c1
-rw-r--r--src/shared/libosmocore/src/vty/telnet_interface.c2
-rw-r--r--src/shared/libosmocore/src/vty/vty.c2
-rw-r--r--src/shared/libosmocore/tests/Makefile.am2
-rw-r--r--src/shared/libosmocore/tests/smscb/Makefile.am5
-rw-r--r--src/shared/libosmocore/tests/smscb/smscb_test.c41
9 files changed, 71 insertions, 7 deletions
diff --git a/src/shared/libosmocore/.gitignore b/src/shared/libosmocore/.gitignore
index 455440fa..d39ae4a8 100644
--- a/src/shared/libosmocore/.gitignore
+++ b/src/shared/libosmocore/.gitignore
@@ -29,3 +29,4 @@ tests/sms/sms_test
tests/timer/timer_test
tests/msgfile/msgfile_test
tests/ussd/ussd_test
+tests/smscb/smscb_test
diff --git a/src/shared/libosmocore/configure.in b/src/shared/libosmocore/configure.in
index 825152d3..309aa034 100644
--- a/src/shared/libosmocore/configure.in
+++ b/src/shared/libosmocore/configure.in
@@ -116,4 +116,5 @@ AC_OUTPUT(
tests/sms/Makefile
tests/msgfile/Makefile
tests/ussd/Makefile
+ tests/smscb/Makefile
Makefile)
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h b/src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h
index 250d6675..3b1b7c9f 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h
+++ b/src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h
@@ -3,15 +3,15 @@
#include <stdint.h>
-/* GSM TS 03.41 definitions */
+/* GSM TS 03.41 definitions also TS 23.041*/
/* Chapter 9.3.2 */
struct gsm341_ms_message {
struct {
uint8_t code_hi:6;
uint8_t gs:2;
- uint8_t update:2;
- uint8_t code_lo:6;
+ uint8_t update:4;
+ uint8_t code_lo:4;
} serial;
uint16_t msg_id;
struct {
@@ -25,6 +25,23 @@ struct gsm341_ms_message {
uint8_t data[0];
} __attribute__((packed));
+/* Chapter 9.4.1.3 */
+struct gsm341_etws_message {
+ struct {
+ uint8_t code_hi:4;
+ uint8_t popup:1;
+ uint8_t alert:1;
+ uint8_t gs:2;
+ uint8_t update:4;
+ uint8_t code_lo:4;
+ } serial;
+ uint16_t msg_id;
+ uint16_t warning_type;
+ uint8_t data[0];
+} __attribute__((packed));
+
+#define GSM341_MSG_CODE(ms) (ms->serial.code_lo | (msg->serial.code_hi << 4))
+
/* Section 9.3.2.1 - Geographical Scope */
#define GSM341_GS_CELL_WIDE_IMMED 0
#define GSM341_GS_PLMN_WIDE 1
diff --git a/src/shared/libosmocore/src/rate_ctr.c b/src/shared/libosmocore/src/rate_ctr.c
index f58b5c4a..80ef55b2 100644
--- a/src/shared/libosmocore/src/rate_ctr.c
+++ b/src/shared/libosmocore/src/rate_ctr.c
@@ -21,7 +21,6 @@
*/
#include <stdint.h>
-#include <inttypes.h>
#include <string.h>
#include <osmocore/utils.h>
diff --git a/src/shared/libosmocore/src/vty/telnet_interface.c b/src/shared/libosmocore/src/vty/telnet_interface.c
index 1523a899..098fa2e6 100644
--- a/src/shared/libosmocore/src/vty/telnet_interface.c
+++ b/src/shared/libosmocore/src/vty/telnet_interface.c
@@ -70,7 +70,7 @@ int telnet_init(void *tall_ctx, void *priv, int port)
sock_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
rc = bind(fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr));
- if (bind < 0) {
+ if (rc < 0) {
LOGP(0, LOGL_ERROR, "Telnet interface failed to bind\n");
close(fd);
return rc;
diff --git a/src/shared/libosmocore/src/vty/vty.c b/src/shared/libosmocore/src/vty/vty.c
index 5c5a908d..a5b16dce 100644
--- a/src/shared/libosmocore/src/vty/vty.c
+++ b/src/shared/libosmocore/src/vty/vty.c
@@ -306,7 +306,7 @@ static void vty_prompt(struct vty *vty)
const char *hostname;
if (vty->type == VTY_TERM) {
- hostname = host.name;
+ hostname = host.app_info->name;
if (!hostname) {
uname(&names);
hostname = names.nodename;
diff --git a/src/shared/libosmocore/tests/Makefile.am b/src/shared/libosmocore/tests/Makefile.am
index 0166b4f2..2b4ac6e6 100644
--- a/src/shared/libosmocore/tests/Makefile.am
+++ b/src/shared/libosmocore/tests/Makefile.am
@@ -1,5 +1,5 @@
if ENABLE_TESTS
-SUBDIRS = timer sms ussd
+SUBDIRS = timer sms ussd smscb
if ENABLE_MSGFILE
SUBDIRS += msgfile
endif
diff --git a/src/shared/libosmocore/tests/smscb/Makefile.am b/src/shared/libosmocore/tests/smscb/Makefile.am
new file mode 100644
index 00000000..1d0e5384
--- /dev/null
+++ b/src/shared/libosmocore/tests/smscb/Makefile.am
@@ -0,0 +1,5 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/include
+noinst_PROGRAMS = smscb_test
+
+smscb_test_SOURCES = smscb_test.c
+smscb_test_LDADD = $(top_builddir)/src/libosmocore.la
diff --git a/src/shared/libosmocore/tests/smscb/smscb_test.c b/src/shared/libosmocore/tests/smscb/smscb_test.c
new file mode 100644
index 00000000..627d5a13
--- /dev/null
+++ b/src/shared/libosmocore/tests/smscb/smscb_test.c
@@ -0,0 +1,41 @@
+/*
+ * (C) 2010 Holger Hans Peter Freyther
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <osmocore/protocol/gsm_03_41.h>
+
+#include <stdio.h>
+
+static uint8_t smscb_msg[] = { 0x40, 0x10, 0x05, 0x0d, 0x01, 0x11 };
+
+int main(int argc, char **argv)
+{
+ struct gsm341_ms_message *msg;
+
+ msg = (struct gsm341_ms_message *) smscb_msg;
+ printf("(srl) GS: %d MSG_CODE: %d UPDATE: %d\n",
+ msg->serial.gs, GSM341_MSG_CODE(msg), msg->serial.update);
+ printf("(msg) msg_id: %d\n", htons(msg->msg_id));
+ printf("(dcs) group: %d language: %d\n",
+ msg->dcs.language, msg->dcs.group);
+ printf("(pge) page total: %d current: %d\n",
+ msg->page.total, msg->page.current);
+
+ return 0;
+}