Change in libosmocore[master]: gprs_ns2: add member name to bind

2020-12-15 Thread lynxis lazus
lynxis lazus has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/21485 )

Change subject: gprs_ns2: add member name to bind
..

gprs_ns2: add member name to bind

Every bind will have a unique name. Add a name argument
to all bind creating functions and require them to be unique.

This is an API break but there wasn't yet a release with NS2.

Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_fr.c
M src/gb/gprs_ns2_frgre.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_udp.c
M src/gb/gprs_ns2_vty.c
M src/gb/libosmogb.map
8 files changed, 75 insertions(+), 4 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  daniel: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index 6140da2..86bf1ae 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -162,8 +162,13 @@
 void gprs_ns2_free_nsvc(struct gprs_ns2_vc *nsvc);
 struct gprs_ns2_vc *gprs_ns2_nsvc_by_nsvci(struct gprs_ns2_inst *nsi, uint16_t 
nsvci);

+/* generic VL driver */
+struct gprs_ns2_vc_bind *gprs_ns2_bind_by_name(struct gprs_ns2_inst *nsi,
+  const char *name);
+
 /* IP VL driver */
 int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi,
+const char *name,
 const struct osmo_sockaddr *local,
 int dscp,
 struct gprs_ns2_vc_bind **result);
@@ -176,6 +181,7 @@
const char *netif);
 const char *gprs_ns2_fr_bind_netif(struct gprs_ns2_vc_bind *bind);
 int gprs_ns2_fr_bind(struct gprs_ns2_inst *nsi,
+const char *name,
 const char *netif,
 struct osmo_fr_network *fr_network,
 enum osmo_fr_role fr_role,
@@ -226,6 +232,7 @@
const struct osmo_sockaddr *saddr);

 int gprs_ns2_frgre_bind(struct gprs_ns2_inst *nsi,
+   const char *name,
const struct osmo_sockaddr *local,
int dscp,
struct gprs_ns2_vc_bind **result);
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 890b656..bd69acf 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -1239,6 +1239,7 @@
bind->driver->free_bind(bind);

llist_del(>list);
+   talloc_free((char *)bind->name);
talloc_free(bind);
 }

@@ -1251,6 +1252,24 @@
}
 }

+/*! Search for a bind with a unique name
+ *  \param[in] nsi NS instance on which we operate
+ *  \param[in] name The unique bind name to search for
+ *  \return the bind or NULL if not found
+ */
+struct gprs_ns2_vc_bind *gprs_ns2_bind_by_name(
+   struct gprs_ns2_inst *nsi, const char *name)
+{
+   struct gprs_ns2_vc_bind *bind;
+
+   llist_for_each_entry(bind, >binding, list) {
+   if (!strcmp(bind->name, name))
+   return bind;
+   }
+
+   return NULL;
+}
+
 enum gprs_ns2_vc_mode gprs_ns2_dialect_to_vc_mode(
enum gprs_ns2_dialect dialect)
 {
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 6b4fa52..5da6fce 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -453,19 +453,33 @@
  *  \param[out] result pointer to created bind
  *  \return 0 on success; negative on error */
 int gprs_ns2_fr_bind(struct gprs_ns2_inst *nsi,
+const char *name,
 const char *netif,
 struct osmo_fr_network *fr_network,
 enum osmo_fr_role fr_role,
 struct gprs_ns2_vc_bind **result)
 {
-   struct gprs_ns2_vc_bind *bind = talloc_zero(nsi, struct 
gprs_ns2_vc_bind);
+   struct gprs_ns2_vc_bind *bind;
struct priv_bind *priv;
struct osmo_fr_link *fr_link;
int rc = 0;

+   if (!name)
+   return -EINVAL;
+
+   if (gprs_ns2_bind_by_name(nsi, name))
+   return -EALREADY;
+
+   bind = talloc_zero(nsi, struct gprs_ns2_vc_bind);
if (!bind)
return -ENOSPC;

+   bind->name = talloc_strdup(bind, name);
+   if (!bind->name) {
+   rc = -ENOSPC;
+   goto err_bind;
+   }
+
bind->driver = _driver_fr;
bind->ll = GPRS_NS2_LL_FR;
bind->send_vc = fr_vc_sendmsg;
@@ -475,7 +489,7 @@
priv = bind->priv = talloc_zero(bind, struct priv_bind);
if (!priv) {
rc = -ENOSPC;
-   goto err_bind;
+   goto err_name;
}

priv->fd.cb = fr_fd_cb;
@@ -536,6 +550,8 @@
osmo_fr_link_free(fr_link);
 err_priv:
talloc_free(priv);
+err_name:
+   talloc_free((char *)bind->name);
 err_bind:
talloc_free(bind);

diff --git 

Change in libosmocore[master]: gprs_ns2: add member name to bind

2020-12-11 Thread daniel
daniel has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/21485 )

Change subject: gprs_ns2: add member name to bind
..


Patch Set 7: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21485
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Gerrit-Change-Number: 21485
Gerrit-PatchSet: 7
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Fri, 11 Dec 2020 11:07:58 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: gprs_ns2: add member name to bind

2020-12-10 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/21485 )

