//--------------------------------------------------------------------------- // Request the establishment of a connexion (DC channel) int nas_mesh_DC_send_cx_establish_request(struct cx_entity *cx,struct nas_priv *gpriv){ //--------------------------------------------------------------------------- struct nas_ue_dc_element *p; int bytes_wrote=0; // Start debug information #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_SEND_CX_ESTABLISH - begin \n"); #endif if (cx==NULL){ #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_SEND_CX_ESTABLISH - input parameter cx is NULL \n"); #endif return NAS_ERROR_NOTCORRECTVALUE; } // End debug information switch (cx->state){ case NAS_CX_CONNECTING: case NAS_CX_CONNECTING_FAILURE: case NAS_IDLE: p= (struct nas_ue_dc_element *)(gpriv->xbuffer); p->type = CONN_ESTABLISH_REQ; p->length = NAS_TL_SIZE + sizeof(struct NASConnEstablishReq); p->nasUEDCPrimitive.conn_establish_req.localConnectionRef = cx->lcr; p->nasUEDCPrimitive.conn_establish_req.cellId = cx->cellid; #ifdef NAS_DEBUG_DC printk ("\nCONN_ESTABLISH_REQ Buffer to Xmit: "); nas_tool_print_buffer((char *)p,p->length); #endif ++cx->retry; #ifdef NAS_NETLINK #else // bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); #endif cx->countimer=gpriv->timer_establishment; if (bytes_wrote==p->length){ cx->state=NAS_CX_CONNECTING; #ifdef NAS_DEBUG_DC printk("nas_mesh_DC_send_cx_establish_req: Message sent successfully in DC-FIFO\n"); printk(" Local Connection reference %u\n", p->nasUEDCPrimitive.conn_establish_req.localConnectionRef); printk(" Cell Identification %u\n", p->nasUEDCPrimitive.conn_establish_req.cellId); print_TOOL_state(cx->state); #endif }else{ cx->state=NAS_CX_CONNECTING_FAILURE; printk("NAS_MESH_DC_SEND_CX_ESTABLISHMENT_REQUEST: Message sent failure in DC-FIFO\n"); print_TOOL_state(cx->state); } return bytes_wrote; default: return -NAS_ERROR_NOTIDLE; #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_SEND_CX_ESTABLISH - NAS_ERROR_NOTIDLE \n"); #endif } }
//--------------------------------------------------------------------------- // Decode CONN_LOSS_IND message from RRC void nas_mesh_DC_decode_cx_loss_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) { //--------------------------------------------------------------------------- // Start debug information #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_CX_LOSS - begin \n"); #endif if (cx==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_CX_LOSS - input parameter cx is NULL \n"); #endif return; } if (p==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_CX_LOSS - input parameter p is NULL \n"); #endif return; } // End debug information cx->state=NAS_IDLE; cx->iid4=0; //nas_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); nas_COMMON_flush_rb(cx); #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_RECEIVE: CONN_LOSS_IND reception\n"); printk(" Local Connection reference %u\n", p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef); print_TOOL_state(cx->state); #endif }
//--------------------------------------------------------------------------- // Decode RB_RELEASE_IND message from RRC void nas_mesh_DC_decode_rb_release_ind(struct cx_entity *cx, struct nas_ue_dc_element *p){ //--------------------------------------------------------------------------- struct rb_entity *rb; // Start debug information #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND - begin \n"); #endif if (cx==NULL){ #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND - input parameter cx is NULL \n"); #endif return; } if (p==NULL){ #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND - input parameter p is NULL \n"); #endif return; } // End debug information rb=nas_COMMON_search_rb(cx, p->nasUEDCPrimitive.rb_release_ind.rbId); if (rb!=NULL){ rb->state=NAS_IDLE; //needs also to flush corresponding control block to be coherent with add_rb #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_RELEASE_IND: RB_RELEASE_IND reception\n"); printk("Local Connection reference %u\n",p->nasUEDCPrimitive.rb_release_ind.localConnectionRef); printk("Radio Bearer Identity %u\n",p->nasUEDCPrimitive.rb_release_ind.rbId); print_TOOL_state(cx->state); #endif }else printk("NAS_DC_RG_RECEIVE: RB_RELEASE_IND reception, No corresponding radio bearer\n"); }
//--------------------------------------------------------------------------- // Decode MEASUREMENT_IND message from RRC void nas_mesh_DC_decode_measurement_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) { //--------------------------------------------------------------------------- uint8_t i; // Start debug information #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_MEASUREMENT_IND - begin \n"); #endif if (cx==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_MEASUREMENT_IND - input parameter cx is NULL \n"); #endif return; } if (p==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_MEASUREMENT_IND - input parameter p is NULL \n"); #endif return; } // End debug information #ifdef NAS_DEBUG_DC_MEASURE printk("NAS_MESH_DC_RECEIVE: MEASUREMENT_IND reception\n"); printk(" Local Connection reference: %u\n", p->nasUEDCPrimitive.measurement_ind.localConnectionRef); printk(" Number of RGs: %u\n", p->nasUEDCPrimitive.measurement_ind.nb_rg); print_TOOL_state(cx->state); for (i=0; i<p->nasUEDCPrimitive.measurement_ind.nb_rg; ++i) { printk(" RG[%u]: Cell_Id %u, Level: %u\n", i, p->nasUEDCPrimitive.measurement_ind.measures[i].cell_id, p->nasUEDCPrimitive.measurement_ind.measures[i].level); } #endif //NAS_DEBUG_DC_MEASURE cx->num_measures = p->nasUEDCPrimitive.measurement_ind.nb_rg; for (i=0; i<cx->num_measures; i++) { cx->meas_cell_id[i]= (int)(p->nasUEDCPrimitive.measurement_ind.measures[i].cell_id); cx->meas_level[i] = (int)(p->nasUEDCPrimitive.measurement_ind.measures[i].level); //npriv->provider_id[i]=; } cx->provider_id[0]=25; cx->provider_id[1]=1; cx->provider_id[2]=25; }
//--------------------------------------------------------------------------- // Decode RB_ESTABLISH_IND message from RRC void nas_mesh_DC_decode_rb_establish_ind(struct cx_entity *cx, struct nas_ue_dc_element *p,struct nas_priv *gpriv) { //--------------------------------------------------------------------------- struct rb_entity *rb; // Start debug information #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND - begin \n"); #endif if (cx==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND - input parameter cx is NULL \n"); #endif return; } if (p==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND - input parameter p is NULL \n"); #endif return; } // End debug information rb=nas_COMMON_search_rb(cx, p->nasUEDCPrimitive.rb_release_ind.rbId); if (rb==NULL) { rb=nas_COMMON_add_rb(cx, p->nasUEDCPrimitive.rb_establish_ind.rbId, p->nasUEDCPrimitive.rb_establish_ind.QoSclass); rb->state=NAS_RB_DCH; cx->state=NAS_CX_DCH; //For demo, add automatically a classifier #ifdef DEMO_3GSM rb->countimer=gpriv->timer_establishment+10; #endif #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND: RB_ESTABLISH_IND reception\n"); printk(" Local Connection reference %u\n",p->nasUEDCPrimitive.rb_establish_ind.localConnectionRef); printk(" Radio Bearer Identity %u \n",p->nasUEDCPrimitive.rb_establish_ind.rbId); printk(" QoS Traffic Class %u\n",p->nasUEDCPrimitive.rb_establish_ind.QoSclass); printk(" DSCP Code %u\n",p->nasUEDCPrimitive.rb_establish_ind.dscp); printk(" SAP Id %u\n",p->nasUEDCPrimitive.rb_establish_ind.sapId); print_TOOL_state(cx->state); nas_print_rb_entity(rb); #endif } else printk("NAS_MESH_DC_DECODE_RB_ESTABLISH_IND: RB_ESTABLISH_IND reception, Radio bearer already opened\n"); }
//--------------------------------------------------------------------------- // Decode CONN_ESTABLISH_RESP message from RRC void nas_mesh_DC_decode_cx_establish_resp(struct cx_entity *cx, struct nas_ue_dc_element *p,struct nas_priv *gpriv) { //--------------------------------------------------------------------------- uint8_t sig_category; // Start debug information #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - begin \n"); #endif if (cx==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - input parameter cx is NULL \n"); #endif return; } if (p==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - input parameter p is NULL \n"); #endif return; } // End debug information cx->retry=0; if (p->nasUEDCPrimitive.conn_establish_resp.status == TERMINATED) { cx->state=NAS_CX_DCH; //to be changed to NAS_CX_FACH cx->iid4=1; //nas_TOOL_imei2iid(NAS_RG_IMEI, (uint8_t *)cx->iid6); sig_category = NAS_CMD_OPEN_RB; //For demo, add automatically a radio bearer #ifdef DEMO_3GSM printk("NAS_MESH_DC_DECODE_CX_ESTABLISH - sig_category %u \n", sig_category); nas_mesh_DC_send_peer_sig_data_request(cx, sig_category,gpriv); #endif } else { cx->state=NAS_IDLE; } #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_RECEIVE: CONN_ESTABLISH_RESP\n"); printk("Local Connection reference %u\n",p->nasUEDCPrimitive.conn_establish_resp.localConnectionRef); printk("Connection Establishment status %u\n",p->nasUEDCPrimitive.conn_establish_resp.status); print_TOOL_state(cx->state); #endif }
//--------------------------------------------------------------------------- // Request the release of a connexion (DC channel) int nas_mesh_DC_send_cx_release_request(struct cx_entity *cx, struct nas_priv *gpriv) { //--------------------------------------------------------------------------- struct nas_ue_dc_element *p; int bytes_wrote=0; // Start debug information #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_SEND_CX_RELEASE - begin \n"); #endif if (cx==NULL) { #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_SEND_CX_RELEASE - input parameter cx is NULL \n"); #endif return NAS_ERROR_NOTCORRECTVALUE; } // End debug information switch (cx->state) { case NAS_CX_RELEASING_FAILURE: case NAS_CX_DCH: p= (struct nas_ue_dc_element *)(gpriv->xbuffer); p->type = CONN_RELEASE_REQ; p->length = NAS_TL_SIZE + sizeof(struct NASConnReleaseReq); p->nasUEDCPrimitive.conn_release_req.localConnectionRef = cx->lcr; p->nasUEDCPrimitive.conn_release_req.releaseCause = NAS_CX_RELEASE_UNDEF_CAUSE; #ifdef PDCP_USE_NETLINK #else // bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); #endif if (bytes_wrote==p->length) { cx->state=NAS_IDLE; cx->iid4=0; // nas_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); nas_COMMON_flush_rb(cx); #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_SEND_CX_RELEASE_REQUEST: Message sent successfully in DC-FIFO\n"); printk(" Local Connection Reference %u\n", p->nasUEDCPrimitive.conn_release_req.localConnectionRef); printk(" Release Cause %u\n", p->nasUEDCPrimitive.conn_release_req.releaseCause); print_TOOL_state(cx->state); #endif } else { ++cx->retry; cx->countimer=gpriv->timer_release; cx->state=NAS_CX_RELEASING_FAILURE; printk("NAS_MESH_DC_SEND_CX_RELEASE_REQUEST: Message sent failure in DC-FIFO\n"); print_TOOL_state(cx->state); } return bytes_wrote; default: return -NAS_ERROR_NOTCONNECTED; #ifdef NAS_DEBUG_DC printk("NAS_MESH_DC_SEND_CX_RELEASE_REQUEST - NAS_ERROR_NOTCONNECTED \n"); #endif } }