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

📄 dsr_pkt_support.ex.c

📁 opnet11.5 manet dsr和aodv协议
💻 C
📖 第 1 页 / 共 4 页
字号:
							case (DSRC_ACKNOWLEDGEMENT):				{				/* Acknowledgement Option	*/				dsr_pkt_support_acknowledgement_mem_free (dsr_tlv_ptr);				break;				}							case (DSRC_SOURCE_ROUTE):				{				/* DSR Source Route Option	*/				dsr_pkt_support_source_route_mem_free (dsr_tlv_ptr);				break;				}						default:				{				/* Invalid option type	*/				op_sim_end ("Invalid Option Type in DSR packet", OPC_NIL, OPC_NIL, OPC_NIL);				break;				}			}		}		/* Free the list	*/	op_prg_mem_free (tlv_options_lptr);		FOUT;	}static voiddsr_pkt_support_route_request_mem_free (DsrT_Packet_Option* dsr_tlv_ptr)	{	DsrT_Route_Request_Option*		route_request_ptr = OPC_NIL;	int								num_hops, count;	InetT_Address*					hop_address_ptr;		/** Frees the memory associated with a route request	**/	/** option in the DSR packet header						**/	FIN (dsr_pkt_support_route_request_mem_free (<args>));		/* Get the route request options	*/	route_request_ptr = (DsrT_Route_Request_Option*) dsr_tlv_ptr->dsr_option_ptr;	inet_address_destroy (route_request_ptr->target_address);		/* Free each hop in the route	*/	if (route_request_ptr->route_lptr != OPC_NIL)		{		num_hops = op_prg_list_size (route_request_ptr->route_lptr);		for (count = 0; count < num_hops; count++)			{			hop_address_ptr = (InetT_Address*) op_prg_list_remove (route_request_ptr->route_lptr, OPC_LISTPOS_HEAD);			inet_address_destroy_dynamic (hop_address_ptr);			}		}		op_prg_mem_free (route_request_ptr->route_lptr);	op_prg_mem_free (route_request_ptr);	op_prg_mem_free (dsr_tlv_ptr);		FOUT;	}static voiddsr_pkt_support_route_reply_mem_free (DsrT_Packet_Option* dsr_tlv_ptr)	{	DsrT_Route_Reply_Option*		route_reply_ptr = OPC_NIL;	int								num_hops, count;	InetT_Address*					hop_address_ptr;		/** Frees the route reply TLV	**/	FIN (dsr_pkt_support_route_reply_mem_free (<args>));		/* Get the route reply options	*/	route_reply_ptr = (DsrT_Route_Reply_Option*) dsr_tlv_ptr->dsr_option_ptr;		/* Get the number of hops and destroy each hop	*/	num_hops = op_prg_list_size (route_reply_ptr->route_lptr);		for (count = 0; count < num_hops; count ++)		{		hop_address_ptr = (InetT_Address*) op_prg_list_remove (route_reply_ptr->route_lptr, OPC_LISTPOS_HEAD);		inet_address_destroy_dynamic (hop_address_ptr);		}		/* Free the list and the TLV	*/	op_prg_mem_free (route_reply_ptr->route_lptr);	op_prg_mem_free (route_reply_ptr);	op_prg_mem_free (dsr_tlv_ptr);		FOUT;	}static voiddsr_pkt_support_route_error_mem_free (DsrT_Packet_Option* dsr_tlv_ptr)	{	DsrT_Route_Error_Option*		route_error_ptr = OPC_NIL;		/** Frees the Route Error TLV	**/	FIN (dsr_pkt_support_route_error_mem_free (<args>));		/* Get the route error options	*/	route_error_ptr = (DsrT_Route_Error_Option*) dsr_tlv_ptr->dsr_option_ptr;		/* Free the IP addresses	*/	inet_address_destroy (route_error_ptr->error_source_address);	inet_address_destroy (route_error_ptr->error_dest_address);	inet_address_destroy (route_error_ptr->unreachable_node_address);		/* Free the memory	*/	op_prg_mem_free (route_error_ptr);	op_prg_mem_free (dsr_tlv_ptr);		FOUT;	}static voiddsr_pkt_support_ack_request_mem_free (DsrT_Packet_Option* dsr_tlv_ptr)	{	DsrT_Acknowledgement_Request*	ack_request_ptr = OPC_NIL;		/** Frees the Acknowledgement Request TLV	**/	FIN (dsr_pkt_support_ack_request_mem_free (<args>));		/* Get the acknowledgement request options	*/	ack_request_ptr = (DsrT_Acknowledgement_Request*) dsr_tlv_ptr->dsr_option_ptr;		/* Free the memory	*/	op_prg_mem_free (ack_request_ptr);	op_prg_mem_free (dsr_tlv_ptr);		FOUT;	}static voiddsr_pkt_support_acknowledgement_mem_free (DsrT_Packet_Option* dsr_tlv_ptr)	{	DsrT_Acknowledgement*		acknowledgement_ptr = OPC_NIL;		/** Frees the Acknowledgement TLV	**/	FIN (dsr_pkt_support_acknowledgement_mem_free (<void>));		/* Get the acknowledgement option	*/	acknowledgement_ptr = (DsrT_Acknowledgement*) dsr_tlv_ptr->dsr_option_ptr;		/* Destroy the IP addresses	*/	inet_address_destroy (acknowledgement_ptr->ack_source_address);	inet_address_destroy (acknowledgement_ptr->ack_dest_address);		/* Free the memory	*/	op_prg_mem_free (acknowledgement_ptr);	op_prg_mem_free (dsr_tlv_ptr);		FOUT;	}static voiddsr_pkt_support_source_route_mem_free (DsrT_Packet_Option* dsr_tlv_ptr)	{	DsrT_Source_Route_Option*		source_route_ptr = OPC_NIL;	int								num_hops, count;	InetT_Address*					hop_address_ptr;		/** Frees the DSR Source Route TLV	**/	FIN (dsr_pkt_support_source_route_mem_free (<args>));		/* Get the source route option	*/	source_route_ptr = (DsrT_Source_Route_Option*) dsr_tlv_ptr->dsr_option_ptr;		/* Free the IP addresses for each hop	*/	num_hops = op_prg_list_size (source_route_ptr->route_lptr);		for (count = 0; count < num_hops; count++)		{		hop_address_ptr = (InetT_Address*) op_prg_list_remove (source_route_ptr->route_lptr, OPC_LISTPOS_HEAD);		inet_address_destroy_dynamic (hop_address_ptr);		}		/* Free the memory allocated	*/	op_prg_mem_free (source_route_ptr->route_lptr);	op_prg_mem_free (source_route_ptr);	op_prg_mem_free (dsr_tlv_ptr);		FOUT;	}/*****************************************************//******** POOLED MEMORY ALLOCATION FUNCTIONS *********//*****************************************************/static DsrT_Packet_Option*dsr_pkt_support_option_mem_alloc (void)	{	static Pmohandle		dsr_option_pmh;	static Boolean			dsr_option_pmh_defined = OPC_FALSE;	DsrT_Packet_Option*		dsr_header_ptr = OPC_NIL;		/** Allocates pooled memory for the DSR header options	**/	FIN (dsr_pkt_support_option_mem_alloc (<args>));		if (dsr_option_pmh_defined == OPC_FALSE)		{		/* Define the pool memory for the DSR option header	*/		dsr_option_pmh = op_prg_pmo_define ("DSR TLV Option", sizeof (DsrT_Packet_Option), 32);		dsr_option_pmh_defined = OPC_TRUE;		}		/* Allocate the DSR header from the pooled memory	*/	dsr_header_ptr = (DsrT_Packet_Option*) op_prg_pmo_alloc (dsr_option_pmh);		FRET (dsr_header_ptr);	}static DsrT_Route_Request_Option*dsr_pkt_support_route_request_mem_alloc (void)	{	static Pmohandle				route_request_pmh;	DsrT_Route_Request_Option*		route_request_ptr = OPC_NIL;	static Boolean					route_request_pmh_defined = OPC_FALSE;		/** Allocates pooled memory for the route request	**/	/** options in the DSR header						**/	FIN (dsr_pkt_support_route_request_mem_alloc (<args>));		if (route_request_pmh_defined == OPC_FALSE)		{		/* Define the pool memory handle for route request	*/		/* option in the DSR packets if not already defined	*/		route_request_pmh = op_prg_pmo_define ("Route Request Option", sizeof (DsrT_Route_Request_Option), 32);		route_request_pmh_defined = OPC_TRUE;		}		/* Allocate the route request options from the pooled memory	*/	route_request_ptr = (DsrT_Route_Request_Option*) op_prg_pmo_alloc (route_request_pmh);	route_request_ptr->route_lptr = op_prg_list_create ();		FRET (route_request_ptr);	}static DsrT_Route_Reply_Option*dsr_pkt_support_route_reply_mem_alloc (void)	{	static Pmohandle				route_reply_pmh;	DsrT_Route_Reply_Option*		route_reply_ptr = OPC_NIL;	static Boolean					route_reply_pmh_defined = OPC_FALSE;		/** Allocates pooled memory for the route reply		**/	/** options in the DSR header						**/	FIN (dsr_pkt_support_route_reply_mem_alloc (void));		if (route_reply_pmh_defined == OPC_FALSE)		{		/* Define the pool memory handle for route reply	*/		/* option in the DSR packets if not already defined	*/		route_reply_pmh = op_prg_pmo_define ("Route Reply Option", sizeof (DsrT_Route_Reply_Option), 32);		route_reply_pmh_defined = OPC_TRUE;		}		/* Allocate the route reply options from the pooled memory	*/	route_reply_ptr = (DsrT_Route_Reply_Option*) op_prg_pmo_alloc (route_reply_pmh);	route_reply_ptr->route_lptr = op_prg_list_create ();		FRET (route_reply_ptr);	}static DsrT_Route_Error_Option*dsr_pkt_support_route_error_mem_alloc (void)	{	static Pmohandle				route_error_pmh;	DsrT_Route_Error_Option*		route_error_ptr = OPC_NIL;	static Boolean					route_error_pmh_defined = OPC_FALSE;		/** Allocates pooled memory for the route error		**/	/** options in the DSR header						**/	FIN (dsr_pkt_support_route_error_mem_alloc (void));		if (route_error_pmh_defined == OPC_FALSE)		{		/* Define the pool memory handle for route error	*/		/* option in the DSR packets if not already defined	*/		route_error_pmh = op_prg_pmo_define ("Route Error Option", sizeof (DsrT_Route_Error_Option), 32);		route_error_pmh_defined = OPC_TRUE;		}		/* Allocate the route error options from the pooled memory	*/	route_error_ptr = (DsrT_Route_Error_Option*) op_prg_pmo_alloc (route_error_pmh);		FRET (route_error_ptr);	}static DsrT_Acknowledgement_Request*dsr_pkt_support_ack_request_mem_alloc (void)	{	static Pmohandle				ack_request_pmh;	DsrT_Acknowledgement_Request*	ack_request_ptr = OPC_NIL;	static Boolean					ack_request_pmh_defined = OPC_FALSE;		/** Allocates pooled memory for the ack request		**/	/** options in the DSR header						**/	FIN (dsr_pkt_support_ack_request_mem_alloc (void));		if (ack_request_pmh_defined == OPC_FALSE)		{		/* Define the pool memory handle for ack request	*/		/* option in the DSR packets if not already defined	*/		ack_request_pmh = op_prg_pmo_define ("Acknowledgement Request Option", sizeof (DsrT_Acknowledgement_Request), 32);		ack_request_pmh_defined = OPC_TRUE;		}		/* Allocate the acknowledgement request option from the pooled memory	*/	ack_request_ptr = (DsrT_Acknowledgement_Request*) op_prg_pmo_alloc (ack_request_pmh);		FRET (ack_request_ptr);	}static DsrT_Acknowledgement*dsr_pkt_support_acknowledgement_mem_alloc (void)	{	static Pmohandle				acknowledgement_pmh;	DsrT_Acknowledgement*			acknowledgement_ptr = OPC_NIL;	static Boolean					acknowledgement_pmh_defined = OPC_FALSE;		/** Allocates pooled memory for the acknowledgement	**/	/** options in the DSR header						**/	FIN (dsr_pkt_support_acknowledgement_mem_alloc (void));		if (acknowledgement_pmh_defined == OPC_FALSE)		{		/* Define the pool memory handle for acknowledgement	*/		/* option in the DSR packets if not already defined	*/		acknowledgement_pmh = op_prg_pmo_define ("Acknowledgement Option", sizeof (DsrT_Acknowledgement), 32);		acknowledgement_pmh_defined = OPC_TRUE;		}		/* Allocate the acknowledgement option from the pooled memory	*/	acknowledgement_ptr = (DsrT_Acknowledgement*) op_prg_pmo_alloc (acknowledgement_pmh);		FRET (acknowledgement_ptr);	}static DsrT_Source_Route_Option*dsr_pkt_support_source_route_mem_alloc (void)	{	static Pmohandle				source_route_pmh;	DsrT_Source_Route_Option*		source_route_ptr = OPC_NIL;	static Boolean					source_route_pmh_defined = OPC_FALSE;		/** Allocates pooled memory for the source route	**/	/** options in the DSR header						**/	FIN (dsr_pkt_support_source_route_mem_alloc (void));		if (source_route_pmh_defined == OPC_FALSE)		{		/* Define the pool memory handle for source route	*/		/* option in the DSR packets if not already defined	*/		source_route_pmh = op_prg_pmo_define ("Source Route Option", sizeof (DsrT_Source_Route_Option), 32);		source_route_pmh_defined = OPC_TRUE;		}		/* Allocate the source route option from the pooled memory	*/	source_route_ptr = (DsrT_Source_Route_Option*) op_prg_pmo_alloc (source_route_pmh);	source_route_ptr->first_hop_external = OPC_FALSE;	source_route_ptr->last_hop_external = OPC_FALSE;	source_route_ptr->export_route = OPC_FALSE;	source_route_ptr->route_lptr = op_prg_list_create ();		FRET (source_route_ptr);	}

⌨️ 快捷键说明

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