4 /* (C) 2008 by Harald Welte <laforge@gnumonks.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "linuxlist.h"
29 struct llist_head list;
31 /* ptr to the physical E1 link to the BTS(s) */
32 struct gsm_bts_link *bts_link;
34 /* Part of which TRX logical channel we were received / transmitted */
35 struct gsm_bts_trx *trx;
36 struct gsm_lchan *lchan;
48 unsigned char _data[0];
51 extern struct msgb *msgb_alloc(uint16_t size, const char *name);
52 extern void msgb_free(struct msgb *m);
53 extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
54 extern struct msgb *msgb_dequeue(struct llist_head *queue);
55 extern void msgb_reset(struct msgb *m);
57 #define msgb_l2(m) ((void *)(m->l2h))
58 #define msgb_l3(m) ((void *)(m->l3h))
59 #define msgb_sms(m) ((void *)(m->smsh))
61 static inline unsigned int msgb_l2len(const struct msgb *msgb)
63 return msgb->tail - (uint8_t *)msgb_l2(msgb);
66 static inline unsigned int msgb_l3len(const struct msgb *msgb)
68 return msgb->tail - (uint8_t *)msgb_l3(msgb);
71 static inline unsigned int msgb_headlen(const struct msgb *msgb)
73 return msgb->len - msgb->data_len;
75 static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len)
77 unsigned char *tmp = msgb->tail;
82 static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len)
88 static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len)
91 return msgb->data += len;
93 static inline int msgb_tailroom(const struct msgb *msgb)
95 return (msgb->data + msgb->data_len) - msgb->tail;
98 /* increase the headroom of an empty msgb, reducing the tailroom */
99 static inline void msgb_reserve(struct msgb *msg, int len)
105 static inline struct msgb *msgb_alloc_headroom(int size, int headroom,
108 struct msgb *msg = msgb_alloc(size, name);
110 msgb_reserve(msg, headroom);