The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
application.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: 2af80794111f17e16cafd9631a2eb22709d43eba $
20  *
21  * @file io/application.h
22  * @brief Application interfaces.
23  *
24  * @copyright 2017 The FreeRADIUS project
25  */
26 #include <freeradius-devel/io/base.h>
27 #include <freeradius-devel/server/cf_util.h>
28 #include <freeradius-devel/server/dl_module.h>
29 #include <freeradius-devel/server/virtual_servers.h>
30 
31 /*
32  * src/lib/io/schedule.h
33  */
34 typedef struct fr_schedule_s fr_schedule_t;
35 
36 /** Open a new socket or other packet source
37  *
38  * @param[in] instance of the #fr_app_t.
39  * @param[in] sc we should register sockets with.
40  * @param[in] cs of the listen section that created this #fr_app_t.
41  * @return
42  * - 0 on success.
43  * - <0 on failure.
44  */
45 typedef int (*fr_app_open_t)(void *instance, fr_schedule_t *sc, CONF_SECTION *cs);
46 
47 /** Set the priority of a packet
48  *
49  * @param[in] instance of the #fr_app_t.
50  * @param[in] buffer raw packet
51  * @param[in] buflen length of the packet
52  * @return
53  * -1 - error, drop the packet
54  * 0 - no error, but we still drop the packet
55  * * - the priority of this packet
56  */
57 typedef int (*fr_app_priority_get_t)(void const *instance, uint8_t const *buffer, size_t buflen);
58 
59 /** Called by the network thread to pass an event list for the module to use for timer events
60  */
61 typedef void (*fr_app_event_list_set_t)(fr_listen_t *li, fr_event_list_t *el, void *nr);
62 
63 /** Describes a new application (protocol)
64  *
65  * This is the main application structure. It contains different callbacks that
66  * are run at different points during the server lifecycle and are called by the IO
67  * framework.
68  *
69  * How the fr_app_t operates is specific to each protocol.
70  */
71 typedef struct {
72  module_t common; //!< Common fields provided by all modules.
73 
74  fr_dict_t const **dict; //!< default dictionary for this application.
75 
76  fr_app_open_t open; //!< Callback to allow the #fr_app_t to build an #fr_listen_t
77  ///< and register it with the scheduler so we can receive
78  ///< data.
79 
80  fr_io_decode_t decode; //!< Translate raw bytes into fr_pair_ts and metadata.
81  ///< May be NULL.
82  ///< Here for convenience, so that decode operations common
83  ///< to all #fr_app_io_t can be performed by the #fr_app_t.
84 
85  fr_io_encode_t encode; //!< Pack fr_pair_ts back into a byte array.
86  ///< May be NULL.
87  ///< Here for convenience, so that encode operations common
88  ///< to all #fr_app_io_t can be performed by the #fr_app_t.
89 
90  fr_app_priority_get_t priority; //!< Assign a priority to the packet.
91 } fr_app_t;
92 
93 /** Public structure describing an application (protocol) specialisation
94  *
95  * The fr_app_worker_t provides the state machine that's used to process
96  * the packet after its been decoded.
97  */
98 typedef struct {
99  module_t common; //!< Common fields to all loadable modules.
100  module_method_t entry_point; //!< Entry point into the protocol subtype's state machine.
101  virtual_server_compile_t const *compile_list; //!< list of processing sections
103 
104 #include <freeradius-devel/io/app_io.h>
static int const char char buffer[256]
Definition: acutest.h:574
module_t common
Common fields to all loadable modules.
Definition: application.h:99
int(* fr_app_open_t)(void *instance, fr_schedule_t *sc, CONF_SECTION *cs)
Open a new socket or other packet source.
Definition: application.h:45
virtual_server_compile_t const * compile_list
list of processing sections
Definition: application.h:101
void(* fr_app_event_list_set_t)(fr_listen_t *li, fr_event_list_t *el, void *nr)
Called by the network thread to pass an event list for the module to use for timer events.
Definition: application.h:61
fr_app_priority_get_t priority
Assign a priority to the packet.
Definition: application.h:90
module_t common
Common fields provided by all modules.
Definition: application.h:72
module_method_t entry_point
Entry point into the protocol subtype's state machine.
Definition: application.h:100
fr_io_decode_t decode
Translate raw bytes into fr_pair_ts and metadata.
Definition: application.h:80
fr_io_encode_t encode
Pack fr_pair_ts back into a byte array.
Definition: application.h:85
fr_app_open_t open
Callback to allow the fr_app_t to build an fr_listen_t and register it with the scheduler so we can r...
Definition: application.h:76
fr_dict_t const ** dict
default dictionary for this application.
Definition: application.h:74
int(* fr_app_priority_get_t)(void const *instance, uint8_t const *buffer, size_t buflen)
Set the priority of a packet.
Definition: application.h:57
Describes a new application (protocol)
Definition: application.h:71
Public structure describing an application (protocol) specialisation.
Definition: application.h:98
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
int(* fr_io_decode_t)(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode a raw packet and convert it into a request.
Definition: base.h:103
ssize_t(* fr_io_encode_t)(void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
Encode data from a request_t into a raw packet.
Definition: base.h:123
Stores all information relating to an event list.
Definition: event.c:411
unsigned char uint8_t
Definition: merged_model.c:30
CONF_SECTION * cs
thread pool configuration section
Definition: schedule.c:128
The scheduler.
Definition: schedule.c:125
unlang_action_t(* module_method_t)(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Module section callback.
Definition: module.h:69
Struct exported by a rlm_* module.
Definition: module.h:142
static const uchar sc[16]
Definition: smbdes.c:115
static fr_event_list_t * el
Processing sections which are allowed in this virtual server.