[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email ) Change subject: add osmo_pfcp_ip_addrs_get .. add osmo_pfcp_ip_addrs_get This pattern shows up a lot when working with PFCP. Let's make it easier to handle IPv4 and v6 at the same time. Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 --- M include/osmocom/pfcp/pfcp_ies_custom.h M src/libosmo-pfcp/pfcp_msg.c 2 files changed, 50 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/include/osmocom/pfcp/pfcp_ies_custom.h b/include/osmocom/pfcp/pfcp_ies_custom.h index 0540bfe..84f862a 100644 --- a/include/osmocom/pfcp/pfcp_ies_custom.h +++ b/include/osmocom/pfcp/pfcp_ies_custom.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include @@ -40,6 +41,11 @@ int osmo_pfcp_ip_addrs_to_str_buf(char *buf, size_t buflen, const struct osmo_pfcp_ip_addrs *addrs); char *osmo_pfcp_ip_addrs_to_str_c(void *ctx, const struct osmo_pfcp_ip_addrs *addrs); +int osmo_pfcp_ip_addrs_get(struct osmo_sockaddr *v4, struct osmo_sockaddr *v6, + struct osmo_pfcp_ip_addrs *src); +int osmo_pfcp_ip_addrs_get_str(struct osmo_sockaddr_str *v4, struct osmo_sockaddr_str *v6, + struct osmo_pfcp_ip_addrs *src); + /* 3GPP TS 29.244 8.2.38, IETF RFC 1035 3.1 */ struct osmo_pfcp_ie_node_id { enum osmo_pfcp_node_id_type type; diff --git a/src/libosmo-pfcp/pfcp_msg.c b/src/libosmo-pfcp/pfcp_msg.c index abcee18..66f6e59 100644 --- a/src/libosmo-pfcp/pfcp_msg.c +++ b/src/libosmo-pfcp/pfcp_msg.c @@ -514,6 +514,38 @@ } } +int osmo_pfcp_ip_addrs_get(struct osmo_sockaddr *v4, struct osmo_sockaddr *v6, struct osmo_pfcp_ip_addrs *src) +{ + if (v4) { + if (src->v4_present) + *v4 = src->v4; + else + *v4 = (struct osmo_sockaddr){ .u.sa.sa_family = AF_UNSPEC }; + } + if (v6) { + if (src->v6_present) + *v6 = src->v6; + else + *v6 = (struct osmo_sockaddr){ .u.sa.sa_family = AF_UNSPEC }; + } + return 0; +} + +int osmo_pfcp_ip_addrs_get_str(struct osmo_sockaddr_str *v4, struct osmo_sockaddr_str *v6, struct osmo_pfcp_ip_addrs *src) +{ + if (v4) { + if (src->v4_present) + return osmo_sockaddr_str_from_sockaddr(v4, >v4.u.sas); + *v4 = (struct osmo_sockaddr_str){}; + } + if (v6) { + if (src->v6_present) + return osmo_sockaddr_str_from_sockaddr(v6, >v6.u.sas); + *v6 = (struct osmo_sockaddr_str){}; + } + return 0; +} + /* If a osmo_fsm_inst placed in m->ctx deallocates before the osmo_pfcp_msg, call this function, to make sure to avoid * use after free. Alternatively use m->ctx.*_use_count to make sure the FSM inst does not deallocate before the * osmo_pfcp_msg is discarded from the resend queue. */ -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 2 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: pespin Gerrit-MessageType: merged
[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
Attention is currently required from: neels. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email ) Change subject: add osmo_pfcp_ip_addrs_get .. Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 2 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: pespin Gerrit-Attention: neels Gerrit-Comment-Date: Tue, 26 Mar 2024 08:14:14 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
Attention is currently required from: neels. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email ) Change subject: add osmo_pfcp_ip_addrs_get .. Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 2 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-Attention: neels Gerrit-Comment-Date: Mon, 25 Mar 2024 10:35:06 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified-1 by Jenkins Builder Change subject: add osmo_pfcp_ip_addrs_get .. add osmo_pfcp_ip_addrs_get This pattern shows up a lot when working with PFCP. Let's make it easier to handle IPv4 and v6 at the same time. Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 --- M include/osmocom/pfcp/pfcp_ies_custom.h M src/libosmo-pfcp/pfcp_msg.c 2 files changed, 50 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/48/36348/2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 2 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin Gerrit-Attention: pespin Gerrit-MessageType: newpatchset
[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
Attention is currently required from: pespin. neels has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email ) Change subject: add osmo_pfcp_ip_addrs_get .. Patch Set 1: (1 comment) File src/libosmo-pfcp/pfcp_msg.c: https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348/comment/ba463341_162c07fa PS1, Line 523: *v4 = (struct osmo_sockaddr){}; > you probably want to set sa_family to AF_UNSPEC here. […] i doubt that it's needed, but simple enough. BTW for the sockaddr_str below it suffices to have .ip[0] == 0. -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 1 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin Gerrit-Attention: pespin Gerrit-Comment-Date: Sat, 23 Mar 2024 12:03:43 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
Attention is currently required from: neels. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email ) Change subject: add osmo_pfcp_ip_addrs_get .. Patch Set 1: (1 comment) File src/libosmo-pfcp/pfcp_msg.c: https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348/comment/79c70236_7713c0be PS1, Line 523: *v4 = (struct osmo_sockaddr){}; you probably want to set sa_family to AF_UNSPEC here. If you can find somewhere that it's specified that AF_UNSPEC is 0 then it's fine. -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 1 Gerrit-Owner: neels Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin Gerrit-Attention: neels Gerrit-Comment-Date: Tue, 19 Mar 2024 11:43:19 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email ) Change subject: add osmo_pfcp_ip_addrs_get .. Patch Set 1: (2 comments) File src/libosmo-pfcp/pfcp_msg.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15227): https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348/comment/16ff848d_a378cb8f PS1, Line 539: else else is not generally useful after a break or return Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15227): https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348/comment/1b09a9b1_c02216d7 PS1, Line 545: else else is not generally useful after a break or return -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 1 Gerrit-Owner: neels Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Tue, 19 Mar 2024 03:47:32 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
[M] Change in libosmo-pfcp[master]: add osmo_pfcp_ip_addrs_get
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email ) Change subject: add osmo_pfcp_ip_addrs_get .. add osmo_pfcp_ip_addrs_get This pattern shows up a lot when working with PFCP. Let's make it easier to handle IPv4 and v6 at the same time. Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 --- M include/osmocom/pfcp/pfcp_ies_custom.h M src/libosmo-pfcp/pfcp_msg.c 2 files changed, 52 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/48/36348/1 diff --git a/include/osmocom/pfcp/pfcp_ies_custom.h b/include/osmocom/pfcp/pfcp_ies_custom.h index 0540bfe..84f862a 100644 --- a/include/osmocom/pfcp/pfcp_ies_custom.h +++ b/include/osmocom/pfcp/pfcp_ies_custom.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include @@ -40,6 +41,11 @@ int osmo_pfcp_ip_addrs_to_str_buf(char *buf, size_t buflen, const struct osmo_pfcp_ip_addrs *addrs); char *osmo_pfcp_ip_addrs_to_str_c(void *ctx, const struct osmo_pfcp_ip_addrs *addrs); +int osmo_pfcp_ip_addrs_get(struct osmo_sockaddr *v4, struct osmo_sockaddr *v6, + struct osmo_pfcp_ip_addrs *src); +int osmo_pfcp_ip_addrs_get_str(struct osmo_sockaddr_str *v4, struct osmo_sockaddr_str *v6, + struct osmo_pfcp_ip_addrs *src); + /* 3GPP TS 29.244 8.2.38, IETF RFC 1035 3.1 */ struct osmo_pfcp_ie_node_id { enum osmo_pfcp_node_id_type type; diff --git a/src/libosmo-pfcp/pfcp_msg.c b/src/libosmo-pfcp/pfcp_msg.c index abcee18..8ae5ab4 100644 --- a/src/libosmo-pfcp/pfcp_msg.c +++ b/src/libosmo-pfcp/pfcp_msg.c @@ -514,6 +514,40 @@ } } +int osmo_pfcp_ip_addrs_get(struct osmo_sockaddr *v4, struct osmo_sockaddr *v6, struct osmo_pfcp_ip_addrs *src) +{ + if (v4) { + if (src->v4_present) + *v4 = src->v4; + else + *v4 = (struct osmo_sockaddr){}; + } + if (v6) { + if (src->v6_present) + *v6 = src->v6; + else + *v6 = (struct osmo_sockaddr){}; + } + return 0; +} + +int osmo_pfcp_ip_addrs_get_str(struct osmo_sockaddr_str *v4, struct osmo_sockaddr_str *v6, struct osmo_pfcp_ip_addrs *src) +{ + if (v4) { + if (src->v4_present) + return osmo_sockaddr_str_from_sockaddr(v4, >v4.u.sas); + else + *v4 = (struct osmo_sockaddr_str){}; + } + if (v6) { + if (src->v6_present) + return osmo_sockaddr_str_from_sockaddr(v6, >v6.u.sas); + else + *v6 = (struct osmo_sockaddr_str){}; + } + return 0; +} + /* If a osmo_fsm_inst placed in m->ctx deallocates before the osmo_pfcp_msg, call this function, to make sure to avoid * use after free. Alternatively use m->ctx.*_use_count to make sure the FSM inst does not deallocate before the * osmo_pfcp_msg is discarded from the resend queue. */ -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/36348?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4338a83f26ef2443f90cf835621e73aed5eac521 Gerrit-Change-Number: 36348 Gerrit-PatchSet: 1 Gerrit-Owner: neels Gerrit-MessageType: newchange