⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 natmgmt.c

📁 nat PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
                                  pNatClass->ip_translation_entry_timer;        pNatTblEntry->natUdpSessionMaxIdleTime = 0;        pNatTblEntry->natIcmpSessionMaxIdleTime = 0;        }    /* Fill up the common timer values */    pNatTblEntry->natTcpUpSessionMaxIdleTime =                                    pNatClass->tcp_connected_timer;    pNatTblEntry->natTcpDiscSessionMaxIdleTime =                                   pNatClass->tcp_disconnected_timer;    pNatTblEntry->natTcpClosingSessionMaxIdleTime =                                   pNatClass->tcp_closing_timer;    pNatTblEntry->natTcpSyncSessionMaxIdleTime =                                    pNatClass->tcp_connecting_timer;    /* Fill up the log mask value using the various debug values */    if (pNatClass->printing_enabled)        pNatTblEntry->natLogMask |= NAT_PRINT_ENABLED;    if (pNatClass->initialization_printing_enabled)        pNatTblEntry->natLogMask |= NAT_INIT_PRINT_ENABLED;    if (pNatClass->trace_printing_enabled)        pNatTblEntry->natLogMask |= NAT_TRACE_PRINT_ENABLED;    if (pNatClass->data_printing_enabled)        pNatTblEntry->natLogMask |= NAT_DATA_PRINT_ENABLED;    if (pNatClass->error_printing_enabled)        pNatTblEntry->natLogMask |= NAT_ERROR_PRINT_ENABLED;    if (pNatClass->enabled)	pNatTblEntry->natEnable = TRUE;    else         /* Do the boolean formatting for FALSE as per the MIB expectations */	pNatTblEntry->natEnable = 2;    if (pNatClass->static_entries_enabled)	pNatTblEntry->natStaticBindEnable = TRUE;    else         /* Do the boolean formatting for FALSE as per the MIB expectations */	pNatTblEntry->natStaticBindEnable = 2;    pNatTblEntry->natDefXEnable = TRUE;    pNatTblEntry->natGlobalAddrFilter = TRUE;    return OK;    }/************************************************************************** * * m2NatTblEntrySet - The SET routine for the NAT table objects * * This routine selects the NAT device described by the index field in * <pNatTblEntry> and attempts to modify the values of all the objects  * mentioned using the bit masked <varsToSet> value. * * RETURNS: OK    if a successful modification was done *          ERROR otherwise */STATUS m2NatTblEntrySet    (        NAT_TBL_ENTRY *    pNatTblEntry,    /* Pointer to the new values */    int                varsToSet        /* Mask of objects to set */    )    {    NAT_CLASS * pNatClass = &nat;    if (!pNatTblEntry)        return ERROR;    /*      * If, at later time, the NAT implementation is upgraded to allow     * the existance of more than one NAT device, uncomment the for     * loop below and enclose all the code following it within this     * for loop. Also, change the pNatClass initialization above to     * NULL instead of the nat global's address.     */    /*     * for (index = 1; index <= NAT_NUM_DEVICES; index++)     *     {     *     if (nat[index] == pNatTblEntry->natIndex)     *         {     *         pNatClass = &nat[index];     *         break;     *         }     *     }     */    /*      * If you uncomment the code above, change pNatTblEntry->index      * to index.     */    if (pNatTblEntry->natIndex > NUM_NAT_DEVICES)	{	errnoSet(S_m2Lib_ENTRY_NOT_FOUND);        return ERROR;	}    if (varsToSet & NAT_SESS_MAX_IDLETIME)        {        pNatClass->ip_translation_entry_timer =                                      pNatTblEntry->natSessionMaxIdleTime;        }    if (varsToSet & NAT_UDP_SESS_MAX_IDLETIME)        {        pNatClass->udp_translation_entry_timer =                                      pNatTblEntry->natUdpSessionMaxIdleTime;        }    if (varsToSet & NAT_ICMP_SESS_MAX_IDLETIME)        {        pNatClass->icmp_translation_entry_timer =                                      pNatTblEntry->natIcmpSessionMaxIdleTime;        }    if (varsToSet & NAT_TCPUP_SESS_MAX_IDLETIME)        {        pNatClass->tcp_connected_timer =                                      pNatTblEntry->natTcpUpSessionMaxIdleTime;        }    if (varsToSet & NAT_TCPDISC_SESS_MAX_IDLETIME)        {        pNatClass->tcp_disconnected_timer =                                      pNatTblEntry->natTcpDiscSessionMaxIdleTime;        }    if (varsToSet & NAT_TCPCLOS_SESS_MAX_IDLETIME)        {        pNatClass->tcp_closing_timer =                                  pNatTblEntry->natTcpClosingSessionMaxIdleTime;        }    if (varsToSet & NAT_TCPSYNC_SESS_MAX_IDLETIME)        {        pNatClass->tcp_connecting_timer =                                  pNatTblEntry->natTcpSyncSessionMaxIdleTime;        }    if (varsToSet & NAT_LOG_MASK)        {        if (pNatTblEntry->natLogMask & NAT_PRINT_ENABLED)	    {            if (pNatClass->printing_enabled == 0)                natBoolValModify (pNatClass->printing_enabled,                                          (int *) &pNatClass->printing_enabled);	    }        else	    {            if (pNatClass->printing_enabled == 1)                natBoolValModify (pNatClass->printing_enabled,                                          (int *) &pNatClass->printing_enabled);	    }        if (pNatTblEntry->natLogMask & NAT_INIT_PRINT_ENABLED)	    {	    if (pNatClass->initialization_printing_enabled == 0)                natBoolValModify (pNatClass->initialization_printing_enabled,                          (int *) &pNatClass->initialization_printing_enabled);	    }        else	    {	    if (pNatClass->initialization_printing_enabled == 1)                natBoolValModify (pNatClass->initialization_printing_enabled,                          (int *) &pNatClass->initialization_printing_enabled);	    }        if (pNatTblEntry->natLogMask & NAT_DATA_PRINT_ENABLED)	    {	    if (pNatClass->data_printing_enabled == 0)                natBoolValModify (pNatClass->data_printing_enabled,                                    (int *) &pNatClass->data_printing_enabled);	    }        else	    {	    if (pNatClass->data_printing_enabled == 1)                natBoolValModify (pNatClass->data_printing_enabled,                                    (int *) &pNatClass->data_printing_enabled);	    }        if (pNatTblEntry->natLogMask & NAT_TRACE_PRINT_ENABLED)	    {	    if (pNatClass->trace_printing_enabled == 0)                natBoolValModify (pNatClass->trace_printing_enabled,                                   (int *) &pNatClass->trace_printing_enabled);	    }        else	    {	    if (pNatClass->trace_printing_enabled == 1)                natBoolValModify (pNatClass->trace_printing_enabled,                                   (int *) &pNatClass->trace_printing_enabled);	    }        if (pNatTblEntry->natLogMask & NAT_ERROR_PRINT_ENABLED)	    {	    if (pNatClass->error_printing_enabled == 0)                natBoolValModify (pNatClass->error_printing_enabled,                                   (int *) &pNatClass->error_printing_enabled);	    }        else	    {	    if (pNatClass->error_printing_enabled == 1)                natBoolValModify (pNatClass->error_printing_enabled,                                   (int *) &pNatClass->error_printing_enabled);	    }        }    if (varsToSet & NAT_ENABLE)        {        natBoolValModify (pNatClass->enabled, (int *)&pNatClass->enabled);        }    if (varsToSet & NAT_STATIC_BIND_ENABLE)        {        natBoolValModify (pNatClass->static_entries_enabled,                                      (int *)&pNatClass->static_entries_enabled);        }    return OK;    }/************************************************************************** * * m2NatBindTblEntrySet - The SET routine for the NAT bind table objects * * This routine provides an interface to create/modify/delete a bind * relationship in the bind table. If the address tuples, identifying * a bind entry, do not match an entry in the translation lists, a  * new entry is created. Otherwise, we try to either modify an existing * entry in the translation table or delete it. * * Currently, the only actions that are supported are CREATE a new row * or DELETE an entire row. * * RETURNS: OK    if successful *          ERROR otherwise */STATUS m2NatBindTblEntrySet    (    NAT_BINDTBL_ENTRY *   pNatBindEntry,   /* Pointer to buffer */    int                   varsToSet        /* Bit mask of variables to set */    )    {    char addr[INET_ADDR_LEN];    struct in_addr iaddr;    if (!pNatBindEntry)        return ERROR;    /* Must provide both NAT_BIND_PROTO and NAT_BIND_ACTION in Set*/    if ( !(varsToSet & NAT_BIND_PROTO) || !(varsToSet & NAT_BIND_ACTION) )        {        DBG_PRINT(("ignore single request varsToSet as 0x%x", varsToSet));        return ERROR; /*test should have failed it, so should not reach here*/        }    iaddr.s_addr = ntohl(pNatBindEntry->natBindLocalAddress);    inet_ntoa_b(iaddr, addr);    if (pNatBindEntry->natBindAction == NAT_BIND_CREATE)        {        /* Create a new entry, since we did not find one */        if (pNatBindEntry->natBindProto == TCP_TRANS_LIST)            {            /* the remote port contains the global port in this case*/            if (natTcpStaticAdd (                               addr,                               pNatBindEntry->natBindLocalPort,                               pNatBindEntry->natBindRemPort                              ) != OK)                {                return ERROR;                }            }        else            {            /* Create a UDP entry */            /* the remote port contains the global port in this case*/            if (natUdpStaticAdd (                               addr,                               pNatBindEntry->natBindLocalPort,                               pNatBindEntry->natBindRemPort                               ) != OK)                {                return ERROR;                }            }        return OK;        }    /*      * If we reached here, then an entry maybe already exists and the only      * action we allow is to delete it.     */    if (pNatBindEntry->natBindAction == NAT_BIND_DELETE)        {        if (pNatBindEntry->natBindProto == TCP_TRANS_LIST)            {            /* the remote port contains the global port in this case*/            if (natTcpStaticDelete (                              addr,                              pNatBindEntry->natBindLocalPort,                              pNatBindEntry->natBindRemPort                              ) != OK)                {                return ERROR;                }            }        else            {            /* the remote port contains the global port in this case*/            if (natUdpStaticDelete (                              addr,                              pNatBindEntry->natBindLocalPort,                              pNatBindEntry->natBindRemPort                             ) != OK)                {                return ERROR;                }            }        return OK;        }    /*      * if we reach here, it means we didn't provide correct action, return ERROR.     */    return ERROR;    }/**************************************************************************  * * m2NatBindTblEntryGet - Get/Next Routine for the bind table *  * This routine performs the lookup of all the objects associated with * a particular bind entry, as specified by the loc addr, loc port,  * rem addr and rem port combination. If the search type is NEXT_VALUE, * the objects that are looked up are that for the lexicographic  * successor of the given combination. And you should increment the  * lowest part of the index by 1 for search type NEXT_VALUE. * * * RETURNS: OK    if a successful lookup was done, *          ERROR otherwise

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -