2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil, Switzerland
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 /* we need to fake some charon symbols to dlopen() its plugins */
23 void *eap_type_names
, *auth_class_names
, *charon
, *protocol_id_names
,
24 *action_names
, *ipsec_mode_names
, *ike_sa_state_names
, *child_sa_state_names
,
25 *proposal_create_default
, *peer_cfg_create
, *ike_cfg_create
, *child_cfg_create
,
26 *traffic_selector_create_dynamic
, *callback_job_create
, *delete_ike_sa_job_create
,
27 *eap_type_from_string
, *auth_cfg_create
, *proposal_create_from_string
,
28 *traffic_selector_create_from_subnet
, *traffic_selector_create_from_bytes
,
29 *eap_payload_create_data
, *ike_sa_create
, *child_sa_create
, *policy_dir_names
,
30 *controller_cb_empty
, *proposal_create
, *ipcomp_transform_names
,
31 *traffic_selector_create_from_string
, *update_sa_job_create
, *ike_sa_id_create
,
32 *rekey_child_sa_job_create
, *roam_job_create
, *migrate_job_create
,
33 *acquire_job_create
, *delete_child_sa_job_create
, *debug_names
;
35 int main(int argc
, char* argv
[])
38 integrity_checker_t
*integrity
;
40 /* avoid confusing leak reports in build process */
41 setenv("LEAK_DETECTIVE_DISABLE", "1", 0);
43 atexit(library_deinit
);
45 integrity
= integrity_checker_create(NULL
);
48 printf(" * checksums of files and loaded code segments.\n");
49 printf(" * created by %s\n", argv
[0]);
52 printf("#include <library.h>\n");
54 printf("integrity_checksum_t checksums[] = {\n");
55 for (i
= 1; i
< argc
; i
++)
57 char *name
, *path
, *sname
;
58 void *handle
, *symbol
;
63 if ((name
= strstr(path
, "libstrongswan-")))
65 name
= strdup(name
+ strlen("libstrongswan-"));
66 name
[strlen(name
) - 3] = '"';
67 name
[strlen(name
) - 2] = ',';
68 name
[strlen(name
) - 1] = '\0';
69 sname
= "plugin_create";
71 else if (strstr(path
, "libstrongswan.so"))
73 name
= strdup("libstrongswan\",");
74 sname
= "library_init";
78 fprintf(stderr
, "don't know how to handle '%s', ignored", path
);
82 fsum
= integrity
->build_file(integrity
, path
);
84 handle
= dlopen(path
, RTLD_LAZY
);
87 symbol
= dlsym(handle
, sname
);
90 ssum
= integrity
->build_segment(integrity
, symbol
);
94 fprintf(stderr
, "symbol lookup failed: %s\n", dlerror());
100 fprintf(stderr
, "dlopen failed: %s\n", dlerror());
103 printf("\t{\"%-20s0x%08x, 0x%08x},\n", name
, fsum
, ssum
);
108 printf("int checksum_count = countof(checksums);\n");
110 integrity
->destroy(integrity
);