refactoring: split parse_datagram() into own class