mirror of https://gerrit.osmocom.org/osmo-tetra
first version of the mods
This commit is contained in:
parent
cae3e84875
commit
080bd4d3b5
|
@ -9,7 +9,7 @@ all: conv_enc_test crc_test tetra-rx float_to_bits tunctl
|
||||||
libosmo-tetra-phy.a: phy/tetra_burst_sync.o phy/tetra_burst.o
|
libosmo-tetra-phy.a: phy/tetra_burst_sync.o phy/tetra_burst.o
|
||||||
$(AR) r $@ $^
|
$(AR) r $@ $^
|
||||||
|
|
||||||
libosmo-tetra-mac.a: lower_mac/tetra_conv_enc.o lower_mac/tch_reordering.o tetra_tdma.o lower_mac/tetra_scramb.o lower_mac/tetra_rm3014.o lower_mac/tetra_interleave.o lower_mac/crc_simple.o tetra_common.o lower_mac/viterbi.o lower_mac/viterbi_cch.o lower_mac/viterbi_tch.o lower_mac/tetra_lower_mac.o tetra_upper_mac.o tetra_mac_pdu.o tetra_llc_pdu.o tetra_llc.o tetra_mle_pdu.o tetra_mm_pdu.o tetra_cmce_pdu.o tetra_sndcp_pdu.o tetra_gsmtap.o tuntap.o
|
libosmo-tetra-mac.a: lower_mac/tetra_conv_enc.o lower_mac/tch_reordering.o tetra_tdma.o lower_mac/tetra_scramb.o lower_mac/tetra_rm3014.o lower_mac/tetra_interleave.o lower_mac/crc_simple.o tetra_common.o lower_mac/viterbi.o lower_mac/viterbi_cch.o lower_mac/viterbi_tch.o lower_mac/tetra_lower_mac.o tetra_upper_mac.o tetra_mac_pdu.o tetra_llc_pdu.o tetra_llc.o tetra_mle_pdu.o tetra_mm_pdu.o tetra_cmce_pdu.o tetra_sndcp_pdu.o tetra_gsmtap.o tuntap.o tetra_sds.o
|
||||||
$(AR) r $@ $^
|
$(AR) r $@ $^
|
||||||
|
|
||||||
float_to_bits: float_to_bits.o
|
float_to_bits: float_to_bits.o
|
||||||
|
|
|
@ -39,6 +39,13 @@
|
||||||
#include "tetra_upper_mac.h"
|
#include "tetra_upper_mac.h"
|
||||||
#include <lower_mac/viterbi.h>
|
#include <lower_mac/viterbi.h>
|
||||||
|
|
||||||
|
/*sq5bpf*/
|
||||||
|
#include<time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
struct tetra_blk_param {
|
struct tetra_blk_param {
|
||||||
const char *name;
|
const char *name;
|
||||||
uint16_t type345_bits;
|
uint16_t type345_bits;
|
||||||
|
@ -154,6 +161,7 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
||||||
struct tmv_unitdata_param *tup;
|
struct tmv_unitdata_param *tup;
|
||||||
|
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
unsigned char tmpstr[1380+6];
|
||||||
|
|
||||||
ttp = tmvsap_prim_alloc(PRIM_TMV_UNITDATA, PRIM_OP_INDICATION);
|
ttp = tmvsap_prim_alloc(PRIM_TMV_UNITDATA, PRIM_OP_INDICATION);
|
||||||
tup = &ttp->u.unitdata;
|
tup = &ttp->u.unitdata;
|
||||||
|
@ -206,7 +214,7 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
tup->crc_ok = 1;
|
tup->crc_ok = 1;
|
||||||
printf("%s %s type1: %s\n", tbp->name, time_str,
|
printf("%s %s type1: %s\n", tbp->name, time_str,
|
||||||
osmo_ubit_dump(type2, tbp->type1_bits));
|
osmo_ubit_dump(type2, tbp->type1_bits));
|
||||||
} else
|
} else
|
||||||
printf("WRONG\n");
|
printf("WRONG\n");
|
||||||
} else if (type == TPSAP_T_BBK) {
|
} else if (type == TPSAP_T_BBK) {
|
||||||
|
@ -216,7 +224,6 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
||||||
DEBUGP("%s %s type1: %s\n", tbp->name, time_str,
|
DEBUGP("%s %s type1: %s\n", tbp->name, time_str,
|
||||||
osmo_ubit_dump(type2, tbp->type1_bits));
|
osmo_ubit_dump(type2, tbp->type1_bits));
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->l1h = msgb_put(msg, tbp->type1_bits);
|
msg->l1h = msgb_put(msg, tbp->type1_bits);
|
||||||
memcpy(msg->l1h, type2, tbp->type1_bits);
|
memcpy(msg->l1h, type2, tbp->type1_bits);
|
||||||
|
|
||||||
|
@ -240,6 +247,12 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
||||||
/* update the PHY layer time */
|
/* update the PHY layer time */
|
||||||
memcpy(&t_phy_state.time, &tcd->time, sizeof(t_phy_state.time));
|
memcpy(&t_phy_state.time, &tcd->time, sizeof(t_phy_state.time));
|
||||||
tup->lchan = TETRA_LC_BSCH;
|
tup->lchan = TETRA_LC_BSCH;
|
||||||
|
/* send bursts for further processing --sq5bpf */
|
||||||
|
|
||||||
|
snprintf(tmpstr,sizeof(tmpstr)-1,"TETMON_begin FUNC:NETINFO1 CCODE:%2.2x MCC:%4.4x MNC:%4.4x DLF:%i ULF:%i RX:%i TETMON_end",tcd->colour_code,tcd->mcc,tcd->mnc,tetra_hack_dl_freq,tetra_hack_ul_freq,tetra_hack_rxid);
|
||||||
|
//sendto(tetra_hack_live_socket, (char *)&tmpstr, strlen(tmpstr), 0, (struct sockaddr *)&tetra_hack_live_sockaddr, tetra_hack_socklen);
|
||||||
|
sendto(tetra_hack_live_socket, (char *)&tmpstr, 128, 0, (struct sockaddr *)&tetra_hack_live_sockaddr, tetra_hack_socklen);
|
||||||
|
//printf("\nSQ5BPF MESSAGE [%s]\n",tmpstr);
|
||||||
break;
|
break;
|
||||||
case TPSAP_T_SB2:
|
case TPSAP_T_SB2:
|
||||||
case TPSAP_T_NDB:
|
case TPSAP_T_NDB:
|
||||||
|
@ -250,6 +263,39 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
||||||
break;
|
break;
|
||||||
case TPSAP_T_SCH_F:
|
case TPSAP_T_SCH_F:
|
||||||
tup->lchan = TETRA_LC_SCH_F;
|
tup->lchan = TETRA_LC_SCH_F;
|
||||||
|
|
||||||
|
/* send voice frames for further processing --sq5bpf */
|
||||||
|
if (tms->cur_burst.is_traffic)
|
||||||
|
{
|
||||||
|
int16_t block[690];
|
||||||
|
FILE *f;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
|
||||||
|
/* Generate a block */
|
||||||
|
memset(block, 0x00, sizeof(int16_t) * 690);
|
||||||
|
for (i=0; i<6; i++)
|
||||||
|
block[115*i] = 0x6b21 + i;
|
||||||
|
|
||||||
|
for (i=0; i<114; i++)
|
||||||
|
block[ 1+i] = type4[ i] ? -127 : 127;
|
||||||
|
|
||||||
|
for (i=0; i<114; i++)
|
||||||
|
block[116+i] = type4[114+i] ? -127 : 127;
|
||||||
|
|
||||||
|
for (i=0; i<114; i++)
|
||||||
|
block[231+i] = type4[228+i] ? -127 : 127;
|
||||||
|
|
||||||
|
for (i=0; i<90; i++)
|
||||||
|
block[346+i] = type4[342+i] ? -127 : 127;
|
||||||
|
|
||||||
|
sprintf(tmpstr,"TRA%2.2x\0",tms->cur_burst.is_traffic);
|
||||||
|
memcpy(tmpstr+6,block,sizeof(block));
|
||||||
|
|
||||||
|
sendto(tetra_hack_live_socket, (char *)&tmpstr, sizeof(block)+6, 0, (struct sockaddr *)&tetra_hack_live_sockaddr, tetra_hack_socklen);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* sq5bpf: koniec */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* FIXME: do something */
|
/* FIXME: do something */
|
||||||
|
|
|
@ -55,6 +55,7 @@ int tetra_burst_sync_in(struct tetra_rx_state *trs, uint8_t *bits, unsigned int
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned int train_seq_offs;
|
unsigned int train_seq_offs;
|
||||||
|
char tmpstr[1380];
|
||||||
|
|
||||||
DEBUGP("burst_sync_in: %u bits, state %u\n", len, trs->state);
|
DEBUGP("burst_sync_in: %u bits, state %u\n", len, trs->state);
|
||||||
|
|
||||||
|
@ -114,6 +115,12 @@ int tetra_burst_sync_in(struct tetra_rx_state *trs, uint8_t *bits, unsigned int
|
||||||
printf("\nBURST");
|
printf("\nBURST");
|
||||||
DEBUGP(": %s", osmo_ubit_dump(trs->bitbuf, TETRA_BITS_PER_TS));
|
DEBUGP(": %s", osmo_ubit_dump(trs->bitbuf, TETRA_BITS_PER_TS));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
/* log the burst frames. useful for scanning etc --sq5bpf */
|
||||||
|
sprintf(tmpstr,"TETMON_begin FUNC:BURST TETMON_end");
|
||||||
|
sendto(tetra_hack_live_socket, (char *)&tmpstr, 128, 0, (struct sockaddr *)&tetra_hack_live_sockaddr, tetra_hack_socklen);
|
||||||
|
|
||||||
|
|
||||||
rc = tetra_find_train_seq(trs->bitbuf, trs->bits_in_buf,
|
rc = tetra_find_train_seq(trs->bitbuf, trs->bits_in_buf,
|
||||||
(1 << TETRA_TRAIN_NORM_1)|
|
(1 << TETRA_TRAIN_NORM_1)|
|
||||||
(1 << TETRA_TRAIN_NORM_2)|
|
(1 << TETRA_TRAIN_NORM_2)|
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
#include <phy/tetra_burst_sync.h>
|
#include <phy/tetra_burst_sync.h>
|
||||||
#include "tetra_gsmtap.h"
|
#include "tetra_gsmtap.h"
|
||||||
|
|
||||||
|
/* sq5bpf */
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
void *tetra_tall_ctx;
|
void *tetra_tall_ctx;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -52,6 +58,26 @@ int main(int argc, char **argv)
|
||||||
perror("open");
|
perror("open");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
/* sq5bpf */
|
||||||
|
memset((void *)&tetra_hack_db,0,sizeof(tetra_hack_db));
|
||||||
|
tetra_hack_live_idx=0;
|
||||||
|
tetra_hack_live_lastseen=0;
|
||||||
|
tetra_hack_live_socket=0;
|
||||||
|
|
||||||
|
if (getenv("TETRA_HACK_PORT")) {
|
||||||
|
tetra_hack_rxid=atoi(getenv("TETRA_HACK_RXID"));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
tetra_hack_rxid=0;
|
||||||
|
}
|
||||||
|
if (getenv("TETRA_HACK_PORT")) {
|
||||||
|
tetra_hack_live_socket=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
tetra_hack_socklen=sizeof(struct sockaddr_in);
|
||||||
|
tetra_hack_live_sockaddr.sin_family = AF_INET;
|
||||||
|
tetra_hack_live_sockaddr.sin_port = htons(atoi(getenv("TETRA_HACK_PORT")));
|
||||||
|
inet_aton("127.0.0.1", & tetra_hack_live_sockaddr.sin_addr);
|
||||||
|
if (tetra_hack_live_socket<1) tetra_hack_live_socket=0;
|
||||||
|
}
|
||||||
|
|
||||||
tetra_gsmtap_init("localhost", 0);
|
tetra_gsmtap_init("localhost", 0);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
#include "tetra_mac_pdu.h"
|
#include "tetra_mac_pdu.h"
|
||||||
#include <osmocom/core/linuxlist.h>
|
#include <osmocom/core/linuxlist.h>
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DEBUGP(x, args...) printf(x, ## args)
|
#define DEBUGP(x, args...) printf(x, ## args)
|
||||||
#else
|
#else
|
||||||
|
@ -33,9 +38,39 @@ enum tetra_log_chan {
|
||||||
|
|
||||||
/* FIXME: QAM */
|
/* FIXME: QAM */
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t bits_to_uint(const uint8_t *bits, unsigned int len);
|
uint32_t bits_to_uint(const uint8_t *bits, unsigned int len);
|
||||||
|
|
||||||
|
|
||||||
|
/* tetra hack --sq5bpf */
|
||||||
|
#define HACK_MAX_TIME 5
|
||||||
|
#define HACK_LIVE_MAX_TIME 1
|
||||||
|
#define HACK_NUM_STRUCTS 256
|
||||||
|
struct tetra_hack_struct {
|
||||||
|
uint32_t ssi;
|
||||||
|
uint32_t ssi2;
|
||||||
|
time_t lastseen;
|
||||||
|
int is_encr;
|
||||||
|
char curfile[100];
|
||||||
|
char comment[100];
|
||||||
|
uint16_t callident;
|
||||||
|
int seen; //czy juz to widzielismy
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tetra_hack_struct tetra_hack_db[HACK_NUM_STRUCTS];
|
||||||
|
|
||||||
|
|
||||||
|
int tetra_hack_live_socket;
|
||||||
|
struct sockaddr_in tetra_hack_live_sockaddr;
|
||||||
|
int tetra_hack_socklen;
|
||||||
|
|
||||||
|
int tetra_hack_live_idx;
|
||||||
|
int tetra_hack_live_lastseen;
|
||||||
|
int tetra_hack_rxid;
|
||||||
|
|
||||||
|
uint32_t tetra_hack_dl_freq, tetra_hack_ul_freq;
|
||||||
|
|
||||||
|
/* end tetra hack --sq5bpf */
|
||||||
|
|
||||||
#include "tetra_tdma.h"
|
#include "tetra_tdma.h"
|
||||||
struct tetra_phy_state {
|
struct tetra_phy_state {
|
||||||
struct tetra_tdma_time time;
|
struct tetra_tdma_time time;
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
/* Tetra SDS functions --sq5bpf */
|
||||||
|
#include "tetra_sds.h"
|
||||||
|
|
||||||
|
const char oth_reserved[]="Other Reserved";
|
||||||
|
|
||||||
|
int decode_pdu(char *dec,unsigned char *enc,int len)
|
||||||
|
{
|
||||||
|
int outlen=0;
|
||||||
|
int bits=0;
|
||||||
|
unsigned char carry=0;
|
||||||
|
while(len) {
|
||||||
|
*dec=carry|(*enc<<(bits))&0x7f;
|
||||||
|
carry=*enc>>(7-bits);
|
||||||
|
bits++;
|
||||||
|
dec++;
|
||||||
|
outlen++;
|
||||||
|
enc++;
|
||||||
|
|
||||||
|
if (bits==7) {
|
||||||
|
*dec=carry;
|
||||||
|
dec++;
|
||||||
|
bits=0;
|
||||||
|
outlen++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*dec=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char *get_sds_type(uint8_t type) {
|
||||||
|
struct sds_type* a= (struct sds_type *)&sds_types;
|
||||||
|
while (a->description)
|
||||||
|
{
|
||||||
|
if (a->type==type) {
|
||||||
|
return(a->description);
|
||||||
|
|
||||||
|
}
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
return((char *)&oth_reserved);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/* tetra sds stuff --sq5bpf */
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_TETRA_SDS_H
|
||||||
|
#define HAVE_TETRA_SDS_H
|
||||||
|
|
||||||
|
/* Table 29.21: Protocol identifier information element contents */
|
||||||
|
enum tetra_sds_protoid {
|
||||||
|
TETRA_SDS_PROTO_RESERVED = 0x00,
|
||||||
|
TETRA_SDS_PROTO_OTAK = 0x01,
|
||||||
|
TETRA_SDS_PROTO_SIMPLE_TXTMSG = 0x02,
|
||||||
|
TETRA_SDS_PROTO_SIMPLE_LOC = 0x03,
|
||||||
|
TETRA_SDS_PROTO_WAP = 0x04,
|
||||||
|
TETRA_SDS_PROTO_WCMP = 0x05,
|
||||||
|
TETRA_SDS_PROTO_MDMO = 0x06,
|
||||||
|
TETRA_SDS_PROTO_PINAUTH = 0x07,
|
||||||
|
TETRA_SDS_PROTO_EEENCR = 0x08,
|
||||||
|
TETRA_SDS_PROTO_SIMPLE_ITXTMSG = 0x09,
|
||||||
|
TETRA_SDS_PROTO_LIP = 0x0a,
|
||||||
|
TETRA_SDS_PROTO_NAP = 0x0b,
|
||||||
|
TETRA_SDS_PROTO_CONCAT_SDS = 0x0c,
|
||||||
|
TETRA_SDS_PROTO_DOTAM = 0x0d,
|
||||||
|
TETRA_SDS_PROTO_TXTMSG = 0x82,
|
||||||
|
TETRA_SDS_PROTO_LOCSYSTEM = 0x83,
|
||||||
|
TETRA_SDS_PROTO_WAP2 = 0x84,
|
||||||
|
TETRA_SDS_PROTO_WCMP2 = 0x85,
|
||||||
|
TETRA_SDS_PROTO_MDMO2 = 0x86,
|
||||||
|
TETRA_SDS_PROTO_EEENCR2 = 0x88,
|
||||||
|
TETRA_SDS_PROTO_ITXTMSG = 0x89,
|
||||||
|
TETRA_SDS_PROTO_MSMUSERHEAD = 0x8a,
|
||||||
|
TETRA_SDS_PROTO_CONCAT_SDS2 = 0x8c
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct sds_type {
|
||||||
|
uint8_t type;
|
||||||
|
char * description;
|
||||||
|
};
|
||||||
|
static const struct sds_type sds_types[]=
|
||||||
|
{
|
||||||
|
{ TETRA_SDS_PROTO_RESERVED , "Reserved" },
|
||||||
|
{ TETRA_SDS_PROTO_OTAK , "OTAK" },
|
||||||
|
{ TETRA_SDS_PROTO_SIMPLE_TXTMSG , "Simple Text Messaging" },
|
||||||
|
{ TETRA_SDS_PROTO_SIMPLE_LOC , "Simple location system" },
|
||||||
|
{ TETRA_SDS_PROTO_WAP , "Wireless Datagram Protocol WAP" },
|
||||||
|
{ TETRA_SDS_PROTO_WCMP , "Wireless Control Message Protocol WCMP" },
|
||||||
|
{ TETRA_SDS_PROTO_MDMO , "M-DMO" },
|
||||||
|
{ TETRA_SDS_PROTO_PINAUTH , "PIN authentication" },
|
||||||
|
{ TETRA_SDS_PROTO_EEENCR , "End-to-end encrypted message" },
|
||||||
|
{ TETRA_SDS_PROTO_SIMPLE_ITXTMSG , "Simple immediate text messaging" },
|
||||||
|
{ TETRA_SDS_PROTO_LIP , "Location information protocol" },
|
||||||
|
{ TETRA_SDS_PROTO_NAP , "Net Assist Protocol (NAP)" },
|
||||||
|
{ TETRA_SDS_PROTO_CONCAT_SDS , "Concatenated SDS message" },
|
||||||
|
{ TETRA_SDS_PROTO_DOTAM , "DOTAM, refer to TS 100 392-18-3" },
|
||||||
|
{ TETRA_SDS_PROTO_TXTMSG , "Text Messaging" },
|
||||||
|
{ TETRA_SDS_PROTO_LOCSYSTEM , "Location system" },
|
||||||
|
{ TETRA_SDS_PROTO_WAP2 , "Wireless Datagram Protocol WAP" },
|
||||||
|
{ TETRA_SDS_PROTO_WCMP2 , "Wireless Control Message Protocol WCMP" },
|
||||||
|
{ TETRA_SDS_PROTO_MDMO2 , "M-DMO" },
|
||||||
|
{ TETRA_SDS_PROTO_EEENCR2 , "End-to-end encrypted message" },
|
||||||
|
{ TETRA_SDS_PROTO_ITXTMSG , "Immediate text messaging" },
|
||||||
|
{ TETRA_SDS_PROTO_MSMUSERHEAD , "Message with User Data Header" },
|
||||||
|
{ TETRA_SDS_PROTO_CONCAT_SDS2 , "Concatenated SDS message" },
|
||||||
|
{ 0x0,0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
char *get_sds_type(uint8_t type);
|
||||||
|
int decode_pdu(char *dec,unsigned char *enc,int len);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue