add TITAN support for MNCC/PCU interface decoding

This commit is contained in:
Harald Welte 2018-03-26 19:02:08 +02:00
parent 75e9578917
commit 670659c28c
15 changed files with 92996 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.o
*.so
*.a

View File

@ -1,11 +1,26 @@
LIB_SRCS = utils.c sock_events.c libc_overrides.c
CFLAGS = -Wall
LIB_OBJS = $(LIB_SRCS:.c=.o)
EXTRA_LIBS =
CFLAGS = -Wall
LDFLAGS=-L/usr/lib/titan -fPIC -lttcn3-dynamic
ifdef ENABLE_TITAN
EXTRA_LIBS += titan/titan.a
CFLAGS += -DENABLE_TITAN
endif
default: libudtrace.so
libudtrace.so: $(LIB_SRCS)
$(CC) $(CFLAGS) -fPIC -shared -Wl,-soname,libudtrace.so -o $@ $^ -ldl
%.o: %.c
$(CC) $(CFLAGS) -fPIC -o $@ -c $^
libudtrace.so: $(LIB_OBJS) $(EXTRA_LIBS)
$(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,libudtrace.so -o $@ $^ -ldl
titan/titan.a:
$(MAKE) -C titan titan.a
clean:
rm -f *.o libudtrace.so

14382
titan/General_Types.cc Normal file

File diff suppressed because it is too large Load Diff

2464
titan/General_Types.hh Normal file

File diff suppressed because it is too large Load Diff

321
titan/MNCC_EncDec.cc Normal file
View File

@ -0,0 +1,321 @@
#include "mncc.h"
#include "MNCC_Types.hh"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
namespace MNCC__Types {
static void enc_bcap(struct gsm_mncc_bearer_cap *out, const MNCC__bearer__cap& in)
{
out->transfer = in.transfer();
out->mode = in.mode();
out->coding = in.coding();
out->radio = in.radio();
out->speech_ctm = in.speech__ctm();
for (int i = 0; i < in.speech__ver().lengthof(); i++)
out->speech_ver[i] = in.speech__ver()[i];
if (in.data().is_value()) {
MNCC__bearer__cap__data data = in.data();
out->data.rate_adaption = (gsm48_bcap_ra) (int) data.rate__adaptation();
out->data.sig_access = (gsm48_bcap_sig_access) (int) data.sig__access();
out->data.async = data.async();
out->data.nr_stop_bits = data.nr__stop__bits();
out->data.nr_data_bits = data.nr__data__bits();
out->data.user_rate = (gsm48_bcap_user_rate) (int) data.user__rate();
out->data.parity = (gsm48_bcap_parity) (int) data.parity();
out->data.interm_rate = (gsm48_bcap_interm_rate) (int) data.interm__rate();
out->data.transp = (gsm48_bcap_transp) (int) data.transp();
out->data.modem_type = (gsm48_bcap_modem_type) (int) data.modem__type();
}
}
static MNCC__bearer__cap dec_bcap(const struct gsm_mncc_bearer_cap *in)
{
MNCC__bearer__cap__data data;
MNCC__speech__vers vers;
data = MNCC__bearer__cap__data((GSM48__bcap__ra) in->data.rate_adaption,
(GSM48__bcap__sig__access) in->data.sig_access,
in->data.async,
in->data.nr_stop_bits,
in->data.nr_data_bits,
(GSM48__bcap__user__rate) in->data.user_rate,
(GSM48__bcap__parity) in->data.parity,
(GSM48__bcap__interm__rate) in->data.interm_rate,
(GSM48__bcap__transp) in->data.transp,
(GSM48__bcap__modem__type) in->data.modem_type);
for (unsigned int i = 0; i < ARRAY_SIZE(in->speech_ver); i++)
vers[0] = in->speech_ver[0];
return MNCC__bearer__cap(in->transfer, in->mode, in->coding, in->radio, in->speech_ctm,
vers, data);
}
static void enc_number(struct gsm_mncc_number *num, const MNCC__number& in)
{
num->type = in.number__type();
num->plan = in.plan();
num->present = in.presence();
num->screen = in.screen();
strncpy(num->number, in.number(), sizeof(num->number));
}
static MNCC__number dec_number(const struct gsm_mncc_number *num)
{
return MNCC__number(num->type, num->plan,num->present, num->screen, num->number);
}
OCTETSTRING enc__MNCC__PDU(const MNCC__PDU& in)
{
struct gsm_mncc mncc;
OCTETSTRING ret_val;
memset(&mncc, 0, sizeof(mncc));
mncc.msg_type = in.msg__type();
switch (in.u().get_selection()) {
case MNCC__MsgUnion::ALT_signal: {
const MNCC__PDU__Signal& in_sig = in.u().signal();
mncc.callref = in_sig.callref();
if (in_sig.bearer__cap().is_value()) {
enc_bcap(&mncc.bearer_cap, in_sig.bearer__cap());
mncc.fields |= MNCC_F_BEARER_CAP;
}
if (in_sig.called().is_value()) {
enc_number(&mncc.called, in_sig.called());
mncc.fields |= MNCC_F_CALLED;
}
if (in_sig.calling().is_value()) {
enc_number(&mncc.calling, in_sig.calling());
mncc.fields |= MNCC_F_CALLING;
}
if (in_sig.redirecting().is_value()) {
enc_number(&mncc.redirecting, in_sig.redirecting());
mncc.fields |= MNCC_F_REDIRECTING;
}
if (in_sig.connected().is_value()) {
enc_number(&mncc.connected, in_sig.connected());
mncc.fields |= MNCC_F_CONNECTED;
}
if (in_sig.cause().is_value()) {
const MNCC__cause &cause = in_sig.cause();
TTCN_Buffer ttcn_buffer(cause.diag());
mncc.cause.location = cause.location();
mncc.cause.coding = cause.coding();
mncc.cause.rec = cause.rec();
mncc.cause.rec_val = cause.rec__val();
mncc.cause.value = cause.val();
mncc.cause.diag_len = ttcn_buffer.get_len();
if (mncc.cause.diag_len > (int) sizeof(mncc.cause.diag)) {
TTCN_error("MNCC diagnostics length %u too long", mncc.cause.diag_len);
mncc.cause.diag_len = sizeof(mncc.cause.diag);
}
memcpy(mncc.cause.diag, ttcn_buffer.get_data(), ttcn_buffer.get_len());
mncc.fields |= MNCC_F_CAUSE;
}
if (in_sig.progress().is_value()) {
const MNCC__progress &progress = in_sig.progress();
mncc.progress.coding = progress.coding();
mncc.progress.location = progress.location();
mncc.progress.descr = progress.descr();
mncc.fields |= MNCC_F_PROGRESS;
}
if (in_sig.useruser().is_value()) {
const MNCC__useruser &useruser = in_sig.useruser();
mncc.useruser.proto = useruser.proto();
strncpy(mncc.useruser.info, useruser.info(), sizeof(mncc.useruser.info));
mncc.fields |= MNCC_F_USERUSER;
}
if (in_sig.facility().is_value()) {
const CHARSTRING &fac = in_sig.facility();
strncpy(mncc.facility.info, fac, sizeof(mncc.facility.info));
mncc.facility.len = strlen(mncc.facility.info);
mncc.fields |= MNCC_F_FACILITY;
}
if (in_sig.cccap().is_value()) {
const MNCC__cccap &cccap = in_sig.cccap();
mncc.cccap.dtmf = cccap.dtmf();
mncc.cccap.pcp = cccap.pcp();
mncc.fields |= MNCC_F_CCCAP;
}
if (in_sig.ssversion().is_value()) {
const CHARSTRING &ssv = in_sig.ssversion();
strncpy(mncc.ssversion.info, ssv, sizeof(mncc.ssversion.info));
mncc.ssversion.len = strlen(mncc.ssversion.info);
mncc.fields |= MNCC_F_SSVERSION;
}
mncc.clir.sup = in_sig.clir__sup();
mncc.clir.inv = in_sig.clir__inv();
if (in_sig.signal().is_value()) {
const INTEGER &sig = in_sig.signal();
mncc.signal = sig;
mncc.fields |= MNCC_F_SIGNAL;
}
if (in_sig.keypad().is_value()) {
const CHARSTRING &kpd = in_sig.keypad();
mncc.signal = (int) kpd[0].get_char();
mncc.fields |= MNCC_F_KEYPAD;
}
mncc.more = in_sig.more();
mncc.notify = in_sig.notify();
if (in_sig.emergency().is_value()) {
const INTEGER &emerg = in_sig.emergency();
mncc.emergency = emerg;
mncc.fields |= MNCC_F_EMERGENCY;
}
strncpy(mncc.imsi, in_sig.imsi(), sizeof(mncc.imsi));
mncc.lchan_type = in_sig.lchan__type();
mncc.lchan_mode = in_sig.lchan__mode();
ret_val = OCTETSTRING(sizeof(mncc), (uint8_t *)&mncc);
}
break;
case MNCC__MsgUnion::ALT_data:
struct gsm_data_frame data;
memset(&data, 0, sizeof(data));
data.msg_type = in.msg__type();
ret_val = OCTETSTRING(sizeof(data), (uint8_t *)&data);
ret_val = ret_val & in.u().data().data();
break;
case MNCC__MsgUnion::ALT_rtp:
struct gsm_mncc_rtp rtp;
memset(&rtp, 0, sizeof(rtp));
rtp.msg_type = in.msg__type();
rtp.callref = in.u().rtp().callref();
rtp.ip = in.u().rtp().ip();
rtp.port = in.u().rtp().rtp__port();
rtp.payload_type = in.u().rtp().payload__type();
rtp.payload_msg_type = in.u().rtp().payload__msg__type();
ret_val = OCTETSTRING(sizeof(rtp), (uint8_t *) &rtp);
break;
case MNCC__MsgUnion::ALT_hello:
struct gsm_mncc_hello hello;
memset(&hello, 0, sizeof(hello));
hello.msg_type = in.msg__type();
hello.version = in.u().hello().version();
hello.mncc_size = in.u().hello().mncc__size();
hello.data_frame_size = in.u().hello().data__frame__size();
hello.called_offset = in.u().hello().called__offset();
hello.signal_offset = in.u().hello().signal__offset();
hello.emergency_offset = in.u().hello().emergency__offset();
hello.lchan_type_offset = in.u().hello().lchan__type__offset();
ret_val = OCTETSTRING(sizeof(hello), (uint8_t *) &hello);
break;
}
return ret_val;
}
MNCC__PDU dec__MNCC__PDU(const OCTETSTRING& in)
{
TTCN_Buffer ttcn_buffer(in);
const struct gsm_mncc *in_mncc;
MNCC__PDU__Signal sign;
const struct gsm_mncc_hello *in_hello;
MNCC__PDU__Hello hello;
const struct gsm_data_frame *in_data;
MNCC__PDU__Data data;
const struct gsm_mncc_rtp *in_rtp;
MNCC__PDU__Rtp rtp;
MNCC__MsgUnion u;
in_mncc = (struct gsm_mncc *) ttcn_buffer.get_read_data();
sign.set_implicit_omit();
hello.set_implicit_omit();
data.set_implicit_omit();
rtp.set_implicit_omit();
switch (in_mncc->msg_type) {
case MNCC_SOCKET_HELLO:
in_hello = (const struct gsm_mncc_hello *) in_mncc;
hello = MNCC__PDU__Hello(in_hello->version,
in_hello->mncc_size,
in_hello->data_frame_size,
in_hello->called_offset,
in_hello->signal_offset,
in_hello->emergency_offset,
in_hello->lchan_type_offset);
u.hello() = hello;
break;
case GSM_TCHF_FRAME:
case GSM_TCHF_FRAME_EFR:
case GSM_TCHH_FRAME:
case GSM_TCH_FRAME_AMR:
case GSM_BAD_FRAME:
in_data = (const struct gsm_data_frame *) in_mncc;
u.data() = MNCC__PDU__Data(in_data->callref,
substr(in, offsetof(struct gsm_data_frame, data),
in.lengthof() - offsetof(struct gsm_data_frame, data)));
break;
case MNCC_RTP_CREATE:
case MNCC_RTP_CONNECT:
case MNCC_RTP_FREE:
in_rtp = (const struct gsm_mncc_rtp *) in_mncc;
rtp = MNCC__PDU__Rtp(in_rtp->callref, in_rtp->ip, in_rtp->port, in_rtp->payload_type,
in_rtp->payload_msg_type);
u.rtp() = rtp;
break;
default:
sign.callref() = in_mncc->callref;
if (in_mncc->fields & MNCC_F_BEARER_CAP) {
sign.bearer__cap() = dec_bcap(&in_mncc->bearer_cap);
}
if (in_mncc->fields & MNCC_F_CALLED)
sign.called() = dec_number(&in_mncc->called);
if (in_mncc->fields & MNCC_F_CALLING)
sign.calling() = dec_number(&in_mncc->calling);
if (in_mncc->fields & MNCC_F_REDIRECTING)
sign.redirecting() = dec_number(&in_mncc->redirecting);
if (in_mncc->fields & MNCC_F_CONNECTED)
sign.connected() = dec_number(&in_mncc->connected);
if (in_mncc->fields & MNCC_F_CAUSE) {
sign.cause() = MNCC__cause(in_mncc->cause.location,
in_mncc->cause.coding,
in_mncc->cause.rec,
in_mncc->cause.rec_val,
in_mncc->cause.value,
OCTETSTRING(in_mncc->cause.diag_len,
(const uint8_t *)in_mncc->cause.diag));
}
if (in_mncc->fields & MNCC_F_USERUSER) {
sign.useruser() = MNCC__useruser(in_mncc->useruser.proto,
CHARSTRING(in_mncc->useruser.info));
}
if (in_mncc->fields & MNCC_F_PROGRESS) {
sign.progress() = MNCC__progress(in_mncc->progress.coding,
in_mncc->progress.location,
in_mncc->progress.descr);
}
if (in_mncc->fields & MNCC_F_EMERGENCY)
sign.emergency() = in_mncc->emergency;
if (in_mncc->fields & MNCC_F_FACILITY)
sign.facility() = CHARSTRING(in_mncc->facility.info);
if (in_mncc->fields & MNCC_F_SSVERSION)
sign.ssversion() = CHARSTRING(in_mncc->ssversion.info);
if (in_mncc->fields & MNCC_F_CCCAP)
sign.cccap() = MNCC__cccap(in_mncc->cccap.dtmf, in_mncc->cccap.pcp);
if (in_mncc->fields & MNCC_F_KEYPAD) {
char kpd[2] = { (char) in_mncc->keypad, 0 };
sign.keypad() = CHARSTRING(kpd);
}
if (in_mncc->fields & MNCC_F_SIGNAL)
sign.signal() = in_mncc->signal;
sign.clir__sup() = in_mncc->clir.sup;
sign.clir__inv() = in_mncc->clir.inv;
sign.more() = in_mncc->more;
sign.notify() = in_mncc->notify;
sign.imsi() = CHARSTRING(in_mncc->imsi);
sign.lchan__type() = in_mncc->lchan_type;
sign.lchan__mode() = in_mncc->lchan_mode;
u.signal() = sign;
break;
}
return MNCC__PDU(in_mncc->msg_type, u);
}
}

33991
titan/MNCC_Types.cc Normal file

File diff suppressed because it is too large Load Diff

4049
titan/MNCC_Types.hh Normal file

File diff suppressed because it is too large Load Diff

19
titan/Makefile Normal file
View File

@ -0,0 +1,19 @@
OBJS=General_Types.o Osmocom_Types.o hello.o
OBJS+=MNCC_Types.o MNCC_EncDec.o
OBJS+=PCUIF_Types.o
CXXFLAGS=-DLINUX -DMAKEDEPEND_RUN -I/usr/include/titan -fPIC
LDFLAGS=-L/usr/lib/titan -fPIC -lttcn3-dynamic
LDFLAGS_STATIC=-L/usr/lib/titan -lttcn3 -lxml2 -lssl -lcrypto
all: titan.a
titan.a: $(OBJS)
$(AR) r $@ $^
%.o: %.cc
$(CXX) $(CXXFLAGS) -c -o $@ $^
clean:
@rm titan.a $(OBJS)

2348
titan/Osmocom_Types.cc Normal file

File diff suppressed because it is too large Load Diff

389
titan/Osmocom_Types.hh Normal file
View File

@ -0,0 +1,389 @@
// This C++ header file was generated by the TTCN-3 compiler
// of the TTCN-3 Test Executor version CRL 113 200/6 R3B
// for Harald Welte (laforge@nataraja) on Mon Mar 26 16:56:01 2018
// Copyright (c) 2000-2017 Ericsson Telecom AB
// Do not edit this file unless you know what you are doing.
#ifndef Osmocom__Types_HH
#define Osmocom__Types_HH
#ifdef TITAN_RUNTIME_2
#error Generated code does not match with used runtime.\
Code was generated without -R option but -DTITAN_RUNTIME_2 was used.
#endif
/* Header file includes */
#include <TTCN3.hh>
#include "General_Types.hh"
#if TTCN3_VERSION != 60301
#error Version mismatch detected.\
Please check the version of the TTCN-3 compiler and the base library.\
Run make clean and rebuild the project if the version of the compiler changed recently.
#endif
#ifndef LINUX
#error This file should be compiled on LINUX
#endif
#undef Osmocom__Types_HH
#endif
namespace Osmocom__Types {
/* Forward declarations of classes */
class Arfcn;
class Arfcn_template;
typedef PreGenRecordOf::PREGEN__RECORD__OF__INTEGER IntegerRecord;
typedef PreGenRecordOf::PREGEN__RECORD__OF__INTEGER_template IntegerRecord_template;
} /* end of namespace */
#ifndef Osmocom__Types_HH
#define Osmocom__Types_HH
namespace Osmocom__Types {
/* Type definitions */
typedef INTEGER uint8__t;
typedef INTEGER_template uint8__t_template;
typedef INTEGER uint16__t;
typedef INTEGER_template uint16__t_template;
typedef INTEGER uint24__t;
typedef INTEGER_template uint24__t_template;
typedef INTEGER uint32__t;
typedef INTEGER_template uint32__t_template;
typedef INTEGER int8__t;
typedef INTEGER_template int8__t_template;
typedef INTEGER int16__t;
typedef INTEGER_template int16__t_template;
typedef INTEGER uint1__t;
typedef INTEGER_template uint1__t_template;
typedef INTEGER uint2__t;
typedef INTEGER_template uint2__t_template;
typedef INTEGER uint3__t;
typedef INTEGER_template uint3__t_template;
typedef INTEGER uint4__t;
typedef INTEGER_template uint4__t_template;
typedef INTEGER uint5__t;
typedef INTEGER_template uint5__t_template;
typedef INTEGER uint6__t;
typedef INTEGER_template uint6__t_template;
typedef INTEGER uint7__t;
typedef INTEGER_template uint7__t_template;
typedef INTEGER uint9__t;
typedef INTEGER_template uint9__t_template;
typedef INTEGER uint10__t;
typedef INTEGER_template uint10__t_template;
typedef INTEGER uint11__t;
typedef INTEGER_template uint11__t_template;
typedef INTEGER uint12__t;
typedef INTEGER_template uint12__t_template;
typedef INTEGER uint13__t;
typedef INTEGER_template uint13__t_template;
typedef INTEGER uint14__t;
typedef INTEGER_template uint14__t_template;
typedef INTEGER uint15__t;
typedef INTEGER_template uint15__t_template;
/* Class definitions */
class Arfcn : public Base_Type {
BOOLEAN field_pcs;
INTEGER field_arfcn;
public:
Arfcn();
Arfcn(const BOOLEAN& par_pcs,
const INTEGER& par_arfcn);
Arfcn(const Arfcn& other_value);
inline boolean is_component() { return FALSE; }
void clean_up();
Arfcn& operator=(const Arfcn& other_value);
boolean operator==(const Arfcn& other_value) const;
inline boolean operator!=(const Arfcn& other_value) const
{ return !(*this == other_value); }
boolean is_bound() const;
inline boolean is_present() const { return is_bound(); }
boolean is_value() const;
inline BOOLEAN& pcs()
{return field_pcs;}
inline const BOOLEAN& pcs() const
{return field_pcs;}
inline INTEGER& arfcn()
{return field_arfcn;}
inline const INTEGER& arfcn() const
{return field_arfcn;}
inline int size_of() const
{return 2;}
void log() const;
void set_param(Module_Param& param);
void set_implicit_omit();
void encode_text(Text_Buf& text_buf) const;
void decode_text(Text_Buf& text_buf);
void encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, TTCN_EncDec::coding_t, ...) const;
void decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, TTCN_EncDec::coding_t, ...);
int RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree&) const;
int RAW_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, int, raw_order_t, boolean no_err=FALSE,int sel_field=-1, boolean first_call=TRUE);
};
class Arfcn_template : public Base_Template {
struct single_value_struct;
union {
single_value_struct *single_value;
struct {
unsigned int n_values;
Arfcn_template *list_value;
} value_list;
};
void set_specific();
void copy_value(const Arfcn& other_value);
void copy_template(const Arfcn_template& other_value);
public:
Arfcn_template();
Arfcn_template(template_sel other_value);
Arfcn_template(const Arfcn& other_value);
Arfcn_template(const OPTIONAL<Arfcn>& other_value);
Arfcn_template(const Arfcn_template& other_value);
~Arfcn_template();
Arfcn_template& operator=(template_sel other_value);
Arfcn_template& operator=(const Arfcn& other_value);
Arfcn_template& operator=(const OPTIONAL<Arfcn>& other_value);
Arfcn_template& operator=(const Arfcn_template& other_value);
boolean match(const Arfcn& other_value, boolean legacy = FALSE) const;
boolean is_bound() const;
boolean is_value() const;
void clean_up();
Arfcn valueof() const;
void set_type(template_sel template_type, unsigned int list_length);
Arfcn_template& list_item(unsigned int list_index) const;
BOOLEAN_template& pcs();
const BOOLEAN_template& pcs() const;
INTEGER_template& arfcn();
const INTEGER_template& arfcn() const;
int size_of() const;
void log() const;
void log_match(const Arfcn& match_value, boolean legacy = FALSE) const;
void encode_text(Text_Buf& text_buf) const;
void decode_text(Text_Buf& text_buf);
void set_param(Module_Param& param);
void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const;
boolean is_present(boolean legacy = FALSE) const;
boolean match_omit(boolean legacy = FALSE) const;
};
/* Function prototypes */
extern void uint8__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint8__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint16__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint16__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint24__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint24__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint32__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint32__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void int8__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER int8__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void int16__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER int16__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint1__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint1__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint2__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint2__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint3__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint3__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint4__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint4__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint5__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint5__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint6__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint6__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint7__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint7__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint9__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint9__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint10__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint10__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint11__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint11__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint12__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint12__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint13__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint13__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint14__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint14__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void uint15__t_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER uint15__t_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void Arfcn_pcs_encoder(const BOOLEAN& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER Arfcn_pcs_decoder(OCTETSTRING& input_stream, BOOLEAN& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void Arfcn_arfcn_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER Arfcn_arfcn_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void Arfcn_encoder(const Arfcn& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER Arfcn_decoder(OCTETSTRING& input_stream, Arfcn& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER f__rnd__int(const INTEGER& max);
extern HEXSTRING f__rnd__hexstring(const INTEGER& len, const INTEGER& max);
extern OCTETSTRING f__rnd__octstring(const INTEGER& len);
extern HEXSTRING f__rnd__imsi(const HEXSTRING& prefix);
extern OCTETSTRING f__rnd__msisdn(const OCTETSTRING& prefix, const INTEGER& len);
extern void f__sleep(const FLOAT& seconds);
extern BITSTRING bool2bit(const BOOLEAN& inp);
extern BITSTRING_template bool2bit__tmpl(const BOOLEAN_template& inp);
extern void IntegerRecord_0_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER IntegerRecord_0_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern void IntegerRecord_encoder(const IntegerRecord& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name);
extern INTEGER IntegerRecord_decoder(OCTETSTRING& input_stream, IntegerRecord& output_value, const UNIVERSAL_CHARSTRING& coding_name);
extern BOOLEAN int2bool(const INTEGER& int_);
extern BOOLEAN f__array__contains(const IntegerRecord& arr, const INTEGER& key);
extern void f__timer__safe__restart(TIMER& T);
extern INTEGER f__div__round__up(const INTEGER& dividend, const INTEGER& divisor);
/* Global variable declarations */
extern const TTCN_RAWdescriptor_t uint8__t_raw_;
extern const XERdescriptor_t uint8__t_xer_;
extern const TTCN_JSONdescriptor_t uint8__t_json_;
extern const TTCN_OERdescriptor_t uint8__t_oer_;
extern const TTCN_Typedescriptor_t uint8__t_descr_;
extern UNIVERSAL_CHARSTRING uint8__t_default_coding;
extern const TTCN_RAWdescriptor_t uint16__t_raw_;
extern const XERdescriptor_t uint16__t_xer_;
extern const TTCN_JSONdescriptor_t uint16__t_json_;
extern const TTCN_OERdescriptor_t uint16__t_oer_;
extern const TTCN_Typedescriptor_t uint16__t_descr_;
extern UNIVERSAL_CHARSTRING uint16__t_default_coding;
extern const TTCN_RAWdescriptor_t uint24__t_raw_;
extern const XERdescriptor_t uint24__t_xer_;
extern const TTCN_JSONdescriptor_t uint24__t_json_;
extern const TTCN_Typedescriptor_t uint24__t_descr_;
extern UNIVERSAL_CHARSTRING uint24__t_default_coding;
extern const TTCN_RAWdescriptor_t uint32__t_raw_;
extern const XERdescriptor_t uint32__t_xer_;
extern const TTCN_JSONdescriptor_t uint32__t_json_;
extern const TTCN_OERdescriptor_t uint32__t_oer_;
extern const TTCN_Typedescriptor_t uint32__t_descr_;
extern UNIVERSAL_CHARSTRING uint32__t_default_coding;
extern const TTCN_RAWdescriptor_t int8__t_raw_;
extern const XERdescriptor_t int8__t_xer_;
extern const TTCN_JSONdescriptor_t int8__t_json_;
extern const TTCN_Typedescriptor_t int8__t_descr_;
extern UNIVERSAL_CHARSTRING int8__t_default_coding;
extern const TTCN_RAWdescriptor_t int16__t_raw_;
extern const XERdescriptor_t int16__t_xer_;
extern const TTCN_JSONdescriptor_t int16__t_json_;
extern const TTCN_Typedescriptor_t int16__t_descr_;
extern UNIVERSAL_CHARSTRING int16__t_default_coding;
extern const TTCN_RAWdescriptor_t uint1__t_raw_;
extern const XERdescriptor_t uint1__t_xer_;
extern const TTCN_JSONdescriptor_t uint1__t_json_;
extern const TTCN_OERdescriptor_t uint1__t_oer_;
extern const TTCN_Typedescriptor_t uint1__t_descr_;
extern UNIVERSAL_CHARSTRING uint1__t_default_coding;
extern const TTCN_RAWdescriptor_t uint2__t_raw_;
extern const XERdescriptor_t uint2__t_xer_;
extern const TTCN_JSONdescriptor_t uint2__t_json_;
extern const TTCN_OERdescriptor_t uint2__t_oer_;
extern const TTCN_Typedescriptor_t uint2__t_descr_;
extern UNIVERSAL_CHARSTRING uint2__t_default_coding;
extern const TTCN_RAWdescriptor_t uint3__t_raw_;
extern const XERdescriptor_t uint3__t_xer_;
extern const TTCN_JSONdescriptor_t uint3__t_json_;
extern const TTCN_OERdescriptor_t uint3__t_oer_;
extern const TTCN_Typedescriptor_t uint3__t_descr_;
extern UNIVERSAL_CHARSTRING uint3__t_default_coding;
extern const TTCN_RAWdescriptor_t uint4__t_raw_;
extern const XERdescriptor_t uint4__t_xer_;
extern const TTCN_JSONdescriptor_t uint4__t_json_;
extern const TTCN_Typedescriptor_t uint4__t_descr_;
extern UNIVERSAL_CHARSTRING uint4__t_default_coding;
extern const TTCN_RAWdescriptor_t uint5__t_raw_;
extern const XERdescriptor_t uint5__t_xer_;
extern const TTCN_JSONdescriptor_t uint5__t_json_;
extern const TTCN_Typedescriptor_t uint5__t_descr_;
extern UNIVERSAL_CHARSTRING uint5__t_default_coding;
extern const TTCN_RAWdescriptor_t uint6__t_raw_;
extern const XERdescriptor_t uint6__t_xer_;
extern const TTCN_JSONdescriptor_t uint6__t_json_;
extern const TTCN_Typedescriptor_t uint6__t_descr_;
extern UNIVERSAL_CHARSTRING uint6__t_default_coding;
extern const TTCN_RAWdescriptor_t uint7__t_raw_;
extern const XERdescriptor_t uint7__t_xer_;
extern const TTCN_JSONdescriptor_t uint7__t_json_;
extern const TTCN_Typedescriptor_t uint7__t_descr_;
extern UNIVERSAL_CHARSTRING uint7__t_default_coding;
extern const TTCN_RAWdescriptor_t uint9__t_raw_;
extern const XERdescriptor_t uint9__t_xer_;
extern const TTCN_JSONdescriptor_t uint9__t_json_;
extern const TTCN_Typedescriptor_t uint9__t_descr_;
extern UNIVERSAL_CHARSTRING uint9__t_default_coding;
extern const TTCN_RAWdescriptor_t uint10__t_raw_;
extern const XERdescriptor_t uint10__t_xer_;
extern const TTCN_JSONdescriptor_t uint10__t_json_;
extern const TTCN_Typedescriptor_t uint10__t_descr_;
extern UNIVERSAL_CHARSTRING uint10__t_default_coding;
extern const TTCN_RAWdescriptor_t uint11__t_raw_;
extern const XERdescriptor_t uint11__t_xer_;
extern const TTCN_JSONdescriptor_t uint11__t_json_;
extern const TTCN_Typedescriptor_t uint11__t_descr_;
extern UNIVERSAL_CHARSTRING uint11__t_default_coding;
extern const TTCN_RAWdescriptor_t uint12__t_raw_;
extern const XERdescriptor_t uint12__t_xer_;
extern const TTCN_JSONdescriptor_t uint12__t_json_;
extern const TTCN_Typedescriptor_t uint12__t_descr_;
extern UNIVERSAL_CHARSTRING uint12__t_default_coding;
extern const TTCN_RAWdescriptor_t uint13__t_raw_;
extern const XERdescriptor_t uint13__t_xer_;
extern const TTCN_JSONdescriptor_t uint13__t_json_;
extern const TTCN_Typedescriptor_t uint13__t_descr_;
extern UNIVERSAL_CHARSTRING uint13__t_default_coding;
extern const TTCN_RAWdescriptor_t uint14__t_raw_;
extern const XERdescriptor_t uint14__t_xer_;
extern const TTCN_JSONdescriptor_t uint14__t_json_;
extern const TTCN_Typedescriptor_t uint14__t_descr_;
extern UNIVERSAL_CHARSTRING uint14__t_default_coding;
extern const TTCN_RAWdescriptor_t uint15__t_raw_;
extern const XERdescriptor_t uint15__t_xer_;
extern const TTCN_JSONdescriptor_t uint15__t_json_;
extern const TTCN_Typedescriptor_t uint15__t_descr_;
extern UNIVERSAL_CHARSTRING uint15__t_default_coding;
extern const INTEGER& c__UINT16__MAX;
extern const INTEGER& c__UINT32__MAX;
extern const TTCN_RAWdescriptor_t Arfcn_pcs_raw_;
extern const XERdescriptor_t Arfcn_pcs_xer_;
extern const TTCN_JSONdescriptor_t Arfcn_pcs_json_;
extern const TTCN_OERdescriptor_t Arfcn_pcs_oer_;
extern const TTCN_Typedescriptor_t Arfcn_pcs_descr_;
extern UNIVERSAL_CHARSTRING Arfcn_pcs_default_coding;
extern const TTCN_RAWdescriptor_t Arfcn_arfcn_raw_;
extern const XERdescriptor_t Arfcn_arfcn_xer_;
extern const TTCN_JSONdescriptor_t Arfcn_arfcn_json_;
extern const TTCN_OERdescriptor_t Arfcn_arfcn_oer_;
extern const TTCN_Typedescriptor_t Arfcn_arfcn_descr_;
extern UNIVERSAL_CHARSTRING Arfcn_arfcn_default_coding;
extern const TTCN_RAWdescriptor_t Arfcn_raw_;
extern const TTCN_Typedescriptor_t Arfcn_descr_;
extern UNIVERSAL_CHARSTRING Arfcn_default_coding;
extern const INTEGER& f__rnd__hexstring_max_defval;
extern const INTEGER& f__rnd__msisdn_len_defval;
extern const TTCN_RAWdescriptor_t IntegerRecord_raw_;
extern const TTCN_Typedescriptor_t IntegerRecord_descr_;
extern const TTCN_RAWdescriptor_t IntegerRecord_0_raw_;
extern const XERdescriptor_t IntegerRecord_0_xer_;
extern const TTCN_JSONdescriptor_t IntegerRecord_0_json_;
extern const TTCN_Typedescriptor_t IntegerRecord_0_descr_;
extern UNIVERSAL_CHARSTRING IntegerRecord_0_default_coding;
extern UNIVERSAL_CHARSTRING IntegerRecord_default_coding;
extern TTCN_Module module_object;
} /* end of namespace */
#endif

31065
titan/PCUIF_Types.cc Normal file

File diff suppressed because it is too large Load Diff

3579
titan/PCUIF_Types.hh Normal file

File diff suppressed because it is too large Load Diff

44
titan/hello.cc Normal file
View File

@ -0,0 +1,44 @@
#include <errno.h>
extern char *program_invocation_short_name;
#include <iostream>
#include "MNCC_Types.hh"
#include "PCUIF_Types.hh"
using namespace std;
extern "C" {
void pcu_dissector(int fd, bool is_out, const char *fn, const uint8_t *data, unsigned int len)
{
OCTETSTRING oct(len, data);
PCUIF__Types::PCUIF__Message pdu = PCUIF__Types::dec__PCUIF__Message(oct);
TTCN_Logger::begin_event(TTCN_ERROR);
TTCN_Logger::log_event("%s(%d) %s: ", fn, fd, is_out ? "Tx" : "Rx");
pdu.log();
TTCN_Logger::end_event();
}
void mncc_dissector(int fd, bool is_out, const char *fn, const uint8_t *data, unsigned int len)
{
OCTETSTRING oct(len, data);
MNCC__Types::MNCC__PDU pdu = MNCC__Types::dec__MNCC__PDU(oct);
TTCN_Logger::begin_event(TTCN_ERROR);
TTCN_Logger::log_event("%s(%d) %s: ", fn, fd, is_out ? "Tx" : "Rx");
pdu.log();
TTCN_Logger::end_event();
}
__attribute__ ((constructor)) static void init_mncc(void)
{
TTCN_Runtime::set_state(TTCN_Runtime::SINGLE_CONTROLPART);
//TTCN_Runtime::install_signal_handlers();
TTCN_Logger::initialize_logger();
TTCN_Logger::set_executable_name(program_invocation_short_name);
TTCN_Logger::set_start_time();
TTCN_Logger::open_file();
}
}

304
titan/mncc.h Normal file
View File

@ -0,0 +1,304 @@
/* This file contains sections copied from
* libosmocore/include/osmocom/gsm/protocol/gsm_04_08.h,
* libosmocore/include/osmocom/gsm/mncc.h and
* openbsc/include/openbsc/mncc.h
*/
#include <stdint.h>
/* GSM 04.08 Bearer Capability: Rate Adaption */
enum gsm48_bcap_ra {
GSM48_BCAP_RA_NONE = 0,
GSM48_BCAP_RA_V110_X30 = 1,
GSM48_BCAP_RA_X31 = 2,
GSM48_BCAP_RA_OTHER = 3,
};
/* GSM 04.08 Bearer Capability: Signalling access protocol */
enum gsm48_bcap_sig_access {
GSM48_BCAP_SA_I440_I450 = 1,
GSM48_BCAP_SA_X21 = 2,
GSM48_BCAP_SA_X28_DP_IN = 3,
GSM48_BCAP_SA_X28_DP_UN = 4,
GSM48_BCAP_SA_X28_NDP = 5,
GSM48_BCAP_SA_X32 = 6,
};
/* GSM 04.08 Bearer Capability: User Rate */
enum gsm48_bcap_user_rate {
GSM48_BCAP_UR_300 = 1,
GSM48_BCAP_UR_1200 = 2,
GSM48_BCAP_UR_2400 = 3,
GSM48_BCAP_UR_4800 = 4,
GSM48_BCAP_UR_9600 = 5,
GSM48_BCAP_UR_12000 = 6,
GSM48_BCAP_UR_1200_75 = 7,
};
/* GSM 04.08 Bearer Capability: Parity */
enum gsm48_bcap_parity {
GSM48_BCAP_PAR_ODD = 0,
GSM48_BCAP_PAR_EVEN = 2,
GSM48_BCAP_PAR_NONE = 3,
GSM48_BCAP_PAR_ZERO = 4,
GSM48_BCAP_PAR_ONE = 5,
};
/* GSM 04.08 Bearer Capability: Intermediate Rate */
enum gsm48_bcap_interm_rate {
GSM48_BCAP_IR_8k = 2,
GSM48_BCAP_IR_16k = 3,
};
/* GSM 04.08 Bearer Capability: Transparency */
enum gsm48_bcap_transp {
GSM48_BCAP_TR_TRANSP = 0,
GSM48_BCAP_TR_RLP = 1,
GSM48_BCAP_TR_TR_PREF = 2,
GSM48_BCAP_TR_RLP_PREF = 3,
};
/* GSM 04.08 Bearer Capability: Modem Type */
enum gsm48_bcap_modem_type {
GSM48_BCAP_MT_NONE = 0,
GSM48_BCAP_MT_V21 = 1,
GSM48_BCAP_MT_V22 = 2,
GSM48_BCAP_MT_V22bis = 3,
GSM48_BCAP_MT_V23 = 4,
GSM48_BCAP_MT_V26ter = 5,
GSM48_BCAP_MT_V32 = 6,
GSM48_BCAP_MT_UNDEF = 7,
GSM48_BCAP_MT_AUTO_1 = 8,
};
#define GSM_MAX_FACILITY 128
#define GSM_MAX_SSVERSION 128
#define GSM_MAX_USERUSER 128
/* Expanded fields from GSM TS 04.08, Table 10.5.102 */
struct gsm_mncc_bearer_cap {
int transfer; /* Information Transfer Capability */
int mode; /* Transfer Mode */
int coding; /* Coding Standard */
int radio; /* Radio Channel Requirement */
int speech_ctm; /* CTM text telephony indication */
int speech_ver[8]; /* Speech version indication */
struct {
enum gsm48_bcap_ra rate_adaption;
enum gsm48_bcap_sig_access sig_access;
int async;
int nr_stop_bits;
int nr_data_bits;
enum gsm48_bcap_user_rate user_rate;
enum gsm48_bcap_parity parity;
enum gsm48_bcap_interm_rate interm_rate;
enum gsm48_bcap_transp transp;
enum gsm48_bcap_modem_type modem_type;
} data;
};
struct gsm_mncc_number {
int type;
int plan;
int present;
int screen;
char number[33];
};
struct gsm_mncc_cause {
int location;
int coding;
int rec;
int rec_val;
int value;
int diag_len;
char diag[32];
};
struct gsm_mncc_useruser {
int proto;
char info[GSM_MAX_USERUSER + 1]; /* + termination char */
};
struct gsm_mncc_progress {
int coding;
int location;
int descr;
};
struct gsm_mncc_facility {
int len;
char info[GSM_MAX_FACILITY];
};
struct gsm_mncc_ssversion {
int len;
char info[GSM_MAX_SSVERSION];
};
struct gsm_mncc_cccap {
int dtmf;
int pcp;
};
enum {
GSM_MNCC_BCAP_SPEECH = 0,
GSM_MNCC_BCAP_UNR_DIG = 1,
GSM_MNCC_BCAP_AUDIO = 2,
GSM_MNCC_BCAP_FAX_G3 = 3,
GSM_MNCC_BCAP_OTHER_ITC = 5,
GSM_MNCC_BCAP_RESERVED = 7,
};
#define MNCC_SETUP_REQ 0x0101
#define MNCC_SETUP_IND 0x0102
#define MNCC_SETUP_RSP 0x0103
#define MNCC_SETUP_CNF 0x0104
#define MNCC_SETUP_COMPL_REQ 0x0105
#define MNCC_SETUP_COMPL_IND 0x0106
/* MNCC_REJ_* is perfomed via MNCC_REL_* */
#define MNCC_CALL_CONF_IND 0x0107
#define MNCC_CALL_PROC_REQ 0x0108
#define MNCC_PROGRESS_REQ 0x0109
#define MNCC_ALERT_REQ 0x010a
#define MNCC_ALERT_IND 0x010b
#define MNCC_NOTIFY_REQ 0x010c
#define MNCC_NOTIFY_IND 0x010d
#define MNCC_DISC_REQ 0x010e
#define MNCC_DISC_IND 0x010f
#define MNCC_REL_REQ 0x0110
#define MNCC_REL_IND 0x0111
#define MNCC_REL_CNF 0x0112
#define MNCC_FACILITY_REQ 0x0113
#define MNCC_FACILITY_IND 0x0114
#define MNCC_START_DTMF_IND 0x0115
#define MNCC_START_DTMF_RSP 0x0116
#define MNCC_START_DTMF_REJ 0x0117
#define MNCC_STOP_DTMF_IND 0x0118
#define MNCC_STOP_DTMF_RSP 0x0119
#define MNCC_MODIFY_REQ 0x011a
#define MNCC_MODIFY_IND 0x011b
#define MNCC_MODIFY_RSP 0x011c
#define MNCC_MODIFY_CNF 0x011d
#define MNCC_MODIFY_REJ 0x011e
#define MNCC_HOLD_IND 0x011f
#define MNCC_HOLD_CNF 0x0120
#define MNCC_HOLD_REJ 0x0121
#define MNCC_RETRIEVE_IND 0x0122
#define MNCC_RETRIEVE_CNF 0x0123
#define MNCC_RETRIEVE_REJ 0x0124
#define MNCC_USERINFO_REQ 0x0125
#define MNCC_USERINFO_IND 0x0126
#define MNCC_REJ_REQ 0x0127
#define MNCC_REJ_IND 0x0128
#define MNCC_BRIDGE 0x0200
#define MNCC_FRAME_RECV 0x0201
#define MNCC_FRAME_DROP 0x0202
#define MNCC_LCHAN_MODIFY 0x0203
#define MNCC_RTP_CREATE 0x0204
#define MNCC_RTP_CONNECT 0x0205
#define MNCC_RTP_FREE 0x0206
#define GSM_TCHF_FRAME 0x0300
#define GSM_TCHF_FRAME_EFR 0x0301
#define GSM_TCHH_FRAME 0x0302
#define GSM_TCH_FRAME_AMR 0x0303
#define GSM_BAD_FRAME 0x03ff
#define MNCC_SOCKET_HELLO 0x0400
#define GSM_MAX_FACILITY 128
#define GSM_MAX_SSVERSION 128
#define GSM_MAX_USERUSER 128
#define MNCC_F_BEARER_CAP 0x0001
#define MNCC_F_CALLED 0x0002
#define MNCC_F_CALLING 0x0004
#define MNCC_F_REDIRECTING 0x0008
#define MNCC_F_CONNECTED 0x0010
#define MNCC_F_CAUSE 0x0020
#define MNCC_F_USERUSER 0x0040
#define MNCC_F_PROGRESS 0x0080
#define MNCC_F_EMERGENCY 0x0100
#define MNCC_F_FACILITY 0x0200
#define MNCC_F_SSVERSION 0x0400
#define MNCC_F_CCCAP 0x0800
#define MNCC_F_KEYPAD 0x1000
#define MNCC_F_SIGNAL 0x2000
struct gsm_mncc {
/* context based information */
uint32_t msg_type;
uint32_t callref;
/* which fields are present */
uint32_t fields;
/* data derived informations (MNCC_F_ based) */
struct gsm_mncc_bearer_cap bearer_cap;
struct gsm_mncc_number called;
struct gsm_mncc_number calling;
struct gsm_mncc_number redirecting;
struct gsm_mncc_number connected;
struct gsm_mncc_cause cause;
struct gsm_mncc_progress progress;
struct gsm_mncc_useruser useruser;
struct gsm_mncc_facility facility;
struct gsm_mncc_cccap cccap;
struct gsm_mncc_ssversion ssversion;
struct {
int sup;
int inv;
} clir;
int signal;
/* data derived information, not MNCC_F based */
int keypad;
int more;
int notify; /* 0..127 */
int emergency;
char imsi[16];
unsigned char lchan_type;
unsigned char lchan_mode;
};
struct gsm_data_frame {
uint32_t msg_type;
uint32_t callref;
unsigned char data[0];
};
#define MNCC_SOCK_VERSION 5
struct gsm_mncc_hello {
uint32_t msg_type;
uint32_t version;
/* send the sizes of the structs */
uint32_t mncc_size;
uint32_t data_frame_size;
/* send some offsets */
uint32_t called_offset;
uint32_t signal_offset;
uint32_t emergency_offset;
uint32_t lchan_type_offset;
};
struct gsm_mncc_rtp {
uint32_t msg_type;
uint32_t callref;
uint32_t ip;
uint16_t port;
uint32_t payload_type;
uint32_t payload_msg_type;
};
struct gsm_mncc_bridge {
uint32_t msg_type;
uint32_t callref[2];
};

25
utils.c
View File

@ -9,6 +9,11 @@
#define MAX_UNIX_FDS 32
#ifdef ENABLE_TITAN
extern void mncc_dissector(int fd, bool is_out, const char *fn, const uint8_t *data, unsigned int len);
extern void pcu_dissector(int fd, bool is_out, const char *fn, const uint8_t *data, unsigned int len);
#endif
/***********************************************************************
* Utility functions
***********************************************************************/
@ -60,7 +65,13 @@ static struct sock_state unix_fds[MAX_UNIX_FDS];
__attribute__ ((constructor)) static void udtrace_init(void)
{
int i;
LOG("Unix Domain Socket Trace initialized\n");
LOG("Unix Domain Socket Trace initialized (TITAN support "
#ifdef ENABLE_TITAN
"enabled"
#else
"DISABLED"
#endif
")\n");
for (i = 0; i < ARRAY_SIZE(unix_fds); i++) {
unix_fds[i] = (struct sock_state) { -1, NULL, NULL };
}
@ -97,8 +108,16 @@ void udtrace_del_fd(int fd)
static void udtrace_resolve_dissector(struct sock_state *ss)
{
/* FIXME: actual useful dissectors resovled by path */
ss->dissector = &default_dissector;
/* actual useful dissectors resovled by path */
if (0) { }
#ifdef ENABLE_TITAN
else if (strstr(ss->path, "mncc"))
ss->dissector = mncc_dissector;
else if (strstr(ss->path, "pcu"))
ss->dissector = pcu_dissector;
#endif
else
ss->dissector = &default_dissector;
}
/* set the path of a given fd */