dovecot-2.2: imap: use human-readable helper macro in remote_ip_...
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 27 18:19:16 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/52ea7c8b587c
changeset: 17411:52ea7c8b587c
user: Phil Carmody <phil at dovecot.fi>
date: Tue May 27 21:17:34 2014 +0300
description:
imap: use human-readable helper macro in remote_ip_is_usable
More readable, but helpfully shuts up sparse which complained about some
constants being long.
Signed-off-by: Phil Carmody <phil at dovecot.fi>
diffstat:
src/imap/cmd-idle.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diffs (25 lines):
diff -r c2da4daac0b8 -r 52ea7c8b587c src/imap/cmd-idle.c
--- a/src/imap/cmd-idle.c Tue May 27 21:17:34 2014 +0300
+++ b/src/imap/cmd-idle.c Tue May 27 21:17:34 2014 +0300
@@ -168,15 +168,17 @@
if (ip->family == 0)
return FALSE;
if (ip->family == AF_INET) {
+#define IP4(a,b,c,d) ((unsigned)(a)<<24|(unsigned)(b)<<16|(unsigned)(c)<<8|(unsigned)(d))
addr = ip->u.ip4.s_addr;
- if (addr >= 167772160 && addr <= 184549375)
+ if (addr >= IP4(10,0,0,0) && addr <= IP4(10,255,255,255))
return FALSE; /* 10/8 */
- if (addr >= 3232235520 && addr <= 3232301055)
+ if (addr >= IP4(192,168,0,0) && addr <= IP4(192,168,255,255))
return FALSE; /* 192.168/16 */
- if (addr >= 2886729728 && addr <= 2887778303)
+ if (addr >= IP4(172,16,0,0) && addr <= IP4(172,31,255,255))
return FALSE; /* 172.16/12 */
- if (addr >= 2130706432 && addr <= 2147483647)
+ if (addr >= IP4(127,0,0,0) && addr <= IP4(127,255,255,255))
return FALSE; /* 127/8 */
+#undef IP4
}
#ifdef HAVE_IPV6
else if (ip->family == AF_INET6) {
More information about the dovecot-cvs
mailing list