fix coding of Node ID: FQDN type
Decode FQDN type Node IDs into "human" dotted notation instead of storing the DNS type data in the FQDN string. Related: OS#5806 Change-Id: I25d0f9b095287aa30e24498d8361c0a326ded447
This commit is contained in:
parent
9110daf27f
commit
e756bde244
|
@ -310,8 +310,10 @@ int osmo_pfcp_dec_node_id(void *decoded_struct, void *decode_to, const struct os
|
|||
osmo_sockaddr_from_octets(&node_id->ip, ip, ip_len);
|
||||
break;
|
||||
case OSMO_PFCP_NODE_ID_T_FQDN:
|
||||
/* Copy and add a trailing nul */
|
||||
OSMO_STRLCPY_ARRAY(node_id->fqdn, ip);
|
||||
if (ip_len < 1 || sizeof(node_id->fqdn) < ip_len)
|
||||
RETURN_ERROR(-EINVAL, "FQDN in Node ID is too long: %u > %zu", ip_len, sizeof(node_id->fqdn));
|
||||
if (osmo_apn_to_str(node_id->fqdn, ip, ip_len) == NULL)
|
||||
RETURN_ERROR(-EINVAL, "Invalid FQDN in Node ID");
|
||||
break;
|
||||
default:
|
||||
RETURN_ERROR(-EINVAL, "Invalid Node ID Type: %d", node_id->type);
|
||||
|
@ -323,6 +325,7 @@ int osmo_pfcp_enc_node_id(struct osmo_gtlv_put *tlv, const void *decoded_struct,
|
|||
{
|
||||
unsigned int l;
|
||||
const struct osmo_pfcp_ie_node_id *node_id = encode_from;
|
||||
int rc;
|
||||
msgb_put_u8(tlv->dst, node_id->type);
|
||||
switch (node_id->type) {
|
||||
case OSMO_PFCP_NODE_ID_T_IPV4:
|
||||
|
@ -334,9 +337,11 @@ int osmo_pfcp_enc_node_id(struct osmo_gtlv_put *tlv, const void *decoded_struct,
|
|||
osmo_sockaddr_to_octets(msgb_put(tlv->dst, l), l, &node_id->ip);
|
||||
break;
|
||||
case OSMO_PFCP_NODE_ID_T_FQDN:
|
||||
l = strnlen(node_id->fqdn, sizeof(node_id->fqdn));
|
||||
/* Copy without trailing nul */
|
||||
memcpy((char *)msgb_put(tlv->dst, l), node_id->fqdn, l);
|
||||
rc = osmo_apn_from_str(tlv->dst->tail, msgb_tailroom(tlv->dst), node_id->fqdn);
|
||||
if (rc <= 0)
|
||||
RETURN_ERROR(rc ? : -EINVAL, "Encoding Node ID FQDN from '%s' failed",
|
||||
(const char *)encode_from);
|
||||
msgb_put(tlv->dst, rc);
|
||||
break;
|
||||
default:
|
||||
RETURN_ERROR(-EINVAL, "Invalid Node ID Type: %d", node_id->type);
|
||||
|
@ -701,7 +706,8 @@ int osmo_pfcp_dec_network_inst(void *decoded_struct, void *decode_to, const stru
|
|||
struct osmo_pfcp_ie_network_inst *network_inst = decode_to;
|
||||
|
||||
if (tlv->len < 1 || sizeof(network_inst->str) < tlv->len)
|
||||
RETURN_ERROR(-EINVAL, "Network Instance value part is too long");
|
||||
RETURN_ERROR(-EINVAL, "Network Instance value part is too long: %zu > %zu",
|
||||
tlv->len, sizeof(network_inst->str));
|
||||
if (osmo_apn_to_str(network_inst->str, tlv->val, tlv->len) == NULL)
|
||||
RETURN_ERROR(-EINVAL, "decoding qname (RFC 1035 4.1.2) failed");
|
||||
return 0;
|
||||
|
|
|
@ -36,8 +36,8 @@ parsed == orig
|
|||
encoding: ASSOC_SETUP_RESP
|
||||
PFCPv1 ASSOC_SETUP_RESP hdr={seq=4} ies={ 'Node ID'=fqdn:"example.com" 'Cause'=Request accepted (success) 'Recovery Time Stamp'=724249387 'UP Function Features'=( BUCP PDIU ) }
|
||||
osmo_pfcp_msg_encode() rc = 0
|
||||
20 06 00 2b 00 00 04 00 00 3c 00 0c 02 65 78 61 6d 70 6c 65 2e 63 6f 6d 00 13 00 01 01 00 60 00 04 2b 2b 2b 2b 00 2b 00 06 01 02 00 00 00 00 .
|
||||
osmo_pfcp_msg_decode_header() rc = 47
|
||||
20 06 00 2c 00 00 04 00 00 3c 00 0d 02 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 13 00 01 01 00 60 00 04 2b 2b 2b 2b 00 2b 00 06 01 02 00 00 00 00 .
|
||||
osmo_pfcp_msg_decode_header() rc = 48
|
||||
rc == msgb_length()
|
||||
osmo_pfcp_msg_decode_tlv() rc = 0
|
||||
parsed == orig
|
||||
|
|
Loading…
Reference in New Issue