The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
proto_dns_udp.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: a02bdbc950d73816551abc23068c92c54a71ef1d $
19  * @file proto_dns_udp.c
20  * @brief DHCPv6 handler for UDP.
21  *
22  * @copyright 2020 Network RADIUS SAS (legal@networkradius.com)
23  */
24 #define LOG_PREFIX "proto_dns_udp"
25 
26 #include <freeradius-devel/server/protocol.h>
27 #include <freeradius-devel/server/cf_util.h>
28 #include <freeradius-devel/util/udp.h>
29 #include <freeradius-devel/util/table.h>
30 #include <freeradius-devel/util/trie.h>
31 #include <freeradius-devel/io/application.h>
32 #include <freeradius-devel/io/listen.h>
33 #include <freeradius-devel/io/schedule.h>
34 #include <freeradius-devel/protocol/dns/freeradius.internal.h>
35 #include "proto_dns.h"
36 
38 
39 typedef struct {
40  char const *name; //!< socket name
41  int sockfd;
42 
43  fr_io_address_t *connection; //!< for connected sockets.
44 
45  fr_stats_t stats; //!< statistics for this socket
47 
48 typedef struct {
49  CONF_SECTION *cs; //!< our configuration
50 
51  fr_ipaddr_t ipaddr; //!< IP address to listen on.
52 
53  char const *interface; //!< Interface to bind to.
54 
55  uint32_t recv_buff; //!< How big the kernel's receive buffer should be.
56 
57  uint32_t max_packet_size; //!< for message ring buffer.
58  uint32_t max_attributes; //!< Limit maximum decodable attributes.
59 
60  uint16_t port; //!< Port to listen on.
61 
62  bool recv_buff_is_set; //!< Whether we were provided with a receive
63  //!< buffer value.
64 
65  fr_client_list_t *clients; //!< local clients
66  fr_client_t *default_client; //!< default 0/0 client
67 
68  fr_trie_t *trie; //!< for parsed networks
69  fr_ipaddr_t *allow; //!< allowed networks for dynamic clients
70  fr_ipaddr_t *deny; //!< denied networks for dynamic clients
72 
73 
74 static const conf_parser_t networks_config[] = {
77 
79 };
80 
81 
82 static const conf_parser_t udp_listen_config[] = {
84  { FR_CONF_OFFSET_TYPE_FLAGS("ipv6addr", FR_TYPE_IPV6_ADDR, 0, proto_dns_udp_t, ipaddr) },
85  { FR_CONF_OFFSET_TYPE_FLAGS("ipv4addr", FR_TYPE_IPV4_ADDR, 0, proto_dns_udp_t, ipaddr) },
86 
87  { FR_CONF_OFFSET("interface", proto_dns_udp_t, interface) },
88 
89  { FR_CONF_OFFSET("port", proto_dns_udp_t, port), .dflt = "547" },
90  { FR_CONF_OFFSET_IS_SET("recv_buff", FR_TYPE_UINT32, 0, proto_dns_udp_t, recv_buff) },
91 
92  { FR_CONF_POINTER("networks", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) networks_config },
93 
94  { FR_CONF_OFFSET("max_packet_size", proto_dns_udp_t, max_packet_size), .dflt = "576" } ,
95  { FR_CONF_OFFSET("max_attributes", proto_dns_udp_t, max_attributes), .dflt = STRINGIFY(DNS_MAX_ATTRIBUTES) } ,
96 
98 };
99 
100 static fr_dict_t const *dict_dns;
101 
104  { .out = &dict_dns, .proto = "dns" },
105  { NULL }
106 };
107 
109 
112  { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_dns},
113 
114  { NULL }
115 };
116 
117 static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len,
118  size_t *leftover)
119 {
120 // proto_dns_udp_t const *inst = talloc_get_type_abort_const(li->app_io_instance, proto_dns_udp_t);
121  proto_dns_udp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_dns_udp_thread_t);
122  fr_io_address_t *address, **address_p;
123 
124  int flags;
125  ssize_t data_size;
126  size_t packet_len;
127  uint32_t xid;
128  fr_dns_packet_t *packet;
129  fr_dns_decode_fail_t reason;
130 
131  *leftover = 0; /* always for UDP */
132 
133  /*
134  * Where the addresses should go. This is a special case
135  * for proto_dns.
136  */
137  address_p = (fr_io_address_t **)packet_ctx;
138  address = *address_p;
139 
140  /*
141  * Tell udp_recv if we're connected or not.
142  */
143  flags = UDP_FLAGS_CONNECTED * (thread->connection != NULL);
144 
145  data_size = udp_recv(thread->sockfd, flags, &address->socket, buffer, buffer_len, recv_time_p);
146  if (data_size < 0) {
147  RATE_LIMIT_GLOBAL(PERROR, "Read error (%zd)", data_size);
148  return data_size;
149  }
150 
151  if ((size_t) data_size < DNS_HDR_LEN) {
152  RATE_LIMIT_GLOBAL(WARN, "Insufficient data - ignoring");
153  return 0;
154  }
155 
156  packet_len = data_size;
157 
158  /*
159  * We've seen a server reply to this port, but the giaddr
160  * is *not* our address. Drop it.
161  */
162  packet = (fr_dns_packet_t *) buffer;
163 
164  if (!fr_dns_packet_ok(buffer, packet_len, true, &reason)) {
165  RATE_LIMIT_GLOBAL(WARN, "Ignoring invalid DNS packet - %s",
166  fr_table_str_by_value(fr_dns_reason_fail_table, reason, "unknown"));
167  return 0;
168  }
169 
170  /*
171  * check packet code
172  */
173 
174  /*
175  * proto_dns sets the priority
176  */
177 
178  xid = fr_nbo_to_uint16(buffer);
179 
180  /*
181  * Print out what we received.
182  */
183  DEBUG2("Received %s ID %04x length %d %s", fr_dns_packet_names[packet->opcode], xid,
184  (int) packet_len, thread->name);
185 
186  return packet_len;
187 }
188 
189 static ssize_t mod_write(fr_listen_t *li, void *packet_ctx, UNUSED fr_time_t request_time,
190  uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
191 {
192 // proto_dns_udp_t const *inst = talloc_get_type_abort_const(li->app_io_instance, proto_dns_udp_t);
193  proto_dns_udp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_dns_udp_thread_t);
194 
195  fr_io_track_t *track = talloc_get_type_abort(packet_ctx, fr_io_track_t);
196  fr_socket_t socket;
197 
198  int flags;
199  ssize_t data_size;
200 
201  /*
202  * @todo - share a stats interface with the parent? or
203  * put the stats in the listener, so that proto_dns
204  * can update them, too.. <sigh>
205  */
206  thread->stats.total_responses++;
207 
208  flags = UDP_FLAGS_CONNECTED * (thread->connection != NULL);
209 
210  /*
211  * Send packets to the originator.
212  */
213  fr_socket_addr_swap(&socket, &track->address->socket);
214 
215  /*
216  * Figure out which kind of packet we're sending.
217  */
218  if (!thread->connection) {
219  // @todo - figure out where to send the packet
220  }
221 
222  /*
223  * proto_dns takes care of suppressing do-not-respond, etc.
224  */
225  data_size = udp_send(&socket, flags, buffer, buffer_len);
226 
227  /*
228  * This socket is dead. That's an error...
229  */
230  if (data_size <= 0) return data_size;
231 
232  return data_size;
233 }
234 
235 
236 static int mod_connection_set(fr_listen_t *li, fr_io_address_t *connection)
237 {
238  proto_dns_udp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_dns_udp_thread_t);
239 
240  thread->connection = connection;
241  return 0;
242 }
243 
244 
245 static void mod_network_get(void *instance, int *ipproto, bool *dynamic_clients, fr_trie_t const **trie)
246 {
247  proto_dns_udp_t *inst = talloc_get_type_abort(instance, proto_dns_udp_t);
248 
249  *ipproto = IPPROTO_UDP;
250  *dynamic_clients = false;
251  *trie = inst->trie;
252 }
253 
254 
255 /** Open a UDP listener for DHCPv6
256  *
257  */
258 static int mod_open(fr_listen_t *li)
259 {
261  proto_dns_udp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_dns_udp_thread_t);
262 
263  int sockfd, rcode;
264  fr_ipaddr_t ipaddr = inst->ipaddr;
265  uint16_t port = inst->port;
266 
267  li->fd = sockfd = fr_socket_server_udp(&inst->ipaddr, &port, "domain", true);
268  if (sockfd < 0) {
269  PERROR("Failed opening UDP socket");
270  error:
271  return -1;
272  }
273 
274  li->app_io_addr = fr_socket_addr_alloc_inet_src(li, IPPROTO_UDP, 0, &inst->ipaddr, port);
275 
276  /*
277  * Set SO_REUSEPORT before bind, so that all packets can
278  * listen on the same destination IP address.
279  */
280  if (1) {
281  int on = 1;
282 
283  if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0) {
284  ERROR("Failed to set socket 'reuseport': %s", fr_syserror(errno));
285  close(sockfd);
286  return -1;
287  }
288  }
289 
290  /*
291  * SUID up is really only needed if interface is set, OR port <1024.
292  */
293  rad_suid_up();
294  rcode = fr_socket_bind(sockfd, inst->interface, &ipaddr, &port);
295  rad_suid_down();
296  if (rcode < 0) {
297  PERROR("Failed binding socket");
298  close(sockfd);
299  goto error;
300  }
301 
302  thread->sockfd = sockfd;
303 
304  fr_assert((cf_parent(inst->cs) != NULL) && (cf_parent(cf_parent(inst->cs)) != NULL)); /* listen { ... } */
305 
306  thread->name = fr_app_io_socket_name(thread, &proto_dns_udp,
307  NULL, 0,
308  &inst->ipaddr, inst->port,
309  inst->interface);
310  return 0;
311 }
312 
313 
314 /** Set the file descriptor for this socket.
315  *
316  */
317 static int mod_fd_set(fr_listen_t *li, int fd)
318 {
320  proto_dns_udp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_dns_udp_thread_t);
321 
322  thread->sockfd = fd;
323 
324  thread->name = fr_app_io_socket_name(thread, &proto_dns_udp,
325  &thread->connection->socket.inet.src_ipaddr, thread->connection->socket.inet.src_port,
326  &inst->ipaddr, inst->port,
327  inst->interface);
328 
329  return 0;
330 }
331 
332 
333 static char const *mod_name(fr_listen_t *li)
334 {
335  proto_dns_udp_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_dns_udp_thread_t);
336 
337  return thread->name;
338 }
339 
340 
341 static int mod_bootstrap(module_inst_ctx_t const *mctx)
342 {
343  proto_dns_udp_t *inst = talloc_get_type_abort(mctx->inst->data, proto_dns_udp_t);
344  CONF_SECTION *conf = mctx->inst->conf;
345  size_t num;
346  CONF_SECTION *server_cs;
347  fr_client_t *client;
348 
349  inst->cs = conf;
350 
351  /*
352  * Complain if no "ipaddr" is set.
353  */
354  if (inst->ipaddr.af == AF_UNSPEC) {
355  if (!inst->interface) {
356  cf_log_err(conf, "No 'ipaddr' was specified in the 'udp' section");
357  return -1;
358  }
359 
360  /*
361  * If there's a named interface, maybe we can
362  * find a link-local address for it. If so, just
363  * use that.
364  */
365  if (inst->interface &&
366  (fr_interface_to_ipaddr(inst->interface, &inst->ipaddr, AF_INET, true) < 0)) {
367  cf_log_err(conf, "No 'ipaddr' specified, and we cannot determine one for interface '%s'",
368  inst->interface);
369  return -1;
370  }
371  }
372 
373  if (inst->recv_buff_is_set) {
374  FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
375  FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
376  }
377 
378  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 64);
379  FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
380 
381  /*
382  * Parse and create the trie for dynamic clients, even if
383  * there's no dynamic clients.
384  */
385  num = talloc_array_length(inst->allow);
386  if (num) {
387  inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
388  if (!inst->trie) {
389  cf_log_perr(conf, "Failed creating list of networks");
390  return -1;
391  }
392  }
393 
394  server_cs = cf_section_find_parent(inst->cs, "server", CF_IDENT_ANY);
395  fr_assert(server_cs != NULL);
396 
397  /*
398  * Look up local clients, if they exist.
399  *
400  * @todo - ensure that we only parse clients which are
401  * for IPPROTO_UDP, and don't require a "secret".
402  */
403  if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
404  inst->clients = client_list_parse_section(server_cs, IPPROTO_UDP, false);
405  if (!inst->clients) {
406  cf_log_err(conf, "Failed creating local clients");
407  return -1;
408  }
409  }
410 
411  /*
412  * Create a fake client.
413  */
414  client = inst->default_client = talloc_zero(inst, fr_client_t);
415  if (!inst->default_client) return 0;
416 
417  client->ipaddr = (fr_ipaddr_t ) {
418  .af = AF_INET6,
419  };
420 
421  client->src_ipaddr = client->ipaddr;
422 
423  client->longname = client->shortname = client->secret = talloc_strdup(client, "default");
424  client->nas_type = talloc_strdup(client, "other");
425 
426  return 0;
427 }
428 
430 {
432 
433  /*
434  * Prefer local clients.
435  */
436  if (inst->clients) {
437  fr_client_t *client;
438 
439  client = client_find(inst->clients, ipaddr, ipproto);
440  if (client) return client;
441  }
442 
443  return inst->default_client;
444 }
445 
447  .common = {
448  .magic = MODULE_MAGIC_INIT,
449  .name = "dns_udp",
450  .config = udp_listen_config,
451  .inst_size = sizeof(proto_dns_udp_t),
452  .thread_inst_size = sizeof(proto_dns_udp_thread_t),
453  .bootstrap = mod_bootstrap
454  },
455  .default_message_size = 576,
456  .track_duplicates = false,
457 
458  .open = mod_open,
459  .read = mod_read,
460  .write = mod_write,
461  .fd_set = mod_fd_set,
462  .connection_set = mod_connection_set,
463  .network_get = mod_network_get,
464  .client_find = mod_client_find,
465  .get_name = mod_name,
466 };
static int const char char buffer[256]
Definition: acutest.h:574
char const * fr_app_io_socket_name(TALLOC_CTX *ctx, fr_app_io_t const *app_io, fr_ipaddr_t const *src_ipaddr, int src_port, fr_ipaddr_t const *dst_ipaddr, int dst_port, char const *interface)
Definition: app_io.c:32
module_t common
Common fields to all loadable modules.
Definition: app_io.h:34
Public structure describing an I/O path for a protocol.
Definition: app_io.h:33
#define STRINGIFY(x)
Definition: build.h:195
#define UNUSED
Definition: build.h:313
#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_IS_SET(_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:282
@ CONF_FLAG_MULTI
CONF_PAIR can have multiple copies.
Definition: cf_parse.h:420
@ 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
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
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_next(CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
Return the next matching section.
Definition: cf_util.c:991
#define cf_log_err(_cf, _fmt,...)
Definition: cf_util.h:265
#define cf_parent(_cf)
Definition: cf_util.h:98
#define cf_log_perr(_cf, _fmt,...)
Definition: cf_util.h:272
#define CF_IDENT_ANY
Definition: cf_util.h:78
#define ERROR(fmt,...)
Definition: dhcpclient.c:41
static int sockfd
Definition: dhcpclient.c:56
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
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
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
int fr_interface_to_ipaddr(char const *interface, fr_ipaddr_t *ipaddr, int af, bool link_local)
Definition: inet.c:1559
int af
Address family.
Definition: inet.h:64
IPv4/6 prefix.
Definition: merged_model.c:272
fr_socket_t socket
src/dst ip and port.
Definition: base.h:336
fr_socket_t * app_io_addr
for tracking duplicate sockets
Definition: listen.h:35
void const * app_io_instance
I/O path configuration context.
Definition: listen.h:32
void * thread_instance
thread / socket context
Definition: listen.h:33
int fd
file descriptor for this socket - set by open
Definition: listen.h:28
fr_ipaddr_t ipaddr
IPv4/IPv6 address of the host.
Definition: client.h:80
char const * secret
Secret PSK.
Definition: client.h:87
fr_ipaddr_t src_ipaddr
IPv4/IPv6 address to send responses from (family must match ipaddr).
Definition: client.h:81
char const * nas_type
Type of client (arbitrary).
Definition: client.h:99
char const * longname
Client identifier.
Definition: client.h:84
char const * shortname
Client nickname.
Definition: client.h:85
Describes a host allowed to send packets to the server.
Definition: client.h:77
#define PERROR(_fmt,...)
Definition: log.h:228
#define RATE_LIMIT_GLOBAL(_log, _fmt,...)
Rate limit messages using a global limiting entry.
Definition: log.h:641
void rad_suid_up(void)
Definition: util.c:894
void rad_suid_down(void)
Definition: util.c:898
ssize_t udp_recv(int sockfd, int flags, fr_socket_t *socket_out, void *data, size_t data_len, fr_time_t *when)
Read a UDP packet.
Definition: udp.c:145
int udp_send(fr_socket_t const *sock, int flags, void *data, size_t data_len)
Send a packet via a UDP socket.
Definition: udp.c:43
fr_trie_t * fr_master_io_network(TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ipaddr_t *deny)
Create a trie from arrays of allow / deny IP addresses.
Definition: master.c:2744
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition: master.h:54
unsigned short uint16_t
Definition: merged_model.c:31
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
Definition: merged_model.c:86
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
Definition: merged_model.c:92
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
Definition: merged_model.c:88
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
Definition: merged_model.c:91
unsigned int uint32_t
Definition: merged_model.c:33
long int ssize_t
Definition: merged_model.c:24
unsigned char uint8_t
Definition: merged_model.c:30
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
uint32_t max_attributes
Limit maximum decodable attributes.
Definition: proto_dns_udp.c:58
static fr_dict_attr_t const * attr_packet_type
fr_io_address_t * connection
for connected sockets.
Definition: proto_dns_udp.c:43
static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
uint16_t port
Port to listen on.
Definition: proto_dns_udp.c:60
static fr_client_t * mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, int ipproto)
CONF_SECTION * cs
our configuration
Definition: proto_dns_udp.c:49
fr_client_list_t * clients
local clients
Definition: proto_dns_udp.c:65
fr_ipaddr_t * allow
allowed networks for dynamic clients
Definition: proto_dns_udp.c:69
fr_client_t * default_client
default 0/0 client
Definition: proto_dns_udp.c:66
fr_app_io_t proto_dns_udp
char const * name
socket name
Definition: proto_dns_udp.c:40
fr_stats_t stats
statistics for this socket
Definition: proto_dns_udp.c:45
bool recv_buff_is_set
Whether we were provided with a receive buffer value.
Definition: proto_dns_udp.c:62
static int mod_bootstrap(module_inst_ctx_t const *mctx)
fr_dict_attr_autoload_t proto_dns_udp_dict_attr[]
uint32_t max_packet_size
for message ring buffer.
Definition: proto_dns_udp.c:57
char const * interface
Interface to bind to.
Definition: proto_dns_udp.c:53
static int mod_open(fr_listen_t *li)
Open a UDP listener for DHCPv6.
static const conf_parser_t udp_listen_config[]
Definition: proto_dns_udp.c:82
fr_ipaddr_t ipaddr
IP address to listen on.
Definition: proto_dns_udp.c:51
fr_ipaddr_t * deny
denied networks for dynamic clients
Definition: proto_dns_udp.c:70
static char const * mod_name(fr_listen_t *li)
static const conf_parser_t networks_config[]
Definition: proto_dns_udp.c:74
fr_dict_autoload_t proto_dns_udp_dict[]
fr_trie_t * trie
for parsed networks
Definition: proto_dns_udp.c:68
uint32_t recv_buff
How big the kernel's receive buffer should be.
Definition: proto_dns_udp.c:55
static void mod_network_get(void *instance, int *ipproto, bool *dynamic_clients, fr_trie_t const **trie)
static fr_dict_t const * dict_dns
static int mod_connection_set(fr_listen_t *li, fr_io_address_t *connection)
static int mod_fd_set(fr_listen_t *li, int fd)
Set the file descriptor for this socket.
static ssize_t mod_write(fr_listen_t *li, void *packet_ctx, UNUSED fr_time_t request_time, uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
char const * fr_dns_packet_names[FR_DNS_CODE_MAX]
Definition: base.c:68
bool fr_dns_packet_ok(uint8_t const *packet, size_t packet_len, bool query, fr_dns_decode_fail_t *reason)
Definition: base.c:100
fr_table_num_ordered_t fr_dns_reason_fail_table[]
Definition: decode.c:387
#define DNS_HDR_LEN
Definition: dns.h:141
unsigned int opcode
Definition: dns.h:49
fr_dns_decode_fail_t
Definition: dns.h:111
#define DNS_MAX_ATTRIBUTES
Definition: dns.h:35
static int ipproto
Definition: radclient-ng.c:94
#define DEBUG2(fmt,...)
Definition: radclient.h:43
#define WARN(fmt,...)
Definition: radclient.h:47
static rs_t * conf
Definition: radsniff.c:53
fr_uint_t total_responses
Definition: stats.h:43
int fr_socket_server_udp(fr_ipaddr_t const *src_ipaddr, uint16_t *src_port, char const *port_name, bool async)
Open an IPv4/IPv6 unconnected UDP socket.
Definition: socket.c:867
int fr_socket_bind(int sockfd, char const *ifname, fr_ipaddr_t *src_ipaddr, uint16_t *src_port)
Bind a UDP/TCP v4/v6 socket to a given ipaddr src port, and interface.
Definition: socket.c:229
fr_client_t * client_find(fr_client_list_t const *clients, fr_ipaddr_t const *ipaddr, int proto)
Definition: client.c:375
fr_client_list_t * client_list_parse_section(CONF_SECTION *section, int proto, TLS_UNUSED bool tls_required)
Definition: client.c:467
Group of clients.
Definition: client.c:52
fr_assert(0)
eap_aka_sim_process_conf_t * inst
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
Definition: syserror.c:243
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
Definition: table.h:253
#define talloc_get_type_abort_const
Definition: talloc.h:270
"server local" time.
Definition: time.h:69
#define UDP_FLAGS_CONNECTED
Definition: udp.h:38
close(uq->fd)
static fr_socket_t * fr_socket_addr_alloc_inet_src(TALLOC_CTX *ctx, int proto, int ifindex, fr_ipaddr_t const *ipaddr, int port)
A variant of fr_socket_addr_init_inet_src will also allocates a fr_socket_t.
Definition: socket.h:244
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
Holds information necessary for binding or connecting to a socket.
Definition: socket.h:63