├── .gitignore ├── .travis.yml ├── LICENSE ├── LICENSE_LOGICA ├── README.md ├── charset ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── smpp │ │ │ └── charset │ │ │ ├── Gsm7BitCharset.java │ │ │ └── Gsm7BitCharsetProvider.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── java.nio.charset.spi.CharsetProvider │ └── test │ └── java │ └── org │ └── smpp │ └── charset │ ├── Gsm7BitCharsetProviderTest.java │ └── Gsm7BitCharsetTest.java ├── client ├── pom.xml ├── smppsender.cfg ├── smpptest.cfg └── src │ └── main │ └── java │ └── org │ └── smpp │ ├── client │ └── SMPPSender.java │ └── test │ ├── PDUInitDeadlockTest.java │ └── SMPPTest.java ├── core ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── smpp │ │ ├── Connection.java │ │ ├── Data.java │ │ ├── NotSynchronousException.java │ │ ├── OutbindEvent.java │ │ ├── OutbindEventListener.java │ │ ├── OutbindReceiver.java │ │ ├── ReceivedPDUEvent.java │ │ ├── Receiver.java │ │ ├── ReceiverBase.java │ │ ├── SSLConnection.java │ │ ├── ServerPDUEvent.java │ │ ├── ServerPDUEventListener.java │ │ ├── Session.java │ │ ├── SmppException.java │ │ ├── SmppObject.java │ │ ├── TCPIPConnection.java │ │ ├── TimeoutException.java │ │ ├── Transmitter.java │ │ ├── WrongSessionStateException.java │ │ ├── debug │ │ ├── Debug.java │ │ ├── DefaultDebug.java │ │ ├── DefaultEvent.java │ │ ├── Event.java │ │ ├── FileDebug.java │ │ ├── FileEvent.java │ │ ├── FileLog.java │ │ └── LoggerDebug.java │ │ ├── pdu │ │ ├── Address.java │ │ ├── AddressRange.java │ │ ├── AlertNotification.java │ │ ├── BindReceiver.java │ │ ├── BindReceiverResp.java │ │ ├── BindRequest.java │ │ ├── BindResponse.java │ │ ├── BindTransciever.java │ │ ├── BindTranscieverResp.java │ │ ├── BindTransmitter.java │ │ ├── BindTransmitterResp.java │ │ ├── ByteData.java │ │ ├── ByteDataList.java │ │ ├── CancelSM.java │ │ ├── CancelSMResp.java │ │ ├── DataSM.java │ │ ├── DataSMResp.java │ │ ├── DeliverSM.java │ │ ├── DeliverSMResp.java │ │ ├── DestinationAddress.java │ │ ├── DistributionList.java │ │ ├── EnquireLink.java │ │ ├── EnquireLinkResp.java │ │ ├── GenericNack.java │ │ ├── HeaderIncompleteException.java │ │ ├── IntegerOutOfRangeException.java │ │ ├── InvalidPDUException.java │ │ ├── MessageIncompleteException.java │ │ ├── Outbind.java │ │ ├── PDU.java │ │ ├── PDUException.java │ │ ├── PDUFactory.java │ │ ├── PDUHeader.java │ │ ├── QuerySM.java │ │ ├── QuerySMResp.java │ │ ├── ReplaceSM.java │ │ ├── ReplaceSMResp.java │ │ ├── Request.java │ │ ├── Response.java │ │ ├── ShortMessage.java │ │ ├── SubmitMultiSM.java │ │ ├── SubmitMultiSMResp.java │ │ ├── SubmitSM.java │ │ ├── SubmitSMResp.java │ │ ├── TooManyValuesException.java │ │ ├── Unbind.java │ │ ├── UnbindResp.java │ │ ├── UnexpectedOptionalParameterException.java │ │ ├── UnknownCommandIdException.java │ │ ├── UnsuccessSME.java │ │ ├── ValueNotSetException.java │ │ ├── WrongDateFormatException.java │ │ ├── WrongDestFlagException.java │ │ ├── WrongLengthOfStringException.java │ │ └── tlv │ │ │ ├── TLV.java │ │ │ ├── TLVByte.java │ │ │ ├── TLVEmpty.java │ │ │ ├── TLVException.java │ │ │ ├── TLVInt.java │ │ │ ├── TLVOctets.java │ │ │ ├── TLVShort.java │ │ │ ├── TLVString.java │ │ │ ├── TLVUByte.java │ │ │ └── WrongLengthException.java │ │ └── util │ │ ├── ByteBuffer.java │ │ ├── DataCodingCharsetHandler.java │ │ ├── DefaultServerPDUEventListener.java │ │ ├── NotEnoughDataInByteBufferException.java │ │ ├── ProcessingThread.java │ │ ├── Queue.java │ │ ├── SimpleOutbindListener.java │ │ ├── TerminatingZeroNotFoundException.java │ │ └── Unprocessed.java │ └── test │ └── java │ └── org │ └── smpp │ ├── ClientSessionUnbindIT.java │ ├── SmppObjectTest.java │ ├── TestServer.java │ ├── TestUtils.java │ ├── debug │ ├── DefaultDebugTest.java │ └── DefaultEventTest.java │ ├── pdu │ ├── AddressTest.java │ ├── ByteDataTest.java │ └── Matchers.java │ └── util │ ├── ByteBufferTest.java │ ├── NotEnoughDataInByteBufferExceptionMatcher.java │ ├── QueueTest.java │ └── UnprocessedTest.java ├── pom.xml └── sim ├── pom.xml ├── src └── main │ └── java │ └── org │ └── smpp │ └── smscsim │ ├── DeliveryInfoSender.java │ ├── PDUProcessor.java │ ├── PDUProcessorFactory.java │ ├── PDUProcessorGroup.java │ ├── SMSCListener.java │ ├── SMSCListenerImpl.java │ ├── SMSCSession.java │ ├── SMSCSessionImpl.java │ ├── ShortMessageStore.java │ ├── ShortMessageValue.java │ ├── Simulator.java │ ├── SimulatorPDUProcessor.java │ ├── SimulatorPDUProcessorFactory.java │ └── util │ ├── Attribute.java │ ├── BasicTableParser.java │ ├── Record.java │ ├── Table.java │ └── TableParser.java └── users.txt /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .project 3 | .settings 4 | .classpath 5 | .DS_Store 6 | hs_err_pid* 7 | 8 | # Log files by simulator 9 | *.dbg0 10 | *.evt0 11 | 12 | # Used by simulator 13 | sim/etc/users.txt 14 | 15 | # Eclipse 16 | **/.settings/ 17 | **/.classpath 18 | **/.project 19 | 20 | # IntelliJ 21 | **/*.iml 22 | .idea 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005, OpenSmpp Project 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the OpenSmpp Project nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 26 | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | This software was originally issued under the Logica Open Source License Version 1.0, 29 | but was subsequently put in the public domain under the current BSD licence, which was 30 | deemed closest to the spirit of the original licence. 31 | -------------------------------------------------------------------------------- /LICENSE_LOGICA: -------------------------------------------------------------------------------- 1 | 2 | This, the original license for this software, has been superseded - please see 3 | the file LICENSE for the latest licensing information. 4 | 5 | =========================================================================== 6 | Logica Open Source License Version 1.0 7 | Copyright (c) 1996-2001 Logica Mobile Networks Limited, all rights reserved. 8 | 9 | Logica Mobile Networks Limited ("Logica") is the owner of the rights 10 | in the software programs ("Software"). In the following text, the term 11 | "you" or "your" refers to you as an individual and/or (as the case may be) 12 | to the legal entity to which the Software has been supplied. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided all copies and partial copies 16 | made and/or distributed (in whatever form) and all associated documentation 17 | and other material must acknowledge Logica's rights by the inclusion 18 | of the following notice: 19 | 20 | "Copyright (c) 1996-2001 Logica Mobile Networks Limited; 21 | this product includes software developed by Logica by whom copyright 22 | and know-how are retained, all rights reserved." 23 | 24 | The location of such notice shall be such that it is clearly displayed 25 | and readable to any person accessing the Software. 26 | 27 | 28 | Any use, copying or distribution of the Software is subject to the following: 29 | 30 | * Your rights in respect of the Software are confined to the non-exclusive 31 | and non-assignable license expressed herein. If you breach any of these 32 | term and conditions then your license may be terminated. 33 | 34 | * The copyright and other intellectual property rights in and in connection 35 | with the Software are and shall remain the exclusive property of Logica 36 | or its third party licensors. You must not remove or alter any copyright 37 | or other proprietary notice on any of the software. 38 | 39 | 40 | To the extent permitted by law and in the absence of a formal written contract 41 | between you and Logica the following limitations and exclusions also apply: 42 | 43 | * The Software is supplied and licensed on an "as is" basis without any 44 | warranty or representation from Logica of any kind. 45 | 46 | * Conditions, warranties and representations that might be attributed 47 | to Logica or the Software (including, but not limited to, any implied 48 | condition or warranty relating to merchantability, fitness, suitability 49 | or quality) are excluded. 50 | 51 | * In no event shall Logica be liable in respect of or in connection 52 | with the supply, licensing, use or distribution of the software in any 53 | form for any direct, special, indirect or consequential loss or damages 54 | or for any loss of use, loss of data or of profits or for any business 55 | interruption or loss of goodwill. 56 | 57 | * Logica shall have no obligation to fix any defect or deficiency 58 | in the Software and Logica shall have no liability for any consequences 59 | (direct or consequential) that may arise from any such defect or deficiency. 60 | 61 | * Logica's maximum liability (if any) in relation to the licensing, 62 | provision and/or performance of the Software shall not exceed the price 63 | you paid to secure your license. 64 | 65 | The laws of Ireland shall apply to these terms and conditions and shall 66 | govern every aspect of the supply and licensing of the Software. 67 | =========================================================================== 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenSmpp 2 | 3 | Java library implementing the SMPP protocol, and allowing development of 4 | External Short Message Entities (ESMEs) and more 5 | 6 | It is based on the OpenSmpp library from http://sourceforge.net/projects/smstools/ 7 | 8 | OpenSMPP is based on the original Logica SMPP libraries. It contains several 9 | bug fixes, and has been generally refactored. 10 | 11 | # Modules 12 | 13 | * core - the core library 14 | * charset - character sets useful in SMPP 15 | * client - a simple SMPP client 16 | * sim - a simple SMSC simulator 17 | 18 | # Versions 19 | 20 | Versions of this project are managed according to the 21 | [Semantic Versioning](http://semver.org) specification. 22 | 23 | # Build Status 24 | 25 | [![Build Status](https://travis-ci.com/OpenSmpp/opensmpp.png?branch=master)](https://travis-ci.com/OpenSmpp/opensmpp) 26 | 27 | # License 28 | 29 | Copyright (c) 2005, OpenSmpp Project 30 | All rights reserved. 31 | 32 | Redistribution and use in source and binary forms, with or without modification, 33 | are permitted provided that the following conditions are met: 34 | 35 | * Redistributions of source code must retain the above copyright notice, 36 | this list of conditions and the following disclaimer. 37 | 38 | * Redistributions in binary form must reproduce the above copyright notice, 39 | this list of conditions and the following disclaimer in the documentation 40 | and/or other materials provided with the distribution. 41 | 42 | * Neither the name of the OpenSmpp Project nor the names of its contributors 43 | may be used to endorse or promote products derived from this software 44 | without specific prior written permission. 45 | 46 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 47 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 48 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 49 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 50 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 51 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 52 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 53 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 54 | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 | 56 | This software was originally issued under the Logica Open Source License Version 1.0, 57 | but was subsequently put in the public domain under the current BSD licence, which was 58 | deemed closest to the spirit of the original licence. 59 | -------------------------------------------------------------------------------- /charset/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.opensmpp 7 | opensmpp-parent 8 | 3.0.3-SNAPSHOT 9 | 10 | opensmpp-charset 11 | jar 12 | OpenSMPP Character Sets 13 | 14 | 15 | 16 | junit 17 | junit 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /charset/src/main/java/org/smpp/charset/Gsm7BitCharsetProvider.java: -------------------------------------------------------------------------------- 1 | package org.smpp.charset; 2 | 3 | import java.nio.charset.Charset; 4 | import java.nio.charset.spi.CharsetProvider; 5 | import java.util.HashSet; 6 | import java.util.Iterator; 7 | 8 | /** 9 | * This is a CharsetProvider for the GSM 7-Bit character set. It is named 10 | * X-Gsm7Bit since it's not registered in the IANA registry 11 | * 12 | * To activate this CharsetProvider, it's necessary to add a file to 13 | * the classpath of the JVM runtime at the following location: 14 | * META-INF/services/java.nio.charsets.spi.CharsetProvider 15 | * 16 | * That file must contain a line with the fully qualified name of 17 | * this class on a line by itself: 18 | * org.smpp.charset.Gsm7BitCharsetProvider 19 | * 20 | * See the javadoc page for java.nio.charsets.spi.CharsetProvider 21 | * for full details. 22 | * 23 | * @author Sverker Abrahamsson 24 | * @version $Revision: 1.1 $ 25 | */ 26 | public class Gsm7BitCharsetProvider extends CharsetProvider { 27 | 28 | // The name of the charset we provide 29 | private static final String CHARSET_NAME = "X-Gsm7Bit"; 30 | 31 | // A handle to the Charset object 32 | private Charset gsm7Bit = null; 33 | 34 | private boolean debug = false; 35 | 36 | /** 37 | * Constructor, instantiate a Charset object and save the reference. 38 | */ 39 | public Gsm7BitCharsetProvider() { 40 | super(); 41 | if(debug) 42 | System.out.println("Instansiating " + CHARSET_NAME); 43 | this.gsm7Bit = new Gsm7BitCharset(CHARSET_NAME, null); 44 | } 45 | 46 | /** 47 | * Called by Charset static methods to find a particular named 48 | * Charset. If it's the name of this charset (we don't have 49 | * any aliases) then return the Rot13 Charset, else return null. 50 | */ 51 | public Charset charsetForName (String charsetName) { 52 | if(charsetName.equalsIgnoreCase(CHARSET_NAME)) { 53 | return(gsm7Bit); 54 | } 55 | return(null); 56 | } 57 | 58 | /** 59 | * Return an Iterator over the set of Charset objects we provide. 60 | * @return An Iterator object containing references to all the 61 | * Charset objects provided by this class. 62 | */ 63 | public Iterator charsets() { 64 | HashSet set = new HashSet(1); 65 | set.add(gsm7Bit); 66 | return(set.iterator()); 67 | } 68 | } 69 | /* 70 | * $Log: not supported by cvs2svn $ 71 | */ -------------------------------------------------------------------------------- /charset/src/main/resources/META-INF/services/java.nio.charset.spi.CharsetProvider: -------------------------------------------------------------------------------- 1 | org.smpp.charset.Gsm7BitCharsetProvider 2 | -------------------------------------------------------------------------------- /charset/src/test/java/org/smpp/charset/Gsm7BitCharsetProviderTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp.charset; 2 | 3 | import static org.junit.Assert.assertNotNull; 4 | 5 | import java.nio.charset.Charset; 6 | 7 | import org.junit.Test; 8 | 9 | public class Gsm7BitCharsetProviderTest { 10 | 11 | @Test 12 | public void testCharsetName() { 13 | Gsm7BitCharsetProvider provider = new Gsm7BitCharsetProvider(); 14 | Charset charset = provider.charsetForName("X-Gsm7Bit"); 15 | 16 | assertNotNull(charset); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /charset/src/test/java/org/smpp/charset/Gsm7BitCharsetTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp.charset; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.nio.ByteBuffer; 6 | import java.nio.CharBuffer; 7 | import java.nio.charset.Charset; 8 | import java.nio.charset.CoderResult; 9 | import java.nio.charset.spi.CharsetProvider; 10 | 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | 14 | public class Gsm7BitCharsetTest { 15 | 16 | private Charset charset; 17 | 18 | @Before 19 | public void setup() { 20 | CharsetProvider provider = new Gsm7BitCharsetProvider(); 21 | 22 | charset = provider.charsetForName("X-Gsm7Bit"); 23 | } 24 | 25 | @Test 26 | public void testEncoderOverflow() { 27 | assertEquals(CoderResult.OVERFLOW, charset.newEncoder().encode(CharBuffer.wrap("00"), ByteBuffer.wrap(new byte[1]), true)); 28 | } 29 | 30 | @Test 31 | public void testDecoderOverflow() { 32 | assertEquals(CoderResult.OVERFLOW, charset.newDecoder().decode(ByteBuffer.wrap(new byte[] { 0x30, 0x30 }), CharBuffer.allocate(1), true)); 33 | } 34 | 35 | @Test 36 | public void testEuroCharacterEncoding() { 37 | assertEquals(ByteBuffer.wrap(new byte[] { (byte) 0x1b, (byte) 0x65 }), charset.encode("€")); 38 | } 39 | 40 | @Test 41 | public void testEuroCharacterDecoding() { 42 | assertEquals(CharBuffer.wrap("€"), charset.decode(ByteBuffer.wrap(new byte[] { (byte) 0x1b, (byte) 0x65 }))); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.opensmpp 7 | opensmpp-parent 8 | 3.0.3-SNAPSHOT 9 | 10 | opensmpp-client 11 | jar 12 | OpenSMPP Client 13 | 14 | 15 | org.smpp.test.SMPPTest 16 | 17 | 18 | 19 | 20 | ${project.groupId} 21 | opensmpp-core 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-shade-plugin 30 | 3.1.0 31 | 32 | false 33 | 34 | 35 | 36 | 37 | ${app.mainClass} 38 | 39 | 40 | 41 | 42 | 43 | 44 | package 45 | 46 | shade 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /client/smppsender.cfg: -------------------------------------------------------------------------------- 1 | # This is the IP address of SMSC 2 | ip-address=127.0.0.1 3 | 4 | # Port to bind to 5 | port=2577 6 | 7 | # Your system id 8 | system-id=pavel 9 | 10 | # Your password 11 | password=dfsew 12 | 13 | # The bind mode can be t, r, or tr for transmitter, 14 | # receiver or transciever respectively 15 | bind-mode=t 16 | 17 | # The address range this smpp client will serve 18 | addr-ton=1 19 | addr-npi=1 20 | 21 | # The source address for this client 22 | source-ton=1 23 | source-npi=1 24 | # This is a made-up address 25 | source-address=3538612345678 26 | 27 | # The default destination address 28 | destination-ton=1 29 | destination-npi=1 30 | # Set your destination address default 31 | # destination-address= 32 | 33 | # The service type can be empty or one of 34 | # the following values: 35 | # CMT, CPT, VMN, VMA, WAP or USSD 36 | # service-type= 37 | 38 | system-type= 39 | 40 | # The receive timeout is a timeout for trying to receive a message 41 | # from the SMSC. If you want go to infinite wait until a PDU 42 | # is received, set the receive-timeout to -1. Otherwise 43 | # set the receive-timeout to number of seconds. 44 | 45 | receive-timeout=10 46 | -------------------------------------------------------------------------------- /client/smpptest.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file with default parameters 2 | # for SMSCTest application. It's loaded by the application 3 | # on startup. 4 | # 5 | # 10-10-01 ticp@logica.com bind-mode default changed to tr, i.e. transceiver 6 | # 10-10-01 ticp@logica.com added sync-mode parameter to set default for 7 | # asynchronous/synchronous processing 8 | # 9 | 10 | 11 | # This is the IP address of SMSC 12 | ip-address=65.199.187.169 13 | 14 | # Port to bind to 15 | port=900 16 | 17 | # Your system id 18 | system-id=pavel 19 | 20 | # Your password 21 | password=dfsew 22 | 23 | # The bind mode can be t, r, or tr for transmitter, 24 | # receiver or transciever respectively 25 | bind-mode=tr 26 | 27 | 28 | # The address range this smpp client will serve 29 | 30 | addr-ton=1 31 | addr-npi=1 32 | address-range=11* 33 | 34 | 35 | # The source address for this client 36 | 37 | source-ton=1 38 | source-npi=1 39 | # This is a made-up address 40 | source-address=3538612345678 41 | 42 | 43 | # The default destination address 44 | 45 | destination-ton=1 46 | destination-npi=1 47 | # Set your destination address default 48 | # destination-address= 49 | 50 | 51 | # The service type can be empty or one of 52 | # the following values: 53 | # CMT, CPT, VMN, VMA, WAP or USSD 54 | # service-type= 55 | 56 | system-type=Logica 57 | 58 | 59 | # The receive timeout is a timeout for trying to receive a message 60 | # from the SMSC. If you want go to infinite wait until a PDU 61 | # is received, set the receive-timeout to -1. Otherwise 62 | # set the receive-timeout to number of seconds. 63 | 64 | receive-timeout=10 65 | 66 | 67 | # This is receiving mode. If set to sync, then the application 68 | # waits for response after sending a request pdu. If set to sync, 69 | # the application doesn't wait for responses, rather they are passed to 70 | # and implementation of ServerPDUListener by the Receiver. 71 | # The listener is also passed every request pdu received from the smsc. 72 | # Possible values are "sync" and "async" 73 | 74 | sync-mode=sync 75 | 76 | -------------------------------------------------------------------------------- /client/src/main/java/org/smpp/test/PDUInitDeadlockTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp.test; 2 | 3 | import org.smpp.pdu.BindReceiver; 4 | import org.smpp.pdu.BindTransciever; 5 | 6 | /** 7 | * Reproducible demonstration of bug #1029141. PDU was instantiating subclasses 8 | * of itself during (synchronized) class initialisation. A race condition 9 | * existed whereby, say, two threads would try to instantiate two different 10 | * subclasses of PDU. One thread (X) would get the lock on subclass A, and then 11 | * on PDU.class (following the constructor hierarchy). Another thread (Y) would 12 | * seemingly get the lock on its own target subclass (B). Thread X would then 13 | * try to construct B via static initialisation, causing a deadlock. 14 | * 15 | * Being related to initialisation, this deadlock would likely be experienced by 16 | * users (if at all) only at JVM startup time, and then only under certain 17 | * conditions, and perhaps also intermittently. 18 | * 19 | * Solved via: 20 | * 21 | * @see org.smpp.pdu.PDUFactory 22 | * 23 | * @author Paolo Campanella, BulkSMS.com. 24 | * 25 | */ 26 | public class PDUInitDeadlockTest { 27 | static private int TYPE_RECEIVER = 1; 28 | static private int TYPE_TRANSCEIVER = 2; 29 | 30 | private PDUInitDeadlockTest() { 31 | // Create two or more test threads: 32 | int numThreads = 2; 33 | 34 | System.out.println("Creating PDU creator threads"); 35 | PDUCreatorThread[] threads = new PDUCreatorThread[numThreads]; 36 | boolean makeReceiver = false; 37 | 38 | for (int i = 0; i < numThreads; i++) { 39 | if (makeReceiver) { 40 | threads[i] = new PDUCreatorThread(TYPE_RECEIVER, "Receiver" + i); 41 | } else { 42 | threads[i] = new PDUCreatorThread(TYPE_TRANSCEIVER, "Transceiver" + i); 43 | } 44 | makeReceiver = !makeReceiver; 45 | } 46 | 47 | for (int i = 0; i < numThreads; i++) { 48 | threads[i].start(); 49 | // On my workstation, anything over about 400ms gap between 50 | // starting threads masks the problem (gives the PDU 51 | // init code enough time to initialise): 52 | // Thread.sleep(400); 53 | } 54 | 55 | try { 56 | Thread.sleep(500); 57 | System.out.println("PDU creator threads started - please wait..."); 58 | Thread.sleep(5000); 59 | boolean threadsAlive = false; 60 | for (int i = 0; i < numThreads; i++) { 61 | if (threads[i].isAlive()) { 62 | threadsAlive = true; 63 | System.out.println("Thread " + threads[i].getName() + 64 | " is alive. Here is its stack trace: "); 65 | System.out.println("(stacktrace - TODO)"); 66 | //threads[i].getStackTrace() 67 | } 68 | } 69 | if (threadsAlive) { 70 | Thread.sleep(200); 71 | System.out.println("Some threads are still alive (after 5 seconds) - likely deadlock!"); 72 | System.out.println(" - interrupting all living threads..."); 73 | for (int i = 0; i < numThreads; i++) { 74 | if (threads[i].isAlive()) { 75 | threads[i].interrupt(); 76 | } 77 | } 78 | Thread.sleep(1000); 79 | } else { 80 | System.out.println("All threads have exited correctly."); 81 | } 82 | } catch (InterruptedException e2) { 83 | e2.printStackTrace(); 84 | } 85 | 86 | System.out.println("Exiting"); 87 | System.exit(0); 88 | } 89 | 90 | public static void main(String[] args) { 91 | new PDUInitDeadlockTest(); 92 | } 93 | 94 | class PDUCreatorThread extends Thread { 95 | int type; 96 | public PDUCreatorThread(int type, String name) { 97 | this.type = type; 98 | this.setName(name); 99 | } 100 | public void run() { 101 | System.out.println(getName() + ": starting"); 102 | // Doesn't need to be BindReceiver and BindTransciever - you 103 | // can use any PDU types to cause a deadlock. 104 | if (type == TYPE_RECEIVER) { 105 | new BindReceiver(); 106 | } 107 | else if (type == TYPE_TRANSCEIVER) { 108 | new BindTransciever(); 109 | } 110 | System.out.println(getName() + ": done"); 111 | } 112 | } 113 | 114 | } 115 | 116 | -------------------------------------------------------------------------------- /core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.opensmpp 7 | opensmpp-parent 8 | 3.0.3-SNAPSHOT 9 | 10 | opensmpp-core 11 | jar 12 | OpenSMPP Core 13 | 14 | 15 | 16 | ${project.groupId} 17 | opensmpp-charset 18 | 19 | 20 | 21 | junit 22 | junit 23 | 24 | 25 | org.mockito 26 | mockito-core 27 | 28 | 29 | org.powermock 30 | powermock-module-junit4 31 | 32 | 33 | org.powermock 34 | powermock-api-mockito2 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/NotSynchronousException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | /** 14 | * Exception NotSynchronousException is thrown when 15 | * Session's (synchronous) method receive is called when 16 | * the Receiver is in asynchronous state, i.e when all PDUs received 17 | * from the SMSC are passed to an instance of implementation of 18 | * ServerPDUListener class. 19 | 20 | * @author Logica Mobile Networks SMPP Open Source Team 21 | * @version $Revision: 1.2 $ 22 | */ 23 | 24 | public class NotSynchronousException extends SmppException { 25 | private static final long serialVersionUID = -2785891348929001265L; 26 | private Session session = null; 27 | 28 | public NotSynchronousException() { 29 | } 30 | 31 | public NotSynchronousException(Session session) { 32 | this.session = session; 33 | } 34 | 35 | public Session getSession() { 36 | return session; 37 | } 38 | 39 | } 40 | /* 41 | * $Log: not supported by cvs2svn $ 42 | * Revision 1.1 2003/07/23 00:28:39 sverkera 43 | * Imported 44 | * 45 | */ 46 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/OutbindEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | import org.smpp.pdu.Outbind; 14 | 15 | /** 16 | * Created when outbind pdu is received from smsc. 17 | * This event is created and passed to the OutbindEventListener by 18 | * the OutbindReceiver. 19 | * 20 | * @author Logica Mobile Networks SMPP Open Source Team 21 | * @version $Revision: 1.2 $ 22 | * @see OutbindReceiver 23 | * @see OutbindEventListener 24 | */ 25 | 26 | /* 27 | 21-08-01 ticp@logica.com now derived from common ReceivedPDUEvent 28 | and functionality covered by new parent 29 | removed from this class 30 | */ 31 | 32 | public class OutbindEvent extends ReceivedPDUEvent { 33 | private static final long serialVersionUID = 1808913846085130877L; 34 | 35 | /** 36 | * Construct event for outbind pdu received over conection 37 | * belonging to the outbind receiver. 38 | */ 39 | public OutbindEvent(OutbindReceiver source, Connection connection, Outbind outbindPDU) { 40 | super(source, connection, outbindPDU); 41 | } 42 | 43 | /** 44 | * Returns the outbind receiver thru which was received the outbind pdu 45 | * this event relates to. 46 | */ 47 | public OutbindReceiver getReceiver() { 48 | return (OutbindReceiver) getSource(); 49 | } 50 | 51 | /** 52 | * Returns the outbind pdu. 53 | */ 54 | public Outbind getOutbindPDU() { 55 | return (Outbind) getPDU(); 56 | } 57 | 58 | } 59 | /* 60 | * $Log: not supported by cvs2svn $ 61 | * Revision 1.1 2003/07/23 00:28:39 sverkera 62 | * Imported 63 | * 64 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/OutbindEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | import java.util.EventListener; 14 | 15 | /** 16 | * Callback interface for Outbind requests received from SMSC. 17 | * The only method of this interface, handleOutbind, is called 18 | * whenever an outbind request is received from SMSC.
19 | * Important:The handleOutbind method is called 20 | * from the receiver's thread context, so the implementation of the listener 21 | * should ensure that there is no deadloock, or at least not too much 22 | * time spent in the method. 23 | * 24 | * @author Logica Mobile Networks SMPP Open Source Team 25 | * @version $Revision: 1.1 $ 26 | * @see OutbindReceiver 27 | */ 28 | 29 | public interface OutbindEventListener extends EventListener { 30 | public void handleOutbind(OutbindEvent outbind); 31 | } 32 | /* 33 | * $Log: not supported by cvs2svn $ 34 | * 35 | * Old changelog: 36 | * 02-10-01 ticp@logica.com comments added 37 | */ 38 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/ReceivedPDUEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | import java.util.EventObject; 14 | 15 | import org.smpp.pdu.PDU; 16 | 17 | /** 18 | * The base class for events representing receiving a pdu by 19 | * receiver. 20 | * 21 | * @author Logica Mobile Networks SMPP Open Source Team 22 | * @version $Revision: 1.2 $ 23 | */ 24 | public class ReceivedPDUEvent extends EventObject { 25 | private static final long serialVersionUID = 2888578757849035826L; 26 | 27 | /** 28 | * The connection over which was the pdu received. 29 | */ 30 | private transient Connection connection = null; 31 | 32 | /** 33 | * The received pdu. 34 | */ 35 | private transient PDU pdu = null; 36 | 37 | /** 38 | * Construct event for pdu received over connection belonging 39 | * to the receiver. 40 | */ 41 | public ReceivedPDUEvent(ReceiverBase source, Connection connection, PDU pdu) { 42 | super(source); 43 | this.connection = connection; 44 | this.pdu = pdu; 45 | } 46 | 47 | /** 48 | * Return the connection over which the pdu was received. 49 | */ 50 | public Connection getConnection() { 51 | return connection; 52 | } 53 | 54 | /** 55 | * Return the received pdu. 56 | */ 57 | public PDU getPDU() { 58 | return pdu; 59 | } 60 | 61 | } 62 | /* 63 | * $Log: not supported by cvs2svn $ 64 | * Revision 1.1 2003/07/23 00:28:39 sverkera 65 | * Imported 66 | * 67 | * 68 | * Old changelog: 69 | * 10-10-01 ticp@logica.com connection and pdu carried by the event made transient 70 | * (they are non-serializable) 71 | */ 72 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/SSLConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 2004-jul-12 3 | * 4 | * To change the template for this generated file go to 5 | * Window - Preferences - Java - Code Generation - Code and Comments 6 | */ 7 | package org.smpp; 8 | 9 | import java.io.IOException; 10 | 11 | import javax.net.ServerSocketFactory; 12 | import javax.net.SocketFactory; 13 | import javax.net.ssl.SSLServerSocketFactory; 14 | import javax.net.ssl.SSLSocket; 15 | import javax.net.ssl.SSLSocketFactory; 16 | 17 | /** 18 | * @author Sverker Abrahamsson 19 | * 20 | * To change the template for this generated type comment go to 21 | * Window - Preferences - Java - Code Generation - Code and Comments 22 | */ 23 | public class SSLConnection extends TCPIPConnection { 24 | 25 | /** 26 | * Override the superclass SocketFactory with a SSLSocketFactory 27 | */ 28 | protected SocketFactory socketFactory = SSLSocketFactory.getDefault(); 29 | 30 | /** 31 | * Override the superclass ServerSocketFactory with a SSLServerSocketFactory 32 | */ 33 | protected ServerSocketFactory serverSocketFactory = SSLServerSocketFactory.getDefault(); 34 | 35 | /** 36 | * Initialises the connection with port only, which means that 37 | * the connection will serve as connection receiving server. 38 | * The accepting of the connection must be invoked explicitly by 39 | * calling of accept method. 40 | * 41 | * @param port the port number to listen on 42 | */ 43 | public SSLConnection(int port) { 44 | super(port); 45 | } 46 | 47 | /** 48 | * Initialises the connection for client communication. 49 | * 50 | * @param address the address of the remote end 51 | * of the socket 52 | * @param port the port number on the remote host 53 | */ 54 | public SSLConnection(String address, int port) { 55 | super(address, port); 56 | } 57 | 58 | /** 59 | * Initialises the connection with existing socket. 60 | * It's intended for use with one server connection which generates 61 | * new sockets and creates connections with the sockets. 62 | * 63 | * @param sslsocket the socket to use for communication 64 | * @see #accept() 65 | * @throws IOException 66 | */ 67 | public SSLConnection(SSLSocket sslsocket) throws IOException { 68 | super(sslsocket); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/ServerPDUEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | import org.smpp.pdu.PDU; 14 | 15 | /** 16 | * Instance of this class is created and passed to 17 | * the ServerPDUEventListener by the Receiver. 18 | * 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Revision: 1.2 $ 21 | */ 22 | public class ServerPDUEvent extends ReceivedPDUEvent { 23 | private static final long serialVersionUID = 8400363453588829420L; 24 | 25 | /** 26 | * Creates event for provided Receiver and 27 | * Connection with the received PDU. 28 | */ 29 | public ServerPDUEvent(Receiver source, Connection connection, PDU pdu) { 30 | super(source, connection, pdu); 31 | } 32 | 33 | /** 34 | * Returns the receiver thru which was received the PDU this 35 | * event relates to. 36 | */ 37 | public Receiver getReceiver() { 38 | return (Receiver) getSource(); 39 | } 40 | 41 | } 42 | /* 43 | * $Log: not supported by cvs2svn $ 44 | * Revision 1.1 2003/07/23 00:28:39 sverkera 45 | * Imported 46 | * 47 | */ 48 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/ServerPDUEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | import java.util.EventListener; 14 | 15 | /** 16 | * The interface ServerPDUEventListener defines method for processing 17 | * of PDUs received by the Receiver from the SMSC. 18 | * Implementation of this interface is used when the communication with 19 | * the SMSC is asynchronous. The asynchronous communication means that 20 | * the Session after sending a request to the SMSC doesn't wait for 21 | * a response to the request sent, instead it returns null. All PDUs received from the SMSC, 22 | * i.e both responses to the sent requests and requests sent on behalf of 23 | * the SMSC, are passed to the instance of ServerPDUEventListener 24 | * implementation class. Users of the library are expected to implement 25 | * the listener. 26 | * Important:The handleEvent method is called 27 | * from the receiver's thread context, so the implementation of the listener 28 | * should ensure that there is no deadloock, or at least not too much 29 | * time spent in the method. 30 | * 31 | * @author Logica Mobile Networks SMPP Open Source Team 32 | * @version $Revision: 1.2 $ 33 | * @see Receiver#setServerPDUEventListener(ServerPDUEventListener) 34 | * @see Session#setServerPDUEventListener(ServerPDUEventListener) 35 | */ 36 | public interface ServerPDUEventListener extends EventListener { 37 | /** 38 | * Meant to process PDUs received from the SMSC. 39 | * This method is called by the Receiver whenever a 40 | * PDU is received from the SMSC. 41 | * @param event the event received from the SMSC 42 | */ 43 | public abstract void handleEvent(ServerPDUEvent event); 44 | 45 | } 46 | /* 47 | * $Log: not supported by cvs2svn $ 48 | * Revision 1.1 2003/07/23 00:28:39 sverkera 49 | * Imported 50 | * 51 | */ 52 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/SmppException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | /** 14 | * Class SmppException is the root of all SMPP Library 15 | * exceptions. Every exception defined in the library SmppException 16 | * as a superclass -- this way class SmppException 17 | * provides single class for catch clause. 18 | * 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Id: SmppException.java 72 2008-07-15 19:43:00Z sverkera $ 21 | */ 22 | 23 | public class SmppException extends Exception { 24 | private static final long serialVersionUID = 3108928509613380097L; 25 | 26 | /** 27 | * Constructs a SmppException with no specified detail 28 | * message. 29 | */ 30 | public SmppException() { 31 | super(); 32 | } 33 | 34 | /** 35 | * Constructs a SmppException with a nested exception. 36 | * 37 | * @param e The nested exception 38 | */ 39 | public SmppException(Exception e) { 40 | super(e); 41 | } 42 | 43 | /** 44 | * Constructs a SmppException with the specified detail 45 | * message. 46 | * 47 | * @param s the detail message. 48 | */ 49 | public SmppException(String s) { 50 | super(s); 51 | } 52 | 53 | /** 54 | * Constructs a SmppException with the specified detail 55 | * message and a nested exception 56 | * 57 | * @param s the detail message. 58 | * @param e The nested exception 59 | */ 60 | public SmppException(String s, Exception e) { 61 | super(s, e); 62 | } 63 | } 64 | /* 65 | * $Log: not supported by cvs2svn $ 66 | * Revision 1.2 2003/07/24 14:32:21 sverkera 67 | * Added support for nested exception 68 | * 69 | * Revision 1.1 2003/07/23 00:28:39 sverkera 70 | * Imported 71 | * 72 | */ 73 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/TimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | /** 14 | * Thrown when only a part of PDU was received and the rest of the PDU 15 | * hasn't been received for too long time. 16 | * 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.2 $ 19 | */ 20 | public class TimeoutException extends SmppException { 21 | private static final long serialVersionUID = 4873432724200896611L; 22 | 23 | /** The expired timeout. */ 24 | public long timeout = 0; 25 | 26 | /** The expected bytes. */ 27 | public int expected = 0; 28 | 29 | /** The received bytes. */ 30 | public int received = 0; 31 | 32 | /** Don't allow default constructor */ 33 | @SuppressWarnings("unused") 34 | private TimeoutException() { 35 | } 36 | 37 | /** 38 | * Construct with provided timeout and expected and received amount 39 | * of data. 40 | */ 41 | public TimeoutException(long timeout, int expected, int received) { 42 | super( 43 | "The rest of pdu not received for " 44 | + (timeout / 1000) 45 | + " seconds. " 46 | + "Expected " 47 | + expected 48 | + " bytes, received " 49 | + received 50 | + " bytes."); 51 | this.timeout = timeout; 52 | this.expected = expected; 53 | this.received = received; 54 | } 55 | 56 | } 57 | /* 58 | * $Log: not supported by cvs2svn $ 59 | * Revision 1.1 2003/07/23 00:28:39 sverkera 60 | * Imported 61 | * 62 | * 63 | * Old changelog: 64 | * 01-10-01 ticp@logica.com javadoc wording improved 65 | */ 66 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/Transmitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp; 12 | 13 | import java.io.IOException; 14 | 15 | import org.smpp.pdu.*; 16 | 17 | /** 18 | * Class Transmitter transmits PDUs over connection. 19 | * It is used by Session. 20 | * 21 | * @author Logica Mobile Networks SMPP Open Source Team 22 | * @version $Revision: 1.2 $ 23 | * @see Connection 24 | * @see Receiver 25 | * @see Session 26 | */ 27 | public class Transmitter extends SmppObject { 28 | /** 29 | * The connection object. It is used for transmitting the PDUs. It's 30 | * created outside of the Transmitter and passed to 31 | * transmitter as a constructor parameter. 32 | * @see Connection 33 | */ 34 | private Connection connection = null; 35 | 36 | /** 37 | * Default constructor made protected as it's not desirable to 38 | * allow creation of Transmitter without providing 39 | * Connection. 40 | */ 41 | protected Transmitter() { 42 | } 43 | 44 | /** 45 | * Creates Transmitter which uses provided 46 | * Connection. Typically the connection 47 | * parameter will be an instance of TCPIPConnection class. 48 | * 49 | * @param c connection used for transmitting the PDUs 50 | */ 51 | public Transmitter(Connection c) { 52 | connection = c; 53 | } 54 | 55 | /** 56 | * Assigns unique sequence number to PDU, if necessary, and sends its 57 | * data over connection. 58 | * 59 | * @param pdu the PDU to send 60 | * 61 | * @exception IOException exception during communication 62 | * @exception ValueNotSetException optional param not set but requested 63 | */ 64 | public void send(PDU pdu) throws ValueNotSetException, IOException { 65 | debug.enter(DCOM, this, "send"); 66 | pdu.assignSequenceNumber(); 67 | try { 68 | debug.write(DCOM, "going to send pdu's data over connection"); 69 | connection.send(pdu.getData()); 70 | debug.write(DCOM, "successfully sent pdu's data over connection"); 71 | } finally { 72 | debug.exit(DCOM, this); 73 | } 74 | } 75 | 76 | } 77 | /* 78 | * $Log: not supported by cvs2svn $ 79 | * Revision 1.1 2003/07/23 00:28:39 sverkera 80 | * Imported 81 | * 82 | * 83 | * Old changelog: 84 | * 28-09-01 ticp@logica.com traces added 85 | */ 86 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/debug/Debug.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.debug; 12 | 13 | /** 14 | * The interface Debug is an interface to application specific 15 | * debug information trace facility. Users of the SMPP library can either 16 | * use one of the two implementations of the Debug interface -- 17 | * DefaultDebug or FileDebug or they can implement 18 | * their own class or create an adapter to their legacy trace facility. 19 | * The SMPP library's root class, SmppObject contains 20 | * object of type Debug so that all descendants of the 21 | * SmppObject class can write trace lines. 22 | *
23 | * The interface contains methods to write lines of trace information 24 | * and also support functions to structure the written information according 25 | * function call nesting. Morover, the users can group their tracing 26 | * code to groups according functional areas and turn on and of these 27 | * areas. 28 | * 29 | * @see DefaultDebug 30 | * @see FileDebug 31 | * @see org.smpp.SmppObject 32 | * @see org.smpp.SmppObject#setDebug(Debug) 33 | * @see org.smpp.SmppObject#getDebug() 34 | * 35 | * @author Logica Mobile Networks SMPP Open Source Team 36 | * @version $Revision: 1.1 $ 37 | */ 38 | public interface Debug { 39 | /** 40 | * Used to enter tracing in the function in the class if the provided 41 | * group is turned on. Entering usually means that the trace lines 42 | * indentation increases and the lines get new prefix 43 | * based on the name of the class and the name of the function. 44 | */ 45 | public void enter(int group, Object from, String name); 46 | 47 | /** 48 | * Used to always enter tracing in the function in the class. 49 | * Entering usually means that the trace lines 50 | * indentation increases and the lines get new prefix 51 | * based on the name of the class and the name of the function. 52 | */ 53 | public void enter(Object from, String name); 54 | 55 | /** 56 | * Used to write a line of trace if the provided group is turned on. 57 | */ 58 | public void write(int group, String msg); 59 | 60 | /** 61 | * Used to always write a line of trace. 62 | */ 63 | public void write(String msg); 64 | 65 | /** 66 | * Used to exit tracing in the function in the class if the provided 67 | * group is turned on. Exiting usually means that the trace lines 68 | * indentation decreases and the prefix of lines is restored to 69 | * the value set before call to the corresponding enter. 70 | */ 71 | public void exit(int group, Object from); 72 | 73 | /** 74 | * Used to exit tracing in the function in the class. 75 | * Exiting usually means that the trace lines 76 | * indentation decreases and the prefix of lines is restored to 77 | * the value set before call to the corresponding enter. 78 | */ 79 | public void exit(Object from); 80 | 81 | /** 82 | * Activate the tracing, whatever it means. 83 | */ 84 | public void activate(); 85 | 86 | /** 87 | * Activate the tracing in specified group. 88 | */ 89 | public void activate(int group); 90 | 91 | /** 92 | * Deactivate the tracing, whatever it means. 93 | */ 94 | public void deactivate(); 95 | 96 | /** 97 | * Deactivate the tracing in specified group. 98 | */ 99 | public void deactivate(int group); 100 | 101 | /** 102 | * Returns if the given group is active. 103 | */ 104 | public boolean active(int group); 105 | } 106 | /* 107 | * $Log: not supported by cvs2svn $ 108 | * 109 | * Old changelog: 110 | * 25-09-01 ticp@logica.com added debug groups 111 | * 25-09-01 ticp@logica.com added comments 112 | * 16-10-01 ticp@logica.com added method active(group) 113 | */ 114 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/debug/DefaultDebug.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.debug; 12 | 13 | /** 14 | * Simple implementation of Debug interface which writes 15 | * the trace lines to the System.out and provides simple 16 | * indentation. This is the class whose instance is assigned as a default 17 | * debug class to the SmppObject's debug object. 18 | * 19 | * @see Debug 20 | * @see org.smpp.SmppObject 21 | * 22 | * @author Logica Mobile Networks SMPP Open Source Team 23 | * @version $Revision: 1.1 $ 24 | */ 25 | public class DefaultDebug implements Debug { 26 | private int indent = 0; 27 | private boolean active = false; 28 | 29 | public void enter(int group, Object from, String name) { 30 | enter(from, name); 31 | } 32 | 33 | public void enter(Object from, String name) { 34 | if (active) { 35 | System.out.println(getDelimiter(true, from, name)); 36 | indent++; 37 | } 38 | } 39 | 40 | public void write(int group, String msg) { 41 | write(msg); 42 | } 43 | 44 | public void write(String msg) { 45 | if (active) { 46 | System.out.println(getIndent() + " " + msg); 47 | } 48 | } 49 | 50 | public void exit(int group, Object from) { 51 | exit(from); 52 | } 53 | 54 | public void exit(Object from) { 55 | if (active) { 56 | indent--; 57 | if (indent < 0) { 58 | // it's your fault :-) 59 | indent = 0; 60 | } 61 | System.out.println(getDelimiter(false, from, "")); 62 | } 63 | } 64 | 65 | public void activate() { 66 | active = true; 67 | } 68 | public void activate(int group) { 69 | } 70 | public void deactivate() { 71 | active = false; 72 | } 73 | public void deactivate(int group) { 74 | } 75 | 76 | public boolean active(int group) { 77 | return true; 78 | } 79 | 80 | private String getDelimiter(boolean start, Object from, String name) { 81 | String indentStr = getIndent(); 82 | if (start) { 83 | indentStr += "-> "; 84 | } else { 85 | indentStr += "<- "; 86 | } 87 | return indentStr + from.toString() + (name == "" ? "" : " " + name); 88 | } 89 | 90 | private String getIndent() { 91 | String result = new String(""); 92 | for (int i = 0; i < indent; i++) { 93 | result += " "; 94 | } 95 | return result; 96 | } 97 | } 98 | /* 99 | * $Log: not supported by cvs2svn $ 100 | * 101 | * Old changelog: 102 | * 25-09-01 ticp@logica.com added functions for grouping althoug grouping not 103 | * supported 104 | * 16-10-01 ticp@logica.com added method active(group) 105 | */ 106 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/debug/DefaultEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.debug; 12 | 13 | import java.io.StringWriter; 14 | import java.io.PrintWriter; 15 | 16 | /** 17 | * Simple implementation of Event interface which writes 18 | * the event information to the System.out. This is the class 19 | * whose instance is assigned as a default event class to the 20 | * SmppObject's event object. 21 | * 22 | * @author Logica Mobile Networks SMPP Open Source Team 23 | * @version $Revision: 1.1 $ 24 | */ 25 | public class DefaultEvent implements Event { 26 | private boolean active = false; 27 | 28 | public void write(String msg) { 29 | if (active) { 30 | System.out.println(msg); 31 | } 32 | } 33 | 34 | public void write(Exception e, String msg) { 35 | if (active) { 36 | StringWriter stackOutString = new StringWriter(); 37 | PrintWriter stackOut = new PrintWriter(stackOutString); 38 | e.printStackTrace(stackOut); 39 | try { 40 | write("Exception: " + stackOutString.toString() + " " + msg); 41 | } catch (Exception ex) { 42 | System.err.println("Event log failure " + ex); 43 | } 44 | } 45 | } 46 | 47 | public void activate() { 48 | active = true; 49 | } 50 | public void deactivate() { 51 | active = false; 52 | } 53 | } 54 | /* 55 | * $Log: not supported by cvs2svn $ 56 | * 57 | * Old changelog: 58 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces 59 | */ 60 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/debug/Event.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.debug; 12 | 13 | /** 14 | * The interface Event is an interface to application specific 15 | * event trace facility. It is used in the library to notify about 16 | * like exception. Implementors are expected either to use one of the 17 | * predefined implementations DefaultEvent or 18 | * FileEvent or that the will write an implementation 19 | * which will adapt this interface to their legacy tracing facility. 20 | * 21 | * @author Logica Mobile Networks SMPP Open Source Team 22 | * @version $Revision: 1.1 $ 23 | */ 24 | public interface Event { 25 | /** Sends a message to the event object. */ 26 | public void write(String msg); 27 | 28 | /** Sends an information about exception to the event object. */ 29 | public void write(Exception e, String msg); 30 | 31 | /** Activates the event tracing. */ 32 | public void activate(); 33 | 34 | /** Deactivates the event tracing. */ 35 | public void deactivate(); 36 | } 37 | /* 38 | * $Log: not supported by cvs2svn $ 39 | * 40 | * Old changelog: 41 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces 42 | */ 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/debug/FileEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.debug; 12 | 13 | import java.io.StringWriter; 14 | import java.io.PrintWriter; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class FileEvent implements Event { 21 | private FileLog log = null; 22 | 23 | public FileEvent(String dir, String name) { 24 | log = new FileLog(dir, name); 25 | activate(); 26 | } 27 | 28 | public void write(String msg) { 29 | if (isActive()) { 30 | log.genericWrite(msg == null ? "" : msg); 31 | } 32 | } 33 | 34 | public void write(Exception e, String msg) { 35 | if (isActive()) { 36 | StringWriter stackOutString = new StringWriter(); 37 | PrintWriter stackOut = new PrintWriter(stackOutString); 38 | e.printStackTrace(stackOut); 39 | try { 40 | if (msg != null) { 41 | write(msg); 42 | } 43 | write("Exception: " + stackOutString.toString()); 44 | } catch (Exception ex) { 45 | System.err.println("Event log failure " + ex); 46 | } 47 | } 48 | } 49 | 50 | public void activate() { 51 | if (log != null) 52 | log.activate(); 53 | } 54 | public void deactivate() { 55 | if (log != null) 56 | log.deactivate(); 57 | } 58 | public boolean isActive() { 59 | return (log != null) ? log.isActive() : false; 60 | } 61 | } 62 | /* 63 | * $Log: not supported by cvs2svn $ 64 | * 65 | * Old changelog: 66 | * 01-10-01 ticp@logica.com message passed to write methods can be null now 67 | * 09-10-01 ticp@logica.com when logging exception with extra text message 68 | * message is written on separate line now 69 | */ 70 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/debug/LoggerDebug.java: -------------------------------------------------------------------------------- 1 | package org.smpp.debug; 2 | 3 | import java.util.logging.Level; 4 | import java.util.logging.Logger; 5 | 6 | /** 7 | * Implementation of Debug interface which uses log4j 8 | * logger 9 | * 10 | * @see Debug 11 | * @see org.smpp.SmppObject 12 | * 13 | * @author Sverker Abrahamsson, LimeTransit AB 14 | * @version $Revision: 1.1 $ 15 | */ 16 | 17 | public class LoggerDebug implements Debug { 18 | private Logger logger; 19 | private boolean active = false; 20 | private int indent = 0; 21 | 22 | public LoggerDebug(String category) { 23 | // get logger instance 24 | logger = Logger.getLogger(category); 25 | } 26 | 27 | public LoggerDebug(Logger logger) { 28 | this.logger = logger; 29 | } 30 | 31 | public void enter(int group, Object from, String name) { 32 | enter(from, name); 33 | } 34 | 35 | public void enter(Object from, String name) { 36 | if (active && logger.isLoggable(Level.FINE)) { 37 | logger.fine(getDelimiter(true, from, name)); 38 | indent++; 39 | } 40 | } 41 | 42 | public void write(int group, String msg) { 43 | write(msg); 44 | } 45 | 46 | public void write(String msg) { 47 | if (active && logger.isLoggable(Level.FINE)) { 48 | logger.fine(getIndent() + " " + msg); 49 | } 50 | } 51 | 52 | public void exit(int group, Object from) { 53 | exit(from); 54 | } 55 | 56 | public void exit(Object from) { 57 | if (active) { 58 | indent--; 59 | if (indent < 0) { 60 | // it's your fault :-) 61 | indent = 0; 62 | } 63 | logger.fine(getDelimiter(false, from, "")); 64 | } 65 | } 66 | 67 | public void activate() { 68 | active = true; 69 | } 70 | public void activate(int group) { 71 | } 72 | public void deactivate() { 73 | active = false; 74 | } 75 | public void deactivate(int group) { 76 | } 77 | 78 | public boolean active(int group) { 79 | return true; 80 | } 81 | 82 | private String getDelimiter(boolean start, Object from, String name) { 83 | String indentStr = getIndent(); 84 | if (start) { 85 | indentStr += "-> "; 86 | } else { 87 | indentStr += "<- "; 88 | } 89 | return indentStr + from.toString() + (name == "" ? "" : " " + name); 90 | } 91 | 92 | private String getIndent() { 93 | String result = new String(""); 94 | for (int i = 0; i < indent; i++) { 95 | result += " "; 96 | } 97 | return result; 98 | } 99 | } 100 | /* 101 | * $Log: not supported by cvs2svn $ 102 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/AddressRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class AddressRange extends ByteData { 21 | private byte ton = Data.getDefaultTon(); 22 | private byte npi = Data.getDefaultNpi(); 23 | private String addressRange = Data.DFLT_ADDR_RANGE; 24 | 25 | public AddressRange() { 26 | super(); 27 | setTon(Data.getDefaultTon()); 28 | setNpi(Data.getDefaultNpi()); 29 | } 30 | 31 | public AddressRange(String addressRange) throws WrongLengthOfStringException { 32 | super(); 33 | setTon(Data.getDefaultTon()); 34 | setNpi(Data.getDefaultNpi()); 35 | setAddressRange(addressRange); 36 | } 37 | 38 | public AddressRange(byte ton, byte npi, String addressRange) throws WrongLengthOfStringException { 39 | setTon(ton); 40 | setNpi(npi); 41 | setAddressRange(addressRange); 42 | } 43 | 44 | public void setData(ByteBuffer buffer) 45 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException { 46 | byte ton = buffer.removeByte(); 47 | byte npi = buffer.removeByte(); 48 | String addressRange = buffer.removeCString(); 49 | setAddressRange(addressRange); 50 | setTon(ton); 51 | setNpi(npi); 52 | } 53 | 54 | public ByteBuffer getData() { 55 | ByteBuffer addressBuf = new ByteBuffer(); 56 | addressBuf.appendByte(getTon()); 57 | addressBuf.appendByte(getNpi()); 58 | addressBuf.appendCString(getAddressRange()); 59 | return addressBuf; 60 | } 61 | 62 | public void setTon(byte t) { 63 | ton = t; 64 | } 65 | public void setNpi(byte n) { 66 | npi = n; 67 | } 68 | public void setAddressRange(String a) throws WrongLengthOfStringException { 69 | checkCString(a, Data.SM_ADDR_RANGE_LEN); 70 | addressRange = a; 71 | } 72 | 73 | public byte getTon() { 74 | return ton; 75 | } 76 | public byte getNpi() { 77 | return npi; 78 | } 79 | public String getAddressRange() { 80 | return addressRange; 81 | } 82 | 83 | public String debugString() { 84 | String dbgs = "(addrrang: "; 85 | dbgs += super.debugString(); 86 | dbgs += Integer.toString(getTon()); 87 | dbgs += " "; 88 | dbgs += Integer.toString(getNpi()); 89 | dbgs += " "; 90 | dbgs += getAddressRange(); 91 | dbgs += ") "; 92 | return dbgs; 93 | } 94 | } 95 | /* 96 | * $Log: not supported by cvs2svn $ 97 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/AlertNotification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class AlertNotification extends Request { 21 | public AlertNotification() { 22 | super(Data.ALERT_NOTIFICATION); 23 | } 24 | 25 | protected Response createResponse() { 26 | return null; 27 | } 28 | 29 | public boolean canResponse() { 30 | return false; 31 | } 32 | 33 | public void setBody(ByteBuffer buffer) 34 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 35 | } 36 | 37 | public ByteBuffer getBody() { 38 | return null; 39 | } 40 | 41 | public String debugString() { 42 | String dbgs = "(alertnotification: "; 43 | dbgs += super.debugString(); 44 | dbgs += ") "; 45 | return dbgs; 46 | } 47 | } 48 | /* 49 | * $Log: not supported by cvs2svn $ 50 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | 20 | public class BindReceiver extends BindRequest { 21 | public BindReceiver() { 22 | super(Data.BIND_RECEIVER); 23 | } 24 | 25 | protected Response createResponse() { 26 | return new BindReceiverResp(); 27 | } 28 | 29 | public boolean isTransmitter() { 30 | return false; 31 | } 32 | 33 | public boolean isReceiver() { 34 | return true; 35 | } 36 | } 37 | /* 38 | * $Log: not supported by cvs2svn $ 39 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindReceiverResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | 20 | public class BindReceiverResp extends BindResponse { 21 | public BindReceiverResp() { 22 | super(Data.BIND_RECEIVER_RESP); 23 | } 24 | } 25 | /* 26 | * $Log: not supported by cvs2svn $ 27 | */ 28 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public abstract class BindRequest extends Request { 21 | private String systemId = Data.DFLT_SYSID; 22 | private String password = Data.DFLT_PASS; 23 | private String systemType = Data.DFLT_SYSTYPE; 24 | private AddressRange addressRange = new AddressRange(); 25 | private byte interfaceVersion = Data.SMPP_V34; 26 | 27 | public abstract boolean isTransmitter(); 28 | public abstract boolean isReceiver(); 29 | 30 | public BindRequest(int commandId) { 31 | super(commandId); 32 | } 33 | 34 | public void setBody(ByteBuffer buffer) 35 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 36 | setSystemId(buffer.removeCString()); 37 | setPassword(buffer.removeCString()); 38 | setSystemType(buffer.removeCString()); 39 | setInterfaceVersion(buffer.removeByte()); 40 | addressRange.setData(buffer); 41 | } 42 | 43 | public ByteBuffer getBody() { 44 | ByteBuffer buffer = new ByteBuffer(); 45 | buffer.appendCString(getSystemId()); 46 | buffer.appendCString(getPassword()); 47 | buffer.appendCString(getSystemType()); 48 | buffer.appendByte(getInterfaceVersion()); 49 | buffer.appendBuffer(getAddressRange().getData()); 50 | return buffer; 51 | } 52 | 53 | public void setSystemId(String sysId) throws WrongLengthOfStringException { 54 | checkString(sysId, Data.SM_SYSID_LEN); 55 | systemId = sysId; 56 | } 57 | 58 | public void setPassword(String pwd) throws WrongLengthOfStringException { 59 | checkString(pwd, Data.SM_PASS_LEN); 60 | password = pwd; 61 | } 62 | 63 | public void setSystemType(String type) throws WrongLengthOfStringException { 64 | checkString(type, Data.SM_SYSTYPE_LEN); 65 | systemType = type; 66 | } 67 | 68 | public void setInterfaceVersion(byte vers) { 69 | interfaceVersion = vers; 70 | } 71 | public void setAddressRange(AddressRange adr) { 72 | addressRange = adr; 73 | } 74 | public void setAddressRange(String rangeString) throws WrongLengthOfStringException { 75 | setAddressRange(new AddressRange(rangeString)); 76 | } 77 | public void setAddressRange(byte ton, byte npi, String rangeString) throws WrongLengthOfStringException { 78 | setAddressRange(new AddressRange(ton, npi, rangeString)); 79 | } 80 | 81 | public String getSystemId() { 82 | return systemId; 83 | } 84 | public String getPassword() { 85 | return password; 86 | } 87 | public String getSystemType() { 88 | return systemType; 89 | } 90 | public byte getInterfaceVersion() { 91 | return interfaceVersion; 92 | } 93 | public AddressRange getAddressRange() { 94 | return addressRange; 95 | } 96 | 97 | public String debugString() { 98 | String dbgs = "(bindreq: "; 99 | dbgs += super.debugString(); 100 | dbgs += getSystemId(); 101 | dbgs += " "; 102 | dbgs += getPassword(); 103 | dbgs += " "; 104 | dbgs += getSystemType(); 105 | dbgs += " "; 106 | dbgs += Integer.toString(getInterfaceVersion()); 107 | dbgs += " "; 108 | dbgs += getAddressRange().debugString(); 109 | dbgs += ") "; 110 | return dbgs; 111 | } 112 | } 113 | /* 114 | * $Log: not supported by cvs2svn $ 115 | */ 116 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.pdu.tlv.*; 15 | import org.smpp.util.*; 16 | 17 | /** 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Revision: 1.2 $ 20 | */ 21 | public abstract class BindResponse extends Response { 22 | 23 | // mandatory parameters 24 | private String systemId = Data.DFLT_SYSID; 25 | 26 | // optional parameters 27 | private TLVByte scInterfaceVersion = new TLVByte(Data.OPT_PAR_SC_IF_VER); 28 | 29 | public BindResponse(int commandId) { 30 | super(commandId); 31 | 32 | registerOptional(scInterfaceVersion); 33 | } 34 | 35 | public void setBody(ByteBuffer buffer) 36 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 37 | if (getCommandStatus() == 0) { // ok => have body 38 | setSystemId(buffer.removeCString()); 39 | } 40 | } 41 | 42 | public ByteBuffer getBody() { 43 | ByteBuffer buffer = new ByteBuffer(); 44 | //if (getCommandStatus() == 0) { // ok => append body 45 | buffer.appendCString(getSystemId()); 46 | //} 47 | return buffer; 48 | } 49 | 50 | public void setSystemId(String sysId) throws WrongLengthOfStringException { 51 | checkString(sysId, Data.SM_SYSID_LEN); 52 | systemId = sysId; 53 | } 54 | 55 | public String getSystemId() { 56 | return systemId; 57 | } 58 | 59 | public boolean hasScInterfaceVersion() { 60 | return scInterfaceVersion.hasValue(); 61 | } 62 | 63 | public void setScInterfaceVersion(byte value) { 64 | scInterfaceVersion.setValue(value); 65 | } 66 | 67 | public byte getScInterfaceVersion() throws ValueNotSetException { 68 | return scInterfaceVersion.getValue(); 69 | } 70 | 71 | public String debugString() { 72 | String dbgs = "(bindresp: "; 73 | dbgs += super.debugString(); 74 | dbgs += getSystemId(); 75 | if (hasScInterfaceVersion()) { 76 | dbgs += " "; 77 | try { 78 | dbgs += getScInterfaceVersion(); 79 | } catch (Exception e) { 80 | // don't want to throw exception in debug code! 81 | } 82 | } 83 | dbgs += ") "; 84 | return dbgs; 85 | } 86 | } 87 | /* 88 | * $Log: not supported by cvs2svn $ 89 | * Revision 1.1 2003/07/23 00:28:39 sverkera 90 | * Imported 91 | * 92 | * 93 | * Old changelog: 94 | * 09-10-01 ticp@logica.com ID changed to Id in getSystemID and setSystemID 95 | */ 96 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindTransciever.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class BindTransciever extends BindRequest { 20 | public BindTransciever() { 21 | super(Data.BIND_TRANSCEIVER); 22 | } 23 | 24 | protected Response createResponse() { 25 | return new BindTranscieverResp(); 26 | } 27 | 28 | public boolean isTransmitter() { 29 | return true; 30 | } 31 | 32 | public boolean isReceiver() { 33 | return true; 34 | } 35 | } 36 | /* 37 | * $Log: not supported by cvs2svn $ 38 | */ 39 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindTranscieverResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class BindTranscieverResp extends BindResponse { 20 | public BindTranscieverResp() { 21 | super(Data.BIND_TRANSCEIVER_RESP); 22 | } 23 | } 24 | /* 25 | * $Log: not supported by cvs2svn $ 26 | */ 27 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindTransmitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class BindTransmitter extends BindRequest { 20 | public BindTransmitter() { 21 | super(Data.BIND_TRANSMITTER); 22 | } 23 | 24 | protected Response createResponse() { 25 | return new BindTransmitterResp(); 26 | } 27 | 28 | public boolean isTransmitter() { 29 | return true; 30 | } 31 | 32 | public boolean isReceiver() { 33 | return false; 34 | } 35 | } 36 | /* 37 | * $Log: not supported by cvs2svn $ 38 | */ 39 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/BindTransmitterResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class BindTransmitterResp extends BindResponse { 20 | public BindTransmitterResp() { 21 | super(Data.BIND_TRANSMITTER_RESP); 22 | } 23 | } 24 | /* 25 | * $Log: not supported by cvs2svn $ 26 | */ 27 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/ByteDataList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import java.util.Vector; 14 | 15 | import org.smpp.util.*; 16 | 17 | /** 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Revision: 1.1 $ 20 | */ 21 | public abstract class ByteDataList extends ByteData { 22 | 23 | public final static byte BYTE_SIZE = 1; 24 | public final static byte SHORT_SIZE = 2; 25 | public final static byte INT_SIZE = 4; 26 | 27 | public abstract ByteData createValue(); 28 | 29 | private Vector values = new Vector(); 30 | private int maxSize = 0; 31 | 32 | /** 33 | * Length of the size field when reading from/storing to ByteBuffer. 34 | * Can be only 1, 2 or 4. 35 | */ 36 | private int lengthOfSize = INT_SIZE; 37 | 38 | public ByteDataList() { 39 | } 40 | 41 | public ByteDataList(int max, int lengthOfSize) { 42 | maxSize = max; 43 | if ((lengthOfSize != 1) && (lengthOfSize != 2) && (lengthOfSize != 4)) { 44 | throw new Error("Length of the size field is invalid. " + "Expected 1, 2 or 4 and got " + lengthOfSize); 45 | } 46 | this.lengthOfSize = lengthOfSize; 47 | } 48 | 49 | private void resetValues() { 50 | values.removeAllElements(); 51 | } 52 | 53 | public void setData(ByteBuffer buffer) 54 | throws PDUException, NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, TooManyValuesException { 55 | resetValues(); 56 | int nrValues = 0; 57 | switch (lengthOfSize) { 58 | case BYTE_SIZE : 59 | nrValues = decodeUnsigned(buffer.removeByte()); 60 | break; 61 | case SHORT_SIZE : 62 | nrValues = decodeUnsigned(buffer.removeShort()); 63 | break; 64 | case INT_SIZE : 65 | // won't convert, maybe some other day (does anyone expect 66 | // correct values > 2147483648?) 67 | nrValues = buffer.removeInt(); 68 | break; 69 | } 70 | ByteData value; 71 | for (int i = 0; i < nrValues; i++) { 72 | value = createValue(); 73 | value.setData(buffer); 74 | addValue(value); 75 | } 76 | 77 | } 78 | 79 | public ByteBuffer getData() throws ValueNotSetException // PDUException 80 | { 81 | ByteBuffer buffer = new ByteBuffer(); 82 | int nrValues = getCount(); 83 | switch (lengthOfSize) { 84 | case BYTE_SIZE : 85 | buffer.appendByte(encodeUnsigned((short) nrValues)); 86 | break; 87 | case SHORT_SIZE : 88 | buffer.appendShort(encodeUnsigned((int) nrValues)); 89 | break; 90 | case INT_SIZE : 91 | buffer.appendInt(nrValues); 92 | break; 93 | } 94 | ByteData value; 95 | for (int i = 0; i < nrValues; i++) { 96 | value = getValue(i); 97 | buffer.appendBuffer(value.getData()); 98 | } 99 | return buffer; 100 | } 101 | 102 | public int getCount() { 103 | return values.size(); 104 | } 105 | 106 | public void addValue(ByteData value) throws TooManyValuesException { 107 | if (getCount() >= maxSize) { 108 | throw new TooManyValuesException(); 109 | } 110 | values.add(value); 111 | } 112 | 113 | public ByteData getValue(int i) { 114 | if (i < getCount()) { 115 | return (ByteData) values.get(i); 116 | } else { 117 | return null; 118 | } 119 | } 120 | 121 | public String debugString() { 122 | String dbgs = "(bdlist: "; 123 | dbgs += super.debugString(); 124 | int count = getCount(); 125 | dbgs += "(count: " + count + ") "; 126 | for (int i = 0; i < count; i++) { 127 | ByteData value = getValue(i); 128 | dbgs += (i + 1) + ": " + value.debugString(); 129 | dbgs += " "; 130 | } 131 | dbgs += ") "; 132 | return dbgs; 133 | } 134 | } 135 | /* 136 | * $Log: not supported by cvs2svn $ 137 | * 138 | * Old changelog: 139 | * 01-11-01 ticp@logica.com better handling of lengths, now can specify size of 140 | * length field, fixed bug related to the unsigned value 141 | * stoed in signed Java integral variable 142 | */ 143 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/CancelSM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | 21 | public class CancelSM extends Request { 22 | private String serviceType = Data.DFLT_SRVTYPE; 23 | private String messageId = Data.DFLT_MSGID; 24 | private Address sourceAddr = new Address(); 25 | private Address destAddr = new Address(); 26 | 27 | public CancelSM() { 28 | super(Data.CANCEL_SM); 29 | } 30 | 31 | protected Response createResponse() { 32 | return new CancelSMResp(); 33 | } 34 | 35 | public void setBody(ByteBuffer buffer) 36 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 37 | setServiceType(buffer.removeCString()); 38 | setMessageId(buffer.removeCString()); 39 | sourceAddr.setData(buffer); // ? 40 | destAddr.setData(buffer); // ? 41 | } 42 | 43 | public ByteBuffer getBody() { 44 | ByteBuffer buffer = new ByteBuffer(); 45 | buffer.appendCString(getServiceType()); 46 | buffer.appendCString(messageId); 47 | buffer.appendBuffer(getSourceAddr().getData()); 48 | buffer.appendBuffer(getDestAddr().getData()); 49 | return buffer; 50 | } 51 | 52 | public void setServiceType(String value) throws WrongLengthOfStringException { 53 | checkCString(value, Data.SM_SRVTYPE_LEN); 54 | serviceType = value; 55 | } 56 | 57 | public void setMessageId(String value) throws WrongLengthOfStringException { 58 | checkString(value, Data.SM_MSGID_LEN); 59 | messageId = value; 60 | } 61 | 62 | public void setSourceAddr(Address value) { 63 | sourceAddr = value; 64 | } 65 | public void setSourceAddr(String address) throws WrongLengthOfStringException { 66 | setSourceAddr(new Address(address)); 67 | } 68 | public void setSourceAddr(byte ton, byte npi, String address) throws WrongLengthOfStringException { 69 | setSourceAddr(new Address(ton, npi, address)); 70 | } 71 | 72 | public void setDestAddr(Address value) { 73 | destAddr = value; 74 | } 75 | public void setDestAddr(String address) throws WrongLengthOfStringException { 76 | setDestAddr(new Address(address)); 77 | } 78 | public void setDestAddr(byte ton, byte npi, String address) throws WrongLengthOfStringException { 79 | setDestAddr(new Address(ton, npi, address)); 80 | } 81 | 82 | public String getServiceType() { 83 | return serviceType; 84 | } 85 | public String getMessageId() { 86 | return messageId; 87 | } 88 | public Address getSourceAddr() { 89 | return sourceAddr; 90 | } 91 | public Address getDestAddr() { 92 | return destAddr; 93 | } 94 | 95 | public String debugString() { 96 | String dbgs = "(cancel: "; 97 | dbgs += super.debugString(); 98 | dbgs += getServiceType(); 99 | dbgs += " "; 100 | dbgs += getMessageId(); 101 | dbgs += " "; 102 | dbgs += getSourceAddr().debugString(); 103 | dbgs += " "; 104 | dbgs += getDestAddr().debugString(); 105 | dbgs += ") "; 106 | return dbgs; 107 | } 108 | } 109 | /* 110 | * $Log: not supported by cvs2svn $ 111 | */ 112 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/CancelSMResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | 21 | public class CancelSMResp extends Response { 22 | public CancelSMResp() { 23 | super(Data.CANCEL_SM_RESP); 24 | } 25 | 26 | public void setBody(ByteBuffer buffer) 27 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 28 | } 29 | 30 | public ByteBuffer getBody() { 31 | return null; 32 | } 33 | 34 | public String debugString() { 35 | String dbgs = "(cancel_resp: "; 36 | dbgs += super.debugString(); 37 | dbgs += ") "; 38 | return dbgs; 39 | } 40 | } 41 | /* 42 | * $Log: not supported by cvs2svn $ 43 | */ 44 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/DataSMResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.pdu.ValueNotSetException; 15 | import org.smpp.pdu.tlv.*; 16 | import org.smpp.util.*; 17 | 18 | /** 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Revision: 1.1 $ 21 | */ 22 | public class DataSMResp extends Response { 23 | 24 | // mandatory parameters 25 | private String messageId = Data.DFLT_MSGID; 26 | 27 | // optional parameters 28 | private TLVByte deliveryFailureReason = new TLVByte(Data.OPT_PAR_DEL_FAIL_RSN); 29 | private TLVOctets networkErrorCode = 30 | new TLVOctets(Data.OPT_PAR_NW_ERR_CODE, Data.OPT_PAR_NW_ERR_CODE_MIN, Data.OPT_PAR_NW_ERR_CODE_MAX); 31 | // exactly 3 32 | private TLVString additionalStatusInfoText = 33 | new TLVString(Data.OPT_PAR_ADD_STAT_INFO, Data.OPT_PAR_ADD_STAT_INFO_MIN, Data.OPT_PAR_ADD_STAT_INFO_MAX); 34 | private TLVByte dpfResult = new TLVByte(Data.OPT_PAR_DPF_RES); 35 | 36 | public DataSMResp() { 37 | super(Data.DATA_SM_RESP); 38 | 39 | registerOptional(deliveryFailureReason); 40 | registerOptional(networkErrorCode); 41 | registerOptional(additionalStatusInfoText); 42 | registerOptional(dpfResult); 43 | } 44 | 45 | public void setBody(ByteBuffer buffer) 46 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 47 | setMessageId(buffer.removeCString()); 48 | } 49 | 50 | public ByteBuffer getBody() { 51 | ByteBuffer buffer = new ByteBuffer(); 52 | buffer.appendCString(messageId); 53 | return buffer; 54 | } 55 | 56 | public void setMessageId(String value) throws WrongLengthOfStringException { 57 | checkString(value, Data.SM_MSGID_LEN); 58 | messageId = value; 59 | } 60 | 61 | public String getMessageId() { 62 | return messageId; 63 | } 64 | 65 | public boolean hasDeliveryFailureReason() { 66 | return deliveryFailureReason.hasValue(); 67 | } 68 | public boolean hasNetworkErrorCode() { 69 | return networkErrorCode.hasValue(); 70 | } 71 | public boolean hasAdditionalStatusInfoText() { 72 | return additionalStatusInfoText.hasValue(); 73 | } 74 | public boolean hasDpfResult() { 75 | return dpfResult.hasValue(); 76 | } 77 | 78 | public void setDeliveryFailureReason(byte value) { 79 | deliveryFailureReason.setValue(value); 80 | } 81 | public void setNetworkErrorCode(ByteBuffer value) { 82 | networkErrorCode.setValue(value); 83 | } 84 | public void setAdditionalStatusInfoText(String value) throws WrongLengthException { 85 | additionalStatusInfoText.setValue(value); 86 | } 87 | public void setDpfResult(byte value) { 88 | dpfResult.setValue(value); 89 | } 90 | 91 | public byte getDeliveryFailureReason() throws ValueNotSetException { 92 | return deliveryFailureReason.getValue(); 93 | } 94 | 95 | public ByteBuffer getNetworkErrorCode() throws ValueNotSetException { 96 | return networkErrorCode.getValue(); 97 | } 98 | 99 | public String getAdditionalStatusInfoText() throws ValueNotSetException { 100 | return additionalStatusInfoText.getValue(); 101 | } 102 | 103 | public byte getDpfResult() throws ValueNotSetException { 104 | return dpfResult.getValue(); 105 | } 106 | 107 | public String debugString() { 108 | String dbgs = "(data_resp: "; 109 | dbgs += super.debugString(); 110 | dbgs += getMessageId(); 111 | dbgs += " "; 112 | dbgs += debugStringOptional(); 113 | dbgs += ") "; 114 | return dbgs; 115 | } 116 | } 117 | /* 118 | * $Log: not supported by cvs2svn $ 119 | */ 120 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/DeliverSMResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class DeliverSMResp extends Response { 21 | private String messageId = Data.DFLT_MSGID; 22 | 23 | public DeliverSMResp() { 24 | super(Data.DELIVER_SM_RESP); 25 | } 26 | 27 | public void setBody(ByteBuffer buffer) 28 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException { 29 | setMessageId(buffer.removeCString()); 30 | } 31 | 32 | public ByteBuffer getBody() { 33 | ByteBuffer buffer = new ByteBuffer(); 34 | buffer.appendCString(messageId); 35 | return buffer; 36 | } 37 | 38 | public void setMessageId(String value) throws WrongLengthOfStringException { 39 | checkString(value, Data.SM_MSGID_LEN); 40 | messageId = value; 41 | } 42 | 43 | public String getMessageId() { 44 | return messageId; 45 | } 46 | 47 | public String debugString() { 48 | String dbgs = "(deliver_resp: "; 49 | dbgs += super.debugString(); 50 | dbgs += getMessageId(); 51 | dbgs += " "; 52 | dbgs += debugStringOptional(); 53 | dbgs += ") "; 54 | return dbgs; 55 | } 56 | } 57 | /* 58 | * $Log: not supported by cvs2svn $ 59 | */ 60 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/DestinationAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class DestinationAddress extends ByteData { 21 | private byte destFlag = Data.DFLT_DEST_FLAG; 22 | private ByteData theAddress = null; // either Address or DistributionList 23 | 24 | public DestinationAddress() { 25 | } 26 | 27 | public DestinationAddress(Address address) { 28 | setAddress(address); 29 | } 30 | 31 | // it's more likely that this will be used with device address 32 | // than with distribution list 33 | public DestinationAddress(String address) throws WrongLengthOfStringException { 34 | setAddress(new Address(address)); 35 | } 36 | 37 | public DestinationAddress(byte ton, byte npi, String address) throws WrongLengthOfStringException { 38 | setAddress(new Address(ton, npi, address)); 39 | } 40 | 41 | public DestinationAddress(DistributionList dl) { 42 | setDistributionList(dl); 43 | } 44 | 45 | public void setData(ByteBuffer buffer) 46 | throws 47 | NotEnoughDataInByteBufferException, 48 | TerminatingZeroNotFoundException, 49 | WrongLengthOfStringException, 50 | WrongDestFlagException { 51 | destFlag = buffer.removeByte(); 52 | switch (destFlag) { 53 | case Data.SM_DEST_SME_ADDRESS : 54 | { 55 | Address address = new Address(); 56 | address.setData(buffer); 57 | setAddress(address); 58 | break; 59 | } 60 | case Data.SM_DEST_DL_NAME : 61 | { 62 | DistributionList dl = new DistributionList(); 63 | dl.setData(buffer); 64 | setDistributionList(dl); 65 | break; 66 | } 67 | default : 68 | { 69 | throw new WrongDestFlagException("" + destFlag); 70 | } 71 | } 72 | } 73 | 74 | public ByteBuffer getData() throws ValueNotSetException { 75 | if (hasValue()) { 76 | ByteBuffer buffer = new ByteBuffer(); 77 | buffer.appendByte(getDestFlag()); 78 | if (isAddress()) { 79 | Address address = getAddress(); 80 | buffer.appendBuffer(address.getData()); 81 | } else if (isDistributionList()) { 82 | DistributionList dl = getDistributionList(); 83 | buffer.appendBuffer(dl.getData()); 84 | } 85 | return buffer; 86 | } else { 87 | throw new ValueNotSetException(); 88 | } 89 | } 90 | 91 | public void setAddress(Address address) { 92 | destFlag = Data.SM_DEST_SME_ADDRESS; 93 | theAddress = address; 94 | } 95 | 96 | public void setDistributionList(DistributionList dl) { 97 | destFlag = Data.SM_DEST_DL_NAME; 98 | theAddress = dl; 99 | } 100 | 101 | public byte getDestFlag() { 102 | return destFlag; 103 | } 104 | public ByteData getTheAddress() { 105 | return theAddress; 106 | } 107 | public Address getAddress() { 108 | if (isAddress()) { 109 | return (Address) theAddress; 110 | } else { 111 | return null; 112 | } 113 | } 114 | 115 | public DistributionList getDistributionList() { 116 | if (isDistributionList()) { 117 | return (DistributionList) theAddress; 118 | } else { 119 | return null; 120 | } 121 | } 122 | 123 | public boolean hasValue() { 124 | return destFlag != Data.DFLT_DEST_FLAG; 125 | } 126 | public boolean isAddress() { 127 | return destFlag == Data.SM_DEST_SME_ADDRESS; 128 | } 129 | public boolean isDistributionList() { 130 | return destFlag == Data.SM_DEST_DL_NAME; 131 | } 132 | 133 | public String debugString() { 134 | String dbgs = "(destaddr: "; 135 | dbgs += super.debugString(); 136 | dbgs += Integer.toString(getDestFlag()); 137 | dbgs += " "; 138 | dbgs += getTheAddress().debugString(); 139 | dbgs += ") "; 140 | return dbgs; 141 | } 142 | } 143 | /* 144 | * $Log: not supported by cvs2svn $ 145 | */ 146 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/DistributionList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class DistributionList extends ByteData { 21 | private String dlName = Data.DFLT_DL_NAME; 22 | 23 | public DistributionList() { 24 | } 25 | 26 | public DistributionList(String dlName) throws WrongLengthOfStringException { 27 | setDlName(dlName); 28 | } 29 | 30 | public void setData(ByteBuffer buffer) 31 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException { 32 | setDlName(buffer.removeCString()); 33 | } 34 | 35 | public ByteBuffer getData() { 36 | ByteBuffer buffer = new ByteBuffer(); 37 | buffer.appendCString(getDlName()); 38 | return buffer; 39 | } 40 | 41 | public void setDlName(String dln) throws WrongLengthOfStringException { 42 | checkCString(dln, Data.SM_DL_NAME_LEN); 43 | dlName = dln; 44 | } 45 | 46 | public String getDlName() { 47 | return dlName; 48 | } 49 | 50 | public String debugString() { 51 | String dbgs = "(dl: "; 52 | dbgs += super.debugString(); 53 | dbgs += getDlName(); 54 | dbgs += ") "; 55 | return dbgs; 56 | } 57 | } 58 | /* 59 | * $Log: not supported by cvs2svn $ 60 | */ 61 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/EnquireLink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class EnquireLink extends Request { 21 | public EnquireLink() { 22 | super(Data.ENQUIRE_LINK); 23 | } 24 | 25 | protected Response createResponse() { 26 | return new EnquireLinkResp(); 27 | } 28 | 29 | public void setBody(ByteBuffer buffer) 30 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 31 | } 32 | 33 | public ByteBuffer getBody() { 34 | return null; 35 | } 36 | 37 | public String debugString() { 38 | String dbgs = "(enquirelink: "; 39 | dbgs += super.debugString(); 40 | dbgs += ") "; 41 | return dbgs; 42 | } 43 | } 44 | /* 45 | * $Log: not supported by cvs2svn $ 46 | */ 47 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/EnquireLinkResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class EnquireLinkResp extends Response { 21 | public EnquireLinkResp() { 22 | super(Data.ENQUIRE_LINK_RESP); 23 | } 24 | 25 | public void setBody(ByteBuffer buffer) 26 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 27 | } 28 | 29 | public ByteBuffer getBody() { 30 | return null; 31 | } 32 | 33 | public String debugString() { 34 | String dbgs = "(enquirelink_resp: "; 35 | dbgs += super.debugString(); 36 | dbgs += ") "; 37 | return dbgs; 38 | } 39 | } 40 | /* 41 | * $Log: not supported by cvs2svn $ 42 | */ 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/GenericNack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class GenericNack extends Response { 21 | public GenericNack() { 22 | super(Data.GENERIC_NACK); 23 | } 24 | 25 | public GenericNack(int commandStatus, int sequenceNumber) { 26 | super(Data.GENERIC_NACK); 27 | setCommandStatus(commandStatus); 28 | setSequenceNumber(sequenceNumber); 29 | } 30 | 31 | public void setBody(ByteBuffer buffer) 32 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 33 | } 34 | 35 | public ByteBuffer getBody() { 36 | return null; 37 | } 38 | 39 | public String debugString() { 40 | String dbgs = "(genericnack: "; 41 | dbgs += super.debugString(); 42 | dbgs += ")"; 43 | return dbgs; 44 | } 45 | 46 | } 47 | /* 48 | * $Log: not supported by cvs2svn $ 49 | */ 50 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/HeaderIncompleteException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | /** 14 | * @author Logica Mobile Networks SMPP Open Source Team 15 | * @version $Revision: 1.1 $ 16 | */ 17 | public class HeaderIncompleteException extends PDUException { 18 | private static final long serialVersionUID = 3813030249230646966L; 19 | } 20 | /* 21 | * $Log: not supported by cvs2svn $ 22 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/IntegerOutOfRangeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class IntegerOutOfRangeException extends PDUException { 20 | private static final long serialVersionUID = 750364511680192335L; 21 | 22 | public IntegerOutOfRangeException() { 23 | super("The integer is lower or greater than required."); 24 | setErrorCode(Data.ESME_RINVPARAM); 25 | } 26 | 27 | public IntegerOutOfRangeException(int min, int max, int val) { 28 | super("The integer is lower or greater than required: " + " min=" + min + " max=" + max + " actual=" + val + "."); 29 | setErrorCode(Data.ESME_RINVPARAM); 30 | } 31 | } 32 | /* 33 | * $Log: not supported by cvs2svn $ 34 | */ 35 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/InvalidPDUException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.2 $ 18 | */ 19 | public class InvalidPDUException extends PDUException { 20 | private static final long serialVersionUID = -6985061862208729984L; 21 | private Exception underlyingException = null; 22 | 23 | public InvalidPDUException(PDU pdu, Exception e) { 24 | super(pdu, e); 25 | underlyingException = e; 26 | setErrorCode(Data.ESME_RINVMSGLEN); 27 | } 28 | 29 | public InvalidPDUException(PDU pdu, String s) { 30 | super(pdu, s); 31 | setErrorCode(Data.ESME_RINVMSGLEN); 32 | } 33 | 34 | public String toString() { 35 | String s = super.toString(); 36 | if (underlyingException != null) { 37 | s += "\nUnderlying exception: " + underlyingException.toString(); 38 | } 39 | return s; 40 | } 41 | 42 | public Exception getException() { 43 | return underlyingException; 44 | } 45 | } 46 | /* 47 | * $Log: not supported by cvs2svn $ 48 | * Revision 1.1 2003/07/23 00:28:39 sverkera 49 | * Imported 50 | * 51 | */ 52 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/MessageIncompleteException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | /** 14 | * @author Logica Mobile Networks SMPP Open Source Team 15 | * @version $Revision: 1.1 $ 16 | */ 17 | public class MessageIncompleteException extends PDUException { 18 | private static final long serialVersionUID = 9081917316954328823L; 19 | } 20 | /* 21 | * $Log: not supported by cvs2svn $ 22 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/Outbind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class Outbind extends Request { 21 | private String systemId = Data.DFLT_SYSID; 22 | private String password = Data.DFLT_PASS; 23 | 24 | public Outbind() { 25 | super(Data.OUTBIND); 26 | } 27 | 28 | protected Response createResponse() { 29 | return null; 30 | } 31 | 32 | public boolean canResponse() { 33 | return false; 34 | } 35 | 36 | public void setBody(ByteBuffer buffer) 37 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 38 | setSystemId(buffer.removeCString()); 39 | setPassword(buffer.removeCString()); 40 | } 41 | 42 | public ByteBuffer getBody() { 43 | ByteBuffer buffer = new ByteBuffer(); 44 | buffer.appendCString(getSystemId()); 45 | buffer.appendCString(getPassword()); 46 | return buffer; 47 | } 48 | 49 | public void setSystemId(String sysId) throws WrongLengthOfStringException { 50 | checkString(sysId, Data.SM_SYSID_LEN); 51 | systemId = sysId; 52 | } 53 | 54 | public void setPassword(String pwd) throws WrongLengthOfStringException { 55 | checkString(pwd, Data.SM_PASS_LEN); 56 | password = pwd; 57 | } 58 | 59 | public String getSystemId() { 60 | return systemId; 61 | } 62 | public String getPassword() { 63 | return password; 64 | } 65 | 66 | public String debugString() { 67 | String dbgs = "(outbind: "; 68 | dbgs += super.debugString(); 69 | dbgs += getSystemId(); 70 | dbgs += " "; 71 | dbgs += getPassword(); 72 | dbgs += ")"; 73 | return dbgs; 74 | } 75 | 76 | // special equals() for outbind: as we don't care 77 | // about outbind's sequence number, any outbind is equal to 78 | // any other outbind, sort of :-) 79 | public boolean equals(Object object) { 80 | if (object == null) { 81 | return false; 82 | } else { 83 | PDU pdu = (PDU) object; 84 | return pdu.getCommandId() == getCommandId(); 85 | } 86 | } 87 | 88 | } 89 | /* 90 | * $Log: not supported by cvs2svn $ 91 | */ 92 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/PDUException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.SmppException; 15 | 16 | /** 17 | * Incorrect format of PDU passed as a parameter or received from SMSC. 18 | * 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Revision: 1.2 $ 21 | */ 22 | public class PDUException extends SmppException { 23 | private static final long serialVersionUID = 5174606627714918071L; 24 | private transient PDU pdu = null; 25 | private transient int errorCode = Data.ESME_RUNKNOWNERR; 26 | 27 | public PDUException() { 28 | } 29 | 30 | public PDUException(PDU pdu) { 31 | setPDU(pdu); 32 | } 33 | 34 | public PDUException(String s) { 35 | super(s); 36 | } 37 | 38 | public PDUException(PDU pdu, String s) { 39 | super(s); 40 | setPDU(pdu); 41 | } 42 | 43 | public PDUException(PDU pdu, Exception e) { 44 | super(e); 45 | setPDU(pdu); 46 | } 47 | 48 | public PDUException(PDU pdu, String s, Exception e) { 49 | super(s, e); 50 | setPDU(pdu); 51 | } 52 | 53 | public String toString() { 54 | String s = super.toString(); 55 | if (pdu != null) { 56 | s += "\nPDU debug string: " + pdu.debugString(); 57 | } 58 | return s; 59 | } 60 | 61 | public void setPDU(PDU pdu) { 62 | this.pdu = pdu; 63 | } 64 | public PDU getPDU() { 65 | return pdu; 66 | } 67 | public boolean hasPDU() { 68 | return pdu != null; 69 | } 70 | 71 | public void setErrorCode(int errorCode) { 72 | this.errorCode = errorCode; 73 | } 74 | public int getErrorCode() { 75 | return errorCode; 76 | } 77 | } 78 | /* 79 | * $Log: not supported by cvs2svn $ 80 | * Revision 1.1 2003/07/23 00:28:39 sverkera 81 | * Imported 82 | * 83 | * 84 | * Old changelog: 85 | * 10-10-01 ticp@logica.com pdu carried by the exception made transient 86 | * (it is not serializable) 87 | */ 88 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/PDUHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.util.ByteBuffer; 14 | import org.smpp.util.NotEnoughDataInByteBufferException; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class PDUHeader extends ByteData { 21 | private int commandLength = 0; 22 | private int commandId = 0; 23 | private int commandStatus = 0; 24 | private int sequenceNumber = 1; 25 | 26 | public ByteBuffer getData() { 27 | ByteBuffer buffer = new ByteBuffer(); 28 | buffer.appendInt(getCommandLength()); 29 | buffer.appendInt(getCommandId()); 30 | buffer.appendInt(getCommandStatus()); 31 | buffer.appendInt(getSequenceNumber()); 32 | return buffer; 33 | } 34 | 35 | public void setData(ByteBuffer buffer) throws NotEnoughDataInByteBufferException { 36 | commandLength = buffer.removeInt(); 37 | commandId = buffer.removeInt(); 38 | commandStatus = buffer.removeInt(); 39 | sequenceNumber = buffer.removeInt(); 40 | } 41 | 42 | public int getCommandLength() { 43 | return commandLength; 44 | } 45 | 46 | public int getCommandId() { 47 | return commandId; 48 | } 49 | 50 | public int getCommandStatus() { 51 | return commandStatus; 52 | } 53 | 54 | public int getSequenceNumber() { 55 | return sequenceNumber; 56 | } 57 | 58 | public void setCommandLength(int cmdLen) { 59 | commandLength = cmdLen; 60 | } 61 | 62 | public void setCommandId(int cmdId) { 63 | commandId = cmdId; 64 | } 65 | 66 | public void setCommandStatus(int cmdStatus) { 67 | commandStatus = cmdStatus; 68 | } 69 | 70 | public void setSequenceNumber(int seqNr) { 71 | sequenceNumber = seqNr; 72 | } 73 | } 74 | /* 75 | * $Log: not supported by cvs2svn $ 76 | */ 77 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/QuerySM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class QuerySM extends Request { 21 | private String messageId = Data.DFLT_MSGID; 22 | private Address sourceAddr = new Address(); 23 | 24 | public QuerySM() { 25 | super(Data.QUERY_SM); 26 | } 27 | 28 | protected Response createResponse() { 29 | return new QuerySMResp(); 30 | } 31 | 32 | public void setBody(ByteBuffer buffer) 33 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 34 | setMessageId(buffer.removeCString()); 35 | sourceAddr.setData(buffer); // ? 36 | } 37 | 38 | public ByteBuffer getBody() { 39 | ByteBuffer buffer = new ByteBuffer(); 40 | buffer.appendCString(messageId); 41 | buffer.appendBuffer(getSourceAddr().getData()); 42 | return buffer; 43 | } 44 | public void setMessageId(String value) throws WrongLengthOfStringException { 45 | checkString(value, Data.SM_MSGID_LEN); 46 | messageId = value; 47 | } 48 | 49 | public void setSourceAddr(Address value) { 50 | sourceAddr = value; 51 | } 52 | public void setSourceAddr(String address) throws WrongLengthOfStringException { 53 | setSourceAddr(new Address(address)); 54 | } 55 | 56 | public void setSourceAddr(byte ton, byte npi, String address) throws WrongLengthOfStringException { 57 | setSourceAddr(new Address(ton, npi, address)); 58 | } 59 | 60 | public String getMessageId() { 61 | return messageId; 62 | } 63 | public Address getSourceAddr() { 64 | return sourceAddr; 65 | } 66 | 67 | public String debugString() { 68 | String dbgs = "(query: "; 69 | dbgs += super.debugString(); 70 | dbgs += getMessageId(); 71 | dbgs += " "; 72 | dbgs += getSourceAddr().debugString(); 73 | dbgs += " "; 74 | dbgs += debugStringOptional(); 75 | dbgs += ") "; 76 | return dbgs; 77 | } 78 | } 79 | /* 80 | * $Log: not supported by cvs2svn $ 81 | */ 82 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/QuerySMResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class QuerySMResp extends Response { 21 | private String messageId = Data.DFLT_MSGID; 22 | private String finalDate = Data.DFLT_DATE; //1 or 17 23 | private byte messageState = Data.DFLT_MSG_STATE; 24 | private byte errorCode = Data.DFLT_ERR; 25 | 26 | public QuerySMResp() { 27 | super(Data.QUERY_SM_RESP); 28 | } 29 | 30 | public void setBody(ByteBuffer buffer) 31 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 32 | setMessageId(buffer.removeCString()); 33 | setFinalDate(buffer.removeCString()); 34 | setMessageState(buffer.removeByte()); 35 | setErrorCode(buffer.removeByte()); 36 | } 37 | 38 | public ByteBuffer getBody() { 39 | ByteBuffer buffer = new ByteBuffer(); 40 | buffer.appendCString(getMessageId()); 41 | buffer.appendCString(getFinalDate()); 42 | buffer.appendByte(getMessageState()); 43 | buffer.appendByte(getErrorCode()); 44 | return buffer; 45 | } 46 | 47 | public void setMessageId(String value) throws WrongLengthOfStringException { 48 | checkString(value, Data.SM_MSGID_LEN); 49 | messageId = value; 50 | } 51 | 52 | public void setFinalDate(String value) throws WrongDateFormatException { 53 | checkDate(value); 54 | finalDate = value; 55 | } 56 | 57 | public void setMessageState(byte value) { 58 | messageState = value; 59 | } 60 | public void setErrorCode(byte value) { 61 | errorCode = value; 62 | } 63 | 64 | public String getMessageId() { 65 | return messageId; 66 | } 67 | public String getFinalDate() { 68 | return finalDate; 69 | } 70 | public byte getMessageState() { 71 | return messageState; 72 | } 73 | public byte getErrorCode() { 74 | return errorCode; 75 | } 76 | 77 | public String debugString() { 78 | String dbgs = "(query_resp: "; 79 | dbgs += super.debugString(); 80 | dbgs += getMessageId(); 81 | dbgs += " "; 82 | dbgs += getFinalDate(); 83 | dbgs += " "; 84 | dbgs += getMessageState(); 85 | dbgs += " "; 86 | dbgs += getErrorCode(); 87 | dbgs += " "; 88 | dbgs += debugStringOptional(); 89 | dbgs += ") "; 90 | return dbgs; 91 | } 92 | } 93 | /* 94 | * $Log: not supported by cvs2svn $ 95 | */ 96 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/ReplaceSMResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class ReplaceSMResp extends Response { 21 | public ReplaceSMResp() { 22 | super(Data.REPLACE_SM_RESP); 23 | } 24 | 25 | public void setBody(ByteBuffer buffer) 26 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 27 | } 28 | 29 | public ByteBuffer getBody() { 30 | return null; 31 | } 32 | 33 | public String debugString() { 34 | String dbgs = "(replace_resp: "; 35 | dbgs += super.debugString(); 36 | dbgs += ") "; 37 | return dbgs; 38 | } 39 | } 40 | /* 41 | * $Log: not supported by cvs2svn $ 42 | */ 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/Request.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | /** 14 | * Represents a PDU request. All classes which are used as SMPP requests are 15 | * derived from this class. 16 | * 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public abstract class Request extends PDU { 21 | /** 22 | * This method should instantiate a response corresponding to the request. 23 | */ 24 | protected abstract Response createResponse(); 25 | 26 | /** Create a request PDU with default parameters. */ 27 | public Request() { 28 | } 29 | 30 | /** 31 | * Create request PDU with given command id. 32 | * Derived classes usually uses super(THE_COMMAND_ID) 33 | * where the THE_COMMAND_ID is the command id of the 34 | * PDU the derived class represents. 35 | */ 36 | public Request(int commandId) { 37 | super(commandId); 38 | } 39 | 40 | /** 41 | * This method is used to create generate a response corresponding to 42 | * this request. It creates the response using createResponse 43 | * and then sets the sequence number of the response to the sequence 44 | * number of this request. This way is ensured automatic matching 45 | * of the response to the request. 46 | * The created response is set this as the original request. 47 | * @see #createResponse() 48 | * @see Response#setOriginalRequest(Request) 49 | */ 50 | public Response getResponse() { 51 | Response response = createResponse(); 52 | response.setSequenceNumber(getSequenceNumber()); 53 | response.setOriginalRequest(this); 54 | return response; 55 | } 56 | 57 | /** 58 | * Returns the command id of the corresponing response. 59 | */ 60 | public int getResponseCommandId() { 61 | Response response = createResponse(); 62 | return response.getCommandId(); 63 | } 64 | 65 | /** 66 | * Returns true. If the derived class cannot respond, then it must 67 | * overwrite this function to return false. 68 | * @see PDU#canResponse() 69 | */ 70 | public boolean canResponse() { 71 | return true; 72 | } 73 | 74 | /** 75 | * Returns true. 76 | * @see PDU#isRequest() 77 | */ 78 | public boolean isRequest() { 79 | return true; 80 | } 81 | 82 | /** Returns false. 83 | * @see PDU#isResponse() 84 | */ 85 | public boolean isResponse() { 86 | return false; 87 | } 88 | } 89 | /* 90 | * $Log: not supported by cvs2svn $ 91 | * 92 | * Old changelog: 93 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces 94 | * 09-10-01 ticp@logica.com added registration of the request as original request 95 | * to the response created by getResponse 96 | */ 97 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.pdu.PDU; 14 | 15 | /** 16 | * Represents a PDU response. All classes which are used as SMPP response are 17 | * derived from this class. 18 | * 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Revision: 1.1 $ 21 | */ 22 | public abstract class Response extends PDU { 23 | /** 24 | * The original request which this response relates to. 25 | * @see Request#getResponse() 26 | */ 27 | private Request originalRequest = null; 28 | 29 | /** Create a request PDU with default parameters. */ 30 | public Response() { 31 | } 32 | 33 | /** 34 | * Create response PDU with given command id. 35 | * Derived classes usually uses super(THE_COMMAND_ID) 36 | * where the THE_COMMAND_ID is the command id of the 37 | * PDU the derived class represents. 38 | */ 39 | public Response(int commandId) { 40 | super(commandId); 41 | } 42 | 43 | /** 44 | * Returns false as there can be no response to a response. 45 | * @see PDU#canResponse() 46 | */ 47 | public boolean canResponse() { 48 | return false; 49 | } 50 | 51 | /** 52 | * Returns false. 53 | * @see PDU#isRequest() 54 | */ 55 | public boolean isRequest() { 56 | return false; 57 | } 58 | 59 | /** 60 | * Returns true. 61 | * @see PDU#isResponse() 62 | */ 63 | public boolean isResponse() { 64 | return true; 65 | } 66 | 67 | /** 68 | * Sets the original Request which this Response 69 | * was created from. 70 | * @see Request#getResponse() 71 | */ 72 | public void setOriginalRequest(Request originalRequest) { 73 | this.originalRequest = originalRequest; 74 | } 75 | 76 | /** 77 | * Returns the original Request which this Response 78 | * was created from. 79 | * @see Request#getResponse() 80 | */ 81 | public Request getOriginalRequest() { 82 | return originalRequest; 83 | } 84 | 85 | } 86 | /* 87 | * $Log: not supported by cvs2svn $ 88 | * 89 | * Old changelog: 90 | * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces 91 | * 09-10-01 ticp@logica.com added registration of original request if the response 92 | * was created from Request by getResponse 93 | */ 94 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/SubmitMultiSMResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class SubmitMultiSMResp extends Response { 21 | private String messageId = Data.DFLT_MSGID; 22 | private UnsuccessSMEsList unsuccessSMEs = new UnsuccessSMEsList(); 23 | 24 | public SubmitMultiSMResp() { 25 | super(Data.SUBMIT_MULTI_RESP); 26 | } 27 | 28 | public void setBody(ByteBuffer buffer) 29 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 30 | setMessageId(buffer.removeCString()); 31 | unsuccessSMEs.setData(buffer); 32 | } 33 | 34 | public ByteBuffer getBody() throws ValueNotSetException { 35 | ByteBuffer buffer = new ByteBuffer(); 36 | buffer.appendCString(messageId); 37 | buffer.appendBuffer(unsuccessSMEs.getData()); 38 | return buffer; 39 | } 40 | 41 | public void setMessageId(String value) throws WrongLengthOfStringException { 42 | checkString(value, Data.SM_MSGID_LEN); 43 | messageId = value; 44 | } 45 | 46 | public void addUnsuccessSME(UnsuccessSME unsuccessSME) throws TooManyValuesException { 47 | unsuccessSMEs.addValue(unsuccessSME); 48 | } 49 | 50 | public String getMessageId() { 51 | return messageId; 52 | } 53 | public short getNoUnsuccess() { 54 | return (short) unsuccessSMEs.getCount(); 55 | } 56 | public UnsuccessSME getUnsuccessSME(int i) { 57 | return (UnsuccessSME) unsuccessSMEs.getValue(i); 58 | } 59 | 60 | public String debugString() { 61 | String dbgs = "(submitmulti_resp: "; 62 | dbgs += super.debugString(); 63 | dbgs += getMessageId(); 64 | dbgs += " "; 65 | dbgs += unsuccessSMEs.debugString(); 66 | dbgs += " "; 67 | dbgs += debugStringOptional(); 68 | dbgs += ") "; 69 | return dbgs; 70 | } 71 | 72 | private class UnsuccessSMEsList extends ByteDataList { 73 | public UnsuccessSMEsList() { 74 | super(Data.SM_MAX_CNT_DEST_ADDR, 1); 75 | } 76 | 77 | public ByteData createValue() { 78 | return new UnsuccessSME(); 79 | } 80 | 81 | public String debugString() { 82 | return "(unsuccess_addr_list: " + super.debugString() + ")"; 83 | } 84 | } 85 | } 86 | /* 87 | * $Log: not supported by cvs2svn $ 88 | * 89 | * Old changelog: 90 | * 01-11-01 ticp@logica.com number of unsuccessfull destination addresses now 91 | * stored correctly (octet > 127 problem) as ByteDataList 92 | * was fixed 93 | */ 94 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/SubmitSMResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.pdu.Response; 15 | import org.smpp.util.*; 16 | 17 | /** 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Id: SubmitSMResp.java 72 2008-07-15 19:43:00Z sverkera $ 20 | */ 21 | public class SubmitSMResp extends Response { 22 | 23 | private String messageId = Data.DFLT_MSGID; 24 | 25 | public SubmitSMResp() { 26 | super(Data.SUBMIT_SM_RESP); 27 | } 28 | 29 | public void setBody(ByteBuffer buffer) 30 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException, InvalidPDUException { 31 | 32 | if (getCommandStatus() == 0) { 33 | setMessageId(buffer.removeCString()); 34 | return; 35 | } 36 | 37 | if (buffer.length() > 0) { 38 | // This is broken in so many implementations that it's not practical 39 | // to be so pedantic about it, so we now just accept it. 40 | // throw new InvalidPDUException(this,"command_status non-zero, but body was present"); 41 | debug.enter(this,"setBody"); 42 | debug.write("invalid SubmitSMResp: command_status non-zero, but body was present (ignoring body)"); 43 | debug.exit(this); 44 | event.write("invalid SubmitSMResp sequenceNumber ["+getSequenceNumber()+"]: command_status non-zero, but body was present (ignoring body)"); 45 | buffer.removeBytes(buffer.length()); // discard body 46 | } 47 | } 48 | 49 | public ByteBuffer getBody() { 50 | ByteBuffer buffer = new ByteBuffer(); 51 | if (getCommandStatus() == 0) buffer.appendCString(messageId); 52 | return buffer; 53 | } 54 | 55 | public void setMessageId(String value) throws WrongLengthOfStringException { 56 | checkString(value, Data.SM_MSGID_LEN); 57 | messageId = value; 58 | } 59 | 60 | public String getMessageId() { 61 | return messageId; 62 | } 63 | 64 | public String debugString() { 65 | String dbgs = "(submit_resp: "; 66 | dbgs += super.debugString(); 67 | dbgs += getMessageId(); 68 | dbgs += " "; 69 | dbgs += debugStringOptional(); 70 | dbgs += ") "; 71 | return dbgs; 72 | } 73 | } 74 | /* 75 | * $Log: not supported by cvs2svn $ 76 | * Revision 1.2 2004/09/04 08:10:56 paoloc 77 | * Changes to enforce this statement from SMPP spec (v3.4 p. 67): "The submit_sm_resp PDU Body is not returned if the command_status field contains a non-zero value". 78 | * 79 | * Revision 1.1 2003/07/23 00:28:39 sverkera 80 | * Imported 81 | * 82 | */ 83 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/TooManyValuesException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class TooManyValuesException extends PDUException { 20 | private static final long serialVersionUID = -2777016699062489252L; 21 | 22 | public TooManyValuesException() { 23 | setErrorCode(Data.ESME_RINVPARAM); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/Unbind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class Unbind extends Request { 21 | public Unbind() { 22 | super(Data.UNBIND); 23 | } 24 | 25 | protected Response createResponse() { 26 | return new UnbindResp(); 27 | } 28 | 29 | public void setBody(ByteBuffer buffer) 30 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 31 | } 32 | 33 | public ByteBuffer getBody() { 34 | return null; 35 | } 36 | 37 | public String debugString() { 38 | String dbgs = "(unbind: "; 39 | dbgs += super.debugString(); 40 | dbgs += ") "; 41 | return dbgs; 42 | } 43 | } 44 | /* 45 | * $Log: not supported by cvs2svn $ 46 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/UnbindResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class UnbindResp extends Response { 21 | public UnbindResp() { 22 | super(Data.UNBIND_RESP); 23 | } 24 | 25 | public void setBody(ByteBuffer buffer) 26 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { 27 | } 28 | 29 | public ByteBuffer getBody() { 30 | return null; 31 | } 32 | 33 | public String debugString() { 34 | String dbgs = "(unbind_resp: "; 35 | dbgs += super.debugString(); 36 | dbgs += ") "; 37 | return dbgs; 38 | } 39 | } 40 | /* 41 | * $Log: not supported by cvs2svn $ 42 | */ 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/UnexpectedOptionalParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class UnexpectedOptionalParameterException extends PDUException { 20 | private static final long serialVersionUID = -1284359967986779783L; 21 | private int tag = 0; 22 | 23 | public UnexpectedOptionalParameterException() { 24 | super("The optional parameter wasn't expected for the PDU."); 25 | setErrorCode(Data.ESME_ROPTPARNOTALLWD); 26 | } 27 | 28 | public UnexpectedOptionalParameterException(short tag) { 29 | super("The optional parameter wasn't expected for the PDU:" + " tag=" + tag + "."); 30 | this.tag = tag; 31 | setErrorCode(Data.ESME_ROPTPARNOTALLWD); 32 | } 33 | 34 | public void setTag(int tag) { 35 | this.tag = tag; 36 | } 37 | 38 | public int getTag() { 39 | return tag; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/UnknownCommandIdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | /** 14 | * @author Logica Mobile Networks SMPP Open Source Team 15 | * @version $Revision: 1.1 $ 16 | */ 17 | public class UnknownCommandIdException extends PDUException { 18 | /** 19 | * 20 | */ 21 | private static final long serialVersionUID = -5091873576710864441L; 22 | private transient PDUHeader header = null; 23 | 24 | public UnknownCommandIdException() { 25 | } 26 | 27 | public UnknownCommandIdException(PDUHeader header) { 28 | this.header = header; 29 | } 30 | 31 | public int getCommandLength() { 32 | return header == null ? 0 : header.getCommandLength(); 33 | } 34 | 35 | public int getCommandId() { 36 | return header == null ? 0 : header.getCommandId(); 37 | } 38 | 39 | public int getCommandStatus() { 40 | return header == null ? 0 : header.getCommandStatus(); 41 | } 42 | 43 | public int getSequenceNumber() { 44 | return header == null ? 0 : header.getSequenceNumber(); 45 | } 46 | } 47 | /* 48 | * $Log: not supported by cvs2svn $ 49 | * 50 | * Old changelog: 51 | * 10-10-01 ticp@logica.com pdu header carried by the exception made transient 52 | * (it is not serializable) 53 | */ 54 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/UnsuccessSME.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.*; 15 | 16 | /** 17 | * @author Logica Mobile Networks SMPP Open Source Team 18 | * @version $Revision: 1.1 $ 19 | */ 20 | public class UnsuccessSME extends Address { 21 | public int errorStatusCode = Data.ESME_ROK; 22 | 23 | public UnsuccessSME() { 24 | } 25 | 26 | public UnsuccessSME(String address, int err) throws WrongLengthOfStringException { 27 | super(address); 28 | setErrorStatusCode(err); 29 | } 30 | 31 | public UnsuccessSME(byte ton, byte npi, String address, int err) throws WrongLengthOfStringException { 32 | super(ton, npi, address); 33 | setErrorStatusCode(err); 34 | } 35 | 36 | public void setData(ByteBuffer buffer) 37 | throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException { 38 | super.setData(buffer); 39 | setErrorStatusCode(buffer.removeInt()); 40 | } 41 | 42 | public ByteBuffer getData() { 43 | ByteBuffer buffer = super.getData(); 44 | buffer.appendInt(getErrorStatusCode()); 45 | return buffer; 46 | } 47 | 48 | public void setErrorStatusCode(int sc) { 49 | errorStatusCode = sc; 50 | } 51 | public int getErrorStatusCode() { 52 | return errorStatusCode; 53 | } 54 | 55 | public String debugString() { 56 | String dbgs = "(unsucsme: "; 57 | dbgs += super.debugString(); 58 | dbgs += Integer.toString(getErrorStatusCode()); 59 | dbgs += ") "; 60 | return dbgs; 61 | } 62 | } 63 | /* 64 | * $Log: not supported by cvs2svn $ 65 | */ 66 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/ValueNotSetException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * optional's parameter's value was requested but the optional parameter 17 | * wasn't present in the PDU 18 | * 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Revision: 1.1 $ 21 | */ 22 | public class ValueNotSetException extends PDUException { 23 | private static final long serialVersionUID = -4595064103809398438L; 24 | 25 | public ValueNotSetException() { 26 | setErrorCode(Data.ESME_RMISSINGOPTPARAM); 27 | } 28 | } 29 | /* 30 | * $Log: not supported by cvs2svn $ 31 | */ 32 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/WrongDateFormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class WrongDateFormatException extends PDUException { 20 | private static final long serialVersionUID = 5831937612139037591L; 21 | 22 | public WrongDateFormatException() { 23 | super("Date must be either null or of format YYMMDDhhmmsstnnp"); 24 | setErrorCode(Data.ESME_RINVPARAM); 25 | } 26 | 27 | public WrongDateFormatException(String dateStr) { 28 | super("Date must be either null or of format YYMMDDhhmmsstnnp and not " + dateStr + "."); 29 | setErrorCode(Data.ESME_RINVPARAM); 30 | } 31 | 32 | public WrongDateFormatException(String dateStr, String msg) { 33 | super("Invalid date " + dateStr + ": " + msg); 34 | setErrorCode(Data.ESME_RINVPARAM); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/WrongDestFlagException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class WrongDestFlagException extends PDUException { 20 | private static final long serialVersionUID = 6266749651012701472L; 21 | 22 | public WrongDestFlagException() { 23 | setErrorCode(Data.ESME_RINVPARAM); 24 | } 25 | 26 | public WrongDestFlagException(PDU pdu) { 27 | super(pdu); 28 | setErrorCode(Data.ESME_RINVPARAM); 29 | } 30 | 31 | public WrongDestFlagException(String s) { 32 | super(s); 33 | setErrorCode(Data.ESME_RINVPARAM); 34 | } 35 | 36 | public WrongDestFlagException(PDU pdu, String s) { 37 | super(pdu, s); 38 | setErrorCode(Data.ESME_RINVPARAM); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/WrongLengthOfStringException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu; 12 | 13 | import org.smpp.Data; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.1 $ 18 | */ 19 | public class WrongLengthOfStringException extends PDUException { 20 | private static final long serialVersionUID = 8604133584902790266L; 21 | 22 | public WrongLengthOfStringException() { 23 | super("The string is shorter or longer than required."); 24 | setErrorCode(Data.ESME_RINVPARAM); 25 | } 26 | 27 | public WrongLengthOfStringException(int min, int max, int actual) { 28 | super( 29 | "The string is shorter or longer than required: " 30 | + " min=" 31 | + min 32 | + " max=" 33 | + max 34 | + " actual=" 35 | + actual 36 | + "."); 37 | setErrorCode(Data.ESME_RINVPARAM); 38 | } 39 | } 40 | /* 41 | * $Log: not supported by cvs2svn $ 42 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVByte.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import org.smpp.pdu.ValueNotSetException; 14 | import org.smpp.util.ByteBuffer; 15 | import org.smpp.util.NotEnoughDataInByteBufferException; 16 | 17 | /** 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Revision: 1.1 $ 20 | */ 21 | public class TLVByte extends TLV { 22 | private byte value = 0; 23 | 24 | public TLVByte() { 25 | super(1, 1); 26 | } 27 | 28 | public TLVByte(short p_tag) { 29 | super(p_tag, 1, 1); 30 | } 31 | 32 | public TLVByte(short p_tag, byte p_value) { 33 | super(p_tag, 1, 1); 34 | value = p_value; 35 | markValueSet(); 36 | } 37 | 38 | protected void setValueData(ByteBuffer buffer) throws TLVException { 39 | checkLength(buffer); 40 | try { 41 | value = buffer.removeByte(); 42 | } catch (NotEnoughDataInByteBufferException e) { 43 | // can't happen as the size is already checked by checkLength() 44 | } 45 | markValueSet(); 46 | } 47 | 48 | protected ByteBuffer getValueData() throws ValueNotSetException { 49 | ByteBuffer valueBuf = new ByteBuffer(); 50 | valueBuf.appendByte(getValue()); 51 | return valueBuf; 52 | } 53 | 54 | public void setValue(byte p_value) { 55 | value = p_value; 56 | markValueSet(); 57 | } 58 | 59 | public byte getValue() throws ValueNotSetException { 60 | if (hasValue()) { 61 | return value; 62 | } else { 63 | throw new ValueNotSetException(); 64 | } 65 | } 66 | 67 | public String debugString() { 68 | String dbgs = "(byte: "; 69 | dbgs += super.debugString(); 70 | dbgs += value; 71 | dbgs += ") "; 72 | return dbgs; 73 | } 74 | } 75 | /* 76 | * $Log: not supported by cvs2svn $ 77 | */ 78 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVEmpty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import org.smpp.pdu.ValueNotSetException; 14 | import org.smpp.pdu.tlv.WrongLengthException; 15 | import org.smpp.util.ByteBuffer; 16 | 17 | /** 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Revision: 1.1 $ 20 | */ 21 | public class TLVEmpty extends TLV { 22 | private boolean present = false; 23 | 24 | public TLVEmpty() { 25 | super(0, 0); 26 | } 27 | 28 | public TLVEmpty(short p_tag) { 29 | super(p_tag, 0, 0); 30 | } 31 | 32 | public TLVEmpty(short p_tag, boolean p_present) { 33 | super(p_tag, 0, 0); 34 | present = p_present; 35 | markValueSet(); 36 | } 37 | 38 | public ByteBuffer getValueData() { 39 | // nothing, just present or not 40 | return null; 41 | } 42 | 43 | public void setValueData(ByteBuffer buffer) throws WrongLengthException { 44 | // nothing, just set presence 45 | checkLength(buffer); 46 | setValue(true); 47 | } 48 | 49 | public void setValue(boolean p_present) { 50 | present = p_present; 51 | markValueSet(); 52 | } 53 | 54 | public boolean getValue() throws ValueNotSetException { 55 | if (hasValue()) { 56 | return present; 57 | } else { 58 | throw new ValueNotSetException(); 59 | } 60 | } 61 | 62 | public String debugString() { 63 | String dbgs = "(empty: "; 64 | dbgs += super.debugString(); 65 | dbgs += ") "; 66 | return dbgs; 67 | } 68 | } 69 | /* 70 | * $Log: not supported by cvs2svn $ 71 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import org.smpp.pdu.PDUException; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.2 $ 18 | */ 19 | public class TLVException extends PDUException { 20 | private static final long serialVersionUID = -6659626685298184198L; 21 | 22 | public TLVException() { 23 | super(); 24 | } 25 | 26 | public TLVException(String s) { 27 | super(s); 28 | } 29 | } 30 | /* 31 | * $Log: not supported by cvs2svn $ 32 | * Revision 1.1 2003/07/23 00:28:39 sverkera 33 | * Imported 34 | * 35 | */ -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVInt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import org.smpp.pdu.ValueNotSetException; 14 | import org.smpp.util.ByteBuffer; 15 | import org.smpp.util.NotEnoughDataInByteBufferException; 16 | 17 | /** 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Revision: 1.1 $ 20 | */ 21 | public class TLVInt extends TLV { 22 | private int value = 0; 23 | 24 | public TLVInt() { 25 | super(4, 4); 26 | } 27 | 28 | public TLVInt(short p_tag) { 29 | super(p_tag, 4, 4); 30 | } 31 | 32 | public TLVInt(short p_tag, int p_value) { 33 | super(p_tag, 4, 4); 34 | value = p_value; 35 | markValueSet(); 36 | } 37 | 38 | protected void setValueData(ByteBuffer buffer) throws TLVException { 39 | checkLength(buffer); 40 | try { 41 | value = buffer.removeInt(); 42 | } catch (NotEnoughDataInByteBufferException e) { 43 | // can't happen as the size is already checked by checkLength() 44 | } 45 | markValueSet(); 46 | } 47 | 48 | protected ByteBuffer getValueData() throws ValueNotSetException { 49 | ByteBuffer valueBuf = new ByteBuffer(); 50 | valueBuf.appendInt(getValue()); 51 | return valueBuf; 52 | } 53 | 54 | public void setValue(int p_value) { 55 | value = p_value; 56 | markValueSet(); 57 | } 58 | 59 | public int getValue() throws ValueNotSetException { 60 | if (hasValue()) { 61 | return value; 62 | } else { 63 | throw new ValueNotSetException(); 64 | } 65 | } 66 | 67 | public String debugString() { 68 | String dbgs = "(int: "; 69 | dbgs += super.debugString(); 70 | dbgs += value; 71 | dbgs += ") "; 72 | return dbgs; 73 | } 74 | } 75 | /* 76 | * $Log: not supported by cvs2svn $ 77 | */ 78 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVOctets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import java.lang.Error; 14 | 15 | import org.smpp.pdu.ValueNotSetException; 16 | import org.smpp.util.ByteBuffer; 17 | import org.smpp.util.NotEnoughDataInByteBufferException; 18 | 19 | /** 20 | * @author Logica Mobile Networks SMPP Open Source Team 21 | * @version $Revision: 1.1 $ 22 | */ 23 | public class TLVOctets extends TLV { 24 | private ByteBuffer value = null; 25 | 26 | public TLVOctets() { 27 | super(); 28 | } 29 | 30 | public TLVOctets(short p_tag) { 31 | super(p_tag); 32 | } 33 | 34 | public TLVOctets(short p_tag, int min, int max) { 35 | super(p_tag, min, max); 36 | } 37 | 38 | public TLVOctets(short p_tag, ByteBuffer p_value) throws TLVException { 39 | super(p_tag); 40 | setValueData(p_value); 41 | } 42 | 43 | public TLVOctets(short p_tag, int min, int max, ByteBuffer p_value) throws TLVException { 44 | super(p_tag, min, max); 45 | setValueData(p_value); 46 | } 47 | 48 | protected void setValueData(ByteBuffer buffer) throws TLVException { 49 | checkLength(buffer); 50 | if (buffer != null) { 51 | try { 52 | value = buffer.removeBuffer(buffer.length()); 53 | } catch (NotEnoughDataInByteBufferException e) { 54 | throw new Error( 55 | "Removing buf.length() data from ByteBuffer buf " 56 | + "reported too little data in buf, which shouldn't happen."); 57 | } 58 | } else { 59 | value = null; 60 | } 61 | markValueSet(); 62 | } 63 | 64 | protected ByteBuffer getValueData() throws ValueNotSetException { 65 | ByteBuffer valueBuf = new ByteBuffer(); 66 | valueBuf.appendBuffer(getValue()); 67 | return valueBuf; 68 | } 69 | 70 | public void setValue(ByteBuffer p_value) { 71 | if (p_value != null) { 72 | try { 73 | value = p_value.removeBuffer(p_value.length()); 74 | } catch (NotEnoughDataInByteBufferException e) { 75 | throw new Error( 76 | "Removing buf.length() data from ByteBuffer buf " 77 | + "reported too little data in buf, which shouldn't happen."); 78 | } 79 | } else { 80 | value = null; 81 | } 82 | markValueSet(); 83 | } 84 | 85 | public ByteBuffer getValue() throws ValueNotSetException { 86 | if (hasValue()) { 87 | return value; 88 | } else { 89 | throw new ValueNotSetException(); 90 | } 91 | } 92 | 93 | public String debugString() { 94 | String dbgs = "(oct: "; 95 | dbgs += super.debugString(); 96 | dbgs += value == null ? "" : value.getHexDump(); 97 | dbgs += ") "; 98 | return dbgs; 99 | } 100 | 101 | } 102 | /* 103 | * $Log: not supported by cvs2svn $ 104 | * 105 | * Old changelog: 106 | * 26-09-01 ticp@logica.com debugString() now prints hex dump of the buffer data 107 | * instead of the object reference of it 108 | */ 109 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVShort.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import org.smpp.pdu.ValueNotSetException; 14 | import org.smpp.util.ByteBuffer; 15 | import org.smpp.util.NotEnoughDataInByteBufferException; 16 | 17 | /** 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Revision: 1.1 $ 20 | */ 21 | public class TLVShort extends TLV { 22 | private short value = 0; 23 | 24 | public TLVShort() { 25 | super(2, 2); 26 | } 27 | 28 | public TLVShort(short p_tag) { 29 | super(p_tag, 2, 2); 30 | } 31 | 32 | public TLVShort(short p_tag, short p_value) { 33 | super(p_tag, 2, 2); 34 | value = p_value; 35 | markValueSet(); 36 | } 37 | 38 | protected void setValueData(ByteBuffer buffer) throws TLVException { 39 | checkLength(buffer); 40 | try { 41 | value = buffer.removeShort(); 42 | } catch (NotEnoughDataInByteBufferException e) { 43 | // can't happen as the size is already checked by checkLength() 44 | } 45 | markValueSet(); 46 | } 47 | 48 | protected ByteBuffer getValueData() throws ValueNotSetException { 49 | ByteBuffer valueBuf = new ByteBuffer(); 50 | valueBuf.appendShort(getValue()); 51 | return valueBuf; 52 | } 53 | 54 | public void setValue(short p_value) { 55 | value = p_value; 56 | markValueSet(); 57 | } 58 | 59 | public short getValue() throws ValueNotSetException { 60 | if (hasValue()) { 61 | return value; 62 | } else { 63 | throw new ValueNotSetException(); 64 | } 65 | } 66 | 67 | public String debugString() { 68 | String dbgs = "(short: "; 69 | dbgs += super.debugString(); 70 | dbgs += value; 71 | dbgs += ") "; 72 | return dbgs; 73 | } 74 | } 75 | /* 76 | * $Log: not supported by cvs2svn $ 77 | */ 78 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import org.smpp.pdu.ValueNotSetException; 14 | import org.smpp.util.ByteBuffer; 15 | import org.smpp.util.NotEnoughDataInByteBufferException; 16 | import org.smpp.util.TerminatingZeroNotFoundException; 17 | 18 | /** 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Revision: 1.1 $ 21 | */ 22 | public class TLVString extends TLV { 23 | private String value; 24 | 25 | public TLVString() { 26 | super(); 27 | } 28 | 29 | public TLVString(short tag) { 30 | super(tag); 31 | } 32 | 33 | public TLVString(short tag, int min, int max) { 34 | super(tag, min, max); 35 | } 36 | 37 | public TLVString(short tag, String value) throws TLVException { 38 | super(tag); 39 | setValue(value); 40 | } 41 | 42 | public TLVString(short tag, int min, int max, String value) throws TLVException { 43 | super(tag, min, max); 44 | setValue(value); 45 | } 46 | 47 | public void setValueData(ByteBuffer buffer) throws TLVException { 48 | checkLength(buffer); 49 | if (buffer != null) { 50 | try { 51 | value = buffer.removeCString(); 52 | } catch (NotEnoughDataInByteBufferException e) { 53 | throw new TLVException("Not enough data for string in the buffer."); 54 | } catch (TerminatingZeroNotFoundException e) { 55 | throw new TLVException("String terminating zero not found in the buffer."); 56 | } 57 | } else { 58 | value = new String(""); 59 | } 60 | markValueSet(); 61 | } 62 | 63 | public ByteBuffer getValueData() throws ValueNotSetException { 64 | ByteBuffer valueBuf = new ByteBuffer(); 65 | valueBuf.appendCString(getValue()); 66 | return valueBuf; 67 | } 68 | 69 | public void setValue(String value) throws WrongLengthException { 70 | checkLength(value.length() + 1); 71 | this.value = value; 72 | markValueSet(); 73 | } 74 | 75 | public String getValue() throws ValueNotSetException { 76 | if (hasValue()) { 77 | return value; 78 | } else { 79 | throw new ValueNotSetException(); 80 | } 81 | } 82 | 83 | public String debugString() { 84 | String dbgs = "(str: "; 85 | dbgs += super.debugString(); 86 | dbgs += value; 87 | dbgs += ") "; 88 | return dbgs; 89 | } 90 | 91 | } 92 | /* 93 | * $Log: not supported by cvs2svn $ 94 | * 95 | * Old changelog: 96 | * 20-11-01 ticp@logica.com setValue() now sets flag that the value was set 97 | */ 98 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/TLVUByte.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | import org.smpp.pdu.IntegerOutOfRangeException; 14 | import org.smpp.pdu.ValueNotSetException; 15 | import org.smpp.util.ByteBuffer; 16 | import org.smpp.util.NotEnoughDataInByteBufferException; 17 | 18 | /** 19 | * TLV carrying unsigned byte (octet). 20 | * 21 | * @author Logica Mobile Networks SMPP Open Source Team 22 | * @version $Revision: 1.1 $ 23 | */ 24 | public class TLVUByte extends TLV { 25 | /** The value of the TLV. Stored as short (two byte) as byte 26 | * can't carry full unsigned octet. 27 | */ 28 | private short value = 0; 29 | 30 | /** 31 | * Initialises the TLV with default values. 32 | */ 33 | public TLVUByte() { 34 | super(1, 1); 35 | } 36 | 37 | /** 38 | * Initialises the TLV with provided tag. 39 | * @param p_tag the tag of this TLV 40 | */ 41 | public TLVUByte(short p_tag) { 42 | super(p_tag, 1, 1); 43 | } 44 | 45 | /** 46 | * Reads 1 octet from buffer and interprets it as unsigned byte. 47 | * @param buffer the buffer to read the unsigned byte from 48 | */ 49 | protected void setValueData(ByteBuffer buffer) throws TLVException { 50 | checkLength(buffer); 51 | try { 52 | value = decodeUnsigned(buffer.removeByte()); 53 | } catch (NotEnoughDataInByteBufferException e) { 54 | // can't happen as the size is already checked by checkLength() 55 | } 56 | markValueSet(); 57 | } 58 | 59 | /** 60 | * Creates byt buffer containing one unsigned byte. 61 | * @return the byte buffer with one unsingned byte 62 | */ 63 | protected ByteBuffer getValueData() throws ValueNotSetException { 64 | ByteBuffer valueBuf = new ByteBuffer(); 65 | valueBuf.appendByte(encodeUnsigned(getValue())); 66 | return valueBuf; 67 | } 68 | 69 | /** 70 | * Sets the value of the TLV to the new value. 71 | * @param value the new value of the TLV 72 | */ 73 | public void setValue(short value) throws IntegerOutOfRangeException { 74 | checkRange(0, value, 255); 75 | this.value = value; 76 | markValueSet(); 77 | } 78 | 79 | /** 80 | * Returns the current value of the TLV 81 | * @return the curent value of the TLV 82 | * @throws ValueNotSetException if value hasn't been set 83 | */ 84 | public short getValue() throws ValueNotSetException { 85 | if (hasValue()) { 86 | return value; 87 | } else { 88 | throw new ValueNotSetException(); 89 | } 90 | } 91 | 92 | public String debugString() { 93 | String dbgs = "(byte: "; 94 | dbgs += super.debugString(); 95 | dbgs += value; 96 | dbgs += ") "; 97 | return dbgs; 98 | } 99 | } 100 | /* 101 | * $Log: not supported by cvs2svn $ 102 | */ 103 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/pdu/tlv/WrongLengthException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.pdu.tlv; 12 | 13 | /** 14 | * @author Logica Mobile Networks SMPP Open Source Team 15 | * @version $Revision: 1.2 $ 16 | */ 17 | public class WrongLengthException extends TLVException { 18 | private static final long serialVersionUID = 7935018427341458286L; 19 | 20 | public WrongLengthException() { 21 | super("The TLV is shorter or longer than allowed."); 22 | } 23 | 24 | public WrongLengthException(int min, int max, int actual) { 25 | super( 26 | "The TLV is shorter or longer than allowed: " + " min=" + min + " max=" + max + " actual=" + actual + "."); 27 | } 28 | } 29 | /* 30 | * $Log: not supported by cvs2svn $ 31 | * Revision 1.1 2003/07/23 00:28:39 sverkera 32 | * Imported 33 | * 34 | */ 35 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/util/DataCodingCharsetHandler.java: -------------------------------------------------------------------------------- 1 | package org.smpp.util; 2 | 3 | import org.smpp.Data; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * Handles charset handling based on data_coding parameter, see 10 | * SMPP 3.4 specification, paragraph 5.2.19 11 | */ 12 | public class DataCodingCharsetHandler { 13 | private static final Map DATA_CODING_CHARSET; 14 | 15 | static { 16 | DATA_CODING_CHARSET = new HashMap(); 17 | DATA_CODING_CHARSET.put((byte) 0, Data.ENC_GSM7BIT); 18 | DATA_CODING_CHARSET.put((byte) 8, Data.ENC_UTF16); 19 | } 20 | 21 | /** 22 | * Return the correct charset given the data_coding parameter. 23 | * If none is found it defaults to X-Gsm7Bit. 24 | * 25 | * @param dataCoding 26 | * @return encoding name 27 | */ 28 | public static String getCharsetName(byte dataCoding) { 29 | return getCharsetName(dataCoding, Data.ENC_GSM7BIT); 30 | } 31 | 32 | /** 33 | * Return the correct charset given the data_coding parameter. 34 | * 35 | * @param dataCoding 36 | * @param defaultEncoding 37 | * @return encoding name 38 | */ 39 | public static String getCharsetName(byte dataCoding, String defaultEncoding) { 40 | String encoding = DATA_CODING_CHARSET.get(dataCoding); 41 | return encoding != null ? encoding : defaultEncoding; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/util/DefaultServerPDUEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.util; 12 | 13 | import org.smpp.ServerPDUEvent; 14 | import org.smpp.ServerPDUEventListener; 15 | import org.smpp.SmppObject; 16 | import org.smpp.pdu.PDU; 17 | 18 | /** 19 | * Simple listener processing PDUs received from SMSC by the 20 | * Receiver in asynchronous mode. 21 | * 22 | * @author Logica Mobile Networks SMPP Open Source Team 23 | * @version $Revision: 1.1 $ 24 | * @see ServerPDUEventListener 25 | */ 26 | public class DefaultServerPDUEventListener extends SmppObject implements ServerPDUEventListener { 27 | /** 28 | * "Handles" the event generated for received PDUs -- just logs 29 | * the event and throws it away. 30 | */ 31 | public void handleEvent(ServerPDUEvent event) { 32 | PDU pdu = event.getPDU(); 33 | if (pdu != null) { 34 | if (pdu.isRequest()) { 35 | debug.write(DUTL, "receiver listener: handling request " + pdu.debugString()); 36 | } else if (pdu.isResponse()) { 37 | debug.write(DUTL, "receiver listener: handling response " + pdu.debugString()); 38 | } else { 39 | debug.write(DUTL, "receiver listener: handling strange pdu " + pdu.debugString()); 40 | } 41 | } 42 | } 43 | } 44 | /* 45 | * $Log: not supported by cvs2svn $ 46 | */ 47 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/util/NotEnoughDataInByteBufferException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.util; 12 | 13 | import org.smpp.SmppException; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.2 $ 18 | */ 19 | public class NotEnoughDataInByteBufferException extends SmppException { 20 | private static final long serialVersionUID = -3720107899765064964L; 21 | private int available; 22 | private int expected; 23 | 24 | public NotEnoughDataInByteBufferException(int p_available, int p_expected) { 25 | super("Not enough data in byte buffer. " + "Expected " + p_expected + ", available: " + p_available + "."); 26 | available = p_available; 27 | expected = p_expected; 28 | } 29 | 30 | public NotEnoughDataInByteBufferException(String s) { 31 | super(s); 32 | available = 0; 33 | expected = 0; 34 | } 35 | 36 | public int getAvailable() { 37 | return available; 38 | } 39 | 40 | public int getExpected() { 41 | return expected; 42 | } 43 | } 44 | /* 45 | * $Log: not supported by cvs2svn $ 46 | * Revision 1.1 2003/07/23 00:28:39 sverkera 47 | * Imported 48 | * 49 | */ 50 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/util/Queue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.util; 12 | 13 | import java.util.LinkedList; 14 | import java.util.ListIterator; 15 | 16 | import org.smpp.SmppObject; 17 | 18 | /** 19 | * Implements fifo style queue with removal of specified element from inside of 20 | * the queue. 21 | * 22 | * @author Logica Mobile Networks SMPP Open Source Team 23 | * @version $Revision: 1.1 $ 24 | */ 25 | public class Queue extends SmppObject { 26 | private int maxQueueSize = 0; 27 | private LinkedList queueData = new LinkedList(); 28 | private Object mutex; 29 | 30 | public Queue() { 31 | mutex = this; 32 | } 33 | 34 | public Queue(int maxSize) { 35 | maxQueueSize = maxSize; 36 | mutex = this; 37 | } 38 | 39 | /** 40 | * Current count of the elements in the queue. 41 | */ 42 | public int size() { 43 | synchronized (mutex) { 44 | return queueData.size(); 45 | } 46 | } 47 | 48 | /** 49 | * If there is no element in the queue. 50 | */ 51 | public boolean isEmpty() { 52 | synchronized (mutex) { 53 | return queueData.isEmpty(); 54 | } 55 | } 56 | 57 | /** 58 | * Removes first element form the queue and returns it. 59 | * If the queue is empty, returns null. 60 | */ 61 | public Object dequeue() { 62 | synchronized (mutex) { 63 | Object first = null; 64 | if (size() > 0) { 65 | first = queueData.removeFirst(); 66 | } 67 | return first; 68 | } 69 | } 70 | 71 | /** 72 | * Tries to find the provided element in the queue and if found, 73 | * removes it from the queue and returns it. 74 | * If the element is not found returns null. 75 | */ 76 | public Object dequeue(Object obj) { 77 | Object found = null; 78 | synchronized (mutex) { 79 | found = find(obj); 80 | if (found != null) { 81 | queueData.remove(found); 82 | } 83 | } 84 | return found; 85 | } 86 | 87 | /** 88 | * Appends an element to the end of the queue. If the queue 89 | * has set limit on maximum elements and there is already specified 90 | * max count of elements in the queue throws IndexOutOfBoundsException. 91 | */ 92 | public void enqueue(Object obj) throws IndexOutOfBoundsException { 93 | synchronized (mutex) { 94 | if ((maxQueueSize > 0) && (size() >= maxQueueSize)) { 95 | throw new IndexOutOfBoundsException("Queue is full. Element not added."); 96 | } 97 | queueData.add(obj); 98 | } 99 | } 100 | 101 | /** 102 | * Searches the queue to find the provided element. 103 | * Uses equals method to compare elements. 104 | */ 105 | public Object find(Object obj) { 106 | synchronized (mutex) { 107 | Object current; 108 | ListIterator iter = queueData.listIterator(0); 109 | while (iter.hasNext()) { 110 | current = iter.next(); 111 | if (current.equals(obj)) { 112 | return current; 113 | } 114 | } 115 | } 116 | return null; 117 | } 118 | } 119 | /* 120 | * $Log: not supported by cvs2svn $ 121 | * 122 | * Old changelog: 123 | * 13-07-01 ticp@logica.com added dequeue(Object) method which finds and removes 124 | * object which equals() to the provided one 125 | * (not too queue-ish) 126 | * 01-10-01 ticp@logica.com added some javadoc comments 127 | */ 128 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/util/SimpleOutbindListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.util; 12 | 13 | import org.smpp.OutbindEvent; 14 | import org.smpp.OutbindEventListener; 15 | import org.smpp.SmppObject; 16 | 17 | /** 18 | * The SimpleOutbindListener class is example class for OutbindEventListener. 19 | * It stores all OutbindEvent passed to it's handleOutbind 20 | * method to Queue and notifies thread waiting on signaller object.

