SUBDIRS = include src tests
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libosmocore.pc libosmovty.pc
+pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc
BUILT_SOURCES = $(top_srcdir)/.version
$(top_srcdir)/.version:
AC_OUTPUT(
libosmocore.pc
+ libosmocodec.pc
libosmovty.pc
include/osmocom/Makefile
include/osmocom/vty/Makefile
+ include/osmocom/codec/Makefile
include/osmocom/crypt/Makefile
include/osmocore/Makefile
include/osmocore/protocol/Makefile
if ENABLE_VTY
-SUBDIRS = vty crypt
+SUBDIRS = vty codec crypt
else
-SUBDIRS = crypt
+SUBDIRS = codec crypt
endif
--- /dev/null
+osmocodec_HEADERS = codec.h
+
+osmocodecdir = $(includedir)/osmocom/codec
#include <stdint.h>
extern uint16_t gsm610_bitorder[]; /* FR */
-extern uint16_t gsm620_bitorder[]; /* HR */
+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 */
struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, uint16_t ci);
struct msgb *gsm0808_create_reset(void);
+struct msgb *gsm0808_create_clear_command(uint8_t reason);
struct msgb *gsm0808_create_clear_complete(void);
struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id);
struct msgb *gsm0808_create_cipher_reject(uint8_t cause);
uint8_t chosen_channel, uint8_t encr_alg_id,
uint8_t speech_mode);
struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause);
+struct msgb *gsm0808_create_clear_rqst(uint8_t cause);
+struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id);
void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id);
const struct tlv_definition *gsm0808_att_tlvdef();
#define ARFCN_PCS 0x8000
#define ARFCN_UPLINK 0x4000
+#define ARFCN_FLAG_MASK 0xf000 /* Reserve the upper 5 bits for flags */
enum gsm_band gsm_arfcn2band(uint16_t arfcn);
#ifdef MSGB_DEBUG
#include <osmocore/panic.h>
-static inline void msgb_abort(struct msgb *msg, const char *text)
-{
- osmo_panic("%s", text);
-}
+#define MSGB_ABORT(msg, fmt, args ...) do { \
+ osmo_panic("msgb(%p): " fmt, msg, ## args); \
+ } while(0)
+#else
+#define MSGB_ABORT(msg, fmt, args ...)
#endif
#define msgb_l1(m) ((void *)(m->l1h))
static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len)
{
unsigned char *tmp = msgb->tail;
-#ifdef MSGB_DEBUG
- if (msgb_tailroom(msgb) < len)
- msgb_abort(msgb, "Not enough tailroom\n");
-#endif
+ if (msgb_tailroom(msgb) < (int) len)
+ MSGB_ABORT(msgb, "Not enough tailroom msgb_push (%u < %u)\n",
+ msgb_tailroom(msgb), len);
msgb->tail += len;
msgb->len += len;
return tmp;
}
static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len)
{
-#ifdef MSGB_DEBUG
- if (msgb_headroom(msgb) < len)
- msgb_abort(msgb, "Not enough headroom\n");
-#endif
+ if (msgb_headroom(msgb) < (int) len)
+ MSGB_ABORT(msgb, "Not enough headroom msgb_push (%u < %u)\n",
+ msgb_headroom(msgb), len);
msgb->data -= len;
msgb->len += len;
return msgb->data;
typedef void (*osmo_panic_handler_t)(const char *fmt, va_list args);
void osmo_panic(const char *fmt, ...);
-void osmo_set_panic_handler(osmo_panic_handler_t *h);
+void osmo_set_panic_handler(osmo_panic_handler_t h);
#endif
--- /dev/null
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Osmocom Codec related utilities Library
+Description: C Utility Library
+Version: @VERSION@
+Libs: -L${libdir} -losmocodec
+Cflags: -I${includedir}/
+
return msg;
}
+struct msgb *gsm0808_create_clear_command(uint8_t reason)
+{
+ struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
+ "bssmap: clear command");
+ if (!msg)
+ return NULL;
+
+ msg->l3h = msgb_tv_put(msg, BSSAP_MSG_BSS_MANAGEMENT, 4);
+ msgb_v_put(msg, BSS_MAP_MSG_CLEAR_CMD);
+ msgb_tlv_put(msg, GSM0808_IE_CAUSE, 1, &reason);
+ return msg;
+}
+
struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id)
{
struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
return msg;
}
+struct msgb *gsm0808_create_clear_rqst(uint8_t cause)
+{
+ struct msgb *msg;
+
+ msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
+ "bssmap: clear rqst");
+ if (!msg)
+ return NULL;
+
+ msg->l3h = msgb_put(msg, 2 + 4);
+ msg->l3h[0] = BSSAP_MSG_BSS_MANAGEMENT;
+ msg->l3h[1] = 4;
+
+ msg->l3h[2] = BSS_MAP_MSG_CLEAR_RQST;
+ msg->l3h[3] = GSM0808_IE_CAUSE;
+ msg->l3h[4] = 1;
+ msg->l3h[5] = cause;
+ return msg;
+}
+
void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id)
{
uint8_t *hh = msgb_push(msg, 3);
hh[2] = msg->len - 3;
}
+struct msgb *gsm0808_create_dtap(struct msgb *msg_l3, uint8_t link_id)
+{
+ struct dtap_header *header;
+ uint8_t *data;
+ struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
+ "dtap");
+ if (!msg)
+ return NULL;
+
+ /* DTAP header */
+ msg->l3h = msgb_put(msg, sizeof(*header));
+ header = (struct dtap_header *) &msg->l3h[0];
+ header->type = BSSAP_MSG_DTAP;
+ header->link_id = link_id;
+ header->length = msgb_l3len(msg_l3);
+
+ /* Payload */
+ data = msgb_put(msg, header->length);
+ memcpy(data, msg_l3->l3h, header->length);
+
+ return msg;
+}
+
static const struct tlv_definition bss_att_tlvdef = {
.def = {
[GSM0808_IE_IMSI] = { TLV_TYPE_TLV },
enum gsm_band gsm_arfcn2band(uint16_t arfcn)
{
- if (arfcn & ARFCN_PCS)
+ int is_pcs = arfcn & ARFCN_PCS;
+
+ arfcn &= ~ARFCN_FLAG_MASK;
+
+ if (is_pcs)
return GSM_BAND_1900;
else if (arfcn <= 124)
return GSM_BAND_900;
{
uint16_t freq10_ul;
uint16_t freq10_dl;
+ int is_pcs = arfcn & ARFCN_PCS;
+
+ arfcn &= ~ARFCN_FLAG_MASK;
- if (arfcn & ARFCN_PCS) {
+ if (is_pcs) {
/* DCS 1900 */
arfcn &= ~ARFCN_PCS;
freq10_ul = 18502 + 2 * (arfcn-512);
char *items[3];
int last_item = 0;
+ /* Skip comments from the file */
+ if (line[0] == '#')
+ return;
+
for (i = 0; i < len; ++i) {
if (line[i] == '\n' || line[i] == '\r')
line[i] = '\0';
*
*/
+#include <osmocore/gsm_utils.h>
#include <osmocore/panic.h>
#include "../config.h"
static void osmo_panic_default(const char *fmt, va_list args)
{
vfprintf(stderr, fmt, args);
+ generate_backtrace();
abort();
}
}
-void osmo_set_panic_handler(osmo_panic_handler_t *h)
+void osmo_set_panic_handler(osmo_panic_handler_t h)
{
osmo_panic_handler = h;
}
* (C) 2000-2009 by Harald Welte <laforge@gnumonks.org>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation
+ * 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
+# This is a comment
*:*::Hello Welt