-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcucp_uemgr_ue_update.cpp
More file actions
executable file
·73 lines (55 loc) · 2.02 KB
/
cucp_uemgr_ue_update.cpp
File metadata and controls
executable file
·73 lines (55 loc) · 2.02 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
69
70
71
72
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
// This codelet simply forwards the message.
//
#include <linux/bpf.h>
#include "jbpf_srsran_contexts.h"
#include "ue_contexts.pb.h"
#include "../utils/misc_utils.h"
#include "../utils/hashmap_utils.h"
#include "jbpf_defs.h"
#include "jbpf_helper.h"
// output map for stats
jbpf_ringbuf_map(output_map, cucp_ue_ctx_update, 256);
// map to store data before sending to output_map
struct jbpf_load_map_def SEC("maps") output_tmp_map = {
.type = JBPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(cucp_ue_ctx_update),
.max_entries = 1,
};
//#define DEBUG_PRINT
extern "C" SEC("jbpf_srsran_generic")
uint64_t jbpf_main(void* state)
{
struct jbpf_ran_generic_ctx *ctx = (jbpf_ran_generic_ctx *)state;
const jbpf_cucp_uemgr_ctx_info& cucp_ctx = *reinterpret_cast<const jbpf_cucp_uemgr_ctx_info*>(ctx->data);
// Ensure the object is within valid bounds
if (reinterpret_cast<const uint8_t*>(&cucp_ctx) + sizeof(jbpf_cucp_uemgr_ctx_info) > reinterpret_cast<const uint8_t*>(ctx->data_end)) {
return JBPF_CODELET_FAILURE; // Out-of-bounds access
}
// get the output map
int zero_index=0;
cucp_ue_ctx_update *out = (cucp_ue_ctx_update *)jbpf_map_lookup_elem(&output_tmp_map, &zero_index);
if (!out) {
return JBPF_CODELET_FAILURE;
}
uint32_t pci = (uint32_t) (ctx->srs_meta_data1 & 0xFFFF);
uint32_t crnti = (uint32_t) (ctx->srs_meta_data2 & 0xFFFF);
// populate the output
uint64_t timestamp = jbpf_time_get_ns();
out->timestamp = timestamp;
out->cucp_ue_index = cucp_ctx.cu_cp_ue_index;
out->plmn = cucp_ctx.plmn;
out->pci = pci;
out->crnti = crnti;
int ret = jbpf_ringbuf_output(&output_map, (void *)out, sizeof(cucp_ue_ctx_update));
if (ret < 0) {
#ifdef DEBUG_PRINT
jbpf_printf_debug("cucp_ue_ctx_update: Failure: jbpf_ringbuf_output\n");
#endif
return JBPF_CODELET_FAILURE;
}
return JBPF_CODELET_SUCCESS;
}