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

📄 pcap-remote.h

📁 Windows XP下的抓包程序实现
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright (c) 2002 - 2003
 * NetGroup, Politecnico di Torino (Italy)
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 * 
 * 1. Redistributions of source code must retain the above copyright 
 * notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright 
 * notice, this list of conditions and the following disclaimer in the 
 * documentation and/or other materials provided with the distribution. 
 * 3. Neither the name of the Politecnico di Torino nor the names of its 
 * contributors may be used to endorse or promote products derived from 
 * this software without specific prior written permission. 
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */

#ifndef __PCAP_REMOTE_H__
#define __PCAP_REMOTE_H__


#include "pcap.h"
#include "sockutils.h"	// Needed for some structures (like SOCKET, sockaddr_in) which are used here


/*!
	\file pcap-remote.h
	
	This file keeps all the new definitions and typedefs that are exported to the user and
	that are needed for the RPCAP protocol.

	\warning All the RPCAP functions that are allowed to return a buffer containing
	the error description can return max PCAP_ERRBUF_SIZE characters.
	However there is no guarantees that the string will be zero-terminated.
	Best practice is to define the errbuf variable as a char of size 'PCAP_ERRBUF_SIZE+1'
	and to insert manually the termination char at the end of the buffer. This will
	guarantee that no buffer overflows occur even if we use the printf() to show
	the error on the screen.

	\warning This file declares some typedefs that MUST be of a specific size.
	These definitions (i.e. typedefs) could need to be changed on other platforms than 
	Intel IA32.

	\warning This file defines some structures that are used to transfer data on the network.
	Be careful that you compiler MUST not insert padding into these structures
	for better alignment.
	These structures have been created in order to be correctly aligned to a 32 bits
	boundary, but be careful in any case.
*/








/*********************************************************
 *                                                       *
 * General definitions / typedefs for the RPCAP protocol *
 *                                                       *
 *********************************************************/

// All the following structures and typedef belongs to the Private Documentation
/*! \addtogroup remote_pri_struct
	\{
*/

#define RPCAP_DEFAULT_NETPORT "2002" /*!< Default port on which the RPCAP daemon is waiting for connections. */
/*! Default port on which the client workstation is waiting for connections in case of active mode. */
#define RPCAP_DEFAULT_NETPORT_ACTIVE "2003"
#define RPCAP_DEFAULT_NETADDR ""	/*!< Default network address on which the RPCAP daemon binds to. */
#define RPCAP_VERSION 0				/*!< Present version of the RPCAP protocol (0 = Experimental). */
#define RPCAP_TIMEOUT_INIT 90		/*!< Initial timeout for RPCAP connections (default: 90 sec) */
#define RPCAP_TIMEOUT_RUNTIME 180	/*!< Run-time timeout for RPCAP connections (default: 3 min) */
#define RPCAP_ACTIVE_WAIT 30		/*!< Waiting time betweek two attempts to open a connection, in active mode (default: 30 sec) */
#define RPCAP_SUSPEND_WRONGAUTH 1	/*!< If the authentication is wrong, stops 1 sec before accepting a new auth message */

/*!
	\brief Buffer used by socket functions to send-receive packets.
	In case you plan to have messages larger than this value, you have to increase it.
*/
#define RPCAP_NETBUF_SIZE 64000


/*!
	\brief Separators used for the host list.

	It is used:
	- by the rpcapd daemon, when you types a list of allowed connecting hosts
	- by the rpcap in active mode, when the client waits for incoming connections from other hosts
*/
#define RPCAP_HOSTLIST_SEP " ,;\n\r"




// WARNING: These could need to be changed on other platforms
typedef unsigned char uint8;		//!< Provides an 8-bits unsigned integer
typedef unsigned short uint16;		//!< Provides a 16-bits unsigned integer
typedef unsigned int uint32;		//!< Provides a 32-bits unsigned integer
typedef int int32;					//!< Provides a 32-bits integer




/*!
	\brief Keeps a list of all the opened connections in the active mode.

	This structure defines a linked list of items that are needed to keep the info required to
	manage the active mode.
	In other words, when a new connection in active mode starts, this structure is updated so that
	it reflects the list of active mode connections currently opened.
	This structure is required by findalldevs() and open_remote() to see if they have to open a new
	control connection toward the host, or they already have a control connection in place.
*/
struct activehosts
{
	struct sockaddr_storage host;
	SOCKET sockctrl;
	struct activehosts *next;
};


/*********************************************************
 *                                                       *
 * Protocol messages formats                             *
 *                                                       *
 *********************************************************/
// WARNING Take care you compiler does not insert padding for better alignments into these structs


//! Common header for all the RPCAP messages
struct rpcap_header
{
	uint8 ver;							//!< RPCAP version number
	uint8 type;							//!< RPCAP message type (error, findalldevs, ...)
	uint16 value;						//!< Message-dependent value (not always used)
	uint32 plen;						//!< Length of the payload of this RPCAP message
};


//! Format of the message for the interface description (findalldevs command)
struct rpcap_findalldevs_if
{
	uint16 namelen;						//!< Length of the interface name
	uint16 desclen;						//!< Length of the interface description
	uint32 flags;						//!< Interface flags
	uint16 naddr;						//!< Number of addresses
	uint16 dummy;						//!< Must be zero
};


//! Format of the message for the address listing (findalldevs command)
struct rpcap_findalldevs_ifaddr
{
	struct sockaddr_storage addr;		//!< Network address
	struct sockaddr_storage netmask;	//!< Netmask for that address
	struct sockaddr_storage broadaddr;	//!< Broadcast address for that address
	struct sockaddr_storage dstaddr;	//!< P2P destination address for that address
};



/*!
	\brief Format of the message of the connection opening reply (open command).
	

⌨️ 快捷键说明

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