s6a_dict.c 8.97 KB
Newer Older
Cedric Roux's avatar
 
Cedric Roux committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
/*******************************************************************************

  Eurecom OpenAirInterface
  Copyright(c) 1999 - 2013 Eurecom

  This program is free software; you can redistribute it and/or modify it
  under the terms and conditions of the GNU General Public License,
  version 2, as published by the Free Software Foundation.

  This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

  The full GNU General Public License is included in this distribution in
  the file called "COPYING".

  Contact Information
  Openair Admin: openair_admin@eurecom.fr
  Openair Tech : openair_tech@eurecom.fr
  Forums       : http://forums.eurecom.fr/openairinterface
  Address      : EURECOM, Campus SophiaTech, 450 Route des Chappes
                 06410 Biot FRANCE

*******************************************************************************/

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include "intertask_interface.h"
#include "s6a_defs.h"
#include "s6a_messages.h"
#include "assertions.h"

#define CHECK_FD_FCT(fCT)  DevAssert(fCT == 0);

/*! \file s6a_dict.c
 * \brief Initialize s6a dictionnary and setup callbacks for procedures
 * \author Sebastien ROUX <sebastien.roux@eurecom.fr>
 * \date 2013
 * \version 0.1
 */

int s6a_fd_init_dict_objs(void)
{
    struct disp_when when;

    vendor_id_t vendor_3gpp = VENDOR_3GPP;
    application_id_t app_s6a = APP_S6A;

    /* Pre-loading vendor object */
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict,
                                DICT_VENDOR,
                                VENDOR_BY_ID,
                                (void *)&vendor_3gpp,
                                &s6a_fd_cnf.dataobj_s6a_vendor,
                                ENOENT));

    /* Pre-loading application object */
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_APPLICATION,
                                APPLICATION_BY_ID, (void *)&app_s6a,
                                &s6a_fd_cnf.dataobj_s6a_app, ENOENT));

    /* Pre-loading commands objects */
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Authentication-Information-Request",
                                &s6a_fd_cnf.dataobj_s6a_air, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Authentication-Information-Answer",
                                &s6a_fd_cnf.dataobj_s6a_aia, ENOENT));

    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Update-Location-Request",
                                &s6a_fd_cnf.dataobj_s6a_ulr, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Update-Location-Answer",
                                &s6a_fd_cnf.dataobj_s6a_ula, ENOENT));

    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Purge-UE-Request",
                                &s6a_fd_cnf.dataobj_s6a_pur, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Purge-UE-Answer",
                                &s6a_fd_cnf.dataobj_s6a_pua, ENOENT));

    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Cancel-Location-Request",
                                &s6a_fd_cnf.dataobj_s6a_clr, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                                CMD_BY_NAME, "Cancel-Location-Answer",
                                &s6a_fd_cnf.dataobj_s6a_cla, ENOENT));

    /* Pre-loading base avps */
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME, "Destination-Host",
                                &s6a_fd_cnf.dataobj_s6a_destination_host, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME, "Destination-Realm",
                                &s6a_fd_cnf.dataobj_s6a_destination_realm, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME, "User-Name",
                                &s6a_fd_cnf.dataobj_s6a_user_name, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME, "Session-Id",
                                &s6a_fd_cnf.dataobj_s6a_session_id, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME, "Auth-Session-State",
                                &s6a_fd_cnf.dataobj_s6a_auth_session_state, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME, "Result-Code",
                                &s6a_fd_cnf.dataobj_s6a_result_code, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME, "Experimental-Result",
                                &s6a_fd_cnf.dataobj_s6a_experimental_result, ENOENT));

    /* Pre-loading S6A specifics AVPs */
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "Visited-PLMN-Id",
                                &s6a_fd_cnf.dataobj_s6a_visited_plmn_id, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "RAT-Type",
                                &s6a_fd_cnf.dataobj_s6a_rat_type, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "ULR-Flags",
                                &s6a_fd_cnf.dataobj_s6a_ulr_flags, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "ULA-Flags",
                                &s6a_fd_cnf.dataobj_s6a_ula_flags, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "Subscription-Data",
                                &s6a_fd_cnf.dataobj_s6a_subscription_data, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "Requested-EUTRAN-Authentication-Info",
                                &s6a_fd_cnf.dataobj_s6a_req_eutran_auth_info, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "Number-Of-Requested-Vectors",
                                &s6a_fd_cnf.dataobj_s6a_number_of_requested_vectors, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "Immediate-Response-Preferred",
                                &s6a_fd_cnf.dataobj_s6a_immediate_response_pref, ENOENT));
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "Authentication-Info",
                                &s6a_fd_cnf.dataobj_s6a_authentication_info, ENOENT));
149 150 151
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "Re-Synchronization-Info",
                                &s6a_fd_cnf.dataobj_s6a_re_synchronization_info, ENOENT));
Cedric Roux's avatar
 
Cedric Roux committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
    CHECK_FD_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                                AVP_BY_NAME_ALL_VENDORS, "UE-SRVCC-Capability",
                                &s6a_fd_cnf.dataobj_s6a_ue_srvcc_cap, ENOENT));

    /* Register callbacks */
    memset(&when, 0, sizeof(when));

    when.command = s6a_fd_cnf.dataobj_s6a_ula;
    when.app     = s6a_fd_cnf.dataobj_s6a_app;

    /* Register the callback for Update Location Answer S6A Application */
    CHECK_FD_FCT(fd_disp_register(s6a_ula_cb, DISP_HOW_CC, &when, NULL,
                                  &s6a_fd_cnf.ula_hdl));
    DevAssert(s6a_fd_cnf.ula_hdl != NULL);

    when.command = s6a_fd_cnf.dataobj_s6a_aia;
    when.app     = s6a_fd_cnf.dataobj_s6a_app;

    /* Register the callback for Authentication Information Answer S6A Application */
    CHECK_FD_FCT(fd_disp_register(s6a_aia_cb, DISP_HOW_CC, &when, NULL,
                                  &s6a_fd_cnf.aia_hdl));
    DevAssert(s6a_fd_cnf.aia_hdl != NULL);

    /* Advertise the support for the test application in the peer */
    CHECK_FD_FCT(fd_disp_app_support(s6a_fd_cnf.dataobj_s6a_app,
                                     s6a_fd_cnf.dataobj_s6a_vendor, 1, 0));

    return 0;
}