line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1658
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
87
|
|
2
|
3
|
|
|
3
|
|
62
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
118
|
|
3
|
|
|
|
|
|
|
package Net::MQTT::Message::Connect; |
4
|
|
|
|
|
|
|
$Net::MQTT::Message::Connect::VERSION = '1.143250'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Perl module to represent an MQTT Connect message |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
12
|
use base 'Net::MQTT::Message'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
178
|
|
9
|
3
|
|
|
3
|
|
13
|
use Net::MQTT::Constants qw/:all/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
14
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub message_type { |
12
|
15
|
|
|
15
|
1
|
33
|
1 |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
12
|
100
|
|
12
|
1
|
47
|
sub protocol_name { shift->{protocol_name} || 'MQIsdp' } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
12
|
100
|
|
12
|
1
|
41
|
sub protocol_version { shift->{protocol_version} || 3 } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub user_name_flag { |
23
|
21
|
|
|
21
|
1
|
18
|
my $self = shift; |
24
|
21
|
100
|
|
|
|
80
|
$self->{user_name_flag} || defined $self->{user_name}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub password_flag { |
29
|
21
|
|
|
21
|
1
|
17
|
my $self = shift; |
30
|
21
|
100
|
|
|
|
68
|
$self->{password_flag} || defined $self->{password}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
8
|
100
|
|
8
|
1
|
31
|
sub will_retain { shift->{will_retain} || 0 } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
8
|
100
|
|
8
|
1
|
25
|
sub will_qos { shift->{will_qos} || 0 } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub will_flag { |
41
|
27
|
|
|
27
|
1
|
21
|
my $self = shift; |
42
|
27
|
100
|
|
|
|
109
|
$self->{will_flag} || defined $self->{will_topic} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub clean_session { |
47
|
6
|
|
|
6
|
1
|
5
|
my $self = shift; |
48
|
6
|
100
|
|
|
|
19
|
defined $self->{clean_session} ? $self->{clean_session} : 1 |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
6
|
100
|
|
6
|
1
|
23
|
sub connect_reserved_flag { shift->{connect_reserved_flag} || 0 } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
6
|
100
|
|
6
|
1
|
23
|
sub keep_alive_timer { shift->{keep_alive_timer} || 60 } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
14
|
100
|
|
14
|
1
|
375
|
sub client_id { shift->{client_id} || 'NetMQTTpm'.$$ } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
4
|
1
|
9
|
sub will_topic { shift->{will_topic} } |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
4
|
1
|
11
|
sub will_message { shift->{will_message} } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
4
|
|
|
4
|
1
|
11
|
sub user_name { shift->{user_name} } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
4
|
|
|
4
|
1
|
10
|
sub password { shift->{password} } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _remaining_string { |
73
|
6
|
|
|
6
|
|
7
|
my ($self, $prefix) = @_; |
74
|
6
|
100
|
|
|
|
10
|
$self->protocol_name.'/'.$self->protocol_version.'/'.$self->client_id. |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
75
|
|
|
|
|
|
|
($self->user_name_flag ? ' user='.$self->user_name : ''). |
76
|
|
|
|
|
|
|
($self->password_flag ? ' pass='.$self->password : ''). |
77
|
|
|
|
|
|
|
($self->will_flag |
78
|
|
|
|
|
|
|
? ' will='.$self->will_topic.',"'.$self->will_message.'",'. |
79
|
|
|
|
|
|
|
$self->will_retain.','.qos_string($self->will_qos) : ''). |
80
|
|
|
|
|
|
|
' '.$self->SUPER::_remaining_string($prefix) |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _parse_remaining { |
84
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
85
|
3
|
|
|
|
|
2
|
my $offset = 0; |
86
|
3
|
|
|
|
|
14
|
$self->{protocol_name} = decode_string($self->{remaining}, \$offset); |
87
|
3
|
|
|
|
|
9
|
$self->{protocol_version} = decode_byte($self->{remaining}, \$offset); |
88
|
3
|
|
|
|
|
7
|
my $b = decode_byte($self->{remaining}, \$offset); |
89
|
3
|
|
|
|
|
8
|
$self->{user_name_flag} = ($b&0x80) >> 7; |
90
|
3
|
|
|
|
|
6
|
$self->{password_flag} = ($b&0x40) >> 6; |
91
|
3
|
|
|
|
|
5
|
$self->{will_retain} = ($b&0x20) >> 5; |
92
|
3
|
|
|
|
|
4
|
$self->{will_qos} = ($b&0x18) >> 3; |
93
|
3
|
|
|
|
|
10
|
$self->{will_flag} = ($b&0x4) >> 2; |
94
|
3
|
|
|
|
|
3
|
$self->{clean_session} = ($b&0x2) >> 1; |
95
|
3
|
|
|
|
|
3
|
$self->{connect_reserved_flag} = $b&0x1; |
96
|
3
|
|
|
|
|
7
|
$self->{keep_alive_timer} = decode_short($self->{remaining}, \$offset); |
97
|
3
|
|
|
|
|
6
|
$self->{client_id} = decode_string($self->{remaining}, \$offset); |
98
|
3
|
100
|
|
|
|
8
|
if ($self->will_flag) { |
99
|
1
|
|
|
|
|
4
|
$self->{will_topic} = decode_string($self->{remaining}, \$offset); |
100
|
1
|
|
|
|
|
3
|
$self->{will_message} = decode_string($self->{remaining}, \$offset); |
101
|
|
|
|
|
|
|
} |
102
|
3
|
100
|
|
|
|
6
|
if ($self->user_name_flag) { |
103
|
1
|
|
|
|
|
4
|
$self->{user_name} = decode_string($self->{remaining}, \$offset); |
104
|
|
|
|
|
|
|
} |
105
|
3
|
100
|
|
|
|
6
|
if ($self->password_flag) { |
106
|
1
|
|
|
|
|
3
|
$self->{password} = decode_string($self->{remaining}, \$offset); |
107
|
|
|
|
|
|
|
} |
108
|
3
|
|
|
|
|
9
|
substr $self->{remaining}, 0, $offset, ''; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _remaining_bytes { |
112
|
6
|
|
|
6
|
|
7
|
my $self = shift; |
113
|
6
|
|
|
|
|
8
|
my $o = encode_string($self->protocol_name); |
114
|
6
|
|
|
|
|
10
|
$o .= encode_byte($self->protocol_version); |
115
|
6
|
|
|
|
|
11
|
$o .= encode_byte( |
116
|
|
|
|
|
|
|
($self->user_name_flag << 7) | |
117
|
|
|
|
|
|
|
($self->password_flag << 6) | |
118
|
|
|
|
|
|
|
($self->will_retain << 5) | ($self->will_qos << 3) | |
119
|
|
|
|
|
|
|
($self->will_flag << 2) | |
120
|
|
|
|
|
|
|
($self->clean_session << 1) | |
121
|
|
|
|
|
|
|
$self->connect_reserved_flag); |
122
|
6
|
|
|
|
|
11
|
$o .= encode_short($self->keep_alive_timer); |
123
|
6
|
|
|
|
|
10
|
$o .= encode_string($self->client_id); |
124
|
6
|
100
|
|
|
|
9
|
$o .= encode_string($self->will_topic) if ($self->will_flag); |
125
|
6
|
100
|
|
|
|
10
|
$o .= encode_string($self->will_message) if ($self->will_flag); |
126
|
6
|
100
|
|
|
|
8
|
$o .= encode_string($self->user_name) if ($self->user_name_flag); |
127
|
6
|
100
|
|
|
|
9
|
$o .= encode_string($self->password) if ($self->password_flag); |
128
|
6
|
|
|
|
|
12
|
$o; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |