From ae18da83b239003961532d94bda48314e456eda7 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 27 Oct 2017 14:22:04 +0100 Subject: [PATCH] Starting to add functions to the HSS to get K, AMF and OP. --- srsepc/hdr/hss/hss.h | 6 ++-- srsepc/hdr/mme/s1ap.h | 2 ++ srsepc/hdr/mme/s1ap_nas_transport.h | 46 ++++++++++++++++++++++++++ srsepc/src/hss/hss.cc | 17 ++++++++++ srsepc/src/mme/s1ap.cc | 26 +++++++++++---- srsepc/src/mme/s1ap_nas_transport.cc | 48 ++++++++++++++++++++++++++++ 6 files changed, 134 insertions(+), 11 deletions(-) create mode 100644 srsepc/hdr/mme/s1ap_nas_transport.h create mode 100644 srsepc/src/mme/s1ap_nas_transport.cc diff --git a/srsepc/hdr/hss/hss.h b/srsepc/hdr/hss/hss.h index 76cd416a5..9c8145974 100644 --- a/srsepc/hdr/hss/hss.h +++ b/srsepc/hdr/hss/hss.h @@ -54,10 +54,8 @@ public: static hss* get_instance(void); static void cleanup(void); int init(hss_args_t *hss_args, srslte::logger* logger); - - //bool gen_auth_info_answer(uint64_t imsi); - - //bool get_k_amf_op(uint64_t imsi, *k, *amf, *op); + + bool get_k_amf_op(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op); private: diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 0355e0cda..9e81770c4 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -40,6 +40,7 @@ #include #include "mme/s1ap_common.h" #include "mme/s1ap_mngmt_proc.h" +#include "hss/hss.h" namespace srsepc{ @@ -76,6 +77,7 @@ private: uint32_t m_plmn; srslte::log *m_s1ap_log; + hss *m_hss; int m_s1mme; std::map m_active_enbs; diff --git a/srsepc/hdr/mme/s1ap_nas_transport.h b/srsepc/hdr/mme/s1ap_nas_transport.h new file mode 100644 index 000000000..0c3f71bf8 --- /dev/null +++ b/srsepc/hdr/mme/s1ap_nas_transport.h @@ -0,0 +1,46 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2017 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of srsLTE. + * + * srsLTE 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. + * + * srsLTE 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 Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ +#ifndef S1AP_MNGMT_PROC_H +#define S1AP_MNGMT_PROC_H + +#include "srslte/asn1/liblte_s1ap.h" +#include "srslte/common/common.h" +#include "mme/s1ap_common.h" + +namespace srsepc{ + +class s1ap_nas_transport +{ +public: + s1ap_mngmt_proc(srslte::logger s1ap_logger); + virtual ~s1ap_nas_transport(); + + bool unpack_initial_ue_message(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, uint64_t *imsi); +}; + +} //namespace srsepc + +#endif //S1AP_MNGMT_PROC diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index 90b83b595..0cc05d726 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -77,6 +77,23 @@ hss::init(hss_args_t *hss_args, srslte::logger *logger) return 0; } +bool +hss::get_k_amf_op(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op ) +{ + + if(imsi != 1010123456789) + { + return false; + } + else + { + } + //uint8_t k[16]; + //uint8_t amf[2]; // 3GPP 33.102 v10.0.0 Annex H + //uint8_t op[16]; + + return false; +} } //namespace srsepc diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 6b172fbff..47c9fcfdd 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -49,7 +49,9 @@ s1ap::init(s1ap_args_t s1ap_args, srslte::log *s1ap_log) m_s1ap_log = s1ap_log; m_s1mme = enb_listen(); - + + m_hss = hss::get_instance(); + return 0; } @@ -234,11 +236,14 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg m_s1ap_log->console("Received Initial UE Message\n"); m_s1ap_log->info("Received Initial UE Message\n"); + uint8_t amf[2]; // 3GPP 33.102 v10.0.0 Annex H + uint8_t op[16]; + uint8_t k[16]; + uint64_t imsi; + LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT attach_req; LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req; - /*Get */ - /*Get NAS Attach Request Message*/ if(!liblte_mme_unpack_attach_request_msg((LIBLTE_BYTE_MSG_STRUCT *) msg->NAS_PDU.buffer, &attach_req)){ m_s1ap_log->console("Error unpacking NAS attach request."); @@ -251,13 +256,13 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg m_s1ap_log->warning("NAS Attach Request: Unhandle UE Id Type"); } else{ - uint64_t temp = 0; + imsi = 0; for(int i=14;i>=0;i--) { - temp *=10; - temp += attach_req.eps_mobile_id.imsi[i]; + imsi *=10; + imsi += attach_req.eps_mobile_id.imsi[i]; } - m_s1ap_log->console("IMSI: %d", temp); + m_s1ap_log->console("IMSI: %d", imsi); } if(attach_req.old_p_tmsi_signature_present){} @@ -326,6 +331,13 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg if(msg->LHN_ID_present){ m_s1ap_log->warning("LHN Id present, but not handled."); } + + if(!m_hss->get_k_amf_op(imsi, k, amf, op)) + { + m_s1ap_log->info("User %d not found",imsi); + } + + /* typedef struct{ diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc new file mode 100644 index 000000000..701e8200f --- /dev/null +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -0,0 +1,48 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2017 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of srsLTE. + * + * srsLTE 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. + * + * srsLTE 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 Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#include "mme/s1ap.h" +#include "mme/s1ap_nas_transport.h" + +namespace srsepc{ + +s1ap_nas_transport::s1ap_nas_transport(srslte::logger *s1ap_logger) +{ + m_s1ap_logger=s1ap_logger; +} + +s1ap_nas_transport::~s1ap_nas_transport() +{ +} + +bool +s1ap_nas_transport::initial_ue_message(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, uint64_t *imsi) +{ + return true; +} + + +} //namespace srsepc