forked from acouzens/open5gs
lib/proto/types.{c,h}: Constify several parameters
This commit is contained in:
parent
55844d1eed
commit
1f8f20da34
|
@ -23,7 +23,7 @@
|
|||
#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10)
|
||||
#define PLMN_ID_DIGIT3(x) ((x) % 10)
|
||||
|
||||
uint32_t ogs_plmn_id_hexdump(void *plmn_id)
|
||||
uint32_t ogs_plmn_id_hexdump(const void *plmn_id)
|
||||
{
|
||||
uint32_t hex;
|
||||
ogs_assert(plmn_id);
|
||||
|
@ -32,18 +32,18 @@ uint32_t ogs_plmn_id_hexdump(void *plmn_id)
|
|||
return hex;
|
||||
}
|
||||
|
||||
uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id)
|
||||
uint16_t ogs_plmn_id_mcc(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
return plmn_id->mcc1 * 100 + plmn_id->mcc2 * 10 + plmn_id->mcc3;
|
||||
}
|
||||
uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id)
|
||||
uint16_t ogs_plmn_id_mnc(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
return plmn_id->mnc1 == 0xf ? plmn_id->mnc2 * 10 + plmn_id->mnc3 :
|
||||
plmn_id->mnc1 * 100 + plmn_id->mnc2 * 10 + plmn_id->mnc3;
|
||||
}
|
||||
uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id)
|
||||
uint16_t ogs_plmn_id_mnc_len(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
return plmn_id->mnc1 == 0xf ? 2 : 3;
|
||||
|
@ -70,7 +70,7 @@ void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id,
|
|||
}
|
||||
|
||||
void *ogs_nas_from_plmn_id(
|
||||
ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id)
|
||||
ogs_nas_plmn_id_t *ogs_nas_plmn_id, const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(ogs_nas_plmn_id);
|
||||
ogs_assert(plmn_id);
|
||||
|
@ -84,7 +84,7 @@ void *ogs_nas_from_plmn_id(
|
|||
return ogs_nas_plmn_id;
|
||||
}
|
||||
void *ogs_nas_to_plmn_id(
|
||||
ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id)
|
||||
ogs_plmn_id_t *plmn_id, const ogs_nas_plmn_id_t *ogs_nas_plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
ogs_assert(ogs_nas_plmn_id);
|
||||
|
@ -98,13 +98,13 @@ void *ogs_nas_to_plmn_id(
|
|||
return plmn_id;
|
||||
}
|
||||
|
||||
char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id)
|
||||
char *ogs_plmn_id_mcc_string(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
return ogs_msprintf("%03d", ogs_plmn_id_mcc(plmn_id));
|
||||
}
|
||||
|
||||
char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id)
|
||||
char *ogs_plmn_id_mnc_string(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
if (ogs_plmn_id_mnc_len(plmn_id) == 2)
|
||||
|
@ -113,7 +113,7 @@ char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id)
|
|||
return ogs_msprintf("%03d", ogs_plmn_id_mnc(plmn_id));
|
||||
}
|
||||
|
||||
char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf)
|
||||
char *ogs_plmn_id_to_string(const ogs_plmn_id_t *plmn_id, char *buf)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
ogs_assert(buf);
|
||||
|
@ -132,27 +132,27 @@ char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf)
|
|||
#define FQDN_5GC_MNC "5gc.mnc"
|
||||
#define FQDN_MCC ".mcc"
|
||||
|
||||
char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id)
|
||||
char *ogs_serving_network_name_from_plmn_id(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
return ogs_msprintf("5G:mnc%03d.mcc%03d" FQDN_3GPPNETWORK_ORG,
|
||||
ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id));
|
||||
}
|
||||
|
||||
char *ogs_home_network_domain_from_plmn_id(ogs_plmn_id_t *plmn_id)
|
||||
char *ogs_home_network_domain_from_plmn_id(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(plmn_id);
|
||||
return ogs_msprintf("5gc.mnc%03d.mcc%03d" FQDN_3GPPNETWORK_ORG,
|
||||
ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id));
|
||||
}
|
||||
|
||||
char *ogs_nrf_fqdn_from_plmn_id(ogs_plmn_id_t *plmn_id)
|
||||
char *ogs_nrf_fqdn_from_plmn_id(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
return ogs_msprintf("nrf.5gc.mnc%03d.mcc%03d" FQDN_3GPPNETWORK_ORG,
|
||||
ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id));
|
||||
}
|
||||
|
||||
char *ogs_nssf_fqdn_from_plmn_id(ogs_plmn_id_t *plmn_id)
|
||||
char *ogs_nssf_fqdn_from_plmn_id(const ogs_plmn_id_t *plmn_id)
|
||||
{
|
||||
return ogs_msprintf("nssf.5gc.mnc%03d.mcc%03d" FQDN_3GPPNETWORK_ORG,
|
||||
ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id));
|
||||
|
@ -232,7 +232,7 @@ uint16_t ogs_plmn_id_mnc_from_fqdn(char *fqdn)
|
|||
return atoi(mnc);
|
||||
}
|
||||
|
||||
uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id)
|
||||
uint32_t ogs_amf_id_hexdump(const ogs_amf_id_t *amf_id)
|
||||
{
|
||||
uint32_t hex;
|
||||
|
||||
|
@ -262,7 +262,7 @@ ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex)
|
|||
}
|
||||
|
||||
#define OGS_AMFIDSTRLEN (sizeof(ogs_amf_id_t)*2+1)
|
||||
char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id)
|
||||
char *ogs_amf_id_to_string(const ogs_amf_id_t *amf_id)
|
||||
{
|
||||
char *str = NULL;
|
||||
ogs_assert(amf_id);
|
||||
|
@ -278,17 +278,17 @@ char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id)
|
|||
return str;
|
||||
}
|
||||
|
||||
uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id)
|
||||
uint8_t ogs_amf_region_id(const ogs_amf_id_t *amf_id)
|
||||
{
|
||||
ogs_assert(amf_id);
|
||||
return amf_id->region;
|
||||
}
|
||||
uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id)
|
||||
uint16_t ogs_amf_set_id(const ogs_amf_id_t *amf_id)
|
||||
{
|
||||
ogs_assert(amf_id);
|
||||
return (amf_id->set1 << 2) + amf_id->set2;
|
||||
}
|
||||
uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id)
|
||||
uint8_t ogs_amf_pointer(const ogs_amf_id_t *amf_id)
|
||||
{
|
||||
ogs_assert(amf_id);
|
||||
return amf_id->pointer;
|
||||
|
@ -370,7 +370,7 @@ cleanup:
|
|||
return ueid;
|
||||
}
|
||||
|
||||
char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd)
|
||||
char *ogs_s_nssai_sd_to_string(const ogs_uint24_t sd)
|
||||
{
|
||||
char *string = NULL;
|
||||
|
||||
|
@ -612,7 +612,7 @@ char *ogs_ipv4_to_string(uint32_t addr)
|
|||
return (char*)OGS_INET_NTOP(&addr, buf);
|
||||
}
|
||||
|
||||
char *ogs_ipv6addr_to_string(uint8_t *addr6)
|
||||
char *ogs_ipv6addr_to_string(const uint8_t *addr6)
|
||||
{
|
||||
char *buf = NULL;
|
||||
ogs_assert(addr6);
|
||||
|
@ -626,7 +626,7 @@ char *ogs_ipv6addr_to_string(uint8_t *addr6)
|
|||
return (char *)OGS_INET6_NTOP(addr6, buf);
|
||||
}
|
||||
|
||||
char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen)
|
||||
char *ogs_ipv6prefix_to_string(const uint8_t *addr6, uint8_t prefixlen)
|
||||
{
|
||||
char *buf = NULL;
|
||||
uint8_t tmp[OGS_IPV6_LEN];
|
||||
|
@ -649,7 +649,7 @@ char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen)
|
|||
return ogs_mstrcatf(buf, "/%d", prefixlen);
|
||||
}
|
||||
|
||||
int ogs_ipv4_from_string(uint32_t *addr, char *string)
|
||||
int ogs_ipv4_from_string(uint32_t *addr, const char *string)
|
||||
{
|
||||
int rv;
|
||||
ogs_sockaddr_t tmp;
|
||||
|
@ -668,7 +668,7 @@ int ogs_ipv4_from_string(uint32_t *addr, char *string)
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
int ogs_ipv6addr_from_string(uint8_t *addr6, char *string)
|
||||
int ogs_ipv6addr_from_string(uint8_t *addr6, const char *string)
|
||||
{
|
||||
int rv;
|
||||
ogs_sockaddr_t tmp;
|
||||
|
@ -687,7 +687,7 @@ int ogs_ipv6addr_from_string(uint8_t *addr6, char *string)
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
int ogs_ipv6prefix_from_string(uint8_t *addr6, uint8_t *prefixlen, char *string)
|
||||
int ogs_ipv6prefix_from_string(uint8_t *addr6, uint8_t *prefixlen, const char *string)
|
||||
{
|
||||
int rv;
|
||||
ogs_sockaddr_t tmp;
|
||||
|
|
|
@ -196,25 +196,25 @@ ED2(uint8_t mnc3:4;,
|
|||
uint8_t mnc2:4;)
|
||||
} __attribute__ ((packed)) ogs_plmn_id_t;
|
||||
|
||||
uint32_t ogs_plmn_id_hexdump(void *plmn_id);
|
||||
uint32_t ogs_plmn_id_hexdump(const void *plmn_id);
|
||||
|
||||
uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id);
|
||||
uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id);
|
||||
uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id);
|
||||
uint16_t ogs_plmn_id_mcc(const ogs_plmn_id_t *plmn_id);
|
||||
uint16_t ogs_plmn_id_mnc(const ogs_plmn_id_t *plmn_id);
|
||||
uint16_t ogs_plmn_id_mnc_len(const ogs_plmn_id_t *plmn_id);
|
||||
|
||||
void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id,
|
||||
uint16_t mcc, uint16_t mnc, uint16_t mnc_len);
|
||||
|
||||
char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_plmn_id_mcc_string(const ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_plmn_id_mnc_string(const ogs_plmn_id_t *plmn_id);
|
||||
|
||||
#define OGS_PLMNIDSTRLEN (sizeof(ogs_plmn_id_t)*2+1)
|
||||
char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf);
|
||||
char *ogs_plmn_id_to_string(const ogs_plmn_id_t *plmn_id, char *buf);
|
||||
|
||||
char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_home_network_domain_from_plmn_id(ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_nrf_fqdn_from_plmn_id(ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_nssf_fqdn_from_plmn_id(ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_serving_network_name_from_plmn_id(const ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_home_network_domain_from_plmn_id(const ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_nrf_fqdn_from_plmn_id(const ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_nssf_fqdn_from_plmn_id(const ogs_plmn_id_t *plmn_id);
|
||||
char *ogs_home_network_domain_from_fqdn(char *fqdn);
|
||||
uint16_t ogs_plmn_id_mnc_from_fqdn(char *fqdn);
|
||||
uint16_t ogs_plmn_id_mcc_from_fqdn(char *fqdn);
|
||||
|
@ -231,9 +231,9 @@ ED2(uint8_t mnc2:4;,
|
|||
} __attribute__ ((packed)) ogs_nas_plmn_id_t;
|
||||
|
||||
void *ogs_nas_from_plmn_id(
|
||||
ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id);
|
||||
ogs_nas_plmn_id_t *ogs_nas_plmn_id, const ogs_plmn_id_t *plmn_id);
|
||||
void *ogs_nas_to_plmn_id(
|
||||
ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id);
|
||||
ogs_plmn_id_t *plmn_id, const ogs_nas_plmn_id_t *ogs_nas_plmn_id);
|
||||
|
||||
/************************************
|
||||
* AMF_ID Structure */
|
||||
|
@ -249,14 +249,14 @@ typedef struct ogs_guami_s {
|
|||
ogs_amf_id_t amf_id;
|
||||
} ogs_guami_t;
|
||||
|
||||
uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id);
|
||||
uint32_t ogs_amf_id_hexdump(const ogs_amf_id_t *amf_id);
|
||||
|
||||
ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex);
|
||||
char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id);
|
||||
char *ogs_amf_id_to_string(const ogs_amf_id_t *amf_id);
|
||||
|
||||
uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id);
|
||||
uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id);
|
||||
uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id);
|
||||
uint8_t ogs_amf_region_id(const ogs_amf_id_t *amf_id);
|
||||
uint16_t ogs_amf_set_id(const ogs_amf_id_t *amf_id);
|
||||
uint8_t ogs_amf_pointer(const ogs_amf_id_t *amf_id);
|
||||
|
||||
ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id,
|
||||
uint8_t region, uint16_t set, uint8_t pointer);
|
||||
|
@ -306,7 +306,7 @@ typedef struct ogs_s_nssai_s {
|
|||
ogs_uint24_t sd;
|
||||
} __attribute__ ((packed)) ogs_s_nssai_t;
|
||||
|
||||
char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd);
|
||||
char *ogs_s_nssai_sd_to_string(const ogs_uint24_t sd);
|
||||
ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex);
|
||||
|
||||
/**************************************************
|
||||
|
@ -332,12 +332,12 @@ int ogs_sockaddr_to_ip(
|
|||
ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip);
|
||||
|
||||
char *ogs_ipv4_to_string(uint32_t addr);
|
||||
char *ogs_ipv6addr_to_string(uint8_t *addr6);
|
||||
char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen);
|
||||
int ogs_ipv4_from_string(uint32_t *addr, char *string);
|
||||
int ogs_ipv6addr_from_string(uint8_t *addr6, char *string);
|
||||
char *ogs_ipv6addr_to_string(const uint8_t *addr6);
|
||||
char *ogs_ipv6prefix_to_string(const uint8_t *addr6, uint8_t prefixlen);
|
||||
int ogs_ipv4_from_string(uint32_t *addr, const char *string);
|
||||
int ogs_ipv6addr_from_string(uint8_t *addr6, const char *string);
|
||||
int ogs_ipv6prefix_from_string(
|
||||
uint8_t *addr6, uint8_t *prefixlen, char *string);
|
||||
uint8_t *addr6, uint8_t *prefixlen, const char *string);
|
||||
|
||||
/**************************************************
|
||||
* GTPv1-C: TS 29.060 7.7.27 End User Address (EUA) */
|
||||
|
|
Loading…
Reference in New Issue