commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10094 - openbts/branches/developers/dburgess00/smswor


From: dburgess00
Subject: [Commit-gnuradio] r10094 - openbts/branches/developers/dburgess00/smswork/SMS
Date: Sat, 29 Nov 2008 21:13:24 -0700 (MST)

Author: dburgess00
Date: 2008-11-29 21:13:24 -0700 (Sat, 29 Nov 2008)
New Revision: 10094

Added:
   openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.cpp
   openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.h
Removed:
   openbts/branches/developers/dburgess00/smswork/SMS/CMMessage.cpp
   openbts/branches/developers/dburgess00/smswork/SMS/CMMessage.h
Log:
All SMS-related messages in all layers will be put in this file.


Deleted: openbts/branches/developers/dburgess00/smswork/SMS/CMMessage.cpp

Deleted: openbts/branches/developers/dburgess00/smswork/SMS/CMMessage.h

Copied: openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.cpp 
(from rev 10093, 
openbts/branches/developers/dburgess00/smswork/SMS/CMMessage.cpp)
===================================================================
--- openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.cpp          
                (rev 0)
+++ openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.cpp  
2008-11-30 04:13:24 UTC (rev 10094)
@@ -0,0 +1,138 @@
+/*
+* Copyright 2008 Free Software Foundation, Inc.
+*
+
+    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 3 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, see <http://www.gnu.org/licenses/>.
+
+* This software is distributed under the terms of the GNU Public License.
+* See the COPYING file in the main directory for details.
+*/
+
+
+
+#include "GSML3Message.h"
+#include "SMSTransfer.h"
+#include "CMMessage.h"
+
+using namespace std;
+using namespace GSM;
+using namespace SMS;
+
+#define DEBUG 1
+
+ostream& SMS::operator<<(ostream& os, CPMessage::MessageType val)
+{
+       switch(val) {
+               case CPMessage::Data:
+                       os<<"CP-Data"; break;
+               case CPMessage::Ack:
+                       os<<"CP-Ack"; break;
+               case CPMessage::Error:
+                       os<<"CP-Error"; break;
+               default :
+                       os<<hex<<"0x"<<(int)val<<dec; break;
+       }
+
+       return os;
+}
+
+
+CPMessage * SMS::CPFactory(CPMessage::MessageType val)
+{
+       switch(val) {
+               case CPMessage::Data: return new CPData();
+               case CPMessage::Ack: return new CPAck();
+               case CPMessage::Error: return new CPError();
+               default: {
+                       CERR("Warning -- no support for mti="<<val);
+                       return NULL;
+               }
+       }       
+}
+
+
+
+CPMessage * SMS::parseSMS( const GSM::L3Frame& frame )
+{
+       CPMessage::MessageType MTI = (CPMessage::MessageType)(frame.MTI());     
+       DCOUT(" parseSMS MTI="<<MTI)
+       
+       CPMessage * retVal = CPFactory(MTI);
+       if( retVal==NULL ) return NULL;
+
+       retVal->TIFlag(frame.TIFlag());
+       retVal->TIValue(frame.TIValue());
+       retVal->parse(frame);
+       return retVal;
+}
+
+
+void CPMessage::text(ostream& os) const 
+{
+       os <<" CM "<<(CPMessage::MessageType)MTI();
+       os <<" TI=("<<mTIFlag<<", "<<mTIValue<<")";
+}
+
+
+
+void CPMessage::write(L3Frame& dest) const
+{
+       // We override L3Message::write for the transaction identifier.
+       size_t l3len = bitsNeeded();
+       if (dest.size()!=l3len) dest.resize(l3len);
+       size_t wp = 0;
+       dest.writeField(wp,mTIFlag,1);
+       dest.writeField(wp,mTIValue,3);
+       dest.writeField(wp,PD(),4);
+       dest.writeField(wp,MTI(),8);
+       writeBody(dest, wp);
+}
+
+void CPData::parseBody( const L3Frame& src, size_t &rp )
+{      
+       mData.parseLV(src,rp);
+}
+
+void CPData::writeBody( L3Frame& dest, size_t &wp ) const
+{
+       mData.writeLV(dest,wp);
+} 
+
+void CPData::text(ostream& os) const
+{
+       CPMessage::text(os);
+       os << "RPDU=(" << mData << ")";
+}
+
+void CPError::writeBody( L3Frame& dest, size_t &wp ) const {
+       mCause.writeV(dest,wp);
+}
+
+
+void CPUserData::parseV(const L3Frame& src, size_t &rp, size_t expectedLength)
+{
+       unsigned numBits = expectedLength*8;
+       src.segmentCopyTo(mRPDU,rp,numBits);
+       rp += numBits;
+}
+
+void CPUserData::writeV(L3Frame& dest, size_t &wp) const
+{
+       unsigned numBits = mRPDU.size();
+       mRPDU.copyToSegment(dest,wp,numBits);
+       wp += numBits;
+}
+
+
+// vim: ts=4 sw=4

Copied: openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.h (from 
rev 10093, openbts/branches/developers/dburgess00/smswork/SMS/CMMessage.h)
===================================================================
--- openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.h            
                (rev 0)
