sres_async.h 2.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef SOFIA_RESOLV_SRES_ASYNC_H
/** Defined when <sofia-resolv/sres_async.h> has been included. */
#define SOFIA_RESOLV_SRES_ASYNC_H
Pekka Pessi's avatar
Pekka Pessi committed
28

29 30 31 32 33
/**
 * @file sofia-resolv/sres_async.h 
 *
 * Asynchronous interface for Sofia DNS Resolver.
 *
Pekka Pessi's avatar
Pekka Pessi committed
34
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
35 36 37
 *
 * @par Include Context
 * @code
Pekka Pessi's avatar
Pekka Pessi committed
38 39
 * #include <sys/types.h>
 * #include <sys/socket.h>
40 41 42 43 44 45 46
 * #include <netinet/in.h>
 * #include <sofia-resolv/sres.h>
 * #include <sofia-resolv/sres_async.h>
 * @endcode
 *
 */

47 48
#include "sofia-resolv/sres_config.h"

49
#ifdef __cplusplus
Pekka Pessi's avatar
Pekka Pessi committed
50 51 52 53 54
extern "C" {
#endif

#ifndef SRES_ASYNC_T 
#define SRES_ASYNC_T struct sres_async_s
55
#endif
Pekka Pessi's avatar
Pekka Pessi committed
56 57
/** Application-defined type for context used by asynchronous operation. */
typedef SRES_ASYNC_T sres_async_t;
58 59 60 61 62 63 64 65 66 67 68 69 70

/** Prototype for update function.
 *
 * This kind of function is called when the nameserver configuration has
 * been updated. 
 *
 * If the old_socket is not -1, it indicates that old_socket will be closed
 * and it should be removed from poll() or select() set.
 *
 * If the new_socket is not -1, it indicates that resolver has created new
 * socket that should be added to the poll() or select() set.
 */
typedef int sres_update_f(sres_async_t *async,
71 72
			  sres_socket_t new_socket,
			  sres_socket_t old_socket);
73 74

/** Set asynchronous operation data. */
75
SRESPUBFUN
76 77 78 79 80 81
sres_async_t *sres_resolver_set_async(sres_resolver_t *res, 
				      sres_update_f *update,
				      sres_async_t *async,
				      int update_all);

/** Get async operation data. */
82
SRESPUBFUN
83 84 85 86
sres_async_t *sres_resolver_get_async(sres_resolver_t const *res,
				      sres_update_f *update);

/** Create sockets for resolver. */
87 88 89
SRESPUBFUN int sres_resolver_sockets(sres_resolver_t *, 
				     sres_socket_t *sockets,
				     int n);
90 91

/** Resolver timer function. */
92
SRESPUBFUN void sres_resolver_timer(sres_resolver_t *, int dummy);
93 94

/** Receive DNS response from socket. */
95
SRESPUBFUN int sres_resolver_receive(sres_resolver_t *, int socket);
96 97

/** Receive error message from socket. */
98
SRESPUBFUN int sres_resolver_error(sres_resolver_t *, int socket);
99 100 101 102 103 104

#ifdef __cplusplus
}
#endif

#endif /* SOFIA_RESOLV_SRES_ASYNC_H */