dp_dyndns.h revision e45b81abe0aafa8a04bd64ac31a2fac63ce675b7
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/*
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen SSSD
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen dp_dyndns.h
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen Authors:
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen Jakub Hrozek <jhrozek@redhat.com>
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen Copyright (C) 2013 Red Hat
dce5a2719df4fc64a8762d2aa94ba98dcf9cd6feTimo Sirainen
e54512a5189192fe72d1e2c53927c98c5ac920b4Timo Sirainen This program is free software; you can redistribute it and/or modify
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen it under the terms of the GNU General Public License as published by
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen the Free Software Foundation; either version 3 of the License, or
645f258ea29afaf09b673fc65d1bd788dfec8db8Timo Sirainen (at your option) any later version.
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen This program is distributed in the hope that it will be useful,
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
043c8a96a035379bcba04f487d58457beefdfcaaTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
043c8a96a035379bcba04f487d58457beefdfcaaTimo Sirainen GNU General Public License for more details.
043c8a96a035379bcba04f487d58457beefdfcaaTimo Sirainen
043c8a96a035379bcba04f487d58457beefdfcaaTimo Sirainen You should have received a copy of the GNU General Public License
043c8a96a035379bcba04f487d58457beefdfcaaTimo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
043c8a96a035379bcba04f487d58457beefdfcaaTimo Sirainen*/
c9dea5c23355dea35c6fa423de69f6507852efe4Timo Sirainen
c9dea5c23355dea35c6fa423de69f6507852efe4Timo Sirainen
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen#ifndef DP_DYNDNS_H_
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen#define DP_DYNDNS_H_
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen/* dynamic dns helpers */
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenstruct sss_iface_addr;
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainentypedef void (*nsupdate_timer_fn_t)(void *pvt);
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenstruct be_nsupdate_ctx {
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen struct dp_option *opts;
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainen
c9dea5c23355dea35c6fa423de69f6507852efe4Timo Sirainen time_t last_refresh;
b88c43d09a288e99d439c78de4cc613212ea924cTimo Sirainen bool timer_in_progress;
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen struct tevent_timer *refresh_timer;
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen nsupdate_timer_fn_t timer_callback;
cf52b37d807553e91a2d6fb7cb2c8b4c34589e1dTimo Sirainen void *timer_pvt;
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen};
8fb1e3e2349c9940732b5bb77a2a4053b8f72a4fTimo Sirainen
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenenum dp_dyndns_opts {
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen DP_OPT_DYNDNS_UPDATE,
c9dea5c23355dea35c6fa423de69f6507852efe4Timo Sirainen DP_OPT_DYNDNS_REFRESH_INTERVAL,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen DP_OPT_DYNDNS_IFACE,
c9dea5c23355dea35c6fa423de69f6507852efe4Timo Sirainen DP_OPT_DYNDNS_TTL,
cf52b37d807553e91a2d6fb7cb2c8b4c34589e1dTimo Sirainen DP_OPT_DYNDNS_UPDATE_PTR,
b88c43d09a288e99d439c78de4cc613212ea924cTimo Sirainen DP_OPT_DYNDNS_FORCE_TCP,
4b058f90f9e8a2c6b2eed275de4eb8cc5195a71dTimo Sirainen
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen DP_OPT_DYNDNS /* attrs counter */
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen};
cf52b37d807553e91a2d6fb7cb2c8b4c34589e1dTimo Sirainen
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen#define DYNDNS_REMOVE_A 0x1
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen#define DYNDNS_REMOVE_AAAA 0x2
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen
cf52b37d807553e91a2d6fb7cb2c8b4c34589e1dTimo Sirainenerrno_t be_nsupdate_check(void);
86ad841251a38aa9ffcf4db4ee2c9fd449121bcbTimo Sirainen
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainenerrno_t
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainenbe_nsupdate_init(TALLOC_CTX *mem_ctx, struct be_ctx *be_ctx,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen struct dp_option *defopts,
86ad841251a38aa9ffcf4db4ee2c9fd449121bcbTimo Sirainen nsupdate_timer_fn_t timer_callback,
86ad841251a38aa9ffcf4db4ee2c9fd449121bcbTimo Sirainen void *timer_pvt,
5cda0bfea032000c4a51134c748d9efe6614870bTimo Sirainen struct be_nsupdate_ctx **_ctx);
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenvoid be_nsupdate_timer_schedule(struct tevent_context *ev,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen struct be_nsupdate_ctx *ctx);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainenerrno_t
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainensss_iface_addr_list_get(TALLOC_CTX *mem_ctx, const char *ifname,
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen struct sss_iface_addr **_addrlist);
8b12e7b44abca3bd51a1c46e19ca504f3b55e723Timo Sirainen
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainenstruct sss_iface_addr *
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainensss_iface_addr_add(TALLOC_CTX *mem_ctx, struct sss_iface_addr **list,
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen struct sockaddr_storage *ss);
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainenerrno_t
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainensss_iface_addr_list_as_str_list(TALLOC_CTX *mem_ctx,
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainen struct sss_iface_addr *ifaddr_list,
8b12e7b44abca3bd51a1c46e19ca504f3b55e723Timo Sirainen char ***_straddrs);
8b12e7b44abca3bd51a1c46e19ca504f3b55e723Timo Sirainen
8b12e7b44abca3bd51a1c46e19ca504f3b55e723Timo Sirainenerrno_t
8b12e7b44abca3bd51a1c46e19ca504f3b55e723Timo Sirainenbe_nsupdate_create_fwd_msg(TALLOC_CTX *mem_ctx, const char *realm,
8b12e7b44abca3bd51a1c46e19ca504f3b55e723Timo Sirainen const char *zone, const char *servername,
8b12e7b44abca3bd51a1c46e19ca504f3b55e723Timo Sirainen const char *hostname, const unsigned int ttl,
872b8fd8a8db97dc54067b7ab25bda96ec0aac0dTimo Sirainen uint8_t remove_af, struct sss_iface_addr *addresses,
872b8fd8a8db97dc54067b7ab25bda96ec0aac0dTimo Sirainen struct sss_iface_addr *old_addresses,
872b8fd8a8db97dc54067b7ab25bda96ec0aac0dTimo Sirainen char **_update_msg);
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainenerrno_t
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenbe_nsupdate_create_ptr_msg(TALLOC_CTX *mem_ctx, const char *realm,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen const char *servername, const char *hostname,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen const unsigned int ttl, uint8_t remove_af,
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen struct sss_iface_addr *addresses,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen struct sss_iface_addr *old_addresses,
cf52b37d807553e91a2d6fb7cb2c8b4c34589e1dTimo Sirainen char **_update_msg);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen/* Returns:
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen * * ERR_OK - on success
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen * * ERR_DYNDNS_FAILED - if nsupdate fails for any reason
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen * * ERR_DYNDNS_TIMEOUT - if the update times out. child_status
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen * is ETIMEDOUT in this case
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen */
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenstruct tevent_req *be_nsupdate_send(TALLOC_CTX *mem_ctx,
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen struct tevent_context *ev,
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen char *nsupdate_msg,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen bool force_tcp);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenerrno_t be_nsupdate_recv(struct tevent_req *req, int *child_status);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenstruct tevent_req * nsupdate_get_addrs_send(TALLOC_CTX *mem_ctx,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen struct tevent_context *ev,
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen struct be_resolv_ctx *be_res,
4bbee99b3aef449a9a2a11a5b5cf1ca486915c49Timo Sirainen const char *hostname);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainenerrno_t
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainennsupdate_get_addrs_recv(struct tevent_req *req,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen TALLOC_CTX *mem_ctx,
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen struct sss_iface_addr **_addrlist,
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen size_t *_count);
5cda0bfea032000c4a51134c748d9efe6614870bTimo Sirainen
b88c43d09a288e99d439c78de4cc613212ea924cTimo Sirainen#endif /* DP_DYNDNS_H_ */
1bdda5c0c30463160c47151537e6bb2c6c994841Timo Sirainen