Hello Harald Welte, Jenkins Builder,

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

    https://gerrit.osmocom.org/6286

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

Add helper functions for ACC bit flags in rach control IE.

Add inline functions to manipulate and query ACC flag bits
in the rach_control.t2 and rach_control.t3 octets.
These function definitions also serve as documentation of
the purpose of rach_control.t2/t3.

Change-Id: I8f0a65c2980f86eb5c43f3bebe727f4d4d973163
Related: OS#2591
---
M include/osmocom/gsm/protocol/gsm_04_08.h
1 file changed, 43 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/6286/2

diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h 
b/include/osmocom/gsm/protocol/gsm_04_08.h
index 0e02744..4a821cc 100644
--- a/include/osmocom/gsm/protocol/gsm_04_08.h
+++ b/include/osmocom/gsm/protocol/gsm_04_08.h
@@ -460,10 +460,51 @@
                 cell_bar :1,
                 tx_integer :4,
                 max_trans :2;
-       uint8_t t2;
-       uint8_t t3;
+       uint8_t t2; /* ACC 8-15 barred flags */
+       uint8_t t3; /* ACC 0-7 barred flags */
 } __attribute__ ((packed));
 
+/*
+ * Mark an Access Control Class as barred.
+ *  \param[in] rach_control A Rach Control Information Element.
+ *  \param[in] acc Access Control Class number (0 - 15) which shall be barred.
+ */
+static inline void gsm48_barr_acc(struct gsm48_rach_control *rach_control, 
unsigned int acc)
+{
+       OSMO_ASSERT(acc >= 0 && acc <= 15);
+       if (acc >= 8)
+               rach_control->t2 |= (1 << (acc - 8));
+       else
+               rach_control->t3 |= (1 << (acc));
+}
+
+/*
+ * Mark an Access Control Class as allowed.
+ *  \param[in] rach_control A Rach Control Information Element.
+ *  \param[in] acc Access Control Class number (0 - 15) which shall be allowed.
+ */
+static inline void gsm48_allow_acc(struct gsm48_rach_control *rach_control, 
unsigned int acc)
+{
+       OSMO_ASSERT(acc >= 0 && acc <= 15);
+       if (acc >= 8)
+               rach_control->t2 &= ~(1 << (acc - 8));
+       else
+               rach_control->t3 &= ~(1 << (acc));
+}
+
+/*
+ * Indicate whether an Access Control Class is barred.
+ *  \param[in] rach_control A Rach Control Information Element.
+ *  \param[in] acc Access Control Class number (0 - 15).
+ *  \returns true if the Access Control class is barred, false otherwise
+ */
+static inline bool gsm48_acc_is_barred(struct gsm48_rach_control 
*rach_control, unsigned int acc)
+{
+       OSMO_ASSERT(acc >= 0 && acc <= 15);
+       if (acc >= 8)
+               return (rach_control->t2 & (1 << (acc - 8))) != 0;
+       return (rach_control->t3 & (1 << (acc))) != 0;
+}
 
 /* Chapter 10.5.2.30 */
 struct gsm48_req_ref {

-- 
To view, visit https://gerrit.osmocom.org/6286
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8f0a65c2980f86eb5c43f3bebe727f4d4d973163
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <ssperl...@sysmocom.de>

Reply via email to