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

📄 jigb_wlan_support.ex.c

📁 利用opnet网络仿真软件,研究802.11的QOS,可以利用此模块研究802.11e
💻 C
📖 第 1 页 / 共 2 页
字号:
/** JIGB_wlan_support.ex.c				**/

/****************************************/
/*      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 <string.h>
#include "JIGB_wlan_support.h"


/*  Variables defined for Pooled Memory allocation.        */
static Pmohandle        	wlan_pk_dhstruct_pmh = NULL;
static Pmohandle			wlan_pk_bbstruct_pmh = NULL;
static Pmohandle        	wlan_pk_chstruct_pmh = NULL;
static Pmohandle        	wlan_pk_rhstruct_pmh = NULL;

/* Macro definition for string handling.                            */
#define PKPRINT_STRING_INSERT(str, contents, list)                              \
	{                                                                           \
	str = (char*) op_prg_mem_alloc ((strlen (contents) + 1) * sizeof (char));   \
	strcpy (str, contents);                                                     \
	op_prg_list_insert (list, str, OPC_LISTPOS_TAIL);                           \
	}


WlanT_Data_Header_Fields*
wlan_mac_pk_dhstruct_create ()
    {
    WlanT_Data_Header_Fields*   pk_dhstruct_ptr;
    
    /**  Allocate memory for packet field structure and initialize  **/
    /**  all components of the data structure. "Pooled" memory is   **/
	/**  used to allocate wlan packet fields data structure         **/
    /**  allocation block since they are frequently created         **/
    /**  and destroyed.                                             **/
    FIN (wlan_mac_pk_dhstruct_create ());

    /*  If the pooled memory object has not yet been defined, do	*/
    /*  so now, prior to allocation.                                */
    if (!wlan_pk_dhstruct_pmh)
        {
        wlan_pk_dhstruct_pmh = op_prg_pmo_define ("wlan packet data headers fields", sizeof (WlanT_Data_Header_Fields), 64);

		/* Initialize the print procedure for the structures.       */
		op_pk_format_print_proc_set ("wlan_mac", "Wlan Header", wlan_mac_pk_data_header_pkprint);		
        }

    pk_dhstruct_ptr = (WlanT_Data_Header_Fields *) op_prg_pmo_alloc (wlan_pk_dhstruct_pmh);
 	if (pk_dhstruct_ptr == OPC_NIL)
		 {
		 op_sim_end ("Error in wlan support code:", "Unable to allocate memory for wlan packet fields.", OPC_NIL, OPC_NIL);
		 }
 
	/* Initialize the header fields.								*/
	pk_dhstruct_ptr->more_frag 		 = 0; 
	pk_dhstruct_ptr->retry 			 = 0; 
	pk_dhstruct_ptr->order 			 = 0;
	pk_dhstruct_ptr->tods 			 = 0;
	pk_dhstruct_ptr->fromds 		 = 0;
	pk_dhstruct_ptr->duration 		 = 0;	/* Duration for which the channel is contended 					*/
	pk_dhstruct_ptr->address1 		 = 0;	/* Destination Address of the final recipient(s) of the frame.	*/
	pk_dhstruct_ptr->address2 		 = 0;	/* Source Address from where the frame is originated.			*/
	pk_dhstruct_ptr->address3        = 0;	/* Receiver Address that identifies the immediated recipient	*/
											/* station(s) address.											*/
	pk_dhstruct_ptr->fragment_number = 0;	/* Sequence control field which contains fragment number		*/
	pk_dhstruct_ptr->sequence_number = 0; 	/* Sequence control field which contains sequence number		*/
	pk_dhstruct_ptr->address4        = 0;	/* Transmitter Address of the station that has last transmitted	*/
											/* the frame.													*/	 
	pk_dhstruct_ptr->more_data       = 0;  	/* Indicates STA has additional packets to send. Implemented 	*/
	 									   	/* only for PCF 												*/								
	     
	FRET (pk_dhstruct_ptr);
    }  
 
  
