summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-05-12 09:38:53 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-05-12 10:03:23 +0200
commit5ec92351f5918da95e04d2ee11d4899a282a3b81 (patch)
treea3d823b08a1fdc750c4410d9ffbc5bac534c6fa3
parenta2a6bbc690e087dfe1ee8070307084076ad1c8e2 (diff)
body: Implement parsing of the body
-rw-r--r--codec/SMPPBindTransmitterBody.st37
-rw-r--r--codec/SMPPBodyBase.st181
-rw-r--r--codec/SMPPMessage.st14
-rw-r--r--codec/attributes/SMPPAddressNumberingPlanIndicator.st84
-rw-r--r--codec/attributes/SMPPAddressRange.st28
-rw-r--r--codec/attributes/SMPPAddressTypeOfNumber.st70
-rw-r--r--codec/attributes/SMPPInterfaceVersion.st39
-rw-r--r--codec/attributes/SMPPOctetString.st41
-rw-r--r--codec/attributes/SMPPPassword.st28
-rw-r--r--codec/attributes/SMPPSystemId.st28
-rw-r--r--codec/attributes/SMPPSystemType.st28
-rw-r--r--package.xml14
12 files changed, 589 insertions, 3 deletions
diff --git a/codec/SMPPBindTransmitterBody.st b/codec/SMPPBindTransmitterBody.st
new file mode 100644
index 0000000..e683bdf
--- /dev/null
+++ b/codec/SMPPBindTransmitterBody.st
@@ -0,0 +1,37 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+SMPPBodyBase subclass: SMPPBindTransmitterBody [
+ | systemd_id password system_type version addr_ton addr_npi addr_range |
+
+ SMPPBindTransmitterBody class >> messageType [
+ ^self bindTransmitter
+ ]
+
+ SMPPBindTransmitterBody class >> tlvDescription [
+ ^OrderedCollection new
+ add: SMPPSystemdId tlvDescription;
+ add: SMPPPassword tlvDescription;
+ add: SMPPSystemType tlvDescription;
+ add: SMPPInterfaceVersion tlvDescription;
+ add: SMPPAddressTypeOfNumber tlvDescription;
+ add: SMPPAddressNumberingPlanIndicator tlvDescription;
+ add: SMPPAddressRange tlvDescription;
+ yourself
+ ]
+]
diff --git a/codec/SMPPBodyBase.st b/codec/SMPPBodyBase.st
new file mode 100644
index 0000000..6021caf
--- /dev/null
+++ b/codec/SMPPBodyBase.st
@@ -0,0 +1,181 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+Osmo.TLVParserBase subclass: SMPPBodyBase [
+ <comment: 'I represent a specific "BODY" of a Payload. My
+sub-classes will provide the specific bodies.'>
+
+ SMPPBodyBase class [
+ genericNack [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000000
+ ]
+
+ bindReceiver [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000001
+ ]
+
+ bindReceiverResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000001
+ ]
+
+ bindTransmitter [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000002
+ ]
+
+ bindTransmitterResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000002
+ ]
+
+ querySM [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000003
+ ]
+
+ querySMResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000003
+ ]
+
+ submitSM [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000004
+
+ ]
+
+ submitSMResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000004
+ ]
+
+ deliverSM [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000005
+ ]
+
+ deliverSMResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000005
+ ]
+
+ unbind [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000006
+ ]
+
+ unbindResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000006
+ ]
+
+ replaceSM [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000007
+ ]
+
+ replaceSMResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000007
+ ]
+
+ cancelSM [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000008
+ ]
+
+ cancelSMResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000008
+ ]
+
+ bindTransceiver [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000009
+ ]
+
+ bindTransceiverResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000009
+ ]
+
+ outbind [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r0000000B
+ ]
+
+ enquireLink [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000015
+ ]
+
+ enquireLinkResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000015
+ ]
+
+ submitMulti [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000021
+ ]
+
+ submitMultiResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000021
+ ]
+
+ alertNotification [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000102
+ ]
+
+ dataSM [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r00000103
+ ]
+
+ dataSMResp [
+ <category: '5.1.2.1 SMPP Command set'>
+ ^16r80000103
+ ]
+ ]
+
+ SMPPBodyBase class >> readFrom: aStream for: aHeader [
+ <category: 'parsing'>
+
+ self allSubclassesDo: [:each |
+ aHeader commandId = each messageType
+ ifTrue: [^each new readFrom: aStream]].
+
+ ^self error: 'No handler for command id = %1' % aHeader commandId displayString.
+ ]
+
+ readFrom: aStream [
+ | description |
+ description := self class tlvDescription.
+ description do: [:attribute |
+ attribute isMandatory
+ ifTrue: [self doParse: attribute stream: aStream].
+ attribute isOptional
+ ifTrue: [^self error: 'Optional attributes not implemented!'].
+ ]
+ ]
+]
diff --git a/codec/SMPPMessage.st b/codec/SMPPMessage.st
index 5a8f8e4..2a2822b 100644
--- a/codec/SMPPMessage.st
+++ b/codec/SMPPMessage.st
@@ -20,13 +20,17 @@ Object subclass: SMPPMessage [
| header body |
SMPPMessage class >> readFrom: aStream [
- | len data stream |
+ | len data stream header body |
len := ((aStream next: 4) uintAt: 1) swap32.
data := aStream next: len - 4.
stream := data readStream.
+
+ header := SMPPPDUHeader readFrom: stream.
+ body := SMPPBodyBase readFrom: stream for: header.
^SMPPMessage new
- header: (SMPPPDUHeader readFrom: stream);
- yourself.
+ header: header;
+ body: body;
+ yourself
]
header: aHeader [
@@ -41,6 +45,10 @@ Object subclass: SMPPMessage [
body := aBody
]
+ body [
+ ^body
+ ]
+
writeOn: aMsg [
| hdrData bodyData |
hdrData := header toMessageOrByteArray.
diff --git a/codec/attributes/SMPPAddressNumberingPlanIndicator.st b/codec/attributes/SMPPAddressNumberingPlanIndicator.st
new file mode 100644
index 0000000..a623d72
--- /dev/null
+++ b/codec/attributes/SMPPAddressNumberingPlanIndicator.st
@@ -0,0 +1,84 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+Object subclass: SMPPAddressNumberingPlanIndicator [
+ <comment: 'I re-present 5.2.6 of SMPPv3.4'>
+
+ SMPPAddressNumberingPlanIndicator class [
+ npiUnknown [
+ <category: 'attribute'>
+ ^2r000
+ ]
+
+ npiISDN [
+ <category: 'attribute'>
+ ^2r001
+ ]
+
+ npiData [
+ <category: 'attribute'>
+ ^2r011
+ ]
+
+ npiTelex [
+ <category: 'attribute'>
+ ^2r100
+ ]
+
+ npiLandMobile [
+ <category: 'attribute'>
+ ^2r110
+ ]
+
+ npiNational [
+ <category: 'attribute'>
+ ^2r1000
+ ]
+
+ npiPrivate [
+ <category: 'attribute'>
+ ^2r1001
+ ]
+
+ npiERMES [
+ <category: 'attribute'>
+ ^2r1010
+ ]
+
+ npiInternet [
+ <category: 'attribute'>
+ ^2r1110
+ ]
+
+ npiWap [
+ <category: 'attribute'>
+ ^2r10010
+ ]
+ ]
+
+ SMPPAddressNumberingPlanIndicator class >> tlvDescription [
+ ^Osmo.TLVDescription new
+ typeKind: Osmo.TLVDescription valueOnly;
+ instVarName: #addr_npi; parseClass: self;
+ yourself
+ ]
+
+ SMPPAddressNumberingPlanIndicator class >> readFrom: aStream with: anAttr [
+ ^aStream next
+ ]
+]
diff --git a/codec/attributes/SMPPAddressRange.st b/codec/attributes/SMPPAddressRange.st
new file mode 100644
index 0000000..22b40f1
--- /dev/null
+++ b/codec/attributes/SMPPAddressRange.st
@@ -0,0 +1,28 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+SMPPOctetString subclass: SMPPAddressRange [
+ <comment: 'I re-present 5.2.7 of SMPPv3.4'>
+
+ SMPPAddressRange class >> tlvDescription [
+ ^super tlvDescription
+ instVarName: #addr_range;
+ minSize: 0 maxSize: 41;
+ yourself
+ ]
+]
diff --git a/codec/attributes/SMPPAddressTypeOfNumber.st b/codec/attributes/SMPPAddressTypeOfNumber.st
new file mode 100644
index 0000000..854fae2
--- /dev/null
+++ b/codec/attributes/SMPPAddressTypeOfNumber.st
@@ -0,0 +1,70 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+Object subclass: SMPPAddressTypeOfNumber [
+ <comment: 'I re-present 5.2.5 of SMPPv3.4'>
+
+ SMPPAddressTypeOfNumber class [
+
+ tonUnknown [
+ <category: 'attribute'>
+ ^2r000
+ ]
+
+ tonInternational [
+ <category: 'attribute'>
+ ^2r001
+ ]
+
+ tonNational [
+ <category: 'attribute'>
+ ^2r010
+ ]
+
+ tonNetworkSpecific [
+ <category: 'attribute'>
+ ^2r011
+ ]
+
+ tonSubscriberNumber [
+ <category: 'attribute'>
+ ^2r100
+ ]
+
+ tonAlphanumeric [
+ <category: 'attribute'>
+ ^2r101
+ ]
+
+ tonAbbreviated [
+ <category: 'attribute'>
+ ^2r110
+ ]
+ ]
+
+ SMPPAddressTypeOfNumber class >> tlvDescription [
+ ^Osmo.TLVDescription new
+ instVarName: #addr_ton; parseClass: self;
+ typeKind: Osmo.TLVDescription valueOnly;
+ yourself
+ ]
+
+ SMPPAddressTypeOfNumber class >> readFrom: aStream with: anAttribute [
+ ^aStream next
+ ]
+]
diff --git a/codec/attributes/SMPPInterfaceVersion.st b/codec/attributes/SMPPInterfaceVersion.st
new file mode 100644
index 0000000..8725add
--- /dev/null
+++ b/codec/attributes/SMPPInterfaceVersion.st
@@ -0,0 +1,39 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+Object subclass: SMPPInterfaceVersion [
+ <comment: 'I re-present 5.2.4 of SMPPv3.4'>
+
+ SMPPInterfaceVersion class >> attrVersion34 [
+ <category: 'Interface version'>
+ ^16r34
+ ]
+
+
+ SMPPInterfaceVersion class >> tlvDescription [
+ ^Osmo.TLVDescription new
+ instVarName: #version; parseClass: self;
+ typeKind: Osmo.TLVDescription valueOnly;
+ valueSize: 1;
+ yourself
+ ]
+
+ SMPPInterfaceVersion class >> readFrom: aStream with: anAttribute [
+ ^aStream next
+ ]
+]
diff --git a/codec/attributes/SMPPOctetString.st b/codec/attributes/SMPPOctetString.st
new file mode 100644
index 0000000..cd76502
--- /dev/null
+++ b/codec/attributes/SMPPOctetString.st
@@ -0,0 +1,41 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+Object subclass: SMPPOctetString [
+ <comment: 'I represent a variable string as used in SMPP'>
+
+ SMPPOctetString class >> tlvDescription [
+ ^Osmo.TLVDescription new
+ instVarName: #string; parseClass: self;
+ typeKind: Osmo.TLVDescription valueOnly;
+ yourself
+ ]
+
+ SMPPOctetString class >> readFrom: aStream with: anAttribute [
+ | str |
+ str := WriteStream on: String new.
+ [aStream peek = 0] whileFalse: [
+ str nextPut: aStream next asCharacter].
+
+ "Skip the $0 now"
+ aStream next.
+
+ "anAttribute... verify the max size"
+ ^str contents
+ ]
+]
diff --git a/codec/attributes/SMPPPassword.st b/codec/attributes/SMPPPassword.st
new file mode 100644
index 0000000..2c5d78c
--- /dev/null
+++ b/codec/attributes/SMPPPassword.st
@@ -0,0 +1,28 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+SMPPOctetString subclass: SMPPPassword [
+ <comment: 'I represent 5.2.2 of SMPPv3.4'>
+
+ SMPPPassword class >> tlvDescription [
+ ^super tlvDescription
+ instVarName: #password;
+ minSize: 0 maxSize: 9;
+ yourself
+ ]
+]
diff --git a/codec/attributes/SMPPSystemId.st b/codec/attributes/SMPPSystemId.st
new file mode 100644
index 0000000..37921fb
--- /dev/null
+++ b/codec/attributes/SMPPSystemId.st
@@ -0,0 +1,28 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+SMPPOctetString subclass: SMPPSystemdId [
+ <comment: 'I re-present 5.2.1 of SMPPv3.4'>
+
+ SMPPSystemdId class >> tlvDescription [
+ ^super tlvDescription
+ instVarName: #systemd_id;
+ minSize: 0 maxSize: 16;
+ yourself
+ ]
+]
diff --git a/codec/attributes/SMPPSystemType.st b/codec/attributes/SMPPSystemType.st
new file mode 100644
index 0000000..4447460
--- /dev/null
+++ b/codec/attributes/SMPPSystemType.st
@@ -0,0 +1,28 @@
+"
+ (C) 2014 by Holger Hans Peter Freyther
+ All Rights Reserved
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"
+
+SMPPOctetString subclass: SMPPSystemType [
+ <comment: 'I re-present 5.2.3 of SMPPv3.4'>
+
+ SMPPSystemType class >> tlvDescription [
+ ^super tlvDescription
+ instVarName: #system_type;
+ minSize: 0 maxSize: 13;
+ yourself
+ ]
+]
diff --git a/package.xml b/package.xml
index 3c9a7be..335b0c6 100644
--- a/package.xml
+++ b/package.xml
@@ -4,6 +4,20 @@
<prereq>OsmoNetwork</prereq>
<filein>codec/SMPPPDUHeader.st</filein>
+
+ <filein>codec/SMPPBodyBase.st</filein>
+ <filein>codec/SMPPBindTransmitterBody.st</filein>
+
+ <filein>codec/attributes/SMPPOctetString.st</filein>
+ <filein>codec/attributes/SMPPSystemId.st</filein>
+ <filein>codec/attributes/SMPPPassword.st</filein>
+ <filein>codec/attributes/SMPPSystemType.st</filein>
+ <filein>codec/attributes/SMPPInterfaceVersion.st</filein>
+ <filein>codec/attributes/SMPPAddressTypeOfNumber.st</filein>
+ <filein>codec/attributes/SMPPAddressNumberingPlanIndicator.st</filein>
+ <filein>codec/attributes/SMPPAddressRange.st</filein>
+
+
<filein>codec/SMPPMessage.st</filein>
<test>