TR181-XPON
1.4.0
TR-181 PON manager.
xpon_mngr_main.c
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** SPDX-License-Identifier: BSD-2-Clause-Patent
4
**
5
** SPDX-FileCopyrightText: Copyright (c) 2022 SoftAtHome
6
**
7
** Redistribution and use in source and binary forms, with or
8
** without modification, are permitted provided that the following
9
** conditions are met:
10
**
11
** 1. Redistributions of source code must retain the above copyright
12
** notice, this list of conditions and the following disclaimer.
13
**
14
** 2. Redistributions in binary form must reproduce the above
15
** copyright notice, this list of conditions and the following
16
** disclaimer in the documentation and/or other materials provided
17
** with the distribution.
18
**
19
** Subject to the terms and conditions of this license, each
20
** copyright holder and contributor hereby grants to those receiving
21
** rights under this license a perpetual, worldwide, non-exclusive,
22
** no-charge, royalty-free, irrevocable (except for failure to
23
** satisfy the conditions of this license) patent license to make,
24
** have made, use, offer to sell, sell, import, and otherwise
25
** transfer this software, where such license applies only to those
26
** patent claims, already acquired or hereafter acquired, licensable
27
** by such copyright holder or contributor that are necessarily
28
** infringed by:
29
**
30
** (a) their Contribution(s) (the licensed copyrights of copyright
31
** holders and non-copyrightable additions of contributors, in
32
** source or binary form) alone; or
33
**
34
** (b) combination of their Contribution(s) with the work of
35
** authorship to which such Contribution(s) was added by such
36
** copyright holder or contributor, if, at the time the Contribution
37
** is added, such addition causes such combination to be necessarily
38
** infringed. The patent license shall not apply to any other
39
** combinations which include the Contribution.
40
**
41
** Except as expressly stated above, no rights or licenses from any
42
** copyright holder or contributor is granted under this license,
43
** whether expressly, by implication, estoppel or otherwise.
44
**
45
** DISCLAIMER
46
**
47
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
48
** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
49
** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
50
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
52
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
53
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
54
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
55
** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
56
** AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
58
** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59
** POSSIBILITY OF SUCH DAMAGE.
60
**
61
****************************************************************************/
62
63
#include "
dm_info.h
"
/* dm_info_init() */
64
#include "
dm_xpon_mngr.h
"
65
#include "
module_mgmt.h
"
/* mod_module_mgmt_init() */
66
#include "
persistency.h
"
/* persistency_init() */
67
#include "
pon_ctrl.h
"
/* pon_ctrl_init() */
68
#include "
populate_dm_startup.h
"
/* pplt_dm_init() */
69
#include "
restore_to_hal.h
"
/* rth_init() */
70
#include "
upgrade_persistency.h
"
/* upgr_persistency_init() */
71
#include "
xpon_trace.h
"
72
73
typedef
struct
_xpon_mngr
{
74
amxd_dm_t*
dm
;
75
amxo_parser_t*
parser
;
76
}
xpon_mngr_t
;
77
78
79
static
xpon_mngr_t
s_app
;
80
81
int
_xpon_mngr_main
(
int
reason,
82
amxd_dm_t*
dm
,
83
amxo_parser_t* parser);
84
85
amxd_dm_t* PRIVATE
xpon_mngr_get_dm
(
void
) {
86
return
s_app
.
dm
;
87
}
88
89
amxo_parser_t* PRIVATE
xpon_mngr_get_parser
(
void
) {
90
return
s_app
.
parser
;
91
}
92
93
static
void
do_cleanup
(
void
) {
94
pplt_dm_cleanup
();
95
rth_cleanup
();
96
mod_module_mgmt_cleanup
();
97
persistency_cleanup
();
98
upgr_persistency_cleanup
();
99
}
100
101
int
_xpon_mngr_main
(
int
reason,
102
amxd_dm_t*
dm
,
103
amxo_parser_t* parser) {
104
105
SAH_TRACEZ_INFO(
ME
,
"reason=%d"
, reason);
106
107
bool
success =
false
;
108
int
rc = 1;
/* error */
109
bool
module_error =
false
;
110
111
switch
(reason) {
112
case
0:
// START
113
s_app
.
dm
=
dm
;
114
s_app
.
parser
= parser;
115
116
if
(!
dm_info_init
()) {
117
return
-1;
118
}
119
persistency_init
();
120
upgr_persistency_init
();
121
rth_init
();
122
if
(!
mod_module_mgmt_init
(&module_error)) {
123
if
(module_error) {
129
rc = 0;
130
}
131
break
;
132
}
133
pon_ctrl_init
();
134
if
(!
pplt_dm_init
()) {
135
break
;
136
}
137
success =
true
;
138
rc = 0;
139
break
;
140
case
1:
// STOP
141
do_cleanup
();
142
s_app
.
dm
= NULL;
143
s_app
.
parser
= NULL;
144
success =
true
;
145
rc = 0;
146
break
;
147
}
148
if
(!success) {
149
do_cleanup
();
150
}
151
152
return
rc;
153
}
dm_info.h
dm_info_init
bool dm_info_init(void)
Definition:
dm_info.c:297
dm_xpon_mngr.h
module_mgmt.h
mod_module_mgmt_cleanup
void mod_module_mgmt_cleanup(void)
Definition:
module_mgmt.c:340
mod_module_mgmt_init
bool mod_module_mgmt_init(bool *module_error)
Definition:
module_mgmt.c:299
persistency.h
persistency_init
void persistency_init(void)
Definition:
persistency.c:161
persistency_cleanup
void persistency_cleanup(void)
Definition:
persistency.c:198
pon_ctrl.h
pon_ctrl_init
void pon_ctrl_init(void)
Definition:
pon_ctrl.c:142
populate_dm_startup.h
pplt_dm_cleanup
void pplt_dm_cleanup(void)
Definition:
populate_dm_startup.c:648
pplt_dm_init
bool pplt_dm_init(void)
Definition:
populate_dm_startup.c:619
restore_to_hal.h
rth_init
void rth_init(void)
Definition:
restore_to_hal.c:226
rth_cleanup
void rth_cleanup(void)
Definition:
restore_to_hal.c:234
_xpon_mngr
Definition:
xpon_mngr_main.c:73
_xpon_mngr::dm
amxd_dm_t * dm
Definition:
xpon_mngr_main.c:74
_xpon_mngr::parser
amxo_parser_t * parser
Definition:
xpon_mngr_main.c:75
dm
on event dm
Definition:
tr181-xpon_definition.odl:209
upgrade_persistency.h
upgr_persistency_cleanup
void upgr_persistency_cleanup(void)
Definition:
upgrade_persistency.c:152
upgr_persistency_init
void upgr_persistency_init(void)
Definition:
upgrade_persistency.c:112
s_app
static xpon_mngr_t s_app
Definition:
xpon_mngr_main.c:79
xpon_mngr_get_parser
amxo_parser_t *PRIVATE xpon_mngr_get_parser(void)
Definition:
xpon_mngr_main.c:89
do_cleanup
static void do_cleanup(void)
Definition:
xpon_mngr_main.c:93
_xpon_mngr_main
int _xpon_mngr_main(int reason, amxd_dm_t *dm, amxo_parser_t *parser)
Definition:
xpon_mngr_main.c:101
xpon_mngr_get_dm
amxd_dm_t *PRIVATE xpon_mngr_get_dm(void)
Definition:
xpon_mngr_main.c:85
xpon_mngr_t
struct _xpon_mngr xpon_mngr_t
xpon_trace.h
ME
#define ME
Definition:
xpon_trace.h:78
src
xpon_mngr_main.c
Generated on Tue Mar 12 2024 03:38:12 for TR181-XPON by
1.9.1