#include<>#include<>#include<>#include<>#include<sys/>#inet/>#include<arpa/>typedefunsignedcharUCHAR;typedefunsignedshortUSHORT;voidpcap_handle(u_char*user,conststructpcap_pkthdr*header,constu_char*pkt_data);typedefstruct{//定义以太帧的头部数据类型 UCHARDestMac[6]; UCHARSrcMac[6]; UCHAREtype[2];}ETHHEADER;typedefstruct{//IP头部的数据类型UCHARheader_len:4;UCHARversion:4;UCHARtos:8;//typeofserviceUSHORTtotal_len:16;//lengthofthepacketUSHORTident:16;//uniqueidentifierUSHORTflags:16;UCHARttl:8;UCHARproto:8;//protocol(IP,TCP,UDPetc)USHORTchecksum:16;UCHARsourceIP[4];UCHARdestIP[4]; }IPHEADER;typedefstruct{//定义端口数据类型用于解析TCP和UDP中的源端口和目的端口 USHORTsrcPort; USHORTdecPort;}PORT;char*Proto[]={"Reserved","ICMP","IGMP","GGP","IP","ST","TCP","UCL","EGP","IGP","BBN-RCC-MON","NVP-II","PUP","ARGUS","EMCON","XNET","CHAOS","UDP","MUX","DCN-MEAS","HMP","PRM","XNS-IDP","TRUNK-1","TRUNK-2","LEAF-1","LEAF-2","RDP","IRTP","ISO-TP4","NETBLT","MFE-NSP","MERIT-INP","SEP","3PC","IDPR","XTP","DDP","IDPR-CMTP","TP++","IL","SIP","SDRP","SIP-SR","SIP-FRAG","IDRP","RSVP","GRE","MHRP","BNA","SIPP-ESP","SIPP-AH","I-NLSP","SWIPE","NHRP","unassigned","unassigned","unassigned","unassigned","unassigned","unassigned","anyhostinternalprotocol","CFTP","work","SAT-EXPAK","KRYPTOLAN","RVD","IPPC","anydistributedfilesystem","SAT-MON","VISA","IPCV","CPNX","CPHB","WSN","PVP","BR-SAT-MON","SUN-ND","W
协议分析器设计源代码 来自淘豆网www.taodocs.com转载请标明出处.