Merge commit '7f6615a37df0dadbe86fdfc980e0a8a15013a80e'

This commit is contained in:
Sylvain Munaut 2010-11-13 22:48:15 +01:00
commit 11316da173
16 changed files with 113 additions and 22 deletions

View File

@ -5,7 +5,7 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
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:

View File

@ -99,9 +99,11 @@ AM_CONDITIONAL(ENABLE_MSGFILE, test "x$enable_msgfile" = "x1")
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

View File

@ -1,5 +1,5 @@
if ENABLE_VTY
SUBDIRS = vty crypt
SUBDIRS = vty codec crypt
else
SUBDIRS = crypt
SUBDIRS = codec crypt
endif

View File

@ -0,0 +1,3 @@
osmocodec_HEADERS = codec.h
osmocodecdir = $(includedir)/osmocom/codec

View File

@ -4,7 +4,8 @@
#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 */

View File

@ -26,6 +26,7 @@ struct msgb;
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);
@ -35,7 +36,9 @@ struct msgb *gsm0808_create_assignment_completed(uint8_t rr_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();

View File

@ -87,6 +87,7 @@ static inline int rach_max_trans_raw2val(int raw) {
#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);

View File

@ -62,10 +62,11 @@ extern void msgb_reset(struct msgb *m);
#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))
@ -106,10 +107,9 @@ static inline int msgb_headroom(const struct msgb *msgb)
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;
@ -157,10 +157,9 @@ static inline uint32_t msgb_get_u32(struct msgb *msgb)
}
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;

View File

@ -6,6 +6,6 @@
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

View File

@ -0,0 +1,11 @@
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}/

View File

@ -108,6 +108,19 @@ struct msgb *gsm0808_create_clear_complete(void)
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,
@ -271,6 +284,26 @@ struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause)
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);
@ -279,6 +312,29 @@ void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id)
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 },

View File

@ -359,7 +359,11 @@ void generate_backtrace()
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;
@ -386,8 +390,11 @@ uint16_t gsm_arfcn2freq10(uint16_t arfcn, int uplink)
{
uint16_t freq10_ul;
uint16_t freq10_dl;
int is_pcs = arfcn & ARFCN_PCS;
if (arfcn & ARFCN_PCS) {
arfcn &= ~ARFCN_FLAG_MASK;
if (is_pcs) {
/* DCS 1900 */
arfcn &= ~ARFCN_PCS;
freq10_ul = 18502 + 2 * (arfcn-512);

View File

@ -70,6 +70,10 @@ static void handle_line(struct msg_entries *entries, char *line)
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';

View File

@ -20,6 +20,7 @@
*
*/
#include <osmocore/gsm_utils.h>
#include <osmocore/panic.h>
#include "../config.h"
@ -36,6 +37,7 @@ static osmo_panic_handler_t osmo_panic_handler = (void*)0;
static void osmo_panic_default(const char *fmt, va_list args)
{
vfprintf(stderr, fmt, args);
generate_backtrace();
abort();
}
@ -64,7 +66,7 @@ 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)
{
osmo_panic_handler = h;
}

View File

@ -5,8 +5,9 @@
* (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

View File

@ -1 +1,2 @@
# This is a comment
*:*::Hello Welt