3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef __PJLIB_UTIL_DNS_SERVER_H__
21 #define __PJLIB_UTIL_DNS_SERVER_H__
25 * @brief Simple DNS server
27 #include <pjlib-util/types.h>
28 #include <pjlib-util/dns.h>
33 * @defgroup PJ_DNS_SERVER Simple DNS Server
36 * This contains a simple but fully working DNS server implementation,
37 * mostly for testing purposes. It supports serving various DNS resource
38 * records such as SRV, CNAME, A, and AAAA.
42 * Opaque structure to hold DNS server instance.
44 typedef struct pj_dns_server pj_dns_server;
47 * Create the DNS server instance. The instance will run immediately.
49 * @param pf The pool factory to create memory pools.
50 * @param ioqueue Ioqueue instance where the server socket will be
52 * @param af Address family of the server socket (valid values
53 * are pj_AF_INET() for IPv4 and pj_AF_INET6() for IPv6).
54 * @param port The UDP port to listen.
55 * @param flags Flags, currently must be zero.
56 * @param p_srv Pointer to receive the DNS server instance.
58 * @return PJ_SUCCESS if server has been created successfully,
59 * otherwise the function will return the appropriate
62 PJ_DECL(pj_status_t) pj_dns_server_create(pj_pool_factory *pf,
63 pj_ioqueue_t *ioqueue,
67 pj_dns_server **p_srv);
70 * Destroy DNS server instance.
72 * @param srv The DNS server instance.
74 * @return PJ_SUCCESS on success or the appropriate error code.
76 PJ_DECL(pj_status_t) pj_dns_server_destroy(pj_dns_server *srv);
80 * Add generic resource record entries to the server.
82 * @param srv The DNS server instance.
83 * @param count Number of records to be added.
84 * @param rr Array of records to be added.
86 * @return PJ_SUCCESS on success or the appropriate error code.
88 PJ_DECL(pj_status_t) pj_dns_server_add_rec(pj_dns_server *srv,
90 const pj_dns_parsed_rr rr[]);
93 * Remove the specified record from the server.
95 * @param srv The DNS server instance.
96 * @param dns_class The resource's DNS class. Valid value is PJ_DNS_CLASS_IN.
97 * @param type The resource type.
98 * @param name The resource name to be removed.
100 * @return PJ_SUCCESS on success or the appropriate error code.
102 PJ_DECL(pj_status_t) pj_dns_server_del_rec(pj_dns_server *srv,
105 const pj_str_t *name);
116 #endif /* __PJLIB_UTIL_DNS_SERVER_H__ */