MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / IsValid

Method IsValid

src/netaddress.cpp:187–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187bool CNetAddr::IsValid() const
188{
189 // Cleanup 3-byte shifted addresses caused by garbage in size field
190 // of addr messages from versions before 0.2.9 checksum.
191 // Two consecutive addr messages look like this:
192 // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26...
193 // so if the first length field is garbled, it reads the second batch
194 // of addr misaligned by 3 bytes.
195 if (memcmp(ip, pchIPv4+3, sizeof(pchIPv4)-3) == 0)
196 return false;
197
198 // unspecified IPv6 address (::/128)
199 unsigned char ipNone6[16] = {};
200 if (memcmp(ip, ipNone6, 16) == 0)
201 return false;
202
203 // documentation IPv6 address
204 if (IsRFC3849())
205 return false;
206
207 if (IsInternal())
208 return false;
209
210 if (IsIPv4())
211 {
212 // INADDR_NONE
213 uint32_t ipNone = INADDR_NONE;
214 if (memcmp(ip+12, &ipNone, 4) == 0)
215 return false;
216
217 // 0
218 ipNone = 0;
219 if (memcmp(ip+12, &ipNone, 4) == 0)
220 return false;
221 }
222
223 return true;
224}
225
226bool CNetAddr::IsRoutable() const
227{

Callers 2

CSubNetMethod · 0.45
MatchMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected