mirror of https://gerrit.osmocom.org/libosmocore
LCLS: add GCR comparison helper
Change-Id: I9e3b5560a058b976638d03cb819415d237ae9984
This commit is contained in:
parent
4fd64e5d93
commit
1bec3908c6
|
@ -39,3 +39,4 @@ struct osmo_gcr_parsed {
|
|||
|
||||
uint8_t osmo_enc_gcr(struct msgb *msg, const struct osmo_gcr_parsed *g);
|
||||
int osmo_dec_gcr(struct osmo_gcr_parsed *gcr, const uint8_t *elem, uint8_t len);
|
||||
bool osmo_gcr_eq(const struct osmo_gcr_parsed *gcr1, const struct osmo_gcr_parsed *gcr2);
|
||||
|
|
|
@ -91,3 +91,24 @@ int osmo_dec_gcr(struct osmo_gcr_parsed *gcr, const uint8_t *elem, uint8_t len)
|
|||
|
||||
return parsed + 5;
|
||||
}
|
||||
|
||||
/*! Compare two GCR structs.
|
||||
* \param[in] gcr1 pointer to the GCR struct
|
||||
* \param[in] gcr2 pointer to the GCR struct
|
||||
* \returns true if GCRs are equal, false otherwise */
|
||||
bool osmo_gcr_eq(const struct osmo_gcr_parsed *gcr1, const struct osmo_gcr_parsed *gcr2)
|
||||
{
|
||||
if (gcr1->net_len != gcr2->net_len)
|
||||
return false;
|
||||
|
||||
if (gcr1->node != gcr2->node)
|
||||
return false;
|
||||
|
||||
if (memcmp(gcr1->cr, gcr2->cr, 5) != 0)
|
||||
return false;
|
||||
|
||||
if (memcmp(gcr1->net, gcr2->net, gcr2->net_len) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -240,6 +240,7 @@ gsm29118_create_service_abort_req;
|
|||
|
||||
osmo_enc_gcr;
|
||||
osmo_dec_gcr;
|
||||
osmo_gcr_eq;
|
||||
|
||||
gsm0858_rsl_ul_meas_enc;
|
||||
|
||||
|
|
|
@ -732,25 +732,10 @@ static void test_enc_dec_lcls()
|
|||
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);
|
||||
abort();
|
||||
}
|
||||
|
||||
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));
|
||||
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));
|
||||
abort();
|
||||
}
|
||||
if (!osmo_gcr_eq(lcls_out.gcr, lcls_in.gcr)) {
|
||||
printf("GCR parsed wrong.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
printf("\tdecoded %d bytes: %s\n", rc, rc == len ? "OK" : "FAIL");
|
||||
msgb_free(msg);
|
||||
|
|
Loading…
Reference in New Issue