-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths10-build.c
More file actions
166 lines (135 loc) · 5.92 KB
/
s10-build.c
File metadata and controls
166 lines (135 loc) · 5.92 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include "s10-build.h"
/* Function to build Context Request */
ogs_pkbuf_t *s10_build_context_request(const char *ue_id, const char *serving_mme_ip, const uint32_t mme_teid) {
// Allocate memory for the message buffer
ogs_pkbuf_t *pkbuf = ogs_pkbuf_alloc(S10_CONTEXT_REQUEST_MAX_LEN);
if (!pkbuf) {
return NULL;
}
// Initialize message headers
set_diameter_header(pkbuf, GTPC_CONTEXT_REQUEST, 0, 0, 0, 0);
// Add IEs
add_diameter_ie(pkbuf, IMSI, ue_id, strlen(ue_id));
add_diameter_ie(pkbuf, SERVING_MME_IP, serving_mme_ip, strlen(serving_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &mme_teid, sizeof(mme_teid));
// Finalize the message
finalize_diameter_message(pkbuf);
return pkbuf;
}
/* Function to build Context Response */
ogs_pkbuf_t *s10_build_context_response(const char *target_mme_ip, const uint32_t target_mme_teid, const bool forward_relocation, const bool relocation_accepted) {
// Allocate memory for the message buffer
ogs_pkbuf_t *pkbuf = ogs_pkbuf_alloc(S10_CONTEXT_RESPONSE_MAX_LEN);
if (!pkbuf) {
return NULL;
}
// Initialize message headers
set_diameter_header(pkbuf, GTPC_CONTEXT_RESPONSE, 0, 0, 0, 0);
// Add IEs
if (forward_relocation) {
if (relocation_accepted) {
add_diameter_ie(pkbuf, FTEID, &target_mme_teid, sizeof(target_mme_teid));
} else {
add_diameter_ie(pkbuf, REDIRECT_HOST, target_mme_ip, strlen(target_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &target_mme_teid, sizeof(target_mme_teid));
}
} else {
if (relocation_accepted) {
add_diameter_ie(pkbuf, REDIRECT_HOST, target_mme_ip, strlen(target_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &target_mme_teid, sizeof(target_mme_teid));
} else {
add_diameter_ie(pkbuf, ERROR_CODE, &rejection_reason, sizeof(rejection_reason));
}
}
// Finalize the message
finalize_diameter_message(pkbuf);
return pkbuf;
}
/* Function to build Context Acknowledge */
ogs_pkbuf_t *s10_build_context_acknowledge(const char *target_mme_ip, const uint32_t target_mme_teid) {
// Allocate memory for the message buffer
ogs_pkbuf_t *pkbuf = ogs_pkbuf_alloc(S10_CONTEXT_ACKNOWLEDGE_MAX_LEN);
if (!pkbuf) {
return NULL;
}
// Initialize message headers
set_diameter_header(pkbuf, GTPC_CONTEXT_ACKNOWLEDGE, 0, 0, 0, 0);
// Add IEs
add_diameter_ie(pkbuf, REDIRECT_HOST, target_mme_ip, strlen(target_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &target_mme_teid, sizeof(target_mme_teid));
// Finalize the message
finalize_diameter_message(pkbuf);
return pkbuf;
}
/* Function to build Forward Relocation Request */
ogs_pkbuf_t *s10_build_forward_relocation_request(const char *ue_id, const char *serving_mme_ip, const uint32_t serving_mme_teid, const char *target_mme_ip, const uint32_t target_mme_teid) {
// Allocate memory for the message buffer
ogs_pkbuf_t *pkbuf = ogs_pkbuf_alloc(S10_FORWARD_RELOCATION_REQUEST_MAX_LEN);
if (!pkbuf) {
return NULL;
}
// Initialize message headers
set_diameter_header(pkbuf, GTPC_FORWARD_RELOCATION_REQUEST, 0, 0, 0, 0);
// Add IEs
add_diameter_ie(pkbuf, IMSI, ue_id, strlen(ue_id));
add_diameter_ie(pkbuf, SERVING_MME_IP, serving_mme_ip, strlen(serving_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &serving_mme_teid, sizeof(serving_mme_teid));
add_diameter_ie(pkbuf, TARGET_MME_IP, target_mme_ip, strlen(target_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &target_mme_teid, sizeof(target_mme_teid));
// Finalize the message
finalize_diameter_message(pkbuf);
S10-interface, [12/11/23 3:44 PM]
return pkbuf;
}
/* Function to build Forward Relocation Response */
ogs_pkbuf_t *s10_build_forward_relocation_response(const char *target_mme_ip, const uint32_t target_mme_teid, const bool relocation_accepted) {
// Allocate memory for the message buffer
ogs_pkbuf_t *pkbuf = ogs_pkbuf_alloc(S10_FORWARD_RELOCATION_RESPONSE_MAX_LEN);
if (!pkbuf) {
return NULL;
}
// Initialize message headers
set_diameter_header(pkbuf, GTPC_FORWARD_RELOCATION_RESPONSE, 0, 0, 0, 0);
// Add IEs
if (relocation_accepted) {
add_diameter_ie(pkbuf, FTEID, &target_mme_teid, sizeof(target_mme_teid));
} else {
add_diameter_ie(pkbuf, ERROR_CODE, &rejection_reason, sizeof(rejection_reason));
}
// Finalize the message
finalize_diameter_message(pkbuf);
return pkbuf;
}
/* Function to build Forward Relocation Complete Notification */
ogs_pkbuf_t *s10_build_forward_relocation_complete_notification(const char *target_mme_ip, const uint32_t target_mme_teid) {
// Allocate memory for the message buffer
ogs_pkbuf_t *pkbuf = ogs_pkbuf_alloc(S10_FORWARD_RELOCATION_COMPLETE_NOTIFICATION_MAX_LEN);
if (!pkbuf) {
return NULL;
}
// Initialize message headers
set_diameter_header(pkbuf, GTPC_FORWARD_RELOCATION_COMPLETE_NOTIFICATION, 0, 0, 0, 0);
// Add IEs
add_diameter_ie(pkbuf, REDIRECT_HOST, target_mme_ip, strlen(target_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &target_mme_teid, sizeof(target_mme_teid));
// Finalize the message
finalize_diameter_message(pkbuf);
return pkbuf;
}
/* Function to build Forward Relocation Complete Acknowledge */
ogs_pkbuf_t *s10_build_forward_relocation_complete_acknowledge(const char *serving_mme_ip, const uint32_t serving_mme_teid) {
// Allocate memory for the message buffer
ogs_pkbuf_t *pkbuf = ogs_pkbuf_alloc(S10_FORWARD_RELOCATION_COMPLETE_ACKNOWLEDGE_MAX_LEN);
if (!pkbuf) {
return NULL;
}
// Initialize message headers
set_diameter_header(pkbuf, GTPC_FORWARD_RELOCATION_COMPLETE_ACKNOWLEDGE, 0, 0, 0, 0);
// Add IEs
add_diameter_ie(pkbuf, SERVING_MME_IP, serving_mme_ip, strlen(serving_mme_ip));
add_diameter_ie(pkbuf, MMETEID, &serving_mme_teid, sizeof(serving_mme_teid));
// Finalize the message
finalize_diameter_message(pkbuf);
return pkbuf;
}
//hello