diff --git a/src/mme/mme-context.c b/src/mme/mme-context.c index 5e0710f51..e416fda4e 100644 --- a/src/mme/mme-context.c +++ b/src/mme/mme-context.c @@ -81,6 +81,7 @@ void mme_context_init() gtp_node_init(); ogs_list_init(&self.sgw_list); ogs_list_init(&self.pgw_list); + ogs_list_init(&self.enb_list); ogs_list_init(&self.vlr_list); ogs_pool_init(&mme_sgw_pool, context_self()->config.max.sgw); @@ -95,7 +96,6 @@ void mme_context_init() ogs_pool_init(&mme_bearer_pool, context_self()->pool.bearer); ogs_pool_init(&self.m_tmsi, context_self()->pool.ue); - self.enb_sock_hash = ogs_hash_make(); self.enb_addr_hash = ogs_hash_make(); self.enb_id_hash = ogs_hash_make(); self.mme_ue_s1ap_id_hash = ogs_hash_make(); @@ -123,8 +123,6 @@ void mme_context_final() mme_pgw_remove_all(); mme_vlr_remove_all(); - ogs_assert(self.enb_sock_hash); - ogs_hash_destroy(self.enb_sock_hash); ogs_assert(self.enb_addr_hash); ogs_hash_destroy(self.enb_addr_hash); ogs_assert(self.enb_id_hash); @@ -1673,9 +1671,6 @@ mme_enb_t *mme_enb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr) ogs_list_init(&enb->enb_ue_list); if (enb->sock_type == SOCK_STREAM) { - /* FIXME : The sock hash is needed? */ - ogs_hash_set(self.enb_sock_hash, enb->sock, sizeof(ogs_sock_t), enb); - enb->poll = ogs_pollset_add(mme_self()->pollset, OGS_POLLIN, sock->fd, s1ap_recv_handler, sock); ogs_assert(enb->poll); @@ -1687,6 +1682,8 @@ mme_enb_t *mme_enb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr) ogs_fsm_create(&enb->sm, s1ap_state_initial, s1ap_state_final); ogs_fsm_init(&enb->sm, &e); + ogs_list_add(&self.enb_list, enb); + return enb; } @@ -1697,6 +1694,8 @@ int mme_enb_remove(mme_enb_t *enb) ogs_assert(enb); ogs_assert(enb->sock); + ogs_list_remove(&self.enb_list, enb); + e.enb = enb; ogs_fsm_fini(&enb->sm, &e); ogs_fsm_delete(&enb->sm); @@ -1707,9 +1706,6 @@ int mme_enb_remove(mme_enb_t *enb) enb_ue_remove_in_enb(enb); if (enb->sock_type == SOCK_STREAM) { - /* FIXME : The sock hash is needed? */ - ogs_hash_set(self.enb_sock_hash, enb->sock, sizeof(ogs_sock_t), NULL); - ogs_pollset_remove(enb->poll); ogs_sctp_destroy(enb->sock); } @@ -1723,25 +1719,14 @@ int mme_enb_remove(mme_enb_t *enb) int mme_enb_remove_all() { - ogs_hash_index_t *hi = NULL; - mme_enb_t *enb = NULL; + mme_enb_t *enb = NULL, *next_enb = NULL; - for (hi = mme_enb_first(); hi; hi = mme_enb_next(hi)) { - enb = mme_enb_this(hi); + ogs_list_for_each_safe(&self.enb_list, next_enb, enb) mme_enb_remove(enb); - } return OGS_OK; } -mme_enb_t *mme_enb_find_by_sock(ogs_sock_t *sock) -{ - ogs_assert(sock); - return (mme_enb_t *)ogs_hash_get(self.enb_sock_hash, sock, sizeof(ogs_sock_t)); - - return NULL; -} - mme_enb_t *mme_enb_find_by_addr(ogs_sockaddr_t *addr) { ogs_assert(addr); @@ -1766,23 +1751,6 @@ int mme_enb_set_enb_id(mme_enb_t *enb, uint32_t enb_id) return OGS_OK; } -ogs_hash_index_t *mme_enb_first() -{ - ogs_assert(self.enb_sock_hash); - return ogs_hash_first(self.enb_sock_hash); -} - -ogs_hash_index_t *mme_enb_next(ogs_hash_index_t *hi) -{ - return ogs_hash_next(hi); -} - -mme_enb_t *mme_enb_this(ogs_hash_index_t *hi) -{ - ogs_assert(hi); - return ogs_hash_this_val(hi); -} - int mme_enb_sock_type(ogs_sock_t *sock) { ogs_socknode_t *snode = NULL; diff --git a/src/mme/mme-context.h b/src/mme/mme-context.h index 4b03189ef..de811731c 100644 --- a/src/mme/mme-context.h +++ b/src/mme/mme-context.h @@ -107,6 +107,8 @@ typedef struct mme_context_s { ogs_sockaddr_t *pgw_addr; /* First IPv4 Address Selected */ ogs_sockaddr_t *pgw_addr6; /* First IPv6 Address Selected */ + ogs_list_t enb_list; /* ENB S1AP Client List */ + ogs_list_t vlr_list; /* VLR SGsAP Client List */ mme_vlr_t *vlr; /* Iterator for VLR */ @@ -152,7 +154,6 @@ typedef struct mme_context_s { ogs_list_t mme_ue_list; - ogs_hash_t *enb_sock_hash; /* hash table for ENB Socket */ ogs_hash_t *enb_addr_hash; /* hash table for ENB Address */ ogs_hash_t *enb_id_hash; /* hash table for ENB-ID */ ogs_hash_t *mme_ue_s1ap_id_hash; /* hash table for MME-UE-S1AP-ID */ @@ -215,6 +216,8 @@ typedef struct mme_vlr_s { } mme_vlr_t; typedef struct mme_enb_s { + ogs_lnode_t lnode; + ogs_fsm_t sm; /* A state machine */ uint32_t enb_id; /* eNB_ID received from eNB */ @@ -609,13 +612,9 @@ mme_vlr_t *mme_vlr_find_by_nas_lai(nas_lai_t *lai); mme_enb_t *mme_enb_add(ogs_sock_t *sock, ogs_sockaddr_t *addr); int mme_enb_remove(mme_enb_t *enb); int mme_enb_remove_all(void); -mme_enb_t *mme_enb_find_by_sock(ogs_sock_t *sock); mme_enb_t *mme_enb_find_by_addr(ogs_sockaddr_t *addr); mme_enb_t *mme_enb_find_by_enb_id(uint32_t enb_id); int mme_enb_set_enb_id(mme_enb_t *enb, uint32_t enb_id); -ogs_hash_index_t *mme_enb_first(); -ogs_hash_index_t *mme_enb_next(ogs_hash_index_t *hi); -mme_enb_t *mme_enb_this(ogs_hash_index_t *hi); int mme_enb_sock_type(ogs_sock_t *sock); enb_ue_t *enb_ue_add(mme_enb_t *enb); diff --git a/src/mme/s1ap-path.c b/src/mme/s1ap-path.c index b4e6dca4e..509af91e1 100644 --- a/src/mme/s1ap-path.c +++ b/src/mme/s1ap-path.c @@ -287,15 +287,12 @@ int s1ap_send_ue_context_release_command( void s1ap_send_paging(mme_ue_t *mme_ue, S1AP_CNDomain_t cn_domain) { ogs_pkbuf_t *s1apbuf = NULL; - ogs_hash_index_t *hi = NULL; mme_enb_t *enb = NULL; int i; int rv; /* Find enB with matched TAI */ - for (hi = mme_enb_first(); hi; hi = mme_enb_next(hi)) { - - enb = mme_enb_this(hi); + ogs_list_for_each(&mme_self()->enb_list, enb) { for (i = 0; i < enb->num_of_supported_ta_list; i++) { if (memcmp(&enb->supported_ta_list[i], &mme_ue->tai, @@ -327,15 +324,12 @@ void s1ap_t3413_timeout(void *data) if (mme_ue->max_paging_retry < MAX_NUM_OF_PAGING) { ogs_pkbuf_t *s1apbuf = NULL; - ogs_hash_index_t *hi = NULL; mme_enb_t *enb = NULL; int i; int rv; /* Find enB with matched TAI */ - for (hi = mme_enb_first(); hi; hi = mme_enb_next(hi)) { - - enb = mme_enb_this(hi); + ogs_list_for_each(&mme_self()->enb_list, enb) { for (i = 0; i < enb->num_of_supported_ta_list; i++) { if (memcmp(&enb->supported_ta_list[i], &mme_ue->tai, diff --git a/src/mme/sbc-handler.c b/src/mme/sbc-handler.c index 954f1c833..153c48208 100644 --- a/src/mme/sbc-handler.c +++ b/src/mme/sbc-handler.c @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * 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 . + */ + #include "mme-context.h" #include "s1ap-path.h" #include "s1ap-build.h" @@ -6,22 +25,16 @@ void sbc_handle_write_replace_warning_request(sbc_pws_data_t *sbc_pws) { ogs_pkbuf_t *s1apbuf = NULL; - ogs_hash_index_t *hi = NULL; mme_enb_t *enb = NULL; int i, j, flag; int rv; /* Find enB with matched TAI */ - for (hi = mme_enb_first(); hi; hi = mme_enb_next(hi)) - { + ogs_list_for_each(&mme_self()->enb_list, enb) { flag = 0; - enb = mme_enb_this(hi); - if (sbc_pws->no_of_tai > 0) - { - for (i = 0, flag = 0; i < enb->num_of_supported_ta_list; i++) - { - for (j = 0; j < sbc_pws->no_of_tai; j++) - { + if (sbc_pws->no_of_tai > 0) { + for (i = 0, flag = 0; i < enb->num_of_supported_ta_list; i++) { + for (j = 0; j < sbc_pws->no_of_tai; j++) { if (!memcmp(&enb->supported_ta_list[i], &sbc_pws->tai[j], sizeof(tai_t))) flag = 1; @@ -30,12 +43,10 @@ void sbc_handle_write_replace_warning_request(sbc_pws_data_t *sbc_pws) } if (flag) break; } - } - else + } else flag = 1; - if (flag) - { + if (flag) { s1apbuf = NULL; /* Buidl S1AP Write Replace Warning Request message */ @@ -52,22 +63,16 @@ void sbc_handle_write_replace_warning_request(sbc_pws_data_t *sbc_pws) void sbc_handle_stop_warning_request(sbc_pws_data_t *sbc_pws) { ogs_pkbuf_t *s1apbuf = NULL; - ogs_hash_index_t *hi = NULL; mme_enb_t *enb = NULL; int i, j, flag; int rv; /* Find enB with matched TAI */ - for (hi = mme_enb_first(); hi; hi = mme_enb_next(hi)) - { + ogs_list_for_each(&mme_self()->enb_list, enb) { flag = 0; - enb = mme_enb_this(hi); - if (sbc_pws->no_of_tai > 0) - { - for (i = 0, flag = 0; i < enb->num_of_supported_ta_list; i++) - { - for (j = 0; j < sbc_pws->no_of_tai; j++) - { + if (sbc_pws->no_of_tai > 0) { + for (i = 0, flag = 0; i < enb->num_of_supported_ta_list; i++) { + for (j = 0; j < sbc_pws->no_of_tai; j++) { if (!memcmp(&enb->supported_ta_list[i], &sbc_pws->tai[j], sizeof(tai_t))) flag = 1; @@ -76,12 +81,10 @@ void sbc_handle_stop_warning_request(sbc_pws_data_t *sbc_pws) } if (flag) break; } - } - else + } else flag = 1; - if (flag) - { + if (flag) { s1apbuf = NULL; /* Buidl S1AP Kill request message */ diff --git a/src/mme/sbc-handler.h b/src/mme/sbc-handler.h index 235e7b103..bcf86a82a 100644 --- a/src/mme/sbc-handler.h +++ b/src/mme/sbc-handler.h @@ -1,5 +1,24 @@ -#ifndef __SBC_HANDLER_H__ -#define __SBC_HANDLER_H__ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * 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 . + */ + +#ifndef SBC_HANDLER_H +#define SBC_HANDLER_H #include "sbc-message.h" @@ -7,13 +26,13 @@ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif void sbc_handle_write_replace_warning_request(sbc_pws_data_t *sbc_pws); void sbc_handle_stop_warning_request(sbc_pws_data_t *sbc_pws); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif -#endif /* __SBC_HANDLER_H__ */ +#endif /* SBC_HANDLER_H */ diff --git a/src/mme/sbc-message.h b/src/mme/sbc-message.h index 0422ad249..89156f7fc 100644 --- a/src/mme/sbc-message.h +++ b/src/mme/sbc-message.h @@ -1,11 +1,30 @@ -#ifndef __SBC_MESSAGE_H__ -#define __SBC_MESSAGE_H__ +/* + * Copyright (C) 2019 by Sukchan Lee + * + * 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 . + */ + +#ifndef SBC_MESSAGE_H +#define SBC_MESSAGE_H #include "base/types.h" #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* SBc-AP messages: * After the CBC integration, the encoding/decoding of @@ -29,6 +48,6 @@ typedef struct _sbc_pws_data_t { #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif -#endif /* __SBC_MESSAGE_H__ */ +#endif /* SBC_MESSAGE_H */ diff --git a/src/mme/sgsap-path.c b/src/mme/sgsap-path.c index 235cc25d5..f9dd6694b 100644 --- a/src/mme/sgsap-path.c +++ b/src/mme/sgsap-path.c @@ -184,7 +184,7 @@ int sgsap_send_service_request(mme_ue_t *mme_ue) ogs_pkbuf_t *pkbuf = NULL; ogs_assert(mme_ue); - ogs_debug("[SGSAP] MO-CSFB-INDICATION"); + ogs_debug("[SGSAP] SERVICE-REQUEST"); ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd); ogs_debug(" SERVICE_INDICATOR[%d]", mme_ue->service_indicator);