data_provider_fo.c revision e840b9da42d696eb86307c641f5196f12ec4b9c4
/*
SSSD
Data Provider Helpers
Copyright (C) Simo Sorce <ssorce@redhat.com> 2009
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <netdb.h>
#include "providers/dp_backend.h"
#include "resolv/async_resolv.h"
struct be_svc_callback {
struct be_svc_callback *prev;
struct be_svc_callback *next;
struct be_svc_data *svc;
void *private_data;
};
struct be_svc_data {
struct be_svc_data *prev;
struct be_svc_data *next;
const char *name;
struct fo_service *fo_service;
struct fo_server *last_good_srv;
bool run_callbacks;
struct be_svc_callback *callbacks;
};
struct be_failover_ctx {
struct resolv_ctx *resolv;
struct be_svc_data *svcs;
};
int be_fo_is_srv_identifier(const char *server)
{
}
struct fo_options *opts)
{
return ret;
}
&opts->family_order);
return ret;
}
return EOK;
}
{
int ret;
int resolv_timeout;
struct fo_options fopts;
return EOK;
}
return ENOMEM;
}
return ret;
}
return ret;
}
return ret;
}
return ENOMEM;
}
return EOK;
}
static int be_svc_data_destroy(void *memptr)
{
struct be_svc_data *svc;
/* callbacks removes themselves from the list,
* so this while will freem them all and then terminate */
}
return 0;
}
/*
* Find registered be_svc_data by service name.
*/
const char *service_name)
{
struct be_svc_data *svc;
return 0;
}
return svc;
}
}
return 0;
}
{
struct fo_service *service;
struct be_svc_data *svc;
int ret;
if (svc) {
/* we already have a service up and configured,
* can happen when using both id and auth provider
*/
return EOK;
}
/* if not in the be service list, try to create new one */
return ret;
}
if (!svc) {
return ENOMEM;
}
return ENOMEM;
}
return EOK;
}
static int be_svc_callback_destroy(void *memptr)
{
struct be_svc_callback *callback;
}
return 0;
}
{
struct be_svc_callback *callback;
struct be_svc_data *svc;
return ENOENT;
}
if (!callback) {
return ENOMEM;
}
return EOK;
}
const char *service_name,
const char *query_service,
const char *default_discovery_domain,
enum be_fo_protocol proto,
bool proto_fallback, void *user_data)
{
struct be_svc_data *svc;
char *domain;
int ret;
int i;
return ENOENT;
}
return ret;
}
/* Add the first protocol as the primary lookup */
return ret;
}
if (proto_fallback) {
/* All the rest as fallback */
while (i != proto) {
proto_table[i], user_data);
return ret;
}
i = (i + 1) % BE_FO_PROTO_SENTINEL;
}
}
return EOK;
}
{
struct be_svc_data *svc_data;
if (!svc_data) {
return 0;
}
}
{
struct be_svc_data *svc;
int ret;
return ENOENT;
}
return ret;
}
return EOK;
}
struct be_resolve_server_state {
struct tevent_context *ev;
struct be_svc_data *svc;
int attempts;
};
struct tevent_context *ev,
const char *service_name)
{
struct be_resolve_server_state *state;
struct be_svc_data *svc;
return req;
}
svc->fo_service);
if (!subreq) {
return NULL;
}
return req;
}
{
struct tevent_req);
struct be_resolve_server_state);
struct be_svc_callback *callback;
int ret;
switch (ret) {
case EOK:
return;
}
break;
case ENOENT:
/* all servers have been tried and none
* was found good, go offline */
return;
default:
/* mark server as bad and retry */
return;
}
return;
}
/* now try next one */
if (!subreq) {
return;
}
return;
}
/* all fine we got the server */
struct resolv_hostent *srvaddr;
char ipaddr[128];
if (!srvaddr) {
return;
}
ipaddr, 128);
}
/* now call all svc callbacks if server changed or if it is explicitly
* requested or if the server is the same but changed status since last time*/
}
}
}
{
struct be_resolve_server_state);
if (srv) {
}
return EOK;
}
{
struct be_svc_data *svc;
if (svc) {
}
}
const char *service_name)
{
struct be_svc_data *svc;
return ENOENT;
}
svc->run_callbacks = true;
return EOK;
}
{
}