WIP: custom #ingest#protocol parser #23

Draft
DarkCat09 wants to merge 5 commits from custom-parser into master
Showing only changes of commit 922f65a38f - Show all commits

View file

@ -155,21 +155,22 @@ pub fn parse_mac_address(input: &[u8]) -> Result<[u8; 6], Error> {
} }
if !least_bit && input[idx] == b'-' { if !least_bit && input[idx] == b'-' {
idx += 1;
continue; continue;
} }
let bit = if (b'0'..b'9').contains(&input[idx]) { let bit = if (b'0'..=b'9').contains(&input[idx]) {
input[idx] - b'0' input[idx] - b'0'
} else if (b'A'..b'F').contains(&input[idx]) { } else if (b'A'..=b'F').contains(&input[idx]) {
input[idx] - b'A' input[idx] - b'A' + 10
} else if (b'a'..b'f').contains(&input[idx]) { } else if (b'a'..=b'f').contains(&input[idx]) {
input[idx] - b'a' input[idx] - b'a' + 10
} else { } else {
return Err(Error::MacInvalidChar { value: input[idx] }); return Err(Error::MacInvalidChar { value: input[idx] });
}; };
if !least_bit { if !least_bit {
mac[cur_byte] = bit << 1; mac[cur_byte] = bit * 16;
least_bit = true; least_bit = true;
} else { } else {
mac[cur_byte] |= bit; mac[cur_byte] |= bit;