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

📄 ip_notif_log_support.ex.c

📁 备
💻 C
📖 第 1 页 / 共 5 页
字号:
/** IP Model Suite support package		**/
/** for simulation notification logging.**/

/****************************************/
/*		Copyright (c) 1987 - 2002		*/
/*      by OPNET Technologies, Inc.		*/
/*       (A Delaware Corporation)      	*/
/*    7255 Woodmont Av., Suite 250     	*/
/*     Bethesda, MD 20814, U.S.A.       */
/*       All Rights Reserved.          	*/
/****************************************/


/** Include directives.			**/
#include <opnet.h>
#include <ip_addr_v4.h>
#include <ip_rte_v4.h>
#include <nato.h>
#include <oms_tan.h>
#include <ip_notif_log_support.h>
#include <ip_cmn_rte_table.h>
#include <ip_rte_map_support.h>
#include <ip_acl_support.h>
#include <ip_sim_attr_cache.h>
#include <string.h>
#include <ip_rte_support.h>
#include <oms_string_support.h>
#include <oms_log_support.h>
#include <ip_auto_addr_sup_v4.h>

/** Global data.				**/

/* Log handles for model configuration messages.	*/ 
Log_Handle				ip_addr_map_loghndl;
Log_Handle				ip_config_error_loghndl;
Log_Handle				ip_config_warning_loghndl;

/* Log handles for protocol event messages.			*/
Log_Handle				ip_prot_error_loghndl;
Log_Handle				ip_prot_warning_loghndl;
Log_Handle       		ip_packet_drop_loghndl;

/* Log handles for messages indicating unexpected	*/
/* results.											*/
Log_Handle				ip_results_warn_loghndl;

/* Log handles for KP invocation failures.			*/
Log_Handle				ip_kp_error_loghndl;

/* Log handles for IP auto assignment for radio		*/
/* nodes											*/
Log_Handle				ip_radio_2wireless_intf_loghndl;
Log_Handle				ip_radio_wireless_intf_loghndl;

   				
/* Log handle to inform user about useful results	*/
Log_Handle				ip_result_loghndl;

/*IP PIM-SM log handles 							*/
Log_Handle				ip_pim_sm_config_error_loghndl;
Log_Handle				ip_pim_sm_config_warning_loghndl;
Log_Handle				ip_pim_sm_lowlevel_error_loghndl;
Log_Handle				ip_pim_sm_prot_warn_loghndl;
Log_Handle				ip_pim_sm_prot_result_loghndl;
Log_Handle				ip_pim_sm_packet_drop_loghndl;

typedef struct
	{
	char*		demand_name;
	char*		node_name;	
	Boolean		routable;
	double		check_time;
	List*		life_cycle_lptr;	
	Objid 		demand_id;
	} IpT_Notif_Demand_Info;

extern const char* route_map_name_attr_name [];
extern const char* route_map_config_attr_name [];
extern const char* term_name_attr_name [];

/* List containing log messages above invalid address configuration for PIM attributes.	*/
static List*				ip_pim_invalid_addr_lptr = OPC_NIL;
static List*				ip_pim_invalid_acl_lptr = OPC_NIL;

/* Hash table containing log messages above unknown RPs	*/
static PrgT_String_Hash_Table*				no_rp_hash_table_ptr = OPC_NIL;
static PrgT_String_Hash_Table*				no_ucast_route_hash_table_ptr = OPC_NIL;
static PrgT_String_Hash_Table*				spt_table_hash_table_ptr = OPC_NIL;

