blob: d73ff3da4e62bcdd4c0ccfe9e393e6cc0816377f [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
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.
10 *
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.
15 *
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
19 */
20#ifndef __PJLIB_UTIL_DNS_SERVER_H__
21#define __PJLIB_UTIL_DNS_SERVER_H__
22
23/**
24 * @file dns_server.h
25 * @brief Simple DNS server
26 */
27#include <pjlib-util/types.h>
28#include <pjlib-util/dns.h>
29
30PJ_BEGIN_DECL
31
32/**
33 * @defgroup PJ_DNS_SERVER Simple DNS Server
34 * @ingroup PJ_DNS
35 * @{
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.
39 */
40
41/**
42 * Opaque structure to hold DNS server instance.
43 */
44typedef struct pj_dns_server pj_dns_server;
45
46/**
47 * Create the DNS server instance. The instance will run immediately.
48 *
49 * @param pf The pool factory to create memory pools.
50 * @param ioqueue Ioqueue instance where the server socket will be
51 * registered to.
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.
57 *
58 * @return PJ_SUCCESS if server has been created successfully,
59 * otherwise the function will return the appropriate
60 * error code.
61 */
62PJ_DECL(pj_status_t) pj_dns_server_create(pj_pool_factory *pf,
63 pj_ioqueue_t *ioqueue,
64 int af,
65 unsigned port,
66 unsigned flags,
67 pj_dns_server **p_srv);
68
69/**
70 * Destroy DNS server instance.
71 *
72 * @param srv The DNS server instance.
73 *
74 * @return PJ_SUCCESS on success or the appropriate error code.
75 */
76PJ_DECL(pj_status_t) pj_dns_server_destroy(pj_dns_server *srv);
77
78
79/**
80 * Add generic resource record entries to the server.
81 *
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.
85 *
86 * @return PJ_SUCCESS on success or the appropriate error code.
87 */
88PJ_DECL(pj_status_t) pj_dns_server_add_rec(pj_dns_server *srv,
89 unsigned count,
90 const pj_dns_parsed_rr rr[]);
91
92/**
93 * Remove the specified record from the server.
94 *
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.
99 *
100 * @return PJ_SUCCESS on success or the appropriate error code.
101 */
102PJ_DECL(pj_status_t) pj_dns_server_del_rec(pj_dns_server *srv,
103 int dns_class,
104 pj_dns_type type,
105 const pj_str_t *name);
106
107
108
109/**
110 * @}
111 */
112
113PJ_END_DECL
114
115
116#endif /* __PJLIB_UTIL_DNS_SERVER_H__ */
117