File size: 4,511 Bytes
258fb37 |
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 |
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "sxa-build.h"
ogs_pkbuf_t *sgwu_sxa_build_session_establishment_response(uint8_t type,
sgwu_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr)
{
ogs_pfcp_message_t *pfcp_message = NULL;
ogs_pfcp_session_establishment_response_t *rsp = NULL;
ogs_pkbuf_t *pkbuf = NULL;
int i = 0, j = 0, rv;
ogs_pfcp_node_id_t node_id;
ogs_pfcp_f_seid_t f_seid;
int len = 0;
ogs_debug("Session Establishment Response");
pfcp_message = ogs_calloc(1, sizeof(*pfcp_message));
if (!pfcp_message) {
ogs_error("ogs_calloc() failed");
return NULL;
}
rsp = &pfcp_message->pfcp_session_establishment_response;
/* Node ID */
rv = ogs_pfcp_sockaddr_to_node_id(&node_id, &len);
if (rv != OGS_OK) {
ogs_error("ogs_pfcp_sockaddr_to_node_id() failed");
ogs_free(pfcp_message);
return NULL;
}
rsp->node_id.presence = 1;
rsp->node_id.data = &node_id;
rsp->node_id.len = len;
/* Cause */
rsp->cause.presence = 1;
rsp->cause.u8 = OGS_PFCP_CAUSE_REQUEST_ACCEPTED;
/* F-SEID */
rv = ogs_pfcp_sockaddr_to_f_seid(&f_seid, &len);
if (rv != OGS_OK) {
ogs_error("ogs_pfcp_sockaddr_to_f_seid() failed");
ogs_free(pfcp_message);
return NULL;
}
f_seid.seid = htobe64(sess->sgwu_sxa_seid);
rsp->up_f_seid.presence = 1;
rsp->up_f_seid.data = &f_seid;
rsp->up_f_seid.len = len;
ogs_pfcp_pdrbuf_init();
/* Created PDR */
for (i = 0, j = 0; i < num_of_created_pdr; i++) {
bool pdr_presence = ogs_pfcp_build_created_pdr(
&rsp->created_pdr[j], i, created_pdr[i]);
if (pdr_presence == true) j++;
}
pfcp_message->h.type = type;
pkbuf = ogs_pfcp_build_msg(pfcp_message);
ogs_expect(pkbuf);
ogs_pfcp_pdrbuf_clear();
ogs_free(pfcp_message);
return pkbuf;
}
ogs_pkbuf_t *sgwu_sxa_build_session_modification_response(uint8_t type,
sgwu_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr)
{
ogs_pfcp_message_t *pfcp_message = NULL;
ogs_pfcp_session_modification_response_t *rsp = NULL;
ogs_pkbuf_t *pkbuf = NULL;
int i = 0, j = 0;
ogs_debug("Session Modification Response");
pfcp_message = ogs_calloc(1, sizeof(*pfcp_message));
if (!pfcp_message) {
ogs_error("ogs_calloc() failed");
return NULL;
}
rsp = &pfcp_message->pfcp_session_modification_response;
/* Cause */
rsp->cause.presence = 1;
rsp->cause.u8 = OGS_PFCP_CAUSE_REQUEST_ACCEPTED;
ogs_pfcp_pdrbuf_init();
/* Created PDR */
for (i = 0, j = 0; i < num_of_created_pdr; i++) {
bool pdr_presence = ogs_pfcp_build_created_pdr(
&rsp->created_pdr[i], i, created_pdr[i]);
if (pdr_presence == true) j++;
}
pfcp_message->h.type = type;
pkbuf = ogs_pfcp_build_msg(pfcp_message);
ogs_expect(pkbuf);
ogs_pfcp_pdrbuf_clear();
ogs_free(pfcp_message);
return pkbuf;
}
ogs_pkbuf_t *sgwu_sxa_build_session_deletion_response(uint8_t type,
sgwu_sess_t *sess)
{
ogs_pfcp_message_t *pfcp_message = NULL;
ogs_pfcp_session_deletion_response_t *rsp = NULL;
ogs_pkbuf_t *pkbuf = NULL;
ogs_debug("Session Deletion Response");
pfcp_message = ogs_calloc(1, sizeof(*pfcp_message));
if (!pfcp_message) {
ogs_error("ogs_calloc() failed");
return NULL;
}
rsp = &pfcp_message->pfcp_session_deletion_response;
/* Cause */
rsp->cause.presence = 1;
rsp->cause.u8 = OGS_PFCP_CAUSE_REQUEST_ACCEPTED;
pfcp_message->h.type = type;
pkbuf = ogs_pfcp_build_msg(pfcp_message);
ogs_expect(pkbuf);
ogs_free(pfcp_message);
return pkbuf;
}
|