?? nat_cleanup.c
字號:
/* nat_cleanup.c - library that supplies nat_cleanup() */
/* Copyright 2000-2004 Wind River Systems, Inc. */
/* @format.tab-size 4, @format.use-tabs true, @format.new-line lf */
/*
modification history
--------------------
01g,28oct03,zhu updated NAT hook cleanups
01f,29aug03,zhu updated the format for refgen
01e,16jun03,myz Use new fragment translation cleanup routine.
01d,12may03,myz added natIcmpErrorHookRemove in nat_cleanup.
01c,25apr03,myz make dllFreeList a global func and add delays in nat_cleanup
01b,24apr03,zhu updated copyright
01a,21apr03,myz enhanced nat_cleanup function, and added dllFreeList
040803 vks updated Copyright info
040303 vks replaced table_free with free
092502 vvv modified fragment lists to use lstLib instead of rw_container
092402 vvv replaced rw_container references with direct linked list
access to improve performance
030901 tk Add call to delete natInitSync semaphore
*/
/*
DESCRIPTION
This library provides nat_cleanup(), a routine that you can use to
shut down WIND NET NAT entirely, thus freeing all its associated
resources (configuration information, tasks, message queues, etc.).
*/
#include "nat.h"
extern void natIcmpErrorHookRemove (void);
extern void natFilterHooksDelete (void);
/****************************************************************************/
/****************************************************************************/
/****************************************************************************
*
* nat_cleanup - shut down WIND NET NAT, free all associated resources
*
* Call this function to shut down WIND NET NAT entirely and free all its
* associated resources.
*
* 'Note:' To merely pause WIND NET NAT, you can call natEnable() with
* the <enable> parameter set to FALSE.
*
*/
void nat_cleanup (void)
{
IP_TRANSLATION_ENTRY *sptr_ip_translation_entry;
/* remove the NAT preinput and output filter hooks */
natFilterHooksDelete();
/* remove the NAT ICMP error hook */
natIcmpErrorHookRemove();
/* give the unhooked NAT engine some time in case it's in progress */
taskDelay(2);
/* delete the NAT task */
natTaskDelete();
/* cleanup the rest of resource */
for (sptr_ip_translation_entry = (IP_TRANSLATION_ENTRY *) DLL_FIRST ((DL_LIST *) &nat.natg.ip_translation_list);
sptr_ip_translation_entry != NULL;
sptr_ip_translation_entry = (IP_TRANSLATION_ENTRY *) DLL_FIRST ((DL_LIST *) &nat.natg.ip_translation_list))
{
dllRemove ((DL_LIST *) &nat.natg.ip_translation_list, (DL_NODE *) sptr_ip_translation_entry);
if (sptr_ip_translation_entry->sptr_local_address_use_entry != NULL)
{
sptr_ip_translation_entry->sptr_local_address_use_entry->address_in_use = FALSE;
}
free (sptr_ip_translation_entry);
}
if(nat.pFragTranResrc)
natFragTranCleanup(nat.pFragTranResrc);
delete_tcp_connection_entry_list ();
/* Clean-up passthrough list */
lstFree (&nat.passthru_list);
/* Clean-up agent list */
lstFree (&nat.agent_list);
/* Clean-up bind list */
lstFree (&nat.bind_list);
/* Clean up the semaphores */
if (udpListLock)
semDelete (udpListLock);
if (tcpListLock)
semDelete (tcpListLock);
if (spoofingPortLock)
semDelete (spoofingPortLock);
if (natInitSync)
semDelete (natInitSync);
if (ipListLock)
semDelete(ipListLock);
if (bindListLock)
semDelete(bindListLock);
if (agentListLock)
semDelete(agentListLock);
if(natentrylock)
semDelete(natentrylock);
if (nat.natg.global_address_pool != NULL)
{
free (nat.natg.global_address_pool);
nat.natg.global_address_pool = NULL;
}
nat.enabled = FALSE;
}
/************************************************************************/
void delete_sequence_entry_list (SEQUENCE_HEADER *sptr_sequence_list)
{
dllFreeList ((DL_LIST *) sptr_sequence_list);
}
/***************************************************************************
*
* dllFreeList - Free a link list
*
* Free a link list.
*
* NOMANUAL
*/
void dllFreeList
(
DL_LIST * pList
)
{
DL_NODE * pNode;
DL_NODE * pPrevNode;
pNode = DLL_FIRST(pList);
while (pNode)
{
pPrevNode = pNode;
pNode = DLL_NEXT(pNode);
free((void *)pPrevNode);
}
dllInit(pList);
}
/************************************************************************/
void delete_tcp_connection_entry_list ()
{
unsigned long nat_timeisup_count;
NAT_CURRENCY_TRANSLATION_ENTRY *sptr_tcp_translation_entry=NULL;
semTake(natentrylock, WAIT_FOREVER);
for( nat_timeisup_count=0;nat_timeisup_count< MAX_NAT_ENTRYS; nat_timeisup_count++)
{
sptr_tcp_translation_entry=&natTabArray[nat_timeisup_count];
delete_sequence_entry_list (&sptr_tcp_translation_entry->local_sequence_delta_list);
delete_sequence_entry_list (&sptr_tcp_translation_entry->global_sequence_delta_list);
}
semGive(natentrylock);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -