|
7 | 7 | # scapy.contrib.status = loads |
8 | 8 |
|
9 | 9 | from scapy.packet import Packet, bind_layers |
10 | | -from scapy.fields import FieldLenField, BitEnumField, StrLenField, \ |
11 | | - ShortField, ConditionalField, ByteEnumField, ByteField, PacketListField |
| 10 | +from scapy.fields import ( |
| 11 | + BitEnumField, |
| 12 | + ByteEnumField, |
| 13 | + ByteField, |
| 14 | + ConditionalField, |
| 15 | + FieldLenField, |
| 16 | + FieldListField, |
| 17 | + PacketListField, |
| 18 | + ShortField, |
| 19 | + StrLenField, |
| 20 | +) |
12 | 21 | from scapy.layers.inet import TCP |
13 | 22 | from scapy.error import Scapy_Exception |
14 | 23 | from scapy.compat import orb, chb |
@@ -250,18 +259,26 @@ class MQTTSubscribe(Packet): |
250 | 259 |
|
251 | 260 |
|
252 | 261 | ALLOWED_RETURN_CODE = { |
253 | | - 0: 'Success', |
254 | | - 1: 'Success', |
255 | | - 2: 'Success', |
256 | | - 128: 'Failure' |
| 262 | + 0x00: 'Granted QoS 0', |
| 263 | + 0x01: 'Granted QoS 1', |
| 264 | + 0x02: 'Granted QoS 2', |
| 265 | + 0x80: 'Unspecified error', |
| 266 | + 0x83: 'Implementation specific error', |
| 267 | + 0x87: 'Not authorized', |
| 268 | + 0x8F: 'Topic Filter invalid', |
| 269 | + 0x91: 'Packet Identifier in use', |
| 270 | + 0x97: 'Quota exceeded', |
| 271 | + 0x9E: 'Shared Subscriptions not supported', |
| 272 | + 0xA1: 'Subscription Identifiers not supported', |
| 273 | + 0xA2: 'Wildcard Subscriptions not supported', |
257 | 274 | } |
258 | 275 |
|
259 | 276 |
|
260 | 277 | class MQTTSuback(Packet): |
261 | 278 | name = "MQTT suback" |
262 | 279 | fields_desc = [ |
263 | 280 | ShortField("msgid", None), |
264 | | - ByteEnumField("retcode", None, ALLOWED_RETURN_CODE) |
| 281 | + FieldListField("retcodes", None, ByteEnumField("", None, ALLOWED_RETURN_CODE)) |
265 | 282 | ] |
266 | 283 |
|
267 | 284 |
|
|
0 commit comments