WlanT_Control_Header_Fields* 
wlan_mac_pk_chstruct_create () 
    { 
    WlanT_Control_Header_Fields*        pk_chstruct_ptr; 
     
    /**  Allocate memory for packet field structure and initialize	**/ 
    /**  all components of the data structure. "Pooled" memory is	**/ 
    /**  used to allocate wlan packet fields data structure			**/ 
    /**  allocation block since they are frequently created			**/ 
    /**  and destroyed.                                   			**/ 
    FIN (wlan_mac_pk_chstruct_create ()); 
 
    /*  If the pooled memory object has not yet been defined, do    */ 
    /*  so now, prior to allocation.                                */ 
    if (!wlan_pk_chstruct_pmh)
        { 
        wlan_pk_chstruct_pmh = op_prg_pmo_define ("wlan packet control header fields", sizeof (WlanT_Control_Header_Fields), 64); 

		/* Initialize the print procedure for the structures.       */
		op_pk_format_print_proc_set ("wlan_control", "Wlan Header", wlan_mac_pk_control_header_pkprint);		 
        } 
 
    pk_chstruct_ptr = (WlanT_Control_Header_Fields *) op_prg_pmo_alloc (wlan_pk_chstruct_pmh); 
 	if (pk_chstruct_ptr == OPC_NIL) 
		{ 
		op_sim_end ("Error in wlan support code:", "Unable to allocate memory for wlan packet fields.", OPC_NIL, OPC_NIL); 
		} 	
 
    /*  Initialize all fields of the packet fields data structure   */ 
	pk_chstruct_ptr->more_frag = 0; 
	pk_chstruct_ptr->retry     = 0; 
	pk_chstruct_ptr->order     = 0;
	pk_chstruct_ptr->tods      = 0;
	pk_chstruct_ptr->fromds    = 0;
	pk_chstruct_ptr->duration  = 0;		/* Duration for which the channel is contended 					*/
	pk_chstruct_ptr->rx_addr   = 0;    	/* Destination Address of the final recipient(s) of the frame.	*/
	pk_chstruct_ptr->tx_addr   = 0;    	/* Source Address from where the frame is originated.			*/
	 
    FRET (pk_chstruct_ptr); 
    }   
 
WlanT_Req_Header_Fields* 
wlan_mac_pk_rhstruct_create () 
    { 
    WlanT_Req_Header_Fields*        pk_rhstruct_ptr; 
     
    /**  Allocate memory for packet field structure and initialize	**/ 
    /**  all components of the data structure. "Pooled" memory is	**/ 
    /**  used to allocate wlan packet fields data structure			**/ 
    /**  allocation block since they are frequently created			**/ 
    /**  and destroyed.                                   			**/ 
    FIN (wlan_mac_pk_rhstruct_create ()); 
 
    /*  If the pooled memory object has not yet been defined, do    */ 
    /*  so now, prior to allocation.                                */ 
    if (!wlan_pk_rhstruct_pmh)
        { 
        wlan_pk_rhstruct_pmh = op_prg_pmo_define ("wlan packet req header fields", sizeof (WlanT_Req_Header_Fields), 64); 

		/* Initialize the print procedure for the structures.       */
		op_pk_format_print_proc_set ("JIGB_wlan_Req", "Wlan Header", wlan_mac_pk_req_header_pkprint);		 
        } 
 
    pk_rhstruct_ptr = (WlanT_Req_Header_Fields *) op_prg_pmo_alloc (wlan_pk_rhstruct_pmh); 
 	if (pk_rhstruct_ptr == OPC_NIL) 
		{ 
		op_sim_end ("Error in wlan support code:", "Unable to allocate memory for wlan packet fields.", OPC_NIL, OPC_NIL); 
		} 	
 
    /*  Initialize all fields of the packet fields data structure   */ 
	pk_rhstruct_ptr->more_frag = 0; 
	pk_rhstruct_ptr->retry     = 0; 
	pk_rhstruct_ptr->order     = 0;
	pk_rhstruct_ptr->tods      = 0;
	pk_rhstruct_ptr->fromds    = 0;
	pk_rhstruct_ptr->duration  = 0;		/* Duration for which the channel is contended 					*/
	pk_rhstruct_ptr->rx_addr   = 0;    	/* Destination Address of the final recipient(s) of the frame.	*/
	pk_rhstruct_ptr->tx_addr   = 0;     /* Source Address from where the frame is originated.			*/
	pk_rhstruct_ptr->P         = 0; 
	pk_rhstruct_ptr->Lm        = 0;
	pk_rhstruct_ptr->lm        = 0;
	pk_rhstruct_ptr->Nm        = 0;
	pk_rhstruct_ptr->flagm     = 0;
	
    FRET (pk_rhstruct_ptr); 
    }   


