MCPcopy Create free account
hub / github.com/ElementsProject/lightning / IsValid

Function IsValid

connectd/netaddress.c:160–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160static 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
190static bool IsRoutable(const struct wireaddr *addr)
191{

Callers 2

IsRoutableFunction · 0.85
mainFunction · 0.85

Calls 5

IsIPv6Function · 0.85
RawEqFunction · 0.85
IsRFC3849Function · 0.85
IsInternalFunction · 0.85
IsIPv4Function · 0.85

Tested by 1

mainFunction · 0.68