All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
radclient.h
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 #ifndef _FR_RADCLIENT_H
17 #define _FR_RADCLIENT_H
18 /**
19  * $Id: 2f2be91e58940082aecc6bdc7de24bf98794504f $
20  *
21  * @file include/radclient.h
22  * @brief Structures for the radclient utility.
23  *
24  * @copyright 2014 The FreeRADIUS server project
25  */
26 RCSIDH(radclient_h, "$Id: 2f2be91e58940082aecc6bdc7de24bf98794504f $")
27 
28 #include <freeradius-devel/libradius.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Logging macros
36  */
37  #undef DEBUG
38 #define DEBUG(fmt, ...) if (do_output && (fr_debug_lvl > 0)) fprintf(fr_log_fp, fmt "\n", ## __VA_ARGS__)
39 #undef DEBUG2
40 #define DEBUG2(fmt, ...) if (do_output && (fr_debug_lvl > 1)) fprintf(fr_log_fp, fmt "\n", ## __VA_ARGS__)
41 
42 
43 #define ERROR(fmt, ...) if (do_output) fr_perror("radclient: " fmt, ## __VA_ARGS__)
44 
45 #define RDEBUG_ENABLED() (do_output && (fr_debug_lvl > 0))
46 #define RDEBUG_ENABLED2() (do_output && (fr_debug_lvl > 1))
47 
48 #define REDEBUG(fmt, ...) if (do_output) fr_perror("(%" PRIu64 ") " fmt , request->num, ## __VA_ARGS__)
49 #define RDEBUG(fmt, ...) if (do_output && (fr_debug_lvl > 0)) fprintf(fr_log_fp, "(%" PRIu64 ") " fmt "\n", request->num, ## __VA_ARGS__)
50 #define RDEBUG2(fmt, ...) if (do_output && (fr_debug_lvl > 1)) fprintf(fr_log_fp, "(%" PRIu64 ") " fmt "\n", request->num, ## __VA_ARGS__)
51 
52 typedef struct rc_stats {
53  uint64_t accepted; //!< Requests to which we received a accept
54  uint64_t rejected; //!< Requests to which we received a reject
55  uint64_t lost; //!< Requests to which we received no response
56  uint64_t passed; //!< Requests which passed a filter
57  uint64_t failed; //!< Requests which failed a fitler
58 } rc_stats_t;
59 
60 typedef struct rc_file_pair {
61  char const *packets; //!< The file containing the request packet
62  char const *filters; //!< The file containing the definition of the
63  //!< packet we want to match.
65 
66 typedef struct rc_request rc_request_t;
67 
68 struct rc_request {
69  uint64_t num; //!< The number (within the file) of the request were reading.
70 
73 
74  rc_file_pair_t *files; //!< Request and response file names.
75 
76  VALUE_PAIR *password; //!< Cleartext-Password
77  time_t timestamp;
78 
79  RADIUS_PACKET *packet; //!< The outgoing request.
80  RADIUS_PACKET *reply; //!< The incoming response.
81  VALUE_PAIR *filter; //!< If the reply passes the filter, then the request passes.
82  PW_CODE filter_code; //!< Expected code of the response packet.
83 
84  int resend;
85  int tries;
86  bool done; //!< Whether the request is complete.
87 
88  char const *name; //!< Test name (as specified in the request).
89 };
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 #endif /* _FR_RADCLIENT_H */
char const * name
Test name (as specified in the request).
Definition: radclient.h:88
#define RCSIDH(h, id)
Definition: build.h:136
VALUE_PAIR * password
Cleartext-Password.
Definition: radclient.h:76
uint64_t lost
Requests to which we received no response.
Definition: radclient.h:55
struct rc_file_pair rc_file_pair_t
bool done
Whether the request is complete.
Definition: radclient.h:86
PW_CODE filter_code
Expected code of the response packet.
Definition: radclient.h:82
char const * packets
The file containing the request packet.
Definition: radclient.h:61
struct rc_stats rc_stats_t
rc_request_t * next
Definition: radclient.h:72
uint64_t passed
Requests which passed a filter.
Definition: radclient.h:56
Stores an attribute, a value and various bits of other data.
Definition: pair.h:112
rc_file_pair_t * files
Request and response file names.
Definition: radclient.h:74
int tries
Definition: radclient.h:85
time_t timestamp
Definition: radclient.h:77
int resend
Definition: radclient.h:84
Structure which holds global statistics information.
Definition: radclient.h:52
VALUE_PAIR * filter
If the reply passes the filter, then the request passes.
Definition: radclient.h:81
uint64_t failed
Requests which failed a fitler.
Definition: radclient.h:57
uint64_t accepted
Requests to which we received a accept.
Definition: radclient.h:53
RADIUS_PACKET * packet
The outgoing request.
Definition: radclient.h:79
RADIUS_PACKET * reply
The incoming response.
Definition: radclient.h:80
char const * filters
The file containing the definition of the packet we want to match.
Definition: radclient.h:62
PW_CODE
RADIUS packet codes.
Definition: radius.h:90
rc_request_t * prev
Definition: radclient.h:71
uint64_t num
The number (within the file) of the request were reading.
Definition: radclient.h:69
uint64_t rejected
Requests to which we received a reject.
Definition: radclient.h:54