WlanT_Beacon_Body_Fields* 
wlan_mac_pk_bbstruct_create () 
    { 
    WlanT_Beacon_Body_Fields*   pk_bbstruct_ptr; 
     
    /**  Allocate memory for packet field structure and initialize	**/ 
    /**  all components of the data structure. "Pooled" memory is	**/ 
    /**  used to allocate wlan packet fields data structure    		**/ 
    /**  allocation block since they are frequently created      	**/ 
    /**  and destroyed.                                         	**/ 
    FIN (wlan_mac_pk_bbstruct_create ()); 
 
    /*  If the pooled memory object has not yet been defined, do    */ 
    /*  so now, prior to allocation.                                */ 
    if (!wlan_pk_bbstruct_pmh)
        { 
        wlan_pk_bbstruct_pmh = op_prg_pmo_define ("wlan packet Beacon body fields", sizeof (WlanT_Beacon_Body_Fields), 64); 

		/* Initialize the print procedure for the structures.       */
		op_pk_format_print_proc_set ("wlan_beacon_body", "Beacon Body", wlan_mac_pk_beacon_body_pkprint);		 
        } 
 
    pk_bbstruct_ptr = (WlanT_Beacon_Body_Fields *) op_prg_pmo_alloc (wlan_pk_bbstruct_pmh); 
 	if (pk_bbstruct_ptr == OPC_NIL) 
		 { 
		 op_sim_end ("Error in wlan support code:", "Unable to allocate memory for wlan beacon body fields.", OPC_NIL, OPC_NIL); 
		 } 
 
    /*  Initialize all fields of the packet fields data structure   */ 
	 pk_bbstruct_ptr->timestamp       = 0.0; 			
	 pk_bbstruct_ptr->beacon_intv     = 0.0; 			
	 pk_bbstruct_ptr->non_erp_present = OPC_FALSE;	
	 pk_bbstruct_ptr->cf_par.cfp_count        = 0;	
	 pk_bbstruct_ptr->cf_par.cfp_period       = 0;
	 pk_bbstruct_ptr->cf_par.cfp_maxduration  = 0;
	 pk_bbstruct_ptr->cf_par.cfp_durremaining = 0;			
	 
    FRET (pk_bbstruct_ptr); 
    } 



WlanT_Data_Header_Fields*
wlan_mac_pk_dhstruct_copy (WlanT_Data_Header_Fields* pk_dh_ptr)
    {
    WlanT_Data_Header_Fields*  copy_pk_dh_ptr;
 
    /**  Copy the packet field structure.    **/
    FIN (wlan_mac_pk_dhstruct_copy (pk_dh_ptr));
 
    /*  Allocate memory for packet field structure and	*/
    /*  copy it.                                        */
    copy_pk_dh_ptr = (WlanT_Data_Header_Fields *) op_prg_pmo_alloc (wlan_pk_dhstruct_pmh);
 	if (copy_pk_dh_ptr == OPC_NIL)
		 {
		 op_sim_end ("Error in wlan support code:",
					 "Unable to allocate memory for copying wlan packet fields.",
					 OPC_NIL, OPC_NIL);
		 } 
	/* Copy frame control fields*/
    op_prg_mem_copy (pk_dh_ptr, copy_pk_dh_ptr, sizeof(WlanT_Data_Header_Fields));
 
    FRET (copy_pk_dh_ptr);
    } 
 

