aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-08-29 16:47:30 +0200
committerHarald Welte <laforge@gnumonks.org>2012-08-29 16:47:30 +0200
commit7c8e2cc7aca1a789bbcf989a14be177d59041959 (patch)
tree6c62b671a97cddb8eb96c9d95d4dd8ec7b2461a4 /src
parentb5372ab110b08b9a2e250a68d484e3c147586b21 (diff)
libosmogsm: Back-port SMS related fixes from openbsc
This was fixed in 9c3dc90d16a40789081c84e46620f4d66689fec1 of openbsc.git, after the sms code had been migrated here: introduce HAVE_TM_GMTOFF_IN_TM Not all architectures have the tm.tm_gmtoff member. This fixes cygwin builds.
Diffstat (limited to 'src')
-rw-r--r--src/gsm/gsm0411_utils.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gsm/gsm0411_utils.c b/src/gsm/gsm0411_utils.c
index 5076ec82..ebde8fca 100644
--- a/src/gsm/gsm0411_utils.c
+++ b/src/gsm/gsm0411_utils.c
@@ -25,6 +25,7 @@
*
*/
+#include "../../config.h"
#include <time.h>
#include <string.h>
@@ -80,7 +81,12 @@ void gsm340_gen_scts(uint8_t *scts, time_t time)
*scts++ = gsm411_bcdify(tm->tm_hour);
*scts++ = gsm411_bcdify(tm->tm_min);
*scts++ = gsm411_bcdify(tm->tm_sec);
- *scts++ = gsm411_bcdify(0); /* GMT */
+#ifdef HAVE_TM_GMTOFF_IN_TM
+ *scts++ = gsm411_bcdify(tm->tm_gmtoff/(60*15));
+#else
+#warning find a portable way to obtain timezone offset
+ *scts++ = 0;
+#endif
}
/* Decode 03.40 TP-SCTS (into utc/gmt timestamp) */
@@ -101,6 +107,9 @@ time_t gsm340_scts(uint8_t *scts)
tm.tm_hour = gsm411_unbcdify(*scts++);
tm.tm_min = gsm411_unbcdify(*scts++);
tm.tm_sec = gsm411_unbcdify(*scts++);
+#ifdef HAVE_TM_GMTOFF_IN_TM
+ tm.tm_gmtoff = gsm411_unbcdify(*scts++) * 15*60;
+#endif
/* according to gsm 03.40 time zone is
"expressed in quarters of an hour" */