Moved generic RADIUS protocol support to a dedicated libradius
[strongswan.git] / src / libradius / radius_socket.h
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup radius_socket radius_socket
18 * @{ @ingroup libradius
19 */
20
21 #ifndef RADIUS_SOCKET_H_
22 #define RADIUS_SOCKET_H_
23
24 typedef struct radius_socket_t radius_socket_t;
25
26 #include "radius_message.h"
27
28 #include <utils/host.h>
29
30 /**
31 * RADIUS socket to a server.
32 */
33 struct radius_socket_t {
34
35 /**
36 * Send a RADIUS request, wait for response.
37 *
38 * The socket fills in RADIUS Message identifier, builds a
39 * Request-Authenticator and calculates the Message-Authenticator
40 * attribute.
41 * The received response gets verified using the Response-Identifier
42 * and the Message-Authenticator attribute.
43 *
44 * @param request request message
45 * @return response message, NULL if timed out
46 */
47 radius_message_t* (*request)(radius_socket_t *this,
48 radius_message_t *request);
49
50 /**
51 * Decrypt the MSK encoded in a messages MS-MPPE-Send/Recv-Key.
52 *
53 * @param request associated RADIUS request message
54 * @param response RADIUS response message containing attributes
55 * @return allocated MSK, empty chunk if none found
56 */
57 chunk_t (*decrypt_msk)(radius_socket_t *this, radius_message_t *request,
58 radius_message_t *response);
59
60 /**
61 * Destroy a radius_socket_t.
62 */
63 void (*destroy)(radius_socket_t *this);
64 };
65
66 /**
67 * Create a radius_socket instance.
68 *
69 * @param address server name
70 * @param auth_port server port for authentication
71 * @param acct_port server port for accounting
72 * @param secret RADIUS secret
73 */
74 radius_socket_t *radius_socket_create(char *address, u_int16_t auth_port,
75 u_int16_t acct_port, chunk_t secret);
76
77 #endif /** RADIUS_SOCKET_H_ @}*/