Check if host is in the black list and how it should be managed.
- Parameters
-
hName | Pointer to the host name or address. |
bList | Optional pointer to a private black list. |
rbuff | Pointer to the buffer to contain the redirect response. If nil, the host is not redirected. |
rblen | The size of rbuff. If zero or insufficiently large the host is not redirected. |
- Returns
- < -1 Host is in the black list and would be redirected; but either rbuff was nil or the buffer was too small. The abs(returned value) is the size the buffer should have been.
-
= -1 Host is in the black list and should not be redirected.
-
= 0 Host not in the black list.
-
> 0 Host is in the black list and should be redirected. The return value is the size of the redirect response placed in the supplied buffer.
Definition at line 515 of file XrdCmsBlackList.cc.
517{
519 int hLen, retval;
520 bool doUnLk;
521
522
523
524 if (!hName || !
blSched)
return 0;
525
526
527
528 if (bList) doUnLk = false;
529 else {doUnLk = true;
532 }
533
534
535
536 if (!bList)
538 return 0;
539 }
540
541
542
543 hLen = strlen(hName);
544 while(bList)
545 {Hdr.
info = bList->dval;
547 {
if (!strcmp(hName, bList->
text))
break;}
548 else if (hLen >= Hdr.
v.totLen)
550 || !strncmp(bList->
text, hName, Hdr.
v.pfxLen))
552 || !strncmp(bList->
text+Hdr.
v.pfxLen+1,
553 hName + (hLen - Hdr.
v.sfxLen),
554 Hdr.
v.sfxLen))
break;
555 }
556 }
558 }
559
560
561
562 if (bList)
565 if (rP)
566 {retval = rP->sval[1];
567 if (!rBuff || retval > rBLen) retval = -retval;
568 else {memcpy(rBuff, &(rP->sval[2]), sizeof(short));
569 memcpy(rBuff+
sizeof(
short), rP->
text, rP->sval[0]);
570 }
571 } else retval = -1;
572 }
573 }
else retval = (
isWList ? -1 : 0);
574
575
576
578 return retval;
579}
struct BL_Info::@243254232005125207266263157042265104236176317146 v
References XrdCms::blMutex, XrdCms::blReal, XrdCms::blRedr, XrdCms::blSched, BL_Info::exact, BL_Info::info, XrdCms::isWList, XrdSysMutex::Lock(), XrdOucTList::next, BL_Info::redir, BL_Info::rmask, XrdOucTList::text, XrdSysMutex::UnLock(), and BL_Info::v.
Referenced by XrdCmsLogin::Admit(), and XrdCmsCluster::BlackList().