Coverage Report

Created: 2026-04-12 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/freeradius-server/src/lib/io/app_io.c
Line
Count
Source
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: c8fd04bb5e374d231bcdcfa4d6e8069225f6f952 $
19
 * @file io/app_io.c
20
 * @brief APP IO utility functions
21
 *
22
 * @copyright 2018 Alan DeKok (aland@freeradius.org)
23
 */
24
#include <freeradius-devel/io/base.h>
25
#include <freeradius-devel/io/application.h>
26
#include <freeradius-devel/util/syserror.h>
27
#include <freeradius-devel/util/debug.h>
28
29
/*
30
 *  @todo - include the name of the virtual server, too.
31
 */
32
char const *fr_app_io_socket_name(TALLOC_CTX *ctx, fr_app_io_t const *app_io,
33
          fr_ipaddr_t const *src_ipaddr, int src_port,
34
          fr_ipaddr_t const *dst_ipaddr, int dst_port,
35
          char const *interface)
36
0
{
37
0
  char        dst_buf[128], src_buf[128];
38
39
  /*
40
   *  Get our name.
41
   */
42
0
  if (fr_ipaddr_is_inaddr_any(dst_ipaddr)) {
43
0
    if (dst_ipaddr->af == AF_INET) {
44
0
      strlcpy(dst_buf, "*", sizeof(dst_buf));
45
0
    } else {
46
0
      fr_assert(dst_ipaddr->af == AF_INET6);
47
0
      strlcpy(dst_buf, "::", sizeof(dst_buf));
48
0
    }
49
0
  } else {
50
0
    fr_value_box_print(&FR_SBUFF_OUT(dst_buf, sizeof(dst_buf)), fr_box_ipaddr(*dst_ipaddr), NULL);
51
0
  }
52
53
0
  if (src_ipaddr) fr_value_box_print(&FR_SBUFF_OUT(src_buf, sizeof(src_buf)), fr_box_ipaddr(*src_ipaddr), NULL);
54
55
0
  if (!interface) {
56
0
    if (!src_ipaddr) {
57
0
      return talloc_typed_asprintf(ctx, "%s server %s port %u",
58
0
                 app_io->common.name, dst_buf, dst_port);
59
0
    }
60
61
62
0
    return talloc_typed_asprintf(ctx, "%s from client %s port %u to server %s port %u",
63
0
               app_io->common.name, src_buf, src_port, dst_buf, dst_port);
64
0
  }
65
66
0
  if (!src_ipaddr) {
67
0
    return talloc_typed_asprintf(ctx, "%s server %s port %u on interface %s",
68
0
               app_io->common.name, dst_buf, dst_port, interface);
69
0
    }
70
71
72
0
    return talloc_typed_asprintf(ctx, "%s from client %s port %u to server %s port %u on interface %s",
73
0
               app_io->common.name, src_buf, src_port, dst_buf, dst_port, interface);
74
0
}