Inter-Layer intergration work
[osmocom-bb.git] / src / shared / libosmocore / include / osmocore / msgb.h
index 131f920..4f0c8c3 100644 (file)
@@ -35,9 +35,22 @@ struct msgb {
        struct gsm_bts_trx *trx;
        struct gsm_lchan *lchan;
 
+       /* the Layer1 header (if any) */
+       unsigned char *l1h;
+       /* the A-bis layer 2 header: OML, RSL(RLL), NS */
        unsigned char *l2h;
+       /* the layer 3 header. For OML: FOM; RSL: 04.08; GPRS: BSSGP */
        unsigned char *l3h;
-       unsigned char *smsh;
+
+       /* the layer 4 header */
+       union {
+               unsigned char *smsh;
+               unsigned char *llch;
+       };
+
+       /* the layer 5 header, GPRS: GMM header */
+       unsigned char *gmmh;
+       uint32_t tlli;
 
        uint16_t data_len;
        uint16_t len;
@@ -54,10 +67,16 @@ extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
 extern struct msgb *msgb_dequeue(struct llist_head *queue);
 extern void msgb_reset(struct msgb *m);
 
+#define msgb_l1(m)     ((void *)(m->l1h))
 #define msgb_l2(m)     ((void *)(m->l2h))
 #define msgb_l3(m)     ((void *)(m->l3h))
 #define msgb_sms(m)    ((void *)(m->smsh))
 
+static inline unsigned int msgb_l1len(const struct msgb *msgb)
+{
+       return msgb->tail - (uint8_t *)msgb_l1(msgb);
+}
+
 static inline unsigned int msgb_l2len(const struct msgb *msgb)
 {
        return msgb->tail - (uint8_t *)msgb_l2(msgb);
@@ -92,7 +111,7 @@ static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len)
 }
 static inline int msgb_tailroom(const struct msgb *msgb)
 {
-       return (msgb->data + msgb->data_len) - msgb->tail;
+       return (msgb->head + msgb->data_len) - msgb->tail;
 }
 
 /* increase the headroom of an empty msgb, reducing the tailroom */