-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrrc_ue_update_context.cpp
More file actions
68 lines (49 loc) · 1.99 KB
/
rrc_ue_update_context.cpp
File metadata and controls
68 lines (49 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include <linux/bpf.h>
#include "jbpf_srsran_contexts.h"
#include "rrc_ue_update_context.pb.h"
#include "../utils/misc_utils.h"
#define SEC(NAME) __attribute__((section(NAME), used))
#include "jbpf_defs.h"
#include "jbpf_helper.h"
#define MAX_NUM_UE (32)
jbpf_ringbuf_map(rrc_ue_update_context_output_map, rrc_ue_update_context, 256);
struct jbpf_load_map_def SEC("maps") output_map_tmp = {
.type = JBPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(rrc_ue_update_context),
.max_entries = 1,
};
//#define DEBUG_PRINT
extern "C" SEC("jbpf_srsran_generic")
uint64_t jbpf_main(void* state)
{
int zero_index=0;
struct jbpf_ran_generic_ctx *ctx = (jbpf_ran_generic_ctx *)state;
const jbpf_rrc_ctx_info& rrc_ctx = *reinterpret_cast<const jbpf_rrc_ctx_info*>(ctx->data);
// Ensure the object is within valid bounds
if (reinterpret_cast<const uint8_t*>(&rrc_ctx) + sizeof(jbpf_rrc_ctx_info) > reinterpret_cast<const uint8_t*>(ctx->data_end)) {
return JBPF_CODELET_FAILURE; // Out-of-bounds access
}
rrc_ue_update_context *out = (rrc_ue_update_context *)jbpf_map_lookup_elem(&output_map_tmp, &zero_index);
if (!out)
return JBPF_CODELET_FAILURE;
out->timestamp = jbpf_time_get_ns();
out->cucp_ue_index = rrc_ctx.cu_cp_ue_index;
out->old_cucp_ue_index = ctx->srs_meta_data1;
out->c_rnti = ctx->srs_meta_data2 >> 48;
out->pci = (ctx->srs_meta_data2 >> 32) & 0xFFFF;
out->tac = ctx->srs_meta_data2 & 0xFFFFFFFF;
out->plmn = ctx->srs_meta_data3 & 0xFFFFFFFF;
out->nci = ctx->srs_meta_data4;
int ret = jbpf_ringbuf_output(&rrc_ue_update_context_output_map, (void *)out, sizeof(rrc_ue_update_context));
jbpf_map_clear(&output_map_tmp);
if (ret < 0) {
#ifdef DEBUG_PRINT
jbpf_printf_debug("rrc_ue_update_context: Failure: jbpf_ringbuf_output\n");
#endif
return JBPF_CODELET_FAILURE;
}
return JBPF_CODELET_SUCCESS;
}