MME2 changes - Propped commits from openmme/paging branch. Added scripts
for code gen
Change-Id: Ie55032217232214ac8544ca76ea34335205329e4
diff --git a/include/s6a/s6a.h b/include/s6a/s6a.h
new file mode 100644
index 0000000..e4aa383
--- /dev/null
+++ b/include/s6a/s6a.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * 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.
+ */
+
+#ifndef __S6A_H_
+#define __S6A_H_
+
+#include <freeDiameter/freeDiameter-host.h>
+#include <freeDiameter/libfdproto.h>
+#include <freeDiameter/libfdcore.h>
+
+#include "log.h"
+#include "hss_message.h"
+
+#define S6A_FD_CONF "conf/s6a_fd.conf"
+#define HSS_RESP_THREADPOOL_SIZE 10
+#define STR_IMSI_LEN 16
+#define SESS_ID_LEN 128
+
+/**
+ * brief: Structure to store s6a freediameter session information
+ */
+struct s6a_sess_info {
+ unsigned char imsi[8];
+ char sess_id[SESS_ID_LEN];
+ int sess_id_len;
+};
+
+/**
+ * @brief Handle HSS reponse message
+ * @param[in] message buffer
+ * @return void
+ */
+void
+hss_resp_handler(void *message);
+
+/**
+ * @brief Handler thread for AIR/ULR request coming from mme-app
+ * This function sends both AIR and ULR
+ * @param[in] data- message buffer
+ * @return void*
+ */
+void*
+AIR_handler(void *data);
+
+/**
+ * @brief Handler thread for detach request coming from mme-app
+ * @param[in] data- message buffer
+ * @return void *
+ */
+void*
+detach_handler(void *data);
+
+/*Handler for AIA coming from built in perf HS*/
+void
+handle_perf_hss_aia(int ue_idx, struct hss_aia_msg *aia);
+
+/*Handler for ULA coming from built in perf HS*/
+void
+handle_perf_hss_ula(int ue_idx, struct hss_ula_msg *ula);
+
+/*Handler for AIA coming from built in perf HS*/
+void
+handle_perf_hss_purge_resp(int ue_idx);
+
+
+//NI Detach
+/*Handler for CLR coming from built in perf HSS*/
+void
+handle_perf_hss_clr(int ue_idx, struct hss_clr_msg *clr);
+
+/**
+ * @brief convert binary imsi to string imsi
+ * Binary imsi is stored in 8 bytes, each nibble representing each imsi char.
+ * char imsi stroes each char in 1 byte.
+ * @param[in] b_imsi : Binary imsi
+ * @param[out] s_imsi : Converted string imsi
+ * @return void
+ */
+void
+imsi_bin_to_str(unsigned char *b_imsi, char *s_imsi);
+
+#endif /*S6A*/
diff --git a/include/s6a/s6a_config.h b/include/s6a/s6a_config.h
new file mode 100644
index 0000000..aaed84d
--- /dev/null
+++ b/include/s6a/s6a_config.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * 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.
+ */
+
+#ifndef __S1AP_CONFIG_H_
+#define __S1AP_CONFIG_H_
+
+#include <stdbool.h>
+#include "s1ap_structs.h"
+
+#define HSS_HOST_NAME_LEN 256
+#define HSS_REALM_LEN 256
+#define SS_IPC_ENDPT_FILE_LEN 256
+
+/**
+ * @brief: Whether HSS to be contacted is freediameter based real HSS or the
+ * dummy designed for performance testing
+ */
+enum e_HSS_HOST_TYPE {
+ HSS_PERF,
+ HSS_FD,
+};
+
+/**
+ * @brief What type of RPC mechanism to use for communication with dummy HSS
+ */
+enum e_HSS_RPC {
+ HSS_IPC,
+ HSS_RPC,
+};
+
+/**
+ * @brief HSS configuration read from hss json file
+ */
+typedef struct s6a_config {
+ /**Defines whether freediameter based hss to be used or inbuilt hss to be
+ * used.
+ */
+ enum e_HSS_HOST_TYPE hss_type;
+
+ /*Applicable in case of in built HSS. Defines which type of communication
+ * to be used. This is for future provision to support RPC
+ */
+ enum e_HSS_RPC hss_rpc;
+ char *hss_ipc_endpt;
+ char *hss_host_name;
+ char *realm;
+} s6a_config;
+
+/**
+ * @brief Initialize json parser for givn file
+ * @param path to the hss json file
+ */
+void
+init_parser(char *path);
+
+/**
+ * @brief Parser hss json file and store parameters in the structure
+ * @params none
+ * @return int as success/fail
+ */
+int
+parse_s6a_conf();
+
+#endif /*__S1AP_CONFIG_H_*/
diff --git a/include/s6a/s6a_fd.h b/include/s6a/s6a_fd.h
new file mode 100644
index 0000000..2bc716a
--- /dev/null
+++ b/include/s6a/s6a_fd.h
@@ -0,0 +1,333 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * 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.
+ */
+
+#ifndef __S6A_FD_H__
+#define __S6A_FD_H__
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <ctype.h>
+#include <freeDiameter/freeDiameter-host.h>
+#include <freeDiameter/libfdproto.h>
+#include <freeDiameter/libfdcore.h>
+
+#include "err_codes.h"
+#include "s6a.h"
+
+/*Update location request(ULR) flag bitfields*/
+/* Single-Registration-Indication -------1*/
+#define ULR_FLAG_SINGLE_REG_IND (1)
+/*S6a/S6d-Indicator: ------1-*/
+#define ULR_FLAG_S6AS6D_IND (1<<1)
+/*Skip-Subscriber-Data: -----1--*/
+#define ULR_FLAGS_SKIP_SUB_DATA (1<<2)
+/*GPRS-Subscription-Data-Indicator:----1---*/
+#define ULR_FLAGS_GPRS_SUBS_DATA_IBND (1<<3)
+/*Node-Type-Indicator: ---1----*/
+#define ULR_FLAGS_NODE_TYPE_IIND (1<<4)
+/*Initial-Attach-Indicator: --1-----*/
+#define ULR_FLAG_INIT_ATCH_IND (1<<5)
+/*PS-LCS-Not-Supported-By-UE: -1------*/
+#define ULR_FLAG_PS_LCS_NOT_SUPPORTED_BY_UE (1<<6)
+/*SMS-Only-Indication: 1-------*/
+#define ULR_FLAG_SMS_ONLY_IND (1<<7)
+
+#define S6A_RAT_EUTRAN 1004
+
+#define FD_DICT_SEARCH(dict, cond, id, obj) \
+ CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, dict, cond,\
+ (void*)id, &obj, ENOENT),\
+ return S6A_FD_DICTSRCH_FAILED)
+
+/**
+ * @brief Freediameter result
+ */
+struct fd_result {
+ bool present;
+ unsigned int vendor_id;
+ unsigned int result_code;
+};
+
+/**
+ * @brief Freediameter disctionary objects user in s6a transactions
+ */
+struct fd_dict_objects {
+ /*s6a and app id*/
+ struct dict_object *vendor_id;
+ struct dict_object *s6a_app;
+
+ /*Message types*/
+ struct dict_object *AIR; /*Authentication-Information-Request*/
+ struct dict_object *AIA; /*Authentication-information-Answer*/
+ struct dict_object *ULR; /*Update-Location-Request*/
+ struct dict_object *ULA; /*Update-Location-Answer*/
+ struct dict_object *PUR; /*Purge-Request*/
+ struct dict_object *PUA; /*Purge-Answer*/
+ //NI Detach
+ struct dict_object *CLR; /*Cancel-Location-Request*/
+ struct dict_object *CLA; /*Cancel-Location-Answer*/
+ //NI Detach
+
+ /*common s6a requst header*/
+ struct dict_object *auth_app_id;
+ struct dict_object *sess_id;
+ struct dict_object *org_host; //NI Detach
+ struct dict_object *org_realm; //NI Detach
+ struct dict_object *dest_host;
+ struct dict_object *dest_realm;
+ struct dict_object *auth_sess_state;
+ struct dict_object *res_code;
+ struct dict_object *exp_res;
+ struct dict_object *user_name;
+
+ /*AIR elements*/
+ struct dict_object *visited_PLMN_id;
+ struct dict_object *req_EUTRAN_auth_info;
+ struct dict_object *no_of_req_vectors;
+ struct dict_object *immediate_resp_pref;
+
+ /*AIA elements*/
+ struct dict_object *auth_info;
+ struct dict_object *E_UTRAN_vector;
+ struct dict_object *RAND;
+ struct dict_object *XRES;
+ struct dict_object *AUTN;
+ struct dict_object *KASME;
+
+ /*ULR elements*/
+ struct dict_object *RAT_type;
+ struct dict_object *ULR_flags;
+
+ /*ULA elements*/
+ struct dict_object *ULA_flags;
+ struct dict_object *subscription_data;
+ struct dict_object *subscriber_status;
+ struct dict_object *MSISDN;
+ struct dict_object *net_access_mode;
+ struct dict_object *access_restriction_data;
+ struct dict_object *AMBR;
+ struct dict_object *max_req_bandwidth_UL;
+ struct dict_object *max_req_bandwidth_DL;
+ struct dict_object *APN_config_profile;
+ struct dict_object *ctx_id;
+ struct dict_object *additional_ctx_id;
+ struct dict_object *all_APN_configs_included_ind;
+ struct dict_object *APN_config;
+ struct dict_object *PDN_type;
+ struct dict_object *PDN_GW_alloc_type;
+ struct dict_object *specific_APN_info;
+ struct dict_object *non_IP_PDN_type_ind;
+ struct dict_object *non_IP_data_delivery_mech;
+ struct dict_object *SCEF_ID;
+ struct dict_object *priority_Level;
+ struct dict_object *location_area_id;
+ struct dict_object *tracking_area_id;
+ struct dict_object *subsc_periodic_RAU_TAU_tmr;
+
+ /*PUR elements*/
+ struct dict_object *PUR_flags;
+ struct dict_object *reg_subs_zone_code;
+
+ //NI Detach
+ /*CLR elements*/
+ struct dict_object *cancellation_type;
+};
+
+/**
+ * @brief Freediameter dictionary data storage
+ */
+struct fd_dict_data {
+ /* S6A AVP data */
+ struct dict_application_data app_s6a_data;
+ struct dict_vendor_data vendor_data;
+
+ /*Common s6a elements*/
+ struct dict_avp_data res_code;
+ struct dict_avp_data exp_res;
+ struct dict_avp_data exp_res_code;
+ struct dict_avp_data vendor_specific_app_id;
+ struct dict_avp_data auth_app_id;
+ struct dict_avp_data acct_app_id;
+ struct dict_avp_data vendor_id;
+ struct dict_avp_data sess_id;
+ struct dict_avp_data auth_sess_state;
+ struct dict_avp_data org_host;
+ struct dict_avp_data org_realm;
+ struct dict_avp_data dest_host;
+ struct dict_avp_data dest_realm;
+ struct dict_avp_data user_name;
+ struct dict_avp_data visited_PLMN_id;
+ struct dict_avp_data req_EUTRAN_auth_info;
+ struct dict_avp_data no_of_req_vectors;
+ struct dict_avp_data immediate_resp_pref;
+
+ /*AIA data*/
+ struct dict_avp_data auth_info;
+ struct dict_avp_data E_UTRAN_vector;
+ struct dict_avp_data RAND;
+ struct dict_avp_data XRES;
+ struct dict_avp_data AUTN;
+ struct dict_avp_data KASME;
+
+ /*ULR data*/
+ struct dict_avp_data RAT_type;
+ struct dict_avp_data ULR_flags;
+
+ /*ULA data*/
+ struct dict_avp_data ULA_flags;
+ struct dict_avp_data subscription_data;
+ struct dict_avp_data subscriber_status;
+ struct dict_avp_data MSISDN;
+ struct dict_avp_data net_access_mode;
+ struct dict_avp_data access_restriction_data;
+ struct dict_avp_data AMBR;
+ struct dict_avp_data max_req_bandwidth_UL;
+ struct dict_avp_data max_req_bandwidth_DL;
+ struct dict_avp_data APN_config_profile;
+ struct dict_avp_data ctx_id;
+ struct dict_avp_data additional_ctx_id;
+ struct dict_avp_data all_APN_configs_included_ind;
+ struct dict_avp_data APN_config;
+ struct dict_avp_data PDN_type;
+ struct dict_avp_data PDN_GW_alloc_type;
+ struct dict_avp_data specific_APN_info;
+ struct dict_avp_data non_IP_PDN_type_ind;
+ struct dict_avp_data non_IP_data_delivery_mech;
+ struct dict_avp_data SCEF_ID;
+ struct dict_avp_data priority_Level;
+ struct dict_avp_data location_area_id;
+ struct dict_avp_data tracking_area_id;
+ struct dict_avp_data subsc_periodic_RAU_TAU_tmr;
+
+ /*PUR flags*/
+ struct dict_avp_data PUR_flags;
+ struct dict_avp_data reg_subs_zone_code;
+
+ //NI Detach
+ /*CLR Data*/
+ struct dict_avp_data cancellation_type;
+};
+
+/**
+ * @brief Initialize freediameter parser, callbacks, dictionary etc.
+ * @params none
+ * @return int as success/fail
+ */
+int
+s6a_fd_init();
+
+/**
+ * @brief Initialize freediameter dictionary
+ * @param none
+ * @return int as success/fail
+ */
+int
+s6a_fd_objs_init();
+
+/**
+ * @brief Initialize freediameter dictionary data objects
+ * @param none
+ * @return int as success/fail
+ */
+int
+s6a_fd_data_init();
+
+/**
+ * @brief Initialize freediameter API callbacks for response handling
+ * @param none
+ * @return int as success/fail
+ */
+int
+s6a_fd_cb_reg();
+
+/**
+ * @brief extract ue index from session id of freediameter
+ * @param[in] sid - session id
+ * @param[in] sidlen - Session Id length
+ * @return UE index extracted out of session id
+ */
+int
+get_ue_idx_from_fd_resp(unsigned char *sid, int sidlen);
+
+/**
+ * @brief Cression session id, append ue index to session id
+ * @param[in, out] s6a_sess - session information
+ * @param[in] ue_idx to append to session id
+ * @return int as success/fail
+ */
+short
+create_fd_sess_id(struct s6a_sess_info *s6a_sess, int ue_idx);
+
+int
+aia_resp_callback(struct msg **msg, struct avp *avp, struct session *sess,
+ void *data, enum disp_action *act);
+
+int
+ula_resp_callback(struct msg **msg, struct avp *avp, struct session *sess,
+ void *data, enum disp_action *act);
+
+//NI Detach
+int
+clr_resp_callback(struct msg **msg, struct avp *avp, struct session *sess,
+ void *data, enum disp_action *act);
+
+
+#if 0
+int
+purge_resp_callback(struct msg **msg, struct avp *avp, struct session *sess,
+ void *data, enum disp_action *act);
+#endif
+
+/**
+ * @brief Dumo freediameter message on console
+ * @param msg - Freediameter message structure
+ * @return void
+ */
+void
+dump_fd_msg(struct msg *msg);
+
+/**
+ * brief add AVl object to freediameter message
+ * @param[in] avp value to add
+ * @param[in] ditionary object for reference
+ * @param[out] frediameter message where avp is added
+ * @return int as success/fail
+ */
+int
+add_fd_msg(union avp_value *val, struct dict_object * obj,
+struct msg **msg_buf);
+
+void
+handle_perf_hss_aia(int ue_idx, struct hss_aia_msg *aia);
+
+void
+handle_perf_hss_ula(int ue_idx, struct hss_ula_msg *ula);
+
+void
+handle_perf_hss_purge_resp(int ue_idx);
+
+//NI Detach
+void
+handle_perf_hss_clr(int ue_idx, struct hss_clr_msg *clr);
+
+short
+parse_fd_result(struct avp *avp, struct fd_result *res);
+
+#endif /* __S6A_FD_H__ */