Change in libosmocore[master]: LCLS: add allocator function

2019-01-15 Thread Max
Max has abandoned this change. ( https://gerrit.osmocom.org/12491 )

Change subject: LCLS: add allocator function
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/12491
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: abandon
Gerrit-Change-Id: If67cf93ae3dd449e96156485fe1baaf013df3f77
Gerrit-Change-Number: 12491
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-CC: Harald Welte 
Gerrit-CC: Neels Hofmeyr 


Change in libosmocore[master]: LCLS: add allocator function

2019-01-14 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12491 )

Change subject: LCLS: add allocator function
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/12491/1/src/gsm/gsm0808_utils.c
File src/gsm/gsm0808_utils.c:

https://gerrit.osmocom.org/#/c/12491/1/src/gsm/gsm0808_utils.c@587
PS1, Line 587: r->gcr = talloc_zero(r, struct osmo_gcr_parsed);
> please remind me, why again was the gcr member not a static member of the 
> struct osmo_lcls and has t […]
GCR is optional in a sense that it's possible that we might have other 
osmo-lcls set while GCR is missing. Right now this is indicated by NULL pointer 
in place of GCR. I can make it static and add bool gcr_available to distinguish 
between "no GCR" and "GCR is all 0" cases. Which one would be better option?



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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If67cf93ae3dd449e96156485fe1baaf013df3f77
Gerrit-Change-Number: 12491
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-CC: Harald Welte 
Gerrit-CC: Neels Hofmeyr 
Gerrit-Comment-Date: Mon, 14 Jan 2019 10:16:41 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add allocator function

2019-01-11 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/12491 )

Change subject: LCLS: add allocator function
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/12491/1/src/gsm/gsm0808_utils.c
File src/gsm/gsm0808_utils.c:

https://gerrit.osmocom.org/#/c/12491/1/src/gsm/gsm0808_utils.c@587
PS1, Line 587: r->gcr = talloc_zero(r, struct osmo_gcr_parsed);
please remind me, why again was the gcr member not a static member of the 
struct osmo_lcls and has to be dynamically allocated?



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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If67cf93ae3dd449e96156485fe1baaf013df3f77
Gerrit-Change-Number: 12491
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Harald Welte 
Gerrit-CC: Neels Hofmeyr 
Gerrit-Comment-Date: Fri, 11 Jan 2019 17:20:42 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add allocator function

2019-01-09 Thread Neels Hofmeyr
Neels Hofmeyr has posted comments on this change. ( 
https://gerrit.osmocom.org/12491 )

Change subject: LCLS: add allocator function
..


Patch Set 1:

ok, but why?


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If67cf93ae3dd449e96156485fe1baaf013df3f77
Gerrit-Change-Number: 12491
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Neels Hofmeyr 
Gerrit-Comment-Date: Wed, 09 Jan 2019 16:37:05 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add allocator function

2019-01-09 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12491


Change subject: LCLS: add allocator function
..

LCLS: add allocator function

Change-Id: If67cf93ae3dd449e96156485fe1baaf013df3f77
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
4 files changed, 32 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/91/12491/1

diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 4a2233e..2d86a7d 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -67,6 +67,8 @@
bool corr_needed;  /**< §3.2.2.118 
Correlation-Not-Needed */
 };

+struct osmo_lcls *osmo_lcls_alloc(void *ctx);
+
 extern const struct value_string gsm0808_cell_id_discr_names[];
 static inline const char *gsm0808_cell_id_discr_name(enum CELL_IDENT id_discr)
 { return get_value_string(gsm0808_cell_id_discr_names, id_discr); }
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 2a458c3..90388fa 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -575,6 +575,22 @@
return enc;
 }

