summaryrefslogtreecommitdiffstats
path: root/otherservice/rpc_library/library/include/other_service/rpc.h
blob: 6947134c6efb43d72c62511bcb04e44894cb4546 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
/*
 * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file rpc.h
 * @brief \~english RPC library --API define header file
 */
/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup other_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup rpc_library
 *  @ingroup other_service
 *  @{
 */
#ifndef OTHERSERVICE_RPC_H_  // NOLINT(build/header_guard)
#define OTHERSERVICE_RPC_H_  // NOLINT(build/header_guard)

#include <stdio.h>
#include <unistd.h>

#include <other_service/rpc_id.h>

#ifdef __cplusplus
extern "C" {
#endif

/** 
*   @brief \~english RPC_ID max number
*/
#define RPC_MAX_THREADS_IN_PROCESS 64

/** @brief \~english fd max number in one process.
 *  0  = main/sub thread communication pipe fd.
 *  1  =  inotify() process listen fd.
 *  2~129  =  even num : API request data socket.
 *  odd num :  secure stream socket.
 *         */
#define RPC_MAX_FD_IN_PROCESS 130


#define RPC_MAX_API_ARG_NUM 8
///< \~english API call parameter max num


#define RPC_MAX_API_ARG_SIZE 1024
///< \~english API call one parameter max byte

#define RPC_MAX_API_ARG_TOTAL_SIZE 1500
///< \~english API call all parameter max byte

#define RPC_MAX_APICALL_QUEUE 16
///< \~english API call max queue num

#define RPC_NO_PORT 0
///< \~english invalid port num

/** @brief \~english RPC library function return value
 */
enum rpc_result {  // NOLINT (readability/nolint)
  RPC_OK = 0,  ///< \~english ok
  RPC_ERR_No_Response = 0x8fff0000,   ///< \~english has no response
  RPC_ERR_Timeout,   ///< \~english timeout
  RPC_ERR_Busy,  ///< \~english busy
  RPC_ERR_API_Error,  ///< \~english API error
  RPC_ERR_API_Fatal,  ///< \~english API fatal
  RPC_ERR_Fatal,   ///< \~english fatal
  RPC_ERR_Configuration,  ///< \~english configuration
  RPC_ERR_Server_DeadLock,  ///< \~english server deadlock
  RPC_ERR_Server_Finish,   ///< \~english server finish
  RPC_ERR_Reject_connect,   ///< \~english  reject connect
};
/** @brief \~english RPC library function return type
 *         @see rpc_result
 *         */
typedef INT32 RPC_Result;

/** @brief \~english RPC ID
 *
 */
typedef UINT32 RPC_ID;

#define RPC_NO_ID RPC_NO_PORT
///< \~english The ID when destination is invalid

#define RPC_SELF_ID RPC_NO_PORT
///< \~english The ID when destination is self

/** @brief \~english The ID when destination is any
 *         */
#define RPC_ANY_ID RPC_NO_PORT


typedef RPC_Result (*RPC_dispatch_func_t)(UINT16 api_num,
            const char *args_string,
            unsigned int args_size,
            char **ret_string,
            unsigned int *ret_bytes);

#ifdef RPC_DISPATCH_FUNC
#error "Please include <rpc.h> before \"*_srvr.h\"."
#else /* !RPC_DISPATCH_FUNC */
#define RPC_DISPATCH_FUNC NULL
#endif /* !RPC_DISPATCH_FUNC */

/* RPC Library Start Function Macro */
/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_START_SERVER
/// \~english @par Brief
///     server start(certification of the client by UID)
/// \~english @param [in] ID
///     RPC_ID - program's RPC_ID
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///       - Case of an input parameter error
///       - Case of fail to information generation
///       - When RPC_start has already been issued
///       - Case of space reservation fails
///       - Case of socket generation fails
///       - Case of socket allocation fails
///       - Case of creating a pipe fails
///         - RPC_ERR_Fatal
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///       - Used when the server program of RPC-API performs RPC library use start processing
///       - ID specifies a symbol in the form of XXX_RPC_ID defined by rpc_id.h
///       - Only one server program is permitted per thread
///       - When the server program calls the API as a client of another server,
///         it only needs to call RPC_START_SERVER, there is no need to call RPC_START_CLIENT
/// \~english @see RPC_start, RPC_end
////////////////////////////////////////////////////////////////////////////////////
#define RPC_START_SERVER(ID) RPC_start((ID), RPC_DISPATCH_FUNC, NULL, NO_SECURE_CHECK)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_START_SECURE_SERVER
/// \~english @par Brief
///     server start(certification of the client by UID)
/// \~english @param [in] ID
///     RPC_ID - program's RPC_ID
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///       - Case of an input parameter error
///       - Case of fail to information generation
///       - When RPC_start has already been issued
///       - Case of space reservation fails
///       - Case of socket generation fails
///       - Case of socket allocation fails
///       - Case of creating a pipe fails
///         - RPC_ERR_Fatal
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///       - Used when the server program of RPC-API performs RPC library use start processing
///       - ID specifies a symbol in the form of XXX_RPC_ID defined by rpc_id.h
///       - Only one server program is permitted per thread
///       - When the server program calls the API as a client of another server,
///         it only needs to call RPC_START_SERVER, there is no need to call RPC_START_CLIENT
/// \~english @see RPC_start, RPC_end
////////////////////////////////////////////////////////////////////////////////////
#define RPC_START_SECURE_SERVER(ID) RPC_start((ID), RPC_DISPATCH_FUNC, NULL, NEED_SECURE_CHECK)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_START_CLIENT
/// \~english @par Brief
///     client start
/// \~english @param [out] pID
///     RPC_ID * - auto allocated program's RPC_ID
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - input parameter error
///     - Unable to get the rpc lib info for the self-thread.
///     - Memory allocation fail for id info.
///     - Socket generation fail.
///     - Socket allocation fail.
///     - Unable to get the socket name.
///         - RPC_ERR_Fatal
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - This macro supports only client function of RPC library.
///     - Run the start processing by using this macro only when the APIs provided by the other program are called.
/// \~english @see RPC_start, RPC_end
////////////////////////////////////////////////////////////////////////////////////
#define RPC_START_CLIENT(pID) RPC_start((UINT16)RPC_NO_ID, NULL, (pID), NO_SECURE_CHECK)
//!< \~english client start

/* Client authentication by registering the server's UID list */
#define NEED_SECURE_CHECK 1  ///< \~english  has secure check
#define NO_SECURE_CHECK 0  ///< \~english  has no secure check

/* Setting whether to register UID list of server */
#define REGISTERED 1  ///< \~english registered
#define NO_REGISTERED 0  ///< \~english not registered

/* API Function Prototypes in the RPC Library */
RPC_Result RPC_start(RPC_ID id, RPC_dispatch_func_t func, RPC_ID *pID, INT32 secure_check);  // NOLINT (readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_get_fd
/// \~english @par Brief
///     Get the file descriptor to judge whether there is the request of RPC-API call or not.
/// \~english @param [in] id
///     RPC_ID - server program's RPC_ID
/// \~english @param [out] fd
///     int * - area for fd
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @par Prerequisite
///     RPC_START_SERVER or RPC_START_SECURE_SERVER is already called.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - Argument(id) is RPC_NO_ID.
///     - Argument(fd) is NULL.
///     - Unable to get the rpc lib info for the self-thread.
///     - RPC sub thread doesn't exist.
///       - RPC_ERR_Fatal
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - This function returns the fd(file descriptor) to judge whether there is the request to server.
///     - Return value(fd) is used only for poll function or select function parameter.
///     - Usage
///       - To get fd from this function.
///       - Wait for the data to use poll function or select function.
///       - After that, call RPC_process_API_request function.
///       - As a result, the API call request from client is done(that is, run the server API).
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
RPC_Result RPC_get_fd(RPC_ID id, int *fd);  // NOLINT (readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_process_API_request
/// \~english @par Brief
///     Run the processing of RPC-API call
/// \~english @param [in] id
///     RPC_ID - server program's RPC_ID
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @par Prerequisite
///     RPC_START_SERVER or RPC_START_SECURE_SERVER is already called.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - Argument(id) is RPC_NO_ID.
///     - Unable to get the rpc lib info for the self-thread.
///     - RPC sub thread doesn't exist.
///     - fail to send UDP packet.
///     - API processing from the client returns the error.
///       - RPC_ERR_Fatal
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - Process all the queued API running requests from the client.
///     - API function of server program is called in this function.
///     - If there are no requests to run API, this function doesn't wait and return immediately.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
RPC_Result RPC_process_API_request(RPC_ID id);  // NOLINT (readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_end
/// \~english @par Brief
///     End processing of RPC library.
/// \~english @param [in] id
///     RPC_ID - program's RPC_ID
/// \~english @retval None
/// \~english @par Prerequisite
///     RPC_START_SERVER or RPC_START_SECURE_SERVER or RPC_START_CLIENT is already called.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     None
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - End processing(socket close and memory release etc) is done.
///     - When there are no more program that uses RPC_ID, RPC sub thread started by RPC_start will be ended.
///     - Need to call this function before the program is ended.
///     - Need to call this function from which the thread called RPC_start.
///     - Nothing is done when incorrect or no more used RPC_ID is designated.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
void RPC_end(RPC_ID id);  // NOLINT (readability/nolint)

////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_end_all
/// \~english @par Brief
///     End processing of RPC library(forcing to clean up).
/// \~english @par Prerequisite
///       - None
/// \~english @par Change of internal state
///       - None
/// \~english @par Conditions of processing failure
///       - None
/// \~english @par Classification
///       Public
/// \~english @par Type
///       Sync Only
/// \~english @par Detail
///       Delete the socket files created in process for communication. /n
///       The program which use RPC library must call RPC_end() to free resource, /n
///       This API is used for insurance processing when socket file's link lost. /n
///       1,Before process ends, call this API. /n
///         When process is ending, auto running socket's close and memory free is not work. /n
///       2,After called this API, all the RPC's process(both server and client) become to useless. /n
///         Even if after called this API, call RPC_START to repair it also can't make sure to active. /n
///       RPC library which use Unix autobind is nothing to do. /n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
void RPC_end_all(void);  // NOLINT (readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_set_API_timeout
/// \~english @par Brief
///     Set timeout time for server side API processing time
/// \~english @param [in] sec
///     INT32 - timeout time
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @retval RPC_ERR_Configuration Argument is out of range
/// \~english @par Prerequisite
///     RPC_START_SERVER or RPC_START_SECURE_SERVER is already called.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - Unable to get the rpc lib info for the self-thread.
///     - Server id info doesn't exist.
///     - Info for API call reception processing doesn't exist.
///       - RPC_ERR_Fatal
///     - The value of the argument(sec) is out of range.
///       - RPC_ERR_Configuration
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     None
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
RPC_Result RPC_set_API_timeout(INT32 sec);  // NOLINT (readability/nolint)


////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_is_server_ready
/// \~english @par Brief
///       Return RPC server's status
/// \~english @param [in] id
///       RPC_ID  -  server program's RPC_ID
///
/// \~english @retval RPC_OK : Success
/// \~english @retval RPC_ERR_No_Response : No response
///
/// \~english @par Prerequisite
///       - None
/// \~english @par Change of internal state
///       - None
/// \~english @par Conditions of processing failure
///       - None
/// \~english @par Classification
///       Public
/// \~english @par Type
///       Sync Only
/// \~english @par Detail
///       return the server's work status.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
RPC_Result RPC_is_server_ready(RPC_ID id);  // NOLINT (readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_regist_credential
/// \~english @par Brief
///     Register UID and GID list
/// \~english @param [in] uid_num
///     int - UID number to regist(number of elements of UID list)
/// \~english @param [in] uid_list
///     uid_t* - head pointer of UID list
/// \~english @param [in] gid_num
///     int - GID number to regist(number of elements of GID list)
/// \~english @param [in] uid_list
///     gid_t* - head pointer of GID list
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @retval RPC_ERR_Configuration Argument is out of range
/// \~english @par Prerequisite
///     RPC_START_SECURE_SERVER is already called.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - Unable to get the rpc lib info for the self-thread.
///     - Server id info doesn't exist.
///     - Info for API call reception processing doesn't exist.
///     - Arguments(client_uid and client_gid) are NULL.
///     - Client authentication check is not necessary.
///     - Authentication info is already registered.
///     - Memory allocation fail for UID and GID lists.
///       - RPC_ERR_Fatal
///     - Values of Arguments(uid_num and gid_num) are out of range.
///       - RPC_ERR_Configuration
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - Register the UID and GID lists acceptable by the RPC server.
///     - If RPC_START_SECURE_SERVER is not called, this function returns the error.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
RPC_Result RPC_regist_credential(int uid_num, uid_t *uid_list, int gid_num, gid_t *gid_list);  // NOLINT (readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_get_client_credential
/// \~english @par Brief
///     Get UID and GID of client that requested to run APIs processing
/// \~english @param [out] client_uid
///     uid_t* - UID of client that requested to run APIs processing
/// \~english @param [out] client_gid
///     gid_t* - GID of client that requested to run APIs processing
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal Error
/// \~english @par Prerequisite
///     RPC_START_SECURE_SERVER is already called.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - Server id info doesn't exist.
///     - Info for API call reception processing doesn't exist.
///     - Arguments(client_uid and client_gid) are NULL.
///     - Client authentication check is not necessary.
///     - There are no running clients.
///     - Info for the running client is not applicable.
///       - RPC_ERR_Fatal
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - This function is to get UID and GID of client that requested to run APIs processing.
///     - If RPC_START_SECURE_SERVER is not called, this function returns the error.
///     - If the running client doesn't exist, this function returns the error.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
RPC_Result RPC_get_client_credential(uid_t *client_uid, gid_t *client_gid);  // NOLINT (readability/nolint)

/*
 * The following are only used in stub files
 */
#define RPC_RETCODE_LEN 9

#define RPC_MARSHALL_FLAG_BITS_CODE 12
#define RPC_MARSHALL_FLAG_BITS_IS_VARARRAY 1
#define RPC_MARSHALL_FLAG_BITS_IS_POINTER 1
#define RPC_MARSHALL_FLAG_BITS_IN_OUT 2

/** @brief \~english  APIcall property stored struct
 *
 */
typedef union {
  UINT32 all;  ///< \~english all property
  struct {
    unsigned int code: RPC_MARSHALL_FLAG_BITS_CODE;   ///< \~english value type
    /** @brief \~english  vararray or not
     *
     */
    unsigned int is_vararray: RPC_MARSHALL_FLAG_BITS_IS_VARARRAY;
    /** @brief \~english  pointer or not
     *
     */
    unsigned int is_pointer: RPC_MARSHALL_FLAG_BITS_IS_POINTER;
    /** @brief \~english  in/out parameter property
     *
     */
    unsigned int in_out: RPC_MARSHALL_FLAG_BITS_IN_OUT;
    /** @brief \~english  string or user define type byte num.other is 0
     *
     */
    UINT16 bytes;
  } bits;   ///< \~english variable properties
} RPC_marshall_flag;

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_API_call
/// \~english @par brief
///     API call execution function (client)
/// \~english @param [in] id
///     RPC_ID - RPC_ID of server program
/// \~english @param [in] api_num
///     UINT16 - Request API number
/// \~english @param [in] args_string
///     const char* - Argument string
/// \~english @param [in] args_size
///     unsigned int - Argument string length
/// \~english @param [out] ret_string
///     char** - Process result string
/// \~english @param [out] ret_size
///     unsigned int* - Process result string length
/// \~english @retval RPC_OK Normal End
/// \~english @retval RPC_ERR_Fatal Fatal error
/// \~english @retval RPC_ERR_No_Response No response
/// \~english @retval RPC_ERR_Busy API call queue overflow
/// \~english @retval RPC_ERR_Server_DeadLock RPC server deadlock
/// \~english @retval RPC_ERR_Reject_connect The RPC server does not allow communication
/// \~english @par Prerequisite
///     The RPC server is running.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - Acquisition of rpc library information for self thread fails
///     - Generation of self-thread rpc library information fails
///     - The RPC ID information does not exist
///     - Failed to receive data from the server at initial authentication
///     - Analysis of received data failed during initial authentication
///     - Commands not expected to be received during initial authentication
///     - Server response when initial authentication is API call error
///     - Failed to receive data from the server at API processing request
///     - Analysis of received data failed during API processing request
///     - Commands not expected to be received during API processing request
///     - Server response when API processing request is API call error
///     - Error in server response other than deadlock when processing results are received
///     - Server shut down
///         - RPC_ERR_Fatal
///     - UDP packet transmission fails at initial authentication
///     - A timeout occurred in response from the server during initial authentication
///     - UDP packet transmission failed at API processing request
///     - A timeout occurred in response from the server during API processing request
///         - RPC_ERR_No_Response
///     - Server response when initial authentication is API call queue overflow
///     - Server response when API processing request is API call queue overflow
///         - RPC_ERR_Busy
///     - When the server response is deadlocked on initial authentication
///     - When the server response is deadlocked on API processing request
///     - Server response is deadlocked when processing result is received
///         - RPC_ERR_Server_DeadLock
///     - Server response is not authenticated at initial authentication
///         - RPC_ERR_Reject_connect
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - Request execution of RPC-API from the client side.
///     - However, since this API is called from the automatically generated code, it is not used directly by the user.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
RPC_Result RPC_API_call(RPC_ID id, UINT16 api_num,  // NOLINT (readability/nolint)
      const char *args_string, unsigned int args_size,
      char **ret_string, unsigned int *ret_size);

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_demarshall_arguments
/// \~english @par Brief
///     Confirm whether the input character string conforms to the prescribed format.
/// \~english @param [in] from
///     const char * - Input string
/// \~english @param [in] size
///     unsigned int - Byte length of the input string
/// \~english @param [in] need_alloc
///     int - Flag whether memory allocation is necessary or not.
/// \~english @param [in] num_args
///     int - Number of the variable length arguments
/// \~english @param [in] ...
///     void * - Variable length arguments
/// \~english @retval  0 Normal End
/// \~english @retval -1 Abnormal End
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - Byte length of the input string is 0 bytes or less or larger than 1024 bytes.
///     - The input character string doesn't conform to the prescribed format.
///       - -1
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     This function is used in the stub file only and user must not call this function directly.
/// \~english @see RPC_marshall_arguments
////////////////////////////////////////////////////////////////////////////////////
int RPC_demarshall_arguments(const char *from, unsigned int size,  // NOLINT (readability/nolint)
           int need_alloc, int num_args, ...);

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_marshall_arguments
/// \~english @par Brief
///     Collect variable arguments, convert them to a format that matches the receiver's specification,
///     and stuff them into the message buffer.
/// \~english @param [in] size
///     unsigned int * - data size after conversion
/// \~english @param [in] dont_marshall_out_args
///     int - input/output kind(when the argument is a pointer)
/// \~english @param [in] num_args
///     int - value of variable argument
/// \~english @param [in] ...
///     void * - variable argument
/// \~english @retval char * Message buffer after conversion
/// \~english @retval NULL   Abnormal
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     - When marshall work securing work area fails
///     - When the specified type size is abnormal
///     - When securing the area of the message buffer after conversion fails
///       - NULL
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     This function is used in the stub file for client only and user must not call this function directly.
/// \~english @see RPC_demarshalol_arguments
////////////////////////////////////////////////////////////////////////////////////
char *RPC_marshall_arguments(unsigned int *size, int dont_marshall_out_args,  // NOLINT (readability/nolint)
           int num_args, ...);

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_marshall_free
/// \~english @par Brief
///     Variadic function for memory release
/// \~english @param [in] num
///     int - number of memory to be released
/// \~english @param [in] ...
///     void * - allocated memory
/// \~english @retval None
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     None
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - This function is used in the stub file only and user must not call this function directly.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
void RPC_marshall_free(int num, ...);  // NOLINT (readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_free_return_string
/// \~english @par Brief
///     release memory allocated during running API call.
/// \~english @param [in] ptr
///     void * - allocated memory
/// \~english @retval None
/// \~english @par Prerequisite
///     RPC_API_call is already called.
/// \~english @par Change of internal state
///     None
/// \~english @par Conditions of processing failure
///     None
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync Only
/// \~english @par Detail
///     - This function is used in the stub file for client only and user must not call this function directly.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////
void RPC_free_return_string(void *ptr);  // NOLINT (readability/nolint)

#ifdef DBG_ENABLE

////////////////////////////////////////////////////////////////////////////////
/// \ingroup RPC_record_dbg_log
/// \~english @par Brief
///       RPC-API call process's log
/// \~english @param [in] filename
///       const char  -  filename's point
/// \~english @param [in] funcname
///       const char  -  function name's point
/// \~english @param [in] line
///       int         -  file's line
/// \~english @param [in] apiname
///       const char  - called API name's point
/// \~english @param [out]
///
/// \~english @retval 0 : Success
///
/// \~english @par Prerequisite
///       - DBG_ENABLE is defined.
/// \~english @par Change of internal state
///       - None
/// \~english @par Conditions of processing failure
///       - None
/// \~english @par Classification
///       Public
/// \~english @par Type
///       Sync Only
/// \~english @par Detail
///       Receipt and record the client's filename, function name,
///       line and called API's function name which called this API.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
int RPC_record_dbg_log(const char *filename, const char *funcname, int line,
  const char *apiname);
#endif

#define rpc_malloc malloc
#define rpc_free free

/*
 * RPC debug message control
 * if set to non-null and some critical information is displayed.
 */
extern char *RPC_DEBUG;  // NOLINT (readability/nolint)

/** @}*/  // end of rpc_library
/** @}*/  // end of other_service
/** @}*/  // end of BaseSystem

#ifdef __cplusplus
}
#endif

#endif  // OTHERSERVICE_RPC_H_