Address Transformation The Parsing of E−mail Addresses

20.3.3 Address Transformation

The rhs of a rewrite rule specifies the format to use for rewriting the address, i.e., the appropriate transformation algorithm. It is defined using the same values as for lhs: literals, macros, and special metasymbols. Literals in the rhs are written into the new address exactly as they appear. Macros are expanded and then written. The metasymbols perform special functions in the transformation. Some metasymbols and their functions are: Metasymbol Meaning n Substitute indefinite token n [name] Substitute canonical name n Call ruleset n Terminate ruleset : Terminate rewrite rule … Special syntax explained later The following example demonstrates how indefinite tokens are used: Assume the old−fashioned input address but very illustrative one for this purpose bjlbithost.bitnet has been preliminarily processed and now is: bjlbithost.bitnet • Assume the current rewrite rule is: R++.bitnet 12B Use the BITNET relay • Assume that the macro B, which is the BITNET relay, is previously defined as cunyvm.cuny.edu. • The complete transformation process is presented in Figure 20.6. A brief explanation of each step in the address transformation follows: The address matches the pattern because it contains one or more tokens before the literals the token bjl, and one or more tokens between literals , and .bitnet the token bithost. • The pattern match produces two indefinite tokens, 1 with the value bjl and 2 with the value bithost that are used in further address transformation. • The transformation contains the indefinite token 1, a literal , the indefinite token 2, a literal , the macro B, and a literal . • Keeping in mind values for the indefinite tokens 1 and 2 and the macro B, the input address can be rewritten as: bjlbithostcunyvm.cuny.edu • 488 Figure 20.6: Rewriting an address. Note: BITNET relay host B is cunyvm.cuny.edu This example explains the implementation of the metasymbol n, and the substitution of the indefinite tokens. However, there are also other metasymbols that could be used in the rules rhs: The [ name ] metasymbol is based on the DNS and converts a hosts nickname or its IP address to its canonical name by passing the value name to the Name Server for resolution. • The n metasymbol calls a ruleset n and passes the address defined by the remainder of the transformation to the ruleset n for processing, for example: 912 ♦ This transformation calls ruleset 9 metasymbol 9, and passes the contents of 1, a literal , and the contents of 2 to ruleset 9 for processing. When ruleset 9 finishes processing, it returns a rewritten address to the calling rule. The return transformed address is then compared again to the pattern in the calling rule. If it still matches, ruleset 9 is called again. • The recursion built into rewrite rules creates the possibility for infinite loops. The and : metasymbols are used to control processing; the terminates the entire ruleset and the remainder of the transformation is the value returned by the ruleset; the : controls the execution of the individual rewrite rule only once. So these two metasymbols could be used to prevent recursion and looping. •

20.4 Testing sendmail Configuration