The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
proto_dns.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: 3dacf56f5ada77aaa9960207f4b0cb0b754a257a $
19  * @file proto_dns.c
20  * @brief DHCPV6 master protocol handler.
21  *
22  * @copyright 2020 Network RADIUS SAS (legal@networkradius.com)
23  */
24 #define LOG_PREFIX "proto_dns"
25 
26 #include <freeradius-devel/io/listen.h>
27 #include <freeradius-devel/server/module_rlm.h>
28 #include <freeradius-devel/util/debug.h>
29 #include "proto_dns.h"
30 
31 extern fr_app_t proto_dns;
32 static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
33 static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
34 
35 static const conf_parser_t priority_config[] = {
37  .func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = channel_packet_priority, .len = &channel_packet_priority_len }, .dflt = "normal" },
39 };
40 
41 
42 static conf_parser_t const limit_config[] = {
43  { FR_CONF_OFFSET("idle_timeout", proto_dns_t, io.idle_timeout), .dflt = "30.0" } ,
44 
45  { FR_CONF_OFFSET("max_connections", proto_dns_t, io.max_connections), .dflt = "1024" } ,
46 
47  /*
48  * For performance tweaking. NOT for normal humans.
49  */
50  { FR_CONF_OFFSET("max_packet_size", proto_dns_t, max_packet_size) } ,
51  { FR_CONF_OFFSET("num_messages", proto_dns_t, num_messages) } ,
52  { FR_CONF_POINTER("priority", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) priority_config },
53 
55 };
56 
57 /** How to parse a DNS listen section
58  *
59  */
60 static conf_parser_t const proto_dns_config[] = {
61  { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_dns_t, allowed_types), .func = type_parse },
62  { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dns_t, io.submodule),
63  .func = transport_parse },
64 
65  { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
66 
68 };
69 
70 static fr_dict_t const *dict_dns;
71 
74  { .out = &dict_dns, .proto = "dns" },
75  { NULL }
76 };
77 
79 
82  { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_dns},
83  { NULL }
84 };
85 
86 /** Wrapper around dl_instance which translates the packet-type into a submodule name
87  *
88  * @param[in] ctx to allocate data in (instance of proto_dns).
89  * @param[out] out Where to write a dl_module_inst_t containing the module handle and instance.
90  * @param[in] parent Base structure address.
91  * @param[in] ci #CONF_PAIR specifying the name of the type module.
92  * @param[in] rule unused.
93  * @return
94  * - 0 on success.
95  * - -1 on failure.
96  */
97 static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
98  CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
99 {
100  proto_dns_t *inst = talloc_get_type_abort(parent, proto_dns_t);
102  CONF_PAIR *cp;
103  char const *value;
104 
105  cp = cf_item_to_pair(ci);
106  value = cf_pair_value(cp);
107 
109  if (!dv || (dv->value->vb_uint32 >= FR_DNS_CODE_MAX)) {
110  cf_log_err(ci, "Unknown DNS packet type '%s'", value);
111  return -1;
112  }
113 
114  inst->allowed[dv->value->vb_uint32] = true;
115  *((char const **) out) = value;
116 
117  return 0;
118 }
119 
120 /** Wrapper around dl_instance
121  *
122  * @param[in] ctx to allocate data in (instance of proto_dns).
123  * @param[out] out Where to write a dl_module_inst_t containing the module handle and instance.
124  * @param[in] parent Base structure address.
125  * @param[in] ci #CONF_PAIR specifying the name of the type module.
126  * @param[in] rule unused.
127  * @return
128  * - 0 on success.
129  * - -1 on failure.
130  */
131 static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
132  CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
133 {
134  char const *name = cf_pair_value(cf_item_to_pair(ci));
135  dl_module_inst_t *parent_inst;
136  proto_dns_t *inst;
137  CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
138  CONF_SECTION *transport_cs;
139  dl_module_inst_t *dl_mod_inst;
140 
141  transport_cs = cf_section_find(listen_cs, name, NULL);
142 
143  /*
144  * Allocate an empty section if one doesn't exist
145  * this is so defaults get parsed.
146  */
147  if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
148 
149  parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_dns"));
150  fr_assert(parent_inst);
151 
152  /*
153  * Set the allowed codes so that we can compile them as
154  * necessary.
155  */
156  inst = talloc_get_type_abort(parent_inst->data, proto_dns_t);
157  inst->io.transport = name;
158 
159  if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
160  DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
161  if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
162  talloc_free(dl_mod_inst);
163  return -1;
164  }
165  *((dl_module_inst_t **)out) = dl_mod_inst;
166 
167  return 0;
168 }
169 
170 /** Decode the packet
171  *
172  */
173 static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
174 {
175  fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
176  fr_io_address_t const *address = track->address;
177  fr_client_t const *client;
178  fr_dns_packet_t const *packet = (fr_dns_packet_t const *) data;
179  fr_dns_ctx_t packet_ctx;
180 
181  /*
182  * Set the request dictionary so that we can do
183  * generic->protocol attribute conversions as
184  * the request runs through the server.
185  */
186  request->dict = dict_dns;
187 
188  RHEXDUMP3(data, data_len, "proto_dns decode packet");
189 
190  client = address->radclient;
191 
192  /*
193  * @todo -
194  */
195  request->packet->code = packet->opcode;
196  request->packet->id = fr_nbo_to_uint16(data);
197  request->reply->id = request->packet->id;
198 
199  request->packet->data = talloc_memdup(request->packet, data, data_len);
200  request->packet->data_len = data_len;
201 
202  packet_ctx.tmp_ctx = talloc(request, uint8_t);
203  packet_ctx.packet = request->packet->data;
204  packet_ctx.packet_len = data_len;
205  packet_ctx.lb = fr_dns_labels_get(request->packet->data, data_len, true);
206  fr_assert(packet_ctx.lb != NULL);
207 
208  /*
209  * Note that we don't set a limit on max_attributes here.
210  * That MUST be set and checked in the underlying
211  * transport, via a call to fr_dns_ok().
212  */
213  if (fr_dns_decode(request->request_ctx, &request->request_pairs,
214  request->packet->data, request->packet->data_len, &packet_ctx) < 0) {
215  talloc_free(packet_ctx.tmp_ctx);
216  RPEDEBUG("Failed decoding packet");
217  return -1;
218  }
219  talloc_free(packet_ctx.tmp_ctx);
220 
221  /*
222  * Set the rest of the fields.
223  */
224  request->client = UNCONST(fr_client_t *, client);
225 
226  request->packet->socket = address->socket;
227  fr_socket_addr_swap(&request->reply->socket, &address->socket);
228 
229  if (fr_packet_pairs_from_packet(request->request_ctx, &request->request_pairs, request->packet) < 0) {
230  RPEDEBUG("Failed decoding 'Net.*' packet");
231  return -1;
232  }
233 
234  REQUEST_VERIFY(request);
235 
236  return 0;
237 }
238 
239 static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
240 {
241 // fr_io_track_t *track = talloc_get_type_abort(request->async->packet_ctx, fr_io_track_t);
243  fr_dns_packet_t *original = (fr_dns_packet_t *) request->packet->data;
244  ssize_t data_len;
245  fr_dns_ctx_t packet_ctx;
246 
247  /*
248  * Process layer NAK, never respond, or "Do not respond".
249  */
250  if ((buffer_len == 1) ||
251  (request->reply->code == FR_DNS_DO_NOT_RESPOND) ||
252  (request->reply->code >= FR_DNS_CODE_MAX)) {
253 // track->do_not_respond = true;
254  return 1;
255  }
256 
257  if (buffer_len < DNS_HDR_LEN) {
258  REDEBUG("Output buffer is too small to hold a DNS packet.");
259  return -1;
260  }
261 
262  packet_ctx.tmp_ctx = talloc(request, uint8_t);
263  packet_ctx.packet = buffer;
264  packet_ctx.packet_len = buffer_len;
265 
266  packet_ctx.lb = fr_dns_labels_get(buffer, buffer_len, false);
267  fr_assert(packet_ctx.lb != NULL);
268 
269  data_len = fr_dns_encode(&FR_DBUFF_TMP(buffer, buffer_len), &request->reply_pairs, &packet_ctx);
270  talloc_free(packet_ctx.tmp_ctx);
271  if (data_len < 0) {
272  RPEDEBUG("Failed encoding DHCPv6 reply");
273  return -1;
274  }
275 
276  reply->id = original->id;
277  request->reply->data_len = data_len;
278 
279  RHEXDUMP3(buffer, data_len, "proto_dns encode packet");
280 
281  fr_packet_pairs_to_packet(request->reply, &request->reply_pairs);
282 
283  return data_len;
284 }
285 
286 static int mod_priority_set(void const *instance, uint8_t const *buffer, size_t buflen)
287 {
288  int opcode;
289  fr_dns_packet_t const *packet = (fr_dns_packet_t const *) buffer;
291 
292  if (buflen < DNS_HDR_LEN) return -1;
293 
294  opcode = packet->opcode;
295 
296  /*
297  * Disallowed packet
298  */
299  if (!inst->priorities[opcode]) return 0;
300 
301  if (!inst->allowed[opcode]) return -1;
302 
303  /*
304  * @todo - if we cared, we could also return -1 for "this
305  * is a bad packet". But that's really only for
306  * mod_inject, as we assume that app_io->read() always
307  * returns good packets.
308  */
309 
310  /*
311  * Return the configured priority.
312  */
313  return inst->priorities[opcode];
314 
315 }
316 
317 /** Open listen sockets/connect to external event source
318  *
319  * @param[in] instance Ctx data for this application.
320  * @param[in] sc to add our file descriptor to.
321  * @param[in] conf Listen section parsed to give us instance.
322  * @return
323  * - 0 on success.
324  * - -1 on failure.
325  */
326 static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
327 {
328  proto_dns_t *inst = talloc_get_type_abort(instance, proto_dns_t);
329 
330  inst->io.app = &proto_dns;
331  inst->io.app_instance = instance;
332 
333  return fr_master_io_listen(inst, &inst->io, sc,
334  inst->max_packet_size, inst->num_messages);
335 }
336 
337 /** Instantiate the application
338  *
339  * Instantiate I/O and type submodules.
340  *
341  * @return
342  * - 0 on success.
343  * - -1 on failure.
344  */
345 static int mod_instantiate(module_inst_ctx_t const *mctx)
346 {
347  proto_dns_t *inst = talloc_get_type_abort(mctx->inst->data, proto_dns_t);
348 
349  /*
350  * No IO module, it's an empty listener.
351  */
352  if (!inst->io.submodule) return 0;
353 
354  /*
355  * These configuration items are not printed by default,
356  * because normal people shouldn't be touching them.
357  */
358  if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
359 
360  if (!inst->num_messages) inst->num_messages = 256;
361 
362  FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
363  FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
364 
365  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 64);
366  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
367 
368  /*
369  * Instantiate the master io submodule
370  */
372 }
373 
374 /** Bootstrap the application
375  *
376  * Bootstrap I/O and type submodules.
377  *
378  * @return
379  * - 0 on success.
380  * - -1 on failure.
381  */
382 static int mod_bootstrap(module_inst_ctx_t const *mctx)
383 {
384  proto_dns_t *inst = talloc_get_type_abort(mctx->inst->data, proto_dns_t);
385 
386  /*
387  * Ensure that the server CONF_SECTION is always set.
388  */
389  inst->io.server_cs = cf_section_find_parent(mctx->inst->conf, "server", CF_IDENT_ANY);
390 
391  fr_assert(dict_dns != NULL);
392  fr_assert(attr_packet_type != NULL);
393 
394  /*
395  * No IO module, it's an empty listener.
396  */
397  if (!inst->io.submodule) return 0;
398 
399  /*
400  * These timers are usually protocol specific.
401  */
402  FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, >=, fr_time_delta_from_sec(1));
403  FR_TIME_DELTA_BOUND_CHECK("idle_timeout", inst->io.idle_timeout, <=, fr_time_delta_from_sec(600));
404 
405  /*
406  * Tell the master handler about the main protocol instance.
407  */
408  inst->io.app = &proto_dns;
409  inst->io.app_instance = inst;
410 
411  /*
412  * We will need this for dynamic clients and connected sockets.
413  */
414  inst->io.dl_inst = dl_module_instance_by_data(inst);
415  fr_assert(inst != NULL);
416 
417  /*
418  * Bootstrap the master IO handler.
419  */
421 }
422 
423 static int mod_load(void)
424 {
425  if (fr_dns_global_init() < 0) {
426  PERROR("Failed initialising protocol library");
427  return -1;
428  }
429 
430  return 0;
431 }
432 
433 static void mod_unload(void)
434 {
436 }
437 
439  .common = {
440  .magic = MODULE_MAGIC_INIT,
441  .name = "dns",
442  .config = proto_dns_config,
443  .inst_size = sizeof(proto_dns_t),
444 
445  .onload = mod_load,
446  .unload = mod_unload,
447 
448  .bootstrap = mod_bootstrap,
450  },
451  .dict = &dict_dns,
452  .open = mod_open,
453  .decode = mod_decode,
454  .encode = mod_encode,
455  .priority = mod_priority_set
456 };
static int const char char buffer[256]
Definition: acutest.h:574
module_t common
Common fields to all loadable modules.
Definition: app_io.h:34
module_t common
Common fields provided by all modules.
Definition: application.h:72
Describes a new application (protocol)
Definition: application.h:71
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition: build.h:165
#define UNUSED
Definition: build.h:313
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
Definition: cf_parse.c:1474
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition: cf_parse.h:486
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:256
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
Definition: cf_parse.h:497
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition: cf_parse.h:421
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:400
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:241
Defines a CONF_PAIR to C data type mapping.
Definition: cf_parse.h:563
Common header for all CONF_* types.
Definition: cf_priv.h:49
Configuration AVP similar to a fr_pair_t.
Definition: cf_priv.h:70
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition: cf_util.c:629
CONF_SECTION * cf_section_find_parent(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a parent CONF_SECTION with name1 and optionally name2.
Definition: cf_util.c:1039
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
Definition: cf_util.c:970
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition: cf_util.c:1511
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
Definition: cf_util.c:1680
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition: cf_util.c:649
#define cf_log_err(_cf, _fmt,...)
Definition: cf_util.h:265
#define cf_data_find(_cf, _type, _name)
Definition: cf_util.h:220
#define cf_parent(_cf)
Definition: cf_util.h:98
#define cf_section_alloc(_ctx, _parent, _name1, _name2)
Definition: cf_util.h:137
#define CF_IDENT_ANY
Definition: cf_util.h:78
size_t channel_packet_priority_len
Definition: channel.c:170
fr_table_num_sorted_t const channel_packet_priority[]
Definition: channel.c:164
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
Definition: dbuff.h:509
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition: dict.h:250
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition: dict.h:263
fr_value_box_t const * value
Enum value (what name maps to).
Definition: dict.h:213
fr_dict_enum_value_t * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Definition: dict_util.c:2992
Specifies an attribute which must be present for the module to function.
Definition: dict.h:249
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition: dict.h:262
Value of an enumerated attribute.
Definition: dict.h:209
Test enumeration values.
Definition: dict_test.h:92
int dl_module_instance(TALLOC_CTX *ctx, dl_module_inst_t **out, dl_module_inst_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name)
Load a module and parse its CONF_SECTION in one operation.
Definition: dl_module.c:552
char const * dl_module_inst_name_from_conf(CONF_SECTION *conf)
Avoid boilerplate when setting the module instance name.
Definition: dl_module.c:584
dl_module_inst_t const * dl_module_instance_by_data(void const *data)
Lookup a dl_module_inst_t via instance data.
Definition: dl_module.c:215
int dl_module_conf_parse(dl_module_inst_t *dl_inst, CONF_SECTION *conf)
Definition: dl_module.c:594
@ DL_MODULE_TYPE_SUBMODULE
Driver (or method in the case of EAP)
Definition: dl_module.h:71
void *_CONST data
Module instance's parsed configuration.
Definition: dl_module.h:165
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:65
CONF_SECTION *_CONST conf
Module's instance configuration.
Definition: dl_module.h:166
A module/inst tuple.
Definition: dl_module.h:162
fr_socket_t socket
src/dst ip and port.
Definition: base.h:336
fr_client_t const * radclient
old-style client definition
Definition: base.h:338
Describes a host allowed to send packets to the server.
Definition: client.h:77
#define PERROR(_fmt,...)
Definition: log.h:228
#define RPEDEBUG(fmt,...)
Definition: log.h:376
#define RHEXDUMP3(_data, _len, _fmt,...)
Definition: log.h:705
void fr_packet_pairs_to_packet(fr_packet_t *packet, fr_pair_list_t const *list)
Convert pairs to information in a packet.
Definition: packet.c:136
int fr_packet_pairs_from_packet(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_packet_t const *packet)
Allocate a "Net." struct with src/dst host and port.
Definition: packet.c:86
talloc_free(reap)
fr_app_io_t fr_master_app_io
Definition: master.c:3131
int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *sc, size_t default_message_size, size_t num_messages)
Definition: master.c:2923
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition: master.h:54
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
long int ssize_t
Definition: merged_model.c:24
unsigned char uint8_t
Definition: merged_model.c:30
#define MODULE_INST_CTX(_dl_inst)
Wrapper to create a module_inst_ctx_t as a compound literal.
Definition: module_ctx.h:153
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
Definition: module_ctx.h:52
Temporary structure to hold arguments for instantiation calls.
Definition: module_ctx.h:51
static uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
Read an unsigned 16bit integer from wire format (big endian)
Definition: nbo.h:137
static int mod_load(void)
Definition: proto_dns.c:423
static fr_dict_attr_t const * attr_packet_type
Definition: proto_dns.c:78
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
Definition: proto_dns.c:239
static conf_parser_t const limit_config[]
Definition: proto_dns.c:42
fr_app_t proto_dns
Definition: proto_dns.c:438
static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Bootstrap the application.
Definition: proto_dns.c:382
static void mod_unload(void)
Definition: proto_dns.c:433
fr_dict_attr_autoload_t proto_dns_dict_attr[]
Definition: proto_dns.c:81
static conf_parser_t const proto_dns_config[]
How to parse a DNS listen section.
Definition: proto_dns.c:60
static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
Definition: proto_dns.c:173
static fr_dict_t const * dict_dns
Definition: proto_dns.c:70
static const conf_parser_t priority_config[]
Definition: proto_dns.c:35
fr_dict_autoload_t proto_dns_dict[]
Definition: proto_dns.c:73
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
Definition: proto_dns.c:345
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
Definition: proto_dns.c:326
static int mod_priority_set(void const *instance, uint8_t const *buffer, size_t buflen)
Definition: proto_dns.c:286
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
An instance of a proto_dns listen section.
Definition: proto_dns.h:32
int fr_dns_global_init(void)
Resolve/cache attributes in the DNS dictionary.
Definition: base.c:404
void fr_dns_global_free(void)
Definition: base.c:426
fr_dns_labels_t * fr_dns_labels_get(uint8_t const *packet, size_t packet_len, bool init_mark)
Definition: base.c:375
ssize_t fr_dns_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len, fr_dns_ctx_t *packet_ctx)
Decode a DNS packet.
Definition: decode.c:265
ssize_t fr_dns_encode(fr_dbuff_t *dbuff, fr_pair_list_t *vps, fr_dns_ctx_t *encode_ctx)
Encode a DNS packet.
Definition: encode.c:454
size_t packet_len
Definition: dns.h:85
@ FR_DNS_DO_NOT_RESPOND
Definition: dns.h:108
@ FR_DNS_QUERY
Definition: dns.h:93
@ FR_DNS_CODE_MAX
Definition: dns.h:99
#define DNS_HDR_LEN
Definition: dns.h:141
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
Definition: dns.h:83
unsigned int opcode
Definition: dns.h:49
uint8_t const * packet
DNS labels can point anywhere in the packet :(.
Definition: dns.h:84
uint16_t id
Definition: dns.h:38
fr_dns_labels_t * lb
Definition: dns.h:86
#define REDEBUG(fmt,...)
Definition: radclient.h:52
static rs_t * conf
Definition: radsniff.c:53
#define REQUEST_VERIFY(_x)
Definition: request.h:275
static char const * name
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1312
The scheduler.
Definition: schedule.c:125
module_instantiate_t instantiate
Definition: module.h:146
module_instantiate_t bootstrap
Definition: module.h:145
static const uchar sc[16]
Definition: smbdes.c:115
if(!subtype_vp) goto fail
fr_assert(0)
eap_aka_sim_process_conf_t * inst
#define talloc_get_type_abort_const
Definition: talloc.h:270
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
Definition: time.h:588
static fr_slen_t parent
Definition: pair.h:844
static void fr_socket_addr_swap(fr_socket_t *dst, fr_socket_t const *src)
Swap src/dst information of a fr_socket_t.
Definition: socket.h:121
static fr_slen_t data
Definition: value.h:1259
static size_t char ** out
Definition: value.h:984