The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
base.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: f23a4fc1a59bdce0326c75e5800dbbee97582d00 $
19 * @file src/process/dns/base.c
20 * @brief DNS processing.
21 *
22 * @copyright 2024 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
23 * @copyright 2020 Network RADIUS SAS (legal@networkradius.com)
24 */
25#include <freeradius-devel/server/pair.h>
26#include <freeradius-devel/server/rcode.h>
27#include <freeradius-devel/util/debug.h>
28#include <freeradius-devel/util/pair.h>
29#include <freeradius-devel/unlang/interpret.h>
30#include <freeradius-devel/dns/dns.h>
31#include <freeradius-devel/protocol/dns/rfc1034.h>
32
33/** Update this if new rcodes are added
34 */
35#define FR_DNS_RCODE_MAX (FR_RCODE_VALUE_BAD_COOKIE + 1)
36
37static fr_dict_t const *dict_dns;
38
44
47static fr_dict_attr_t const *attr_id;
52
55 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_dns},
56 { .out = &attr_header, .name = "Header", .type = FR_TYPE_STRUCT, .dict = &dict_dns},
57 { .out = &attr_opcode, .name = "Header.Opcode", .type = FR_TYPE_UINT8, .dict = &dict_dns},
58 { .out = &attr_id, .name = "Header.ID", .type = FR_TYPE_UINT16, .dict = &dict_dns},
59 { .out = &attr_response_bit, .name = "Header.Query", .type = FR_TYPE_BOOL, .dict = &dict_dns},
60 { .out = &attr_rcode, .name = "Header.Rcode", .type = FR_TYPE_UINT8, .dict = &dict_dns},
61 { .out = &attr_authoritative_bit, .name = "Header.Authoritative", .type = FR_TYPE_BOOL, .dict = &dict_dns},
63};
64
70
73 { .out = &enum_rcode_no_error, .name = "No-Error", .attr = &attr_rcode }, /* ok/updated */
74 { .out = &enum_rcode_format_error, .name = "Format-Error", .attr = &attr_rcode }, /* invalid */
75 { .out = &enum_rcode_server_failure, .name = "Server-Failure", .attr = &attr_rcode }, /* fail */
76 { .out = &enum_rcode_name_error, .name = "Name-Error", .attr = &attr_rcode }, /* notfound */
77 { .out = &enum_rcode_refused, .name = "Refused", .attr = &attr_rcode }, /* reject */
79};
80
81typedef struct {
82 uint64_t nothing; // so that the next field isn't at offset 0
83
84 /** Request/response sections
85 *
86 */
97
98 /** DNS rcode error sections (not the same as rlm_rcode_t values)
99 *
100 * These are called after the `recv { ... }` section runs if rcode is non-zero
101 */
103
106
110
111/** Records fields from the original request so we have a known good copy
112 */
113typedef struct {
114 uint16_t id; //!< Identity of the request.
115 uint8_t opcode; //!< Opcode, what type of query this is.
117
118#define PROCESS_PACKET_TYPE fr_dns_packet_code_t
119#define PROCESS_CODE_MAX FR_DNS_CODE_MAX
120#define PROCESS_CODE_DO_NOT_RESPOND FR_DNS_DO_NOT_RESPOND
121#define PROCESS_PACKET_CODE_VALID FR_DNS_PACKET_CODE_VALID
122#define PROCESS_INST process_dns_t
123#define PROCESS_RCTX_EXTRA_FIELDS process_dns_fields_t fields;
124
125/** Map an rlm_rcode_t to a header.rcode value
126 */
127#define PROCESS_STATE_EXTRA_FIELDS fr_value_box_t const **dns_rcode[RLM_MODULE_NUMCODES];
128
129#include <freeradius-devel/server/process.h>
130
132 {
133 .section = SECTION_NAME("recv", "Query"),
134 .actions = &mod_actions_authorize,
135 .offset = PROCESS_CONF_OFFSET(query),
136 },
137 {
138 .section = SECTION_NAME("send", "Query-Response"),
140 .offset = PROCESS_CONF_OFFSET(query_response),
141 },
142 {
143 .section = SECTION_NAME("recv", "Inverse-Query"),
145 .offset = PROCESS_CONF_OFFSET(inverse_query),
146 },
147 {
148 .section = SECTION_NAME("send", "Inverse-Query-Response"),
150 .offset = PROCESS_CONF_OFFSET(inverse_query_response),
151 },
152 {
153 .section = SECTION_NAME("recv", "Status"),
155 .offset = PROCESS_CONF_OFFSET(status),
156 },
157 {
158 .section = SECTION_NAME("send", "Status-Response"),
160 .offset = PROCESS_CONF_OFFSET(status_response),
161 },
162 {
163 .section = SECTION_NAME("recv", "Update"),
165 .offset = PROCESS_CONF_OFFSET(update),
166 },
167 {
168 .section = SECTION_NAME("send", "Update-Response"),
170 .offset = PROCESS_CONF_OFFSET(update_response),
171 },
172 {
173 .section = SECTION_NAME("recv", "Stateful-Operation"),
175 .offset = PROCESS_CONF_OFFSET(stateful_operation),
176 },
177 {
178 .section = SECTION_NAME("send", "Stateful-Operation-Response"),
180 .offset = PROCESS_CONF_OFFSET(stateful_operation_response),
181 },
182 {
183 .section = SECTION_NAME("send", "Do-Not-Respond"),
185 .offset = PROCESS_CONF_OFFSET(do_not_respond),
186 },
187
188#define ERROR_SECTION(_name, _number) \
189 { \
190 .section = SECTION_NAME("error", _name), \
191 .actions = &mod_actions_postauth, \
192 .offset = PROCESS_CONF_OFFSET(rcode[_number]), \
193 }
194
195 /*
196 * Error sections that can execute after the recv { ... }
197 * section has run.
198 */
199 ERROR_SECTION("Format-Error", FR_RCODE_VALUE_FORMAT_ERROR),
200 ERROR_SECTION("Server-Failure", FR_RCODE_VALUE_SERVER_FAILURE),
201 ERROR_SECTION("Name-Error", FR_RCODE_VALUE_NAME_ERROR),
202 ERROR_SECTION("Not-Implemented", FR_RCODE_VALUE_NOT_IMPLEMENTED),
203 ERROR_SECTION("Refused", FR_RCODE_VALUE_REFUSED),
204 ERROR_SECTION("YX-Domain", FR_RCODE_VALUE_YX_DOMAIN),
205 ERROR_SECTION("YX-Resource-Record-Set", FR_RCODE_VALUE_YX_RESOURCE_RECORD_SET),
206 ERROR_SECTION("NX-Resource-Record-Set", FR_RCODE_VALUE_NX_RESOURCE_RECORD_SET),
207 ERROR_SECTION("Not-Auth", FR_RCODE_VALUE_NOT_AUTH),
208 ERROR_SECTION("Not-Zone", FR_RCODE_VALUE_NOT_ZONE),
209 ERROR_SECTION("DSO-Type-Not-Implemented", FR_RCODE_VALUE_DSO_TYPE_NOT_IMPLEMENTED),
210 ERROR_SECTION("Bad-Signature", FR_RCODE_VALUE_BAD_SIGNATURE),
211 ERROR_SECTION("Bad-Key", FR_RCODE_VALUE_BAD_KEY),
212 ERROR_SECTION("Bad-Time", FR_RCODE_VALUE_BAD_TIME),
213 ERROR_SECTION("Bad-Mode", FR_RCODE_VALUE_BAD_MODE),
214 ERROR_SECTION("Bad-Name", FR_RCODE_VALUE_BAD_NAME),
215 ERROR_SECTION("Bad-Algorithm", FR_RCODE_VALUE_BAD_ALGORITHM),
216 ERROR_SECTION("Bad-Truncation", FR_RCODE_VALUE_BAD_TRUNCATION),
217 ERROR_SECTION("Bad-Cookie", FR_RCODE_VALUE_BAD_COOKIE),
219};
220
221
222/** Keep a copy of header fields to prevent them being tampered with
223 *
224 */
225static inline CC_HINT(always_inline)
226process_rctx_t *dns_fields_store(request_t *request)
227{
228 fr_pair_t *header;
229 fr_pair_t *id;
230 fr_pair_t *opcode;
231 process_rctx_t *rctx;
232
233 /*
234 * We could use fr_find_by_da_nested, but it's more efficient
235 * to look up the header attribute once.
236 */
237 header = fr_pair_find_by_da(&request->request_pairs, NULL, attr_header);
238 if (!header) {
239 REDEBUG("Missing Header attribute");
240 return NULL;
241 }
242
243 id = fr_pair_find_by_da(&header->vp_group, NULL, attr_id);
244 if (!id) {
245 REDEBUG("Missing ID attribute");
246 return NULL;
247 }
248
249 opcode = fr_pair_find_by_da(&header->vp_group, NULL, attr_opcode);
250 if (!opcode) {
251 REDEBUG("Missing Opcode attribute");
252 return NULL;
253 }
254
255 MEM(rctx = talloc(unlang_interpret_frame_talloc_ctx(request), process_rctx_t));
256 rctx->fields.id = id->vp_uint16;
257 rctx->fields.opcode = opcode->vp_uint8;
258
259 return rctx;
260}
261
262/** Copy values from the request header back into the response
263 *
264 * If a value already exists in the response, don't overwrite it so the user has absolute control
265 */
266static inline CC_HINT(always_inline)
267int dns_fields_restore(request_t *request, process_rctx_t *rctx)
268{
269 fr_pair_t *header;
270 fr_pair_t *id;
271 fr_pair_t *response;
272 fr_pair_t *authoritative;
273 fr_pair_t *opcode;
274 int ret;
275
276 MEM(pair_update_reply(&header, attr_header) >= 0);
277
278 /*
279 * ID should always match the request
280 * but we allow overrides for testing.
281 */
282 MEM((ret = fr_pair_update_by_da_parent(header, &id, attr_id)) != -1);
283 fr_assert_msg(ret >= 0, "Failed to update header attribute %s:", fr_strerror());
284 if (ret == 0) id->vp_uint16 = rctx->fields.id;
285
286 /*
287 * This marks the packet as a response.
288 * Save the user from having to do this manually.
289 */
290 MEM((ret = fr_pair_update_by_da_parent(header, &response, attr_response_bit)) != -1);
291 fr_assert_msg(ret >= 0, "Failed to update response_bit attribute %s:", fr_strerror());
292 if (ret == 0) response->vp_bool = true;
293
294 /*
295 * Opcode should always match the request
296 * but we allow overrides for testing.
297 */
298 MEM((ret = fr_pair_update_by_da_parent(header, &opcode, attr_opcode)) != -1);
299 fr_assert_msg(ret >= 0, "Failed to update opcode attribute %s:", fr_strerror());
300 if (ret == 0) opcode->vp_uint8 = rctx->fields.opcode;
301
302 /*
303 * Default to setting the authoritative bit if
304 * it's not been set by something already.
305 */
306 MEM((ret = fr_pair_update_by_da_parent(header, &authoritative, attr_authoritative_bit)) != -1);
307 fr_assert_msg(ret >= 0, "Failed to update authoritative_bit attribute %s:", fr_strerror());
308 if (ret == 0) authoritative->vp_bool = true;
309
310 return 0;
311}
312
313/** Add/update the rcode attribute based on the last rlm_rcode value
314 *
315 */
316static inline CC_HINT(always_inline)
317void dns_rcode_add(fr_pair_t **rcode, request_t *request, fr_value_box_t const **code)
318{
319 fr_value_box_t const *vb;
320 int ret;
321
322 if (!code || !*code) return;
323
324 vb = *code;
325
326 /*
327 * Don't override the user status
328 * code.
329 */
330 MEM((ret = fr_pair_update_by_da_parent(request->reply_ctx, rcode, attr_rcode)) >= 0);
331 if (ret == 0) {
332 if (unlikely(fr_value_box_copy(*rcode, &(*rcode)->data, vb) < 0)) {
333 RPEDEBUG("Failed copying rcode value");
334 return;
335 }
336 (*rcode)->data.enumv = (*rcode)->da; /* Hack, boxes should have their enumv field populated */
337 }
338}
339
340/** Store basic information from the request, and jump into the correct processing section
341 *
342 */
343RECV(request)
344{
345 process_rctx_t *rctx;
346
348
349 rctx = dns_fields_store(request);
350 if (!rctx) RETURN_UNLANG_INVALID;
351
352 return CALL_RECV_RCTX(generic, rctx);
353}
354
355/** Sets the DNS rcode after we get a result from the recv section
356 *
357 * Calls error processing sections as appropriate
358 */
359RESUME(recv_request)
360{
362 fr_process_state_t const *state;
363 fr_pair_t *rcode = NULL;
364
366
367 /*
368 * Pick the next state based on the response
369 */
370 UPDATE_STATE(reply);
371
372 /*
373 * Don't bother adding VPs if we're not going
374 * be responding to the client.
375 */
376 if (state->packet_type[RESULT_RCODE] == FR_DNS_DO_NOT_RESPOND) return CALL_RESUME(recv_generic);
377
378 /*
379 * Add an rcode based on the result of the `recv { ... }` section
380 */
381 dns_rcode_add(&rcode, request, state->dns_rcode[RESULT_RCODE]);
382
383 /*
384 * Call an appropriate error section if it's been set
385 * otherwise, just call the generic recv resume
386 * which'll call an appropriate send section.
387 */
388 if (rcode && (rcode->vp_uint8 < NUM_ELEMENTS(inst->sections.rcode)) &&
389 (inst->sections.rcode[rcode->vp_uint8])) {
390 return unlang_module_yield_to_section(RESULT_P, request,
391 inst->sections.rcode[rcode->vp_uint8],
393 /*
394 * We ignore everything from the error section
395 * it's only there for logging.
396 *
397 * Jump straight to the send function.
398 */
399 state->send,
400 NULL, 0, mctx->rctx);
401 }
402
403 /*
404 * Use that rcode to determine the processing section
405 */
406 return CALL_RESUME(recv_generic);
407}
408
409/** Set defaults in the response and values copied from the request like opcode and id
410 *
411 */
412RESUME(send_response)
413{
414 fr_process_state_t const *state;
415 fr_pair_t *vp;
416
417 UPDATE_STATE(reply);
418
419 /*
420 * Don't bother adding VPs if we're not going
421 * be responding to the client.
422 */
423 if (state->packet_type[RESULT_RCODE] == FR_DNS_DO_NOT_RESPOND) return CALL_RESUME(send_generic);
424
425 /*
426 * Add fields from the request back in,
427 * deferring to user specified values.
428 */
429 dns_fields_restore(request, talloc_get_type_abort(mctx->rctx, process_rctx_t));
430
431 /*
432 * Hack. This is because this stupid framework uses
433 * packet_type values to represent request and response
434 * packet types, and DNS uses the same values for
435 * both request and response packet types.
436 */
438 MEM(vp);
439 request->reply->code = vp->vp_uint32 = state->default_reply;
440
441 return CALL_RESUME(send_generic);
442}
443
444/** Entry point into the state machine
445 */
446static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
447{
448 fr_process_state_t const *state;
449
451
453 fr_assert(PROCESS_PACKET_CODE_VALID(request->packet->code));
454
455 request->component = "dns";
456 request->module = NULL;
457 fr_assert(request->proto_dict == dict_dns);
458
459 UPDATE_STATE(packet);
460
461 if (!state->recv) {
462 REDEBUG("Invalid packet type (%u)", request->packet->code);
464 }
465
466 return state->recv(p_result, mctx, request);
467}
468
469#define DNS_RCODE_COMMON \
470 .dns_rcode = { \
471 [RLM_MODULE_NOOP] = &enum_rcode_no_error, \
472 [RLM_MODULE_OK] = &enum_rcode_no_error, \
473 [RLM_MODULE_UPDATED] = &enum_rcode_no_error, \
474 [RLM_MODULE_HANDLED] = &enum_rcode_no_error, \
475 [RLM_MODULE_REJECT] = &enum_rcode_refused, \
476 [RLM_MODULE_FAIL] = &enum_rcode_server_failure, \
477 [RLM_MODULE_INVALID] = &enum_rcode_format_error, \
478 [RLM_MODULE_DISALLOW] = &enum_rcode_refused, \
479 [RLM_MODULE_NOTFOUND] = &enum_rcode_name_error, \
480 [RLM_MODULE_TIMEOUT] = &enum_rcode_server_failure, \
481 }
482
483static fr_process_state_t const process_state[] = {
484 [ FR_DNS_QUERY ] = {
486 .default_reply = FR_DNS_QUERY_RESPONSE,
487 .default_rcode = RLM_MODULE_NOOP,
488 .recv = recv_request,
489 .resume = resume_recv_request,
490 .section_offset = PROCESS_CONF_OFFSET(query),
491 },
494 .default_reply = FR_DNS_INVERSE_QUERY_RESPONSE,
495 .default_rcode = RLM_MODULE_NOOP,
496 .recv = recv_request,
497 .resume = resume_recv_request,
498 .section_offset = PROCESS_CONF_OFFSET(inverse_query),
499 },
500 [ FR_DNS_STATUS ] = {
502 .default_reply = FR_DNS_STATUS_RESPONSE,
503 .default_rcode = RLM_MODULE_NOOP,
504 .recv = recv_request,
505 .resume = resume_recv_request,
506 .section_offset = PROCESS_CONF_OFFSET(status),
507 },
508 [ FR_DNS_UPDATE ] = {
510 .default_reply = FR_DNS_UPDATE_RESPONSE,
511 .default_rcode = RLM_MODULE_NOOP,
512 .recv = recv_request,
513 .resume = resume_recv_request,
514 .section_offset = PROCESS_CONF_OFFSET(update),
515 },
518 .default_reply = FR_DNS_STATEFUL_OPERATION_RESPONSE,
519 .default_rcode = RLM_MODULE_NOOP,
520 .recv = recv_request,
521 .resume = resume_recv_request,
522 .section_offset = PROCESS_CONF_OFFSET(stateful_operation),
523 },
525 .default_reply = FR_DNS_QUERY,
526 .default_rcode = RLM_MODULE_NOOP,
527 .result_rcode = RLM_MODULE_OK,
528 .send = send_generic,
529 .resume = resume_send_response,
530 .section_offset = PROCESS_CONF_OFFSET(query_response),
531 },
532
534 .default_reply = FR_DNS_QUERY,
535 .default_rcode = RLM_MODULE_NOOP,
536 .result_rcode = RLM_MODULE_OK,
537 .send = send_generic,
538 .resume = resume_send_response,
539 .section_offset = PROCESS_CONF_OFFSET(inverse_query_response),
540 },
541
543 .default_reply = FR_DNS_STATUS,
544 .default_rcode = RLM_MODULE_NOOP,
545 .result_rcode = RLM_MODULE_OK,
546 .send = send_generic,
547 .resume = resume_send_response,
548 .section_offset = PROCESS_CONF_OFFSET(status_response),
549 },
550
552 .default_reply = FR_DNS_UPDATE,
553 .default_rcode = RLM_MODULE_NOOP,
554 .result_rcode = RLM_MODULE_OK,
555 .send = send_generic,
556 .resume = resume_send_response,
557 .section_offset = PROCESS_CONF_OFFSET(update_response),
558 },
559
561 .default_reply = FR_DNS_STATEFUL_OPERATION,
562 .default_rcode = RLM_MODULE_NOOP,
563 .result_rcode = RLM_MODULE_OK,
564 .send = send_generic,
565 .resume = resume_send_response,
566 .section_offset = PROCESS_CONF_OFFSET(stateful_operation_response),
567 },
568
570 .packet_type = {
574
581 },
582 .default_rcode = RLM_MODULE_NOOP,
583 .result_rcode = RLM_MODULE_HANDLED,
584 .send = send_generic,
585 .resume = resume_send_response,
586 .section_offset = PROCESS_CONF_OFFSET(do_not_respond),
587 },
588};
589
592 .common = {
593 .magic = MODULE_MAGIC_INIT,
594 .name = "dns",
596 MODULE_RCTX(process_rctx_t)
597 },
598 .process = mod_process,
599 .compile_list = compile_list,
600 .dict = &dict_dns,
601 .packet_type = &attr_packet_type
602};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
#define unlikely(_x)
Definition build.h:455
#define NUM_ELEMENTS(_t)
Definition build.h:406
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
Definition debug.h:243
#define MEM(x)
Definition debug.h:38
fr_value_box_t const ** out
Enumeration value.
Definition dict.h:281
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:292
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:305
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:311
Specifies an attribute which must be present for the module to function.
Definition dict.h:291
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:304
Specifies a value which must be present for the module to function.
Definition dict.h:280
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
TALLOC_CTX * unlang_interpret_frame_talloc_ctx(request_t *request)
Get a talloc_ctx which is valid only for this frame.
Definition interpret.c:2053
fr_dict_attr_t const * attr_packet_type
Definition base.c:91
#define RPEDEBUG(fmt,...)
Definition log.h:393
unsigned short uint16_t
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_BOOL
A truth value.
unsigned char uint8_t
unlang_mod_actions_t const mod_actions_authorize
Definition mod_action.c:45
unlang_mod_actions_t const mod_actions_postauth
Definition mod_action.c:92
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
Definition mod_action.h:69
module_instance_t const * mi
Instance of the module being instantiated.
Definition module_ctx.h:42
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
Definition pair.c:707
int fr_pair_update_by_da_parent(fr_pair_t *parent, fr_pair_t **out, fr_dict_attr_t const *da)
Return the first fr_pair_t matching the fr_dict_attr_t or alloc a new fr_pair_t and its subtree (and ...
Definition pair.c:1602
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition base.c:168
static const virtual_server_compile_t compile_list[]
Definition base.c:192
static fr_process_state_t const process_state[]
Definition base.c:68
#define PROCESS_PACKET_CODE_VALID
Definition base.c:64
RECV(for_any_server)
Validate a solicit/rebind/confirm message.
Definition base.c:348
fr_dict_attr_autoload_t process_dns_dict_attr[]
Definition base.c:54
CONF_SECTION * stateful_operation_response
Definition base.c:96
fr_dict_autoload_t process_dns_dict[]
Definition base.c:40
#define ERROR_SECTION(_name, _number)
uint64_t nothing
Definition base.c:82
static fr_value_box_t const * enum_rcode_server_failure
Definition base.c:67
static fr_dict_attr_t const * attr_authoritative_bit
Definition base.c:51
CONF_SECTION * status
Definition base.c:91
static void dns_rcode_add(fr_pair_t **rcode, request_t *request, fr_value_box_t const **code)
Add/update the rcode attribute based on the last rlm_rcode value.
Definition base.c:317
CONF_SECTION * inverse_query_response
Definition base.c:90
CONF_SECTION * query_response
Definition base.c:88
CONF_SECTION * stateful_operation
Definition base.c:95
static int dns_fields_restore(request_t *request, process_rctx_t *rctx)
Copy values from the request header back into the response.
Definition base.c:267
static fr_dict_attr_t const * attr_opcode
Definition base.c:49
static fr_value_box_t const * enum_rcode_refused
Definition base.c:69
static fr_dict_attr_t const * attr_response_bit
Definition base.c:48
static fr_value_box_t const * enum_rcode_no_error
Definition base.c:65
CONF_SECTION * query
Request/response sections.
Definition base.c:87
uint8_t opcode
Opcode, what type of query this is.
Definition base.c:115
static fr_dict_attr_t const * attr_id
Definition base.c:47
CONF_SECTION * inverse_query
Definition base.c:89
#define FR_DNS_RCODE_MAX
Update this if new rcodes are added.
Definition base.c:35
fr_dict_enum_autoload_t process_dns_dict_enum[]
Definition base.c:72
process_dns_sections_t sections
Definition base.c:108
static fr_value_box_t const * enum_rcode_name_error
Definition base.c:68
uint16_t id
Identity of the request.
Definition base.c:114
#define DNS_RCODE_COMMON
Definition base.c:469
static fr_dict_t const * dict_dns
Definition base.c:37
CONF_SECTION * update_response
Definition base.c:94
CONF_SECTION * update
Definition base.c:93
static process_rctx_t * dns_fields_store(request_t *request)
Keep a copy of header fields to prevent them being tampered with.
Definition base.c:226
static fr_value_box_t const * enum_rcode_format_error
Definition base.c:66
static fr_dict_attr_t const * attr_header
Definition base.c:46
CONF_SECTION * status_response
Definition base.c:92
CONF_SECTION * do_not_respond
Definition base.c:104
fr_process_module_t process_dns
Definition base.c:591
static fr_dict_attr_t const * attr_rcode
Definition base.c:50
Records fields from the original request so we have a known good copy.
Definition base.c:113
#define PROCESS_TRACE
Trace each state function as it's entered.
Definition process.h:55
#define PROCESS_CONF_OFFSET(_x)
Definition process.h:79
module_t common
Common fields for all loadable modules.
Common public symbol definition for all process modules.
@ FR_DNS_DO_NOT_RESPOND
Definition dns.h:99
@ FR_DNS_STATEFUL_OPERATION_RESPONSE
Definition dns.h:97
@ FR_DNS_UPDATE_RESPONSE
Definition dns.h:96
@ FR_DNS_STATEFUL_OPERATION
Definition dns.h:89
@ FR_DNS_QUERY
Definition dns.h:84
@ FR_DNS_QUERY_RESPONSE
Definition dns.h:92
@ FR_DNS_STATUS_RESPONSE
Definition dns.h:94
@ FR_DNS_INVERSE_QUERY
Definition dns.h:85
@ FR_DNS_STATUS
Definition dns.h:86
@ FR_DNS_INVERSE_QUERY_RESPONSE
Definition dns.h:93
@ FR_DNS_UPDATE
Definition dns.h:88
#define fr_assert(_expr)
Definition rad_assert.h:37
#define REDEBUG(fmt,...)
#define RETURN_UNLANG_INVALID
Definition rcode.h:66
#define RETURN_UNLANG_FAIL
Definition rcode.h:63
@ RLM_MODULE_INVALID
The module considers the request invalid.
Definition rcode.h:51
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:49
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:48
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:52
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:47
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
Definition rcode.h:56
@ RLM_MODULE_NOTFOUND
User not found.
Definition rcode.h:53
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:55
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:54
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
Definition rcode.h:50
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:39
void * data
Module's instance data.
Definition module.h:293
#define MODULE_RCTX(_ctype)
Definition module.h:259
#define MODULE_INST(_ctype)
Definition module.h:257
#define pair_update_reply(_attr, _da)
Return or allocate a fr_pair_t in the reply list.
Definition pair.h:129
unlang_action_t unlang_module_yield_to_section(unlang_result_t *p_result, request_t *request, CONF_SECTION *subcs, rlm_rcode_t default_rcode, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
Definition module.c:236
eap_aka_sim_process_conf_t * inst
#define RESUME(_x)
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
#define talloc_get_type_abort_const
Definition talloc.h:117
void * state
Definition testlib.c:46
char const * fr_strerror(void)
Get the last library error.
Definition strerror.c:558
int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src)
Copy value data verbatim duplicating any buffers.
Definition value.c:4416
section_name_t const * section
Identifier for the section.
#define COMPILE_TERMINATOR
Processing sections which are allowed in this virtual server.