Commit f081ff5a authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Remove unecessary files

parent 9f793608
......@@ -30,7 +30,6 @@
#define FILE_3GPP_29_274_SEEN
#include "common_root_types.h"
#include "3gpp_24.008.h"
#include "3gpp_commons.h"
#include "conversions.hpp"
#include "logger.hpp" // for fmt::format in spdlog
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_29.281.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_29_281_SEEN
#define FILE_3GPP_29_281_SEEN
#include "3gpp_29.274.h"
#include "3gpp_commons.h"
#include "common_root_types.h"
#include "logger.hpp" // for fmt::format in spdlog
#include <arpa/inet.h>
#include <stdint.h>
#include <string>
#include <vector>
// 8.2 Recovery
// 8.3 Tunnel Endpoint Identifier Data I
typedef struct tunnel_endpoint_identifier_data_i_s {
uint32_t tunnel_endpoint_identifier_data_i;
} tunnel_endpoint_identifier_data_i_t;
// 8.4 GTP-U Peer Address
typedef struct gtp_u_peer_address_s {
// may use variant if can stay with C++17
struct in_addr ipv4_address;
struct in6_addr ipv6_address;
bool is_v4;
} gtp_u_peer_address_t;
// 8.5 Extension Header Type List
typedef struct extension_header_type_list_s {
uint8_t length;
std::vector<uint8_t> extension_types_list;
} extension_header_type_list_t;
// 8.6 Private Extension defined in 3gpp_29.274.h
// typedef struct private_extension_s {
// uint16_t extension_identifier;
// std::string extension_value;
//} private_extension_t;
#endif /* FILE_3GPP_29_281_SEEN */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_commons.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_COMMONS_SEEN
#define FILE_3GPP_COMMONS_SEEN
#include <stdint.h>
// 8.2 Recovery
typedef struct recovery_s {
uint8_t restart_counter;
} recovery_t;
#endif /* FILE_3GPP_COMMONS_SEEN */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_33.401.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include "security_types.h"
#ifndef FILE_3GPP_33_401_SEEN
#define FILE_3GPP_33_401_SEEN
//------------------------------------------------------------------------------
// 5.1.3.2 Algorithm Identifier Values
//------------------------------------------------------------------------------
#define EEA0_ALG_ID 0b000
#define EEA1_128_ALG_ID 0b001
#define EEA2_128_ALG_ID 0b010
//------------------------------------------------------------------------------
// 5.1.4.2 Algorithm Identifier Values
//------------------------------------------------------------------------------
#define EIA0_ALG_ID 0b000
#define EIA1_128_ALG_ID 0b001
#define EIA2_128_ALG_ID 0b010
//------------------------------------------------------------------------------
// 6.1.2 Distribution of authentication data from HSS to serving network
//------------------------------------------------------------------------------
/* NOTE 2: It is recommended that the MME fetch only one EPS authentication
* vector at a time as the need to perform AKA runs has been reduced in EPS
* through the use of a more elaborate key hierarchy. In particular, service
* requests can be authenticated using a stored K ASME without the need to
* perform AKA. Furthermore, the sequence number management schemes in
* TS 33.102, Annex C [4], designed to avoid re-synchronisation problems caused
* by interleaving use of batches of authentication vectors, are only optional.
* Re-synchronisation problems in EPS can be avoided, independently of the
* sequence number management scheme, by immediately using an authentication
* vector retrieved from the HSS in an authentication procedure between UE and
* MME.
*/
#define MAX_EPS_AUTH_VECTORS 1
//----------------------------
typedef struct mm_ue_eps_authentication_quadruplet_s {
uint8_t rand[16];
uint8_t xres_len;
uint8_t xres[XRES_LENGTH_MAX];
uint8_t autn_len;
uint8_t autn[AUTN_LENGTH_OCTETS];
uint8_t k_asme[32];
} mm_ue_eps_authentication_quadruplet_t;
typedef struct mm_ue_eps_authentication_quintuplet_s {
uint8_t rand[16];
uint8_t xres_len;
uint8_t xres[XRES_LENGTH_MAX];
uint8_t ck[16];
uint8_t ik[16];
uint8_t autn_len;
uint8_t autn[AUTN_LENGTH_OCTETS];
} mm_ue_eps_authentication_quintuplet_t;
#endif /* FILE_3GPP_33_401_SEEN */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_36.401.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_36_401_SEEN
#define FILE_3GPP_36_401_SEEN
//------------------------------------------------------------------------------
// 6.2 E-UTRAN Identifiers
//------------------------------------------------------------------------------
typedef uint32_t enb_ue_s1ap_id_t; /*!< \brief An eNB UE S1AP ID shall be
allocated so as to uniquely identify the UE over the S1 interface within an
eNB. When an MME receives an eNB UE S1AP ID it shall store it for the duration
of the UE-associated logical S1-connection for this UE. Once known to an MME
this IE is included in all UE associated S1-AP signalling. The eNB UE S1AP ID
shall be unique within the eNB logical node. */
typedef uint32_t mme_ue_s1ap_id_t; /*!< \brief A MME UE S1AP ID shall be
allocated so as to uniquely identify the UE over the S1 interface within the
MME. When an eNB receives MME UE S1AP ID it shall store it for the duration of
the UE-associated logical S1-connection for this UE. Once known to an eNB this
IE is included in all UE associated S1-AP signalling.
The MME UE S1AP ID shall be unique within the MME logical node.*/
#endif /* FILE_3GPP_36_401_SEEN */
......@@ -53,14 +53,6 @@
#define AUTN_LENGTH_BITS (128)
#define AUTN_LENGTH_OCTETS (AUTN_LENGTH_BITS / 8)
/* Some methods to convert a string to an int64_t */
/*
#define STRING_TO_64BITS(sTRING, cONTAINER) \
sscanf(sTRING, "%" SCN64, cONTAINER)
#define STRING_TO_U64BITS(sTRING, cONTAINER) \
sscanf(sTRING, "%" SCNu64, cONTAINER)
*/
/* Converts a string to 128 bits gmplib integer holder */
#define STRING_TO_XBITS(sTRING, lENGTH, cONTAINER, rET) \
do { \
......
......@@ -30,7 +30,6 @@
#define FILE_3GPP_CONVERSIONS_HPP_SEEN
#include "3gpp_29.274.h"
#include "3gpp_29.244.h"
#include "3gpp_29.281.h"
#include "3gpp_24.501.h"
#include "endpoint.hpp"
#include "3gpp_24.008.h"
......
......@@ -27,13 +27,11 @@ include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
set(CN_UTILS_SRC STATIC
${CMAKE_CURRENT_SOURCE_DIR}/3gpp_conversions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/async_shell_cmd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/conversions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/epc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_gateway_netlink.cpp
${CMAKE_CURRENT_SOURCE_DIR}/if.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pid_file.cpp
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
......@@ -41,7 +39,4 @@ set(CN_UTILS_SRC STATIC
${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp
)
add_library(CN_UTILS ${CN_UTILS_SRC})
add_library(CN_UTILS ${CN_UTILS_SRC})
\ No newline at end of file
/* From https://gist.github.com/javiermon/6272065#file-gateway_netlink-c */
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <net/if.h>
#include <fstream> // std::ifstream
#include <string>
#include "common_defs.h"
#include "get_gateway_netlink.hpp"
#include "logger.hpp"
#define BUFFER_SIZE 4096
using namespace std;
//------------------------------------------------------------------------------
bool util::get_iface_l2_addr(const std::string& iface, std::string& mac) {
std::string mac_address_path =
fmt::format("/sys/class/net/{}/address", iface);
std::ifstream mac_address_in(
mac_address_path.c_str(), ios_base::in | ios_base::binary);
char wb[32];
mac_address_in.get(wb, 32);
mac.assign(wb);
Logger::pfcp_switch().error(
"Found IFace %s MAC %s", iface.c_str(), mac.c_str());
mac.erase(std::remove(mac.begin(), mac.end(), ':'), mac.end());
return true;
// ifr = {};
// strncpy ((char *) ifr.ifr_name, ifname, IFNAMSIZ);
// if (ioctl(sd, SIOCGIFFLAGS, &ifr) == 0) {
// if (! (ifr.ifr_flags & IFF_LOOPBACK)) { // don't count loopback
// if (ioctl(sd, SIOCGIFHWADDR, &ifr) == 0) {
// memcpy(pdn_mac_address, ifr.ifr_hwaddr.sa_data, 6);
// }
// }
// }
}
//------------------------------------------------------------------------------
bool util::get_gateway_and_iface(std::string& gw, std::string& iface) {
int received_bytes = 0, msg_len = 0, route_attribute_len = 0;
int sock = -1, msgseq = 0;
struct nlmsghdr *nlh, *nlmsg;
struct rtmsg* route_entry;
// This struct contain route attributes (route type)
struct rtattr* route_attribute;
char gateway_address[INET_ADDRSTRLEN], interface[IF_NAMESIZE + 1];
char msgbuf[BUFFER_SIZE], buffer[BUFFER_SIZE];
char* ptr = buffer;
struct timeval tv;
int rv = RETURNok;
if ((sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0) {
perror("socket failed");
return false;
}
memset(msgbuf, 0, sizeof(msgbuf));
memset(gateway_address, 0, sizeof(gateway_address));
memset(interface, 0, sizeof(interface));
memset(buffer, 0, sizeof(buffer));
/* point the header and the msg structure pointers into the buffer */
nlmsg = (struct nlmsghdr*) msgbuf;
/* Fill in the nlmsg header*/
nlmsg->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
nlmsg->nlmsg_type =
RTM_GETROUTE; // Get the routes from kernel routing table .
nlmsg->nlmsg_flags =
NLM_F_DUMP | NLM_F_REQUEST; // The message is a request for dump.
nlmsg->nlmsg_seq = msgseq++; // Sequence of the message packet.
nlmsg->nlmsg_pid = getpid(); // PID of process sending the request.
/* 1 Sec Timeout to avoid stall */
tv.tv_sec = 1;
setsockopt(
sock, SOL_SOCKET, SO_RCVTIMEO, (struct timeval*) &tv,
sizeof(struct timeval));
/* send msg */
if (send(sock, nlmsg, nlmsg->nlmsg_len, 0) < 0) {
perror("send failed");
return false;
}
/* receive response */
do {
received_bytes = recv(sock, ptr, sizeof(buffer) - msg_len, 0);
if (received_bytes < 0) {
perror("Error in recv");
return false;
}
nlh = (struct nlmsghdr*) ptr;
/* Check if the header is valid */
if ((NLMSG_OK(nlmsg, received_bytes) == 0) ||
(nlmsg->nlmsg_type == NLMSG_ERROR)) {
perror("Error in received packet");
return false;
}
/* If we received all data break */
if (nlh->nlmsg_type == NLMSG_DONE)
break;
else {
ptr += received_bytes;
msg_len += received_bytes;
}
/* Break if its not a multi part message */
if ((nlmsg->nlmsg_flags & NLM_F_MULTI) == 0) break;
} while ((nlmsg->nlmsg_seq != msgseq) || (nlmsg->nlmsg_pid != getpid()));
/* parse response */
for (; NLMSG_OK(nlh, received_bytes); nlh = NLMSG_NEXT(nlh, received_bytes)) {
/* Get the route data */
route_entry = (struct rtmsg*) NLMSG_DATA(nlh);
/* We are just interested in main routing table */
if (route_entry->rtm_table != RT_TABLE_MAIN) continue;
route_attribute = (struct rtattr*) RTM_RTA(route_entry);
route_attribute_len = RTM_PAYLOAD(nlh);
/* Loop through all attributes */
for (; RTA_OK(route_attribute, route_attribute_len);
route_attribute = RTA_NEXT(route_attribute, route_attribute_len)) {
switch (route_attribute->rta_type) {
case RTA_OIF:
if_indextoname(*(int*) RTA_DATA(route_attribute), interface);
break;
case RTA_GATEWAY:
inet_ntop(
AF_INET, RTA_DATA(route_attribute), gateway_address,
sizeof(gateway_address));
break;
default:
break;
}
}
if ((*gateway_address) && (*interface)) {
gw.assign(gateway_address);
iface.assign(interface);
break;
} else {
rv = false;
}
}
close(sock);
return true;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file get_gateway_netlink.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_GET_GATEWAY_NETLINK_HPP_SEEN
#define FILE_GET_GATEWAY_NETLINK_HPP_SEEN
#include <string>
namespace util {
bool get_iface_l2_addr(const std::string& iface, std::string& mac);
bool get_gateway_and_iface(std::string& gw, std::string& iface);
} // namespace util
#endif /* FILE_GET_GATEWAY_NETLINK_HPP_SEEN */
......@@ -1304,17 +1304,13 @@ void smf_context::handle_pdu_session_create_sm_context_request(
bool set_paa = false;
paa_t paa = {};
// Step 6. pco
// Step 6. PCO
// section 6.2.4.2, TS 24.501
// If the UE wants to use DHCPv4 for IPv4 address assignment, it shall
// indicate that to the network within the Extended protocol configuration
// options IE in the PDU SESSION ESTABLISHMENT REQUEST Extended protocol
// configuration options: See subclause 10.5.6.3A in 3GPP TS 24.008.
// ExtendedProtocolConfigurationOptions epco =
// (sm_context_req_msg.get_nas_msg()).extendedprotocolconfigurationoptions;
// TODO: PCO
protocol_configuration_options_t pco_req = {};
smreq->req.get_epco(pco_req);
protocol_configuration_options_t pco_resp = {};
......@@ -1374,7 +1370,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
Logger::smf_app().info(
"UE requests to use DHCPv4 for IPv4 address assignment, this "
"feature has not been supported yet!");
// TODO: DHCP
// TODO
}
} break;
......@@ -2874,19 +2870,21 @@ void smf_context::update_qos_info(
QOSFlowDescriptionsContents qos_flow_description_content = {};
// Only one flow description for new requested QoS Flow
QOSFlowDescriptionsContents* qos_flow_description =
(QOSFlowDescriptionsContents*) calloc(
number_of_flow_descriptions, sizeof(QOSFlowDescriptionsContents));
// QOSFlowDescriptionsContents* qos_flow_description =
// (QOSFlowDescriptionsContents*) calloc(
// number_of_flow_descriptions, sizeof(QOSFlowDescriptionsContents));
if (number_of_flow_descriptions > 0) {
qos_flow_description = nas_msg.plain.sm.pdu_session_modification_request
.qosflowdescriptions.qosflowdescriptionscontents;
// qos_flow_description = nas_msg.plain.sm.pdu_session_modification_request
// .qosflowdescriptions.qosflowdescriptionscontents;
for (int i = 0; i < number_of_flow_descriptions; i++) {
if (qos_flow_description[i].qfi == NO_QOS_FLOW_IDENTIFIER_ASSIGNED) {
if (nas_msg.plain.sm.pdu_session_modification_request
.qosflowdescriptions.qosflowdescriptionscontents[i].qfi == NO_QOS_FLOW_IDENTIFIER_ASSIGNED) {
// TODO: generate new QFI
generated_qfi.qfi = (uint8_t) 60; // hardcoded for now
qos_flow_description_content = qos_flow_description[i];
qos_flow_description_content = nas_msg.plain.sm.pdu_session_modification_request
.qosflowdescriptions.qosflowdescriptionscontents[i];
qos_flow_description_content.qfi = generated_qfi.qfi;
break;
}
......@@ -3007,7 +3005,7 @@ void smf_context::update_qos_info(
i++;
}
free_wrapper((void**) &qos_flow_description);
// free_wrapper((void**) &qos_flow_description);
}
//------------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment