s4 dns: Split up the code into multiple files for easier development
[Samba/gebeck_regimport.git] / source4 / dns_server / dns_update.c
blobd243736b5bb9761bc5586ade4a8849adf96638e6
1 /*
2 Unix SMB/CIFS implementation.
4 DNS server handler for update requests
6 Copyright (C) 2010 Kai Blin <kai@samba.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "libcli/util/ntstatus.h"
24 #include "librpc/ndr/libndr.h"
25 #include "librpc/gen_ndr/ndr_dns.h"
26 #include "librpc/gen_ndr/ndr_dnsp.h"
27 #include <ldb.h>
28 #include "dsdb/samdb/samdb.h"
29 #include "dsdb/common/util.h"
30 #include "dns_server/dns_server.h"
32 NTSTATUS dns_server_process_update(struct dns_server *dns,
33 TALLOC_CTX *mem_ctx,
34 struct dns_name_packet *in,
35 struct dns_res_rec **prereqs, uint16_t *prereq_count,
36 struct dns_res_rec **updates, uint16_t *update_count,
37 struct dns_res_rec **additional, uint16_t *arcount)
39 struct dns_name_question *zone;
40 NTSTATUS status;
41 const struct dns_server_zone *z;
42 size_t host_part_len = 0;
44 if (in->qdcount != 1) {
45 return NT_STATUS_INVALID_PARAMETER;
48 zone = in->questions;
50 if (zone->question_type != DNS_QTYPE_SOA) {
51 return NT_STATUS_INVALID_PARAMETER;
54 DEBUG(0, ("Got a dns update request.\n"));
56 for (z = dns->zones; z != NULL; z = z->next) {
57 bool match;
59 match = dns_name_match(z->name, zone->name, &host_part_len);
60 if (match) {
61 break;
65 if (z == NULL) {
66 return NT_STATUS_FOOBAR;
69 if (host_part_len != 0) {
70 return NT_STATUS_NOT_IMPLEMENTED;
73 return NT_STATUS_NOT_IMPLEMENTED;