/*
** SellaNMS
** $Id: icmp.h,v 1.5 2005/11/06 05:02:05 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __DGS_DISCOVERY_ICMP_H
#define __DGS_DISCOVERY_ICMP_H

#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include "defaults.h"
#include "common/util.h"
#include "common/netblock.h"
#include "common/storagedata.h"
#include "policy_framework/policy_framework.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
#include <arpa/inet.h>
#include <stl/list>
#include <stl/queue>

#define ICMP_NOREPLY			0
#define ICMP_REPLY			1
#define PAYLOAD				"SellaNMS - ICMP Discovery"
#define PAYLOAD_SIZE			36
#define PACKET_BUFFER_SIZE	512

#define MODULE_DISCOVERY_ICMP_TRANSMITCOUNT_DEFAULT	3
#define MODULE_DISCOVERY_ICMP_REQUIREDCOUNT_DEFAULT	1
#define MODULE_DISCOVERY_ICMP_BANDWIDTH_DEFAULT			64000
#define MODULE_DISCOVERY_ICMP_TIMEOUT_DEFAULT			5000
#define MODULE_DISCOVERY_ICMP_SLEEPCOUNTINT_DEFAULT	5

typedef hash_map<u_int32_t, unsigned long> received_hash_t;

class ICMP {
	public:
		ICMP();
		~ICMP();
		virtual RESULT execute();
		virtual RESULT readConfig();

	protected:
		virtual void printConfig();

	private:

		static RESULT transmit_thread(void* args);
		static RESULT receive_thread(void* args);
		static RESULT storage_thread(void* args);

		unsigned long tx_count;
		unsigned long rx_count;
		unsigned long bandwidth;
		unsigned long timeout;

		uint32_t			source;
		vector<string> netblocks;

		u_int16_t module_id;
		received_hash_t rx_hash;
		pthread_mutex_t rx_hash_mutex;

		PolicyFramework	inputPolicy;
		PolicyFramework	outputPolicy;

		Storage storage;
};

#endif

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3
*/
