The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
listen.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /**
19  * $Id: c3f60b1c0f9dae95bf38c0b619ecfe418fc2ffc7 $
20  *
21  * @file lib/server/listen.h
22  * @brief Listener API. Binds sockets to protocol encoders/decoders.
23  *
24  * @copyright 2015 The FreeRADIUS server project
25  */
26 RCSIDH(listen_h, "$Id: c3f60b1c0f9dae95bf38c0b619ecfe418fc2ffc7 $")
27 
28 #include <freeradius-devel/server/client.h>
29 #include <freeradius-devel/server/socket.h>
30 #include <freeradius-devel/server/stats.h>
31 #include <freeradius-devel/util/event.h>
32 #include <freeradius-devel/util/packet.h>
33 #include <freeradius-devel/util/pcap.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Types of listeners.
41  *
42  * Ordered by priority!
43  */
44 typedef enum RAD_LISTEN_TYPE {
56 
57 typedef enum RAD_LISTEN_STATUS {
64 
65 typedef struct rad_protocol_s rad_protocol_t;
66 typedef struct rad_listen rad_listen_t;
67 
68 typedef int (*rad_listen_recv_t)(rad_listen_t *);
70 typedef int (*rad_listen_error_t)(rad_listen_t *, int);
71 typedef int (*rad_listen_print_t)(rad_listen_t const *, char *, size_t);
72 typedef void (*rad_listen_debug_t)(request_t *, fr_packet_t *, fr_pair_list_t *, bool received);
75 
76 struct rad_listen {
77  rad_listen_t *next; /* should be rbtree stuff */
79 
80  /*
81  * For normal sockets.
82  */
84  int fd;
85  char const *server; //!< Name of the virtual server that the listener is associated with
86  CONF_SECTION *server_cs; //!< Virtual server that the listener is associated with
88  bool old_style;
89 
90  int count;
91  bool dual;
94  bool nodup;
95 
103 
104  CONF_SECTION const *cs;
105  void *data;
106 };
107 #ifdef __cplusplus
108 }
109 #endif
#define RCSIDH(h, id)
Definition: build.h:445
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
unsigned long int size_t
Definition: merged_model.c:25
Struct exported by a proto_* module.
Definition: protocol.h:58
The main red black tree structure.
Definition: rb.h:73
RAD_LISTEN_STATUS status
Definition: listen.h:87
CONF_SECTION const * cs
Definition: listen.h:104
fr_rb_tree_t * children
Definition: listen.h:92
rad_listen_decode_t decode
Definition: listen.h:100
rad_listen_print_t print
Definition: listen.h:102
int(* rad_listen_print_t)(rad_listen_t const *, char *, size_t)
Definition: listen.h:71
RAD_LISTEN_STATUS
Definition: listen.h:57
@ RAD_LISTEN_STATUS_FROZEN
Definition: listen.h:60
@ RAD_LISTEN_STATUS_INIT
Definition: listen.h:58
@ RAD_LISTEN_STATUS_REMOVE_NOW
Definition: listen.h:62
@ RAD_LISTEN_STATUS_KNOWN
Definition: listen.h:59
@ RAD_LISTEN_STATUS_EOL
Definition: listen.h:61
rad_listen_t * parent
Definition: listen.h:93
int(* rad_listen_recv_t)(rad_listen_t *)
Definition: listen.h:68
rad_listen_encode_t encode
Definition: listen.h:99
int count
Definition: listen.h:90
int(* rad_listen_decode_t)(rad_listen_t *, request_t *)
Definition: listen.h:74
CONF_SECTION * server_cs
Virtual server that the listener is associated with.
Definition: listen.h:86
int(* rad_listen_send_t)(rad_listen_t *, request_t *)
Definition: listen.h:69
RAD_LISTEN_TYPE
Definition: listen.h:44
@ RAD_LISTEN_PROXY
Definition: listen.h:46
@ RAD_LISTEN_COA
Definition: listen.h:53
@ RAD_LISTEN_DETAIL
Definition: listen.h:49
@ RAD_LISTEN_ACCT
Definition: listen.h:48
@ RAD_LISTEN_AUTH
Definition: listen.h:47
@ RAD_LISTEN_VQP
Definition: listen.h:50
@ RAD_LISTEN_MAX
Definition: listen.h:54
@ RAD_LISTEN_NONE
Definition: listen.h:45
@ RAD_LISTEN_COMMAND
Definition: listen.h:52
@ RAD_LISTEN_DHCP
Definition: listen.h:51
int(* rad_listen_encode_t)(rad_listen_t *, request_t *)
Definition: listen.h:73
rad_listen_recv_t recv
Definition: listen.h:96
bool old_style
Definition: listen.h:88
rad_listen_error_t error
Definition: listen.h:98
rad_listen_t * next
Definition: listen.h:77
int(* rad_listen_error_t)(rad_listen_t *, int)
Definition: listen.h:70
rad_protocol_t const * proto
Definition: listen.h:78
rad_listen_debug_t debug
Definition: listen.h:101
bool dual
Definition: listen.h:91
RAD_LISTEN_TYPE type
Definition: listen.h:83
rad_listen_send_t send
Definition: listen.h:97
void * data
Definition: listen.h:105
bool nodup
Definition: listen.h:94
void(* rad_listen_debug_t)(request_t *, fr_packet_t *, fr_pair_list_t *, bool received)
Definition: listen.h:72
char const * server
Name of the virtual server that the listener is associated with.
Definition: listen.h:85
int fd
Definition: listen.h:84