MCPcopy Create free account
hub / github.com/apache/trafficserver / recordIPCheck

Function recordIPCheck

src/records/RecUtils.cc:420–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420bool
421recordIPCheck(const char *pattern, const char *value)
422{
423 // regex_t regex;
424 // int result;
425 bool check;
426 const char *range_pattern = R"(\[[0-9]+\-[0-9]+\]\\\.\[[0-9]+\-[0-9]+\]\\\.\[[0-9]+\-[0-9]+\]\\\.\[[0-9]+\-[0-9]+\])";
427 const char *ip_pattern = "[0-9]*[0-9]*[0-9].[0-9]*[0-9]*[0-9].[0-9]*[0-9]*[0-9].[0-9]*[0-9]*[0-9]";
428
429 Tokenizer dotTok1(".");
430 Tokenizer dotTok2(".");
431
432 check = true;
433 if (recordRegexCheck(range_pattern, pattern) && recordRegexCheck(ip_pattern, value)) {
434 if (dotTok1.Initialize(const_cast<char *>(pattern), COPY_TOKS) == 4 &&
435 dotTok2.Initialize(const_cast<char *>(value), COPY_TOKS) == 4) {
436 for (int i = 0; i < 4 && check; i++) {
437 if (!recordRangeCheck(dotTok1[i], dotTok2[i])) {
438 check = false;
439 }
440 }
441 if (check) {
442 return true;
443 }
444 }
445 } else if (strcmp(value, "") == 0) {
446 return true;
447 }
448 return false;
449}
450} // namespace
451
452bool

Callers 1

RecordValidityCheckFunction · 0.85

Calls 4

recordRegexCheckFunction · 0.85
recordRangeCheckFunction · 0.85
strcmpFunction · 0.85
InitializeMethod · 0.45

Tested by

no test coverage detected