diff --git a/src/ingest_protocol/parser.rs b/src/ingest_protocol/parser.rs index 3c8e010..ce1bc3c 100644 --- a/src/ingest_protocol/parser.rs +++ b/src/ingest_protocol/parser.rs @@ -155,21 +155,22 @@ pub fn parse_mac_address(input: &[u8]) -> Result<[u8; 6], Error> { } if !least_bit && input[idx] == b'-' { + idx += 1; 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' - } else if (b'A'..b'F').contains(&input[idx]) { - input[idx] - b'A' - } else if (b'a'..b'f').contains(&input[idx]) { - input[idx] - b'a' + } else if (b'A'..=b'F').contains(&input[idx]) { + input[idx] - b'A' + 10 + } else if (b'a'..=b'f').contains(&input[idx]) { + input[idx] - b'a' + 10 } else { return Err(Error::MacInvalidChar { value: input[idx] }); }; if !least_bit { - mac[cur_byte] = bit << 1; + mac[cur_byte] = bit * 16; least_bit = true; } else { mac[cur_byte] |= bit;