dp_dyndns.h revision 038b9ba28a618e3e553803da632116a040b94034
b6ff72be73dad3d1394cf2c71e29e67624ff030bChristian Maeder/*
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder SSSD
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski dp_dyndns.h
2725abe920f91de62ae5c0b7230c1627cccf5fabChristian Maeder
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu Authors:
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder Jakub Hrozek <jhrozek@redhat.com>
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder Copyright (C) 2013 Red Hat
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder This program is free software; you can redistribute it and/or modify
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder it under the terms of the GNU General Public License as published by
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder the Free Software Foundation; either version 3 of the License, or
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder (at your option) any later version.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder This program is distributed in the hope that it will be useful,
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
0a26144c20fa9cdcd05011ca5019cbac8e4afae0cmaeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0a26144c20fa9cdcd05011ca5019cbac8e4afae0cmaeder GNU General Public License for more details.
d1c667fd9445963d9d31e2cf5d0ead15e77082a4cmaeder
93603bd881e43d4ff5a57d7ca4e2b9fa619f25b4cmaeder You should have received a copy of the GNU General Public License
d1c667fd9445963d9d31e2cf5d0ead15e77082a4cmaeder along with this program. If not, see <http://www.gnu.org/licenses/>.
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder*/
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
bbba10ee00dcf6bcbc9f22473b1acd0983b10512notanartist#ifndef DP_DYNDNS_H_
df87ff823273ae2969e9d29e833845b4c0a9ee77notanartist#define DP_DYNDNS_H_
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder/* dynamic dns helpers */
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maederstruct sss_iface_addr;
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maedertypedef void (*nsupdate_timer_fn_t)(void *pvt);
85e1d54a475bfc30b3eac5ae6c5e42a2d7e93f10Christian Maeder
85e1d54a475bfc30b3eac5ae6c5e42a2d7e93f10Christian Maederenum be_nsupdate_auth {
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder BE_NSUPDATE_AUTH_NONE,
91e24fc45834b35f2a3830d72565640251149bf3Christian Maeder BE_NSUPDATE_AUTH_GSS_TSIG,
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder};
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maederstruct be_nsupdate_ctx {
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder struct dp_option *opts;
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder enum be_nsupdate_auth auth_type;
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder time_t last_refresh;
0130083f314580170af1195037be3325f125fbceChristian Maeder bool timer_in_progress;
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder struct tevent_timer *refresh_timer;
0130083f314580170af1195037be3325f125fbceChristian Maeder nsupdate_timer_fn_t timer_callback;
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder void *timer_pvt;
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder};
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maederenum dp_dyndns_opts {
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder DP_OPT_DYNDNS_UPDATE,
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder DP_OPT_DYNDNS_REFRESH_INTERVAL,
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder DP_OPT_DYNDNS_IFACE,
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder DP_OPT_DYNDNS_TTL,
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder DP_OPT_DYNDNS_UPDATE_PTR,
a461314c811f4187dff85c8be079a41b2f13f176Christian Maeder DP_OPT_DYNDNS_FORCE_TCP,
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder DP_OPT_DYNDNS_AUTH,
a31430de8b0632d29f42634d6395e982bf31b14dChristian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder DP_OPT_DYNDNS /* attrs counter */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder};
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
be43c3fa0292555bd126784ae27ff5c1d23438cbChristian Maeder#define DYNDNS_REMOVE_A 0x1
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define DYNDNS_REMOVE_AAAA 0x2
16b71dad8d398af412d66a4f4763f1ada5b03d23Christian Maeder
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maedererrno_t be_nsupdate_check(void);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maedererrno_t
3a9d784341454573b50b32fa1b494e7418df3086Christian Maederbe_nsupdate_init(TALLOC_CTX *mem_ctx, struct be_ctx *be_ctx,
dff1de7ad15d1582e25d636c3724dd202874897fChristian Maeder struct dp_option *defopts,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct be_nsupdate_ctx **_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maedererrno_t be_nsupdate_init_timer(struct be_nsupdate_ctx *ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct tevent_context *ev,
502483734c83d0bf1eadcc94113d0362f8713784Christian Maeder nsupdate_timer_fn_t timer_callback,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder void *timer_pvt);
be43c3fa0292555bd126784ae27ff5c1d23438cbChristian Maeder
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maedervoid be_nsupdate_timer_schedule(struct tevent_context *ev,
16b71dad8d398af412d66a4f4763f1ada5b03d23Christian Maeder struct be_nsupdate_ctx *ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
96ae1a1d2197d0e0d5b80da2474b64c456feb1b0Christian Maedererrno_t
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedersss_iface_addr_list_get(TALLOC_CTX *mem_ctx, const char *ifname,
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder struct sss_iface_addr **_addrlist);
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maederstruct sss_iface_addr *
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maedersss_iface_addr_add(TALLOC_CTX *mem_ctx, struct sss_iface_addr **list,
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder struct sockaddr_storage *ss);
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maedererrno_t
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maedersss_iface_addr_list_as_str_list(TALLOC_CTX *mem_ctx,
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder struct sss_iface_addr *ifaddr_list,
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder char ***_straddrs);
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maedererrno_t
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederbe_nsupdate_create_fwd_msg(TALLOC_CTX *mem_ctx, const char *realm,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder const char *zone, const char *servername,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *hostname, const unsigned int ttl,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint8_t remove_af, struct sss_iface_addr *addresses,
dff1de7ad15d1582e25d636c3724dd202874897fChristian Maeder char **_update_msg);
dff1de7ad15d1582e25d636c3724dd202874897fChristian Maeder
96ae1a1d2197d0e0d5b80da2474b64c456feb1b0Christian Maedererrno_t
8c8545dd3bf34fbcbc16904b65d249658f8f9efcChristian Maederbe_nsupdate_create_ptr_msg(TALLOC_CTX *mem_ctx, const char *realm,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *servername, const char *hostname,
d81905a5b924415c524d702df26204683c82c12eChristian Maeder const unsigned int ttl, uint8_t remove_af,
96ae1a1d2197d0e0d5b80da2474b64c456feb1b0Christian Maeder struct sss_iface_addr *addresses,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sss_iface_addr *old_addresses,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder char **_update_msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Returns:
dff1de7ad15d1582e25d636c3724dd202874897fChristian Maeder * * ERR_OK - on success
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * * ERR_DYNDNS_FAILED - if nsupdate fails for any reason
cb2044812811d66efe038d914966e04290be93faChristian Maeder * * ERR_DYNDNS_TIMEOUT - if the update times out. child_status
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * is ETIMEDOUT in this case
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder */
dff1de7ad15d1582e25d636c3724dd202874897fChristian Maederstruct tevent_req *be_nsupdate_send(TALLOC_CTX *mem_ctx,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder struct tevent_context *ev,
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder enum be_nsupdate_auth auth_type,
6352f3c31da3043783a13be6594aacb2147378baRazvan Pascanu char *nsupdate_msg,
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu bool force_tcp);
b324cda6178c49ddeead3ce62b832ccf644cbcabRazvan Pascanuerrno_t be_nsupdate_recv(struct tevent_req *req, int *child_status);
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu
bc263f610d20a9cd3014ddfca903026127fa0d48Christian Maederstruct tevent_req * nsupdate_get_addrs_send(TALLOC_CTX *mem_ctx,
966519955f5f7111abac20118563132b9dd41165Christian Maeder struct tevent_context *ev,
8c8545dd3bf34fbcbc16904b65d249658f8f9efcChristian Maeder struct be_resolv_ctx *be_res,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *hostname);
0b13f102310e03a20b38c870b5acb88712f316a4Christian Maedererrno_t
0b13f102310e03a20b38c870b5acb88712f316a4Christian Maedernsupdate_get_addrs_recv(struct tevent_req *req,
0b13f102310e03a20b38c870b5acb88712f316a4Christian Maeder TALLOC_CTX *mem_ctx,
33fcc19ef2b59493b4e91eebf701df95fd230765Christian Maeder struct sss_iface_addr **_addrlist,
33fcc19ef2b59493b4e91eebf701df95fd230765Christian Maeder size_t *_count);
33fcc19ef2b59493b4e91eebf701df95fd230765Christian Maeder
d4ebd9e5adc974cfa2bdf4bdd155e07be0e26f75Christian Maedervoid
d4ebd9e5adc974cfa2bdf4bdd155e07be0e26f75Christian Maedersss_iface_addr_concatenate(struct sss_iface_addr **list,
d4ebd9e5adc974cfa2bdf4bdd155e07be0e26f75Christian Maeder struct sss_iface_addr *list2);
0d79ea4ed8512a802ecb6645edac141e0fbcee3fChristian Maeder
0d79ea4ed8512a802ecb6645edac141e0fbcee3fChristian Maeder#endif /* DP_DYNDNS_H_ */
0d79ea4ed8512a802ecb6645edac141e0fbcee3fChristian Maeder