NVIDIA DriveOS Linux NSR SDK API Reference

7.0.3.0 Release
duplugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2024, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 
18 #ifndef DUPLUGIN_H_
19 #define DUPLUGIN_H_
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include "dulink.h"
26 #include <pthread.h>
27 
37 /* ------------------------ Defines ----------------------------------------- */
38 
40 #define DUMASTER_PATH "/master"
41 
45 #define PLUGIN_TYPE_INSTALLER "installer"
47 #define PLUGIN_TYPE_CONTROLLER "controller"
49 #define PLUGIN_TYPE_CONTENT_PROVIDER "content_provider"
51 #define PLUGIN_TYPE_FILE_TRANSFORM "file_transform"
53 #define PLUGIN_TYPE_VALIDATOR "validator"
55 #define PLUGIN_TYPE_METADATA_PROVIDER "metadata_provider"
57 #define PLUGIN_TYPE_PERS_CTX_STORE "persistent_ctx_store"
59 #define PLUGIN_TYPE_DEBUG "debug"
61 
70 #define NODE_PLUGIN_TYPE "plugin-type"
72 #define NODE_REQUESTED_RL "requested_rl"
74 #define NODE_CURRENT_RL "current_rl"
76 #define NODE_PERSISTENT_CTX_PATH "persistent_ctx_path"
78 #define NODE_PENDING_RL "pending_rl"
80 #define NODE_STATE "state"
82 #define NODE_STATE_LIST "state.list"
84 
88 #define NODE_PROGRESS "progress"
90 #define NODE_CMD "cmd"
92 #define NODE_CMD_LIST "cmd.list"
94 #define NODE_RESULT "result"
96 
101 #define NOTIFY_NODE_CURRENT_RL "current_rl.notify"
103 #define NOTIFY_NODE_STATE "state.notify"
105 #define NOTIFY_NODE_PENDING_RL "pending_rl.notify"
107 
112 #define NOTIFY_NODE_PROGRESS "progress.notify"
114 #define NOTIFY_NODE_RESULT "result.notify"
116 
121 #define READ_ONLY_ATTR { \
122  .type = DULINK_NODE_TYPE_FILE, \
123  .numACL = 1U, \
124  .acl = \
125  { \
126  [0].srcElement = "/*", \
127  [0].allowMask = DULINK_PERMISSION_READ, \
128  [0].denyMask = DULINK_PERMISSION_WRITE, \
129  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
130  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
131  } \
132 }
133 
135 #define READ_ONLY_DIR_ATTR { \
136  .type = DULINK_NODE_TYPE_DIRECTORY, \
137  .numACL = 1U, \
138  .acl = \
139  { \
140  [0].srcElement = "/*", \
141  [0].allowMask = DULINK_PERMISSION_READ, \
142  [0].denyMask = DULINK_PERMISSION_WRITE, \
143  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
144  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
145  } \
146 }
147 
149 #define READ_WRITE_ATTRIBUTE { \
150  .type = DULINK_NODE_TYPE_FILE, \
151  .numACL = 1U, \
152  .acl = \
153  { \
154  [0].srcElement = "/*", \
155  [0].allowMask = DULINK_PERMISSION_WRITE | DULINK_PERMISSION_READ, \
156  [0].denyMask = DULINK_PERMISSION_NONE, \
157  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
158  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
159  } \
160 }
161 
163 #define WRITE_ONLY_ATTRIBUTE { \
164  .type = DULINK_NODE_TYPE_FILE, \
165  .numACL = 1U, \
166  .acl = \
167  { \
168  [0].srcElement = "/*", \
169  [0].allowMask = DULINK_PERMISSION_WRITE, \
170  [0].denyMask = DULINK_PERMISSION_READ, \
171  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
172  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
173  } \
174 }
175 
178 #define MASTER_ONLY_RW_ATTRIBUTE { \
179  .type = DULINK_NODE_TYPE_FILE, \
180  .numACL = 2U, \
181  .acl = \
182  { \
183  [0].srcElement = "/*", \
184  [0].allowMask = DULINK_PERMISSION_NONE, \
185  [0].denyMask = DULINK_PERMISSION_NONE, \
186  [1].srcElement = "/master", \
187  [1].allowMask = DULINK_PERMISSION_READ | DULINK_PERMISSION_WRITE, \
188  [1].denyMask = DULINK_PERMISSION_NONE, \
189  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
190  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
191  } \
192 }
193 
196 #define MASTER_ONLY_WRITE_ATTRIBUTE { \
197  .type = DULINK_NODE_TYPE_FILE, \
198  .numACL = 2U, \
199  .acl = \
200  { \
201  [0].srcElement = "/*", \
202  [0].allowMask = DULINK_PERMISSION_NONE, \
203  [0].denyMask = DULINK_PERMISSION_READ, \
204  [1].srcElement = "/master", \
205  [1].allowMask = DULINK_PERMISSION_WRITE, \
206  [1].denyMask = DULINK_PERMISSION_READ, \
207  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
208  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
209  } \
210 }
211 
215 #define COMPAT_ONLY_RW_ATTR { \
216  .type = DULINK_NODE_TYPE_FILE, \
217  .numACL = 2U, \
218  .acl = \
219  { \
220  [0].srcElement = "/*", \
221  [0].allowMask = DULINK_PERMISSION_NONE, \
222  [0].denyMask = DULINK_PERMISSION_NONE, \
223  [1].srcElement = "/compatchecker", \
224  [1].allowMask = DULINK_PERMISSION_READ | DULINK_PERMISSION_WRITE, \
225  [1].denyMask = DULINK_PERMISSION_NONE, \
226  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
227  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
228  } \
229 }
230 
231 
234 #define MASTER_ONLY_READ_ATTR \
235 { \
236  .type = DULINK_NODE_TYPE_FILE, \
237  .numACL = 2U, \
238  .acl = \
239  { \
240  [0].srcElement = "/*", \
241  [0].allowMask = DULINK_PERMISSION_NONE, \
242  [0].denyMask = DULINK_PERMISSION_WRITE, \
243  [1].srcElement = "/master", \
244  [1].allowMask = DULINK_PERMISSION_READ, \
245  [1].denyMask = DULINK_PERMISSION_WRITE, \
246  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
247  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
248  } \
249 }
250 
254 #define ALL_RO_MASTER_RW_ATTR \
255 { \
256  .type = DULINK_NODE_TYPE_FILE, \
257  .numACL = 2U, \
258  .acl = \
259  { \
260  [0].srcElement = "/*", \
261  [0].allowMask = DULINK_PERMISSION_READ, \
262  [0].denyMask = DULINK_PERMISSION_NONE, \
263  [1].srcElement = "/master", \
264  [1].allowMask = DULINK_PERMISSION_READ | DULINK_PERMISSION_WRITE, \
265  [1].denyMask = DULINK_PERMISSION_NONE, \
266  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
267  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
268  } \
269 }
270 
273 #define CCHECK_ONLY_READ_ATTR \
274 { \
275  .type = DULINK_NODE_TYPE_FILE, \
276  .numACL = 2U, \
277  .acl = \
278  { \
279  [0].srcElement = "/*", \
280  [0].allowMask = DULINK_PERMISSION_NONE, \
281  [0].denyMask = DULINK_PERMISSION_WRITE, \
282  [1].srcElement = "/compatchecker", \
283  [1].allowMask = DULINK_PERMISSION_READ, \
284  [1].denyMask = DULINK_PERMISSION_WRITE, \
285  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
286  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
287  } \
288 }
289 
292 #define DDU_ONLY_WRITE_ATTR \
293 { \
294  .type = DULINK_NODE_TYPE_FILE, \
295  .numACL = 2U, \
296  .acl = \
297  { \
298  [0].srcElement = "/*", \
299  [0].allowMask = DULINK_PERMISSION_NONE, \
300  [0].denyMask = DULINK_PERMISSION_READ, \
301  [1].srcElement = "/ddu", \
302  [1].allowMask = DULINK_PERMISSION_WRITE, \
303  [1].denyMask = DULINK_PERMISSION_READ, \
304  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
305  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
306  } \
307 }
308 
312 #define DUCLIENT_ONLY_RW_ATTR \
313 { \
314  .type = DULINK_NODE_TYPE_FILE, \
315  .numACL = 2U, \
316  .acl = \
317  { \
318  [0].srcElement = "/*", \
319  [0].allowMask = DULINK_PERMISSION_NONE, \
320  [0].denyMask = DULINK_PERMISSION_NONE, \
321  [1].srcElement = "/du-client", \
322  [1].allowMask = DULINK_PERMISSION_READ | DULINK_PERMISSION_WRITE, \
323  [1].denyMask = DULINK_PERMISSION_NONE, \
324  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
325  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
326  } \
327 }
328 
332 #define ALL_RO_DUCLIENT_RW_ATTR \
333 { \
334  .type = DULINK_NODE_TYPE_FILE, \
335  .numACL = 2U, \
336  .acl = \
337  { \
338  [0].srcElement = "/*", \
339  [0].allowMask = DULINK_PERMISSION_READ, \
340  [0].denyMask = DULINK_PERMISSION_NONE, \
341  [1].srcElement = "/du-client", \
342  [1].allowMask = DULINK_PERMISSION_READ | DULINK_PERMISSION_WRITE, \
343  [1].denyMask = DULINK_PERMISSION_NONE, \
344  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
345  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
346  } \
347 }
348 
352 #define ALL_RO_CTX_STORE_RW_ATTR \
353 { \
354  .type = DULINK_NODE_TYPE_FILE, \
355  .numACL = 2U, \
356  .acl = \
357  { \
358  [0].srcElement = "/*", \
359  [0].allowMask = DULINK_PERMISSION_READ, \
360  [0].denyMask = DULINK_PERMISSION_NONE, \
361  [1].srcElement = "/ctx_store", \
362  [1].allowMask = DULINK_PERMISSION_READ | DULINK_PERMISSION_WRITE, \
363  [1].denyMask = DULINK_PERMISSION_NONE, \
364  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, \
365  {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}} \
366  } \
367 }
368 
371 #define DUTR_PARAM_BUFLEN (1024)
372 
373 /* ------------------------ Type Definitions -------------------------------- */
374 
377 typedef enum DUPLUGIN_TYPE
378 {
386 } DUPLUGIN_TYPE;
387 
392 {
398 
403 typedef struct DULINK_EXPORT_REQS
404 {
406  const char *pPath;
408  const DULINK_CB cb;
412  void *pCtx;
414 
419 typedef struct CTX_LOCK_STR
420 {
422  const char *pStr;
424  pthread_mutex_t *pMutex;
426 
431 typedef struct CTX_LOCK_UINT8
432 {
434  uint8_t *pInt;
436  pthread_mutex_t *pMutex;
438 
443 typedef struct CTX_LOCK_RL
444 {
448  pthread_mutex_t *pMutex;
450 
454 typedef struct CTX_LIST_STR
455 {
457  const uint8_t size;
459  const char * const *ppStrList;
461 
465 typedef struct DULINK_CONNECT_INFO
466 {
476  uint64_t trParamBuf[DUTR_PARAM_BUFLEN / sizeof(uint64_t)];
478  uint64_t secParamBuf[DUTR_PARAM_BUFLEN / sizeof(uint64_t)];
480  uint32_t refId;
484 
485 /* ------------------------ Common Helper Functions ------------------------- */
533 (
534  const DULINK_EXPORT_REQS *pDulinkDirs,
535  uint8_t numDirs,
536  const DULINK_EXPORT_REQS *pDulinkFiles,
537  uint8_t numFiles,
538  const DULINK_EXPORT_REQS *pDulinkNotifyNodes,
539  uint8_t numNotifyNodes
540 );
541 
575 (
576  const char *pMasterPath
577 );
578 
611 (
612  char *pStr,
613  const char *pContRootVal,
614  uint64_t bufLen
615 );
616 
649 (
650  char *pBuf,
651  uint32_t bufLen
652 );
653 
690 (
691  const char *pPluginName,
693 );
694 
695 /* ------------------------ Shared Callbacks -------------------------------- */
761 (
762  const char *pRequestPath,
763  const char *pOriginPath,
764  void *pCtx,
765  uint64_t offset,
766  uint64_t length,
767  void *pBuf,
768  DULINK_CB_OPERATION operation,
769  uint64_t *pRetVal
770 );
771 
833 (
834  const char *pRequestPath,
835  const char *pOriginPath,
836  void *pCtx,
837  uint64_t offset,
838  uint64_t length,
839  void *pBuf,
840  DULINK_CB_OPERATION operation,
841  uint64_t *pRetVal
842 );
843 
905 (
906  const char *pRequestPath,
907  const char *pOriginPath,
908  void *pCtx,
909  uint64_t offset,
910  uint64_t length,
911  void *pBuf,
912  DULINK_CB_OPERATION operation,
913  uint64_t *pRetVal
914 );
915 
917 #ifdef __cplusplus
918 }
919 #endif
920 
921 #endif // DUPLUGIN_H_
CTX_LOCK_UINT8
Data structure to enable access in a DU Link callback to a uint8_t requiring thread access protection...
Definition: duplugin.h:431
METADATA_PROVIDER
@ METADATA_PROVIDER
Definition: duplugin.h:384
CTX_LOCK_UINT8::pMutex
pthread_mutex_t * pMutex
Will be locked before reading from pStr.
Definition: duplugin.h:436
CTX_LOCK_UINT8::pInt
uint8_t * pInt
Integer to be passed to callback context.
Definition: duplugin.h:434
readOnlyStringCB
DU_RCODE readOnlyStringCB(const char *pRequestPath, const char *pOriginPath, void *pCtx, uint64_t offset, uint64_t length, void *pBuf, DULINK_CB_OPERATION operation, uint64_t *pRetVal)
Callback for read only strings in a DU-Link node.
exportDULinkNodes
DU_RCODE exportDULinkNodes(const DULINK_EXPORT_REQS *pDulinkDirs, uint8_t numDirs, const DULINK_EXPORT_REQS *pDulinkFiles, uint8_t numFiles, const DULINK_EXPORT_REQS *pDulinkNotifyNodes, uint8_t numNotifyNodes)
Export DU Link directories, files and notify nodes.
CTX_LOCK_STR
Data structure to enable access in a DU Link callback to a string requiring thread access protection.
Definition: duplugin.h:419
FILE_TRANSFORM
@ FILE_TRANSFORM
Definition: duplugin.h:382
getPluginParent
DU_RCODE getPluginParent(char *pBuf, uint32_t bufLen)
Get plugin parent path.
CTX_LOCK_RL::pMutex
pthread_mutex_t * pMutex
Will be locked before reading from pStr.
Definition: duplugin.h:448
CTX_LOCK_STR::pStr
const char * pStr
String to be passed to callback context.
Definition: duplugin.h:422
CONTROLLER
@ CONTROLLER
Definition: duplugin.h:379
CTX_LOCK_STR
struct CTX_LOCK_STR CTX_LOCK_STR
Data structure to enable access in a DU Link callback to a string requiring thread access protection.
CTX_LIST_STR::ppStrList
const char *const * ppStrList
Pointer to array of strings to iterate.
Definition: duplugin.h:459
DUTR_TR_TYPE
DUTR_TR_TYPE
Defines DU-Transport back-end transport protocols.
Definition: dutransport.h:48
CTX_LOCK_RL::pRl
DU_RUN_LEVEL * pRl
Runlevel to be passed to callback context.
Definition: duplugin.h:446
DU_RCODE
uint32_t DU_RCODE
Drive Update error codes.
Definition: ducommon.h:74
DULINK_CONNECT_INFO
struct DULINK_CONNECT_INFO DULINK_CONNECT_INFO
Data structure to hold information for single DU Link connection.
DU_RUN_LEVEL
DU_RUN_LEVEL
Defines the run level.
Definition: ducommon.h:159
registerToMaster
DU_RCODE registerToMaster(const char *pMasterPath)
Register a DU Link plugin to DU Master.
DULINK_CONNECT_ROUTER
@ DULINK_CONNECT_ROUTER
Router.
Definition: duplugin.h:394
PDULINK_EXPORT_REQS
struct DULINK_EXPORT_REQS * PDULINK_EXPORT_REQS
CTX_LOCK_RL
Data structure to enable access in a DU Link callback to a DU_RUN_LEVEL requiring thread access prote...
Definition: duplugin.h:443
PCTX_LOCK_UINT8
struct CTX_LOCK_UINT8 * PCTX_LOCK_UINT8
DUPLUGIN_TYPE_MAX
@ DUPLUGIN_TYPE_MAX
Definition: duplugin.h:385
CTX_LOCK_UINT8
struct CTX_LOCK_UINT8 CTX_LOCK_UINT8
Data structure to enable access in a DU Link callback to a uint8_t requiring thread access protection...
DUTR_PARAM_BUFLEN
#define DUTR_PARAM_BUFLEN
Defines the buffer size of the input parameters for DU Transport, used by DULINK_CONNECT_INFO.
Definition: duplugin.h:371
DUTR_SEC_TYPE
DUTR_SEC_TYPE
Defines DU-Transport security protocols.
Definition: dutransport.h:61
listNodeCB
DU_RCODE listNodeCB(const char *pRequestPath, const char *pOriginPath, void *pCtx, uint64_t offset, uint64_t length, void *pBuf, DULINK_CB_OPERATION operation, uint64_t *pRetVal)
Callback for read-only .list nodes.
replaceContentRoot
DU_RCODE replaceContentRoot(char *pStr, const char *pContRootVal, uint64_t bufLen)
Replace $CONTENT_ROOT$ in path string to actual content.
getPluginConnInfo
DU_RCODE getPluginConnInfo(const char *pPluginName, PDULINK_CONNECT_INFO pInfo)
Get plugin connection info for DU-Link open.
VALIDATOR
@ VALIDATOR
Definition: duplugin.h:383
DULINK_EXPORT_REQS
struct DULINK_EXPORT_REQS DULINK_EXPORT_REQS
Data structure to define DU Link node to be exported by a DRIVE Update plugin via exportDULinkNodes.
PDULINK_CONNECT_INFO
struct DULINK_CONNECT_INFO * PDULINK_CONNECT_INFO
CONTENT_PROVIDER
@ CONTENT_PROVIDER
Definition: duplugin.h:381
INSTALLER
@ INSTALLER
Definition: duplugin.h:380
readOnlyRunlevelCB
DU_RCODE readOnlyRunlevelCB(const char *pRequestPath, const char *pOriginPath, void *pCtx, uint64_t offset, uint64_t length, void *pBuf, DULINK_CB_OPERATION operation, uint64_t *pRetVal)
Callback for read-only runlevel nodes.
DUPLUGIN_TYPE
DUPLUGIN_TYPE
Defines all of the valid DRIVE Update plugin types.
Definition: duplugin.h:377
CTX_LOCK_RL
struct CTX_LOCK_RL CTX_LOCK_RL
Data structure to enable access in a DU Link callback to a DU_RUN_LEVEL requiring thread access prote...
DULINK_CONNECTION_ROLE
DULINK_CONNECTION_ROLE
Role of DU LINK connection.
Definition: duplugin.h:391
PCTX_LIST_STR
struct CTX_LIST_STR * PCTX_LIST_STR
DULINK_CONNECT_PLUGIN
@ DULINK_CONNECT_PLUGIN
Plugin.
Definition: duplugin.h:396
CTX_LIST_STR
Data structure to enable reading a list of values in a DU Link callback.
Definition: duplugin.h:454
CTX_LIST_STR::size
const uint8_t size
Number of items in the list.
Definition: duplugin.h:457
CTX_LOCK_STR::pMutex
pthread_mutex_t * pMutex
Will be locked before reading from pStr.
Definition: duplugin.h:424
CTX_LIST_STR
struct CTX_LIST_STR CTX_LIST_STR
Data structure to enable reading a list of values in a DU Link callback.
PCTX_LOCK_RL
struct CTX_LOCK_RL * PCTX_LOCK_RL
PCTX_LOCK_STR
struct CTX_LOCK_STR * PCTX_LOCK_STR