Replace EUA magic numbers for IETF, IPv4 and IPv6 with #defines
Change-Id: I33f65e404217e717bd795e5229c8d9456a7b3739
This commit is contained in:
parent
ed1ba2c902
commit
cee7546f15
|
@ -3259,8 +3259,8 @@ int char2ul_t(char *src, struct ul_t dst)
|
|||
|
||||
int ipv42eua(struct ul66_t *eua, struct in_addr *src)
|
||||
{
|
||||
eua->v[0] = 0xf1; /* IETF */
|
||||
eua->v[1] = 0x21; /* IPv4 */
|
||||
eua->v[0] = PDP_EUA_ORG_IETF;
|
||||
eua->v[1] = PDP_EUA_TYPE_v4;
|
||||
if (src) {
|
||||
eua->l = 6;
|
||||
memcpy(&eua->v[2], src, 4);
|
||||
|
@ -3272,7 +3272,7 @@ int ipv42eua(struct ul66_t *eua, struct in_addr *src)
|
|||
|
||||
int eua2ipv4(struct in_addr *dst, struct ul66_t *eua)
|
||||
{
|
||||
if ((eua->l != 6) || (eua->v[0] != 0xf1) || (eua->v[1] = 0x21))
|
||||
if ((eua->l != 6) || (eua->v[0] != PDP_EUA_ORG_IETF) || (eua->v[1] != PDP_EUA_TYPE_v4))
|
||||
return -1; /* Not IPv4 address */
|
||||
memcpy(dst, &eua->v[2], 4);
|
||||
return 0;
|
||||
|
|
|
@ -367,15 +367,15 @@ int pdp_ipget(struct pdp_t **pdp, void* ipif, struct ul66_t *eua) {
|
|||
int pdp_ntoeua(struct in_addr *src, struct ul66_t *eua)
|
||||
{
|
||||
eua->l = 6;
|
||||
eua->v[0] = 0xf1; /* IETF */
|
||||
eua->v[1] = 0x21; /* IPv4 */
|
||||
eua->v[0] = PDP_EUA_ORG_IETF;
|
||||
eua->v[1] = PDP_EUA_TYPE_v4;
|
||||
memcpy(&eua->v[2], src, 4); /* Copy a 4 byte address */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pdp_euaton(struct ul66_t *eua, struct in_addr *dst)
|
||||
{
|
||||
if ((eua->l != 6) || (eua->v[0] != 0xf1) || (eua->v[1] != 0x21)) {
|
||||
if ((eua->l != 6) || (eua->v[0] != PDP_EUA_ORG_IETF) || (eua->v[1] != PDP_EUA_TYPE_v4)) {
|
||||
return EOF;
|
||||
}
|
||||
memcpy(dst, &eua->v[2], 4); /* Copy a 4 byte address */
|
||||
|
|
|
@ -23,6 +23,10 @@ struct gsn_t;
|
|||
#define PDP_MAX 1024 /* Max number of PDP contexts */
|
||||
#define PDP_MAXNSAPI 16 /* Max number of NSAPI */
|
||||
|
||||
#define PDP_EUA_ORG_IETF 0xF1
|
||||
#define PDP_EUA_TYPE_v4 0x21
|
||||
#define PDP_EUA_TYPE_v6 0x57
|
||||
|
||||
/* GTP Information elements from 29.060 v3.9.0 7.7 Information Elements */
|
||||
/* Also covers version 0. Note that version 0 6: QOS Profile was superceded *
|
||||
* by 135: QOS Profile in version 1 */
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
|
||||
#include "../lib/in46_addr.h"
|
||||
#include "../gtp/pdp.h"
|
||||
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
|
@ -201,15 +202,15 @@ int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua)
|
|||
switch (src->len) {
|
||||
case 4:
|
||||
eua->l = 6;
|
||||
eua->v[0] = 0xf1; /* IETF */
|
||||
eua->v[1] = 0x21; /* IPv4 */
|
||||
eua->v[0] = PDP_EUA_ORG_IETF;
|
||||
eua->v[1] = PDP_EUA_TYPE_v4;
|
||||
memcpy(&eua->v[2], &src->v4, 4); /* Copy a 4 byte address */
|
||||
break;
|
||||
case 8:
|
||||
case 16:
|
||||
eua->l = 18;
|
||||
eua->v[0] = 0xf1; /* IETF */
|
||||
eua->v[1] = 0x57; /* IPv6 */
|
||||
eua->v[0] = PDP_EUA_ORG_IETF;
|
||||
eua->v[1] = PDP_EUA_TYPE_v6;
|
||||
memcpy(&eua->v[2], &src->v6, 16); /* Copy a 16 byte address */
|
||||
break;
|
||||
default:
|
||||
|
@ -230,14 +231,14 @@ int in46a_from_eua(const struct ul66_t *eua, struct in46_addr *dst)
|
|||
return -1;
|
||||
|
||||
switch (eua->v[1]) {
|
||||
case 0x21:
|
||||
case PDP_EUA_TYPE_v4:
|
||||
dst->len = 4;
|
||||
if (eua->l >= 6)
|
||||
memcpy(&dst->v4, &eua->v[2], 4); /* Copy a 4 byte address */
|
||||
else
|
||||
dst->v4.s_addr = 0;
|
||||
break;
|
||||
case 0x57:
|
||||
case PDP_EUA_TYPE_v6:
|
||||
dst->len = 16;
|
||||
if (eua->l >= 18)
|
||||
memcpy(&dst->v6, &eua->v[2], 16); /* Copy a 16 byte address */
|
||||
|
|
Loading…
Reference in New Issue