Merge remote-tracking branch 'origin/cleanup-20220125' into integration_2022_wk08
This commit is contained in:
@@ -19,18 +19,12 @@
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
MESSAGE_DEF(GTPV1U_ENB_UPDATE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_update_tunnel_req_t, Gtpv1uUpdateTunnelReq)
|
||||
MESSAGE_DEF(GTPV1U_ENB_UPDATE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_enb_update_tunnel_resp_t, Gtpv1uUpdateTunnelResp)
|
||||
MESSAGE_DEF(GTPV1U_ENB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_delete_tunnel_req_t, Gtpv1uDeleteTunnelReq)
|
||||
MESSAGE_DEF(GTPV1U_ENB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_enb_delete_tunnel_resp_t, Gtpv1uDeleteTunnelResp)
|
||||
MESSAGE_DEF(GTPV1U_ENB_TUNNEL_DATA_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_tunnel_data_ind_t, Gtpv1uTunnelDataInd)
|
||||
|
||||
MESSAGE_DEF(GTPV1U_ENB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_tunnel_data_req_t, Gtpv1uTunnelDataReq)
|
||||
MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_data_forwarding_req_t,Gtpv1uDataForwardingReq)
|
||||
MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_data_forwarding_ind_t,Gtpv1uDataForwardingInd)
|
||||
MESSAGE_DEF(GTPV1U_ENB_END_MARKER_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_req_t, Gtpv1uEndMarkerReq)
|
||||
MESSAGE_DEF(GTPV1U_ENB_END_MARKER_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_ind_t, Gtpv1uEndMarkerInd)
|
||||
MESSAGE_DEF(GTPV1U_REQ, MESSAGE_PRIORITY_MED, Gtpv1uReq, gtpv1uReq)
|
||||
MESSAGE_DEF(GTPV1U_REQ, MESSAGE_PRIORITY_MED, Gtpv1uReq, gtpv1uReq)
|
||||
|
||||
MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_req_t, NRGtpv1uDeleteTunnelReq)
|
||||
MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_resp_t, NRGtpv1uDeleteTunnelResp)
|
||||
MESSAGE_DEF(GTPV1U_GNB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_tunnel_data_req_t, NRGtpv1uTunnelDataReq)
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
#define GTPV1U_MAX_BEARERS_PER_UE max_val_LTE_DRB_Identity
|
||||
#define NR_GTPV1U_MAX_BEARERS_PER_UE max_val_NR_DRB_Identity
|
||||
|
||||
#define GTPV1U_ENB_UPDATE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uUpdateTunnelReq
|
||||
#define GTPV1U_ENB_UPDATE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uUpdateTunnelResp
|
||||
#define GTPV1U_ENB_DELETE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uDeleteTunnelReq
|
||||
#define GTPV1U_ENB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uDeleteTunnelResp
|
||||
#define GTPV1U_ENB_TUNNEL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uTunnelDataInd
|
||||
#define GTPV1U_ENB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uTunnelDataReq
|
||||
#define GTPV1U_ENB_DATA_FORWARDING_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uDataForwardingReq
|
||||
@@ -41,8 +37,6 @@
|
||||
|
||||
#define GTPV1U_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uReq
|
||||
|
||||
#define GTPV1U_GNB_DELETE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelReq
|
||||
#define GTPV1U_GNB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelResp
|
||||
#define GTPV1U_GNB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uTunnelDataReq
|
||||
|
||||
#define GTPV1U_ALL_TUNNELS_TEID (teid_t)0xFFFFFFFF
|
||||
@@ -200,7 +194,6 @@ typedef struct gtpv1u_gnb_create_tunnel_resp_s {
|
||||
pdusessionid_t pdusession_id[NR_GTPV1U_MAX_BEARERS_PER_UE];
|
||||
transport_layer_addr_t gnb_addr;
|
||||
} gtpv1u_gnb_create_tunnel_resp_t;
|
||||
|
||||
typedef struct gtpv1u_gnb_delete_tunnel_req_s {
|
||||
rnti_t rnti;
|
||||
uint8_t num_pdusession;
|
||||
@@ -212,7 +205,6 @@ typedef struct gtpv1u_gnb_delete_tunnel_resp_s {
|
||||
uint8_t status; ///< Status of NGU endpoint deleteion (Failed = 0xFF or Success = 0x0)
|
||||
teid_t gnb_NGu_teid; ///< local NGU Tunnel Endpoint Identifier to be deleted
|
||||
} gtpv1u_gnb_delete_tunnel_resp_t;
|
||||
|
||||
typedef struct gtpv1u_gnb_tunnel_data_req_s {
|
||||
uint8_t *buffer;
|
||||
uint32_t length;
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include "common/config/config_userapi.h"
|
||||
#include "RRC_config_tools.h"
|
||||
#include "enb_paramdef.h"
|
||||
#include "proto_agent.h"
|
||||
#include "executables/thread-common.h"
|
||||
#include <openair3/ocp-gtpu/gtp_itf.h>
|
||||
|
||||
@@ -2080,7 +2079,7 @@ int RCconfig_gtpu(void ) {
|
||||
GTPV1U_REQ(message).localPort = enb_port_for_S1U;
|
||||
strcpy(GTPV1U_REQ(message).localAddrStr,address);
|
||||
sprintf(GTPV1U_REQ(message).localPortStr,"%d", enb_port_for_S1U);
|
||||
itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
|
||||
itti_send_msg_to_task (TASK_GTPV1_U, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
|
||||
} else
|
||||
LOG_E(GTPU,"invalid address for S1U\n");
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "f1ap_cu_rrc_message_transfer.h"
|
||||
#include "f1ap_cu_ue_context_management.h"
|
||||
#include "f1ap_cu_task.h"
|
||||
#include "proto_agent.h"
|
||||
#include <openair3/ocp-gtpu/gtp_itf.h>
|
||||
|
||||
//Fixme: Uniq dirty DU instance, by global var, datamodel need better management
|
||||
@@ -47,7 +46,7 @@ static instance_t cu_task_create_gtpu_instance_to_du(eth_params_t *IPaddrs) {
|
||||
strncpy(tmp.destinationHost, IPaddrs->remote_addr, sizeof(tmp.destinationHost)-1);
|
||||
sprintf(tmp.originService, "%d", IPaddrs->my_portd);
|
||||
sprintf(tmp.destinationService, "%d", IPaddrs->remote_portd);
|
||||
return ocp_gtpv1Init(tmp);
|
||||
return gtpv1Init(tmp);
|
||||
}
|
||||
|
||||
static void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_association_ind_t *sctp_new_association_ind,
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "f1ap_du_ue_context_management.h"
|
||||
#include "f1ap_du_rrc_message_transfer.h"
|
||||
#include "f1ap_du_task.h"
|
||||
#include "proto_agent.h"
|
||||
#include <openair3/ocp-gtpu/gtp_itf.h>
|
||||
|
||||
//Fixme: Uniq dirty DU instance, by global var, datamodel need better management
|
||||
@@ -103,7 +102,7 @@ static instance_t du_create_gtpu_instance_to_cu(char *CUaddr, uint16_t CUport, c
|
||||
strncpy(tmp.destinationHost, CUaddr, sizeof(tmp.destinationHost)-1);
|
||||
sprintf(tmp.originService, "%d", DUport);
|
||||
sprintf(tmp.destinationService, "%d", CUport);
|
||||
return ocp_gtpv1Init(tmp);
|
||||
return gtpv1Init(tmp);
|
||||
}
|
||||
|
||||
void *F1AP_DU_task(void *arg) {
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <stdio.h>
|
||||
#include <nr_pdcp/nr_pdcp.h>
|
||||
#include <softmodem-common.h>
|
||||
#include <nr-softmodem.h>
|
||||
#include <split_headers.h>
|
||||
#include <proto_agent.h>
|
||||
|
||||
#include "gnb_app.h"
|
||||
#include "gnb_config.h"
|
||||
@@ -135,34 +135,6 @@ static uint32_t gNB_app_register_x2(uint32_t gnb_id_start, uint32_t gnb_id_end)
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
static void init_pdcp(void) {
|
||||
if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) {
|
||||
pdcp_layer_init();
|
||||
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
|
||||
(PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
|
||||
if (IS_SOFTMODEM_NOS1) {
|
||||
LOG_I(PDCP, "IS_SOFTMODEM_NOS1 option enabled\n");
|
||||
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT;
|
||||
}
|
||||
|
||||
nr_pdcp_module_init(pdcp_initmask, 0);
|
||||
|
||||
if (NODE_IS_CU(RC.nrrrc[0]->node_type)) {
|
||||
LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n");
|
||||
pdcp_set_rlc_data_req_func(proto_agent_send_rlc_data_req);
|
||||
} else {
|
||||
LOG_I(PDCP, "node is gNB \n");
|
||||
pdcp_set_rlc_data_req_func(rlc_data_req);
|
||||
pdcp_set_pdcp_data_ind_func(pdcp_data_ind);
|
||||
}
|
||||
} else {
|
||||
LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n");
|
||||
pdcp_set_pdcp_data_ind_func(proto_agent_send_pdcp_data_ind);
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
void *gNB_app_task(void *args_p)
|
||||
{
|
||||
|
||||
|
||||
@@ -1227,7 +1227,7 @@ int RCconfig_nr_gtpu(void ) {
|
||||
GTPV1U_REQ(message).localPort = port;
|
||||
strcpy(GTPV1U_REQ(message).localAddrStr,address);
|
||||
sprintf(GTPV1U_REQ(message).localPortStr,"%d", port);
|
||||
itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
|
||||
itti_send_msg_to_task (TASK_GTPV1_U, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
|
||||
} else
|
||||
LOG_E(GTPU,"invalid address for NGU or S1U\n");
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
#include <pthread.h>
|
||||
|
||||
# include "gtpv1u_eNB_task.h"
|
||||
# include "gtpv1u.h"
|
||||
#include <openair3/ocp-gtpu/gtp_itf.h>
|
||||
|
||||
#include "ENB_APP/enb_config.h"
|
||||
@@ -229,7 +228,7 @@ rlc_op_status_t cu_send_to_du(const protocol_ctxt_t *const ctxt,
|
||||
LOG_D(PDCP, "%s() (drb %ld) sending message to gtp size %d\n",
|
||||
__func__, rb_id, size);
|
||||
extern instance_t CUuniqInstance;
|
||||
itti_send_msg_to_task(TASK_VARIABLE, CUuniqInstance, message_p);
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, CUuniqInstance, message_p);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1078,7 +1077,7 @@ pdcp_data_ind(
|
||||
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
|
||||
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti;
|
||||
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
|
||||
itti_send_msg_to_task(TASK_VARIABLE, INSTANCE_DEFAULT, message_p);
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
|
||||
packet_forwarded = TRUE;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -85,8 +85,6 @@ extern struct msghdr nas_msg_rx;
|
||||
|
||||
|
||||
# include "gtpv1u_eNB_task.h"
|
||||
# include "gtpv1u_eNB_defs.h"
|
||||
|
||||
|
||||
extern int gtpv1u_new_data_req( uint8_t enb_module_idP, rnti_t ue_rntiP, uint8_t rab_idP, uint8_t *buffer_pP, uint32_t buf_lenP, uint32_t buf_offsetP);
|
||||
uint16_t ue_id_g; // Global variable to identify the ID for each UE. It is updated in main() of lte-uesoftmodem.c
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "ENB_APP/enb_paramdef.h"
|
||||
#include "LAYER2/PROTO_AGENT/proto_agent.h"
|
||||
#define BUF_MAX 1400
|
||||
|
||||
int recv_client = 0;
|
||||
FILE *output;
|
||||
|
||||
void usage(char *prg_name) {
|
||||
fprintf(stderr, "usage: %s <file or ->\n", prg_name);
|
||||
fprintf(stderr, " - is stdin\n");
|
||||
fprintf(stderr, " received packets are written to stdout\n");
|
||||
}
|
||||
|
||||
long uelapsed(struct timeval *s, struct timeval *e) {
|
||||
return e->tv_sec * 1000000 + e->tv_usec - (s->tv_sec * 1000000 + s->tv_usec);
|
||||
}
|
||||
|
||||
boolean_t
|
||||
pdcp_data_ind(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP,
|
||||
const MBMS_flag_t MBMS_flagP,
|
||||
const rb_id_t rb_idP,
|
||||
const sdu_size_t sdu_buffer_sizeP,
|
||||
mem_block_t *const sdu_buffer_pP
|
||||
) {
|
||||
fwrite(sdu_buffer_pP->data, sdu_buffer_sizeP, 1, stdout);
|
||||
fflush(stdout);
|
||||
free_mem_block(sdu_buffer_pP, __func__);
|
||||
/* cannot free because of const */
|
||||
//free(ctxt_pP);
|
||||
recv_client = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void close_proto_agent(void) {
|
||||
proto_agent_stop(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
const cudu_params_t params = {
|
||||
.local_ipv4_address = "192.168.12.45",
|
||||
.local_port = 6464,
|
||||
.remote_ipv4_address = "192.168.12.45",
|
||||
.remote_port = 6465
|
||||
};
|
||||
protocol_ctxt_t p;
|
||||
memset(&p, 0, sizeof p);
|
||||
mem_block_t mem;
|
||||
char s[BUF_MAX];
|
||||
size_t size, totsize = 0;
|
||||
struct timeval t_start, t_end;
|
||||
FILE *f;
|
||||
|
||||
if (argc != 2) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-") == 0) {
|
||||
f = stdin;
|
||||
} else {
|
||||
f = fopen(argv[1], "r");
|
||||
}
|
||||
|
||||
if (!f) {
|
||||
fprintf(stderr, "cannot open %s: %s\n", argv[1], strerror(errno));
|
||||
return 2;
|
||||
}
|
||||
|
||||
pool_buffer_init();
|
||||
|
||||
if (proto_agent_start(0, ¶ms) != 0) {
|
||||
fprintf(stderr, "error on proto_agent_start()\n");
|
||||
fclose(f);
|
||||
return 3;
|
||||
}
|
||||
|
||||
atexit(close_proto_agent);
|
||||
|
||||
/* wait for first packet of client */
|
||||
while (!recv_client) sleep(1);
|
||||
|
||||
fprintf(stderr, "reading file\n");
|
||||
/* now send back at the same time */
|
||||
gettimeofday(&t_start, NULL);
|
||||
|
||||
while ((size = fread(s, 1, BUF_MAX, f)) > 0) {
|
||||
usleep(10);
|
||||
totsize += size;
|
||||
mem.data = &s[0];
|
||||
proto_agent_send_rlc_data_req(&p, 0, 0, 0, 0, 0, size, &mem);
|
||||
}
|
||||
|
||||
gettimeofday(&t_end, NULL);
|
||||
fclose(f);
|
||||
long us = uelapsed(&t_start, &t_end);
|
||||
fprintf(stderr, "read %zu bytes in %ld ms -> %.3fMB/s, %.3fMbps\n",
|
||||
totsize, us / 1000, ((float) totsize ) / us,
|
||||
((float) totsize) / us * 8);
|
||||
fprintf(stderr, "check files using 'diff afile bfile'\n");
|
||||
/* give some time in case the other direction is slower */
|
||||
sleep(5);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************
|
||||
* arbitrary functions, needed for linking (used or not) *
|
||||
*********************************************************
|
||||
*/
|
||||
|
||||
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP,
|
||||
const MBMS_flag_t MBMS_flagP,
|
||||
const rb_id_t rb_idP,
|
||||
const mui_t muiP,
|
||||
confirm_t confirmP,
|
||||
sdu_size_t sdu_sizeP,
|
||||
mem_block_t *sdu_pP,
|
||||
const uint32_t *const sourceL2Id,
|
||||
const uint32_t *const destinationL2Id
|
||||
) {
|
||||
fprintf(stderr, "This should never be called on the CU\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pthread_t new_thread(void *(*f)(void *), void *b) {
|
||||
pthread_t t;
|
||||
pthread_attr_t att;
|
||||
|
||||
if (pthread_attr_init(&att)) {
|
||||
fprintf(stderr, "pthread_attr_init err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
|
||||
fprintf(stderr, "pthread_attr_setdetachstate err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_create(&t, &att, f, b)) {
|
||||
fprintf(stderr, "pthread_create err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_attr_destroy(&att)) {
|
||||
fprintf(stderr, "pthread_attr_destroy err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_get(paramdef_t *params,int numparams, char *prefix) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "ENB_APP/enb_paramdef.h"
|
||||
#include "LAYER2/PROTO_AGENT/proto_agent.h"
|
||||
|
||||
#define BUF_MAX 1400
|
||||
|
||||
void usage(char *prg_name) {
|
||||
fprintf(stderr, "usage: %s <file or ->\n", prg_name);
|
||||
fprintf(stderr, " - is stdin\n");
|
||||
fprintf(stderr, " received packets are written to stdout\n");
|
||||
}
|
||||
|
||||
long uelapsed(struct timeval *s, struct timeval *e) {
|
||||
return e->tv_sec * 1000000 + e->tv_usec - (s->tv_sec * 1000000 + s->tv_usec);
|
||||
}
|
||||
|
||||
|
||||
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP,
|
||||
const MBMS_flag_t MBMS_flagP,
|
||||
const rb_id_t rb_idP,
|
||||
const mui_t muiP,
|
||||
confirm_t confirmP,
|
||||
sdu_size_t sdu_sizeP,
|
||||
mem_block_t *sdu_pP,
|
||||
const uint32_t *const sourceL2Id,
|
||||
const uint32_t *const destinationL2Id
|
||||
) {
|
||||
fwrite(sdu_pP->data, sdu_sizeP, 1, stdout);
|
||||
fflush(stdout);
|
||||
free_mem_block(sdu_pP, __func__);
|
||||
//free(ctxt_pP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void close_proto_agent(void) {
|
||||
proto_agent_stop(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
const cudu_params_t params = {
|
||||
.local_ipv4_address = "192.168.12.45",
|
||||
.local_port = 6465,
|
||||
.remote_ipv4_address = "192.168.12.45",
|
||||
.remote_port = 6464
|
||||
};
|
||||
protocol_ctxt_t p;
|
||||
memset(&p, 0, sizeof p);
|
||||
mem_block_t mem;
|
||||
char s[BUF_MAX];
|
||||
size_t size, totsize = 0;
|
||||
struct timeval t_start, t_end;
|
||||
FILE *f;
|
||||
|
||||
if (argc != 2) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-") == 0) {
|
||||
f = stdin;
|
||||
} else {
|
||||
f = fopen(argv[1], "r");
|
||||
}
|
||||
|
||||
if (!f) {
|
||||
fprintf(stderr, "cannot open %s: %s\n", argv[1], strerror(errno));
|
||||
return 2;
|
||||
}
|
||||
|
||||
pool_buffer_init();
|
||||
|
||||
if (proto_agent_start(0, ¶ms) != 0) {
|
||||
fprintf(stderr, "error on proto_agent_start()\n");
|
||||
fclose(f);
|
||||
return 3;
|
||||
}
|
||||
|
||||
atexit(close_proto_agent);
|
||||
gettimeofday(&t_start, NULL);
|
||||
|
||||
while ((size = fread(s, 1, BUF_MAX, f)) > 0) {
|
||||
usleep(10);
|
||||
totsize += size;
|
||||
mem.data = &s[0];
|
||||
proto_agent_send_pdcp_data_ind(&p, 0, 0, 0, size, &mem);
|
||||
}
|
||||
|
||||
gettimeofday(&t_end, NULL);
|
||||
fclose(f);
|
||||
long us = uelapsed(&t_start, &t_end);
|
||||
fprintf(stderr, "read %zu bytes in %ld ms -> %.3fMB/s, %.3fMbps\n",
|
||||
totsize, us / 1000, ((float) totsize ) / us,
|
||||
((float) totsize) / us * 8);
|
||||
fprintf(stderr, "check files using 'diff afile bfile'\n");
|
||||
/* wait, we are possibly receiving data */
|
||||
sleep(5);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************
|
||||
* arbitrary functions, needed for linking (used or not) *
|
||||
*********************************************************
|
||||
*/
|
||||
|
||||
boolean_t
|
||||
pdcp_data_ind(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP,
|
||||
const MBMS_flag_t MBMS_flagP,
|
||||
const rb_id_t rb_idP,
|
||||
const sdu_size_t sdu_buffer_sizeP,
|
||||
mem_block_t *const sdu_buffer_pP
|
||||
) {
|
||||
fprintf(stderr, "This should never be called on the DU\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pthread_t new_thread(void *(*f)(void *), void *b) {
|
||||
pthread_t t;
|
||||
pthread_attr_t att;
|
||||
|
||||
if (pthread_attr_init(&att)) {
|
||||
fprintf(stderr, "pthread_attr_init err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
|
||||
fprintf(stderr, "pthread_attr_setdetachstate err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_create(&t, &att, f, b)) {
|
||||
fprintf(stderr, "pthread_create err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_attr_destroy(&att)) {
|
||||
fprintf(stderr, "pthread_attr_destroy err\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_get(paramdef_t *params,int numparams, char *prefix) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file enb_agent.h
|
||||
* \brief top level enb agent receive thread and itti task
|
||||
* \author Navid Nikaein and Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include "proto_agent_common.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "proto_agent.h"
|
||||
#include "assertions.h"
|
||||
#include "proto_agent_net_comm.h"
|
||||
#include "proto_agent_async.h"
|
||||
#include <common/utils/system.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define ENB_AGENT_MAX 9
|
||||
|
||||
proto_agent_instance_t proto_agent[MAX_DU];
|
||||
|
||||
//pthread_t new_thread(void *(*f)(void *), void *b);
|
||||
|
||||
Protocol__FlexsplitMessage *proto_agent_timeout_fsp(void *args);
|
||||
|
||||
#define TEST_MOD 0
|
||||
|
||||
#define ECHO
|
||||
|
||||
/* Server side function; upon a new connection
|
||||
reception, sends the hello packets
|
||||
*/
|
||||
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) {
|
||||
int channel_id;
|
||||
// RS: CUDU does not work!
|
||||
//DevAssert(p->local_interface);
|
||||
//DevAssert(p->local_ipv4_address);
|
||||
//DevAssert(p->local_port > 1024); // "unprivileged" port
|
||||
//DevAssert(p->remote_ipv4_address);
|
||||
//DevAssert(p->remote_port > 1024); // "unprivileged" port
|
||||
proto_agent[mod_id].mod_id = mod_id;
|
||||
proto_agent[mod_id].exit = 0;
|
||||
/* Initialize the channel container */
|
||||
/* TODO only initialize the first time */
|
||||
proto_agent_init_channel_container();
|
||||
/*Create the async channel info*/
|
||||
proto_agent_async_channel_t *channel_info;
|
||||
channel_info = proto_agent_async_channel_info(mod_id, p->local_ipv4_address, p->local_port,
|
||||
p->remote_ipv4_address, p->remote_port);
|
||||
|
||||
if (!channel_info) goto error;
|
||||
|
||||
/* Create a channel using the async channel info */
|
||||
channel_id = proto_agent_create_channel((void *) channel_info,
|
||||
proto_agent_async_msg_send,
|
||||
proto_agent_async_msg_recv,
|
||||
proto_agent_async_release);
|
||||
|
||||
if (channel_id <= 0) goto error;
|
||||
|
||||
proto_agent_channel_t *channel = proto_agent_get_channel(channel_id);
|
||||
|
||||
if (!channel) goto error;
|
||||
|
||||
proto_agent[mod_id].channel = channel;
|
||||
/* Register the channel for all underlying agents (use ENB_AGENT_MAX) */
|
||||
proto_agent_register_channel(mod_id, channel, ENB_AGENT_MAX);
|
||||
// Code for sending the HELLO/ECHO_REQ message once a connection is established
|
||||
//uint8_t *msg = NULL;
|
||||
//Protocol__FlexsplitMessage *init_msg=NULL;
|
||||
//if (udp == 0)
|
||||
//{
|
||||
// // If the comm is not UDP, allow the server to send the first packet over the channel
|
||||
// //printf( "Proto agent Server: Calling the echo_request packet constructor\n");
|
||||
// msg_flag = proto_agent_echo_request(mod_id, NULL, &init_msg);
|
||||
// if (msg_flag != 0)
|
||||
// goto error;
|
||||
//
|
||||
// int msgsize = 0;
|
||||
// if (init_msg != NULL)
|
||||
// msg = proto_agent_pack_message(init_msg, &msgsize);
|
||||
// if (msg!= NULL)
|
||||
// {
|
||||
// LOG_D(PROTO_AGENT, "Server sending the message over the async channel\n");
|
||||
// proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, (void *) channel_info);
|
||||
// }
|
||||
// /* After sending the message, wait for any replies;
|
||||
// the server thread blocks until it reads any data
|
||||
// over the channel
|
||||
// */
|
||||
//}
|
||||
//proto_agent[mod_id].recv_thread = new_thread(proto_agent_receive, &proto_agent[mod_id]);
|
||||
threadCreate(&proto_agent[mod_id].recv_thread, proto_agent_receive, &proto_agent[mod_id], "proto", -1, OAI_PRIORITY_RT_LOW);
|
||||
fprintf(stderr, "[PROTO_AGENT] server started at port %s:%d\n", p->local_ipv4_address, p->local_port);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(PROTO_AGENT, "there was an error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void proto_agent_stop(mod_id_t mod_id) {
|
||||
if (!proto_agent[mod_id].channel) return;
|
||||
|
||||
/* unlock the independent read thread proto_agent_receive() */
|
||||
proto_agent[mod_id].exit = 1;
|
||||
proto_agent_async_msg_recv_unlock(proto_agent[mod_id].channel->channel_info);
|
||||
proto_agent_async_release(proto_agent[mod_id].channel);
|
||||
proto_agent_destroy_channel(proto_agent[mod_id].channel->channel_id);
|
||||
free(proto_agent[mod_id].channel);
|
||||
proto_agent[mod_id].channel = NULL;
|
||||
LOG_W(PROTO_AGENT, "server stopped\n");
|
||||
}
|
||||
|
||||
//void
|
||||
//proto_agent_send_hello(void)
|
||||
//{
|
||||
// uint8_t *msg = NULL;
|
||||
// Protocol__FlexsplitMessage *init_msg=NULL;
|
||||
// int msg_flag = 0;
|
||||
//
|
||||
//
|
||||
// //printf( "PDCP agent: Calling the HELLO packet constructor\n");
|
||||
// msg_flag = proto_agent_hello(proto_agent[TEST_MOD].mod_id, NULL, &init_msg);
|
||||
//
|
||||
// int msgsize = 0;
|
||||
// if (msg_flag == 0)
|
||||
// {
|
||||
// proto_agent_serialize_message(init_msg, &msg, &msgsize);
|
||||
// }
|
||||
//
|
||||
// LOG_D(PROTO_AGENT, "Agent sending the message over the async channel\n");
|
||||
// proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, (void *) client_channel[TEST_MOD]);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
rlc_op_status_t proto_agent_send_rlc_data_req(const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
|
||||
const rb_id_t rb_idP, const mui_t muiP,
|
||||
confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID) {
|
||||
uint8_t *msg = NULL;
|
||||
Protocol__FlexsplitMessage *init_msg=NULL;
|
||||
int msg_flag = 0;
|
||||
int msgsize = 0;
|
||||
mod_id_t mod_id = ctxt_pP->module_id;
|
||||
data_req_args args;
|
||||
DevAssert(proto_agent[mod_id].channel);
|
||||
DevAssert(proto_agent[mod_id].channel->channel_info);
|
||||
args.ctxt = ctxt_pP;
|
||||
args.srb_flag = srb_flagP;
|
||||
args.MBMS_flag = MBMS_flagP;
|
||||
args.rb_id = rb_idP;
|
||||
args.mui = muiP;
|
||||
args.confirm = confirmP;
|
||||
args.sdu_size = sdu_sizeP;
|
||||
args.sdu_p = sdu_pP;
|
||||
msg_flag = proto_agent_pdcp_data_req(mod_id, (void *) &args, &init_msg);
|
||||
|
||||
if (msg_flag != 0 || !init_msg) goto error;
|
||||
|
||||
msg = proto_agent_pack_message(init_msg, &msgsize);
|
||||
|
||||
if (!msg) goto error;
|
||||
|
||||
proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
|
||||
free_mem_block(sdu_pP, __func__);
|
||||
return RLC_OP_STATUS_OK;
|
||||
error:
|
||||
LOG_E(PROTO_AGENT, "PROTO_AGENT there was an error\n");
|
||||
return RLC_OP_STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
boolean_t proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP,
|
||||
const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP,
|
||||
sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,
|
||||
const uint32_t *const SrcID, const uint32_t *const DstID) {
|
||||
uint8_t *msg = NULL;
|
||||
Protocol__FlexsplitMessage *init_msg = NULL;
|
||||
int msg_flag = 0;
|
||||
int msgsize = 0;
|
||||
mod_id_t mod_id = ctxt_pP->module_id;
|
||||
data_req_args args;
|
||||
DevAssert(proto_agent[mod_id].channel);
|
||||
DevAssert(proto_agent[mod_id].channel->channel_info);
|
||||
args.ctxt = ctxt_pP;
|
||||
args.srb_flag = srb_flagP;
|
||||
args.MBMS_flag = MBMS_flagP;
|
||||
args.rb_id = rb_idP;
|
||||
args.sdu_size = sdu_sizeP;
|
||||
args.sdu_p = sdu_pP;
|
||||
msg_flag = proto_agent_pdcp_data_ind(mod_id, (void *) &args, &init_msg);
|
||||
|
||||
if (msg_flag != 0 || !init_msg) goto error;
|
||||
|
||||
msg = proto_agent_pack_message(init_msg, &msgsize);
|
||||
|
||||
if (!msg) goto error;
|
||||
|
||||
proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
|
||||
free_mem_block(sdu_pP, __func__);
|
||||
return TRUE;
|
||||
error:
|
||||
LOG_E(PROTO_AGENT, "there was an error in %s\n", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void *
|
||||
proto_agent_receive(void *args) {
|
||||
proto_agent_instance_t *inst = args;
|
||||
void *data = NULL;
|
||||
int size;
|
||||
int priority;
|
||||
err_code_t err_code;
|
||||
pthread_setname_np(pthread_self(), "proto_rx");
|
||||
Protocol__FlexsplitMessage *msg;
|
||||
uint8_t *ser_msg;
|
||||
|
||||
while (1) {
|
||||
msg = NULL;
|
||||
ser_msg = NULL;
|
||||
|
||||
if ((size = proto_agent_async_msg_recv(&data, &priority, inst->channel->channel_info)) < 0) {
|
||||
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (inst->exit) break;
|
||||
|
||||
LOG_D(PROTO_AGENT, "Server side Received message with size %d and priority %d, calling message handle\n", size, priority);
|
||||
msg = proto_agent_handle_message(inst->mod_id, data, size);
|
||||
|
||||
if (!msg) {
|
||||
LOG_D(PROTO_AGENT, "msg to send back is NULL\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
ser_msg = proto_agent_pack_message(msg, &size);
|
||||
|
||||
if (!ser_msg) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG_D(PROTO_AGENT, "Server sending the reply message over the async channel\n");
|
||||
|
||||
if (proto_agent_async_msg_send((void *)ser_msg, (int) size, 1, inst->channel->channel_info)) {
|
||||
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
|
||||
goto error;
|
||||
}
|
||||
|
||||
LOG_D(PROTO_AGENT, "sent message with size %d\n", size);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
error:
|
||||
LOG_E(PROTO_AGENT, "proto_agent_receive(): error %d occured\n",err_code);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file proto_agent.h
|
||||
* \brief top level protocol agent
|
||||
* \author Navid Nikaein and Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#ifndef PROTO_AGENT_H_
|
||||
#define PROTO_AGENT_H_
|
||||
#include "ENB_APP/enb_config.h" // for enb properties
|
||||
#include "proto_agent_common.h"
|
||||
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
|
||||
#include "RRC/NR/nr_rrc_defs.h"
|
||||
|
||||
|
||||
void *proto_agent_receive(void *args);
|
||||
|
||||
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p);
|
||||
void proto_agent_stop(mod_id_t mod_id);
|
||||
|
||||
rlc_op_status_t proto_agent_send_rlc_data_req( const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
|
||||
const rb_id_t rb_idP, const mui_t muiP, confirm_t confirmP,
|
||||
sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID);
|
||||
|
||||
pdcp_data_ind_t proto_agent_send_pdcp_data_ind;
|
||||
|
||||
#endif
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include "proto_agent_async.h"
|
||||
#include "proto_agent_defs.h"
|
||||
|
||||
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
proto_agent_async_channel_t *
|
||||
proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bind_port,
|
||||
const char* peer_ip, uint16_t peer_port)
|
||||
{
|
||||
proto_agent_async_channel_t *channel;
|
||||
channel = malloc(sizeof(proto_agent_async_channel_t));
|
||||
|
||||
if (channel == NULL)
|
||||
goto error;
|
||||
|
||||
channel->enb_id = mod_id;
|
||||
channel->link = new_link_udp_server(bind_ip, bind_port);
|
||||
|
||||
if (channel->link == NULL) goto error;
|
||||
|
||||
channel->send_queue = new_message_queue();
|
||||
if (channel->send_queue == NULL) goto error;
|
||||
channel->receive_queue = new_message_queue();
|
||||
if (channel->receive_queue == NULL) goto error;
|
||||
|
||||
channel->manager = create_link_manager(channel->send_queue,
|
||||
channel->receive_queue,
|
||||
channel->link);
|
||||
/* manually set remote IP&port for UDP server remote end */
|
||||
channel->manager->peer_port = peer_port;
|
||||
channel->manager->peer_addr = peer_ip;
|
||||
|
||||
if (channel->manager == NULL) goto error;
|
||||
|
||||
return channel;
|
||||
|
||||
error:
|
||||
if (channel)
|
||||
free(channel);
|
||||
LOG_E(PROTO_AGENT, "error creating proto_agent_async_channel_t\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info)
|
||||
{
|
||||
proto_agent_async_channel_t *channel = channel_info;
|
||||
return message_put(channel->send_queue, data, size, priority);
|
||||
}
|
||||
|
||||
int proto_agent_async_msg_recv(void **data, int *priority, void *channel_info)
|
||||
{
|
||||
proto_agent_async_channel_t *channel = channel_info;
|
||||
return message_get(channel->receive_queue, data, priority);
|
||||
}
|
||||
|
||||
void proto_agent_async_msg_recv_unlock(proto_agent_async_channel_t *channel) {
|
||||
message_get_unlock(channel->receive_queue);
|
||||
}
|
||||
|
||||
void proto_agent_async_release(proto_agent_channel_t *channel)
|
||||
{
|
||||
proto_agent_async_channel_t *channel_info = channel->channel_info;
|
||||
|
||||
destroy_link_manager(channel_info->manager);
|
||||
|
||||
destroy_message_queue(channel_info->send_queue);
|
||||
destroy_message_queue(channel_info->receive_queue);
|
||||
|
||||
close_link(channel_info->link);
|
||||
free(channel_info);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file enb_agent_async.h
|
||||
* \brief channel implementation for async interface
|
||||
* \author Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#ifndef PROTO_AGENT_ASYNC_H_
|
||||
#define PROTO_AGENT_ASYNC_H_
|
||||
|
||||
#include "proto_agent_net_comm.h"
|
||||
|
||||
typedef struct proto_agent_async_channel_s {
|
||||
mod_id_t enb_id;
|
||||
socket_link_t *link;
|
||||
message_queue_t *send_queue;
|
||||
message_queue_t *receive_queue;
|
||||
link_manager_t *manager;
|
||||
} proto_agent_async_channel_t;
|
||||
|
||||
proto_agent_async_channel_t *
|
||||
proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bind_port,
|
||||
const char *peer_ip, uint16_t peer_port);
|
||||
|
||||
int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info);
|
||||
|
||||
int proto_agent_async_msg_recv(void **data, int *priority, void *channel_info);
|
||||
|
||||
/* unlocks a running proto_agent_async_msg_recv() */
|
||||
void proto_agent_async_msg_recv_unlock(proto_agent_async_channel_t *channel);
|
||||
|
||||
void proto_agent_async_release(proto_agent_channel_t *channel);
|
||||
|
||||
|
||||
#endif /*PROTO_AGENT_ASYNC_H_*/
|
||||
@@ -1,719 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file proto_agent_common.c
|
||||
* \brief common primitives for all agents
|
||||
* \author Navid Nikaein and Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#include<stdio.h>
|
||||
#include <dlfcn.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "PHY/phy_extern.h"
|
||||
#include "proto_agent_common.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "common/ran_context.h"
|
||||
|
||||
extern RAN_CONTEXT_t RC;
|
||||
|
||||
/*
|
||||
* message primitives
|
||||
*/
|
||||
|
||||
// Function to fill in the dl_data header (32bits) with the appropriate fields (doing bitwise operations)
|
||||
void fill_dl_data_header(int pdu_type, int spare, int seq_no, uint32_t *header) {
|
||||
uint32_t type = pdu_type;
|
||||
uint32_t spare_ = spare;
|
||||
uint32_t seq = seq_no;
|
||||
type = type << 28;
|
||||
spare_ = spare_ << 24;
|
||||
*header = (type | spare_);
|
||||
*header = (*header | seq);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Function to retrieve data from the dl_data header (32bits) (doing bitwise operations)
|
||||
void read_dl_data_header(int *pdu_type, int *spare, int *seqno, uint32_t header) {
|
||||
*pdu_type = header;
|
||||
*spare = header;
|
||||
*seqno = header;
|
||||
*pdu_type = *pdu_type >> 28;
|
||||
*spare = *spare << 4;
|
||||
*spare = *spare >> 28;
|
||||
*seqno = *seqno << 8;
|
||||
*seqno = *seqno >> 8;
|
||||
return;
|
||||
}
|
||||
|
||||
int f1u_serialize_message(Protocol__F1uMessage *msg, void **buf,int *size) {
|
||||
*size = protocol__f1u_message__get_packed_size(msg);
|
||||
*buf = malloc(*size);
|
||||
|
||||
if (!(*buf))
|
||||
goto error;
|
||||
|
||||
protocol__f1u_message__pack(msg, *buf);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(F1U, "an error occured\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int f1u_deserialize_message(void *data, int size, Protocol__F1uMessage **msg) {
|
||||
*msg = protocol__f1u_message__unpack(NULL, size, data);
|
||||
|
||||
if (*msg == NULL)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(F1U, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int f1u_dl_data_create_header(uint32_t pdu_type, uint32_t f1u_sn, Protocol__DlDataHeader **header) {
|
||||
*header = malloc(sizeof(Protocol__DlDataHeader));
|
||||
|
||||
if(*header == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__dl_data_header__init(*header);
|
||||
LOG_D(F1U, "Initialized the DL Data User header\n");
|
||||
fill_dl_data_header(pdu_type, 0, f1u_sn, &(*header)->fields);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(F1U, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int f1u_dl_data(const void *params, Protocol__F1uMessage **msg) {
|
||||
// Initialize the PDCP params
|
||||
dl_data_args *args = (dl_data_args *)params;
|
||||
Protocol__DlDataHeader *header;
|
||||
|
||||
if (f1u_dl_data_create_header(args->pdu_type, args->sn, &header) != 0)
|
||||
goto error;
|
||||
|
||||
Protocol__DlUserData *dl_data = NULL;
|
||||
*msg = malloc(sizeof(Protocol__DlUserData));
|
||||
|
||||
if(*msg == NULL)
|
||||
goto error;
|
||||
|
||||
// FIXME: Is the following used? It seems to be overwritten by the function
|
||||
// protocol__dl_user_data__init() anyway
|
||||
//dl_data = *msg;
|
||||
protocol__dl_user_data__init(dl_data);
|
||||
// Copy data to the bytes structure
|
||||
dl_data->pdu.data = malloc(args->sdu_size);
|
||||
dl_data->pdu.len = args->sdu_size;
|
||||
memcpy(dl_data->pdu.data, args->sdu_p, args->sdu_size);
|
||||
dl_data->frame = args->frame;
|
||||
dl_data->subframe = args->subframe;
|
||||
dl_data->rnti = args->rnti;
|
||||
dl_data->header = header;
|
||||
return 0;
|
||||
error:
|
||||
|
||||
if(header != NULL)
|
||||
free(header);
|
||||
|
||||
if(*msg != NULL)
|
||||
free(*msg);
|
||||
|
||||
LOG_E(F1U, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_serialize_message(Protocol__FlexsplitMessage *msg, uint8_t **buf, int *size) {
|
||||
*size = protocol__flexsplit_message__get_packed_size(msg);
|
||||
*buf = malloc(*size);
|
||||
|
||||
if (!(*buf))
|
||||
goto error;
|
||||
|
||||
protocol__flexsplit_message__pack(msg, *buf);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "an error occured\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We assume that the buffer size is equal to the message size.
|
||||
Should be chekced durint Tx/Rx */
|
||||
int proto_agent_deserialize_message(void *data, int size, Protocol__FlexsplitMessage **msg) {
|
||||
*msg = protocol__flexsplit_message__unpack(NULL, size, data);
|
||||
|
||||
if (*msg == NULL)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fsp_create_header(xid_t xid, Protocol__FspType type, Protocol__FspHeader **header) {
|
||||
*header = malloc(sizeof(Protocol__FspHeader));
|
||||
|
||||
if(*header == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__fsp_header__init(*header);
|
||||
LOG_D(PROTO_AGENT, "Initialized the PROTOBUF message header\n");
|
||||
(*header)->version = FLEXSPLIT_VERSION;
|
||||
LOG_D(PROTO_AGENT, "Set the vversion to FLEXSPLIT_VERSION\n");
|
||||
(*header)->has_version = 1;
|
||||
(*header)->type = type;
|
||||
(*header)->has_type = 1;
|
||||
(*header)->xid = xid;
|
||||
(*header)->has_xid = 1;
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int just_print(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int proto_agent_pdcp_data_req(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
Protocol__FspCtxt *ctxt = NULL;
|
||||
Protocol__FspRlcPdu *pdu = NULL;
|
||||
Protocol__FspRlcData *rlc_data = NULL;
|
||||
Protocol__FspRlcDataReq *data_req = NULL;
|
||||
// Initialize the PDCP params
|
||||
data_req_args *args = (data_req_args *)params;
|
||||
// Create the protobuf header
|
||||
Protocol__FspHeader *header;
|
||||
xid_t xid = mod_id;
|
||||
LOG_D(PROTO_AGENT, "creating the data_req message\n");
|
||||
|
||||
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_RLC_DATA_REQ, &header) != 0)
|
||||
goto error;
|
||||
|
||||
/* Begin constructing the messages. They are defined as follows:
|
||||
* 1) fspRlcPdu is storing the bytes of the packet
|
||||
* 2) Message fspRlcData is packing the packet + the context of the PDCP (separate message)
|
||||
* 3) Messge fspRlcDataReq is packing the header, enb_id and fspRlcData
|
||||
*/
|
||||
ctxt = malloc(sizeof(Protocol__FspCtxt));
|
||||
pdu = malloc(sizeof(Protocol__FspRlcPdu));
|
||||
rlc_data = malloc(sizeof(Protocol__FspRlcData));
|
||||
data_req = malloc(sizeof(Protocol__FspRlcDataReq));
|
||||
protocol__fsp_ctxt__init(ctxt);
|
||||
protocol__fsp_rlc_pdu__init(pdu);
|
||||
protocol__fsp_rlc_data__init(rlc_data);
|
||||
protocol__fsp_rlc_data_req__init(data_req);
|
||||
// Copy data to the RlcPdu structure
|
||||
pdu->fsp_pdu_data.data = malloc(args->sdu_size);
|
||||
pdu->fsp_pdu_data.len = args->sdu_size;
|
||||
memcpy(pdu->fsp_pdu_data.data, args->sdu_p->data, args->sdu_size);
|
||||
pdu->has_fsp_pdu_data = 1;
|
||||
// Copy data to the ctxt structure
|
||||
ctxt->fsp_mod_id = args->ctxt->module_id;
|
||||
ctxt->fsp_enb_flag = args->ctxt->enb_flag;
|
||||
ctxt->fsp_instance = args->ctxt->instance;
|
||||
ctxt->fsp_rnti = args->ctxt->rnti;
|
||||
ctxt->fsp_frame = args->ctxt->frame;
|
||||
ctxt->fsp_subframe = args->ctxt->subframe;
|
||||
ctxt->fsp_enb_index = args->ctxt->eNB_index;
|
||||
ctxt->has_fsp_mod_id = 1;
|
||||
ctxt->has_fsp_enb_flag = 1;
|
||||
ctxt->has_fsp_instance = 1;
|
||||
ctxt->has_fsp_rnti = 1;
|
||||
ctxt->has_fsp_frame = 1;
|
||||
ctxt->has_fsp_subframe = 1;
|
||||
ctxt->has_fsp_enb_index = 1;
|
||||
rlc_data->fsp_ctxt = ctxt;
|
||||
rlc_data->fsp_srb_flag = args->srb_flag;
|
||||
rlc_data->fsp_mbms_flag = args->MBMS_flag;
|
||||
rlc_data->fsp_rb_id = args->rb_id;
|
||||
rlc_data->fsp_muip = args->mui;
|
||||
rlc_data->fsp_confirm = args->confirm;
|
||||
rlc_data->fsp_sdu_buffer_size = args->sdu_size;
|
||||
rlc_data->fsp_pdu = pdu;
|
||||
rlc_data->has_fsp_srb_flag = 1;
|
||||
rlc_data->has_fsp_mbms_flag = 1;
|
||||
rlc_data->has_fsp_rb_id = 1;
|
||||
rlc_data->has_fsp_muip = 1;
|
||||
rlc_data->has_fsp_confirm = 1;
|
||||
rlc_data->has_fsp_sdu_buffer_size = 1;
|
||||
// Up to here, everything is a signle message that is packed inside another. The final data_req
|
||||
// will be created later, after the setting of all variables
|
||||
data_req->header = header;
|
||||
data_req->enb_id = mod_id;
|
||||
data_req->has_enb_id = 1;
|
||||
data_req->pdcp_data = rlc_data;
|
||||
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
|
||||
|
||||
if(*msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__flexsplit_message__init(*msg);
|
||||
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_REQ_MSG;
|
||||
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__INITIATING_MESSAGE; //we will be waiting for the ACK
|
||||
(*msg)->has_msg_dir = 1;
|
||||
(*msg)->data_req_msg = data_req;
|
||||
return 0;
|
||||
error:
|
||||
|
||||
if(header != NULL)
|
||||
free(header);
|
||||
|
||||
if(pdu!=NULL)
|
||||
free(pdu);
|
||||
|
||||
if(rlc_data!=NULL)
|
||||
free(rlc_data);
|
||||
|
||||
if(data_req!= NULL)
|
||||
free(data_req);
|
||||
|
||||
if(*msg != NULL)
|
||||
free(*msg);
|
||||
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_destroy_pdcp_data_req(Protocol__FlexsplitMessage *msg) {
|
||||
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_REQ_MSG)
|
||||
goto error;
|
||||
|
||||
free(msg->data_req_msg->header);
|
||||
free(msg->data_req_msg->pdcp_data->fsp_pdu->fsp_pdu_data.data);
|
||||
free(msg->data_req_msg->pdcp_data->fsp_pdu);
|
||||
free(msg->data_req_msg->pdcp_data->fsp_ctxt);
|
||||
free(msg->data_req_msg->pdcp_data);
|
||||
free(msg->data_req_msg);
|
||||
free(msg);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_get_ack_result(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
/* code useless in this status: return 0 anyways
|
||||
rlc_op_status_t result = 0;
|
||||
printf("PROTO_AGENT: handling the data_req_ack message\n");
|
||||
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
|
||||
Protocol__FspRlcDataReqAck *data_ack = input->data_req_ack;
|
||||
result = data_ack->result;
|
||||
printf("PROTO_AGENT: ACK RESULT IS %u\n", result);
|
||||
ack_result = result;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int proto_agent_pdcp_data_req_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
rlc_op_status_t result = 0;
|
||||
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
|
||||
Protocol__FspRlcDataReq *data_req = input->data_req_msg;
|
||||
Protocol__FspCtxt *ctxt = NULL;
|
||||
Protocol__FspRlcData *rlc_data = NULL;
|
||||
rlc_data = data_req->pdcp_data;
|
||||
ctxt = rlc_data->fsp_ctxt;
|
||||
protocol_ctxt_t ctxt_pP;
|
||||
srb_flag_t srb_flagP = 0;
|
||||
rb_id_t rb_idP = 0;
|
||||
mui_t muiP = 0;
|
||||
confirm_t confirmP = 0;
|
||||
MBMS_flag_t flag_MBMS = 0;
|
||||
sdu_size_t pdcp_pdu_size = 0;
|
||||
mem_block_t *pdcp_pdu_p = NULL;
|
||||
// Create a new protocol context for handling the packet
|
||||
ctxt_pP.module_id = ctxt->fsp_mod_id;
|
||||
ctxt_pP.enb_flag = ctxt->fsp_enb_flag;
|
||||
ctxt_pP.instance = ctxt->fsp_instance;
|
||||
ctxt_pP.rnti = ctxt->fsp_rnti;
|
||||
ctxt_pP.frame = ctxt->fsp_frame;
|
||||
ctxt_pP.subframe = ctxt->fsp_subframe;
|
||||
ctxt_pP.eNB_index = ctxt->fsp_enb_index;
|
||||
srb_flagP = rlc_data->fsp_srb_flag;
|
||||
flag_MBMS = rlc_data->fsp_mbms_flag;
|
||||
rb_idP = rlc_data->fsp_rb_id;
|
||||
muiP = rlc_data->fsp_muip;
|
||||
confirmP = rlc_data->fsp_confirm;
|
||||
pdcp_pdu_size = rlc_data->fsp_pdu->fsp_pdu_data.len;
|
||||
pdcp_pdu_p = get_free_mem_block(pdcp_pdu_size, __func__);
|
||||
|
||||
if (!pdcp_pdu_p) {
|
||||
LOG_E(PROTO_AGENT, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(pdcp_pdu_p->data, rlc_data->fsp_pdu->fsp_pdu_data.data, pdcp_pdu_size);
|
||||
if (RC.nrrrc) {
|
||||
LOG_D(PROTO_AGENT, "proto_agent received pdcp_data_req \n");
|
||||
// for (int i = 0; i < pdcp_pdu_size; i++)
|
||||
// printf(" %2.2x", (unsigned char)pdcp_pdu_p->data[i]);
|
||||
// printf("\n");
|
||||
du_rlc_data_req(&ctxt_pP, srb_flagP, flag_MBMS, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p);
|
||||
result = 1;
|
||||
} else {
|
||||
result = rlc_data_req(&ctxt_pP, srb_flagP, flag_MBMS, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p, NULL, NULL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int proto_agent_destroy_pdcp_data_ind(Protocol__FlexsplitMessage *msg) {
|
||||
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG)
|
||||
goto error;
|
||||
|
||||
free(msg->data_ind_msg->header);
|
||||
free(msg->data_ind_msg->rlc_data->fsp_pdu->fsp_pdu_data.data);
|
||||
free(msg->data_ind_msg->rlc_data->fsp_pdu);
|
||||
free(msg->data_ind_msg->rlc_data->fsp_ctxt);
|
||||
free(msg->data_ind_msg->rlc_data);
|
||||
free(msg->data_ind_msg);
|
||||
free(msg);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_pdcp_data_ind(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
Protocol__FspCtxt *ctxt = NULL;
|
||||
Protocol__FspRlcPdu *pdu = NULL;
|
||||
Protocol__FspRlcData *rlc_data = NULL;
|
||||
Protocol__FspPdcpDataInd *data_ind = NULL;
|
||||
// Initialize the PDCP params
|
||||
data_req_args *args = (data_req_args *)params;
|
||||
// Create the protobuf header
|
||||
Protocol__FspHeader *header;
|
||||
xid_t xid = mod_id;
|
||||
LOG_D(PROTO_AGENT, "creating the data_ind message\n");
|
||||
|
||||
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_PDCP_DATA_IND, &header) != 0)
|
||||
goto error;
|
||||
|
||||
/* Begin constructing the messages. They are defined as follows:
|
||||
* 1) fspRlcPdu is storing the bytes of the packet
|
||||
* 2) Message fspRlcData is packing the packet + the context of the PDCP (separate message)
|
||||
* 3) Messge fspRlcDataReq is packing the header, enb_id and fspRlcData
|
||||
*/
|
||||
ctxt = malloc(sizeof(Protocol__FspCtxt));
|
||||
pdu = malloc(sizeof(Protocol__FspRlcPdu));
|
||||
rlc_data = malloc(sizeof(Protocol__FspRlcData));
|
||||
data_ind = malloc(sizeof(Protocol__FspPdcpDataInd));
|
||||
protocol__fsp_ctxt__init(ctxt);
|
||||
protocol__fsp_rlc_pdu__init(pdu);
|
||||
protocol__fsp_rlc_data__init(rlc_data);
|
||||
protocol__fsp_pdcp_data_ind__init(data_ind);
|
||||
// Copy data to the RlcPdu structure
|
||||
pdu->fsp_pdu_data.data = malloc(args->sdu_size);
|
||||
pdu->fsp_pdu_data.len = args->sdu_size;
|
||||
memcpy(pdu->fsp_pdu_data.data, args->sdu_p->data, args->sdu_size);
|
||||
pdu->has_fsp_pdu_data = 1;
|
||||
// Copy data to the ctxt structure
|
||||
ctxt->fsp_mod_id = args->ctxt->module_id;
|
||||
ctxt->fsp_enb_flag = args->ctxt->enb_flag;
|
||||
ctxt->fsp_instance = args->ctxt->instance;
|
||||
ctxt->fsp_rnti = args->ctxt->rnti;
|
||||
ctxt->fsp_frame = args->ctxt->frame;
|
||||
ctxt->fsp_subframe = args->ctxt->subframe;
|
||||
ctxt->fsp_enb_index = args->ctxt->eNB_index;
|
||||
ctxt->has_fsp_mod_id = 1;
|
||||
ctxt->has_fsp_enb_flag = 1;
|
||||
ctxt->has_fsp_instance = 1;
|
||||
ctxt->has_fsp_rnti = 1;
|
||||
ctxt->has_fsp_frame = 1;
|
||||
ctxt->has_fsp_subframe = 1;
|
||||
ctxt->has_fsp_enb_index = 1;
|
||||
rlc_data->fsp_ctxt = ctxt;
|
||||
rlc_data->fsp_srb_flag = args->srb_flag;
|
||||
rlc_data->fsp_mbms_flag = args->MBMS_flag;
|
||||
rlc_data->fsp_rb_id = args->rb_id;
|
||||
rlc_data->fsp_sdu_buffer_size = args->sdu_size;
|
||||
rlc_data->fsp_pdu = pdu;
|
||||
rlc_data->has_fsp_srb_flag = 1;
|
||||
rlc_data->has_fsp_mbms_flag = 1;
|
||||
rlc_data->has_fsp_rb_id = 1;
|
||||
rlc_data->has_fsp_sdu_buffer_size = 1;
|
||||
// Up to here, everything is a signle message that is packed inside another. The final data_req
|
||||
// will be created later, after the setting of all variables
|
||||
data_ind->header = header;
|
||||
data_ind->enb_id = mod_id;
|
||||
data_ind->has_enb_id = 1;
|
||||
data_ind->rlc_data = rlc_data;
|
||||
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
|
||||
|
||||
if(*msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__flexsplit_message__init(*msg);
|
||||
LOG_D(PROTO_AGENT,"setting the message case to %d\n", PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG);
|
||||
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG;
|
||||
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__INITIATING_MESSAGE; //we will be waiting for the ACK
|
||||
(*msg)->has_msg_dir = 1;
|
||||
(*msg)->data_ind_msg = data_ind; //data_req;
|
||||
return 0;
|
||||
error:
|
||||
|
||||
if(header != NULL)
|
||||
free(header);
|
||||
|
||||
if(pdu!=NULL)
|
||||
free(pdu);
|
||||
|
||||
if(rlc_data!=NULL)
|
||||
free(rlc_data);
|
||||
|
||||
if(data_ind!= NULL)
|
||||
free(data_ind);
|
||||
|
||||
if(*msg != NULL)
|
||||
free(*msg);
|
||||
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
boolean_t result = 0;
|
||||
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
|
||||
Protocol__FspPdcpDataInd *data_ind = input->data_ind_msg;
|
||||
Protocol__FspCtxt *ctxt = NULL;
|
||||
Protocol__FspRlcData *rlc_data = NULL;
|
||||
rlc_data = data_ind->rlc_data;
|
||||
ctxt = rlc_data->fsp_ctxt;
|
||||
protocol_ctxt_t ctxt_pP;
|
||||
srb_flag_t srb_flagP = 0;
|
||||
rb_id_t rb_idP = 0;
|
||||
sdu_size_t pdcp_pdu_size = 0;
|
||||
MBMS_flag_t flag_MBMS = 0;
|
||||
mem_block_t *pdcp_pdu_p = NULL;
|
||||
// Create a new protocol context for handling the packet
|
||||
ctxt_pP.module_id = ctxt->fsp_mod_id;
|
||||
ctxt_pP.enb_flag = ctxt->fsp_enb_flag;
|
||||
ctxt_pP.instance = ctxt->fsp_instance;
|
||||
ctxt_pP.rnti = ctxt->fsp_rnti;
|
||||
ctxt_pP.frame = ctxt->fsp_frame;
|
||||
ctxt_pP.subframe = ctxt->fsp_subframe;
|
||||
ctxt_pP.brOption = 0;
|
||||
ctxt_pP.eNB_index = ctxt->fsp_enb_index;
|
||||
srb_flagP = rlc_data->fsp_srb_flag;
|
||||
flag_MBMS = rlc_data->fsp_mbms_flag;
|
||||
rb_idP = rlc_data->fsp_rb_id;
|
||||
pdcp_pdu_size = rlc_data->fsp_pdu->fsp_pdu_data.len;
|
||||
pdcp_pdu_p = get_free_mem_block(pdcp_pdu_size, __func__);
|
||||
|
||||
if (!pdcp_pdu_p) goto error;
|
||||
|
||||
memcpy(pdcp_pdu_p->data, rlc_data->fsp_pdu->fsp_pdu_data.data, pdcp_pdu_size);
|
||||
// if (xid == 1)
|
||||
// pdcp_data_ind_wifi((const protocol_ctxt_t*) ctxt_pP, (const srb_flag_t) srb_flagP, (const MBMS_flag_t) flag_MBMS, (const rb_id_t) rb_idP, pdcp_pdu_size, pdcp_pdu_p);
|
||||
// else if (xid == 0) // FIXME: USE a preprocessed definition
|
||||
LOG_D(PROTO_AGENT, "[inst %ld] Received PDCP PDU with size %d for UE RNTI %x RB %ld, Calling pdcp_data_ind\n", ctxt_pP.instance, pdcp_pdu_size,ctxt_pP.rnti,rb_idP);
|
||||
result = pdcp_data_ind(&ctxt_pP,
|
||||
srb_flagP,
|
||||
flag_MBMS,
|
||||
rb_idP,
|
||||
pdcp_pdu_size,
|
||||
pdcp_pdu_p, NULL, NULL);
|
||||
return result;
|
||||
error:
|
||||
|
||||
if (pdcp_pdu_p)
|
||||
free_mem_block(pdcp_pdu_p, __func__);
|
||||
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_hello(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
Protocol__FspHeader *header;
|
||||
Protocol__FspHello *hello_msg = NULL;
|
||||
/*TODO: Need to set random xid or xid from received hello message*/
|
||||
xid_t xid = mod_id;
|
||||
|
||||
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_HELLO, &header) != 0)
|
||||
goto error;
|
||||
|
||||
LOG_D(PROTO_AGENT, "creating the HELLO message\n");
|
||||
hello_msg = malloc(sizeof(Protocol__FspHello));
|
||||
|
||||
if(hello_msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__fsp_hello__init(hello_msg);
|
||||
hello_msg->header = header;
|
||||
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
|
||||
|
||||
if(*msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__flexsplit_message__init(*msg);
|
||||
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_HELLO_MSG;
|
||||
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__SUCCESSFUL_OUTCOME;
|
||||
(*msg)->has_msg_dir = 1;
|
||||
(*msg)->hello_msg = hello_msg;
|
||||
return 0;
|
||||
error:
|
||||
|
||||
if(header != NULL)
|
||||
free(header);
|
||||
|
||||
if(hello_msg!=NULL)
|
||||
free(hello_msg);
|
||||
|
||||
if(*msg != NULL)
|
||||
free(*msg);
|
||||
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int proto_agent_destroy_hello(Protocol__FlexsplitMessage *msg) {
|
||||
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_HELLO_MSG)
|
||||
goto error;
|
||||
|
||||
free(msg->hello_msg->header);
|
||||
free(msg->hello_msg);
|
||||
free(msg);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_echo_request(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
Protocol__FspHeader *header;
|
||||
Protocol__FspEchoRequest *echo_request_msg = NULL;
|
||||
xid_t xid = mod_id;
|
||||
|
||||
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_ECHO_REQUEST, &header) != 0)
|
||||
goto error;
|
||||
|
||||
LOG_D(PROTO_AGENT, "creating the echo request message\n");
|
||||
echo_request_msg = malloc(sizeof(Protocol__FspEchoRequest));
|
||||
|
||||
if(echo_request_msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__fsp_echo_request__init(echo_request_msg);
|
||||
echo_request_msg->header = header;
|
||||
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
|
||||
|
||||
if(*msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__flexsplit_message__init(*msg);
|
||||
LOG_D(PROTO_AGENT,"setting the message direction to %d\n", PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REQUEST_MSG);
|
||||
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REQUEST_MSG;
|
||||
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__INITIATING_MESSAGE;
|
||||
(*msg)->has_msg_dir = 1;
|
||||
(*msg)->echo_request_msg = echo_request_msg;
|
||||
return 0;
|
||||
error:
|
||||
|
||||
if(header != NULL)
|
||||
free(header);
|
||||
|
||||
if(echo_request_msg != NULL)
|
||||
free(echo_request_msg);
|
||||
|
||||
if(*msg != NULL)
|
||||
free(*msg);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_destroy_echo_request(Protocol__FlexsplitMessage *msg) {
|
||||
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REQUEST_MSG)
|
||||
goto error;
|
||||
|
||||
free(msg->echo_request_msg->header);
|
||||
free(msg->echo_request_msg);
|
||||
free(msg);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_echo_reply(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
|
||||
xid_t xid;
|
||||
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
|
||||
Protocol__FspEchoRequest *echo_req = input->echo_request_msg;
|
||||
Protocol__FspEchoReply *echo_reply_msg = NULL;
|
||||
xid = (echo_req->header)->xid;
|
||||
LOG_D(PROTO_AGENT, "creating the echo reply message\n");
|
||||
Protocol__FspHeader *header;
|
||||
|
||||
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_ECHO_REPLY, &header) != 0)
|
||||
goto error;
|
||||
|
||||
echo_reply_msg = malloc(sizeof(Protocol__FspEchoReply));
|
||||
|
||||
if(echo_reply_msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__fsp_echo_reply__init(echo_reply_msg);
|
||||
echo_reply_msg->header = header;
|
||||
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
|
||||
|
||||
if(*msg == NULL)
|
||||
goto error;
|
||||
|
||||
protocol__flexsplit_message__init(*msg);
|
||||
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REPLY_MSG;
|
||||
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__SUCCESSFUL_OUTCOME;
|
||||
(*msg)->has_msg_dir = 1;
|
||||
(*msg)->echo_reply_msg = echo_reply_msg;
|
||||
return 0;
|
||||
error:
|
||||
|
||||
if(header != NULL)
|
||||
free(header);
|
||||
|
||||
if(echo_reply_msg != NULL)
|
||||
free(echo_reply_msg);
|
||||
|
||||
if(*msg != NULL)
|
||||
free(*msg);
|
||||
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int proto_agent_destroy_echo_reply(Protocol__FlexsplitMessage *msg) {
|
||||
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REPLY_MSG)
|
||||
goto error;
|
||||
|
||||
free(msg->echo_reply_msg->header);
|
||||
free(msg->echo_reply_msg);
|
||||
free(msg);
|
||||
return 0;
|
||||
error:
|
||||
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file enb_agent_common.h
|
||||
* \brief common message primitves and utilities
|
||||
* \author Navid Nikaein and Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef PROTO_AGENT_COMMON_H_
|
||||
#define PROTO_AGENT_COMMON_H_
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "flexsplit.pb-c.h"
|
||||
|
||||
// Do not need these
|
||||
//#include "stats_messages.pb-c.h"
|
||||
//#include "stats_common.pb-c.h"
|
||||
|
||||
#include "proto_agent_defs.h"
|
||||
//#include "ENB_APP/enb_config.h"
|
||||
#include "UTIL/MEM/mem_block.h"
|
||||
|
||||
//#include "LAYER2/MAC/extern.h"
|
||||
//#include "LAYER2/RLC/rlc.h"
|
||||
|
||||
# include "tree.h"
|
||||
# include "intertask_interface.h"
|
||||
|
||||
#define FLEXSPLIT_VERSION 0
|
||||
|
||||
typedef int (*proto_agent_message_decoded_callback)(
|
||||
mod_id_t mod_id,
|
||||
const void *params,
|
||||
Protocol__FlexsplitMessage **msg
|
||||
);
|
||||
|
||||
typedef int (*proto_agent_message_destruction_callback)(
|
||||
Protocol__FlexsplitMessage *msg
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**********************************
|
||||
* progRAN protocol messages helper
|
||||
* functions and generic handlers
|
||||
**********************************/
|
||||
|
||||
int proto_agent_serialize_message(Protocol__FlexsplitMessage *msg, uint8_t **buf, int *size);
|
||||
int proto_agent_deserialize_message(void *data, int size, Protocol__FlexsplitMessage **msg);
|
||||
|
||||
uint8_t *proto_agent_pack_message(Protocol__FlexsplitMessage *msg, int *size);
|
||||
|
||||
err_code_t proto_agent_destroy_flexsplit_message(Protocol__FlexsplitMessage *msg);
|
||||
|
||||
int fsp_create_header(xid_t xid, Protocol__FspType type, Protocol__FspHeader **header);
|
||||
|
||||
int proto_agent_hello(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
int proto_agent_destroy_hello(Protocol__FlexsplitMessage *msg);
|
||||
int proto_agent_echo_request(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
int proto_agent_destroy_echo_request(Protocol__FlexsplitMessage *msg);
|
||||
int proto_agent_echo_reply(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
int proto_agent_destroy_echo_reply(Protocol__FlexsplitMessage *msg);
|
||||
|
||||
int proto_agent_pdcp_data_req(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
int proto_agent_pdcp_data_req_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
int proto_agent_destroy_pdcp_data_req(Protocol__FlexsplitMessage *msg);
|
||||
int proto_agent_pdcp_data_ind(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
int proto_agent_destroy_pdcp_data_ind(Protocol__FlexsplitMessage *msg);
|
||||
int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
|
||||
int just_print(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
|
||||
|
||||
int proto_agent_get_ack_result(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
|
||||
|
||||
|
||||
Protocol__FlexsplitMessage* proto_agent_handle_message (mod_id_t mod_id,
|
||||
uint8_t *data,
|
||||
int size);
|
||||
|
||||
Protocol__FlexsplitMessage *proto_agent_handle_timed_task(void *args);
|
||||
|
||||
typedef struct _data_req_args data_req_args;
|
||||
typedef struct _dl_data_args dl_data_args;
|
||||
|
||||
struct _data_req_args{
|
||||
const protocol_ctxt_t* ctxt;
|
||||
srb_flag_t srb_flag;
|
||||
MBMS_flag_t MBMS_flag;
|
||||
rb_id_t rb_id;
|
||||
mui_t mui;
|
||||
confirm_t confirm;
|
||||
sdu_size_t sdu_size;
|
||||
mem_block_t *sdu_p;
|
||||
};
|
||||
|
||||
struct _dl_data_args{
|
||||
uint8_t pdu_type;
|
||||
uint32_t sn;
|
||||
frame_t frame;
|
||||
sub_frame_t subframe;
|
||||
rnti_t rnti;
|
||||
sdu_size_t sdu_size;
|
||||
mem_block_t *sdu_p;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file enb_agent_defs.h
|
||||
* \brief enb agent common definitions
|
||||
* \author Navid Nikaein and Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
#ifndef PROTO_AGENT_DEFS_H_
|
||||
#define PROTO_AGENT_DEFS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "openairinterface5g_limits.h"
|
||||
#include "UTIL/ASYNC_IF/link_manager.h"
|
||||
|
||||
#define DEFAULT_PROTO_AGENT_IPv4_ADDRESS "127.0.0.1"
|
||||
#define DEFAULT_PROTO_AGENT_PORT 2210
|
||||
#define DEFAULT_PROTO_AGENT_CACHE "/mnt/oai_agent_cache"
|
||||
|
||||
typedef enum {
|
||||
|
||||
PROTO_AGENT_DEFAULT=0,
|
||||
|
||||
ENB_AGENT_PHY=1,
|
||||
ENB_AGENT_MAC=2,
|
||||
ENB_AGENT_RLC=3,
|
||||
ENB_AGENT_PDCP=4,
|
||||
ENB_AGENT_RRC=5,
|
||||
ENB_AGENT_S1AP=6,
|
||||
ENB_AGENT_GTP=7,
|
||||
ENB_AGENT_X2AP=8,
|
||||
|
||||
ENB_AGENT_MAX=9,
|
||||
|
||||
} proto_agent_id_t;
|
||||
|
||||
/*
|
||||
typedef enum {
|
||||
ENB_AGENT_ACTION_NONE = 0x0,
|
||||
|
||||
ENB_AGENT_ACTION_SEND = 0x1,
|
||||
|
||||
ENB_AGENT_ACTION_APPLY = 0x2,
|
||||
|
||||
ENB_AGENT_ACTION_CLEAR = 0x4,
|
||||
|
||||
ENB_AGENT_ACTION_WRITE = 0x8,
|
||||
|
||||
ENB_AGENT_ACTION_FILTER = 0x10,
|
||||
|
||||
ENB_AGENT_ACTION_PREPROCESS = 0x20,
|
||||
|
||||
ENB_AGENT_ACTION_METER = 0x40,
|
||||
|
||||
ENB_AGENT_ACTION_MAX = 0x7f,
|
||||
} agent_action_t;
|
||||
*/
|
||||
/*
|
||||
typedef enum {
|
||||
|
||||
RAN_LTE_OAI= 0,
|
||||
|
||||
RAN_NAME_MAX = 0x7f,
|
||||
} ran_name_t;
|
||||
*/
|
||||
typedef uint8_t xid_t;
|
||||
typedef uint8_t mod_id_t; // module or enb id
|
||||
typedef uint8_t lcid_t;
|
||||
typedef int32_t err_code_t;
|
||||
|
||||
typedef struct {
|
||||
/* general info */
|
||||
|
||||
/* stats */
|
||||
|
||||
uint32_t total_rx_msg;
|
||||
uint32_t total_tx_msg;
|
||||
|
||||
uint32_t rx_msg[NUMBER_OF_eNB_MAX];
|
||||
uint32_t tx_msg[NUMBER_OF_eNB_MAX];
|
||||
|
||||
} proto_agent_info_t;
|
||||
|
||||
/* forward declaration */
|
||||
struct proto_agent_channel_s;
|
||||
|
||||
typedef struct proto_agent_instance_s {
|
||||
mod_id_t mod_id;
|
||||
proto_agent_info_t agent_info;
|
||||
struct proto_agent_channel_s *channel;
|
||||
pthread_t recv_thread;
|
||||
uint8_t exit;
|
||||
} proto_agent_instance_t;
|
||||
|
||||
#endif
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file enb_agent_handler.c
|
||||
* \brief enb agent tx and rx message handler
|
||||
* \author Navid Nikaein and Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
|
||||
#include "proto_agent_common.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "assertions.h"
|
||||
|
||||
proto_agent_message_decoded_callback proto_agent_messages_callback[][3] = {
|
||||
{proto_agent_hello, 0, 0}, /* agent hello */
|
||||
{proto_agent_echo_reply, 0, 0}, /* echo */
|
||||
{0, just_print, 0}, /* just print */
|
||||
{proto_agent_pdcp_data_req_process, proto_agent_pdcp_data_req_process, 0}, /* PDCP data REQ */
|
||||
{0, proto_agent_get_ack_result, 0}, /* get ACK result */
|
||||
{proto_agent_pdcp_data_ind_process, proto_agent_pdcp_data_ind_process, 0}, /* PDCP data IND */
|
||||
{0, just_print, 0}, /* just print */
|
||||
};
|
||||
|
||||
proto_agent_message_destruction_callback proto_message_destruction_callback[] = {
|
||||
proto_agent_destroy_hello,
|
||||
proto_agent_destroy_echo_request,
|
||||
proto_agent_destroy_echo_reply,
|
||||
proto_agent_destroy_pdcp_data_req,
|
||||
0,
|
||||
proto_agent_destroy_pdcp_data_ind,
|
||||
0,
|
||||
};
|
||||
|
||||
//static const char *proto_agent_direction2String[] = {
|
||||
// "", /* not_set */
|
||||
// "originating message", /* originating message */
|
||||
// "successfull outcome", /* successfull outcome */
|
||||
// "unsuccessfull outcome", /* unsuccessfull outcome */
|
||||
//};
|
||||
|
||||
|
||||
Protocol__FlexsplitMessage* proto_agent_handle_message (mod_id_t mod_id,
|
||||
uint8_t *data,
|
||||
int size){
|
||||
|
||||
Protocol__FlexsplitMessage *decoded_message = NULL;
|
||||
Protocol__FlexsplitMessage *reply_message = NULL;
|
||||
err_code_t err_code;
|
||||
DevAssert(data != NULL);
|
||||
|
||||
LOG_D(PROTO_AGENT, "Deserializing message with size %u \n", size);
|
||||
if (proto_agent_deserialize_message(data, (int) size, &decoded_message) < 0) {
|
||||
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_DECODING;
|
||||
goto error;
|
||||
}
|
||||
/* after deserialization, we don't need the original data memory anymore */
|
||||
free(data);
|
||||
Protocol__FspHeader *header = (Protocol__FspHeader*) decoded_message;
|
||||
if (header->has_type)
|
||||
{
|
||||
LOG_D(PROTO_AGENT, "Deserialized MSG type is %d and %u\n", decoded_message->msg_case, decoded_message->msg_dir);
|
||||
}
|
||||
|
||||
if ((decoded_message->msg_case > sizeof(proto_agent_messages_callback) / (3*sizeof(proto_agent_message_decoded_callback))) ||
|
||||
(decoded_message->msg_dir > PROTOCOL__FLEXSPLIT_DIRECTION__UNSUCCESSFUL_OUTCOME))
|
||||
{
|
||||
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_NOT_HANDLED;
|
||||
LOG_D(PROTO_AGENT,"Handling message: MSG NOT handled, going to error\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
err_code = ((*proto_agent_messages_callback[decoded_message->msg_case-1][decoded_message->msg_dir-1])(mod_id, (void *) decoded_message, &reply_message));
|
||||
|
||||
if ( err_code < 0 )
|
||||
{
|
||||
LOG_I(PROTO_AGENT, "decoded_message case : %d, direction : %d \n", decoded_message->msg_case-1, decoded_message->msg_dir-1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
protocol__flexsplit_message__free_unpacked(decoded_message, NULL);
|
||||
LOG_D(PROTO_AGENT,"Returning REPLY message after the callback\n");
|
||||
return reply_message;
|
||||
|
||||
error:
|
||||
LOG_E(PROTO_AGENT,"errno %d occured\n",err_code);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t *proto_agent_pack_message(Protocol__FlexsplitMessage *msg, int *size)
|
||||
{
|
||||
uint8_t *buffer;
|
||||
err_code_t err_code = PROTOCOL__FLEXSPLIT_ERR__NO_ERR;
|
||||
|
||||
if (proto_agent_serialize_message(msg, &buffer, size) < 0 ) {
|
||||
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENCODING;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (proto_message_destruction_callback[msg->msg_case-1])
|
||||
err_code = ((*proto_message_destruction_callback[msg->msg_case-1])(msg));
|
||||
|
||||
DevAssert(buffer !=NULL);
|
||||
|
||||
LOG_D(PROTO_AGENT,"Serialized the enb mac stats reply (size %d)\n", *size);
|
||||
return buffer;
|
||||
|
||||
error :
|
||||
LOG_E(PROTO_AGENT,"errno %d occured\n",err_code);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err_code_t proto_agent_destroy_flexsplit_message(Protocol__FlexsplitMessage *msg) {
|
||||
return ((*proto_message_destruction_callback[msg->msg_case-1])(msg));
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file enb_agent_net_comm.c
|
||||
* \brief enb agent network interface abstraction
|
||||
* \author Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#include "proto_agent_net_comm.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
proto_agent_channel_t *proto_channel[NUMBER_OF_eNB_MAX][ENB_AGENT_MAX];
|
||||
static proto_agent_channel_instance_t channel_instance;
|
||||
int proto_agent_channel_id = 0;
|
||||
|
||||
int proto_agent_register_channel(mod_id_t mod_id, proto_agent_channel_t *channel, proto_agent_id_t agent_id) {
|
||||
int i;
|
||||
|
||||
if (channel == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (agent_id == ENB_AGENT_MAX) {
|
||||
for (i = 0; i < ENB_AGENT_MAX; i++) {
|
||||
proto_channel[mod_id][i] = channel;
|
||||
}
|
||||
} else {
|
||||
proto_channel[mod_id][agent_id] = channel;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void proto_agent_unregister_channel(mod_id_t mod_id, proto_agent_id_t agent_id) {
|
||||
int i;
|
||||
|
||||
if (agent_id == ENB_AGENT_MAX) {
|
||||
for (i = 0; i < ENB_AGENT_MAX; i++) {
|
||||
proto_channel[mod_id][i] = NULL;
|
||||
}
|
||||
} else {
|
||||
proto_channel[mod_id][agent_id] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int proto_agent_create_channel(void *channel_info,
|
||||
int (*msg_send)(void *data, int size, int priority, void *channel_info),
|
||||
int (*msg_recv)(void **data, int *priority, void *channel_info),
|
||||
void (*release)(proto_agent_channel_t *channel)) {
|
||||
|
||||
int channel_id = ++proto_agent_channel_id;
|
||||
proto_agent_channel_t *channel = (proto_agent_channel_t *) malloc(sizeof(proto_agent_channel_t));
|
||||
channel->channel_id = channel_id;
|
||||
channel->channel_info = channel_info;
|
||||
channel->msg_send = msg_send;
|
||||
channel->msg_recv = msg_recv;
|
||||
channel->release = release;
|
||||
|
||||
/*element should be a real pointer*/
|
||||
RB_INSERT(proto_agent_channel_map, &channel_instance.proto_agent_head, channel);
|
||||
|
||||
LOG_D(PROTO_AGENT, "Created a new channel with id 0x%x\n", channel->channel_id);
|
||||
|
||||
return channel_id;
|
||||
}
|
||||
|
||||
int proto_agent_destroy_channel(int channel_id) {
|
||||
int i, j;
|
||||
|
||||
/*Check to see if channel exists*/
|
||||
struct proto_agent_channel_s *e = NULL;
|
||||
struct proto_agent_channel_s search;
|
||||
memset(&search, 0, sizeof(struct proto_agent_channel_s));
|
||||
|
||||
e = RB_FIND(proto_agent_channel_map, &channel_instance.proto_agent_head, &search);
|
||||
|
||||
if (e == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*Unregister the channel from all agents*/
|
||||
for (i = 0; i < NUMBER_OF_eNB_MAX; i++) {
|
||||
for (j = 0; j < ENB_AGENT_MAX; j++) {
|
||||
if (proto_channel[i][j] != NULL) {
|
||||
if (proto_channel[i][j]->channel_id == e->channel_id) {
|
||||
proto_channel[i][j] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Remove the channel from the tree and free memory*/
|
||||
RB_REMOVE(proto_agent_channel_map, &channel_instance.proto_agent_head, e);
|
||||
e->release(e);
|
||||
free(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
err_code_t proto_agent_init_channel_container(void) {
|
||||
int i, j;
|
||||
LOG_D(PROTO_AGENT, "init RB tree for channel container\n");
|
||||
|
||||
RB_INIT(&channel_instance.proto_agent_head);
|
||||
|
||||
for (i = 0; i < NUMBER_OF_eNB_MAX; i++) {
|
||||
for (j = 0; j < ENB_AGENT_MAX; j++) {
|
||||
proto_channel[i][j] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
RB_GENERATE(proto_agent_channel_map,proto_agent_channel_s, entry, proto_agent_compare_channel);
|
||||
|
||||
int proto_agent_compare_channel(struct proto_agent_channel_s *a, struct proto_agent_channel_s *b) {
|
||||
if (a->channel_id < b->channel_id) return -1;
|
||||
if (a->channel_id > b->channel_id) return 1;
|
||||
|
||||
// equal timers
|
||||
return 0;
|
||||
}
|
||||
|
||||
proto_agent_channel_t * proto_agent_get_channel(int channel_id) {
|
||||
|
||||
struct proto_agent_channel_s search;
|
||||
memset(&search, 0, sizeof(struct proto_agent_channel_s));
|
||||
search.channel_id = channel_id;
|
||||
|
||||
return RB_FIND(proto_agent_channel_map, &channel_instance.proto_agent_head, &search);
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file enb_agent_net_comm.h
|
||||
* \brief enb agent network interface abstraction
|
||||
* \autho Xenofon Foukas
|
||||
* \date 2016
|
||||
* \version 0.1
|
||||
*/
|
||||
#ifndef PROTO_AGENT_NET_COMM_H_
|
||||
#define PROTO_AGENT_NET_COMM_H_
|
||||
|
||||
#include "proto_agent_defs.h"
|
||||
|
||||
#include "tree.h"
|
||||
#define ENB_AGENT_MAX 9
|
||||
|
||||
/* forward declaration */
|
||||
struct proto_agent_async_channel_s;
|
||||
|
||||
/*Channel related information used for Tx/Rx of protocol messages*/
|
||||
typedef struct proto_agent_channel_s {
|
||||
RB_ENTRY(proto_agent_channel_s) entry;
|
||||
int channel_id;
|
||||
struct proto_agent_async_channel_s *channel_info;
|
||||
/*Callbacks for channel message Tx and Rx*/
|
||||
int (*msg_send)(void *data, int size, int priority, void *channel_info);
|
||||
int (*msg_recv)(void **data, int *priority, void *channel_info);
|
||||
void (*release)(struct proto_agent_channel_s *channel);
|
||||
} proto_agent_channel_t;
|
||||
|
||||
typedef struct proto_agent_channel_instance_s{
|
||||
RB_HEAD(proto_agent_channel_map, proto_agent_channel_s) proto_agent_head;
|
||||
} proto_agent_channel_instance_t;
|
||||
|
||||
|
||||
/*Register a channel to an agent. Use ENB_AGENT_MAX to register the
|
||||
*same channel to all agents*/
|
||||
int proto_agent_register_channel(mod_id_t mod_id, proto_agent_channel_t *channel, proto_agent_id_t agent_id);
|
||||
|
||||
/*Unregister the current channel of an agent. Use ENB_AGENT_MAX to unregister all channels*/
|
||||
void proto_agent_unregister_channel(mod_id_t mod_id, proto_agent_id_t agent_id);
|
||||
|
||||
/*Create a new channel. Returns the id of the new channel or negative number otherwise*/
|
||||
int proto_agent_create_channel(void *channel_info,
|
||||
int (*msg_send)(void *data, int size, int priority, void *channel_info),
|
||||
int (*msg_recv)(void **data, int *priority, void *channel_info),
|
||||
void (*release)(proto_agent_channel_t *channel));
|
||||
|
||||
/*Unregister a channel from all agents and destroy it. Returns 0 in case of success*/
|
||||
int proto_agent_destroy_channel(int channel_id);
|
||||
|
||||
/*Return an agent communication channel based on its id*/
|
||||
proto_agent_channel_t * proto_agent_get_channel(int channel_id);
|
||||
|
||||
/*Should be called before performing any channel operations*/
|
||||
err_code_t proto_agent_init_channel_container(void);
|
||||
|
||||
int proto_agent_compare_channel(struct proto_agent_channel_s *a, struct proto_agent_channel_s *b);
|
||||
|
||||
/* RB_PROTOTYPE is for .h files */
|
||||
RB_PROTOTYPE(proto_agent_channel_map, proto_agent_channel_s, entry, proto_agent_compare_channel);
|
||||
|
||||
#endif /*ENB_AGENT_COMM_H_*/
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
#ifndef __PROTO_AGENT_RLC_PRIMITIVES_H__
|
||||
#define __PROTO_AGENT_RLC_PRIMITIVES_H__
|
||||
|
||||
#include "RRC/LTE/rrc_defs.h"
|
||||
#include "LAYER2/PROTO_AGENT/proto_agent.h"
|
||||
// PROTO AGENT
|
||||
pthread_t async_server_thread;
|
||||
int async_server_thread_finalize (void);
|
||||
void async_server_thread_init (void);
|
||||
|
||||
pthread_mutex_t async_server_lock;
|
||||
pthread_cond_t async_server_notify;
|
||||
int async_server_shutdown;
|
||||
|
||||
#endif
|
||||
@@ -674,7 +674,7 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
|
||||
sdap_gnb_ul_header_handler(buf[0]); // Handler for the UL gNB SDAP Header
|
||||
}
|
||||
LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size-offset);
|
||||
itti_send_msg_to_task(TASK_VARIABLE, INSTANCE_DEFAULT, message_p);
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -728,7 +728,7 @@ rb_found:
|
||||
LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n",
|
||||
__func__, rb_id, size);
|
||||
extern instance_t CUuniqInstance;
|
||||
itti_send_msg_to_task(TASK_VARIABLE, CUuniqInstance, message_p);
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, CUuniqInstance, message_p);
|
||||
} else {
|
||||
|
||||
memblock = get_free_mem_block(size, __FUNCTION__);
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
|
||||
#include "openair2/F1AP/f1ap_du_rrc_message_transfer.h"
|
||||
|
||||
#include "openair2/LAYER2/PROTO_AGENT/proto_agent.h"
|
||||
|
||||
extern RAN_CONTEXT_t RC;
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -518,7 +516,7 @@ rb_found:
|
||||
req->pdusession_id=rb_id;
|
||||
LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size);
|
||||
extern instance_t DUuniqInstance;
|
||||
itti_send_msg_to_task(OCP_GTPV1_U, DUuniqInstance, msg);
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ rb_found:
|
||||
req->rnti=ue->rnti;
|
||||
req->rab_id=rb_id+4;
|
||||
LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size);
|
||||
itti_send_msg_to_task(OCP_GTPV1_U, DUuniqInstance, msg);
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +54,6 @@
|
||||
#include "common/config/config_userapi.h"
|
||||
#include "RRC_config_tools.h"
|
||||
#include "enb_paramdef.h"
|
||||
#include "proto_agent.h"
|
||||
|
||||
#include "m3ap_MCE.h"
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
* \warning
|
||||
*/
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "PHY/defs_nr_UE.h"
|
||||
#include "NR_IF_Module.h"
|
||||
#include "NR_MAC_UE/mac_proto.h"
|
||||
|
||||
@@ -9572,20 +9572,6 @@ void *rrc_enb_process_itti_msg(void *notUsed) {
|
||||
rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p, msg_name_p, instance);
|
||||
break;
|
||||
|
||||
case GTPV1U_ENB_DELETE_TUNNEL_RESP: {
|
||||
rrc_eNB_ue_context_t *ue = rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti);
|
||||
|
||||
if (ue != NULL
|
||||
&& ue->ue_context.ue_release_timer_rrc > 0
|
||||
&& (ue->ue_context.handover_info == NULL ||
|
||||
(ue->ue_context.handover_info->state != HO_RELEASE &&
|
||||
ue->ue_context.handover_info->state != HO_CANCEL))) {
|
||||
ue->ue_context.ue_release_timer_rrc = ue->ue_context.ue_release_timer_thres_rrc;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case S1AP_PATH_SWITCH_REQ_ACK:
|
||||
LOG_I(RRC, "[eNB %ld] received path switch ack %s\n", instance, msg_name_p);
|
||||
rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK(msg_p, msg_name_p, instance);
|
||||
|
||||
@@ -210,7 +210,7 @@ boolean_t gtpv_data_req_new (
|
||||
GTPV1U_ENB_END_MARKER_REQ(msg).offset = GTPU_HEADER_OVERHEAD_MAX;
|
||||
LOG_I(GTPU, "Send End Marker to GTPV1-U at frame %d and subframe %d \n", ctxt->frame,ctxt->subframe);
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, ENB_MODULE_ID_TO_INSTANCE(ctxt->module_id), msg);
|
||||
return NW_GTPV1U_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* target enb */
|
||||
@@ -225,7 +225,7 @@ boolean_t gtpv_data_req_new (
|
||||
gtpv1u_enb_delete_tunnel_req_t delete_tunnel_req;
|
||||
memset(&delete_tunnel_req, 0, sizeof(delete_tunnel_req));
|
||||
delete_tunnel_req.rnti = ctxt->rnti;
|
||||
gtpv1u_delete_x2u_tunnel(ctxt->module_id, &delete_tunnel_req, GTPV1U_TARGET_ENB);
|
||||
gtpv1u_delete_x2u_tunnel(ctxt->module_id, &delete_tunnel_req);
|
||||
return true;
|
||||
} else {
|
||||
/* data packet */
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "rrc_eNB_S1AP.h"
|
||||
#include "enb_config.h"
|
||||
#include "common/ran_context.h"
|
||||
#include "gtpv1u.h"
|
||||
|
||||
#include "s1ap_eNB.h"
|
||||
#include "s1ap_eNB_defs.h"
|
||||
|
||||
@@ -112,9 +112,6 @@ void apply_macrlc_config(gNB_RRC_INST *rrc,
|
||||
rrc_gNB_ue_context_t *const ue_context_pP,
|
||||
const protocol_ctxt_t *const ctxt_pP );
|
||||
|
||||
void apply_pdcp_config(rrc_gNB_ue_context_t *const ue_context_pP,
|
||||
const protocol_ctxt_t *const ctxt_pP );
|
||||
|
||||
void
|
||||
rrc_gNB_generate_RRCSetup(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#define RRC_GNB_C
|
||||
#define RRC_GNB_C
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "nr_rrc_config.h"
|
||||
#include "nr_rrc_defs.h"
|
||||
#include "nr_rrc_extern.h"
|
||||
@@ -103,27 +107,6 @@
|
||||
|
||||
extern RAN_CONTEXT_t RC;
|
||||
|
||||
extern boolean_t nr_rrc_pdcp_config_asn1_req(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
NR_SRB_ToAddModList_t *const srb2add_list,
|
||||
NR_DRB_ToAddModList_t *const drb2add_list,
|
||||
NR_DRB_ToReleaseList_t *const drb2release_list,
|
||||
const uint8_t security_modeP,
|
||||
uint8_t *const kRRCenc,
|
||||
uint8_t *const kRRCint,
|
||||
uint8_t *const kUPenc,
|
||||
uint8_t *const kUPint
|
||||
,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9
|
||||
,rb_id_t *const defaultDRB,
|
||||
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
|
||||
|
||||
extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP,
|
||||
const NR_SRB_ToAddModList_t * const srb2add_listP,
|
||||
const NR_DRB_ToAddModList_t * const drb2add_listP,
|
||||
const NR_DRB_ToReleaseList_t * const drb2release_listP,
|
||||
const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP,
|
||||
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
|
||||
|
||||
static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn);
|
||||
|
||||
mui_t rrc_gNB_mui = 0;
|
||||
@@ -2195,7 +2178,6 @@ rrc_gNB_decode_dcch(
|
||||
asn_dec_rval_t dec_rval;
|
||||
NR_UL_DCCH_Message_t *ul_dcch_msg = NULL;
|
||||
struct rrc_gNB_ue_context_s *ue_context_p = NULL;
|
||||
MessageDef *msg_delete_tunnels_p = NULL;
|
||||
uint8_t xid;
|
||||
|
||||
int i;
|
||||
@@ -2294,21 +2276,17 @@ rrc_gNB_decode_dcch(
|
||||
xid = ul_dcch_msg->message.choice.c1->choice.rrcReconfigurationComplete->rrc_TransactionIdentifier;
|
||||
ue_context_p->ue_context.pdu_session_release_command_flag = 0;
|
||||
//gtp tunnel delete
|
||||
msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_GNB, 0, GTPV1U_GNB_DELETE_TUNNEL_REQ);
|
||||
memset(>PV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
|
||||
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
|
||||
|
||||
gtpv1u_gnb_delete_tunnel_req_t req={0};
|
||||
for(i = 0; i < NB_RB_MAX; i++) {
|
||||
if(xid == ue_context_p->ue_context.pduSession[i].xid) {
|
||||
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).pdusession_id[GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_pdusession++] =
|
||||
req.pdusession_id[req.num_pdusession++] =
|
||||
ue_context_p->ue_context.gnb_gtp_psi[i];
|
||||
ue_context_p->ue_context.gnb_gtp_teid[i] = 0;
|
||||
memset(&ue_context_p->ue_context.gnb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.gnb_gtp_addrs[i]));
|
||||
ue_context_p->ue_context.gnb_gtp_psi[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p);
|
||||
gtpv1u_delete_ngu_tunnel(ctxt_pP->instance, &req);
|
||||
//NGAP_PDUSESSION_RELEASE_RESPONSE
|
||||
rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(ctxt_pP, ue_context_p, xid);
|
||||
} else if (ue_context_p->ue_context.established_pdu_sessions_flag != 1) {
|
||||
@@ -3641,9 +3619,6 @@ void *rrc_gnb_task(void *args_p) {
|
||||
rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(msg_p, msg_name_p, instance);
|
||||
break;
|
||||
|
||||
case GTPV1U_GNB_DELETE_TUNNEL_RESP:
|
||||
break;
|
||||
|
||||
/* Messages from gNB app */
|
||||
case NRRRC_CONFIGURATION_REQ:
|
||||
LOG_I(NR_RRC, "[gNB %ld] Received %s : %p\n", instance, msg_name_p,&NRRRC_CONFIGURATION_REQ(msg_p));
|
||||
@@ -3693,11 +3668,6 @@ void *rrc_gnb_task(void *args_p) {
|
||||
rrc_gNB_process_dc_overall_timeout(GNB_INSTANCE_TO_MODULE_ID(instance), &X2AP_ENDC_DC_OVERALL_TIMEOUT(msg_p));
|
||||
break;
|
||||
|
||||
/* Messages from GTP */
|
||||
case GTPV1U_ENB_DELETE_TUNNEL_RESP:
|
||||
/* nothing to do? */
|
||||
break;
|
||||
|
||||
case NGAP_UE_CONTEXT_RELEASE_REQ:
|
||||
rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name_p, instance);
|
||||
break;
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "rrc_eNB_S1AP.h"
|
||||
#include "gnb_config.h"
|
||||
#include "common/ran_context.h"
|
||||
#include "gtpv1u.h"
|
||||
|
||||
#include "asn1_conversions.h"
|
||||
#include "intertask_interface.h"
|
||||
@@ -44,6 +43,7 @@
|
||||
|
||||
#include "gtpv1u_eNB_task.h"
|
||||
#include "gtpv1u_gNB_task.h"
|
||||
#include <openair3/ocp-gtpu/gtp_itf.h>
|
||||
#include "RRC/LTE/rrc_eNB_GTPV1U.h"
|
||||
#include "RRC/NR/rrc_gNB_GTPV1U.h"
|
||||
|
||||
@@ -1395,7 +1395,6 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(
|
||||
protocol_ctxt_t ctxt;
|
||||
pdusession_release_t pdusession_release_params[NGAP_MAX_PDUSESSION];
|
||||
uint8_t nb_pdusessions_torelease;
|
||||
MessageDef *msg_delete_tunnels_p = NULL;
|
||||
uint8_t xid;
|
||||
int i, pdusession;
|
||||
uint8_t b_existed,is_existed;
|
||||
@@ -1473,20 +1472,18 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(
|
||||
} else {
|
||||
//gtp tunnel delete
|
||||
LOG_I(NR_RRC, "gtp tunnel delete \n");
|
||||
msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_GNB, 0, GTPV1U_GNB_DELETE_TUNNEL_REQ);
|
||||
memset(>PV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
|
||||
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
|
||||
gtpv1u_gnb_delete_tunnel_req_t req={0};
|
||||
req.rnti = ue_context_p->ue_context.rnti;
|
||||
|
||||
for(i = 0; i < NB_RB_MAX; i++) {
|
||||
if(xid == ue_context_p->ue_context.pduSession[i].xid) {
|
||||
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).pdusession_id[GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_pdusession++] = ue_context_p->ue_context.gnb_gtp_psi[i];
|
||||
req.pdusession_id[req.num_pdusession++] = ue_context_p->ue_context.gnb_gtp_psi[i];
|
||||
ue_context_p->ue_context.gnb_gtp_teid[i] = 0;
|
||||
memset(&ue_context_p->ue_context.gnb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.gnb_gtp_addrs[i]));
|
||||
ue_context_p->ue_context.gnb_gtp_psi[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p);
|
||||
gtpv1u_delete_ngu_tunnel(instance, &req);
|
||||
//NGAP_PDUSESSION_RELEASE_RESPONSE
|
||||
rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(&ctxt, ue_context_p, xid);
|
||||
LOG_I(NR_RRC, "Send PDU Session Release Response \n");
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*
|
||||
May 10, 2001
|
||||
Modified in June, 2001, to include the length non multiple of 8
|
||||
crc_byte.c
|
||||
Byte oriented implementation of CRC's
|
||||
|
||||
*/
|
||||
#include "rtos_header.h"
|
||||
#include "platform_types.h"
|
||||
|
||||
|
||||
/*ref 25.222 v4.0.0 , p12 */
|
||||
/* the highest degree is set by default */
|
||||
unsigned int poly24 = 0x80006100; // 1000 0000 0000 0000 0110 0001 D^24 + D^23 + D^6 + D^5 + D + 1
|
||||
unsigned int poly16 = 0x10210000; // 0001 0000 0010 0001 D^16 + D^12 + D^5 + 1
|
||||
unsigned int poly12 = 0x80F00000; // 1000 0000 1111 D^12 + D^11 + D^3 + D^2 + D + 1
|
||||
unsigned int poly8 = 0x9B000000; // 1001 1011 D^8 + D^7 + D^4 + D^3 + D + 1
|
||||
/*********************************************************
|
||||
|
||||
For initialization && verification purposes,
|
||||
bit by bit implementation with any polynomial
|
||||
|
||||
The first bit is in the MSB of each byte
|
||||
|
||||
*********************************************************/
|
||||
static unsigned int
|
||||
crcbit (unsigned char * inputptr, int octetlen, unsigned int poly)
|
||||
{
|
||||
unsigned int i, crc = 0, c;
|
||||
|
||||
while (octetlen-- > 0) {
|
||||
c = (*inputptr++) << 24;
|
||||
|
||||
for (i = 8; i != 0; i--) {
|
||||
if ((1 << 31) & (c ^ crc))
|
||||
crc = (crc << 1) ^ poly;
|
||||
else
|
||||
crc <<= 1;
|
||||
|
||||
c <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
|
||||
crc table initialization
|
||||
|
||||
*********************************************************/
|
||||
static unsigned int crc24Table[256];
|
||||
static unsigned short crc16Table[256];
|
||||
static unsigned short crc12Table[256];
|
||||
static unsigned char crc8Table[256];
|
||||
void
|
||||
crcTableInit ()
|
||||
{
|
||||
unsigned char c = 0;
|
||||
|
||||
do {
|
||||
crc24Table[c] = crcbit (&c, 1, poly24);
|
||||
crc16Table[c] = (unsigned short) (crcbit (&c, 1, poly16) >> 16);
|
||||
crc12Table[c] = (unsigned short) (crcbit (&c, 1, poly12) >> 16);
|
||||
crc8Table[c] = (unsigned char) (crcbit (&c, 1, poly8) >> 24);
|
||||
} while (++c);
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
|
||||
Byte by byte implementations,
|
||||
assuming initial byte is 0 padded (in MSB) if necessary
|
||||
|
||||
*********************************************************/
|
||||
unsigned int
|
||||
crc24 (unsigned char * inptr, int bitlen)
|
||||
{
|
||||
|
||||
int octetlen, resbit;
|
||||
unsigned int crc = 0;
|
||||
octetlen = bitlen / 8; /* Change in octets */
|
||||
resbit = (bitlen % 8);
|
||||
|
||||
while (octetlen-- > 0) {
|
||||
crc = (crc << 8) ^ crc24Table[(*inptr++) ^ (crc >> 24)];
|
||||
}
|
||||
|
||||
if (resbit > 0)
|
||||
crc = (crc << resbit) ^ crc24Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
crc16 (unsigned char * inptr, int bitlen)
|
||||
{
|
||||
int octetlen, resbit;
|
||||
unsigned int crc = 0;
|
||||
octetlen = bitlen / 8; /* Change in octets */
|
||||
resbit = (bitlen % 8);
|
||||
|
||||
while (octetlen-- > 0) {
|
||||
crc = (crc << 8) ^ (crc16Table[(*inptr++) ^ (crc >> 24)] << 16);
|
||||
}
|
||||
|
||||
if (resbit > 0)
|
||||
crc = (crc << resbit) ^ (crc16Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
crc12 (unsigned char * inptr, int bitlen)
|
||||
{
|
||||
int octetlen, resbit;
|
||||
unsigned int crc = 0;
|
||||
octetlen = bitlen / 8; /* Change in octets */
|
||||
resbit = (bitlen % 8);
|
||||
|
||||
while (octetlen-- > 0) {
|
||||
crc = (crc << 8) ^ (crc12Table[(*inptr++) ^ (crc >> 24)] << 16);
|
||||
}
|
||||
|
||||
if (resbit > 0)
|
||||
crc = (crc << resbit) ^ (crc12Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
crc8 (unsigned char * inptr, int bitlen)
|
||||
{
|
||||
int octetlen, resbit;
|
||||
unsigned int crc = 0;
|
||||
octetlen = bitlen / 8; /* Change in octets */
|
||||
resbit = (bitlen % 8);
|
||||
|
||||
while (octetlen-- > 0) {
|
||||
crc = crc8Table[(*inptr++) ^ (crc >> 24)] << 24;
|
||||
}
|
||||
|
||||
if (resbit > 0)
|
||||
crc = (crc << resbit) ^ (crc8Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 24);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
/**
|
||||
Test code
|
||||
********************************************************************/
|
||||
|
||||
/* #ifdef MAIN
|
||||
#include <stdio.h>
|
||||
main()
|
||||
{
|
||||
unsigned char test[] = "Thebigredfox";
|
||||
crcTableInit();
|
||||
printf("%x\n", crcbit(test, sizeof(test) - 1, poly24));
|
||||
printf("%x\n", crc24(test, (sizeof(test) - 1)*8));
|
||||
printf("%x\n", crcbit(test, sizeof(test) - 1, poly8));
|
||||
printf("%x\n", crc8(test, (sizeof(test) - 1)*8));
|
||||
}
|
||||
#endif */
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
random_proto_extern.h
|
||||
-------------------
|
||||
AUTHOR : Lionel GAUTHIER
|
||||
COMPANY : EURECOM
|
||||
EMAIL : Lionel.Gauthier@eurecom.fr
|
||||
***************************************************************************/
|
||||
extern int uniform (void);
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file taus.c
|
||||
* \brief random number generator per OAI component
|
||||
* \author Navid Nikaein
|
||||
* \date 2011 - 2014
|
||||
* \version 0.1
|
||||
* \email navid.nikaein@eurecom.fr
|
||||
* \warning
|
||||
* @ingroup util
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include "oml.h"
|
||||
|
||||
unsigned int s0[MAX_NUM_COMPS], s1[MAX_NUM_COMPS], s2[MAX_NUM_COMPS], b[MAX_NUM_COMPS], r[MAX_NUM_COMPS];
|
||||
|
||||
|
||||
|
||||
|
||||
inline unsigned int taus(unsigned int comp) {
|
||||
b[comp] = (((s0[comp] << 13) ^ s0[comp]) >> 19);
|
||||
s0[comp] = (((s0[comp] & 0xFFFFFFFE) << 12)^ b[comp]);
|
||||
b[comp] = (((s1[comp] << 2) ^ s1[comp]) >> 25);
|
||||
s1[comp] = (((s1[comp] & 0xFFFFFFF8) << 4)^ b[comp]);
|
||||
b[comp] = (((s2[comp] << 3) ^ s2[comp]) >> 11);
|
||||
s2[comp] = (((s2[comp] & 0xFFFFFFF0) << 17)^ b[comp]);
|
||||
r[comp] = s0[comp] ^ s1[comp] ^ s2[comp];
|
||||
return r[comp];
|
||||
}
|
||||
|
||||
/*void set_taus_seed(unsigned int seed_type) {
|
||||
unsigned int i; // i index of component
|
||||
|
||||
for (i=MIN_NUM_COMPS; i < MAX_NUM_COMPS ; i ++) {
|
||||
switch (seed_type) {
|
||||
case 0: // use rand func
|
||||
if (i == 0) srand(time(NULL));
|
||||
|
||||
s0[i] = ((unsigned int)rand());
|
||||
s1[i] = ((unsigned int)rand());
|
||||
s2[i] = ((unsigned int)rand());
|
||||
printf("Initial seeds use rand: s0[%u] = 0x%x, s1[%u] = 0x%x, s2[%u] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
|
||||
break;
|
||||
|
||||
case 1: // use rand with seed
|
||||
if (i == 0) srand(0x1e23d851);
|
||||
|
||||
s0[i] = ((unsigned int)rand());
|
||||
s1[i] = ((unsigned int)rand());
|
||||
s2[i] = ((unsigned int)rand());
|
||||
printf("Initial seeds use rand with seed : s0[%u] = 0x%x, s1[%u] = 0x%x, s2[%u] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
int get_rand (unsigned int comp) {
|
||||
if ((comp > MIN_NUM_COMPS) && (comp < MAX_NUM_COMPS))
|
||||
return r[comp];
|
||||
else {
|
||||
//LOG_E(RNG,"unknown component %d\n",comp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int dtaus(unsigned int comp, unsigned int a, unsigned b) {
|
||||
return (int) (((double)taus(comp)/(double)0xffffffff)* (double)(b-a) + (double)a);
|
||||
}
|
||||
/*
|
||||
#ifdef STANDALONE
|
||||
main() {
|
||||
|
||||
unsigned int i,randomg, randphy;
|
||||
|
||||
set_taus_seed(0);
|
||||
printf("dtaus %d \n",dtaus(PHY, 1000, 1000000));
|
||||
|
||||
do {//for (i=0;i<10;i++){
|
||||
randphy = taus(PHY);
|
||||
randomg = taus(OTG);
|
||||
i++;
|
||||
// printf("rand for OMG (%d,0x%x) PHY (%d,0x%x)\n",OMG, randomg, PHY, randphy);
|
||||
} while (randphy != randomg);
|
||||
printf("after %d run: get rand for (OMG 0x%x, PHY 0x%x)\n",i, get_rand(OTG), get_rand(PHY));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user