Coverage Report

Created: 2026-08-14 06:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/ngap/message.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com>
3
 *
4
 * This file is part of Open5GS.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
#include "ogs-ngap.h"
21
22
int __ogs_ngap_domain;
23
24
ogs_pkbuf_t *ogs_ngap_encode(ogs_ngap_message_t *message)
25
0
{
26
0
    ogs_pkbuf_t *pkbuf = NULL;
27
28
0
    ogs_assert(message);
29
30
0
    if (ogs_log_get_domain_level(OGS_LOG_DOMAIN) >= OGS_LOG_TRACE)
31
0
        asn_fprint(stdout, &asn_DEF_NGAP_NGAP_PDU, message);
32
33
0
    pkbuf = ogs_asn_encode(&asn_DEF_NGAP_NGAP_PDU, message);
34
0
    if (!pkbuf) {
35
0
        ogs_error("ogs_asn_encode() failed");
36
0
        return NULL;
37
0
    }
38
39
0
    return pkbuf;
40
0
}
41
42
int ogs_ngap_decode(ogs_ngap_message_t *message, ogs_pkbuf_t *pkbuf)
43
4.96k
{
44
4.96k
    int rv;
45
4.96k
    ogs_assert(message);
46
4.96k
    ogs_assert(pkbuf);
47
4.96k
    ogs_assert(pkbuf->data);
48
4.96k
    ogs_assert(pkbuf->len);
49
50
4.96k
    rv = ogs_asn_decode(&asn_DEF_NGAP_NGAP_PDU,
51
4.96k
            message, sizeof(ogs_ngap_message_t), pkbuf);
52
4.96k
    if (rv != OGS_OK) {
53
4.88k
        ogs_warn("Failed to decode NGAP-PDU");
54
4.88k
        return rv;
55
4.88k
    }
56
57
82
    if (ogs_log_get_domain_level(OGS_LOG_DOMAIN) >= OGS_LOG_TRACE)
58
0
        asn_fprint(stdout, &asn_DEF_NGAP_NGAP_PDU, message);
59
60
82
    return OGS_OK;
61
4.96k
}
62
63
void ogs_ngap_free(ogs_ngap_message_t *message)
64
82
{
65
82
    ogs_assert(message);
66
82
    ogs_asn_free(&asn_DEF_NGAP_NGAP_PDU, message);
67
82
}