On Tue, Jan 23, 2007 at 12:19:22PM -0500, Wakko Warner wrote:
> Alexander Shikoff wrote:
> > Thanks a lot. I've read that chapter a lot of times before wrote to this
> > mailing list. What about the case if database field contains not a single
> > IP-address but a network address? In MySQL there is no way to write
> > WHERE condition which will match IP-address against address of network.
> >
> > Example:
> >
> > SELECT `prefix` FROM `nets` WHERE `class` = 'WHITE' returns '193.0.0.0/21'.
> >
> > hostlist white_list = mysql;SELECT `prefix` FROM `nets` WHERE `class` = 'WHITE'
> > acl_check_rcpt:
> > warn
> > message = host is white
> > hosts = +white_list
> >
> > 'warn' condition in example above will match any host address because a query
> > to database is always successful.
>
> This is a WHERE fragment that I use:
> data='$sender_host_address' OR \
> INET_ATON('$sender_host_address') & (-1 << 32 - SUBSTRING_INDEX(data,'/',-1)) = INET_ATON(SUBSTRING_INDEX(data,'/',1))
>
> The table contains more than just ip lists so the column's name is data.
> The format is your typical IP or network/bits notation. There's no error
> checking so if the network is a host address, the match will always fail.
Thanks a lot! This works for me.
--
Kind Regards, Alexander Shikoff
minotaur@???