• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

emqx / emqx / 8628139215

10 Apr 2024 08:18AM UTC coverage: 62.44% (-0.05%) from 62.489%
8628139215

push

github

web-flow
Merge pull request #12851 from zmstone/0327-feat-add-emqx_variform

emqx_variform for string substitution and transform

206 of 238 new or added lines in 3 files covered. (86.55%)

28 existing lines in 16 files now uncovered.

34895 of 55886 relevant lines covered (62.44%)

6585.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.44
/apps/emqx/src/emqx_reason_codes.erl
1
%%--------------------------------------------------------------------
2
%% Copyright (c) 2018-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
3
%%
4
%% Licensed under the Apache License, Version 2.0 (the "License");
5
%% you may not use this file except in compliance with the License.
6
%% You may obtain a copy of the License at
7
%%
8
%%     http://www.apache.org/licenses/LICENSE-2.0
9
%%
10
%% Unless required by applicable law or agreed to in writing, software
11
%% distributed under the License is distributed on an "AS IS" BASIS,
12
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
%% See the License for the specific language governing permissions and
14
%% limitations under the License.
15
%%--------------------------------------------------------------------
16

17
%% @doc MQTT5 reason codes
18
-module(emqx_reason_codes).
19

20
-include("emqx_mqtt.hrl").
21

22
-export([
23
    name/1,
24
    name/2,
25
    text/1,
26
    text/2
27
]).
28

29
-export([
30
    frame_error/1,
31
    connack_error/1
32
]).
33

34
-export([compat/2]).
35

36
name(I, Ver) when Ver >= ?MQTT_PROTO_V5 ->
37
    name(I);
86✔
38
name(0, _Ver) ->
39
    connection_accepted;
2✔
40
name(1, _Ver) ->
41
    unacceptable_protocol_version;
2✔
42
name(2, _Ver) ->
43
    client_identifier_not_valid;
3✔
44
name(3, _Ver) ->
45
    server_unavaliable;
2✔
46
name(4, _Ver) ->
47
    malformed_username_or_password;
1✔
48
name(5, _Ver) ->
49
    unauthorized_client;
1✔
50
name(_, _Ver) ->
51
    unknown_error.
3✔
52

