Change in libosmocore[master]: gprs_ns2_sns: replace ns2_sns_type with address family
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24589 ) Change subject: gprs_ns2_sns: replace ns2_sns_type with address family .. gprs_ns2_sns: replace ns2_sns_type with address family Reduces the code as the conversion between address family (bind) and ns2_sns_type is not needed anymore. Related: OS#5036 Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7 --- M src/gb/gprs_ns2_sns.c 1 file changed, 24 insertions(+), 28 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c index d7ff47a..3f09054 100644 --- a/src/gb/gprs_ns2_sns.c +++ b/src/gb/gprs_ns2_sns.c @@ -56,11 +56,6 @@ #define S(x) (1 << (x)) -enum ns2_sns_type { - IPv4, - IPv6, -}; - enum ns2_sns_role { GPRS_SNS_ROLE_BSS, GPRS_SNS_ROLE_SGSN, @@ -132,7 +127,8 @@ struct ns2_sns_state { struct gprs_ns2_nse *nse; - enum ns2_sns_type ip; + /* containing the address family AF_* */ + int family; enum ns2_sns_role role; /* local role: BSS or SGSN */ /* holds the list of initial SNS endpoints */ @@ -666,14 +662,14 @@ /* Upon receiving an SNS-ADD PDU, if the consequent number of IPv4 endpoints * exceeds the number of IPv4 endpoints supported by the NSE, the NSE shall send * an SNS-ACK PDU with a cause code set to "Invalid number of IP4 Endpoints". */ - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: if (gss->remote.num_ip4 >= gss->num_max_ip4_remote) return -NS_CAUSE_INVAL_NR_NS_VC; /* TODO: log message duplicate */ rc = add_ip4_elem(gss, >remote, ip4); break; - case IPv6: + case AF_INET6: if (gss->remote.num_ip6 >= gss->num_max_ip6_remote) return -NS_CAUSE_INVAL_NR_NS_VC; /* TODO: log message duplicate */ @@ -690,8 +686,8 @@ /* Upon receiving an SNS-ADD PDU containing an already configured IP endpoint the * NSE shall send an SNS-ACK PDU with the cause code "Protocol error - * unspecified" */ - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: nsvc = nsvc_by_ip4_elem(nse, ip4); if (nsvc) { /* the nsvc should be already in sync with the ip4 / ip6 elements */ @@ -701,7 +697,7 @@ /* TODO: failure case */ ns2_nsvc_create_ip4(fi, nse, ip4); break; - case IPv6: + case AF_INET6: nsvc = nsvc_by_ip6_elem(nse, ip6); if (nsvc) { /* the nsvc should be already in sync with the ip4 / ip6 elements */ @@ -752,7 +748,7 @@ } } -static int ns2_sns_count_num_local_ep(struct osmo_fsm_inst *fi, enum ns2_sns_type stype) +static int ns2_sns_count_num_local_ep(struct osmo_fsm_inst *fi, int ip_proto) { struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; struct ns2_sns_bind *sbind; @@ -763,12 +759,12 @@ if (!sa) continue; - switch (stype) { - case IPv4: + switch (ip_proto) { + case AF_INET: if (sa->u.sas.ss_family == AF_INET) count++; break; - case IPv6: + case AF_INET6: if (sa->u.sas.ss_family == AF_INET6) count++; break; @@ -806,8 +802,8 @@ return; } - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: ip4_elems = talloc_realloc(fi, gss->local.ip4, struct gprs_ns_ie_ip4_elem, count); if (!ip4_elems) return; @@ -841,7 +837,7 @@ gss->local.num_ip4 = count; gss->num_max_nsvcs = OSMO_MAX(gss->num_max_ip4_remote * gss->local.num_ip4, 8); break; - case IPv6: + case AF_INET6: /* IPv6 */ ip6_elems = talloc_realloc(fi, gss->local.ip6, struct gprs_ns_ie_ip6_elem, count); if (!ip6_elems) @@ -960,13 +956,13 @@ gss->N = 0; /* Transmit SNS-CONFIG */ - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: ns2_tx_sns_config(gss->sns_nsvc, true, gss->local.ip4, gss->local.num_ip4, NULL, 0); break; - case IPv6: + case AF_INET6: ns2_tx_sns_config(gss->sns_nsvc, true,
Change in libosmocore[master]: gprs_ns2_sns: replace ns2_sns_type with address family
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24589 ) Change subject: gprs_ns2_sns: replace ns2_sns_type with address family .. Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24589 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7 Gerrit-Change-Number: 24589 Gerrit-PatchSet: 2 Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: pespin Gerrit-Comment-Date: Sun, 13 Jun 2021 18:31:44 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in libosmocore[master]: gprs_ns2_sns: replace ns2_sns_type with address family
Hello Jenkins Builder, pespin, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmocore/+/24589 to look at the new patch set (#2). Change subject: gprs_ns2_sns: replace ns2_sns_type with address family .. gprs_ns2_sns: replace ns2_sns_type with address family Reduces the code as the conversion between address family (bind) and ns2_sns_type is not needed anymore. Related: OS#5036 Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7 --- M src/gb/gprs_ns2_sns.c 1 file changed, 24 insertions(+), 28 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/89/24589/2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24589 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7 Gerrit-Change-Number: 24589 Gerrit-PatchSet: 2 Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-MessageType: newpatchset
Change in libosmocore[master]: gprs_ns2_sns: replace ns2_sns_type with address family
lynxis lazus has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24589 ) Change subject: gprs_ns2_sns: replace ns2_sns_type with address family .. Patch Set 1: (1 comment) https://gerrit.osmocom.org/c/libosmocore/+/24589/1/src/gb/gprs_ns2_sns.c File src/gb/gprs_ns2_sns.c: https://gerrit.osmocom.org/c/libosmocore/+/24589/1/src/gb/gprs_ns2_sns.c@130 PS1, Line 130: int family; > probably a comment referring to AF_* would be welcome to understand what's > stored here. Ack -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24589 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7 Gerrit-Change-Number: 24589 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-Comment-Date: Sat, 12 Jun 2021 20:36:26 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
Change in libosmocore[master]: gprs_ns2_sns: replace ns2_sns_type with address family
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24589 ) Change subject: gprs_ns2_sns: replace ns2_sns_type with address family .. Patch Set 1: Code-Review+1 (1 comment) https://gerrit.osmocom.org/c/libosmocore/+/24589/1/src/gb/gprs_ns2_sns.c File src/gb/gprs_ns2_sns.c: https://gerrit.osmocom.org/c/libosmocore/+/24589/1/src/gb/gprs_ns2_sns.c@130 PS1, Line 130: int family; probably a comment referring to AF_* would be welcome to understand what's stored here. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24589 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7 Gerrit-Change-Number: 24589 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-Comment-Date: Mon, 07 Jun 2021 09:17:22 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in libosmocore[master]: gprs_ns2_sns: replace ns2_sns_type with address family
lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/24589 ) Change subject: gprs_ns2_sns: replace ns2_sns_type with address family .. gprs_ns2_sns: replace ns2_sns_type with address family Reduces the code as the conversion between address family (bind) and ns2_sns_type is not needed anymore. Related: OS#5036 Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7 --- M src/gb/gprs_ns2_sns.c 1 file changed, 23 insertions(+), 28 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/89/24589/1 diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c index 0badcee..ec4bd87 100644 --- a/src/gb/gprs_ns2_sns.c +++ b/src/gb/gprs_ns2_sns.c @@ -56,11 +56,6 @@ #define S(x) (1 << (x)) -enum ns2_sns_type { - IPv4, - IPv6, -}; - enum ns2_sns_role { GPRS_SNS_ROLE_BSS, GPRS_SNS_ROLE_SGSN, @@ -132,7 +127,7 @@ struct ns2_sns_state { struct gprs_ns2_nse *nse; - enum ns2_sns_type ip; + int family; enum ns2_sns_role role; /* local role: BSS or SGSN */ /* holds the list of initial SNS endpoints */ @@ -665,14 +660,14 @@ /* Upon receiving an SNS-ADD PDU, if the consequent number of IPv4 endpoints * exceeds the number of IPv4 endpoints supported by the NSE, the NSE shall send * an SNS-ACK PDU with a cause code set to "Invalid number of IP4 Endpoints". */ - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: if (gss->remote.num_ip4 >= gss->num_max_ip4_remote) return -NS_CAUSE_INVAL_NR_NS_VC; /* TODO: log message duplicate */ rc = add_ip4_elem(gss, >remote, ip4); break; - case IPv6: + case AF_INET6: if (gss->remote.num_ip6 >= gss->num_max_ip6_remote) return -NS_CAUSE_INVAL_NR_NS_VC; /* TODO: log message duplicate */ @@ -689,8 +684,8 @@ /* Upon receiving an SNS-ADD PDU containing an already configured IP endpoint the * NSE shall send an SNS-ACK PDU with the cause code "Protocol error - * unspecified" */ - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: nsvc = nsvc_by_ip4_elem(nse, ip4); if (nsvc) { /* the nsvc should be already in sync with the ip4 / ip6 elements */ @@ -700,7 +695,7 @@ /* TODO: failure case */ ns2_nsvc_create_ip4(fi, nse, ip4); break; - case IPv6: + case AF_INET6: nsvc = nsvc_by_ip6_elem(nse, ip6); if (nsvc) { /* the nsvc should be already in sync with the ip4 / ip6 elements */ @@ -751,7 +746,7 @@ } } -static int ns2_sns_count_num_local_ep(struct osmo_fsm_inst *fi, enum ns2_sns_type stype) +static int ns2_sns_count_num_local_ep(struct osmo_fsm_inst *fi, int ip_proto) { struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; struct ns2_sns_bind *sbind; @@ -762,12 +757,12 @@ if (!sa) continue; - switch (stype) { - case IPv4: + switch (ip_proto) { + case AF_INET: if (sa->u.sas.ss_family == AF_INET) count++; break; - case IPv6: + case AF_INET6: if (sa->u.sas.ss_family == AF_INET6) count++; break; @@ -805,8 +800,8 @@ return; } - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: ip4_elems = talloc_realloc(fi, gss->local.ip4, struct gprs_ns_ie_ip4_elem, count); if (!ip4_elems) return; @@ -840,7 +835,7 @@ gss->local.num_ip4 = count; gss->num_max_nsvcs = OSMO_MAX(gss->num_max_ip4_remote * gss->local.num_ip4, 8); break; - case IPv6: + case AF_INET6: /* IPv6 */ ip6_elems = talloc_realloc(fi, gss->local.ip6, struct gprs_ns_ie_ip6_elem, count); if (!ip6_elems) @@ -959,13 +954,13 @@ gss->N = 0; /* Transmit SNS-CONFIG */ - switch (gss->ip) { - case IPv4: + switch (gss->family) { + case AF_INET: ns2_tx_sns_config(gss->sns_nsvc, true, gss->local.ip4, gss->local.num_ip4, NULL, 0); break; - case IPv6: + case AF_INET6: ns2_tx_sns_config(gss->sns_nsvc, true, NULL, 0,