open5gs/src/pgw/pgw_handler.c

77 lines
2.3 KiB
C
Raw Normal View History

2017-03-30 15:15:13 +00:00
#define TRACE_MODULE _pgw_handler
#include "core_debug.h"
2017-04-06 14:29:20 +00:00
#include "gtp_types.h"
2017-04-04 02:26:59 +00:00
#include "pgw_event.h"
2017-04-06 14:29:20 +00:00
#include "pgw_context.h"
2017-03-30 15:15:13 +00:00
#include "pgw_path.h"
2017-04-04 02:26:59 +00:00
#include "pgw_handler.h"
2017-03-30 15:15:13 +00:00
2017-04-04 02:26:59 +00:00
void pgw_handle_create_session_request(
2017-03-30 15:15:13 +00:00
gtp_xact_t *xact, gtp_create_session_request_t *req)
{
2017-04-06 00:57:56 +00:00
status_t rv;
pkbuf_t *pkbuf;
2017-04-03 05:18:25 +00:00
gtp_message_t gtp_message;
2017-04-06 00:57:56 +00:00
c_uint8_t type = GTP_CREATE_SESSION_RESPONSE_TYPE;
2017-04-03 05:18:25 +00:00
gtp_create_session_response_t *rsp = &gtp_message.create_session_response;
2017-04-06 14:29:20 +00:00
gtp_cause_t cause;
gtp_f_teid_t *sgw_f_teid;
gtp_f_teid_t pgw_f_teid;
pgw_gtpc_t *gtpc = NULL;
d_assert(xact, return, "Null param");
d_assert(req, return, "Null param");
if (req->sender_f_teid_for_control_plane.presence == 0)
{
d_error("No Sender F-TEID for control plance");
return;
}
sgw_f_teid = req->sender_f_teid_for_control_plane.data;
if (!(sgw_f_teid->ipv4 == 1 && sgw_f_teid->ipv6 == 0 &&
sgw_f_teid->interface_type == GTP_F_TEID_S5_S8_SGW_GTP_C))
{
d_error("Invalid Parameter(ipv4:%d,ipv6:%d,type:%d",
sgw_f_teid->ipv4, sgw_f_teid->ipv6,
sgw_f_teid->interface_type);
return;
}
gtpc = pgw_gtpc_add();
d_assert(gtpc, return, "gtpc_add failed");
gtpc->sgw_teid = ntohl(sgw_f_teid->teid);
gtpc->sgw_ipv4 = sgw_f_teid->ipv4_addr;
2017-04-03 05:18:25 +00:00
memset(&gtp_message, 0, sizeof(gtp_message_t));
2017-04-06 14:29:20 +00:00
memset(&cause, 0, sizeof(cause));
cause.cause_value = GTP_CAUSE_REQUEST_ACCEPTED;
2017-04-03 05:18:25 +00:00
rsp->cause.presence = 1;
2017-04-06 14:29:20 +00:00
rsp->cause.len = sizeof(cause);
rsp->cause.data = &cause;
memset(&pgw_f_teid, 0, sizeof(gtp_f_teid_t));
pgw_f_teid.ipv4 = 1;
pgw_f_teid.interface_type = GTP_F_TEID_S5_S8_PGW_GTP_C;
pgw_f_teid.ipv4_addr = pgw_self()->s5c_addr;
pgw_f_teid.teid = htonl(gtpc->teid);
rsp->pgw_s5_s8__s2a_s2b_f_teid_for_pmip_based_interface_or_for_gtp_based_control_plane_interface.
presence = 1;
rsp->pgw_s5_s8__s2a_s2b_f_teid_for_pmip_based_interface_or_for_gtp_based_control_plane_interface.
data = &pgw_f_teid;
rsp->pgw_s5_s8__s2a_s2b_f_teid_for_pmip_based_interface_or_for_gtp_based_control_plane_interface.
len = GTP_F_TEID_IPV4_LEN;
2017-04-03 05:18:25 +00:00
2017-04-06 00:57:56 +00:00
rv = gtp_build_msg(&pkbuf, type, &gtp_message);
d_assert(rv == CORE_OK, return, "gtp build failed");
2017-04-06 14:29:20 +00:00
pgw_s5c_send_to_sgw(xact, type, gtpc->sgw_teid, pkbuf);
2017-03-30 15:15:13 +00:00
}