private static int ParseAnswer(Record[] records, int current, byte[] packet, int start) { var i = start; var name = ""; i = ParseName(ref name, packet, i); var type = RecordType.None; if (!DNSGenerator.TryGenerateRecordType(ref type, packet[i++] * 256 + packet[i++])) { throw new MailformRequestException(); } i += 2; uint ttl = (uint)packet[i++] * (uint)16777216 + (uint)packet[i++] * (uint)65536 + (uint)packet[i++] * (uint)256 + (uint)packet[i++]; var dLength = packet[i++] * 256 + packet[i++]; object data = null; i = ParseRecordData(ref data, packet, type, i, dLength); records[current] = new Record(name, type, ttl, data); return(i); }
private static int ParseQuestion(Question[] questions, int current, byte[] packet, int startIndex) { int i = startIndex; var domain = ""; i = ParseName(ref domain, packet, i); int typeNum = packet[i] * 256 + packet[i + 2]; RecordType type = RecordType.None; if (!DNSGenerator.TryGenerateRecordType(ref type, typeNum)) { throw new MailformRequestException("Type with number " + typeNum + " has not found!"); } var quest = new Question(domain, type); questions[current] = quest; return(i + 5); }