line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######################################################################### |
2
|
|
|
|
|
|
|
# - Net::UCP 0.41 - |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Version : 0.41 |
5
|
|
|
|
|
|
|
# Date : 06/04/2010 |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Library based on EMI - UCP INTERFACE Specification |
8
|
|
|
|
|
|
|
# Version 3.5 of December 1999 |
9
|
|
|
|
|
|
|
# Spcification Copyright (C) CMG telecommunication & Utilities BV Division |
10
|
|
|
|
|
|
|
# Advanced Technology |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Library Copyright (C) 2004-2009 Marco Romano |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or modify |
15
|
|
|
|
|
|
|
# it under the same terms as Perl itself, either Perl version 5.8.4 or, |
16
|
|
|
|
|
|
|
# at your option, any later version of Perl 5 you may have available. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
######################################################################### |
19
|
|
|
|
|
|
|
package Net::UCP; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5516
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
22
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
23
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
57
|
|
24
|
1
|
|
|
1
|
|
871
|
use IO::Socket; |
|
1
|
|
|
|
|
25760
|
|
|
1
|
|
|
|
|
4
|
|
25
|
1
|
|
|
1
|
|
1526
|
use IO::Select; |
|
1
|
|
|
|
|
1531
|
|
|
1
|
|
|
|
|
41
|
|
26
|
1
|
|
|
1
|
|
906
|
use Time::HiRes qw(setitimer ITIMER_REAL); |
|
1
|
|
|
|
|
1978
|
|
|
1
|
|
|
|
|
5
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
1109
|
use Net::UCP::Common qw(:all); |
|
1
|
|
|
|
|
1281
|
|
|
1
|
|
|
|
|
123
|
|
29
|
1
|
|
|
1
|
|
773
|
use Net::UCP::IntTimeout; |
|
1
|
|
|
|
|
411
|
|
|
1
|
|
|
|
|
34
|
|
30
|
1
|
|
|
1
|
|
826
|
use Net::UCP::TransactionManager; |
|
1
|
|
|
|
|
523
|
|
|
1
|
|
|
|
|
42
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
require Exporter; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
84
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
37
|
|
|
|
|
|
|
@EXPORT = qw(); |
38
|
|
|
|
|
|
|
@EXPORT_OK = (); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$VERSION = '0.41'; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
1
|
|
5
|
use constant TRUE => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
15170
|
BEGIN { *logout = *close_link; } |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
1
|
1
|
693
|
sub new { bless({}, shift())->_init(@_); } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# login to SMSC |
51
|
|
|
|
|
|
|
sub login { |
52
|
0
|
|
|
0
|
1
|
0
|
my $self = shift(); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
my %args = ( |
55
|
|
|
|
|
|
|
SMSC_ID => '', |
56
|
|
|
|
|
|
|
SMSC_PW => '', |
57
|
|
|
|
|
|
|
SHORT_CODE => undef, |
58
|
|
|
|
|
|
|
ONPI => '', |
59
|
|
|
|
|
|
|
OTON => '', |
60
|
|
|
|
|
|
|
STYP => 1, #def 1 (open session) |
61
|
|
|
|
|
|
|
VERS => '0100', #def 0100 |
62
|
|
|
|
|
|
|
@_); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Conditionally open the socket unless already opened. |
65
|
0
|
0
|
|
|
|
0
|
$self->open_link() unless(defined($self->{SOCK})); |
66
|
0
|
0
|
|
|
|
0
|
unless(defined($self->{SOCK})) { |
67
|
0
|
0
|
|
|
|
0
|
return(defined(wantarray)?wantarray?(undef,0,''):undef:undef); |
|
|
0
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
0
|
|
|
0
|
defined($args{SMSC_ID})&&length($args{SMSC_ID})||do { |
71
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("Missing mandatory parameter 'SMSC_ID' when trying to login. Login failed"); |
72
|
0
|
0
|
|
|
|
0
|
return(defined(wantarray)?wantarray?(undef,0,''):undef:undef); |
|
|
0
|
|
|
|
|
|
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
0
|
|
|
0
|
defined($args{SMSC_PW})&&length($args{SMSC_PW})||do { |
76
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("Missing mandatory parameter 'SMSC_PW' when trying to login. Login failed"); |
77
|
0
|
0
|
|
|
|
0
|
return(defined(wantarray)?wantarray?(undef,0,''):undef:undef); |
|
|
0
|
|
|
|
|
|
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
my $message_string = $self->make_message( |
81
|
|
|
|
|
|
|
op => '60', |
82
|
|
|
|
|
|
|
operation => 1, |
83
|
|
|
|
|
|
|
oadc => $args{SMSC_ID}, |
84
|
|
|
|
|
|
|
oton => $args{OTON}, |
85
|
|
|
|
|
|
|
onpi => $args{ONPI}, |
86
|
|
|
|
|
|
|
styp => $args{STYP}, |
87
|
|
|
|
|
|
|
pwd => $args{SMSC_PW}, |
88
|
|
|
|
|
|
|
vers => $args{VERS} |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
0
|
if ( defined $message_string ) { |
92
|
0
|
|
|
|
|
0
|
my $timeout = $self->{TIMEOUT_OBJ}->get(); |
93
|
0
|
|
|
|
|
0
|
$self->transmit_msg($message_string, $timeout, 1); |
94
|
|
|
|
|
|
|
} else { |
95
|
0
|
0
|
|
|
|
0
|
return(defined(wantarray)?wantarray?(undef,0,''):undef:undef); |
|
|
0
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# This method will also conditionally be called from the login() method. |
100
|
|
|
|
|
|
|
sub open_link { |
101
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
0
|
$self->{SOCK} = IO::Socket::INET->new( |
|
|
0
|
|
|
|
|
|
104
|
|
|
|
|
|
|
PeerAddr => $self->{SMSC_HOST}, |
105
|
|
|
|
|
|
|
PeerPort => $self->{SMSC_PORT}, |
106
|
|
|
|
|
|
|
Proto => 'tcp', |
107
|
|
|
|
|
|
|
LocalAddr => defined($self->{SRC_HOST}) ? $self->{SRC_HOST} : undef, |
108
|
|
|
|
|
|
|
LocalPort => defined($self->{SRC_PORT}) ? $self->{SRC_PORT} : undef |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
0
|
defined($self->{SOCK})||do { |
112
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("Failed to establish a socket connection with host $self->{SMSC_HOST} on port $self->{SMSC_PORT} : $!"); |
113
|
0
|
|
|
|
|
0
|
return; |
114
|
|
|
|
|
|
|
}; |
115
|
0
|
|
|
|
|
0
|
TRUE; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# To avoid keeping the socket open if not used any more. |
120
|
|
|
|
|
|
|
sub close_link { |
121
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
0
|
defined($self->{SOCK})||return; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
close($self->{SOCK}); |
126
|
0
|
|
|
|
|
0
|
$self->{SOCK}=undef; |
127
|
0
|
|
|
|
|
0
|
$self->{TRN_OBJ}->reset_trn(); |
128
|
0
|
|
|
|
|
0
|
TRUE; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# send SMS |
132
|
|
|
|
|
|
|
sub send_sms { |
133
|
0
|
|
|
0
|
1
|
0
|
my $self = shift(); |
134
|
0
|
|
|
|
|
0
|
my %args = ( |
135
|
|
|
|
|
|
|
RECIPIENT => '', |
136
|
|
|
|
|
|
|
MESSAGE_TEXT => '', |
137
|
|
|
|
|
|
|
SENDER_TEXT => '', |
138
|
|
|
|
|
|
|
UDH => '', |
139
|
|
|
|
|
|
|
MESSAGE_BINARY => undef, |
140
|
|
|
|
|
|
|
FLASH => undef, |
141
|
|
|
|
|
|
|
TIMEOUT => undef, |
142
|
|
|
|
|
|
|
@_); |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
0
|
my $timeout; |
145
|
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
0
|
if(defined($args{TIMEOUT})) { |
147
|
0
|
|
|
|
|
0
|
my $tv = Net::UCP::IntTimeout->new( TIMEOUT => $args{TIMEOUT} ); |
148
|
0
|
|
|
|
|
0
|
$timeout = $tv->get(); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
else { |
151
|
0
|
|
|
|
|
0
|
$timeout = $self->{TIMEOUT_OBJ}->get(); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
0
|
0
|
|
|
0
|
defined($args{RECIPIENT})&&length($args{RECIPIENT})||do { |
155
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("Missing mandatory parameter 'RECIPIENT' when trying to send message. Transmission failed"); |
156
|
0
|
0
|
|
|
|
0
|
return(defined(wantarray)?wantarray?(undef,0,''):undef:undef); |
|
|
0
|
|
|
|
|
|
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
0
|
$args{RECIPIENT}=~s/^\+/00/; |
160
|
0
|
0
|
|
|
|
0
|
$args{RECIPIENT}=~/^\d+$/||do{ |
161
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("The recipient address contains illegal (non-numerical) characters: $args{RECIPIENT}\nMessage not sent "); |
162
|
0
|
0
|
|
|
|
0
|
return(defined(wantarray)?wantarray?(undef,0,''):undef:undef); |
|
|
0
|
|
|
|
|
|
163
|
|
|
|
|
|
|
}; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# It's OK to send an empty message, but not to use undef. |
166
|
0
|
0
|
|
|
|
0
|
defined($args{MESSAGE_TEXT})||($args{MESSAGE_TEXT}=' '); |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
0
|
my $oadcTmp = ''; |
169
|
0
|
|
|
|
|
0
|
my $otoaTmp = ''; |
170
|
|
|
|
|
|
|
|
171
|
0
|
0
|
0
|
|
|
0
|
($oadcTmp, $otoaTmp) = $self->_get_info_from($args{SENDER_TEXT}) if ((defined($args{SENDER_TEXT}) |
172
|
|
|
|
|
|
|
and |
173
|
|
|
|
|
|
|
length($args{SENDER_TEXT}))); |
174
|
|
|
|
|
|
|
|
175
|
0
|
0
|
0
|
|
|
0
|
my $mclsTmp = (defined($args{FLASH}) and ($args{FLASH} == 1)) ? 1 : ''; |
176
|
0
|
0
|
|
|
|
0
|
my $class = ($mclsTmp) ? 0 : 1; |
177
|
|
|
|
|
|
|
|
178
|
0
|
0
|
0
|
|
|
0
|
my %param_tmp = ( |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
179
|
|
|
|
|
|
|
op => '51', |
180
|
|
|
|
|
|
|
operation => 1, |
181
|
|
|
|
|
|
|
adc => $args{RECIPIENT}, |
182
|
|
|
|
|
|
|
oadc => $oadcTmp, |
183
|
|
|
|
|
|
|
ac => $self->{SHORT_CODE}, |
184
|
|
|
|
|
|
|
mt => (defined($args{MESSAGE_BINARY}) ? '4' : '3'), |
185
|
|
|
|
|
|
|
nb => (defined($args{MESSAGE_BINARY}) ? |
186
|
|
|
|
|
|
|
(length($args{MESSAGE_BINARY})/2)*8 : ''), |
187
|
|
|
|
|
|
|
dcs => (defined($args{MESSAGE_BINARY}) ? '1' : ''), |
188
|
|
|
|
|
|
|
mcls => $mclsTmp, |
189
|
|
|
|
|
|
|
otoa => $otoaTmp, |
190
|
|
|
|
|
|
|
xser => (defined($args{MESSAGE_BINARY}) |
191
|
|
|
|
|
|
|
&& |
192
|
|
|
|
|
|
|
defined($args{MESSAGE_BINARY}) |
193
|
|
|
|
|
|
|
? |
194
|
|
|
|
|
|
|
make_xser("B", $args{UDH}, $class) : make_xser("T", $args{UDH}, $class) |
195
|
|
|
|
|
|
|
) |
196
|
|
|
|
|
|
|
); |
197
|
|
|
|
|
|
|
|
198
|
0
|
0
|
|
|
|
0
|
if (defined $args{MESSAGE_BINARY}) { |
199
|
0
|
|
|
|
|
0
|
$param_tmp{tmsg} = $args{MESSAGE_BINARY}; |
200
|
|
|
|
|
|
|
} else { |
201
|
0
|
|
|
|
|
0
|
$param_tmp{amsg} = $args{MESSAGE_TEXT}; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
0
|
my $message_string = $self->make_message(%param_tmp); |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
0
|
$self->transmit_msg($message_string, $timeout, 1); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub send_sms_multipart { |
211
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
212
|
0
|
|
|
|
|
0
|
my %argsLong =(RECIPIENT => '', |
213
|
|
|
|
|
|
|
MESSAGE_TEXT => '', |
214
|
|
|
|
|
|
|
SENDER_TEXT => '', |
215
|
|
|
|
|
|
|
UDH => undef, |
216
|
|
|
|
|
|
|
MESSAGE_BINARY => undef, |
217
|
|
|
|
|
|
|
FLASH => undef, |
218
|
|
|
|
|
|
|
TIMEOUT => undef, |
219
|
|
|
|
|
|
|
@_); |
220
|
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
0
|
my $messageId = random_int(1,255); |
222
|
0
|
|
|
|
|
0
|
my $multiHash; |
223
|
0
|
|
|
|
|
0
|
my $countPart = 0; |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
0
|
foreach my $chunk ($argsLong{MESSAGE_TEXT}=~m/(.{1,134})/sg){ |
226
|
0
|
|
|
|
|
0
|
$multiHash->{++$countPart} = $chunk; |
227
|
|
|
|
|
|
|
} |
228
|
0
|
|
|
|
|
0
|
while (my ($k, $textChunk) = each %{$multiHash}) { |
|
0
|
|
|
|
|
0
|
|
229
|
0
|
|
|
|
|
0
|
my $udh=sprintf('%s%02X%02X%02X',"0106050003",$messageId,$countPart,$k); |
230
|
0
|
|
|
|
|
0
|
my $ret = $self->send_sms( |
231
|
|
|
|
|
|
|
RECIPIENT => $argsLong{RECIPIENT}, |
232
|
|
|
|
|
|
|
MESSAGE_TEXT => $textChunk, |
233
|
|
|
|
|
|
|
SENDER_TEXT => $argsLong{SENDER_TEXT}, |
234
|
|
|
|
|
|
|
UDH => $udh |
235
|
|
|
|
|
|
|
); |
236
|
|
|
|
|
|
|
|
237
|
0
|
0
|
0
|
|
|
0
|
return $ret if (!$ret || !defined($ret)); #it could be better |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
0
|
return TRUE; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub random_int ($$) { |
246
|
0
|
|
|
0
|
0
|
0
|
my($min, $max) = @_; |
247
|
|
|
|
|
|
|
|
248
|
0
|
0
|
|
|
|
0
|
return $min if $min == $max; |
249
|
|
|
|
|
|
|
|
250
|
0
|
0
|
|
|
|
0
|
($min, $max) = ($max, $min) if $min > $max; |
251
|
0
|
|
|
|
|
0
|
return $min + int rand(1 + $max - $min); |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub _get_info_from { |
257
|
0
|
|
|
0
|
|
0
|
my ($self, $from) = @_; |
258
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
0
|
my ($oadc_tmp, $otoa_tmp); |
260
|
|
|
|
|
|
|
|
261
|
0
|
0
|
|
|
|
0
|
if ($from =~ /^([0-9]+)$/) { |
|
|
0
|
|
|
|
|
|
262
|
0
|
|
|
|
|
0
|
$otoa_tmp = ''; |
263
|
0
|
0
|
|
|
|
0
|
if (length ($from) > 22) {substr($from,22) = ''} |
|
0
|
|
|
|
|
0
|
|
264
|
0
|
|
|
|
|
0
|
$oadc_tmp = $from; |
265
|
|
|
|
|
|
|
} elsif ($from =~ /^\+([0-9]+)$/) { |
266
|
0
|
|
|
|
|
0
|
$from =~ s/^.//; |
267
|
0
|
|
|
|
|
0
|
$otoa_tmp = '1139'; |
268
|
0
|
0
|
|
|
|
0
|
if (length ($from) > 22) {substr($from,22) = ''} |
|
0
|
|
|
|
|
0
|
|
269
|
0
|
|
|
|
|
0
|
$oadc_tmp = $from; |
270
|
|
|
|
|
|
|
} else { |
271
|
0
|
|
|
|
|
0
|
$otoa_tmp = '5039'; |
272
|
0
|
0
|
|
|
|
0
|
if (length ($from) > 11) {substr($from,11) = ''} |
|
0
|
|
|
|
|
0
|
|
273
|
0
|
|
|
|
|
0
|
$oadc_tmp = $from; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
0
|
return ($oadc_tmp,$otoa_tmp); |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
#make_xser() subfunction. |
281
|
|
|
|
|
|
|
# |
282
|
|
|
|
|
|
|
#Parameters: |
283
|
|
|
|
|
|
|
#1)Message Type (it can be "T" -> Text or "B" -> Binary messages) |
284
|
|
|
|
|
|
|
#2)UserDataHeader (in hexadecimal without octet length) |
285
|
|
|
|
|
|
|
#3)Message Class (optional) |
286
|
|
|
|
|
|
|
################################## |
287
|
|
|
|
|
|
|
sub make_xser { |
288
|
0
|
|
|
0
|
0
|
0
|
my $type=shift; |
289
|
0
|
|
|
|
|
0
|
my $udh=shift; |
290
|
0
|
|
|
|
|
0
|
my $class=shift; |
291
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
0
|
my $xser_ret = ''; |
293
|
|
|
|
|
|
|
|
294
|
0
|
0
|
|
|
|
0
|
$class = 1 if ($class eq ''); |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
#count UDH octest numbers |
297
|
0
|
|
|
|
|
0
|
my $udh_len = sprintf("%02X",length($udh)/2); |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
#count octets numbers of DD field |
300
|
|
|
|
|
|
|
#numero totale di ottetti |
301
|
0
|
|
|
|
|
0
|
my $udh_oct = sprintf("%02X",(length($udh)/2)+1); |
302
|
|
|
|
|
|
|
|
303
|
0
|
0
|
|
|
|
0
|
if (not $class) { |
304
|
|
|
|
|
|
|
|
305
|
0
|
0
|
|
|
|
0
|
$type eq "T" and $xser_ret='020110'; |
306
|
|
|
|
|
|
|
|
307
|
0
|
0
|
0
|
|
|
0
|
if ($udh =~ m/\d+/ and $type eq "T") { |
308
|
0
|
|
|
|
|
0
|
$xser_ret = $udh; |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
} else { |
312
|
|
|
|
|
|
|
|
313
|
0
|
0
|
0
|
|
|
0
|
if ($udh =~ m/\d+/ and $type eq "T") { |
314
|
0
|
|
|
|
|
0
|
$xser_ret = $udh; |
315
|
|
|
|
|
|
|
} else { |
316
|
0
|
|
|
|
|
0
|
$xser_ret=''; |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
#XSER for binary message with udh |
322
|
|
|
|
|
|
|
#XSER multipart |
323
|
|
|
|
|
|
|
#TT 02 -> Xser per DCS |
324
|
|
|
|
|
|
|
#LL 01 -> ottetti DD |
325
|
|
|
|
|
|
|
#DD 00 -> imposta data coding scheme a 8 bit |
326
|
|
|
|
|
|
|
#TT 01 -> Xser per UDH |
327
|
|
|
|
|
|
|
#LL $udh_oct -> otetti UDH information field |
328
|
|
|
|
|
|
|
#DD -> contiene UDH field specificato dall'utente |
329
|
|
|
|
|
|
|
|
330
|
0
|
0
|
|
|
|
0
|
$type eq "B" and $xser_ret='02011501'.$udh_oct.$udh_len.$udh; |
331
|
|
|
|
|
|
|
|
332
|
0
|
|
|
|
|
0
|
return $xser_ret; |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub _init { |
337
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
338
|
|
|
|
|
|
|
|
339
|
1
|
|
|
|
|
11
|
$self->{OBJ_EMI_COMMON} = new Net::UCP::Common; |
340
|
1
|
|
|
|
|
51
|
$self->{TRN_OBJ} = new Net::UCP::TransactionManager; |
341
|
1
|
|
|
|
|
25
|
$self->{TIMEOUT_OBJ} = new Net::UCP::IntTimeout; |
342
|
|
|
|
|
|
|
|
343
|
1
|
50
|
|
|
|
17
|
return $self if @_ == 0; |
344
|
|
|
|
|
|
|
|
345
|
0
|
|
|
|
|
0
|
my %args = ( |
346
|
|
|
|
|
|
|
FAKE => 0, |
347
|
|
|
|
|
|
|
SMSC_HOST => '', |
348
|
|
|
|
|
|
|
SMSC_PORT => DEF_SMSC_PORT, |
349
|
|
|
|
|
|
|
SENDER_TEXT => '', |
350
|
|
|
|
|
|
|
WARN => 0, |
351
|
|
|
|
|
|
|
TIMEOUT => undef, |
352
|
|
|
|
|
|
|
SRC_HOST => undef, |
353
|
|
|
|
|
|
|
SRC_PORT => undef, |
354
|
|
|
|
|
|
|
@_); |
355
|
|
|
|
|
|
|
|
356
|
0
|
0
|
|
|
|
0
|
if ($args{FAKE} == 0) { |
357
|
|
|
|
|
|
|
|
358
|
0
|
0
|
|
|
|
0
|
$self->{WARN} = defined($args{WARN}) ? $args{WARN} ? 1 : 0 : 0; |
|
|
0
|
|
|
|
|
|
359
|
0
|
|
|
|
|
0
|
$self->{TIMEOUT_OBJ}->set($args{TIMEOUT}); |
360
|
|
|
|
|
|
|
|
361
|
0
|
0
|
0
|
|
|
0
|
defined($args{SMSC_HOST}) && length($args{SMSC_HOST}) || do { |
362
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("Mandatory entity 'SMSC_HOST' was missing when creating an object of class ". |
363
|
|
|
|
|
|
|
__PACKAGE__. |
364
|
|
|
|
|
|
|
". Object not created"); |
365
|
0
|
|
|
|
|
0
|
return; # Failed to instantiate this object. |
366
|
|
|
|
|
|
|
}; |
367
|
0
|
0
|
0
|
|
|
0
|
defined($args{SMSC_PORT})&&length($args{SMSC_PORT})||do{ |
368
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("Mandatory entity 'SMSC_PORT' was missing when creating an object of class ". |
369
|
|
|
|
|
|
|
__PACKAGE__. |
370
|
|
|
|
|
|
|
". Object not created"); |
371
|
0
|
|
|
|
|
0
|
return; # Failed to instantiate this object. |
372
|
|
|
|
|
|
|
}; |
373
|
0
|
0
|
|
|
|
0
|
$args{SMSC_PORT}=~/^\d+$/||do{ |
374
|
0
|
0
|
|
|
|
0
|
$self->{WARN}&&warn("Non-numerical data found in entity 'SMSC_PORT' when creating an object of class ". |
375
|
|
|
|
|
|
|
__PACKAGE__. |
376
|
|
|
|
|
|
|
". Object not created"); |
377
|
0
|
|
|
|
|
0
|
return; # Failed to instantiate this object. |
378
|
|
|
|
|
|
|
}; |
379
|
|
|
|
|
|
|
|
380
|
0
|
|
|
|
|
0
|
$self->{SMSC_HOST} = $args{SMSC_HOST}; |
381
|
0
|
|
|
|
|
0
|
$self->{SMSC_PORT} = $args{SMSC_PORT}; |
382
|
0
|
0
|
0
|
|
|
0
|
$self->{SENDER_TEXT} = defined($args{SENDER_TEXT})&&length($args{SENDER_TEXT})?$args{SENDER_TEXT}:__PACKAGE__; |
383
|
|
|
|
|
|
|
|
384
|
0
|
|
|
|
|
0
|
$self->{SRC_HOST} = $args{SRC_HOST}; |
385
|
0
|
|
|
|
|
0
|
$self->{SRC_PORT} = $args{SRC_PORT}; |
386
|
|
|
|
|
|
|
# itguru fix |
387
|
0
|
0
|
0
|
|
|
0
|
$self->{SHORT_CODE} = defined($args{SHORT_CODE})&&length($args{SHORT_CODE})?$args{SHORT_CODE}:undef; |
388
|
|
|
|
|
|
|
|
389
|
0
|
|
|
|
|
0
|
$self->{SOCK} = undef; |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
# Some systems have not implemented alarm(). |
392
|
|
|
|
|
|
|
# On such systems, calling alarm() will create a run-time error. |
393
|
|
|
|
|
|
|
# Determine if we dare calling alarm() or not. |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
#I must work on it... |
396
|
|
|
|
|
|
|
|
397
|
0
|
|
|
|
|
0
|
eval{alarm(0)}; |
|
0
|
|
|
|
|
0
|
|
398
|
0
|
0
|
|
|
|
0
|
$self->{CAN_ALARM} = $@ ? 0 : 1; |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
|
401
|
0
|
|
|
|
|
0
|
$self; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
##RAW MODE |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
#timeout, action |
409
|
|
|
|
|
|
|
#clear = 0,1 |
410
|
|
|
|
|
|
|
################# |
411
|
|
|
|
|
|
|
sub wait_in_loop { |
412
|
0
|
|
|
0
|
1
|
0
|
my ($self) = shift; |
413
|
0
|
|
|
|
|
0
|
my %arg = @_; |
414
|
0
|
|
|
|
|
0
|
my ($retval, $bits); |
415
|
|
|
|
|
|
|
|
416
|
0
|
|
|
|
|
0
|
my $socket = $self->{SOCK}; |
417
|
|
|
|
|
|
|
|
418
|
0
|
0
|
0
|
|
|
0
|
if (exists($arg{timeout}) and $arg{timeout} > 0) { |
419
|
0
|
0
|
0
|
|
|
0
|
$SIG{ALRM} = (exists($arg{action}) and ref($arg{action}) eq 'CODE') ? $arg{action} : \&_sig_alarm; |
420
|
0
|
|
|
|
|
0
|
setitimer(ITIMER_REAL, $arg{timeout}, 0); |
421
|
|
|
|
|
|
|
} |
422
|
|
|
|
|
|
|
|
423
|
0
|
|
|
|
|
0
|
while ($socket) { |
424
|
0
|
|
|
|
|
0
|
$bits = ''; |
425
|
0
|
|
|
|
|
0
|
vec($bits,fileno($socket),1) = 1; |
426
|
0
|
|
|
|
|
0
|
$retval = 0; |
427
|
0
|
|
|
|
|
0
|
$retval = select($bits,undef,undef,undef); |
428
|
|
|
|
|
|
|
|
429
|
0
|
0
|
|
|
|
0
|
if ($retval) { |
430
|
0
|
|
|
|
|
0
|
my ($buffer,$response); |
431
|
0
|
|
|
|
|
0
|
do { |
432
|
0
|
|
|
|
|
0
|
read($socket,$buffer,1); |
433
|
0
|
|
|
|
|
0
|
$response.=$buffer; |
434
|
|
|
|
|
|
|
} until ($buffer eq ETX); |
435
|
|
|
|
|
|
|
|
436
|
0
|
0
|
|
|
|
0
|
if (exists $arg{clear}) { |
437
|
0
|
0
|
|
|
|
0
|
$self->remove_ucp_enclosure(\$response) if ($arg{clear}); |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
|
440
|
0
|
|
|
|
|
0
|
setitimer(ITIMER_REAL, $arg{timeout}, 0); |
441
|
0
|
|
|
|
|
0
|
return $response; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
|
445
|
0
|
|
|
|
|
0
|
setitimer(ITIMER_REAL, $arg{timeout}, 0); |
446
|
0
|
|
|
|
|
0
|
return undef; |
447
|
|
|
|
|
|
|
} |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
sub remove_ucp_enclosure { |
450
|
0
|
|
|
0
|
1
|
0
|
my ($self, $msg) = @_; |
451
|
0
|
|
|
|
|
0
|
$$msg =~ s/@{[ETX]}|@{[STX]}//g; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
sub add_ucp_enclosure { |
455
|
0
|
|
|
0
|
1
|
0
|
my ($self, $msg) = @_; |
456
|
0
|
|
|
|
|
0
|
$$msg = STX . $$msg . ETX; |
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
|
459
|
0
|
|
|
0
|
|
0
|
sub _sig_alarm { croak "No response from SMSC\n"; } |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
#RAW functions |
462
|
|
|
|
|
|
|
########################### |
463
|
|
|
|
|
|
|
sub make_message { |
464
|
1
|
|
|
1
|
1
|
317
|
my $self = shift; |
465
|
1
|
|
|
|
|
10
|
my %arg = @_; |
466
|
|
|
|
|
|
|
|
467
|
1
|
|
|
|
|
2
|
my $op = $arg{op}; |
468
|
1
|
|
|
|
|
2
|
my $string = undef; |
469
|
|
|
|
|
|
|
|
470
|
1
|
50
|
|
|
|
12
|
if ($op eq "01") { $string = $self->make_01(%arg) } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
471
|
0
|
|
|
|
|
0
|
elsif ($op eq "02") { $string = $self->make_02(%arg) } |
472
|
0
|
|
|
|
|
0
|
elsif ($op eq "03") { $string = $self->make_03(%arg) } |
473
|
0
|
|
|
|
|
0
|
elsif ($op eq "30") { $string = $self->make_30(%arg) } |
474
|
0
|
|
|
|
|
0
|
elsif ($op eq "31") { $string = $self->make_31(%arg) } |
475
|
1
|
|
|
|
|
8
|
elsif ($op eq "51") { $string = $self->make_51(%arg) } |
476
|
0
|
|
|
|
|
0
|
elsif ($op eq "52") { $string = $self->make_52(%arg) } |
477
|
0
|
|
|
|
|
0
|
elsif ($op eq "53") { $string = $self->make_53(%arg) } |
478
|
0
|
|
|
|
|
0
|
elsif ($op eq "54") { $string = $self->make_54(%arg) } |
479
|
0
|
|
|
|
|
0
|
elsif ($op eq "55") { $string = $self->make_55(%arg) } |
480
|
0
|
|
|
|
|
0
|
elsif ($op eq "56") { $string = $self->make_56(%arg) } |
481
|
0
|
|
|
|
|
0
|
elsif ($op eq "57") { $string = $self->make_57(%arg) } |
482
|
0
|
|
|
|
|
0
|
elsif ($op eq "58") { $string = $self->make_58(%arg) } |
483
|
0
|
|
|
|
|
0
|
elsif ($op eq "60") { $string = $self->make_60(%arg) } |
484
|
0
|
|
|
|
|
0
|
elsif ($op eq "61") { $string = $self->make_61(%arg) } |
485
|
|
|
|
|
|
|
|
486
|
1
|
|
|
|
|
7
|
return $string; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
sub parse_message { |
490
|
1
|
|
|
1
|
1
|
427
|
my ($self, $resp) = @_; |
491
|
|
|
|
|
|
|
|
492
|
1
|
|
|
|
|
2
|
my $ref_mess = undef; |
493
|
|
|
|
|
|
|
|
494
|
1
|
50
|
|
|
|
13
|
if (my($optype) = $resp =~ m{^\d{2}/\d{5}/.*?/(01|02|03|30|51|52|53|54|55|56|57|58|60|61)/.*}) { |
495
|
1
|
|
|
|
|
2
|
my $parse_method = "parse_$optype"; |
496
|
1
|
|
|
|
|
5
|
$ref_mess = $self->$parse_method($resp); |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
|
499
|
1
|
|
|
|
|
4
|
return $ref_mess; |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
# OPERATION TYPE 01 |
503
|
|
|
|
|
|
|
sub parse_01 { |
504
|
1
|
|
|
1
|
0
|
3
|
my ($self, $response)=@_; |
505
|
1
|
|
|
|
|
3
|
my %mess; |
506
|
|
|
|
|
|
|
|
507
|
1
|
|
|
|
|
3
|
my $resp_tmp = $response; |
508
|
1
|
|
|
|
|
6
|
$resp_tmp =~ s/..$//; |
509
|
1
|
|
|
|
|
7
|
$mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp); |
510
|
|
|
|
|
|
|
|
511
|
1
|
|
|
|
|
54
|
my (@ucp) = split(UCP_DELIMITER,$response); |
512
|
|
|
|
|
|
|
|
513
|
1
|
|
|
|
|
3
|
$mess{trn} = $ucp[0]; |
514
|
1
|
|
|
|
|
3
|
$mess{len} = $ucp[1]; |
515
|
1
|
|
|
|
|
29
|
$mess{type} = $ucp[2]; |
516
|
1
|
|
|
|
|
2
|
$mess{ot} = $ucp[3]; |
517
|
|
|
|
|
|
|
|
518
|
1
|
50
|
|
|
|
5
|
if ($mess{type} eq "O") { |
519
|
0
|
|
|
|
|
0
|
$mess{adc} = $ucp[4]; |
520
|
0
|
|
|
|
|
0
|
$mess{oadc} = $ucp[5]; |
521
|
0
|
|
|
|
|
0
|
$mess{ac} = $ucp[6]; |
522
|
0
|
|
|
|
|
0
|
$mess{mt} = $ucp[7]; |
523
|
0
|
0
|
|
|
|
0
|
$mess{nmsg} = $mess{mt} == 2 ? $ucp[8] : ''; |
524
|
0
|
0
|
|
|
|
0
|
$mess{amsg} = $mess{mt} == 3 ? $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[8]) : ''; |
525
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[9]; |
526
|
|
|
|
|
|
|
} else { |
527
|
1
|
50
|
|
|
|
3
|
if ($ucp[4] eq ACK) { |
528
|
1
|
|
|
|
|
3
|
$mess{ack} = $ucp[4]; |
529
|
1
|
|
|
|
|
2
|
$mess{sm} = $ucp[5]; |
530
|
1
|
|
|
|
|
4
|
$mess{checksum} = $ucp[6]; |
531
|
|
|
|
|
|
|
} else { |
532
|
0
|
|
|
|
|
0
|
$mess{nack} = $ucp[4]; |
533
|
0
|
|
|
|
|
0
|
$mess{ec} = $ucp[5]; |
534
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
535
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
|
539
|
1
|
|
|
|
|
4
|
return \%mess; |
540
|
|
|
|
|
|
|
} |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
sub make_01 { |
543
|
1
|
|
|
1
|
0
|
36
|
my ($self) = shift; |
544
|
1
|
|
|
|
|
9
|
my %arg = @_; |
545
|
|
|
|
|
|
|
|
546
|
1
|
|
|
|
|
2
|
my $message_string = undef; |
547
|
|
|
|
|
|
|
|
548
|
1
|
50
|
33
|
|
|
10
|
if (exists $arg{operation} and $arg{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
549
|
|
|
|
|
|
|
|
550
|
1
|
50
|
33
|
|
|
10
|
my $text = (exists $arg{nmsg} && !exists $arg{amsg}) |
551
|
|
|
|
|
|
|
? $arg{nmsg} |
552
|
|
|
|
|
|
|
: $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg}); |
553
|
|
|
|
|
|
|
|
554
|
1
|
50
|
|
|
|
50
|
my $string = |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
555
|
|
|
|
|
|
|
(exists $arg{adc} ? $arg{adc} : '') . |
556
|
|
|
|
|
|
|
UCP_DELIMITER . |
557
|
|
|
|
|
|
|
(exists $arg{oadc} ? $arg{oadc} : '') . |
558
|
|
|
|
|
|
|
UCP_DELIMITER . |
559
|
|
|
|
|
|
|
(exists $arg{ac} ? $arg{ac} : '') . |
560
|
|
|
|
|
|
|
UCP_DELIMITER . |
561
|
|
|
|
|
|
|
(exists $arg{mt} ? $arg{mt} : '') . |
562
|
|
|
|
|
|
|
UCP_DELIMITER . |
563
|
|
|
|
|
|
|
$text; |
564
|
|
|
|
|
|
|
|
565
|
1
|
|
|
|
|
6
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
566
|
|
|
|
|
|
|
UCP_DELIMITER . |
567
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
568
|
|
|
|
|
|
|
UCP_DELIMITER . |
569
|
|
|
|
|
|
|
'O'. |
570
|
|
|
|
|
|
|
UCP_DELIMITER . |
571
|
|
|
|
|
|
|
'01'; |
572
|
|
|
|
|
|
|
|
573
|
1
|
|
|
|
|
31
|
$message_string = $header. |
574
|
|
|
|
|
|
|
UCP_DELIMITER . |
575
|
|
|
|
|
|
|
$string . |
576
|
|
|
|
|
|
|
UCP_DELIMITER . |
577
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
578
|
|
|
|
|
|
|
UCP_DELIMITER . |
579
|
|
|
|
|
|
|
$string . |
580
|
|
|
|
|
|
|
UCP_DELIMITER); |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
} elsif (exists($arg{result}) and $arg{result} == 1) { |
583
|
|
|
|
|
|
|
|
584
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{ack} and $arg{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
585
|
|
|
|
|
|
|
|
586
|
0
|
0
|
|
|
|
0
|
my $string = |
587
|
|
|
|
|
|
|
$arg{ack} . |
588
|
|
|
|
|
|
|
UCP_DELIMITER . |
589
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : ''); |
590
|
|
|
|
|
|
|
|
591
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
592
|
|
|
|
|
|
|
UCP_DELIMITER . |
593
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
594
|
|
|
|
|
|
|
UCP_DELIMITER . |
595
|
|
|
|
|
|
|
'R'. |
596
|
|
|
|
|
|
|
UCP_DELIMITER . |
597
|
|
|
|
|
|
|
'01'; |
598
|
|
|
|
|
|
|
|
599
|
0
|
|
|
|
|
0
|
$message_string = $header. |
600
|
|
|
|
|
|
|
UCP_DELIMITER . |
601
|
|
|
|
|
|
|
$string . |
602
|
|
|
|
|
|
|
UCP_DELIMITER . |
603
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
604
|
|
|
|
|
|
|
UCP_DELIMITER . |
605
|
|
|
|
|
|
|
$string . |
606
|
|
|
|
|
|
|
UCP_DELIMITER); |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
} elsif (exists $arg{nack} and $arg{nack} ne '') { |
609
|
|
|
|
|
|
|
|
610
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
611
|
|
|
|
|
|
|
$arg{nack} . |
612
|
|
|
|
|
|
|
UCP_DELIMITER . |
613
|
|
|
|
|
|
|
(exists $arg{ec} ? $arg{ec} : '') . |
614
|
|
|
|
|
|
|
UCP_DELIMITER . |
615
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : ''); |
616
|
|
|
|
|
|
|
|
617
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
618
|
|
|
|
|
|
|
UCP_DELIMITER . |
619
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
620
|
|
|
|
|
|
|
UCP_DELIMITER. |
621
|
|
|
|
|
|
|
'R'. |
622
|
|
|
|
|
|
|
UCP_DELIMITER. |
623
|
|
|
|
|
|
|
'01'; |
624
|
|
|
|
|
|
|
|
625
|
0
|
|
|
|
|
0
|
$message_string = $header. |
626
|
|
|
|
|
|
|
UCP_DELIMITER . |
627
|
|
|
|
|
|
|
$string . |
628
|
|
|
|
|
|
|
UCP_DELIMITER . |
629
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
630
|
|
|
|
|
|
|
UCP_DELIMITER . |
631
|
|
|
|
|
|
|
$string . |
632
|
|
|
|
|
|
|
UCP_DELIMITER); |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
1
|
|
|
|
|
80
|
return $message_string; |
637
|
|
|
|
|
|
|
} |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
#OP 02 |
640
|
|
|
|
|
|
|
sub parse_02 { |
641
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
642
|
0
|
|
|
|
|
0
|
my %mess; |
643
|
|
|
|
|
|
|
|
644
|
0
|
|
|
|
|
0
|
my $resp_tmp = $response; |
645
|
0
|
|
|
|
|
0
|
$resp_tmp =~ s/..$//; |
646
|
0
|
|
|
|
|
0
|
$mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp); |
647
|
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
0
|
my (@ucp) = split(UCP_DELIMITER,$response); |
649
|
|
|
|
|
|
|
#header... |
650
|
0
|
|
|
|
|
0
|
$mess{trn} = $ucp[0]; |
651
|
0
|
|
|
|
|
0
|
$mess{len} = $ucp[1]; |
652
|
0
|
|
|
|
|
0
|
$mess{type} = $ucp[2]; |
653
|
0
|
|
|
|
|
0
|
$mess{ot} = $ucp[3]; |
654
|
|
|
|
|
|
|
|
655
|
0
|
0
|
|
|
|
0
|
if ($mess{type} eq "O") { |
656
|
0
|
|
|
|
|
0
|
$mess{npl} = $ucp[4]; |
657
|
0
|
|
|
|
|
0
|
$mess{rads} = $ucp[5]; |
658
|
0
|
|
|
|
|
0
|
$mess{oadc} = $ucp[6]; |
659
|
0
|
|
|
|
|
0
|
$mess{ac} = $ucp[7]; |
660
|
0
|
|
|
|
|
0
|
$mess{mt} = $ucp[8]; |
661
|
0
|
0
|
|
|
|
0
|
$mess{nmsg} = $mess{mt} == 2 ? $ucp[9] : ''; |
662
|
0
|
0
|
|
|
|
0
|
$mess{amsg} = $mess{mt} == 3 ? $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[9]) : ''; |
663
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[10]; |
664
|
|
|
|
|
|
|
} else { |
665
|
0
|
0
|
|
|
|
0
|
if ($ucp[4] eq ACK) { |
666
|
0
|
|
|
|
|
0
|
$mess{ack} = $ucp[4]; |
667
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[5]; |
668
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[6]; |
669
|
|
|
|
|
|
|
} else { |
670
|
0
|
|
|
|
|
0
|
$mess{nack} = $ucp[4]; |
671
|
0
|
|
|
|
|
0
|
$mess{ec} = $ucp[5]; |
672
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
673
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
|
677
|
0
|
|
|
|
|
0
|
return \%mess; |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
sub make_02 { |
682
|
1
|
|
|
1
|
0
|
353
|
my ($self) = shift; |
683
|
1
|
|
|
|
|
8
|
my %arg = @_; |
684
|
|
|
|
|
|
|
|
685
|
1
|
|
|
|
|
2
|
my $message_string = undef; |
686
|
|
|
|
|
|
|
|
687
|
1
|
50
|
33
|
|
|
16
|
if (exists $arg{operation} and $arg{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
688
|
|
|
|
|
|
|
|
689
|
1
|
50
|
33
|
|
|
21
|
my $text = (exists $arg{nmsg} && !exists $arg{amsg}) |
690
|
|
|
|
|
|
|
? $arg{nmsg} |
691
|
|
|
|
|
|
|
: $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg}); |
692
|
|
|
|
|
|
|
|
693
|
1
|
50
|
|
|
|
76
|
my $string = |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
694
|
|
|
|
|
|
|
(exists $arg{npl} ? $arg{npl} : '') . |
695
|
|
|
|
|
|
|
UCP_DELIMITER . |
696
|
|
|
|
|
|
|
(exists $arg{rads} ? $arg{rads} : '') . |
697
|
|
|
|
|
|
|
UCP_DELIMITER . |
698
|
|
|
|
|
|
|
(exists $arg{oadc} ? $arg{oadc} : '') . |
699
|
|
|
|
|
|
|
UCP_DELIMITER . |
700
|
|
|
|
|
|
|
(exists $arg{ac} ? $arg{ac} : '') . |
701
|
|
|
|
|
|
|
UCP_DELIMITER . |
702
|
|
|
|
|
|
|
(exists $arg{mt} ? $arg{mt} : '') . |
703
|
|
|
|
|
|
|
UCP_DELIMITER . |
704
|
|
|
|
|
|
|
$text; |
705
|
|
|
|
|
|
|
|
706
|
1
|
|
|
|
|
5
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
707
|
|
|
|
|
|
|
UCP_DELIMITER . |
708
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
709
|
|
|
|
|
|
|
UCP_DELIMITER. |
710
|
|
|
|
|
|
|
'O'. |
711
|
|
|
|
|
|
|
UCP_DELIMITER. |
712
|
|
|
|
|
|
|
'02'; |
713
|
|
|
|
|
|
|
|
714
|
1
|
|
|
|
|
25
|
$message_string = $header. |
715
|
|
|
|
|
|
|
UCP_DELIMITER . |
716
|
|
|
|
|
|
|
$string . |
717
|
|
|
|
|
|
|
UCP_DELIMITER . |
718
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
719
|
|
|
|
|
|
|
UCP_DELIMITER . |
720
|
|
|
|
|
|
|
$string . |
721
|
|
|
|
|
|
|
UCP_DELIMITER); |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
} elsif (exists($arg{result}) and $arg{result} == 1) { |
724
|
|
|
|
|
|
|
|
725
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{ack} and $arg{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
726
|
|
|
|
|
|
|
|
727
|
0
|
0
|
|
|
|
0
|
my $string = |
728
|
|
|
|
|
|
|
$arg{ack} . |
729
|
|
|
|
|
|
|
UCP_DELIMITER . |
730
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
731
|
|
|
|
|
|
|
|
732
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
733
|
|
|
|
|
|
|
UCP_DELIMITER . |
734
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
735
|
|
|
|
|
|
|
UCP_DELIMITER. |
736
|
|
|
|
|
|
|
'R'. |
737
|
|
|
|
|
|
|
UCP_DELIMITER. |
738
|
|
|
|
|
|
|
'02'; |
739
|
|
|
|
|
|
|
|
740
|
0
|
|
|
|
|
0
|
$message_string = $header. |
741
|
|
|
|
|
|
|
UCP_DELIMITER . |
742
|
|
|
|
|
|
|
$string . |
743
|
|
|
|
|
|
|
UCP_DELIMITER . |
744
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
745
|
|
|
|
|
|
|
UCP_DELIMITER . |
746
|
|
|
|
|
|
|
$string . |
747
|
|
|
|
|
|
|
UCP_DELIMITER); |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
} elsif (exists $arg{nack} and $arg{nack} ne '') { |
750
|
|
|
|
|
|
|
|
751
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
752
|
|
|
|
|
|
|
$arg{nack} . |
753
|
|
|
|
|
|
|
UCP_DELIMITER . |
754
|
|
|
|
|
|
|
(exists $arg{ec} ? $arg{ec} : '') . |
755
|
|
|
|
|
|
|
UCP_DELIMITER . |
756
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
757
|
|
|
|
|
|
|
|
758
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
759
|
|
|
|
|
|
|
UCP_DELIMITER . |
760
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
761
|
|
|
|
|
|
|
UCP_DELIMITER. |
762
|
|
|
|
|
|
|
'R'. |
763
|
|
|
|
|
|
|
UCP_DELIMITER. |
764
|
|
|
|
|
|
|
'02'; |
765
|
|
|
|
|
|
|
|
766
|
0
|
|
|
|
|
0
|
$message_string = $header. |
767
|
|
|
|
|
|
|
UCP_DELIMITER . |
768
|
|
|
|
|
|
|
$string . |
769
|
|
|
|
|
|
|
UCP_DELIMITER . |
770
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
771
|
|
|
|
|
|
|
UCP_DELIMITER . |
772
|
|
|
|
|
|
|
$string . |
773
|
|
|
|
|
|
|
UCP_DELIMITER); |
774
|
|
|
|
|
|
|
} |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
|
777
|
1
|
|
|
|
|
107
|
return $message_string; |
778
|
|
|
|
|
|
|
} |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
#OP 03 |
782
|
|
|
|
|
|
|
sub parse_03 { |
783
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
784
|
0
|
|
|
|
|
0
|
my %mess ; |
785
|
|
|
|
|
|
|
|
786
|
0
|
|
|
|
|
0
|
my $resp_tmp = $response; |
787
|
0
|
|
|
|
|
0
|
$resp_tmp =~ s/..$//; |
788
|
0
|
|
|
|
|
0
|
$mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp); |
789
|
|
|
|
|
|
|
|
790
|
0
|
|
|
|
|
0
|
my (@ucp) = split(UCP_DELIMITER,$response); |
791
|
|
|
|
|
|
|
#header... |
792
|
0
|
|
|
|
|
0
|
$mess{trn} = $ucp[0]; |
793
|
0
|
|
|
|
|
0
|
$mess{len} = $ucp[1]; |
794
|
0
|
|
|
|
|
0
|
$mess{type} = $ucp[2]; |
795
|
0
|
|
|
|
|
0
|
$mess{ot} = $ucp[3]; |
796
|
|
|
|
|
|
|
|
797
|
0
|
0
|
|
|
|
0
|
if ($mess{type} eq "O") { |
798
|
0
|
|
|
|
|
0
|
$mess{rad} = $ucp[4]; |
799
|
0
|
|
|
|
|
0
|
$mess{oadc} = $ucp[5]; |
800
|
0
|
|
|
|
|
0
|
$mess{ac} = $ucp[6]; |
801
|
0
|
|
|
|
|
0
|
$mess{npl} = $ucp[7]; #must be 0 |
802
|
0
|
|
|
|
|
0
|
$mess{gas} = $ucp[8]; #empty if npl 0 |
803
|
0
|
|
|
|
|
0
|
$mess{rp} = $ucp[9]; |
804
|
0
|
|
|
|
|
0
|
$mess{pr} = $ucp[10]; |
805
|
0
|
|
|
|
|
0
|
$mess{lpr} = $ucp[11]; |
806
|
0
|
|
|
|
|
0
|
$mess{ur} = $ucp[12]; |
807
|
0
|
|
|
|
|
0
|
$mess{lur} = $ucp[13]; |
808
|
0
|
|
|
|
|
0
|
$mess{rc} = $ucp[14]; |
809
|
0
|
|
|
|
|
0
|
$mess{lrc} = $ucp[15]; |
810
|
0
|
|
|
|
|
0
|
$mess{dd} = $ucp[16]; |
811
|
0
|
|
|
|
|
0
|
$mess{ddt} = $ucp[17]; |
812
|
0
|
|
|
|
|
0
|
$mess{mt} = $ucp[18]; |
813
|
0
|
0
|
|
|
|
0
|
$mess{nmsg} = $mess{mt} == 2 ? $ucp[19] : ''; |
814
|
0
|
0
|
|
|
|
0
|
$mess{amsg} = $mess{mt} == 3 ? $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[19]) : ''; |
815
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[20]; |
816
|
|
|
|
|
|
|
} else { |
817
|
0
|
0
|
|
|
|
0
|
if ($ucp[4] eq ACK) { |
818
|
0
|
|
|
|
|
0
|
$mess{ack} = $ucp[4]; |
819
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[5]; |
820
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[6]; |
821
|
|
|
|
|
|
|
} else { |
822
|
0
|
|
|
|
|
0
|
$mess{nack} = $ucp[4]; |
823
|
0
|
|
|
|
|
0
|
$mess{ec} = $ucp[5]; |
824
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
825
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
826
|
|
|
|
|
|
|
} |
827
|
|
|
|
|
|
|
} |
828
|
|
|
|
|
|
|
|
829
|
0
|
|
|
|
|
0
|
return \%mess; |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
sub make_03 { |
834
|
0
|
|
|
0
|
0
|
0
|
my ($self) = shift; |
835
|
0
|
|
|
|
|
0
|
my %arg = @_; |
836
|
|
|
|
|
|
|
|
837
|
0
|
|
|
|
|
0
|
my $message_string = undef; |
838
|
|
|
|
|
|
|
|
839
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{operation} and $arg{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
840
|
|
|
|
|
|
|
|
841
|
0
|
0
|
0
|
|
|
0
|
my $text = (exists $arg{nmsg} && !exists $arg{amsg}) |
842
|
|
|
|
|
|
|
? $arg{nmsg} |
843
|
|
|
|
|
|
|
: $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg}); |
844
|
|
|
|
|
|
|
|
845
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
846
|
|
|
|
|
|
|
(exists $arg{rad} ? $arg{rad} : '') . |
847
|
|
|
|
|
|
|
UCP_DELIMITER . |
848
|
|
|
|
|
|
|
(exists $arg{oadc} ? $arg{oadc} : '') . |
849
|
|
|
|
|
|
|
UCP_DELIMITER . |
850
|
|
|
|
|
|
|
(exists $arg{ac} ? $arg{ac} : '') . |
851
|
|
|
|
|
|
|
UCP_DELIMITER . |
852
|
|
|
|
|
|
|
(exists $arg{npl} ? $arg{npl} : '') . |
853
|
|
|
|
|
|
|
UCP_DELIMITER . |
854
|
|
|
|
|
|
|
(exists $arg{gas} ? $arg{gas} : '') . |
855
|
|
|
|
|
|
|
UCP_DELIMITER . |
856
|
|
|
|
|
|
|
(exists $arg{rp} ? $arg{rp} : '') . |
857
|
|
|
|
|
|
|
UCP_DELIMITER . |
858
|
|
|
|
|
|
|
(exists $arg{pr} ? $arg{pr} : '') . |
859
|
|
|
|
|
|
|
UCP_DELIMITER . |
860
|
|
|
|
|
|
|
(exists $arg{lpr} ? $arg{lpr} : '') . |
861
|
|
|
|
|
|
|
UCP_DELIMITER . |
862
|
|
|
|
|
|
|
(exists $arg{ur} ? $arg{ur} : '') . |
863
|
|
|
|
|
|
|
UCP_DELIMITER . |
864
|
|
|
|
|
|
|
(exists $arg{lur} ? $arg{lur} : '') . |
865
|
|
|
|
|
|
|
UCP_DELIMITER . |
866
|
|
|
|
|
|
|
(exists $arg{rc} ? $arg{rc} : '') . |
867
|
|
|
|
|
|
|
UCP_DELIMITER . |
868
|
|
|
|
|
|
|
(exists $arg{lrc} ? $arg{lrc} : '') . |
869
|
|
|
|
|
|
|
UCP_DELIMITER . |
870
|
|
|
|
|
|
|
(exists $arg{dd} ? $arg{dd} : '') . |
871
|
|
|
|
|
|
|
UCP_DELIMITER . |
872
|
|
|
|
|
|
|
(exists $arg{ddt} ? $arg{ddt} : '') . |
873
|
|
|
|
|
|
|
UCP_DELIMITER . |
874
|
|
|
|
|
|
|
(exists $arg{mt} ? $arg{mt} : '') . |
875
|
|
|
|
|
|
|
UCP_DELIMITER . |
876
|
|
|
|
|
|
|
$text; |
877
|
|
|
|
|
|
|
|
878
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
879
|
|
|
|
|
|
|
UCP_DELIMITER . |
880
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
881
|
|
|
|
|
|
|
UCP_DELIMITER. |
882
|
|
|
|
|
|
|
'O'. |
883
|
|
|
|
|
|
|
UCP_DELIMITER. |
884
|
|
|
|
|
|
|
'03'; |
885
|
|
|
|
|
|
|
|
886
|
0
|
|
|
|
|
0
|
$message_string = $header. |
887
|
|
|
|
|
|
|
UCP_DELIMITER . |
888
|
|
|
|
|
|
|
$string . |
889
|
|
|
|
|
|
|
UCP_DELIMITER . |
890
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
891
|
|
|
|
|
|
|
UCP_DELIMITER . |
892
|
|
|
|
|
|
|
$string . |
893
|
|
|
|
|
|
|
UCP_DELIMITER); |
894
|
|
|
|
|
|
|
|
895
|
|
|
|
|
|
|
} elsif (exists($arg{result}) and $arg{result} == 1) { |
896
|
|
|
|
|
|
|
|
897
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{ack} and $arg{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
898
|
|
|
|
|
|
|
|
899
|
0
|
0
|
|
|
|
0
|
my $string = |
900
|
|
|
|
|
|
|
$arg{ack} . |
901
|
|
|
|
|
|
|
UCP_DELIMITER . |
902
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : ''); |
903
|
|
|
|
|
|
|
|
904
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
905
|
|
|
|
|
|
|
UCP_DELIMITER . |
906
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
907
|
|
|
|
|
|
|
UCP_DELIMITER. |
908
|
|
|
|
|
|
|
'R'. |
909
|
|
|
|
|
|
|
UCP_DELIMITER. |
910
|
|
|
|
|
|
|
'03'; |
911
|
|
|
|
|
|
|
|
912
|
0
|
|
|
|
|
0
|
$message_string = $header. |
913
|
|
|
|
|
|
|
UCP_DELIMITER . |
914
|
|
|
|
|
|
|
$string . |
915
|
|
|
|
|
|
|
UCP_DELIMITER . |
916
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
917
|
|
|
|
|
|
|
UCP_DELIMITER . |
918
|
|
|
|
|
|
|
$string . |
919
|
|
|
|
|
|
|
UCP_DELIMITER); |
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
} elsif (exists $arg{nack} and $arg{nack} ne '') { |
922
|
|
|
|
|
|
|
|
923
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
924
|
|
|
|
|
|
|
$arg{nack} . |
925
|
|
|
|
|
|
|
UCP_DELIMITER . |
926
|
|
|
|
|
|
|
(exists $arg{ec} ? $arg{ec} : '') . |
927
|
|
|
|
|
|
|
UCP_DELIMITER . |
928
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : ''); |
929
|
|
|
|
|
|
|
|
930
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
931
|
|
|
|
|
|
|
UCP_DELIMITER . |
932
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
933
|
|
|
|
|
|
|
UCP_DELIMITER. |
934
|
|
|
|
|
|
|
'R'. |
935
|
|
|
|
|
|
|
UCP_DELIMITER. |
936
|
|
|
|
|
|
|
'03'; |
937
|
|
|
|
|
|
|
|
938
|
0
|
|
|
|
|
0
|
$message_string = $header. |
939
|
|
|
|
|
|
|
UCP_DELIMITER . |
940
|
|
|
|
|
|
|
$string . |
941
|
|
|
|
|
|
|
UCP_DELIMITER . |
942
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
943
|
|
|
|
|
|
|
UCP_DELIMITER . |
944
|
|
|
|
|
|
|
$string . |
945
|
|
|
|
|
|
|
UCP_DELIMITER); |
946
|
|
|
|
|
|
|
} |
947
|
|
|
|
|
|
|
} |
948
|
|
|
|
|
|
|
|
949
|
0
|
|
|
|
|
0
|
return $message_string; |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
#OP 30 |
954
|
|
|
|
|
|
|
sub parse_30 { |
955
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
956
|
0
|
|
|
|
|
0
|
my %mess; |
957
|
|
|
|
|
|
|
|
958
|
0
|
|
|
|
|
0
|
my $resp_tmp = $response; |
959
|
0
|
|
|
|
|
0
|
$resp_tmp =~ s/..$//; |
960
|
0
|
|
|
|
|
0
|
$mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp); |
961
|
|
|
|
|
|
|
|
962
|
0
|
|
|
|
|
0
|
my (@ucp) = split(UCP_DELIMITER,$response); |
963
|
|
|
|
|
|
|
#header... |
964
|
0
|
|
|
|
|
0
|
$mess{trn} = $ucp[0]; |
965
|
0
|
|
|
|
|
0
|
$mess{len} = $ucp[1]; |
966
|
0
|
|
|
|
|
0
|
$mess{type} = $ucp[2]; |
967
|
0
|
|
|
|
|
0
|
$mess{ot} = $ucp[3]; |
968
|
|
|
|
|
|
|
|
969
|
0
|
0
|
|
|
|
0
|
if ($mess{type} eq "O") { |
970
|
0
|
|
|
|
|
0
|
$mess{adc} = $ucp[4]; |
971
|
0
|
|
|
|
|
0
|
$mess{oadc} = $ucp[5]; |
972
|
0
|
|
|
|
|
0
|
$mess{ac} = $ucp[6]; |
973
|
0
|
|
|
|
|
0
|
$mess{nrq} = $ucp[7]; |
974
|
0
|
|
|
|
|
0
|
$mess{nad} = $ucp[8]; |
975
|
0
|
|
|
|
|
0
|
$mess{npid} = $ucp[9]; |
976
|
0
|
|
|
|
|
0
|
$mess{dd} = $ucp[10]; |
977
|
0
|
|
|
|
|
0
|
$mess{ddt} = $ucp[11]; |
978
|
0
|
|
|
|
|
0
|
$mess{vp} = $ucp[12]; |
979
|
0
|
|
|
|
|
0
|
$mess{amsg} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[13]); |
980
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[14]; |
981
|
|
|
|
|
|
|
} else { |
982
|
0
|
0
|
|
|
|
0
|
if ($ucp[4] eq ACK) { |
983
|
0
|
|
|
|
|
0
|
$mess{ack} = $ucp[4]; |
984
|
0
|
|
|
|
|
0
|
$mess{mvp} = $ucp[5]; |
985
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
986
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
987
|
|
|
|
|
|
|
} else { |
988
|
0
|
|
|
|
|
0
|
$mess{nack} = $ucp[4]; |
989
|
0
|
|
|
|
|
0
|
$mess{ec} = $ucp[5]; |
990
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
991
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
992
|
|
|
|
|
|
|
} |
993
|
|
|
|
|
|
|
} |
994
|
|
|
|
|
|
|
|
995
|
0
|
|
|
|
|
0
|
return \%mess; |
996
|
|
|
|
|
|
|
} |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
sub make_30 { |
1000
|
0
|
|
|
0
|
0
|
0
|
my ($self) = shift; |
1001
|
0
|
|
|
|
|
0
|
my %arg = @_; |
1002
|
|
|
|
|
|
|
|
1003
|
0
|
|
|
|
|
0
|
my $message_string = undef; |
1004
|
|
|
|
|
|
|
|
1005
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{operation} and $arg{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
1006
|
|
|
|
|
|
|
|
1007
|
0
|
|
|
|
|
0
|
my $text = $self->{OBJ_EMI_COMMON}->ia5_encode($arg{amsg}); |
1008
|
|
|
|
|
|
|
|
1009
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
(exists $arg{adc} ? $arg{adc} : '') . |
1011
|
|
|
|
|
|
|
UCP_DELIMITER . |
1012
|
|
|
|
|
|
|
(exists $arg{oadc} ? $arg{oadc} : '') . |
1013
|
|
|
|
|
|
|
UCP_DELIMITER . |
1014
|
|
|
|
|
|
|
(exists $arg{ac} ? $arg{ac} : '') . |
1015
|
|
|
|
|
|
|
UCP_DELIMITER . |
1016
|
|
|
|
|
|
|
(exists $arg{nrq} ? $arg{nrq} : '') . |
1017
|
|
|
|
|
|
|
UCP_DELIMITER . |
1018
|
|
|
|
|
|
|
(exists $arg{nad} ? $arg{nad} : '') . |
1019
|
|
|
|
|
|
|
UCP_DELIMITER . |
1020
|
|
|
|
|
|
|
(exists $arg{npid} ? $arg{npid} : '') . |
1021
|
|
|
|
|
|
|
UCP_DELIMITER . |
1022
|
|
|
|
|
|
|
(exists $arg{dd} ? $arg{dd} : '') . |
1023
|
|
|
|
|
|
|
UCP_DELIMITER . |
1024
|
|
|
|
|
|
|
(exists $arg{ddt} ? $arg{ddt} : '') . |
1025
|
|
|
|
|
|
|
UCP_DELIMITER . |
1026
|
|
|
|
|
|
|
(exists $arg{vp} ? $arg{vp} : '') . |
1027
|
|
|
|
|
|
|
UCP_DELIMITER . |
1028
|
|
|
|
|
|
|
$text; |
1029
|
|
|
|
|
|
|
|
1030
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
1031
|
|
|
|
|
|
|
UCP_DELIMITER . |
1032
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1033
|
|
|
|
|
|
|
UCP_DELIMITER. |
1034
|
|
|
|
|
|
|
'O'. |
1035
|
|
|
|
|
|
|
UCP_DELIMITER. |
1036
|
|
|
|
|
|
|
'30'; |
1037
|
|
|
|
|
|
|
|
1038
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1039
|
|
|
|
|
|
|
UCP_DELIMITER . |
1040
|
|
|
|
|
|
|
$string . |
1041
|
|
|
|
|
|
|
UCP_DELIMITER . |
1042
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1043
|
|
|
|
|
|
|
UCP_DELIMITER . |
1044
|
|
|
|
|
|
|
$string . |
1045
|
|
|
|
|
|
|
UCP_DELIMITER); |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
} elsif (exists($arg{result}) and $arg{result} == 1) { |
1048
|
|
|
|
|
|
|
|
1049
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{ack} and $arg{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
1050
|
|
|
|
|
|
|
|
1051
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
$arg{ack} . |
1053
|
|
|
|
|
|
|
UCP_DELIMITER . |
1054
|
|
|
|
|
|
|
(exists $arg{mvp} ? $arg{mvp} : '') . |
1055
|
|
|
|
|
|
|
UCP_DELIMITER . |
1056
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
1057
|
|
|
|
|
|
|
|
1058
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
1059
|
|
|
|
|
|
|
UCP_DELIMITER . |
1060
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1061
|
|
|
|
|
|
|
UCP_DELIMITER. |
1062
|
|
|
|
|
|
|
'R'. |
1063
|
|
|
|
|
|
|
UCP_DELIMITER. |
1064
|
|
|
|
|
|
|
'30'; |
1065
|
|
|
|
|
|
|
|
1066
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1067
|
|
|
|
|
|
|
UCP_DELIMITER . |
1068
|
|
|
|
|
|
|
$string . |
1069
|
|
|
|
|
|
|
UCP_DELIMITER . |
1070
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1071
|
|
|
|
|
|
|
UCP_DELIMITER . |
1072
|
|
|
|
|
|
|
$string . |
1073
|
|
|
|
|
|
|
UCP_DELIMITER); |
1074
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
} elsif (exists $arg{nack} and $arg{nack} ne '') { |
1076
|
|
|
|
|
|
|
|
1077
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
$arg{nack} . |
1079
|
|
|
|
|
|
|
UCP_DELIMITER . |
1080
|
|
|
|
|
|
|
(exists $arg{ec} ? $arg{ec} : '') . |
1081
|
|
|
|
|
|
|
UCP_DELIMITER . |
1082
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : ''); |
1083
|
|
|
|
|
|
|
|
1084
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
1085
|
|
|
|
|
|
|
UCP_DELIMITER . |
1086
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1087
|
|
|
|
|
|
|
UCP_DELIMITER. |
1088
|
|
|
|
|
|
|
'R'. |
1089
|
|
|
|
|
|
|
UCP_DELIMITER. |
1090
|
|
|
|
|
|
|
'30'; |
1091
|
|
|
|
|
|
|
|
1092
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1093
|
|
|
|
|
|
|
UCP_DELIMITER . |
1094
|
|
|
|
|
|
|
$string . |
1095
|
|
|
|
|
|
|
UCP_DELIMITER . |
1096
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1097
|
|
|
|
|
|
|
UCP_DELIMITER . |
1098
|
|
|
|
|
|
|
$string . |
1099
|
|
|
|
|
|
|
UCP_DELIMITER); |
1100
|
|
|
|
|
|
|
} |
1101
|
|
|
|
|
|
|
} |
1102
|
|
|
|
|
|
|
|
1103
|
0
|
|
|
|
|
0
|
return $message_string; |
1104
|
|
|
|
|
|
|
} |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
#OP 31 |
1108
|
|
|
|
|
|
|
sub parse_31 { |
1109
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1110
|
0
|
|
|
|
|
0
|
my %mess; |
1111
|
|
|
|
|
|
|
|
1112
|
0
|
|
|
|
|
0
|
my $resp_tmp = $response; |
1113
|
0
|
|
|
|
|
0
|
$resp_tmp =~ s/..$//; |
1114
|
0
|
|
|
|
|
0
|
$mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp); |
1115
|
|
|
|
|
|
|
|
1116
|
0
|
|
|
|
|
0
|
my (@ucp) = split(UCP_DELIMITER,$response); |
1117
|
|
|
|
|
|
|
#header... |
1118
|
0
|
|
|
|
|
0
|
$mess{trn} = $ucp[0]; |
1119
|
0
|
|
|
|
|
0
|
$mess{len} = $ucp[1]; |
1120
|
0
|
|
|
|
|
0
|
$mess{type} = $ucp[2]; |
1121
|
0
|
|
|
|
|
0
|
$mess{ot} = $ucp[3]; |
1122
|
|
|
|
|
|
|
|
1123
|
0
|
0
|
|
|
|
0
|
if ($mess{type} eq "O") { |
1124
|
0
|
|
|
|
|
0
|
$mess{adc} = $ucp[4]; |
1125
|
0
|
|
|
|
|
0
|
$mess{pid} = $ucp[5]; |
1126
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[6]; |
1127
|
|
|
|
|
|
|
} else { |
1128
|
0
|
0
|
|
|
|
0
|
if ($ucp[4] eq ACK) { |
1129
|
0
|
|
|
|
|
0
|
$mess{ack} = $ucp[4]; |
1130
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[5]; |
1131
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[6]; |
1132
|
|
|
|
|
|
|
} else { |
1133
|
0
|
|
|
|
|
0
|
$mess{nack} = $ucp[4]; |
1134
|
0
|
|
|
|
|
0
|
$mess{ec} = $ucp[5]; |
1135
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
1136
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
1137
|
|
|
|
|
|
|
} |
1138
|
|
|
|
|
|
|
} |
1139
|
|
|
|
|
|
|
|
1140
|
0
|
|
|
|
|
0
|
return \%mess; |
1141
|
|
|
|
|
|
|
} |
1142
|
|
|
|
|
|
|
|
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
sub make_31 { |
1145
|
0
|
|
|
0
|
0
|
0
|
my ($self) = shift; |
1146
|
0
|
|
|
|
|
0
|
my %arg = @_; |
1147
|
|
|
|
|
|
|
|
1148
|
0
|
|
|
|
|
0
|
my $message_string = undef; |
1149
|
|
|
|
|
|
|
|
1150
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{operation} and $arg{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
1151
|
|
|
|
|
|
|
|
1152
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
(exists $arg{adc} ? $arg{adc} : '') . |
1154
|
|
|
|
|
|
|
UCP_DELIMITER . |
1155
|
|
|
|
|
|
|
(exists $arg{pid} ? $arg{pid} : '') ; |
1156
|
|
|
|
|
|
|
|
1157
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
1158
|
|
|
|
|
|
|
UCP_DELIMITER . |
1159
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1160
|
|
|
|
|
|
|
UCP_DELIMITER. |
1161
|
|
|
|
|
|
|
'O'. |
1162
|
|
|
|
|
|
|
UCP_DELIMITER. |
1163
|
|
|
|
|
|
|
'31'; |
1164
|
|
|
|
|
|
|
|
1165
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1166
|
|
|
|
|
|
|
UCP_DELIMITER . |
1167
|
|
|
|
|
|
|
$string . |
1168
|
|
|
|
|
|
|
UCP_DELIMITER . |
1169
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1170
|
|
|
|
|
|
|
UCP_DELIMITER . |
1171
|
|
|
|
|
|
|
$string . |
1172
|
|
|
|
|
|
|
UCP_DELIMITER); |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
} elsif (exists($arg{result}) and $arg{result} == 1) { |
1175
|
|
|
|
|
|
|
|
1176
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg{ack} and $arg{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
1177
|
|
|
|
|
|
|
|
1178
|
0
|
0
|
|
|
|
0
|
my $string = |
1179
|
|
|
|
|
|
|
$arg{ack} . |
1180
|
|
|
|
|
|
|
UCP_DELIMITER . |
1181
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
1182
|
|
|
|
|
|
|
|
1183
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
1184
|
|
|
|
|
|
|
UCP_DELIMITER . |
1185
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1186
|
|
|
|
|
|
|
UCP_DELIMITER. |
1187
|
|
|
|
|
|
|
'R'. |
1188
|
|
|
|
|
|
|
UCP_DELIMITER. |
1189
|
|
|
|
|
|
|
'31'; |
1190
|
|
|
|
|
|
|
|
1191
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1192
|
|
|
|
|
|
|
UCP_DELIMITER . |
1193
|
|
|
|
|
|
|
$string . |
1194
|
|
|
|
|
|
|
UCP_DELIMITER . |
1195
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1196
|
|
|
|
|
|
|
UCP_DELIMITER . |
1197
|
|
|
|
|
|
|
$string . |
1198
|
|
|
|
|
|
|
UCP_DELIMITER); |
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
} elsif (exists $arg{nack} and $arg{nack} ne '') { |
1201
|
|
|
|
|
|
|
|
1202
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
$arg{nack} . |
1204
|
|
|
|
|
|
|
UCP_DELIMITER . |
1205
|
|
|
|
|
|
|
(exists $arg{ec} ? $arg{ec} : '') . |
1206
|
|
|
|
|
|
|
UCP_DELIMITER . |
1207
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : ''); |
1208
|
|
|
|
|
|
|
|
1209
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg{trn}) . |
1210
|
|
|
|
|
|
|
UCP_DELIMITER . |
1211
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1212
|
|
|
|
|
|
|
UCP_DELIMITER. |
1213
|
|
|
|
|
|
|
'R'. |
1214
|
|
|
|
|
|
|
UCP_DELIMITER. |
1215
|
|
|
|
|
|
|
'31'; |
1216
|
|
|
|
|
|
|
|
1217
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1218
|
|
|
|
|
|
|
UCP_DELIMITER . |
1219
|
|
|
|
|
|
|
$string . |
1220
|
|
|
|
|
|
|
UCP_DELIMITER . |
1221
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1222
|
|
|
|
|
|
|
UCP_DELIMITER . |
1223
|
|
|
|
|
|
|
$string . |
1224
|
|
|
|
|
|
|
UCP_DELIMITER); |
1225
|
|
|
|
|
|
|
} |
1226
|
|
|
|
|
|
|
} |
1227
|
|
|
|
|
|
|
|
1228
|
0
|
|
|
|
|
0
|
return $message_string; |
1229
|
|
|
|
|
|
|
} |
1230
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
#OP 5x abstract |
1233
|
|
|
|
|
|
|
sub _parse_5x { |
1234
|
0
|
|
|
0
|
|
0
|
my ($self, $response)=@_; |
1235
|
0
|
|
|
|
|
0
|
my %mess; |
1236
|
|
|
|
|
|
|
|
1237
|
0
|
|
|
|
|
0
|
my $resp_tmp = $response; |
1238
|
0
|
|
|
|
|
0
|
$resp_tmp =~ s/..$//; |
1239
|
0
|
|
|
|
|
0
|
$mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp); |
1240
|
|
|
|
|
|
|
|
1241
|
0
|
|
|
|
|
0
|
my (@ucp) = split(UCP_DELIMITER,$response); |
1242
|
|
|
|
|
|
|
#header... |
1243
|
0
|
|
|
|
|
0
|
$mess{trn} = $ucp[0]; |
1244
|
0
|
|
|
|
|
0
|
$mess{len} = $ucp[1]; |
1245
|
0
|
|
|
|
|
0
|
$mess{type} = $ucp[2]; |
1246
|
0
|
|
|
|
|
0
|
$mess{ot} = $ucp[3]; |
1247
|
|
|
|
|
|
|
|
1248
|
0
|
0
|
|
|
|
0
|
if ($mess{type} eq "O") { |
1249
|
0
|
|
|
|
|
0
|
$mess{adc} = $ucp[4]; |
1250
|
0
|
|
|
|
|
0
|
$mess{otoa} = $ucp[32]; |
1251
|
0
|
0
|
|
|
|
0
|
$mess{oadc} = ($mess{otoa} eq "5039") ? $self->{OBJ_EMI_COMMON}->decode_7bit(substr($ucp[5],2)) : $ucp[5]; |
1252
|
0
|
|
|
|
|
0
|
$mess{ac} = $ucp[6]; |
1253
|
0
|
|
|
|
|
0
|
$mess{nrq} = $ucp[7]; |
1254
|
0
|
|
|
|
|
0
|
$mess{nadc} = $ucp[8]; |
1255
|
0
|
|
|
|
|
0
|
$mess{nt} = $ucp[9]; |
1256
|
0
|
|
|
|
|
0
|
$mess{npid} = $ucp[10]; |
1257
|
0
|
|
|
|
|
0
|
$mess{lrq} = $ucp[11]; |
1258
|
0
|
|
|
|
|
0
|
$mess{lrad} = $ucp[12]; |
1259
|
0
|
|
|
|
|
0
|
$mess{lpid} = $ucp[13]; |
1260
|
0
|
|
|
|
|
0
|
$mess{dd} = $ucp[14]; |
1261
|
0
|
|
|
|
|
0
|
$mess{ddt} = $ucp[15]; |
1262
|
0
|
|
|
|
|
0
|
$mess{vp} = $ucp[16]; |
1263
|
0
|
|
|
|
|
0
|
$mess{rpid} = $ucp[17]; |
1264
|
0
|
|
|
|
|
0
|
$mess{scts} = $ucp[18]; |
1265
|
0
|
|
|
|
|
0
|
$mess{dst} = $ucp[19]; |
1266
|
0
|
|
|
|
|
0
|
$mess{rsn} = $ucp[20]; |
1267
|
0
|
|
|
|
|
0
|
$mess{dscts} = $ucp[21]; |
1268
|
0
|
|
|
|
|
0
|
$mess{mt} = $ucp[22]; |
1269
|
0
|
|
|
|
|
0
|
$mess{nb} = $ucp[23]; |
1270
|
0
|
0
|
0
|
|
|
0
|
$mess{nmsg} = $ucp[24] if ($mess{mt} && $mess{mt} == 2); |
1271
|
0
|
0
|
0
|
|
|
0
|
$mess{amsg} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[24]) if ($mess{mt} && $mess{mt} == 3); |
1272
|
0
|
0
|
0
|
|
|
0
|
$mess{tmsg} = $ucp[24] if ($mess{mt} && $mess{mt} == 4); |
1273
|
0
|
|
|
|
|
0
|
$mess{mms} = $ucp[25]; |
1274
|
0
|
|
|
|
|
0
|
$mess{pr} = $ucp[26]; |
1275
|
0
|
|
|
|
|
0
|
$mess{dcs} = $ucp[27]; |
1276
|
0
|
|
|
|
|
0
|
$mess{mcls} = $ucp[28]; |
1277
|
0
|
|
|
|
|
0
|
$mess{rpi} = $ucp[29]; |
1278
|
0
|
|
|
|
|
0
|
$mess{cpg} = $ucp[30]; |
1279
|
0
|
|
|
|
|
0
|
$mess{rply} = $ucp[31]; |
1280
|
0
|
|
|
|
|
0
|
$mess{hplmn} = $ucp[33]; |
1281
|
0
|
|
|
|
|
0
|
$mess{xser} = $ucp[34]; |
1282
|
0
|
|
|
|
|
0
|
$mess{res4} = $ucp[35]; |
1283
|
0
|
|
|
|
|
0
|
$mess{res5} = $ucp[36]; |
1284
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[37]; |
1285
|
|
|
|
|
|
|
} else { |
1286
|
0
|
0
|
|
|
|
0
|
if ($ucp[4] eq ACK) { |
1287
|
0
|
|
|
|
|
0
|
$mess{ack} = $ucp[4]; |
1288
|
0
|
|
|
|
|
0
|
$mess{mvp} = $ucp[5]; |
1289
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
1290
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
1291
|
|
|
|
|
|
|
} else { |
1292
|
0
|
|
|
|
|
0
|
$mess{nack} = $ucp[4]; |
1293
|
0
|
|
|
|
|
0
|
$mess{ec} = $ucp[5]; |
1294
|
0
|
|
|
|
|
0
|
$mess{sm} = $ucp[6]; |
1295
|
0
|
|
|
|
|
0
|
$mess{checksum} = $ucp[7]; |
1296
|
|
|
|
|
|
|
} |
1297
|
|
|
|
|
|
|
} |
1298
|
|
|
|
|
|
|
|
1299
|
0
|
|
|
|
|
0
|
return \%mess; |
1300
|
|
|
|
|
|
|
|
1301
|
|
|
|
|
|
|
} |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
sub _make_5x { |
1304
|
1
|
|
|
1
|
|
2
|
my ($self) = shift; |
1305
|
1
|
|
|
|
|
2
|
my $arg = shift; |
1306
|
1
|
|
|
|
|
2
|
my $op_type = shift; |
1307
|
|
|
|
|
|
|
|
1308
|
1
|
|
|
|
|
13
|
my $message_string = undef; |
1309
|
|
|
|
|
|
|
|
1310
|
1
|
50
|
33
|
|
|
10
|
if (exists $arg->{operation} and $arg->{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
1311
|
|
|
|
|
|
|
|
1312
|
1
|
|
|
|
|
3
|
my $text = ''; |
1313
|
1
|
|
|
|
|
2
|
my $from = ''; |
1314
|
|
|
|
|
|
|
|
1315
|
1
|
50
|
|
|
|
3
|
if (exists $arg->{amsg}) { |
1316
|
1
|
|
|
|
|
5
|
$text = $self->{OBJ_EMI_COMMON}->ia5_encode($arg->{amsg}); |
1317
|
|
|
|
|
|
|
} else { |
1318
|
0
|
0
|
0
|
|
|
0
|
$text = exists $arg->{nmsg} && !exists $arg->{tmsg} ? $arg->{nmsg} : $arg->{tmsg}; |
1319
|
|
|
|
|
|
|
} |
1320
|
|
|
|
|
|
|
|
1321
|
1
|
50
|
|
|
|
51
|
$from = $arg->{otoa} eq '5039' |
|
|
50
|
|
|
|
|
|
1322
|
|
|
|
|
|
|
? $self->{OBJ_EMI_COMMON}->encode_7bit($arg->{oadc}) |
1323
|
|
|
|
|
|
|
: $arg->{oadc} |
1324
|
|
|
|
|
|
|
if exists $arg->{otoa} ; |
1325
|
|
|
|
|
|
|
|
1326
|
1
|
50
|
|
|
|
162
|
my $string = |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
(exists $arg->{adc} ? $arg->{adc} : '') . |
1328
|
|
|
|
|
|
|
UCP_DELIMITER . |
1329
|
|
|
|
|
|
|
$from . |
1330
|
|
|
|
|
|
|
UCP_DELIMITER . |
1331
|
|
|
|
|
|
|
(exists $arg->{ac} ? $arg->{ac} : '') . |
1332
|
|
|
|
|
|
|
UCP_DELIMITER . |
1333
|
|
|
|
|
|
|
(exists $arg->{nrq} ? $arg->{nrq} : '') . |
1334
|
|
|
|
|
|
|
UCP_DELIMITER . |
1335
|
|
|
|
|
|
|
(exists $arg->{nadc} ? $arg->{nadc} : '') . |
1336
|
|
|
|
|
|
|
UCP_DELIMITER . |
1337
|
|
|
|
|
|
|
(exists $arg->{nt} ? $arg->{nt} : '') . |
1338
|
|
|
|
|
|
|
UCP_DELIMITER . |
1339
|
|
|
|
|
|
|
(exists $arg->{npid} ? $arg->{npid} : '') . |
1340
|
|
|
|
|
|
|
UCP_DELIMITER . |
1341
|
|
|
|
|
|
|
(exists $arg->{lrq} ? $arg->{lrq} : '') . |
1342
|
|
|
|
|
|
|
UCP_DELIMITER . |
1343
|
|
|
|
|
|
|
(exists $arg->{lrad} ? $arg->{lrad} : '') . |
1344
|
|
|
|
|
|
|
UCP_DELIMITER . |
1345
|
|
|
|
|
|
|
(exists $arg->{lpid} ? $arg->{lpid} : '') . |
1346
|
|
|
|
|
|
|
UCP_DELIMITER . |
1347
|
|
|
|
|
|
|
(exists $arg->{dd} ? $arg->{dd} : '') . |
1348
|
|
|
|
|
|
|
UCP_DELIMITER . |
1349
|
|
|
|
|
|
|
(exists $arg->{ddt} ? $arg->{ddt} : '') . |
1350
|
|
|
|
|
|
|
UCP_DELIMITER . |
1351
|
|
|
|
|
|
|
(exists $arg->{vp} ? $arg->{vp} : '') . |
1352
|
|
|
|
|
|
|
UCP_DELIMITER . |
1353
|
|
|
|
|
|
|
(exists $arg->{rpid} ? $arg->{rpid} : '') . |
1354
|
|
|
|
|
|
|
UCP_DELIMITER . |
1355
|
|
|
|
|
|
|
(exists $arg->{scts} ? $arg->{scts} : '') . |
1356
|
|
|
|
|
|
|
UCP_DELIMITER . |
1357
|
|
|
|
|
|
|
(exists $arg->{dst} ? $arg->{dst} : '') . |
1358
|
|
|
|
|
|
|
UCP_DELIMITER . |
1359
|
|
|
|
|
|
|
(exists $arg->{rsn} ? $arg->{rsn} : '') . |
1360
|
|
|
|
|
|
|
UCP_DELIMITER . |
1361
|
|
|
|
|
|
|
(exists $arg->{dscts} ? $arg->{dscts} : '') . |
1362
|
|
|
|
|
|
|
UCP_DELIMITER . |
1363
|
|
|
|
|
|
|
(exists $arg->{mt} ? $arg->{mt} : '') . |
1364
|
|
|
|
|
|
|
UCP_DELIMITER . |
1365
|
|
|
|
|
|
|
(exists $arg->{nb} ? $arg->{nb} : '') . |
1366
|
|
|
|
|
|
|
UCP_DELIMITER . |
1367
|
|
|
|
|
|
|
$text . |
1368
|
|
|
|
|
|
|
UCP_DELIMITER . |
1369
|
|
|
|
|
|
|
(exists $arg->{mms} ? $arg->{mms} : '') . |
1370
|
|
|
|
|
|
|
UCP_DELIMITER . |
1371
|
|
|
|
|
|
|
(exists $arg->{pr} ? $arg->{pr} : '') . |
1372
|
|
|
|
|
|
|
UCP_DELIMITER . |
1373
|
|
|
|
|
|
|
(exists $arg->{dcs} ? $arg->{dcs} : '') . |
1374
|
|
|
|
|
|
|
UCP_DELIMITER . |
1375
|
|
|
|
|
|
|
(exists $arg->{mcls} ? $arg->{mcls} : '') . |
1376
|
|
|
|
|
|
|
UCP_DELIMITER . |
1377
|
|
|
|
|
|
|
(exists $arg->{rpi} ? $arg->{rpi} : '') . |
1378
|
|
|
|
|
|
|
UCP_DELIMITER . |
1379
|
|
|
|
|
|
|
(exists $arg->{cpg} ? $arg->{cpg} : '') . |
1380
|
|
|
|
|
|
|
UCP_DELIMITER . |
1381
|
|
|
|
|
|
|
(exists $arg->{rply} ? $arg->{rply} : '') . |
1382
|
|
|
|
|
|
|
UCP_DELIMITER . |
1383
|
|
|
|
|
|
|
(exists $arg->{otoa} ? $arg->{otoa} : '') . |
1384
|
|
|
|
|
|
|
UCP_DELIMITER . |
1385
|
|
|
|
|
|
|
(exists $arg->{hplmn} ? $arg->{hplmn} : '') . |
1386
|
|
|
|
|
|
|
UCP_DELIMITER . |
1387
|
|
|
|
|
|
|
(exists $arg->{xser} ? $arg->{xser} : '') . |
1388
|
|
|
|
|
|
|
UCP_DELIMITER . |
1389
|
|
|
|
|
|
|
(exists $arg->{res4} ? $arg->{res4} : '') . |
1390
|
|
|
|
|
|
|
UCP_DELIMITER . |
1391
|
|
|
|
|
|
|
(exists $arg->{res5} ? $arg->{res5} : '') |
1392
|
|
|
|
|
|
|
; |
1393
|
|
|
|
|
|
|
|
1394
|
1
|
|
|
|
|
4
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
1395
|
|
|
|
|
|
|
UCP_DELIMITER . |
1396
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1397
|
|
|
|
|
|
|
UCP_DELIMITER. |
1398
|
|
|
|
|
|
|
'O'. |
1399
|
|
|
|
|
|
|
UCP_DELIMITER. |
1400
|
|
|
|
|
|
|
$op_type; |
1401
|
|
|
|
|
|
|
|
1402
|
1
|
|
|
|
|
31
|
$message_string = $header. |
1403
|
|
|
|
|
|
|
UCP_DELIMITER . |
1404
|
|
|
|
|
|
|
$string . |
1405
|
|
|
|
|
|
|
UCP_DELIMITER . |
1406
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1407
|
|
|
|
|
|
|
UCP_DELIMITER . |
1408
|
|
|
|
|
|
|
$string . |
1409
|
|
|
|
|
|
|
UCP_DELIMITER); |
1410
|
|
|
|
|
|
|
|
1411
|
|
|
|
|
|
|
} elsif (exists($arg->{result}) and $arg->{result} == 1) { |
1412
|
|
|
|
|
|
|
|
1413
|
0
|
0
|
0
|
|
|
0
|
if (exists $arg->{ack} and $arg->{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
1414
|
|
|
|
|
|
|
|
1415
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
1416
|
|
|
|
|
|
|
$arg->{ack} . |
1417
|
|
|
|
|
|
|
UCP_DELIMITER . |
1418
|
|
|
|
|
|
|
(exists $arg->{mvp} ? $arg->{mvp} : '') . |
1419
|
|
|
|
|
|
|
UCP_DELIMITER . |
1420
|
|
|
|
|
|
|
(exists $arg->{sm} ? $arg->{sm} : '') ; |
1421
|
|
|
|
|
|
|
|
1422
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg->{trn}) . |
1423
|
|
|
|
|
|
|
UCP_DELIMITER . |
1424
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1425
|
|
|
|
|
|
|
UCP_DELIMITER. |
1426
|
|
|
|
|
|
|
'R'. |
1427
|
|
|
|
|
|
|
UCP_DELIMITER. |
1428
|
|
|
|
|
|
|
$op_type; |
1429
|
|
|
|
|
|
|
|
1430
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1431
|
|
|
|
|
|
|
UCP_DELIMITER . |
1432
|
|
|
|
|
|
|
$string . |
1433
|
|
|
|
|
|
|
UCP_DELIMITER . |
1434
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1435
|
|
|
|
|
|
|
UCP_DELIMITER . |
1436
|
|
|
|
|
|
|
$string . |
1437
|
|
|
|
|
|
|
UCP_DELIMITER); |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
} elsif (exists $arg->{nack} and $arg->{nack} ne '') { |
1440
|
|
|
|
|
|
|
|
1441
|
0
|
0
|
|
|
|
0
|
my $string = |
|
|
0
|
|
|
|
|
|
1442
|
|
|
|
|
|
|
$arg->{nack} . |
1443
|
|
|
|
|
|
|
UCP_DELIMITER . |
1444
|
|
|
|
|
|
|
(exists $arg->{ec} ? $arg->{ec} : '') . |
1445
|
|
|
|
|
|
|
UCP_DELIMITER . |
1446
|
|
|
|
|
|
|
(exists $arg->{sm} ? $arg->{sm} : '') ; |
1447
|
|
|
|
|
|
|
|
1448
|
0
|
|
|
|
|
0
|
my $header = sprintf("%02d",$arg->{trn}) . |
1449
|
|
|
|
|
|
|
UCP_DELIMITER . |
1450
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1451
|
|
|
|
|
|
|
UCP_DELIMITER. |
1452
|
|
|
|
|
|
|
'R'. |
1453
|
|
|
|
|
|
|
UCP_DELIMITER. |
1454
|
|
|
|
|
|
|
$op_type; |
1455
|
|
|
|
|
|
|
|
1456
|
0
|
|
|
|
|
0
|
$message_string = $header. |
1457
|
|
|
|
|
|
|
UCP_DELIMITER . |
1458
|
|
|
|
|
|
|
$string . |
1459
|
|
|
|
|
|
|
UCP_DELIMITER . |
1460
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1461
|
|
|
|
|
|
|
UCP_DELIMITER . |
1462
|
|
|
|
|
|
|
$string . |
1463
|
|
|
|
|
|
|
UCP_DELIMITER); |
1464
|
|
|
|
|
|
|
} |
1465
|
|
|
|
|
|
|
} |
1466
|
|
|
|
|
|
|
|
1467
|
1
|
|
|
|
|
119
|
return $message_string; |
1468
|
|
|
|
|
|
|
} |
1469
|
|
|
|
|
|
|
|
1470
|
|
|
|
|
|
|
#submit |
1471
|
|
|
|
|
|
|
sub parse_51 { |
1472
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1473
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1474
|
|
|
|
|
|
|
} |
1475
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
#OP 52 delivery short message |
1477
|
|
|
|
|
|
|
sub parse_52 { |
1478
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1479
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1480
|
|
|
|
|
|
|
} |
1481
|
|
|
|
|
|
|
|
1482
|
|
|
|
|
|
|
sub parse_53 { |
1483
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1484
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1485
|
|
|
|
|
|
|
} |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
sub parse_54 { |
1488
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1489
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1490
|
|
|
|
|
|
|
} |
1491
|
|
|
|
|
|
|
|
1492
|
|
|
|
|
|
|
sub parse_55 { |
1493
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1494
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1495
|
|
|
|
|
|
|
} |
1496
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
sub parse_56 { |
1498
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1499
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1500
|
|
|
|
|
|
|
} |
1501
|
|
|
|
|
|
|
|
1502
|
|
|
|
|
|
|
sub parse_57 { |
1503
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1504
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1505
|
|
|
|
|
|
|
} |
1506
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
sub parse_58 { |
1508
|
0
|
|
|
0
|
0
|
0
|
my ($self, $response)=@_; |
1509
|
0
|
|
|
|
|
0
|
return $self->_parse_5x($response); |
1510
|
|
|
|
|
|
|
} |
1511
|
|
|
|
|
|
|
|
1512
|
|
|
|
|
|
|
sub make_51 { |
1513
|
1
|
|
|
1
|
0
|
2
|
my ($self) = shift; |
1514
|
1
|
|
|
|
|
5
|
my %arg = @_; |
1515
|
1
|
|
|
|
|
6
|
return $self->_make_5x(\%arg,'51'); |
1516
|
|
|
|
|
|
|
} |
1517
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
sub make_52 { |
1519
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1520
|
0
|
|
|
|
|
|
my %arg = @_; |
1521
|
0
|
|
|
|
|
|
return $self->_make_5x(\%arg,'52'); |
1522
|
|
|
|
|
|
|
} |
1523
|
|
|
|
|
|
|
|
1524
|
|
|
|
|
|
|
sub make_53 { |
1525
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1526
|
0
|
|
|
|
|
|
my %arg = @_; |
1527
|
0
|
|
|
|
|
|
return $self->_make_5x(\%arg,'53'); |
1528
|
|
|
|
|
|
|
} |
1529
|
|
|
|
|
|
|
|
1530
|
|
|
|
|
|
|
sub make_54 { |
1531
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1532
|
0
|
|
|
|
|
|
my %arg = @_; |
1533
|
0
|
|
|
|
|
|
return $self->_make_5x(\%arg,'54'); |
1534
|
|
|
|
|
|
|
} |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
sub make_55 { |
1537
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1538
|
0
|
|
|
|
|
|
my %arg = @_; |
1539
|
0
|
|
|
|
|
|
return $self->_make_5x(\%arg,'55'); |
1540
|
|
|
|
|
|
|
} |
1541
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
sub make_56 { |
1543
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1544
|
0
|
|
|
|
|
|
my %arg = @_; |
1545
|
0
|
|
|
|
|
|
return $self->_make_5x(\%arg,'56'); |
1546
|
|
|
|
|
|
|
} |
1547
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
sub make_57 { |
1549
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1550
|
0
|
|
|
|
|
|
my %arg = @_; |
1551
|
0
|
|
|
|
|
|
return $self->_make_5x(\%arg,'57'); |
1552
|
|
|
|
|
|
|
} |
1553
|
|
|
|
|
|
|
|
1554
|
|
|
|
|
|
|
sub make_58 { |
1555
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1556
|
0
|
|
|
|
|
|
my %arg = @_; |
1557
|
0
|
|
|
|
|
|
return $self->_make_5x(\%arg,'58'); |
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
|
1560
|
|
|
|
|
|
|
|
1561
|
|
|
|
|
|
|
#OP 60 abstract |
1562
|
|
|
|
|
|
|
sub parse_60 { |
1563
|
0
|
|
|
0
|
0
|
|
my ($self, $response)=@_; |
1564
|
0
|
|
|
|
|
|
my %mess; |
1565
|
|
|
|
|
|
|
|
1566
|
0
|
|
|
|
|
|
my $resp_tmp = $response; |
1567
|
0
|
|
|
|
|
|
$resp_tmp =~ s/..$//; |
1568
|
0
|
|
|
|
|
|
$mess{my_checksum} = $self->{OBJ_EMI_COMMON}->checksum($resp_tmp); |
1569
|
|
|
|
|
|
|
|
1570
|
0
|
|
|
|
|
|
my (@ucp) = split(UCP_DELIMITER,$response); |
1571
|
|
|
|
|
|
|
#header... |
1572
|
0
|
|
|
|
|
|
$mess{trn} = $ucp[0]; |
1573
|
0
|
|
|
|
|
|
$mess{len} = $ucp[1]; |
1574
|
0
|
|
|
|
|
|
$mess{type} = $ucp[2]; |
1575
|
0
|
|
|
|
|
|
$mess{ot} = $ucp[3]; |
1576
|
|
|
|
|
|
|
|
1577
|
0
|
0
|
|
|
|
|
if ($mess{type} eq "O") { |
1578
|
0
|
|
|
|
|
|
$mess{oadc} = $ucp[4]; |
1579
|
0
|
|
|
|
|
|
$mess{oton} = $ucp[5]; |
1580
|
0
|
|
|
|
|
|
$mess{onpi} = $ucp[6]; |
1581
|
0
|
|
|
|
|
|
$mess{styp} = $ucp[7]; |
1582
|
0
|
|
|
|
|
|
$mess{pwd} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[8]); |
1583
|
0
|
|
|
|
|
|
$mess{npwd} = $self->{OBJ_EMI_COMMON}->ia5_decode($ucp[9]); |
1584
|
0
|
|
|
|
|
|
$mess{vers} = $ucp[10]; |
1585
|
0
|
|
|
|
|
|
$mess{ladc} = $ucp[11]; |
1586
|
0
|
|
|
|
|
|
$mess{lton} = $ucp[12]; |
1587
|
0
|
|
|
|
|
|
$mess{lnpi} = $ucp[13]; |
1588
|
0
|
|
|
|
|
|
$mess{opid} = $ucp[14]; |
1589
|
0
|
|
|
|
|
|
$mess{res1} = $ucp[15]; |
1590
|
0
|
|
|
|
|
|
$mess{checksum} = $ucp[16]; |
1591
|
|
|
|
|
|
|
} else { |
1592
|
0
|
0
|
|
|
|
|
if ($ucp[4] eq ACK) { |
1593
|
0
|
|
|
|
|
|
$mess{ack} = $ucp[4]; |
1594
|
0
|
|
|
|
|
|
$mess{sm} = $ucp[5]; |
1595
|
0
|
|
|
|
|
|
$mess{checksum} = $ucp[6]; |
1596
|
|
|
|
|
|
|
} else { |
1597
|
0
|
|
|
|
|
|
$mess{nack} = $ucp[4]; |
1598
|
0
|
|
|
|
|
|
$mess{ec} = $ucp[5]; |
1599
|
0
|
|
|
|
|
|
$mess{sm} = $ucp[6]; |
1600
|
0
|
|
|
|
|
|
$mess{checksum} = $ucp[7]; |
1601
|
|
|
|
|
|
|
} |
1602
|
|
|
|
|
|
|
} |
1603
|
|
|
|
|
|
|
|
1604
|
0
|
|
|
|
|
|
return \%mess; |
1605
|
|
|
|
|
|
|
} |
1606
|
|
|
|
|
|
|
|
1607
|
|
|
|
|
|
|
sub parse_61 { |
1608
|
0
|
|
|
0
|
0
|
|
my ($self, $response)=@_; |
1609
|
0
|
|
|
|
|
|
return $self->parse_60($response); |
1610
|
|
|
|
|
|
|
} |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
|
1613
|
|
|
|
|
|
|
sub make_60 { |
1614
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1615
|
0
|
|
|
|
|
|
my %arg = @_; |
1616
|
|
|
|
|
|
|
|
1617
|
0
|
|
|
|
|
|
my $message_string = undef; |
1618
|
|
|
|
|
|
|
|
1619
|
0
|
0
|
0
|
|
|
|
if (exists $arg{operation} and $arg{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
1620
|
|
|
|
|
|
|
|
1621
|
0
|
0
|
|
|
|
|
my $string = |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1622
|
|
|
|
|
|
|
(exists $arg{oadc} ? $arg{oadc} : '') . |
1623
|
|
|
|
|
|
|
UCP_DELIMITER . |
1624
|
|
|
|
|
|
|
(exists $arg{oton} ? $arg{oton} : '') . |
1625
|
|
|
|
|
|
|
UCP_DELIMITER . |
1626
|
|
|
|
|
|
|
(exists $arg{onpi} ? $arg{onpi} : '') . |
1627
|
|
|
|
|
|
|
UCP_DELIMITER . |
1628
|
|
|
|
|
|
|
(exists $arg{styp} ? $arg{styp} : '') . |
1629
|
|
|
|
|
|
|
UCP_DELIMITER . |
1630
|
|
|
|
|
|
|
(exists $arg{pwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{pwd}) : '') . |
1631
|
|
|
|
|
|
|
UCP_DELIMITER . |
1632
|
|
|
|
|
|
|
(exists $arg{npwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{npwd}) : '') . |
1633
|
|
|
|
|
|
|
UCP_DELIMITER . |
1634
|
|
|
|
|
|
|
(exists $arg{vers} ? $arg{vers} : '') . |
1635
|
|
|
|
|
|
|
UCP_DELIMITER . |
1636
|
|
|
|
|
|
|
(exists $arg{ladc} ? $arg{ladc} : '') . |
1637
|
|
|
|
|
|
|
UCP_DELIMITER . |
1638
|
|
|
|
|
|
|
(exists $arg{lton} ? $arg{lton} : '') . |
1639
|
|
|
|
|
|
|
UCP_DELIMITER . |
1640
|
|
|
|
|
|
|
(exists $arg{lnpi} ? $arg{lnpi} : '') . |
1641
|
|
|
|
|
|
|
UCP_DELIMITER . |
1642
|
|
|
|
|
|
|
(exists $arg{opid} ? $arg{opid} : '') . |
1643
|
|
|
|
|
|
|
UCP_DELIMITER . |
1644
|
|
|
|
|
|
|
(exists $arg{res1} ? $arg{res1} : '') ; |
1645
|
|
|
|
|
|
|
|
1646
|
0
|
|
|
|
|
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
1647
|
|
|
|
|
|
|
UCP_DELIMITER . |
1648
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1649
|
|
|
|
|
|
|
UCP_DELIMITER. |
1650
|
|
|
|
|
|
|
'O'. |
1651
|
|
|
|
|
|
|
UCP_DELIMITER. |
1652
|
|
|
|
|
|
|
'60'; |
1653
|
|
|
|
|
|
|
|
1654
|
0
|
|
|
|
|
|
$message_string = $header. |
1655
|
|
|
|
|
|
|
UCP_DELIMITER . |
1656
|
|
|
|
|
|
|
$string . |
1657
|
|
|
|
|
|
|
UCP_DELIMITER . |
1658
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1659
|
|
|
|
|
|
|
UCP_DELIMITER . |
1660
|
|
|
|
|
|
|
$string . |
1661
|
|
|
|
|
|
|
UCP_DELIMITER); |
1662
|
|
|
|
|
|
|
|
1663
|
|
|
|
|
|
|
} elsif (exists($arg{result}) and $arg{result} == 1) { |
1664
|
|
|
|
|
|
|
|
1665
|
0
|
0
|
0
|
|
|
|
if (exists $arg{ack} and $arg{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
1666
|
|
|
|
|
|
|
|
1667
|
0
|
0
|
|
|
|
|
my $string = |
1668
|
|
|
|
|
|
|
$arg{ack} . |
1669
|
|
|
|
|
|
|
UCP_DELIMITER . |
1670
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
1671
|
|
|
|
|
|
|
|
1672
|
0
|
|
|
|
|
|
my $header = sprintf("%02d",$arg{trn}) . |
1673
|
|
|
|
|
|
|
UCP_DELIMITER . |
1674
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1675
|
|
|
|
|
|
|
UCP_DELIMITER. |
1676
|
|
|
|
|
|
|
'R'. |
1677
|
|
|
|
|
|
|
UCP_DELIMITER. |
1678
|
|
|
|
|
|
|
'60'; |
1679
|
|
|
|
|
|
|
|
1680
|
0
|
|
|
|
|
|
$message_string = $header. |
1681
|
|
|
|
|
|
|
UCP_DELIMITER . |
1682
|
|
|
|
|
|
|
$string . |
1683
|
|
|
|
|
|
|
UCP_DELIMITER . |
1684
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1685
|
|
|
|
|
|
|
UCP_DELIMITER . |
1686
|
|
|
|
|
|
|
$string . |
1687
|
|
|
|
|
|
|
UCP_DELIMITER); |
1688
|
|
|
|
|
|
|
|
1689
|
|
|
|
|
|
|
} elsif (exists $arg{nack} and $arg{nack} ne '') { |
1690
|
|
|
|
|
|
|
|
1691
|
0
|
0
|
|
|
|
|
my $string = |
|
|
0
|
|
|
|
|
|
1692
|
|
|
|
|
|
|
$arg{nack} . |
1693
|
|
|
|
|
|
|
UCP_DELIMITER . |
1694
|
|
|
|
|
|
|
(exists $arg{ec} ? $arg{ec} : '') . |
1695
|
|
|
|
|
|
|
UCP_DELIMITER . |
1696
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
1697
|
|
|
|
|
|
|
|
1698
|
0
|
|
|
|
|
|
my $header = sprintf("%02d",$arg{trn}) . |
1699
|
|
|
|
|
|
|
UCP_DELIMITER . |
1700
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1701
|
|
|
|
|
|
|
UCP_DELIMITER. |
1702
|
|
|
|
|
|
|
'R'. |
1703
|
|
|
|
|
|
|
UCP_DELIMITER. |
1704
|
|
|
|
|
|
|
'60'; |
1705
|
|
|
|
|
|
|
|
1706
|
0
|
|
|
|
|
|
$message_string = $header. |
1707
|
|
|
|
|
|
|
UCP_DELIMITER . |
1708
|
|
|
|
|
|
|
$string . |
1709
|
|
|
|
|
|
|
UCP_DELIMITER . |
1710
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1711
|
|
|
|
|
|
|
UCP_DELIMITER . |
1712
|
|
|
|
|
|
|
$string . |
1713
|
|
|
|
|
|
|
UCP_DELIMITER); |
1714
|
|
|
|
|
|
|
} |
1715
|
|
|
|
|
|
|
} |
1716
|
|
|
|
|
|
|
|
1717
|
0
|
|
|
|
|
|
return $message_string; |
1718
|
|
|
|
|
|
|
} |
1719
|
|
|
|
|
|
|
|
1720
|
|
|
|
|
|
|
|
1721
|
|
|
|
|
|
|
sub make_61 { |
1722
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
1723
|
0
|
|
|
|
|
|
my %arg = @_; |
1724
|
|
|
|
|
|
|
|
1725
|
0
|
|
|
|
|
|
my $message_string = undef; |
1726
|
|
|
|
|
|
|
|
1727
|
0
|
0
|
0
|
|
|
|
if (exists $arg{operation} and $arg{operation} == 1) { |
|
|
0
|
0
|
|
|
|
|
1728
|
|
|
|
|
|
|
|
1729
|
0
|
0
|
|
|
|
|
my $string = |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1730
|
|
|
|
|
|
|
(exists $arg{oadc} ? $arg{oadc} : '') . |
1731
|
|
|
|
|
|
|
UCP_DELIMITER . |
1732
|
|
|
|
|
|
|
(exists $arg{oton} ? $arg{oton} : '') . |
1733
|
|
|
|
|
|
|
UCP_DELIMITER . |
1734
|
|
|
|
|
|
|
(exists $arg{onpi} ? $arg{onpi} : '') . |
1735
|
|
|
|
|
|
|
UCP_DELIMITER . |
1736
|
|
|
|
|
|
|
(exists $arg{styp} ? $arg{styp} : '') . |
1737
|
|
|
|
|
|
|
UCP_DELIMITER . |
1738
|
|
|
|
|
|
|
(exists $arg{pwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{pwd}) : '') . |
1739
|
|
|
|
|
|
|
UCP_DELIMITER . |
1740
|
|
|
|
|
|
|
(exists $arg{npwd} ? $self->{OBJ_EMI_COMMON}->ia5_encode($arg{npwd}) : '') . |
1741
|
|
|
|
|
|
|
UCP_DELIMITER . |
1742
|
|
|
|
|
|
|
(exists $arg{vers} ? $arg{vers} : '') . |
1743
|
|
|
|
|
|
|
UCP_DELIMITER . |
1744
|
|
|
|
|
|
|
(exists $arg{ladc} ? $arg{ladc} : '') . |
1745
|
|
|
|
|
|
|
UCP_DELIMITER . |
1746
|
|
|
|
|
|
|
(exists $arg{lton} ? $arg{lton} : '') . |
1747
|
|
|
|
|
|
|
UCP_DELIMITER . |
1748
|
|
|
|
|
|
|
(exists $arg{lnpi} ? $arg{lnpi} : '') . |
1749
|
|
|
|
|
|
|
UCP_DELIMITER . |
1750
|
|
|
|
|
|
|
(exists $arg{opid} ? $arg{opid} : '') . |
1751
|
|
|
|
|
|
|
UCP_DELIMITER . |
1752
|
|
|
|
|
|
|
(exists $arg{res1} ? $arg{res1} : '') . |
1753
|
|
|
|
|
|
|
UCP_DELIMITER . |
1754
|
|
|
|
|
|
|
(exists $arg{res2} ? $arg{res2} : '') ; |
1755
|
|
|
|
|
|
|
|
1756
|
0
|
|
|
|
|
|
my $header = sprintf("%02d",$self->{TRN_OBJ}->next_trn()) . |
1757
|
|
|
|
|
|
|
UCP_DELIMITER . |
1758
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1759
|
|
|
|
|
|
|
UCP_DELIMITER. |
1760
|
|
|
|
|
|
|
'O'. |
1761
|
|
|
|
|
|
|
UCP_DELIMITER. |
1762
|
|
|
|
|
|
|
'61'; |
1763
|
|
|
|
|
|
|
|
1764
|
0
|
|
|
|
|
|
$message_string = $header. |
1765
|
|
|
|
|
|
|
UCP_DELIMITER . |
1766
|
|
|
|
|
|
|
$string . |
1767
|
|
|
|
|
|
|
UCP_DELIMITER . |
1768
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1769
|
|
|
|
|
|
|
UCP_DELIMITER . |
1770
|
|
|
|
|
|
|
$string . |
1771
|
|
|
|
|
|
|
UCP_DELIMITER); |
1772
|
|
|
|
|
|
|
|
1773
|
|
|
|
|
|
|
} elsif (exists($arg{result}) and $arg{result} == 1) { |
1774
|
|
|
|
|
|
|
|
1775
|
0
|
0
|
0
|
|
|
|
if (exists $arg{ack} and $arg{ack} ne '') { |
|
|
0
|
0
|
|
|
|
|
1776
|
|
|
|
|
|
|
|
1777
|
0
|
0
|
|
|
|
|
my $string = |
1778
|
|
|
|
|
|
|
$arg{ack} . |
1779
|
|
|
|
|
|
|
UCP_DELIMITER . |
1780
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
1781
|
|
|
|
|
|
|
|
1782
|
0
|
|
|
|
|
|
my $header = sprintf("%02d",$arg{trn}) . |
1783
|
|
|
|
|
|
|
UCP_DELIMITER . |
1784
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1785
|
|
|
|
|
|
|
UCP_DELIMITER. |
1786
|
|
|
|
|
|
|
'R'. |
1787
|
|
|
|
|
|
|
UCP_DELIMITER. |
1788
|
|
|
|
|
|
|
'61'; |
1789
|
|
|
|
|
|
|
|
1790
|
0
|
|
|
|
|
|
$message_string = $header. |
1791
|
|
|
|
|
|
|
UCP_DELIMITER . |
1792
|
|
|
|
|
|
|
$string . |
1793
|
|
|
|
|
|
|
UCP_DELIMITER . |
1794
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1795
|
|
|
|
|
|
|
UCP_DELIMITER . |
1796
|
|
|
|
|
|
|
$string . |
1797
|
|
|
|
|
|
|
UCP_DELIMITER); |
1798
|
|
|
|
|
|
|
|
1799
|
|
|
|
|
|
|
} elsif (exists $arg{nack} and $arg{nack} ne '') { |
1800
|
|
|
|
|
|
|
|
1801
|
0
|
0
|
|
|
|
|
my $string = |
|
|
0
|
|
|
|
|
|
1802
|
|
|
|
|
|
|
$arg{nack} . |
1803
|
|
|
|
|
|
|
UCP_DELIMITER . |
1804
|
|
|
|
|
|
|
(exists $arg{ec} ? $arg{ec} : '') . |
1805
|
|
|
|
|
|
|
UCP_DELIMITER . |
1806
|
|
|
|
|
|
|
(exists $arg{sm} ? $arg{sm} : '') ; |
1807
|
|
|
|
|
|
|
|
1808
|
0
|
|
|
|
|
|
my $header = sprintf("%02d",$arg{trn}) . |
1809
|
|
|
|
|
|
|
UCP_DELIMITER . |
1810
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->data_len($string) . |
1811
|
|
|
|
|
|
|
UCP_DELIMITER. |
1812
|
|
|
|
|
|
|
'R'. |
1813
|
|
|
|
|
|
|
UCP_DELIMITER. |
1814
|
|
|
|
|
|
|
'61'; |
1815
|
|
|
|
|
|
|
|
1816
|
0
|
|
|
|
|
|
$message_string = $header. |
1817
|
|
|
|
|
|
|
UCP_DELIMITER . |
1818
|
|
|
|
|
|
|
$string . |
1819
|
|
|
|
|
|
|
UCP_DELIMITER . |
1820
|
|
|
|
|
|
|
$self->{OBJ_EMI_COMMON}->checksum($header . |
1821
|
|
|
|
|
|
|
UCP_DELIMITER . |
1822
|
|
|
|
|
|
|
$string . |
1823
|
|
|
|
|
|
|
UCP_DELIMITER); |
1824
|
|
|
|
|
|
|
} |
1825
|
|
|
|
|
|
|
} |
1826
|
|
|
|
|
|
|
|
1827
|
0
|
|
|
|
|
|
return $message_string; |
1828
|
|
|
|
|
|
|
} |
1829
|
|
|
|
|
|
|
|
1830
|
|
|
|
|
|
|
#it doesn't get response! |
1831
|
|
|
|
|
|
|
#param : host, port, listen |
1832
|
|
|
|
|
|
|
#param : output, action, sending |
1833
|
|
|
|
|
|
|
#param : reading_mode (0 = line feed at the end, 1 = reading defined message length - default 1Kb) |
1834
|
|
|
|
|
|
|
#param : max_len (for reading_mode = 1) |
1835
|
|
|
|
|
|
|
################################## |
1836
|
|
|
|
|
|
|
sub create_fake_smsc { |
1837
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
1838
|
0
|
|
|
|
|
|
my %opt = @_; |
1839
|
|
|
|
|
|
|
|
1840
|
0
|
|
|
|
|
|
my $remote_socket = undef; |
1841
|
|
|
|
|
|
|
|
1842
|
0
|
0
|
0
|
|
|
|
my $main_socket = new IO::Socket::INET (LocalHost => exists $opt{host} && $opt{host} ne '' ? $opt{host} : '127.0.0.1', |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1843
|
|
|
|
|
|
|
LocalPort => exists $opt{port} && $opt{port} ne '' ? $opt{port} : 6666, |
1844
|
|
|
|
|
|
|
Listen => exists $opt{listen} ? $opt{listen} : 5, |
1845
|
|
|
|
|
|
|
Proto => 'tcp', |
1846
|
|
|
|
|
|
|
Reuse => 1, |
1847
|
|
|
|
|
|
|
); |
1848
|
0
|
0
|
|
|
|
|
croak "Fake SMSC could not be created, [$!]\n" unless ($main_socket); |
1849
|
|
|
|
|
|
|
|
1850
|
|
|
|
|
|
|
|
1851
|
0
|
0
|
0
|
|
|
|
my $debug = (exists $opt{output} and $opt{output} == 1) ? 1 : 0; |
1852
|
|
|
|
|
|
|
|
1853
|
0
|
|
|
|
|
|
my $reading_mode = 0; |
1854
|
0
|
0
|
|
|
|
|
if (exists $opt{reading_mode}) { |
1855
|
0
|
0
|
0
|
|
|
|
if ($opt{reading_mode} != 0 && $opt{reading_mode} != 1) { |
1856
|
0
|
|
|
|
|
|
$reading_mode = 0; |
1857
|
|
|
|
|
|
|
} else { |
1858
|
0
|
|
|
|
|
|
$reading_mode = $opt{reading_mode}; |
1859
|
|
|
|
|
|
|
} |
1860
|
|
|
|
|
|
|
} |
1861
|
|
|
|
|
|
|
|
1862
|
0
|
0
|
0
|
|
|
|
my $max_len = (exists $opt{max_len} and $opt{max_len} >= 1) ? $opt{max_len} : 1024; |
1863
|
|
|
|
|
|
|
|
1864
|
0
|
|
|
|
|
|
my $readable_handles = new IO::Select(); |
1865
|
0
|
|
|
|
|
|
$readable_handles->add($main_socket); |
1866
|
|
|
|
|
|
|
|
1867
|
0
|
|
|
|
|
|
my ($sock, $new_sock); |
1868
|
|
|
|
|
|
|
|
1869
|
0
|
|
|
|
|
|
while (1) { |
1870
|
0
|
|
|
|
|
|
my ($new_readable) = IO::Select->select($readable_handles, undef, undef, undef); |
1871
|
0
|
|
|
|
|
|
foreach $sock (@$new_readable) { |
1872
|
0
|
0
|
|
|
|
|
if ($sock == $main_socket) { |
1873
|
0
|
|
|
|
|
|
$new_sock = $sock->accept(); |
1874
|
0
|
|
|
|
|
|
$readable_handles->add($new_sock); |
1875
|
|
|
|
|
|
|
} else { |
1876
|
|
|
|
|
|
|
|
1877
|
0
|
0
|
|
|
|
|
print "[*] Reading on socket [$sock]\n" if $debug; |
1878
|
0
|
|
|
|
|
|
my $message = 0; |
1879
|
|
|
|
|
|
|
|
1880
|
0
|
0
|
|
|
|
|
$message = <$sock> if (!$reading_mode); |
1881
|
0
|
0
|
|
|
|
|
$sock->recv($message, $max_len) if ($reading_mode == 1); |
1882
|
|
|
|
|
|
|
|
1883
|
0
|
0
|
|
|
|
|
if ($message) { |
1884
|
0
|
|
|
|
|
|
$message =~ s/[\n\r]//g; |
1885
|
0
|
0
|
|
|
|
|
if ($debug) { |
1886
|
0
|
|
|
|
|
|
print "\n\n[*] UCP string -\n"; |
1887
|
0
|
|
|
|
|
|
print "-"x30; |
1888
|
0
|
|
|
|
|
|
print "\n" . $message . "\n"; |
1889
|
0
|
|
|
|
|
|
print "-"x30; |
1890
|
0
|
|
|
|
|
|
print "\n"; |
1891
|
|
|
|
|
|
|
} |
1892
|
|
|
|
|
|
|
|
1893
|
0
|
0
|
0
|
|
|
|
if (exists $opt{action} and ref($opt{action}) eq "CODE") { |
1894
|
0
|
|
|
|
|
|
my $resp_be = $opt{action}($message); |
1895
|
0
|
0
|
0
|
|
|
|
print $sock $resp_be if (defined($resp_be) && ($resp_be ne '')); |
1896
|
|
|
|
|
|
|
|
1897
|
0
|
0
|
0
|
|
|
|
if (exists $opt{sending} and ref($opt{sending}) eq "CODE") { |
1898
|
0
|
|
|
|
|
|
my $next_ucp_message = $opt{sending}(); |
1899
|
0
|
0
|
0
|
|
|
|
print $sock $next_ucp_message if (defined($next_ucp_message) && ($next_ucp_message ne '')); |
1900
|
|
|
|
|
|
|
} |
1901
|
|
|
|
|
|
|
|
1902
|
|
|
|
|
|
|
} else { |
1903
|
0
|
|
|
|
|
|
my $response = $self->parse_message($message); |
1904
|
0
|
0
|
|
|
|
|
if (ref($response) eq "HASH") { |
1905
|
0
|
|
|
|
|
|
foreach my $k (keys %{$response}) { |
|
0
|
|
|
|
|
|
|
1906
|
0
|
0
|
|
|
|
|
print "\nP.Name: [$k] - Value:\t$response->{$k}" if $debug; |
1907
|
|
|
|
|
|
|
} |
1908
|
|
|
|
|
|
|
} else { |
1909
|
0
|
|
|
|
|
|
print "Error while parsing message\n"; |
1910
|
|
|
|
|
|
|
} |
1911
|
|
|
|
|
|
|
} |
1912
|
|
|
|
|
|
|
} else { |
1913
|
|
|
|
|
|
|
|
1914
|
0
|
0
|
|
|
|
|
print "[*] Closing socket [$sock]\n" if $debug; |
1915
|
0
|
|
|
|
|
|
$readable_handles->remove($sock); |
1916
|
0
|
|
|
|
|
|
close($sock); |
1917
|
|
|
|
|
|
|
|
1918
|
|
|
|
|
|
|
} |
1919
|
|
|
|
|
|
|
} |
1920
|
|
|
|
|
|
|
} |
1921
|
|
|
|
|
|
|
} |
1922
|
|
|
|
|
|
|
|
1923
|
0
|
|
|
|
|
|
return; |
1924
|
|
|
|
|
|
|
} |
1925
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
sub transmit_msg { |
1927
|
0
|
|
|
0
|
1
|
|
my($self, $message_string, $timeout, $need_resp) = @_; |
1928
|
|
|
|
|
|
|
|
1929
|
0
|
|
|
|
|
|
my($rd,$buffer,$response,$acknack,$errcode,$errtxt,$ack); |
1930
|
|
|
|
|
|
|
|
1931
|
0
|
0
|
|
|
|
|
defined($timeout) || do{ $timeout = 0 }; |
|
0
|
|
|
|
|
|
|
1932
|
|
|
|
|
|
|
|
1933
|
0
|
0
|
|
|
|
|
if (!defined($self->{SOCK})) { |
1934
|
0
|
|
|
|
|
|
die "Unable to send message : smsc socket is not initialized, maybe u are using it in FAKE mode... "; |
1935
|
|
|
|
|
|
|
} |
1936
|
0
|
|
|
|
|
|
my $enclosed = STX . $message_string . ETX; |
1937
|
|
|
|
|
|
|
|
1938
|
0
|
|
0
|
|
|
|
print {$self->{SOCK}} $enclosed || do { |
|
0
|
|
|
|
|
|
|
1939
|
|
|
|
|
|
|
$errtxt = "Failed to print to SMSC socket. Remote end closed?"; |
1940
|
|
|
|
|
|
|
$self->{WARN} && warn($errtxt); |
1941
|
|
|
|
|
|
|
return(defined(wantarray) ? wantarray?(undef,0,$errtxt) : undef : undef); |
1942
|
|
|
|
|
|
|
}; |
1943
|
|
|
|
|
|
|
|
1944
|
0
|
|
|
|
|
|
$self->{SOCK}->flush(); |
1945
|
|
|
|
|
|
|
|
1946
|
0
|
0
|
|
|
|
|
if ($need_resp == 1) { |
1947
|
0
|
|
|
|
|
|
do { |
1948
|
|
|
|
|
|
|
# If this system implements alarm(), we will do a non-blocking read. |
1949
|
0
|
0
|
|
|
|
|
if($self->{CAN_ALARM}) { |
1950
|
0
|
|
|
|
|
|
eval { |
1951
|
0
|
|
|
|
|
|
$rd=undef; |
1952
|
0
|
|
|
0
|
|
|
local($SIG{ALRM})=sub{die("alarm\n")}; # NB: \n required |
|
0
|
|
|
|
|
|
|
1953
|
0
|
|
|
|
|
|
alarm($timeout); |
1954
|
0
|
|
|
|
|
|
$rd=read($self->{SOCK},$buffer,1); |
1955
|
0
|
|
|
|
|
|
alarm(0); |
1956
|
|
|
|
|
|
|
}; |
1957
|
|
|
|
|
|
|
# Propagate unexpected errors. |
1958
|
0
|
0
|
0
|
|
|
|
$@&&$@ne"alarm\n"&&die($@); |
1959
|
|
|
|
|
|
|
} |
1960
|
|
|
|
|
|
|
else { |
1961
|
|
|
|
|
|
|
# No alarm() implemented. Must do a (potentially) blocking call to read(). |
1962
|
0
|
|
|
|
|
|
$rd=read($self->{SOCK},$buffer,1); |
1963
|
|
|
|
|
|
|
} |
1964
|
0
|
0
|
|
|
|
|
defined($rd)||do{ # undef, read error. |
1965
|
0
|
|
|
|
|
|
$errtxt="Failed to read from SMSC socket. Never received ETX. Remote end closed?"; |
1966
|
0
|
0
|
|
|
|
|
$self->{WARN}&&warn($errtxt); |
1967
|
0
|
0
|
|
|
|
|
return(defined(wantarray)?wantarray?(undef,0,$errtxt):undef:undef); |
|
|
0
|
|
|
|
|
|
1968
|
|
|
|
|
|
|
}; |
1969
|
0
|
0
|
|
|
|
|
$rd||do{ # Zero, end of 'file'. |
1970
|
0
|
|
|
|
|
|
$errtxt="Never received ETX from SMSC. Remote end closed?"; |
1971
|
0
|
0
|
|
|
|
|
$self->{WARN}&&warn($errtxt); |
1972
|
0
|
0
|
|
|
|
|
return(defined(wantarray)?wantarray?(undef,0,$errtxt):undef:undef); |
|
|
0
|
|
|
|
|
|
1973
|
|
|
|
|
|
|
}; |
1974
|
0
|
|
|
|
|
|
$response.=$buffer; |
1975
|
|
|
|
|
|
|
} until($buffer eq ETX); |
1976
|
|
|
|
|
|
|
|
1977
|
0
|
|
|
|
|
|
(undef,undef,undef,undef,$acknack,$errcode,$errtxt,undef)=split(UCP_DELIMITER, $response); |
1978
|
0
|
0
|
|
|
|
|
if($acknack eq ACK) { |
1979
|
0
|
|
|
|
|
|
($ack,$errcode,$errtxt)=(TRUE,0,''); |
1980
|
|
|
|
|
|
|
} |
1981
|
|
|
|
|
|
|
else { |
1982
|
0
|
|
|
|
|
|
$ack = 0; |
1983
|
0
|
|
|
|
|
|
$errtxt =~ s/^\s+//; |
1984
|
0
|
|
|
|
|
|
$errtxt =~ s/\s+$//; |
1985
|
|
|
|
|
|
|
} |
1986
|
|
|
|
|
|
|
|
1987
|
0
|
|
|
|
|
|
$errtxt .= "\nSent : " . $message_string . "\nReceive : " . $response . "\n"; |
1988
|
0
|
0
|
|
|
|
|
defined(wantarray) ? wantarray ? ($ack, $errcode, $errtxt) : $ack : undef; |
|
|
0
|
|
|
|
|
|
1989
|
|
|
|
|
|
|
|
1990
|
|
|
|
|
|
|
} else { |
1991
|
0
|
0
|
|
|
|
|
defined(wantarray) ? wantarray ? (undef, undef, undef) : undef : undef; |
|
|
0
|
|
|
|
|
|
1992
|
|
|
|
|
|
|
} |
1993
|
|
|
|
|
|
|
|
1994
|
|
|
|
|
|
|
} |
1995
|
|
|
|
|
|
|
|
1996
|
|
|
|
|
|
|
1; |
1997
|
|
|
|
|
|
|
|
1998
|
|
|
|
|
|
|
__END__ |