This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
daniel gerrit-no-reply at lists.osmocom.orgdaniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22235 ) Change subject: Refactor ns2_nsvc_create_ip* ...................................................................... Refactor ns2_nsvc_create_ip* Move code common in ipv4/6 into a separate function and call that function. Change-Id: I076d53bee2e67e1cb3ad6ee5cd05c63ebe3359fb Related: OS#4948 --- M src/gb/gprs_ns2_sns.c 1 file changed, 27 insertions(+), 38 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/35/22235/1 diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c index 1958477..90688af 100644 --- a/src/gb/gprs_ns2_sns.c +++ b/src/gb/gprs_ns2_sns.c @@ -255,66 +255,55 @@ } } -static void ns2_nsvc_create_ip4(struct osmo_fsm_inst *fi, - struct gprs_ns2_nse *nse, - const struct gprs_ns_ie_ip4_elem *ip4) +static void ns2_vc_create_ip(struct osmo_fsm_inst *fi, struct gprs_ns2_nse *nse, struct osmo_sockaddr *remote, + uint8_t sig_weight, uint8_t data_weight) { struct gprs_ns2_inst *nsi = nse->nsi; struct gprs_ns2_vc *nsvc; struct gprs_ns2_vc_bind *bind; + + /* for every bind, create a connection if bind type == IP */ + llist_for_each_entry(bind, &nsi->binding, list) { + if (bind->ll != GPRS_NS2_LL_UDP) + continue; + /* ignore failed connection */ + nsvc = gprs_ns2_ip_connect_inactive(bind, + remote, + nse, 0); + if (!nsvc) { + LOGPFSML(fi, LOGL_ERROR, "SNS-CONFIG: Failed to create NSVC\n"); + continue; + } + + nsvc->sig_weight = sig_weight; + nsvc->data_weight = data_weight; + } +} + +static void ns2_nsvc_create_ip4(struct osmo_fsm_inst *fi, + struct gprs_ns2_nse *nse, + const struct gprs_ns_ie_ip4_elem *ip4) +{ struct osmo_sockaddr remote = { }; /* copy over. Both data structures use network byte order */ remote.u.sin.sin_family = AF_INET; remote.u.sin.sin_addr.s_addr = ip4->ip_addr; remote.u.sin.sin_port = ip4->udp_port; - /* for every bind, create a connection if bind type == IP */ - llist_for_each_entry(bind, &nsi->binding, list) { - if (bind->ll != GPRS_NS2_LL_UDP) - continue; - /* ignore failed connection */ - nsvc = gprs_ns2_ip_connect_inactive(bind, - &remote, - nse, 0); - if (!nsvc) { - LOGPFSML(fi, LOGL_ERROR, "SNS-CONFIG: Failed to create NSVC\n"); - continue; - } - - nsvc->sig_weight = ip4->sig_weight; - nsvc->data_weight = ip4->data_weight; - } + ns2_vc_create_ip(fi, nse, &remote, ip4->sig_weight, ip4->data_weight); } static void ns2_nsvc_create_ip6(struct osmo_fsm_inst *fi, struct gprs_ns2_nse *nse, const struct gprs_ns_ie_ip6_elem *ip6) { - struct gprs_ns2_inst *nsi = nse->nsi; - struct gprs_ns2_vc *nsvc; - struct gprs_ns2_vc_bind *bind; struct osmo_sockaddr remote = {}; /* copy over. Both data structures use network byte order */ remote.u.sin6.sin6_family = AF_INET6; remote.u.sin6.sin6_addr = ip6->ip_addr; remote.u.sin6.sin6_port = ip6->udp_port; - /* for every bind, create a connection if bind type == IP */ - llist_for_each_entry(bind, &nsi->binding, list) { - if (bind->ll != GPRS_NS2_LL_UDP) - continue; - /* ignore failed connection */ - nsvc = gprs_ns2_ip_connect_inactive(bind, - &remote, - nse, 0); - if (!nsvc) { - LOGPFSML(fi, LOGL_ERROR, "SNS-CONFIG: Failed to create NSVC\n"); - continue; - } - - nsvc->sig_weight = ip6->sig_weight; - nsvc->data_weight = ip6->data_weight; - } + ns2_vc_create_ip(fi, nse, &remote, ip6->sig_weight, ip6->data_weight); } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22235 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I076d53bee2e67e1cb3ad6ee5cd05c63ebe3359fb Gerrit-Change-Number: 22235 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210116/ff7e70bd/attachment.htm>