| 1 |
use std::str::Utf8Error; |
| 2 |
|
| 3 |
quick_error! { |
| 4 |
/// Error parsing DNS packet |
| 5 |
#[derive(Debug)] |
| 6 |
pub enum Error { |
| 7 |
/// Invalid compression pointer not pointing backwards |
| 8 |
/// when parsing label |
| 9 |
BadPointer { |
| 10 |
description("invalid compression pointer not pointing backwards \ |
| 11 |
when parsing label") |
| 12 |
} |
| 13 |
/// Packet is smaller than header size |
| 14 |
HeaderTooShort { |
| 15 |
description("packet is smaller than header size") |
| 16 |
} |
| 17 |
/// Packet ihas incomplete data |
| 18 |
UnexpectedEOF { |
| 19 |
description("packet is has incomplete data") |
| 20 |
} |
| 21 |
/// Wrong (too short or too long) size of RDATA |
| 22 |
WrongRdataLength { |
| 23 |
description("wrong (too short or too long) size of RDATA") |
| 24 |
} |
| 25 |
/// Packet has non-zero reserved bits |
| 26 |
ReservedBitsAreNonZero { |
| 27 |
description("packet has non-zero reserved bits") |
| 28 |
} |
| 29 |
/// Label in domain name has unknown label format |
| 30 |
UnknownLabelFormat { |
| 31 |
description("label in domain name has unknown label format") |
| 32 |
} |
| 33 |
/// Query type code is invalid |
| 34 |
InvalidQueryType(code: u16) { |
| 35 |
description("query type code is invalid") |
| 36 |
display("query type {} is invalid", code) |
| 37 |
} |
| 38 |
/// Query class code is invalid |
| 39 |
InvalidQueryClass(code: u16) { |
| 40 |
description("query class code is invalid") |
| 41 |
display("query class {} is invalid", code) |
| 42 |
} |
| 43 |
/// Type code is invalid |
| 44 |
InvalidType(code: u16) { |
| 45 |
description("type code is invalid") |
| 46 |
display("type {} is invalid", code) |
| 47 |
} |
| 48 |
/// Class code is invalid |
| 49 |
InvalidClass(code: u16) { |
| 50 |
description("class code is invalid") |
| 51 |
display("class {} is invalid", code) |
| 52 |
} |
| 53 |
/// Invalid characters encountered while reading label |
| 54 |
LabelIsNotAscii { |
| 55 |
description("invalid characters encountered while reading label") |
| 56 |
} |
| 57 |
/// Invalid characters encountered while reading TXT |
| 58 |
TxtDataIsNotUTF8(error: Utf8Error) { |
| 59 |
description("invalid characters encountered while reading TXT") |
| 60 |
display("{:?}", error) |
| 61 |
} |
| 62 |
/// Parser is in the wrong state |
| 63 |
WrongState { |
| 64 |
description("parser is in the wrong state") |
| 65 |
} |
| 66 |
/// Additional OPT record found |
| 67 |
AdditionalOPT { |
| 68 |
description("additional OPT record found") |
| 69 |
} |
| 70 |
} |
| 71 |
} |