[PATCH] osmo-bts[master]: use osmo_init_logging2() with proper talloc ctx

2018-04-01 Thread Neels Hofmeyr

Review at  https://gerrit.osmocom.org/7603

use osmo_init_logging2() with proper talloc ctx

Completely drop bts_log_init(), call osmo_init_logging2() directly instead: all
callers of bts_log_init() passed NULL as category string, so all it ever did
was call osmo_init_logging(). The bts_log_info is already declared in the .h.

Here and there also define a proper talloc root context instead of using NULL.

Change-Id: Ic049f77bef74123b95350bcae182a468e0086b9c
---
M doc/startup.txt
M include/osmo-bts/logging.h
M src/common/logging.c
M src/common/main.c
M src/osmo-bts-litecell15/misc/lc15bts_mgr.c
M src/osmo-bts-omldummy/main.c
M src/osmo-bts-sysmo/l1_fwd_main.c
M src/osmo-bts-sysmo/misc/sysmobts_mgr.c
M tests/agch/agch_test.c
M tests/cipher/cipher_test.c
M tests/handover/handover_test.c
M tests/meas/meas_test.c
M tests/misc/misc_test.c
M tests/paging/paging_test.c
M tests/tx_power/tx_power_test.c
15 files changed, 21 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/03/7603/1

diff --git a/doc/startup.txt b/doc/startup.txt
index cc64375..50766e4 100644
--- a/doc/startup.txt
+++ b/doc/startup.txt
@@ -6,7 +6,7 @@
 |===
 | bts-specific | main() |
 | common | bts_main() | initialization of talloc contexts
-| common | bts_log_init() | initialization of logging
+| common | osmo_init_logging2() | initialization of logging
 | common | handle_options() | common option parsing
 | bts-specific | bts_model_handle_options() | model-specific option parsing
 | common | gsm_bts_alloc() | allocation of BTS/TRX/TS data structures
diff --git a/include/osmo-bts/logging.h b/include/osmo-bts/logging.h
index 68f379c..852c383 100644
--- a/include/osmo-bts/logging.h
+++ b/include/osmo-bts/logging.h
@@ -25,8 +25,6 @@
 
 extern const struct log_info bts_log_info;
 
-int bts_log_init(const char *category_mask);
-
 /* LOGP with gsm_time prefix */
 #define LOGPGT(ss, lvl, gt, fmt, args...) \
LOGP(ss, lvl, "%s " fmt, osmo_dump_gsmtime(gt), ## args)
diff --git a/src/common/logging.c b/src/common/logging.c
index a4d30e6..3315a01 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -148,13 +148,3 @@
.cat = bts_log_info_cat,
.num_cat = ARRAY_SIZE(bts_log_info_cat),
 };
-
-int bts_log_init(const char *category_mask)
-{
-   osmo_init_logging(_log_info);
-
-   if (category_mask)
-   log_parse_category_mask(osmo_stderr_target, category_mask);
-
-   return 0;
-}
diff --git a/src/common/main.c b/src/common/main.c
index 0f6f529..9121a2a 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -239,7 +239,7 @@
msgb_talloc_ctx_init(tall_bts_ctx, 100*1024);
bts_vty_info.tall_ctx = tall_bts_ctx;
 
-   bts_log_init(NULL);
+   osmo_init_logging2(tall_bts_ctx, _log_info);
vty_init(_vty_info);
ctrl_vty_init(tall_bts_ctx);
rate_ctr_init(tall_bts_ctx);
diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr.c 
b/src/osmo-bts-litecell15/misc/lc15bts_mgr.c
index 7886a5e..dbdcc9f 100644
--- a/src/osmo-bts-litecell15/misc/lc15bts_mgr.c
+++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr.c
@@ -281,12 +281,6 @@
.num_cat = ARRAY_SIZE(mgr_log_info_cat),
 };
 
