3 #include <netinet/in.h>
4 #include <arpa/nameser.h>
6 #include "sysdep_decls.h"
9 #define SMART_HOST "gatekeeper.wdcs.com"
14 * Return one or more MX's for a mail destination.
16 * Upon success, it fills 'mxbuf' with one or more MX hosts, separated by
17 * vertical bar characters, and returns the number of hosts as its return
18 * value. If no MX's are found, it returns 0.
21 int getmx(char *mxbuf, char *dest) {
24 unsigned char *startptr, *endptr, *ptr;
26 char expanded_buf[1024];
27 unsigned short pref, type;
31 /* If we're configured to send all mail to a smart-host, then our
32 * job here is really easy.
35 strcpy(mxbuf, SMART_HOST);
39 /* No smart-host? Look up the best MX for a site.
43 C_IN, T_MX, answer, sizeof(answer) );
45 lprintf(9, "res_query() returned %d\n", ret);
48 lprintf(5, "No MX found\n");
52 /* If we had to truncate, shrink the number to avoid fireworks */
53 if (ret > sizeof(answer))
55 lprintf(9, "size of answer is %d\n", ret);
57 startptr = &answer[0]; /* start and end of buffer */
58 endptr = &answer[ret];
60 ptr = startptr + HFIXEDSZ; /* advance past header */
63 memset(expanded_buf, 0, sizeof(expanded_buf));
64 ret = dn_expand(startptr,
74 ptr += INT16SZ + INT32SZ;
78 lprintf(9, "ret=%d, type=%d\n", ret, type);
93 /* FIX not done yet */