2 * Copyright 2003, 2004, 2004 Porchdog Software. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
21 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
22 * OF THE POSSIBILITY OF SUCH DAMAGE.
24 * The views and conclusions contained in the software and documentation are those
25 * of the authors and should not be interpreted as representing official policies,
26 * either expressed or implied, of Porchdog Software.
30 #include <salt/debug.h>
34 static sw_result HOWL_API
36 sw_discovery discovery,
38 sw_uint32 interface_index,
41 sw_const_string domain,
42 sw_ipv4_address address,
44 sw_octets text_record,
45 sw_uint32 text_record_len,
48 sw_text_record_iterator it;
50 sw_int8 key[SW_TEXT_RECORD_MAX_LEN];
51 sw_int8 sval[SW_TEXT_RECORD_MAX_LEN];
52 sw_uint8 oval[SW_TEXT_RECORD_MAX_LEN];
54 sw_result err = SW_OKAY;
56 sw_discovery_cancel(discovery, oid);
58 fprintf(stderr, "resolve reply: 0x%x %s %s %s %s %d\n", interface_index, name, type, domain, sw_ipv4_address_name(address, name_buf, 16), port);
60 if ((text_record_len > 0) && (text_record) && (*text_record != '\0'))
62 err = sw_text_record_iterator_init(&it, text_record, text_record_len);
63 sw_check_okay(err, exit);
65 while (sw_text_record_iterator_next(it, key, oval, &oval_len) == SW_OKAY)
67 fprintf(stderr, "key = %s, data is %d bytes\n", key, oval_len);
70 err = sw_text_record_iterator_fina(it);
71 sw_check_okay(err, exit);
89 sw_discovery discovery;
93 err = sw_discovery_init(&discovery);
94 sw_check_okay(err, exit);
98 fprintf(stderr, "usage: mDNSResolve <name> <type>\n");
102 err = sw_discovery_resolve(discovery, 0, argv[1], argv[2], "local.", my_resolver, NULL, &oid);
103 sw_check_okay(err, exit);
105 err = sw_discovery_run(discovery);
106 sw_check_okay(err, exit);