21 | * The typical usage would be:

22 | *

23 |  * Connection conn = new TCPIPConnection("123.123.123.123",1234);
24 |  * OutbindReceiver rcvr = new OutbindReceiver(conn);
25 |  * // this as parameter means that the listener will notify
26 |  * // the calling thread
27 |  * SimpleOutbindListener listener = new SimpleOutbindListener(this);
28 |  * OutbindEvent event;
29 |  * rcvr.setOutbindListener(listener);
30 |  * rcvr.startReceiving();
31 |  * while (true) {
32 |  *    listener.waitOutbind(1000);
33 |  *    event = listener.getOutbindEvent();
34 |  *    if (event != null) {
35 |  *       // process the event
36 |  *    }
37 |  * }
38 |  * 
39 | * 40 | * @author Logica Mobile Networks SMPP Open Source Team 41 | * @version $Revision: 1.1 $ 42 | */ 43 | public class SimpleOutbindListener extends SmppObject implements OutbindEventListener { 44 | private Queue eventQueue = new Queue(); 45 | 46 | private Object signaller = null; 47 | 48 | public SimpleOutbindListener() { 49 | signaller = this; 50 | } 51 | 52 | public SimpleOutbindListener(Object signaller) { 53 | this.signaller = signaller; 54 | } 55 | 56 | public void handleOutbind(OutbindEvent outbind) { 57 | eventQueue.enqueue(outbind); 58 | signaller.notify(); 59 | } 60 | 61 | public OutbindEvent getOutbindEvent() { 62 | if (!eventQueue.isEmpty()) { 63 | return (OutbindEvent) eventQueue.dequeue(); 64 | } else { 65 | return null; 66 | } 67 | } 68 | 69 | public void waitOutbind() throws InterruptedException { 70 | signaller.wait(); 71 | } 72 | 73 | public void waitOutbind(long timeout) throws InterruptedException { 74 | signaller.wait(timeout); 75 | } 76 | 77 | public void waitOutbind(long timeout, int nanos) throws InterruptedException { 78 | signaller.wait(timeout, nanos); 79 | } 80 | } 81 | /* 82 | * $Log: not supported by cvs2svn $ 83 | */ 84 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/util/TerminatingZeroNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.util; 12 | 13 | import org.smpp.SmppException; 14 | 15 | /** 16 | * @author Logica Mobile Networks SMPP Open Source Team 17 | * @version $Revision: 1.2 $ 18 | */ 19 | public class TerminatingZeroNotFoundException extends SmppException { 20 | private static final long serialVersionUID = 7028315742573472677L; 21 | 22 | public TerminatingZeroNotFoundException() { 23 | super("Terminating zero not found in buffer."); 24 | } 25 | 26 | public TerminatingZeroNotFoundException(String s) { 27 | super(s); 28 | } 29 | 30 | } 31 | /* 32 | * $Log: not supported by cvs2svn $ 33 | * Revision 1.1 2003/07/23 00:29:08 sverkera 34 | * Imported 35 | * 36 | */ 37 | -------------------------------------------------------------------------------- /core/src/main/java/org/smpp/util/Unprocessed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.util; 12 | 13 | import org.smpp.Data; 14 | import org.smpp.util.ByteBuffer; 15 | 16 | /** 17 | * Utility class Unprocessed is used for data received from 18 | * connection which aren't complete PDU yet. 19 | * 20 | * @author Logica Mobile Networks SMPP Open Source Team 21 | * @version $Revision: 1.1 $ 22 | */ 23 | public class Unprocessed { 24 | /** 25 | * Buffer for data which aren't complete PDU yet. Each time new data 26 | * are received, they are appended to this buffer and PDU is created 27 | * from this buffer. 28 | * 29 | * @see #hasUnprocessed 30 | * @see org.smpp.ReceiverBase#receivePDUFromConnection(Connection,Unprocessed) 31 | */ 32 | private ByteBuffer unprocessed = new ByteBuffer(); 33 | 34 | /** 35 | * Contains haw many bytes is expected after it's been decided that 36 | * the current bytes aren't enough to build up complete PDU. 37 | */ 38 | private int expected = 0; 39 | 40 | /** 41 | * Indicates that after creating PDU from unprocessed buffer 42 | * there were still some data left in the unprocessed buffer. 43 | * In the next receive even if no new data will be received an attempt 44 | * to create PDU from unprocessed buffer will be performed. 45 | * 46 | * @see #unprocessed 47 | * @see org.smpp.ReceiverBase#receivePDUFromConnection(Connection,Unprocessed) 48 | */ 49 | private boolean hasUnprocessed = false; 50 | 51 | /** 52 | * Contains the time when some data were received from connection. 53 | * If it is currently longer from lastTimeReceived 54 | * than specified by receiveTimeout, 55 | * TimeoutException is thrown. 56 | * 57 | * @see org.smpp.ReceiverBase#receiveTimeout 58 | * @see TimeoutException 59 | * @see org.smpp.ReceiverBase#receivePDUFromConnection(Connection,Unprocessed) 60 | */ 61 | private long lastTimeReceived = 0; 62 | 63 | /** 64 | * Resets flag hasUnprocessed, removes all bytes 65 | * from unprocessed buffer and sets expected 66 | * to zero. 67 | * 68 | * @see #hasUnprocessed 69 | * @see #unprocessed 70 | * @see #expected 71 | */ 72 | public void reset() { 73 | hasUnprocessed = false; 74 | unprocessed.setBuffer(null); 75 | expected = 0; 76 | } 77 | 78 | /** 79 | * Sets flag hasUnprocessed if there are any 80 | * unprocessed bytes in unprocessed buffer. 81 | * 82 | * @see #hasUnprocessed 83 | * @see #unprocessed 84 | */ 85 | public void check() { 86 | hasUnprocessed = unprocessed.length() > 0; 87 | } 88 | 89 | public void setHasUnprocessed(boolean value) { 90 | hasUnprocessed = value; 91 | } 92 | public void setExpected(int value) { 93 | expected = value; 94 | } 95 | public void setLastTimeReceived(long value) { 96 | lastTimeReceived = value; 97 | } 98 | public void setLastTimeReceived() { 99 | lastTimeReceived = Data.getCurrentTime(); 100 | } 101 | 102 | public ByteBuffer getUnprocessed() { 103 | return unprocessed; 104 | } 105 | public boolean getHasUnprocessed() { 106 | return hasUnprocessed; 107 | } 108 | public int getExpected() { 109 | return expected; 110 | } 111 | public long getLastTimeReceived() { 112 | return lastTimeReceived; 113 | } 114 | } 115 | /* 116 | * $Log: not supported by cvs2svn $ 117 | */ 118 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/SmppObjectTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp; 2 | 3 | import static org.junit.Assert.*; 4 | import static org.mockito.Mockito.*; 5 | 6 | import org.junit.AfterClass; 7 | import org.junit.Test; 8 | import org.smpp.debug.Debug; 9 | import org.smpp.debug.DefaultDebug; 10 | import org.smpp.debug.DefaultEvent; 11 | import org.smpp.debug.Event; 12 | 13 | public class SmppObjectTest { 14 | 15 | @AfterClass 16 | public static void tearDownClass() { 17 | SmppObject.setDebug(new DefaultDebug()); 18 | SmppObject.setEvent(new DefaultEvent()); 19 | } 20 | 21 | @Test 22 | public void testDRXTXConstant() { 23 | assertEquals(1, SmppObject.DRXTX); 24 | } 25 | @Test 26 | public void testDRXTXDConstant() { 27 | assertEquals(2, SmppObject.DRXTXD); 28 | } 29 | @Test 30 | public void testDRXTXD2Constant() { 31 | assertEquals(3, SmppObject.DRXTXD2); 32 | } 33 | @Test 34 | public void testDSESSConstant() { 35 | assertEquals(4, SmppObject.DSESS); 36 | } 37 | @Test 38 | public void testDPDUConstant() { 39 | assertEquals(5, SmppObject.DPDU); 40 | } 41 | @Test 42 | public void testDPDUDConstant() { 43 | assertEquals(6, SmppObject.DPDUD); 44 | } 45 | @Test 46 | public void testDCOMConstant() { 47 | assertEquals(7, SmppObject.DCOM); 48 | } 49 | @Test 50 | public void testDCOMDConstant() { 51 | assertEquals(8, SmppObject.DCOMD); 52 | } 53 | @Test 54 | public void testDUTLConstant() { 55 | assertEquals(9, SmppObject.DUTL); 56 | } 57 | @Test 58 | public void testDUTLDConstant() { 59 | assertEquals(10, SmppObject.DUTLD); 60 | } 61 | 62 | @Test 63 | public void testDefaultDebug() { 64 | assertEquals(DefaultDebug.class, SmppObject.getDebug().getClass()); 65 | } 66 | @Test 67 | public void testDefaultEvent() { 68 | assertEquals(DefaultEvent.class, SmppObject.getEvent().getClass()); 69 | } 70 | 71 | @Test 72 | public void testSetDebug() { 73 | Debug debug = mock(Debug.class); 74 | SmppObject.setDebug(debug); 75 | assertEquals(debug, SmppObject.getDebug()); 76 | } 77 | @Test 78 | public void testSetEvent() { 79 | Event event = mock(Event.class); 80 | SmppObject.setEvent(event); 81 | assertEquals(event, SmppObject.getEvent()); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/TestUtils.java: -------------------------------------------------------------------------------- 1 | package org.smpp; 2 | 3 | import org.smpp.debug.DefaultDebug; 4 | import org.smpp.debug.DefaultEvent; 5 | 6 | public class TestUtils { 7 | 8 | /** 9 | * Switch on debugging to stdout. 10 | */ 11 | public static void debuggingToStdout() { 12 | DebugWithThreadName debugWithThreadName = new TestUtils.DebugWithThreadName(); 13 | debugWithThreadName.activate(); 14 | SmppObject.setDebug(debugWithThreadName); 15 | } 16 | 17 | /** 18 | * Switch on events to stdout. 19 | */ 20 | public static void eventsToStdout() { 21 | EventWithThreadName eventWithThreadName = new TestUtils.EventWithThreadName(); 22 | eventWithThreadName.activate(); 23 | SmppObject.setEvent(eventWithThreadName); 24 | 25 | } 26 | 27 | public static class DebugWithThreadName extends DefaultDebug { 28 | @Override 29 | public void write(String msg) { 30 | super.write("[" + Thread.currentThread().getName() + "] " + msg); 31 | } 32 | } 33 | public static class EventWithThreadName extends DefaultEvent { 34 | @Override 35 | public void write(String msg) { 36 | super.write("[" + Thread.currentThread().getName() + "] " + msg); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/debug/DefaultDebugTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp.debug; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.PrintStream; 7 | 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | public class DefaultDebugTest { 13 | private static final Object OBJECT = new Object() { 14 | @Override public String toString() { return "OBJECT"; } 15 | }; 16 | private static final String NAME = "NAME"; 17 | private static final String EMPTY = ""; 18 | 19 | private ByteArrayOutputStream out; 20 | 21 | private DefaultDebug debug; 22 | 23 | private static final String newLine = System.getProperty("line.separator"); 24 | 25 | @Before 26 | public void setup() { 27 | debug = new DefaultDebug(); 28 | debug.activate(); 29 | } 30 | 31 | @Before 32 | public void setupStreams() { 33 | out = new ByteArrayOutputStream(); 34 | 35 | System.setOut(new PrintStream(out)); 36 | } 37 | 38 | @After 39 | public void cleanUpStreams() { 40 | System.setOut(null); 41 | } 42 | 43 | @Test 44 | public void testEnterWithName() { 45 | debug.enter(0, OBJECT, NAME); 46 | assertEquals("-> OBJECT NAME" + newLine, out.toString()); 47 | } 48 | @Test 49 | public void testEnterWithoutName() { 50 | debug.enter(0, OBJECT, EMPTY); 51 | assertEquals("-> OBJECT" + newLine, out.toString()); 52 | } 53 | @Test 54 | public void testExit() { 55 | debug.exit(0, OBJECT); 56 | assertEquals("<- OBJECT" + newLine, out.toString()); 57 | } 58 | @Test 59 | public void testWrite() { 60 | debug.write(0, "HELLO"); 61 | assertEquals(" HELLO" + newLine, out.toString()); 62 | } 63 | @Test 64 | public void testNestedEnter() { 65 | debug.enter(OBJECT, NAME); 66 | debug.enter(OBJECT, NAME); 67 | assertEquals("-> OBJECT NAME" + newLine + " -> OBJECT NAME" + newLine, out.toString()); 68 | } 69 | @Test 70 | public void testNestedWrite() { 71 | debug.enter(0, OBJECT, NAME); 72 | debug.write(0, "HELLO"); 73 | assertEquals("-> OBJECT NAME" + newLine + " HELLO" + newLine, out.toString()); 74 | } 75 | @Test 76 | public void testDeactivate() { 77 | debug.deactivate(); 78 | debug.write(0, "HELLO"); 79 | assertEquals("", out.toString()); 80 | } 81 | @Test 82 | public void testDeactiveGroupDoesNothing() { 83 | debug.deactivate(0); 84 | debug.write(0, "HELLO"); 85 | assertEquals(" HELLO" + newLine, out.toString()); 86 | } 87 | @Test 88 | public void testActivateGroupDoesNothing() { 89 | debug.deactivate(); 90 | debug.write("HELLO"); 91 | assertEquals("", out.toString()); 92 | debug.activate(0); 93 | debug.write(0, "HELLO"); 94 | assertEquals("", out.toString()); 95 | } 96 | @Test 97 | public void testActiveIsAlwaysTrue() { 98 | assertTrue(debug.active(0)); 99 | debug.deactivate(0); 100 | assertTrue(debug.active(0)); 101 | debug.deactivate(); 102 | assertTrue(debug.active(0)); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/debug/DefaultEventTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp.debug; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.PrintStream; 7 | 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | public class DefaultEventTest { 13 | 14 | private ByteArrayOutputStream out; 15 | 16 | private DefaultEvent event; 17 | 18 | private static final String newLine = System.getProperty("line.separator"); 19 | 20 | @Before 21 | public void setup() { 22 | event = new DefaultEvent(); 23 | event.activate(); 24 | } 25 | 26 | @Before 27 | public void setupStreams() { 28 | out = new ByteArrayOutputStream(); 29 | 30 | System.setOut(new PrintStream(out)); 31 | } 32 | 33 | @After 34 | public void cleanUpStreams() { 35 | System.setOut(null); 36 | } 37 | 38 | @Test 39 | public void testInactiveByDefault() { 40 | event = new DefaultEvent(); 41 | event.write("HELLO"); 42 | assertEquals("", out.toString()); 43 | } 44 | @Test 45 | public void testWrite() { 46 | event.write("HELLO"); 47 | assertEquals("HELLO" + newLine, out.toString()); 48 | } 49 | @Test 50 | public void testWriteException() { 51 | try { throw new RuntimeException(); } 52 | catch (Exception ex) { 53 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 54 | ex.printStackTrace(new PrintStream(baos)); 55 | 56 | String expected = "Exception: " + baos.toString() + " END" + newLine; 57 | event.write(ex, "END"); 58 | assertEquals(expected, out.toString()); 59 | } 60 | } 61 | @Test 62 | public void testDeactivate() { 63 | event.deactivate(); 64 | event.write("HELLO"); 65 | assertEquals("", out.toString()); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/pdu/Matchers.java: -------------------------------------------------------------------------------- 1 | package org.smpp.pdu; 2 | 3 | import org.hamcrest.BaseMatcher; 4 | import org.hamcrest.Description; 5 | import org.hamcrest.Matcher; 6 | 7 | public class Matchers { 8 | public static Matcher stringLengthException(int min, int max, int actual) { 9 | return new WrongLengthOfStringExceptionMatcher(min, max, actual); 10 | } 11 | 12 | public static Matcher integerOutOfRange(int min, int max, int actual) { 13 | return new IntegerOutOfRangeExceptionMatcher(min, max, actual); 14 | } 15 | 16 | private static class WrongLengthOfStringExceptionMatcher extends BaseMatcher { 17 | private static final String FORMAT = "org.smpp.pdu.WrongLengthOfStringException: The string is shorter or longer than required: min=%d max=%d actual=%d."; 18 | 19 | private final int min; 20 | private final int max; 21 | private final int actual; 22 | 23 | private WrongLengthOfStringExceptionMatcher(int min, int max, int actual) { 24 | this.min = min; 25 | this.max = max; 26 | this.actual = actual; 27 | } 28 | 29 | public boolean matches(Object item) { 30 | if (! (item instanceof WrongLengthOfStringException)) { 31 | return false; 32 | } 33 | 34 | return String.format(FORMAT, min, max, actual).equals(((WrongLengthOfStringException) item).toString()); 35 | } 36 | 37 | public void describeTo(Description description) { 38 | description.appendText("Wrong length of string"); 39 | } 40 | } 41 | 42 | public static class IntegerOutOfRangeExceptionMatcher extends BaseMatcher { 43 | private static final String FORMAT = "org.smpp.pdu.IntegerOutOfRangeException: The integer is lower or greater than required: min=%d max=%d actual=%d."; 44 | 45 | private final int min; 46 | private final int max; 47 | private final int actual; 48 | 49 | private IntegerOutOfRangeExceptionMatcher(int min, int max, int actual) { 50 | this.min = min; 51 | this.max = max; 52 | this.actual = actual; 53 | } 54 | 55 | public boolean matches(Object item) { 56 | if (! (item instanceof IntegerOutOfRangeException)) { 57 | return false; 58 | } 59 | 60 | return String.format(FORMAT, min, max, actual).equals(((IntegerOutOfRangeException) item).toString()); 61 | } 62 | 63 | public void describeTo(Description description) { 64 | description.appendText("Integer out of range"); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/util/NotEnoughDataInByteBufferExceptionMatcher.java: -------------------------------------------------------------------------------- 1 | package org.smpp.util; 2 | 3 | import org.hamcrest.Description; 4 | import org.hamcrest.TypeSafeMatcher; 5 | import org.smpp.util.NotEnoughDataInByteBufferException; 6 | 7 | public class NotEnoughDataInByteBufferExceptionMatcher extends TypeSafeMatcher{ 8 | 9 | private final int expected; 10 | private final int available; 11 | 12 | public static NotEnoughDataInByteBufferExceptionMatcher notEnoughData(int expected, int available) { 13 | return new NotEnoughDataInByteBufferExceptionMatcher(expected, available); 14 | } 15 | 16 | public NotEnoughDataInByteBufferExceptionMatcher(int expected, int available) { 17 | this.expected = expected; 18 | this.available = available; 19 | } 20 | 21 | public void describeTo(Description description) { 22 | description 23 | .appendText("expected ") 24 | .appendValue(expected) 25 | .appendText("available ") 26 | .appendValue(available); 27 | } 28 | 29 | @Override 30 | protected boolean matchesSafely(NotEnoughDataInByteBufferException ex) { 31 | return ex.getExpected() == expected && ex.getAvailable() == available; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/util/QueueTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp.util; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Before; 6 | import org.junit.Rule; 7 | import org.junit.Test; 8 | import org.junit.rules.ExpectedException; 9 | 10 | public class QueueTest { 11 | 12 | private Queue queue; 13 | 14 | @Rule 15 | public ExpectedException thrown = ExpectedException.none(); 16 | 17 | @Before 18 | public void setup() { 19 | queue = new Queue(); 20 | } 21 | 22 | @Test 23 | public void testDefaultConstructorDoesNotLimitSize() { 24 | Object o = new Object(); 25 | // FIXME: there seems to be a performance issue going over this... 26 | int limit = 1000000; 27 | for (int i = 0; i < limit; i++) { 28 | queue.enqueue(o); 29 | } 30 | assertEquals(limit, queue.size()); 31 | } 32 | 33 | @Test 34 | public void testConstructorLimitsSize() throws IndexOutOfBoundsException { 35 | thrown.expect(IndexOutOfBoundsException.class); 36 | 37 | queue = new Queue(10); 38 | for (int i = 0; i < 11; i++) { 39 | queue.enqueue(new Object()); 40 | } 41 | } 42 | 43 | @Test 44 | public void testIsEmpty() { 45 | assertTrue(queue.isEmpty()); 46 | queue.enqueue(new Object()); 47 | assertFalse(queue.isEmpty()); 48 | queue.dequeue(); 49 | assertTrue(queue.isEmpty()); 50 | } 51 | 52 | @Test 53 | public void testSize() { 54 | int size = 0; 55 | assertEquals(size, queue.size()); 56 | for (int i = 0; i < 10; i++) { 57 | queue.enqueue(size++); 58 | assertEquals(size, queue.size()); 59 | } 60 | } 61 | 62 | @Test 63 | public void testFifo() { 64 | Object a = new Object(); 65 | Object b = new Object(); 66 | Object c = new Object(); 67 | 68 | queue.enqueue(a); 69 | queue.enqueue(b); 70 | queue.enqueue(c); 71 | 72 | assertSame(a, queue.dequeue()); 73 | assertSame(b, queue.dequeue()); 74 | assertSame(c, queue.dequeue()); 75 | assertTrue(queue.isEmpty()); 76 | } 77 | 78 | @Test 79 | public void testFind() { 80 | Object a = new Object(); 81 | Object b = new Object(); 82 | Object c = new Object(); 83 | 84 | queue.enqueue(a); 85 | queue.enqueue(b); 86 | queue.enqueue(c); 87 | 88 | assertEquals(3, queue.size()); 89 | assertSame(a, queue.find(a)); 90 | assertSame(b, queue.find(b)); 91 | assertSame(c, queue.find(c)); 92 | assertEquals(3, queue.size()); 93 | } 94 | 95 | @Test 96 | public void testDequeueReturnsNullWhenEmpty() { 97 | assertNull(queue.dequeue()); 98 | } 99 | 100 | @Test 101 | public void testDequeueReturnsNullWhenNotEnqueued() { 102 | queue.enqueue(new Object()); 103 | assertNull(queue.dequeue(new Object())); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /core/src/test/java/org/smpp/util/UnprocessedTest.java: -------------------------------------------------------------------------------- 1 | package org.smpp.util; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | public class UnprocessedTest { 9 | 10 | private Unprocessed unprocessed; 11 | 12 | @Before 13 | public void setup() { 14 | unprocessed = new Unprocessed(); 15 | } 16 | 17 | @Test 18 | public void testInitialState() { 19 | assertEquals(0, unprocessed.getExpected()); 20 | assertEquals(0, unprocessed.getLastTimeReceived()); 21 | assertFalse(unprocessed.getHasUnprocessed()); 22 | } 23 | 24 | @Test 25 | public void testReset() { 26 | unprocessed.getUnprocessed().setBuffer(new byte[] { 0x00 }); 27 | unprocessed.setExpected(1); 28 | unprocessed.setHasUnprocessed(true); 29 | unprocessed.setLastTimeReceived(1); 30 | 31 | unprocessed.reset(); 32 | 33 | assertNull(unprocessed.getUnprocessed().getBuffer()); 34 | assertEquals(0, unprocessed.getExpected()); 35 | assertFalse(unprocessed.getHasUnprocessed()); 36 | // specifically, this is not reset, for reasons unknown 37 | assertEquals(1, unprocessed.getLastTimeReceived()); 38 | } 39 | 40 | @Test 41 | public void testCheckWithNullBuffer() { 42 | unprocessed.getUnprocessed().setBuffer(null); 43 | unprocessed.check(); 44 | assertFalse(unprocessed.getHasUnprocessed()); 45 | } 46 | 47 | @Test 48 | public void testCheckWithEmptyBuffer() { 49 | unprocessed.getUnprocessed().setBuffer(new byte[] {}); 50 | unprocessed.check(); 51 | assertFalse(unprocessed.getHasUnprocessed()); 52 | } 53 | 54 | @Test 55 | public void testCheckWithBuffer() { 56 | unprocessed.getUnprocessed().setBuffer(new byte[] { 0x00 }); 57 | unprocessed.check(); 58 | assertTrue(unprocessed.getHasUnprocessed()); 59 | } 60 | 61 | @Test 62 | public void testSetUnprocessed() { 63 | unprocessed.setHasUnprocessed(true); 64 | assertTrue(unprocessed.getHasUnprocessed()); 65 | } 66 | 67 | @Test 68 | public void testSetExpected() { 69 | unprocessed.setExpected(1234); 70 | assertEquals(1234, unprocessed.getExpected()); 71 | } 72 | 73 | @Test 74 | public void testSetTimeLastReceivedWithValue() { 75 | unprocessed.setLastTimeReceived(1234L); 76 | assertEquals(1234L, unprocessed.getLastTimeReceived()); 77 | } 78 | 79 | @Test 80 | public void testSetTimeLastReceived() { 81 | unprocessed.setLastTimeReceived(); 82 | assertTrue(Math.abs(unprocessed.getLastTimeReceived() - System.currentTimeMillis()) < 5); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /sim/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.opensmpp 7 | opensmpp-parent 8 | 3.0.3-SNAPSHOT 9 | 10 | opensmpp-sim 11 | jar 12 | OpenSMPP Simulator 13 | 14 | 15 | org.smpp.smscsim.Simulator 16 | 17 | 18 | 19 | 20 | ${project.groupId} 21 | opensmpp-core 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-shade-plugin 30 | 3.1.0 31 | 32 | false 33 | 34 | 35 | 36 | 37 | ${app.mainClass} 38 | 39 | 40 | 41 | 42 | 43 | 44 | package 45 | 46 | shade 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/PDUProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.smscsim; 12 | 13 | import java.io.IOException; 14 | 15 | import org.smpp.pdu.PDUException; 16 | import org.smpp.pdu.Request; 17 | import org.smpp.pdu.Response; 18 | 19 | /** 20 | * PDUProcessor is abstract class which defines interface 21 | * functions for processing PDUs received by SMSCSession 22 | * from client as well as functions for the server side sending of PDU. 23 | * The actual implementation of the abstract functions of the class 24 | * defines the behaviour of the particular simulator.
25 | * The implementations of this class are ment to be generated by 26 | * descendant of PDUProcessorFactory class whenewer 27 | * new connection is accepted by SMSCListener. 28 | * 29 | * @author Logica Mobile Networks SMPP Open Source Team 30 | * @version $Revision: 1.2 $ 31 | * @see PDUProcessorFactory 32 | * @see SMSCSession 33 | * @see SMSCListener 34 | */ 35 | public abstract class PDUProcessor { 36 | /** 37 | * The group the processor belongs to. It's good for having overall control 38 | * over specific group of processors, e.g. for those generated 39 | * for particular listener. 40 | */ 41 | private PDUProcessorGroup group = null; 42 | 43 | /** 44 | * If the processor is still processing, i.e. wasn't exited. 45 | * @see #exit() 46 | */ 47 | private boolean active = true; 48 | 49 | /** 50 | * Private variables initialsed to default values. 51 | */ 52 | public PDUProcessor() { 53 | } 54 | 55 | /** 56 | * Initialises the processor with the given group. 57 | * The group is basicaly intended to be a group of active 58 | * processors. 59 | * @param group the group this processor belongs to 60 | */ 61 | public PDUProcessor(PDUProcessorGroup group) { 62 | setGroup(group); 63 | } 64 | 65 | /** 66 | * Meant to process requests received from client. 67 | * @param request the request received from client 68 | */ 69 | public abstract void clientRequest(Request request); 70 | 71 | /** 72 | * Meant to process responses received from client. 73 | * @param response the response received from client 74 | */ 75 | public abstract void clientResponse(Response response); 76 | 77 | /** 78 | * Meant to process requests sent on behalf of the server. 79 | * This method is called by server and typically only sends the PDU 80 | * to the client. 81 | * @param request the request which has to be sent to client 82 | */ 83 | public abstract void serverRequest(Request request) throws IOException, PDUException; 84 | 85 | /** 86 | * Meant to process responses sent on behalf of the server. 87 | * This method is called by server and typically only sends the PDU 88 | * to the client. 89 | * @param response the response which has to be sent to client 90 | */ 91 | public abstract void serverResponse(Response response) throws IOException, PDUException; 92 | 93 | /** 94 | * Stop the processor 95 | */ 96 | public abstract void stop(); 97 | 98 | /** 99 | * Sets the group which the pdu processor belongs to. 100 | * Processor can belong to only one group. 101 | * @param g the new group for the processor 102 | */ 103 | public void setGroup(PDUProcessorGroup g) { 104 | if (group != null) { 105 | group.remove(this); 106 | } 107 | group = g; 108 | if (group != null) { 109 | group.add(this); 110 | } 111 | } 112 | 113 | /** 114 | * Returns the group of this pdu processor. 115 | * @return the current group of the processor 116 | * @see #setGroup(PDUProcessorGroup) 117 | */ 118 | public PDUProcessorGroup getGroup() { 119 | return group; 120 | } 121 | 122 | /** 123 | * Returns if this pdu processor is still active. 124 | * @return the activity status of the processor 125 | * @see #exit() 126 | */ 127 | public boolean isActive() { 128 | return active; 129 | } 130 | 131 | /** 132 | * Sets the processor to inactive state. 133 | * Removes the processor from the group it belonged to. 134 | * Called from SMSCSession. 135 | * @see SMSCSession#run() 136 | */ 137 | public void exit() { 138 | if (group != null) { 139 | group.remove(this); 140 | } 141 | active = false; 142 | stop(); 143 | } 144 | } 145 | /* 146 | * $Log: not supported by cvs2svn $ 147 | * Revision 1.1 2003/07/23 00:28:39 sverkera 148 | * Imported 149 | * 150 | */ -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/PDUProcessorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.smscsim; 12 | 13 | /** 14 | * Descandants of this class are passed to SMSCListener for 15 | * generating instancies of classes derived from PDUProcessor. 16 | * User should set up their derived classes so that they contain all 17 | * information necessary for generating new PDU processors. 18 | * This way is the logic of the PDU processing isolated from logic of 19 | * establishing new connections (sessions). 20 | * 21 | * @author Logica Mobile Networks SMPP Open Source Team 22 | * @version $Revision: 1.1 $ 23 | * @see PDUProcessor 24 | * @see SMSCListener 25 | * @see SMSCSession 26 | */ 27 | public interface PDUProcessorFactory { 28 | /** 29 | * Should generate proper PDU processor for processing of PDUs. 30 | * @param session the session the PDU processor should work on 31 | * @return the new PDU processor for processing reqests and responses 32 | */ 33 | public abstract PDUProcessor createPDUProcessor(SMSCSession session); 34 | } 35 | /* 36 | * $Log: not supported by cvs2svn $ 37 | */ 38 | -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/PDUProcessorGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.smscsim; 12 | 13 | import java.util.Vector; 14 | 15 | /** 16 | * Simple container to hold set of somehow related processors. 17 | * 18 | * @author Logica Mobile Networks SMPP Open Source Team 19 | * @version $Revision: 1.1 $ 20 | * @see PDUProcessor 21 | */ 22 | public class PDUProcessorGroup { 23 | private Vector processors = null; 24 | 25 | /** 26 | * Initialises the underlying container. 27 | */ 28 | public PDUProcessorGroup() { 29 | processors = new Vector(); 30 | } 31 | 32 | /** 33 | * Initialises the underlying container to the given size. 34 | */ 35 | public PDUProcessorGroup(int initSize) { 36 | processors = new Vector(initSize); 37 | } 38 | 39 | /** 40 | * Adds single processor to the group. 41 | * @param p the processor to add 42 | * @see #remove(PDUProcessor) 43 | */ 44 | public void add(PDUProcessor p) { 45 | synchronized (processors) { 46 | if (!processors.contains(p)) { 47 | processors.add(p); 48 | } 49 | } 50 | } 51 | 52 | /** 53 | * Removes single processor from the group. 54 | * @param p the processor to remove 55 | * @see #add(PDUProcessor) 56 | */ 57 | public void remove(PDUProcessor p) { 58 | synchronized (processors) { 59 | processors.remove(p); 60 | } 61 | } 62 | 63 | /** 64 | * Returns the count of the processors currently in the group. 65 | * @return current count of processors in the group 66 | */ 67 | public int count() { 68 | synchronized (processors) { 69 | return processors.size(); 70 | } 71 | } 72 | 73 | /** 74 | * Returns ith processor in the group. 75 | * @param i index of the processor to return 76 | * @return the processor on the given position 77 | */ 78 | public PDUProcessor get(int i) { 79 | synchronized (processors) { 80 | return (PDUProcessor) processors.get(i); 81 | } 82 | } 83 | } 84 | /* 85 | * $Log: not supported by cvs2svn $ 86 | */ 87 | -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/SMSCListener.java: -------------------------------------------------------------------------------- 1 | package org.smpp.smscsim; 2 | 3 | import java.io.IOException; 4 | 5 | /* Created on 2003-jul-26 */ 6 | 7 | /** 8 | * Please enter a description of this class here 9 | * 10 | * @author Sverker Abrahamsson 11 | * 12 | * @version $Revision: 1.2 $ 13 | * 14 | */ 15 | public interface SMSCListener { 16 | /** 17 | * Starts the listening. If the listener is asynchronous (reccomended), 18 | * then new thread is created which listens on the port and the 19 | * start method returns to the caller. Otherwise 20 | * the caller is blocked in the start method. 21 | * @see #stop() 22 | */ 23 | public abstract void start() throws IOException; 24 | /** 25 | * Signals the listener that it should stop listening and wait 26 | * until the listener stops. Note that based on the timeout settings 27 | * it can take some time befor this method is finished -- the listener 28 | * can be blocked on i/o operation and only after exiting i/o 29 | * it can detect that it should stop. 30 | * @see #start() 31 | */ 32 | public abstract void stop() throws IOException; 33 | /** 34 | * The actual listening code which is run either from the thread 35 | * (for async listener) or called from start method 36 | * (for sync listener). The method can be exited by calling of method 37 | * stop. 38 | * @see #start() 39 | * @see #stop() 40 | */ 41 | public abstract void run(); 42 | /** 43 | * Sets a PDU processor factory to use for generating PDU processors. 44 | * @param processorFactory the new PDU processor factory 45 | */ 46 | public abstract void setPDUProcessorFactory(PDUProcessorFactory processorFactory); 47 | /** 48 | * Sets new timeout for accepting new connection. 49 | * The listening blocks the for maximum this time, then it 50 | * exits regardless the connection was acctepted or not. 51 | * @param value the new value for accept timeout 52 | */ 53 | public abstract void setAcceptTimeout(int value); 54 | /** 55 | * Returns the current setting of accept timeout. 56 | * @return the current accept timeout 57 | * @see #setAcceptTimeout(int) 58 | */ 59 | public abstract long getAcceptTimeout(); 60 | } 61 | /* 62 | * $Log: not supported by cvs2svn $ 63 | */ -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/SMSCSession.java: -------------------------------------------------------------------------------- 1 | package org.smpp.smscsim; 2 | 3 | import java.io.IOException; 4 | 5 | import org.smpp.Connection; 6 | import org.smpp.pdu.PDU; 7 | import org.smpp.pdu.PDUException; 8 | 9 | /* Created on 2003-jul-28 */ 10 | 11 | /** 12 | * Please enter a description of this class here 13 | * 14 | * @author Sverker Abrahamsson 15 | * 16 | * @version $Id: SMSCSession.java 85 2010-04-26 13:39:31Z sverkera $ 17 | * 18 | */ 19 | public interface SMSCSession extends Runnable { 20 | /** 21 | * Signals the session's thread that it should stop. 22 | * Doesn't wait for the thread to be completly finished. 23 | * Note that it can take some time before the thread is completly 24 | * stopped. 25 | * @see #run() 26 | */ 27 | public abstract void stop(); 28 | /** 29 | * Implements the logic of receiving of the PDUs from client and passing 30 | * them to PDU processor. First starts receiver, then in cycle 31 | * receives PDUs and passes them to the proper PDU processor's 32 | * methods. After the function stop is called (externally) 33 | * stops the receiver, exits the PDU processor and closes the connection, 34 | * so no extry tidy-up routines are necessary. 35 | * @see #stop() 36 | * @see PDUProcessor#clientRequest(Request) 37 | * @see PDUProcessor#clientResponse(Response) 38 | */ 39 | public abstract void run(); 40 | /** 41 | * Sends a PDU to the client. 42 | * @param pdu the PDU to send 43 | */ 44 | public abstract void send(PDU pdu) throws IOException, PDUException; 45 | /** 46 | * Sets new PDU processor. 47 | * @param pduProcessor the new PDU processor 48 | */ 49 | public abstract void setPDUProcessor(PDUProcessor pduProcessor); 50 | /** 51 | * Sets PDU processor factory, used instead of setPDUProcessor in case the session creates 52 | * the PDU processor. 53 | * @param pduProcessorFactory the PDU processor factory 54 | * @see #setPDUProcessor() 55 | */ 56 | public abstract void setPDUProcessorFactory(PDUProcessorFactory pduProcessorFactory); 57 | /** 58 | * Sets the timeout for receiving the complete message. 59 | * @param timeout the new timeout value 60 | */ 61 | public abstract void setReceiveTimeout(long timeout); 62 | /** 63 | * Returns the current setting of receiving timeout. 64 | * @return the current timeout value 65 | */ 66 | public abstract long getReceiveTimeout(); 67 | 68 | /** 69 | * Returns the details about the account that is logged in to this session 70 | * @return An object representing the account. It is casted to the correct type by the implementation 71 | */ 72 | public abstract Object getAccount(); 73 | 74 | /** 75 | * Set details about the account that is logged in to this session 76 | * @param account An object representing the account. It is casted to the correct type by the implementation 77 | */ 78 | public abstract void setAccount(Object account); 79 | 80 | public abstract Connection getConnection(); 81 | } 82 | /* 83 | * $Log: not supported by cvs2svn $ 84 | * Revision 1.2 2003/09/30 09:17:49 sverkera 85 | * Created an interface for SMSCListener and SMSCSession and implementations of them so that it is possible to provide other implementations of these classes. 86 | * 87 | */ -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/ShortMessageValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.smscsim; 12 | 13 | import org.smpp.pdu.SubmitSM; 14 | import org.smpp.util.DataCodingCharsetHandler; 15 | 16 | import java.io.UnsupportedEncodingException; 17 | 18 | /** 19 | * Class for storing a subset of attributes of messages to a message store. 20 | * 21 | * @author Logica Mobile Networks SMPP Open Source Team 22 | * @version $Revision: 1.1 $ 23 | */ 24 | class ShortMessageValue { 25 | String systemId; 26 | String serviceType; 27 | String sourceAddr; 28 | String destinationAddr; 29 | String shortMessage; 30 | 31 | /** 32 | * Constructor for building the object from SubmitSM 33 | * PDU. 34 | * 35 | * @param systemId system id of the client 36 | * @param submit the PDU send from the client 37 | */ 38 | ShortMessageValue(String systemId, SubmitSM submit) throws UnsupportedEncodingException { 39 | this.systemId = systemId; 40 | serviceType = submit.getServiceType(); 41 | sourceAddr = submit.getSourceAddr().getAddress(); 42 | destinationAddr = submit.getDestAddr().getAddress(); 43 | 44 | String encoding = DataCodingCharsetHandler.getCharsetName(submit.getDataCoding()); 45 | shortMessage = submit.getShortMessage(encoding); 46 | } 47 | } 48 | /* 49 | * $Log: not supported by cvs2svn $ 50 | */ 51 | -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/SimulatorPDUProcessorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.smscsim; 12 | 13 | import org.smpp.debug.FileLog; 14 | import org.smpp.smscsim.util.Table; 15 | /** 16 | * Class SimulatorPDUProcessorFactory creates new instances of 17 | * a SimulatorPDUProcessor. It's passed to SMSCListener 18 | * which uses it to create new PDU processors whenewer new connection 19 | * from client is requested. The PDU processor is passed to 20 | * instance of SMSCSession which uses the processor to handle 21 | * client requests and responses. 22 | * 23 | * @author Logica Mobile Networks SMPP Open Source Team 24 | * @version $Revision: 1.1 $ 25 | * @see PDUProcessorFactory 26 | * @see PDUProcessorGroup 27 | * @see SimulatorPDUProcessor 28 | */ 29 | public class SimulatorPDUProcessorFactory implements PDUProcessorFactory { 30 | private PDUProcessorGroup procGroup; 31 | private ShortMessageStore messageStore; 32 | private DeliveryInfoSender deliveryInfoSender; 33 | private Table users; 34 | 35 | /** 36 | * If the information about processing has to be printed 37 | * to the standard output. 38 | */ 39 | private boolean displayInfo = false; 40 | 41 | /** 42 | * Constructs processor factory with given processor group, 43 | * message store for storing of the messages and a table of 44 | * users for authentication. The message store and users parameters are 45 | * passed to generated instancies of SimulatorPDUProcessor. 46 | * @param procGroup the group the newly generated PDU processors will belong to 47 | * @param messageStore the store for messages received from the client 48 | * @param users the list of users used for authenticating of the client 49 | */ 50 | public SimulatorPDUProcessorFactory( 51 | PDUProcessorGroup procGroup, 52 | ShortMessageStore messageStore, 53 | DeliveryInfoSender deliveryInfoSender, 54 | Table users) { 55 | this.procGroup = procGroup; 56 | this.messageStore = messageStore; 57 | this.deliveryInfoSender = deliveryInfoSender; 58 | this.users = users; 59 | } 60 | 61 | /** 62 | * Creates a new instance of SimulatorPDUProcessor with 63 | * parameters provided in construction of th factory. 64 | * 65 | * @param session the sessin the PDU processor will work for 66 | * @return newly created SimulatorPDUProcessor 67 | */ 68 | public PDUProcessor createPDUProcessor(SMSCSession session) { 69 | SimulatorPDUProcessor simPDUProcessor = new SimulatorPDUProcessor(session, messageStore, users); 70 | simPDUProcessor.setDisplayInfo(getDisplayInfo()); 71 | simPDUProcessor.setGroup(procGroup); 72 | simPDUProcessor.setDeliveryInfoSender(deliveryInfoSender); 73 | display("new connection accepted"); 74 | return simPDUProcessor; 75 | } 76 | 77 | /** 78 | * Sets if the info about processing has to be printed on 79 | * the standard output. 80 | */ 81 | public void setDisplayInfo(boolean on) { 82 | displayInfo = on; 83 | } 84 | 85 | /** 86 | * Returns status of printing of processing info on the standard output. 87 | */ 88 | public boolean getDisplayInfo() { 89 | return displayInfo; 90 | } 91 | 92 | private void display(String info) { 93 | if (getDisplayInfo()) { 94 | System.out.println(FileLog.getLineTimeStamp() + " [sys] " + info); 95 | } 96 | } 97 | } 98 | /* 99 | * $Log: not supported by cvs2svn $ 100 | * 101 | * Old changelog: 102 | * 20-09-01 ticp@logica.com added reference to the DeliveryInfoSender to support 103 | * automatic sending of delivery info PDUs 104 | */ 105 | -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/util/Attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.smscsim.util; 12 | 13 | /** 14 | * Represents an attribute (field) of a Record. Each attribute 15 | * has name and a value. Values are textual, i.e. if you want to use 16 | * this class to work with integral values, you have to cast the values 17 | * explicitly. 18 | * 19 | * @author Logica Mobile Networks SMPP Open Source Team 20 | * @version $Revision: 1.1 $ 21 | * @see Record 22 | * @see Table 23 | */ 24 | public class Attribute { 25 | /** 26 | * The name of the attribute 27 | */ 28 | private String name = null; 29 | 30 | /** 31 | * The value of the attribute. 32 | */ 33 | private String value = null; 34 | 35 | /** 36 | * Default constructor initialises name and value 37 | * of the attribute to empty (null) values. 38 | * @see #setName(String) 39 | * @see #setValue(String) 40 | */ 41 | public Attribute() { 42 | } 43 | 44 | /** 45 | * If you know the name but not the value yet, use this constructor. 46 | * @see #setValue(String) 47 | */ 48 | public Attribute(String name) { 49 | this.name = name; 50 | } 51 | 52 | /** 53 | * Initialises the attribute's both name and value 54 | */ 55 | public Attribute(String name, String value) { 56 | this.name = name; 57 | this.value = value; 58 | } 59 | 60 | /** 61 | * Sets the name of the attribute. 62 | * @param name the new value for the name of the attribute. 63 | */ 64 | public void setName(String name) { 65 | this.name = name; 66 | } 67 | 68 | /** 69 | * Sets the value of the attribute. 70 | * @param value the new vlaue of the attribute. 71 | */ 72 | public void setValue(String value) { 73 | this.value = value; 74 | } 75 | 76 | /** 77 | * Returns the name of the attribute. 78 | * @return the name of the attribute 79 | */ 80 | public String getName() { 81 | return name; 82 | } 83 | 84 | /** 85 | * Returns the current value of the attribute. 86 | * @return the current value of the attribute 87 | */ 88 | public String getValue() { 89 | return value; 90 | } 91 | 92 | /** 93 | * Compares the name of the attribute to the provided value. 94 | * The comparison is case sensitive, i.e. 'Password' and 'password' are 95 | * different names! 96 | * @param name the name to compare the attribute's name to 97 | * @return if the name of the attribute is equal to the provided name 98 | */ 99 | public boolean nameEquals(String name) { 100 | if (this.name != null) { 101 | return this.name.equals(name); 102 | } else { 103 | return name == null; // nulls are equal 104 | } 105 | } 106 | 107 | /** 108 | * Compares two attributes if their names and values are equal. 109 | * @param attr the attribute to compare this attribute to 110 | * @return if the attribute's name & value are equal to those of 111 | * the provided 112 | */ 113 | public boolean equals(Attribute attr) { 114 | if (attr != null) { 115 | if (nameEquals(attr.getName())) { 116 | if (this.value != null) { 117 | return this.value.equals(value); 118 | } else { 119 | return value == null; // nulls are equal 120 | } 121 | } else { 122 | return false; 123 | } 124 | } else { 125 | return false; 126 | } 127 | } 128 | } 129 | /* 130 | * $Log: not supported by cvs2svn $ 131 | */ 132 | -------------------------------------------------------------------------------- /sim/src/main/java/org/smpp/smscsim/util/TableParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2001 3 | * Logica Mobile Networks Limited 4 | * All rights reserved. 5 | * 6 | * This software is distributed under Logica Open Source License Version 1.0 7 | * ("Licence Agreement"). You shall use it and distribute only in accordance 8 | * with the terms of the License Agreement. 9 | * 10 | */ 11 | package org.smpp.smscsim.util; 12 | 13 | import java.io.InputStream; 14 | import java.io.IOException; 15 | import java.io.OutputStream; 16 | 17 | /** 18 | * The TableParser is an interface for parsing and exportin 19 | * of Table data from and to data streams. 20 | * 21 | * @author Logica Mobile Networks SMPP Open Source Team 22 | * @version $Revision: 1.1 $ 23 | */ 24 | public interface TableParser { 25 | /** 26 | * Should write the table to the output stream. 27 | * @param os the output stream to write to 28 | */ 29 | public void compose(OutputStream os) throws IOException; 30 | 31 | /** 32 | * Should read the table from the input stream. 33 | * @param is the stream to read the table from 34 | */ 35 | public void parse(InputStream is) throws IOException; 36 | } 37 | /* 38 | * $Log: not supported by cvs2svn $ 39 | */ 40 | -------------------------------------------------------------------------------- /sim/users.txt: -------------------------------------------------------------------------------- 1 | # This is an example of user definition file used to authenticate bounding ESME. 2 | # User consists from attributes, each attribute is on one line, 3 | # each attribute has key and value; users are delimited by one or more 4 | # consecutive blank lines - next user is started by the next attribute after 5 | # first occurence of blank line. 6 | # Comment line can appear anywhere and it's ignored => it can't delimit 7 | # two users. 8 | # Format of attribute is "=" 9 | # 10 | # The name and password attributes are compulsory for each user definition 11 | # as they are compared to the system_id and password parameters 12 | # in the incoming bound PDU. 13 | # 14 | # Note that timeout and bound attributes below are just exampples 15 | # of additional attributes and aren't really used by the simulator :-) 16 | # (future expansion?) 17 | # Also note that whitespaces aren't removed from neither attribute name 18 | # and it's value, i.e. "name=peter" and "name= peter" define two different users, 19 | # "peter" and " peter". 20 | 21 | 22 | # Pavel can bound for unlimited time as any type 23 | name=pavel 24 | password=dfsew 25 | timeout=unlimited 26 | 27 | 28 | # Jorge has time limited to 10, then the connection is dropped 29 | # if enquire is unsuccessfull 30 | # Also, Jorge can connect only as triansmitter or receiver, he can't 31 | # connect as transciever 32 | 33 | name=jorge 34 | password=prtgljrg 35 | # And this timeout is in minutes, bad luck, jorge %^) 36 | timout=5 37 | bound=t,r 38 | 39 | # And another users 40 | name=hugo 41 | password=ggoohu 42 | 43 | # that's all folks 44 | name=DAMIEN 45 | password=neimad 46 | 47 | --------------------------------------------------------------------------------