53
name(16#00) -> success;
8,535✔
54
name(16#01) -> granted_qos1;
1✔
55
name(16#02) -> granted_qos2;
4✔
56
name(16#04) -> disconnect_with_will_message;
11✔
57
name(16#10) -> no_matching_subscribers;
1✔
58
name(16#11) -> no_subscription_existed;
3✔
UNCOV
59
name(16#18) -> continue_authentication;
×
60
name(16#19) -> re_authenticate;
5✔
61
name(16#80) -> unspecified_error;
22✔
62
name(16#81) -> malformed_packet;
1✔
63
name(16#82) -> protocol_error;
27✔
64
name(16#83) -> implementation_specific_error;
12✔
65
name(16#84) -> unsupported_protocol_version;
2✔
66
name(16#85) -> client_identifier_not_valid;
72✔
67
name(16#86) -> bad_username_or_password;
5✔
68
name(16#87) -> not_authorized;
13✔
69
name(16#88) -> server_unavailable;
×
70
name(16#89) -> server_busy;
1✔
71
name(16#8A) -> banned;
3✔
72
name(16#8B) -> server_shutting_down;
5✔
73
name(16#8C) -> bad_authentication_method;
4✔
74
name(16#8D) -> keepalive_timeout;
3✔
75
name(16#8E) -> session_taken_over;
1✔
76
name(16#8F) -> topic_filter_invalid;
5✔
77
name(16#90) -> topic_name_invalid;
127✔
78
name(16#91) -> packet_identifier_inuse;
4✔
79
name(16#92) -> packet_identifier_not_found;
4✔
80
name(16#93) -> receive_maximum_exceeded;
5✔
81
name(16#94) -> topic_alias_invalid;
3✔
82
name(16#95) -> packet_too_large;
2✔
83
name(16#96) -> message_rate_too_high;
3✔
84
name(16#97) -> quota_exceeded;
17✔
85
name(16#98) -> administrative_action;
2✔
86
name(16#99) -> payload_format_invalid;
2✔
87
name(16#9A) -> retain_not_supported;
3✔
88
name(16#9B) -> qos_not_supported;
13✔
89
name(16#9C) -> use_another_server;
11✔
90
name(16#9D) -> server_moved;
2✔
91
name(16#9E) -> shared_subscriptions_not_supported;
3✔
92
name(16#9F) -> connection_rate_exceeded;
1✔
UNCOV
93
name(16#A0) -> maximum_connect_time;
×
94
name(16#A1) -> subscription_identifiers_not_supported;
3✔
95
name(16#A2) -> wildcard_subscriptions_not_supported;
2✔
96
name(_Code) -> unknown_error.
2✔
97

98
text(I, Ver) when Ver >= ?MQTT_PROTO_V5 ->
99
    text(I);
86✔
100
text(0, _Ver) ->
101
    <<"Connection accepted">>;
2✔
102
text(1, _Ver) ->
103
    <<"unacceptable_protocol_version">>;
2✔
104
text(2, _Ver) ->
105
    <<"client_identifier_not_valid">>;
3✔
106
text(3, _Ver) ->
107
    <<"server_unavaliable">>;
2✔
108
text(4, _Ver) ->
109
    <<"malformed_username_or_password">>;
1✔
110
text(5, _Ver) ->
111
    <<"unauthorized_client">>;
1✔
112
text(_, _Ver) ->
113
    <<"unknown_error">>.
3✔
114

UNCOV
115
text(16#00) -> <<"Success">>;
×
116
text(16#01) -> <<"Granted QoS 1">>;
1✔
117
text(16#02) -> <<"Granted QoS 2">>;
4✔
118
text(16#04) -> <<"Disconnect with Will Message">>;
1✔
119
text(16#10) -> <<"No matching subscribers">>;
1✔
120
text(16#11) -> <<"No subscription existed">>;
3✔
UNCOV
121
text(16#18) -> <<"Continue authentication">>;
×
122
text(16#19) -> <<"Re-authenticate">>;
5✔
UNCOV
123
text(16#80) -> <<"Unspecified error">>;
×
124
text(16#81) -> <<"Malformed Packet">>;
1✔
125
text(16#82) -> <<"Protocol Error">>;
2✔
126
text(16#83) -> <<"Implementation specific error">>;
5✔
127
text(16#84) -> <<"Unsupported Protocol Version">>;
2✔
128
text(16#85) -> <<"Client Identifier not valid">>;
2✔
129
text(16#86) -> <<"Bad User Name or Password">>;
1✔
130
text(16#87) -> <<"Not authorized">>;
6✔
131
text(16#88) -> <<"Server unavailable">>;
×
132
text(16#89) -> <<"Server busy">>;
1✔
133
text(16#8A) -> <<"Banned">>;
3✔
134
text(16#8B) -> <<"Server shutting down">>;
5✔
135
text(16#8C) -> <<"Bad authentication method">>;
2✔
136
text(16#8D) -> <<"Keep Alive timeout">>;
1✔
137
text(16#8E) -> <<"Session taken over">>;
1✔
138
text(16#8F) -> <<"Topic Filter invalid">>;
3✔
UNCOV
139
text(16#90) -> <<"Topic Name invalid">>;
×
UNCOV
140
text(16#91) -> <<"Packet Identifier in use">>;
×
141
text(16#92) -> <<"Packet Identifier not found">>;
4✔
UNCOV
142
text(16#93) -> <<"Receive Maximum exceeded">>;
×
143
text(16#94) -> <<"Topic Alias invalid">>;
1✔
144
text(16#95) -> <<"Packet too large">>;
2✔
145
text(16#96) -> <<"Message rate too high">>;
3✔
146
text(16#97) -> <<"Quota exceeded">>;
3✔
147
text(16#98) -> <<"Administrative action">>;
2✔
148
text(16#99) -> <<"Payload format invalid">>;
2✔
149
text(16#9A) -> <<"Retain not supported">>;
3✔
150
text(16#9B) -> <<"QoS not supported">>;
1✔
151
text(16#9C) -> <<"Use another server">>;
2✔
152
text(16#9D) -> <<"Server moved">>;
2✔
153
text(16#9E) -> <<"Shared Subscriptions not supported">>;
3✔
154
text(16#9F) -> <<"Connection rate exceeded">>;
1✔
UNCOV
155
text(16#A0) -> <<"Maximum connect time">>;
×
156
text(16#A1) -> <<"Subscription Identifiers not supported">>;
3✔
157
text(16#A2) -> <<"Wildcard Subscriptions not supported">>;
2✔
158
text(_Code) -> <<"Unknown error">>.
2✔
159

160
compat(connack, 16#80) -> ?CONNACK_PROTO_VER;
3✔
161
compat(connack, 16#81) -> ?CONNACK_PROTO_VER;
2✔
162
compat(connack, 16#82) -> ?CONNACK_PROTO_VER;
2✔
163
compat(connack, 16#83) -> ?CONNACK_PROTO_VER;
3✔
164
compat(connack, 16#84) -> ?CONNACK_PROTO_VER;
4✔
165
compat(connack, 16#85) -> ?CONNACK_INVALID_ID;
44✔
166
compat(connack, 16#86) -> ?CONNACK_CREDENTIALS;
4✔
167
compat(connack, 16#87) -> ?CONNACK_AUTH;
7✔
168
compat(connack, 16#88) -> ?CONNACK_SERVER;
3✔
169
compat(connack, 16#89) -> ?CONNACK_SERVER;
3✔
170
compat(connack, 16#8A) -> ?CONNACK_AUTH;
2✔
UNCOV
171
compat(connack, 16#8B) -> ?CONNACK_SERVER;
×
172
compat(connack, 16#8C) -> ?CONNACK_AUTH;
1✔
173
compat(connack, 16#90) -> ?CONNACK_SERVER;
2✔
174
compat(connack, 16#97) -> ?CONNACK_SERVER;
3✔
175
compat(connack, 16#9C) -> ?CONNACK_SERVER;
1✔
176
compat(connack, 16#9D) -> ?CONNACK_SERVER;
2✔
177
compat(connack, 16#9F) -> ?CONNACK_SERVER;
2✔
178
compat(suback, Code) when Code =< ?QOS_2 -> Code;
14,489✔
179
compat(suback, Code) when Code >= 16#80 -> 16#80;
9✔
180
%% TODO: 16#80(qos0) 16#81(qos1) 16#82(qos2) for mqtt-v3.1.1
181
compat(unsuback, _Code) -> undefined;
6✔
182
compat(_Other, _Code) -> undefined.
48✔
183

184
frame_error(frame_too_large) -> ?RC_PACKET_TOO_LARGE;
1✔
185
frame_error(_) -> ?RC_MALFORMED_PACKET.
2✔
186

187
connack_error(protocol_error) -> ?RC_PROTOCOL_ERROR;
×
188
connack_error(bad_username_or_password) -> ?RC_BAD_USER_NAME_OR_PASSWORD;
14✔
189
connack_error(not_authorized) -> ?RC_NOT_AUTHORIZED;
10✔
190
connack_error(server_unavailable) -> ?RC_SERVER_UNAVAILABLE;
8✔
191
connack_error(server_busy) -> ?RC_SERVER_BUSY;
12✔
192
connack_error(banned) -> ?RC_BANNED;
10✔
193
connack_error(bad_authentication_method) -> ?RC_BAD_AUTHENTICATION_METHOD;
9✔
194
connack_error(_) -> ?RC_UNSPECIFIED_ERROR.
47✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc