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

emqx / emqx / 8613439193

09 Apr 2024 09:25AM UTC coverage: 62.491% (-0.1%) from 62.636%
8613439193

push

github

web-flow
Merge pull request #12854 from id/0409-update-codeowners

chore: update codeowners

34606 of 55378 relevant lines covered (62.49%)

6551.4 hits per line

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

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

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

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

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

160
compat(connack, 16#80) -> ?CONNACK_PROTO_VER;
2✔
161
compat(connack, 16#81) -> ?CONNACK_PROTO_VER;
1✔
162
compat(connack, 16#82) -> ?CONNACK_PROTO_VER;
4✔
163
compat(connack, 16#83) -> ?CONNACK_PROTO_VER;
4✔
164
compat(connack, 16#84) -> ?CONNACK_PROTO_VER;
3✔
165
compat(connack, 16#85) -> ?CONNACK_INVALID_ID;
50✔
166
compat(connack, 16#86) -> ?CONNACK_CREDENTIALS;
6✔
167
compat(connack, 16#87) -> ?CONNACK_AUTH;
5✔
168
compat(connack, 16#88) -> ?CONNACK_SERVER;
2✔
169
compat(connack, 16#89) -> ?CONNACK_SERVER;
4✔
170
compat(connack, 16#8A) -> ?CONNACK_AUTH;
2✔
171
compat(connack, 16#8B) -> ?CONNACK_SERVER;
3✔
172
compat(connack, 16#8C) -> ?CONNACK_AUTH;
×
173
compat(connack, 16#90) -> ?CONNACK_SERVER;
1✔
174
compat(connack, 16#97) -> ?CONNACK_SERVER;
3✔
175
compat(connack, 16#9C) -> ?CONNACK_SERVER;
1✔
176
compat(connack, 16#9D) -> ?CONNACK_SERVER;
3✔
177
compat(connack, 16#9F) -> ?CONNACK_SERVER;
2✔
178
compat(suback, Code) when Code =< ?QOS_2 -> Code;
14,439✔
179
compat(suback, Code) when Code >= 16#80 -> 16#80;
13✔
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.
43✔
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;
10✔
189
connack_error(not_authorized) -> ?RC_NOT_AUTHORIZED;
21✔
190
connack_error(server_unavailable) -> ?RC_SERVER_UNAVAILABLE;
8✔
191
connack_error(server_busy) -> ?RC_SERVER_BUSY;
10✔
192
connack_error(banned) -> ?RC_BANNED;
11✔
193
connack_error(bad_authentication_method) -> ?RC_BAD_AUTHENTICATION_METHOD;
9✔
194
connack_error(_) -> ?RC_UNSPECIFIED_ERROR.
41✔
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