osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/36791?usp=email )
Change subject: gtp: remove conversion functions up ......................................................................
gtp: remove conversion functions up
Move the conversion functions above the first user, so we can make in_addr2gsna static in a follow-up commit and remove the extra declaration.
Change-Id: I51e6a7c1161320fc54b0e8197ae57e4327976eb1 --- M gtp/gtp.c 1 file changed, 47 insertions(+), 34 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/91/36791/1
diff --git a/gtp/gtp.c b/gtp/gtp.c index 9442b33..482875d 100644 --- a/gtp/gtp.c +++ b/gtp/gtp.c @@ -823,6 +823,40 @@ }
/* *********************************************************** + * Conversion functions + *************************************************************/ + +/* *********************************************************** + * IP address conversion functions + * There exist several types of address representations: + * - eua: End User Address. (29.060, 7.7.27, message type 128) + * Used for signalling address to mobile station. Supports IPv4 + * IPv6 x.25 etc. etc. + * - gsna: GSN Address. (29.060, 7.7.32, message type 133): IP address + * of GSN. If length is 4 it is IPv4. If length is 16 it is IPv6. + * - in_addr: IPv4 address struct. + * - sockaddr_in: Socket API representation of IP address and + * port number. + *************************************************************/ + +int gsna2in_addr(struct in_addr *dst, struct ul16_t *gsna) +{ + memset(dst, 0, sizeof(struct in_addr)); + if (gsna->l != 4) + return EOF; /* Return if not IPv4 */ + memcpy(dst, gsna->v, gsna->l); + return 0; +} + +int in_addr2gsna(struct ul16_t *gsna, struct in_addr *src) +{ + memset(gsna, 0, sizeof(struct ul16_t)); + gsna->l = 4; + memcpy(gsna->v, src, gsna->l); + return 0; +} + +/* *********************************************************** * Session management messages * Messages: create, update and delete PDP context * @@ -3052,40 +3086,6 @@ return 0; }
-/* *********************************************************** - * Conversion functions - *************************************************************/ - -/* *********************************************************** - * IP address conversion functions - * There exist several types of address representations: - * - eua: End User Address. (29.060, 7.7.27, message type 128) - * Used for signalling address to mobile station. Supports IPv4 - * IPv6 x.25 etc. etc. - * - gsna: GSN Address. (29.060, 7.7.32, message type 133): IP address - * of GSN. If length is 4 it is IPv4. If length is 16 it is IPv6. - * - in_addr: IPv4 address struct. - * - sockaddr_in: Socket API representation of IP address and - * port number. - *************************************************************/ - -int gsna2in_addr(struct in_addr *dst, struct ul16_t *gsna) -{ - memset(dst, 0, sizeof(struct in_addr)); - if (gsna->l != 4) - return EOF; /* Return if not IPv4 */ - memcpy(dst, gsna->v, gsna->l); - return 0; -} - -int in_addr2gsna(struct ul16_t *gsna, struct in_addr *src) -{ - memset(gsna, 0, sizeof(struct ul16_t)); - gsna->l = 4; - memcpy(gsna->v, src, gsna->l); - return 0; -} - /* TS 29.060 has yet again a different encoding for IMSIs than * what we have in other places, so we cannot use the gsm48 * decoding functions. Also, libgtp uses an uint64_t in