/* ---- Externally Callable Procedures ---- */
void
ip_notif_log_handles_init (void)
	{
    static Boolean	ip_notif_log_handles_init = OPC_FALSE;
	int				ip_conf_log_limit		= 25;
	int				ip_proto_log_limit		= 25;
	int				ip_results_log_limit	= 25;	
	int				ip_low_lev_log_limit	= 25;

	/** This function initializes Log_Handle global vars. and as	**/
	/** a result sets up <Category, Class, Subclass> tuple instances**/
	/** that will be used to output messages to the simulation log	**/
	/** by the ip3_rte process model.								**/
	FIN (ip_notif_log_handles_init (void))

	if (ip_notif_log_handles_init == OPC_FALSE)
		{
		/* If present, obtain the values set for the maximum	*/
		/* number of log entries on a per "category" basis.		*/
		if (op_ima_sim_attr_exists (IPC_CONF_LOG_LIMIT))
			{
			op_ima_sim_attr_get (
				OPC_IMA_INTEGER, IPC_CONF_LOG_LIMIT, &ip_conf_log_limit);
	   	 	}

		if (op_ima_sim_attr_exists (IPC_PROTO_LOG_LIMIT))
		    {
			op_ima_sim_attr_get (
				OPC_IMA_INTEGER, IPC_PROTO_LOG_LIMIT, &ip_proto_log_limit);
	    	}

		if (op_ima_sim_attr_exists (IPC_RESULTS_LOG_LIMIT))
			{
			op_ima_sim_attr_get (
				OPC_IMA_INTEGER, IPC_CONF_LOG_LIMIT, &ip_results_log_limit);
			}

		if (op_ima_sim_attr_exists (IPC_LOW_LEV_LOG_LIMIT))
			{
			op_ima_sim_attr_get (
				OPC_IMA_INTEGER, IPC_CONF_LOG_LIMIT, &ip_low_lev_log_limit);
			}

		/* Initialize the log handle placeholders.			*/
		ip_addr_map_loghndl			= op_prg_log_handle_create (
										OpC_Log_Category_Lowlevel,
										"IP",
										"Address_Mapping_via_NATO",
										ip_conf_log_limit);

		ip_prot_error_loghndl		= op_prg_log_handle_create (
										OpC_Log_Category_Protocol,
										"IP",
										"Protocol_Error",
										ip_proto_log_limit);

		ip_prot_warning_loghndl		= op_prg_log_handle_create (
										OpC_Log_Category_Protocol,
										"IP",
										"Protocol_Warning",
										ip_proto_log_limit);

		ip_config_error_loghndl		= op_prg_log_handle_create (
										OpC_Log_Category_Configuration,
										"IP",
										"Model_Configuration_Error",
										ip_conf_log_limit);

		ip_config_warning_loghndl	= op_prg_log_handle_create (
										OpC_Log_Category_Configuration,
										"IP",
										"Model_Configuration_Warning",
										ip_conf_log_limit);

		ip_kp_error_loghndl			= op_prg_log_handle_create (
										OpC_Log_Category_Lowlevel,
										"IP",
										"KP_Invocation_Error",
										ip_low_lev_log_limit);

		ip_results_warn_loghndl		= op_prg_log_handle_create (
										OpC_Log_Category_Results,
										"IP",
										"Unexpected_Results",
										ip_results_log_limit);

		ip_packet_drop_loghndl		= op_prg_log_handle_create (
										OpC_Log_Category_Protocol,
										"IP",
										"Packet Drop",
										ip_proto_log_limit);

       ip_radio_2wireless_intf_loghndl 	= op_prg_log_handle_create (
										OpC_Log_Category_Protocol,
										"IP",
										"Wireless2Intf_Auto_Assignment_Warning",
										ip_proto_log_limit);

       ip_radio_wireless_intf_loghndl 	= op_prg_log_handle_create (
										OpC_Log_Category_Protocol,
										"IP",
										"Static_Auto_Assignment_Warning",
										ip_proto_log_limit);	   

	   ip_result_loghndl				= op_prg_log_handle_create (
		   								OpC_Log_Category_Results,
										"IP",
										"Results",
										ip_results_log_limit);

		ip_notif_log_handles_init = OPC_TRUE;
		}

	FOUT
	}

void
ipnl_duplicate_ip_address_error (const char* addr, const char* mask)
	{
	/** Logs when detecting a duplicate IP address.	**/
	FIN (ipnl_duplicate_ip_address_error (addr, mask));

	op_prg_log_entry_write (ip_config_error_loghndl,
		"ERROR:\n"
		" IP address auto-assignment procedure detected the\n"
		" following address to be configured on more than\n"
		" one IP interface in this network:\n"
		"\n"
		"   Network Address: %s\n"
		"   Subnet Mask:     %s\n"
		"\n"
		" The interface with duplicate address may also be \n"
		" a tunnel interface.	\n"
		"\n"	
		"LOCATION:\n"
		" You can obtain the location of the duplicate IP\n"
		" address assignment using the following approaches:\n"
		"\n"
		" 1. Run \"IP Addressing\" specific NetDoctor rules.\n"
		"    (i.e., using NetDoctor Validation)\n"
		" 2. Using \"Protocols->IP->Addressing->Select Node\n"
		"	 with Specified IP Address...\" menu item.\n"
		"\n"
		"SUGGESTION:\n"
		" In order to run a discrete event simulation using\n"
		" this network, you may choose either of the following\n"
		" workarounds:\n"
		"\n"
		"   1. Make all IP address assignments unique.\n"
		"   2. Set the simulation attribute \"IP Interface\n"
		"      Addressing Mode\" to \"Manually Addressed\".\n"
		"\n"
		" NOTE: For networks created by importing information\n"
		" from router configuration files use option 2.\n"
		" \n",		
		addr, mask);
	
	FOUT;
	}

void
ipnl_addresses_unavailable_in_subnet_error (const char* subnet)
	{
	/** Logs when no more addresses are avaialibe in a subnet	**/
	
	FIN (ipnl_addresses_unavailable_in_subnet_error (subnet));
	
	op_prg_log_entry_write (ip_config_error_loghndl,
		"ERROR:\n"
		" IP address auto-assignment procedure detected that\n"
		" there are no more addresses available in this subnet\n"
		"\n"
		"   Subnet Address: %s\n"
		"\n"
		"SUGGESTION:\n"
		" Use a new subnet for assigning further IP addresses.\n",
		subnet);
	FOUT;
	}

void
ipnl_incompatible_subnet_error (const char* subnet, const char* prev_subnet, const char* objects)
	{
	/** Logs when incompatible subnet mask is used		**/
	
	FIN (ipnl_incompatible_subnet_error (subnet, prev_subnet, objects));
	
	op_prg_log_entry_write (ip_config_error_loghndl,
		"ERROR:\n"
		" IP address auto-assignment procedure detected that\n"
		" there was an incompatible subnet mask used.\n"
		"\n"
		"   Subnet 1: %s\n"
		"   Subnet 2: %s\n"
		"\n"
		"LOCATION:\n"
		" You can check the interfaces of the following nodes\n"
		" and links against neighbors:\n"
		" %s\n"
		"\n"
		"SUGGESTION:\n"
		" Make sure that all subnet masks are compatible with\n"
		" neighbor's subnet masks.\n",
		subnet, prev_subnet, objects);
	FOUT;
	}

void
ipnl_subnet_mask_error_for_manet (void)
	{
	static Boolean message_written = OPC_FALSE;
	
	/** Logs when incompatible subnet mask is used		**/
	
	FIN (ipnl_subnet_mask_error_for_manet (void));
	
	/* Do not write this log message more than once.	*/
	if (message_written)
		{
		FOUT;
		}
	
	/* Set the flag indicating that we have written the	*/
	/* log message at least once.						*/
	message_written = OPC_TRUE;
	
	op_prg_log_entry_write (ip_config_warning_loghndl,
		"WARNING(s):\n"
		" MANET routing protocol has detected router interface\n"
		" addresses with ambiguous subnet masks.\n"
		"\n"	
		" Subnet masks should be set to 255.255.255.255 (IPv4)\n"
		" and prefix length should be set to 128 (IPv6).\n" 	
		"\n"
		" Auto-Assigned value for subnet masks will be resolved\n"
		" to class-based masks, which is ambiguous for MANET.\n"	
		"\n"
		" This message is critical for AODV/DYMO routing protocol.\n"
		"\n"			
		"SYMPTOM(s):\n"
		" Packets losses in a wireless network due to incorrect\n"
		" routing behavior.\n"
		"\n"
		"REASON(s):\n"
		" A router inserts directly connected interfaces as\n"
		" reachable addresses, after applying its subnet-mask.\n"
		" Based on the subnet-mask, it may result either in a\n"
		" network prefix or as an host address.\n"	
		"\n"
		" A network prefix like 192.1.1.0/24 in a routing table\n"
		" provides routing to 256 hosts even if they are not in\n"
		" transmission range of a wireless network. This can\n"
		" lead to packet losses.\n"	
		"\n"	
		" However more specific routes like 192.1.1.50 restricts\n"
		" reachability.\n"
		"\n"
		"SUGGESTION:\n"
		" Subnet masks should be set to 255.255.255.255 for IPv4\n"
		" interface addresses and prefix length should be set to 128\n"
		" for IPv6 interface addresses. \n"	
		"\n"
		" Note: this message will not be repeated for other routers\n"
		"       which have similar configurations.	\n"
		"\n");
	
	FOUT;
	}

void
ipnl_family_mismatch_pkt_drop_in_manet (SimT_Pk_Id packet_id, int addr_node, int addr_pkt)
	{
	static int	error_count = 0;
	const char*		addr_node_str;
	const char*		addr_pkt_str;
	
	/* This message warns of packets being dropped that are received 	*/
	/* at a node running MANET routing protocol, where address family 	*/
	/* of received packet is not supported on this node.		   		*/
	FIN (ipnl_family_mismatch_pkt_drop_in_manet (<args>));
	
	if (error_count < 2)
		{
		/** This error will only be reported for a max of 2 times **/
		addr_node_str = (addr_node == InetC_Addr_Family_v4)? "IPv4": "IPv6";
		addr_pkt_str = (addr_pkt == InetC_Addr_Family_v4) ? "IPv4" : "IPv6";
	
		op_prg_log_entry_write (
			ip_packet_drop_loghndl,
			"WARNING(S):\n"
			" The packet (ID " SIMC_PK_ID_FMT ") is being dropped \n"
		    " on this node running AODV/DYMO due to address family \n"
			" mismatch.\n"
			" Addressing Mode configured on this node: (%s)\n"
			" Address Family of dropped packet		: (%s)\n"
			"\n"
		    "POSSIBLE CAUSE(S):\n"
		    "1. The destination address of the received \n"
			"	control or application packet does not \n"
			"	match the address family currently supported\n"
			"	by this node.\n"
		    "\n"
		    "SUGGESTIONS:\n"
			"1. Ensure that the nodes configured to support\n"
			"	different address families do not exchange \n"
		    "	packets. Nodes configured to run AODV/DYMO can  \n"
			"	support either IPv4 or IPv6 but not both\n"
			"	at the same time.\n"
			"2. 'Addressing Mode' attribute for a node can  \n"
			"	be found under AD-HOC Routing Parameters-> \n"
			"	AODV/DYMO Parameters.\n"
			"\n"
		    "NOTE: This warning will only be printed a max of 2 times\n",

⌨️ 快捷键说明

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