Commit c6aefa31 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

minor update to fix issues related to PC5-S

parent 9c00f4b7
......@@ -1373,14 +1373,13 @@ rrc_mac_config_req_ue(
//for D2D
#if defined(Rel10) || defined(Rel14)
if ( sourceL2Id && groupL2Id) {
if (sourceL2Id){
UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id;
}
if (groupL2Id) {
UE_mac_inst[Mod_idP].groupL2Id = *groupL2Id;
} else if (sourceL2Id) { //reset groupL2Id
UE_mac_inst[Mod_idP].groupL2Id = 0x00000000;
}
if ( sourceL2Id && destinationL2Id) {
UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id;
if (destinationL2Id) {
UE_mac_inst[Mod_idP].destinationL2Id = *destinationL2Id;
}
......
......@@ -765,7 +765,7 @@ void ue_send_sl_sdu(module_id_t module_idP,
AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID);
//filter incoming packet based on destination address
destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623);
LOG_I( MAC, "[DestinationL2Id: %"PRIu32"] \n", destinationL2Id );
LOG_I( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id );
//match the destinationL2Id with UE L2Id or groupL2ID
if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (destinationL2Id == UE_mac_inst[module_idP].groupL2Id))){
LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
......
......@@ -407,7 +407,8 @@ struct pdcp_netlink_element_s {
#ifdef Rel14
#define PDCP_SOCKET_PORT_NO 9999 //temporary value
int pdcp_pc5_sockfd;
struct sockaddr_in prose_app_addr;
struct sockaddr_in prose_ctrl_addr;
struct sockaddr_in prose_pdcp_addr;
struct sockaddr_in pdcp_sin;
int pdcp_pc5_socket_init();
......
......@@ -218,25 +218,25 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP)
sl_pc5s_msg_recv = calloc(1, sizeof(sidelink_pc5s_element));
memcpy((void*)sl_pc5s_msg_recv, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element));
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header msg_type: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.msg_type);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header rb_id: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.rb_id);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header data_size: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.data_size);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header inst: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.inst);
LOG_D(PDCP,"Received PC5S message, header msg_type: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.msg_type);
LOG_D(PDCP,"Received PC5S message, header rb_id: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.rb_id);
LOG_D(PDCP,"Received PC5S message, header data_size: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.data_size);
LOG_D(PDCP,"Received PC5S message, header inst: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.inst);
if (sl_pc5s_msg_recv->pdcp_data_header.msg_type == SL_DIRECT_COMMUNICATION_REQUEST){
LOG_D(PDCP,"[pdcp_pc5_socket_thread_fct]: Received DirectCommunicationRequest (PC5-S), seqno: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.sequenceNumber);
LOG_D(PDCP,"[pdcp_pc5_socket_thread_fct]: Received DirectCommunicationRequest (PC5-S), ipAddressConfig: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.ipAddressConfig);
LOG_D(PDCP,"PC5S message (SL_DIRECT_COMMUNICATION_REQUEST), seqno: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.sequenceNumber);
LOG_D(PDCP,"PC5S message (SL_DIRECT_COMMUNICATION_REQUEST), ipAddressConfig: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.ipAddressConfig);
}
//send to ProSe app
LOG_D(RRC,"[pdcp_fifo_flush_sdus]: Send DirectCommunicationRequest to ProSe App \n");
LOG_D(PDCP,"Send DirectCommunicationRequest to ProSe App \n");
#endif
memset(send_buf, 0, BUFSIZE);
//memcpy((void *)send_buf, (void *)sl_pc5s_msg_recv, sizeof(sidelink_pc5s_element));
memcpy((void *)send_buf, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element));
//free(sl_ctrl_msg_send);
int prose_addr_len = sizeof(prose_app_addr);
int n = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
int prose_addr_len = sizeof(prose_pdcp_addr);
int n = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len);
if (n < 0) {
LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
......@@ -570,11 +570,11 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
//TTN for D2D (PC5S)
#ifdef Rel14
// module_id = 0 ; //hardcoded for testing only
prose_addr_len = sizeof(prose_app_addr);
prose_addr_len = sizeof(prose_pdcp_addr);
// receive a message from ProSe App
memset(receive_buf, 0, BUFSIZE);
bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0,
(struct sockaddr *) &prose_app_addr, &prose_addr_len);
(struct sockaddr *) &prose_pdcp_addr, &prose_addr_len);
// if (bytes_received < 0){
// LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n");
// exit(EXIT_FAILURE);
......@@ -592,8 +592,8 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
sl_pc5s_msg_send->pc5sPrimitive.status = 1;
memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element));
int prose_addr_len = sizeof(prose_app_addr);
int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
int prose_addr_len = sizeof(prose_pdcp_addr);
int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len);
if (bytes_sent < 0) {
LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
......@@ -1306,14 +1306,14 @@ void *pdcp_pc5_socket_thread_fct(void *arg)
LOG_I(PDCP,"*****************[pdcp_pc5_socket_thread_fct]**************\n");
//from the main program, listen for the incoming messages from control socket (ProSe App)
prose_addr_len = sizeof(prose_app_addr);
prose_addr_len = sizeof(prose_pdcp_addr);
while (1) {
LOG_I(RRC,"[pdcp_pc5_socket_thread_fct]: Listening to incoming connection from ProSe App \n");
// receive a message from ProSe App
memset(receive_buf, 0, BUFSIZE);
n = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0,
(struct sockaddr *) &prose_app_addr, &prose_addr_len);
(struct sockaddr *) &prose_pdcp_addr, &prose_addr_len);
if (n < 0){
LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n");
exit(EXIT_FAILURE);
......
......@@ -120,6 +120,7 @@ struct DirectCommunicationEstablishReq {
};
struct PC5SEstablishReq{
uint8_t type;
uint32_t sourceL2Id;
uint32_t destinationL2Id;
};
......
......@@ -5440,6 +5440,7 @@ void *rrc_control_socket_thread_fct(void *arg)
struct sidelink_ctrl_element *sl_ctrl_msg_send = NULL;
uint32_t sourceL2Id, groupL2Id, destinationL2Id;
module_id_t module_id = 0; //hardcoded for testing only
uint8_t type;
//from the main program, listen for the incoming messages from control socket (ProSe App)
prose_addr_len = sizeof(prose_app_addr);
......@@ -5509,8 +5510,8 @@ void *rrc_control_socket_thread_fct(void *arg)
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[GroupCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[GroupCommunicationEstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.type);
LOG_I(RRC,"[GroupCommunicationEstablishReq] source Id: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id);
LOG_I(RRC,"[GroupCommunicationEstablishReq] group Id: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id);
LOG_I(RRC,"[GroupCommunicationEstablishReq] source Id: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id);
LOG_I(RRC,"[GroupCommunicationEstablishReq] group Id: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id);
LOG_I(RRC,"[GroupCommunicationEstablishReq] group IP Address: " IPV4_ADDR "\n",IPV4_ADDR_FORMAT(sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupIpAddress));
#endif
......@@ -5566,9 +5567,7 @@ void *rrc_control_socket_thread_fct(void *arg)
sl_ctrl_msg_send->type = GROUP_COMMUNICATION_ESTABLISH_RSP;
//in case of TX, assign a new SLRB and prepare for the filter
if (sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.type == 1) {
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[GroupCommunicationEstablishReq] PPPP: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.pppp);
#endif
sl_ctrl_msg_send->sidelinkPrimitive.slrb_id = SLRB_ID; //slrb_id
//pthread_mutex_lock(&slrb_mutex);
slrb_id = SLRB_ID;
......@@ -5672,16 +5671,25 @@ void *rrc_control_socket_thread_fct(void *arg)
case PC5S_ESTABLISH_REQ:
type = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type;
sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id;
destinationL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.destinationL2Id;
#ifdef DEBUG_CTRL_SOCKET
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[PC5EstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[PC5EstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type); //RX/TX
LOG_I(RRC,"[PC5EstablishReq] source Id: 0x%08x \n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id);
#endif
if (type > 0) {
destinationL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.destinationL2Id;
#ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[PC5EstablishReq] destination Id: 0x%08x \n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.destinationL2Id);
#endif
}
//store sourceL2Id, destinationL2Id
if (type > 0) { //TX
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
UE_rrc_inst[module_id].destinationL2Id = destinationL2Id;
// configure lower layers PDCP/MAC/PHY
rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0
(RadioResourceConfigCommonSIB_t *)NULL,
......@@ -5717,11 +5725,55 @@ void *rrc_control_socket_thread_fct(void *arg)
#if defined(Rel10) || defined(Rel14)
,
&sourceL2Id,
&destinationL2Id,
NULL,
&destinationL2Id
#endif
);
} else {//RX
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
// configure lower layers PDCP/MAC/PHY
rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0
(RadioResourceConfigCommonSIB_t *)NULL,
(struct PhysicalConfigDedicated *)NULL,
#if defined(Rel10) || defined(Rel14)
(SCellToAddMod_r10_t *)NULL,
//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
#endif
(MeasObjectToAddMod_t **)NULL,
(MAC_MainConfig_t *)NULL,
0,
(struct LogicalChannelConfig *)NULL,
(MeasGapConfig_t *)NULL,
(TDD_Config_t *)NULL,
(MobilityControlInfo_t *)NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
#if defined(Rel10) || defined(Rel14)
,0,
(MBSFN_AreaInfoList_r9_t *)NULL,
(PMCH_InfoList_r9_t *)NULL
#endif
#ifdef CBA
,
0,
0
#endif
#if defined(Rel10) || defined(Rel14)
,
&sourceL2Id,
NULL,
NULL
#endif
);
}
LOG_I(RRC,"Send PC5EstablishRsp to ProSe App\n");
memset(send_buf, 0, BUFSIZE);
sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element));
......@@ -5733,7 +5785,7 @@ void *rrc_control_socket_thread_fct(void *arg)
prose_addr_len = sizeof(prose_app_addr);
n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
free(sl_ctrl_msg_send);
// free(sl_ctrl_msg_send);
if (n < 0){
LOG_E(RRC, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment