NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
LTENR_Association.c
1/************************************************************************************
2* Copyright (C) 2023 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14
15#pragma region HEADER_FILES
16#include "stdafx.h"
17#include "LTENR_PHY.h"
18#include "Stack.h"
19#include "NTN.h"
20#pragma endregion
21
22#pragma region ASSOCIATION_INIT
23void fn_NetSim_NTN_InitAssociation()
24{
25 for (NETSIM_ID d = 0; d < NETWORK->nDeviceCount; d++)
26 {
27 for (NETSIM_ID i = 0; i < DEVICE(d + 1)->nNumOfInterface; i++)
28 {
29 if (!isLTE_NRInterface(d + 1, i + 1))
30 continue;
31
32 ptrLTENR_PROTODATA data = LTENR_PROTODATA_GET(d + 1, i + 1);
33
34 if (!data || data->deviceType != LTENR_DEVICETYPE_NTN_GNB)
35 continue;
36
37 for (NETSIM_ID rd = 0; rd < NETWORK->nDeviceCount; rd++)
38 {
39 for (NETSIM_ID ri = 0; ri < DEVICE(rd + 1)->nNumOfInterface; ri++)
40 {
41 if (!isLTE_NRInterface(rd + 1, ri + 1))
42 continue;
43
44 ptrLTENR_PROTODATA rxdata = LTENR_PROTODATA_GET(rd + 1, ri + 1);
45
46 if (!rxdata)
47 continue;
48
49 if (rxdata->deviceType == LTENR_DEVICETYPE_UE)
50 {
51 LTENR_ASSOCIATEINFO_ADD(d + 1, i + 1,
52 rd + 1, ri + 1);
53 }
54
55 }
56 }
57 }
58 }
59 return;
60}
61
62void fn_NetSim_LTENR_InitAssociation()
63{
64 if (isNTNScenario())
65 return;
66
67 for (NETSIM_ID d = 0; d < NETWORK->nDeviceCount; d++)
68 {
69 for (NETSIM_ID i = 0; i < DEVICE(d + 1)->nNumOfInterface; i++)
70 {
71 if (!isLTE_NRInterface(d + 1, i + 1))
72 continue;
73
74 ptrLTENR_PROTODATA data = LTENR_PROTODATA_GET(d + 1, i + 1);
75
76 if (!data || data->deviceType != LTENR_DEVICETYPE_GNB)
77 continue;
78
79 NetSim_LINKS* link = DEVICE_PHYLAYER(d + 1, i + 1)->pstruNetSimLinks;
80
81 if (link->nLinkType == LinkType_P2P)
82 continue;
83
84 for (NETSIM_ID c = 0; c < link->puniDevList.pstrup2MP.nConnectedDeviceCount-1; c++)
85 {
86 LTENR_ASSOCIATEINFO_ADD(d + 1,
87 i + 1,
88 link->puniDevList.pstrup2MP.anDevIds[c],
89 link->puniDevList.pstrup2MP.anDevInterfaceIds[c]);
90 }
91 }
92 }
93}
94
95#pragma endregion
96
97#pragma region ASSOCIATION_CALLBACK
98#define MAX_ASSOCIATION_CALLBACK 100
99typedef void(*fnAssociationCallback)(NETSIM_ID, NETSIM_ID,
100 NETSIM_ID, NETSIM_ID,
101 bool);
102static fnAssociationCallback fnpAssociationCallback[MAX_ASSOCIATION_CALLBACK];
103static UINT associationCallbackCount = 0;
104
105void fn_NetSim_LTENR_RegisterCallBackForAssociation(void(*fnCallBack)(NETSIM_ID gnbId,
106 NETSIM_ID gnbIf,
107 NETSIM_ID ueId,
108 NETSIM_ID ueIf,
109 bool isAssociated))
110{
111 fnpAssociationCallback[associationCallbackCount] = fnCallBack;
112 associationCallbackCount++;
113}
114
115static void LTENR_ASSOCIATION_CALL_CALLBACK(NETSIM_ID gnbId,
116 NETSIM_ID gnbIf,
117 NETSIM_ID ueId,
118 NETSIM_ID ueIf,
119 bool isAssociated)
120{
121 UINT i;
122 for (i = 0; i < associationCallbackCount; i++)
123 fnpAssociationCallback[i](gnbId, gnbIf, ueId, ueIf, isAssociated);
124}
125
126#pragma endregion