diff options
author | Kai Blin <kai@samba.org> | 2012-03-27 13:59:03 +0200 |
---|---|---|
committer | Kai Blin <kai@samba.org> | 2012-03-27 16:03:16 +0200 |
commit | 533b2e6612bd6497c1d53c31912bccba0260a3e9 (patch) | |
tree | 8fdc21d8954c033788e2d92abf77bee11acdb48f | |
parent | 8d9da67185aac48d7d0bc1e7b90262ae9afc6a64 (diff) | |
download | samba-533b2e6612bd6497c1d53c31912bccba0260a3e9.tar.gz samba-533b2e6612bd6497c1d53c31912bccba0260a3e9.tar.bz2 samba-533b2e6612bd6497c1d53c31912bccba0260a3e9.zip |
s4 dns: Allow changing the dns operation flags in handlers
-rw-r--r-- | source4/dns_server/dns_query.c | 2 | ||||
-rw-r--r-- | source4/dns_server/dns_server.c | 20 | ||||
-rw-r--r-- | source4/dns_server/dns_server.h | 5 | ||||
-rw-r--r-- | source4/dns_server/dns_update.c | 1 |
4 files changed, 23 insertions, 5 deletions
diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c index 9d287bd3a4..e1deff4938 100644 --- a/source4/dns_server/dns_query.c +++ b/source4/dns_server/dns_query.c @@ -207,6 +207,7 @@ static WERROR handle_question(struct dns_server *dns, } WERROR dns_server_process_query(struct dns_server *dns, + struct dns_request_state *state, TALLOC_CTX *mem_ctx, struct dns_name_packet *in, struct dns_res_rec **answers, uint16_t *ancount, @@ -227,6 +228,7 @@ WERROR dns_server_process_query(struct dns_server *dns, } if (dns_authorative_for_zone(dns, in->questions[0].name)) { + state->flags |= DNS_FLAG_AUTHORITATIVE; werror = handle_question(dns, mem_ctx, &in->questions[0], &ans, &num_answers); } else { DEBUG(2, ("I don't feel responsible for '%s', forwarding\n", in->questions[0].name)); diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c index cf43590b63..9e88bd9ebf 100644 --- a/source4/dns_server/dns_server.c +++ b/source4/dns_server/dns_server.c @@ -100,6 +100,7 @@ static NTSTATUS dns_process(struct dns_server *dns, { enum ndr_err_code ndr_err; WERROR ret; + struct dns_request_state *state; struct dns_name_packet *in_packet; struct dns_name_packet *out_packet; struct dns_res_rec *answers = NULL, *nsrecs = NULL, *additional = NULL; @@ -109,9 +110,11 @@ static NTSTATUS dns_process(struct dns_server *dns, return NT_STATUS_INVALID_PARAMETER; } - in_packet = talloc_zero(mem_ctx, struct dns_name_packet); + state = talloc_zero(mem_ctx, struct dns_request_state); + + in_packet = talloc_zero(state, struct dns_name_packet); /* TODO: We don't really need an out_packet. */ - out_packet = talloc_zero(mem_ctx, struct dns_name_packet); + out_packet = talloc_zero(state, struct dns_name_packet); if (in_packet == NULL) return NT_STATUS_NO_MEMORY; if (out_packet == NULL) return NT_STATUS_NO_MEMORY; @@ -134,19 +137,24 @@ static NTSTATUS dns_process(struct dns_server *dns, NDR_PRINT_DEBUG(dns_name_packet, in_packet); } *out_packet = *in_packet; - out_packet->operation |= DNS_FLAG_REPLY; + state->flags |= in_packet->operation | DNS_FLAG_REPLY; + + /* TODO: Allow setting the forwarding in smb.conf or the like */ + state->flags |= DNS_FLAG_RECURSION_AVAIL; switch (in_packet->operation & DNS_OPCODE) { case DNS_OPCODE_QUERY: - ret = dns_server_process_query(dns, out_packet, in_packet, + ret = dns_server_process_query(dns, state, + out_packet, in_packet, &answers, &num_answers, &nsrecs, &num_nsrecs, &additional, &num_additional); break; case DNS_OPCODE_UPDATE: - ret = dns_server_process_update(dns, out_packet, in_packet, + ret = dns_server_process_update(dns, state, + out_packet, in_packet, &answers, &num_answers, &nsrecs, &num_nsrecs, &additional, &num_additional); @@ -169,6 +177,8 @@ static NTSTATUS dns_process(struct dns_server *dns, out_packet->operation |= werr_to_dns_err(ret); } + out_packet->operation |= state->flags; + if (DEBUGLVL(2)) { NDR_PRINT_DEBUG(dns_name_packet, out_packet); } diff --git a/source4/dns_server/dns_server.h b/source4/dns_server/dns_server.h index 718df00dd8..c6f5fb319e 100644 --- a/source4/dns_server/dns_server.h +++ b/source4/dns_server/dns_server.h @@ -39,8 +39,12 @@ struct dns_server { struct dns_server_zone *zones; }; +struct dns_request_state { + uint16_t flags; +}; WERROR dns_server_process_query(struct dns_server *dns, + struct dns_request_state *state, TALLOC_CTX *mem_ctx, struct dns_name_packet *in, struct dns_res_rec **answers, uint16_t *ancount, @@ -48,6 +52,7 @@ WERROR dns_server_process_query(struct dns_server *dns, struct dns_res_rec **additional, uint16_t *arcount); WERROR dns_server_process_update(struct dns_server *dns, + struct dns_request_state *state, TALLOC_CTX *mem_ctx, struct dns_name_packet *in, struct dns_res_rec **prereqs, uint16_t *prereq_count, diff --git a/source4/dns_server/dns_update.c b/source4/dns_server/dns_update.c index 3d7ecce126..d6b764087e 100644 --- a/source4/dns_server/dns_update.c +++ b/source4/dns_server/dns_update.c @@ -680,6 +680,7 @@ failed: } WERROR dns_server_process_update(struct dns_server *dns, + struct dns_request_state *state, TALLOC_CTX *mem_ctx, struct dns_name_packet *in, struct dns_res_rec **prereqs, uint16_t *prereq_count, |