WlanT_Control_Header_Fields* 
wlan_mac_pk_chstruct_copy (WlanT_Control_Header_Fields* pk_ch_ptr) 
    { 
    WlanT_Control_Header_Fields*  copy_pk_ch_ptr; 
  
    /**  Copy the packet field structure.    **/ 
    FIN (wlan_mac_pk_chstruct_copy (pk_ch_ptr)); 
  
    /*  Allocate memory for packet field structure and 	*/ 
    /*  copy it.                                        */ 
    copy_pk_ch_ptr = (WlanT_Control_Header_Fields *) op_prg_pmo_alloc (wlan_pk_chstruct_pmh); 
 	if (copy_pk_ch_ptr == OPC_NIL) 
		 { 
		 op_sim_end ("Error in wlan support code:", 
					 "Unable to allocate memory for copying wlan packet fields.", 
					 OPC_NIL, OPC_NIL); 
		 } 
	/* Copy sequence control fields				*/ 
    op_prg_mem_copy (pk_ch_ptr, copy_pk_ch_ptr, sizeof(WlanT_Control_Header_Fields)); 
  
    FRET (copy_pk_ch_ptr); 
    }  

WlanT_Req_Header_Fields* 
wlan_mac_pk_rhstruct_copy (WlanT_Req_Header_Fields* pk_rh_ptr) 
    { 
    WlanT_Req_Header_Fields*  copy_pk_rh_ptr; 
  
    /**  Copy the packet field structure.    **/ 
    FIN (wlan_mac_pk_rhstruct_copy (pk_rh_ptr)); 
  
    /*  Allocate memory for packet field structure and 	*/ 
    /*  copy it.                                        */ 
    copy_pk_rh_ptr = (WlanT_Req_Header_Fields *) op_prg_pmo_alloc (wlan_pk_rhstruct_pmh); 
 	if (copy_pk_rh_ptr == OPC_NIL) 
		 { 
		 op_sim_end ("Error in wlan support code:", 
					 "Unable to allocate memory for copying wlan packet fields.", 
					 OPC_NIL, OPC_NIL); 
		 } 
	/* Copy sequence control fields				*/ 
    op_prg_mem_copy (pk_rh_ptr, copy_pk_rh_ptr, sizeof(WlanT_Req_Header_Fields)); 
  
    FRET (copy_pk_rh_ptr); 
    }  

 
WlanT_Beacon_Body_Fields*
wlan_mac_pk_bbstruct_copy (WlanT_Beacon_Body_Fields* pk_bb_ptr)
    {
    WlanT_Beacon_Body_Fields*  copy_pk_bb_ptr;
 
    /**  Copy the packet field structure.    **/
    FIN (wlan_mac_pk_bbstruct_copy (pk_bb_ptr));
 
    /*  Allocate memory for packet field structure and 	*/
    /*  copy it.                                        */
    copy_pk_bb_ptr = (WlanT_Beacon_Body_Fields *) op_prg_pmo_alloc (wlan_pk_bbstruct_pmh);
 	if (copy_pk_bb_ptr == OPC_NIL)
		 {
		 op_sim_end ("Error in wlan support code:",
					 "Unable to allocate memory for copying wlan beacon body fields.",
					 OPC_NIL, OPC_NIL);
		 } 
	/* Copy frame control fields*/
    op_prg_mem_copy (pk_bb_ptr, copy_pk_bb_ptr, sizeof(WlanT_Beacon_Body_Fields));
 
    FRET (copy_pk_bb_ptr);
    } 

void

⌨️ 快捷键说明

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