blob: 3fe78621a3be1d7d032546a37a02991c3e5bff2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#ifndef __RADIUS_H
#define __RADIUS_H
#include <netinet/in.h>
#include "triton.h"
#define REQ_LENGTH_MAX 4096
#define ATTR_TYPE_INTEGER 0
#define ATTR_TYPE_STRING 1
#define ATTR_TYPE_DATE 2
#define ATTR_TYPE_IPADDR 3
#define CODE_ACCESS_REQUEST 1
struct radius_pd_t
{
struct ppp_pd_t pd;
struct ppp_t *ppp;
};
typedef union
{
int integer;
const char *string;
time_t date;
in_addr_t ipaddr;
} rad_value_t;
struct rad_dict_t
{
struct list_head items;
};
struct rad_dict_value_t
{
struct list_head entry;
rad_value_t val;
const char *name;
};
struct rad_dict_attr_t
{
struct list_head entry;
const char *name;
int id;
int type;
struct list_head values;
};
struct rad_req_attr_t
{
struct list_head entry;
struct rad_dict_attr_t *attr;
//struct rad_dict_value_t *val;
rad_value_t val;
};
struct rad_packet_t
{
int code;
int id;
struct list_head attrs;
void *buf;
};
struct rad_req_t
{
struct triton_md_handler_t hnd;
struct triton_timer_t timeout;
struct rad_packet_t pack;
struct rad_packet_t *answer;
const char *server_host;
int server_port;
struct radius_pd_t *rpd;
};
int rad_dict_load(const char *fname);
void rad_dict_free(struct rad_dict_t *dict);
struct rad_dict_attr_t *rad_dict_find_attr(const char *name);
struct rad_dict_attr_t *rad_dict_find_attr_type(int type);
struct rad_dict_value_t *rad_dict_find_val(struct rad_dict_attr_t *, const char *name);
struct rad_req_t *rad_rec_alloc(struct radius_pd_t *rpd, int code);
void rad_rec_free(struct rad_req_t *);
int rad_req_send(struct rad_req_t *);
int rad_req_add_int(struct rad_req_t *req, const char *name, int val);
int rad_req_add_val(struct rad_req_t *req, const char *name, const char *val, int len);
int rad_req_add_str(struct rad_req_t *req, const char *name, const char *val, int len);
int rad_packet_build(struct rad_packet_t *pack);
struct rad_packet_t *rad_packet_recv(int fd);
void rad_packet_free(struct rad_packet_t *);
#endif
|