+/*! Dynamically allocate LCLS parameters struct.
+ *  \param[in] ctx context pointer to hang the result off
+ *  \returns osmo_lcls pointer or NULL on error */
+struct osmo_lcls *osmo_lcls_alloc(void *ctx)
+{
+   struct osmo_lcls *r = talloc_zero(ctx, struct osmo_lcls);
+   if (!r)
+   return NULL;
+
+   r->gcr = talloc_zero(r, struct osmo_gcr_parsed);
+   if (!r->gcr)
+   return NULL;
+
+   return r;
+}
+
 /*! Decode LCLS parameters to a given msgb, 3GPP TS 48.008 §3.2.2.115 - 
3.2.2.120.
  *  \param[out] lcls Caller-provided memory to store LCLS-related data
  *  \param[in] tp IE values to be decoded
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index bb97878..6b5f0ae 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -38,6 +38,7 @@
 abis_nm_get_sw_conf;
 abis_nm_get_sw_desc_len;

+osmo_lcls_alloc;
 osmo_sitype_strs;
 osmo_c4;
 osmo_get_rand_id;
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 40e2b87..cb0df88 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -682,7 +682,7 @@
};
uint8_t len;
struct msgb *msg;
-   struct osmo_gcr_parsed p = { 0 }, g = {
+   struct osmo_gcr_parsed g = {
.net_len = 3,
.net = { 0xf1, 0xf2, 0xf3 },
.node = 0xDEAD,
@@ -690,7 +690,7 @@
};
int rc;
struct tlv_parsed tp;
-   struct osmo_lcls lcls_out = { .gcr =  }, lcls_in = {
+   struct osmo_lcls *lcls_out, lcls_in = {
.gcr = ,
.config = GSM0808_LCLS_CFG_NA,
.control = GSM0808_LCLS_CSC_NA,
@@ -701,6 +701,8 @@
if (!msg)
return;

+   lcls_out = osmo_lcls_alloc(msg);
+
len = gsm0808_enc_lcls(msg, _in);
printf("Testing Global Call Reference IE encoder...\n\t%d bytes added: 
%s\n",
   len, len == ARRAY_SIZE(res) ? "OK" : "FAIL");
@@ -714,29 +716,29 @@
abort();
}

-   rc = gsm0808_dec_lcls(_out, );
+   rc = gsm0808_dec_lcls(lcls_out, );
if (rc < 0) {
printf("decoding failed: %s [%s]\n", strerror(-rc), 
msgb_hexdump(msg));
abort();
}

-   if (lcls_out.gcr->net_len != g.net_len) {
-   printf("Network ID length parsed wrong: %u != %u\n", 
lcls_out.gcr->net_len, g.net_len);
+   if (lcls_out->gcr->net_len != g.net_len) {
+   printf("Network ID length parsed wrong: %u != %u\n", 
lcls_out->gcr->net_len, g.net_len);
abort();
}

-   if (lcls_out.gcr->node != g.node) {
-   printf("Node ID parsed wrong: 0x%X != 0x%X\n", 
lcls_out.gcr->node, g.node);
+   if (lcls_out->gcr->node != g.node) {
+   printf("Node ID parsed wrong: 0x%X != 0x%X\n", 
lcls_out->gcr->node, g.node);
abort();
}

-   if (memcmp(lcls_out.gcr->net, g.net, g.net_len) != 0) {
-   printf("Network ID parsed wrong: %s\n", 
osmo_hexdump(lcls_out.gcr->net, lcls_out.gcr->net_len));
+   if (memcmp(lcls_out->gcr->net, g.net, g.net_len) != 0) {
+   printf("Network ID parsed wrong: %s\n", 
osmo_hexdump(lcls_out->gcr->net, lcls_out->gcr->net_len));
abort();
}

-   if (memcmp(lcls_out.gcr->cr, g.cr, 5) != 0) {
-   printf("Call ref. ID parsed wrong: %s\n", 
osmo_hexdump(lcls_out.gcr->cr, 5));
+   if (memcmp(lcls_out->gcr->cr, g.cr, 5) != 0) {
+   printf("Call ref. ID parsed wrong: %s\n", 
osmo_hexdump(lcls_out->gcr->cr, 5));
abort();
}


--
To view, visit