From 653e476f7a4acc6ad5adb4c3a5a9fa45ebcfff8d Mon Sep 17 00:00:00 2001 From: ervteng Date: Wed, 11 Jun 2014 16:07:16 -0700 Subject: [PATCH 1/3] Changed hard-coded language code for SMSCB to 0x01, from 0x10. This displays properly on Android devices, and corresponds to English. --- Control/SMSCB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Control/SMSCB.cpp b/Control/SMSCB.cpp index b1a8ef09..138770ad 100644 --- a/Control/SMSCB.cpp +++ b/Control/SMSCB.cpp @@ -124,7 +124,7 @@ void SMSCBSendMessage(sqlite3* DB, sqlite3_stmt* stmt, GSM::CBCHLogicalChannel* while (dp<82) { thisPage[dp++] = 0; thisPage[dp++]='\r'; } } else { // 03.38 section 5 - codingScheme = 0x10; // 7' + codingScheme = 0x01; // 7' int buf = 0; int shift = 0; // The spec (above) says to put this language stuff in, but it doesn't work on my samsung galaxy y. From f76b6519a5668f222a8fa5b435ec57dc4812b688 Mon Sep 17 00:00:00 2001 From: ervteng Date: Wed, 11 Jun 2014 16:08:15 -0700 Subject: [PATCH 2/3] At the CBCH, the last of the four L2 frames now set the Last Block Bit to 0x03, corresponding to the end of the SMSCB message. GSM 04.12 Also, added SMSCB as a GSMTAP type, so it is recognized by Wireshark. --- GSM/GSML2LAPDm.cpp | 12 +++++++++--- GSM/GSMTAPDump.cpp | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/GSM/GSML2LAPDm.cpp b/GSM/GSML2LAPDm.cpp index 496d6dab..a8a42344 100644 --- a/GSM/GSML2LAPDm.cpp +++ b/GSM/GSML2LAPDm.cpp @@ -1071,13 +1071,19 @@ void CBCHL2::l2WriteHighSide(const GSM::L3Frame& l3) assert(l3.primitive()==UNIT_DATA); assert(l3.size()==88*8); L2Frame outFrame(DATA); - // Chop the L3 frame into 4 L2 frames. + // Chop the L3 frame into 4 L2 frames. for (unsigned i=0; i<4; i++) { - outFrame.fillField(0,0x02,4); + // If it is the fourth frame, set the Last Block Bit to 0x03. + if(i==3){ + outFrame.fillField(0,0x03,4); + } + else { + outFrame.fillField(0,0x02,4); + } outFrame.fillField(4,i,4); const BitVector2 thisSeg = l3.cloneSegment(i*22*8,22*8); thisSeg.copyToSegment(outFrame,8); - OBJLOG(DEBUG) << "CBCHL2 outgoing L2 frame: " << outFrame; + OBJLOG(DEBUG) <<"Frame "<< i <<" of 4 " << "CBCHL2 outgoing L2 frame: " << outFrame; mL2Downstream->writeHighSide(outFrame); } } diff --git a/GSM/GSMTAPDump.cpp b/GSM/GSMTAPDump.cpp index 6190353c..0fd1837c 100644 --- a/GSM/GSMTAPDump.cpp +++ b/GSM/GSMTAPDump.cpp @@ -57,6 +57,11 @@ void gWriteGSMTAP(unsigned ARFCN, unsigned TS, unsigned FN, case GSM::SDCCH_4_0: case GSM::SDCCH_4_1: case GSM::SDCCH_4_2: + if(gConfig.getStr("Control.SMSCB.Table").length() != 0){ + stype = GSMTAP_CHANNEL_CBCH52; + scn = to - GSM::SDCCH_4_0; + break; + } case GSM::SDCCH_4_3: stype = GSMTAP_CHANNEL_SDCCH4; scn = to - GSM::SDCCH_4_0; From c7bb6cf77dc10be83db27da0300b148062318420 Mon Sep 17 00:00:00 2001 From: ervteng Date: Wed, 2 Jul 2014 13:05:18 -0700 Subject: [PATCH 3/3] SMSCB respects send_time Changed SMSCB behavior so that messages are not sent until send_time is reached. --- Control/SMSCB.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Control/SMSCB.cpp b/Control/SMSCB.cpp index 138770ad..1547223b 100644 --- a/Control/SMSCB.cpp +++ b/Control/SMSCB.cpp @@ -176,11 +176,13 @@ void* Control::SMSCBSender(void*) while (1) { // Get the next message ready to send. - const char* query = + char query[200]; + sprintf(query, "SELECT" " GS,MESSAGE_CODE,UPDATE_NUMBER,MSGID,MESSAGE,LANGUAGE_CODE,SEND_COUNT,ROWID" " FROM SMSCB" - " WHERE SEND_TIME==(SELECT min(SEND_TIME) FROM SMSCB)"; + " WHERE SEND_TIME==(SELECT min(SEND_TIME) FROM SMSCB)" + " AND SEND_TIME<=%u", (unsigned)time(NULL)); sqlite3_stmt *stmt; if (sqlite3_prepare_statement(DB,&stmt,query)) { LOG(ALERT) << "Cannot access SMSCB database: " << sqlite3_errmsg(DB);