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

emqx / emqx / 8684992748

15 Apr 2024 07:16AM UTC coverage: 67.831% (+5.4%) from 62.388%
8684992748

push

github

web-flow
Merge pull request #12877 from id/0415-sync-release-56

sync release 56

29 of 40 new or added lines in 7 files covered. (72.5%)

129 existing lines in 17 files now uncovered.

37939 of 55932 relevant lines covered (67.83%)

7734.92 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);
83✔
38
name(0, _Ver) ->
39
    connection_accepted;
2✔
40
name(1, _Ver) ->
41
    unacceptable_protocol_version;
3✔
42
name(2, _Ver) ->
43
    client_identifier_not_valid;
4✔
44
name(3, _Ver) ->
45
    server_unavaliable;
3✔
46
name(4, _Ver) ->
47
    malformed_username_or_password;
3✔
48
name(5, _Ver) ->
49
    unauthorized_client;
1✔
50
name(_, _Ver) ->
51
    unknown_error.
1✔
52

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

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

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

160
compat(connack, 16#80) -> ?CONNACK_PROTO_VER;
2✔
161
compat(connack, 16#81) -> ?CONNACK_PROTO_VER;
2✔
162
compat(connack, 16#82) -> ?CONNACK_PROTO_VER;
2✔
UNCOV
163
compat(connack, 16#83) -> ?CONNACK_PROTO_VER;
×
164
compat(connack, 16#84) -> ?CONNACK_PROTO_VER;
4✔
165
compat(connack, 16#85) -> ?CONNACK_INVALID_ID;
47✔
166
compat(connack, 16#86) -> ?CONNACK_CREDENTIALS;
7✔
167
compat(connack, 16#87) -> ?CONNACK_AUTH;
6✔
168
compat(connack, 16#88) -> ?CONNACK_SERVER;
3✔
169
compat(connack, 16#89) -> ?CONNACK_SERVER;
2✔
170
compat(connack, 16#8A) -> ?CONNACK_AUTH;
1✔
171
compat(connack, 16#8B) -> ?CONNACK_SERVER;
1✔
172
compat(connack, 16#8C) -> ?CONNACK_AUTH;
2✔
UNCOV
173
compat(connack, 16#90) -> ?CONNACK_SERVER;
×
174
compat(connack, 16#97) -> ?CONNACK_SERVER;
4✔
175
compat(connack, 16#9C) -> ?CONNACK_SERVER;
1✔
UNCOV
176
compat(connack, 16#9D) -> ?CONNACK_SERVER;
×
177
compat(connack, 16#9F) -> ?CONNACK_SERVER;
1✔
178
compat(suback, Code) when Code =< ?QOS_2 -> Code;
14,591✔
179
compat(suback, Code) when Code >= 16#80 -> 16#80;
15✔
180
%% TODO: 16#80(qos0) 16#81(qos1) 16#82(qos2) for mqtt-v3.1.1
181
compat(unsuback, _Code) -> undefined;
2✔
182
compat(_Other, _Code) -> undefined.
52✔
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;
12✔
189
connack_error(not_authorized) -> ?RC_NOT_AUTHORIZED;
17✔
190
connack_error(server_unavailable) -> ?RC_SERVER_UNAVAILABLE;
8✔
191
connack_error(server_busy) -> ?RC_SERVER_BUSY;
10✔
192
connack_error(banned) -> ?RC_BANNED;
8✔
193
connack_error(bad_authentication_method) -> ?RC_BAD_AUTHENTICATION_METHOD;
4✔
194
connack_error(_) -> ?RC_UNSPECIFIED_ERROR.
51✔
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