blob: 993af1a0c120705070e7d74bff9ea9fa1a305483 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
"
(C) 2010-2012 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: SCCPAddress [
| route_ssn ssn poi gti gti_ind |
<category: 'OsmoNetwork-SCCP'>
<comment: 'I represent the SCCP Address including the
SSN, GTI if present.'>
SCCPAddress class >> ssnNotKnown [ <category: 'constants'> ^ 0 ]
SCCPAddress class >> ssnSCCPMgnt [ <category: 'constants'> ^ 1 ]
SCCPAddress class >> ssnITURsrvd [ <category: 'constants'> ^ 2 ]
SCCPAddress class >> ssnISUP [ <category: 'constants'> ^ 3 ]
SCCPAddress class >> ssnOMA [ <category: 'constants'> ^ 4 ]
SCCPAddress class >> ssnMAP [ <category: 'constants'> ^ 5 ]
SCCPAddress class >> ssnHLR [ <category: 'constants'> ^ 6 ]
SCCPAddress class >> ssnVLR [ <category: 'constants'> ^ 7 ]
SCCPAddress class >> ssnMSC [ <category: 'constants'> ^ 8 ]
SCCPAddress class >> ssnEIC [ <category: 'constants'> ^ 9 ]
SCCPAddress class >> ssnAUC [ <category: 'constants'> ^ 10 ]
SCCPAddress class >> ssnISUPSRV [ <category: 'constants'> ^ 11 ]
SCCPAddress class >> ssnReserved [ <category: 'constants'> ^ 12 ]
SCCPAddress class >> ssnBroadISDN[ <category: 'constants'> ^ 13 ]
SCCPAddress class >> ssnTCTest [ <category: 'constants'> ^ 14 ]
SCCPAddress class >> createWith: ssn [
<category: 'creation'>
^ (SCCPAddress new)
ssn: ssn;
routedOnSSN: true;
yourself
]
SCCPAddress class >> createWith: ssn poi: aPoi [
<category: 'creation'>
^ SCCPAddress new
ssn: ssn;
routedOnSSN: true;
poi: aPoi;
yourself
]
SCCPAddress class >> parseFrom: aByteArray [
| routed_ssn gti_ind gti len ai ssn poi dat |
<category: 'parsing'>
poi := nil.
len := aByteArray at: 1.
ai := aByteArray at: 2.
"Copy the address"
dat := aByteArray copyFrom: 3 to: len + 1.
"Point Code"
(ai bitAnd: 1) = 1
ifTrue: [
poi := (dat ushortAt: 1).
dat := dat copyFrom: 3.
].
"SSN"
routed_ssn := (ai bitAnd: 16r40) = 16r40.
ssn := dat at: 1.
dat := dat copyFrom: 2.
"GTI"
gti_ind := (ai bitAnd: 16r3C) bitShift: -2.
gti := dat copyFrom: 1.
^ SCCPAddress new
ssn: ssn;
poi: poi;
routedOnSSN: routed_ssn;
gti: gti indicator: gti_ind;
yourself.
]
routedOnSSN: aFlag [
<category: 'ssn'>
route_ssn := aFlag
]
routedOnSSN [
<category: 'ssn'>
^ route_ssn ifNil: [false]
]
gti [
<category: 'gti'>
^ gti
]
gtiInd [
<category: 'gti'>
^ gti_ind
]
gti: aGti indicator: aGtiInd [
<category: 'gti'>
gti := aGti.
gti_ind := aGtiInd bitAnd: 16rF.
]
gtiAsParsed [
<category: 'gti'>
^ gti_ind = 0
ifTrue: [nil]
ifFalse: [SCCPGTI initWith: gti_ind data: gti].
]
gtiFromAddr: aGti [
<category: 'gti'>
gti_ind := aGti class subType.
gti := aGti asByteArray.
]
poi: aPoi [
<category: 'point-code-indicator'>
poi := aPoi.
]
poi [
<category: 'point-code-indicator'>
^ poi
]
ssn: assn [
<category: 'ssn'>
ssn := assn
]
ssn [
<category: 'accessing'>
^ ssn.
]
asByteArray [
"Most simple address storing routine"
| ai data |
<category: 'encoding'>
data := OrderedCollection new.
"Create the Address Information"
ai := 0.
"SSN indicator"
ai := ai bitOr: 2.
self routedOnSSN ifTrue: [
ai := ai bitOr: 64.
].
"Point Code"
poi ifNotNil: [
ai := ai bitOr: 1.
].
"GTI Indicator"
gti_ind ifNotNil: [
ai := ai bitOr: (gti_ind bitShift: 2).
].
data add: ai.
"POC"
poi ifNotNil: [
data add: ((poi bitAnd: 16r00FF) bitShift: 0).
data add: ((poi bitAnd: 16rFF00) bitShift: -8).
].
"SSN"
data add: ssn.
"GTI"
gti_ind ifNotNil: [
gti do: [:each | data add: each ].
].
data addFirst: data size.
^ data asByteArray
]
]
|