├── conf
├── smpp-lib.zip
├── logback.xml
├── Logging.properties
├── props.mo
└── props.std_test
├── src
├── main
│ └── java
│ │ ├── manifest.txt
│ │ ├── com
│ │ └── seleniumsoftware
│ │ │ ├── examples
│ │ │ ├── CallbackReceivable.java
│ │ │ ├── CallbackServer.java
│ │ │ ├── CallbackReceiver.java
│ │ │ └── CallbackHandler.java
│ │ │ └── SMPPSim
│ │ │ ├── Counter.java
│ │ │ ├── pdu
│ │ │ ├── util
│ │ │ │ └── SeqnoStatus.java
│ │ │ ├── Demarshaller.java
│ │ │ ├── Marshaller.java
│ │ │ ├── DestAddress.java
│ │ │ ├── Unbind.java
│ │ │ ├── GenericNak.java
│ │ │ ├── EnquireLink.java
│ │ │ ├── DestAddressDL.java
│ │ │ ├── TlvEmpty.java
│ │ │ ├── UnbindResp.java
│ │ │ ├── CancelSMResp.java
│ │ │ ├── GenericNakResp.java
│ │ │ ├── Response.java
│ │ │ ├── EnquireLinkResp.java
│ │ │ ├── ReplaceSMResp.java
│ │ │ ├── DeliverSMResp.java
│ │ │ ├── DestAddressSME.java
│ │ │ ├── Tlv.java
│ │ │ ├── BindReceiverResp.java
│ │ │ ├── BindTransceiverResp.java
│ │ │ ├── BindTransmitterResp.java
│ │ │ ├── Request.java
│ │ │ ├── SubmitSMResp.java
│ │ │ ├── Pdu.java
│ │ │ ├── UnsuccessSME.java
│ │ │ ├── Outbind.java
│ │ │ ├── QuerySMResp.java
│ │ │ ├── SubmitMultiResp.java
│ │ │ ├── QuerySM.java
│ │ │ ├── DataSMResp.java
│ │ │ ├── BindReceiver.java
│ │ │ ├── BindTransmitter.java
│ │ │ └── BindTransceiver.java
│ │ │ ├── exceptions
│ │ │ ├── InternalException.java
│ │ │ ├── InboundQueueFullException.java
│ │ │ ├── InvalidHexStringlException.java
│ │ │ ├── OutboundQueueFullException.java
│ │ │ └── MessageStateNotFoundException.java
│ │ │ ├── LogFormatter.java
│ │ │ ├── Session.java
│ │ │ ├── CallbackServerConnector.java
│ │ │ ├── MessageQueue.java
│ │ │ ├── DeterministicLifeCycleManager.java
│ │ │ ├── util
│ │ │ ├── LoggingUtilities.java
│ │ │ └── Utilities.java
│ │ │ ├── DelayedDrQueue.java
│ │ │ ├── MoService.java
│ │ │ ├── MoMessagePool.java
│ │ │ ├── DelayedInboundQueue.java
│ │ │ └── LifeCycleManager.java
│ │ └── tests
│ │ ├── exceptions
│ │ ├── QuerySmFailedException.java
│ │ ├── CancelSmFailedException.java
│ │ ├── DeliverSmFailedException.java
│ │ ├── ReplaceSmFailedException.java
│ │ ├── SubmitSmFailedException.java
│ │ ├── EnquireLinkFailedException.java
│ │ ├── SubmitMultiFailedException.java
│ │ ├── BindReceiverException.java
│ │ ├── BindTransceiverException.java
│ │ └── BindTransmitterException.java
│ │ ├── SmppsimTests.java
│ │ ├── ReceiverLogger.java
│ │ ├── SmppsimEnquireLinkTests.java
│ │ ├── OutbindTest.java
│ │ ├── SmppsimQuerySmTests.java
│ │ ├── SmppsimDeliverSmTests.java
│ │ └── SmppsimReplaceSmTests.java
└── test
│ └── java
│ └── com
│ └── mycompany
│ └── smppsim
│ └── AppTest.java
├── startsmppsim.sh
├── README.md
├── .gitignore
└── pom.xml
/conf/smpp-lib.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haifzhan/SMPPSim/HEAD/conf/smpp-lib.zip
--------------------------------------------------------------------------------
/src/main/java/manifest.txt:
--------------------------------------------------------------------------------
1 | Main-Class: com.seleniumsoftware.SMPPSim.SMPPSim
2 | Class-Path: . lib/jakarta-regexp-1.2.jar
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/examples/CallbackReceivable.java:
--------------------------------------------------------------------------------
1 | package com.seleniumsoftware.examples;
2 |
3 | public interface CallbackReceivable {
4 | public void sent(byte pdu[]);
5 | public void received(byte pdu[]);
6 | }
--------------------------------------------------------------------------------
/startsmppsim.sh:
--------------------------------------------------------------------------------
1 | # $Header: /var/cvsroot/SMPPSim2/startsmppsim.sh,v 1.6 2005/12/09 17:35:32 martin Exp $
2 | #! /bin/bash
3 | #java -Djava.net.preferIPv4Stack=true -Djava.util.logging.config.file=conf/logging.properties -jar smppsim.jar conf/smppsim.props
4 | java -jar target/smppsim.jar conf/logback.xml conf/smppsim.props
5 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/QuerySmFailedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class QuerySmFailedException extends Exception {
10 | public QuerySmFailedException() {
11 | super();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/CancelSmFailedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class CancelSmFailedException extends Exception {
10 | public CancelSmFailedException() {
11 | super();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/DeliverSmFailedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class DeliverSmFailedException extends Exception {
10 | public DeliverSmFailedException() {
11 | super();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/ReplaceSmFailedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class ReplaceSmFailedException extends Exception {
10 | public ReplaceSmFailedException() {
11 | super();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/SubmitSmFailedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class SubmitSmFailedException extends Exception {
10 | public SubmitSmFailedException() {
11 | super();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/EnquireLinkFailedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class EnquireLinkFailedException extends Exception {
10 | public EnquireLinkFailedException() {
11 | super();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/SubmitMultiFailedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class SubmitMultiFailedException extends Exception {
10 | public SubmitMultiFailedException() {
11 | super();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/BindReceiverException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class BindReceiverException extends Exception {
10 | public BindReceiverException() {
11 | super();
12 | }
13 |
14 | public BindReceiverException(String message) {
15 | super(message);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/BindTransceiverException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class BindTransceiverException extends Exception {
10 | public BindTransceiverException() {
11 | super();
12 | }
13 |
14 | public BindTransceiverException(String message) {
15 | super(message);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/tests/exceptions/BindTransmitterException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004
3 | * Martin Woolley
4 | * All rights reserved.
5 | *
6 | */
7 | package tests.exceptions;
8 |
9 | public class BindTransmitterException extends Exception {
10 | public BindTransmitterException() {
11 | super();
12 | }
13 |
14 | public BindTransmitterException(String message) {
15 | super(message);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/Counter.java:
--------------------------------------------------------------------------------
1 | package com.seleniumsoftware.SMPPSim;
2 |
3 | import java.util.TimerTask;
4 | import org.slf4j.LoggerFactory;
5 | import org.slf4j.Logger;
6 | /**
7 | *
8 | * @author hzhang
9 | */
10 | class Counter extends TimerTask
11 | {
12 | private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
13 | public static int counter = 0;
14 |
15 | @Override
16 | public void run()
17 | {
18 | logger.info("COUNTER: {}", counter);
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This repo is for self learn. I modified the origial logging to Slf4j logging which helps me for debugging:)
2 |
3 | SMPPSim official website tutorial:
4 | http://www.seleniumsoftware.com/user-guide.htm#quick
5 |
6 | REQUIERD SOFTWARE:
7 | 1. java environment java 1.6.x or later.
8 | 2. maven 2.x or 3.x
9 |
10 | QUICK START
11 |
12 | How to run?
13 | java -jar smppsim.jar conf/logback.xml conf/smppsim.props
14 |
15 | How to change credentials?
16 | All credential information is in the conf/smppsim.props
17 |
18 | ***attention***:
19 | the smpp-lib may not be downloaded, please get the maven dependency
20 | in the conf/ folder and put it into your local maven repository:
21 | /.m2/respository/smpp/smpp-lib
22 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/util/SeqnoStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created on 25 Nov 2010
3 | *
4 | */
5 | package com.seleniumsoftware.SMPPSim.pdu.util;
6 |
7 | public class SeqnoStatus {
8 |
9 | private int seq_no;
10 |
11 | private int command_status;
12 |
13 | public SeqnoStatus(int seq_no, int command_status) {
14 | this.seq_no = seq_no;
15 | this.command_status = command_status;
16 | }
17 |
18 | public int getSeq_no() {
19 | return seq_no;
20 | }
21 | public void setSeq_no(int seqNo) {
22 | seq_no = seqNo;
23 | }
24 | public int getCommand_status() {
25 | return command_status;
26 | }
27 | public void setCommand_status(int commandStatus) {
28 | command_status = commandStatus;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/tests/SmppsimTests.java:
--------------------------------------------------------------------------------
1 | package tests;
2 | import junit.framework.*;
3 |
4 | public class SmppsimTests extends TestCase {
5 |
6 | public static Test suite() {
7 | TestSuite suite = new TestSuite(SmppsimBindTests.class);
8 | suite.addTestSuite(SmppsimSubmitSmTests.class);
9 | suite.addTestSuite(SmppsimDeliverSmTests.class);
10 | suite.addTestSuite(SmppsimEnquireLinkTests.class);
11 | suite.addTestSuite(SmppsimQuerySmTests.class);
12 | suite.addTestSuite(SmppsimCancelSmTests.class);
13 | suite.addTestSuite(SmppsimReplaceSmTests.class);
14 | suite.addTestSuite(SmppsimSubmitMultiTests.class);
15 | return suite;
16 | }
17 |
18 | public static void main(String[] args) {
19 | junit.textui.TestRunner.run(suite());
20 | }
21 | }
--------------------------------------------------------------------------------
/src/test/java/com/mycompany/smppsim/AppTest.java:
--------------------------------------------------------------------------------
1 | package com.mycompany.smppsim;
2 |
3 | import junit.framework.Test;
4 | import junit.framework.TestCase;
5 | import junit.framework.TestSuite;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | extends TestCase
12 | {
13 | /**
14 | * Create the test case
15 | *
16 | * @param testName name of the test case
17 | */
18 | public AppTest( String testName )
19 | {
20 | super( testName );
21 | }
22 |
23 | /**
24 | * @return the suite of tests being tested
25 | */
26 | public static Test suite()
27 | {
28 | return new TestSuite( AppTest.class );
29 | }
30 |
31 | /**
32 | * Rigourous Test :-)
33 | */
34 | public void testApp()
35 | {
36 | assertTrue( true );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/conf/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{yyy-mm-dd HH:mm:ss.SSS} [%thread] [%c] %-5p - %m%n
6 |
7 |
8 |
9 | /Users/hzhang/Desktop/defaultLog.log
10 | true
11 | true
12 |
13 | %date %level [%thread] [%c] %-5p - %m%n
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /build/
3 | *.DS_Store
4 | *nbactions.xml
5 | /SMSC_Simulator/smscSimulator/target/
6 | /docs/examples/nbproject/private/
7 | /docs/examples/HighCharts/nbproject/private/
8 |
9 | # New .gitnore for all SMP projects. Reconsider the part above this line and remove (umer)
10 | *.class
11 |
12 | # Package Files #
13 | *.jar
14 | *.war
15 | *.ear
16 | .*
17 | !.gitignore
18 | *~
19 | .DS_Store
20 | .AppleDouble
21 | .LSOverride
22 | Icon
23 |
24 | # Thumbnails
25 | ._*
26 |
27 | # Files that might appear on external disk
28 | .Spotlight-V100
29 | .Trashes
30 | *.pydevproject
31 | .project
32 | .metadata
33 | bin/**
34 | tmp/**
35 | tmp/**/*
36 | *.tmp
37 | *.bak
38 | *.swp
39 | *~.nib
40 | local.properties
41 | .classpath
42 | .settings/
43 | .loadpath
44 |
45 | # External tool builders
46 | .externalToolBuilders/
47 |
48 | # Locally stored "Eclipse launch configurations"
49 | *.launch
50 |
51 | # CDT-specific
52 | .cproject
53 |
54 | # PDT-specific
55 | .buildpath
56 | nbproject/private/
57 | build/
58 | nbbuild/
59 | dist/
60 | nbdist/
61 | nbactions.xml
62 | nb-configuration.xml
63 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/exceptions/InternalException.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * InternalException.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/exceptions/InternalException.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 | package com.seleniumsoftware.SMPPSim.exceptions;
29 |
30 | public class InternalException extends Exception
31 | {
32 | public InternalException() {
33 | super();
34 | }
35 |
36 | public InternalException(String message) {
37 | super(message);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Demarshaller.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Demarshaller.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Demarshaller.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 | package com.seleniumsoftware.SMPPSim.pdu;
28 | public interface Demarshaller {
29 |
30 | /* All request PDUs must implement this interface such that they can populate their
31 | * own attributes from an input byte array
32 | */
33 |
34 | public void demarshall(byte [] request) throws Exception;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/exceptions/InboundQueueFullException.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * InboundQueueFullException.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/exceptions/InboundQueueFullException.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 | package com.seleniumsoftware.SMPPSim.exceptions;
29 |
30 | public class InboundQueueFullException extends Exception
31 | {
32 | public InboundQueueFullException() {
33 | super();
34 | }
35 |
36 | public InboundQueueFullException(String message) {
37 | super(message);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Marshaller.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Marshaller.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Marshaller.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 | package com.seleniumsoftware.SMPPSim.pdu;
28 | public interface Marshaller {
29 |
30 | /*
31 | * All response PDUs must implement this interface such that they can produce
32 | * a properly formatted byte array corresponding to their attribute values and the
33 | * SMPP format for that PDU
34 | */
35 | public byte [] marshall() throws Exception;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/exceptions/InvalidHexStringlException.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * OutboundQueueFullException.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/exceptions/InvalidHexStringlException.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 | package com.seleniumsoftware.SMPPSim.exceptions;
29 |
30 | public class InvalidHexStringlException extends Exception
31 | {
32 | public InvalidHexStringlException() {
33 | super();
34 | }
35 |
36 | public InvalidHexStringlException(String message) {
37 | super(message);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/exceptions/OutboundQueueFullException.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * OutboundQueueFullException.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/exceptions/OutboundQueueFullException.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 | package com.seleniumsoftware.SMPPSim.exceptions;
29 |
30 | public class OutboundQueueFullException extends Exception
31 | {
32 | public OutboundQueueFullException() {
33 | super();
34 | }
35 |
36 | public OutboundQueueFullException(String message) {
37 | super(message);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/exceptions/MessageStateNotFoundException.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * MessageStateNotFoundException.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/exceptions/MessageStateNotFoundException.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 | package com.seleniumsoftware.SMPPSim.exceptions;
29 |
30 | public class MessageStateNotFoundException extends Exception
31 | {
32 | public MessageStateNotFoundException() {
33 | super();
34 | }
35 |
36 | public MessageStateNotFoundException(String message) {
37 | super(message);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/DestAddress.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * DestAddress.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/DestAddress.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | public class DestAddress {
31 |
32 | private int dest_flag;
33 |
34 | /**
35 | * @return
36 | */
37 | public int getDest_flag() {
38 | return dest_flag;
39 | }
40 |
41 | /**
42 | * @param i
43 | */
44 | public void setDest_flag(int i) {
45 | dest_flag = i;
46 | }
47 |
48 | public String toString() {
49 | return "dest_flag="+dest_flag;
50 | }
51 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Unbind.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Unbind.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Unbind.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | public class Unbind extends Request implements Demarshaller {
31 |
32 | // PDU attributes
33 |
34 | public void demarshall(byte[] request) throws Exception {
35 | // demarshall the header
36 | super.demarshall(request);
37 | }
38 |
39 | /**
40 | * *returns String representation of PDU
41 | */
42 | public String toString() {
43 | return super.toString();
44 | }
45 |
46 |
47 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/GenericNak.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * GenericNak.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/GenericNak.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | public class GenericNak extends Request implements Demarshaller {
31 |
32 | // PDU attributes
33 |
34 | public void demarshall(byte[] request) throws Exception {
35 | // demarshall the header
36 | super.demarshall(request);
37 | }
38 |
39 | /**
40 | * *returns String representation of PDU
41 | */
42 | public String toString() {
43 | return super.toString();
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/EnquireLink.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * SMPPEnquireLinkSM.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/EnquireLink.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | public class EnquireLink extends Request implements Demarshaller {
31 |
32 | // PDU attributes
33 |
34 | public void demarshall(byte[] request) throws Exception {
35 | // demarshall the header
36 | super.demarshall(request);
37 | }
38 |
39 | /**
40 | * *returns String representation of PDU
41 | */
42 | public String toString() {
43 | return super.toString();
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/examples/CallbackServer.java:
--------------------------------------------------------------------------------
1 | package com.seleniumsoftware.examples;
2 |
3 | import java.net.ServerSocket;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | public class CallbackServer {
8 | private static Logger logger = LoggerFactory.getLogger(CallbackServer.class);
9 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.examples");
10 | private CallbackHandler[] callbackHandlers;
11 | private ServerSocket ss;
12 | private int connections;
13 |
14 | public static void main (String [] args) throws Exception {
15 | logger.info("Starting example Callback Server..");
16 | CallbackReceiver receiver = new CallbackReceiver();
17 | CallbackServer server = new CallbackServer(10,3333,receiver);
18 | }
19 |
20 | public CallbackServer(int connections, int port, CallbackReceivable receiver) throws Exception {
21 | this.connections = connections;
22 | Thread callbackThread[] = new Thread[connections];
23 | int threadIndex = 0;
24 | callbackHandlers = new CallbackHandler[connections];
25 | try {
26 | ss = new ServerSocket(port, 10);
27 | logger.info("Example Callback Server is listening on port 3333");
28 | } catch (Exception e) {
29 | logger.debug("Exception creating CallbackServer server: " + e.toString());
30 | e.printStackTrace();
31 | throw e;
32 | }
33 | for (int i = 0; i < connections; i++) {
34 | CallbackHandler ch = new CallbackHandler(ss,receiver);
35 | callbackHandlers[threadIndex] = ch;
36 | callbackThread[threadIndex] = new Thread(callbackHandlers[threadIndex], "CH" + threadIndex);
37 | callbackThread[threadIndex].start();
38 | threadIndex++;
39 | }
40 | }
41 |
42 | public void stop() {
43 | for (int i = 0; i < connections; i++) {
44 | CallbackHandler ch = (CallbackHandler) callbackHandlers[i];
45 | ch.setRunning(false);
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/DestAddressDL.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * DestAddressDL.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/DestAddressDL.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | public class DestAddressDL extends DestAddress {
31 |
32 | private String dl_name;
33 |
34 | /**
35 | * @return
36 | */
37 | public String getDl_name() {
38 | return dl_name;
39 | }
40 |
41 | /**
42 | * @param string
43 | */
44 | public void setDl_name(String string) {
45 | dl_name = string;
46 | }
47 |
48 | public String toString() {
49 | return super.toString()+","+
50 | "dl_name="+dl_name;
51 | }
52 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/TlvEmpty.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Tlv.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/TlvEmpty.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
30 |
31 | public class TlvEmpty extends Tlv {
32 |
33 | private short tag;
34 | private short len;
35 |
36 | public TlvEmpty(short t, short l) {
37 | tag = t;
38 | len = l;
39 | }
40 |
41 | /**
42 | * @return Returns the len.
43 | */
44 | public short getLen() {
45 | return len;
46 | }
47 | /**
48 | * @param len The len to set.
49 | */
50 | public void setLen(short len) {
51 | this.len = len;
52 | }
53 | /**
54 | * @return Returns the tag.
55 | */
56 | public short getTag() {
57 | return tag;
58 | }
59 | /**
60 | * @param tag The tag to set.
61 | */
62 | public void setTag(short tag) {
63 | this.tag = tag;
64 | }
65 |
66 | public String toString() {
67 | return "tag="+tag+",len="+len;
68 | }
69 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/LogFormatter.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * LogFormatter.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/LogFormatter.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim;
29 | import java.util.logging.*;
30 | import java.text.*;
31 | import java.util.*;
32 |
33 |
34 | public class LogFormatter extends java.util.logging.Formatter {
35 |
36 | private SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss S");
37 |
38 | public LogFormatter() {
39 | }
40 |
41 | public String format(LogRecord rec) {
42 | StringBuffer buf = new StringBuffer();
43 | long logTime = rec.getMillis();
44 | Date logDate = new Date(logTime);
45 | String dateTime = (df.format(logDate)+" ").substring(0,23);
46 | buf.append(dateTime);
47 | buf.append(" ");
48 | buf.append((rec.getLevel().getName()+" ").substring(0,7));
49 | buf.append(" ");
50 | buf.append(rec.getThreadID());
51 | buf.append(" ");
52 | buf.append(formatMessage(rec));
53 | buf.append('\n');
54 | return buf.toString();
55 | }
56 | }
--------------------------------------------------------------------------------
/conf/Logging.properties:
--------------------------------------------------------------------------------
1 | ############################################################
2 | # Default Logging Configuration File
3 | #
4 | # You can use a different file by specifying a filename
5 | # with the java.util.logging.config.file system property.
6 | # For example java -Djava.util.logging.config.file=myfile
7 | ############################################################
8 |
9 | ############################################################
10 | # Global properties
11 | ############################################################
12 |
13 | # "handlers" specifies a comma separated list of log Handler
14 | # classes. These handlers will be installed during VM startup.
15 | # Note that these classes must be on the system classpath.
16 | # By default we only configure a ConsoleHandler, which will only
17 | # show messages at the INFO and above levels.
18 | handlers= java.util.logging.ConsoleHandler
19 |
20 | # To also add the FileHandler, use the following line instead.
21 | handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
22 |
23 | # Default global logging level.
24 | # This specifies which kinds of events are logged across
25 | # all loggers. For any given facility this global level
26 | # can be overriden by a facility specific level
27 | # Note that the ConsoleHandler also has a separate level
28 | # setting to limit messages printed to the console.
29 | .level= INFO
30 |
31 | ############################################################
32 | # Handler specific properties.
33 | # Describes specific configuration info for Handlers.
34 | ############################################################
35 |
36 | # default file output is in user's home directory.
37 | java.util.logging.FileHandler.pattern = ./smppsim%u.log
38 | java.util.logging.FileHandler.limit = 5000000
39 | java.util.logging.FileHandler.count = 10
40 | # java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
41 | java.util.logging.FileHandler.formatter = com.seleniumsoftware.SMPPSim.LogFormatter
42 |
43 | # Limit the message that are printed on the console to INFO and above.
44 | java.util.logging.ConsoleHandler.level = INFO
45 | # java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
46 | java.util.logging.ConsoleHandler.formatter = com.seleniumsoftware.SMPPSim.LogFormatter
47 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/UnbindResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * UnbindResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/UnbindResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class UnbindResp extends Response implements Marshaller {
32 |
33 | public UnbindResp(Unbind requestMsg) {
34 | // message header fields except message length
35 | setCmd_id(PduConstants.UNBIND_RESP);
36 | setCmd_status(PduConstants.ESME_ROK);
37 | setSeq_no(requestMsg.getSeq_no());
38 | // Set message length to zero since actual length will not be known until the object is
39 | // converted back to a message complete with null terminated strings
40 | setCmd_len(0);
41 | }
42 |
43 | public byte[] marshall() throws Exception {
44 | out.reset();
45 | super.prepareHeaderForMarshalling();
46 | byte[] response = out.toByteArray();
47 | int l = response.length;
48 | response = PduUtilities.setPduLength(response, l);
49 | return response;
50 | }
51 |
52 | /**
53 | * *returns String representation of PDU
54 | */
55 | public String toString() {
56 | return super.toString();
57 | }
58 |
59 |
60 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/CancelSMResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * CancelSMResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/CancelSMResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class CancelSMResp extends Response implements Marshaller {
32 |
33 | public CancelSMResp(CancelSM requestMsg) {
34 | // message header fields except message length
35 | setCmd_id(PduConstants.CANCEL_SM_RESP);
36 | setCmd_status(PduConstants.ESME_ROK);
37 | setSeq_no(requestMsg.getSeq_no());
38 | // Set message length to zero since actual length will not be known until the object is
39 | // converted back to a message complete with null terminated strings
40 | setCmd_len(0);
41 | }
42 |
43 | public byte[] marshall() throws Exception {
44 | out.reset();
45 | super.prepareHeaderForMarshalling();
46 | byte[] response = out.toByteArray();
47 | int l = response.length;
48 | response = PduUtilities.setPduLength(response, l);
49 | return response;
50 | }
51 |
52 | /**
53 | * *returns String representation of PDU
54 | */
55 | public String toString() {
56 | return super.toString();
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/GenericNakResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * GenericNakResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/GenericNakResp.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class GenericNakResp extends Response implements Marshaller {
32 |
33 | public GenericNakResp(Pdu requestMsg) {
34 | // message header fields except message length
35 | setCmd_id(PduConstants.GENERIC_NAK);
36 | setCmd_status(PduConstants.ESME_ROK);
37 | setSeq_no(requestMsg.getSeq_no());
38 | // Set message length to zero since actual length will not be known until the object is
39 | // converted back to a message complete with null terminated strings
40 | setCmd_len(0);
41 | }
42 |
43 | public byte[] marshall() throws Exception {
44 | out.reset();
45 | super.prepareHeaderForMarshalling();
46 | byte[] response = out.toByteArray();
47 | int l = response.length;
48 | response = PduUtilities.setPduLength(response, l);
49 | return response;
50 | }
51 |
52 | /**
53 | * *returns String representation of PDU
54 | */
55 | public String toString() {
56 | return super.toString();
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Response.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Response.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Response.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
30 |
31 | import java.io.*;
32 |
33 | abstract public class Response extends Pdu implements Marshaller {
34 |
35 | transient ByteArrayOutputStream out = new ByteArrayOutputStream();
36 |
37 | public void prepareHeaderForMarshalling() throws Exception {
38 | out.reset();
39 | out.write(PduUtilities.makeByteArrayFromInt(getCmd_len(),4));
40 | out.write(PduUtilities.makeByteArrayFromInt(getCmd_id(),4));
41 | out.write(PduUtilities.makeByteArrayFromInt(getCmd_status(),4));
42 | out.write(PduUtilities.makeByteArrayFromInt(getSeq_no(),4));
43 | }
44 |
45 | public byte [] errorResponse(int cmd_id, int cmd_status, int seq_no) throws Exception {
46 | out.reset();
47 | setCmd_len(16);
48 | setCmd_id(cmd_id);
49 | setCmd_status(cmd_status);
50 | setSeq_no(seq_no);
51 | prepareHeaderForMarshalling();
52 | byte [] response = out.toByteArray();
53 | return response;
54 | }
55 |
56 | public String toString() {
57 | return super.toString();
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/EnquireLinkResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * EnquireLinkResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/EnquireLinkResp.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class EnquireLinkResp extends Response implements Marshaller {
32 |
33 | public EnquireLinkResp(EnquireLink requestMsg) {
34 | // message header fields except message length
35 | setCmd_id(PduConstants.ENQUIRE_LINK_RESP);
36 | setCmd_status(PduConstants.ESME_ROK);
37 | setSeq_no(requestMsg.getSeq_no());
38 | // Set message length to zero since actual length will not be known until the object is
39 | // converted back to a message complete with null terminated strings
40 | setCmd_len(0);
41 | }
42 |
43 | public byte[] marshall() throws Exception {
44 | out.reset();
45 | super.prepareHeaderForMarshalling();
46 | byte[] response = out.toByteArray();
47 | int l = response.length;
48 | response = PduUtilities.setPduLength(response, l);
49 | return response;
50 | }
51 |
52 | /**
53 | * *returns String representation of PDU
54 | */
55 | public String toString() {
56 | return super.toString();
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/ReplaceSMResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * ReplaceSMResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/ReplaceSMResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class ReplaceSMResp extends Response implements Marshaller {
32 |
33 | public ReplaceSMResp(ReplaceSM requestMsg) {
34 | // message header fields except message length
35 | setCmd_id(PduConstants.REPLACE_SM_RESP);
36 | setCmd_status(PduConstants.ESME_ROK);
37 | setSeq_no(requestMsg.getSeq_no());
38 | // Set message length to zero since actual length will not be known until the object is
39 | // converted back to a message complete with null terminated strings
40 | setCmd_len(0);
41 | // message body
42 | }
43 |
44 | public byte[] marshall() throws Exception {
45 | out.reset();
46 | super.prepareHeaderForMarshalling();
47 | byte[] response = out.toByteArray();
48 | int l = response.length;
49 | response = PduUtilities.setPduLength(response, l);
50 | return response;
51 | }
52 |
53 | /**
54 | * *returns String representation of PDU
55 | */
56 | public String toString() {
57 | return super.toString();
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/DeliverSMResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * DeliverSMResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/DeliverSMResp.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
30 | import org.slf4j.LoggerFactory;
31 |
32 | public class DeliverSMResp extends Request implements Demarshaller {
33 |
34 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(DeliverSMResp.class);
35 | // PDU attributes
36 |
37 | private String message_id;
38 |
39 | public void demarshall(byte[] request) throws Exception {
40 |
41 | // demarshall the header
42 | super.demarshall(request);
43 | // now set atributes of this specific PDU type
44 | int inx = 16;
45 | try {
46 | message_id = PduUtilities.getStringValueFixedLength(request, inx, 1);
47 | } catch (Exception e) {
48 | logger.debug("DELIVER_SM_RESP PDU is malformed. message_id is incorrect");
49 | throw (e);
50 | }
51 |
52 | }
53 |
54 | /**
55 | * @return
56 | */
57 | public String getMessage_id() {
58 | return message_id;
59 | }
60 | /**
61 | * *returns String representation of PDU
62 | */
63 | public String toString() {
64 | return super.toString()+","+
65 | "system_id="+message_id;
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/DestAddressSME.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * DestAddressSME.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/DestAddressSME.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | public class DestAddressSME extends DestAddress {
31 | private int sme_ton;
32 | private int sme_npi;
33 | private String sme_address;
34 |
35 | /**
36 | * @return
37 | */
38 | public String getSme_address() {
39 | return sme_address;
40 | }
41 |
42 | /**
43 | * @return
44 | */
45 | public int getSme_npi() {
46 | return sme_npi;
47 | }
48 |
49 | /**
50 | * @return
51 | */
52 | public int getSme_ton() {
53 | return sme_ton;
54 | }
55 |
56 | /**
57 | * @param string
58 | */
59 | public void setSme_address(String string) {
60 | sme_address = string;
61 | }
62 |
63 | /**
64 | * @param i
65 | */
66 | public void setSme_npi(int i) {
67 | sme_npi = i;
68 | }
69 |
70 | /**
71 | * @param i
72 | */
73 | public void setSme_ton(int i) {
74 | sme_ton = i;
75 | }
76 |
77 | public String toString() {
78 | return super.toString()
79 | + ","
80 | + "sme_ton="
81 | + sme_ton
82 | + ","
83 | + "sme_npi="
84 | + sme_npi
85 | + ","
86 | + "sme_address="
87 | + sme_address;
88 | }
89 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/Session.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Session.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/Session.java,v 1.1 2012/07/24 14:49:00 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim;
29 |
30 | public class Session {
31 | private boolean isBound = false;
32 | private boolean isReceiver = false;
33 | private boolean isTransmitter = false;
34 | private int interface_version;
35 |
36 | public Session() {
37 | }
38 | /**
39 | * @return
40 | */
41 | public boolean isBound() {
42 | return isBound;
43 | }
44 |
45 | /**
46 | * @return
47 | */
48 | public boolean isReceiver() {
49 | return isReceiver;
50 | }
51 |
52 | /**
53 | * @return
54 | */
55 | public boolean isTransmitter() {
56 | return isTransmitter;
57 | }
58 |
59 | /**
60 | * @param b
61 | */
62 | public void setBound(boolean b) {
63 | isBound = b;
64 | }
65 |
66 | /**
67 | * @param b
68 | */
69 | public void setReceiver(boolean b) {
70 | isReceiver = b;
71 | }
72 |
73 | /**
74 | * @param b
75 | */
76 | public void setTransmitter(boolean b) {
77 | isTransmitter = b;
78 | }
79 | public int getInterface_version() {
80 | return interface_version;
81 | }
82 | public void setInterface_version(int interfaceVersion) {
83 | interface_version = interfaceVersion;
84 | }
85 |
86 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Tlv.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Tlv.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Tlv.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import java.io.Serializable;
30 |
31 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
32 |
33 | public class Tlv implements Serializable {
34 |
35 | private short tag;
36 | private short len;
37 | private byte [] value;
38 |
39 | public Tlv() {
40 |
41 | }
42 |
43 | public Tlv(short t, short l, byte[] v) {
44 | tag = t;
45 | len = l;
46 | value = v;
47 | }
48 |
49 | /**
50 | * @return Returns the len.
51 | */
52 | public short getLen() {
53 | return len;
54 | }
55 | /**
56 | * @param len The len to set.
57 | */
58 | public void setLen(short len) {
59 | this.len = len;
60 | }
61 | /**
62 | * @return Returns the tag.
63 | */
64 | public short getTag() {
65 | return tag;
66 | }
67 | /**
68 | * @param tag The tag to set.
69 | */
70 | public void setTag(short tag) {
71 | this.tag = tag;
72 | }
73 | /**
74 | * @return Returns the value.
75 | */
76 | public byte[] getValue() {
77 | return value;
78 | }
79 | /**
80 | * @param value The value to set.
81 | */
82 | public void setValue(byte[] value) {
83 | this.value = value;
84 | }
85 |
86 | public String toString() {
87 | return "tag="+tag+",len="+len+",value=0x"+PduUtilities.byteArrayToHexString(value);
88 | }
89 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/BindReceiverResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * BindReceiverResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/BindReceiverResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class BindReceiverResp
32 | extends Response
33 | implements Marshaller {
34 |
35 | String system_id;
36 |
37 | public BindReceiverResp() {
38 | }
39 |
40 | public BindReceiverResp(
41 | BindReceiver requestMsg,
42 | String sysid) {
43 | // message header fields except message length
44 | setCmd_id(PduConstants.BIND_RECEIVER_RESP);
45 | setCmd_status(PduConstants.ESME_ROK);
46 | setSeq_no(requestMsg.getSeq_no());
47 | // Set message length to zero since actual length will not be known until the object is
48 | // converted back to a message complete with null terminated strings
49 | setCmd_len(0);
50 |
51 | // message body
52 | system_id = sysid;
53 | }
54 |
55 | public byte [] marshall() throws Exception {
56 | out.reset();
57 | super.prepareHeaderForMarshalling();
58 | out.write(PduUtilities.stringToNullTerminatedByteArray(system_id));
59 | byte [] response = out.toByteArray();
60 | int l = response.length;
61 | response = PduUtilities.setPduLength(response,l);
62 | return response;
63 | }
64 | /**
65 | * *returns String representation of PDU
66 | */
67 | public String toString() {
68 | return super.toString()+","+
69 | "system_id="+system_id;
70 | }
71 |
72 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/BindTransceiverResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * BindTransceiverResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/BindTransceiverResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class BindTransceiverResp
32 | extends Response
33 | implements Marshaller {
34 |
35 | String system_id;
36 |
37 | public BindTransceiverResp() {
38 | }
39 |
40 | public BindTransceiverResp(
41 | BindTransceiver requestMsg,
42 | String sysid) {
43 | // message header fields except message length
44 | setCmd_id(PduConstants.BIND_TRANSCEIVER_RESP);
45 | setCmd_status(PduConstants.ESME_ROK);
46 | setSeq_no(requestMsg.getSeq_no());
47 | // Set message length to zero since actual length will not be known until the object is
48 | // converted back to a message complete with null terminated strings
49 | setCmd_len(0);
50 |
51 | // message body
52 | system_id = sysid;
53 | }
54 |
55 | public byte [] marshall() throws Exception {
56 | out.reset();
57 | super.prepareHeaderForMarshalling();
58 | out.write(PduUtilities.stringToNullTerminatedByteArray(system_id));
59 | byte [] response = out.toByteArray();
60 | int l = response.length;
61 | response = PduUtilities.setPduLength(response,l);
62 | return response;
63 | }
64 |
65 | /**
66 | * *returns String representation of PDU
67 | */
68 | public String toString() {
69 | return super.toString()+","+
70 | "system_id="+system_id;
71 | }
72 |
73 |
74 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/BindTransmitterResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * BindTransmitterResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/BindTransmitterResp.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | public class BindTransmitterResp
32 | extends Response
33 | implements Marshaller {
34 |
35 | String system_id;
36 |
37 | public BindTransmitterResp() {
38 | }
39 |
40 | public BindTransmitterResp(
41 | BindTransmitter requestMsg,
42 | String sysid) {
43 | // message header fields except message length
44 | setCmd_id(PduConstants.BIND_TRANSMITTER_RESP);
45 | setCmd_status(PduConstants.ESME_ROK);
46 | setSeq_no(requestMsg.getSeq_no());
47 | // Set message length to zero since actual length will not be known until the object is
48 | // converted back to a message complete with null terminated strings
49 | setCmd_len(0);
50 |
51 | // message body
52 | system_id = sysid;
53 | }
54 |
55 | public byte [] marshall() throws Exception {
56 | out.reset();
57 | super.prepareHeaderForMarshalling();
58 | out.write(PduUtilities.stringToNullTerminatedByteArray(system_id));
59 | byte [] response = out.toByteArray();
60 | int l = response.length;
61 | response = PduUtilities.setPduLength(response,l);
62 | return response;
63 | }
64 |
65 | /**
66 | * *returns String representation of PDU
67 | */
68 | public String toString() {
69 | return super.toString()+","+
70 | "system_id="+system_id;
71 | }
72 |
73 |
74 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Request.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Request.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Request.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
31 | import org.slf4j.LoggerFactory;
32 |
33 | abstract public class Request extends Pdu implements Demarshaller {
34 |
35 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(Request.class);
36 |
37 | public void demarshall(byte[] request) throws Exception {
38 | int inx = 0;
39 | try {
40 | setCmd_len(PduUtilities.getIntegerValue(request, inx, 4));
41 | } catch (Exception e) {
42 | logger.debug("SMPP header PDU is malformed. cmd_len is incorrect");
43 | throw (e);
44 | }
45 | inx = inx + 4;
46 | try {
47 | setCmd_id(PduUtilities.getIntegerValue(request, inx, 4));
48 | } catch (Exception e) {
49 | logger.debug("SMPP header PDU is malformed. cmd_id is incorrect");
50 | throw (e);
51 | }
52 | inx = inx + 4;
53 | try {
54 | setCmd_status(PduUtilities.getIntegerValue(request, inx, 4));
55 | } catch (Exception e) {
56 | logger
57 | .debug("SMPP header PDU is malformed. cmd_status is incorrect");
58 | throw (e);
59 | }
60 | inx = inx + 4;
61 | try {
62 | setSeq_no(PduUtilities.getIntegerValue(request, inx, 4));
63 | } catch (Exception e) {
64 | logger.debug("SMPP header PDU is malformed. seq_no is incorrect");
65 | throw (e);
66 | }
67 | inx = inx + 4;
68 | }
69 |
70 | public String toString() {
71 | return super.toString();
72 | }
73 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/CallbackServerConnector.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * CallbackServerConnector.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/CallbackServerConnector.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim;
29 |
30 | import java.net.*;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 |
34 |
35 | public class CallbackServerConnector implements Runnable {
36 |
37 | private Smsc smsc = Smsc.getInstance();
38 |
39 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
40 | private static Logger logger = LoggerFactory.getLogger(CallbackServerConnector.class);
41 | private Object mutex;
42 |
43 | public CallbackServerConnector(Object mutex) {
44 | this.mutex = mutex;
45 | }
46 |
47 | public void run() {
48 |
49 | if (SMPPSim.isCallback()) {
50 | synchronized (mutex) {
51 | boolean connected = false;
52 | Socket callback;
53 | while (!connected) {
54 | try {
55 | callback = new Socket(
56 | SMPPSim.getCallback_target_host(), SMPPSim
57 | .getCallback_port());
58 | connected = true;
59 | smsc.setCallback(callback);
60 | smsc.setCallback_stream(callback.getOutputStream());
61 | smsc.setCallback_server_online(true);
62 | logger.info("Connected to callback server");
63 | } catch (Exception ce) {
64 | try {
65 | logger
66 | .info("Callback server not accepting connections - retrying");
67 | Thread.sleep(1000);
68 | } catch (InterruptedException ie) {
69 | }
70 | }
71 | }
72 | mutex.notifyAll();
73 | }
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/src/main/java/tests/ReceiverLogger.java:
--------------------------------------------------------------------------------
1 | package tests;
2 | import tests.exceptions.*;
3 |
4 | import java.io.IOException;
5 | import java.net.*;
6 | import com.logica.smpp.*;
7 | import com.logica.smpp.pdu.*;
8 |
9 | public class ReceiverLogger {
10 |
11 | public static void main(String [] args)
12 | throws Exception {
13 | System.out.println("Attempting to establish receiver session");
14 | Response resp = null;
15 | Connection conn;
16 | Session session;
17 | // get a receiver session
18 | try {
19 | conn = new TCPIPConnection("localhost", 2775);
20 | session = new Session(conn);
21 | BindRequest breq = new BindReceiver();
22 | breq.setSystemId("smppclient");
23 | breq.setPassword("password");
24 | resp = session.bind(breq);
25 | } catch (Exception e) {
26 | System.out.println("Exception: " + e.getMessage());
27 | System.out.println(
28 | "Exception whilst setting up or executing bind receiver. "
29 | + e.getMessage());
30 | throw new BindReceiverException(
31 | "Exception whilst setting up or executing bind receiver. "
32 | + e.getMessage());
33 | }
34 | System.out.println("Established receiver session successfully");
35 |
36 | // now wait for messages and log them as they are received
37 | PDU pdu = null;
38 | DeliverSM deliversm;
39 | Response response;
40 | int count=0;
41 | boolean gotDeliverSM = false;
42 | while (true) {
43 | try {
44 | // wait for a PDU
45 | pdu = session.receive();
46 | if (pdu != null) {
47 | if (pdu instanceof DeliverSM) {
48 | count++;
49 | deliversm = (DeliverSM) pdu;
50 | gotDeliverSM = true;
51 | System.out.println("Received DELIVER_SM #:"+count+" : "+pdu.toString());
52 | response = ((Request)pdu).getResponse();
53 | session.respond(response);
54 |
55 | } else {
56 | if (pdu instanceof EnquireLinkResp) {
57 | System.out.println("EnquireLinkResp received");
58 | } else {
59 | System.out.println(
60 | "Unexpected PDU of type: "
61 | + pdu.getClass().getName()
62 | + " received - discarding");
63 | }
64 | }
65 | }
66 | } catch (SocketException e) {
67 | System.out.println("Connection has dropped for some reason");
68 | } catch (IOException ioe) {
69 | System.out.println("IOException: " + ioe.getMessage());
70 | } catch (NotSynchronousException nse) {
71 | System.out.println("NotSynchronousException: " + nse.getMessage());
72 | } catch (PDUException pdue) {
73 | System.out.println("PDUException: " + pdue.getMessage());
74 | } catch (TimeoutException toe) {
75 | System.out.println("TimeoutException: " + toe.getMessage());
76 | } catch (WrongSessionStateException wsse) {
77 | System.out.println("WrongSessionStateException: " + wsse.getMessage());
78 | }
79 | }
80 | }
81 |
82 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/MessageQueue.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * MessageQueue.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/MessageQueue.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 | package com.seleniumsoftware.SMPPSim;
29 | import com.seleniumsoftware.SMPPSim.pdu.*;
30 |
31 | import java.util.*;
32 | import org.slf4j.Logger;
33 | import org.slf4j.LoggerFactory;
34 |
35 | public class MessageQueue {
36 |
37 | private static Logger logger = LoggerFactory.getLogger(MessageQueue.class);
38 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
39 | private String queueName;
40 | private Vector queue;
41 | private Object message = new Object();
42 |
43 | public MessageQueue(String name) {
44 | queueName = name;
45 | queue = new Vector();
46 | }
47 |
48 | protected synchronized void addMessage(Pdu message) {
49 | logger.debug(
50 | "MessageQueue(" + queueName + ") : adding message to queue");
51 | queue.add(message);
52 | notifyAll();
53 | }
54 |
55 | protected synchronized Object getMessage() {
56 | while (isEmpty()) {
57 | try {
58 | logger.debug(
59 | "MessageQueue("
60 | + queueName
61 | + "): waiting for message from queue");
62 | wait();
63 | } catch (InterruptedException e) {
64 | logger.error(
65 | "Exception in MessageQueue("
66 | + queueName
67 | + ") : "
68 | + e.getMessage());
69 | e.printStackTrace();
70 | }
71 | }
72 | message = queue.firstElement();
73 | queue.remove(message);
74 | notifyAll();
75 | return message;
76 | }
77 |
78 | protected synchronized boolean isEmpty() {
79 | return queue.isEmpty();
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/examples/CallbackReceiver.java:
--------------------------------------------------------------------------------
1 | package com.seleniumsoftware.examples;
2 |
3 | import java.net.ServerSocket;
4 | import org.slf4j.LoggerFactory;
5 |
6 | public class CallbackReceiver implements CallbackReceivable {
7 |
8 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(CallbackReceiver.class);
9 |
10 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.examples");
11 |
12 | public void sent(byte[] pdu) {
13 | hexDump("SMPPSim sent to ESME:", pdu, pdu.length);
14 | if (pduIsDeliverSm(pdu)) {
15 | logger.info("(PDU type was DeliverSM)");
16 | } else
17 | logger.debug("Unrecognised PDU type");
18 | }
19 |
20 | public void received(byte[] pdu) {
21 | hexDump("SMPPSim received from ESME", pdu, pdu.length);
22 | if (pduIsSubmitSm(pdu)) {
23 | logger.info("(PDU type was SubmitSm)");
24 | } else if (pduIsDataSm(pdu)) {
25 | logger.info("(PDU type was DataSm)");
26 | } else if (pduIsBindRx(pdu)) {
27 | logger.info("(PDU type was BindRX)");
28 | } else if (pduIsBindTx(pdu)) {
29 | logger.info("(PDU type was BindTX)");
30 | } else if (pduIsBindTrx(pdu)) {
31 | logger.info("(PDU type was BindTRX)");
32 | } else if (pduIsEnquireLink(pdu)) {
33 | logger.info("(PDU type was Enquire_Link)");
34 | } else if (pduIsUnbind(pdu)) {
35 | logger.info("(PDU type was Unbind)");
36 | } else
37 | logger.debug("Unrecognised PDU type");
38 | }
39 |
40 | private boolean pduIsSubmitSm(byte[] pdu) {
41 | return (pdu[16] == (byte) 4);
42 | }
43 |
44 | private boolean pduIsDataSm(byte[] pdu) {
45 | return (pdu[16] == (byte) 0x00000103);
46 | }
47 |
48 | private boolean pduIsBindRx(byte[] pdu) {
49 | return (pdu[16] == (byte) 1);
50 | }
51 |
52 | private boolean pduIsBindTx(byte[] pdu) {
53 | return (pdu[16] == (byte) 2);
54 | }
55 |
56 | private boolean pduIsBindTrx(byte[] pdu) {
57 | return (pdu[16] == (byte) 9);
58 | }
59 |
60 | private boolean pduIsDeliverSm(byte[] pdu) {
61 | return (pdu[16] == (byte) 5);
62 | }
63 |
64 | private boolean pduIsEnquireLink(byte[] pdu) {
65 | return (pdu[16] == (byte) 0x15);
66 | }
67 |
68 | private boolean pduIsUnbind(byte[] pdu) {
69 | return (pdu[16] == (byte) 6);
70 | }
71 |
72 | public static void hexDump(String title, byte[] m, int l) {
73 | int p = 0;
74 | StringBuffer line = new StringBuffer();
75 | logger.info(title);
76 | logger.info("Hex dump (" + l + ") bytes:");
77 | for (int i = 0; i < l; i++) {
78 | if ((m[i] >= 0) & (m[i] < 16))
79 | line.append("0");
80 | line.append(Integer.toString(m[i] & 0xff, 16).toUpperCase());
81 | if ((++p % 4) == 0) {
82 | line.append(":");
83 | }
84 | if (p == 16) {
85 | p = 0;
86 | logger.info(line.toString());
87 | line = new StringBuffer();
88 | }
89 | }
90 | if (p != 16) {
91 | logger.info(line.toString());
92 | }
93 | logger.info("====================================");
94 | }
95 |
96 |
97 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/SubmitSMResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * SubmitSMResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/SubmitSMResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.*;
30 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
31 |
32 | public class SubmitSMResp extends Response implements Marshaller {
33 | private Smsc smsc = Smsc.getInstance();
34 |
35 | String message_id;
36 |
37 | public SubmitSMResp(SubmitSM requestMsg) {
38 | // message header fields except message length
39 | setCmd_id(PduConstants.SUBMIT_SM_RESP);
40 | setCmd_status(PduConstants.ESME_ROK);
41 | setSeq_no(requestMsg.getSeq_no());
42 | // Set message length to zero since actual length will not be known until the object is
43 | // converted back to a message complete with null terminated strings
44 | setCmd_len(0);
45 |
46 | // message body
47 | message_id = smsc.getMessageID();
48 | }
49 |
50 | public byte[] marshall() throws Exception {
51 | out.reset();
52 | super.prepareHeaderForMarshalling();
53 | out.write(PduUtilities.stringToNullTerminatedByteArray(message_id));
54 | byte[] response = out.toByteArray();
55 | int l = response.length;
56 | response = PduUtilities.setPduLength(response, l);
57 | return response;
58 | }
59 | /**
60 | * @return
61 | */
62 | public String getMessage_id() {
63 | return message_id;
64 | }
65 |
66 | /**
67 | * @param string
68 | */
69 | public void setMessage_id(String string) {
70 | message_id = string;
71 | }
72 |
73 | public String toString() {
74 | return super.toString()+","+
75 | "message_id="+message_id;
76 | }
77 |
78 | }
--------------------------------------------------------------------------------
/src/main/java/tests/SmppsimEnquireLinkTests.java:
--------------------------------------------------------------------------------
1 | package tests;
2 | import tests.exceptions.*;
3 | import junit.framework.*;
4 |
5 | import java.net.*;
6 | import java.util.logging.*;
7 | import com.logica.smpp.*;
8 | import com.logica.smpp.pdu.*;
9 | import org.slf4j.LoggerFactory;
10 |
11 | public class SmppsimEnquireLinkTests extends TestCase {
12 |
13 | String smppServiceType = "tests";
14 | String srcAddress = "12345";
15 | String destAddress = "4477805432122";
16 | String smppAccountName = "smppclient";
17 | String smppPassword = "password";
18 | String smppSystemType = "tests";
19 | String smppAddressRange = "[0-9]";
20 | boolean txBound;
21 | boolean rxBound;
22 | Session session;
23 | String smppHost = "localhost";
24 | int smppPort = 2775;
25 | int smppAltPort1 = 2776;
26 | private static org.slf4j.Logger logger = LoggerFactory.getLogger("test");
27 |
28 | // private static Logger logger = Logger.getLogger("smppsim.tests");
29 |
30 | public SmppsimEnquireLinkTests() {
31 | }
32 |
33 | /*
34 | * Condition: Basic enquire_link sent
35 | * Expected: No exceptions. ESME_ROK in response.
36 | */
37 |
38 | public void test001EnquireLink()
39 | throws BindTransmitterException, EnquireLinkFailedException, SocketException {
40 | logger.info("Attempting to establish transmitter session");
41 | Response resp = null;
42 | Connection conn;
43 | // get a transmitter session
44 | try {
45 | conn = new TCPIPConnection(smppHost, smppPort);
46 | session = new Session(conn);
47 | BindRequest breq = new BindTransmitter();
48 | breq.setSystemId(smppAccountName);
49 | breq.setPassword(smppPassword);
50 | breq.setInterfaceVersion((byte) 0x34);
51 | breq.setSystemType(smppSystemType);
52 | resp = session.bind(breq);
53 | } catch (Exception e) {
54 | logger.error(
55 | "Exception whilst setting up or executing bind transmitter. "
56 | + e.getMessage());
57 | fail(
58 | "Exception whilst setting up or executing bind transmitter. "
59 | + e.getMessage());
60 | throw new BindTransmitterException(
61 | "Exception whilst setting up or executing bind transmitter. "
62 | + e.getMessage());
63 | }
64 | assertEquals(
65 | "BindTransmitter failed: response was not ESME_ROK",
66 | Data.ESME_ROK,
67 | resp.getCommandStatus());
68 | logger.info("Established transmitter session successfully");
69 |
70 | // now send an EnquireLink
71 | try {
72 | EnquireLinkResp response = new EnquireLinkResp();
73 | response = session.enquireLink();
74 | assertEquals(
75 | "ENQUIRE_LINK failed: response was not ESME_ROK",
76 | Data.ESME_ROK,
77 | response.getCommandStatus());
78 | } catch (SocketException se) {
79 | logger.error("Connection has dropped");
80 | throw se;
81 | } catch (Exception e) {
82 | logger.error(e.getMessage());
83 | throw new EnquireLinkFailedException();
84 | }
85 |
86 | // Now unbind and disconnect ready for the next test
87 | try {
88 | UnbindResp response = session.unbind();
89 | } catch (Exception e) {
90 | logger.error(
91 | "Unbind operation failed for TX session. " + e.getMessage());
92 | }
93 | }
94 |
95 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Pdu.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Pdu.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Pdu.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | import java.io.Serializable;
31 | import org.slf4j.LoggerFactory;
32 |
33 | abstract public class Pdu implements Serializable {
34 |
35 |
36 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(DeliverSM.class);
37 |
38 | // static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
39 |
40 | // need this for RMI use
41 | public Pdu() {
42 |
43 | }
44 | // All PDUs have a header
45 |
46 | private int cmd_len;
47 | private int cmd_id;
48 | private int cmd_status;
49 | private int seq_no;
50 |
51 | public boolean equals(Object o) {
52 | if (o instanceof Pdu) {
53 | Pdu p = (Pdu) o;
54 | if (p.getSeq_no() == this.seq_no)
55 | return true;
56 | }
57 | return false;
58 | }
59 |
60 | /**
61 | * @return
62 | */
63 | public int getCmd_id() {
64 | return cmd_id;
65 | }
66 |
67 | /**
68 | * @return
69 | */
70 | public int getCmd_len() {
71 | return cmd_len;
72 | }
73 |
74 | /**
75 | * @return
76 | */
77 | public int getCmd_status() {
78 | return cmd_status;
79 | }
80 |
81 | /**
82 | * @return
83 | */
84 | public int getSeq_no() {
85 | return seq_no;
86 | }
87 |
88 | /**
89 | * @param i
90 | */
91 | public void setCmd_id(int i) {
92 | cmd_id = i;
93 | }
94 |
95 | /**
96 | * @param i
97 | */
98 | public void setCmd_len(int i) {
99 | cmd_len = i;
100 | }
101 |
102 | /**
103 | * @param i
104 | */
105 | public void setCmd_status(int i) {
106 | cmd_status = i;
107 | }
108 |
109 | /**
110 | * @param i
111 | */
112 | public void setSeq_no(int i) {
113 | seq_no = i;
114 | }
115 |
116 | public String toString() {
117 | return "cmd_len="+cmd_len+","+
118 | "cmd_id="+cmd_id+","+
119 | "cmd_status="+cmd_status+","+
120 | "seq_no="+seq_no;
121 | }
122 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/UnsuccessSME.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * SMPPSubmitMultiRespUnsuccessDest.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/UnsuccessSME.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | public class UnsuccessSME {
31 |
32 | int dest_addr_ton;
33 | int dest_addr_npi;
34 | String destination_addr;
35 | int error_status_code;
36 |
37 | public UnsuccessSME() {
38 | }
39 |
40 | public UnsuccessSME(
41 | int dest_addr_ton,
42 | int dest_addr_npi,
43 | String destination_addr,
44 | int error_status_code) {
45 | this.dest_addr_ton = dest_addr_ton;
46 | this.dest_addr_npi = dest_addr_npi;
47 | this.destination_addr = destination_addr;
48 | this.error_status_code = error_status_code;
49 | }
50 |
51 | /**
52 | * @return
53 | */
54 | public int getDest_addr_npi() {
55 | return dest_addr_npi;
56 | }
57 |
58 | /**
59 | * @return
60 | */
61 | public int getDest_addr_ton() {
62 | return dest_addr_ton;
63 | }
64 |
65 | /**
66 | * @return
67 | */
68 | public String getDestination_addr() {
69 | return destination_addr;
70 | }
71 |
72 | /**
73 | * @return
74 | */
75 | public int getError_status_code() {
76 | return error_status_code;
77 | }
78 |
79 | /**
80 | * @param i
81 | */
82 | public void setDest_addr_npi(int i) {
83 | dest_addr_npi = i;
84 | }
85 |
86 | /**
87 | * @param i
88 | */
89 | public void setDest_addr_ton(int i) {
90 | dest_addr_ton = i;
91 | }
92 |
93 | /**
94 | * @param string
95 | */
96 | public void setDestination_addr(String string) {
97 | destination_addr = string;
98 | }
99 |
100 | /**
101 | * @param i
102 | */
103 | public void setError_status_code(int i) {
104 | error_status_code = i;
105 | }
106 |
107 | public String toString() {
108 | return "dest_addr_ton="+dest_addr_ton+","+
109 | "dest_addr_npi="+dest_addr_npi+","+
110 | "destination_addr="+destination_addr+","+
111 | "error_status_code="+error_status_code;
112 | }
113 |
114 | }
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.mycompany
6 | SMPPSim
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | SMPPSim
11 | http://maven.apache.org
12 |
13 |
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 | jakarta-regexp
21 | jakarta-regexp
22 | 1.4
23 |
24 |
25 | ch.qos.logback
26 | logback-classic
27 | 0.9.27
28 |
29 |
30 |
31 |
32 | ch.qos.logback
33 | logback-core
34 | 0.9.27
35 |
36 |
37 |
38 |
39 | org.slf4j
40 | slf4j-api
41 | 1.6.1
42 |
43 |
44 | org.slf4j
45 | jcl-over-slf4j
46 | 1.6.1
47 |
48 |
49 |
50 |
51 | smpp
52 | smpp-lib
53 | 1.3
54 |
55 |
56 |
57 | junit
58 | junit
59 | 4.10
60 | jar
61 |
62 |
63 |
64 |
65 |
66 |
67 | maven-assembly-plugin
68 | 2.4
69 |
70 | smppsim
71 | false
72 |
73 | jar-with-dependencies
74 |
75 |
76 |
77 | com.seleniumsoftware.SMPPSim.SMPPSim
78 | true
79 |
80 |
81 |
82 |
83 |
84 | make-assembly
85 | package
86 |
87 | single
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/DeterministicLifeCycleManager.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * DeterministicLifeCycleManager.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/DeterministicLifeCycleManager.java,v 1.1 2012/07/24 14:49:00 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim;
29 |
30 | import com.seleniumsoftware.SMPPSim.pdu.*;
31 | import org.slf4j.Logger;
32 |
33 | import org.slf4j.LoggerFactory;
34 |
35 | public class DeterministicLifeCycleManager extends LifeCycleManager {
36 |
37 | private static Logger logger = LoggerFactory.getLogger(DeterministicLifeCycleManager.class);
38 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
39 | private Smsc smsc = Smsc.getInstance();
40 | private int discardThreshold;
41 |
42 | public DeterministicLifeCycleManager() {
43 | discardThreshold = SMPPSim.getDiscardFromQueueAfter();
44 | logger.debug("discardThreshold=" + discardThreshold);
45 | }
46 |
47 | public MessageState setState(MessageState m) {
48 | // Should a transition take place at all?
49 | if (isTerminalState(m.getState()))
50 | return m;
51 | byte currentState = m.getState();
52 | String dest = m.getPdu().getDestination_addr();
53 | if (dest.substring(0, 1).equals("1")) {
54 | m.setState(PduConstants.EXPIRED);
55 | m.setErr(903);
56 | } else if (dest.substring(0, 1).equals("2")) {
57 | m.setState(PduConstants.DELETED);
58 | m.setErr(904);
59 | } else if (dest.substring(0, 1).equals("3")) {
60 | m.setState(PduConstants.UNDELIVERABLE);
61 | m.setErr(901);
62 | } else if (dest.substring(0, 1).equals("4")) {
63 | m.setState(PduConstants.ACCEPTED);
64 | m.setErr(2);
65 | } else if (dest.substring(0, 1).equals("5")) {
66 | m.setState(PduConstants.REJECTED);
67 | m.setErr(902);
68 | } else {
69 | m.setState(PduConstants.DELIVERED);
70 | m.setErr(0);
71 | }
72 | if (isTerminalState(m.getState())) {
73 | m.setFinal_time(System.currentTimeMillis());
74 | // If delivery receipt requested prepare it....
75 | SubmitSM p = m.getPdu();
76 | if (p.getRegistered_delivery_flag() == 1 &&
77 | currentState != m.getState()) {
78 | // delivery_receipt requested
79 | //logger.info("Delivery Receipt requested");
80 | smsc.prepareDeliveryReceipt(
81 | p,
82 | m.getMessage_id(),
83 | m.getState(),
84 | 1,
85 | 1,
86 | m.getErr());
87 | }
88 | }
89 | return m;
90 | }
91 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/util/LoggingUtilities.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * LoggingUtilities.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/util/LoggingUtilities.java,v 1.1 2012/07/24 14:49:00 martin Exp $
26 | ****************************************************************************/
27 | package com.seleniumsoftware.SMPPSim.util;
28 | import com.seleniumsoftware.SMPPSim.SMPPSim;
29 | import com.seleniumsoftware.SMPPSim.pdu.*;
30 |
31 | import java.util.StringTokenizer;
32 | import java.util.logging.*;
33 | import org.slf4j.LoggerFactory;
34 |
35 |
36 | public class LoggingUtilities {
37 |
38 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
39 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(LoggingUtilities.class);
40 | public static void hexDump(String title, byte[] m, int l)
41 | {
42 | //empty method, do nothing!
43 | }
44 | // public static void hexDump(String title, byte[] m, int l) {
45 | // int p = 0;
46 | // StringBuffer line = new StringBuffer();
47 | // logger.info(title);
48 | // logger.info("Hex dump (" + l + ") bytes:");
49 | // for (int i = 0; i < l; i++) {
50 | // if ((m[i] >= 0) & (m[i] < 16))
51 | // line.append("0");
52 | // line.append(Integer.toString(m[i] & 0xff, 16).toUpperCase());
53 | // if ((++p % 4) == 0) {
54 | // line.append(":");
55 | // }
56 | // if (p == 16) {
57 | // p = 0;
58 | // logger.info(line.toString());
59 | // line = new StringBuffer();
60 | // }
61 | // }
62 | // if (p != 16) {
63 | // logger.info(line.toString());
64 | // }
65 | // }
66 |
67 | public static void logDecodedPdu(Pdu p)
68 | {
69 | //empty, do nothing!
70 | }
71 |
72 | // public static void logDecodedPdu(Pdu p) {
73 | // // Split into max 80 character lines around comma delimited boundaries
74 | // int i=0;
75 | // String pdustring = p.toString();
76 | // StringBuffer line=new StringBuffer();
77 | // String token="";
78 | // StringTokenizer st = new StringTokenizer(pdustring,",");
79 | // while (st.hasMoreElements()) {
80 | // token = st.nextToken();
81 | // if ((line.length() + token.length())<79) {
82 | // if (i > 0) {
83 | // line.append(",");
84 | // }
85 | // line.append(token);
86 | // i++;
87 | // } else {
88 | // logger.info(line.toString());
89 | // line = new StringBuffer();
90 | // line.append(token);
91 | // i = 1;
92 | // }
93 | // }
94 | // if (line.length() > 0)
95 | // logger.info(line.toString());
96 | // }
97 |
98 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/Outbind.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * Outbind.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/Outbind.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | import com.seleniumsoftware.SMPPSim.Smsc;
31 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
32 | import org.slf4j.LoggerFactory;
33 |
34 | public class Outbind extends Response implements Marshaller {
35 |
36 |
37 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(Outbind.class);
38 |
39 | private Smsc smsc = Smsc.getInstance();
40 |
41 | // PDU attributes
42 |
43 | private String system_id="";
44 |
45 | private String password="";
46 |
47 | public Outbind(String system_id,String password) {
48 | // message header fields except message length
49 | setCmd_id(PduConstants.OUTBIND);
50 | setCmd_status(PduConstants.ESME_ROK);
51 | setSeq_no(smsc.getNextSequence_No());
52 | // Set message length to zero since actual length will not be known until the object is
53 | // converted back to a message complete with null terminated strings
54 | setCmd_len(0);
55 | this.system_id = system_id;
56 | this.password = password;
57 | }
58 |
59 | public byte[] marshall() throws Exception {
60 | out.reset();
61 | super.prepareHeaderForMarshalling();
62 | logger.debug("Prepared header for marshalling");
63 | out.write(PduUtilities.stringToNullTerminatedByteArray(system_id));
64 | logger.debug("marshalled system_id");
65 | out.write(PduUtilities.stringToNullTerminatedByteArray(password));
66 | logger.debug("marshalled password");
67 | byte[] response = out.toByteArray();
68 | int l = response.length;
69 | response = PduUtilities.setPduLength(response, l);
70 | return response;
71 | }
72 |
73 | /**
74 | * @return
75 | */
76 | public String getPassword() {
77 | return password;
78 | }
79 |
80 | /**
81 | * @return
82 | */
83 | public String getSystem_id() {
84 | return system_id;
85 | }
86 |
87 | /**
88 | * @param string
89 | */
90 | public void setPassword(String string) {
91 | password = string;
92 | }
93 |
94 | /**
95 | * @param string
96 | */
97 | public void setSystem_id(String string) {
98 | system_id = string;
99 | }
100 |
101 | /**
102 | * *returns String representation of PDU
103 | */
104 | public String toString() {
105 | return super.toString() + "," + "system_id=" + system_id + ","
106 | + "password=" + password;
107 | }
108 |
109 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/DelayedDrQueue.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * DelayedDrQueue.java
3 | *
4 | * Copyright (C) Martin Woolley 2001
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | ****************************************************************************
26 | */
27 | package com.seleniumsoftware.SMPPSim;
28 |
29 | import com.seleniumsoftware.SMPPSim.exceptions.InboundQueueFullException;
30 | import com.seleniumsoftware.SMPPSim.pdu.*;
31 |
32 | import java.util.*;
33 | import org.slf4j.Logger;
34 | import org.slf4j.LoggerFactory;
35 |
36 | public class DelayedDrQueue implements Runnable {
37 |
38 | private static DelayedDrQueue drqueue;
39 |
40 | // private static Logger logger = Logger
41 | // .getLogger("com.seleniumsoftware.smppsim");
42 | private static Logger logger = LoggerFactory.getLogger(CallbackServerConnector.class);
43 |
44 | private Smsc smsc = Smsc.getInstance();
45 |
46 | private InboundQueue iqueue = InboundQueue.getInstance();
47 |
48 | ArrayList dr_queue_pdus;
49 |
50 | private static final int period = 5000;
51 |
52 | private long delay_ms;
53 |
54 | public static DelayedDrQueue getInstance() {
55 | if (drqueue == null)
56 | drqueue = new DelayedDrQueue();
57 | return drqueue;
58 | }
59 |
60 | private DelayedDrQueue() {
61 | dr_queue_pdus = new ArrayList();
62 | delay_ms = SMPPSim.getDelayReceiptsBy();
63 | }
64 |
65 | public void delayDeliveryReceipt(DeliveryReceipt pdu) {
66 | synchronized (dr_queue_pdus) {
67 | if (!dr_queue_pdus.contains(pdu)) {
68 | logger.debug("DelayedDrQueue: adding object to queue<"
69 | + pdu.toString() + ">");
70 | dr_queue_pdus.add(pdu);
71 | }
72 | logger.debug("DelayedDrQueue: now contains " + dr_queue_pdus.size()
73 | + " object(s)");
74 | }
75 | }
76 |
77 | public void run() {
78 | // this code periodically processes the contents of the delayed DR queue, moving
79 | // messages that are old enough to the active inbound queue for attempted delivery.
80 |
81 | logger.info("Starting DelayedDrQueue service....");
82 |
83 | while (true) {
84 | try {
85 | Thread.sleep(period);
86 | } catch (InterruptedException e) {
87 | }
88 | int dcount = dr_queue_pdus.size();
89 | logger.debug("Processing " + dcount
90 | + " messages in the delayed DR queue");
91 |
92 | synchronized (dr_queue_pdus) {
93 | for (int i = 0; i < dr_queue_pdus.size(); i++) {
94 | Pdu mo = dr_queue_pdus.get(i);
95 | try {
96 | DeliverSM dsm = (DeliverSM) mo;
97 | long earliest_delivery_time = (dsm.getCreated()+delay_ms);
98 | long now = System.currentTimeMillis();
99 | long diff = earliest_delivery_time - now;
100 | //logger.debug("Considering delivery receipt: "+(diff/1000)+" seconds to go");
101 | if (earliest_delivery_time < now) {
102 | iqueue.addMessage(mo);
103 | dr_queue_pdus.remove(mo);
104 | }
105 | } catch (InboundQueueFullException e) {
106 | // try again next time around
107 | }
108 | }
109 | }
110 | }
111 | }
112 |
113 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/MoService.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * MoService.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/MoService.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 |
29 | package com.seleniumsoftware.SMPPSim;
30 |
31 | import com.seleniumsoftware.SMPPSim.exceptions.InvalidHexStringlException;
32 | import com.seleniumsoftware.SMPPSim.pdu.*;
33 | import org.slf4j.Logger;
34 |
35 | import org.slf4j.LoggerFactory;
36 |
37 | public class MoService implements Runnable {
38 |
39 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
40 |
41 | private static Logger logger = LoggerFactory.getLogger(MoService.class);
42 |
43 | private Smsc smsc = Smsc.getInstance();
44 |
45 | private int messagesPerMin;
46 |
47 | boolean moServiceRunning = false;
48 |
49 | String deliveryFile;
50 |
51 | MoMessagePool messages;
52 |
53 | public MoService(String filename, int deliverMessagesPerMin) {
54 | deliveryFile = filename;
55 | messagesPerMin = deliverMessagesPerMin;
56 | }
57 |
58 | public void run() {
59 | logger.info("Starting MO Service....");
60 | try {
61 | messages = new MoMessagePool(deliveryFile);
62 | } catch (Exception e) {
63 | logger.error("Exception creating MoMessagePool. "
64 | + e.getMessage());
65 | e.printStackTrace();
66 | }
67 |
68 | try {
69 | runMoService();
70 | } catch (Exception e) {
71 | logger.error("MO Service threw an Exception:" + e.getMessage()
72 | + ". It's game over");
73 | }
74 | }
75 |
76 | private void runMoService() throws Exception {
77 | long timer = 0;
78 | long actualTime = 0;
79 | int sleepMS;
80 | sleepMS = (int) (60000 / messagesPerMin);
81 | int count = 0;
82 | int minCount = 0;
83 | DeliverSM newMessage;
84 |
85 | timer = System.currentTimeMillis();
86 |
87 | while (moServiceRunning) {
88 | newMessage = messages.getMessage();
89 | newMessage.setSm_length(newMessage.getShort_message().length);
90 | newMessage.setSeq_no(smsc.getNextSequence_No());
91 | logger.debug("MoService: DeliverSM object:"
92 | + newMessage.toString());
93 | smsc.getIq().addMessage(newMessage);
94 | count++;
95 | minCount++;
96 | if (minCount == messagesPerMin) {
97 | actualTime = System.currentTimeMillis() - timer;
98 | logger.info(count + " MO messages inserted in InboundQueue. "
99 | + minCount + " per minute target, actual time "
100 | + actualTime + " ms");
101 | logger.info("drift = " + (actualTime - 60000));
102 | timer = System.currentTimeMillis();
103 | minCount = 0;
104 | }
105 | try {
106 | logger.debug("MO Service is sleeping for " + sleepMS
107 | + " milliseconds");
108 | Thread.sleep(sleepMS);
109 | } catch (Exception e) {
110 | e.printStackTrace();
111 | }
112 |
113 | } // while loop
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/src/main/java/tests/OutbindTest.java:
--------------------------------------------------------------------------------
1 | package tests;
2 |
3 | import java.io.EOFException;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.net.ServerSocket;
7 | import java.net.Socket;
8 | import java.util.logging.*;
9 |
10 | import com.logica.smpp.*;
11 | import com.logica.smpp.pdu.*;
12 | import com.seleniumsoftware.SMPPSim.pdu.PduConstants;
13 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
14 | import com.seleniumsoftware.SMPPSim.util.LoggingUtilities;
15 |
16 | public class OutbindTest {
17 |
18 | String smppAccountName = "smppclient";
19 |
20 | String smppPassword = "password";
21 |
22 | String smppSystemType = "tests";
23 |
24 | String smppAddressRange = "[0-9]";
25 |
26 | boolean txBound;
27 |
28 | boolean rxBound;
29 |
30 | Session session;
31 |
32 | String smppHost = "localhost";
33 |
34 | int smppPort = 2775;
35 |
36 | int outbindPort = 2776;
37 |
38 | byte[] packetLen = new byte[4];
39 |
40 | byte[] message;
41 |
42 | private static Object mutex = new Object();
43 |
44 | private static Logger logger = Logger.getLogger("smppsim.tests");
45 |
46 | public static void main(String args[]) throws Exception {
47 | OutbindTest ot = new OutbindTest();
48 | ot.start();
49 | }
50 |
51 | public void start() throws Exception {
52 | logger.info("Outbind test starting.....");
53 | logger.info("Waiting for outbind.....");
54 | boolean outbind = false;
55 | ServerSocket ss = new ServerSocket(outbindPort);
56 | while (!outbind) {
57 | Socket socket = ss.accept();
58 | logger.info("Accepted a connection");
59 | InputStream is = socket.getInputStream();
60 | logger.info("Received client connection");
61 | boolean done = false;
62 | int i = readPacketInto(is);
63 | LoggingUtilities.hexDump("PDU", message, i);
64 | int cmd = PduUtilities.getIntegerValue(message, 4, 4);
65 | if (cmd == PduConstants.OUTBIND)
66 | outbind = true;
67 | }
68 | Response resp = null;
69 | Connection conn;
70 | try {
71 | conn = new TCPIPConnection(smppHost, smppPort);
72 | session = new Session(conn);
73 | BindRequest breq = new BindReceiver();
74 | breq.setSystemId(smppAccountName);
75 | breq.setPassword(smppPassword);
76 | breq.setInterfaceVersion((byte) 0x34);
77 | breq.setSystemType(smppSystemType);
78 | resp = session.bind(breq);
79 | } catch (Exception e) {
80 | logger.log(Level.WARNING, "Exception: " + e.getMessage(), e);
81 | }
82 | logger.info("Established receiver session successfully");
83 |
84 | boolean got_all_mo = false;
85 | int mo_count=0;
86 | while (!got_all_mo) {
87 | PDU mo = session.receive(2000);
88 | if (mo != null) {
89 | logger.info(mo.debugString());
90 | mo_count++;
91 | Response response = ((Request)mo).getResponse();
92 | session.respond(response);
93 | } else
94 | got_all_mo = true;
95 | }
96 | logger.info("Received "+mo_count+" MO messages");
97 | try {
98 | session.unbind();
99 | } catch (Exception e) {
100 | logger.log(Level.WARNING, "Exception: " + e.getMessage(), e);
101 | logger.warning("Unbind operation failed for RX session. "
102 | + e.getMessage());
103 | }
104 | logger.info("End of test");
105 | System.exit(0);
106 | }
107 |
108 | private static final int getBytesAsInt(byte i_byte) {
109 | return i_byte & 0xff;
110 | }
111 |
112 | private int readPacketInto(InputStream is) throws IOException {
113 | int len;
114 | packetLen[0] = (byte) is.read();
115 | packetLen[1] = (byte) is.read();
116 | packetLen[2] = (byte) is.read();
117 | packetLen[3] = (byte) is.read();
118 | len =
119 | (getBytesAsInt(packetLen[0]) << 24)
120 | | (getBytesAsInt(packetLen[1]) << 16)
121 | | (getBytesAsInt(packetLen[2]) << 8)
122 | | (getBytesAsInt(packetLen[3]));
123 |
124 | if (packetLen[3] == -1) {
125 | logger.warning("packetLen[3] == -1, throwing EOFException");
126 | throw new EOFException();
127 | }
128 |
129 | logger.finest("Reading " + len + " bytes");
130 | message = new byte[len];
131 | message[0] = packetLen[0];
132 | message[1] = packetLen[1];
133 | message[2] = packetLen[2];
134 | message[3] = packetLen[3];
135 | for (int i = 4; i < len; i++)
136 | message[i] = (byte) is.read();
137 | return len;
138 | }
139 |
140 |
141 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/QuerySMResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * QuerySMResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/QuerySMResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
30 |
31 | import java.util.*;
32 |
33 | public class QuerySMResp extends Response implements Marshaller {
34 |
35 | private String original_message_id;
36 | private String final_date;
37 | private int message_state;
38 | private int error_code;
39 |
40 | public QuerySMResp(QuerySM requestMsg) {
41 | // message header fields except message length
42 | setCmd_id(PduConstants.QUERY_SM_RESP);
43 | setCmd_status(PduConstants.ESME_ROK);
44 | setSeq_no(requestMsg.getSeq_no());
45 | // Set message length to zero since actual length will not be known until the object is
46 | // converted back to a message complete with null terminated strings
47 | setCmd_len(0);
48 | // message body
49 | original_message_id = requestMsg.getOriginal_message_id();
50 | Date now = new Date();
51 | final_date = SmppTime.dateToSMPPString(now);
52 | message_state = PduConstants.DELIVERED;
53 | error_code = PduConstants.ESME_ROK;
54 |
55 | }
56 |
57 | public byte[] marshall() throws Exception {
58 | out.reset();
59 | super.prepareHeaderForMarshalling();
60 | out.write(PduUtilities.stringToNullTerminatedByteArray(original_message_id));
61 | out.write(PduUtilities.stringToNullTerminatedByteArray(final_date));
62 | out.write(PduUtilities.makeByteArrayFromInt(message_state,1));
63 | out.write(PduUtilities.makeByteArrayFromInt(error_code,1));
64 | byte[] response = out.toByteArray();
65 | int l = response.length;
66 | response = PduUtilities.setPduLength(response, l);
67 | return response;
68 | }
69 | /**
70 | * @return
71 | */
72 | public int getError_code() {
73 | return error_code;
74 | }
75 |
76 | /**
77 | * @return
78 | */
79 | public String getFinal_date() {
80 | return final_date;
81 | }
82 |
83 | /**
84 | * @return
85 | */
86 | public int getMessage_state() {
87 | return message_state;
88 | }
89 |
90 | /**
91 | * @return
92 | */
93 | public String getOriginal_message_id() {
94 | return original_message_id;
95 | }
96 |
97 | /**
98 | * @param i
99 | */
100 | public void setError_code(int i) {
101 | error_code = i;
102 | }
103 |
104 | /**
105 | * @param string
106 | */
107 | public void setFinal_date(String string) {
108 | final_date = string;
109 | }
110 |
111 | /**
112 | * @param i
113 | */
114 | public void setMessage_state(int i) {
115 | message_state = i;
116 | }
117 |
118 | /**
119 | * @param string
120 | */
121 | public void setOriginal_message_id(String string) {
122 | original_message_id = string;
123 | }
124 |
125 | /**
126 | * *returns String representation of PDU
127 | */
128 | public String toString() {
129 | return super.toString()+","+
130 | "original_message_id="+original_message_id+","+
131 | "final_date="+final_date+","+
132 | "message_state="+message_state+","+
133 | "error_code="+error_code;
134 | }
135 |
136 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/examples/CallbackHandler.java:
--------------------------------------------------------------------------------
1 | package com.seleniumsoftware.examples;
2 |
3 | import com.seleniumsoftware.SMPPSim.SMPPSim;
4 | import java.io.ByteArrayOutputStream;
5 | import java.io.EOFException;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.net.ServerSocket;
9 | import java.net.Socket;
10 | import java.net.SocketException;
11 | import org.slf4j.LoggerFactory;
12 |
13 | public class CallbackHandler implements Runnable {
14 |
15 | private static org.slf4j.Logger logger = LoggerFactory.getLogger(CallbackHandler.class);
16 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.examples");
17 |
18 | ServerSocket ss;
19 |
20 | CallbackReceivable receiver;
21 |
22 | byte[] messageLen = new byte[4];
23 |
24 | byte[] message;
25 |
26 | boolean start_of_message = true;
27 | boolean running = true;
28 |
29 | int current_length = 0;
30 |
31 | int expected_length;
32 |
33 | public CallbackHandler(ServerSocket ss, CallbackReceivable receiver) {
34 | this.ss = ss;
35 | this.receiver = receiver;
36 | }
37 |
38 | public void run() {
39 | running = true;
40 | Socket socket = null;
41 | boolean isConnected = false;
42 |
43 | InputStream is = null;
44 | do // process connections forever
45 | {
46 | do // {accept connection, create protocol handler, {read PDU,handle
47 | // it}, close connection}
48 | {
49 | try {
50 | socket = ss.accept();
51 | isConnected = true;
52 | is = socket.getInputStream();
53 | logger.info("CallbackHandler has accepted a connection");
54 | } catch (Exception exception) {
55 | logger.error("Exception processing connection: "
56 | + exception.getMessage());
57 | logger.error("Exception is of type: "
58 | + exception.getClass().getName());
59 | exception.printStackTrace();
60 | try {
61 | socket.close();
62 | } catch (Exception e) {
63 | logger
64 | .error("Could not close socket following exception");
65 | e.printStackTrace();
66 | }
67 | }
68 | } while (!isConnected);
69 |
70 | do // until the end of time
71 | {
72 | try {
73 | readPacketInto(is);
74 | if (isReceived(message))
75 | receiver.received(message);
76 | else
77 | receiver.sent(message);
78 | } catch (SocketException se) {
79 | logger
80 | .info("Socket exception: probably connection closed by client without error");
81 | se.printStackTrace();
82 | isConnected = false;
83 | } catch (Exception exception) {
84 | logger.info(exception.getMessage());
85 | exception.printStackTrace();
86 | try {
87 | socket.close();
88 | } catch (Exception e) {
89 | logger
90 | .error("Could not close socket following exception");
91 | e.printStackTrace();
92 | }
93 | isConnected = false;
94 | }
95 | } while (isConnected);
96 | logger.debug("leaving callback handler main loop");
97 | } while (running);
98 | }
99 |
100 | private int readPacketInto(InputStream is) throws IOException {
101 | logger.debug("starting readPacketInto");
102 | // Read the length of the incoming message...
103 | int len;
104 |
105 | logger.debug("reading message length");
106 | messageLen[0] = (byte) is.read();
107 | messageLen[1] = (byte) is.read();
108 | messageLen[2] = (byte) is.read();
109 | messageLen[3] = (byte) is.read();
110 |
111 | // put that into the message header
112 | len = (getBytesAsInt(messageLen[0]) << 24)
113 | | (getBytesAsInt(messageLen[1]) << 16)
114 | | (getBytesAsInt(messageLen[2]) << 8)
115 | | (getBytesAsInt(messageLen[3]));
116 |
117 | if (messageLen[3] == -1) {
118 | logger.error("messageLen[3] == -1, throwing EOFException");
119 | throw new EOFException();
120 | }
121 |
122 | logger.debug("Reading " + len + " bytes");
123 |
124 | message = new byte[len];
125 | message[0] = messageLen[0];
126 | message[1] = messageLen[1];
127 | message[2] = messageLen[2];
128 | message[3] = messageLen[3];
129 | for (int i = 4; i < len; i++)
130 | message[i] = (byte) is.read();
131 | logger.debug("exiting readPacketInto");
132 | return len;
133 | }
134 |
135 | private static final int getBytesAsInt(byte i_byte) {
136 | return i_byte & 0xff;
137 | }
138 |
139 | private boolean isReceived(byte[] message) {
140 | return (message[4] == 0x01);
141 | }
142 |
143 | public void setRunning(boolean state) {
144 | running = state;
145 | }
146 | }
--------------------------------------------------------------------------------
/src/main/java/tests/SmppsimQuerySmTests.java:
--------------------------------------------------------------------------------
1 | package tests;
2 | import tests.exceptions.*;
3 | import junit.framework.*;
4 |
5 | import java.net.*;
6 | import java.util.logging.*;
7 | import com.logica.smpp.*;
8 | import com.logica.smpp.pdu.*;
9 | import org.slf4j.LoggerFactory;
10 |
11 | public class SmppsimQuerySmTests extends TestCase {
12 |
13 | String smppServiceType = "tests";
14 | String srcAddress = "12345";
15 | String destAddress = "4477805432122";
16 | String smppAccountName = "smppclient";
17 | String smppPassword = "password";
18 | String smppSystemType = "tests";
19 | String smppAddressRange = "[0-9]";
20 | boolean txBound;
21 | boolean rxBound;
22 | Session session;
23 | String smppHost = "localhost";
24 | int smppPort = 2775;
25 | int smppAltPort1 = 2776;
26 | private static org.slf4j.Logger logger = LoggerFactory.getLogger("test");
27 |
28 | // private static Logger logger = Logger.getLogger("smppsim.tests");
29 |
30 | public SmppsimQuerySmTests() {
31 | }
32 |
33 | /*
34 | * Condition: Basic query_sm sent
35 | *
36 | * Expected: No exceptions. ESME_ROK in response.
37 | */
38 |
39 | public void test001QuerySM()
40 | throws BindTransmitterException, QuerySmFailedException, SubmitSmFailedException, SocketException {
41 | logger.info("Attempting to establish transmitter session");
42 | Response resp = null;
43 | Connection conn;
44 | // get a transmitter session
45 | try {
46 | conn = new TCPIPConnection(smppHost, smppPort);
47 | session = new Session(conn);
48 | BindRequest breq = new BindTransmitter();
49 | breq.setSystemId(smppAccountName);
50 | breq.setPassword(smppPassword);
51 | breq.setInterfaceVersion((byte) 0x34);
52 | breq.setSystemType(smppSystemType);
53 | resp = session.bind(breq);
54 | } catch (Exception e) {
55 | logger.error(
56 | "Exception whilst setting up or executing bind transmitter. "
57 | + e.getMessage());
58 | fail(
59 | "Exception whilst setting up or executing bind transmitter. "
60 | + e.getMessage());
61 | throw new BindTransmitterException(
62 | "Exception whilst setting up or executing bind transmitter. "
63 | + e.getMessage());
64 | }
65 | assertEquals(
66 | "BindTransmitter failed: response was not ESME_ROK",
67 | Data.ESME_ROK,
68 | resp.getCommandStatus());
69 | logger.info("Established transmitter session successfully");
70 |
71 | // now send a message
72 |
73 | String messageid = "";
74 | try {
75 | SubmitSM request = new SubmitSM();
76 | SubmitSMResp response;
77 | // set values
78 | request.setServiceType(smppServiceType);
79 | request.setSourceAddr(srcAddress);
80 | request.setDestAddr(destAddress);
81 | request.setShortMessage("SUBMIT_SM test using JUnit");
82 |
83 | // send the request
84 |
85 | request.assignSequenceNumber(true);
86 | response = session.submit(request);
87 | messageid = response.getMessageId();
88 | assertEquals(
89 | "SUBMIT_SM failed: response was not ESME_ROK",
90 | Data.ESME_ROK,
91 | response.getCommandStatus());
92 | } catch (SocketException se) {
93 | logger.error("Connection has dropped");
94 | throw se;
95 | } catch (Exception e) {
96 | logger.error(e.getMessage());
97 | throw new SubmitSmFailedException();
98 | }
99 |
100 | // Now query the message state
101 | try {
102 | QuerySM request = new QuerySM();
103 | QuerySMResp response;
104 |
105 | // set values
106 | request.setMessageId(messageid);
107 | request.setSourceAddr(srcAddress);
108 |
109 | // send the request
110 | response = session.query(request);
111 | messageid = response.getMessageId();
112 | assertEquals(
113 | "QUERY_SM failed: response was not ESME_ROK",
114 | Data.ESME_ROK,
115 | response.getCommandStatus());
116 | } catch (SocketException se) {
117 | logger.error("Connection has dropped");
118 | throw se;
119 | } catch (Exception e) {
120 | logger.error(e.getMessage());
121 | throw new QuerySmFailedException();
122 | }
123 |
124 | // Now unbind and disconnect ready for the next test
125 | try {
126 | UnbindResp response = session.unbind();
127 | } catch (Exception e) {
128 | logger.error(
129 | "Unbind operation failed for TX session. " + e.getMessage());
130 | }
131 | }
132 |
133 | // TODO test message states using DeterministicLifeCycleManager
134 |
135 | }
--------------------------------------------------------------------------------
/src/main/java/tests/SmppsimDeliverSmTests.java:
--------------------------------------------------------------------------------
1 | package tests;
2 | import tests.exceptions.*;
3 | import junit.framework.*;
4 |
5 | import java.io.IOException;
6 | import java.net.*;
7 | import java.util.logging.*;
8 | import com.logica.smpp.*;
9 | import com.logica.smpp.pdu.*;
10 | import com.seleniumsoftware.SMPPSim.SMPPSim;
11 | import org.slf4j.LoggerFactory;
12 |
13 | public class SmppsimDeliverSmTests extends TestCase {
14 |
15 | String smppServiceType = "tests";
16 | String srcAddress = "12345";
17 | String destAddress = "4477805432122";
18 | String smppAccountName = "smppclient";
19 | String smppPassword = "password";
20 | String smppSystemType = "tests";
21 | String smppAddressRange = "[0-9]";
22 | boolean txBound;
23 | boolean rxBound;
24 | Session session;
25 | String smppHost = "localhost";
26 | int smppPort = 2775;
27 | int smppAltPort2 = 2777;
28 | // private static Logger logger = Logger.getLogger("smppsim.tests");
29 | private static org.slf4j.Logger logger = LoggerFactory.getLogger("test");
30 | public SmppsimDeliverSmTests() {
31 | }
32 |
33 | /*
34 | * Condition: Basic deliver_sm. Test will block until it receives a PDU. Requires an instance
35 | * of SMPPSim running in delivery mode.
36 | * Expected: No exceptions. ESME_ROK response.
37 | */
38 |
39 | public void test001DeliverSM()
40 | throws DeliverSmFailedException, BindReceiverException, SocketException {
41 | logger.info("Attempting to establish receiver session");
42 | Response resp = null;
43 | Connection conn;
44 | // get a receiver session
45 | try {
46 | conn = new TCPIPConnection(smppHost, smppAltPort2);
47 | session = new Session(conn);
48 | BindRequest breq = new BindReceiver();
49 | breq.setSystemId(smppAccountName);
50 | breq.setPassword(smppPassword);
51 | breq.setInterfaceVersion((byte) 0x34);
52 | breq.setSystemType(smppSystemType);
53 | breq.setAddressRange((byte) 1, (byte) 1, smppAddressRange);
54 | resp = session.bind(breq);
55 | } catch (Exception e) {
56 | logger.error(
57 | "Exception whilst setting up or executing bind receiver. "
58 | + e.getMessage());
59 | fail(
60 | "Exception whilst setting up or executing bind receiver. "
61 | + e.getMessage());
62 | throw new BindReceiverException(
63 | "Exception whilst setting up or executing bind receiver. "
64 | + e.getMessage());
65 | }
66 | assertEquals(
67 | "BindReceiver failed: response was not ESME_ROK",
68 | Data.ESME_ROK,
69 | resp.getCommandStatus());
70 | logger.info("Established receiver session successfully");
71 |
72 | // now wait for a message
73 | PDU pdu = null;
74 | DeliverSM deliversm;
75 | Response response;
76 | boolean gotDeliverSM = false;
77 | while (!gotDeliverSM) {
78 | try {
79 | // wait for a PDU
80 | pdu = session.receive();
81 | if (pdu != null) {
82 | if (pdu instanceof DeliverSM) {
83 | deliversm = (DeliverSM) pdu;
84 | gotDeliverSM = true;
85 | logger.info("Received DELIVER_SM");
86 | response = ((Request)pdu).getResponse();
87 | session.respond(response);
88 |
89 | } else {
90 | if (pdu instanceof EnquireLinkResp) {
91 | logger.debug("EnquireLinkResp received");
92 | } else {
93 | logger.debug(
94 | "Unexpected PDU of type: "
95 | + pdu.getClass().getName()
96 | + " received - discarding");
97 | fail(
98 | "Unexpected PDU type received"
99 | + pdu.getClass().getName());
100 | }
101 | }
102 | }
103 | } catch (SocketException e) {
104 | fail("Connection has dropped for some reason");
105 | } catch (IOException ioe) {
106 | fail("IOException: " + ioe.getMessage());
107 | } catch (NotSynchronousException nse) {
108 | fail("NotSynchronousException: " + nse.getMessage());
109 | } catch (PDUException pdue) {
110 | fail("PDUException: " + pdue.getMessage());
111 | } catch (TimeoutException toe) {
112 | fail("TimeoutException: " + toe.getMessage());
113 | } catch (WrongSessionStateException wsse) {
114 | fail("WrongSessionStateException: " + wsse.getMessage());
115 | }
116 | }
117 | // Now unbind and disconnect ready for the next test
118 | try {
119 | session.unbind();
120 | } catch (Exception e) {
121 | logger.error(
122 | "Unbind operation failed for RX session. " + e.getMessage());
123 | }
124 | }
125 |
126 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/SubmitMultiResp.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * SubmitMultiResp.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/SubmitMultiResp.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 | import com.seleniumsoftware.SMPPSim.*;
30 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
31 |
32 | public class SubmitMultiResp extends Response implements Marshaller {
33 |
34 | private Smsc smsc = Smsc.getInstance();
35 |
36 | private String message_id;
37 | private int no_unsuccess;
38 | private UnsuccessSME[] unsuccess_smes;
39 |
40 | public SubmitMultiResp(SubmitMulti requestMsg) {
41 | // message header fields except message length
42 | setCmd_id(PduConstants.SUBMIT_MULTI_RESP);
43 | setCmd_status(PduConstants.ESME_ROK);
44 | setSeq_no(requestMsg.getSeq_no());
45 | // Set message length to zero since actual length will not be known until the object is
46 | // converted back to a message complete with null terminated strings
47 | setCmd_len(0);
48 |
49 | // message body
50 | message_id = smsc.getMessageID();
51 | no_unsuccess = 0;
52 | // until we have message state simulator working
53 | }
54 |
55 | public byte[] marshall() throws Exception {
56 | out.reset();
57 | UnsuccessSME u = new UnsuccessSME();
58 | super.prepareHeaderForMarshalling();
59 |
60 | out.write(PduUtilities.stringToNullTerminatedByteArray(message_id));
61 | out.write(PduUtilities.makeByteArrayFromInt(no_unsuccess, 1));
62 | for (int i=0;i 0)
116 | string = string + unsuccessSmesToString(unsuccess_smes);
117 | else
118 | string = string + "";
119 | return string;
120 | }
121 |
122 | public String unsuccessSmesToString(UnsuccessSME[] unsuccess_smes) {
123 | int l=unsuccess_smes.length;
124 | StringBuffer sb = new StringBuffer();
125 | for (int i=0;i= 0; i--) {
139 | ba[ia] = msg[inx + i];
140 | ia--;
141 | }
142 | for (int i = ia; i >= 0; i--) {
143 | ba[i] = 0x00;
144 | }
145 |
146 | newInt |= ((((int) ba[0]) << 24) & 0xff000000);
147 | newInt |= ((((int) ba[1]) << 16) & 0x00ff0000);
148 | newInt |= ((((int) ba[2]) << 8) & 0x0000ff00);
149 | newInt |= (((int) ba[3]) & 0x000000ff);
150 |
151 | return newInt;
152 | }
153 |
154 | public static short getShortValue(byte[] msg, int start, int len) {
155 | if (msg == null) {
156 | return 0;
157 | }
158 | int inx = start;
159 | byte[] ba = new byte[2];
160 | short newShort = 0x00000000;
161 | int l = len - 1;
162 | int ia = 1;
163 |
164 | for (int i = l; i >= 0; i--) {
165 | ba[ia] = msg[inx + i];
166 | ia--;
167 | }
168 | for (int i = ia; i >= 0; i--) {
169 | ba[i] = 0x00;
170 | }
171 |
172 | newShort |= ((((int) ba[0]) << 8) & 0x0000ff00);
173 | newShort |= (((int) ba[1]) & 0x000000ff);
174 |
175 | return newShort;
176 | }
177 |
178 | }
--------------------------------------------------------------------------------
/src/main/java/tests/SmppsimReplaceSmTests.java:
--------------------------------------------------------------------------------
1 | package tests;
2 | import tests.exceptions.*;
3 | import junit.framework.*;
4 |
5 | import java.net.*;
6 | import java.util.logging.*;
7 | import com.logica.smpp.*;
8 | import com.logica.smpp.pdu.*;
9 | import org.slf4j.LoggerFactory;
10 |
11 | public class SmppsimReplaceSmTests extends TestCase {
12 |
13 | String smppServiceType = "tests";
14 | String srcAddress = "12345";
15 | String destAddress = "4477805432122";
16 | String smppAccountName = "smppclient";
17 | String smppPassword = "password";
18 | String smppSystemType = "tests";
19 | String smppAddressRange = "[0-9]";
20 | boolean txBound;
21 | boolean rxBound;
22 | Session session;
23 | String smppHost = "localhost";
24 | int smppPort = 2775;
25 | int smppAltPort1 = 2776;
26 | private static org.slf4j.Logger logger = LoggerFactory.getLogger("test");
27 |
28 | // private static Logger logger = Logger.getLogger("smppsim.tests");
29 |
30 | public SmppsimReplaceSmTests() {
31 | }
32 |
33 | /*
34 | * Condition: Basic cancel_sm sent
35 | *
36 | * Expected: No exceptions. ESME_ROK in response.
37 | */
38 |
39 | public void test001ReplaceSM()
40 | throws BindTransmitterException, ReplaceSmFailedException, SubmitSmFailedException, SocketException {
41 | logger.info("Attempting to establish transmitter session");
42 | Response resp = null;
43 | Connection conn;
44 | // get a transmitter session
45 | try {
46 | conn = new TCPIPConnection(smppHost, smppPort);
47 | session = new Session(conn);
48 | BindRequest breq = new BindTransmitter();
49 | breq.setSystemId(smppAccountName);
50 | breq.setPassword(smppPassword);
51 | breq.setInterfaceVersion((byte) 0x34);
52 | breq.setSystemType(smppSystemType);
53 | resp = session.bind(breq);
54 | } catch (Exception e) {
55 | logger.error(
56 | "Exception whilst setting up or executing bind transmitter. "
57 | + e.getMessage());
58 | fail(
59 | "Exception whilst setting up or executing bind transmitter. "
60 | + e.getMessage());
61 | throw new BindTransmitterException(
62 | "Exception whilst setting up or executing bind transmitter. "
63 | + e.getMessage());
64 | }
65 | assertEquals(
66 | "BindTransmitter failed: response was not ESME_ROK",
67 | Data.ESME_ROK,
68 | resp.getCommandStatus());
69 | logger.info("Established transmitter session successfully");
70 |
71 | // now send a message
72 |
73 | String messageid = "";
74 | try {
75 | SubmitSM request = new SubmitSM();
76 | SubmitSMResp response;
77 | // set values
78 | request.setServiceType(smppServiceType);
79 | request.setSourceAddr(srcAddress);
80 | request.setDestAddr(destAddress);
81 |
82 | request.setScheduleDeliveryTime("090223170405000+");
83 | request.setValidityPeriod("090323170405000+");
84 | request.setRegisteredDelivery((byte)0);
85 | request.setSmDefaultMsgId((byte)0);
86 | request.setShortMessage("SUBMIT_SM test using JUnit");
87 |
88 | // TODO just noticed that null in a replacesm attribute means "don't change this attribute"
89 |
90 | // send the request
91 |
92 | request.assignSequenceNumber(true);
93 | response = session.submit(request);
94 | messageid = response.getMessageId();
95 | assertEquals(
96 | "SUBMIT_SM failed: response was not ESME_ROK",
97 | Data.ESME_ROK,
98 | response.getCommandStatus());
99 | } catch (SocketException se) {
100 | logger.error("Connection has dropped");
101 | throw se;
102 | } catch (Exception e) {
103 | logger.error(e.getMessage());
104 | throw new SubmitSmFailedException();
105 | }
106 |
107 | // Now replace the message
108 | try {
109 | ReplaceSM request = new ReplaceSM();
110 | ReplaceSMResp response;
111 |
112 | // set values
113 | request.setMessageId(messageid);
114 | request.setSourceAddr(srcAddress);
115 | // Different values to the originals in all cases
116 | // Note have to manually inspect log to check this currently
117 | request.setScheduleDeliveryTime("100223170405000+");
118 | request.setValidityPeriod("100323170405000+");
119 | request.setRegisteredDelivery((byte)1);
120 | request.setSmDefaultMsgId((byte)1);
121 | request.setShortMessage("REPLACE_SM test using JUnit");
122 |
123 | // send the request
124 | response = session.replace(request);
125 | assertEquals(
126 | "REPLACE_SM failed: response was not ESME_ROK",
127 | Data.ESME_ROK,
128 | response.getCommandStatus());
129 | } catch (SocketException se) {
130 | logger.error("Connection has dropped");
131 | throw se;
132 | } catch (Exception e) {
133 | logger.error(e.getMessage());
134 | throw new ReplaceSmFailedException();
135 | }
136 |
137 | // Now unbind and disconnect ready for the next test
138 | try {
139 | UnbindResp response = session.unbind();
140 | } catch (Exception e) {
141 | logger.error(
142 | "Unbind operation failed for TX session. " + e.getMessage());
143 | }
144 | }
145 |
146 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/DataSMResp.java:
--------------------------------------------------------------------------------
1 | package com.seleniumsoftware.SMPPSim.pdu;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.Iterator;
6 | import java.util.List;
7 |
8 | import com.seleniumsoftware.SMPPSim.pdu.util.PduUtilities;
9 | import com.seleniumsoftware.SMPPSim.*;
10 |
11 | /****************************************************************************
12 | * DataSMResp
13 | *
14 | * Copyright (C) Selenium Software Ltd 2006
15 | *
16 | * This file is part of SMPPSim.
17 | *
18 | * SMPPSim is free software; you can redistribute it and/or modify
19 | * it under the terms of the GNU General Public License as published by
20 | * the Free Software Foundation; either version 2 of the License, or
21 | * (at your option) any later version.
22 | *
23 | * SMPPSim is distributed in the hope that it will be useful,
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 | * GNU General Public License for more details.
27 | *
28 | * You should have received a copy of the GNU General Public License
29 | * along with SMPPSim; if not, write to the Free Software
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 | *
32 | * @author Jean-Cedric Desrochers
33 | * http://www.woolleynet.com
34 | * http://www.seleniumsoftware.com
35 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/DataSMResp.java,v 1.1 2012/07/24 14:48:59 martin Exp $
36 | ****************************************************************************/
37 |
38 | public class DataSMResp extends Response implements Marshaller, Demarshaller {
39 |
40 | private Smsc smsc = Smsc.getInstance();
41 | String message_id;
42 |
43 | // Optional PDU attributes
44 | private HashMap optionalsByTag = new HashMap();
45 |
46 | public DataSMResp() {
47 | }
48 |
49 | public DataSMResp(DataSM requestMsg) {
50 | // message header fields except message length
51 | setCmd_id(PduConstants.DATA_SM_RESP);
52 | setCmd_status(PduConstants.ESME_ROK);
53 | setSeq_no(requestMsg.getSeq_no());
54 | // Set message length to zero since actual length will not be known until the object is
55 | // converted back to a message complete with null terminated strings
56 | setCmd_len(0);
57 |
58 | // message body
59 | message_id = smsc.getMessageID();
60 | }
61 |
62 | public byte[] marshall() throws Exception {
63 | out.reset();
64 | super.prepareHeaderForMarshalling();
65 | out.write(PduUtilities.stringToNullTerminatedByteArray(message_id));
66 |
67 | for (Iterator it = optionalsByTag.values().iterator(); it.hasNext(); ) {
68 | Tlv opt = it.next();
69 | out.write(PduUtilities.makeByteArrayFromInt(opt.getTag(), 2));
70 | out.write(PduUtilities.makeByteArrayFromInt(opt.getLen(), 2));
71 | out.write(opt.getValue());
72 | }
73 |
74 | byte[] response = out.toByteArray();
75 | int l = response.length;
76 | response = PduUtilities.setPduLength(response, l);
77 | return response;
78 | }
79 |
80 |
81 | public void demarshall(byte[] request) throws Exception {
82 |
83 | // demarshall the header
84 | int inx = 0;
85 | setCmd_len(PduUtilities.getIntegerValue(request, inx, 4));
86 | inx = inx+4;
87 | setCmd_id(PduUtilities.getIntegerValue(request, inx, 4));
88 | inx = inx+4;
89 | setCmd_status(PduUtilities.getIntegerValue(request, inx, 4));
90 | inx = inx+4;
91 | setSeq_no(PduUtilities.getIntegerValue(request, inx, 4));
92 |
93 | // now set mandatory attributes of this specific PDU type
94 | inx = inx+4;
95 | message_id = PduUtilities.getStringValueNullTerminated(request, inx, 65, PduConstants.C_OCTET_STRING_TYPE);
96 | }
97 |
98 | /**
99 | * @return
100 | */
101 | public String getMessage_id() {
102 | return message_id;
103 | }
104 |
105 | public boolean hasOptionnal(short aTag) {
106 | return optionalsByTag.containsKey(new Short(aTag));
107 | }
108 |
109 | public Tlv getOptionnal(short aTag) {
110 | return optionalsByTag.get(new Short(aTag));
111 | }
112 |
113 | public List getOptionnalTags() {
114 | return new ArrayList(optionalsByTag.keySet());
115 | }
116 |
117 | /**
118 | * @param string
119 | */
120 | public void setMessage_id(String string) {
121 | message_id = string;
122 | }
123 |
124 | public void setOptionnal(Tlv opt) {
125 | optionalsByTag.put(new Short(opt.getTag()), opt);
126 | }
127 |
128 | public String toString() {
129 | StringBuffer sb = new StringBuffer();
130 | sb.append(super.toString()).
131 | append(",message_id=").append(message_id);
132 |
133 | if (optionalsByTag.size() > 0) {
134 | for (Iterator it = optionalsByTag.values().iterator(); it.hasNext(); ) {
135 | sb.append(",").append(it.next().toString());
136 | }
137 | }
138 | return sb.toString();
139 | }
140 |
141 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/MoMessagePool.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * MoMessagePool.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/MoMessagePool.java,v 1.1 2012/07/24 14:49:00 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim;
29 |
30 | import com.seleniumsoftware.SMPPSim.exceptions.InvalidHexStringlException;
31 | import com.seleniumsoftware.SMPPSim.pdu.*;
32 | import com.seleniumsoftware.SMPPSim.util.Utilities;
33 |
34 | import java.util.*;
35 | import java.io.*;
36 | import org.slf4j.Logger;
37 | import org.slf4j.LoggerFactory;
38 |
39 | public class MoMessagePool {
40 |
41 | private static Logger logger = LoggerFactory.getLogger(MoMessagePool.class);
42 |
43 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
44 |
45 | private Vector messages;
46 |
47 | private BufferedReader messagesReader;
48 |
49 | private String source_addr;
50 |
51 | private String destination_addr;
52 |
53 | private byte[] short_message;
54 |
55 | private int data_coding = 0;
56 |
57 | private int recno = 0;
58 |
59 | public MoMessagePool() {
60 | }
61 |
62 | public MoMessagePool(String filename) {
63 | String record = null;
64 | DeliverSM msg;
65 | messages = new Vector();
66 | try {
67 | messagesReader = new BufferedReader(new FileReader(filename));
68 | } catch (FileNotFoundException fnfe) {
69 | logger.error("MoMessagePool: file not found: " + filename);
70 | fnfe.printStackTrace();
71 | }
72 |
73 | do {
74 | try {
75 | record = messagesReader.readLine();
76 | String therecord;
77 | if (record == null)
78 | therecord = "null";
79 | else
80 | therecord = record;
81 | logger.debug("Read from file:<" + therecord + ">");
82 | if (record != null) {
83 | msg = new DeliverSM();
84 | try {
85 | getMessageAttributes(record);
86 | } catch (Exception e) {
87 | logger
88 | .error("Error processing delivery_messages file, record number"
89 | + (recno + 1));
90 | logger.error(e.getMessage());
91 | e.printStackTrace();
92 | continue;
93 | }
94 | msg.setSource_addr(source_addr);
95 | msg.setDestination_addr(destination_addr);
96 | msg.setShort_message(short_message);
97 | msg.setData_coding(data_coding);
98 | messages.add(msg);
99 | recno++;
100 | logger.debug("Added delivery_message: " + source_addr
101 | + "," + destination_addr + "," + short_message);
102 | }
103 | } catch (Exception e) {
104 | logger.error("Error processing delivery_messages file");
105 | logger.info(e.getMessage());
106 | e.printStackTrace();
107 | }
108 | } while (record != null);
109 | logger.debug("loaded " + recno + " delivery messages");
110 | }
111 |
112 | private void getMessageAttributes(String rec) throws Exception {
113 | int commaIX1;
114 | int commaIX2;
115 | String msg = "";
116 | commaIX1 = rec.indexOf(",");
117 | if (commaIX1 != -1) {
118 | source_addr = rec.substring(0, commaIX1);
119 | commaIX2 = rec.indexOf(",", commaIX1 + 1);
120 | if (commaIX2 != -1) {
121 | destination_addr = rec.substring(commaIX1 + 1, commaIX2);
122 | msg = rec.substring(commaIX2 + 1, rec.length());
123 | data_coding = 0;
124 | if (!msg.startsWith("0x"))
125 | short_message = msg.getBytes();
126 | else {
127 | try {
128 | short_message = Utilities.getByteArrayFromHexString(msg.substring(2));
129 | data_coding = 4; // binary
130 | } catch (InvalidHexStringlException e) {
131 | logger.error("Invalid hex string in MO service input file: <"+msg+">. Used as plain text instead.");
132 | short_message = msg.getBytes();
133 | }
134 | }
135 | } else {
136 | throw new Exception(
137 | "Invalid delivery message file format: record "
138 | + (recno + 1));
139 | }
140 | } else {
141 | throw new Exception("Invalid delivery message file format: record "
142 | + recno);
143 | }
144 |
145 | }
146 |
147 | protected DeliverSM getMessage() {
148 | int messageIX = (int) (Math.random() * recno);
149 | logger.debug("Selected delivery_message #" + messageIX);
150 | DeliverSM dsm = new DeliverSM();
151 | DeliverSM selected = messages.elementAt(messageIX);
152 | ;
153 | dsm = (DeliverSM) selected.clone();
154 | return dsm;
155 | }
156 |
157 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/DelayedInboundQueue.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * DelayedInboundQueue.java
3 | *
4 | * Copyright (C) Martin Woolley 2001
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/DelayedInboundQueue.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************
27 | */
28 | package com.seleniumsoftware.SMPPSim;
29 |
30 | import com.seleniumsoftware.SMPPSim.exceptions.InboundQueueFullException;
31 | import com.seleniumsoftware.SMPPSim.pdu.*;
32 | import java.util.*;
33 | import org.slf4j.Logger;
34 | import org.slf4j.LoggerFactory;
35 |
36 | public class DelayedInboundQueue implements Runnable {
37 |
38 | private static DelayedInboundQueue diqueue;
39 |
40 | // private static Logger logger = Logger
41 | // .getLogger("com.seleniumsoftware.smppsim");
42 |
43 | private static Logger logger = LoggerFactory.getLogger(DelayedInboundQueue.class);
44 |
45 | private Smsc smsc = Smsc.getInstance();
46 |
47 | private InboundQueue iqueue = InboundQueue.getInstance();
48 |
49 | ArrayList delayed_queue_pdus;
50 |
51 | ArrayList delayed_queue_attempts;
52 |
53 | private int period;
54 |
55 | private int max_attempts;
56 |
57 | public static DelayedInboundQueue getInstance() {
58 | if (diqueue == null)
59 | diqueue = new DelayedInboundQueue();
60 | return diqueue;
61 | }
62 |
63 | private DelayedInboundQueue() {
64 | period = SMPPSim.getDelayed_iqueue_period();
65 | max_attempts = SMPPSim.getDelayed_inbound_queue_max_attempts();
66 | delayed_queue_attempts = new ArrayList();
67 | delayed_queue_pdus = new ArrayList();
68 | }
69 |
70 | public void retryLater(Pdu pdu) {
71 | synchronized (delayed_queue_pdus) {
72 | synchronized (delayed_queue_attempts) {
73 | if (!delayed_queue_pdus.contains(pdu)) {
74 | logger.debug("DelayedInboundQueue: adding object to queue<"
75 | + pdu.toString() + ">");
76 | delayed_queue_pdus.add(pdu);
77 | delayed_queue_attempts.add(new Integer(0));
78 | } else {
79 | int i = delayed_queue_pdus.indexOf(pdu);
80 | if (i > -1) {
81 | int a = delayed_queue_attempts.get(i).intValue();
82 | a++;
83 | delayed_queue_attempts.set(i,a);
84 | logger.debug("DelayedInboundQueue: incremented retry count to "+a+" for "+"<"
85 | + pdu.toString() + ">");
86 | }
87 | }
88 | logger.info("DelayedInboundQueue: now contains "
89 | + delayed_queue_pdus.size() + " object(s)");
90 | }
91 | }
92 | }
93 |
94 | public void deliveredOK(Pdu pdu) {
95 | int seqno = pdu.getSeq_no();
96 | synchronized (delayed_queue_pdus) {
97 | synchronized (delayed_queue_attempts) {
98 | logger.debug("DelayedInboundQueue: removing object from queue<"
99 | + pdu.toString() + ">");
100 | int i = delayed_queue_pdus.indexOf(pdu);
101 | if (i > -1) {
102 | Pdu mo = delayed_queue_pdus.get(i);
103 | if (mo.getSeq_no() == seqno) {
104 | delayed_queue_pdus.remove(i);
105 | delayed_queue_attempts.remove(i);
106 | logger.debug("Removed delayed message because it was delivered OK or with permanent error. seqno="+seqno);
107 | }
108 | }
109 | logger.info("DelayedInboundQueue: now contains "
110 | + delayed_queue_pdus.size() + " object(s)");
111 | }
112 | }
113 |
114 | }
115 |
116 | public void run() {
117 | // this code periodically processes the contents of the delayed inbound queue, moving
118 | // messages that are old enough to the active inbound queue for attempted delivery.
119 |
120 | logger.info("Starting DelayedInboundQueue service....");
121 |
122 |
123 | while (true) {
124 | try {
125 | Thread.sleep(period);
126 | } catch (InterruptedException e) {
127 | }
128 | int dcount = delayed_queue_pdus.size();
129 | //logger.info("Processing " + dcount + " messages in the delayed inbound queue");
130 |
131 | synchronized (delayed_queue_pdus) {
132 | synchronized (delayed_queue_attempts) {
133 | for (int i = 0; i < delayed_queue_pdus.size(); i++) {
134 | Pdu mo = delayed_queue_pdus.get(i);
135 | try {
136 | if (delayed_queue_attempts.get(i).intValue() < max_attempts) {
137 | iqueue.addMessage(mo);
138 | int attempts = delayed_queue_attempts.get(i)
139 | .intValue() + 1;
140 | delayed_queue_attempts.set(i, new Integer(
141 | attempts));
142 | logger.debug("Requesting retry delivery of message "+mo.getSeq_no());
143 | } else {
144 | logger.info("MO message not delivered after max ("+max_attempts+") allowed attempts so deleting : "+delayed_queue_pdus.get(i).getSeq_no());
145 | delayed_queue_pdus.remove(i);
146 | }
147 | } catch (InboundQueueFullException e) {
148 | // try again next time around
149 | }
150 | }
151 | }
152 | }
153 | }
154 | }
155 |
156 | }
--------------------------------------------------------------------------------
/conf/props.mo:
--------------------------------------------------------------------------------
1 | # SMPP_PORT specified the port that SMPPSim will listen on for connections from SMPP
2 | # clients. SMPP_CONNECTION_HANDLERS determines the maximum number of client connections
3 | # that can be handled concurrently.
4 | SMPP_PORT=2777
5 | SMPP_CONNECTION_HANDLERS=10
6 |
7 | # Specify the classes that imlement connection and protocol handling respectively here.
8 | # Such classes *must* be subclasses of com.seleniumsoftware.SMPPSim.ConnectionHandler and com.seleniumsoftware.SMPPSim.SMPPProtocolHandler respectively
9 | # Or those classes themselves for the default (good) behaviour
10 | # Supply your own subclasses with particular methods overridden if you want to implement
11 | # bad SMSC behaviours to see how your client application copes...
12 | CONNECTION_HANDLER_CLASS=com.seleniumsoftware.SMPPSim.StandardConnectionHandler
13 | PROTOCOL_HANDLER_CLASS=com.seleniumsoftware.SMPPSim.StandardProtocolHandler
14 |
15 | # Specify the class that implements the message state life cycle simulation.
16 | # Such classes must extend the default class, LifeCycleManager
17 | LIFE_CYCLE_MANAGER=com.seleniumsoftware.SMPPSim.LifeCycleManager
18 | #
19 | # The Deterministic Lifecycle Manager sets message state according to the first character of the message destination address:
20 | # 1=EXPIRED,2=DELETED,3=UNDELIVERABLE,4=ACCEPTED,5=REJECTED, other=DELIVERED
21 | # LIFE_CYCLE_MANAGER=com.seleniumsoftware.SMPPSim.DeterministicLifeCycleManager
22 |
23 | # LifeCycleManager parameters
24 | #
25 | # Check and possibly change the state of messages in the OutboundQueue every n milliseconds
26 | MESSAGE_STATE_CHECK_FREQUENCY=5000
27 |
28 | # Maximum time (in milliseconds) in the initial ENROUTE state
29 | MAX_TIME_ENROUTE=10000
30 |
31 | # Percentage of messages that change state each time we check (excluding expiry or messages being completely discarded due to age)
32 | # Requires an integer between 0 and 100
33 | PERCENTAGE_THAT_TRANSITION=75
34 |
35 | # State transition percentages. These parameters define the percentage of messages that
36 | # transition from ENROUTE to the specified final state. The list of percentages should
37 | # add up to 100 and must be integer values. SMPPSim will adjust the percentages if they do not.
38 |
39 | # Percentage of messages that will transition from ENROUTE to DELIVERED
40 | PERCENTAGE_DELIVERED=90
41 |
42 | # Percentage of messages that will transition from ENROUTE to UNDELIVERABLE
43 | PERCENTAGE_UNDELIVERABLE=6
44 |
45 | # Percentage of messages that will transition from ENROUTE to ACCEPTED
46 | PERCENTAGE_ACCEPTED=2
47 |
48 | # Percentage of messages that will transition from ENROUTE to REJECTED
49 | PERCENTAGE_REJECTED=2
50 |
51 | # Time messages held in queue before being discarded, after a final state has been reached (milliseconds)
52 | # For example, after transitioning to DELIVERED (a final state), state info about this message will be
53 | # retained in the queue for a further (e.g.) 60000 milliseconds before being deleted.
54 | DISCARD_FROM_QUEUE_AFTER=60000
55 |
56 | # Web Management
57 | HTTP_PORT=90
58 | HTTP_THREADS=1
59 | DOCROOT=www
60 | AUTHORISED_FILES=/css/style.css,/index.htm,/inject_mo.htm,/favicon.ico,/images/logo.gif,/images/dots.gif,/user-guide.htm,/images/homepage.gif,/images/inject_mo.gif
61 | INJECT_MO_PAGE=/inject_mo.htm
62 |
63 | # Account details. One account only can be specified. SystemID and Password provided in Binds will be validated against these credentials.
64 | SYSTEM_IDS=smppclient
65 | PASSWORDS=password
66 |
67 | # MO SERVICE
68 | DELIVERY_MESSAGES_PER_MINUTE=1
69 | DELIVER_MESSAGES_FILE=deliver_messages.csv
70 |
71 | # LOOPBACK
72 | LOOPBACK=FALSE
73 |
74 | # QUEUES
75 | # Maximum size parameters are expressed as max number of objects the queue can hold
76 | OUTBOUND_QUEUE_MAX_SIZE=1000
77 | INBOUND_QUEUE_MAX_SIZE=1000
78 |
79 | # LOGGING
80 | # See logging.properties for configuration of the logging system as a whole
81 | #
82 | # Set the following property to true to have each PDU logged in human readable
83 | # format. Uses INFO level logging so the log level must be set accordingly for this
84 | # output to appear.
85 | DECODE_PDUS_IN_LOG=true
86 |
87 | # PDU CAPTURE
88 | # The following properties allow binary and/or decoded PDUs to be captured in files
89 | # This is to allow the results of test runs (especially regression testing) to be
90 | # checked with reference to these files
91 | #
92 | # Note that currently you must use the StandardConnectionHandler and StandardProtocolHandler classes for this
93 | # feature to be available.
94 | #
95 | # _SME_ properties concern PDUs sent from the SME application to SMPPSim
96 | # _SMPPSIM_ properties concern PDUs sent from SMPPSim to the SME application
97 | #
98 | CAPTURE_SME_BINARY=false
99 | CAPTURE_SME_BINARY_TO_FILE=sme_binary.capture
100 | CAPTURE_SMPPSIM_BINARY=false
101 | CAPTURE_SMPPSIM_BINARY_TO_FILE=smppsim_binary.capture
102 | CAPTURE_SME_DECODED=false
103 | CAPTURE_SME_DECODED_TO_FILE=sme_decoded.capture
104 | CAPTURE_SMPPSIM_DECODED=false
105 | CAPTURE_SMPPSIM_DECODED_TO_FILE=smppsim_decoded.capture
106 |
107 | # Byte Stream Callback
108 | #
109 | # This feature, if enabled, will cause SMPPSim to send PDUs received from the ESME or sent to it
110 | # as byte streams over a couple of connections.
111 | # This is intended to be useful in automated testing scenarios where you need to notify the test application
112 | # with details of what was *actually* received by SMPPSim (or sent by it).
113 | #
114 | # Note that byte streams are prepended by the following fields:
115 | #
116 | # a 4 byte integer which indicates the length of the whole callback message
117 | # a 1 byte indicator of the type of interaction giving rise to the callback,
118 | # - where 0x01 means SMPPSim received a request PDU and
119 | # 0x02 means SMPPSim sent a request PDU (e.g. a DeliverSM)
120 | # a 4 byte fixed length identified, which identifies the SMPPSim instance that sent the bytes
121 | #
122 | # So the length of the SMPP pdu is the callback message length - 9.
123 | #
124 | # LENGTH(4) TYPE(1) ID(4) PDU (LENGTH)
125 | CALLBACK=false
126 | CALLBACK_ID=SIM1
127 | CALLBACK_TARGET_HOST=localhost
128 | CALLBACK_PORT=3333
129 |
130 | # MISC
131 | SMSCID=SMPPSim
132 |
--------------------------------------------------------------------------------
/conf/props.std_test:
--------------------------------------------------------------------------------
1 | # SMPP_PORT specified the port that SMPPSim will listen on for connections from SMPP
2 | # clients. SMPP_CONNECTION_HANDLERS determines the maximum number of client connections
3 | # that can be handled concurrently.
4 | SMPP_PORT=2775
5 | SMPP_CONNECTION_HANDLERS=10
6 |
7 | # Specify the classes that imlement connection and protocol handling respectively here.
8 | # Such classes *must* be subclasses of com.seleniumsoftware.SMPPSim.ConnectionHandler and com.seleniumsoftware.SMPPSim.SMPPProtocolHandler respectively
9 | # Or those classes themselves for the default (good) behaviour
10 | # Supply your own subclasses with particular methods overridden if you want to implement
11 | # bad SMSC behaviours to see how your client application copes...
12 | CONNECTION_HANDLER_CLASS=com.seleniumsoftware.SMPPSim.StandardConnectionHandler
13 | PROTOCOL_HANDLER_CLASS=com.seleniumsoftware.SMPPSim.StandardProtocolHandler
14 |
15 | # Specify the class that implements the message state life cycle simulation.
16 | # Such classes must extend the default class, LifeCycleManager
17 | LIFE_CYCLE_MANAGER=com.seleniumsoftware.SMPPSim.LifeCycleManager
18 | #
19 | # The Deterministic Lifecycle Manager sets message state according to the first character of the message destination address:
20 | # 1=EXPIRED,2=DELETED,3=UNDELIVERABLE,4=ACCEPTED,5=REJECTED, other=DELIVERED
21 | # LIFE_CYCLE_MANAGER=com.seleniumsoftware.SMPPSim.DeterministicLifeCycleManager
22 |
23 | # LifeCycleManager parameters
24 | #
25 | # Check and possibly change the state of messages in the OutboundQueue every n milliseconds
26 | MESSAGE_STATE_CHECK_FREQUENCY=5000
27 |
28 | # Maximum time (in milliseconds) in the initial ENROUTE state
29 | MAX_TIME_ENROUTE=10000
30 |
31 | # Percentage of messages that change state each time we check (excluding expiry or messages being completely discarded due to age)
32 | # Requires an integer between 0 and 100
33 | PERCENTAGE_THAT_TRANSITION=75
34 |
35 | # State transition percentages. These parameters define the percentage of messages that
36 | # transition from ENROUTE to the specified final state. The list of percentages should
37 | # add up to 100 and must be integer values. SMPPSim will adjust the percentages if they do not.
38 |
39 | # Percentage of messages that will transition from ENROUTE to DELIVERED
40 | PERCENTAGE_DELIVERED=90
41 |
42 | # Percentage of messages that will transition from ENROUTE to UNDELIVERABLE
43 | PERCENTAGE_UNDELIVERABLE=6
44 |
45 | # Percentage of messages that will transition from ENROUTE to ACCEPTED
46 | PERCENTAGE_ACCEPTED=2
47 |
48 | # Percentage of messages that will transition from ENROUTE to REJECTED
49 | PERCENTAGE_REJECTED=2
50 |
51 | # Time messages held in queue before being discarded, after a final state has been reached (milliseconds)
52 | # For example, after transitioning to DELIVERED (a final state), state info about this message will be
53 | # retained in the queue for a further (e.g.) 60000 milliseconds before being deleted.
54 | DISCARD_FROM_QUEUE_AFTER=60000
55 |
56 | # Web Management
57 | HTTP_PORT=88
58 | HTTP_THREADS=1
59 | DOCROOT=www
60 | AUTHORISED_FILES=/css/style.css,/index.htm,/inject_mo.htm,/favicon.ico,/images/logo.gif,/images/dots.gif,/user-guide.htm,/images/homepage.gif,/images/inject_mo.gif
61 | INJECT_MO_PAGE=/inject_mo.htm
62 |
63 | # Account details. One account only can be specified. SystemID and Password provided in Binds will be validated against these credentials.
64 | SYSTEM_IDS=smppclient
65 | PASSWORDS=password
66 |
67 | # MO SERVICE
68 | DELIVERY_MESSAGES_PER_MINUTE=0
69 | DELIVER_MESSAGES_FILE=deliver_messages.csv
70 |
71 | # LOOPBACK
72 | LOOPBACK=FALSE
73 |
74 | # QUEUES
75 | # Maximum size parameters are expressed as max number of objects the queue can hold
76 | OUTBOUND_QUEUE_MAX_SIZE=1000
77 | INBOUND_QUEUE_MAX_SIZE=1000
78 |
79 | # LOGGING
80 | # See logging.properties for configuration of the logging system as a whole
81 | #
82 | # Set the following property to true to have each PDU logged in human readable
83 | # format. Uses INFO level logging so the log level must be set accordingly for this
84 | # output to appear.
85 | DECODE_PDUS_IN_LOG=true
86 |
87 | # PDU CAPTURE
88 | # The following properties allow binary and/or decoded PDUs to be captured in files
89 | # This is to allow the results of test runs (especially regression testing) to be
90 | # checked with reference to these files
91 | #
92 | # Note that currently you must use the StandardConnectionHandler and StandardProtocolHandler classes for this
93 | # feature to be available.
94 | #
95 | # _SME_ properties concern PDUs sent from the SME application to SMPPSim
96 | # _SMPPSIM_ properties concern PDUs sent from SMPPSim to the SME application
97 | #
98 | CAPTURE_SME_BINARY=false
99 | CAPTURE_SME_BINARY_TO_FILE=sme_binary.capture
100 | CAPTURE_SMPPSIM_BINARY=false
101 | CAPTURE_SMPPSIM_BINARY_TO_FILE=smppsim_binary.capture
102 | CAPTURE_SME_DECODED=false
103 | CAPTURE_SME_DECODED_TO_FILE=sme_decoded.capture
104 | CAPTURE_SMPPSIM_DECODED=false
105 | CAPTURE_SMPPSIM_DECODED_TO_FILE=smppsim_decoded.capture
106 |
107 | # Byte Stream Callback
108 | #
109 | # This feature, if enabled, will cause SMPPSim to send PDUs received from the ESME or sent to it
110 | # as byte streams over a couple of connections.
111 | # This is intended to be useful in automated testing scenarios where you need to notify the test application
112 | # with details of what was *actually* received by SMPPSim (or sent by it).
113 | #
114 | # Note that byte streams are prepended by the following fields:
115 | #
116 | # a 4 byte integer which indicates the length of the whole callback message
117 | # a 1 byte indicator of the type of interaction giving rise to the callback,
118 | # - where 0x01 means SMPPSim received a request PDU and
119 | # 0x02 means SMPPSim sent a request PDU (e.g. a DeliverSM)
120 | # a 4 byte fixed length identified, which identifies the SMPPSim instance that sent the bytes
121 | #
122 | # So the length of the SMPP pdu is the callback message length - 9.
123 | #
124 | # LENGTH(4) TYPE(1) ID(4) PDU (LENGTH)
125 | CALLBACK=false
126 | CALLBACK_ID=SIM1
127 | CALLBACK_TARGET_HOST=localhost
128 | CALLBACK_PORT=3333
129 |
130 | # MISC
131 | SMSCID=SMPPSim
132 |
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/LifeCycleManager.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * LifeCycleManager.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/LifeCycleManager.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim;
29 | import com.seleniumsoftware.SMPPSim.pdu.*;
30 | import org.slf4j.Logger;
31 |
32 | import org.slf4j.LoggerFactory;
33 |
34 | public class LifeCycleManager {
35 |
36 | private static Logger logger = LoggerFactory.getLogger(LifeCycleManager.class);
37 | // private static Logger logger = Logger.getLogger("com.seleniumsoftware.smppsim");
38 | private Smsc smsc = Smsc.getInstance();
39 | private double transitionThreshold;
40 | private double deliveredThreshold;
41 | private double undeliverableThreshold;
42 | private double acceptedThreshold;
43 | private double rejectedThreshold;
44 | private double enrouteThreshold;
45 | private int maxTimeEnroute;
46 | private int discardThreshold;
47 | private double transition;
48 | private double stateChoice;
49 |
50 | public LifeCycleManager() {
51 | double a = (double) SMPPSim.getPercentageThatTransition() + 1.0;
52 | transitionThreshold = (a / 100);
53 | logger.debug("transitionThreshold="+transitionThreshold);
54 | logger.debug("SMPPSim.getPercentageThatTransition()="+SMPPSim.getPercentageThatTransition());
55 | maxTimeEnroute = SMPPSim.getMaxTimeEnroute();
56 | logger.debug("maxTimeEnroute="+maxTimeEnroute);
57 | discardThreshold = SMPPSim.getDiscardFromQueueAfter();
58 | logger.debug("discardThreshold="+discardThreshold);
59 | deliveredThreshold = ((double) SMPPSim.getPercentageDelivered() / 100);
60 | logger.debug("deliveredThreshold="+deliveredThreshold);
61 | // .90
62 | undeliverableThreshold =
63 | deliveredThreshold + ((double) SMPPSim.getPercentageUndeliverable() / 100);
64 | logger.debug("undeliverableThreshold="+undeliverableThreshold);
65 | // .90 + .06 = .96
66 | acceptedThreshold =
67 | undeliverableThreshold + ((double) SMPPSim.getPercentageAccepted() / 100);
68 | logger.debug("acceptedThreshold="+acceptedThreshold);
69 | // .96 + .02 = .98
70 | rejectedThreshold =
71 | acceptedThreshold + ((double) SMPPSim.getPercentageRejected() / 100);
72 | logger.debug("rejectedThreshold="+rejectedThreshold);
73 | // .98 + .02 = 1.00
74 | }
75 |
76 | public MessageState setState(MessageState m) {
77 | // Should a transition take place at all?
78 | if (isTerminalState(m.getState()))
79 | return m;
80 | byte currentState = m.getState();
81 | boolean stateSet = false;
82 | for (String pattern : SMPPSim.getUndeliverable_phoneNumbers()) {
83 | if (m.pdu.getDestination_addr().matches(pattern)) {
84 | m.setState(PduConstants.UNDELIVERABLE);
85 | logger.debug("State set to UNDELIVERABLE due to undeliverable pattern match.");
86 | stateSet = true;
87 | break;
88 | }
89 | }
90 | if (!stateSet) {
91 | transition = Math.random();
92 | if ((transition < transitionThreshold)
93 | || ((System.currentTimeMillis() - m.getSubmit_time())
94 | > maxTimeEnroute)) {
95 | // so which transition should it be?
96 | stateChoice = Math.random();
97 | if (stateChoice < deliveredThreshold) {
98 | m.setState(PduConstants.DELIVERED);
99 | logger.debug("State set to DELIVERED");
100 | } else if (stateChoice < undeliverableThreshold) {
101 | m.setState(PduConstants.UNDELIVERABLE);
102 | logger.debug("State set to UNDELIVERABLE");
103 | } else if (stateChoice < acceptedThreshold) {
104 | m.setState(PduConstants.ACCEPTED);
105 | logger.debug("State set to ACCEPTED");
106 | } else {
107 | m.setState(PduConstants.REJECTED);
108 | logger.debug("State set to REJECTED");
109 | }
110 | }
111 | }
112 | if (isTerminalState(m.getState())) {
113 | m.setFinal_time(System.currentTimeMillis());
114 | // If delivery receipt requested prepare it....
115 | SubmitSM p = m.getPdu();
116 | boolean dr = ((p.getRegistered_delivery_flag() & 0x01) == 0x01);
117 | if (dr && currentState != m.getState()) {
118 | // delivery_receipt requested
119 | //logger.info("Delivery Receipt requested");
120 | smsc.prepareDeliveryReceipt(p, m.getMessage_id(), m.getState(),1, 1, m.getErr());
121 | }
122 | }
123 |
124 | return m;
125 | }
126 |
127 | public boolean isTerminalState(byte state) {
128 | if ((state == PduConstants.DELIVERED)
129 | || (state == PduConstants.EXPIRED)
130 | || (state == PduConstants.DELETED)
131 | || (state == PduConstants.UNDELIVERABLE)
132 | || (state == PduConstants.ACCEPTED)
133 | || (state == PduConstants.REJECTED))
134 | return true;
135 | else
136 | return false;
137 | }
138 |
139 | public boolean messageShouldBeDiscarded(MessageState m) {
140 | long now = System.currentTimeMillis();
141 | long age = now - m.getSubmit_time();
142 | if (isTerminalState(m.getState())) {
143 | if (age > discardThreshold)
144 | return true;
145 | }
146 | return false;
147 | }
148 |
149 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/BindReceiver.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * BindReceiver.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/BindReceiver.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 |
34 | public class BindReceiver extends Request implements Demarshaller {
35 |
36 | // PDU attributes
37 | private static Logger logger = LoggerFactory.getLogger(BindReceiver.class);
38 | private String system_id;
39 |
40 | private String password;
41 |
42 | private String system_type;
43 |
44 | private int interface_version;
45 |
46 | private int addr_ton;
47 |
48 | private int addr_npi;
49 |
50 | private String address_range;
51 |
52 | public BindReceiver() {
53 | }
54 |
55 | public void demarshall(byte[] request) throws Exception {
56 |
57 | // demarshall the header
58 | super.demarshall(request);
59 | // now set atributes of this specific PDU type
60 | int inx = 16;
61 | try {
62 | system_id = PduUtilities.getStringValueNullTerminated(request, inx,
63 | 16, PduConstants.C_OCTET_STRING_TYPE);
64 | } catch (Exception e) {
65 | logger
66 | .debug("BIND_RECEIVER PDU is malformed. system_id is incorrect");
67 | throw (e);
68 | }
69 | inx = inx + system_id.length() + 1;
70 | try {
71 | password = PduUtilities.getStringValueNullTerminated(request, inx,
72 | 9, PduConstants.C_OCTET_STRING_TYPE);
73 | } catch (Exception e) {
74 | logger
75 | .debug("BIND_RECEIVER PDU is malformed. password is incorrect");
76 | throw (e);
77 | }
78 | inx = inx + password.length() + 1;
79 | try {
80 | system_type = PduUtilities.getStringValueNullTerminated(request,
81 | inx, 13, PduConstants.C_OCTET_STRING_TYPE);
82 | } catch (Exception e) {
83 | logger
84 | .debug("BIND_RECEIVER PDU is malformed. system_type is incorrect");
85 | throw (e);
86 | }
87 | inx = inx + system_type.length() + 1;
88 | try {
89 | interface_version = PduUtilities.getIntegerValue(request, inx, 1);
90 | } catch (Exception e) {
91 | logger
92 | .debug("BIND_RECEIVER PDU is malformed. interface_version is incorrect");
93 | throw (e);
94 | }
95 | inx = inx + 1;
96 | try {
97 | addr_ton = PduUtilities.getIntegerValue(request, inx, 1);
98 | } catch (Exception e) {
99 | logger
100 | .debug("BIND_RECEIVER PDU is malformed. addr_ton is incorrect");
101 | throw (e);
102 | }
103 | inx = inx + 1;
104 | try {
105 | addr_npi = PduUtilities.getIntegerValue(request, inx, 1);
106 | } catch (Exception e) {
107 | logger
108 | .debug("BIND_RECEIVER PDU is malformed. addr_npi is incorrect");
109 | throw (e);
110 | }
111 | inx = inx + 1;
112 | try {
113 | address_range = PduUtilities.getStringValueNullTerminated(request,
114 | inx, 41, PduConstants.C_OCTET_STRING_TYPE);
115 | } catch (Exception e) {
116 | logger
117 | .debug("BIND_RECEIVER PDU is malformed. address_range is incorrect");
118 | throw (e);
119 | }
120 | }
121 |
122 | /**
123 | * @return
124 | */
125 | public int getAddr_npi() {
126 | return addr_npi;
127 | }
128 |
129 | /**
130 | * @return
131 | */
132 | public int getAddr_ton() {
133 | return addr_ton;
134 | }
135 |
136 | /**
137 | * @return
138 | */
139 | public String getAddress_range() {
140 | return address_range;
141 | }
142 |
143 | /**
144 | * @return
145 | */
146 | public int getInterface_version() {
147 | return interface_version;
148 | }
149 |
150 | /**
151 | * @return
152 | */
153 | public String getPassword() {
154 | return password;
155 | }
156 |
157 | /**
158 | * @return
159 | */
160 | public String getSystem_id() {
161 | return system_id;
162 | }
163 |
164 | /**
165 | * @return
166 | */
167 | public String getSystem_type() {
168 | return system_type;
169 | }
170 |
171 | /**
172 | * @param i
173 | */
174 | public void setAddr_npi(int i) {
175 | addr_npi = i;
176 | }
177 |
178 | /**
179 | * @param i
180 | */
181 | public void setAddr_ton(int i) {
182 | addr_ton = i;
183 | }
184 |
185 | /**
186 | * @param string
187 | */
188 | public void setAddress_range(String string) {
189 | address_range = string;
190 | }
191 |
192 | /**
193 | * @param i
194 | */
195 | public void setInterface_version(int i) {
196 | interface_version = i;
197 | }
198 |
199 | /**
200 | * @param string
201 | */
202 | public void setPassword(String string) {
203 | password = string;
204 | }
205 |
206 | /**
207 | * @param string
208 | */
209 | public void setSystem_id(String string) {
210 | system_id = string;
211 | }
212 |
213 | /**
214 | * @param string
215 | */
216 | public void setSystem_type(String string) {
217 | system_type = string;
218 | }
219 |
220 | /**
221 | * *returns String representation of PDU
222 | */
223 | public String toString() {
224 | return super.toString() + "," + "system_id=" + system_id + ","
225 | + "password=" + password + "," + "system_type=" + system_type
226 | + "," + "interface_version=" + interface_version + ","
227 | + "addr_ton=" + addr_ton + "," + "addr_npi=" + addr_npi + ","
228 | + "address_range=" + address_range;
229 | }
230 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/BindTransmitter.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * BindTransmitter.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/BindTransmitter.java,v 1.1 2012/07/24 14:48:58 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 |
34 | public class BindTransmitter extends Request implements Demarshaller {
35 |
36 | private static Logger logger = LoggerFactory.getLogger(BindTransmitter.class);
37 | // PDU attributes
38 |
39 | private String system_id;
40 |
41 | private String password;
42 |
43 | private String system_type;
44 |
45 | private int interface_version;
46 |
47 | private int addr_ton;
48 |
49 | private int addr_npi;
50 |
51 | private String address_range;
52 |
53 | public BindTransmitter() {
54 | }
55 |
56 | public void demarshall(byte[] request) throws Exception {
57 | // demarshall the header
58 | super.demarshall(request);
59 | // now set atributes of this specific PDU type
60 | int inx = 16;
61 | try {
62 | system_id = PduUtilities.getStringValueNullTerminated(request, inx,
63 | 16, PduConstants.C_OCTET_STRING_TYPE);
64 | } catch (Exception e) {
65 | logger
66 | .debug("BIND_TRANSMITTER PDU is malformed. system_id is incorrect");
67 | throw (e);
68 | }
69 | inx = inx + system_id.length() + 1;
70 | try {
71 | password = PduUtilities.getStringValueNullTerminated(request, inx,
72 | 9, PduConstants.C_OCTET_STRING_TYPE);
73 | } catch (Exception e) {
74 | logger
75 | .debug("BIND_TRANSMITTER PDU is malformed. password is incorrect");
76 | throw (e);
77 | }
78 | inx = inx + password.length() + 1;
79 | try {
80 | system_type = PduUtilities.getStringValueNullTerminated(request,
81 | inx, 13, PduConstants.C_OCTET_STRING_TYPE);
82 | } catch (Exception e) {
83 | logger
84 | .debug("BIND_TRANSMITTER PDU is malformed. system_type is incorrect");
85 | throw (e);
86 | }
87 | inx = inx + system_type.length() + 1;
88 | try {
89 | interface_version = PduUtilities.getIntegerValue(request, inx, 1);
90 | } catch (Exception e) {
91 | logger
92 | .debug("BIND_TRANSMITTER PDU is malformed. interface_version is incorrect");
93 | throw (e);
94 | }
95 | inx = inx + 1;
96 | try {
97 | addr_ton = PduUtilities.getIntegerValue(request, inx, 1);
98 | } catch (Exception e) {
99 | logger
100 | .debug("BIND_TRANSMITTER PDU is malformed. addr_ton is incorrect");
101 | throw (e);
102 | }
103 | inx = inx + 1;
104 | try {
105 | addr_npi = PduUtilities.getIntegerValue(request, inx, 1);
106 | } catch (Exception e) {
107 | logger
108 | .debug("BIND_TRANSMITTER PDU is malformed. addr_npi is incorrect");
109 | throw (e);
110 | }
111 | inx = inx + 1;
112 | try {
113 | address_range = PduUtilities.getStringValueNullTerminated(request,
114 | inx, 41, PduConstants.C_OCTET_STRING_TYPE);
115 | } catch (Exception e) {
116 | logger
117 | .debug("BIND_TRANSMITTER PDU is malformed. address_range is incorrect");
118 | throw (e);
119 | }
120 | }
121 |
122 | /**
123 | * @return
124 | */
125 | public int getAddr_npi() {
126 | return addr_npi;
127 | }
128 |
129 | /**
130 | * @return
131 | */
132 | public int getAddr_ton() {
133 | return addr_ton;
134 | }
135 |
136 | /**
137 | * @return
138 | */
139 | public String getAddress_range() {
140 | return address_range;
141 | }
142 |
143 | /**
144 | * @return
145 | */
146 | public int getInterface_version() {
147 | return interface_version;
148 | }
149 |
150 | /**
151 | * @return
152 | */
153 | public String getPassword() {
154 | return password;
155 | }
156 |
157 | /**
158 | * @return
159 | */
160 | public String getSystem_id() {
161 | return system_id;
162 | }
163 |
164 | /**
165 | * @return
166 | */
167 | public String getSystem_type() {
168 | return system_type;
169 | }
170 |
171 | /**
172 | * @param i
173 | */
174 | public void setAddr_npi(int i) {
175 | addr_npi = i;
176 | }
177 |
178 | /**
179 | * @param i
180 | */
181 | public void setAddr_ton(int i) {
182 | addr_ton = i;
183 | }
184 |
185 | /**
186 | * @param string
187 | */
188 | public void setAddress_range(String string) {
189 | address_range = string;
190 | }
191 |
192 | /**
193 | * @param i
194 | */
195 | public void setInterface_version(int i) {
196 | interface_version = i;
197 | }
198 |
199 | /**
200 | * @param string
201 | */
202 | public void setPassword(String string) {
203 | password = string;
204 | }
205 |
206 | /**
207 | * @param string
208 | */
209 | public void setSystem_id(String string) {
210 | system_id = string;
211 | }
212 |
213 | /**
214 | * @param string
215 | */
216 | public void setSystem_type(String string) {
217 | system_type = string;
218 | }
219 |
220 | /**
221 | * *returns String representation of PDU
222 | */
223 | public String toString() {
224 | return super.toString() + "," + "system_id=" + system_id + ","
225 | + "password=" + password + "," + "system_type=" + system_type
226 | + "," + "interface_version=" + interface_version + ","
227 | + "addr_ton=" + addr_ton + "," + "addr_npi=" + addr_npi + ","
228 | + "address_range=" + address_range;
229 | }
230 |
231 | }
--------------------------------------------------------------------------------
/src/main/java/com/seleniumsoftware/SMPPSim/pdu/BindTransceiver.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | * BindTransceiver.java
3 | *
4 | * Copyright (C) Selenium Software Ltd 2006
5 | *
6 | * This file is part of SMPPSim.
7 | *
8 | * SMPPSim is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * SMPPSim is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with SMPPSim; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | *
22 | * @author martin@seleniumsoftware.com
23 | * http://www.woolleynet.com
24 | * http://www.seleniumsoftware.com
25 | * $Header: /var/cvsroot/SMPPSim2/distribution/2.6.9/SMPPSim/src/java/com/seleniumsoftware/SMPPSim/pdu/BindTransceiver.java,v 1.1 2012/07/24 14:48:59 martin Exp $
26 | ****************************************************************************/
27 |
28 | package com.seleniumsoftware.SMPPSim.pdu;
29 |
30 | import com.seleniumsoftware.SMPPSim.pdu.util.*;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 |
34 | public class BindTransceiver extends Request implements Demarshaller {
35 |
36 | private static Logger logger = LoggerFactory.getLogger(BindReceiver.class);
37 | // PDU attributes
38 |
39 | private String system_id;
40 |
41 | private String password;
42 |
43 | private String system_type;
44 |
45 | private int interface_version;
46 |
47 | private int addr_ton;
48 |
49 | private int addr_npi;
50 |
51 | private String address_range;
52 |
53 | public BindTransceiver() {
54 | }
55 |
56 | public void demarshall(byte[] request) throws Exception {
57 |
58 | // demarshall the header
59 | super.demarshall(request);
60 | // now set atributes of this specific PDU type
61 | int inx = 16;
62 | try {
63 | system_id = PduUtilities.getStringValueNullTerminated(request, inx,
64 | 16, PduConstants.C_OCTET_STRING_TYPE);
65 | } catch (Exception e) {
66 | logger
67 | .debug("BIND_TRANSCEIVER PDU is malformed. system_id is incorrect");
68 | throw (e);
69 | }
70 | inx = inx + system_id.length() + 1;
71 | try {
72 | password = PduUtilities.getStringValueNullTerminated(request, inx,
73 | 9, PduConstants.C_OCTET_STRING_TYPE);
74 | } catch (Exception e) {
75 | logger
76 | .debug("BIND_TRANSCEIVER PDU is malformed. password is incorrect");
77 | throw (e);
78 | }
79 | inx = inx + password.length() + 1;
80 | try {
81 | system_type = PduUtilities.getStringValueNullTerminated(request,
82 | inx, 13, PduConstants.C_OCTET_STRING_TYPE);
83 | } catch (Exception e) {
84 | logger
85 | .debug("BIND_TRANSCEIVER PDU is malformed. system_type is incorrect");
86 | throw (e);
87 | }
88 | inx = inx + system_type.length() + 1;
89 | try {
90 | interface_version = PduUtilities.getIntegerValue(request, inx, 1);
91 | } catch (Exception e) {
92 | logger
93 | .debug("BIND_TRANSCEIVER PDU is malformed. interface_version is incorrect");
94 | throw (e);
95 | }
96 | inx = inx + 1;
97 | try {
98 | addr_ton = PduUtilities.getIntegerValue(request, inx, 1);
99 | } catch (Exception e) {
100 | logger
101 | .debug("BIND_TRANSCEIVER PDU is malformed. addr_ton is incorrect");
102 | throw (e);
103 | }
104 | inx = inx + 1;
105 | try {
106 | addr_npi = PduUtilities.getIntegerValue(request, inx, 1);
107 | } catch (Exception e) {
108 | logger
109 | .debug("BIND_TRANSCEIVER PDU is malformed. addr_npi is incorrect");
110 | throw (e);
111 | }
112 | inx = inx + 1;
113 | try {
114 | address_range = PduUtilities.getStringValueNullTerminated(request,
115 | inx, 41, PduConstants.C_OCTET_STRING_TYPE);
116 | } catch (Exception e) {
117 | logger
118 | .debug("BIND_TRANSCEIVER PDU is malformed. address_range is incorrect");
119 | throw (e);
120 | }
121 | }
122 |
123 | /**
124 | * @return
125 | */
126 | public int getAddr_npi() {
127 | return addr_npi;
128 | }
129 |
130 | /**
131 | * @return
132 | */
133 | public int getAddr_ton() {
134 | return addr_ton;
135 | }
136 |
137 | /**
138 | * @return
139 | */
140 | public String getAddress_range() {
141 | return address_range;
142 | }
143 |
144 | /**
145 | * @return
146 | */
147 | public int getInterface_version() {
148 | return interface_version;
149 | }
150 |
151 | /**
152 | * @return
153 | */
154 | public String getPassword() {
155 | return password;
156 | }
157 |
158 | /**
159 | * @return
160 | */
161 | public String getSystem_id() {
162 | return system_id;
163 | }
164 |
165 | /**
166 | * @return
167 | */
168 | public String getSystem_type() {
169 | return system_type;
170 | }
171 |
172 | /**
173 | * @param i
174 | */
175 | public void setAddr_npi(int i) {
176 | addr_npi = i;
177 | }
178 |
179 | /**
180 | * @param i
181 | */
182 | public void setAddr_ton(int i) {
183 | addr_ton = i;
184 | }
185 |
186 | /**
187 | * @param string
188 | */
189 | public void setAddress_range(String string) {
190 | address_range = string;
191 | }
192 |
193 | /**
194 | * @param i
195 | */
196 | public void setInterface_version(int i) {
197 | interface_version = i;
198 | }
199 |
200 | /**
201 | * @param string
202 | */
203 | public void setPassword(String string) {
204 | password = string;
205 | }
206 |
207 | /**
208 | * @param string
209 | */
210 | public void setSystem_id(String string) {
211 | system_id = string;
212 | }
213 |
214 | /**
215 | * @param string
216 | */
217 | public void setSystem_type(String string) {
218 | system_type = string;
219 | }
220 |
221 | /**
222 | * *returns String representation of PDU
223 | */
224 | public String toString() {
225 | return super.toString() + "," + "system_id=" + system_id + ","
226 | + "password=" + password + "," + "system_type=" + system_type
227 | + "," + "interface_version=" + interface_version + ","
228 | + "addr_ton=" + addr_ton + "," + "addr_npi=" + addr_npi + ","
229 | + "address_range=" + address_range;
230 | }
231 |
232 | }
--------------------------------------------------------------------------------