Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -u --recursive --new-file 1/include/openbsc/gsm_data.h 2/include/openbsc/gsm_data.h
- --- 1/include/openbsc/gsm_data.h 2010-08-17 11:59:24.000000000 +0200
- +++ 2/include/openbsc/gsm_data.h 2010-09-13 11:37:40.412701000 +0200
- @@ -305,6 +305,10 @@
- } abis_ip;
- struct gsm_subscriber_connection *conn;
- +
- + // Diese ID ist nötig da das conn struct nicht immer initialisiert ist
- +#warning NICK
- + long MYSQL_ID;
- };
- struct gsm_e1_subslot {
- diff -u --recursive --new-file 1/src/abis_rsl.c 2/src/abis_rsl.c
- --- 1/src/abis_rsl.c 2010-08-17 11:59:24.000000000 +0200
- +++ 2/src/abis_rsl.c 2010-09-13 11:34:13.072700000 +0200
- @@ -907,22 +907,36 @@
- DEBUGPC(DMEAS, "L1_TA=%u ", mr->ms_l1.ta);
- }
- - if (mr->flags & MEAS_REP_F_UL_DTX)
- +#warning Nick
- + char* FLAG = "";
- +
- + if (mr->flags & MEAS_REP_F_UL_DTX) {
- DEBUGPC(DMEAS, "DTXu ");
- - if (mr->flags & MEAS_REP_F_BA1)
- + FLAG = "DTXu";
- + }
- + if (mr->flags & MEAS_REP_F_BA1) {
- DEBUGPC(DMEAS, "BA1 ");
- - if (!(mr->flags & MEAS_REP_F_DL_VALID))
- + FLAG = "BA1";
- + }
- + if (!(mr->flags & MEAS_REP_F_DL_VALID)) {
- DEBUGPC(DMEAS, "NOT VALID ");
- - else
- + FLAG = "NOT VALID";
- + } else
- print_meas_rep_uni(&mr->dl, "dl");
- -
- +#warning NICK
- DEBUGPC(DMEAS, "NUM_NEIGH=%u\n", mr->num_cell);
- +
- + int ms_timing_offset = (mr->flags & MEAS_REP_F_MS_TO) ? mr->ms_timing_offset : -1;
- +
- if (mr->num_cell == 7)
- return;
- for (i = 0; i < mr->num_cell; i++) {
- struct gsm_meas_rep_cell *mrc = &mr->cell[i];
- DEBUGP(DMEAS, "IDX=%u ARFCN=%u BSIC=%u => %d dBm\n",
- mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev));
- + if (mr->flags & MEAS_REP_F_DL_VALID) {
- + UpdateMeasurementResult(get_last_insert_id(), i, mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev));
- + }
- }
- }
- @@ -1233,6 +1247,14 @@
- "r=%s ra=0x%02x\n", gsm_lchan_name(lchan), arfcn, subch,
- gsm_lchant_name(lchan->type), gsm_chreq_name(chreq_reason),
- rqd_ref->ra);
- +
- +#warning NICK
- + // Jedes Mal wenn ein Channel angefordert wird, wird eine "leere Hülse" in die Datenbank eingetragen, welche später befüllt wird.
- + InsertEmptyAction();
- + lchan->MYSQL_ID = get_last_insert_id();
- +
- + insertUsedBTS(lchan->MYSQL_ID, bts->cell_identity, "Channel Request");
- +
- return 0;
- }
- diff -u --recursive --new-file 1/src/bsc_hack.c 2/src/bsc_hack.c
- --- 1/src/bsc_hack.c 2010-08-17 11:59:24.000000000 +0200
- +++ 2/src/bsc_hack.c 2010-09-13 12:29:56.572705000 +0200
- @@ -207,6 +207,11 @@
- .go_parent_cb = bsc_vty_go_parent,
- };
- +#warning Nick
- +const char* dbLogging = "test";
- +const char* dbUsername = "root";
- +const char* dbPassword = "openbsc";
- +
- int main(int argc, char **argv)
- {
- int rc;
- @@ -256,6 +261,19 @@
- }
- printf("DB: Database prepared.\n");
- +#warning NICK_MYSQL
- + if (dbLogging_init(dbLogging, dbUsername, dbPassword)) { // makefile.am muss editiert werden: libmsc_a_SOURCES = gsm_subscriber.c db.c dbLogging.c
- + printf("DB Logging: Failed to init database. Please check the option settings.\n");
- + return -1;
- + }
- + printf("DB Logging: Database initialized.\n");
- + if (dbLogging_prepare()) {
- + printf("DB Logging: Failed to prepare database.\n");
- + return -1;
- + }
- + printf("DB Logging: Database prepared.\n");
- +#warning NICK_MYSQL
- +
- /* setup the timer */
- db_sync_timer.cb = db_sync_timer_cb;
- db_sync_timer.data = NULL;
- diff -u --recursive --new-file 1/src/dbLogging.c 2/src/dbLogging.c
- --- 1/src/dbLogging.c 1970-01-01 01:00:00.000000000 +0100
- +++ 2/src/dbLogging.c 2010-08-31 13:42:38.203621000 +0200
- @@ -0,0 +1,217 @@
- +/* Simple HLR/VLR database backend using dbi */
- +/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
- + * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- + * (C) 2009 by Harald Welte <laforge@gnumonks.org>
- + * All Rights Reserved
- + *
- + * This program is free software; you can redistribute it and/or modify
- + * 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
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License along
- + * with this program; if not, write to the Free Software Foundation, Inc.,
- + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- + *
- + */
- +
- +#include <stdint.h>
- +#include <inttypes.h>
- +#include <libgen.h>
- +#include <stdio.h>
- +#include <stdlib.h>
- +#include <string.h>
- +#include <errno.h>
- +#include <dbi/dbi.h>
- +
- +#include <openbsc/gsm_data.h>
- +#include <openbsc/gsm_04_11.h>
- +#include <openbsc/db.h>
- +#include <osmocore/talloc.h>
- +#include <openbsc/debug.h>
- +#include <osmocore/statistics.h>
- +#include <osmocore/rate_ctr.h>
- +
- +static dbi_conn LogConn;
- +
- +static char *create_stmts[] = { "CREATE TABLE IF NOT EXISTS action ("
- + "id BIGINT NOT NULL AUTO_INCREMENT,"
- + "cur_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
- + "actionID TINYINT DEFAULT NULL,"
- + "IMSI varchar(100) DEFAULT NULL,"
- + "PRIMARY KEY (id)"
- + ")", "CREATE TABLE IF NOT EXISTS measurementResults ("
- + "id INT NOT NULL AUTO_INCREMENT,"
- + "cur_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
- + "actionRefID BIGINT DEFAULT NULL,"
- + "RXL_FULL_ul int DEFAULT NULL,"
- + "RXL_SUB_ul int DEFAULT NULL,"
- + "RXQ_FULL_ul int DEFAULT NULL,"
- + "RXQ_SUB_ul int DEFAULT NULL,"
- + "BS_POWER int DEFAULT NULL,"
- + "MS_TO int DEFAULT NULL,"
- + "FLAG varchar(100) DEFAULT NULL,"
- + "RXL_FULL_dl int DEFAULT NULL,"
- + "RXL_SUB_dl int DEFAULT NULL,"
- + "RXQ_FULL_dl int DEFAULT NULL,"
- + "RXQ_SUB_dl int DEFAULT NULL,"
- + "NUM_NEIGH int DEFAULT NULL,"
- +
- + "IDX_0 int DEFAULT NULL,"
- + "ARFCN_0 int DEFAULT NULL,"
- + "BSIC_0 int DEFAULT NULL,"
- + "rxlev_0 int DEFAULT NULL,"
- +
- + "IDX_1 int DEFAULT NULL,"
- + "ARFCN_1 int DEFAULT NULL,"
- + "BSIC_1 int DEFAULT NULL,"
- + "rxlev_1 int DEFAULT NULL,"
- +
- + "IDX_2 int DEFAULT NULL,"
- + "ARFCN_2 int DEFAULT NULL,"
- + "BSIC_2 int DEFAULT NULL,"
- + "rxlev_2 int DEFAULT NULL,"
- +
- + "IDX_3 int DEFAULT NULL,"
- + "ARFCN_3 int DEFAULT NULL,"
- + "BSIC_3 int DEFAULT NULL,"
- + "rxlev_3 int DEFAULT NULL,"
- +
- + "IDX_4 int DEFAULT NULL,"
- + "ARFCN_4 int DEFAULT NULL,"
- + "BSIC_4 int DEFAULT NULL,"
- + "rxlev_4 int DEFAULT NULL,"
- +
- + "IDX_5 int DEFAULT NULL,"
- + "ARFCN_5 int DEFAULT NULL,"
- + "BSIC_5 int DEFAULT NULL,"
- + "rxlev_5 int DEFAULT NULL,"
- +
- + "PRIMARY KEY (id)"
- + ")", "CREATE TABLE IF NOT EXISTS usedBTS ("
- + "id BIGINT NOT NULL AUTO_INCREMENT,"
- + "cur_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
- + "actionRefID BIGINT DEFAULT NULL,"
- + "bts int DEFAULT NULL,"
- + "cause varchar(100) DEFAULT NULL,"
- + "PRIMARY KEY (id)"
- + ")", "CREATE TABLE IF NOT EXISTS actionIdentifier ("
- + "id TINYINT NOT NULL,"
- + "Name varchar(100) NOT NULL,"
- + "PRIMARY KEY (id),"
- + "UNIQUE KEY id (id)"
- + ")" };
- +
- +void dbLogging_error_func(dbi_conn conn, void *data) {
- + const char *msg;
- + dbi_conn_error(conn, &msg);
- + LOGP(DDB, LOGL_ERROR, "DBI Logging: %s\n", msg);
- +}
- +
- +int dbLogging_init(const char *dbName, const char *user, const char *password) {
- + dbi_initialize(NULL);
- +
- + LogConn = dbi_conn_new("mysql");
- +
- + if (LogConn == NULL) {
- + LOGP(DDB, LOGL_FATAL, "Failed to create connection to Logging Database.\n");
- + return 1;
- + }
- +
- + dbi_conn_error_handler(LogConn, dbLogging_error_func, NULL);
- +
- + dbi_conn_set_option(LogConn, "host", "localhost");
- + dbi_conn_set_option(LogConn, "username", strdup(user));
- + dbi_conn_set_option(LogConn, "password", strdup(password));
- + dbi_conn_set_option(LogConn, "dbname", strdup(dbName));
- + dbi_conn_set_option(LogConn, "encoding", "latin1");
- +
- + if (dbi_conn_connect(LogConn) < 0)
- + goto out_err;
- +
- + return 0;
- +
- + out_err: return -1;
- +}
- +
- +int dbLogging_prepare() {
- + dbi_result result;
- + int i;
- +
- + for (i = 0; i < ARRAY_SIZE(create_stmts); i++) {
- + result = dbi_conn_query(LogConn, create_stmts[i]);
- + if (!result) {
- + LOGP(DDB, LOGL_ERROR, "Failed to create some table.\n");
- + return 1;
- + }
- + dbi_result_free(result);
- + }
- +
- + InsertActionIdentifiers();
- +
- + return 0;
- +}
- +
- +int dbLogging_fini() {
- + dbi_conn_close(LogConn);
- + dbi_shutdown();
- +
- + return 0;
- +}
- +
- +long get_last_insert_id() {
- + dbi_result result = dbi_conn_queryf(LogConn, "select last_insert_id();");
- + dbi_result_first_row(result);
- +
- + long _result = dbi_result_get_longlong(result, "last_insert_id()");
- +
- + dbi_result_free(result);
- +
- + return _result;
- +}
- +
- +void InsertActionIdentifiers() {
- + dbi_result_free(dbi_conn_query(LogConn, "insert into actionIdentifier(id, Name) VALUES(1, 'Location Update');"));
- + dbi_result_free(dbi_conn_query(LogConn, "insert into actionIdentifier(id, Name) VALUES(2, 'Call');"));
- +}
- +
- +void InsertEmptyAction() {
- + dbi_result_free(dbi_conn_query(LogConn, "insert into action(actionID) VALUES(-1);"));
- +}
- +
- +void UpdateActionID(long id, int ActionID) {
- + dbi_result_free(dbi_conn_queryf(LogConn, "UPDATE action SET actionID=%i where id=%i;", ActionID, id));
- +}
- +
- +void UpdateActionIMSI(long id, char* IMSI) {
- + dbi_result_free(dbi_conn_queryf(LogConn, "UPDATE action SET IMSI='%s' where id=%i;", IMSI, id));
- +}
- +
- +void InsertMeasurementResult(long actionRefID, int RXL_FULL_ul, int RXL_SUB_ul, int RXQ_FULL_ul, int RXQ_SUB_ul, int BS_POWER, int MS_TO, char* FLAG, int RXL_FULL_dl, int RXL_SUB_dl, int RXQ_FULL_dl, int RXQ_SUB_dl, int NUM_NEIGH) {
- + dbi_result_free(dbi_conn_queryf(LogConn, "insert into measurementResults(actionRefID, RXL_FULL_ul , RXL_SUB_ul , RXQ_FULL_ul, RXQ_SUB_ul , BS_POWER , MS_TO , FLAG , RXL_FULL_dl , RXL_SUB_dl , RXQ_FULL_dl , RXQ_SUB_dl , NUM_NEIGH) VALUES(%i, %i, %i, %i, %i, %i, %i, '%s', %i, %i, %i, %i, %i);", actionRefID, RXL_FULL_ul, RXL_SUB_ul, RXQ_FULL_ul, RXQ_SUB_ul, BS_POWER, MS_TO, FLAG, RXL_FULL_dl, RXL_SUB_dl, RXQ_FULL_dl, RXQ_SUB_dl, NUM_NEIGH));
- +}
- +
- +void UpdateMeasurementResult(long actionRefID, int index, int neigh_idx, int arfcn, int bsic, int rxlev) {
- + char IDX_[100];
- + sprintf(IDX_, "IDX_%i", index);
- +
- + char ARFCN_[100];
- + sprintf(ARFCN_, "ARFCN_%i", index);
- +
- + char BSIC_[100];
- + sprintf(BSIC_, "BSIC_%i", index);
- +
- + char rxlev_[100];
- + sprintf(rxlev_, "rxlev_%i", index);
- +
- + dbi_result_free(dbi_conn_queryf(LogConn, "UPDATE measurementResults SET %s=%i, %s=%i, %s=%i, %s=%i where id=%i;", IDX_, neigh_idx, ARFCN_, arfcn, BSIC_, bsic, rxlev_, rxlev, actionRefID));
- +}
- +
- +void insertUsedBTS(long actionRefID, int BTS, char* cause) {
- + dbi_result_free(dbi_conn_queryf(LogConn, "insert into usedBTS(actionRefID, bts, cause) values(%i, %i, '%s');", actionRefID, BTS, cause));
- +}
- diff -u --recursive --new-file 1/src/gsm_04_08.c 2/src/gsm_04_08.c
- --- 1/src/gsm_04_08.c 2010-08-17 11:59:24.000000000 +0200
- +++ 2/src/gsm_04_08.c 2010-09-13 11:43:01.729200000 +0200
- @@ -349,6 +349,9 @@
- subscr_name(conn->subscr) : "unknown",
- bts->location_area_code, bts->nr);
- +#warning NICK
- + UpdateActionIMSI(conn->lchan->MYSQL_ID, conn->subscr->imsi);
- +
- return gsm48_conn_sendmsg(msg, conn, NULL);
- }
- @@ -376,6 +379,9 @@
- DEBUGP(DMM, "-> LOCATION UPDATE ACCEPT\n");
- +#warning NICK_MYSQL
- + UpdateActionIMSI(conn->lchan->MYSQL_ID, conn->subscr->imsi);
- +
- counter_inc(bts->network->stats.loc_upd_resp.accept);
- return gsm48_conn_sendmsg(msg, conn, NULL);
- @@ -490,6 +496,13 @@
- gsm48_mi_to_string(mi_string, sizeof(mi_string), lu->mi, lu->mi_len);
- +#warning NICK - muss hier oben sein !
- + UpdateActionID(conn->lchan->MYSQL_ID, 1);
- + if (mi_type == GSM_MI_TYPE_IMSI) {
- + DEBUGPC(DMM, "NICK MYSQL: IMSI already available in Updating Request: %s \n", mi_string);
- + UpdateActionIMSI(conn->lchan->MYSQL_ID, mi_string);
- + }
- +
- DEBUGPC(DMM, "mi_type=0x%02x MI(%s) type=%s ", mi_type, mi_string,
- lupd_name(lu->type));
- diff -u --recursive --new-file 1/src/gsm_04_11.c 2/src/gsm_04_11.c
- --- 1/src/gsm_04_11.c 2010-08-17 11:59:24.000000000 +0200
- +++ 2/src/gsm_04_11.c 2010-09-13 11:49:21.025201000 +0200
- @@ -602,6 +602,10 @@
- gsms->sender = subscr_get(conn->subscr);
- +#warning NICK
- + UpdateActionID(conn->lchan->MYSQL_ID, 3);
- + UpdateActionIMSI(conn->lchan->MYSQL_ID, gsms->sender->imsi);
- +
- LOGP(DSMS, LOGL_INFO, "RX SMS: Sender: %s, MTI: 0x%02x, VPF: 0x%02x, "
- "MR: 0x%02x PID: 0x%02x, DCS: 0x%02x, DA: %s, "
- "UserDataLength: 0x%02x, UserData: \"%s\"\n",
- @@ -1097,6 +1101,10 @@
- DEBUGP(DSMS, "TX: SMS DELIVER\n");
- +#warning NICK
- + UpdateActionID(conn->lchan->MYSQL_ID, 3);
- + UpdateActionIMSI(conn->lchan->MYSQL_ID, conn->subscr->imsi);
- +
- counter_inc(conn->bts->network->stats.sms.delivered);
- return gsm411_rp_sendmsg(msg, trans, GSM411_MT_RP_DATA_MT, msg_ref);
- diff -u --recursive --new-file 1/src/handover_logic.c 2/src/handover_logic.c
- --- 1/src/handover_logic.c 2010-08-17 11:59:24.000000000 +0200
- +++ 2/src/handover_logic.c 2010-09-13 11:43:59.544908000 +0200
- @@ -128,6 +128,9 @@
- new_lchan->rsl_cmode = old_lchan->rsl_cmode;
- new_lchan->tch_mode = old_lchan->tch_mode;
- +#warning NICK
- + new_lchan->MYSQL_ID = old_lchan->MYSQL_ID;
- +
- new_lchan->conn = old_lchan->conn;
- new_lchan->conn->ho_lchan = new_lchan;
- @@ -257,6 +260,9 @@
- ho->old_lchan->ts->trx->bts->nr, new_lchan->ts->trx->bts->nr,
- ho->old_lchan->ts->trx->arfcn, new_lchan->ts->trx->arfcn);
- +#warning NICK
- + insertUsedBTS(new_lchan->MYSQL_ID, new_lchan->ts->trx->bts->cell_identity, "Handover complete");
- +
- counter_inc(net->stats.handover.completed);
- bsc_del_timer(&ho->T3103);
- diff -u --recursive --new-file 1/src/Makefile.am 2/src/Makefile.am
- --- 1/src/Makefile.am 2010-08-17 11:59:24.000000000 +0200
- +++ 2/src/Makefile.am 2010-09-13 12:58:05.929203165 +0200
- @@ -25,7 +25,7 @@
- rtp_proxy.c bts_siemens_bs11.c bts_ipaccess_nanobts.c \
- bts_unknown.c bsc_version.c bsc_api.c bsc_vty.c meas_rep.c
- -libmsc_a_SOURCES = gsm_subscriber.c db.c \
- +libmsc_a_SOURCES = gsm_subscriber.c db.c dbLogging.c \
- mncc.c gsm_04_08.c gsm_04_11.c transaction.c \
- token_auth.c rrlp.c gsm_04_80.c ussd.c silent_call.c \
- handover_decision.c auth.c \
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement