fail_over_srv.c revision 4e748c28dec6fcb732ebe24829f1b750074d488e
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen Pavel B??ezina <pbrezina@redhat.com>
50e4970035d1278597d13cac6c5ae26e7af93025Timo Sirainen Copyright (C) 2013 Red Hat
14102a0c5db8828ca8c7751ec96587fadc97a0bcTimo Sirainen This program is free software; you can redistribute it and/or modify
14102a0c5db8828ca8c7751ec96587fadc97a0bcTimo Sirainen it under the terms of the GNU General Public License as published by
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi the Free Software Foundation; either version 3 of the License, or
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi (at your option) any later version.
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi This program is distributed in the hope that it will be useful,
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi but WITHOUT ANY WARRANTY; without even the implied warranty of
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen GNU General Public License for more details.
05128fda80748e107bccdece0a3d23551e99e8f3Timo Sirainen You should have received a copy of the GNU General Public License
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi along with this program. If not, see <http://www.gnu.org/licenses/>.
3fd8086f71f25a68e33993e24123b10b671dac67Aki Tuomistatic void fo_discover_srv_done(struct tevent_req *subreq);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomistruct tevent_req *fo_discover_srv_send(TALLOC_CTX *mem_ctx,
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi const char *service,
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi req = tevent_req_create(mem_ctx, &state, struct fo_discover_srv_state);
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi DEBUG(SSSDBG_CRIT_FAILURE, ("tevent_req_create() failed\n"));
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi subreq = resolv_discover_srv_send(state, ev, resolv_ctx, service,
14af7be4aa26d55c341cd6efe32bb2add2c39830Aki Tuomi tevent_req_set_callback(subreq, fo_discover_srv_done, req);
aaa1b6bb4cd2d7f8f4e7977d61176ea1c8f7e32bAki Tuomistatic void fo_discover_srv_done(struct tevent_req *subreq)
79bbb900ffba886779474dfb04c41408f0ba0602Timo Sirainen req = tevent_req_callback_data(subreq, struct tevent_req);
79bbb900ffba886779474dfb04c41408f0ba0602Timo Sirainen state = tevent_req_data(req, struct fo_discover_srv_state);
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen DEBUG(SSSDBG_TRACE_FUNC, ("Got answer. Processing...\n"));
36a052b7bd94ccb47abbb6b15c1380f03780ba20Timo Sirainen /* sort and store the answer */
36a052b7bd94ccb47abbb6b15c1380f03780ba20Timo Sirainen ret = resolv_sort_srv_reply(state, &reply_list);
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, ("Could not sort the answers from DNS "
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen for (record = reply_list; record != NULL; record = record->next) {
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen DEBUG(SSSDBG_TRACE_FUNC, ("Got %lu servers\n", state->num_servers));
55accf49e32ff93bfdd92961cb54ccc8c329147cTimo Sirainen state->servers = talloc_array(state, struct fo_server_info,
79bbb900ffba886779474dfb04c41408f0ba0602Timo Sirainen state->servers[i].host = talloc_steal(state->servers, record->host);
68cc278710182485b6c09e9a9ff8db90a727f343Aki Tuomi state = tevent_req_data(req, struct fo_discover_srv_state);
6eb1a7a7ae2c1dfff6731956ade08f9a4a7c791aAki Tuomi *_dns_domain = talloc_steal(mem_ctx, state->dns_domain);
return EOK;
struct fo_discover_servers_state {
const char *service;
const char *protocol;
const char *primary_domain;
const char *backup_domain;
char *dns_domain;
const char *service,
const char *protocol,
const char *primary_domain,
const char *backup_domain)
struct fo_discover_servers_state);
return NULL;
goto immediately;
goto immediately;
goto immediately;
goto immediately;
goto immediately;
goto immediately;
goto immediately;
return req;
return req;
goto done;
goto done;
goto done;
goto done;
done:
char **_dns_domain,
if (_primary_servers) {
if (_num_primary_servers) {
if (_backup_servers) {
if (_num_backup_servers) {
if (_dns_domain) {
return EOK;
struct fo_resolve_srv_dns_ctx {
char *hostname;
char *sssd_domain;
char *detected_domain;
struct fo_resolve_srv_dns_state {
const char *service;
const char *protocol;
const char *discovery_domain;
char *dns_domain;
struct fo_resolve_srv_dns_ctx *
const char *hostname,
const char *sssd_domain)
return NULL;
goto fail;
goto fail;
return ctx;
fail:
return NULL;
const char *service,
const char *protocol,
const char *discovery_domain,
void *pvt)
return NULL;
goto immediately;
goto immediately;
goto immediately;
return req;
return req;
goto done;
done:
goto done;
goto done;
goto done;
goto done;
done:
return ret;
goto done;
done:
char **_dns_domain,
if (_primary_servers) {
if (_num_primary_servers) {
if (_backup_servers) {
if (_num_backup_servers) {
*_num_backup_servers = 0;
if (_dns_domain) {
return EOK;