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

📄 pgpnetattackstrings.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
字号:
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.

	$Id: pgpNetAttackStrings.c,v 1.8 2002/08/06 20:10:25 dallen Exp $
____________________________________________________________________________*/
#include "pgpConfig.h"

#include <string.h>

#include <stdio.h>

#include "pgpDebug.h"
#include "pgpPubTypes.h"
#include "pgpStrings.h"
#include "pgpNetAttack.h"
#include "pgpNetAttackStrings.h"
#include "pgpMem.h"
#include "pgpPFLPriv.h"


typedef struct TextEntry
{
	PGPUInt32 const		number;
	const char * const	string;
} TextEntry;

#define EN(number, string)		{ number, string }


static const TextEntry sAttackTypes[] =
{
/* __________________________________________________________________ */

EN( kPGPnetAttack_None,			"Manual" ),
EN( kPGPnetAttack_PingOfDeath,	"Ping of Death" ),
EN( kPGPnetAttack_SynFlood,		"SYN Flood" ),
EN( kPGPnetAttack_PortScan,		"Port Scan" ),
EN( kPGPnetAttack_IPSpoof,		"IP Spoof" ),
EN( kPGPnetAttack_Land,			"Land" ),
EN( kPGPnetAttack_Teardrop,		"Teardrop" ),
EN( kPGPnetAttack_Bonk,			"Bonk/Nestea" ),
EN( kPGPnetAttack_Fraggle,		"Fraggle" ),
EN( kPGPnetAttack_Smurf,		"Smurf" ),
EN( kPGPnetAttack_BackOrifice,	"Back Orifice" ),
EN( kPGPnetAttack_PingFlood,	"Ping Flood" ),
EN( kPGPnetAttack_UDPFlood,		"UDP Flood" ),
EN( kPGPnetAttack_Jolt2,		"Jolt2" ),
EN( kPGPnetAttack_Snork,		"Snork" ),
EN( kPGPnetAttack_WinNuke,		"WinNuke" ),

};
#define kPGP_NumAttackEntries		\
	( sizeof( sAttackTypes ) / sizeof( sAttackTypes[ 0 ] ) )


#undef EN

	PGPError
PGPGetNetAttackString(
	PGPnetAttackType	attackType,
	PGPSize				sizeString,
	char *				pszString )
{
	PGPUInt32			idx;
	const TextEntry *	pentry;
	char				temp[ 256 ];
	char const *		psz	= NULL;
	PGPSize				len	= 0;
	PGPBoolean			bBufferBigEnough	= FALSE;

	PGPValidateParam( sizeString >= 1 );
	PGPValidatePtr( pszString );
	*pszString	= '\0';

	for( idx = 0; idx < kPGP_NumAttackEntries; ++idx )
	{
		pentry	= &sAttackTypes[ idx ];
		if ( pentry->number == (PGPUInt32)attackType )
		{
			psz	= pentry->string;
			break;
		}
	}

	if ( IsNull( psz ) )
	{
		/* Produce something for missing types */
		sprintf( temp, "%ld", (long)attackType );
		psz	= temp;
	}

	len	= strlen( psz );
	bBufferBigEnough = ( len + 1 <= sizeString );
	if ( bBufferBigEnough )
	{
		strcpy( pszString, psz );
	}
	else
	{
		pgpCopyMemory( psz, pszString, sizeString - 1 );
		pszString[ sizeString - 1 ]	= '\0';
	}

	return( bBufferBigEnough ? kPGPError_NoErr : kPGPError_BufferTooSmall );
}


/*__Editor_settings____

	Local Variables:
	tab-width: 4
	End:
	vi: ts=4 sw=4
	vim: si
_____________________*/

⌨️ 快捷键说明

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