2 * Copyright (C) 2006 Stig Venaas <venaas@uninett.no>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
9 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
11 #define SOCKADDR_SIZE(addr) ((addr).ss_family == AF_INET ? \
12 sizeof(struct sockaddr_in) : \
13 sizeof(struct sockaddr_in6))
15 #define DEBUG_LEVEL DBG_INFO
17 #define CONFIG_MAIN "/etc/radsecproxy/radsecproxy.conf"
18 #define CONFIG_SERVERS "/etc/radsecproxy/servers.conf"
19 #define CONFIG_CLIENTS "/etc/radsecproxy/clients.conf"
21 /* MAX_REQUESTS must be 256 due to Radius' 8 bit ID field */
22 #define MAX_REQUESTS 256
23 #define DEFAULT_TLS_SECRET "mysecret"
24 #define DEFAULT_UDP_PORT "1812"
25 #define DEFAULT_TLS_PORT "2083"
26 #define REQUEST_EXPIRY 20
27 #define REQUEST_RETRIES 3
28 #define MAX_CERT_DEPTH 5
29 #define STATUS_SERVER_PERIOD 25
30 #define RAD_Access_Request 1
31 #define RAD_Access_Accept 2
32 #define RAD_Access_Reject 3
33 #define RAD_Accounting_Request 4
34 #define RAD_Accounting_Response 5
35 #define RAD_Access_Challenge 11
36 #define RAD_Status_Server 12
37 #define RAD_Status_Client 13
39 #define RAD_Attr_User_Name 1
40 #define RAD_Attr_User_Password 2
41 #define RAD_Attr_Vendor_Specific 26
42 #define RAD_Attr_Tunnel_Password 69
43 #define RAD_Attr_Message_Authenticator 80
45 #define RAD_VS_ATTR_MS_MPPE_Send_Key 16
46 #define RAD_VS_ATTR_MS_MPPE_Recv_Key 17
48 #define RAD_Attr_Type 0
49 #define RAD_Attr_Length 1
50 #define RAD_Attr_Value 2
53 char *tlscacertificatefile;
54 char *tlscacertificatepath;
55 char *tlscertificatefile;
56 char *tlscertificatekeyfile;
57 char *tlscertificatekeypassword;
63 /* requests that our client will send */
68 struct timeval expiry;
70 unsigned char *messageauthattrval;
71 uint8_t origid; /* used by servwr */
72 char origauth[16]; /* used by servwr */
73 struct sockaddr_storage fromsa; /* used by udpservwr */
76 /* replies that a server will send */
79 struct sockaddr_storage tosa; /* used by udpservwr */
83 struct reply *replies;
86 pthread_mutex_t count_mutex;
87 pthread_cond_t count_cond;
91 char type; /* U for UDP, T for TLS */
96 struct addrinfo *addrinfo;
101 struct replyq *replyq;
109 pthread_mutex_t lock;
111 struct timeval lastconnecttry;
112 uint8_t connectionok;
114 struct request *requests;
116 pthread_mutex_t newrq_mutex;
117 pthread_cond_t newrq_cond;
120 void errx(char *format, ...);
121 void err(char *format, ...);
122 char *stringcopy(char *s, int len);
123 char *addr2string(struct sockaddr *addr, socklen_t len);
124 int bindport(int type, char *port);
125 int connectport(int type, char *host, char *port);