/*
 * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
 *
 * 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 <https://www.gnu.org/licenses/>.
 */

#include "sgsap-types.h"
#include "sgsap-conv.h"

int mme_name_build(char *buf, 
        uint32_t mme_code, uint16_t mme_gid, ogs_plmn_id_t *plmn_id)
{
    int len;
    char temp[SGSAP_IE_MME_NAME_LEN];
    ogs_assert(buf);
    ogs_assert(plmn_id);

    len = ogs_snprintf(temp, SGSAP_IE_MME_NAME_LEN,
        "mmec%02d.mmegi%04d.mme.epc.mnc%03d.mcc%03d.3gppnetwork.org",
        mme_code, mme_gid, ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id));
    if (len < 0) {
        ogs_assert_if_reached();
    }

    return ogs_fqdn_build(buf, temp, len);
}