+++ openbts/branches/developers/dburgess00/smswork/SMS/SMSMessages.h    
2008-11-30 04:13:24 UTC (rev 10094)
@@ -0,0 +1,217 @@
+/*
+* Copyright 2008 Free Software Foundation, Inc.
+*
+* This software is distributed under the terms of the GNU Public License.
+* See the COPYING file in the main directory for details.
+
+    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 3 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, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+
+#ifndef CM_MESSAGE_H
+#define CM_MESSAGE_H
+
+#include <GSML3Message.h>
+
+
+namespace SMS {
+
+/**
+       A virtual class for SMS CM-layer messages.
+       See GSM 04.11 7.
+       This is probably nearly the same as GSM::L3CCMessage,
+       but with different message types.
+*/
+
+class CPMessage : public GSM::L3Message 
+{
+       private:
+
+       /address@hidden Header information ref. Figure 8. GSM 04.11 */
+       //@{
+       unsigned mTIFlag;       ///< 0 for originating side, see GSM 04.07 
11.2.3.1.3
+       unsigned mTIValue;      ///< short transaction ID, GSM 04.07 11.2.3.1.3
+       //@}
+
+
+       public:
+
+       /** Message type defined in GSM 04.11 8.1.3 Table 8.1 */
+       enum MessageType {
+               Data=0x01,
+               Ack=0x04,
+               Error=0x10
+       };
+
+
+       CPMessage( unsigned wTIFlag, unsigned wTIValue )
+               :L3Message(),
+               mTIFlag(wTIFlag), mTIValue(wTIValue)
+       {}
+
+       /** Override the write method to include transaction identifiers in 
header. */
+       void write(GSM::L3Frame& dest) const;
+
+       GSM::L3PD PD() const { return GSM::L3SMSPD; }
+
+       unsigned TIValue() const { return mTIValue; }
+       void TIValue(unsigned wTIValue){ mTIValue=wTIValue; }
+       
+       unsigned TIFlag() const { return mTIFlag; }
+       void TIFlag( unsigned wTIFlag) { mTIFlag=wTIFlag; }
+       
+       void text(std::ostream&) const;
+
+};
+
+
+std::ostream& operator<<(std::ostream& os, CPMessage::MessageType MTI);
+
+/** Parse a complete SMS L3 (CM) message. */
+CPMessage * parseSMS( const GSM::L3Frame& frame );
+
+/** A factory method for SMS L3 (CM) messages. */
+CPMessage * CPFactory( CPMessage::MessageType MTI );
+
+
+
+/address@hidden CP Elements for SMS */
+//@{
+
+/** GSM 04.11 8.1.4.2 */
+class CPCause : public GSM::L3ProtocolElement {
+
+       private:
+
+       unsigned mValue;
+
+       public:
+
+       CPCause(unsigned wValue)
+               :L3ProtocolElement(),
+               mValue(wValue)
+       {}
+
+       size_t lengthV() const { return 1; }
+
+       void parseV(const GSM::L3Frame& src, size_t &rp)
+               { mValue = src.readField(rp,8); }
+
+       void writeV(GSM::L3Frame& dest, size_t &wp) const
+               { dest.writeField(wp,mValue,8); }
+
+       void text(std::ostream& os) const
+               { os << std::hex << "0x" << mValue << std::dec; }
+};
+
+
+/** GSM 04.11 8.1.4.1 */
+class CPUserData : public GSM::L3ProtocolElement {
+
+       private:
+
+       // The BitVector is a placeholder for a higher-layer object.
+       BitVector mRPDU;
+
+       public:
+
+       CPUserData()
+               :L3ProtocolElement(),
+               mRPDU()
+       {}
+
+       CPUserData(const BitVector& wRPDU)
+               :L3ProtocolElement(),
+               mRPDU(wRPDU)
+       {}
+
+       size_t lengthV() const { return mRPDU.size()/8; }
+
+       void parseV(const GSM::L3Frame& src, size_t &rp, size_t expectedLength);
+
+       void writeV(GSM::L3Frame& dest, size_t &wp) const;
+
+       void text(std::ostream& os) const { os << mRPDU; }
+};
+
+//@} // CP Elements
+
+
+/** GSM 04.11 7.2.1 */
+class CPAck : public CPMessage 
+{      
+       public:
+
+       CPAck( unsigned wTIFlag=0, unsigned wTIValue=7)
+               :CPMessage(wTIFlag, wTIValue)
+       { }
+
+       int MTI() const { return Ack; }
+       size_t bodyLength() const { return 0; }
+
+       void parseBody( const GSM::L3Frame& dest, size_t &rp ){};
+       void writeBody( GSM::L3Frame& dest, size_t &wp ) const{};
+       void text(std::ostream& os) const { CPMessage::text(os); }
+};
+
+
+
+/** GSM 04.11 7.2.3 */
+class CPError : public CPMessage 
+{ 
+       private:
+
+       CPCause mCause;
+
+       public:
+       CPError(unsigned wTIFlag=0, unsigned wTIValue=0, const CPCause& wCause 
= 0x7f)
+               :CPMessage(wTIFlag, wTIValue),
+               mCause(wCause)
+       { }
+
+       int MTI() const { return Error; }
+       size_t bodyLength() const { return mCause.lengthV(); }
+       void writeBody( GSM::L3Frame& dest, size_t &wp ) const; 
+};
+
+
+
+/** GSM 04.11 7.2.1 */
+class CPData : public CPMessage
+{
+       private:
+
+       CPUserData mData;
+
+       public: 
+       CPData( unsigned wTIFlag=0, unsigned wTIValue=7)
+               :CPMessage(wTIFlag, wTIValue)
+       { }
+
+       int MTI() const { return Data; }
+       size_t bodyLength() const { return mData.lengthLV(); }
+       void parseBody( const GSM::L3Frame& dest, size_t &rp );
+       void writeBody( GSM::L3Frame& dest, size_t &wp ) const;
+       void text(std::ostream&) const;
+};
+
+
+
+}; // namespace SMS {
+
+#endif
+
+// vim: ts=4 sw=4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]