aboutsummaryrefslogtreecommitdiffstats
path: root/src/isup.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-12-17 10:23:51 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-02-24 15:10:55 +0100
commit4822c8bc568b46088bffda77c42454df55819481 (patch)
tree6653781a05d31a915c7ad08e9db3cf1ce75b1904 /src/isup.c
parent6808407dcf22dd55fc764f4658585495c6bdc96c (diff)
isup: Make isup CIC parsing/using work on big endian machines as well
This is a hot fix to make CIC reading (and later status) work on big endian machines. There might be a more elegant way to do it and I will explore this later.
Diffstat (limited to 'src/isup.c')
-rw-r--r--src/isup.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/isup.c b/src/isup.c
index 31b4221..2827f21 100644
--- a/src/isup.c
+++ b/src/isup.c
@@ -21,10 +21,13 @@
#include <isup_types.h>
#include <cellmgr_debug.h>
#include <mtp_data.h>
+#include <mtp_level3.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
+#include <endian.h>
+
static struct msgb *isup_status_alloc(int cic, int msg_type, uint8_t *extra, int range, int val)
{
struct isup_msg_hdr *hdr;
@@ -260,3 +263,15 @@ int mtp_link_set_isup(struct mtp_link_set *set, struct msgb *msg, int sls)
return rc;
}
+
+uint16_t isup_cic_to_local(const struct isup_msg_hdr *hdr)
+{
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ return hdr->cic;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ return c_swap_16(hdr->cic);
+#else
+ #error "Unknown endian"
+#endif
+}
+