public bool Register(string name, IPAddress address) { DnsRequest request = new DnsRequest(new Question(EncodeName(name), DnsType.NB, DnsClass.IN)); request.Header.Opcode = OpcodeType.Registration; request.Header.RA = false; request.Header.RD = false; request.Header.B = false; Additional add = new Additional(); add.Domain = EncodeName(name); add.Class = DnsClass.IN; add.Type = DnsType.NB; add.Ttl = 30000; NBRecord nb = new NBRecord(address); add.Record = nb; #if (MF) request.AdditionalRecords = new Additional[] { add }; #else request.AdditionalRecords.Add(add); #endif DnsResponse res = Invoke(request, false); return(true); }
internal DnsResponse(DnsReader br) { _header = new DnsHeader(br); _numQuestions = br.ReadInt16(); _numAnswers = br.ReadInt16(); _numNameServers = br.ReadInt16(); _numAdditionalRecords = br.ReadInt16(); #if (MF) _questions = new Question[_numQuestions]; _answers = new Answer[_numAnswers]; _authorities = new Authority[_numNameServers]; _additionalRecords = new Additional[_numAdditionalRecords]; #endif #if (MF) for (int i = 0; i < _numQuestions; i++) { _questions[i] = new Question(br); } for (int i = 0; i < _numAnswers; i++) { _answers[i] = new Answer(br); } for (int i = 0; i < _numNameServers; i++) { _authorities[i] = new Authority(br); } for (int i = 0; i < _numAdditionalRecords; i++) { _additionalRecords[i] = new Additional(br); } #else for (int i = 0; i < _numQuestions; i++) { _questions.Add(new Question(br)); } for (int i = 0; i < _numAnswers; i++) { _answers.Add(new Answer(br)); } for (int i = 0; i < _numNameServers; i++) { _authorities.Add(new Authority(br)); } for (int i = 0; i < _numAdditionalRecords; i++) { _additionalRecords.Add(new Additional(br)); } #endif }