s4 dns: Split up the code into multiple files for easier development
[gd/samba-autobuild/.git] / source4 / dns_server / dns_update.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    DNS server handler for update requests
5
6    Copyright (C) 2010 Kai Blin  <kai@samba.org>
7
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.
12
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.
17
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/>.
20 */
21
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"
31
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)
38 {
39         struct dns_name_question *zone;
40         NTSTATUS status;
41         const struct dns_server_zone *z;
42         size_t host_part_len = 0;
43
44         if (in->qdcount != 1) {
45                 return NT_STATUS_INVALID_PARAMETER;
46         }
47
48         zone = in->questions;
49
50         if (zone->question_type != DNS_QTYPE_SOA) {
51                 return NT_STATUS_INVALID_PARAMETER;
52         }
53
54         DEBUG(0, ("Got a dns update request.\n"));
55
56         for (z = dns->zones; z != NULL; z = z->next) {
57                 bool match;
58
59                 match = dns_name_match(z->name, zone->name, &host_part_len);
60                 if (match) {
61                         break;
62                 }
63         }
64
65         if (z == NULL) {
66                 return NT_STATUS_FOOBAR;
67         }
68
69         if (host_part_len != 0) {
70                 return NT_STATUS_NOT_IMPLEMENTED;
71         }
72
73         return NT_STATUS_NOT_IMPLEMENTED;
74 }