/*! ******************************************************************************* \brief La fonction ajoute un voisin dans la liste des voisins du Cluster head. \return retourne la valeur du nouvel element */ neighbor_desc_t *add_neighbor( neighbor_desc_t **neighbor_entry, ///< pointeur sur l'entree de la liste de voisinage L2_ID *L2_id ///< ID du nouveau noeud ) { neighbor_desc_t *pNewItem = get_neighbor( *neighbor_entry, L2_id ); if ( pNewItem == NULL ) { // If not Exist then create a new item neighbor_desc_t *pOldEntry = *neighbor_entry; pNewItem = RRM_MALLOC(neighbor_desc_t , 1 ) ; PNULL(pNewItem) ; if ( pNewItem == NULL ) return NULL ; memcpy( pNewItem->L2_id.L2_id , L2_id->L2_id, sizeof(L2_ID) ) ; //pNewItem->RSSI = 0 ; pNewItem->NB_neighbor = 0 ; pNewItem->Sensing_meas= NULL; *neighbor_entry = pNewItem ; pNewItem->next = pOldEntry; } PRINT_NEIGHBOR_DB( *neighbor_entry ); return pNewItem ; }
/*! ******************************************************************************* \brief La fonction ajoute un couple de voisin a la liste de type neighbor_list_t \return le nouvel element de liste */ static neighbor_list_t *add_item_neighbor_list( neighbor_list_t **neighbor_list_entry , ///< pointeur sur l'entree de la liste des couples de voisins L2_ID *L2_id1 , ///< ID du noeud 1 L2_ID *L2_id2 ///< ID du noeud 2 ) { neighbor_list_t *pOldEntry = *neighbor_list_entry; neighbor_list_t *pNewItem = RRM_MALLOC(neighbor_list_t, 1 ) ; PNULL(pNewItem) ; if ( pNewItem == NULL ) return NULL ; memcpy( &(pNewItem->L2_id[0]) , L2_id1, sizeof(L2_ID) ) ; memcpy( &(pNewItem->L2_id[1]) , L2_id2, sizeof(L2_ID) ) ; pNewItem->Rssi[0] = 0xFF ; pNewItem->Rssi[1] = 0xFF ; pNewItem->nb_opened_rb = 0 ; pNewItem->rb_meas = NULL; *neighbor_list_entry = pNewItem ; pNewItem->next = pOldEntry; return pNewItem ; }
/*! ******************************************************************************* \brief La fonction ajoute un rb dans la liste des RB ouverts du Cluster head. \return retourne la valeur du nouvel element */ RB_desc_t *add_rb( RB_desc_t **rb_entry , ///< pointeur sur l'entree de la liste des RB Transaction_t Trans_id , ///< transaction associee QOS_CLASS_T QoS_class , ///< index de la classe de QoS L2_ID *L2_id ///< ID de niveau 2 des noeuds associes au RB ) { RB_desc_t *pOldEntry = *rb_entry; RB_desc_t *pNewItem = RRM_CALLOC( RB_desc_t , 1 ) ; PNULL(pNewItem) ; if ( pNewItem == NULL ) return NULL ; pNewItem->QoS_class = QoS_class ; memcpy( &(pNewItem->L2_id[0]) , L2_id, 2*sizeof(L2_ID) ) ; pNewItem->Trans_id = Trans_id ; pNewItem->Rb_id = 0 ; pNewItem->RB_type = 0; *rb_entry = pNewItem ; pNewItem->next = pOldEntry; PRINT_RB_DB( *rb_entry ); return pNewItem ; }