[This is preliminary documentation and subject to change.]
DWORD
APIENTRY
DisableInterface(
IN DWORD dwIndex
)
/*++
Routine Description
Called by the IP Router Manger to disable an interface. This is
usually in response to an admin setting the AdminStatus in IP to
DOWN. This is different from an admin just disabling the bEnabled
flag in our config because that is opaque to IP. That is a routing
protocol specific disable and is conveyed to us via
SetInterfaceConfig() calls. THIS IS AN IMPORTANT DISTINCTION. A
ROUTING PROTOCOL NEEDS TO MANTAIN TWO STATES - AN NT STATE AND A
PROTOCOL SPECIFIC STATE.
Arguments
dwIndex The index of the interface to disable
Return Value
ERROR_INVALID_PARAMETER
NO_ERROR
--*/
{
PNT_IF pIf;
PLIST_ENTRY pleNode;
PINTRNL_IF pBind;
DWORD dwResult;
EnterProtocolApi();
TraceEnter("DisableInterface");
EnterCriticalSection(&g_csIfListLock);
pIf = GetIfBlockGivenIndex(dwIndex);
if(pIf == NULL)
{
LeaveCriticalSection(&g_csIfListLock);
Trace1(ERR,
"DisableInterface: Interface %d does not exist",
dwIndex);
TraceLeave("DisableInterface");
ExitProtocolApi();
return ERROR_INVALID_PARAMETER;
}
if(!IsNtEnabled(pIf))
{
//
// Nothing new happening
//
Trace1(INTF,
"DisableInterface: Disable received for %S which was never enabled",
pIf->pwszIfName);
LeaveCriticalSection(&g_csIfListLock);
TraceLeave("DisableInterface");
ExitProtocolApi();
return NO_ERROR;
}
ClearNtEnabled(pIf);
if(IsNtBound(pIf))
{
//
// Since it was enabled and is bound, it must have been
// activated, so deactivate the bindings now
//
for(pleNode = pIf->leInternalIfHead.Flink;
pleNode != &pIf->leInternalIfHead;
pleNode = pleNode->Flink)
{
pBind = CONTAINING_RECORD(pleNode, INTRNL_IF, leInternalIfLink);
if(pBind->dwState == BINDING_UP)
{
//
// This binding had been successfully activated
//
dwResult = DeactivateBinding(pBind);
if(dwResult != NO_ERROR)
{
Trace2(ERR,
"DisableInterface: Unable to deactivate %d.%d.%d.%d over %S",
PRINT_ADDRESS(pBind->dwAddress),
pIf->pwszIfName);
}
}
}
}
LeaveCriticalSection(&g_csIfListLock);
TraceLeave("DisableInterface");
ExitProtocolApi();
return NO_ERROR;
}