body: Implement parsing of the body
This commit is contained in:
parent
a2a6bbc690
commit
5ec92351f5
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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!'].
|
||||
]
|
||||
]
|
||||
]
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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
|
||||
]
|
||||
]
|
|
@ -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
|
||||
]
|
||||
]
|
14
package.xml
14
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>
|
||||
|
|
Reference in New Issue