forked from acouzens/open5gs
Rename and move ogs_gtp2_paa_to_ip() to lib/proto/conv
Both types are defined under lib/proto/type.h, and the conversion function is used in several different protocols, so let's better move it to generic lib/proto/conv.h and remove the "gtp2" prefix.
This commit is contained in:
parent
b3845d5b0b
commit
4ab275ad70
|
@ -153,31 +153,3 @@ int ogs_gtp2_ip_to_f_teid(ogs_ip_t *ip, ogs_gtp2_f_teid_t *f_teid, int *len)
|
||||||
|
|
||||||
return OGS_OK;
|
return OGS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ogs_gtp2_paa_to_ip(ogs_paa_t *paa, ogs_ip_t *ip)
|
|
||||||
{
|
|
||||||
ogs_assert(paa);
|
|
||||||
ogs_assert(ip);
|
|
||||||
|
|
||||||
memset(ip, 0, sizeof *ip);
|
|
||||||
|
|
||||||
if (paa->session_type == OGS_PDU_SESSION_TYPE_IPV4V6) {
|
|
||||||
ip->ipv4 = 1;
|
|
||||||
ip->addr = paa->both.addr;
|
|
||||||
ip->ipv6 = 1;
|
|
||||||
memcpy(ip->addr6, paa->both.addr6, OGS_IPV6_LEN);
|
|
||||||
} else if (paa->session_type == OGS_PDU_SESSION_TYPE_IPV4) {
|
|
||||||
ip->ipv4 = 1;
|
|
||||||
ip->ipv6 = 0;
|
|
||||||
ip->addr = paa->addr;
|
|
||||||
} else if (paa->session_type == OGS_PDU_SESSION_TYPE_IPV6) {
|
|
||||||
ip->ipv4 = 0;
|
|
||||||
ip->ipv6 = 1;
|
|
||||||
memcpy(ip->addr6, paa->addr6, OGS_IPV6_LEN);
|
|
||||||
} else {
|
|
||||||
ogs_error("No IPv4 or IPv6");
|
|
||||||
return OGS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OGS_OK;
|
|
||||||
}
|
|
||||||
|
|
|
@ -35,8 +35,6 @@ int ogs_gtp2_sockaddr_to_f_teid(ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6,
|
||||||
int ogs_gtp2_f_teid_to_ip(ogs_gtp2_f_teid_t *f_teid, ogs_ip_t *ip);
|
int ogs_gtp2_f_teid_to_ip(ogs_gtp2_f_teid_t *f_teid, ogs_ip_t *ip);
|
||||||
int ogs_gtp2_ip_to_f_teid(ogs_ip_t *ip, ogs_gtp2_f_teid_t *f_teid, int *len);
|
int ogs_gtp2_ip_to_f_teid(ogs_ip_t *ip, ogs_gtp2_f_teid_t *f_teid, int *len);
|
||||||
|
|
||||||
int ogs_gtp2_paa_to_ip(ogs_paa_t *paa, ogs_ip_t *ip);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,3 +40,32 @@ void ogs_extract_digit_from_string(char *digit, char *string)
|
||||||
|
|
||||||
*digit = 0;
|
*digit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ogs_paa_to_ip(const ogs_paa_t *paa, ogs_ip_t *ip)
|
||||||
|
{
|
||||||
|
ogs_assert(paa);
|
||||||
|
ogs_assert(ip);
|
||||||
|
|
||||||
|
memset(ip, 0, sizeof *ip);
|
||||||
|
|
||||||
|
if (paa->session_type == OGS_PDU_SESSION_TYPE_IPV4V6) {
|
||||||
|
ip->ipv4 = 1;
|
||||||
|
ip->addr = paa->both.addr;
|
||||||
|
ip->ipv6 = 1;
|
||||||
|
memcpy(ip->addr6, paa->both.addr6, OGS_IPV6_LEN);
|
||||||
|
} else if (paa->session_type == OGS_PDU_SESSION_TYPE_IPV4) {
|
||||||
|
ip->ipv4 = 1;
|
||||||
|
ip->ipv6 = 0;
|
||||||
|
ip->addr = paa->addr;
|
||||||
|
} else if (paa->session_type == OGS_PDU_SESSION_TYPE_IPV6) {
|
||||||
|
ip->ipv4 = 0;
|
||||||
|
ip->ipv6 = 1;
|
||||||
|
memcpy(ip->addr6, paa->addr6, OGS_IPV6_LEN);
|
||||||
|
} else {
|
||||||
|
ogs_error("No IPv4 or IPv6");
|
||||||
|
return OGS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OGS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ extern "C" {
|
||||||
|
|
||||||
void ogs_extract_digit_from_string(char *digit, char *string);
|
void ogs_extract_digit_from_string(char *digit, char *string);
|
||||||
|
|
||||||
|
int ogs_paa_to_ip(const ogs_paa_t *paa, ogs_ip_t *ip);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -376,7 +376,7 @@ void mme_s11_handle_create_session_response(
|
||||||
rsp->pdn_address_allocation.len);
|
rsp->pdn_address_allocation.len);
|
||||||
session->session_type = session->paa.session_type;
|
session->session_type = session->paa.session_type;
|
||||||
ogs_assert(OGS_OK ==
|
ogs_assert(OGS_OK ==
|
||||||
ogs_gtp2_paa_to_ip(&session->paa, &session->ue_ip));
|
ogs_paa_to_ip(&session->paa, &session->ue_ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ePCO */
|
/* ePCO */
|
||||||
|
|
|
@ -174,7 +174,7 @@ ogs_pkbuf_t *smf_gn_build_create_pdp_context_response(
|
||||||
rsp->charging_id.u32 = sess->charging.id;
|
rsp->charging_id.u32 = sess->charging.id;
|
||||||
|
|
||||||
/* End User Address */
|
/* End User Address */
|
||||||
rv = ogs_gtp2_paa_to_ip(&sess->session.paa, &ip_eua);
|
rv = ogs_paa_to_ip(&sess->session.paa, &ip_eua);
|
||||||
rv = ogs_gtp1_ip_to_eua(sess->session.session_type, &ip_eua, &eua,
|
rv = ogs_gtp1_ip_to_eua(sess->session.session_type, &ip_eua, &eua,
|
||||||
&eua_len);
|
&eua_len);
|
||||||
rsp->end_user_address.presence = 1;
|
rsp->end_user_address.presence = 1;
|
||||||
|
|
|
@ -247,7 +247,7 @@ uint8_t smf_s5c_handle_create_session_request(
|
||||||
|
|
||||||
/* Initially Set Session Type from UE */
|
/* Initially Set Session Type from UE */
|
||||||
sess->session.session_type = sess->ue_session_type;
|
sess->session.session_type = sess->ue_session_type;
|
||||||
rv = ogs_gtp2_paa_to_ip(paa, &sess->session.ue_ip);
|
rv = ogs_paa_to_ip(paa, &sess->session.ue_ip);
|
||||||
ogs_assert(rv == OGS_OK);
|
ogs_assert(rv == OGS_OK);
|
||||||
|
|
||||||
/* Set UE IP Address */
|
/* Set UE IP Address */
|
||||||
|
|
Loading…
Reference in New Issue