utils.c 6.02 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*________________________openair_rrc_utils.c________________________

 Authors : Hicham Anouar
 Company : EURECOM
 Emails  : anouar@eurecom.fr
________________________________________________________________*/




//#include "openair_types.h"
#include "defs.h"
#include "extern.h"
//#include "openair_proto.h"


#ifndef USER_MODE
char bcmp(void *x, void *y,int Size ){
  unsigned char i;
  for(i=0;i<Size;i++)
    if(*(char*)(x+i)!= *(char *)(y+i))
      return 1;
  return 0;
}
#endif 


//------------------------------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
29
30
uint16_t find_free_dtch_position(uint8_t Mod_id, uint16_t UE_CH_index){
  uint16_t i,j;
31
32
33
34
35
36
37
38
39
40
41
42
  if(UE_CH_index==0)
    j=0;
  else 
    j=1;
  for(i=j;i<NB_RAB_MAX;i++){//first RAB IS BROADCAST DTCH

    //msg("i=%d\n",i);
    if(CH_rrc_inst[Mod_id].Rab[i][UE_CH_index].Active==0)
      return( i);
  }  
  msg("NO FREE DTCH LCHAN, exit... \n");

gauthier's avatar
gauthier committed
43
    Mac_rlc_xface->macphy_exit("NO FREE DTCH LCHAN, exit");
44
45
46
47
48

  return 0;
}

//-------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
49
uint8_t rrc_find_free_ue_index(uint8_t Mod_id){
50
//-------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
51
  uint16_t i;
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  for(i=1;i<=NB_CNX_CH;i++)
    if ( (CH_rrc_inst[Mod_id].Info.UE_list[i][0] == 0) &&
	 (CH_rrc_inst[Mod_id].Info.UE_list[i][1] == 0) &&	
	 (CH_rrc_inst[Mod_id].Info.UE_list[i][2] == 0) &&
	 (CH_rrc_inst[Mod_id].Info.UE_list[i][3] == 0) &&
	 (CH_rrc_inst[Mod_id].Info.UE_list[i][4] == 0))
      return i;
  return 0xff;  
}


//-------------------------------------------------------------------------------------------//
unsigned short rrc_find_ue_index(unsigned char Mod_id, L2_ID Mac_id){
//-------------------------------------------------------------------------------------------//
  unsigned char i; 
  /*
  for(i=0;i<=NB_CNX_CH;i++)
    if( bcmp(Mac_id.L2_id,CH_rrc_inst[Mod_id].Info.UE_list[i].L2_id,sizeof(L2_ID))==0)
      return i;
  return i;
  */
}
//-------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
75
uint8_t rrc_is_node_isolated(uint8_t Mod_id){
76
//-------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
77
  /*uint8_t i;
78
79
80
81
82
83
84
85
  for(i=0;i<NB_CNX_UE;i++)
    if( Rrc_inst[Mod_id].Rrc_info[i].Info.UE_info.Nb_bcch_wait < NB_WAIT_CH_BCCH) 
      break;
  return((i==NB_CNX_UE)?1:0);  
*/
}

