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

📄 dce2_memory.c

📁 snort2.8.4版本
💻 C
📖 第 1 页 / 共 2 页
字号:
/**************************************************************************** * Copyright (C) 2008-2008 Sourcefire,Inc * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License Version 2 as * published by the Free Software Foundation.  You may not use, modify or * distribute this program under any other version of the GNU General * Public License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ****************************************************************************  * ****************************************************************************/#include "dce2_memory.h"#include "dce2_utils.h"#include "dce2_config.h"#include "dce2_event.h"#include <stdio.h>#include <stdlib.h>#include <string.h>/******************************************************************** * Macros ********************************************************************/#define DCE2_MEMCAP_OK        0#define DCE2_MEMCAP_EXCEEDED  1/******************************************************************** * Global variables ********************************************************************/DCE2_Memory dce2_memory;DCE2_MemState dce2_mem_state = DCE2_MEM_STATE__OKAY;/******************************************************************** * Private function prototypes ********************************************************************/static void DCE2_RegMemSmb(uint32_t, DCE2_MemType);static void DCE2_RegMemCo(uint32_t, DCE2_MemType);static void DCE2_RegMemCl(uint32_t, DCE2_MemType);static int DCE2_CheckMemcap(uint32_t, DCE2_MemType);/******************************************************************** * Function: * * Purpose: * * Arguments: * * Returns: * ********************************************************************/void DCE2_RegMem(uint32_t size, DCE2_MemType mtype){    switch (mtype)    {        case DCE2_MEM_TYPE__CONFIG:            dce2_memory.config += size;            if (dce2_memory.config > dce2_memory.config_max)                dce2_memory.config_max = dce2_memory.config;            break;        case DCE2_MEM_TYPE__ROPTION:            dce2_memory.roptions += size;            if (dce2_memory.roptions > dce2_memory.roptions_max)                dce2_memory.roptions_max = dce2_memory.roptions;            break;        case DCE2_MEM_TYPE__RT:            dce2_memory.rt += size;            if (dce2_memory.rt > dce2_memory.rt_max)                dce2_memory.rt_max = dce2_memory.rt;            break;        case DCE2_MEM_TYPE__INIT:            dce2_memory.init += size;            if (dce2_memory.init > dce2_memory.init_max)                dce2_memory.init_max = dce2_memory.init;            break;        case DCE2_MEM_TYPE__SMB_SSN:        case DCE2_MEM_TYPE__SMB_SEG:        case DCE2_MEM_TYPE__SMB_UID:        case DCE2_MEM_TYPE__SMB_TID:        case DCE2_MEM_TYPE__SMB_FID:        case DCE2_MEM_TYPE__SMB_UT:        case DCE2_MEM_TYPE__SMB_PM:            DCE2_RegMemSmb(size, mtype);            break;        case DCE2_MEM_TYPE__TCP_SSN:            dce2_memory.tcp_ssn += size;            if (dce2_memory.tcp_ssn > dce2_memory.tcp_ssn_max)                dce2_memory.tcp_ssn_max = dce2_memory.tcp_ssn;            dce2_memory.tcp_total += size;            if (dce2_memory.tcp_total > dce2_memory.tcp_total_max)                dce2_memory.tcp_total_max = dce2_memory.tcp_total;            break;        case DCE2_MEM_TYPE__CO_SEG:        case DCE2_MEM_TYPE__CO_FRAG:        case DCE2_MEM_TYPE__CO_CTX:            DCE2_RegMemCo(size, mtype);            break;        case DCE2_MEM_TYPE__UDP_SSN:            dce2_memory.udp_ssn += size;            if (dce2_memory.udp_ssn > dce2_memory.udp_ssn_max)                dce2_memory.udp_ssn_max = dce2_memory.udp_ssn;            dce2_memory.udp_total += size;            if (dce2_memory.udp_total > dce2_memory.udp_total_max)                dce2_memory.udp_total_max = dce2_memory.udp_total;            break;        case DCE2_MEM_TYPE__HTTP_SSN:            dce2_memory.http_ssn += size;            if (dce2_memory.http_ssn > dce2_memory.http_ssn_max)                dce2_memory.http_ssn_max = dce2_memory.http_ssn;            dce2_memory.http_total += size;            if (dce2_memory.http_total > dce2_memory.http_total_max)                dce2_memory.http_total_max = dce2_memory.http_total;            break;        case DCE2_MEM_TYPE__CL_ACT:        case DCE2_MEM_TYPE__CL_FRAG:            DCE2_RegMemCl(size, mtype);            break;        default:            DCE2_Log("%s(%d) => Invalid memory type\n", __FILE__, __LINE__);            break;    }    switch (mtype)    {        case DCE2_MEM_TYPE__CONFIG:        case DCE2_MEM_TYPE__ROPTION:        case DCE2_MEM_TYPE__RT:        case DCE2_MEM_TYPE__INIT:            break;        default:            dce2_memory.rtotal += size;            if (dce2_memory.rtotal > dce2_memory.rtotal_max)                dce2_memory.rtotal_max = dce2_memory.rtotal;    }    dce2_memory.total += size;    if (dce2_memory.total > dce2_memory.total_max)        dce2_memory.total_max = dce2_memory.total;}/******************************************************************** * Function: * * Purpose: * * Arguments: * * Returns: * ********************************************************************/static void DCE2_RegMemSmb(uint32_t size, DCE2_MemType mtype){    switch (mtype)    {        case DCE2_MEM_TYPE__SMB_SSN:            dce2_memory.smb_ssn += size;            if (dce2_memory.smb_ssn > dce2_memory.smb_ssn_max)                dce2_memory.smb_ssn_max = dce2_memory.smb_ssn;            break;        case DCE2_MEM_TYPE__SMB_SEG:            dce2_memory.smb_seg += size;            if (dce2_memory.smb_seg > dce2_memory.smb_seg_max)                dce2_memory.smb_seg_max = dce2_memory.smb_seg;            break;        case DCE2_MEM_TYPE__SMB_UID:            dce2_memory.smb_uid += size;            if (dce2_memory.smb_uid > dce2_memory.smb_uid_max)                dce2_memory.smb_uid_max = dce2_memory.smb_uid;            break;        case DCE2_MEM_TYPE__SMB_TID:            dce2_memory.smb_tid += size;            if (dce2_memory.smb_tid > dce2_memory.smb_tid_max)                dce2_memory.smb_tid_max = dce2_memory.smb_tid;            break;        case DCE2_MEM_TYPE__SMB_FID:            dce2_memory.smb_fid += size;            if (dce2_memory.smb_fid > dce2_memory.smb_fid_max)                dce2_memory.smb_fid_max = dce2_memory.smb_fid;            break;        case DCE2_MEM_TYPE__SMB_UT:            dce2_memory.smb_ut += size;            if (dce2_memory.smb_ut > dce2_memory.smb_ut_max)                dce2_memory.smb_ut_max = dce2_memory.smb_ut;            break;        case DCE2_MEM_TYPE__SMB_PM:            dce2_memory.smb_pm += size;            if (dce2_memory.smb_pm > dce2_memory.smb_pm_max)                dce2_memory.smb_pm_max = dce2_memory.smb_pm;            break;        default:            return;    }    dce2_memory.smb_total += size;    if (dce2_memory.smb_total > dce2_memory.smb_total_max)        dce2_memory.smb_total_max = dce2_memory.smb_total;}/******************************************************************** * Function: * * Purpose: * * Arguments: * * Returns: * ********************************************************************/static void DCE2_RegMemCo(uint32_t size, DCE2_MemType mtype){    switch (mtype)    {        case DCE2_MEM_TYPE__CO_SEG:            dce2_memory.co_seg += size;            if (dce2_memory.co_seg > dce2_memory.co_seg_max)                dce2_memory.co_seg_max = dce2_memory.co_seg;            break;        case DCE2_MEM_TYPE__CO_FRAG:            dce2_memory.co_frag += size;            if (dce2_memory.co_frag > dce2_memory.co_frag_max)                dce2_memory.co_frag_max = dce2_memory.co_frag;            break;        case DCE2_MEM_TYPE__CO_CTX:            dce2_memory.co_ctx += size;            if (dce2_memory.co_ctx > dce2_memory.co_ctx_max)                dce2_memory.co_ctx_max = dce2_memory.co_ctx;            break;        default:            return;    }    dce2_memory.co_total += size;    if (dce2_memory.co_total > dce2_memory.co_total_max)        dce2_memory.co_total_max = dce2_memory.co_total;}/******************************************************************** * Function: * * Purpose: * * Arguments: * * Returns: * ********************************************************************/static void DCE2_RegMemCl(uint32_t size, DCE2_MemType mtype){    switch (mtype)    {        case DCE2_MEM_TYPE__CL_ACT:            dce2_memory.cl_act += size;            if (dce2_memory.cl_act > dce2_memory.cl_act_max)

⌨️ 快捷键说明

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