xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/tok822_resolve.c (revision 41fbaed053f8fbfdf9d2a4ee0a7386a3c83f8505)
1*41fbaed0Stron /*	$NetBSD: tok822_resolve.c,v 1.1.1.1 2009/06/23 10:08:48 tron Exp $	*/
2*41fbaed0Stron 
3*41fbaed0Stron /*++
4*41fbaed0Stron /* NAME
5*41fbaed0Stron /*	tok822_resolve 3
6*41fbaed0Stron /* SUMMARY
7*41fbaed0Stron /*	address resolving, client interface
8*41fbaed0Stron /* SYNOPSIS
9*41fbaed0Stron /*	#include <tok822.h>
10*41fbaed0Stron /*
11*41fbaed0Stron /*	void	tok822_resolve(addr, reply)
12*41fbaed0Stron /*	TOK822	*addr;
13*41fbaed0Stron /*	RESOLVE_REPLY *reply;
14*41fbaed0Stron /*
15*41fbaed0Stron /*	void	tok822_resolve_from(sender, addr, reply)
16*41fbaed0Stron /*	const char *sender;
17*41fbaed0Stron /*	TOK822	*addr;
18*41fbaed0Stron /*	RESOLVE_REPLY *reply;
19*41fbaed0Stron /* DESCRIPTION
20*41fbaed0Stron /*	tok822_resolve() takes an address token tree and finds out the
21*41fbaed0Stron /*	transport to deliver via, the next-hop host on that transport,
22*41fbaed0Stron /*	and the recipient relative to that host.
23*41fbaed0Stron /*
24*41fbaed0Stron /*	tok822_resolve_from() allows the caller to specify sender context
25*41fbaed0Stron /*	that will be used to look up sender-dependent relayhost information.
26*41fbaed0Stron /* SEE ALSO
27*41fbaed0Stron /*	resolve_clnt(3) basic resolver client interface
28*41fbaed0Stron /* LICENSE
29*41fbaed0Stron /* .ad
30*41fbaed0Stron /* .fi
31*41fbaed0Stron /*	The Secure Mailer license must be distributed with this software.
32*41fbaed0Stron /* AUTHOR(S)
33*41fbaed0Stron /*	Wietse Venema
34*41fbaed0Stron /*	IBM T.J. Watson Research
35*41fbaed0Stron /*	P.O. Box 704
36*41fbaed0Stron /*	Yorktown Heights, NY 10598, USA
37*41fbaed0Stron /*--*/
38*41fbaed0Stron 
39*41fbaed0Stron /* System library. */
40*41fbaed0Stron 
41*41fbaed0Stron #include <sys_defs.h>
42*41fbaed0Stron 
43*41fbaed0Stron /* Utility library. */
44*41fbaed0Stron 
45*41fbaed0Stron #include <vstring.h>
46*41fbaed0Stron #include <msg.h>
47*41fbaed0Stron 
48*41fbaed0Stron /* Global library. */
49*41fbaed0Stron 
50*41fbaed0Stron #include "resolve_clnt.h"
51*41fbaed0Stron #include "tok822.h"
52*41fbaed0Stron 
53*41fbaed0Stron /* tok822_resolve - address rewriting interface */
54*41fbaed0Stron 
tok822_resolve_from(const char * sender,TOK822 * addr,RESOLVE_REPLY * reply)55*41fbaed0Stron void    tok822_resolve_from(const char *sender, TOK822 *addr,
56*41fbaed0Stron 			            RESOLVE_REPLY *reply)
57*41fbaed0Stron {
58*41fbaed0Stron     VSTRING *intern_form = vstring_alloc(100);
59*41fbaed0Stron 
60*41fbaed0Stron     if (addr->type != TOK822_ADDR)
61*41fbaed0Stron 	msg_panic("tok822_resolve: non-address token type: %d", addr->type);
62*41fbaed0Stron 
63*41fbaed0Stron     /*
64*41fbaed0Stron      * Internalize the token tree and ship it to the resolve service.
65*41fbaed0Stron      * Shipping string forms is much simpler than shipping parse trees.
66*41fbaed0Stron      */
67*41fbaed0Stron     tok822_internalize(intern_form, addr->head, TOK822_STR_DEFL);
68*41fbaed0Stron     resolve_clnt_query_from(sender, vstring_str(intern_form), reply);
69*41fbaed0Stron     if (msg_verbose)
70*41fbaed0Stron 	msg_info("tok822_resolve: from=%s addr=%s -> chan=%s, host=%s, rcpt=%s",
71*41fbaed0Stron 		 sender,
72*41fbaed0Stron 		 vstring_str(intern_form), vstring_str(reply->transport),
73*41fbaed0Stron 		 vstring_str(reply->nexthop), vstring_str(reply->recipient));
74*41fbaed0Stron 
75*41fbaed0Stron     vstring_free(intern_form);
76*41fbaed0Stron }
77