//-------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
86
uint8_t find_rrc_info_index(uint8_t Mod_id,uint8_t CH_id){
87
  //-------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
88
  /*uint8_t i;
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

  for (i=0;i<NB_CNX_UE;i++){
    msg("RRC_FIND_CH_INFO %d, Now %d \n",CH_id,Rrc_inst[Mod_id].Rrc_info[i].Info.UE_info.CH_id);
    if(Rrc_inst[Mod_id].Rrc_info[i].Info.UE_info.CH_id == CH_id) return i;
  }
  error_msg("[OPENAIR][RRC] RRC_INFO_INDEX: FATAL ERROR: Not yet Pre_Synchronized with CH ???%d\n",CH_id);
#ifndef USER_MODE
  //  mac_xface->macphy_exit();
#else
  exit(-1);
#endif    
  */
}
/*
//--------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
104
SRB_INFO* rrc_find_srb_info(uint8_t Mod_id,uint16_t Srb_id){
105
    //----------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
106
  uint8_t i;
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  if(Rrc_inst[Mod_id].Rrc_info[0].Status == CH_READY){
    for(i=0;i<NB_CNX_CH;i++){
      //msg("i=%d, Srb0Id %d Srb2Id %d S_id=%d\n",i,Rrc_inst[Mod_id].Srb0[i].Srb_id,Rrc_inst[Mod_id].Srb2[i].Srb_info.Srb_id, Srb_id);
      if(Rrc_inst[Mod_id].Srb0[i].Srb_id == Srb_id)
	return &Rrc_inst[Mod_id].Srb0[i]; 
      if(Rrc_inst[Mod_id].Srb1[i].Srb_id == Srb_id)
	return &Rrc_inst[Mod_id].Srb1[i]; 
      if(Rrc_inst[Mod_id].Srb2[i].Srb_info.Srb_id == Srb_id)
	return &Rrc_inst[Mod_id].Srb2[i].Srb_info; 
    }
  }
  else{
    for(i=0;i<NB_CNX_UE;i++){
      //msg("i=%d, Srb0Id %d Srb2Id %d S_id=%d\n",i,Rrc_inst[Mod_id].Srb0[i].Srb_id,Rrc_inst[Mod_id].Srb2[i].Srb_info.Srb_id, Srb_id);
      if(Rrc_inst[Mod_id].Srb0[i].Srb_id == Srb_id)
	return &Rrc_inst[Mod_id].Srb0[i]; 
      if(Rrc_inst[Mod_id].Srb1[i].Srb_id == Srb_id)
	return &Rrc_inst[Mod_id].Srb1[i]; 
      if(Rrc_inst[Mod_id].Srb2[i].Srb_info.Srb_id == Srb_id)
	return &Rrc_inst[Mod_id].Srb2[i].Srb_info; 
    }
  }
  return(SRB_INFO*)0; 
}

//--------------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
133
RB_INFO* rrc_find_rb_info(uint8_t Mod_id,uint16_t Rb_id){
134
    //----------------------------------------------------------------------------------------//
gauthier's avatar
gauthier committed
135
  uint16_t i,j;
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
  if(Rrc_inst[Mod_id].Rrc_info[0].Status == CH_READY){
    for(i=0;i<NB_CNX_CH;i++)
      for(j=0;j<NB_RAB_MAX;j++){
	//  msg("j=%d, exit_id %d rb_id %d\n",j,Rrc_inst[Mod_id].Rab[j][i].Rb_info.Rb_id,Rb_id);
        if((Rrc_inst[Mod_id].Rab[j][i].Active == 1) && (Rrc_inst[Mod_id].Rab[j][i].Rb_info.Rb_id == Rb_id))
	  return &Rrc_inst[Mod_id].Rab[j][i].Rb_info; 
      }
  }
  else{
    for(i=0;i<NB_CNX_UE;i++)
      for(j=0;j<NB_RAB_MAX;j++){
	//  msg("j=%d, exit_id %d rb_id %d\n",j,Rrc_inst[Mod_id].Rab[j][i].Rb_info.Rb_id,Rb_id);
        if((Rrc_inst[Mod_id].Rab[j][i].Active == 1) && (Rrc_inst[Mod_id].Rab[j][i].Rb_info.Rb_id == Rb_id))
	  return &Rrc_inst[Mod_id].Rab[j][i].Rb_info; 
      }
  }
  return(RB_INFO*)0; 
}
*/

/*------------------------------------------------------------------------------*/
gauthier's avatar
gauthier committed
157
unsigned char rrc_is_mobile_already_associated(uint8_t Mod_id, L2_ID Mac_id){
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
  /*------------------------------------------------------------------------------*/
  /*
  unsigned char i; 
  for(i=0;i<NB_CNX_CH;i++)
    if( bcmp(Mac_id.L2_id,CH_rrc_inst[Mod_id].Info.UE_list[i].L2_id,sizeof(L2_ID))==0)
      return 1;
  return 0;
  */
}


//-------------------------------------------------------------------------------------------//
void rrc_reset_buffer(RRC_BUFFER *Rrc_buffer){
//-------------------------------------------------------------------------------------------//
//    Rrc_buffer->Header->Rv_tb_idx=0;        
  //  Rrc_buffer->W_idx=0;
  //Rrc_buffer->R_idx=0;     
}