bool tcp_stream_create(struct tcp_stream *stream) { memset(stream, 0, sizeof(struct tcp_stream)); if (!vbuffer_stream_init(&stream->stream, NULL)) { return false; } stream->lua_object = lua_object_init; list2_init(&stream->current); list2_init(&stream->queued); list2_init(&stream->sent); stream->start_seq = (uint32)-1; return true; }
//----------------------------------------------------------------------------- void rlc_am_init( const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *const rlc_pP) //----------------------------------------------------------------------------- { if (rlc_pP->initialized == TRUE) { LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] INITIALIZATION ALREADY DONE, DOING NOTHING\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); } else { LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] INITIALIZATION: STATE VARIABLES, BUFFERS, LISTS\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); memset(rlc_pP, 0, sizeof(rlc_am_entity_t)); list2_init(&rlc_pP->receiver_buffer, "RX BUFFER"); list_init(&rlc_pP->pdus_to_mac_layer, "PDUS TO MAC"); list_init(&rlc_pP->control_pdu_list, "CONTROL PDU LIST"); list_init(&rlc_pP->segmentation_pdu_list, "SEGMENTATION PDU LIST"); //LOG_D(RLC,"RLC_AM_SDU_CONTROL_BUFFER_SIZE %d sizeof(rlc_am_tx_sdu_management_t) %d \n", RLC_AM_SDU_CONTROL_BUFFER_SIZE, sizeof(rlc_am_tx_sdu_management_t)); pthread_mutex_init(&rlc_pP->lock_input_sdus, NULL); rlc_pP->input_sdus = calloc(1, RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t)); #warning "cast the rlc retrans buffer to uint32" // rlc_pP->pdu_retrans_buffer = calloc(1, (uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); rlc_pP->pdu_retrans_buffer = calloc(1, (uint32_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof( rlc_am_tx_data_pdu_management_t))); LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] input_sdus[] = %p element size=%d\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->input_sdus, sizeof(rlc_am_tx_sdu_management_t)); LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] pdu_retrans_buffer[] = %p element size=%d\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->pdu_retrans_buffer, sizeof(rlc_am_tx_data_pdu_management_t)); // TX state variables //rlc_pP->vt_a = 0; rlc_pP->vt_ms = rlc_pP->vt_a + RLC_AM_WINDOW_SIZE; //rlc_pP->vt_s = 0; //rlc_pP->poll_sn = 0; // TX counters //rlc_pP->c_pdu_without_poll = 0; //rlc_pP->c_byte_without_poll = 0; // RX state variables //rlc_pP->vr_r = 0; rlc_pP->vr_mr = rlc_pP->vr_r + RLC_AM_WINDOW_SIZE; //rlc_pP->vr_x = 0; //rlc_pP->vr_ms = 0; //rlc_pP->vr_h = 0; rlc_pP->last_frame_status_indication = 123456; // any value > 1 rlc_pP->first_retrans_pdu_sn = -1; rlc_pP->initialized = TRUE; } }
int list2_clean(struct list2 * listContext) { int err; err = list2_firstElement(listContext); while (!err) { err = list2_removeCurrentElement(listContext); }; if (err != E_NO_MORE_ELEMENTS) { return err; }; err = list2_init(listContext); return err; };