Mercurial > dnsbl
comparison src/context.cpp @ 388:2354a1944e49
start parsing spf txt records
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 06 Mar 2017 16:22:15 -0800 |
parents | 7b7066a51c33 |
children | bcef093b1ba6 |
comparison
equal
deleted
inserted
replaced
387:616e46e9b8f0 | 388:2354a1944e49 |
---|---|
1138 if (b) *b = '\0'; | 1138 if (b) *b = '\0'; |
1139 char *s = strchr(p, '/'); | 1139 char *s = strchr(p, '/'); |
1140 if (s) *s = '\0'; | 1140 if (s) *s = '\0'; |
1141 in_addr ipx; | 1141 in_addr ipx; |
1142 if (inet_aton(p, &ipx)) { | 1142 if (inet_aton(p, &ipx)) { |
1143 if (s) { | 1143 uint32_t ipy = htonl(ipx.s_addr); |
1144 int mask = atoi(s+1); | 1144 int mask = (s) ? atoi(s+1) : 32; |
1145 if ((mask >= 16) && (mask <= 32)) { | 1145 if ((mask >= 16) && (mask <= 32)) { |
1146 int low = (1 << (32-mask)) - 1; | 1146 uint32_t low = (1 << (32-mask)) - 1; |
1147 ipx.s_addr &= low ^ 0xffffffff; | 1147 ipy &= low ^ 0xffffffff; |
1148 if ((ip >= ipx.s_addr) && (ip <= ipx.s_addr + low)) { | 1148 if ((ipy <= ip) && (ip <= ipy + low)) { |
1149 log(priv->queueid, "match %s", p); | 1149 log(priv->queueid, "match %s", p); |
1150 if (s) log(priv->queueid, "match /%s", s+1); | 1150 if (s) log(priv->queueid, "match /%s", s+1); |
1151 return true; | 1151 return true; |
1152 } | |
1153 } | 1152 } |
1154 } | 1153 } |
1155 } | 1154 } |
1156 if (b) *b = ' '; | 1155 if (b) *b = ' '; |
1157 if (s) *s = '/'; | 1156 if (s) *s = '/'; |