| 158 | } |
| 159 | |
| 160 | static bool IsValid(const struct wireaddr *addr) |
| 161 | { |
| 162 | // unspecified IPv6 address (::/128) |
| 163 | unsigned char ipNone6[16] = {}; |
| 164 | if (IsIPv6(addr) && RawEq(addr, ipNone6, sizeof(ipNone6))) |
| 165 | return false; |
| 166 | |
| 167 | // documentation IPv6 address |
| 168 | if (IsRFC3849(addr)) |
| 169 | return false; |
| 170 | |
| 171 | if (IsInternal(addr)) |
| 172 | return false; |
| 173 | |
| 174 | if (IsIPv4(addr)) |
| 175 | { |
| 176 | // INADDR_NONE |
| 177 | uint32_t ipNone = INADDR_NONE; |
| 178 | if (RawEq(addr, &ipNone, sizeof(ipNone))) |
| 179 | return false; |
| 180 | |
| 181 | // 0 |
| 182 | ipNone = 0; |
| 183 | if (RawEq(addr, &ipNone, sizeof(ipNone))) |
| 184 | return false; |
| 185 | } |
| 186 | |
| 187 | return true; |
| 188 | } |
| 189 | |
| 190 | static bool IsRoutable(const struct wireaddr *addr) |
| 191 | { |