diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2016-02-04 18:00:36 +0100 |
---|---|---|
committer | Daniel Willmann <dwillmann@sysmocom.de> | 2016-02-18 13:21:35 +0100 |
commit | 4870b995ec0bf1b01d91b08d396ff0bffc2d0ab3 (patch) | |
tree | a5a967df439f689dc0650468bbf34b8e2c8d49a6 /src/ranap_common.c | |
parent | 49f99cd265a89ba155afdcb8daade73c60824de6 (diff) |
ranap_common: Add helper function to get IP from transport layer addr
Diffstat (limited to 'src/ranap_common.c')
-rw-r--r-- | src/ranap_common.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ranap_common.c b/src/ranap_common.c index 4bd088c..f2fdf9d 100644 --- a/src/ranap_common.c +++ b/src/ranap_common.c @@ -523,3 +523,20 @@ void ranap_set_log_area(int log_area) { _ranap_DRANAP = log_area; } + +int ranap_ip_from_transp_layer_addr(const BIT_STRING_t *in, uint32_t *ip) +{ + uint32_t addr; + uint8_t x213[] = {0x35, 0x00, 0x01}; + + /* Only support IPv4 for now - plain and with x213 encapsulation */ + if (in->size == 4) + *ip = *(uint32_t *)in->buf; + else if ((in->size == 7) && !memcmp(in->buf, x213, sizeof(x213))) + *ip = htonl(*(uint32_t *)&in->buf[3]); + else + return -1; + + return 0; + +} |