RDK Documentation (Open Sourced RDK Components)
TR69BusAgent.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21 * @file
22 *
23 * @brief TR69 Bus Agent Public API.
24 *
25 */
26 
27 /**
28  * @defgroup TR69 TR-069
29  *
30  * @par Terminology
31  * Code | Description
32  * ------------|------------
33  * ACS | Auto-Configuration Server
34  * CPE | Customer Premises Equipment
35  * CWMP | CPE WAN Management Protocol
36  * NAT | Network Address Translation
37  * STUN | Simple Traversal of UDP through NATs
38  * B-NT | Broadband-Network Termination
39  * DT Schema | Device Type Schema
40  * RPC | Remote Procedure Call
41  * DT Instance | Device Type Schema instance document
42  * ACL | Access control list
43  * ADSL | Asymmetric Digital Subscriber Line
44  * AES | Advanced Encryption Standard
45  * ASCII | American Standard Code for Information Interchange
46  * ATA | Analog terminal adapter
47  * ATM | Asynchronous Transfer Mode
48  * BOOTP | Boot Strap Protocol
49  * CGI | Common Gateway Interface
50  * CN | Common Name
51  * CSRF | Cross-site request forgery
52  * DHCP | Dynamic Host Configuration Protocol
53  * DNS | Domain Name System
54  * DSL | Digital Subscriber Line
55  *
56  * @par Introduction to TR-069
57  * TR-069 is a technical specification that defines an application layer protocol for remote management of end-user devices.
58  * It was published by the Broadband Forum and was entitled CPE WAN Management Protocol(CWMP).
59  * The CWMP, published by The Broadband Forum as TR-069, specifies a standard
60  * communication mechanism for the remote management of end-user devices. It defines a protocol for the secure
61  * auto-configuration of a TR-069 device and incorporates other management functions into a common framework.
62  * This protocol simplifies device management by specifying the use of an auto configuration server (ACS)
63  * to perform remote, centralized management of customer premises equipment (CPE).
64  * @n
65  * TR-069 supports a variety of functionalities to manage CPEs and has the following primary capabilities:
66  * - Auto-configuration and dynamic service provisioning
67  * - Software/firmware management
68  * - Status and performance monitoring
69  * - Diagnostics
70  *
71  * @par RDK TR-069 Feature Summary
72  * - Service Activation
73  * - Firmware upgrade management
74  * - Register device to Auto-Configuration Server (ACS) using Inform notification
75  * - Periodically send device information to ACS using Inform notification
76  * - Forced Inform for required parameters
77  * - Allow ACS to configure periodic Inform interval.
78  * - Allow ACS to reach devices that are connected behind NAT using STUN + UDP NAT traversal
79  * - (future) Allow ACS to reach devices that are connected behind NAT using XMPP
80  * - Retrieve device diagnostics/parameters using GetParameterValues() method
81  * - Set device parameters using SetParameterValues() method
82  * - Factory reset using FactoryReset method
83  * - Device reboot using Reboot method
84  * - SSL/TLS 1.2 (Transport Layer Security) per RFC5246 to encrypt communications with ACS
85  *
86  * @par What is an ACS and why is it necessary?
87  * - TR-069 specifies communication between customer-premises equipment (CPE) and an auto configuration server.
88  * - The auto configuration server acts as a management server for TR-069-enabled CPE.
89  * - It is essentially the link between the subscriber's devices in the home and the service provider's customer service
90  * representative (CSR), support staff, operational support systems and business support systems (OSS/BSS).
91  * - An auto configuration server enables you to automate provisioning and many management tasks for TR-069 devices,
92  * facilitating remote management.
93  *
94  * @par How does TR-069 work?
95  * TR-069 is a SOAP(Simple Object Access Protocol)/HTTP-based protocol. Orders are sent between the device (CPE)
96  * and an auto configuration server over HTTP or HTTPS in the form of remote procedure calls (RPCs) and responses,
97  * with SOAP acting as the encoding syntax to transport RPCs. The CPE acts as the HTTP client and the ACS acts as
98  * the HTTP server.
99  * @n
100  * The basic network elements required include:
101  * @n
102  * - An auto configuration server (ACS): The management server on the network.
103  * - Customer premises equipment (CPE): The device that is managed on the network
104  * - DNS server: Used to resolve the URL that is required for the ACS and CPE to interact
105  * - DHCP server: Can be used to assign an IP address to a device on the network. Well-known DHCP options
106  * can configure important parameters on the CPE, such as the ACS URL.
107  * - TR-069 provides the communication interface between CPE and Auto Configuration Server (ACS)
108  * - An ACS can manage a device, trouble shoot, configure and upgrade. the information.
109  * @n
110  * @image html tr69_overview.png
111  * TR-069 closely monitor and control the Customer Premises Equipment (CPE). In RDK it would be Settop box or Gateway.
112  * - The Auto Configuration Server (ACS) is located in the cloud which control the Customer Premises Equipment.
113  * - ACS server is controlled by Operation/Support team.
114  * - There are different kinds of data model used in customer premises, such as TR-135 data model is used in STB,
115  * TR-104 data model is used in VoIP, TR-140 data module is used in storage, and so on.
116  *
117  * @par What is a remote procedure call (RPC)?
118  * A remote procedure call (RPC) is an operation between an ACS and the CPE. It is used for bidirectional communication between
119  * CPE and an ACS. Some common RPCs include:
120  * - @b GetParameterValue: The ACS uses this RPC to get the value of one or more parameters of a CPE
121  * - @b SetParameterValue: The ACS sets the value of one or more parameters of a CPE
122  * - @b Inform: A CPE sends this message to an ACS to initiate a session and to periodically send local information
123  * - @b Download: When the ACS requires a CPE to download a specified file to upgrade hardware and download a configuration file
124  * - @b Upload: When the ACS requires a CPE to upload a specified file to a specified location
125  * - @b Reboot: An ACS reboots a CPE remotely when the CPE encounters a failure or needs a software upgrade
126  * - <b> Add Object</b>: Allows the ACS to create instances of objects available on the CPE, for example, port mapping entries.
127  * The ACS also creates the associated parameters and sub-objects.
128  * - <b>Delete Object</b>: Enables the ACS to delete existing instances of objects available on the CPE.
129  * It also deletes the associated parameters and sub-objects.
130  *
131  * @par Why RDK use TR-069?
132  * There are many benefits associated with using TR-069 to provision and manage end-user devices.
133  * TR-069 and its extensions allow you to:
134  * - Enable remote provisioning of CPE devices such as Xi3, XG1v3, etc.
135  * - Better manage broadband networks with increased visibility and control of CPE.
136  * - Collect data for analytics on network usage and activity, home network characteristics, and service utilization.
137  * - Deliver new managed data services such as WiFi, content filtering and other parental controls, online backup,
138  * and home surveillance.
139  * - Offer subscribers a degree of self-service through web portals.
140  * - Expand service offerings and manage the connected home.
141  * - Improve your customer service with improved diagnostics, monitoring, and firmware management.
142  * - Reduce support calls and remove the burden of CPE configuration from subscribers and roll-out services
143  * with an automated process.
144  *
145  * @par TR-069 Setup
146  * @image html tr69_intro.png
147  *
148  * @par TR-069 Message Flow:
149  * @image html tr69_setup.png
150  *
151  * @par Features implemented in RDK IP Clients,
152  * These are the following features implemented in RDK IP Clients.
153  * @n
154  * @li @ref TR69_FIRMWARE_DOWNLOAD
155  * @li @ref TR69_PERIODIC_INFORMATION
156  * @li @ref TR69_DEVICE_MANAGEMENT
157  * @li @ref TR69_DIAGNOSTICS
158  *
159  * @defgroup TR69_FIRMWARE_DOWNLOAD TR-069 Firmware Download
160  * @ingroup TR69
161  * Firmware Download in NATed Clients
162  * @n Currently Docsis based RDK STBs support the following CDL methods
163  * - SNMP and bootfile triggered downloads
164  * - TFTP based downloads
165  * - However, IP client devices do not have a public IP address, and can only be reached through their Gateway STBs
166  * - IP Client STBs hence rely on TR-069 and ACS directive for Code Download
167  * - It can be triggered from CDL server just as in the case of gateways,
168  * - The IP client device is connected to Gateway device and it is behind the XG1.
169  * - Download RPC is used to trigger download to the IP Clients
170  * @li The CDL server triggers the request to ACS based on the Serial and MOUI of IP Client device.
171  * - The ACS selects the device based on the request from CDL server.
172  * - Then ACS uses the download RPC to trigger the firmware download.
173  *
174  * @par Code Download Terminologies
175  * @n
176  * Term | Definition
177  * -----| -----------
178  * ACS | Auto-Configuration Server
179  * Bootloader | Refers to the first stage bootloader responsible for lunching the firmware image.
180  * B-DRI | Used in the event the disaster recovery image is corrupt. The capabilities are limited to ensuring that a secure download of the firmware image can take place.
181  * P-DRI | Disaster Recovery Image. Refers to a disaster recovery image that is launched if the firmware image is invalid due to corruption of other reasons. When the device is running an DRI image, then it is DRI mode. If a normal firmware image is running, then it is in normal mode.
182  * OTP | One time programmable memory.
183  *
184  * @n
185  * @par Code Download - Example Decision Flow
186  *
187  * @image html tr69_cdl.png
188  *
189  * When firmware updates are required, the device needs to know where to go to get the firmware update file.
190  * ACS calls "Download" method to download Firmware image to Device with the following arguments
191  * - Command Key
192  * - FileType
193  * - URL
194  * - Username
195  * - Password
196  * - FileSize
197  * - TargetFileName
198  * - DelaySeconds
199  * - SuccessURL
200  * - FailureURL
201  * CPE uses the above information to trigger for firmware download.
202  *
203  * @defgroup TR69_PERIODIC_INFORMATION TR-069 Gathering Periodic Information
204  * @ingroup TR69
205  * Intended to check the heart beat of deployed IP client STB.
206  * A mechanism to establish periodic communication with the ACS on an ongoing basis, or when events occurs that
207  * must be reported to the ACS such as when the broadband IP address of the CPE changes.
208  * The ACS must be aware of this event in order to establish incoming connections to the CPE.
209  * @n - CPE periodically sends CPE information to the ACS using the inform method call.
210  * @n - CPE attempts to connect with ACS and call the inform method if, the following parameter is set to True.
211  * @li "Device.ManagementServer.PeriodicInformEnable"
212  * @n - The periodic interval duration can be configured by the ACS using the parameter,
213  * @li "Device.ManagementServer.PeriodicInformInterval"
214  *
215  * @defgroup TR69_DEVICE_MANAGEMENT TR-069 Device Management
216  * @ingroup TR69
217  * Following are the device management features implemented in RDK,
218  * - Fetching of parameter values from IP client STB to ACS using @b GetParameterValues" RPC.
219  * - Setting of parameter values to IP client STB from ACS using @b SetParameterValues RPC.
220  * - Factory Reset to IP client STB from ACS using @b FactoryReset RPC.
221  * - Reboot to IP client STB from ACS using @b Reboot RPC.
222  *
223  * @par Broadband Data Model Definition,
224  * RDK supports the following data models,
225  * @n
226  * - IP client STB device related: tr-181-2-2-0 (http://www.broadband-forum.org/cwmp/tr-181-2-2-0.html)
227  * @n Example:
228  * Name | Description
229  * -----| -----------
230  * Device.DeviceInfo.SoftwareVersion | Software version currently installed in the CPE.
231  * Device.DeviceInfo.HardwareVersion | Identifying the particular CPE model and version.
232  * Device.DeviceInfo.UpTime | Time in seconds since the CPE was last restarted.
233  * Device.DeviceInfo.MemoryStatus.Total | Status of the device's volatile physical memory.
234  * Device.DeviceInfo.MemoryStatus.Free | Status of the free physical RAM, in kilobytes, currently available on the device.
235  * Device.DeviceInfo.TemperatureStatus | Status of the temperature of the device.
236  * Device.ManagementServer. | This object contains parameters relating to the CPE's association with an ACS
237  * Device.ManagementServer.EnableCWMP | Enables and disables the CPE's support for CWMP.
238  * Device.ManagementServer.URL | For the CPE to connect to the ACS using the CPE WAN Management Protocol.
239  * @n @n
240  * - IP client STB service related: tr-135-1-2-0 (http://www.broadband-forum.org/cwmp/tr-135-1-0-0.html)
241  * @n Example:
242  * Name | Description
243  * -----| -----------
244  * STBService.{i}.Components.AudioOutput.{i}. | Audio output instance table.
245  * STBService.{i}.Components.AudioOutput.{i}.AudioFormat | Currently active audio output format.
246  * STBService.{i}.Components.AudioOutput.{i}.AudioLevel | The audio level on this audio output.
247  * STBService.{i}.Components.VideoOutput.{i}. | Video output instance table.
248  * STBService.{i}.Components.VideoOutput.{i}.VideoFormat | Currently active video output format
249  * @n
250  * - RDK IP client custom parameters
251  * @li Example1: STBService.{i}.Components.X_RDKCENTRAL-COM_SDCard.Capacity
252  * @li Example2: STBService.{i}.Components.X_RDKCENTRAL-COM_SDCard.Model
253  *
254  *
255  * @defgroup TR69_DIAGNOSTICS TR-069 Diagnostics
256  * When the diagnostic initiated by the ACS is completed successfully or not,
257  * the CPE MUST establish a new connection to the ACS to allow the ACS to view the results, indicating the
258  * Event code "8 DIAGNOSTICS COMPLETE" in the Inform message.
259  * @n @n
260  * After the diagnostic is complete, the value of all result parameters MUST be retained by the CPE until
261  * either this diagnostic runs again, or the CPE reboots. After a reboot, if the CPE has not retained
262  * the resultant parameters from the most recent test, it MUST set the value of this parameter to “None”.
263  * @n @n
264  * Modifying any of the writable parameters in this object except for this one MUST result in the value
265  * of this parameter being set to “None”.
266  * @n @n
267  * While the test is in progress, modifying any of the writable parameters in this object except for this
268  * one MUST result in the test being terminated and the value of this parameter being set to “None”.
269  * @n @n
270  * While the test is in progress, setting this parameter to Requested MUST result in the test being terminated
271  * and then restarted using the current values of the test parameters.
272  *
273  * @par Diagnostics states,
274  * If the ACS sets the value of this parameter to Requested, the CPE MUST initiate the
275  * corresponding diagnostic test. When writing, the only allowed value is Requested.
276  * To ensure the use of the proper test parameters i.e the writable parameters in this object,
277  * the test parameters MUST be set either prior to or at the same time as in the same SetParameterValues
278  * setting the DiagnosticsState to Requested.
279  * @n @n
280  * When requested, the CPE SHOULD wait until after completion of the communication session with the
281  * ACS before starting the diagnostic. When the test is completed, the value of this parameter MUST be
282  * either Complete i.e if the test completed successfully, or one of the Error values listed above.
283  * If the value of this parameter is anything other than Complete, the values of the results parameters for
284  * this test are indeterminate. Following are the diagnostics states,
285  * - None
286  * - Requested
287  * - Complete
288  * - Error_CannotResolveHostName
289  * - Error_Internal
290  * - Error_Other
291  *
292  * @ingroup TR69
293  *
294  *
295  * @defgroup TR69_HOSTIF TR-069 Host Interface
296  * @par TR-069 Host Interface Manager
297  * TR-069 Host Interface Manager is responsible to cater the service for two interfaces
298  * - TR-069 client interface
299  * - JSON Interface
300  * TR-069 route the request based on the request parameter path and map to respective manager components,
301  * like DeviceSetting, MoCA and other managers.
302  *
303  * @par TR-069 Host Interface Manager Vs TR-069 client interface
304  * Following methods are supported by Host-if to tr-069 agent
305  * - Get Parameter/Profile values | TR-069 Agent -> TR069 Host-If
306  * - Set Parameter values | TR-069 Host-If -> TR-069 Agent
307  *
308  * @par TR-069 Notification
309  * - Add instance of table.
310  * - Delete instance of table.
311  * - Subscribe | This will subscribe the parameter for notification of type Active, Passive and no notification
312  *
313  * @par TR-069 Host Interface Manager / Json interface
314  * - It can only be used to get values from Host-If
315  * - It can provide the values to html diagnostic pages.
316  *
317  * @par TR-069 Host Interface Manager / Json interface
318  * <b> Json message request format: </b>
319  * @code
320  * {
321  * "paramList":[
322  * {
323  * "name:: "<Parameter-Path",
324  * }
325  * ]
326  * }
327  * @endcode
328  * <b> Json message response format: </b>
329  * @code
330  * {
331  * "paramList": [
332  * {
333  * "name":"<Parameter-Path>",
334  * "value":"<Param-Value>"
335  * }
336  * ]
337  * }
338  * @endcode
339  *
340  * @ingroup TR69
341  *
342  *
343  */
344 
345 /**
346 * @defgroup tr69hostif
347 * @{
348 * @defgroup tr69BusAgent
349 * @{
350 **/
351 
352 
353 #ifndef TR69BUSAGENT_H
354 #define TR69BUSAGENT_H
355 
356 #ifdef __cplusplus
357 extern "C"
358 {
359 #endif
360 #include "hostIf_tr69ReqHandler.h"
361 #define TR69_BUF_MIN 64
362 #define TR69_BUF_MAX 1024
363 #define IARM_BUS_TR69_COMMON_API_AgentParameterHandler "agentParameterHandler"
364 
365  faultCode_t TR69Bus_ProcessSharedMalloc(size_t , void **);
366 
367  /**
368  * @brief TR69 Incoming Request function pointer.
369  *
370  * This function passes the request info structure, parameter type and value .
371  *
372  * @return bool true/false.
373  */
374 
376  /**
377  * @brief Starts the TR69 Register Callback.
378  *
379  * This function registers and connects TR69 Bus Agent.
380  *
381  * @return bool true/false.
382  */
383 
384  bool tr69Register( const char*, fpIncomingTR69Request);
385 
386  /**
387  * @brief Function Wrapper around fpIncomingTR69Request.
388  *
389  * @return bool true/false.
390  */
391 
392  IARM_Result_t _TR69AgentCallback_FuncWrapper(void *);
393 
394  /**
395  * @brief TR69 UnRegister function.
396  *
397  * This function unregisters and disconnects TR69 Bus Agent.
398  *
399  * @return bool true/false.
400  */
401 
402  bool tr69UnRegister( const char *);
403 
404  /**
405  * @brief TR69 Request Complete function.
406  *
407  * This function is responsible to map the heap memory to process
408  * of requestinfo pointer from TR69 Bus Agents.
409  *
410  * @return bool true/false.
411  */
412 
414 
415 #ifdef __cplusplus
416 }
417 #endif
418 
419 #endif // TR69BUSAGENT_H
420 
421 
422 /** @} */
423 /** @} */
tr69RequestComplete
bool tr69RequestComplete(HOSTIF_MsgData_t *)
TR69 Request Complete function.
Definition: TR69BusAgent.cpp:146
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
fpIncomingTR69Request
bool(* fpIncomingTR69Request)(HOSTIF_MsgData_t *)
TR69 Incoming Request function pointer.
Definition: TR69BusAgent.h:375
_TR69AgentCallback_FuncWrapper
IARM_Result_t _TR69AgentCallback_FuncWrapper(void *)
Function Wrapper around fpIncomingTR69Request.
Definition: TR69BusAgent.cpp:75
faultCode_t
enum _faultCodes faultCode_t
tr69Register
bool tr69Register(const char *, fpIncomingTR69Request)
Starts the TR69 Register Callback.
Definition: TR69BusAgent.cpp:98
tr69UnRegister
bool tr69UnRegister(const char *)
TR69 UnRegister function.
Definition: TR69BusAgent.cpp:135