-static int mgr_log_init(void)
-{
-   osmo_init_logging(_log_info);
-   return 0;
-}
-
 int main(int argc, char **argv)
 {
int rc;
@@ -294,7 +288,7 @@
tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager");
msgb_talloc_ctx_init(tall_mgr_ctx, 0);
 
-   mgr_log_init();
+   osmo_init_logging2(tall_mgr_ctx, _log_info);
 
osmo_init_ignore_signals();
signal(SIGINT, _handler);
diff --git a/src/osmo-bts-omldummy/main.c b/src/osmo-bts-omldummy/main.c
index 39f2ac2..ef94553 100644
--- a/src/osmo-bts-omldummy/main.c
+++ b/src/osmo-bts-omldummy/main.c
@@ -19,7 +19,7 @@
tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context");
msgb_talloc_ctx_init(tall_bts_ctx, 10*1024);
 
-   bts_log_init(NULL);
+   osmo_init_logging2(tall_bts_ctx, _log_info);
 
bts = gsm_bts_alloc(tall_bts_ctx, 0);
if (!bts)
diff --git a/src/osmo-bts-sysmo/l1_fwd_main.c b/src/osmo-bts-sysmo/l1_fwd_main.c
index 92d2ea4..4268629 100644
--- a/src/osmo-bts-sysmo/l1_fwd_main.c
+++ b/src/osmo-bts-sysmo/l1_fwd_main.c
@@ -169,11 +169,12 @@
struct l1fwd_hdl *l1fh;
struct femtol1_hdl *fl1h;
int rc, i;
+   void *ctx = talloc_named_const(NULL, 0, "l1_fwd");
 
printf("sizeof(GsmL1_Prim_t) = %zu\n", sizeof(GsmL1_Prim_t));
printf("sizeof(SuperFemto_Prim_t) = %zu\n", sizeof(SuperFemto_Prim_t));
 
-   bts_log_init(NULL);
+   osmo_init_logging2(ctx, bts_log_info);
 
/*
 * hack and prevent that two l1fwd-proxy/sysmobts run at the same
@@ -187,7 +188,7 @@
}
 
/* allocate new femtol1_handle */
-   fl1h = talloc_zero(NULL, struct femtol1_hdl);
+   fl1h = talloc_zero(ctx, struct femtol1_hdl);
INIT_LLIST_HEAD(>wlc_list);
 
   

[PATCH] osmo-pcu[master]: use osmo_init_logging2() with proper talloc ctx

2018-04-01 Thread Neels Hofmeyr

Review at  https://gerrit.osmocom.org/7604

use osmo_init_logging2() with proper talloc ctx

There is a duality of initialization: early_init() in bts.cpp wants to init
logging even before static instances get initialized. Make sure that
tall_pcu_ctx is initialized during early_init() as well. There is a build
context that does not seem to include bts.cpp (osmo-pcu-remote), so to be sure,
init tall_pcu_ctx as NULL and both in early_init() as well as pcu_main.cpp,
init both tall_pcu_ctx and logging if it is still NULL.

Change-Id: I2199b62d0270bd35dec2283e8f5b364b7c63915b
---
M src/bts.cpp
M src/pcu_main.cpp
M tests/alloc/AllocTest.cpp
M tests/alloc/MslotTest.cpp
M tests/bitcomp/BitcompTest.cpp
M tests/codel/codel_test.c
M tests/edge/EdgeTest.cpp
M tests/emu/pcu_emu.cpp
M tests/fn/FnTest.cpp
M tests/llc/LlcTest.cpp
M tests/ms/MsTest.cpp
M tests/rlcmac/RLCMACTest.cpp
M tests/tbf/TbfTest.cpp
M tests/types/TypesTest.cpp
14 files changed, 28 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/04/7604/1

diff --git a/src/bts.cpp b/src/bts.cpp
index 47607df..b6d0d0c 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -59,7 +59,10 @@
 * require logging already to be initialized. */
__attribute__((constructor)) static void early_init(void)
{
-   osmo_init_logging(_log_info);
+   if (!tall_pcu_ctx) {
+   tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU 
context");
+   osmo_init_logging2(tall_pcu_ctx, _log_info);
+   }
}
 }
 
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 84ade6f..5b1b1be 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -56,7 +56,7 @@
 static int config_given = 0;
 static char *config_file = strdup("osmo-pcu.cfg");
 extern struct vty_app_info pcu_vty_info;
-void *tall_pcu_ctx;
+void *tall_pcu_ctx = NULL;
 extern void *bv_tall_ctx;
 static int quit = 0;
 static int rt_prio = -1;
@@ -181,9 +181,13 @@
struct gprs_rlcmac_bts *bts;
int rc;
 
-   tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context");
-   if (!tall_pcu_ctx)
-   return -ENOMEM;
+   /* tall_pcu_ctx may already have been initialized in bts.cpp during 
early_init(). */
+   if (!tall_pcu_ctx) {
+   tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context");
+   if (!tall_pcu_ctx)
+   return -ENOMEM;
+   osmo_init_logging2(tall_pcu_ctx, _log_info);
+   }
 
bts = bts_main_data();
bts->fc_interval = 1;
@@ -259,7 +263,6 @@
 
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
 
-   osmo_init_logging(_log_info);
osmo_stats_init(tall_pcu_ctx);
rate_ctr_init(tall_pcu_ctx);
gprs_ns_set_log_ss(DNS);
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 9f6e6c4..64d6a50 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -797,7 +797,7 @@
abort();
 
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
-   osmo_init_logging(_log_info);
+   osmo_init_logging2(tall_pcu_ctx, _log_info);
log_set_use_color(osmo_stderr_target, 0);
log_set_print_filename(osmo_stderr_target, 0);
if (getenv("LOGL_DEBUG"))
diff --git a/tests/alloc/MslotTest.cpp b/tests/alloc/MslotTest.cpp
index ebe04ca..8910e52 100644
--- a/tests/alloc/MslotTest.cpp
+++ b/tests/alloc/MslotTest.cpp
@@ -155,7 +155,7 @@
 
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
 
