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

📄 procmodule.c

📁 网络流量采集及分析软件
💻 C
字号:
/*! \file ProcModule.c    Copyright 2003-2004 Fraunhofer Institute for Open Communication Systems (FOKUS),                        Berlin, Germany    This file is part of Network Measurement and Accounting System (NETMATE).    NETMATE is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License as published by     the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    NETMATE 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 software; if not, write to the Free Software     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    Description:    implementation of helper functions for Packet Processing Modules    $Id: ProcModule.c,v 1.1.1.1 2004/12/23 05:52:36 s_zander Exp $*/#include "ProcModule.h"/*! \short   embed magic cookie number in every packet processing module    _N_et_M_ate _P_rocessing Module */int magic = PROC_MAGIC;/*! \short   declaration of struct containing all function pointers of a module */ProcModuleInterface_t func = {     3,     initModule,     destroyModule,     initFlowRec,     getTimers,     destroyFlowRec,    resetFlowRec,     timeout,     processPacket,    exportData,     getModuleInfo,     getErrorMsg,    getTypeInfo };/*! \short   global state variable used within data export macros */void *_dest;int   _pos;int   _listlen;int   _listpos;/* align macro */#define ALIGN( var, type ) var = ( var + sizeof(type)-1 )/sizeof(type) * sizeof(type)/*! export functions */inline void STARTEXPORT(void *data){    _dest = data;     _pos=0;   }inline void ENDEXPORT(void **exp, int *len){    *exp = _dest;     *len = _pos;}inline void ADD_CHAR(char val){    ALIGN(_pos, char);    *((char*)(_dest+_pos)) = val;    _pos += sizeof(val);}inline void ADD_INT8(char val){    ALIGN(_pos, char);    *((char*)(_dest+_pos)) = val;    _pos += sizeof(val);}inline void ADD_INT16(short val){    ALIGN(_pos, short);    *((short*)(_dest+_pos))= val;    _pos += sizeof(val);}inline void ADD_INT32(int val){    ALIGN(_pos, int);    *((int*)(_dest+_pos))= val;    _pos += sizeof(val);}inline void ADD_INT64(long long val){    ALIGN( _pos, long );     /* even 64bit values only aligned to 32 bit! */    *((long long*)(_dest+_pos))= val;     _pos += sizeof(val); }inline void ADD_UINT8(unsigned char val){    ALIGN(_pos, unsigned char);    *((unsigned char*)(_dest+_pos)) = val;    _pos += sizeof(val);}inline void ADD_UINT16(unsigned short val){    ALIGN(_pos, unsigned short);    *((unsigned short*)(_dest+_pos)) = val;    _pos += sizeof(val);}inline void ADD_UINT32(unsigned int val){    ALIGN(_pos, unsigned int);    *((unsigned int*)(_dest+_pos)) = val;    _pos += sizeof(val);}inline void ADD_UINT64(unsigned long long val){    ALIGN( _pos, unsigned long );     /* even 64bit values only aligned to 32 bit! */    *((unsigned long long*)(_dest+_pos)) = val;     _pos += sizeof(val); }inline void ADD_FLOAT(float val){    ALIGN(_pos, float);    *((float*)(_dest+_pos)) = val;    _pos += sizeof(val);}inline void ADD_DOUBLE(double val){    ALIGN(_pos, double);    *((double*)(_dest+_pos)) = val;    _pos += sizeof(val);}inline void ADD_IPV4ADDR(unsigned int val){    /* treat as unsigned32 */    ADD_UINT32(val);}inline void ADD_LIST(unsigned int num){    ADD_UINT32(num);    _listpos = _pos;     ADD_UINT32(0);     _listlen = _pos;}inline void END_LIST(){    ((int*)((char*)_dest+_listpos))[0] = _pos - _listlen;}inline void ADD_STRING(char *txt){    int _slen = strlen(txt) + 1;    memcpy(_dest+_pos, txt, _slen);    _pos += _slen; }inline void ADD_BINARY(unsigned int size, char *src){    ADD_UINT32( size );    memcpy(_dest+_pos, src, size);    _pos += size;}typeInfo_t* getTypeInfo(){    return exportInfo;}

⌨️ 快捷键说明

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