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

📄 sig.c

📁 wimax BS simulation code,implemented under linux.
💻 C
📖 第 1 页 / 共 2 页
字号:
		case DCD_TLVMASK_Downlink_Burst_Profile :			break;		case DCD_TLVMASK_BS_EIRP :		case DCD_TLVMASK_PHY_Type :		case DCD_TLVMASK_Power_adjustment_rule :			t = 5; l = 1; v = &g_bsinfo.power_adjustment_rule;			break;		case DCD_TLVMASK_Channel_Nr :			t = 6; l = 1; v = &g_bsinfo.channel_nr;			break;		case DCD_TLVMASK_TTG :			t = 7; l = 2; be2 = htons(g_bsinfo.ttg); v = &be2;			break;		case DCD_TLVMASK_RTG :			t = 8; l = 1; v = &g_bsinfo.rtg;			break;		case DCD_TLVMASK_RSS_IR_max :			t = 9; l = 2; be2 = htons(g_bsinfo.rss_ir_max); v = &be2;			break;		case DCD_TLVMASK_Channel_Switch_Frame_Number :		case DCD_TLVMASK_Frequency :			t = 12; l = 4; be4 = htonl(g_bsinfo.frequency); v = &be4;			break;		case DCD_TLVMASK_BS_ID :			t = 13; l = 6; v = g_bsinfo.mac_addr;			break;		case DCD_TLVMASK_Frame_Duration_Code :			t = 14; l = 1; v = &g_bsinfo.frame_duration_code;			break;		case DCD_TLVMASK_Frame_Number :			t = 15; l = 3; be4 = htonl(g_bsinfo.frame<<8); v = &be4;			break;		case DCD_TLVMASK_H_ARQ_ACK_delay_for_DL_burst :		case DCD_TLVMASK_Permutation_type_for_broadcast_region_in_HARQ_zone :		case DCD_TLVMASK_Maximum_retransmission :			t = 20; l = 1; v = &g_bsinfo.maximum_retransmission;			break;		case DCD_TLVMASK_Default_RSSI_and_CINR_averaging_parameter :		case DCD_TLVMASK_DL_AMC_allocated_physical_bands_bitmap :		case DCD_TLVMASK_H_Add_Threshold :		case DCD_TLVMASK_H_Delete_Threshold :		case DCD_TLVMASK_ASR_Anchor_Switch_Report_Slot_Length_M_an_SwitchingPeriod_L_ :		case DCD_TLVMASK_DL_region_definition :		case DCD_TLVMASK_Paging_Group_ID :		case DCD_TLVMASK_TUSC1_permutation_active_subchannels_bitmap :		case DCD_TLVMASK_TUSC2_permutation_active_sbuchannels_bitmap :		case DCD_TLVMASK_HO_type_support :		case DCD_TLVMASK_Hysteresis_margin :		case DCD_TLVMASK_Time_to_Trigger_duration :		case DCD_TLVMASK_Trigger :		case DCD_TLVMASK_N_I :		case DCD_TLVMASK_Downlink_burst_profile_for_multiple_FEC_types :		case DCD_TLVMASK_BS_Restart_Count :		case DCD_TLVMASK_MAC_version :			t = 148; l = 1; v = &g_bsinfo.mac_version;			break;		}		if ( n - 1 == DCD_TLVMASK_Downlink_Burst_Profile ) {			t = 1;			__set_bit(BURSTPROFILE_TLVMASK_FEC, (volatile unsigned long *)&tlvmask);			for ( i = 0; i < bp->nr; i++ ) {				v = burstpf_encoding(&l, 0, bp->code[i], i, tlvmask, bp);				off += tlv_encoding(buf+off, len-off, t, l, (uint8_t *)v);				free(v);			}		}		else 			off += tlv_encoding(buf+off, len-off, t, l, (uint8_t *)v);	}	return off;}int32_t build_ucd(uint8_t *buf, uint32_t len, ucdinfo_t *ucd, struct burstpf_set *bp){	uint32_t off = 0, n = 0;	uint8_t t; uint32_t l; void *v;	uint32_t be4, tlvmask = 0;	int32_t i;	memcpy(buf+off, &ucd->ucdhdr, sizeof(ucd->ucdhdr));	off += sizeof(ucd->ucdhdr);	while ( ! (ucd->tlvmask[0] == 0 && ucd->tlvmask[1] == 0) ) {		if  ( ! __test_and_clear_bit(n++, (volatile unsigned long *)ucd->tlvmask) )			continue;		switch ( n-1 ){		case UCD_TLVMASK_Uplink_Burst_Profile :			break;		case UCD_TLVMASK_Contention_based_reservation_timeout :		case UCD_TLVMASK_Bandwidth_request_opportunity_size :		case UCD_TLVMASK_Ranging_request_opportunity_size :		case UCD_TLVMASK_Frequency :			t = 5; l = 4; be4 = htonl(g_bsinfo.frequency); v = &be4;			break;		case UCD_TLVMASK_HO_ranging_start :		case UCD_TLVMASK_HO_ranging_end :		case UCD_TLVMASK_UL_AMC_Allocated_physical_bands_bitmap :		case UCD_TLVMASK_Initial_ranging_codes :			t = 150; l = 1; v = &g_bsinfo.initial_ranging_codes;			break;		case UCD_TLVMASK_Periodic_ranging_codes :			t = 151; l = 1; v = &g_bsinfo.periodic_ranging_codes;			break;		case UCD_TLVMASK_Bandwidth_request_codes :			t = 152; l = 1; v = &g_bsinfo.bandwidth_request_codes;			break;		case UCD_TLVMASK_Periodic_ranging_backoff_start :			t = 153; l = 1; v = &g_bsinfo.periodic_ranging_backoff_start;			break;		case UCD_TLVMASK_Periodic_ranging_backoff_end :			t = 154; l = 1; v = &g_bsinfo.periodic_ranging_backoff_end;			break;		case UCD_TLVMASK_Start_of_ranging_codes_group :			t = 155; l = 1; v = &g_bsinfo.start_of_ranging_codes_group;			break;		case UCD_TLVMASK_Permutation_base :		case UCD_TLVMASK_UL_allocated_subchannels_bitmap :		case UCD_TLVMASK_Optional_permutation_UL_Allocated_subchannels_bitmap :		case UCD_TLVMASK_Band_AMC_Allocation_Threshold :		case UCD_TLVMASK_Band_AMC_Release_Threshold :		case UCD_TLVMASK_Band_AMC_Allocation_Timer :		case UCD_TLVMASK_Band_AMC_Release_Timer :		case UCD_TLVMASK_Band_Status_Reporting_MAX_Period :		case UCD_TLVMASK_Band_AMC_Retry_Timer :		case UCD_TLVMASK_Safety_Channel_Allocation_Threshold :		case UCD_TLVMASK_Safety_Channel_Release_Threshold :		case UCD_TLVMASK_Safety_Channel_Allocation_Timer :		case UCD_TLVMASK_Safety_Channel_Release_Timer :		case UCD_TLVMASK_Bin_Status_Reporting_MAX_Period :		case UCD_TLVMASK_Safety_Channel_Retry_Timer :		case UCD_TLVMASK_H_ARQ_ACK_delay_for_DL_burst :		case UCD_TLVMASK_CQICH_Band_AMC_Transition_Delay :		case UCD_TLVMASK_Maximum_retransimission :			t = 174; l = 1; v = &g_bsinfo.maximum_retransmission;			break;		case UCD_TLVMASK_Normalized_C_N_override :		case UCD_TLVMASK_Size_of_CQICH_ID_field	:		case UCD_TLVMASK_Normalized_C_N_override2 :		case UCD_TLVMASK_Band_AMC_Entry_Average_CINR :		case UCD_TLVMASK_UpperBound_AAS_PREAMBLE :		case UCD_TLVMASK_LowerBound_AAS_PREAMBLE :		case UCD_TLVMASK_Allow_AAS_Beam_Select_Messages :		case UCD_TLVMASK_Use_CQICH_indication_flag :		case UCD_TLVMASK_MS_specific_up_power_offset_adjustment_step :		case UCD_TLVMASK_MS_specific_down_power_offset_adjustment :		case UCD_TLVMASK_Minimum_level_of_power_offset_adjustment :		case UCD_TLVMASK_Maximum_level_of_power_offset_adjustment :		case UCD_TLVMASK_Handover_Ranging_Codes	:		case UCD_TLVMASK_Initial_ranging_interval :		case UCD_TLVMASK_Tx_Power_Report :		case UCD_TLVMASK_Normalized_C_N_for_Channel_Sounding :		case UCD_TLVMASK_Initial_ranging_backoff_start :		case UCD_TLVMASK_Initial_ranging_backoff_end :		case UCD_TLVMASK_Bandwidth_request_backoff_start :		case UCD_TLVMASK_Bandwidth_request_backoff_end :		case UCD_TLVMASK_Uplink_burst_profile_for_multiple_FEC_types :			break;		}		if ( n - 1 == UCD_TLVMASK_Uplink_Burst_Profile ) {			t = 1;			__set_bit(BURSTPROFILE_TLVMASK_FEC, (volatile unsigned long *)&tlvmask);			for ( i = 0; i < bp->nr; i++ ) {				v = burstpf_encoding(&l, 1, bp->code[i], i, tlvmask, bp);				off += tlv_encoding(buf+off, len-off, t, l, (uint8_t *)v);				free(v);			}		}		else			off += tlv_encoding(buf+off, len-off, t, l, (uint8_t *)v);	}	return off;}int32_t build_rngrsp(uint8_t *buf, uint32_t len, rngrspinfo_t *rngrspinfo){	uint32_t off = 0, n = 0;	uint8_t t; uint32_t l; void *v;	uint32_t be4;	memcpy(buf+off, &rngrspinfo->rngrsphdr, sizeof(rngrspinfo->rngrsphdr));	off += sizeof(rngrspinfo->rngrsphdr);	while ( ! (rngrspinfo->tlvmask[0] == 0 && rngrspinfo->tlvmask[1] == 0) ) {		if  ( ! __test_and_clear_bit(n++, (volatile unsigned long *)rngrspinfo->tlvmask) )			continue;				switch ( n-1 ) {		case RNGRSP_TLVMASK_Timing_Adjust :		case RNGRSP_TLVMASK_Power_Level_Adjust :		case RNGRSP_TLVMASK_Offset_Frequency_Adjust :		case RNGRSP_TLVMASK_Ranging_Status :			t = 4; l = 1; v = &rngrspinfo->ranging_status;			break;		case RNGRSP_TLVMASK_Downlink_frequency_override :		case RNGRSP_TLVMASK_Uplink_channel_ID_override :		case RNGRSP_TLVMASK_Downlink_Operational_Burst_Profile :		case RNGRSP_TLVMASK_SS_MAC_Address :		case RNGRSP_TLVMASK_Basic_CID :		case RNGRSP_TLVMASK_Primary_Management_CID :		case RNGRSP_TLVMASK_AAS_broadcast_permission :		case RNGRSP_TLVMASK_Frame_number :		case RNGRSP_TLVMASK_Initial_ranging_oportunity_number :		case RNGRSP_TLVMASK_Ranging_code_attributes :			break;		}		off += tlv_encoding(buf+off, len-off, t, l, (uint8_t *)v);	}	return off;}/* @l:	the length of `v'. * in fact, there is a trick in it. */int32_t tlv_encoding(uint8_t *buf, uint32_t len, uint8_t t, uint32_t l, uint8_t *v){	uint8_t tmp[5];	int32_t i = 1;	uint8_t res;	if ( l > 128 ) {		while (  l != 0 ) {			if ( (res = (l & 0xff000000) >> 24) )				tmp[i++] = res;			l <<= 8;		}				tmp[0] = (1 << 31) | (i - 1);	}	else 		tmp[0] =  (uint8_t)l;	if ( 1 + i + l > len )		return -1;		buf[0] = t;	memcpy(&buf[1], tmp, i);	memcpy(&buf[i+1], v, l);	return 1+i+l;}uint8_t *burstpf_encoding(uint32_t *len, uint8_t doru, uint8_t code, uint8_t xiuc, uint32_t tlvmask, struct burstpf_set *bp){	uint32_t n = 0, m = 0, off = 0;	uint8_t *buf, *tmp;	uint8_t t; uint32_t l; void *v;	uint32_t be4;	while ( n < 6) {		if  ( ! variable_test_bit(n++, (volatile unsigned long *)&tlvmask) )			continue;		switch ( n-1 ) {		case BURSTPROFILE_TLVMASK_FEC :		case BURSTPROFILE_TLVMASK_DIUC_Mandatory_exit_threshold :		case BURSTPROFILE_TLVMASK_DIUC_Minimum_entry_threshold :		case BURSTPROFILE_TLVMASK_Ranging_data_ratio :			m += 3;			break;		case BURSTPROFILE_TLVMASK_Frequency :			m += 6;			break;		}	}	if ( (tmp = buf = (uint8_t *)malloc(m+1)) == NULL )		return NULL;	*len = m + 1;	tmp[0] = (code<<4) | xiuc;		off = 0; n = 0;	while ( tlvmask != 0 ) {		if  ( ! test_and_clear_bit(n++, (volatile unsigned long *)&tlvmask) )			continue;				switch ( n-1 ) {		case BURSTPROFILE_TLVMASK_FEC :			t = 150; l = 1 ; v = &bp->xiuc_fec[doru][xiuc];			break;		case BURSTPROFILE_TLVMASK_DIUC_Mandatory_exit_threshold :			t = 151; l = 1;	v = &bp->diuc_mandatory_exit_threshold[xiuc];			break;		case BURSTPROFILE_TLVMASK_DIUC_Minimum_entry_threshold :			t = 152; l = 1; v = &bp->diuc_minimum_entry_threshold[xiuc];			break;		case BURSTPROFILE_TLVMASK_Frequency :			t = 1; l = 4; be4 = htonl(bp->frequency[xiuc]); v = &be4;			break;		case BURSTPROFILE_TLVMASK_Ranging_data_ratio :			t = 151; l = 1; v = &bp->ranging_data_ratio[xiuc];			break;		}				off += tlv_encoding(tmp+1+off, m-off, t, l, (uint8_t *)v);	}		return buf;}static void do_release_ss(uint32_t arga, void *argb){	release_ss((ssinfo_t *)argb);	return;}

⌨️ 快捷键说明

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