From dfe6c7d910edbba238751d0cfddbb627bb08ef54 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 20 Feb 2010 16:24:02 +0100 Subject: split 'libosmocore' from openbsc codebase This library is intended to collect all generic/common funcitionality of all Osmocom.org projects, including OpenBSC but also OsmocomBB The library currently includes the following modules: bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer, tlv_parse, linuxlist msgb allocation error debugging had to be temporarily disabled as it depends on 'debug.c' functionality which at the moment remains in OpenBSC --- openbsc/include/openbsc/abis_nm.h | 2 +- openbsc/include/openbsc/abis_rsl.h | 2 +- openbsc/include/openbsc/bitvec.h | 65 ------ openbsc/include/openbsc/comp128.h | 22 -- openbsc/include/openbsc/debug.h | 2 +- openbsc/include/openbsc/e1_input.h | 6 +- openbsc/include/openbsc/gsm_04_80.h | 2 +- openbsc/include/openbsc/gsm_data.h | 20 +- openbsc/include/openbsc/gsm_subscriber.h | 2 +- openbsc/include/openbsc/gsm_utils.h | 48 ---- openbsc/include/openbsc/ipaccess.h | 2 +- openbsc/include/openbsc/linuxlist.h | 360 ----------------------------- openbsc/include/openbsc/mgcp.h | 2 +- openbsc/include/openbsc/mncc.h | 2 +- openbsc/include/openbsc/msgb.h | 114 --------- openbsc/include/openbsc/paging.h | 4 +- openbsc/include/openbsc/rtp_proxy.h | 4 +- openbsc/include/openbsc/select.h | 22 -- openbsc/include/openbsc/signal.h | 12 +- openbsc/include/openbsc/statistics.h | 31 --- openbsc/include/openbsc/subchan_demux.h | 2 +- openbsc/include/openbsc/talloc.h | 192 --------------- openbsc/include/openbsc/telnet_interface.h | 2 +- openbsc/include/openbsc/timer.h | 72 ------ openbsc/include/openbsc/tlv.h | 237 ------------------- openbsc/include/openbsc/transaction.h | 2 +- openbsc/include/openbsc/ussd.h | 2 +- 27 files changed, 26 insertions(+), 1207 deletions(-) delete mode 100644 openbsc/include/openbsc/bitvec.h delete mode 100644 openbsc/include/openbsc/comp128.h delete mode 100644 openbsc/include/openbsc/gsm_utils.h delete mode 100644 openbsc/include/openbsc/linuxlist.h delete mode 100644 openbsc/include/openbsc/msgb.h delete mode 100644 openbsc/include/openbsc/select.h delete mode 100644 openbsc/include/openbsc/statistics.h delete mode 100644 openbsc/include/openbsc/talloc.h delete mode 100644 openbsc/include/openbsc/timer.h delete mode 100644 openbsc/include/openbsc/tlv.h (limited to 'openbsc/include') diff --git a/openbsc/include/openbsc/abis_nm.h b/openbsc/include/openbsc/abis_nm.h index 81b4eda61..764e53b61 100644 --- a/openbsc/include/openbsc/abis_nm.h +++ b/openbsc/include/openbsc/abis_nm.h @@ -25,7 +25,7 @@ #include -#include +#include /* PRIVATE */ diff --git a/openbsc/include/openbsc/abis_rsl.h b/openbsc/include/openbsc/abis_rsl.h index 797b2f349..3a10bf990 100644 --- a/openbsc/include/openbsc/abis_rsl.h +++ b/openbsc/include/openbsc/abis_rsl.h @@ -484,7 +484,7 @@ enum rsl_ipac_rtp_csd_format_ir { RSL_IPAC_RTP_CSD_IR_64k = 3, }; -#include "msgb.h" +#include int rsl_bcch_info(struct gsm_bts_trx *trx, u_int8_t type, const u_int8_t *data, int len); diff --git a/openbsc/include/openbsc/bitvec.h b/openbsc/include/openbsc/bitvec.h deleted file mode 100644 index b35aebf16..000000000 --- a/openbsc/include/openbsc/bitvec.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _BITVEC_H -#define _BITVEC_H - -/* bit vector utility routines */ - -/* (C) 2009 by Harald Welte - * - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - - -/* In GSM mac blocks, every bit can be 0 or 1, or L or H. L/H are - * defined relative to the 0x2b padding pattern */ -enum bit_value { - ZERO = 0, - ONE = 1, - L = 2, - H = 3, -}; - -struct bitvec { - unsigned int cur_bit; /* curser to the next unused bit */ - unsigned int data_len; /* length of data array in bytes */ - u_int8_t *data; /* pointer to data array */ -}; - -/* check if the bit is 0 or 1 for a given position inside a bitvec */ -enum bit_value bitvec_get_bit_pos(struct bitvec *bv, unsigned int bitnr); - -/* get the Nth set bit inside the bit vector */ -unsigned int bitvec_get_nth_set_bit(struct bitvec *bv, unsigned int n); - -/* Set a bit at given position */ -int bitvec_set_bit_pos(struct bitvec *bv, unsigned int bitnum, - enum bit_value bit); - -/* Set the next bit in the vector */ -int bitvec_set_bit(struct bitvec *bv, enum bit_value bit); - -/* Set multiple bits at the current position */ -int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count); - -/* Add an unsigned integer (of length count bits) to current position */ -int bitvec_set_uint(struct bitvec *bv, unsigned int in, int count); - - -/* Pad the bit vector up to a certain bit position */ -int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit); - -#endif /* _BITVEC_H */ diff --git a/openbsc/include/openbsc/comp128.h b/openbsc/include/openbsc/comp128.h deleted file mode 100644 index 691ade54b..000000000 --- a/openbsc/include/openbsc/comp128.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * COMP128 header - * - * See comp128.c for details - */ - -#ifndef __COMP128_H__ -#define __COMP128_H__ - -#include - -/* - * Performs the COMP128 algorithm (used as A3/A8) - * ki : u_int8_t [16] - * srand : u_int8_t [16] - * sres : u_int8_t [4] - * kc : u_int8_t [8] - */ -void comp128(u_int8_t *ki, u_int8_t *srand, u_int8_t *sres, u_int8_t *kc); - -#endif /* __COMP128_H__ */ - diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index c40eec3fb..4b67c61b8 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -2,7 +2,7 @@ #define _DEBUG_H #include -#include "linuxlist.h" +#include #define DEBUG diff --git a/openbsc/include/openbsc/e1_input.h b/openbsc/include/openbsc/e1_input.h index 64e0b4f7d..1a3d9d6ad 100644 --- a/openbsc/include/openbsc/e1_input.h +++ b/openbsc/include/openbsc/e1_input.h @@ -4,10 +4,10 @@ #include #include -#include +#include #include -#include -#include +#include +#include #include #define NUM_E1_TS 32 diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h index c240bbe94..266b5f778 100644 --- a/openbsc/include/openbsc/gsm_04_80.h +++ b/openbsc/include/openbsc/gsm_04_80.h @@ -123,7 +123,7 @@ #define ASN1_IA5_STRING_TAG 0x16 #define ASN1_UNICODE_STRING_TAG 0x1E -#include +#include #define MAX_LEN_USSD_STRING 31 diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 5567d89bd..eebe6abb9 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -11,14 +11,6 @@ struct value_string { const char *get_value_string(const struct value_string *vs, u_int32_t val); int get_string_value(const struct value_string *vs, const char *str); -enum gsm_band { - GSM_BAND_400, - GSM_BAND_850, - GSM_BAND_900, - GSM_BAND_1800, - GSM_BAND_1900, -}; - enum gsm_phys_chan_config { GSM_PCHAN_NONE, GSM_PCHAN_CCCH, @@ -56,15 +48,15 @@ enum gsm_chreq_reason_t { GSM_CHREQ_REASON_OTHER, }; -#include +#include #include #include #include -#include -#include -#include - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#include +#include +#include +#include +#include #define TRX_NR_TS 8 #define TS_MAX_LCHAN 8 diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index c639f4046..06539960e 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -3,7 +3,7 @@ #include #include "gsm_data.h" -#include "linuxlist.h" +#include #define GSM_IMEI_LENGTH 17 #define GSM_IMSI_LENGTH 17 diff --git a/openbsc/include/openbsc/gsm_utils.h b/openbsc/include/openbsc/gsm_utils.h deleted file mode 100644 index 56a4120a5..000000000 --- a/openbsc/include/openbsc/gsm_utils.h +++ /dev/null @@ -1,48 +0,0 @@ -/* GSM utility functions, e.g. coding and decoding */ -/* - * (C) 2008 by Daniel Willmann - * (C) 2009 by Holger Hans Peter Freyther - * (C) 2009 by Harald Welte - * - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#ifndef GSM_UTILS_H -#define GSM_UTILS_H - -#include - -int gsm_7bit_decode(char *decoded, const u_int8_t *user_data, u_int8_t length); -int gsm_7bit_encode(u_int8_t *result, const char *data); - -int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm); -int ms_pwr_dbm(enum gsm_band band, u_int8_t lvl); - -/* According to TS 08.05 Chapter 8.1.4 */ -int rxlev2dbm(u_int8_t rxlev); -u_int8_t dbm2rxlev(int dbm); - -/* According to GSM 04.08 Chapter 10.5.2.29 */ -static inline int rach_max_trans_val2raw(int val) { return (val >> 1) & 3; } -static inline int rach_max_trans_raw2val(int raw) { - const int tbl[4] = { 1, 2, 4, 7 }; - return tbl[raw & 3]; -} - -void generate_backtrace(); -#endif diff --git a/openbsc/include/openbsc/ipaccess.h b/openbsc/include/openbsc/ipaccess.h index e101428e4..904a9627b 100644 --- a/openbsc/include/openbsc/ipaccess.h +++ b/openbsc/include/openbsc/ipaccess.h @@ -2,7 +2,7 @@ #define _IPACCESS_H #include "e1_input.h" -#include "linuxlist.h" +#include #define IPA_TCP_PORT_OML 3002 #define IPA_TCP_PORT_RSL 3003 diff --git a/openbsc/include/openbsc/linuxlist.h b/openbsc/include/openbsc/linuxlist.h deleted file mode 100644 index fb99c5ec8..000000000 --- a/openbsc/include/openbsc/linuxlist.h +++ /dev/null @@ -1,360 +0,0 @@ -#ifndef _LINUX_LLIST_H -#define _LINUX_LLIST_H - -#include - -#ifndef inline -#define inline __inline__ -#endif - -static inline void prefetch(const void *x) {;} - -/** - * container_of - cast a member of a structure out to the containing structure - * - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (typeof( ((type *)0)->member ) *)(ptr); \ - (type *)( (char *)__mptr - offsetof(type, member) );}) - - -/* - * These are non-NULL pointers that will result in page faults - * under normal circumstances, used to verify that nobody uses - * non-initialized llist entries. - */ -#define LLIST_POISON1 ((void *) 0x00100100) -#define LLIST_POISON2 ((void *) 0x00200200) - -/* - * Simple doubly linked llist implementation. - * - * Some of the internal functions ("__xxx") are useful when - * manipulating whole llists rather than single entries, as - * sometimes we already know the next/prev entries and we can - * generate better code by using them directly rather than - * using the generic single-entry routines. - */ - -struct llist_head { - struct llist_head *next, *prev; -}; - -#define LLIST_HEAD_INIT(name) { &(name), &(name) } - -#define LLIST_HEAD(name) \ - struct llist_head name = LLIST_HEAD_INIT(name) - -#define INIT_LLIST_HEAD(ptr) do { \ - (ptr)->next = (ptr); (ptr)->prev = (ptr); \ -} while (0) - -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal llist manipulation where we know - * the prev/next entries already! - */ -static inline void __llist_add(struct llist_head *_new, - struct llist_head *prev, - struct llist_head *next) -{ - next->prev = _new; - _new->next = next; - _new->prev = prev; - prev->next = _new; -} - -/** - * llist_add - add a new entry - * @new: new entry to be added - * @head: llist head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -static inline void llist_add(struct llist_head *_new, struct llist_head *head) -{ - __llist_add(_new, head, head->next); -} - -/** - * llist_add_tail - add a new entry - * @new: new entry to be added - * @head: llist head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static inline void llist_add_tail(struct llist_head *_new, struct llist_head *head) -{ - __llist_add(_new, head->prev, head); -} - -/* - * Delete a llist entry by making the prev/next entries - * point to each other. - * - * This is only for internal llist manipulation where we know - * the prev/next entries already! - */ -static inline void __llist_del(struct llist_head * prev, struct llist_head * next) -{ - next->prev = prev; - prev->next = next; -} - -/** - * llist_del - deletes entry from llist. - * @entry: the element to delete from the llist. - * Note: llist_empty on entry does not return true after this, the entry is - * in an undefined state. - */ -static inline void llist_del(struct llist_head *entry) -{ - __llist_del(entry->prev, entry->next); - entry->next = (struct llist_head *)LLIST_POISON1; - entry->prev = (struct llist_head *)LLIST_POISON2; -} - -/** - * llist_del_init - deletes entry from llist and reinitialize it. - * @entry: the element to delete from the llist. - */ -static inline void llist_del_init(struct llist_head *entry) -{ - __llist_del(entry->prev, entry->next); - INIT_LLIST_HEAD(entry); -} - -/** - * llist_move - delete from one llist and add as another's head - * @llist: the entry to move - * @head: the head that will precede our entry - */ -static inline void llist_move(struct llist_head *llist, struct llist_head *head) -{ - __llist_del(llist->prev, llist->next); - llist_add(llist, head); -} - -/** - * llist_move_tail - delete from one llist and add as another's tail - * @llist: the entry to move - * @head: the head that will follow our entry - */ -static inline void llist_move_tail(struct llist_head *llist, - struct llist_head *head) -{ - __llist_del(llist->prev, llist->next); - llist_add_tail(llist, head); -} - -/** - * llist_empty - tests whether a llist is empty - * @head: the llist to test. - */ -static inline int llist_empty(const struct llist_head *head) -{ - return head->next == head; -} - -static inline void __llist_splice(struct llist_head *llist, - struct llist_head *head) -{ - struct llist_head *first = llist->next; - struct llist_head *last = llist->prev; - struct llist_head *at = head->next; - - first->prev = head; - head->next = first; - - last->next = at; - at->prev = last; -} - -/** - * llist_splice - join two llists - * @llist: the new llist to add. - * @head: the place to add it in the first llist. - */ -static inline void llist_splice(struct llist_head *llist, struct llist_head *head) -{ - if (!llist_empty(llist)) - __llist_splice(llist, head); -} - -/** - * llist_splice_init - join two llists and reinitialise the emptied llist. - * @llist: the new llist to add. - * @head: the place to add it in the first llist. - * - * The llist at @llist is reinitialised - */ -static inline void llist_splice_init(struct llist_head *llist, - struct llist_head *head) -{ - if (!llist_empty(llist)) { - __llist_splice(llist, head); - INIT_LLIST_HEAD(llist); - } -} - -/** - * llist_entry - get the struct for this entry - * @ptr: the &struct llist_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the llist_struct within the struct. - */ -#define llist_entry(ptr, type, member) \ - container_of(ptr, type, member) - -/** - * llist_for_each - iterate over a llist - * @pos: the &struct llist_head to use as a loop counter. - * @head: the head for your llist. - */ -#define llist_for_each(pos, head) \ - for (pos = (head)->next, prefetch(pos->next); pos != (head); \ - pos = pos->next, prefetch(pos->next)) - -/** - * __llist_for_each - iterate over a llist - * @pos: the &struct llist_head to use as a loop counter. - * @head: the head for your llist. - * - * This variant differs from llist_for_each() in that it's the - * simplest possible llist iteration code, no prefetching is done. - * Use this for code that knows the llist to be very short (empty - * or 1 entry) most of the time. - */ -#define __llist_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - -/** - * llist_for_each_prev - iterate over a llist backwards - * @pos: the &struct llist_head to use as a loop counter. - * @head: the head for your llist. - */ -#define llist_for_each_prev(pos, head) \ - for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \ - pos = pos->prev, prefetch(pos->prev)) - -/** - * llist_for_each_safe - iterate over a llist safe against removal of llist entry - * @pos: the &struct llist_head to use as a loop counter. - * @n: another &struct llist_head to use as temporary storage - * @head: the head for your llist. - */ -#define llist_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -/** - * llist_for_each_entry - iterate over llist of given type - * @pos: the type * to use as a loop counter. - * @head: the head for your llist. - * @member: the name of the llist_struct within the struct. - */ -#define llist_for_each_entry(pos, head, member) \ - for (pos = llist_entry((head)->next, typeof(*pos), member), \ - prefetch(pos->member.next); \ - &pos->member != (head); \ - pos = llist_entry(pos->member.next, typeof(*pos), member), \ - prefetch(pos->member.next)) - -/** - * llist_for_each_entry_reverse - iterate backwards over llist of given type. - * @pos: the type * to use as a loop counter. - * @head: the head for your llist. - * @member: the name of the llist_struct within the struct. - */ -#define llist_for_each_entry_reverse(pos, head, member) \ - for (pos = llist_entry((head)->prev, typeof(*pos), member), \ - prefetch(pos->member.prev); \ - &pos->member != (head); \ - pos = llist_entry(pos->member.prev, typeof(*pos), member), \ - prefetch(pos->member.prev)) - -/** - * llist_for_each_entry_continue - iterate over llist of given type - * continuing after existing point - * @pos: the type * to use as a loop counter. - * @head: the head for your llist. - * @member: the name of the llist_struct within the struct. - */ -#define llist_for_each_entry_continue(pos, head, member) \ - for (pos = llist_entry(pos->member.next, typeof(*pos), member), \ - prefetch(pos->member.next); \ - &pos->member != (head); \ - pos = llist_entry(pos->member.next, typeof(*pos), member), \ - prefetch(pos->member.next)) - -/** - * llist_for_each_entry_safe - iterate over llist of given type safe against removal of llist entry - * @pos: the type * to use as a loop counter. - * @n: another type * to use as temporary storage - * @head: the head for your llist. - * @member: the name of the llist_struct within the struct. - */ -#define llist_for_each_entry_safe(pos, n, head, member) \ - for (pos = llist_entry((head)->next, typeof(*pos), member), \ - n = llist_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = llist_entry(n->member.next, typeof(*n), member)) - -/** - * llist_for_each_rcu - iterate over an rcu-protected llist - * @pos: the &struct llist_head to use as a loop counter. - * @head: the head for your llist. - */ -#define llist_for_each_rcu(pos, head) \ - for (pos = (head)->next, prefetch(pos->next); pos != (head); \ - pos = pos->next, ({ smp_read_barrier_depends(); 0;}), prefetch(pos->next)) - -#define __llist_for_each_rcu(pos, head) \ - for (pos = (head)->next; pos != (head); \ - pos = pos->next, ({ smp_read_barrier_depends(); 0;})) - -/** - * llist_for_each_safe_rcu - iterate over an rcu-protected llist safe - * against removal of llist entry - * @pos: the &struct llist_head to use as a loop counter. - * @n: another &struct llist_head to use as temporary storage - * @head: the head for your llist. - */ -#define llist_for_each_safe_rcu(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, ({ smp_read_barrier_depends(); 0;}), n = pos->next) - -/** - * llist_for_each_entry_rcu - iterate over rcu llist of given type - * @pos: the type * to use as a loop counter. - * @head: the head for your llist. - * @member: the name of the llist_struct within the struct. - */ -#define llist_for_each_entry_rcu(pos, head, member) \ - for (pos = llist_entry((head)->next, typeof(*pos), member), \ - prefetch(pos->member.next); \ - &pos->member != (head); \ - pos = llist_entry(pos->member.next, typeof(*pos), member), \ - ({ smp_read_barrier_depends(); 0;}), \ - prefetch(pos->member.next)) - - -/** - * llist_for_each_continue_rcu - iterate over an rcu-protected llist - * continuing after existing point. - * @pos: the &struct llist_head to use as a loop counter. - * @head: the head for your llist. - */ -#define llist_for_each_continue_rcu(pos, head) \ - for ((pos) = (pos)->next, prefetch((pos)->next); (pos) != (head); \ - (pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}), prefetch((pos)->next)) - - -#endif diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index 5b4aa3eec..2416fadec 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -24,7 +24,7 @@ #ifndef OPENBSC_MGCP_H #define OPENBSC_MGCP_H -#include "msgb.h" +#include #define RTP_PORT_DEFAULT 4000 extern unsigned int rtp_base_port; diff --git a/openbsc/include/openbsc/mncc.h b/openbsc/include/openbsc/mncc.h index fbf3cab1f..06d594236 100644 --- a/openbsc/include/openbsc/mncc.h +++ b/openbsc/include/openbsc/mncc.h @@ -25,7 +25,7 @@ #ifndef _MNCC_H #define _MNCC_H -#include +#include /* One end of a call */ struct gsm_call { diff --git a/openbsc/include/openbsc/msgb.h b/openbsc/include/openbsc/msgb.h deleted file mode 100644 index d0efc90b5..000000000 --- a/openbsc/include/openbsc/msgb.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef _MSGB_H -#define _MSGB_H - -/* (C) 2008 by Harald Welte - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include -#include "linuxlist.h" - -struct bts_link; - -struct msgb { - struct llist_head list; - - /* ptr to the physical E1 link to the BTS(s) */ - struct gsm_bts_link *bts_link; - - /* Part of which TRX logical channel we were received / transmitted */ - struct gsm_bts_trx *trx; - struct gsm_lchan *lchan; - - unsigned char *l2h; - unsigned char *l3h; - unsigned char *smsh; - - u_int16_t data_len; - u_int16_t len; - - unsigned char *head; - unsigned char *tail; - unsigned char *data; - unsigned char _data[0]; -}; - -extern struct msgb *msgb_alloc(u_int16_t size, const char *name); -extern void msgb_free(struct msgb *m); -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_l2(m) ((void *)(m->l2h)) -#define msgb_l3(m) ((void *)(m->l3h)) -#define msgb_sms(m) ((void *)(m->smsh)) - -static inline unsigned int msgb_l2len(const struct msgb *msgb) -{ - return msgb->tail - (u_int8_t *)msgb_l2(msgb); -} - -static inline unsigned int msgb_l3len(const struct msgb *msgb) -{ - return msgb->tail - (u_int8_t *)msgb_l3(msgb); -} - -static inline unsigned int msgb_headlen(const struct msgb *msgb) -{ - return msgb->len - msgb->data_len; -} -static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len) -{ - unsigned char *tmp = msgb->tail; - msgb->tail += len; - msgb->len += len; - return tmp; -} -static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len) -{ - msgb->data -= len; - msgb->len += len; - return msgb->data; -} -static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len) -{ - msgb->len -= len; - return msgb->data += len; -} -static inline int msgb_tailroom(const struct msgb *msgb) -{ - return (msgb->data + msgb->data_len) - msgb->tail; -} - -/* increase the headroom of an empty msgb, reducing the tailroom */ -static inline void msgb_reserve(struct msgb *msg, int len) -{ - msg->data += len; - msg->tail += len; -} - -static inline struct msgb *msgb_alloc_headroom(int size, int headroom, - const char *name) -{ - struct msgb *msg = msgb_alloc(size, name); - if (msg) - msgb_reserve(msg, headroom); - return msg; -} - -#endif /* _MSGB_H */ diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h index ab6a27494..6cbdca902 100644 --- a/openbsc/include/openbsc/paging.h +++ b/openbsc/include/openbsc/paging.h @@ -24,10 +24,10 @@ #include #include -#include "linuxlist.h" +#include #include "gsm_data.h" #include "gsm_subscriber.h" -#include "timer.h" +#include /* call once for every gsm_bts... */ void paging_init(struct gsm_bts *bts); diff --git a/openbsc/include/openbsc/rtp_proxy.h b/openbsc/include/openbsc/rtp_proxy.h index d128e4f23..f82711a8e 100644 --- a/openbsc/include/openbsc/rtp_proxy.h +++ b/openbsc/include/openbsc/rtp_proxy.h @@ -25,8 +25,8 @@ #include -#include -#include +#include +#include enum rtp_rx_action { RTP_NONE, diff --git a/openbsc/include/openbsc/select.h b/openbsc/include/openbsc/select.h deleted file mode 100644 index 2d8b3ec07..000000000 --- a/openbsc/include/openbsc/select.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _BSC_SELECT_H -#define _BSC_SELECT_H - -#include "linuxlist.h" - -#define BSC_FD_READ 0x0001 -#define BSC_FD_WRITE 0x0002 -#define BSC_FD_EXCEPT 0x0004 - -struct bsc_fd { - struct llist_head list; - int fd; - unsigned int when; - int (*cb)(struct bsc_fd *fd, unsigned int what); - void *data; - unsigned int priv_nr; -}; - -int bsc_register_fd(struct bsc_fd *fd); -void bsc_unregister_fd(struct bsc_fd *fd); -int bsc_select_main(int polling); -#endif /* _BSC_SELECT_H */ diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h index 07b4e393d..0c22869f6 100644 --- a/openbsc/include/openbsc/signal.h +++ b/openbsc/include/openbsc/signal.h @@ -28,6 +28,7 @@ #include #include +#include /* * Signalling subsystems @@ -110,9 +111,6 @@ enum signal_global { S_GLOBAL_SHUTDOWN, }; -typedef int signal_cbfn(unsigned int subsys, unsigned int signal, - void *handler_data, void *signal_data); - struct paging_signal_data { struct gsm_subscriber *subscr; struct gsm_bts *bts; @@ -132,12 +130,4 @@ struct ipacc_ack_signal_data { u_int8_t msg_type; }; -/* Management */ -int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data); -void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data); - -/* Dispatch */ -void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data); - - #endif diff --git a/openbsc/include/openbsc/statistics.h b/openbsc/include/openbsc/statistics.h deleted file mode 100644 index 1d56054ab..000000000 --- a/openbsc/include/openbsc/statistics.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _STATISTICS_H -#define _STATISTICS_H - -struct counter { - struct llist_head list; - const char *name; - const char *description; - unsigned long value; -}; - -static inline void counter_inc(struct counter *ctr) -{ - ctr->value++; -} - -static inline unsigned long counter_get(struct counter *ctr) -{ - return ctr->value; -} - -static inline void counter_reset(struct counter *ctr) -{ - ctr->value = 0; -} - -struct counter *counter_alloc(const char *name); -void counter_free(struct counter *ctr); - -int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data); - -#endif /* _STATISTICS_H */ diff --git a/openbsc/include/openbsc/subchan_demux.h b/openbsc/include/openbsc/subchan_demux.h index 9661b0481..02fa02338 100644 --- a/openbsc/include/openbsc/subchan_demux.h +++ b/openbsc/include/openbsc/subchan_demux.h @@ -22,7 +22,7 @@ */ #include -#include +#include #define NR_SUBCH 4 #define TRAU_FRAME_SIZE 40 diff --git a/openbsc/include/openbsc/talloc.h b/openbsc/include/openbsc/talloc.h deleted file mode 100644 index f7f7643b8..000000000 --- a/openbsc/include/openbsc/talloc.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef _TALLOC_H_ -#define _TALLOC_H_ -/* - Unix SMB/CIFS implementation. - Samba temporary memory allocation functions - - Copyright (C) Andrew Tridgell 2004-2005 - Copyright (C) Stefan Metzmacher 2006 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include -#include -#include - -#define HAVE_VA_COPY - -/* this is only needed for compatibility with the old talloc */ -typedef void TALLOC_CTX; - -/* - this uses a little trick to allow __LINE__ to be stringified -*/ -#ifndef __location__ -#define __TALLOC_STRING_LINE1__(s) #s -#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) -#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) -#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ -#endif - -#ifndef TALLOC_DEPRECATED -#define TALLOC_DEPRECATED 0 -#endif - -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - -/* try to make talloc_set_destructor() and talloc_steal() type safe, - if we have a recent gcc */ -#if (__GNUC__ >= 3) -#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) -#define talloc_set_destructor(ptr, function) \ - do { \ - int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ - _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ - } while(0) -/* this extremely strange macro is to avoid some braindamaged warning - stupidity in gcc 4.1.x */ -#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) -#else -#define talloc_set_destructor(ptr, function) \ - _talloc_set_destructor((ptr), (int (*)(void *))(function)) -#define _TALLOC_TYPEOF(ptr) void * -#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) -#endif - -#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) -#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) - -/* useful macros for creating type checked pointers */ -#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) -#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) - -#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) - -#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) - -#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) -#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) -#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) -#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) -#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx)) - -#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) -#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) - -#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) - -#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) -#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) -#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__) - -#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) - -#if TALLOC_DEPRECATED -#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) -#define talloc_p(ctx, type) talloc(ctx, type) -#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) -#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) -#define talloc_destroy(ctx) talloc_free(ctx) -#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) -#endif - -#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) - -/* The following definitions come from talloc.c */ -void *_talloc(const void *context, size_t size); -void *talloc_pool(const void *context, size_t size); -void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *)); -int talloc_increase_ref_count(const void *ptr); -size_t talloc_reference_count(const void *ptr); -void *_talloc_reference(const void *context, const void *ptr); -int talloc_unlink(const void *context, void *ptr); -const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -void talloc_set_name_const(const void *ptr, const char *name); -void *talloc_named(const void *context, size_t size, - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -void *talloc_named_const(const void *context, size_t size, const char *name); -const char *talloc_get_name(const void *ptr); -void *talloc_check_name(const void *ptr, const char *name); -void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location); -void *talloc_parent(const void *ptr); -const char *talloc_parent_name(const void *ptr); -void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); -int talloc_free(void *ptr); -void talloc_free_children(void *ptr); -void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); -void *_talloc_steal(const void *new_ctx, const void *ptr); -void *_talloc_move(const void *new_ctx, const void *pptr); -size_t talloc_total_size(const void *ptr); -size_t talloc_total_blocks(const void *ptr); -void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, - void (*callback)(const void *ptr, - int depth, int max_depth, - int is_ref, - void *private_data), - void *private_data); -void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); -void talloc_report_full(const void *ptr, FILE *f); -void talloc_report(const void *ptr, FILE *f); -void talloc_enable_null_tracking(void); -void talloc_disable_null_tracking(void); -void talloc_enable_leak_report(void); -void talloc_enable_leak_report_full(void); -void *_talloc_zero(const void *ctx, size_t size, const char *name); -void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); -void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); -void *talloc_realloc_fn(const void *context, void *ptr, size_t size); -void *talloc_autofree_context(void); -size_t talloc_get_size(const void *ctx); -void *talloc_find_parent_byname(const void *ctx, const char *name); -void talloc_show_parents(const void *context, FILE *file); -int talloc_is_parent(const void *context, const void *ptr); - -char *talloc_strdup(const void *t, const char *p); -char *talloc_strdup_append(char *s, const char *a); -char *talloc_strdup_append_buffer(char *s, const char *a); - -char *talloc_strndup(const void *t, const char *p, size_t n); -char *talloc_strndup_append(char *s, const char *a, size_t n); -char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); - -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); - -char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); - -void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); - -#endif diff --git a/openbsc/include/openbsc/telnet_interface.h b/openbsc/include/openbsc/telnet_interface.h index 8e0e9108a..20e794b49 100644 --- a/openbsc/include/openbsc/telnet_interface.h +++ b/openbsc/include/openbsc/telnet_interface.h @@ -23,7 +23,7 @@ #include "gsm_data.h" #include "debug.h" -#include "select.h" +#include #include diff --git a/openbsc/include/openbsc/timer.h b/openbsc/include/openbsc/timer.h deleted file mode 100644 index fee888bfd..000000000 --- a/openbsc/include/openbsc/timer.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * (C) 2008, 2009 by Holger Hans Peter Freyther - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#ifndef TIMER_H -#define TIMER_H - -#include - -#include "linuxlist.h" - -/** - * Timer management: - * - Create a struct timer_list - * - Fill out timeout and use add_timer or - * use schedule_timer to schedule a timer in - * x seconds and microseconds from now... - * - Use del_timer to remove the timer - * - * Internally: - * - We hook into select.c to give a timeval of the - * nearest timer. On already passed timers we give - * it a 0 to immediately fire after the select - * - update_timers will call the callbacks and remove - * the timers. - * - */ -struct timer_list { - struct llist_head entry; - struct timeval timeout; - unsigned int active : 1; - unsigned int handled : 1; - unsigned int in_list : 1; - - void (*cb)(void*); - void *data; -}; - -/** - * timer management - */ -void bsc_add_timer(struct timer_list *timer); -void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds); -void bsc_del_timer(struct timer_list *timer); -int bsc_timer_pending(struct timer_list *timer); - - -/** - * internal timer list management - */ -struct timeval *bsc_nearest_timer(); -void bsc_prepare_timers(); -int bsc_update_timers(); -int bsc_timer_check(void); - -#endif diff --git a/openbsc/include/openbsc/tlv.h b/openbsc/include/openbsc/tlv.h deleted file mode 100644 index 6141b1f07..000000000 --- a/openbsc/include/openbsc/tlv.h +++ /dev/null @@ -1,237 +0,0 @@ -#ifndef _TLV_H -#define _TLV_H - -#include -#include - -#include - -/* Terminology / wording - tag length value (in bits) - - V - - 8 - LV - 8 N * 8 - TLV 8 8 N * 8 - TL16V 8 16 N * 8 - TLV16 8 8 N * 16 - TvLV 8 8/16 N * 8 - -*/ - -#define LV_GROSS_LEN(x) (x+1) -#define TLV_GROSS_LEN(x) (x+2) -#define TLV16_GROSS_LEN(x) ((2*x)+2) -#define TL16V_GROSS_LEN(x) (x+3) -#define L16TV_GROSS_LEN(x) (x+3) - -#define TVLV_MAX_ONEBYTE 0x7f - -static inline u_int16_t TVLV_GROSS_LEN(u_int16_t len) -{ - if (len <= TVLV_MAX_ONEBYTE) - return TLV_GROSS_LEN(len); - else - return TL16V_GROSS_LEN(len); -} - -/* TLV generation */ - -static inline u_int8_t *lv_put(u_int8_t *buf, u_int8_t len, - const u_int8_t *val) -{ - *buf++ = len; - memcpy(buf, val, len); - return buf + len; -} - -static inline u_int8_t *tlv_put(u_int8_t *buf, u_int8_t tag, u_int8_t len, - const u_int8_t *val) -{ - *buf++ = tag; - *buf++ = len; - memcpy(buf, val, len); - return buf + len; -} - -static inline u_int8_t *tlv16_put(u_int8_t *buf, u_int8_t tag, u_int8_t len, - const u_int16_t *val) -{ - *buf++ = tag; - *buf++ = len; - memcpy(buf, val, len*2); - return buf + len*2; -} - -static inline u_int8_t *tl16v_put(u_int8_t *buf, u_int8_t tag, u_int16_t len, - const u_int8_t *val) -{ - *buf++ = tag; - *buf++ = len >> 8; - *buf++ = len & 0xff; - memcpy(buf, val, len); - return buf + len*2; -} - -static inline u_int8_t *tvlv_put(u_int8_t *buf, u_int8_t tag, u_int16_t len, - const u_int8_t *val) -{ - u_int8_t *ret; - - if (len <= TVLV_MAX_ONEBYTE) { - ret = tlv_put(buf, tag, len, val); - buf[1] |= 0x80; - } else - ret = tl16v_put(buf, tag, len, val); - - return ret; -} - -static inline u_int8_t *msgb_tlv16_put(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int16_t *val) -{ - u_int8_t *buf = msgb_put(msg, TLV16_GROSS_LEN(len)); - return tlv16_put(buf, tag, len, val); -} - -static inline u_int8_t *msgb_tl16v_put(struct msgb *msg, u_int8_t tag, u_int16_t len, - const u_int8_t *val) -{ - u_int8_t *buf = msgb_put(msg, TL16V_GROSS_LEN(len)); - return tl16v_put(buf, tag, len, val); -} - -static inline u_int8_t *msgb_tvlv_put(struct msgb *msg, u_int8_t tag, u_int16_t len, - const u_int8_t *val) -{ - u_int8_t *buf = msgb_put(msg, TVLV_GROSS_LEN(len)); - return tvlv_put(buf, tag, len, val); -} - -static inline u_int8_t *msgb_l16tv_put(struct msgb *msg, u_int16_t len, u_int8_t tag, - const u_int8_t *val) -{ - u_int8_t *buf = msgb_put(msg, L16TV_GROSS_LEN(len)); - - *buf++ = len >> 8; - *buf++ = len & 0xff; - *buf++ = tag; - memcpy(buf, val, len); - return buf + len; -} - -static inline u_int8_t *v_put(u_int8_t *buf, u_int8_t val) -{ - *buf++ = val; - return buf; -} - -static inline u_int8_t *tv_put(u_int8_t *buf, u_int8_t tag, - u_int8_t val) -{ - *buf++ = tag; - *buf++ = val; - return buf; -} - -/* 'val' is still in host byte order! */ -static inline u_int8_t *tv16_put(u_int8_t *buf, u_int8_t tag, - u_int16_t val) -{ - *buf++ = tag; - *buf++ = val >> 8; - *buf++ = val & 0xff; - return buf; -} - -static inline u_int8_t *msgb_lv_put(struct msgb *msg, u_int8_t len, const u_int8_t *val) -{ - u_int8_t *buf = msgb_put(msg, LV_GROSS_LEN(len)); - return lv_put(buf, len, val); -} - -static inline u_int8_t *msgb_tlv_put(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int8_t *val) -{ - u_int8_t *buf = msgb_put(msg, TLV_GROSS_LEN(len)); - return tlv_put(buf, tag, len, val); -} - -static inline u_int8_t *msgb_tv_put(struct msgb *msg, u_int8_t tag, u_int8_t val) -{ - u_int8_t *buf = msgb_put(msg, 2); - return tv_put(buf, tag, val); -} - -static inline u_int8_t *msgb_v_put(struct msgb *msg, u_int8_t val) -{ - u_int8_t *buf = msgb_put(msg, 1); - return v_put(buf, val); -} - -static inline u_int8_t *msgb_tv16_put(struct msgb *msg, u_int8_t tag, u_int16_t val) -{ - u_int8_t *buf = msgb_put(msg, 3); - return tv16_put(buf, tag, val); -} - -static inline u_int8_t *msgb_tlv_push(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int8_t *val) -{ - u_int8_t *buf = msgb_push(msg, TLV_GROSS_LEN(len)); - return tlv_put(buf, tag, len, val); -} - -static inline u_int8_t *msgb_tv_push(struct msgb *msg, u_int8_t tag, u_int8_t val) -{ - u_int8_t *buf = msgb_push(msg, 2); - return tv_put(buf, tag, val); -} - -static inline u_int8_t *msgb_tv16_push(struct msgb *msg, u_int8_t tag, u_int16_t val) -{ - u_int8_t *buf = msgb_push(msg, 3); - return tv16_put(buf, tag, val); -} - -/* TLV parsing */ - -struct tlv_p_entry { - u_int16_t len; - const u_int8_t *val; -}; - -enum tlv_type { - TLV_TYPE_NONE, - TLV_TYPE_FIXED, - TLV_TYPE_T, - TLV_TYPE_TV, - TLV_TYPE_TLV, - TLV_TYPE_TL16V, - TLV_TYPE_TvLV, -}; - -struct tlv_def { - enum tlv_type type; - u_int8_t fixed_len; -}; - -struct tlv_definition { - struct tlv_def def[0xff]; -}; - -struct tlv_parsed { - struct tlv_p_entry lv[0xff]; -}; - -extern struct tlv_definition tvlv_att_def; - -int tlv_parse_one(u_int8_t *o_tag, u_int16_t *o_len, const u_int8_t **o_val, - const struct tlv_definition *def, - const u_int8_t *buf, int buf_len); -int tlv_parse(struct tlv_parsed *dec, const struct tlv_definition *def, - const u_int8_t *buf, int buf_len, u_int8_t lv_tag, u_int8_t lv_tag2); -/* take a master (src) tlvdev and fill up all empty slots in 'dst' */ -void tlv_def_patch(struct tlv_definition *dst, const struct tlv_definition *src); - -#define TLVP_PRESENT(x, y) ((x)->lv[y].val) -#define TLVP_LEN(x, y) (x)->lv[y].len -#define TLVP_VAL(x, y) (x)->lv[y].val - -#endif /* _TLV_H */ diff --git a/openbsc/include/openbsc/transaction.h b/openbsc/include/openbsc/transaction.h index cf9410082..50c3cc5da 100644 --- a/openbsc/include/openbsc/transaction.h +++ b/openbsc/include/openbsc/transaction.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include /* One transaction */ diff --git a/openbsc/include/openbsc/ussd.h b/openbsc/include/openbsc/ussd.h index e7bd6d69d..63ea31c5e 100644 --- a/openbsc/include/openbsc/ussd.h +++ b/openbsc/include/openbsc/ussd.h @@ -3,7 +3,7 @@ /* Handler function for mobile-originated USSD messages */ -#include +#include int handle_rcv_ussd(struct msgb *msg); -- cgit v1.2.3