]> git.stg.codes - stg.git/blobdiff - projects/rlm_stg/stg_client.h
Merge branch 'stg-2.409-radius'
[stg.git] / projects / rlm_stg / stg_client.h
index 82d2287ba04ffb080a75ce43abbd95d4ba70d359..917d0e511fa18c68bef09587725a765dff3ab191 100644 (file)
  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
  */
 
-#ifndef STG_CLIENT_H
-#define STG_CLIENT_H
+#ifndef __STG_RLM_CLIENT_H__
+#define __STG_RLM_CLIENT_H__
+
+#include "types.h"
 
 #include "stg/os_int.h"
 
 #include <boost/scoped_ptr.hpp>
 
 #include <string>
-#include <vector>
-#include <stdexcept>
-
-typedef std::vector<std::pair<std::string, std::string> > PAIRS;
 
-struct RESULT
+namespace STG
+{
+namespace RLM
 {
-    PAIRS modify;
-    PAIRS reply;
-};
-
-struct ChannelConfig {
-    struct Error : std::runtime_error {
-        Error(const std::string& message) : runtime_error(message) {}
-    };
-
-    ChannelConfig(std::string address);
-
-    std::string transport;
-    std::string key;
-    std::string address;
-    std::string portStr;
-    uint16_t port;
-};
 
-class STG_CLIENT
+class Client
 {
 public:
-    enum TYPE {
-        AUTHORIZE,
-        AUTHENTICATE,
-        POST_AUTH,
-        PRE_ACCT,
-        ACCOUNT
-    };
-    struct Error : std::runtime_error {
-        Error(const std::string& message) : runtime_error(message) {}
-    };
-
-    typedef bool (*Callback)(void* data, const RESULT& result);
-
-    STG_CLIENT(const std::string& address, Callback callback, void* data);
-    ~STG_CLIENT();
+    explicit Client(const std::string& address);
+    ~Client();
 
     bool stop();
 
-    static STG_CLIENT* get();
-    static bool configure(const std::string& address, Callback callback, void* data);
+    static Client* get();
+    static bool configure(const std::string& address);
 
-    bool request(TYPE type, const std::string& userName, const std::string& password, const PAIRS& pairs);
+    RESULT request(REQUEST_TYPE type, const std::string& userName, const std::string& password, const PAIRS& pairs);
 
 private:
     class Impl;
     boost::scoped_ptr<Impl> m_impl;
 };
 
+} // namespace RLM
+} // namespace STG
+
 #endif