smalltalk
/
osmo-st-smpp
Archived
1
0
Fork 0

attr: Introduce a 'int' base class for SMPP

In SMPPv3.4 there are integers with different amounts of bytes.
Let's create a base class that helps with reading them right. Right
now only one byte numbers are supported but that can be changed
in the future.
This commit is contained in:
Holger Hans Peter Freyther 2014-05-13 04:09:05 +02:00
parent 07319cd1aa
commit 1e181e67e6
5 changed files with 48 additions and 25 deletions

View File

@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
Object subclass: SMPPAddressNumberingPlanIndicator [
SMPPInteger subclass: SMPPAddressNumberingPlanIndicator [
<comment: 'I re-present 5.2.6 of SMPPv3.4'>
SMPPAddressNumberingPlanIndicator class [
@ -72,13 +72,9 @@ Object subclass: SMPPAddressNumberingPlanIndicator [
]
SMPPAddressNumberingPlanIndicator class >> tlvDescription [
^Osmo.TLVDescription new
typeKind: Osmo.TLVDescription valueOnly;
instVarName: #addr_npi; parseClass: self;
^super tlvDescription
instVarName: #addr_npi;
valueSize: 1;
yourself
]
SMPPAddressNumberingPlanIndicator class >> readFrom: aStream with: anAttr [
^aStream next
]
]

View File

@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
Object subclass: SMPPAddressTypeOfNumber [
SMPPInteger subclass: SMPPAddressTypeOfNumber [
<comment: 'I re-present 5.2.5 of SMPPv3.4'>
SMPPAddressTypeOfNumber class [
@ -58,13 +58,9 @@ Object subclass: SMPPAddressTypeOfNumber [
]
SMPPAddressTypeOfNumber class >> tlvDescription [
^Osmo.TLVDescription new
instVarName: #addr_ton; parseClass: self;
typeKind: Osmo.TLVDescription valueOnly;
^super tlvDescription
instVarName: #addr_ton;
valueSize: 1;
yourself
]
SMPPAddressTypeOfNumber class >> readFrom: aStream with: anAttribute [
^aStream next
]
]

View File

@ -0,0 +1,36 @@
"
(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: SMPPInteger [
<comment: 'I help with the various kind of numbers'>
SMPPInteger class >> tlvDescription [
^Osmo.TLVDescription new
parseClass: self;
typeKind: Osmo.TLVDescription valueOnly;
yourself
]
SMPPInteger class >> readFrom: aStream with: anAttribute [
anAttribute valueSize = 1
ifTrue: [^aStream next].
"This is not implemented yet"
^self error: 'The base class does not support other value sizes'.
]
]

View File

@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
Object subclass: SMPPInterfaceVersion [
SMPPInteger subclass: SMPPInterfaceVersion [
<comment: 'I re-present 5.2.4 of SMPPv3.4'>
SMPPInterfaceVersion class >> attrVersion34 [
@ -24,16 +24,10 @@ Object subclass: SMPPInterfaceVersion [
^16r34
]
SMPPInterfaceVersion class >> tlvDescription [
^Osmo.TLVDescription new
instVarName: #version; parseClass: self;
typeKind: Osmo.TLVDescription valueOnly;
^super tlvDescription
instVarName: #version;
valueSize: 1;
yourself
]
SMPPInterfaceVersion class >> readFrom: aStream with: anAttribute [
^aStream next
]
]

View File

@ -9,6 +9,7 @@
<filein>codec/SMPPBindTransmitterBody.st</filein>
<filein>codec/attributes/SMPPOctetString.st</filein>
<filein>codec/attributes/SMPPInteger.st</filein>
<filein>codec/attributes/SMPPSystemId.st</filein>
<filein>codec/attributes/SMPPPassword.st</filein>
<filein>codec/attributes/SMPPSystemType.st</filein>