pespin has uploaded this change for review.

View Change

pfcp_msg: Add osmo_pfcp_ie_node_id_cmp()

Related: SYS#7719
Change-Id: Id9bda11078d7d940474389c95d23e90db7bc5bed
---
M TODO-RELEASE
M include/osmocom/pfcp/pfcp_msg.h
M src/libosmo-pfcp/pfcp_msg.c
3 files changed, 25 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/52/41452/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 0ed7189..203a2fd 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
+libosmo-pfcp add osmo_pfcp_ie_node_id_cmp()
diff --git a/include/osmocom/pfcp/pfcp_msg.h b/include/osmocom/pfcp/pfcp_msg.h
index 0023353..2fde3e5 100644
--- a/include/osmocom/pfcp/pfcp_msg.h
+++ b/include/osmocom/pfcp/pfcp_msg.h
@@ -168,7 +168,7 @@

int osmo_pfcp_ie_node_id_from_osmo_sockaddr(struct osmo_pfcp_ie_node_id *node_id, const struct osmo_sockaddr *os);
int osmo_pfcp_ie_node_id_to_osmo_sockaddr(const struct osmo_pfcp_ie_node_id *node_id, struct osmo_sockaddr *os);
-
+int osmo_pfcp_ie_node_id_cmp(const struct osmo_pfcp_ie_node_id *a, const struct osmo_pfcp_ie_node_id *b);
#define OSMO_PFCP_MSG_MEMB(M, OFS) ((OFS) <= 0 ? NULL : (void *)((uint8_t *)(M) + OFS))

static inline enum osmo_pfcp_cause *osmo_pfcp_msg_cause(const struct osmo_pfcp_msg *m)
diff --git a/src/libosmo-pfcp/pfcp_msg.c b/src/libosmo-pfcp/pfcp_msg.c
index 9c73609..2e0db31 100644
--- a/src/libosmo-pfcp/pfcp_msg.c
+++ b/src/libosmo-pfcp/pfcp_msg.c
@@ -135,6 +135,29 @@
return 0;
}

+int osmo_pfcp_ie_node_id_cmp(const struct osmo_pfcp_ie_node_id *a, const struct osmo_pfcp_ie_node_id *b)
+{
+ if (a == b)
+ return 0;
+ if (!a)
+ return 1;
+ if (!b)
+ return -1;
+
+ if (a->type != b->type)
+ return OSMO_CMP(a->type, b->type);
+
+ switch (a->type) {
+ case OSMO_PFCP_NODE_ID_T_IPV4:
+ case OSMO_PFCP_NODE_ID_T_IPV6:
+ return osmo_sockaddr_cmp(&a->ip, &b->ip);
+ case OSMO_PFCP_NODE_ID_T_FQDN:
+ return strncasecmp(&a->fqdn[0], &b->fqdn[0], sizeof(a->fqdn));
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
static int pfcp_header_set_message_length(struct osmo_pfcp_header_common *c, unsigned int header_and_payload_len)
{
if (header_and_payload_len < sizeof(struct osmo_pfcp_header_common))

To view, visit change 41452. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-pfcp
Gerrit-Branch: master
Gerrit-Change-Id: Id9bda11078d7d940474389c95d23e90db7bc5bed
Gerrit-Change-Number: 41452
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>