diff options
author | Phil Pennock <pdp@exim.org> | 2010-06-05 23:50:18 +0000 |
---|---|---|
committer | Phil Pennock <pdp@exim.org> | 2010-06-05 23:50:18 +0000 |
commit | 83e029d54f2edd11b1706609832693c9540f7783 (patch) | |
tree | 37474ff42b06383231b5a7fec9cb0187509b42c5 /src | |
parent | 22380b862c5f5b1cdc119e763b3ab8beb89723f3 (diff) |
New expansion operator: reverse_ip
Diffstat (limited to 'src')
-rw-r--r-- | src/src/expand.c | 23 | ||||
-rw-r--r-- | src/src/functions.h | 3 | ||||
-rw-r--r-- | src/src/verify.c | 10 |
3 files changed, 30 insertions, 6 deletions
diff --git a/src/src/expand.c b/src/src/expand.c index 6e47125bb..e5daff1a8 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.105 2009/11/16 19:50:36 nm4 Exp $ */ +/* $Cambridge: exim/src/src/expand.c,v 1.106 2010/06/05 23:50:18 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -156,6 +156,7 @@ static uschar *op_table_underscore[] = { US"from_utf8", US"local_part", US"quote_local_part", + US"reverse_ip", US"time_eval", US"time_interval"}; @@ -163,6 +164,7 @@ enum { EOP_FROM_UTF8, EOP_LOCAL_PART, EOP_QUOTE_LOCAL_PART, + EOP_REVERSE_IP, EOP_TIME_EVAL, EOP_TIME_INTERVAL }; @@ -5790,6 +5792,25 @@ while (*s != 0) continue; } + /* Reverse IP, including IPv6 to dotted-nibble */ + + case EOP_REVERSE_IP: + { + int family, maskptr; + uschar reversed[128]; + + family = string_is_ip_address(sub, &maskptr); + if (family == 0) + { + expand_string_message = string_sprintf( + "reverse_ip() not given an IP address [%s]", sub); + goto EXPAND_FAILED; + } + invert_address(reversed, sub); + yield = string_cat(yield, &size, &ptr, reversed, Ustrlen(reversed)); + continue; + } + /* Unknown operator */ default: diff --git a/src/src/functions.h b/src/src/functions.h index 436038735..00f8bb7ba 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/functions.h,v 1.49 2010/06/05 11:13:30 pdp Exp $ */ +/* $Cambridge: exim/src/src/functions.h,v 1.50 2010/06/05 23:50:18 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -141,6 +141,7 @@ extern int host_nmtoa(int, int *, int, uschar *, int); extern uschar *host_ntoa(int, const void *, uschar *, int *); extern int host_scan_for_local_hosts(host_item *, host_item **, BOOL *); +extern void invert_address(uschar *, uschar *); extern int ip_bind(int, int, uschar *, int); extern int ip_connect(int, int, uschar *, int, int); extern void ip_keepalive(int, uschar *, BOOL); diff --git a/src/src/verify.c b/src/src/verify.c index cc821a201..371883a37 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/verify.c,v 1.54 2009/11/16 19:50:37 nm4 Exp $ */ +/* $Cambridge: exim/src/src/verify.c,v 1.55 2010/06/05 23:50:18 pdp Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2513,16 +2513,18 @@ return verify_check_this_host(listptr, sender_host_cache, NULL, /************************************************* -* Invert an IP address for a DNS black list * +* Invert an IP address * *************************************************/ -/* +/* Originally just used for DNS xBL lists, now also used for the +reverse_ip expansion operator. + Arguments: buffer where to put the answer address the address to invert */ -static void +void invert_address(uschar *buffer, uschar *address) { int bin[4]; |