removed trailing spaces ([[:space:]]+$)
[strongswan.git] / src / checksum / checksum_builder.c
index b917e11..54f4539 100644 (file)
 #include <library.h>
 
 /* we need to fake some charon symbols to dlopen() its plugins */
 #include <library.h>
 
 /* we need to fake some charon symbols to dlopen() its plugins */
-void *eap_type_names, *auth_class_names, *charon, *protocol_id_names, 
+void *charon, *eap_type_names, *auth_class_names, *protocol_id_names,
 *action_names, *ipsec_mode_names, *ike_sa_state_names, *child_sa_state_names,
 *action_names, *ipsec_mode_names, *ike_sa_state_names, *child_sa_state_names,
-*proposal_create_default, *peer_cfg_create, *ike_cfg_create, *child_cfg_create,
-*traffic_selector_create_dynamic, *callback_job_create, *delete_ike_sa_job_create,
-*eap_type_from_string, *auth_cfg_create, *proposal_create_from_string,
-*traffic_selector_create_from_subnet, *traffic_selector_create_from_bytes,
-*eap_payload_create_data, *ike_sa_create, *child_sa_create, *policy_dir_names,
-*controller_cb_empty, *proposal_create, *ipcomp_transform_names,
-*traffic_selector_create_from_string, *update_sa_job_create, *ike_sa_id_create,
-*rekey_child_sa_job_create, *roam_job_create, *migrate_job_create,
-*acquire_job_create, *delete_child_sa_job_create, *debug_names;
+*policy_dir_names, *ipcomp_transform_names, *debug_names, *controller_cb_empty;
 
 int main(int argc, char* argv[])
 {
        int i;
        integrity_checker_t *integrity;
 
 int main(int argc, char* argv[])
 {
        int i;
        integrity_checker_t *integrity;
-       
+
        /* avoid confusing leak reports in build process */
        setenv("LEAK_DETECTIVE_DISABLE", "1", 0);
        library_init(NULL);
        atexit(library_deinit);
        /* avoid confusing leak reports in build process */
        setenv("LEAK_DETECTIVE_DISABLE", "1", 0);
        library_init(NULL);
        atexit(library_deinit);
-       
+
        integrity = integrity_checker_create(NULL);
        integrity = integrity_checker_create(NULL);
-       
+
        printf("/**\n");
        printf(" * checksums of files and loaded code segments.\n");
        printf(" * created by %s\n", argv[0]);
        printf("/**\n");
        printf(" * checksums of files and loaded code segments.\n");
        printf(" * created by %s\n", argv[0]);
@@ -52,14 +44,18 @@ int main(int argc, char* argv[])
        printf("#include <library.h>\n");
        printf("\n");
        printf("integrity_checksum_t checksums[] = {\n");
        printf("#include <library.h>\n");
        printf("\n");
        printf("integrity_checksum_t checksums[] = {\n");
+       fprintf(stderr, "integrity test data:\n");
+       fprintf(stderr, "module name,       file size / checksum   segment size / checksum\n");
        for (i = 1; i < argc; i++)
        {
        for (i = 1; i < argc; i++)
        {
-               char *name, *path, *sname;
+               char *name, *path, *sname = NULL;
                void *handle, *symbol;
                u_int32_t fsum, ssum;
                void *handle, *symbol;
                u_int32_t fsum, ssum;
-               
+               size_t fsize = 0;
+               size_t ssize = 0;
+
                path = argv[i];
                path = argv[i];
-               
+
                if ((name = strstr(path, "libstrongswan-")))
                {
                        name = strdup(name + strlen("libstrongswan-"));
                if ((name = strstr(path, "libstrongswan-")))
                {
                        name = strdup(name + strlen("libstrongswan-"));
@@ -73,34 +69,63 @@ int main(int argc, char* argv[])
                        name = strdup("libstrongswan\",");
                        sname = "library_init";
                }
                        name = strdup("libstrongswan\",");
                        sname = "library_init";
                }
+               else if (strstr(path, "pool"))
+               {
+                       name = strdup("pool\",");
+               }
+               else if (strstr(path, "charon"))
+               {
+                       name = strdup("charon\",");
+               }
+               else if (strstr(path, "pluto"))
+               {
+                       name = strdup("pluto\",");
+               }
+               else if (strstr(path, "openac"))
+               {
+                       name = strdup("openac\",");
+               }
+               else if (strstr(path, "scepclient"))
+               {
+                       name = strdup("scepclient\",");
+               }
+               else if (strstr(path, "pki"))
+               {
+                       name = strdup("pki\",");
+               }
                else
                {
                        fprintf(stderr, "don't know how to handle '%s', ignored", path);
                        continue;
                }
                else
                {
                        fprintf(stderr, "don't know how to handle '%s', ignored", path);
                        continue;
                }
-               
-               fsum = integrity->build_file(integrity, path);
+
+               fsum = integrity->build_file(integrity, path, &fsize);
                ssum = 0;
                ssum = 0;
-               handle = dlopen(path, RTLD_LAZY);
-               if (handle)
+               if (sname)
                {
                {
-                       symbol = dlsym(handle, sname);
-                       if (symbol)
+                       handle = dlopen(path, RTLD_LAZY);
+                       if (handle)
                        {
                        {
-                               ssum = integrity->build_segment(integrity, symbol);
+                               symbol = dlsym(handle, sname);
+                               if (symbol)
+                               {
+                                       ssum = integrity->build_segment(integrity, symbol, &ssize);
+                               }
+                               else
+                               {
+                                       fprintf(stderr, "symbol lookup failed: %s\n", dlerror());
+                               }
+                               dlclose(handle);
                        }
                        else
                        {
                        }
                        else
                        {
-                               fprintf(stderr, "symbol lookup failed: %s\n", dlerror());
+                               fprintf(stderr, "dlopen failed: %s\n", dlerror());
                        }
                        }
-                       dlclose(handle);
                }
                }
-               else
-               {
-                       fprintf(stderr, "dlopen failed: %s\n", dlerror());
-               }
-               
-               printf("\t{\"%-20s0x%08x, 0x%08x},\n", name, fsum, ssum);
+               printf("\t{\"%-20s%7u, 0x%08x, %6u, 0x%08x},\n",
+                          name, fsize, fsum, ssize, ssum);
+               fprintf(stderr, "\"%-20s%7u / 0x%08x       %6u / 0x%08x\n",
+                               name, fsize, fsum, ssize, ssum);
                free(name);
        }
        printf("};\n");
                free(name);
        }
        printf("};\n");
@@ -108,7 +133,7 @@ int main(int argc, char* argv[])
        printf("int checksum_count = countof(checksums);\n");
        printf("\n");
        integrity->destroy(integrity);
        printf("int checksum_count = countof(checksums);\n");
        printf("\n");
        integrity->destroy(integrity);
-       
+
        exit(0);
 }
 
        exit(0);
 }