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