pdp 2010/06/06 00:50:18 BST
Modified files:
exim-doc/doc-docbook spec.xfpt
exim-doc/doc-txt ChangeLog NewStuff
exim-src/src expand.c functions.h verify.c
Log:
New expansion operator: reverse_ip
Revision Changes Path
1.79 +15 -0 exim/exim-doc/doc-docbook/spec.xfpt
1.622 +2 -0 exim/exim-doc/doc-txt/ChangeLog
1.169 +8 -0 exim/exim-doc/doc-txt/NewStuff
1.106 +21 -0 exim/exim-src/src/expand.c
1.50 +1 -0 exim/exim-src/src/functions.h
1.55 +5 -3 exim/exim-src/src/verify.c
Index: spec.xfpt
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-docbook/spec.xfpt,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- spec.xfpt 5 Jun 2010 21:42:53 -0000 1.78
+++ spec.xfpt 5 Jun 2010 23:50:18 -0000 1.79
@@ -1,4 +1,4 @@
-. $Cambridge: exim/exim-doc/doc-docbook/spec.xfpt,v 1.78 2010/06/05 21:42:53 pdp Exp $
+. $Cambridge: exim/exim-doc/doc-docbook/spec.xfpt,v 1.79 2010/06/05 23:50:18 pdp Exp $
.
. /////////////////////////////////////////////////////////////////////////////
. This is the primary source of the Exim Manual. It is an xfpt document that is
@@ -9615,6 +9615,21 @@
random().
+.vitem &*${reverse_ip:*&<&'ipaddr'&>&*}*&
+.cindex "expansion" "IP address"
+This operator reverses an IP address; for IPv4 addresses, the result is in
+dotted-quad decimal form, while for IPv6 addreses the result is in
+dotted-nibble hexadecimal form. In both cases, this is the "natural" form
+for DNS. For example,
+.code
+${reverse_ip:192.0.2.4} and ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.3}
+.endd
+returns
+.code
+4.2.0.192 and 3.0.2.0.0.0.0.c.d.c.b.a.1.0.0.0.9.0.0.0.2.4.c.0.8.b.d.0.1.0.0.2
+.endd
+
+
.vitem &*${rfc2047:*&<&'string'&>&*}*&
.cindex "expansion" "RFC 2047"
.cindex "RFC 2047" "expansion operator"
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.621
retrieving revision 1.622
diff -u -r1.621 -r1.622
--- ChangeLog 5 Jun 2010 11:13:29 -0000 1.621
+++ ChangeLog 5 Jun 2010 23:50:18 -0000 1.622
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.621 2010/06/05 11:13:29 pdp Exp $
+$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.622 2010/06/05 23:50:18 pdp Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -31,6 +31,8 @@
filtering; old API available if built with WITH_OLD_CLAMAV_STREAM=yes
NB: ClamAV planning to remove STREAM in "middle of 2010".
+PP/09 Implemented reverse_ip expansion operator.
+
Exim version 4.72
-----------------
Index: NewStuff
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/NewStuff,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- NewStuff 5 Jun 2010 11:13:29 -0000 1.168
+++ NewStuff 5 Jun 2010 23:50:18 -0000 1.169
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.168 2010/06/05 11:13:29 pdp Exp $
+$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.169 2010/06/05 23:50:18 pdp Exp $
New Features in Exim
--------------------
@@ -43,6 +43,14 @@
malware-scanning framework. This is intended purely as a debugging aid
to ensure that Exim's scanning is working, not to replace other tools.
+ 5. There is a new expansion operator, "reverse_ip", which will reverse IP
+ addresses; IPv4 into dotted quad, IPv6 into dotted nibble. Examples:
+
+ ${reverse_ip:192.0.2.4}
+ -> 4.2.0.192
+ ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.3}
+ -> 3.0.2.0.0.0.0.c.d.c.b.a.1.0.0.0.9.0.0.0.2.4.c.0.8.b.d.0.1.0.0.2
+
Version 4.72
------------
Index: expand.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/expand.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- expand.c 16 Nov 2009 19:50:36 -0000 1.105
+++ expand.c 5 Jun 2010 23:50:18 -0000 1.106
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/expand.c,v 1.105 2009/11/16 19:50:36 nm4 Exp $ */
+/* $Cambridge: exim/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 @@
US"from_utf8",
US"local_part",
US"quote_local_part",
+ US"reverse_ip",
US"time_eval",
US"time_interval"};
@@ -163,6 +164,7 @@
EOP_FROM_UTF8,
EOP_LOCAL_PART,
EOP_QUOTE_LOCAL_PART,
+ EOP_REVERSE_IP,
EOP_TIME_EVAL,
EOP_TIME_INTERVAL };
@@ -5790,6 +5792,25 @@
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:
Index: functions.h
===================================================================
RCS file: /home/cvs/exim/exim-src/src/functions.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- functions.h 5 Jun 2010 11:13:30 -0000 1.49
+++ functions.h 5 Jun 2010 23:50:18 -0000 1.50
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/functions.h,v 1.49 2010/06/05 11:13:30 pdp Exp $ */
+/* $Cambridge: exim/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 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);
Index: verify.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/verify.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- verify.c 16 Nov 2009 19:50:37 -0000 1.54
+++ verify.c 5 Jun 2010 23:50:18 -0000 1.55
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/verify.c,v 1.54 2009/11/16 19:50:37 nm4 Exp $ */
+/* $Cambridge: exim/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 @@
/*************************************************
-* 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];