EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
radius_server.h
Go to the documentation of this file.
1 /*
2  * RADIUS authentication server
3  * Copyright (c) 2005-2009, 2011, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
15 #ifndef RADIUS_SERVER_H
16 #define RADIUS_SERVER_H
17 
18 #include <stdint.h>
19 #include <sys/types.h>
20 #include <unistd.h>
21 // On FreeBSD, you must include `<sys/socket.h>` and `<netinet/in.h>` before
22 // `<netinet/if_ether.h>`
23 #include <stdbool.h>
24 #include <sys/socket.h>
25 #include <netinet/in.h>
26 #include <netinet/if_ether.h>
27 
28 #include <eloop.h>
29 #include "../utils/os.h"
30 #include "radius_config.h"
31 
36  uint32_t access_requests;
37  uint32_t invalid_requests;
39  uint32_t access_accepts;
40  uint32_t access_rejects;
44  uint32_t packets_dropped;
45  uint32_t unknown_types;
46 };
47 
55  unsigned int sess_id;
56  char *username; /* from User-Name attribute */
57  char *nas_ip;
58  uint8_t mac_addr[ETHER_ADDR_LEN]; /* from Calling-Station-Id attribute */
59 
63  struct sockaddr_storage last_from;
64  socklen_t last_fromlen;
65  uint8_t last_identifier;
67  uint8_t last_authenticator[16];
68 
69  unsigned int macacl : 1;
70 
72 };
73 
77 struct radius_client {
79  struct in_addr addr;
80  struct in_addr mask;
85 
87  void *mac_conn_arg;
88  // int (*get_vlan_id)(uint8_t mac_addr[]);
89  struct hostapd_tunnel_pass (*get_tunnel_pass)(uint8_t mac_addr[]);
90 };
91 
99  struct eloop_data *eloop;
100 
105 
110 
114  unsigned int next_sess_id;
115 
119  int num_sess;
120 
124  struct os_reltime start_time;
125 
132 };
133 
134 struct radius_server_data *radius_server_init(struct eloop_data *eloop,
135  int auth_port,
136  struct radius_client *clients);
137 void radius_server_deinit(struct radius_server_data *data);
138 int radius_server_get_mib(struct radius_server_data *data, char *buf,
139  size_t buflen);
140 struct radius_client *init_radius_client(struct radius_conf *conf,
142  void *mac_conn_arg);
144  struct radius_client *clients);
145 #endif /* RADIUS_SERVER_H */
File containing the definition of the radius config.
struct mac_conn_info(* mac_conn_fn)(uint8_t mac_addr[], void *mac_conn_arg)
Definition: radius_config.h:32
int radius_server_get_mib(struct radius_server_data *data, char *buf, size_t buflen)
Definition: radius_server.c:880
struct radius_client * init_radius_client(struct radius_conf *conf, mac_conn_fn mac_conn_fn, void *mac_conn_arg)
Definition: radius_server.c:768
struct radius_server_data * radius_server_init(struct eloop_data *eloop, int auth_port, struct radius_client *clients)
Definition: radius_server.c:813
void radius_server_deinit(struct radius_server_data *data)
Definition: radius_server.c:859
void radius_server_free_clients(struct radius_server_data *data, struct radius_client *clients)
Definition: radius_server.c:753
Definition: common.h:208
Definition: os.h:98
Definition: radius_server.h:77
struct hostapd_tunnel_pass(* get_tunnel_pass)(uint8_t mac_addr[])
Definition: radius_server.h:89
mac_conn_fn conn_fn
Definition: radius_server.h:86
struct radius_server_counters counters
Definition: radius_server.h:84
struct radius_session * sessions
Definition: radius_server.h:83
char * shared_secret
Definition: radius_server.h:81
struct in_addr addr
Definition: radius_server.h:79
struct in_addr mask
Definition: radius_server.h:80
struct radius_client * next
Definition: radius_server.h:78
int shared_secret_len
Definition: radius_server.h:82
void * mac_conn_arg
Definition: radius_server.h:87
Radius configuration structure.
Definition: radius_config.h:23
Definition: radius.c:33
Definition: radius_server.h:35
uint32_t access_challenges
Definition: radius_server.h:41
uint32_t dup_access_requests
Definition: radius_server.h:38
uint32_t packets_dropped
Definition: radius_server.h:44
uint32_t access_requests
Definition: radius_server.h:36
uint32_t access_rejects
Definition: radius_server.h:40
uint32_t access_accepts
Definition: radius_server.h:39
uint32_t malformed_access_requests
Definition: radius_server.h:42
uint32_t bad_authenticators
Definition: radius_server.h:43
uint32_t invalid_requests
Definition: radius_server.h:37
uint32_t unknown_types
Definition: radius_server.h:45
Definition: radius_server.h:95
struct radius_server_counters counters
Definition: radius_server.h:131
struct eloop_data * eloop
Definition: radius_server.h:99
unsigned int next_sess_id
Definition: radius_server.h:114
int num_sess
Definition: radius_server.h:119
struct os_reltime start_time
Definition: radius_server.h:124
struct radius_client * clients
Definition: radius_server.h:109
int auth_sock
Definition: radius_server.h:104
Definition: radius_server.h:51
struct hostapd_radius_attr * accept_attr
Definition: radius_server.h:71
char * last_from_addr
Definition: radius_server.h:61
socklen_t last_fromlen
Definition: radius_server.h:64
struct radius_session * next
Definition: radius_server.h:52
struct radius_msg * last_reply
Definition: radius_server.h:66
char * username
Definition: radius_server.h:56
char * nas_ip
Definition: radius_server.h:57
uint8_t last_authenticator[16]
Definition: radius_server.h:67
struct radius_msg * last_msg
Definition: radius_server.h:60
struct sockaddr_storage last_from
Definition: radius_server.h:63
struct radius_client * client
Definition: radius_server.h:53
uint8_t last_identifier
Definition: radius_server.h:65
uint8_t mac_addr[ETHER_ADDR_LEN]
Definition: radius_server.h:58
struct radius_server_data * server
Definition: radius_server.h:54
unsigned int macacl
Definition: radius_server.h:69
int last_from_port
Definition: radius_server.h:62
unsigned int sess_id
Definition: radius_server.h:55