rev |
line source |
meillo@200
|
1 /* MasqMail Copyright (C) Oliver Kurth,
|
meillo@200
|
2 /* Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
|
meillo@200
|
3 *
|
meillo@200
|
4 * This program is free software; you can redistribute it and/or modify
|
meillo@200
|
5 * it under the terms of the GNU General Public License as published by
|
meillo@200
|
6 * the Free Software Foundation; either version 2 of the License, or
|
meillo@200
|
7 * (at your option) any later version.
|
meillo@200
|
8 *
|
meillo@200
|
9 * This program is distributed in the hope that it will be useful,
|
meillo@200
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
meillo@200
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
meillo@200
|
12 * GNU General Public License for more details.
|
meillo@200
|
13 *
|
meillo@200
|
14 * You should have received a copy of the GNU General Public License
|
meillo@200
|
15 * along with this program; if not, write to the Free Software
|
meillo@200
|
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
meillo@200
|
17 */
|
meillo@200
|
18
|
meillo@200
|
19
|
meillo@200
|
20 #include <sys/types.h>
|
meillo@200
|
21 #include <netinet/in.h>
|
meillo@200
|
22 #include <arpa/nameser.h>
|
meillo@200
|
23 #include <resolv.h>
|
meillo@200
|
24
|
meillo@200
|
25 #include "masqmail.h"
|
meillo@200
|
26
|
meillo@200
|
27
|
meillo@200
|
28 masqmail_conf conf;
|
meillo@200
|
29
|
meillo@200
|
30
|
meillo@200
|
31 void
|
meillo@200
|
32 debugf(const char *fmt, ...)
|
meillo@200
|
33 {
|
meillo@200
|
34 va_list args;
|
meillo@200
|
35 va_start(args, fmt);
|
meillo@200
|
36
|
meillo@200
|
37 vfprintf(stdout, fmt, args);
|
meillo@200
|
38
|
meillo@200
|
39 va_end(args);
|
meillo@200
|
40
|
meillo@200
|
41 }
|
meillo@200
|
42
|
meillo@200
|
43
|
meillo@200
|
44 int
|
meillo@200
|
45 main(int argc, char *argv[])
|
meillo@200
|
46 {
|
meillo@200
|
47 GList *addr_list = NULL, *node;
|
meillo@200
|
48
|
meillo@200
|
49 conf.debug_level = -1; /* no debug messages */
|
meillo@200
|
50
|
meillo@200
|
51 if (argc != 2) {
|
meillo@200
|
52 fprintf(stderr, "usage: resolvtest HOSTNAME\n");
|
meillo@200
|
53 return 1;
|
meillo@200
|
54 }
|
meillo@200
|
55
|
meillo@200
|
56 if (res_init() != 0) {
|
meillo@200
|
57 printf("res_init() failed.\n");
|
meillo@200
|
58 return 1;
|
meillo@200
|
59 }
|
meillo@200
|
60
|
meillo@200
|
61 printf("A:\n");
|
meillo@200
|
62 addr_list = resolve_dns_a(NULL, argv[1]);
|
meillo@200
|
63 foreach(addr_list, node) {
|
meillo@200
|
64 mxip_addr *p_mxip = (mxip_addr *) (node->data);
|
meillo@200
|
65 printf("%s \t%s\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip)));
|
meillo@200
|
66 }
|
meillo@200
|
67
|
meillo@200
|
68 printf("\nMX:\n");
|
meillo@200
|
69 addr_list = resolve_dns_mx(NULL, argv[1]);
|
meillo@200
|
70 foreach(addr_list, node) {
|
meillo@200
|
71 mxip_addr *p_mxip = (mxip_addr *) (node->data);
|
meillo@200
|
72 printf("%s \t%s %d\n", p_mxip->name,
|
meillo@200
|
73 inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref);
|
meillo@200
|
74 }
|
meillo@200
|
75
|
meillo@200
|
76 printf("\nIP resolved directly (assumed FQDN, no default domain added):\n");
|
meillo@200
|
77 {
|
meillo@200
|
78 guint32 ip;
|
meillo@200
|
79 if (dns_look_ip(argv[1], &ip) >= 0) {
|
meillo@200
|
80 printf("%s\n", inet_ntoa(*((struct in_addr *) (&ip))));
|
meillo@200
|
81 }
|
meillo@200
|
82 }
|
meillo@200
|
83
|
meillo@200
|
84 return 0;
|
meillo@200
|
85 }
|