-   osmo_init_logging(_log_info);
+   osmo_init_logging2(tall_pcu_ctx, _log_info);
log_set_use_color(osmo_stderr_target, 0);
log_set_print_filename(osmo_stderr_target, 0);
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp
index 8dd4534..98bb2cc 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -188,15 +188,15 @@
 
 int main(int argc, char **argv)
 {
-   osmo_init_logging(_log_info);
-   log_set_use_color(osmo_stderr_target, 0);
-   log_set_print_filename(osmo_stderr_target, 0);
-   log_parse_category_mask(osmo_stderr_target, "DRLCMACUL,1");
-
tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile bitcompTest 
context");
if (!tall_pcu_ctx)
abort();
 
+   osmo_init_logging2(tall_pcu_ctx, _log_info);
+   log_set_use_color(osmo_stderr_target, 0);
+   log_set_print_filename(osmo_stderr_target, 0);
+   log_parse_category_mask(osmo_stderr_target, "DRLCMACUL,1");
+
test_EPDAN_decode_tree();
 
if (getenv("TALLOC_REPORT_FULL"))
diff --git a/tests/codel/codel_test.c b/tests/codel/codel_test.c
index 91bad13..2ce2429 100644
--- a/tests/codel/codel_test.c
+++ b/tests/codel/codel_test.c
@@ -134,7 +134,7 @@
 
 int main(int argc, char **argv)
 {
-   osmo_init_logging();
+   osmo_init_logging2(NULL, );

[PATCH] osmo-mgw[master]: use osmo_init_logging2() with proper talloc ctx

2018-04-01 Thread Neels Hofmeyr

Review at  https://gerrit.osmocom.org/7602

use osmo_init_logging2() with proper talloc ctx

Change-Id: I3e2a9aef5242efdf11a64536f79099a6e9cec53f
---
M src/osmo-bsc_mgcp/mgcp_main.c
M src/osmo-mgw/mgw_main.c
M tests/legacy_mgcp/mgcp_test.c
M tests/legacy_mgcp/mgcp_transcoding_test.c
M tests/mgcp/mgcp_test.c
M tests/mgcp_client/mgcp_client_test.c
6 files changed, 11 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/02/7602/1

diff --git a/src/osmo-bsc_mgcp/mgcp_main.c b/src/osmo-bsc_mgcp/mgcp_main.c
index 91f9074..edb19a6 100644
--- a/src/osmo-bsc_mgcp/mgcp_main.c
+++ b/src/osmo-bsc_mgcp/mgcp_main.c
@@ -244,7 +244,7 @@
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
 
osmo_init_ignore_signals();
-   osmo_init_logging(_info);
+   osmo_init_logging2(tall_bsc_ctx, _info);
 
cfg = mgcp_config_alloc();
if (!cfg)
diff --git a/src/osmo-mgw/mgw_main.c b/src/osmo-mgw/mgw_main.c
index 7762032..de094c1 100644
--- a/src/osmo-mgw/mgw_main.c
+++ b/src/osmo-mgw/mgw_main.c
@@ -262,7 +262,7 @@
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
 
osmo_init_ignore_signals();
-   osmo_init_logging(_info);
+   osmo_init_logging2(tall_bsc_ctx, _info);
 
cfg = mgcp_config_alloc();
if (!cfg)
diff --git a/tests/legacy_mgcp/mgcp_test.c b/tests/legacy_mgcp/mgcp_test.c
index 1a4513e..39400d4 100644
--- a/tests/legacy_mgcp/mgcp_test.c
+++ b/tests/legacy_mgcp/mgcp_test.c
@@ -1214,8 +1214,9 @@
 
 int main(int argc, char **argv)
 {
-   void *msgb_ctx = msgb_talloc_ctx_init(NULL, 0);
-   osmo_init_logging(_info);
+   void *ctx = talloc_named_const(NULL, 0, "mgcp_test");
+   void *msgb_ctx = msgb_talloc_ctx_init(ctx, 0);
+   osmo_init_logging2(ctx, _info);
 
test_strline();
test_values();
diff --git a/tests/legacy_mgcp/mgcp_transcoding_test.c 
b/tests/legacy_mgcp/mgcp_transcoding_test.c
index 61de25f..d3f94c7 100644
--- a/tests/legacy_mgcp/mgcp_transcoding_test.c
+++ b/tests/legacy_mgcp/mgcp_transcoding_test.c
@@ -588,7 +588,8 @@
 int main(int argc, char **argv)
 {
int rc;
-   osmo_init_logging(_info);
+   void *ctx = talloc_named_const(NULL, 0, "mgcp_transcoding_test");
+   osmo_init_logging2(ctx, _info);
 
printf("=== Transcoding Good Cases ===\n");
 
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index e1e6290..f6c421a 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -1467,8 +1467,9 @@
 
 int main(int argc, char **argv)
 {
-   void *msgb_ctx = msgb_talloc_ctx_init(NULL, 0);
-   osmo_init_logging(_info);
+   void *ctx = talloc_named_const(NULL, 0, "mgcp_test");
+   void *msgb_ctx = msgb_talloc_ctx_init(ctx, 0);
+   osmo_init_logging2(ctx, _info);
 
test_strline();
test_values();
diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index 19b55e2..007b90c 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -389,7 +389,7 @@
 {
ctx = talloc_named_const(NULL, 1, "mgcp_client_test");
msgb_talloc_ctx_init(ctx, 0);
-   osmo_init_logging(_info);
+   osmo_init_logging2(ctx, _info);
log_set_print_filename(osmo_stderr_target, 0);
log_set_print_timestamp(osmo_stderr_target, 0);
log_set_use_color(osmo_stderr_target, 0);

-- 
To view, visit https://gerrit.osmocom.org/7602
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e2a9aef5242efdf11a64536f79099a6e9cec53f
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


osmo-ttcn3-hacks[master]: support ccache to speed up ttcn3 test compilation

2018-04-01 Thread Neels Hofmeyr

Patch Set 4: Code-Review+1

(1 comment)

I'd +2 but let's give others a chance to comment

https://gerrit.osmocom.org/#/c/7601/4/regen-makefile.sh
File regen-makefile.sh:

Line 51: if [ -n "$USE_CCACHE" ]; then
(if I set my env to 'USE_CCACHE=0' then this still evaluates true. slightly 
nicer would be 'if [ "x$USE_CCACHE" = "x1" ]')


-- 
To view, visit https://gerrit.osmocom.org/7601
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibb538f602206535c06980f88191c1dabe3c4cd82
Gerrit-PatchSet: 4
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: Yes


osmo-ttcn3-hacks[master]: support ccache to speed up ttcn3 test compilation

2018-04-01 Thread Stefan Sperling

Patch Set 1:

> Uploaded patch set 2.

I chose to add a separate sed script instead of another shell script.
Either way, the process used here should be easier to understand now.

-- 
To view, visit https://gerrit.osmocom.org/7601
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibb538f602206535c06980f88191c1dabe3c4cd82
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


[PATCH] osmo-ttcn3-hacks[master]: support ccache to speed up ttcn3 test compilation

2018-04-01 Thread Stefan Sperling
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7601

to look at the new patch set (#3).

support ccache to speed up ttcn3 test compilation

If ccache exists in PATH, use it to cache compiled C++ object files.

Rebuilding the test suite from scratch with a populated cache
is an order of magnitude faster than doing an initial build.
In my case, compile time for BSC_Tests goes down from 3 minutes
and 12 seconds to just 3 seconds, after 'make clean'.

There is a small downside: We need to tweak the generated C++ files
to prevent cache misses due to timestamps inserted into the code
by ttcn3_compiler. This is done by regen-makefile.sh if ccache
is used. This mechanism could break in case the output of
ttcn3_makefilegen changes. However, the only consequence would
be a slow build due to cache misses.

Another thing to note is that builds using objects from ccache
will contain timestamp strings from the build which populated
the cache. ccache provides a way to repopulate the cache if
needed though (set CCACHE_RECACHE=1 in the environment).

These tradeoffs seem acceptable to me since in return we can
achieve much faster turnaround, both during local test
development and during test runs on jenkins.

Change-Id: Ibb538f602206535c06980f88191c1dabe3c4cd82
---
M regen-makefile.sh
A strip-datetime-comments.sed
2 files changed, 63 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/01/7601/3

diff --git a/regen-makefile.sh b/regen-makefile.sh
index 57eebff..2d09e63 100755
--- a/regen-makefile.sh
+++ b/regen-makefile.sh
@@ -12,7 +12,22 @@
 
 test -x "$(which ttcn3_makefilegen 2>/dev/null)" || { echo "ERROR: 
ttcn3_makefilegen not in PATH"; exit 1; }
 
-ttcn3_makefilegen -p -l -f $*
+# Enable ccache if it can be found in path.
+# This speeds up repeated builds of the TTCN3 tests by an order of magnitude
+# since most of the generated C++ source files don't change very often.
+# Roughly, for an initial build which takes N minutes, a complete rebuild
+# after 'make clean' will only take N seconds with ccache.
+# Note that ccache cannot cache compilation of .o files to .so files, so do
+# not pass the -l option to ttcn3_makefilegen if ccache is used. The time
+# savings promised by the -l option are dwarfed by use of ccache anyway.
+if which ccache 2>/dev/null; then
+   USE_CCACHE=1
+   MAKEFILEGEN_FLAGS="-p -f"
+else
+   MAKEFILEGEN_FLAGS="-p -l -f"
+fi
+
+ttcn3_makefilegen $MAKEFILEGEN_FLAGS $*
 sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
 sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan /' Makefile
 #sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile
@@ -32,3 +47,11 @@
 sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr/' Makefile
 fi
 sed -i -e 's/\/bin\/compiler/\/bin\/ttcn3_compiler/' Makefile
+
+if [ -n "$USE_CCACHE" ]; then
+   # enable ccache
+   sed -i -e 's/^CXX = g++ $/CXX = env CCACHE_SLOPPINESS=time_macros 
ccache g++/' Makefile
+   # The Makefile must tweak generated C++ files during the 'make compile' 
step.
+   # See the strip-datetime-comments sed script for details.
+   sed -i -f ../strip-datetime-comments.sed Makefile
+fi
diff --git a/strip-datetime-comments.sed b/strip-datetime-comments.sed
new file mode 100644
index 000..217dedc
--- /dev/null
+++ b/strip-datetime-comments.sed
@@ -0,0 +1,39 @@
+#!/usr/bin/sed
+# This sed script edits a Makefile generated by ttcn3_makefilegen.
+# We insert a sed command into the 'compile:' target in order to
+# remove timestamp comments from generated C++ files.
+
+# The ttcn3_compiler will generate C++ comments with a timestamp, such as:
+#   // for Stefan Sperling (stsp@fintan) on Sat Mar 31 14:34:30 2018
+# We must remove such comments since they cause cache misses with ccache.
+#
+# A related problem is the use of __DATE__ and __TIME__ in generated C++ code,
+# which can be worked around by setting "CCACHE_SLOPPINESS=time_macros". This
+# workaround implies that we must get our cache hits from ccache's "direct"
+# cache, since ccache's "preprocessor" caching method won't work.
+#
+# FIXME: This should really be addressed in ttcn3_compiler itself!
+# It should provide an option to suppress use of timestamps in generated code.
+
+# The generated Makefile's compile target looks like this:
+#
+# compile: $(TTCN3_MODULES)  $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES)
+#  $(TTCN3_DIR)/bin/ttcn3_compiler $(COMPILER_FLAGS) \
+#  $(TTCN3_MODULES) $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES) - $?
+#  touch $@
+#
+# Before the final 'touch $@' step, we now insert a `sed` command that strips
+# offending C++ comments from the generated code.
+
+# match the line in the generated Makefile which starts with 'compile:'
+/^compile:/ {
+   # go to the next line
+   n;
+   # go to the next line
+   n;
+   # go to the next line
+   n;
+   # on this 

osmo-ttcn3-hacks[master]: support ccache to speed up ttcn3 test compilation

2018-04-01 Thread Stefan Sperling

Patch Set 1:

I agree on all suggestions, except one:

Posix specifies that sed supports more than one input file:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html

Both the GNU sed and OpenBSD sed implementations support multiple input files.

Passing each file to sed individually would probably slow down the 'make 
compile' step unnecessarily.

-- 
To view, visit https://gerrit.osmocom.org/7601
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibb538f602206535c06980f88191c1dabe3c4cd82
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


[PATCH] osmo-ttcn3-hacks[master]: support ccache to speed up ttcn3 test compilation

2018-04-01 Thread Stefan Sperling
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7601

to look at the new patch set (#2).

support ccache to speed up ttcn3 test compilation

If ccache exists in PATH, use it to cache compiled C++ object files.

Rebuilding the test suite from scratch with a populated cache
is an order of magnitude faster than doing an initial build.
In my case, compile time for BSC_Tests goes down from 3 minutes
and 12 seconds to just 3 seconds, after 'make clean'.

There is a small downside: We need to tweak the generated C++ files
to prevent cache misses due to timestemps inserted into the code
by ttcn3_compiler. This is done by regen-makefile.sh if ccache
is used. This mechanism could break in case the output of
ttcn3_makefilegen changes. However, the only consequence would
be a slow build due to cache misses.

Another thing to note is that builds using objects from ccache
will contain timestamp strings from the build which populated
the cache. ccache provides a way to repopulate the cache if
needed though (set CCACHE_RECACHE=1 in the environment).

These tradeoffs seem acceptable to me since in return we can
achieve much faster turnaround, both during local test
development and during test runs on jenkins.

Change-Id: Ibb538f602206535c06980f88191c1dabe3c4cd82
---
M regen-makefile.sh
A strip-datetime-comments.sed
2 files changed, 63 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/01/7601/2

diff --git a/regen-makefile.sh b/regen-makefile.sh
index 57eebff..2d09e63 100755
--- a/regen-makefile.sh
+++ b/regen-makefile.sh
@@ -12,7 +12,22 @@
 
 test -x "$(which ttcn3_makefilegen 2>/dev/null)" || { echo "ERROR: 
ttcn3_makefilegen not in PATH"; exit 1; }
 
-ttcn3_makefilegen -p -l -f $*
+# Enable ccache if it can be found in path.
+# This speeds up repeated builds of the TTCN3 tests by an order of magnitude
+# since most of the generated C++ source files don't change very often.
+# Roughly, for an initial build which takes N minutes, a complete rebuild
+# after 'make clean' will only take N seconds with ccache.
+# Note that ccache cannot cache compilation of .o files to .so files, so do
+# not pass the -l option to ttcn3_makefilegen if ccache is used. The time
+# savings promised by the -l option are dwarfed by use of ccache anyway.
+if which ccache 2>/dev/null; then
+   USE_CCACHE=1
+   MAKEFILEGEN_FLAGS="-p -f"
+else
+   MAKEFILEGEN_FLAGS="-p -l -f"
+fi
+
+ttcn3_makefilegen $MAKEFILEGEN_FLAGS $*
 sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
 sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan /' Makefile
 #sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile
@@ -32,3 +47,11 @@
 sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr/' Makefile
 fi
 sed -i -e 's/\/bin\/compiler/\/bin\/ttcn3_compiler/' Makefile
+
+if [ -n "$USE_CCACHE" ]; then
+   # enable ccache
+   sed -i -e 's/^CXX = g++ $/CXX = env CCACHE_SLOPPINESS=time_macros 
ccache g++/' Makefile
+   # The Makefile must tweak generated C++ files during the 'make compile' 
step.
+   # See the strip-datetime-comments sed script for details.
+   sed -i -f ../strip-datetime-comments.sed Makefile
+fi
diff --git a/strip-datetime-comments.sed b/strip-datetime-comments.sed
new file mode 100644
index 000..217dedc
--- /dev/null
+++ b/strip-datetime-comments.sed
@@ -0,0 +1,39 @@
+#!/usr/bin/sed
+# This sed script edits a Makefile generated by ttcn3_makefilegen.
+# We insert a sed command into the 'compile:' target in order to
+# remove timestamp comments from generated C++ files.
+
+# The ttcn3_compiler will generate C++ comments with a timestamp, such as:
+#   // for Stefan Sperling (stsp@fintan) on Sat Mar 31 14:34:30 2018
+# We must remove such comments since they cause cache misses with ccache.
+#
+# A related problem is the use of __DATE__ and __TIME__ in generated C++ code,
+# which can be worked around by setting "CCACHE_SLOPPINESS=time_macros". This
+# workaround implies that we must get our cache hits from ccache's "direct"
+# cache, since ccache's "preprocessor" caching method won't work.
+#
+# FIXME: This should really be addressed in ttcn3_compiler itself!
+# It should provide an option to suppress use of timestamps in generated code.
+
+# The generated Makefile's compile target looks like this:
+#
+# compile: $(TTCN3_MODULES)  $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES)
+#  $(TTCN3_DIR)/bin/ttcn3_compiler $(COMPILER_FLAGS) \
+#  $(TTCN3_MODULES) $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES) - $?
+#  touch $@
+#
+# Before the final 'touch $@' step, we now insert a `sed` command that strips
+# offending C++ comments from the generated code.
+
+# match the line in the generated Makefile which starts with 'compile:'
+/^compile:/ {
+   # go to the next line
+   n;
+   # go to the next line
+   n;
+   # go to the next line
+   n;
+   # on this 

[MERGED] osmo-ttcn3-hacks[master]: improve documentation of templates used in GGSN_Tests

2018-04-01 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: improve documentation of templates used in GGSN_Tests
..


improve documentation of templates used in GGSN_Tests

Various improvements to the comments documenting packet templates
used in GGSN_Tests: fix IPv4 vs. IPv6 confusion, clearly indicate
whether templates are used for sending or for receiving/matching
packets, and add a missing comment.

Found while studying code to prepare for issue OS#2519.

Change-Id: I3bfc21a5ba74e0505457e4874f93501ad7c68b7b
Related: OS#2519
---
M ggsn_tests/GGSN_Tests.ttcn
1 file changed, 8 insertions(+), 7 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn
index f320c20..2b7de96 100644
--- a/ggsn_tests/GGSN_Tests.ttcn
+++ b/ggsn_tests/GGSN_Tests.ttcn
@@ -227,7 +227,7 @@
/* IPv6 neighbor solicitation fe80::2 -> ff02::1:ff00:2 from 
02:88:b5:1f:25:59 */
const octetstring c_neigh_solicit:= 
'60203afffe82ff020001ff0287009f96fe8201010288b51f2559'O;
 
-   /* template for an ICMPv6 echo request */
+   /* template for sending an ICMPv4 echo request */
template PDU_ICMP ts_ICMPv4_ERQ := {
echo := {
type_field := 8,
@@ -239,7 +239,7 @@
}
}
 
-   /* template for an ICMPv6 echo request */
+   /* template for receiving/matching an ICMPv4 echo request */
template PDU_ICMP tr_ICMPv4_ERQ := {
echo := {
type_field := 8,
@@ -251,7 +251,7 @@
}
}
 
-   /* template for an ICMPv4 echo reply */
+   /* template for receiving/matching an ICMPv4 echo reply */
template PDU_ICMP tr_ICMPv4_ERP(template octetstring data := *) := {
echo_reply := {
type_field := 0,
@@ -312,7 +312,7 @@
}
}
 
-   /* template for an ICMPv6 echo request */
+   /* template for sending an ICMPv6 echo request */
template PDU_ICMPv6 ts_ICMPv6_ERQ := {
echoRequest := {
typeField := 128,
@@ -324,7 +324,7 @@
}
}
 
-   /* template for an ICMPv6 router solicitation */
+   /* template for sending an ICMPv6 router solicitation */
template PDU_ICMPv6 ts_ICMPv6_RS := {
routerSolicitation := {
typeField := 133,
@@ -336,7 +336,7 @@
}
}
 
-   /* template for an ICMPv6 router advertisement */
+   /* template for sending an ICMPv6 router advertisement */
template PDU_ICMPv6 ts_ICMPv6_RA(OCT16 prefix, INT1 prefix_len) := {
routerAdvertisement := {
typeField := 134,
@@ -355,6 +355,7 @@
}
}
 
+   /* template for sending an ICMPv6 neighbor solicitation */
template PDU_ICMPv6 ts_ICMPv6_NS(OCT16 target_addr) := {
neighborSolicitation := {
typeField := 135,
@@ -414,7 +415,7 @@
}
}
 
-   /* template for an ICMPv6 echo request */
+   /* template for receiving/matching an ICMPv6 echo request */
template PDU_ICMPv6 tr_ICMPv6_ERQ := {
echoRequest := {
typeField := 128,

-- 
To view, visit https://gerrit.osmocom.org/7598
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3bfc21a5ba74e0505457e4874f93501ad7c68b7b
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 


osmo-ttcn3-hacks[master]: improve documentation of templates used in GGSN_Tests

2018-04-01 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/7598
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3bfc21a5ba74e0505457e4874f93501ad7c68b7b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] osmo-ttcn3-hacks[master]: support ccache to speed up ttcn3 test compilation

2018-04-01 Thread Stefan Sperling
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7601

to look at the new patch set (#4).

support ccache to speed up ttcn3 test compilation

If ccache exists in PATH, use it to cache compiled C++ object files.

Rebuilding the test suite from scratch with a populated cache
is an order of magnitude faster than doing an initial build.
In my case, compile time for BSC_Tests goes down from 3 minutes
and 12 seconds to just 3 seconds, after 'make clean'.

There is a small downside: We need to tweak the generated C++ files
to prevent cache misses due to timestamps inserted into the code
by ttcn3_compiler. This is done by regen-makefile.sh if ccache
is used. This mechanism could break in case the output of
ttcn3_makefilegen changes. However, the only consequence would
be a slow build due to cache misses.

Another thing to note is that builds using objects from ccache
will contain timestamp strings from the build which populated
the cache. ccache provides a way to repopulate the cache if
needed though (set CCACHE_RECACHE=1 in the environment).

These tradeoffs seem acceptable to me since in return we can
achieve much faster turnaround, both during local test
development and during test runs on jenkins.

Change-Id: Ibb538f602206535c06980f88191c1dabe3c4cd82
---
M regen-makefile.sh
A strip-datetime-comments.sed
2 files changed, 69 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/01/7601/4

diff --git a/regen-makefile.sh b/regen-makefile.sh
index 57eebff..2d09e63 100755
--- a/regen-makefile.sh
+++ b/regen-makefile.sh
@@ -12,7 +12,22 @@
 
 test -x "$(which ttcn3_makefilegen 2>/dev/null)" || { echo "ERROR: 
ttcn3_makefilegen not in PATH"; exit 1; }
 
-ttcn3_makefilegen -p -l -f $*
+# Enable ccache if it can be found in path.
+# This speeds up repeated builds of the TTCN3 tests by an order of magnitude
+# since most of the generated C++ source files don't change very often.
+# Roughly, for an initial build which takes N minutes, a complete rebuild
+# after 'make clean' will only take N seconds with ccache.
+# Note that ccache cannot cache compilation of .o files to .so files, so do
+# not pass the -l option to ttcn3_makefilegen if ccache is used. The time
+# savings promised by the -l option are dwarfed by use of ccache anyway.
+if which ccache 2>/dev/null; then
+   USE_CCACHE=1
+   MAKEFILEGEN_FLAGS="-p -f"
+else
+   MAKEFILEGEN_FLAGS="-p -l -f"
+fi
+
+ttcn3_makefilegen $MAKEFILEGEN_FLAGS $*
 sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
 sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan /' Makefile
 #sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile
@@ -32,3 +47,11 @@
 sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr/' Makefile
 fi
 sed -i -e 's/\/bin\/compiler/\/bin\/ttcn3_compiler/' Makefile
+
+if [ -n "$USE_CCACHE" ]; then
+   # enable ccache
+   sed -i -e 's/^CXX = g++ $/CXX = env CCACHE_SLOPPINESS=time_macros 
ccache g++/' Makefile
+   # The Makefile must tweak generated C++ files during the 'make compile' 
step.
+   # See the strip-datetime-comments sed script for details.
+   sed -i -f ../strip-datetime-comments.sed Makefile
+fi
diff --git a/strip-datetime-comments.sed b/strip-datetime-comments.sed
new file mode 100644
index 000..8089b8e
--- /dev/null
+++ b/strip-datetime-comments.sed
@@ -0,0 +1,45 @@
+#!/usr/bin/sed
+# (C) 2018 by sysmocom s.f.m.c. GmbH 
+# Author: Stefan Sperling 
+# All rights reserved.
+# Released under the terms of GNU General Public License, Version 2 or
+# (at your option) any later version.
+
+# This sed script edits a Makefile generated by ttcn3_makefilegen.
+# We insert a sed command into the 'compile:' target in order to
+# remove timestamp comments from generated C++ files.
+
+# The ttcn3_compiler will generate C++ comments with a timestamp, such as:
+#   // for Stefan Sperling (stsp@fintan) on Sat Mar 31 14:34:30 2018
+# We must remove such comments since they cause cache misses with ccache.
+#
+# A related problem is the use of __DATE__ and __TIME__ in generated C++ code,
+# which can be worked around by setting "CCACHE_SLOPPINESS=time_macros". This
+# workaround implies that we must get our cache hits from ccache's "direct"
+# cache, since ccache's "preprocessor" caching method won't work.
+#
+# FIXME: This should really be addressed in ttcn3_compiler itself!
+# It should provide an option to suppress use of timestamps in generated code.
+
+# The generated Makefile's compile target looks like this:
+#
+# compile: $(TTCN3_MODULES)  $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES)
+#  $(TTCN3_DIR)/bin/ttcn3_compiler $(COMPILER_FLAGS) \
+#  $(TTCN3_MODULES) $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES) - $?
+#  touch $@
+#
+# Before the final 'touch $@' step, we now insert a `sed` command that strips
+# offending C++ comments from the 

osmo-ttcn3-hacks[master]: support ccache to speed up ttcn3 test compilation

2018-04-01 Thread Stefan Sperling

Patch Set 1:

Oh bummer, just noticed that since the -i option isn't specified in Posix, 
brining up Posix doesn't actually help my argument much :)

However, both GNU and OpenBSD implement 'sed -i' in the same way when mulitple 
files are passed (all input files are modified in the same way). It does not 
seem unreasonable to rely on this behaviour.

-- 
To view, visit https://gerrit.osmocom.org/7601
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibb538f602206535c06980f88191c1dabe3c4cd82
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


libosmocore[master]: GSUP: add USSD encoding / decoding support

2018-04-01 Thread Vadim Yanitskiy

Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/7600/1/include/osmocom/gsm/gsup.h
File include/osmocom/gsm/gsup.h:

Line 85:OSMO_GSUP_USSD_IE   = 0x29,
During OsmoMSC code writing, I understood that we probably
also need another IE - OSMO_GSUP_USSD_SID_IE, that
would carry a session id.


-- 
To view, visit https://gerrit.osmocom.org/7600
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie17a78043a35fffbdd59e80fd2b2da39cce5e532
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


[PATCH] libosmocore[master]: GSUP: add USSD encoding / decoding support

2018-04-01 Thread Vadim Yanitskiy
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7600

to look at the new patch set (#2).

GSUP: add USSD encoding / decoding support

In order to be able to transfer USSD messages via GSUP, this
change introduces the new message types OSMO_GSUP_MSGT_USSD_*,
and a few new information elements:

  - OSMO_GSUP_USSD_SID_IE,
  - OSMO_GSUP_USSD_PAYLOAD_IE.

The 'osmo_gsup_message' structure was extended with a few new
fields, which carry the L3 bytes of USSD payload, its length,
and unique USSD session ID.

Change-Id: Ie17a78043a35fffbdd59e80fd2b2da39cce5e532
Related: OS#1597
---
M include/osmocom/gsm/gsup.h
M src/gsm/gsup.c
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.err
M tests/gsup/gsup_test.ok
5 files changed, 105 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/00/7600/2

diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 1a8a3b2..7b7e0ef 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -81,6 +81,9 @@
OSMO_GSUP_AUTS_IE   = 0x26,
OSMO_GSUP_RES_IE= 0x27,
OSMO_GSUP_CN_DOMAIN_IE  = 0x28,
+   /* USSD support */
+   OSMO_GSUP_USSD_SID_IE   = 0x29,
+   OSMO_GSUP_USSD_PAYLOAD_IE   = 0x30,
 };
 
 /*! GSUP message type */
@@ -110,6 +113,10 @@
OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST  = 0b00011100,
OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR= 0b00011101,
OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT   = 0b0000,
+
+   OSMO_GSUP_MSGT_USSD_REQUEST = 0b0010,
+   OSMO_GSUP_MSGT_USSD_ERROR   = 0b0011,
+   OSMO_GSUP_MSGT_USSD_RESULT  = 0b00100010,
 };
 
 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b0011) == 0b00)
@@ -175,6 +182,9 @@
enum osmo_gsup_cn_domaincn_domain;
const uint8_t   *pdp_charg_enc;
size_t  pdp_charg_enc_len;
+   const uint8_t   *ussd_payload;
+   size_t  ussd_payload_len;
+   uint32_tussd_sid;
 };
 
 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index b6ac56d..d43af9b 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -29,6 +29,7 @@
 #include 
 
 #include 
+#include 
 
 /*! \addtogroup gsup
  *  @{
@@ -62,6 +63,10 @@
OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST),
OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR),
OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT),
+
+   OSMO_VALUE_STRING(OSMO_GSUP_MSGT_USSD_REQUEST),
+   OSMO_VALUE_STRING(OSMO_GSUP_MSGT_USSD_ERROR),
+   OSMO_VALUE_STRING(OSMO_GSUP_MSGT_USSD_RESULT),
{ 0, NULL }
 };
 
@@ -261,6 +266,7 @@
 
/* specific parts */
while (data_len > 0) {
+   uint32_t *ussd_sid;
enum osmo_gsup_iei iei;
struct osmo_gsup_pdp_info pdp_info;
struct osmo_auth_vector auth_info;
@@ -385,6 +391,16 @@
gsup_msg->pdp_charg_enc_len = value_len;
break;
 
+   case OSMO_GSUP_USSD_SID_IE:
+   ussd_sid = (uint32_t *) value;
+   gsup_msg->ussd_sid = ntohl(*ussd_sid);
+   break;
+
+   case OSMO_GSUP_USSD_PAYLOAD_IE:
+   gsup_msg->ussd_payload = value;
+   gsup_msg->ussd_payload_len = value_len;
+   break;
+
default:
LOGP(DLGSUP, LOGL_NOTICE,
 "GSUP IE type %d unknown\n", iei);
@@ -483,6 +499,7 @@
int idx;
uint8_t bcd_buf[GSM48_MI_SIZE] = {0};
size_t bcd_len;
+   uint32_t ussd_sid;
 
/* generic part */
if(!gsup_msg->message_type)
@@ -564,6 +581,17 @@
gsup_msg->pdp_charg_enc_len, 
gsup_msg->pdp_charg_enc);
}
 
+   if (gsup_msg->ussd_sid) {
+   ussd_sid = htonl(gsup_msg->ussd_sid);
+   msgb_tlv_put(msg, OSMO_GSUP_USSD_SID_IE,
+   sizeof(gsup_msg->ussd_sid), (uint8_t *) _sid);
+   }
+
+   if (gsup_msg->ussd_payload) {
+   msgb_tlv_put(msg, OSMO_GSUP_USSD_PAYLOAD_IE,
+   gsup_msg->ussd_payload_len, gsup_msg->ussd_payload);
+   }
+
return 0;
 }
 
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index b55f1d9..437b07f 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -171,6 +171,56 @@
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
};
 
+   static const uint8_t send_ussd_req[] = {
+   0x20,
+   TEST_IMSI_IE,
+   /* USSD_SID_IE */
+