[gsm] Removed obsolete gsm.conf handling. Fixed minor compiling issues.
This commit is contained in:
parent
0eebd3a28e
commit
d5e639588d
|
@ -51,7 +51,7 @@ if ENABLE_GSM
|
|||
|
||||
GSM_INCLUDE +=
|
||||
|
||||
GSM_SOURCE += gsm_audio.c gsm.cpp gsm_conf.c
|
||||
GSM_SOURCE += gsm_audio.c gsm.cpp
|
||||
|
||||
GSM_LIB += /usr/lib/libgsm.a
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
# LCR GSM options
|
||||
#################
|
||||
|
||||
# interfaces-bsc and interface-lcr has been moved to options.conf!
|
||||
|
||||
# Enable debugging of OpenBSC library.
|
||||
# Refer to OpenBSC project for debugging options.
|
||||
# By default, debugging is turned off.
|
||||
#debug DRLL:DCC:DMM:DRR:DRSL:DNM:DSMS:DMNCC:DMNSMS:DPAG:DMUX:DMEAS
|
||||
|
||||
# Give openbsc.cnf config file
|
||||
# It will be located at /usr/local/lcr by default.
|
||||
#config openbsc.cfg
|
||||
|
||||
# Give database of Home Location Register (HLR)
|
||||
# HLR stores all subscribers. It will be used to grant access to the network.
|
||||
# It is an Sqlite3 database. Refer to OpenBSC project for handling.
|
||||
# The database is located at /usr/local/lcr by default.
|
||||
#hlr hlr.sqlite3
|
||||
|
||||
# To keep layer 2 connection to BS11 when quitting, use this option.
|
||||
# It is only usefull for developing. TRX will stay on.
|
||||
# Also changes in frequency, mcc, mnc, lac while keeping layer 2 will cause
|
||||
# malefunction of BSC.
|
||||
# Warning: Keeping layer 2 link may prevent emergency calls. (See below)
|
||||
#keep-l2
|
||||
|
||||
# Write BTS-Link traffic to PCAP file.
|
||||
#pcapfile pcap
|
||||
|
||||
|
|
@ -105,9 +105,8 @@
|
|||
#socketgroup asterisk
|
||||
|
||||
# Enable GSM network capability.
|
||||
# This option turns LCR into a GSM network. Additional options are specified
|
||||
# in 'gsm.conf'. You also need openbsc at compile time and of yourse -
|
||||
# a base station transceiver. For more refer to LCR home page.
|
||||
# This option turns LCR into a GSM network.
|
||||
# For more refer to LCR home page and the OpenBSC page.
|
||||
#
|
||||
# !!! DANGER !!!
|
||||
# Running a GSM network may disturb other networks and may be prossecuted by
|
||||
|
|
187
gsm.cpp
187
gsm.cpp
|
@ -24,6 +24,167 @@ struct lcr_gsm *gsm = NULL;
|
|||
|
||||
int new_callref = 1;
|
||||
|
||||
/* names of MNCC-SAP */
|
||||
static const struct _value_string {
|
||||
int msg_type;
|
||||
const char *name;
|
||||
} mncc_names[] = {
|
||||
#if defined(MNCC_SETUP_REQ)
|
||||
{ MNCC_SETUP_REQ, "MNCC_SETUP_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_SETUP_IND)
|
||||
{ MNCC_SETUP_IND, "MNCC_SETUP_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_SETUP_RSP)
|
||||
{ MNCC_SETUP_RSP, "MNCC_SETUP_RSP" },
|
||||
#endif
|
||||
#if defined(MNCC_SETUP_CNF)
|
||||
{ MNCC_SETUP_CNF, "MNCC_SETUP_CNF" },
|
||||
#endif
|
||||
#if defined(MNCC_SETUP_COMPL_REQ)
|
||||
{ MNCC_SETUP_COMPL_REQ, "MNCC_SETUP_COMPL_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_SETUP_COMPL_IND)
|
||||
{ MNCC_SETUP_COMPL_IND, "MNCC_SETUP_COMPL_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_CALL_CONF_IND)
|
||||
{ MNCC_CALL_CONF_IND, "MNCC_CALL_CONF_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_CALL_PROC_REQ)
|
||||
{ MNCC_CALL_PROC_REQ, "MNCC_CALL_PROC_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_PROGRESS_REQ)
|
||||
{ MNCC_PROGRESS_REQ, "MNCC_PROGRESS_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_ALERT_REQ)
|
||||
{ MNCC_ALERT_REQ, "MNCC_ALERT_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_ALERT_IND)
|
||||
{ MNCC_ALERT_IND, "MNCC_ALERT_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_NOTIFY_REQ)
|
||||
{ MNCC_NOTIFY_REQ, "MNCC_NOTIFY_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_NOTIFY_IND)
|
||||
{ MNCC_NOTIFY_IND, "MNCC_NOTIFY_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_DISC_REQ)
|
||||
{ MNCC_DISC_REQ, "MNCC_DISC_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_DISC_IND)
|
||||
{ MNCC_DISC_IND, "MNCC_DISC_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_REL_REQ)
|
||||
{ MNCC_REL_REQ, "MNCC_REL_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_REL_IND)
|
||||
{ MNCC_REL_IND, "MNCC_REL_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_REL_CNF)
|
||||
{ MNCC_REL_CNF, "MNCC_REL_CNF" },
|
||||
#endif
|
||||
#if defined(MNCC_FACILITY_REQ)
|
||||
{ MNCC_FACILITY_REQ, "MNCC_FACILITY_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_FACILITY_IND)
|
||||
{ MNCC_FACILITY_IND, "MNCC_FACILITY_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_START_DTMF_IND)
|
||||
{ MNCC_START_DTMF_IND, "MNCC_START_DTMF_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_START_DTMF_RSP)
|
||||
{ MNCC_START_DTMF_RSP, "MNCC_START_DTMF_RSP" },
|
||||
#endif
|
||||
#if defined(MNCC_START_DTMF_REJ)
|
||||
{ MNCC_START_DTMF_REJ, "MNCC_START_DTMF_REJ" },
|
||||
#endif
|
||||
#if defined(MNCC_STOP_DTMF_IND)
|
||||
{ MNCC_STOP_DTMF_IND, "MNCC_STOP_DTMF_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_STOP_DTMF_RSP)
|
||||
{ MNCC_STOP_DTMF_RSP, "MNCC_STOP_DTMF_RSP" },
|
||||
#endif
|
||||
#if defined(MNCC_MODIFY_REQ)
|
||||
{ MNCC_MODIFY_REQ, "MNCC_MODIFY_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_MODIFY_IND)
|
||||
{ MNCC_MODIFY_IND, "MNCC_MODIFY_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_MODIFY_RSP)
|
||||
{ MNCC_MODIFY_RSP, "MNCC_MODIFY_RSP" },
|
||||
#endif
|
||||
#if defined(MNCC_MODIFY_CNF)
|
||||
{ MNCC_MODIFY_CNF, "MNCC_MODIFY_CNF" },
|
||||
#endif
|
||||
#if defined(MNCC_MODIFY_REJ)
|
||||
{ MNCC_MODIFY_REJ, "MNCC_MODIFY_REJ" },
|
||||
#endif
|
||||
#if defined(MNCC_HOLD_IND)
|
||||
{ MNCC_HOLD_IND, "MNCC_HOLD_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_HOLD_CNF)
|
||||
{ MNCC_HOLD_CNF, "MNCC_HOLD_CNF" },
|
||||
#endif
|
||||
#if defined(MNCC_HOLD_REJ)
|
||||
{ MNCC_HOLD_REJ, "MNCC_HOLD_REJ" },
|
||||
#endif
|
||||
#if defined(MNCC_RETRIEVE_IND)
|
||||
{ MNCC_RETRIEVE_IND, "MNCC_RETRIEVE_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_RETRIEVE_CNF)
|
||||
{ MNCC_RETRIEVE_CNF, "MNCC_RETRIEVE_CNF" },
|
||||
#endif
|
||||
#if defined(MNCC_RETRIEVE_REJ)
|
||||
{ MNCC_RETRIEVE_REJ, "MNCC_RETRIEVE_REJ" },
|
||||
#endif
|
||||
#if defined(MNCC_USERINFO_REQ)
|
||||
{ MNCC_USERINFO_REQ, "MNCC_USERINFO_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_USERINFO_IND)
|
||||
{ MNCC_USERINFO_IND, "MNCC_USERINFO_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_REJ_REQ)
|
||||
{ MNCC_REJ_REQ, "MNCC_REJ_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_REJ_IND)
|
||||
{ MNCC_REJ_IND, "MNCC_REJ_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_PROGRESS_IND)
|
||||
{ MNCC_PROGRESS_IND, "MNCC_PROGRESS_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_CALL_PROC_IND)
|
||||
{ MNCC_CALL_PROC_IND, "MNCC_CALL_PROC_IND" },
|
||||
#endif
|
||||
#if defined(MNCC_CALL_CONF_REQ)
|
||||
{ MNCC_CALL_CONF_REQ, "MNCC_CALL_CONF_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_START_DTMF_REQ)
|
||||
{ MNCC_START_DTMF_REQ, "MNCC_START_DTMF_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_STOP_DTMF_REQ)
|
||||
{ MNCC_STOP_DTMF_REQ, "MNCC_STOP_DTMF_REQ" },
|
||||
#endif
|
||||
#if defined(MNCC_HOLD_REQ)
|
||||
{ MNCC_HOLD_REQ, "MNCC_HOLD_REQ " },
|
||||
#endif
|
||||
#if defined(MNCC_RETRIEVE_REQ)
|
||||
{ MNCC_RETRIEVE_REQ, "MNCC_RETRIEVE_REQ" },
|
||||
#endif
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const char *mncc_name(int value)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (mncc_names[i].name) {
|
||||
if (mncc_names[i].msg_type == value)
|
||||
return mncc_names[i].name;
|
||||
i++;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/*
|
||||
* create and send mncc message
|
||||
*/
|
||||
|
@ -145,7 +306,7 @@ int Pgsm::bchannel_open(int index)
|
|||
|
||||
/* bind socket to bchannel */
|
||||
addr.family = AF_ISDN;
|
||||
addr.dev = gsm->gsm_port;
|
||||
addr.dev = mISDNloop.port;
|
||||
addr.channel = index+1+(index>15);
|
||||
ret = bind(p_m_g_gsm_b_sock, (struct sockaddr *)&addr, sizeof(addr));
|
||||
if (ret < 0) {
|
||||
|
@ -257,13 +418,13 @@ void Pgsm::frame_receive(void *arg)
|
|||
|
||||
/*
|
||||
* create trace
|
||||
**/
|
||||
*/
|
||||
void gsm_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned int msg_type, int direction)
|
||||
{
|
||||
char msgtext[64];
|
||||
|
||||
/* select message and primitive text */
|
||||
SCPY(msgtext, "gsmnet");
|
||||
SCPY(msgtext, mncc_name(msg_type));
|
||||
|
||||
/* add direction */
|
||||
if (port) {
|
||||
|
@ -837,31 +998,11 @@ int gsm_exit(int rc)
|
|||
|
||||
int gsm_init(void)
|
||||
{
|
||||
char conf_error[256] = "";
|
||||
|
||||
/* seed the PRNG */
|
||||
srand(time(NULL));
|
||||
|
||||
/* create gsm instance */
|
||||
gsm = (struct lcr_gsm *)MALLOC(sizeof(struct lcr_gsm));
|
||||
gsm->gsm_sock = -1;
|
||||
|
||||
/* parse options */
|
||||
if (!gsm_conf(&gsm->conf, conf_error)) {
|
||||
PERROR("%s", conf_error);
|
||||
#ifdef WITH_GSM_BS
|
||||
gsm_bs_exit(-EINVAL);
|
||||
#endif
|
||||
#ifdef WITH_GSM_MS
|
||||
gsm_ms_exit(-EINVAL);
|
||||
#endif
|
||||
return gsm_exit(-EINVAL);
|
||||
}
|
||||
|
||||
/* open gsm loop interface */
|
||||
if (loopback_open()) {
|
||||
return gsm_exit(-1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
15
gsm.h
15
gsm.h
|
@ -3,18 +3,6 @@
|
|||
|
||||
extern int new_callref;
|
||||
|
||||
struct gsm_conf {
|
||||
char debug[128]; /* debug info */
|
||||
char openbsc_cfg[128]; /* openbsc config file */
|
||||
char short_name[64]; /* short network name */
|
||||
char long_name[64]; /* long network name */
|
||||
char hlr[64]; /* database name */
|
||||
int allow_all; /* accept unknown subscribers */
|
||||
int keep_l2; /* keep layer 2 after exit */
|
||||
char pcapfile[128]; /* open capture file for BS11 links */
|
||||
int reject_cause; /* reject cause for unsubcribed IMSIs */
|
||||
};
|
||||
|
||||
struct mncc_q_entry {
|
||||
struct mncc_q_entry *next;
|
||||
unsigned int len;
|
||||
|
@ -23,9 +11,6 @@ struct mncc_q_entry {
|
|||
|
||||
struct lcr_gsm {
|
||||
void *network; /* OpenBSC network handle */
|
||||
struct gsm_conf conf; /* gsm.conf options */
|
||||
int gsm_sock; /* loopback interface GSM side */
|
||||
int gsm_port; /* loopback interface port number */
|
||||
|
||||
struct lcr_fd mncc_lfd; /* Unix domain socket to OpenBSC MNCC */
|
||||
struct mncc_q_entry *mncc_q_hd;
|
||||
|
|
|
@ -932,7 +932,7 @@ static int mncc_fd_write(struct lcr_fd *lfd, void *inst, int idx)
|
|||
return mncc_fd_close(lfd);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
if (rc < qe->len)
|
||||
if (rc < (int)qe->len)
|
||||
return -1;
|
||||
/* dequeue the successfully sent message */
|
||||
qe2 = mncc_q_dequeue();
|
||||
|
|
152
gsm_conf.c
152
gsm_conf.c
|
@ -1,152 +0,0 @@
|
|||
/*****************************************************************************\
|
||||
** **
|
||||
** PBX4Linux **
|
||||
** **
|
||||
**---------------------------------------------------------------------------**
|
||||
** Copyright: Andreas Eversberg **
|
||||
** **
|
||||
** reading options.conf and filling structure **
|
||||
** **
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
/* read options
|
||||
*
|
||||
* read options from options.conf
|
||||
*/
|
||||
int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error)
|
||||
{
|
||||
FILE *fp=NULL;
|
||||
char filename[128];
|
||||
char *p;
|
||||
char option[32];
|
||||
char params[11][256];
|
||||
int pnum;
|
||||
unsigned int line,i;
|
||||
char buffer[256];
|
||||
|
||||
/* set defaults */
|
||||
SCPY(gsm_conf->debug, "");
|
||||
SCPY(gsm_conf->hlr, "hlr.sqlite3");
|
||||
SCPY(gsm_conf->openbsc_cfg, "openbsc.cfg");
|
||||
gsm_conf->reject_cause = 0;
|
||||
gsm_conf->keep_l2 = 0;
|
||||
|
||||
SPRINT(filename, "%s/gsm.conf", CONFIG_DATA);
|
||||
|
||||
if (!(fp=fopen(filename,"r"))) {
|
||||
UPRINT(conf_error, "Cannot open %s\n",filename);
|
||||
return(0);
|
||||
}
|
||||
|
||||
line=0;
|
||||
while((GETLINE(buffer, fp))) {
|
||||
line++;
|
||||
p=buffer;
|
||||
|
||||
while(*p <= 32) { /* skip spaces */
|
||||
if (*p == 0)
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
if (*p==0 || *p=='#') /* ignore comments and empty line */
|
||||
continue;
|
||||
|
||||
option[0]=0;
|
||||
i=0; /* read option */
|
||||
while(*p > 32) {
|
||||
if (i+1 >= sizeof(option)) {
|
||||
UPRINT(conf_error, "Error in %s (line %d): option too long.\n",filename,line);
|
||||
goto error;
|
||||
}
|
||||
option[i+1] = '\0';
|
||||
option[i++] = *p++;
|
||||
}
|
||||
|
||||
while(*p <= 32) { /* skip spaces */
|
||||
if (*p == 0)
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
|
||||
params[0][0] = 0;
|
||||
pnum = 0;
|
||||
while(*p!=0 && *p!='#' && pnum < 10) { /* param */
|
||||
i=0; /* read param */
|
||||
while(*p > 32) {
|
||||
if (i+1 >= sizeof(params[pnum])) {
|
||||
UPRINT(conf_error, "Error in %s (line %d): param too long.\n",filename,line);
|
||||
goto error;
|
||||
}
|
||||
params[pnum][i+1] = '\0';
|
||||
params[pnum][i++] = *p++;
|
||||
}
|
||||
while(*p <= 32) { /* skip spaces */
|
||||
if (*p == 0)
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
pnum++;
|
||||
params[pnum][0] = 0;
|
||||
}
|
||||
|
||||
/* at this point we have option and param */
|
||||
|
||||
/* check option */
|
||||
if (!strcmp(option,"debug")) {
|
||||
if (params[0][0]==0) {
|
||||
UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
|
||||
goto error;
|
||||
}
|
||||
SCPY(gsm_conf->debug, params[0]);
|
||||
|
||||
} else
|
||||
if (!strcmp(option,"config")) {
|
||||
if (params[0][0]==0) {
|
||||
UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
|
||||
goto error;
|
||||
}
|
||||
SCPY(gsm_conf->openbsc_cfg, params[0]);
|
||||
|
||||
} else
|
||||
if (!strcmp(option,"hlr")) {
|
||||
if (params[0][0]==0) {
|
||||
UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
|
||||
goto error;
|
||||
}
|
||||
SCPY(gsm_conf->hlr, params[0]);
|
||||
|
||||
} else
|
||||
if (!strcmp(option,"reject-cause")) {
|
||||
UPRINT(conf_error, "Option '%s' in gsm.conf has moved to openbsc.cfg", option);
|
||||
goto error;
|
||||
} else
|
||||
if (!strcmp(option,"allow-all")) {
|
||||
gsm_conf->allow_all = 1;
|
||||
} else
|
||||
if (!strcmp(option,"keep-l2")) {
|
||||
gsm_conf->keep_l2 = 1;
|
||||
|
||||
} else
|
||||
if (!strcmp(option,"pcapfile")) {
|
||||
if (params[0][0]==0) {
|
||||
UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
|
||||
goto error;
|
||||
}
|
||||
SCPY(gsm_conf->pcapfile, params[0]);
|
||||
} else {
|
||||
UPRINT(conf_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (fp) fclose(fp);
|
||||
return(1);
|
||||
error:
|
||||
if (fp) fclose(fp);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
@ -325,11 +325,9 @@ static int inter_portname(struct interface *interface, char *filename, int line,
|
|||
ifport = ifport->next;
|
||||
}
|
||||
|
||||
/* check for port already assigned, but not for shared gsm interface */
|
||||
/* check for port already assigned, but not for shared loop interface */
|
||||
searchif = interface_newlist;
|
||||
#if defined WITH_GSM_BS || defined WITH_GSM_MS
|
||||
if (options.gsm && !strcmp(value, gsm->conf.interface_lcr))
|
||||
#endif
|
||||
if (!!strcmp(value, options.loopback_lcr))
|
||||
{
|
||||
while(searchif) {
|
||||
ifport = searchif->ifport;
|
||||
|
|
|
@ -699,7 +699,6 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin)
|
|||
if (msg->param.bchannel.type == BCHANNEL_ASSIGN_ACK
|
||||
|| msg->param.bchannel.type == BCHANNEL_REMOVE_ACK
|
||||
|| msg->param.bchannel.type == BCHANNEL_RELEASE) {
|
||||
#warning TODO: depending on the mode (join / remoteport) forward message
|
||||
/* no ref, but address */
|
||||
message_bchannel_from_remote(NULL, msg->param.bchannel.type, msg->param.bchannel.handle);
|
||||
return(0);
|
||||
|
|
Loading…
Reference in New Issue