+++ /dev/null
-#ifndef FR_EVENT_H
-#define FR_EVENT_H
-
-/*
- * event.h Simple event queue
- *
- * Version: $Id: event.h,v 1.1 2010/08/14 04:13:52 faust Exp $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- *
- * Copyright 2007 The FreeRADIUS server project
- * Copyright 2007 Alan DeKok <aland@deployingradius.com>
- */
-
-//#include <freeradius/ident.h>
-//RCSIDH(event_h, "$Id: event.h,v 1.1 2010/08/14 04:13:52 faust Exp $")
-
-typedef struct fr_event_list_t fr_event_list_t;
-typedef struct fr_event_t fr_event_t;
-
-typedef void (*fr_event_callback_t)(void *);
-typedef void (*fr_event_status_t)(struct timeval *);
-typedef void (*fr_event_fd_handler_t)(fr_event_list_t *el, int sock, void *ctx);
-
-fr_event_list_t *fr_event_list_create(fr_event_status_t status);
-void fr_event_list_free(fr_event_list_t *el);
-
-int fr_event_list_num_elements(fr_event_list_t *el);
-
-int fr_event_insert(fr_event_list_t *el,
- fr_event_callback_t callback,
- void *ctx, struct timeval *when, fr_event_t **ev_p);
-int fr_event_delete(fr_event_list_t *el, fr_event_t **ev_p);
-
-int fr_event_run(fr_event_list_t *el, struct timeval *when);
-
-int fr_event_now(fr_event_list_t *el, struct timeval *when);
-
-int fr_event_fd_insert(fr_event_list_t *el, int type, int fd,
- fr_event_fd_handler_t handler, void *ctx);
-int fr_event_fd_delete(fr_event_list_t *el, int type, int fd);
-int fr_event_loop(fr_event_list_t *el);
-void fr_event_loop_exit(fr_event_list_t *el, int code);
-
-#endif /* FR_HASH_H */
#include "iface.h"
-#include "thriftclient.h"
+#include "stg_client.h"
-int stgInstantiateImpl(const char * server, uint16_t port, const char * password)
+namespace
{
- if (STG_CLIENT_ST::Get().Configure(server, port, password))
+
+STG_PAIR* toPairs(const PAIRS& source)
+{
+ STG_PAIR * pairs = new STG_PAIR[source.size() + 1];
+ for (size_t pos = 0; pos < source.size(); ++pos) {
+ bzero(pairs[pos].key, sizeof(STG_PAIR::key));
+ bzero(pairs[pos].value, sizeof(STG_PAIR::value));
+ strncpy(pairs[pos].key, source[pos].first.c_str(), sizeof(STG_PAIR::key));
+ strncpy(pairs[pos].value, source[pos].second.c_str(), sizeof(STG_PAIR::value));
+ ++pos;
+ }
+ bzero(pairs[sources.size()].key, sizeof(STG_PAIR::key));
+ bzero(pairs[sources.size()].value, sizeof(STG_PAIR::value));
+
+ return pairs;
+}
+
+}
+
+int stgInstantiateImpl(const char* server, uint16_t port, const char* password)
+{
+ if (STG_CLIENT::configure(server, port, password))
return 1;
return 0;
}
-const STG_PAIR * stgAuthorizeImpl(const char * userName, const char * serviceType)
+const STG_PAIR* stgAuthorizeImpl(const char* userName, const char* serviceType)
{
- return STG_CLIENT_ST::Get().Authorize(userName, serviceType);
+ STG_CLIENT* client = STG_CLIENT::get();
+ if (client == NULL) {
+ // TODO: log "Not configured"
+ return NULL;
+ }
+ return toPairs(client->authorize(userName, serviceType));
}
-const STG_PAIR * stgAuthenticateImpl(const char * userName, const char * serviceType)
+const STG_PAIR* stgAuthenticateImpl(const char* userName, const char* serviceType)
{
- return STG_CLIENT_ST::Get().Authenticate(userName, serviceType);
+ STG_CLIENT* client = STG_CLIENT::get();
+ if (client == NULL) {
+ // TODO: log "Not configured"
+ return NULL;
+ }
+ return toPairs(client->authenticate(userName, serviceType));
}
-const STG_PAIR * stgPostAuthImpl(const char * userName, const char * serviceType)
+const STG_PAIR* stgPostAuthImpl(const char* userName, const char* serviceType)
{
- return STG_CLIENT_ST::Get().PostAuth(userName, serviceType);
+ STG_CLIENT* client = STG_CLIENT::get();
+ if (client == NULL) {
+ // TODO: log "Not configured"
+ return NULL;
+ }
+ return toPairs(client->postAuth(userName, serviceType));
}
-/*const STG_PAIR * stgPreAcctImpl(const char * userName, const char * serviceType)
+const STG_PAIR* stgPreAcctImpl(const char* userName, const char* serviceType)
{
- return STG_CLIENT_ST::Get().PreAcct(userName, serviceType);
-}*/
+ STG_CLIENT* client = STG_CLIENT::get();
+ if (client == NULL) {
+ // TODO: log "Not configured"
+ return NULL;
+ }
+ return toPairs(client->preAcct(userName, serviceType));
+}
+
+const STG_PAIR* stgAccountingImpl(const char* userName, const char* serviceType, const char* statusType, const char* sessionId)
+{
+ STG_CLIENT* client = STG_CLIENT::get();
+ if (client == NULL) {
+ // TODO: log "Not configured"
+ return NULL;
+ }
+ return toPairs(client->account(userName, serviceType, statusType, sessionId));
+}
+
+int countValuePairs(const VALUE_PAIR* pairs)
+{
+ unsigned count = 0;
+ while (pairs != NULL) {
+ ++count;
+ pairs = pairs->next;
+ }
+ return count;
+}
-const STG_PAIR * stgAccountingImpl(const char * userName, const char * serviceType, const char * statusType, const char * sessionId)
+STG_PAIR* fromValuePairs(const VALUE_PAIR* pairs)
{
- return STG_CLIENT_ST::Get().Account(userName, serviceType, statusType, sessionId);
+ unsigned size = countValuePairs(pairs);
+ STG_PAIR* res = new STG_PAIR[size + 1];
+ size_t pos = 0;
+ while (pairs != NULL) {
+ bzero(res[pos].key, sizeof(STG_PAIR::key));
+ bzero(res[pos].value, sizeof(STG_PAIR::value));
+ strncpy(res[pos].key, pairs->name, sizeof(STG_PAIR::key));
+ strncpy(res[pos].value, pairs->data.strvalue, sizeof(STG_PAIR::value));
+ ++pos;
+ pairs = pairs->next;
+ }
+ bzero(res[pos].key, sizeof(STG_PAIR::key));
+ bzero(res[pos].value, sizeof(STG_PAIR::value));
+ return res;
}
-void deletePairs(const STG_PAIR * pairs)
+void deletePairs(const STG_PAIR* pairs)
{
delete[] pairs;
}
extern "C" {
#endif
-int stgInstantiateImpl(const char * server, uint16_t port, const char * password);
-const STG_PAIR * stgAuthorizeImpl(const char * userName, const char * serviceType);
-const STG_PAIR * stgAuthenticateImpl(const char * userName, const char * serviceType);
-const STG_PAIR * stgPostAuthImpl(const char * userName, const char * serviceType);
-/*const STG_PAIR * stgPreAcctImpl(const char * userName, const char * serviceType);*/
-const STG_PAIR * stgAccountingImpl(const char * userName, const char * serviceType, const char * statusType, const char * sessionId);
+int stgInstantiateImpl(const char* server, uint16_t port, const char* password);
+const STG_PAIR* stgAuthorizeImpl(const char* userName, const char* serviceType);
+const STG_PAIR* stgAuthenticateImpl(const char* userName, const char* serviceType);
+const STG_PAIR* stgPostAuthImpl(const char* userName, const char* serviceType);
+const STG_PAIR* stgPreAcctImpl(const char* userName, const char* serviceType);
+const STG_PAIR* stgAccountingImpl(const char* userName, const char* serviceType, const char* statusType, const char* sessionId);
-void deletePairs(const STG_PAIR * pairs);
+void deletePairs(const STG_PAIR* pairs);
+STG_PAIR* fromValuePairs(const VALUE_PAIR* pairs);
+int countValuePairs(const VALUE_PAIR* pairs);
#ifdef __cplusplus
}
#undef NDEBUG
#endif
-#include "stgpair.h"
#include "iface.h"
+#include "stgpair.h"
typedef struct rlm_stg_t {
- char * server;
+ char* server;
uint16_t port;
- char * password;
+ char* password;
} rlm_stg_t;
static const CONF_PARSER module_config[] = {
{ NULL, -1, 0, NULL, NULL } /* end the list */
};
-int emptyPair(const STG_PAIR * pair);
-
/*
* Do any per-module initialization that is separate to each
* configured instance of the module. e.g. set up connections
* that must be referenced in later calls, store a handle to it
* in *instance otherwise put a null pointer there.
*/
-static int stg_instantiate(CONF_SECTION *conf, void **instance)
+static int stg_instantiate(CONF_SECTION* conf, void** instance)
{
- rlm_stg_t *data;
+ rlm_stg_t* data;
/*
* Set up a storage area for instance data
*/
data = rad_malloc(sizeof(*data));
- if (!data) {
+ if (!data)
return -1;
- }
+
memset(data, 0, sizeof(*data));
/*
* from the database. The authentication code only needs to check
* the password, the rest is done here.
*/
-static int stg_authorize(void *, REQUEST *request)
+static int stg_authorize(void*, REQUEST* request)
{
- const STG_PAIR * pairs;
- const STG_PAIR * pair;
+ const STG_PAIR* pairs;
+ const STG_PAIR* pair;
size_t count = 0;
+ const char* username = NULL;
+ const char* password = NULL;
instance = instance;
DEBUG("rlm_stg: stg_authorize()");
if (request->username) {
- DEBUG("rlm_stg: stg_authorize() request username field: '%s'", request->username->vp_strvalue);
+ username = request->username->data.strvalue;
+ DEBUG("rlm_stg: stg_authorize() request username field: '%s'", username);
}
+
if (request->password) {
- DEBUG("rlm_stg: stg_authorize() request password field: '%s'", request->password->vp_strvalue);
- }
- // Here we need to define Framed-Protocol
- VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE);
- if (svc) {
- DEBUG("rlm_stg: stg_authorize() Service-Type defined as '%s'", svc->vp_strvalue);
- pairs = stgAuthorizeImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue);
- } else {
- DEBUG("rlm_stg: stg_authorize() Service-Type undefined");
- pairs = stgAuthorizeImpl((const char *)request->username->vp_strvalue, "");
+ password = request->password->data.strvalue;
+ DEBUG("rlm_stg: stg_authorize() request password field: '%s'", password);
}
+
+ pairs = stgAuthorizeImpl(username, password, request->packet->vps);
+
if (!pairs) {
DEBUG("rlm_stg: stg_authorize() failed.");
return RLM_MODULE_REJECT;
pair = pairs;
while (!emptyPair(pair)) {
- VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET);
- pairadd(&request->config_items, pwd);
+ VALUE_PAIR* vp = pairmake(pair->key, pair->value, T_OP_SET);
+ pairadd(&request->config_items, vp);
DEBUG("Adding pair '%s': '%s'", pair->key, pair->value);
++pair;
++count;
/*
* Authenticate the user with the given password.
*/
-static int stg_authenticate(void *, REQUEST *request)
+static int stg_authenticate(void*, REQUEST* request)
{
- const STG_PAIR * pairs;
- const STG_PAIR * pair;
+ const STG_PAIR* pairs;
+ const STG_PAIR* pair;
size_t count = 0;
+ const char* username = NULL;
+ const char* password = NULL;
instance = instance;
DEBUG("rlm_stg: stg_authenticate()");
- VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE);
- if (svc) {
- DEBUG("rlm_stg: stg_authenticate() Service-Type defined as '%s'", svc->vp_strvalue);
- pairs = stgAuthenticateImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue);
- } else {
- DEBUG("rlm_stg: stg_authenticate() Service-Type undefined");
- pairs = stgAuthenticateImpl((const char *)request->username->vp_strvalue, "");
+ if (request->username) {
+ username = request->username->data.strvalue;
+ DEBUG("rlm_stg: stg_authenticate() request username field: '%s'", username);
+ }
+
+ if (request->password) {
+ password = request->password->data.strvalue;
+ DEBUG("rlm_stg: stg_authenticate() request password field: '%s'", password);
}
+
+ pairs = stgAuthenticateImpl(username, password, request->packet->vps);
+
if (!pairs) {
DEBUG("rlm_stg: stg_authenticate() failed.");
return RLM_MODULE_REJECT;
pair = pairs;
while (!emptyPair(pair)) {
- VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET);
- pairadd(&request->reply->vps, pwd);
+ VALUE_PAIR* vp = pairmake(pair->key, pair->value, T_OP_SET);
+ pairadd(&request->reply->vps, vp);
++pair;
++count;
}
/*
* Massage the request before recording it or proxying it
*/
-static int stg_preacct(void *, REQUEST *)
+static int stg_preacct(void*, REQUEST*)
{
+ const STG_PAIR* pairs;
+ const STG_PAIR* pair;
+ size_t count = 0;
+ const char* username = NULL;
+ const char* password = NULL;
+
DEBUG("rlm_stg: stg_preacct()");
instance = instance;
- return RLM_MODULE_OK;
+ if (request->username) {
+ username = request->username->data.strvalue;
+ DEBUG("rlm_stg: stg_preacct() request username field: '%s'", username);
+ }
+
+ if (request->password) {
+ password = request->password->data.strvalue;
+ DEBUG("rlm_stg: stg_preacct() request password field: '%s'", password);
+ }
+
+ pairs = stgPreAcctImpl(username, password, request->packet->vps);
+
+ if (!pairs) {
+ DEBUG("rlm_stg: stg_preacct() failed.");
+ return RLM_MODULE_REJECT;
+ }
+
+ pair = pairs;
+ while (!emptyPair(pair)) {
+ VALUE_PAIR* vp = pairmake(pair->key, pair->value, T_OP_SET);
+ pairadd(&request->reply->vps, vp);
+ ++pair;
+ ++count;
+ }
+ deletePairs(pairs);
+
+ if (count)
+ return RLM_MODULE_UPDATED;
+
+ return RLM_MODULE_NOOP;
}
/*
* Write accounting information to this modules database.
*/
-static int stg_accounting(void *, REQUEST * request)
+static int stg_accounting(void*, REQUEST* request)
{
- const STG_PAIR * pairs;
- const STG_PAIR * pair;
+ const STG_PAIR* pairs;
+ const STG_PAIR* pair;
size_t count = 0;
instance = instance;
DEBUG("rlm_stg: stg_accounting()");
- VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE);
- VALUE_PAIR * sessid = pairfind(request->packet->vps, PW_ACCT_SESSION_ID);
- VALUE_PAIR * sttype = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE);
+ VALUE_PAIR* svc = pairfind(request->packet->vps, PW_SERVICE_TYPE);
+ VALUE_PAIR* sessid = pairfind(request->packet->vps, PW_ACCT_SESSION_ID);
+ VALUE_PAIR* sttype = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE);
if (!sessid) {
DEBUG("rlm_stg: stg_accounting() Acct-Session-ID undefined");
}
if (sttype) {
- DEBUG("Acct-Status-Type := %s", sttype->vp_strvalue);
+ DEBUG("Acct-Status-Type := %s", sttype->data.strvalue);
if (svc) {
- DEBUG("rlm_stg: stg_accounting() Service-Type defined as '%s'", svc->vp_strvalue);
- pairs = stgAccountingImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue, (const char *)sttype->vp_strvalue, (const char *)sessid->vp_strvalue);
+ DEBUG("rlm_stg: stg_accounting() Service-Type defined as '%s'", svc->data.strvalue);
+ pairs = stgAccountingImpl((const char*)request->username->data.strvalue, (const char*)svc->data.strvalue, (const char*)sttype->data.strvalue, (const char*)sessid->data.strvalue);
} else {
DEBUG("rlm_stg: stg_accounting() Service-Type undefined");
- pairs = stgAccountingImpl((const char *)request->username->vp_strvalue, "", (const char *)sttype->vp_strvalue, (const char *)sessid->vp_strvalue);
+ pairs = stgAccountingImpl((const char*)request->username->data.strvalue, "", (const char*)sttype->data.strvalue, (const char*)sessid->data.strvalue);
}
} else {
DEBUG("rlm_stg: stg_accounting() Acct-Status-Type := NULL");
pair = pairs;
while (!emptyPair(pair)) {
- VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET);
+ VALUE_PAIR* pwd = pairmake(pair->key, pair->value, T_OP_SET);
pairadd(&request->reply->vps, pwd);
++pair;
++count;
* max. number of logins, do a second pass and validate all
* logins by querying the terminal server (using eg. SNMP).
*/
-static int stg_checksimul(void *, REQUEST *request)
+static int stg_checksimul(void*, REQUEST* request)
{
DEBUG("rlm_stg: stg_checksimul()");
instance = instance;
- request->simul_count=0;
+ request->simul_count = 0;
return RLM_MODULE_OK;
}
-static int stg_postauth(void *, REQUEST *request)
+static int stg_postauth(void*, REQUEST* request)
{
- const STG_PAIR * pairs;
- const STG_PAIR * pair;
+ const STG_PAIR* pairs;
+ const STG_PAIR* pair;
size_t count = 0;
instance = instance;
DEBUG("rlm_stg: stg_postauth()");
- VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE);
+ VALUE_PAIR* svc = pairfind(request->packet->vps, PW_SERVICE_TYPE);
if (svc) {
- DEBUG("rlm_stg: stg_postauth() Service-Type defined as '%s'", svc->vp_strvalue);
- pairs = stgPostAuthImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue);
+ DEBUG("rlm_stg: stg_postauth() Service-Type defined as '%s'", svc->data.strvalue);
+ pairs = stgPostAuthImpl((const char*)request->username->data.strvalue, (const char*)svc->data.strvalue);
} else {
DEBUG("rlm_stg: stg_postauth() Service-Type undefined");
- pairs = stgPostAuthImpl((const char *)request->username->vp_strvalue, "");
+ pairs = stgPostAuthImpl((const char*)request->username->data.strvalue, "");
}
if (!pairs) {
DEBUG("rlm_stg: stg_postauth() failed.");
pair = pairs;
while (!emptyPair(pair)) {
- VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET);
+ VALUE_PAIR* pwd = pairmake(pair->key, pair->value, T_OP_SET);
pairadd(&request->reply->vps, pwd);
++pair;
++count;
return RLM_MODULE_NOOP;
}
-static int stg_detach(void *instance)
+static int stg_detach(void* instance)
{
- free(((struct rlm_stg_t *)instance)->server);
+ free(((struct rlm_stg_t*)instance)->server);
free(instance);
return 0;
}
module_t rlm_stg = {
RLM_MODULE_INIT,
"stg",
- RLM_TYPE_THREAD_SAFE, /* type */
- stg_instantiate, /* instantiation */
- stg_detach, /* detach */
+ RLM_TYPE_THREAD_SAFE, /* type */
+ stg_instantiate, /* instantiation */
+ stg_detach, /* detach */
{
- stg_authenticate, /* authentication */
+ stg_authenticate, /* authentication */
stg_authorize, /* authorization */
- stg_preacct, /* preaccounting */
- stg_accounting, /* accounting */
- stg_checksimul, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- stg_postauth /* post-auth */
+ stg_preacct, /* preaccounting */
+ stg_accounting, /* accounting */
+ stg_checksimul, /* checksimul */
+ stg_pre_proxy, /* pre-proxy */
+ stg_post_proxy, /* post-proxy */
+ stg_postauth /* post-auth */
},
};
#include "stg_client.h"
-typedef std::vector<std::pair<std::string, std::string> > PAIRS;
+namespace {
+
+STG_CLIENT* stgClient = NULL;
+
+}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-const STG_PAIRS * STG_CLIENT::Authorize(const std::string & login, const std::string & svc)
+const STG_PAIRS * STG_CLIENT::Authorize(const PAIRS& pairs)
{
/*RAD_PACKET packet;
return ToSTGPairs(pairs);
}
-const STG_PAIRS * STG_CLIENT::Authenticate(const std::string & login, const std::string & svc)
+const STG_PAIRS * STG_CLIENT::Authenticate(const PAIRS& pairs)
{
/*RAD_PACKET packet;
return ToSTGPairs(pairs);
}
-const STG_PAIRS * STG_CLIENT::PostAuth(const std::string & login, const std::string & svc)
+const STG_PAIRS * STG_CLIENT::PostAuth(const PAIRS& pairs)
{
/*RAD_PACKET packet;
return ToSTGPairs(pairs);
}
-const STG_PAIRS * STG_CLIENT::PreAcct(const std::string & login, const std::String & service)
+const STG_PAIRS * STG_CLIENT::PreAcct(const PAIRS& pairs)
{
PAIRS pairs;
return ToSTGPairs(pairs);
}
-const STG_PAIRS * STG_CLIENT::Account(const std::string & type, const std::string & login, const std::string & svc, const std::string & sessid)
+const STG_PAIRS * STG_CLIENT::Account(const PAIRS& pairs)
{
/*RAD_PACKET packet;
//-----------------------------------------------------------------------------
-STG_CLIENT * STG_CLIENT_ST::Get()
+STG_CLIENT* STG_CLIENT::get()
{
- static STG_CLIENT * stgClient = NULL;
- if ( stgClient == NULL )
- stgClient = new STG_CLIENT(m_host, m_port, m_password);
return stgClient;
}
-void STG_CLIENT_ST::Configure(const std::string & host, uint16_t port, const std::string & password)
+void STG_CLIENT::configure(const std::string& server, uint16_t port, const std::string& password)
{
- m_host = host;
- m_port = port;
- m_password = password;
+ if ( stgClient != NULL )
+ delete stgClient;
+ stgClient = new STG_CLIENT(server, port, password);
}
//-----------------------------------------------------------------------------
#include "stg/blowfish.h"
#include "stg/rad_packets.h"
-#include "stgpair.h"
+typedef std::vector<std::pair<std::string, std::string> > PAIRS;
class STG_CLIENT
{
STG_CLIENT(const std::string & host, uint16_t port, const std::string & password);
~STG_CLIENT();
- const STG_PAIR * Authorize(const std::string & login, const std::string & service);
- const STG_PAIR * Authenticate(const std::string & login, const std::string & service);
- const STG_PAIR * PostAuth(const std::string & login, const std::string & service);
- const STG_PAIR * PreAcct(const std::string & login, const std::string & service);
- const STG_PAIR * Account(const std::string & type, const std::string & login, const std::string & service, const std::string & sessionId);
+ static STG_CLIENT* get();
+ static void configure(const std::string& server, uint16_t port, const std::string& password);
-private:
- std::string password;
-
- int PrepareNet();
-
- int Request(RAD_PACKET * packet, const std::string & login, const std::string & svc, uint8_t packetType);
-
- int RecvData(RAD_PACKET * packet);
- int Send(const RAD_PACKET & packet);
-};
-
-struct STG_CLIENT_ST
-{
- public:
- static void Configure(const std::string & host, uint16_t port, const std::string & password);
- static STG_CLIENT * Get();
+ PAIRS authorize(const PAIRS& pairs);
+ PAIRS authenticate(const PAIRS& pairs);
+ PAIRS postAuth(const PAIRS& pairs);
+ PAIRS preAcct(const PAIRS& pairs);
+ PAIRS account(const PAIRS& pairs);
- private:
- static std::string m_host;
- static uint16_t m_port;
- static std::string m_password;
+private:
};
#endif
--- /dev/null
+#include "stgpair.h"
+
+int emptyPair(const STG_PAIR* pair)
+{
+ return pair != NULL && pair->key[0] != '\0' && pair->value[0] != '\0';
+}
#ifndef __STG_STGPAIR_H__
#define __STG_STGPAIR_H__
+#include <freeradius/libradius.h> // VALUE_PAIR
+
#define STGPAIR_KEYLENGTH 64
#define STGPAIR_VALUELENGTH 256
char value[STGPAIR_VALUELENGTH];
} STG_PAIR;
+int emptyPair(const STG_PAIR* pair);
+
#endif