MCPcopy Create free account
hub / github.com/devkitPro/3ds-hbmenu / validateIp

Function validateIp

source/ui/netsender.c:462–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462static bool validateIp(const char* ip, size_t len)
463{
464 if (len < 7) // if it's not long enough to hold 4 digits and 3 separators, it's too short.
465 return false;
466
467 struct addrinfo *info;
468 if (getaddrinfo(ip, NULL, NULL, &info) == 0) // check it's a valid address first
469 {
470 dsaddr = ((struct sockaddr_in*)info->ai_addr)->sin_addr;
471 freeaddrinfo(info);
472 // this won't error, so 0.0.0.0 (the default ip) will return false and force the user to put something else
473 return inet_addr(ip) != 0;
474 }
475
476 return false;
477}
478
479static SwkbdCallbackResult callback(void *user, const char **ppMessage, const char *text, size_t textlen)
480{

Callers 1

callbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected