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

📄 ip_notif_log_support.ex.c

📁 备
💻 C
📖 第 1 页 / 共 5 页
字号:
			packet_id, addr_node_str, addr_pkt_str);
		
		error_count++;
		}
	FOUT;
	}
	

void
ipnl_incompatible_network_addresses_error (List* same_net_interface_listptr)
	{
	static OmsT_Log_Handle		oms_log_handle = OMSC_LOG_HANDLE_INVALID;
	static int					call_count = 0;
	int							i, j, num_interfaces, entry_interface_num;
	IpT_Net_Traversal_Object	*iface_object_ptr, *duplicate_iface_object_ptr;
	char						node_name [22];
	char						iface_name [18];
	char						addr_str [IPC_ADDR_STR_LEN], mask_str [IPC_ADDR_STR_LEN];
	char						*interface_list_str, *interface_list_str_end_ptr;

	/** Logs when incompatible subnet addresses are used	**/
	
	FIN (ipnl_incompatible_network_addresses_error (same_net_interface_listptr));
	
	/* If this is the first time this function is being called,	*/
	/* initialize the oms log handle.							*/
	if (OMSC_LOG_HANDLE_INVALID == oms_log_handle)
		{
		oms_log_handle = oms_log_handle_create (OpC_Log_Category_Configuration,
			"IP", "Model_Configuration_Warning", 10, op_sim_time (),
			"WARNING:\n"
			" IP address auto-assignment procedure detected that\n"
			" there are incompatible subnet addresses used on the\n"
			" same network. IP expects all interfaces connected to\n"
			" a lower layer network (e.g an ethernet network) to\n"
			" belong to the same IP subnet, i.e the network address\n"
			" portion of their addresses should be the same.\n"
			" The list of all such interfaces is given at the end of\n"
			" this log message.\n"
			"\n"
			"SUGGESTION(s):\n"
			"1. If the lower layer network is logically partitioned\n"
			"   through the use of VLANs, PVCs etc. and the interfaces\n"
			"   belonging to the two IP subnets are in different\n"
			"   partitions, this is not an error and this log\n"
			"   message may be ignored.\n"
			"2. Otherwise, make sure that the above condition is\n"
			"   met by all interfaces in the IP subnets listed above.\n"
			"\n"
			"RESULT(s):\n"
			"1. Interfaces in different IP subnets will not be able\n"
			"   to send packets to each other.\n"
			"2. Packets broadcasted on one IP subnet might not be\n"
			"   handled correctly by nodes belonging to other\n"
			"   IP subnets.\n"
			"\n"
			"Node Name             Interface Name    Address/Subnet Mask\n"
			"====================  ================  ===================\n",
			"");
		}

	/* Increment the call count.								*/
	++call_count;

	/* Construct a string that lists all the interfaces in the list and	*/
	/* the routing protocol configuration on each.						*/

	/* Get the number of interfaces in the list.						*/
	num_interfaces = op_prg_list_size (same_net_interface_listptr);

	/* Estimate the size of the string.									*/
	interface_list_str = (char*) op_prg_mem_alloc (30 + num_interfaces * 75);

	/* Estimate the number of interfaces we can have in a single log	*/
	/* message list entry.												*/
	entry_interface_num = OmsC_Log_Max_Entry_Size / 75 - 5;
	
	/* Initialize the stirng with some header information.				*/
	interface_list_str_end_ptr = interface_list_str + sprintf (interface_list_str,
		"Network #%d\n===========\n\n", call_count);

	/* Loop through each interface and add it to the string.			*/
	for (i = 0; i < num_interfaces; i++)
		{
		/* Get the ith element from the list.							*/
		iface_object_ptr = (IpT_Net_Traversal_Object*) op_prg_list_access
			(same_net_interface_listptr, i);

		/* Due to the way we do a graph walk, the list might contain	*/
		/* duplicate entries. If this a duplicate entry, ignore it.		*/
		for (j = 0; j < i; j++)
			{
			duplicate_iface_object_ptr = (IpT_Net_Traversal_Object*) op_prg_list_access
				(same_net_interface_listptr, j);

			/* Is the current entry a duplicate of this entry.			*/
			if (duplicate_iface_object_ptr->interface_objid == iface_object_ptr->interface_objid)
				{
				/* Ignore this entry.									*/
				break;
				}
			}
		
		/* Check if the current entry is a duplicate entry.				*/
		if (j < i)
			{
			/* We broke out of the inner loop because the current entry	*/
			/* is a duplicate entry. Ignore it.							*/
			continue;
			}

		/* Get the name of the node.									*/
		op_ima_obj_attr_get_str (iface_object_ptr->node_objid, "name", 21, node_name);

		/* Get the interface name.										*/
		op_ima_obj_attr_get_str (iface_object_ptr->interface_objid, "Name", 17, iface_name);

		/* Read the IP address and mask attributes.						*/
		op_ima_obj_attr_get_str (iface_object_ptr->interface_objid, "Address", 16, addr_str);
		op_ima_obj_attr_get_str (iface_object_ptr->interface_objid, "Subnet Mask", 16, mask_str);

		/* Append this interface to the string.							*/
		interface_list_str_end_ptr += sprintf (interface_list_str_end_ptr, "%-20s  %-16s  %s/%s\n",
			node_name, iface_name, addr_str, mask_str);
		
		/* If we already appended certain number of interfaces into 	*/
		/* the interface list string, add this list string to the list	*/
		/* and create a new interface list string not to overrun the	*/
		/* memory limit for a log message list entry.					*/
		if ((i + 1) % entry_interface_num == 0)
			{
			/* Add the current string to the list.						*/
			oms_log_message_append (oms_log_handle, "%s", interface_list_str);
			op_prg_mem_free (interface_list_str);
			
			/* Start a new interface list string.						*/
			interface_list_str = (char*) op_prg_mem_alloc ((num_interfaces - i) * 75);
			interface_list_str_end_ptr = interface_list_str;
			}
		}

	/* Append a new line to the string.									*/
	strcat (interface_list_str_end_ptr, "\n");

	/* Append this network to the log message.							*/
	oms_log_message_append (oms_log_handle, "%s", interface_list_str);

	/* Free the memory allocated to the string.							*/
	op_prg_mem_free (interface_list_str);

	FOUT;
	}


void
ipnl_incompatible_address_and_subnet_error (const char* address, const char* mask, const char* objects)
	{
	/** Logs when an address and subnet mask conflict		**/
	
	FIN (ipnl_incompatiable_address_and_subnet_error (address, mask, objects));
	
	op_prg_log_entry_write (ip_config_error_loghndl,
		"ERROR:\n"
		" IP address auto-assignment procedure detected that\n"
		" there is an address and subnet conflict.\n"
		"\n"
		"   Address:      %s\n"
		"   Subnet Mask:  %s\n"
		"\n"
		"LOCATION:\n"
		" You can check the following interfaces and it's\n"
		" neighbors:\n"
		"%s\n"
		"\n"
		"SUGGESTION:\n"
		" Make sure that all IP addresses correspond to a\n"
		" legal and coinciding subnet mask.\n",
		address, mask, objects);
	FOUT;
	}

void
ipnl_cfgerr_multiple_rte_protocol (void)
	{
	/** This log message is called when it is detected 	**/
	/** that the network has been configured to use more**/
	/** than one routing protocol.						**/
	FIN (ipnl_cfgerr_multiple_rte_protocol (void));

	op_prg_log_entry_write (
		ip_config_error_loghndl,
		"ERROR(s):\n"
		" The network model has been configured with \n" 
		" more than one routing protocol.  E.g Some	\n"
		" routers could have been configured to		\n"
		" run RIP while some others might have  		\n"
		" OSPF or IGRP running.						\n"
		"SUGGESTION(S):\n"	
		" Configure all the routers to use the same	\n"
		" routing protocol. Edit the attribute		\n"
		" \"IP Routing Information\" so that the 	\n"
		"entire network runs the same routing protocol\n");

	FOUT;
	}

void
ipnl_invalid_default_route (const char* default_rte_str, InetT_Addr_Family addr_family)
	{
	const char* proto_params_str;

	/** Writes a log message indicating that the string	**/
	/** specified under the Default Route attribute of	**/
	/** a node does not represent a valid IP address.	**/

	FIN (ipnl_invalid_default_route (default_rte_str, addr_family));

	/* Set the proto_params_str appropriately.			*/
	if (InetC_Addr_Family_v4 == addr_family)
		{
		proto_params_str = "IP Host Parameters";
		}
	else
		{
		proto_params_str = "IPv6 Parameters";
		}

	op_prg_log_entry_write (
		ip_config_error_loghndl,
		"ERROR(S):\n"
		"1. The %s default route specified on this node is\n"
		"   invalid. The string \"%s\" specified under\n"
		"   the %s->Default Route attribute of this node\n"
		"   does not represent a valid %s address.\n"
		"\n"
		"SUGGESTION(S):\n"
		"1. Make sure the above attribute value is set to\n"
		"   a valid IP address.\n"
		"\n"
		"RESULT(S):\n"
		"1. This attribute will be reset to \"Auto Assigned\"\n",
		inet_addr_family_string (addr_family), default_rte_str,
		proto_params_str, inet_addr_family_string (addr_family));

	FOUT;
	}

void
ipnl_cfgerr_defroute (InetT_Addr_Family addr_family)
	{
	const char*	protocol_name;
	const char*	attribute_name;
	static Boolean message_written = OPC_FALSE;

	/** Description of the condition flagged by this	**/
	/** notification log message.						**/
	FIN (ipnl_cfgerr_defroute (addr_family));

	/* 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;

	/* Initialize the variables based on the addr family*/
	if (InetC_Addr_Family_v4 == addr_family)
		{
		protocol_name = "IPv4";
		attribute_name = "Default Route";
		}
	else
		{
		protocol_name = "IPv6";
		attribute_name = "IPv6 Default Route";
		}

	op_prg_log_entry_write (
		ip_config_warning_loghndl,
		"WARNING(S):\n"
		" The %s default route for this node\n"
		" has not been explicitly configured.\n"
		"\n"
		"SUGGESTIONS:\n"
		" 1. If the network contains only one %s\n"
		"    subnet, this message my be ignored.\n"
		" 2. Set the IP Host Parameters->%s \n"
		"    attribute on this node to the address\n"
		"    of a router interface in the same IP subnet.\n"
		" 3. IPv4 default routes may be automatically\n"
		"    assigned by setting the simulation attribute\n"
		"    \"IP Interface Addressing Mode\" to\n"
		"    \"Auto Addressed\" or \"Auto Addressed/Export\"\n"
		"RESULT(s):\n"
		"1. This node will not be able to send packets to\n"
		"   nodes that are not in the same IP subnet.\n"
		"\n"
		"Note: this message will not be repeated.\n",
		protocol_name, protocol_name, attribute_name);

	FOUT;
	}

void
ipnl_default_gtwy_configuration_ignored_log_write (void)
	{
	static Boolean	log_written = OPC_FALSE;

	/** Write a log message warning the user that the	**/
	/** IP Routing Parameters -> Default Gateway 		**/
	/** attribute configuration is being ignored.		**/

	FIN (ipnl_default_gtwy_configuration_ignored_log_write (void));

	/* Do not write this message multiple times.		*/
	if (OPC_FALSE == log_written)
		{
		op_prg_log_entry_write (
			ip_config_warning_loghndl,
			"WARNING(S):\n"
			"The IP Routing Parameters -> Default Gateway\n"
			"attribute configuration on this node is\n"
			"being ignored.\n"
			"\n"
			"POSSIBLE CAUSE(S):\n"
			"This attribute is no longer used.\n"
			"\n"
			"SUGGESTIONS:\n"
			" 1. To configure the gateway of last resort\n"
			"    on this node, use either the\n"
			"    IP Routing Parameters -> Default Network(s)\n"
			"    attribute or configure a static route to\n"
			"    0.0.0.0/0.\n");
		log_written = OPC_TRUE;
		}

	FOUT;
	}

void
ipnl_cfgwarn_intfcfg (int intf_index)
	{
	/** Description of the condition flagged by this	**/
	/** notification log message.						**/
	FIN (ipnl_cfgwarn_intfcfg (intf_index))

	op_prg_log_entry_write (
		ip_config_warning_loghndl,
		"WARNING:\n"
		" Could not map the %d'th row in \"IP > IP Routing\n"
		" Parameters > Interface Information\" to an IP interface.\n"
		"\n"
		"POSSIBLE CAUSE(S):\n"
		" An extra row has been added by the user to the \"IP > \n"
		" IP Routing Parameters > Interface Information\" attribute.\n" 
		"\n"
		"SUGGESTIONS:\n"
		" Delete row number %d from the \"IP > IP Routing \n"
		" Parameters > Interface Information\" attribute.\n"
		"\n"
		"NOTE:\n"
		" Row numbers in compound attributes start\n"
		" at zero.",
		intf_index, intf_index);

	FOUT
	}

void			
ipnl_missing_rows_in_intf_info_log_write (int num_cattr_rows, int total_num_phy_intf)
	{
	/** This function prints out a log message			**/
	/** indicating that the number of rows in the 		**/
	/** Interface Information compound attribute is		**/
	/** less than the number of physical interfaces of	**/
	/** this node.										**/

	FIN (ipnl_missing_rows_in_intf_info_log_write (num_cattr_rows, total_num_phy_intf));

	op_prg_log_entry_write (
		ip_config_error_loghndl,
		"ERROR:\n"
		" The number of rows under the \"IP Routing Parameters ->\n"
		" Interface Information\" compound attribute\n"
		" of this node does not match the actual\n"
		" number of physical interfaces of this node. The\n"
		" number of rows in the compound attribute is (%d),\n"
		" but the number of interfaces is (%d).\n"
		"\n"
		"POSSIBLE CAUSE(S):\n"
		" 1. The number of rows was manually changed.\n"
		" 2. The attribute \"model\" of this node was changed.\n"
		" 3. The node model architecture was manually modified\n"
		"    using the node editor.\n"
		"\n"
		"SUGGESTION(S):\n"
		" 1. Remove this node from the network and replace it\n"
		"    with a new one from the object palette. Note\n"
		"    that you will need to repeat any configuration\n"
		"    that you might have done on this node.\n"

⌨️ 快捷键说明

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