]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/radius/radius.h
Merge branch 'stg-2.409' into stg-2.409-radius
[stg.git] / projects / stargazer / plugins / other / radius / radius.h
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
19  */
20
21 #ifndef __STG_RADIUS_H__
22 #define __STG_RADIUS_H__
23
24 #include "stg/os_int.h"
25 #include "stg/auth.h"
26 #include "stg/module_settings.h"
27 #include "stg/logger.h"
28
29 #include <string>
30
31 #include <pthread.h>
32 #include <unistd.h>
33 #include <sys/select.h>
34 #include <sys/types.h>
35
36 extern "C" PLUGIN * GetPlugin();
37
38 class STORE;
39 class USERS;
40
41 class RADIUS : public AUTH {
42 public:
43     RADIUS();
44     virtual ~RADIUS() {}
45
46     void SetUsers(USERS* u) { users = u; }
47     void SetStore(STORE* s) { store = s; }
48     void SetStgSettings(const SETTINGS*) {}
49     void SetSettings(const MODULE_SETTINGS& s) { settings = s; }
50     int ParseSettings();
51
52     int Start();
53     int Stop();
54     int Reload() { return 0; }
55     bool IsRunning() { return m_running; }
56
57     const std::string& GetStrError() const { return m_error; }
58     std::string GetVersion() const { return "RADIUS data access plugin v 1.0"; }
59     uint16_t GetStartPosition() const { return 30; }
60     uint16_t GetStopPosition() const { return 30; }
61
62     int SendMessage(const STG_MSG&, uint32_t) const { return 0; }
63
64 private:
65     RADIUS(const RADIUS & rvalue);
66     RADIUS & operator=(const RADIUS & rvalue);
67
68     static void* run(void*);
69
70     void rumImpl();
71     int maxFD() const;
72     void buildFDSet(fd_set & fds) const;
73     void cleanupConns();
74     void handleEvents(const fd_set & fds);
75     void acceptConnection();
76
77     mutable std::string m_error;
78     STG::Config m_config;
79
80     MODULE_SETTINGS m_settings;
81
82     bool m_running;
83     bool m_stopped;
84
85     USERS* m_users;
86     const STORE* m_store;
87
88     pthread_t m_thread;
89     pthread_mutex_t m_mutex;
90
91     PLUGIN_LOGGER m_logger;
92 };
93
94 #endif