1c42ebd011f85abee46c350094dc2f6fd0ff1347
[platform/upstream/curl.git] / extensions / tizen_dlp.c
1 /**
2  * @file        tizen_dlp.cpp
3  * @brief       external API functions for DLP
4  */
5
6 #include <dlfcn.h>
7
8 #define LIBRARY_PATH "/lib/libprivacy-guard-client.so"
9
10 static int first_run = 1;
11 static void (*privacy_guard_dlp_init)(void) = 0;
12 static void (*privacy_guard_dlp_check_leak)(const char *, char * const, size_t) = 0;
13
14 /**
15  * @fn void tizen_dlp_init(void)
16  * @brief Initialize the DLP creating the Load Rules and Logging threads
17  * @callgraph
18  */
19 void tizen_dlp_init(void)
20 {
21     if (first_run) {
22         void *handle = dlopen(LIBRARY_PATH, RTLD_LAZY);
23         if (handle) {
24             privacy_guard_dlp_init = dlsym(handle, "privacy_guard_dlp_init");
25             privacy_guard_dlp_check_leak = dlsym(handle, "privacy_guard_dlp_check_leak");
26         }
27         first_run = 0;
28     }
29
30     if (privacy_guard_dlp_init)
31         privacy_guard_dlp_init();
32 }
33
34 /**
35  * @fn void tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len)
36  * @brief Checks for information leak on a given request string
37  *
38  * @param[in] hostname                                  The hostname of the server to which the request will be sent
39  * @param[in] mem                                               Text that we are going to validate for info leak
40  * @param[in] len                                               Size of len in bytes
41  *
42  * @return  either PRIV_GUARD_DLP_RESULT_ALLOW or PRIV_GUARD_DLP_RESULT_DENY
43  * @callgraph
44  */
45 void tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len)
46 {
47     /**
48     * Send data to Tizen DLP verification
49     */
50     if(privacy_guard_dlp_check_leak)
51         privacy_guard_dlp_check_leak(hostname, mem, len);
52 }