summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am1
-rw-r--r--include/osmocom/Makefile.am5
-rw-r--r--include/osmocom/codec/Makefile.am3
-rw-r--r--include/osmocom/codec/codec.h20
-rw-r--r--include/osmocom/core/Makefile.am31
-rw-r--r--include/osmocom/core/application.h23
-rw-r--r--include/osmocom/core/backtrace.h6
-rw-r--r--include/osmocom/core/bits.h78
-rw-r--r--include/osmocom/core/bitvec.h70
-rw-r--r--include/osmocom/core/conv.h146
-rw-r--r--include/osmocom/core/crc16.h34
-rw-r--r--include/osmocom/core/crcXXgen.h.tpl59
-rw-r--r--include/osmocom/core/crcgen.h41
-rw-r--r--include/osmocom/core/gsmtap.h159
-rw-r--r--include/osmocom/core/gsmtap_util.h57
-rw-r--r--include/osmocom/core/linuxlist.h360
-rw-r--r--include/osmocom/core/linuxrbtree.h160
-rw-r--r--include/osmocom/core/logging.h211
-rw-r--r--include/osmocom/core/msgb.h370
-rw-r--r--include/osmocom/core/msgfile.h49
-rw-r--r--include/osmocom/core/panic.h20
-rw-r--r--include/osmocom/core/plugin.h6
-rw-r--r--include/osmocom/core/prim.h58
-rw-r--r--include/osmocom/core/process.h2
-rw-r--r--include/osmocom/core/rate_ctr.h88
-rw-r--r--include/osmocom/core/select.h45
-rw-r--r--include/osmocom/core/serial.h43
-rw-r--r--include/osmocom/core/signal.h46
-rw-r--r--include/osmocom/core/socket.h35
-rw-r--r--include/osmocom/core/statistics.h53
-rw-r--r--include/osmocom/core/talloc.h192
-rw-r--r--include/osmocom/core/timer.h87
-rw-r--r--include/osmocom/core/timer_compat.h79
-rw-r--r--include/osmocom/core/utils.h56
-rw-r--r--include/osmocom/core/write_queue.h63
-rw-r--r--include/osmocom/crypt/Makefile.am3
-rw-r--r--include/osmocom/crypt/auth.h91
-rw-r--r--include/osmocom/crypt/gprs_cipher.h54
-rw-r--r--include/osmocom/gsm/Makefile.am8
-rw-r--r--include/osmocom/gsm/a5.h63
-rw-r--r--include/osmocom/gsm/abis_nm.h40
-rw-r--r--include/osmocom/gsm/comp128.h22
-rw-r--r--include/osmocom/gsm/gsm0411_smc.h62
-rw-r--r--include/osmocom/gsm/gsm0411_smr.h45
-rw-r--r--include/osmocom/gsm/gsm0411_utils.h36
-rw-r--r--include/osmocom/gsm/gsm0480.h26
-rw-r--r--include/osmocom/gsm/gsm0502.h38
-rw-r--r--include/osmocom/gsm/gsm0808.h50
-rw-r--r--include/osmocom/gsm/gsm48.h38
-rw-r--r--include/osmocom/gsm/gsm48_ie.h117
-rw-r--r--include/osmocom/gsm/gsm_utils.h151
-rw-r--r--include/osmocom/gsm/lapd_core.h171
-rw-r--r--include/osmocom/gsm/lapdm.h162
-rw-r--r--include/osmocom/gsm/mncc.h71
-rw-r--r--include/osmocom/gsm/prim.h13
-rw-r--r--include/osmocom/gsm/protocol/Makefile.am6
-rw-r--r--include/osmocom/gsm/protocol/gsm_03_41.h51
-rw-r--r--include/osmocom/gsm/protocol/gsm_04_08.h1265
-rw-r--r--include/osmocom/gsm/protocol/gsm_04_11.h190
-rw-r--r--include/osmocom/gsm/protocol/gsm_04_12.h31
-rw-r--r--include/osmocom/gsm/protocol/gsm_04_80.h126
-rw-r--r--include/osmocom/gsm/protocol/gsm_08_08.h303
-rw-r--r--include/osmocom/gsm/protocol/gsm_08_58.h561
-rw-r--r--include/osmocom/gsm/protocol/gsm_12_21.h748
-rw-r--r--include/osmocom/gsm/protocol/gsm_44_318.h153
-rw-r--r--include/osmocom/gsm/protocol/ipaccess.h94
-rw-r--r--include/osmocom/gsm/rsl.h55
-rw-r--r--include/osmocom/gsm/rxlev_stat.h22
-rw-r--r--include/osmocom/gsm/sysinfo.h43
-rw-r--r--include/osmocom/gsm/tlv.h319
-rw-r--r--include/osmocom/vty/Makefile.am4
-rw-r--r--include/osmocom/vty/buffer.h102
-rw-r--r--include/osmocom/vty/command.h372
-rw-r--r--include/osmocom/vty/logging.h12
-rw-r--r--include/osmocom/vty/misc.h13
-rw-r--r--include/osmocom/vty/telnet_interface.h56
-rw-r--r--include/osmocom/vty/vector.h64
-rw-r--r--include/osmocom/vty/vty.h188
78 files changed, 8795 insertions, 0 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 00000000..3578a80e
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = osmocom
diff --git a/include/osmocom/Makefile.am b/include/osmocom/Makefile.am
new file mode 100644
index 00000000..21f4f2d0
--- /dev/null
+++ b/include/osmocom/Makefile.am
@@ -0,0 +1,5 @@
+if ENABLE_VTY
+SUBDIRS = vty codec crypt gsm core
+else
+SUBDIRS = codec crypt gsm core
+endif
diff --git a/include/osmocom/codec/Makefile.am b/include/osmocom/codec/Makefile.am
new file mode 100644
index 00000000..c2136023
--- /dev/null
+++ b/include/osmocom/codec/Makefile.am
@@ -0,0 +1,3 @@
+osmocodec_HEADERS = codec.h
+
+osmocodecdir = $(includedir)/osmocom/codec
diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h
new file mode 100644
index 00000000..6f9ffea5
--- /dev/null
+++ b/include/osmocom/codec/codec.h
@@ -0,0 +1,20 @@
+#ifndef _OSMOCOM_CODEC_H
+#define _OSMOCOM_CODEC_H
+
+#include <stdint.h>
+
+extern uint16_t gsm610_bitorder[]; /* FR */
+extern uint16_t gsm620_unvoiced_bitorder[]; /* HR unvoiced */
+extern uint16_t gsm620_voiced_bitorder[]; /* HR voiced */
+extern uint16_t gsm660_bitorder[]; /* EFR */
+
+extern uint16_t gsm690_12_2_bitorder[]; /* AMR 12.2 kbits */
+extern uint16_t gsm690_10_2_bitorder[]; /* AMR 10.2 kbits */
+extern uint16_t gsm690_7_95_bitorder[]; /* AMR 7.95 kbits */
+extern uint16_t gsm690_7_4_bitorder[]; /* AMR 7.4 kbits */
+extern uint16_t gsm690_6_7_bitorder[]; /* AMR 6.7 kbits */
+extern uint16_t gsm690_5_9_bitorder[]; /* AMR 5.9 kbits */
+extern uint16_t gsm690_5_15_bitorder[]; /* AMR 5.15 kbits */
+extern uint16_t gsm690_4_75_bitorder[]; /* AMR 4.75 kbits */
+
+#endif /* _OSMOCOM_CODEC_H */
diff --git a/include/osmocom/core/Makefile.am b/include/osmocom/core/Makefile.am
new file mode 100644
index 00000000..1df111af
--- /dev/null
+++ b/include/osmocom/core/Makefile.am
@@ -0,0 +1,31 @@
+osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h bits.h \
+ bitvec.h statistics.h utils.h socket.h \
+ gsmtap.h write_queue.h prim.h \
+ logging.h rate_ctr.h gsmtap_util.h \
+ crc16.h panic.h process.h linuxrbtree.h \
+ backtrace.h conv.h application.h \
+ crcgen.h crc8gen.h crc16gen.h crc32gen.h crc64gen.h
+
+noinst_HEADERS = timer_compat.h
+
+if ENABLE_PLUGIN
+osmocore_HEADERS += plugin.h
+endif
+
+if ENABLE_TALLOC
+osmocore_HEADERS += talloc.h
+endif
+
+if ENABLE_MSGFILE
+osmocore_HEADERS += msgfile.h
+endif
+
+if ENABLE_SERIAL
+osmocore_HEADERS += serial.h
+endif
+
+osmocoredir = $(includedir)/osmocom/core
+
+crc%gen.h: crcXXgen.h.tpl
+ @echo " SED $< -> $@"
+ @sed -e's/XX/$*/g' $< > $@
diff --git a/include/osmocom/core/application.h b/include/osmocom/core/application.h
new file mode 100644
index 00000000..34571698
--- /dev/null
+++ b/include/osmocom/core/application.h
@@ -0,0 +1,23 @@
+#ifndef OSMO_APPLICATION_H
+#define OSMO_APPLICATION_H
+
+/*!
+ * \file application.h
+ * \brief Routines for helping with the osmocom application setup.
+ */
+
+/*! \brief information containing the available logging subsystems */
+struct log_info;
+
+/*! \brief one instance of a logging target (file, stderr, ...) */
+struct log_target;
+
+/*! \brief the default logging target, logging to stderr */
+extern struct log_target *osmo_stderr_target;
+
+void osmo_init_ignore_signals(void);
+int osmo_init_logging(const struct log_info *);
+
+int osmo_daemonize(void);
+
+#endif
diff --git a/include/osmocom/core/backtrace.h b/include/osmocom/core/backtrace.h
new file mode 100644
index 00000000..1ed089ad
--- /dev/null
+++ b/include/osmocom/core/backtrace.h
@@ -0,0 +1,6 @@
+#ifndef _OSMO_BACKTRACE_H_
+#define _OSMO_BACKTRACE_H_
+
+void osmo_generate_backtrace(void);
+
+#endif
diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h
new file mode 100644
index 00000000..4c685321
--- /dev/null
+++ b/include/osmocom/core/bits.h
@@ -0,0 +1,78 @@
+#ifndef _OSMO_BITS_H
+#define _OSMO_BITS_H
+
+#include <stdint.h>
+
+/*! \defgroup bits soft, unpacked and packed bits
+ * @{
+ */
+
+/*! \file bits.h
+ * \brief Osmocom bit level support code
+ */
+
+typedef int8_t sbit_t; /*!< \brief soft bit (-127...127) */
+typedef uint8_t ubit_t; /*!< \brief unpacked bit (0 or 1) */
+typedef uint8_t pbit_t; /*!< \brief packed bis (8 bits in a byte) */
+
+/*
+ NOTE on the endianess of pbit_t:
+ Bits in a pbit_t are ordered MSB first, i.e. 0x80 is the first bit.
+ Bit i in a pbit_t array is array[i/8] & (1<<(7-i%8))
+*/
+
+/*! \brief determine how many bytes we would need for \a num_bits packed bits
+ * \param[in] num_bits Number of packed bits
+ */
+static inline unsigned int osmo_pbit_bytesize(unsigned int num_bits)
+{
+ unsigned int pbit_bytesize = num_bits / 8;
+
+ if (num_bits % 8)
+ pbit_bytesize++;
+
+ return pbit_bytesize;
+}
+
+int osmo_ubit2pbit(pbit_t *out, const ubit_t *in, unsigned int num_bits);
+
+int osmo_pbit2ubit(ubit_t *out, const pbit_t *in, unsigned int num_bits);
+
+int osmo_ubit2pbit_ext(pbit_t *out, unsigned int out_ofs,
+ const ubit_t *in, unsigned int in_ofs,
+ unsigned int num_bits, int lsb_mode);
+
+int osmo_pbit2ubit_ext(ubit_t *out, unsigned int out_ofs,
+ const pbit_t *in, unsigned int in_ofs,
+ unsigned int num_bits, int lsb_mode);
+
+
+/* BIT REVERSAL */
+
+/*! \brief bit-reversal mode for osmo_bit_reversal() */
+enum osmo_br_mode {
+ /*! \brief reverse all bits in a 32bit dword */
+ OSMO_BR_BITS_IN_DWORD = 31,
+ /*! \brief reverse byte order in a 32bit dword */
+ OSMO_BR_BYTES_IN_DWORD = 24,
+ /*! \brief reverse bits of each byte in a 32bit dword */
+ OSMO_BR_BITS_IN_BYTE = 7,
+ /*! \brief swap the two 16bit words in a 32bit dword */
+ OSMO_BR_WORD_SWAP = 16,
+};
+
+/*! \brief generic bit reversal function */
+uint32_t osmo_bit_reversal(uint32_t x, enum osmo_br_mode k);
+
+/* \brief reverse the bits within each byte of a 32bit word */
+uint32_t osmo_revbytebits_32(uint32_t x);
+
+/* \brief reverse the bits within a byte */
+uint32_t osmo_revbytebits_8(uint8_t x);
+
+/* \brief reverse the bits of each byte in a given buffer */
+void osmo_revbytebits_buf(uint8_t *buf, int len);
+
+/*! @} */
+
+#endif /* _OSMO_BITS_H */
diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
new file mode 100644
index 00000000..9c000d02
--- /dev/null
+++ b/include/osmocom/core/bitvec.h
@@ -0,0 +1,70 @@
+#ifndef _BITVEC_H
+#define _BITVEC_H
+
+/* bit vector utility routines */
+
+/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
+ *
+ * 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.
+ *
+ */
+
+/*! \defgroup bitvec Bit vectors
+ * @{
+ */
+
+/*! \file bitvec.h
+ * \brief Osmocom bit vector abstraction
+ */
+
+#include <stdint.h>
+
+/*! \brief A single GSM bit
+ *
+ * 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, /*!< \brief A zero (0) bit */
+ ONE = 1, /*!< \brief A one (1) bit */
+ L = 2, /*!< \brief A CSN.1 "L" bit */
+ H = 3, /*!< \brief A CSN.1 "H" bit */
+};
+
+/*! \brief structure describing a bit vector */
+struct bitvec {
+ unsigned int cur_bit; /*!< \brief curser to the next unused bit */
+ unsigned int data_len; /*!< \brief length of data array in bytes */
+ uint8_t *data; /*!< \brief pointer to data array */
+};
+
+enum bit_value bitvec_get_bit_pos(const struct bitvec *bv, unsigned int bitnr);
+enum bit_value bitvec_get_bit_pos_high(const struct bitvec *bv,
+ unsigned int bitnr);
+unsigned int bitvec_get_nth_set_bit(const struct bitvec *bv, unsigned int n);
+int bitvec_set_bit_pos(struct bitvec *bv, unsigned int bitnum,
+ enum bit_value bit);
+int bitvec_set_bit(struct bitvec *bv, enum bit_value bit);
+int bitvec_get_bit_high(struct bitvec *bv);
+int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count);
+int bitvec_set_uint(struct bitvec *bv, unsigned int in, int count);
+int bitvec_get_uint(struct bitvec *bv, int num_bits);
+int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val);
+int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit);
+
+/*! @} */
+
+#endif /* _BITVEC_H */
diff --git a/include/osmocom/core/conv.h b/include/osmocom/core/conv.h
new file mode 100644
index 00000000..e5b2a975
--- /dev/null
+++ b/include/osmocom/core/conv.h
@@ -0,0 +1,146 @@
+/*
+ * conv.h
+ *
+ * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
+ *
+ * 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.
+ */
+
+/*! \defgroup conv Convolutional encoding and decoding routines
+ * @{
+ */
+
+/*! \file conv.h
+ * \file Osmocom convolutional encoder and decoder
+ */
+
+#ifndef __OSMO_CONV_H__
+#define __OSMO_CONV_H__
+
+#include <stdint.h>
+
+#include <osmocom/core/bits.h>
+
+/*! \brief possibe termination types
+ *
+ * The termination type will determine which state the encoder/decoder
+ * can start/end with. This is mostly taken care of in the high level API
+ * call. So if you use the low level API, you must take care of making the
+ * proper calls yourself.
+ */
+enum osmo_conv_term {
+ CONV_TERM_FLUSH = 0, /*!< \brief Flush encoder state */
+ CONV_TERM_TRUNCATION, /*!< \brief Direct truncation */
+ CONV_TERM_TAIL_BITING, /*!< \brief Tail biting */
+};
+
+/*! \brief structure describing a given convolutional code
+ *
+ * The only required fields are N,K and the next_output/next_state arrays. The
+ * other can be left to default value of zero depending on what the code does.
+ * If 'len' is left at 0 then only the low level API can be used.
+ */
+struct osmo_conv_code {
+ int N; /*!< \brief Inverse of code rate */
+ int K; /*!< \brief Constraint length */
+ int len; /*!< \brief # of data bits */
+
+ enum osmo_conv_term term; /*!< \brief Termination type */
+
+ const uint8_t (*next_output)[2];/*!< \brief Next output array */
+ const uint8_t (*next_state)[2]; /*!< \brief Next state array */
+
+ const uint8_t *next_term_output;/*!< \brief Flush termination output */
+ const uint8_t *next_term_state; /*!< \brief Flush termination state */
+
+ const int *puncture; /*!< \brief Punctured bits indexes */
+};
+
+
+/* Common */
+
+int osmo_conv_get_input_length(const struct osmo_conv_code *code, int len);
+int osmo_conv_get_output_length(const struct osmo_conv_code *code, int len);
+
+
+/* Encoding */
+
+ /* Low level API */
+
+/*! \brief convolutional encoder state */
+struct osmo_conv_encoder {
+ const struct osmo_conv_code *code; /*!< \brief for which code? */
+ int i_idx; /*!< \brief Next input bit index */
+ int p_idx; /*!< \brief Current puncture index */
+ uint8_t state; /*!< \brief Current state */
+};
+
+void osmo_conv_encode_init(struct osmo_conv_encoder *encoder,
+ const struct osmo_conv_code *code);
+void osmo_conv_encode_load_state(struct osmo_conv_encoder *encoder,
+ const ubit_t *input);
+int osmo_conv_encode_raw(struct osmo_conv_encoder *encoder,
+ const ubit_t *input, ubit_t *output, int n);
+int osmo_conv_encode_flush(struct osmo_conv_encoder *encoder, ubit_t *output);
+
+ /* All-in-one */
+int osmo_conv_encode(const struct osmo_conv_code *code,
+