1/*
2 * Copyright (c) 2005, 2006 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 * DNSNameList.h
26 * - convert a list of DNS domain names to/from the compact
27 *   DNS form described in RFC 1035
28 */
29
30/*
31 * Modification History
32 *
33 * January 4, 2006	Dieter Siegmund (dieter@apple)
34 * - created
35 */
36
37#ifndef _S_DNSNAMELIST_H
38#define _S_DNSNAMELIST_H
39
40#include <stdint.h>
41
42/*
43 * Function: DNSNameListBufferCreate
44 *
45 * Purpose:
46 *   Convert the given list of DNS domain names into the compact form
47 *   described in RFC 1035.  If "buffer" is NULL, this routine allocates
48 *   a buffer of sufficient size and returns its size in "buffer_size".
49 *   Use free() to release the memory.
50 *
51 *   If "buffer" is not NULL, this routine places at most "buffer_size"
52 *   bytes into "buffer".  If "buffer" is too small, NULL is returned, and
53 *   "buffer_size" reflects the number of bytes used in the partial conversion.
54 *
55 * Returns:
56 *   NULL if the conversion failed, non-NULL otherwise.
57 */
58uint8_t *
59DNSNameListBufferCreate(const char * names[], int names_count,
60			uint8_t * buffer, int * buffer_size);
61/*
62 * Function: DNSNameListCreate
63 *
64 * Purpose:
65 *   Convert compact domain name list form described in RFC 1035 to a list
66 *   of domain names.  The memory for the list and names buffer area is
67 *   dynamically allocated in a single allocation.  Use free() to release
68 *   the memory.
69 *
70 * Returns:
71 *   NULL if an error occurred i.e. buffer did not contain a valid encoding.
72 *   non-NULL if the conversion was successful, and "names_count" contains
73 *   the number of names in the returned list.
74 */
75const char * *
76DNSNameListCreate(const uint8_t * buffer, int buffer_size,
77		  int * names_count);
78
79#endif /* _S_DNSNAMELIST_H */
80