Change subject: gprs_ns2: add member name to bind
..


Patch Set 6: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/21485/6/src/gb/gprs_ns2.c
File src/gb/gprs_ns2.c:

https://gerrit.osmocom.org/c/libosmocore/+/21485/6/src/gb/gprs_ns2.c@1242
PS6, Line 1242: tal
you don't really need that, as talloc is hierarchical and bind->name always is 
allocated withi nthe 'bind' context.  We can keep it, but it's redundant.



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21485
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Gerrit-Change-Number: 21485
Gerrit-PatchSet: 6
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Thu, 10 Dec 2020 10:02:07 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: gprs_ns2: add member name to bind

2020-12-09 Thread lynxis lazus
lynxis lazus has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/21485 )

Change subject: gprs_ns2: add member name to bind
..


Patch Set 6:

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/21485/4/src/gb/gprs_ns2_internal.h
File src/gb/gprs_ns2_internal.h:

https://gerrit.osmocom.org/c/libosmocore/+/21485/4/src/gb/gprs_ns2_internal.h@185
PS4, Line 185:  char *name;
> const?
Ack



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21485
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Gerrit-Change-Number: 21485
Gerrit-PatchSet: 6
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Thu, 10 Dec 2020 00:56:38 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge 
Gerrit-MessageType: comment


Change in libosmocore[master]: gprs_ns2: add member name to bind

2020-12-09 Thread lynxis lazus
Hello Jenkins Builder, laforge,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/21485

to look at the new patch set (#6).

Change subject: gprs_ns2: add member name to bind
..

gprs_ns2: add member name to bind

Every bind will have a unique name. Add a name argument
to all bind creating functions and require them to be unique.

This is an API break but there wasn't yet a release with NS2.

Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_fr.c
M src/gb/gprs_ns2_frgre.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_udp.c
M src/gb/gprs_ns2_vty.c
M src/gb/libosmogb.map
8 files changed, 75 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/21485/6
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21485
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Gerrit-Change-Number: 21485
Gerrit-PatchSet: 6
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: gprs_ns2: add member name to bind

2020-12-09 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/21485 )

Change subject: gprs_ns2: add member name to bind
..


Patch Set 4: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/21485/4/src/gb/gprs_ns2_internal.h
File src/gb/gprs_ns2_internal.h:

https://gerrit.osmocom.org/c/libosmocore/+/21485/4/src/gb/gprs_ns2_internal.h@185
PS4, Line 185:  char *name;
const?



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21485
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Gerrit-Change-Number: 21485
Gerrit-PatchSet: 4
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 09 Dec 2020 16:17:21 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: gprs_ns2: add member name to bind

2020-12-05 Thread lynxis lazus
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/21485

to look at the new patch set (#2).

Change subject: gprs_ns2: add member name to bind
..

gprs_ns2: add member name to bind

Every bind will have a unique name. Add a name argument
to all bind creating functions and require them to be unique.

This is an API break but there wasn't yet a release with NS2.

Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_fr.c
M src/gb/gprs_ns2_frgre.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_udp.c
M src/gb/gprs_ns2_vty.c
M src/gb/libosmogb.map
8 files changed, 75 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/21485/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21485
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Gerrit-Change-Number: 21485
Gerrit-PatchSet: 2
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: newpatchset