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