]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
removed trailing spaces ([[:space:]]+$)
authorMartin Willi <martin@strongswan.org>
Fri, 4 Sep 2009 11:46:09 +0000 (13:46 +0200)
committerMartin Willi <martin@strongswan.org>
Fri, 4 Sep 2009 11:46:09 +0000 (13:46 +0200)
703 files changed:
scripts/bin2array.c
scripts/bin2sql.c
scripts/dh_speed.c
scripts/id2sql.c
scripts/key2keyid.c
scripts/keyid2sql.c
scripts/pubkey_speed.c
scripts/thread_analysis.c
src/_copyright/_copyright.c
src/charon/bus/bus.c
src/charon/bus/bus.h
src/charon/bus/listeners/file_logger.c
src/charon/bus/listeners/file_logger.h
src/charon/bus/listeners/listener.h
src/charon/bus/listeners/sys_logger.c
src/charon/bus/listeners/sys_logger.h
src/charon/config/attributes/attribute_handler.h
src/charon/config/attributes/attribute_manager.c
src/charon/config/attributes/attribute_manager.h
src/charon/config/attributes/attribute_provider.h
src/charon/config/auth_cfg.c
src/charon/config/auth_cfg.h
src/charon/config/backend_manager.c
src/charon/config/backend_manager.h
src/charon/config/child_cfg.c
src/charon/config/child_cfg.h
src/charon/config/ike_cfg.c
src/charon/config/ike_cfg.h
src/charon/config/peer_cfg.c
src/charon/config/peer_cfg.h
src/charon/config/proposal.c
src/charon/config/proposal.h
src/charon/config/traffic_selector.c
src/charon/config/traffic_selector.h
src/charon/control/controller.c
src/charon/control/controller.h
src/charon/credentials/credential_manager.c
src/charon/credentials/credential_manager.h
src/charon/credentials/credential_set.h
src/charon/credentials/sets/auth_cfg_wrapper.c
src/charon/credentials/sets/auth_cfg_wrapper.h
src/charon/credentials/sets/cert_cache.c
src/charon/credentials/sets/cert_cache.h
src/charon/credentials/sets/ocsp_response_wrapper.c
src/charon/credentials/sets/ocsp_response_wrapper.h
src/charon/daemon.c
src/charon/daemon.h
src/charon/encoding/generator.c
src/charon/encoding/generator.h
src/charon/encoding/message.c
src/charon/encoding/message.h
src/charon/encoding/parser.c
src/charon/encoding/parser.h
src/charon/encoding/payloads/auth_payload.c
src/charon/encoding/payloads/auth_payload.h
src/charon/encoding/payloads/cert_payload.c
src/charon/encoding/payloads/cert_payload.h
src/charon/encoding/payloads/certreq_payload.c
src/charon/encoding/payloads/certreq_payload.h
src/charon/encoding/payloads/configuration_attribute.c
src/charon/encoding/payloads/configuration_attribute.h
src/charon/encoding/payloads/cp_payload.c
src/charon/encoding/payloads/cp_payload.h
src/charon/encoding/payloads/delete_payload.c
src/charon/encoding/payloads/delete_payload.h
src/charon/encoding/payloads/eap_payload.c
src/charon/encoding/payloads/eap_payload.h
src/charon/encoding/payloads/encodings.h
src/charon/encoding/payloads/encryption_payload.c
src/charon/encoding/payloads/encryption_payload.h
src/charon/encoding/payloads/endpoint_notify.c
src/charon/encoding/payloads/endpoint_notify.h
src/charon/encoding/payloads/id_payload.c
src/charon/encoding/payloads/id_payload.h
src/charon/encoding/payloads/ike_header.c
src/charon/encoding/payloads/ike_header.h
src/charon/encoding/payloads/ke_payload.c
src/charon/encoding/payloads/ke_payload.h
src/charon/encoding/payloads/nonce_payload.c
src/charon/encoding/payloads/nonce_payload.h
src/charon/encoding/payloads/notify_payload.c
src/charon/encoding/payloads/notify_payload.h
src/charon/encoding/payloads/payload.h
src/charon/encoding/payloads/proposal_substructure.c
src/charon/encoding/payloads/proposal_substructure.h
src/charon/encoding/payloads/sa_payload.c
src/charon/encoding/payloads/sa_payload.h
src/charon/encoding/payloads/traffic_selector_substructure.c
src/charon/encoding/payloads/traffic_selector_substructure.h
src/charon/encoding/payloads/transform_attribute.c
src/charon/encoding/payloads/transform_attribute.h
src/charon/encoding/payloads/transform_substructure.c
src/charon/encoding/payloads/transform_substructure.h
src/charon/encoding/payloads/ts_payload.c
src/charon/encoding/payloads/ts_payload.h
src/charon/encoding/payloads/unknown_payload.c
src/charon/encoding/payloads/unknown_payload.h
src/charon/encoding/payloads/vendor_id_payload.c
src/charon/encoding/payloads/vendor_id_payload.h
src/charon/kernel/kernel_interface.c
src/charon/kernel/kernel_interface.h
src/charon/kernel/kernel_ipsec.h
src/charon/kernel/kernel_net.h
src/charon/network/packet.c
src/charon/network/packet.h
src/charon/network/receiver.c
src/charon/network/receiver.h
src/charon/network/sender.c
src/charon/network/sender.h
src/charon/network/socket-raw.c
src/charon/network/socket.c
src/charon/network/socket.h
src/charon/plugins/attr/attr_plugin.c
src/charon/plugins/attr/attr_plugin.h
src/charon/plugins/attr/attr_provider.c
src/charon/plugins/attr/attr_provider.h
src/charon/plugins/eap_aka/eap_aka.c
src/charon/plugins/eap_aka/eap_aka_plugin.c
src/charon/plugins/eap_gtc/eap_gtc.c
src/charon/plugins/eap_gtc/eap_gtc_plugin.c
src/charon/plugins/eap_identity/eap_identity.c
src/charon/plugins/eap_identity/eap_identity_plugin.c
src/charon/plugins/eap_md5/eap_md5.c
src/charon/plugins/eap_md5/eap_md5_plugin.c
src/charon/plugins/eap_mschapv2/eap_mschapv2.c
src/charon/plugins/eap_mschapv2/eap_mschapv2_plugin.c
src/charon/plugins/eap_radius/eap_radius.c
src/charon/plugins/eap_radius/eap_radius_plugin.c
src/charon/plugins/eap_radius/radius_client.c
src/charon/plugins/eap_radius/radius_client.h
src/charon/plugins/eap_radius/radius_message.c
src/charon/plugins/eap_radius/radius_message.h
src/charon/plugins/eap_sim/eap_sim.c
src/charon/plugins/eap_sim/eap_sim_plugin.c
src/charon/plugins/eap_sim_file/eap_sim_file_card.c
src/charon/plugins/eap_sim_file/eap_sim_file_card.h
src/charon/plugins/eap_sim_file/eap_sim_file_plugin.c
src/charon/plugins/eap_sim_file/eap_sim_file_provider.c
src/charon/plugins/eap_sim_file/eap_sim_file_provider.h
src/charon/plugins/eap_sim_file/eap_sim_file_triplets.c
src/charon/plugins/kernel_klips/kernel_klips_ipsec.c
src/charon/plugins/kernel_klips/kernel_klips_plugin.c
src/charon/plugins/kernel_klips/pfkeyv2.h
src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c
src/charon/plugins/kernel_netlink/kernel_netlink_net.c
src/charon/plugins/kernel_netlink/kernel_netlink_plugin.c
src/charon/plugins/kernel_netlink/kernel_netlink_shared.c
src/charon/plugins/kernel_netlink/kernel_netlink_shared.h
src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c
src/charon/plugins/kernel_pfkey/kernel_pfkey_plugin.c
src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c
src/charon/plugins/kernel_pfroute/kernel_pfroute_plugin.c
src/charon/plugins/load_tester/load_tester_config.c
src/charon/plugins/load_tester/load_tester_config.h
src/charon/plugins/load_tester/load_tester_creds.c
src/charon/plugins/load_tester/load_tester_creds.h
src/charon/plugins/load_tester/load_tester_diffie_hellman.c
src/charon/plugins/load_tester/load_tester_diffie_hellman.h
src/charon/plugins/load_tester/load_tester_ipsec.c
src/charon/plugins/load_tester/load_tester_listener.c
src/charon/plugins/load_tester/load_tester_listener.h
src/charon/plugins/load_tester/load_tester_plugin.c
src/charon/plugins/load_tester/load_tester_plugin.h
src/charon/plugins/medcli/medcli_config.c
src/charon/plugins/medcli/medcli_config.h
src/charon/plugins/medcli/medcli_creds.c
src/charon/plugins/medcli/medcli_creds.h
src/charon/plugins/medcli/medcli_listener.c
src/charon/plugins/medcli/medcli_listener.h
src/charon/plugins/medcli/medcli_plugin.c
src/charon/plugins/medsrv/medsrv_config.c
src/charon/plugins/medsrv/medsrv_config.h
src/charon/plugins/medsrv/medsrv_creds.c
src/charon/plugins/medsrv/medsrv_creds.h
src/charon/plugins/medsrv/medsrv_plugin.c
src/charon/plugins/nm/gnome/auth-dialog/main.c
src/charon/plugins/nm/gnome/properties/nm-strongswan.c
src/charon/plugins/nm/gnome/properties/nm-strongswan.h
src/charon/plugins/nm/nm_creds.c
src/charon/plugins/nm/nm_creds.h
src/charon/plugins/nm/nm_handler.c
src/charon/plugins/nm/nm_handler.h
src/charon/plugins/nm/nm_plugin.c
src/charon/plugins/nm/nm_service.c
src/charon/plugins/resolv_conf/resolv_conf_handler.c
src/charon/plugins/resolv_conf/resolv_conf_handler.h
src/charon/plugins/resolv_conf/resolv_conf_plugin.c
src/charon/plugins/resolv_conf/resolv_conf_plugin.h
src/charon/plugins/smp/smp.c
src/charon/plugins/sql/pool.c
src/charon/plugins/sql/sql_attribute.c
src/charon/plugins/sql/sql_attribute.h
src/charon/plugins/sql/sql_config.c
src/charon/plugins/sql/sql_config.h
src/charon/plugins/sql/sql_cred.c
src/charon/plugins/sql/sql_cred.h
src/charon/plugins/sql/sql_logger.c
src/charon/plugins/sql/sql_logger.h
src/charon/plugins/sql/sql_plugin.c
src/charon/plugins/stroke/stroke_attribute.c
src/charon/plugins/stroke/stroke_attribute.h
src/charon/plugins/stroke/stroke_ca.c
src/charon/plugins/stroke/stroke_ca.h
src/charon/plugins/stroke/stroke_config.c
src/charon/plugins/stroke/stroke_config.h
src/charon/plugins/stroke/stroke_control.c
src/charon/plugins/stroke/stroke_control.h
src/charon/plugins/stroke/stroke_cred.c
src/charon/plugins/stroke/stroke_cred.h
src/charon/plugins/stroke/stroke_list.c
src/charon/plugins/stroke/stroke_list.h
src/charon/plugins/stroke/stroke_plugin.c
src/charon/plugins/stroke/stroke_plugin.h
src/charon/plugins/stroke/stroke_shared_key.c
src/charon/plugins/stroke/stroke_shared_key.h
src/charon/plugins/stroke/stroke_socket.c
src/charon/plugins/stroke/stroke_socket.h
src/charon/plugins/uci/uci_config.c
src/charon/plugins/uci/uci_config.h
src/charon/plugins/uci/uci_control.c
src/charon/plugins/uci/uci_control.h
src/charon/plugins/uci/uci_creds.c
src/charon/plugins/uci/uci_creds.h
src/charon/plugins/uci/uci_parser.c
src/charon/plugins/uci/uci_parser.h
src/charon/plugins/uci/uci_plugin.c
src/charon/plugins/unit_tester/tests.h
src/charon/plugins/unit_tester/tests/test_agent.c
src/charon/plugins/unit_tester/tests/test_auth_info.c
src/charon/plugins/unit_tester/tests/test_cert.c
src/charon/plugins/unit_tester/tests/test_chunk.c
src/charon/plugins/unit_tester/tests/test_curl.c
src/charon/plugins/unit_tester/tests/test_enumerator.c
src/charon/plugins/unit_tester/tests/test_id.c
src/charon/plugins/unit_tester/tests/test_med_db.c
src/charon/plugins/unit_tester/tests/test_mutex.c
src/charon/plugins/unit_tester/tests/test_mysql.c
src/charon/plugins/unit_tester/tests/test_pool.c
src/charon/plugins/unit_tester/tests/test_rsa_gen.c
src/charon/plugins/unit_tester/tests/test_sqlite.c
src/charon/plugins/unit_tester/unit_tester.c
src/charon/plugins/unit_tester/unit_tester.h
src/charon/plugins/updown/updown_listener.c
src/charon/plugins/updown/updown_listener.h
src/charon/plugins/updown/updown_plugin.c
src/charon/processing/jobs/acquire_job.c
src/charon/processing/jobs/acquire_job.h
src/charon/processing/jobs/callback_job.c
src/charon/processing/jobs/callback_job.h
src/charon/processing/jobs/delete_child_sa_job.c
src/charon/processing/jobs/delete_child_sa_job.h
src/charon/processing/jobs/delete_ike_sa_job.c
src/charon/processing/jobs/delete_ike_sa_job.h
src/charon/processing/jobs/initiate_mediation_job.c
src/charon/processing/jobs/initiate_mediation_job.h
src/charon/processing/jobs/job.h
src/charon/processing/jobs/mediation_job.c
src/charon/processing/jobs/mediation_job.h
src/charon/processing/jobs/migrate_job.c
src/charon/processing/jobs/migrate_job.h
src/charon/processing/jobs/process_message_job.c
src/charon/processing/jobs/process_message_job.h
src/charon/processing/jobs/rekey_child_sa_job.c
src/charon/processing/jobs/rekey_child_sa_job.h
src/charon/processing/jobs/rekey_ike_sa_job.c
src/charon/processing/jobs/rekey_ike_sa_job.h
src/charon/processing/jobs/retransmit_job.c
src/charon/processing/jobs/retransmit_job.h
src/charon/processing/jobs/roam_job.c
src/charon/processing/jobs/roam_job.h
src/charon/processing/jobs/send_dpd_job.c
src/charon/processing/jobs/send_dpd_job.h
src/charon/processing/jobs/send_keepalive_job.c
src/charon/processing/jobs/send_keepalive_job.h
src/charon/processing/jobs/update_sa_job.c
src/charon/processing/jobs/update_sa_job.h
src/charon/processing/processor.c
src/charon/processing/processor.h
src/charon/processing/scheduler.c
src/charon/processing/scheduler.h
src/charon/sa/authenticators/authenticator.c
src/charon/sa/authenticators/authenticator.h
src/charon/sa/authenticators/eap/eap_manager.c
src/charon/sa/authenticators/eap/eap_manager.h
src/charon/sa/authenticators/eap/eap_method.c
src/charon/sa/authenticators/eap/eap_method.h
src/charon/sa/authenticators/eap/sim_manager.c
src/charon/sa/authenticators/eap/sim_manager.h
src/charon/sa/authenticators/eap_authenticator.c
src/charon/sa/authenticators/eap_authenticator.h
src/charon/sa/authenticators/psk_authenticator.c
src/charon/sa/authenticators/psk_authenticator.h
src/charon/sa/authenticators/pubkey_authenticator.c
src/charon/sa/authenticators/pubkey_authenticator.h
src/charon/sa/child_sa.c
src/charon/sa/child_sa.h
src/charon/sa/connect_manager.c
src/charon/sa/connect_manager.h
src/charon/sa/ike_sa.c
src/charon/sa/ike_sa.h
src/charon/sa/ike_sa_id.h
src/charon/sa/ike_sa_manager.c
src/charon/sa/ike_sa_manager.h
src/charon/sa/keymat.c
src/charon/sa/keymat.h
src/charon/sa/mediation_manager.c
src/charon/sa/mediation_manager.h
src/charon/sa/task_manager.c
src/charon/sa/task_manager.h
src/charon/sa/tasks/child_create.c
src/charon/sa/tasks/child_create.h
src/charon/sa/tasks/child_delete.c
src/charon/sa/tasks/child_delete.h
src/charon/sa/tasks/child_rekey.c
src/charon/sa/tasks/child_rekey.h
src/charon/sa/tasks/ike_auth.c
src/charon/sa/tasks/ike_auth_lifetime.c
src/charon/sa/tasks/ike_auth_lifetime.h
src/charon/sa/tasks/ike_cert_post.c
src/charon/sa/tasks/ike_cert_pre.c
src/charon/sa/tasks/ike_config.c
src/charon/sa/tasks/ike_delete.c
src/charon/sa/tasks/ike_dpd.c
src/charon/sa/tasks/ike_init.c
src/charon/sa/tasks/ike_init.h
src/charon/sa/tasks/ike_me.c
src/charon/sa/tasks/ike_me.h
src/charon/sa/tasks/ike_mobike.c
src/charon/sa/tasks/ike_mobike.h
src/charon/sa/tasks/ike_natd.c
src/charon/sa/tasks/ike_natd.h
src/charon/sa/tasks/ike_reauth.c
src/charon/sa/tasks/ike_rekey.c
src/charon/sa/tasks/ike_rekey.h
src/charon/sa/tasks/task.h
src/charon/sa/trap_manager.c
src/charon/sa/trap_manager.h
src/checksum/checksum_builder.c
src/dumm/bridge.c
src/dumm/bridge.h
src/dumm/cowfs.c
src/dumm/cowfs.h
src/dumm/dumm.c
src/dumm/dumm.h
src/dumm/ext/dumm.c
src/dumm/guest.c
src/dumm/guest.h
src/dumm/iface.c
src/dumm/iface.h
src/dumm/irdumm.c
src/dumm/main.c
src/dumm/mconsole.c
src/dumm/mconsole.h
src/include/linux/netlink.h
src/include/linux/rtnetlink.h
src/libfast/context.h
src/libfast/controller.h
src/libfast/dispatcher.c
src/libfast/dispatcher.h
src/libfast/filter.h
src/libfast/request.c
src/libfast/request.h
src/libfast/session.c
src/libfast/session.h
src/libfreeswan/addrtoa.c
src/libfreeswan/addrtot.c
src/libfreeswan/addrtypeof.c
src/libfreeswan/anyaddr.c
src/libfreeswan/atoaddr.c
src/libfreeswan/atoasr.c
src/libfreeswan/atosa.c
src/libfreeswan/atosubnet.c
src/libfreeswan/atoul.c
src/libfreeswan/datatot.c
src/libfreeswan/freeswan.h
src/libfreeswan/goodmask.c
src/libfreeswan/initaddr.c
src/libfreeswan/initsaid.c
src/libfreeswan/initsubnet.c
src/libfreeswan/internal.h
src/libfreeswan/ipsec_param.h
src/libfreeswan/keyblobtoid.c
src/libfreeswan/pfkey.h
src/libfreeswan/pfkey_v2_build.c
src/libfreeswan/pfkey_v2_debug.c
src/libfreeswan/pfkey_v2_ext_bits.c
src/libfreeswan/pfkey_v2_parse.c
src/libfreeswan/pfkeyv2.h
src/libfreeswan/portof.c
src/libfreeswan/prng.c
src/libfreeswan/rangetoa.c
src/libfreeswan/rangetosubnet.c
src/libfreeswan/sameaddr.c
src/libfreeswan/satoa.c
src/libfreeswan/satot.c
src/libfreeswan/subnetof.c
src/libfreeswan/subnettoa.c
src/libfreeswan/subnettot.c
src/libfreeswan/subnettypeof.c
src/libfreeswan/ttoaddr.c
src/libfreeswan/ttodata.c
src/libfreeswan/ttoprotoport.c
src/libfreeswan/ttosa.c
src/libfreeswan/ttosubnet.c
src/libfreeswan/ttoul.c
src/libfreeswan/ultoa.c
src/libfreeswan/ultot.c
src/libstrongswan/asn1/asn1.c
src/libstrongswan/asn1/asn1.h
src/libstrongswan/asn1/asn1_parser.c
src/libstrongswan/asn1/asn1_parser.h
src/libstrongswan/chunk.c
src/libstrongswan/chunk.h
src/libstrongswan/credentials/builder.h
src/libstrongswan/credentials/certificates/ac.h
src/libstrongswan/credentials/certificates/certificate.h
src/libstrongswan/credentials/certificates/crl.h
src/libstrongswan/credentials/certificates/ocsp_response.h
src/libstrongswan/credentials/certificates/x509.h
src/libstrongswan/credentials/credential_factory.c
src/libstrongswan/credentials/credential_factory.h
src/libstrongswan/credentials/keys/key_encoding.c
src/libstrongswan/credentials/keys/key_encoding.h
src/libstrongswan/credentials/keys/private_key.c
src/libstrongswan/credentials/keys/private_key.h
src/libstrongswan/credentials/keys/public_key.c
src/libstrongswan/credentials/keys/public_key.h
src/libstrongswan/credentials/keys/shared_key.c
src/libstrongswan/credentials/keys/shared_key.h
src/libstrongswan/crypto/crypters/crypter.h
src/libstrongswan/crypto/crypto_factory.c
src/libstrongswan/crypto/crypto_factory.h
src/libstrongswan/crypto/crypto_tester.c
src/libstrongswan/crypto/crypto_tester.h
src/libstrongswan/crypto/diffie_hellman.h
src/libstrongswan/crypto/hashers/hasher.h
src/libstrongswan/crypto/pkcs7.c
src/libstrongswan/crypto/pkcs7.h
src/libstrongswan/crypto/pkcs9.c
src/libstrongswan/crypto/pkcs9.h
src/libstrongswan/crypto/prf_plus.c
src/libstrongswan/crypto/prf_plus.h
src/libstrongswan/crypto/prfs/prf.h
src/libstrongswan/crypto/proposal/proposal_keywords.h
src/libstrongswan/crypto/rngs/rng.h
src/libstrongswan/crypto/signers/signer.h
src/libstrongswan/database/database.h
src/libstrongswan/database/database_factory.c
src/libstrongswan/database/database_factory.h
src/libstrongswan/debug.c
src/libstrongswan/debug.h
src/libstrongswan/enum.h
src/libstrongswan/fetcher/fetcher.h
src/libstrongswan/fetcher/fetcher_manager.c
src/libstrongswan/fetcher/fetcher_manager.h
src/libstrongswan/integrity_checker.c
src/libstrongswan/integrity_checker.h
src/libstrongswan/library.c
src/libstrongswan/library.h
src/libstrongswan/plugins/aes/aes_crypter.c
src/libstrongswan/plugins/aes/aes_crypter.h
src/libstrongswan/plugins/aes/aes_plugin.c
src/libstrongswan/plugins/agent/agent_plugin.c
src/libstrongswan/plugins/agent/agent_plugin.h
src/libstrongswan/plugins/agent/agent_private_key.c
src/libstrongswan/plugins/blowfish/bf_enc.c
src/libstrongswan/plugins/blowfish/bf_locl.h
src/libstrongswan/plugins/blowfish/bf_pi.h
src/libstrongswan/plugins/blowfish/bf_skey.c
src/libstrongswan/plugins/blowfish/blowfish.h
src/libstrongswan/plugins/blowfish/blowfish_crypter.c
src/libstrongswan/plugins/blowfish/blowfish_crypter.h
src/libstrongswan/plugins/blowfish/blowfish_plugin.c
src/libstrongswan/plugins/curl/curl_fetcher.c
src/libstrongswan/plugins/curl/curl_fetcher.h
src/libstrongswan/plugins/curl/curl_plugin.c
src/libstrongswan/plugins/des/des_crypter.c
src/libstrongswan/plugins/des/des_crypter.h
src/libstrongswan/plugins/des/des_plugin.c
src/libstrongswan/plugins/dnskey/dnskey_builder.c
src/libstrongswan/plugins/dnskey/dnskey_plugin.c
src/libstrongswan/plugins/fips_prf/fips_prf.c
src/libstrongswan/plugins/fips_prf/fips_prf.h
src/libstrongswan/plugins/fips_prf/fips_prf_plugin.c
src/libstrongswan/plugins/gcrypt/gcrypt_crypter.c
src/libstrongswan/plugins/gcrypt/gcrypt_crypter.h
src/libstrongswan/plugins/gcrypt/gcrypt_dh.c
src/libstrongswan/plugins/gcrypt/gcrypt_dh.h
src/libstrongswan/plugins/gcrypt/gcrypt_hasher.c
src/libstrongswan/plugins/gcrypt/gcrypt_hasher.h
src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c
src/libstrongswan/plugins/gcrypt/gcrypt_rng.c
src/libstrongswan/plugins/gcrypt/gcrypt_rng.h
src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c
src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.h
src/libstrongswan/plugins/gcrypt/gcrypt_rsa_public_key.c
src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c
src/libstrongswan/plugins/gmp/gmp_diffie_hellman.h
src/libstrongswan/plugins/gmp/gmp_plugin.c
src/libstrongswan/plugins/gmp/gmp_plugin.h
src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c
src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
src/libstrongswan/plugins/hmac/hmac.c
src/libstrongswan/plugins/hmac/hmac.h
src/libstrongswan/plugins/hmac/hmac_plugin.c
src/libstrongswan/plugins/hmac/hmac_prf.c
src/libstrongswan/plugins/hmac/hmac_prf.h
src/libstrongswan/plugins/hmac/hmac_signer.c
src/libstrongswan/plugins/hmac/hmac_signer.h
src/libstrongswan/plugins/ldap/ldap_fetcher.c
src/libstrongswan/plugins/ldap/ldap_plugin.c
src/libstrongswan/plugins/md4/md4_hasher.c
src/libstrongswan/plugins/md4/md4_hasher.h
src/libstrongswan/plugins/md4/md4_plugin.c
src/libstrongswan/plugins/md5/md5_hasher.c
src/libstrongswan/plugins/md5/md5_hasher.h
src/libstrongswan/plugins/md5/md5_plugin.c
src/libstrongswan/plugins/mysql/mysql_database.c
src/libstrongswan/plugins/mysql/mysql_plugin.c
src/libstrongswan/plugins/openssl/openssl_crypter.c
src/libstrongswan/plugins/openssl/openssl_crypter.h
src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h
src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.h
src/libstrongswan/plugins/openssl/openssl_ec_private_key.c
src/libstrongswan/plugins/openssl/openssl_ec_public_key.c
src/libstrongswan/plugins/openssl/openssl_hasher.c
src/libstrongswan/plugins/openssl/openssl_hasher.h
src/libstrongswan/plugins/openssl/openssl_plugin.c
src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c
src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c
src/libstrongswan/plugins/openssl/openssl_util.c
src/libstrongswan/plugins/openssl/openssl_util.h
src/libstrongswan/plugins/padlock/padlock_aes_crypter.c
src/libstrongswan/plugins/padlock/padlock_aes_crypter.h
src/libstrongswan/plugins/padlock/padlock_plugin.c
src/libstrongswan/plugins/padlock/padlock_rng.c
src/libstrongswan/plugins/padlock/padlock_rng.h
src/libstrongswan/plugins/padlock/padlock_sha1_hasher.c
src/libstrongswan/plugins/padlock/padlock_sha1_hasher.h
src/libstrongswan/plugins/pem/pem_builder.c
src/libstrongswan/plugins/pem/pem_plugin.c
src/libstrongswan/plugins/pem/pem_plugin.h
src/libstrongswan/plugins/pgp/pgp_builder.c
src/libstrongswan/plugins/pgp/pgp_encoder.c
src/libstrongswan/plugins/pgp/pgp_plugin.c
src/libstrongswan/plugins/pkcs1/pkcs1_builder.c
src/libstrongswan/plugins/pkcs1/pkcs1_encoder.c
src/libstrongswan/plugins/pkcs1/pkcs1_plugin.c
src/libstrongswan/plugins/plugin.h
src/libstrongswan/plugins/plugin_loader.c
src/libstrongswan/plugins/plugin_loader.h
src/libstrongswan/plugins/pubkey/pubkey_cert.c
src/libstrongswan/plugins/pubkey/pubkey_plugin.c
src/libstrongswan/plugins/random/random_plugin.c
src/libstrongswan/plugins/random/random_plugin.h
src/libstrongswan/plugins/random/random_rng.c
src/libstrongswan/plugins/random/random_rng.h
src/libstrongswan/plugins/sha1/sha1_hasher.c
src/libstrongswan/plugins/sha1/sha1_hasher.h
src/libstrongswan/plugins/sha1/sha1_plugin.c
src/libstrongswan/plugins/sha1/sha1_prf.c
src/libstrongswan/plugins/sha1/sha1_prf.h
src/libstrongswan/plugins/sha2/sha2_hasher.c
src/libstrongswan/plugins/sha2/sha2_hasher.h
src/libstrongswan/plugins/sha2/sha2_plugin.c
src/libstrongswan/plugins/sqlite/sqlite_database.c
src/libstrongswan/plugins/sqlite/sqlite_plugin.c
src/libstrongswan/plugins/test_vectors/test_vectors/blowfish.c
src/libstrongswan/plugins/test_vectors/test_vectors/rng.c
src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c
src/libstrongswan/plugins/x509/ietf_attr_list.c
src/libstrongswan/plugins/x509/ietf_attr_list.h
src/libstrongswan/plugins/x509/x509_ac.c
src/libstrongswan/plugins/x509/x509_cert.c
src/libstrongswan/plugins/x509/x509_crl.c
src/libstrongswan/plugins/x509/x509_ocsp_request.c
src/libstrongswan/plugins/x509/x509_ocsp_response.c
src/libstrongswan/plugins/x509/x509_plugin.c
src/libstrongswan/plugins/xcbc/xcbc.c
src/libstrongswan/plugins/xcbc/xcbc.h
src/libstrongswan/plugins/xcbc/xcbc_plugin.c
src/libstrongswan/plugins/xcbc/xcbc_prf.c
src/libstrongswan/plugins/xcbc/xcbc_prf.h
src/libstrongswan/plugins/xcbc/xcbc_signer.c
src/libstrongswan/plugins/xcbc/xcbc_signer.h
src/libstrongswan/printf_hook.c
src/libstrongswan/printf_hook.h
src/libstrongswan/settings.c
src/libstrongswan/settings.h
src/libstrongswan/utils.c
src/libstrongswan/utils.h
src/libstrongswan/utils/backtrace.c
src/libstrongswan/utils/backtrace.h
src/libstrongswan/utils/enumerator.c
src/libstrongswan/utils/enumerator.h
src/libstrongswan/utils/hashtable.c
src/libstrongswan/utils/hashtable.h
src/libstrongswan/utils/host.c
src/libstrongswan/utils/host.h
src/libstrongswan/utils/identification.c
src/libstrongswan/utils/identification.h
src/libstrongswan/utils/iterator.h
src/libstrongswan/utils/leak_detective.c
src/libstrongswan/utils/leak_detective.h
src/libstrongswan/utils/lexparser.c
src/libstrongswan/utils/lexparser.h
src/libstrongswan/utils/linked_list.c
src/libstrongswan/utils/linked_list.h
src/libstrongswan/utils/mutex.c
src/libstrongswan/utils/mutex.h
src/libstrongswan/utils/optionsfrom.c
src/libstrongswan/utils/optionsfrom.h
src/manager/controller/auth_controller.c
src/manager/controller/config_controller.c
src/manager/controller/control_controller.c
src/manager/controller/gateway_controller.c
src/manager/controller/ikesa_controller.c
src/manager/gateway.c
src/manager/gateway.h
src/manager/main.c
src/manager/manager.c
src/manager/manager.h
src/manager/storage.c
src/manager/storage.h
src/manager/xml.c
src/manager/xml.h
src/medsrv/controller/peer_controller.c
src/medsrv/controller/user_controller.c
src/medsrv/filter/auth_filter.c
src/medsrv/main.c
src/medsrv/user.h
src/openac/openac.c
src/pki/pki.c
src/pluto/ac.c
src/pluto/alg_info.c
src/pluto/alg_info.h
src/pluto/builder.c
src/pluto/ca.c
src/pluto/certs.c
src/pluto/connections.c
src/pluto/connections.h
src/pluto/constants.c
src/pluto/constants.h
src/pluto/crl.c
src/pluto/crl.h
src/pluto/crypto.c
src/pluto/db_ops.c
src/pluto/demux.c
src/pluto/dnskey.c
src/pluto/fetch.c
src/pluto/ike_alg.c
src/pluto/ipsec_doi.c
src/pluto/kernel.c
src/pluto/kernel_alg.c
src/pluto/kernel_netlink.c
src/pluto/kernel_noklips.c
src/pluto/kernel_pfkey.c
src/pluto/keys.c
src/pluto/log.c
src/pluto/modecfg.c
src/pluto/modecfg.h
src/pluto/nat_traversal.c
src/pluto/ocsp.c
src/pluto/packet.c
src/pluto/pgpcert.c
src/pluto/pkcs7.c
src/pluto/plutomain.c
src/pluto/rcv_whack.c
src/pluto/rsaref/pkcs11.h
src/pluto/rsaref/pkcs11f.h
src/pluto/smartcard.c
src/pluto/spdb.c
src/pluto/state.c
src/pluto/timer.c
src/pluto/vendor.c
src/pluto/virtual.c
src/pluto/x509.c
src/pluto/x509.h
src/pluto/xauth.c
src/pluto/xauth.h
src/scepclient/loglite.c
src/scepclient/pkcs10.c
src/scepclient/pkcs10.h
src/scepclient/scep.c
src/scepclient/scep.h
src/scepclient/scepclient.c
src/starter/args.c
src/starter/confread.c
src/starter/confread.h
src/starter/invokecharon.c
src/starter/invokepluto.c
src/starter/klips.c
src/starter/klips.h
src/starter/netkey.h
src/starter/starter.c
src/starter/starterstroke.c
src/starter/starterwhack.c
src/stroke/stroke.c
src/stroke/stroke_msg.h
src/whack/whack.c
src/whack/whack.h

index 4778b446afd7f4056e84ca62e451c878a03d005d..5e0ad7c7453f7b4a8e7d864c790bc6721b34de93 100644 (file)
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
                {
                        break;
                }
-       }       
+       }
        printf("};\n");
        return 0;
 }
index 4f83dd3f2f4a4147543d1ef0320b317a364b2a75..8bc72f842ed138a6e25059c7f56eea6de28bdb87 100644 (file)
@@ -18,7 +18,7 @@ int main(int argc, char *argv[])
                        break;
                }
                printf("%02x", (unsigned int)byte);
-       }       
+       }
        printf("'\n");
        return 0;
 }
index 76dafe7524513d83b62aa8a5e8a2486ef37ad231..5a57badb676307219b9e3ac83b2f5d999419f072 100644 (file)
@@ -38,7 +38,7 @@ static void start_timing(struct timespec *start)
 static double end_timing(struct timespec *start)
 {
        struct timespec end;
-       
+
        clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
        return (end.tv_nsec - start->tv_nsec) / 1000000000.0 +
                        (end.tv_sec - start->tv_sec) * 1.0;
@@ -50,7 +50,7 @@ static void run_test(diffie_hellman_group_t group, int rounds)
        chunk_t chunk;
        struct timespec timing;
        int round;
-       
+
        r = lib->crypto->create_dh(lib->crypto, group);
        if (!r)
        {
@@ -58,24 +58,24 @@ static void run_test(diffie_hellman_group_t group, int rounds)
                                diffie_hellman_group_names, group);
                return;
        }
-       
+
        printf("%N:\t",
                        diffie_hellman_group_names, group);
-       
+
        start_timing(&timing);
        for (round = 0; round < rounds; round++)
        {
                l[round] = lib->crypto->create_dh(lib->crypto, group);
        }
        printf("A = g^a/s: %8.1f", rounds / end_timing(&timing));
-       
+
        for (round = 0; round < rounds; round++)
        {
                l[round]->get_my_public_value(l[round], &chunk);
                r->set_other_public_value(r, chunk);
                chunk_free(&chunk);
        }
-       
+
        r->get_my_public_value(r, &chunk);
        start_timing(&timing);
        for (round = 0; round < rounds; round++)
@@ -84,7 +84,7 @@ static void run_test(diffie_hellman_group_t group, int rounds)
        }
        printf(" | S = B^a/s: %8.1f\n", rounds / end_timing(&timing));
        chunk_free(&chunk);
-       
+
        for (round = 0; round < rounds; round++)
        {
                l[round]->destroy(l[round]);
@@ -95,22 +95,22 @@ static void run_test(diffie_hellman_group_t group, int rounds)
 int main(int argc, char *argv[])
 {
        int rounds, i, j;
-       
+
        if (argc < 4)
        {
                usage();
        }
-       
+
        library_init(STRONGSWAN_CONF);
        lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, argv[1]);
        atexit(library_deinit);
-       
+
        rounds = atoi(argv[2]);
-       
+
        for (i = 3; i < argc; i++)
        {
                bool found = FALSE;
-               
+
                for (j = 0; j < countof(groups); j++)
                {
                        if (streq(groups[j].name, argv[i]))
index 5b0bd1d7db3644ecc7bd84f5bc60cd3dcea8efc6..5bc94f5b6f4b7e6f527401e5d78e40323fa9c7ec 100644 (file)
@@ -10,7 +10,7 @@ int main(int argc, char *argv[])
        identification_t *id;
        chunk_t enc;
        int i;
-       
+
        if (argc < 2)
        {
                return -1;
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
        for (i = 0; i < enc.len; i++)
        {
                printf("%02x", (unsigned int)enc.ptr[i]);
-       }       
+       }
        printf("'\n");
        return 0;
 }
index e32c2baf34b2ad64ef7a7bc940d216fdb449c461..cc3e0b18b442d252ae5555043c748575b6bac829 100644 (file)
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
        chunk_t chunk;
        char buf[8096];
        int read;
-       
+
        library_init(NULL);
        lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, PLUGINS);
        atexit(library_deinit);
@@ -26,9 +26,9 @@ int main(int argc, char *argv[])
                fprintf(stderr, "reading key failed.\n");
                return -1;
        }
-       
+
        chunk = chunk_create(buf, read);
-       
+
        private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                                 BUILD_BLOB_PEM, chunk_clone(chunk),
                                                                 BUILD_END);
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
                private->destroy(private);
                return 0;
        }
-       
+
        public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
                                                                BUILD_BLOB_PEM, chunk_clone(chunk),
                                                                BUILD_END);
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
                public->destroy(public);
                return 0;
        }
-       
+
        fprintf(stderr, "unable to parse input key.\n");
        return -1;
 }
index 2ec011950e6724d6f6d68c789267a05466adf3ec..bf952170d6e7fc4f8cfafd22294dcabf1b338205 100644 (file)
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
        chunk_t chunk;
        char buf[8096];
        int read, n;
-       
+
        library_init(NULL);
        lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, PLUGINS);
        atexit(library_deinit);
@@ -26,9 +26,9 @@ int main(int argc, char *argv[])
                fprintf(stderr, "reading key failed.\n");
                return -1;
        }
-       
+
        chunk = chunk_create(buf, read);
-       
+
        private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                                 BUILD_BLOB_PEM, chunk_clone(chunk),
                                                                 BUILD_END);
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
                private->destroy(private);
                return 0;
        }
-       
+
        public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
                                                                BUILD_BLOB_PEM, chunk_clone(chunk),
                                                                BUILD_END);
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
                public->destroy(public);
                return 0;
        }
-       
+
        fprintf(stderr, "unable to parse input key.\n");
        return -1;
 }
index 120ca858cde1f4ca13b50b776ea5a83b69397896..99075d2519e1331c1569d44d3997b07351d3a6e0 100644 (file)
@@ -13,7 +13,7 @@ void start_timing(struct timespec *start)
 double end_timing(struct timespec *start)
 {
        struct timespec end;
-       
+
        clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
        return (end.tv_nsec - start->tv_nsec) / 1000000000.0 +
                        (end.tv_sec - start->tv_sec) * 1.0;
@@ -37,14 +37,14 @@ int main(int argc, char *argv[])
        key_type_t type = KEY_ANY;
        signature_scheme_t scheme = SIGN_UNKNOWN;
        chunk_t keydata, *sigs, data = chunk_from_buf(data_buf);
-       
+
        if (argc < 4)
        {
                usage();
        }
-       
+
        rounds = atoi(argv[3]);
-       
+
        if (streq(argv[2], "rsa"))
        {
                type = KEY_RSA;
@@ -58,18 +58,18 @@ int main(int argc, char *argv[])
        {
                usage();
        }
-       
+
        library_init(STRONGSWAN_CONF);
        lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, argv[1]);
        atexit(library_deinit);
-       
+
        keydata = chunk_create(buf, 0);
        while ((read = fread(pos, 1, sizeof(buf) - (pos - buf), stdin)))
        {
                pos += read;
                keydata.len += read;
        }
-       
+
        private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, type,
                                                                 BUILD_BLOB_PEM, keydata, BUILD_END);
        if (!private)
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
                switch (private->get_keysize(private))
                {
                        case 32:
-                               scheme = SIGN_ECDSA_256; 
+                               scheme = SIGN_ECDSA_256;
                                break;
                        case 48:
                                scheme = SIGN_ECDSA_384;
@@ -96,12 +96,12 @@ int main(int argc, char *argv[])
                                exit(1);
                }
        }
-       
+
        printf("%4d bit %N: ", private->get_keysize(private)*8,
                key_type_names, type);
-       
+
        sigs = malloc(sizeof(chunk_t) * rounds);
-       
+
        start_timing(&timing);
        for (round = 0; round < rounds; round++)
        {
@@ -112,7 +112,7 @@ int main(int argc, char *argv[])
                }
        };
        printf("sign()/s: %8.1f   ", rounds / end_timing(&timing));
-       
+
        public = private->get_public_key(private);
        if (!public)
        {
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
        printf("verify()/s: %8.1f\n", rounds / end_timing(&timing));
        public->destroy(public);
        private->destroy(private);
-       
+
        for (round = 0; round < rounds; round++)
        {
                free(sigs[round].ptr);
index 53cd043590e7ffb6d534a4a4639ae06e83ba40f2..7670ce1f808e07c17d288c7de609cf7cab58d6c3 100644 (file)
@@ -1,5 +1,5 @@
 /* Analyzes the concurrent use of charon's threads
- * 
+ *
  * Copyright (C) 2008 Andreas Steffen
  * Hochschule fuer Technik Rapperswil
  *
@@ -52,7 +52,7 @@ static int readline(FILE *fd, char *line)
                        *line = '\0';
                        return 1;
                }
-               line++;         
+               line++;
        }
        *line = '\0';
        return 0;
@@ -69,14 +69,14 @@ static void printline(state_t *state, char *timestamp)
        for (th = 1; th <= THREADS; th++)
        {
                states[state[th]]++;
-               printf("<td class=\"%s\"></td>", state_names[state[th]]);       
+               printf("<td class=\"%s\"></td>", state_names[state[th]]);
        }
        total = states[STATE_INIT] + states[STATE_AUTH] + states[STATE_BUSY] + states[STATE_RETRY];
        printf("<td class=\"init\">%d</td><td class=\"auth\">%d</td><td class=\"busy\">%d</td>",
                        states[STATE_INIT], states[STATE_AUTH], total);
        for (th = 10; th <= (THREADS + 2); th += 5)
        {
-               printf("<td class=\"%s\"></td>", (th <= total + 2)? "busy":"idle");     
+               printf("<td class=\"%s\"></td>", (th <= total + 2)? "busy":"idle");
        }
        printf("\n");
        printf("    </tr>\n");
@@ -91,13 +91,13 @@ int main(int argc, char *argv[])
        FILE *fd;
 
        state_t state[THREADS + 1];
-       
+
        /* threads 1..5 and 9 are always busy */
        for (th = 1; th <= THREADS; th++)
        {
                state[th] = (th <= 7 && th != 3)? STATE_BUSY : STATE_IDLE;
        }
-  
+
        /* open the log file */
        fd = fopen(LOGFILE, "r");
        if (!fd)
@@ -135,16 +135,16 @@ int main(int argc, char *argv[])
        printf("      <td class=\"log\">Timestamp</td>");
        for (th = 1 ; th <= THREADS; th++)
        {
-               printf("<td>%02d</td>", th);    
+               printf("<td>%02d</td>", th);
        }
        printf("<td class=\"init\">I</td><td class=\"auth\">A</td><td class=\"busy\">B</td>");
        for (th = 10; th <= (THREADS + 2); th += 5)
        {
-               printf("<td class=\"busy\">%d</td>", (th == 100)? 99:th);       
+               printf("<td class=\"busy\">%d</td>", (th == 100)? 99:th);
        }
        printf("\n");
        printf("    </tr>\n");
-       
+
        while (readline(fd, line))
        {
                char *p_section, *p_charon, *p_thread, *p_log;
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
                {
                        continue;
                }
-               
+
                /* determine thread */
                p_thread = p_charon + 8;
                th = atol(p_thread);
@@ -268,6 +268,6 @@ int main(int argc, char *argv[])
        printf("</body>\n");
        printf("</html>\n");
 
-       fclose(fd);     
+       fclose(fd);
        return 0;
 }
index 5abefd4f15ab6f028c40984732caef2c024a9f13..9f0ad978553ed452b90159a17b5d83e7f8915710 100644 (file)
@@ -2,12 +2,12 @@
  * copyright reporter
  * (just avoids having the info in more than one place in the source)
  * Copyright (C) 2001  Henry Spencer.
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
index 2671f848ee88b4d5dd3e3cf7d5f3f6edcd0857fd..7075586e16e86a9c2b5c64e563423ce4ae408fff 100644 (file)
@@ -57,22 +57,22 @@ struct private_bus_t {
         * Public part of a bus_t object.
         */
        bus_t public;
-       
+
        /**
         * List of registered listeners as entry_t's
         */
        linked_list_t *listeners;
-       
+
        /**
         * mutex to synchronize active listeners, recursively
         */
        mutex_t *mutex;
-       
+
        /**
         * Thread local storage for a unique, simple thread ID
         */
        pthread_key_t thread_id;
-       
+
        /**
         * Thread local storage the threads IKE_SA
         */
@@ -90,17 +90,17 @@ struct entry_t {
         * registered listener interface
         */
        listener_t *listener;
-       
+
        /**
         * is this a active listen() call with a blocking thread
         */
        bool blocker;
-       
+
        /**
         * are we currently calling this listener
         */
        int calling;
-       
+
        /**
         * condvar where active listeners wait
         */
@@ -113,12 +113,12 @@ struct entry_t {
 static entry_t *entry_create(listener_t *listener, bool blocker)
 {
        entry_t *this = malloc_thing(entry_t);
-       
+
        this->listener = listener;
        this->blocker = blocker;
        this->calling = 0;
        this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
-       
+
        return this;
 }
 
@@ -140,7 +140,7 @@ static u_int get_thread_number(private_bus_t *this)
 {
        static uintptr_t current_num = 0;
        uintptr_t stored_num;
-       
+
        stored_num = (uintptr_t)pthread_getspecific(this->thread_id);
        if (stored_num == 0)
        {       /* first call of current thread */
@@ -214,7 +214,7 @@ static void listen_(private_bus_t *this, listener_t *listener, job_t *job)
 {
        int old;
        cleanup_data_t data;
-       
+
        data.this = this;
        data.entry = entry_create(listener, TRUE);
 
@@ -302,20 +302,20 @@ static void vlog(private_bus_t *this, debug_t group, level_t level,
                                 char* format, va_list args)
 {
        log_data_t data;
-       
+
        data.ike_sa = pthread_getspecific(this->thread_sa);
        data.thread = get_thread_number(this);
        data.group = group;
        data.level = level;
        data.format = format;
        va_copy(data.args, args);
-       
+
        this->mutex->lock(this->mutex);
        /* We use the remove() method to invoke all listeners. This is cheap and
         * does not require an allocation for this performance critical function. */
        this->listeners->remove(this->listeners, &data, (void*)log_cb);
        this->mutex->unlock(this->mutex);
-       
+
        va_end(data.args);
 }
 
@@ -326,7 +326,7 @@ static void log_(private_bus_t *this, debug_t group, level_t level,
                                 char* format, ...)
 {
        va_list args;
-       
+
        va_start(args, format);
        vlog(this, group, level, format, args);
        va_end(args);
@@ -360,9 +360,9 @@ static void alert(private_bus_t *this, alert_t alert, ...)
        entry_t *entry;
        va_list args;
        bool keep;
-       
+
        ike_sa = pthread_getspecific(this->thread_sa);
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -394,7 +394,7 @@ static void ike_state_change(private_bus_t *this, ike_sa_t *ike_sa,
        enumerator_t *enumerator;
        entry_t *entry;
        bool keep;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -425,9 +425,9 @@ static void child_state_change(private_bus_t *this, child_sa_t *child_sa,
        ike_sa_t *ike_sa;
        entry_t *entry;
        bool keep;
-       
+
        ike_sa = pthread_getspecific(this->thread_sa);
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -458,9 +458,9 @@ static void message(private_bus_t *this, message_t *message, bool incoming)
        ike_sa_t *ike_sa;
        entry_t *entry;
        bool keep;
-       
+
        ike_sa = pthread_getspecific(this->thread_sa);
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -492,7 +492,7 @@ static void ike_keys(private_bus_t *this, ike_sa_t *ike_sa,
        enumerator_t *enumerator;
        entry_t *entry;
        bool keep;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -524,9 +524,9 @@ static void child_keys(private_bus_t *this, child_sa_t *child_sa,
        ike_sa_t *ike_sa;
        entry_t *entry;
        bool keep;
-       
+
        ike_sa = pthread_getspecific(this->thread_sa);
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -557,9 +557,9 @@ static void child_updown(private_bus_t *this, child_sa_t *child_sa, bool up)
        ike_sa_t *ike_sa;
        entry_t *entry;
        bool keep;
-       
+
        ike_sa = pthread_getspecific(this->thread_sa);
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -590,9 +590,9 @@ static void child_rekey(private_bus_t *this, child_sa_t *old, child_sa_t *new)
        ike_sa_t *ike_sa;
        entry_t *entry;
        bool keep;
-       
+
        ike_sa = pthread_getspecific(this->thread_sa);
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -621,7 +621,7 @@ static void ike_updown(private_bus_t *this, ike_sa_t *ike_sa, bool up)
        enumerator_t *enumerator;
        entry_t *entry;
        bool keep;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -640,13 +640,13 @@ static void ike_updown(private_bus_t *this, ike_sa_t *ike_sa, bool up)
        }
        enumerator->destroy(enumerator);
        this->mutex->unlock(this->mutex);
-       
+
        /* a down event for IKE_SA implicitly downs all CHILD_SAs */
        if (!up)
        {
                iterator_t *iterator;
                child_sa_t *child_sa;
-               
+
                iterator = ike_sa->create_child_sa_iterator(ike_sa);
                while (iterator->iterate(iterator, (void**)&child_sa))
                {
@@ -664,7 +664,7 @@ static void ike_rekey(private_bus_t *this, ike_sa_t *old, ike_sa_t *new)
        enumerator_t *enumerator;
        entry_t *entry;
        bool keep;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -694,9 +694,9 @@ static bool authorize(private_bus_t *this, linked_list_t *auth, bool final)
        ike_sa_t *ike_sa;
        entry_t *entry;
        bool keep, success = TRUE;
-       
+
        ike_sa = pthread_getspecific(this->thread_sa);
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->listeners->create_enumerator(this->listeners);
        while (enumerator->enumerate(enumerator, &entry))
@@ -739,7 +739,7 @@ static void destroy(private_bus_t *this)
 bus_t *bus_create()
 {
        private_bus_t *this = malloc_thing(private_bus_t);
-       
+
        this->public.add_listener = (void(*)(bus_t*,listener_t*))add_listener;
        this->public.remove_listener = (void(*)(bus_t*,listener_t*))remove_listener;
        this->public.listen = (void(*)(bus_t*, listener_t *listener, job_t *job))listen_;
@@ -758,12 +758,12 @@ bus_t *bus_create()
        this->public.child_rekey = (void(*)(bus_t*, child_sa_t *old, child_sa_t *new))child_rekey;
        this->public.authorize = (bool(*)(bus_t*, linked_list_t *auth, bool final))authorize;
        this->public.destroy = (void(*)(bus_t*)) destroy;
-       
+
        this->listeners = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
        pthread_key_create(&this->thread_id, NULL);
        pthread_key_create(&this->thread_sa, NULL);
-       
+
        return &this->public;
 }
 
index 9c90db6f912c7e2c544acad32ffec96bbd1ee801..9a4492ffc3c40895603a6c65eddffa08b3736f63 100644 (file)
@@ -142,7 +142,7 @@ enum alert_t {
  * may wait actively to events using the blocking listen() call.
  */
 struct bus_t {
-       
+
        /**
         * Register a listener to the bus.
         *
@@ -153,14 +153,14 @@ struct bus_t {
         * @param listener      listener to register.
         */
        void (*add_listener) (bus_t *this, listener_t *listener);
-       
+
        /**
         * Unregister a listener from the bus.
         *
         * @param listener      listener to unregister.
         */
        void (*remove_listener) (bus_t *this, listener_t *listener);
-       
+
        /**
         * Register a listener and block the calling thread.
         *
@@ -174,20 +174,20 @@ struct bus_t {
         * @param job           job to execute asynchronously when registered, or NULL
         */
        void (*listen)(bus_t *this, listener_t *listener, job_t *job);
-       
+
        /**
         * Set the IKE_SA the calling thread is using.
         *
         * To associate an received log message to an IKE_SA without passing it as
         * parameter each time, the thread registers the currenlty used IKE_SA
-        * during check-out. Before check-in, the thread unregisters the IKE_SA. 
+        * during check-out. Before check-in, the thread unregisters the IKE_SA.
         * This IKE_SA is stored per-thread, so each thread has its own IKE_SA
         * registered.
-        * 
+        *
         * @param ike_sa        ike_sa to register, or NULL to unregister
         */
        void (*set_sa) (bus_t *this, ike_sa_t *ike_sa);
-       
+
        /**
         * Send a log message to the bus.
         *
@@ -202,7 +202,7 @@ struct bus_t {
         * @param ...           printf() style argument list
         */
        void (*log)(bus_t *this, debug_t group, level_t level, char* format, ...);
-       
+
        /**
         * Send a log message to the bus using va_list arguments.
         *
@@ -215,7 +215,7 @@ struct bus_t {
         */
        void (*vlog)(bus_t *this, debug_t group, level_t level,
                                 char* format, va_list args);
-       
+
        /**
         * Raise an alert over the bus.
         *
@@ -223,7 +223,7 @@ struct bus_t {
         * @param ...           alert specific attributes
         */
        void (*alert)(bus_t *this, alert_t alert, ...);
-       
+
        /**
         * Send a IKE_SA state change event to the bus.
         *
@@ -247,7 +247,7 @@ struct bus_t {
         * @param incoming      TRUE for incoming messages, FALSE for outgoing
         */
        void (*message)(bus_t *this, message_t *message, bool incoming);
-       
+
        /**
         * IKE_SA authorization hook.
         *
@@ -256,7 +256,7 @@ struct bus_t {
         * @return                      TRUE to establish IKE_SA, FALSE to send AUTH_FAILED
         */
        bool (*authorize)(bus_t *this, linked_list_t *auth, bool final);
-       
+
        /**
         * IKE_SA keymat hook.
         *
@@ -278,7 +278,7 @@ struct bus_t {
         */
        void (*child_keys)(bus_t *this, child_sa_t *child_sa, diffie_hellman_t *dh,
                                           chunk_t nonce_i, chunk_t nonce_r);
-       
+
        /**
         * IKE_SA up/down hook.
         *
@@ -286,7 +286,7 @@ struct bus_t {
         * @param up            TRUE for an up event, FALSE for a down event
         */
        void (*ike_updown)(bus_t *this, ike_sa_t *ike_sa, bool up);
-       
+
        /**
         * IKE_SA rekeying hook.
         *
@@ -294,7 +294,7 @@ struct bus_t {
         * @param new           new IKE_SA replacing old
         */
        void (*ike_rekey)(bus_t *this, ike_sa_t *old, ike_sa_t *new);
-       
+
        /**
         * CHILD_SA up/down hook.
         *
@@ -302,7 +302,7 @@ struct bus_t {
         * @param up            TRUE for an up event, FALSE for a down event
         */
        void (*child_updown)(bus_t *this, child_sa_t *child_sa, bool up);
-       
+
        /**
         * CHILD_SA rekeying hook.
         *
@@ -310,7 +310,7 @@ struct bus_t {
         * @param new           new CHILD_SA replacing old
         */
        void (*child_rekey)(bus_t *this, child_sa_t *old, child_sa_t *new);
-       
+
        /**
         * Destroy the event bus.
         */
index c3213f5f86540ea03fdc6ffb2505baa6ab5bff7c..12587deafdff9be7d9eb3e88f8c9796ffbd05750 100644 (file)
@@ -25,17 +25,17 @@ typedef struct private_file_logger_t private_file_logger_t;
  * Private data of a file_logger_t object
  */
 struct private_file_logger_t {
-       
+
        /**
         * Public data.
         */
        file_logger_t public;
-       
+
        /**
         * output file
         */
        FILE *out;
-       
+
        /**
         * Maximum level to log, for each group
         */
@@ -52,10 +52,10 @@ static bool log_(private_file_logger_t *this, debug_t group, level_t level,
        {
                char buffer[8192];
                char *current = buffer, *next;
-               
+
                /* write in memory buffer first */
                vsnprintf(buffer, sizeof(buffer), format, args);
-               
+
                /* prepend a prefix in front of every line */
                while (current)
                {
@@ -109,17 +109,17 @@ static void destroy(private_file_logger_t *this)
 file_logger_t *file_logger_create(FILE *out)
 {
        private_file_logger_t *this = malloc_thing(private_file_logger_t);
-       
+
        /* public functions */
        memset(&this->public.listener, 0, sizeof(listener_t));
        this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
        this->public.set_level = (void(*)(file_logger_t*,debug_t,level_t))set_level;
        this->public.destroy = (void(*)(file_logger_t*))destroy;
-       
+
        /* private variables */
        this->out = out;
        set_level(this, DBG_ANY, LEVEL_SILENT);
-       
+
        return &this->public;
 }
 
index a69374f23b92df7e0c8d0912287f680e8b1d1990..bd443fdb83194df9851df71376cc7c1795ba6320 100644 (file)
@@ -29,12 +29,12 @@ typedef struct file_logger_t file_logger_t;
  * Logger to files which implements listener_t.
  */
 struct file_logger_t {
-       
+
        /**
         * Implements the listener_t interface.
         */
        listener_t listener;
-       
+
        /**
         * Set the loglevel for a debug group.
         *
@@ -42,7 +42,7 @@ struct file_logger_t {
         * @param level         max level to log (0..4)
         */
        void (*set_level) (file_logger_t *this, debug_t group, level_t level);
-       
+
        /**
         * Destroys a file_logger_t object.
         */
index 578f08ebe90cfb47894b2c0830b47c78ec75f962..4cd14e2d7f0d157fd593a6f328b8749a2077cf5f 100644 (file)
@@ -29,7 +29,7 @@ typedef struct listener_t listener_t;
  * Listener interface, listens to events if registered to the bus.
  */
 struct listener_t {
-       
+
        /**
         * Log a debugging message.
         *
@@ -48,7 +48,7 @@ struct listener_t {
         */
        bool (*log)(listener_t *this, debug_t group, level_t level, int thread,
                                ike_sa_t *ike_sa, char* format, va_list args);
-       
+
        /**
         * Hook called if a critical alert is risen.
         *
@@ -59,7 +59,7 @@ struct listener_t {
         */
        bool (*alert)(listener_t *this, ike_sa_t *ike_sa,
                                  alert_t alert, va_list args);
-       
+
        /**
         * Handle state changes in an IKE_SA.
         *
@@ -69,7 +69,7 @@ struct listener_t {
         */
        bool (*ike_state_change)(listener_t *this, ike_sa_t *ike_sa,
                                                         ike_sa_state_t state);
-       
+
        /**
         * Handle state changes in a CHILD_SA.
         *
@@ -80,7 +80,7 @@ struct listener_t {
         */
        bool (*child_state_change)(listener_t *this, ike_sa_t *ike_sa,
                                                           child_sa_t *child_sa, child_sa_state_t state);
-       
+
        /**
         * Hook called for received/sent messages of an IKE_SA.
         *
@@ -91,7 +91,7 @@ struct listener_t {
         */
        bool (*message)(listener_t *this, ike_sa_t *ike_sa, message_t *message,
                                        bool incoming);
-       
+
        /**
         * Hook called with IKE_SA key material.
         *
@@ -104,7 +104,7 @@ struct listener_t {
         */
        bool (*ike_keys)(listener_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
                                         chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey);
-       
+
        /**
         * Hook called with CHILD_SA key material.
         *
@@ -117,7 +117,7 @@ struct listener_t {
         */
        bool (*child_keys)(listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
                                           diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r);
-       
+
        /**
         * Hook called if an IKE_SA gets up or down.
         *
@@ -126,7 +126,7 @@ struct listener_t {
         * @return                      TRUE to stay registered, FALSE to unregister
         */
        bool (*ike_updown)(listener_t *this, ike_sa_t *ike_sa, bool up);
-       
+
        /**
         * Hook called when an IKE_SA gets rekeyed.
         *
@@ -135,7 +135,7 @@ struct listener_t {
         * @return                      TRUE to stay registered, FALSE to unregister
         */
        bool (*ike_rekey)(listener_t *this, ike_sa_t *old, ike_sa_t *new);
-       
+
        /**
         * Hook called when a CHILD_SA gets up or down.
         *
@@ -146,7 +146,7 @@ struct listener_t {
         */
        bool (*child_updown)(listener_t *this, ike_sa_t *ike_sa,
                                                 child_sa_t *child_sa, bool up);
-       
+
        /**
         * Hook called when an CHILD_SA gets rekeyed.
         *
@@ -157,7 +157,7 @@ struct listener_t {
         */
        bool (*child_rekey)(listener_t *this, ike_sa_t *ike_sa,
                                                child_sa_t *old, child_sa_t *new);
-       
+
        /**
         * Hook called to invoke additional authorization rules.
         *
index 0b579ce9246647526dc24d84154ff812b076270b..11421ad05ad6bb122eaad87ca5be270b59e56576 100644 (file)
@@ -25,17 +25,17 @@ typedef struct private_sys_logger_t private_sys_logger_t;
  * Private data of a sys_logger_t object
  */
 struct private_sys_logger_t {
-       
+
        /**
         * Public data.
         */
        sys_logger_t public;
-       
+
        /**
         * syslog facility to use
         */
        int facility;
-       
+
        /**
         * Maximum level to log, for each group
         */
@@ -52,10 +52,10 @@ static bool log_(private_sys_logger_t *this, debug_t group, level_t level,
        {
                char buffer[8192];
                char *current = buffer, *next;
-               
+
                /* write in memory buffer first */
                vsnprintf(buffer, sizeof(buffer), format, args);
-               
+
                /* do a syslog with every line */
                while (current)
                {
@@ -106,16 +106,16 @@ static void destroy(private_sys_logger_t *this)
 sys_logger_t *sys_logger_create(int facility)
 {
        private_sys_logger_t *this = malloc_thing(private_sys_logger_t);
-       
+
        /* public functions */
        memset(&this->public.listener, 0, sizeof(listener_t));
        this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
        this->public.set_level = (void(*)(sys_logger_t*,debug_t,level_t))set_level;
        this->public.destroy = (void(*)(sys_logger_t*))destroy;
-       
+
        /* private variables */
        this->facility = facility;
        set_level(this, DBG_ANY, LEVEL_SILENT);
-       
+
        return &this->public;
 }
index 3ed0f02fab575d58ef984142672663018f00ec01..730890d689c22299d4fa0f538f2c3904a758d7e5 100644 (file)
@@ -31,12 +31,12 @@ typedef struct sys_logger_t sys_logger_t;
  * Logger for syslog which implements listener_t.
  */
 struct sys_logger_t {
-       
+
        /**
         * Implements the listener_t interface.
         */
        listener_t listener;
-       
+
        /**
         * Set the loglevel for a debug group.
         *
@@ -44,7 +44,7 @@ struct sys_logger_t {
         * @param level         max level to log (0..4)
         */
        void (*set_level) (sys_logger_t *this, debug_t group, level_t level);
-       
+
        /**
         * Destroys a sys_logger_t object.
         */
index de1c4414d8f66616e5d069262270456c86adb681..d752d512e636192b1244b02754c42d55d2435b3a 100644 (file)
@@ -30,7 +30,7 @@ typedef struct attribute_handler_t attribute_handler_t;
  * Interface to handle configuration payload attributes.
  */
 struct attribute_handler_t {
-       
+
        /**
         * Handle a configuration attribute.
         *
@@ -43,7 +43,7 @@ struct attribute_handler_t {
         */
        bool (*handle)(attribute_handler_t *this, ike_sa_t *ike_sa,
                                   configuration_attribute_type_t type, chunk_t data);
-       
+
        /**
         * Release an attribute handled during handle().
         *
index bf45fdb42b9a59ddaf7f52198d139396b1e53d46..86d7d0759bf553e655d9c9edf07cad942cb37ae6 100644 (file)
@@ -30,17 +30,17 @@ struct private_attribute_manager_t {
         * public functions
         */
        attribute_manager_t public;
-       
+
        /**
         * list of registered providers
         */
        linked_list_t *providers;
-       
+
        /**
         * list of registered handlers
         */
        linked_list_t *handlers;
-       
+
        /**
         * rwlock provider list
         */
@@ -57,7 +57,7 @@ static host_t* acquire_address(private_attribute_manager_t *this,
        enumerator_t *enumerator;
        attribute_provider_t *current;
        host_t *host = NULL;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->providers->create_enumerator(this->providers);
        while (enumerator->enumerate(enumerator, &current))
@@ -70,7 +70,7 @@ static host_t* acquire_address(private_attribute_manager_t *this,
        }
        enumerator->destroy(enumerator);
        this->lock->unlock(this->lock);
-       
+
        if (!host)
        {
                DBG1(DBG_CFG, "acquiring address from pool '%s' failed", pool);
@@ -87,7 +87,7 @@ static void release_address(private_attribute_manager_t *this,
        enumerator_t *enumerator;
        attribute_provider_t *current;
        bool found = FALSE;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->providers->create_enumerator(this->providers);
        while (enumerator->enumerate(enumerator, &current))
@@ -100,7 +100,7 @@ static void release_address(private_attribute_manager_t *this,
        }
        enumerator->destroy(enumerator);
        this->lock->unlock(this->lock);
-       
+
        if (!found)
        {
                DBG1(DBG_CFG, "releasing address to pool '%s' failed", pool);
@@ -161,7 +161,7 @@ static attribute_handler_t* handle(private_attribute_manager_t *this,
 {
        enumerator_t *enumerator;
        attribute_handler_t *current, *handled = NULL;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->handlers->create_enumerator(this->handlers);
        while (enumerator->enumerate(enumerator, &current))
@@ -174,7 +174,7 @@ static attribute_handler_t* handle(private_attribute_manager_t *this,
        }
        enumerator->destroy(enumerator);
        this->lock->unlock(this->lock);
-       
+
        if (!handled)
        {
                DBG1(DBG_CFG, "handling %N attribute failed",
@@ -192,7 +192,7 @@ static void release(private_attribute_manager_t *this,
 {
        enumerator_t *enumerator;
        attribute_handler_t *current;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->handlers->create_enumerator(this->handlers);
        while (enumerator->enumerate(enumerator, &current))
@@ -246,7 +246,7 @@ static void destroy(private_attribute_manager_t *this)
 attribute_manager_t *attribute_manager_create()
 {
        private_attribute_manager_t *this = malloc_thing(private_attribute_manager_t);
-       
+
        this->public.acquire_address = (host_t*(*)(attribute_manager_t*, char*, identification_t*,host_t*))acquire_address;
        this->public.release_address = (void(*)(attribute_manager_t*, char *, host_t*, identification_t*))release_address;
        this->public.create_attribute_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t *id))create_attribute_enumerator;
@@ -257,11 +257,11 @@ attribute_manager_t *attribute_manager_create()
        this->public.add_handler = (void(*)(attribute_manager_t*, attribute_handler_t *handler))add_handler;
        this->public.remove_handler = (void(*)(attribute_manager_t*, attribute_handler_t *handler))remove_handler;
        this->public.destroy = (void(*)(attribute_manager_t*))destroy;
-       
+
        this->providers = linked_list_create();
        this->handlers = linked_list_create();
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index ceea06581c4afe3357dd296285033bcc00351728..68eb8b1bf66a28796dcde8fd99c783a88adb4085 100644 (file)
@@ -35,7 +35,7 @@ typedef struct attribute_manager_t attribute_manager_t;
  * are received on the requesting peer.
  */
 struct attribute_manager_t {
-       
+
        /**
         * Acquire a virtual IP address to assign to a peer.
         *
@@ -47,7 +47,7 @@ struct attribute_manager_t {
        host_t* (*acquire_address)(attribute_manager_t *this,
                                                           char *pool, identification_t *id,
                                                           host_t *requested);
-       
+
        /**
         * Release a previously acquired address.
         *
@@ -57,7 +57,7 @@ struct attribute_manager_t {
         */
        void (*release_address)(attribute_manager_t *this,
                                                        char *pool, host_t *address, identification_t *id);
-       
+
        /**
         * Create an enumerator over attributes to hand out to a peer.
         *
@@ -66,7 +66,7 @@ struct attribute_manager_t {
         */
        enumerator_t* (*create_attribute_enumerator)(attribute_manager_t *this,
                                                                                                 identification_t *id);
-       
+
        /**
         * Register an attribute provider to the manager.
         *
@@ -81,7 +81,7 @@ struct attribute_manager_t {
         */
        void (*remove_provider)(attribute_manager_t *this,
                                                        attribute_provider_t *provider);
-       
+
        /**
         * Handle a configuration attribute by passing them to the handlers.
         *
@@ -92,7 +92,7 @@ struct attribute_manager_t {
         */
        attribute_handler_t* (*handle)(attribute_manager_t *this, ike_sa_t *ike_sa,
                                                        configuration_attribute_type_t type, chunk_t data);
-       
+
        /**
         * Release an attribute previously handle()d by a handler.
         *
@@ -104,7 +104,7 @@ struct attribute_manager_t {
        void (*release)(attribute_manager_t *this, attribute_handler_t *handler,
                                                ike_sa_t *ike_sa, configuration_attribute_type_t type,
                                                chunk_t data);
-       
+
        /**
         * Register an attribute handler to the manager.
         *
@@ -112,7 +112,7 @@ struct attribute_manager_t {
         */
        void (*add_handler)(attribute_manager_t *this,
                                                attribute_handler_t *handler);
-       
+
        /**
         * Unregister an attribute handler from the manager.
         *
@@ -120,7 +120,7 @@ struct attribute_manager_t {
         */
        void (*remove_handler)(attribute_manager_t *this,
                                                   attribute_handler_t *handler);
-       
+
        /**
         * Destroy a attribute_manager instance.
         */
index 0f1057af412d7534342dcff304d4190b56741568..b8825723d8022bc9500f7bc5fefac2d3403861bb 100644 (file)
@@ -41,7 +41,7 @@ struct attribute_provider_t {
         * @return                              allocated address, NULL to serve none
         */
        host_t* (*acquire_address)(attribute_provider_t *this,
-                                                          char *pool, identification_t *id, 
+                                                          char *pool, identification_t *id,
                                                           host_t *requested);
        /**
         * Release a previously acquired address.
@@ -53,7 +53,7 @@ struct attribute_provider_t {
         */
        bool (*release_address)(attribute_provider_t *this,
                                                        char *pool, host_t *address, identification_t *id);
-       
+
        /**
         * Create an enumerator over attributes to hand out to a peer.
         *
index e4501bc93fc2039c09062a0be83fb610efbc0cb3..94362c756099f9149ed8f01291dc66d40d6e1f02 100644 (file)
@@ -45,12 +45,12 @@ typedef struct private_auth_cfg_t private_auth_cfg_t;
  * private data of item_set
  */
 struct private_auth_cfg_t {
-       
+
        /**
         * public functions
         */
        auth_cfg_t public;
-       
+
        /**
         * list of entry_t
         */
@@ -84,7 +84,7 @@ typedef struct {
 static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
 {
        entry_t *entry;
-       
+
        if (this->inner->enumerate(this->inner, &entry))
        {
                this->current = entry;
@@ -110,7 +110,7 @@ static void entry_enumerator_destroy(entry_enumerator_t *this)
 static enumerator_t* create_enumerator(private_auth_cfg_t *this)
 {
        entry_enumerator_t *enumerator;
-       
+
        enumerator = malloc_thing(entry_enumerator_t);
        enumerator->inner = this->entries->create_enumerator(this->entries);
        enumerator->public.enumerate = (void*)enumerate;
@@ -168,9 +168,9 @@ static void replace(auth_cfg_t *this, entry_enumerator_t *enumerator,
        if (enumerator->current)
        {
                va_list args;
-               
+
                va_start(args, type);
-               
+
                destroy_entry_value(enumerator->current);
                enumerator->current->type = type;
                switch (type)
@@ -210,7 +210,7 @@ static void* get(private_auth_cfg_t *this, auth_rule_t type)
        void *current_value, *best_value = NULL;
        auth_rule_t current_type;
        bool found = FALSE;
-       
+
        enumerator = create_enumerator(this);
        while (enumerator->enumerate(enumerator, &current_type, &current_value))
        {
@@ -270,7 +270,7 @@ static void add(private_auth_cfg_t *this, auth_rule_t type, ...)
 {
        entry_t *entry = malloc_thing(entry_t);
        va_list args;
-       
+
        va_start(args, type);
        entry->type = type;
        switch (type)
@@ -311,7 +311,7 @@ static bool complies(private_auth_cfg_t *this, auth_cfg_t *constraints,
        bool success = TRUE;
        auth_rule_t t1, t2;
        void *value;
-       
+
        e1 = constraints->create_enumerator(constraints);
        while (e1->enumerate(e1, &t1, &value))
        {
@@ -321,9 +321,9 @@ static bool complies(private_auth_cfg_t *this, auth_cfg_t *constraints,
                        case AUTH_RULE_IM_CERT:
                        {
                                certificate_t *c1, *c2;
-                               
+
                                c1 = (certificate_t*)value;
-                               
+
                                success = FALSE;
                                e2 = create_enumerator(this);
                                while (e2->enumerate(e2, &t2, &c2))
@@ -345,7 +345,7 @@ static bool complies(private_auth_cfg_t *this, auth_cfg_t *constraints,
                        case AUTH_RULE_SUBJECT_CERT:
                        {
                                certificate_t *c1, *c2;
-                               
+
                                c1 = (certificate_t*)value;
                                c2 = get(this, AUTH_RULE_SUBJECT_CERT);
                                if (!c2 || !c1->equals(c1, c2))
@@ -364,7 +364,7 @@ static bool complies(private_auth_cfg_t *this, auth_cfg_t *constraints,
                        case AUTH_RULE_OCSP_VALIDATION:
                        {
                                cert_validation_t validated, required;
-                               
+
                                required = (uintptr_t)value;
                                validated = (uintptr_t)get(this, t1);
                                switch (required)
@@ -401,7 +401,7 @@ static bool complies(private_auth_cfg_t *this, auth_cfg_t *constraints,
                        case AUTH_RULE_EAP_IDENTITY:
                        {
                                identification_t *id1, *id2;
-                               
+
                                id1 = (identification_t*)value;
                                id2 = get(this, t1);
                                if (!id2 || !id2->matches(id2, id1))
@@ -499,7 +499,7 @@ static void merge(private_auth_cfg_t *this, private_auth_cfg_t *other, bool copy
                enumerator_t *enumerator;
                auth_rule_t type;
                void *value;
-               
+
                enumerator = create_enumerator(other);
                while (enumerator->enumerate(enumerator, &type, &value))
                {
@@ -512,7 +512,7 @@ static void merge(private_auth_cfg_t *this, private_auth_cfg_t *other, bool copy
                                case AUTH_HELPER_SUBJECT_CERT:
                                {
                                        certificate_t *cert = (certificate_t*)value;
-                                       
+
                                        add(this, type, cert->get_ref(cert));
                                        break;
                                }
@@ -530,7 +530,7 @@ static void merge(private_auth_cfg_t *this, private_auth_cfg_t *other, bool copy
                                case AUTH_RULE_AC_GROUP:
                                {
                                        identification_t *id = (identification_t*)value;
-                                       
+
                                        add(this, type, id->clone(id));
                                        break;
                                }
@@ -547,7 +547,7 @@ static void merge(private_auth_cfg_t *this, private_auth_cfg_t *other, bool copy
        else
        {
                entry_t *entry;
-               
+
                while (other->entries->remove_first(other->entries,
                                                                                        (void**)&entry) == SUCCESS)
                {
@@ -564,7 +564,7 @@ static bool equals(private_auth_cfg_t *this, private_auth_cfg_t *other)
        enumerator_t *e1, *e2;
        entry_t *i1, *i2;
        bool equal = TRUE, found;
-       
+
        if (this->entries->get_count(this->entries) !=
                other->entries->get_count(other->entries))
        {
@@ -601,10 +601,10 @@ static bool equals(private_auth_cfg_t *this, private_auth_cfg_t *other)
                                        case AUTH_HELPER_SUBJECT_CERT:
                                        {
                                                certificate_t *c1, *c2;
-                                               
+
                                                c1 = (certificate_t*)i1->value;
                                                c2 = (certificate_t*)i2->value;
-                                               
+
                                                if (c1->equals(c1, c2))
                                                {
                                                        found = TRUE;
@@ -617,10 +617,10 @@ static bool equals(private_auth_cfg_t *this, private_auth_cfg_t *other)
                                        case AUTH_RULE_AC_GROUP:
                                        {
                                                identification_t *id1, *id2;
-                                               
+
                                                id1 = (identification_t*)i1->value;
                                                id2 = (identification_t*)i2->value;
-                                               
+
                                                if (id1->equals(id1, id2))
                                                {
                                                        found = TRUE;
@@ -660,7 +660,7 @@ static void purge(private_auth_cfg_t *this, bool keep_ca)
 {
        entry_t *entry;
        linked_list_t *cas;
-       
+
        cas = linked_list_create();
        while (this->entries->remove_last(this->entries, (void**)&entry) == SUCCESS)
        {
@@ -689,7 +689,7 @@ static auth_cfg_t* clone_(private_auth_cfg_t *this)
        enumerator_t *enumerator;
        auth_cfg_t *clone;
        entry_t *entry;
-       
+
        clone = auth_cfg_create();
        enumerator = this->entries->create_enumerator(this->entries);
        while (enumerator->enumerate(enumerator, &entry))
@@ -749,7 +749,7 @@ static void destroy(private_auth_cfg_t *this)
 auth_cfg_t *auth_cfg_create()
 {
        private_auth_cfg_t *this = malloc_thing(private_auth_cfg_t);
-       
+
        this->public.add = (void(*)(auth_cfg_t*, auth_rule_t type, ...))add;
        this->public.get = (void*(*)(auth_cfg_t*, auth_rule_t type))get;
        this->public.create_enumerator = (enumerator_t*(*)(auth_cfg_t*))create_enumerator;
@@ -760,9 +760,9 @@ auth_cfg_t *auth_cfg_create()
        this->public.equals = (bool(*)(auth_cfg_t*, auth_cfg_t *other))equals;
        this->public.clone = (auth_cfg_t*(*)(auth_cfg_t*))clone_;
        this->public.destroy = (void(*)(auth_cfg_t*))destroy;
-       
+
        this->entries = linked_list_create();
-       
+
        return &this->public;
 }
 
index c6bc1959ba3b95c80c9169a86f3a2d18a2f8b2e5..5e6215a4ab66e17b06f1e168719909a5c78149de 100644 (file)
@@ -41,7 +41,7 @@ typedef enum auth_rule_t auth_rule_t;
  * to transport credentials during the authentication process.
  */
 enum auth_rule_t {
-       
+
        /** identity to use for IKEv2 authentication exchange, identification_t* */
        AUTH_RULE_IDENTITY,
        /** authentication class, auth_class_t */
@@ -64,7 +64,7 @@ enum auth_rule_t {
        AUTH_RULE_OCSP_VALIDATION,
        /** subject is in attribute certificate group, identification_t* */
        AUTH_RULE_AC_GROUP,
-       
+
        /** intermediate certificate, certificate_t* */
        AUTH_HELPER_IM_CERT,
        /** subject certificate, certificate_t* */
@@ -86,7 +86,7 @@ extern enum_name_t *auth_rule_names;
  * RFC4739 defines multiple authentication rounds. This class defines such
  * a round from a configuration perspective, either for the local or the remote
  * peer. Local config are called "rulesets", as they define how we authenticate.
- * Remote peer configs are called "constraits", they define what is needed to 
+ * Remote peer configs are called "constraits", they define what is needed to
  * complete the authentication round successfully.
  *
  * @verbatim
@@ -122,7 +122,7 @@ struct auth_cfg_t {
         * @param ...           associated value to rule
         */
        void (*add)(auth_cfg_t *this, auth_rule_t rule, ...);
-       
+
        /**
         * Get an rule value.
         *
@@ -130,14 +130,14 @@ struct auth_cfg_t {
         * @return                      bool if item has been found
         */
        void* (*get)(auth_cfg_t *this, auth_rule_t rule);
-       
+
        /**
         * Create an enumerator over added rules.
         *
         * @return                      enumerator over (auth_rule_t, union{void*,uintpr_t})
         */
        enumerator_t* (*create_enumerator)(auth_cfg_t *this);
-       
+
        /**
         * Replace an rule at enumerator position.
         *
@@ -147,7 +147,7 @@ struct auth_cfg_t {
         */
        void (*replace)(auth_cfg_t *this, enumerator_t *pos,
                                        auth_rule_t rule, ...);
-       
+
        /**
         * Check if a used config fulfills a set of configured constraints.
         *
@@ -156,7 +156,7 @@ struct auth_cfg_t {
         * @return                              TRUE if this complies with constraints
         */
        bool (*complies)(auth_cfg_t *this, auth_cfg_t *constraints, bool log_error);
-       
+
        /**
         * Merge items from other into this.
         *
@@ -164,14 +164,14 @@ struct auth_cfg_t {
         * @param copy          TRUE to copy items, FALSE to move them
         */
        void (*merge)(auth_cfg_t *this, auth_cfg_t *other, bool copy);
-       
+
        /**
         * Purge all rules in a config.
         *
         * @param keep_ca       wheter to keep AUTH_RULE_CA_CERT entries
         */
        void (*purge)(auth_cfg_t *this, bool keep_ca);
-       
+
        /**
         * Check two configs for equality.
         *
@@ -179,14 +179,14 @@ struct auth_cfg_t {
         * @return                      TRUE if auth infos identical
         */
        bool (*equals)(auth_cfg_t *this, auth_cfg_t *other);
-       
+
        /**
         * Clone a authentication config, including all rules.
         *
         * @return                      cloned configuration
         */
        auth_cfg_t* (*clone)(auth_cfg_t *this);
-       
+
        /**
         * Destroy a config with all associated rules/values.
         */
index cfd611858ec5b5387eaf617a6619d2fb6f39dfbc..f6cbff4bee89565c42644a34f983472484ab6e68 100644 (file)
@@ -34,12 +34,12 @@ struct private_backend_manager_t {
         * Public part of backend_manager_t object.
         */
        backend_manager_t public;
-       
+
        /**
         * list of registered backends
         */
        linked_list_t *backends;
-       
+
        /**
         * rwlock for backends
         */
@@ -80,7 +80,7 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other)
 {
        host_t *me_cand, *other_cand;
        ike_cfg_match_t match = MATCH_NONE;
-       
+
        if (me)
        {
                me_cand = host_create_from_dns(cand->get_my_addr(cand),
@@ -103,7 +103,7 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other)
        {
                match += MATCH_ANY;
        }
-       
+
        if (other)
        {
                other_cand = host_create_from_dns(cand->get_other_addr(cand),
@@ -132,21 +132,21 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other)
 /**
  * implements backend_manager_t.get_ike_cfg.
  */
-static ike_cfg_t *get_ike_cfg(private_backend_manager_t *this, 
+static ike_cfg_t *get_ike_cfg(private_backend_manager_t *this,
                                                          host_t *me, host_t *other)
 {
        ike_cfg_t *current, *found = NULL;
        enumerator_t *enumerator;
        ike_cfg_match_t match, best = MATCH_ANY;
        ike_data_t *data;
-       
+
        data = malloc_thing(ike_data_t);
        data->this = this;
        data->me = me;
        data->other = other;
-       
+
        DBG2(DBG_CFG, "looking for an ike config for %H...%H", me, other);
-       
+
        this->lock->read_lock(this->lock);
        enumerator = enumerator_create_nested(
                                                this->backends->create_enumerator(this->backends),
@@ -154,11 +154,11 @@ static ike_cfg_t *get_ike_cfg(private_backend_manager_t *this,
        while (enumerator->enumerate(enumerator, (void**)&current))
        {
                match = get_ike_match(current, me, other);
-               
+
                if (match)
                {
-                       DBG2(DBG_CFG, "  candidate: %s...%s, prio %d", 
-                                current->get_my_addr(current), 
+                       DBG2(DBG_CFG, "  candidate: %s...%s, prio %d",
+                                current->get_my_addr(current),
                                 current->get_other_addr(current), match);
                        if (match > best)
                        {
@@ -173,7 +173,7 @@ static ike_cfg_t *get_ike_cfg(private_backend_manager_t *this,
        this->lock->unlock(this->lock);
        if (found)
        {
-               DBG2(DBG_CFG, "found matching ike config: %s...%s with prio %d", 
+               DBG2(DBG_CFG, "found matching ike config: %s...%s with prio %d",
                         found->get_my_addr(found), found->get_other_addr(found), best);
        }
        return found;
@@ -189,12 +189,12 @@ static id_match_t get_peer_match(identification_t *id,
        auth_cfg_t *auth;
        identification_t *candidate;
        id_match_t match = ID_MATCH_NONE;
-       
+
        if (!id)
        {
                return ID_MATCH_ANY;
        }
-       
+
        /* compare first auth config only */
        enumerator = cfg->create_auth_cfg_enumerator(cfg, local);
        if (enumerator->enumerate(enumerator, &auth))
@@ -269,7 +269,7 @@ static bool peer_enum_filter(linked_list_t *configs,
 static void peer_enum_filter_destroy(linked_list_t *configs)
 {
        match_entry_t *entry;
-       
+
        while (configs->remove_last(configs, (void**)&entry) == SUCCESS)
        {
                entry->cfg->destroy(entry->cfg);
@@ -285,7 +285,7 @@ static void insert_sorted(match_entry_t *entry, linked_list_t *list,
                                                  linked_list_t *helper)
 {
        match_entry_t *current;
-       
+
        while (list->remove_first(list, (void**)&current) == SUCCESS)
        {
                helper->insert_last(helper, current);
@@ -311,7 +311,7 @@ static void insert_sorted(match_entry_t *entry, linked_list_t *list,
 
 /**
  * Implements backend_manager_t.create_peer_cfg_enumerator.
- */                    
+ */
 static enumerator_t *create_peer_cfg_enumerator(private_backend_manager_t *this,
                                                        host_t *me, host_t *other, identification_t *my_id,
                                                        identification_t *other_id)
@@ -320,26 +320,26 @@ static enumerator_t *create_peer_cfg_enumerator(private_backend_manager_t *this,
        peer_data_t *data;
        peer_cfg_t *cfg;
        linked_list_t *configs, *helper;
-       
+
        data = malloc_thing(peer_data_t);
        data->lock = this->lock;
        data->me = my_id;
        data->other = other_id;
-       
+
        /* create a sorted list with all matches */
        this->lock->read_lock(this->lock);
        enumerator = enumerator_create_nested(
                                        this->backends->create_enumerator(this->backends),
                                        (void*)peer_enum_create, data, (void*)peer_enum_destroy);
-       
+
        if (!me && !other && !my_id && !other_id)
        {       /* shortcut if we are doing a "listall" */
                return enumerator;
        }
-       
+
        DBG1(DBG_CFG, "looking for peer configs matching %H[%Y]...%H[%Y]",
                 me, my_id, other, other_id);
-       
+
        configs = linked_list_create();
        /* only once allocated helper list for sorting */
        helper = linked_list_create();
@@ -348,16 +348,16 @@ static enumerator_t *create_peer_cfg_enumerator(private_backend_manager_t *this,
                id_match_t match_peer_me, match_peer_other;
                ike_cfg_match_t match_ike;
                match_entry_t *entry;
-               
+
                match_peer_me = get_peer_match(my_id, cfg, TRUE);
                match_peer_other = get_peer_match(other_id, cfg, FALSE);
                match_ike = get_ike_match(cfg->get_ike_cfg(cfg), me, other);
-               
+
                if (match_peer_me && match_peer_other && match_ike)
                {
                        DBG2(DBG_CFG, "  candidate \"%s\", match: %d/%d/%d (me/other/ike)",
                                 cfg->get_name(cfg), match_peer_me, match_peer_other, match_ike);
-                       
+
                        entry = malloc_thing(match_entry_t);
                        entry->match_peer = match_peer_me + match_peer_other;
                        entry->match_ike = match_ike;
@@ -367,7 +367,7 @@ static enumerator_t *create_peer_cfg_enumerator(private_backend_manager_t *this,
        }
        enumerator->destroy(enumerator);
        helper->destroy(helper);
-       
+
        return enumerator_create_filter(configs->create_enumerator(configs),
                                                                        (void*)peer_enum_filter, configs,
                                                                        (void*)peer_enum_filter_destroy);
@@ -375,13 +375,13 @@ static enumerator_t *create_peer_cfg_enumerator(private_backend_manager_t *this,
 
 /**
  * implements backend_manager_t.get_peer_cfg_by_name.
- */                    
+ */
 static peer_cfg_t *get_peer_cfg_by_name(private_backend_manager_t *this, char *name)
 {
        backend_t *backend;
        peer_cfg_t *config = NULL;
        enumerator_t *enumerator;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->backends->create_enumerator(this->backends);
        while (config == NULL && enumerator->enumerate(enumerator, (void**)&backend))
@@ -429,17 +429,17 @@ static void destroy(private_backend_manager_t *this)
 backend_manager_t *backend_manager_create()
 {
        private_backend_manager_t *this = malloc_thing(private_backend_manager_t);
-       
+
        this->public.get_ike_cfg = (ike_cfg_t* (*)(backend_manager_t*, host_t*, host_t*))get_ike_cfg;
        this->public.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_manager_t*,char*))get_peer_cfg_by_name;
        this->public.create_peer_cfg_enumerator = (enumerator_t* (*)(backend_manager_t*,host_t*,host_t*,identification_t*,identification_t*))create_peer_cfg_enumerator;
        this->public.add_backend = (void(*)(backend_manager_t*, backend_t *backend))add_backend;
        this->public.remove_backend = (void(*)(backend_manager_t*, backend_t *backend))remove_backend;
        this->public.destroy = (void (*)(backend_manager_t*))destroy;
-       
+
        this->backends = linked_list_create();
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index 0b7d7d0f86798612e8521ef0a895504930afe54d..5b394f79140ecd5175588f79ef826e5069604451 100644 (file)
@@ -46,11 +46,11 @@ typedef struct backend_manager_t backend_manager_t;
    |         |----->|           |     +--------------+         |
    |         |      |           |                              |
    +---------+      +-----------+                              |
-   
+
    @endverbatim
  */
 struct backend_manager_t {
-       
+
        /**
         * Get an ike_config identified by two hosts.
         *
@@ -58,9 +58,9 @@ struct backend_manager_t {
         * @param other_host            address of remote host
         * @return                                      matching ike_config, or NULL if none found
         */
-       ike_cfg_t* (*get_ike_cfg)(backend_manager_t *this, 
+       ike_cfg_t* (*get_ike_cfg)(backend_manager_t *this,
                                                          host_t *my_host, host_t *other_host);
-       
+
        /**
         * Get a peer_config identified by it's name.
         *
@@ -68,7 +68,7 @@ struct backend_manager_t {
         * @return                                      matching peer_config, or NULL if none found
         */
        peer_cfg_t* (*get_peer_cfg_by_name)(backend_manager_t *this, char *name);
-       
+
        /**
         * Create an enumerator over all matching peer configs.
         *
@@ -90,14 +90,14 @@ struct backend_manager_t {
         * @param backend                       backend to register
         */
        void (*add_backend)(backend_manager_t *this, backend_t *backend);
-       
+
        /**
         * Unregister a backend.
         *
         * @param backend                       backend to unregister
         */
        void (*remove_backend)(backend_manager_t *this, backend_t *backend);
-       
+
        /**
         * Destroys a backend_manager_t object.
         */
index 05c47f747b03b232c462899e8f871b754a85dd7a..036a25007336a1b0373459fad2e8992820b2ed76 100644 (file)
@@ -25,7 +25,7 @@ ENUM(action_names, ACTION_NONE, ACTION_RESTART,
        "restart",
 );
 
-ENUM_BEGIN(ipcomp_transform_names, IPCOMP_NONE, IPCOMP_NONE, 
+ENUM_BEGIN(ipcomp_transform_names, IPCOMP_NONE, IPCOMP_NONE,
        "IPCOMP_NONE");
 ENUM_NEXT(ipcomp_transform_names, IPCOMP_OUI, IPCOMP_LZJH, IPCOMP_NONE,
        "IPCOMP_OUI",
@@ -45,62 +45,62 @@ struct private_child_cfg_t {
         * Public part
         */
        child_cfg_t public;
-       
+
        /**
         * Number of references hold by others to this child_cfg
         */
        refcount_t refcount;
-       
+
        /**
         * Name of the child_cfg, used to query it
         */
        char *name;
-       
+
        /**
         * list for all proposals
         */
        linked_list_t *proposals;
-       
+
        /**
         * list for traffic selectors for my site
         */
        linked_list_t *my_ts;
-       
+
        /**
         * list for traffic selectors for others site
         */
        linked_list_t *other_ts;
-       
+
        /**
         * updown script
         */
        char *updown;
-       
+
        /**
         * allow host access
         */
        bool hostaccess;
-       
+
        /**
         * Mode to propose for a initiated CHILD: tunnel/transport
         */
        ipsec_mode_t mode;
-       
+
        /**
         * action to take on DPD
         */
        action_t dpd_action;
-       
+
        /**
         * action to take on CHILD_SA close
         */
        action_t close_action;
-       
+
        /**
         * CHILD_SA lifetime config
         */
        lifetime_cfg_t lifetime;
-       
+
        /**
         * enable IPComp
         */
@@ -141,7 +141,7 @@ static linked_list_t* get_proposals(private_child_cfg_t *this, bool strip_dh)
        enumerator_t *enumerator;
        proposal_t *current;
        linked_list_t *proposals = linked_list_create();
-       
+
        enumerator = this->proposals->create_enumerator(this->proposals);
        while (enumerator->enumerate(enumerator, &current))
        {
@@ -153,7 +153,7 @@ static linked_list_t* get_proposals(private_child_cfg_t *this, bool strip_dh)
                proposals->insert_last(proposals, current);
        }
        enumerator->destroy(enumerator);
-       
+
        return proposals;
 }
 
@@ -165,10 +165,10 @@ static proposal_t* select_proposal(private_child_cfg_t*this,
 {
        enumerator_t *stored_enum, *supplied_enum;
        proposal_t *stored, *supplied, *selected = NULL;
-       
+
        stored_enum = this->proposals->create_enumerator(this->proposals);
        supplied_enum = proposals->create_enumerator(proposals);
-       
+
        /* compare all stored proposals with all supplied. Stored ones are preferred. */
        while (stored_enum->enumerate(stored_enum, &stored))
        {
@@ -194,7 +194,7 @@ static proposal_t* select_proposal(private_child_cfg_t*this,
                        break;
                }
                supplied_enum->destroy(supplied_enum);
-               supplied_enum = proposals->create_enumerator(proposals);        
+               supplied_enum = proposals->create_enumerator(proposals);
        }
        stored_enum->destroy(stored_enum);
        supplied_enum->destroy(supplied_enum);
@@ -232,7 +232,7 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca
        enumerator_t *e1, *e2;
        traffic_selector_t *ts1, *ts2, *selected;
        linked_list_t *result = linked_list_create();
-       
+
        if (local)
        {
                e1 = this->my_ts->create_enumerator(this->my_ts);
@@ -241,11 +241,11 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca
        {
                e1 = this->other_ts->create_enumerator(this->other_ts);
        }
-       
+
        /* no list supplied, just fetch the stored traffic selectors */
        if (supplied == NULL)
        {
-               DBG2(DBG_CFG, "proposing traffic selectors for %s:", 
+               DBG2(DBG_CFG, "proposing traffic selectors for %s:",
                         local ? "us" : "other");
                while (e1->enumerate(e1, &ts1))
                {
@@ -262,7 +262,7 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca
        }
        else
        {
-               DBG2(DBG_CFG, "selecting traffic selectors for %s:", 
+               DBG2(DBG_CFG, "selecting traffic selectors for %s:",
                         local ? "us" : "other");
                e2 = supplied->create_enumerator(supplied);
                /* iterate over all stored selectors */
@@ -274,7 +274,7 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca
                        {
                                ts1->set_address(ts1, host);
                        }
-                       
+
                        /* iterate over all supplied traffic selectors */
                        while (e2->enumerate(e2, &ts2))
                        {
@@ -298,7 +298,7 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca
                e1->destroy(e1);
                e2->destroy(e2);
        }
-       
+
        /* remove any redundant traffic selectors in the list */
        e1 = result->create_enumerator(result);
        e2 = result->create_enumerator(result);
@@ -329,7 +329,7 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca
        }
        e1->destroy(e1);
        e2->destroy(e2);
-       
+
        return result;
 }
 
@@ -410,7 +410,7 @@ static diffie_hellman_group_t get_dh_group(private_child_cfg_t *this)
        enumerator_t *enumerator;
        proposal_t *proposal;
        u_int16_t dh_group = MODP_NONE;
-       
+
        enumerator = this->proposals->create_enumerator(this->proposals);
        while (enumerator->enumerate(enumerator, &proposal))
        {
@@ -514,16 +514,16 @@ child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
        this->public.install_policy = (bool (*) (child_cfg_t *))install_policy;
        this->public.get_ref = (child_cfg_t* (*) (child_cfg_t*))get_ref;
        this->public.destroy = (void (*) (child_cfg_t*))destroy;
-       
+
        this->name = strdup(name);
        this->updown = updown ? strdup(updown) : NULL;
        this->hostaccess = hostaccess;
        this->mode = mode;
        this->dpd_action = dpd_action;
        this->close_action = close_action;
-       this->use_ipcomp = ipcomp; 
+       this->use_ipcomp = ipcomp;
        this->proxy_mode = FALSE;
-       this->install_policy = TRUE; 
+       this->install_policy = TRUE;
        this->refcount = 1;
        this->proposals = linked_list_create();
        this->my_ts = linked_list_create();
index 492514eae82e760d63df76230e344c75f548eb60..becee8107d0a143da2df51ea6191f9988c30f85a 100644 (file)
@@ -88,68 +88,68 @@ struct lifetime_cfg_t {
  * After creation, proposals and traffic selectors may be added to the config.
  * A child_cfg object is referenced multiple times, and is not thread save.
  * Reading from the object is save, adding things is not allowed while other
- * threads may access the object. 
+ * threads may access the object.
  * A reference counter handles the number of references hold to this config.
  *
  * @see peer_cfg_t to get an overview over the configurations.
  */
 struct child_cfg_t {
-       
+
        /**
         * Get the name of the child_cfg.
-        * 
+        *
         * @return                              child_cfg's name
         */
        char *(*get_name) (child_cfg_t *this);
-       
+
        /**
-        * Add a proposal to the list. 
-        * 
+        * Add a proposal to the list.
+        *
         * The proposals are stored by priority, first added
         * is the most prefered.
         * After add, proposal is owned by child_cfg.
-        * 
+        *
         * @param proposal              proposal to add
         */
        void (*add_proposal) (child_cfg_t *this, proposal_t *proposal);
-       
+
        /**
         * Get the list of proposals for the CHILD_SA.
         *
         * Resulting list and all of its proposals must be freed after use.
-        * 
+        *
         * @param strip_dh              TRUE strip out diffie hellman groups
         * @return                              list of proposals
         */
        linked_list_t* (*get_proposals)(child_cfg_t *this, bool strip_dh);
-       
+
        /**
         * Select a proposal from a supplied list.
         *
         * Returned propsal is newly created and must be destroyed after usage.
-        * 
+        *
         * @param proposals             list from from wich proposals are selected
         * @param strip_dh              TRUE strip out diffie hellman groups
         * @return                              selected proposal, or NULL if nothing matches
         */
        proposal_t* (*select_proposal)(child_cfg_t*this, linked_list_t *proposals,
                                                                   bool strip_dh);
-       
+
        /**
         * Add a traffic selector to the config.
-        * 
+        *
         * Use the "local" parameter to add it for the local or the remote side.
         * After add, traffic selector is owned by child_cfg.
-        * 
+        *
         * @param local                 TRUE for local side, FALSE for remote
         * @param ts                    traffic_selector to add
         */
        void (*add_traffic_selector)(child_cfg_t *this, bool local,
                                                                 traffic_selector_t *ts);
-       
+
        /**
         * Get a list of traffic selectors to use for the CHILD_SA.
-        * 
+        *
         * The config contains two set of traffic selectors, one for the local
         * side, one for the remote side.
         * If a list with traffic selectors is supplied, these are used to narrow
@@ -158,7 +158,7 @@ struct child_cfg_t {
         * to a specific address (host-to-host or virtual-IP setups). Use
         * the "host" parameter to narrow such traffic selectors to that address.
         * Resulted list and its traffic selectors must be destroyed after use.
-        * 
+        *
         * @param local                 TRUE for TS on local side, FALSE for remote
         * @param supplied              list with TS to select from, or NULL
         * @param host                  address to use for narrowing "dynamic" TS', or NULL
@@ -169,14 +169,14 @@ struct child_cfg_t {
                                                                                        host_t *host);
        /**
         * Get the updown script to run for the CHILD_SA.
-        * 
+        *
         * @return                              path to updown script
         */
        char* (*get_updown)(child_cfg_t *this);
-       
+
        /**
         * Should we allow access to the local host (gateway)?
-        * 
+        *
         * @return                              value of hostaccess flag
         */
        bool (*get_hostaccess) (child_cfg_t *this);
@@ -190,41 +190,41 @@ struct child_cfg_t {
         * @return                              lifetime_cfg_t (has to be freed)
         */
        lifetime_cfg_t* (*get_lifetime) (child_cfg_t *this);
-       
+
        /**
         * Get the mode to use for the CHILD_SA.
         *
         * The mode is either tunnel, transport or BEET. The peer must agree
         * on the method, fallback is tunnel mode.
-        * 
+        *
         * @return                              ipsec mode
         */
        ipsec_mode_t (*get_mode) (child_cfg_t *this);
-       
+
        /**
         * Action to take on DPD.
         *
         * @return                              DPD action
-        */     
+        */
        action_t (*get_dpd_action) (child_cfg_t *this);
-       
+
        /**
         * Action to take if CHILD_SA gets closed.
         *
         * @return                              close action
-        */     
+        */
        action_t (*get_close_action) (child_cfg_t *this);
-       
+
        /**
         * Get the DH group to use for CHILD_SA setup.
-        * 
+        *
         * @return                              dh group to use
         */
        diffie_hellman_group_t (*get_dh_group)(child_cfg_t *this);
-       
+
        /**
         * Check whether IPComp should be used, if the other peer supports it.
-        * 
+        *
         * @return                              TRUE, if IPComp should be used
         *                                              FALSE, otherwise
         */
@@ -232,7 +232,7 @@ struct child_cfg_t {
 
        /**
         * Sets two options needed for Mobile IPv6 interoperability
-        * 
+        *
         * @param proxy_mode    use IPsec transport proxy mode (default FALSE)
         * @param install_policy install IPsec kernel policies (default TRUE)
         */
@@ -241,27 +241,27 @@ struct child_cfg_t {
 
        /**
         * Check whether IPsec transport SA should be set up in proxy mode
-        * 
+        *
         * @return                              TRUE, if proxy mode should be used
         *                                              FALSE, otherwise
         */
        bool (*use_proxy_mode)(child_cfg_t *this);
-       
+
        /**
         * Check whether IPsec policies should be installed in the kernel
-        * 
+        *
         * @return                              TRUE, if IPsec kernel policies should be installed
         *                                              FALSE, otherwise
         */
        bool (*install_policy)(child_cfg_t *this);
-       
+
        /**
         * Increase the reference count.
         *
         * @return                              reference to this
         */
        child_cfg_t* (*get_ref) (child_cfg_t *this);
-       
+
        /**
         * Destroys the child_cfg object.
         *
@@ -273,7 +273,7 @@ struct child_cfg_t {
 
 /**
  * Create a configuration template for CHILD_SA setup.
- * 
+ *
  * The "name" string gets cloned.
  *
  * The lifetime_cfg_t object gets cloned.
@@ -281,7 +281,7 @@ struct child_cfg_t {
  * specified. Rekeying of an SA starts at (x.rekey - random(0, x.jitter)).
  *
  * After a call to create, a reference is obtained (refcount = 1).
- * 
+ *
  * @param name                         name of the child_cfg
  * @param lifetime                     lifetime_cfg_t for this child_cfg
  * @param updown                       updown script to execute on up/down event
index e80ab577eb7fa0b39da86d73dadcb976e9d4a07a..c2ebf648b12b28bacd239aafad5600876a1ebeac 100644 (file)
@@ -32,7 +32,7 @@ struct private_ike_cfg_t {
         * Public part
         */
        ike_cfg_t public;
-       
+
        /**
         * Number of references hold by others to this ike_cfg
         */
@@ -45,19 +45,19 @@ struct private_ike_cfg_t {
 
        /**
         * Address of remote host
-        */     
+        */
        char *other;
-       
+
        /**
         * should we send a certificate request?
         */
        bool certreq;
-       
+
        /**
         * enforce UDP encapsulation
         */
        bool force_encap;
-       
+
        /**
         * List of proposals to use
         */
@@ -71,7 +71,7 @@ static bool send_certreq(private_ike_cfg_t *this)
 {
        return this->certreq;
 }
-       
+
 /**
  * Implementation of ike_cfg_t.force_encap.
  */
@@ -112,7 +112,7 @@ static linked_list_t* get_proposals(private_ike_cfg_t *this)
        iterator_t *iterator;
        proposal_t *current;
        linked_list_t *proposals = linked_list_create();
-       
+
        iterator = this->proposals->create_iterator(this->proposals, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
@@ -120,10 +120,10 @@ static linked_list_t* get_proposals(private_ike_cfg_t *this)
                proposals->insert_last(proposals, (void*)current);
        }
        iterator->destroy(iterator);
-       
+
        return proposals;
 }
-       
+
 /**
  * Implementation of ike_cfg_t.select_proposal.
  */
@@ -132,16 +132,16 @@ static proposal_t *select_proposal(private_ike_cfg_t *this,
 {
        iterator_t *stored_iter, *supplied_iter;
        proposal_t *stored, *supplied, *selected;
-       
+
        stored_iter = this->proposals->create_iterator(this->proposals, TRUE);
        supplied_iter = proposals->create_iterator(proposals, TRUE);
-       
-       
+
+
        /* compare all stored proposals with all supplied. Stored ones are preferred.*/
        while (stored_iter->iterate(stored_iter, (void**)&stored))
        {
                supplied_iter->reset(supplied_iter);
-               
+
                while (supplied_iter->iterate(supplied_iter, (void**)&supplied))
                {
                        selected = stored->select(stored, supplied);
@@ -162,7 +162,7 @@ static proposal_t *select_proposal(private_ike_cfg_t *this,
        supplied_iter->destroy(supplied_iter);
        DBG1(DBG_CFG, "received proposals: %#P", proposals);
        DBG1(DBG_CFG, "configured proposals: %#P", this->proposals);
-       
+
        return NULL;
 }
 
@@ -174,7 +174,7 @@ static diffie_hellman_group_t get_dh_group(private_ike_cfg_t *this)
        enumerator_t *enumerator;
        proposal_t *proposal;
        u_int16_t dh_group = MODP_NONE;
-       
+
        enumerator = this->proposals->create_enumerator(this->proposals);
        while (enumerator->enumerate(enumerator, &proposal))
        {
@@ -195,7 +195,7 @@ static bool equals(private_ike_cfg_t *this, private_ike_cfg_t *other)
        enumerator_t *e1, *e2;
        proposal_t *p1, *p2;
        bool eq = TRUE;
-       
+
        if (this == other)
        {
                return TRUE;
@@ -260,7 +260,7 @@ ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap,
                                                  char *me, char *other)
 {
        private_ike_cfg_t *this = malloc_thing(private_ike_cfg_t);
-       
+
        /* public functions */
        this->public.send_certreq = (bool(*)(ike_cfg_t*))send_certreq;
        this->public.force_encap = (bool (*) (ike_cfg_t *))force_encap_meth;
@@ -273,7 +273,7 @@ ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap,
        this->public.equals = (bool(*)(ike_cfg_t*,ike_cfg_t*)) equals;
        this->public.get_ref = (ike_cfg_t*(*)(ike_cfg_t*))get_ref;
        this->public.destroy = (void(*)(ike_cfg_t*))destroy;
-       
+
        /* private variables */
        this->refcount = 1;
        this->certreq = certreq;
@@ -281,6 +281,6 @@ ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap,
        this->me = strdup(me);
        this->other = strdup(other);
        this->proposals = linked_list_create();
-       
+
        return &this->public;
 }
index 064906423e1b378d549fa84c9a06a6ecf44e17a2..8b68af3e9d8b6c83981ffd223c40ca1eeecc3e58 100644 (file)
@@ -37,71 +37,71 @@ typedef struct ike_cfg_t ike_cfg_t;
  * @see peer_cfg_t to get an overview over the configurations.
  */
 struct ike_cfg_t {
-       
+
        /**
         * Get own address.
-        * 
+        *
         * @return              string of address/DNS name
         */
        char* (*get_my_addr) (ike_cfg_t *this);
 
        /**
         * Get peers address.
-        * 
+        *
         * @return              string of address/DNS name
         */
        char* (*get_other_addr) (ike_cfg_t *this);
-       
+
        /**
         * Adds a proposal to the list.
-        * 
+        *
         * The first added proposal has the highest priority, the last
         * added the lowest.
-        * 
+        *
         * @param proposal      proposal to add
         */
        void (*add_proposal) (ike_cfg_t *this, proposal_t *proposal);
-       
+
        /**
         * Returns a list of all supported proposals.
-        * 
+        *
         * Returned list and its proposals must be destroyed after use.
-        * 
+        *
         * @return                      list containing all the proposals
         */
        linked_list_t* (*get_proposals) (ike_cfg_t *this);
-       
+
        /**
         * Select a proposed from suggested proposals.
-        * 
+        *
         * Returned proposal must be destroyed after use.
-        * 
+        *
         * @param proposals     list of proposals to select from
         * @return                      selected proposal, or NULL if none matches.
         */
        proposal_t *(*select_proposal) (ike_cfg_t *this, linked_list_t *proposals);
-       
+
        /**
         * Should we send a certificate request in IKE_SA_INIT?
         *
         * @return                      certificate request sending policy
         */
        bool (*send_certreq) (ike_cfg_t *this);
-       
+
        /**
         * Enforce UDP encapsulation by faking NATD notifies?
-        * 
+        *
         * @return                      TRUE to enfoce UDP encapsulation
         */
        bool (*force_encap) (ike_cfg_t *this);
-       
+
        /**
         * Get the DH group to use for IKE_SA setup.
-        * 
+        *
         * @return                      dh group to use for initialization
         */
        diffie_hellman_group_t (*get_dh_group)(ike_cfg_t *this);
-       
+
        /**
         * Check if two IKE configs are equal.
         *
@@ -109,17 +109,17 @@ struct ike_cfg_t {
         * @return                      TRUE if other equal to this
         */
        bool (*equals)(ike_cfg_t *this, ike_cfg_t *other);
-       
+
        /**
         * Increase reference count.
         *
         * @return                      reference to this
         */
        ike_cfg_t* (*get_ref) (ike_cfg_t *this);
-       
+
        /**
         * Destroys a ike_cfg_t object.
-        * 
+        *
         * Decrements the internal reference counter and
         * destroys the ike_cfg when it reaches zero.
         */
@@ -137,7 +137,7 @@ struct ike_cfg_t {
  * @param other                        address/DNS name of remote peer
  * @return                             ike_cfg_t object.
  */
-ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap, 
+ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap,
                                                  char *me, char *other);
 
 #endif /** IKE_CFG_H_ @}*/
index b2d29919dd7da631b4581d93e59659c32694c222..df946b73a0acb22107d5823e92467e7a2022e89c 100644 (file)
@@ -48,113 +48,113 @@ struct private_peer_cfg_t {
         * Public part
         */
        peer_cfg_t public;
-       
+
        /**
         * Number of references hold by others to this peer_cfg
         */
        refcount_t refcount;
-       
+
        /**
         * Name of the peer_cfg, used to query it
         */
        char *name;
-       
+
        /**
         * IKE version to use for initiation
         */
        u_int ike_version;
-       
+
        /**
         * IKE config associated to this peer config
         */
        ike_cfg_t *ike_cfg;
-       
+
        /**
         * list of child configs associated to this peer config
         */
        linked_list_t *child_cfgs;
-       
+
        /**
         * mutex to lock access to list of child_cfgs
         */
        mutex_t *mutex;
-       
+
        /**
         * should we send a certificate
         */
        cert_policy_t cert_policy;
-       
+
        /**
         * uniqueness of an IKE_SA
         */
        unique_policy_t unique;
-       
+
        /**
         * number of tries after giving up if peer does not respond
         */
        u_int32_t keyingtries;
-       
+
        /**
         * enable support for MOBIKE
         */
        bool use_mobike;
-       
+
        /**
         * Time before starting rekeying
         */
        u_int32_t rekey_time;
-       
+
        /**
         * Time before starting reauthentication
         */
        u_int32_t reauth_time;
-       
+
        /**
         * Time, which specifies the range of a random value substracted from above.
         */
        u_int32_t jitter_time;
-       
+
        /**
         * Delay before deleting a rekeying/reauthenticating SA
         */
        u_int32_t over_time;
-       
+
        /**
         * DPD check intervall
         */
        u_int32_t dpd;
-       
+
        /**
         * virtual IP to use locally
         */
        host_t *virtual_ip;
-       
+
        /**
         * pool to acquire configuration attributes from
         */
        char *pool;
-       
+
        /**
         * local authentication configs (rulesets)
         */
        linked_list_t *local_auth;
-       
+
        /**
         * remote authentication configs (constraints)
         */
        linked_list_t *remote_auth;
-       
+
 #ifdef ME
        /**
         * Is this a mediation connection?
         */
        bool mediation;
-       
+
        /**
         * Name of the mediation connection to mediate through
         */
        peer_cfg_t *mediated_by;
-       
+
        /**
         * ID of our peer at the mediation server (= leftid of the peer's conn with
         * the mediation server)
@@ -239,12 +239,12 @@ static bool child_cfg_enumerate(child_cfg_enumerator_t *this, child_cfg_t **chd)
 static enumerator_t* create_child_cfg_enumerator(private_peer_cfg_t *this)
 {
        child_cfg_enumerator_t *enumerator = malloc_thing(child_cfg_enumerator_t);
-       
+
        enumerator->public.enumerate = (void*)child_cfg_enumerate;
        enumerator->public.destroy = (void*)child_cfg_enumerator_destroy;
        enumerator->mutex = this->mutex;
        enumerator->wrapped = this->child_cfgs->create_enumerator(this->child_cfgs);
-       
+
        this->mutex->lock(this->mutex);
        return &enumerator->public;
 }
@@ -259,13 +259,13 @@ static int get_ts_match(child_cfg_t *cfg, bool local,
        enumerator_t *sup_enum, *cfg_enum;
        traffic_selector_t *sup_ts, *cfg_ts;
        int match = 0, round;
-       
+
        /* fetch configured TS list, narrowing dynamic TS */
        cfg_list = cfg->get_traffic_selectors(cfg, local, NULL, host);
-       
+
        /* use a round counter to rate leading TS with higher priority */
        round = sup_list->get_count(sup_list);
-       
+
        sup_enum = sup_list->create_enumerator(sup_list);
        while (sup_enum->enumerate(sup_enum, &sup_ts))
        {
@@ -286,9 +286,9 @@ static int get_ts_match(child_cfg_t *cfg, bool local,
                round--;
        }
        sup_enum->destroy(sup_enum);
-       
+
        cfg_list->destroy_offset(cfg_list, offsetof(traffic_selector_t, destroy));
-       
+
        return match;
 }
 
@@ -303,16 +303,16 @@ static child_cfg_t* select_child_cfg(private_peer_cfg_t *this,
        child_cfg_t *current, *found = NULL;
        enumerator_t *enumerator;
        int best = 0;
-       
+
        DBG2(DBG_CFG, "looking for a child config for %#R=== %#R", my_ts, other_ts);
        enumerator = create_child_cfg_enumerator(this);
        while (enumerator->enumerate(enumerator, &current))
        {
                int my_prio, other_prio;
-               
+
                my_prio = get_ts_match(current, TRUE, my_ts, my_host);
                other_prio = get_ts_match(current, FALSE, other_ts, other_host);
-               
+
                if (my_prio && other_prio)
                {
                        DBG2(DBG_CFG, "  candidate \"%s\" with prio %d+%d",
@@ -421,7 +421,7 @@ static host_t* get_virtual_ip(private_peer_cfg_t *this)
 {
        return this->virtual_ip;
 }
-       
+
 /**
  * Implementation of peer_cfg_t.get_pool.
  */
@@ -493,7 +493,7 @@ static bool auth_cfg_equal(private_peer_cfg_t *this, private_peer_cfg_t *other)
        enumerator_t *e1, *e2;
        auth_cfg_t *cfg1, *cfg2;
        bool equal = TRUE;
-       
+
        if (this->local_auth->get_count(this->local_auth) !=
                other->local_auth->get_count(other->local_auth))
        {
@@ -504,7 +504,7 @@ static bool auth_cfg_equal(private_peer_cfg_t *this, private_peer_cfg_t *other)
        {
                return FALSE;
        }
-       
+
        e1 = this->local_auth->create_enumerator(this->local_auth);
        e2 = other->local_auth->create_enumerator(other->local_auth);
        while (e1->enumerate(e1, &cfg1) && e2->enumerate(e2, &cfg2))
@@ -517,12 +517,12 @@ static bool auth_cfg_equal(private_peer_cfg_t *this, private_peer_cfg_t *other)
        }
        e1->destroy(e1);
        e2->destroy(e2);
-       
+
        if (!equal)
        {
                return FALSE;
        }
-       
+
        e1 = this->remote_auth->create_enumerator(this->remote_auth);
        e2 = other->remote_auth->create_enumerator(other->remote_auth);
        while (e1->enumerate(e1, &cfg1) && e2->enumerate(e2, &cfg2))
@@ -535,7 +535,7 @@ static bool auth_cfg_equal(private_peer_cfg_t *this, private_peer_cfg_t *other)
        }
        e1->destroy(e1);
        e2->destroy(e2);
-       
+
        return equal;
 }
 
@@ -552,7 +552,7 @@ static bool equals(private_peer_cfg_t *this, private_peer_cfg_t *other)
        {
                return FALSE;
        }
-       
+
        return (
                this->ike_version == other->ike_version &&
                this->cert_policy == other->cert_policy &&
@@ -657,7 +657,7 @@ peer_cfg_t *peer_cfg_create(char *name, u_int ike_version, ike_cfg_t *ike_cfg,
        this->public.get_mediated_by = (peer_cfg_t* (*) (peer_cfg_t *))get_mediated_by;
        this->public.get_peer_id = (identification_t* (*) (peer_cfg_t *))get_peer_id;
 #endif /* ME */
-       
+
        /* apply init values */
        this->name = strdup(name);
        this->ike_version = ike_version;
index e6f0db4436cae244757ced10cc19e74dd0def81b..00c8a0cad8524d3b8b18a6b089c8b9a44b76dd79 100644 (file)
@@ -114,7 +114,7 @@ extern enum_name_t *unique_policy_names;
  * to gain access to the configuration.
  */
 struct peer_cfg_t {
-       
+
        /**
         * Get the name of the peer_cfg.
         *
@@ -123,42 +123,42 @@ struct peer_cfg_t {
         * @return                              peer_cfg's name
         */
        char* (*get_name) (peer_cfg_t *this);
-       
+
        /**
         * Get the IKE version to use for initiating.
         *
         * @return                              IKE major version
         */
        u_int (*get_ike_version)(peer_cfg_t *this);
-       
+
        /**
         * Get the IKE config to use for initiaton.
         *
         * @return                              the IKE config to use
         */
        ike_cfg_t* (*get_ike_cfg) (peer_cfg_t *this);
-       
+
        /**
         * Attach a CHILD config.
         *
         * @param child_cfg             CHILD config to add
         */
        void (*add_child_cfg) (peer_cfg_t *this, child_cfg_t *child_cfg);
-       
+
        /**
         * Detach a CHILD config, pointed to by an enumerator.
         *
         * @param enumerator    enumerator indicating element position
         */
        void (*remove_child_cfg)(peer_cfg_t *this, enumerator_t *enumerator);
-       
+
        /**
         * Create an enumerator for all attached CHILD configs.
         *
         * @return                              an enumerator over all CHILD configs.
         */
        enumerator_t* (*create_child_cfg_enumerator) (peer_cfg_t *this);
-       
+
        /**
         * Select a CHILD config from traffic selectors.
         *
@@ -171,7 +171,7 @@ struct peer_cfg_t {
        child_cfg_t* (*select_child_cfg) (peer_cfg_t *this, linked_list_t *my_ts,
                                                                          linked_list_t *other_ts, host_t *my_host,
                                                                          host_t *other_host);
-       
+
        /**
         * Add an authentication config to the peer configuration.
         *
@@ -179,7 +179,7 @@ struct peer_cfg_t {
         * @param local                 TRUE for local rules, FALSE for remote constraints
         */
        void (*add_auth_cfg)(peer_cfg_t *this, auth_cfg_t *cfg, bool local);
-       
+
        /**
         * Create an enumerator over registered authentication configs.
         *
@@ -201,49 +201,49 @@ struct peer_cfg_t {
         * @return                      unique policy
         */
        unique_policy_t (*get_unique_policy) (peer_cfg_t *this);
-       
+
        /**
         * Get the max number of retries after timeout.
         *
         * @return                      max number retries
         */
        u_int32_t (*get_keyingtries) (peer_cfg_t *this);
-       
+
        /**
         * Get a time to start rekeying (is randomized with jitter).
         *
         * @return                      time in s when to start rekeying, 0 disables rekeying
         */
        u_int32_t (*get_rekey_time)(peer_cfg_t *this);
-       
+
        /**
         * Get a time to start reauthentication (is randomized with jitter).
         *
         * @return                      time in s when to start reauthentication, 0 disables it
         */
        u_int32_t (*get_reauth_time)(peer_cfg_t *this);
-       
+
        /**
         * Get the timeout of a rekeying/reauthenticating SA.
         *
         * @return                      timeout in s
         */
        u_int32_t (*get_over_time)(peer_cfg_t *this);
-       
+
        /**
         * Use MOBIKE (RFC4555) if peer supports it?
         *
         * @return                      TRUE to enable MOBIKE support
         */
        bool (*use_mobike) (peer_cfg_t *this);
-       
+
        /**
         * Get the DPD check interval.
         *
         * @return                      dpd_delay in seconds
         */
        u_int32_t (*get_dpd) (peer_cfg_t *this);
-       
+
        /**
         * Get a virtual IP for the local peer.
         *
@@ -255,14 +255,14 @@ struct peer_cfg_t {
         * @return                              virtual IP, %any or NULL
         */
        host_t* (*get_virtual_ip) (peer_cfg_t *this);
-       
+
        /**
         * Get the name of the pool to acquire configuration attributes from.
         *
         * @return                              pool name, NULL if none defined
         */
        char* (*get_pool)(peer_cfg_t *this);
-       
+
 #ifdef ME
        /**
         * Is this a mediation connection?
@@ -270,14 +270,14 @@ struct peer_cfg_t {
         * @return                              TRUE, if this is a mediation connection
         */
        bool (*is_mediation) (peer_cfg_t *this);
-       
+
        /**
         * Get peer_cfg of the connection this one is mediated through.
         *
         * @return                              the peer_cfg of the mediation connection
         */
        peer_cfg_t* (*get_mediated_by) (peer_cfg_t *this);
-       
+
        /**
         * Get the id of the other peer at the mediation server.
         *
@@ -300,14 +300,14 @@ struct peer_cfg_t {
         * @return                              TRUE if peer_cfg and ike_cfg are equal
         */
        bool (*equals)(peer_cfg_t *this, peer_cfg_t *other);
-       
+
        /**
         * Increase reference count.
         *
         * @return                              reference to this
         */
        peer_cfg_t* (*get_ref) (peer_cfg_t *this);
-       
+
        /**
         * Destroys the peer_cfg object.
         *
index cf7e19605774312ce1e018eecddfcac55e071bbc..66a0a3bf8e0cc5db044bebb47201995dccd90f6e 100644 (file)
@@ -52,52 +52,52 @@ struct private_proposal_t {
         * Public part
         */
        proposal_t public;
-       
+
        /**
         * protocol (ESP or AH)
         */
        protocol_id_t protocol;
-       
+
        /**
         * priority ordered list of encryption algorithms
         */
        linked_list_t *encryption_algos;
-       
+
        /**
         * priority ordered list of integrity algorithms
         */
        linked_list_t *integrity_algos;
-       
+
        /**
         * priority ordered list of pseudo random functions
         */
        linked_list_t *prf_algos;
-       
+
        /**
         * priority ordered list of dh groups
         */
        linked_list_t *dh_groups;
-       
+
        /**
         * priority ordered list of extended sequence number flags
         */
        linked_list_t *esns;
-       
-       /** 
+
+       /**
         * senders SPI
         */
        u_int64_t spi;
 };
 
 /**
- * Struct used to store different kinds of algorithms. 
+ * Struct used to store different kinds of algorithms.
  */
 struct algorithm_t {
        /**
         * Value from an encryption_algorithm_t/integrity_algorithm_t/...
         */
        u_int16_t algorithm;
-       
+
        /**
         * the associated key size in bits, or zero if not needed
         */
@@ -110,7 +110,7 @@ struct algorithm_t {
 static void add_algo(linked_list_t *list, u_int16_t algo, u_int16_t key_size)
 {
        algorithm_t *algo_key;
-       
+
        algo_key = malloc_thing(algorithm_t);
        algo_key->algorithm = algo;
        algo_key->key_size = key_size;
@@ -200,7 +200,7 @@ static bool get_algorithm(private_proposal_t *this, transform_type_t type,
 {
        enumerator_t *enumerator;
        bool found = FALSE;
-       
+
        enumerator = create_enumerator(this, type);
        if (enumerator->enumerate(enumerator, alg, key_size))
        {
@@ -216,12 +216,12 @@ static bool get_algorithm(private_proposal_t *this, transform_type_t type,
 static bool has_dh_group(private_proposal_t *this, diffie_hellman_group_t group)
 {
        bool result = FALSE;
-       
+
        if (this->dh_groups->get_count(this->dh_groups))
        {
                algorithm_t *current;
                enumerator_t *enumerator;
-               
+
                enumerator = this->dh_groups->create_enumerator(this->dh_groups);
                while (enumerator->enumerate(enumerator, (void**)&current))
                {
@@ -246,7 +246,7 @@ static bool has_dh_group(private_proposal_t *this, diffie_hellman_group_t group)
 static void strip_dh(private_proposal_t *this)
 {
        algorithm_t *alg;
-       
+
        while (this->dh_groups->remove_last(this->dh_groups, (void**)&alg) == SUCCESS)
        {
                free(alg);
@@ -282,14 +282,14 @@ static bool select_algo(linked_list_t *first, linked_list_t *second, bool *add,
 {
        enumerator_t *e1, *e2;
        algorithm_t *alg1, *alg2;
-       
+
        /* if in both are zero algorithms specified, we HAVE a match */
        if (first->get_count(first) == 0 && second->get_count(second) == 0)
        {
                *add = FALSE;
                return TRUE;
        }
-       
+
        e1 = first->create_enumerator(first);
        e2 = second->create_enumerator(second);
        /* compare algs, order of algs in "first" is preferred */
@@ -327,18 +327,18 @@ static proposal_t *select_proposal(private_proposal_t *this, private_proposal_t
        u_int16_t algo;
        size_t key_size;
        bool add;
-       
+
        DBG2(DBG_CFG, "selecting proposal:");
-       
+
        /* check protocol */
        if (this->protocol != other->protocol)
        {
                DBG2(DBG_CFG, "  protocol mismatch, skipping");
                return NULL;
        }
-       
+
        selected = proposal_create(this->protocol);
-       
+
        /* select encryption algorithm */
        if (select_algo(this->encryption_algos, other->encryption_algos,
                                        &add, &algo, &key_size))
@@ -359,7 +359,7 @@ static proposal_t *select_proposal(private_proposal_t *this, private_proposal_t
        /* select integrity algorithm */
        if (!is_authenticated_encryption(algo))
        {
-               if (select_algo(this->integrity_algos, other->integrity_algos,  
+               if (select_algo(this->integrity_algos, other->integrity_algos,
                                                &add, &algo, &key_size))
                {
                        if (add)
@@ -424,10 +424,10 @@ static proposal_t *select_proposal(private_proposal_t *this, private_proposal_t
                return NULL;
        }
        DBG2(DBG_CFG, "  proposal matches");
-       
+
        /* apply SPI from "other" */
        selected->set_spi(selected, other->spi);
-       
+
        /* everything matched, return new proposal */
        return selected;
 }
@@ -463,7 +463,7 @@ static void clone_algo_list(linked_list_t *list, linked_list_t *clone_list)
 {
        algorithm_t *algo, *clone_algo;
        enumerator_t *enumerator;
-       
+
        enumerator = list->create_enumerator(list);
        while (enumerator->enumerate(enumerator, &algo))
        {
@@ -482,12 +482,12 @@ static bool algo_list_equals(linked_list_t *l1, linked_list_t *l2)
        enumerator_t *e1, *e2;
        algorithm_t *alg1, *alg2;
        bool equals = TRUE;
-       
+
        if (l1->get_count(l1) != l2->get_count(l2))
        {
                return FALSE;
        }
-       
+
        e1 = l1->create_enumerator(l1);
        e2 = l2->create_enumerator(l2);
        while (e1->enumerate(e1, &alg1) && e2->enumerate(e2, &alg2))
@@ -531,15 +531,15 @@ static bool equals(private_proposal_t *this, private_proposal_t *other)
 static proposal_t *clone_(private_proposal_t *this)
 {
        private_proposal_t *clone = (private_proposal_t*)proposal_create(this->protocol);
-       
+
        clone_algo_list(this->encryption_algos, clone->encryption_algos);
        clone_algo_list(this->integrity_algos, clone->integrity_algos);
        clone_algo_list(this->prf_algos, clone->prf_algos);
        clone_algo_list(this->dh_groups, clone->dh_groups);
        clone_algo_list(this->esns, clone->esns);
-       
+
        clone->spi = this->spi;
-       
+
        return &clone->public;
 }
 
@@ -551,7 +551,7 @@ static void check_proposal(private_proposal_t *this)
        enumerator_t *e;
        algorithm_t *alg;
        bool all_aead = TRUE;
-       
+
        e = this->encryption_algos->create_enumerator(this->encryption_algos);
        while (e->enumerate(e, &alg))
        {
@@ -562,7 +562,7 @@ static void check_proposal(private_proposal_t *this)
                }
        }
        e->destroy(e);
-       
+
        if (all_aead)
        {
                /* if all encryption algorithms in the proposal are authenticated encryption
@@ -613,7 +613,7 @@ static status_t add_string_algo(private_proposal_t *this, chunk_t alg)
                        case AUTH_AES_XCBC_96:
                                prf = PRF_AES128_XCBC;
                                break;
-                       default: 
+                       default:
                                prf = PRF_UNDEFINED;
                }
                if (prf != PRF_UNDEFINED)
@@ -633,7 +633,7 @@ static int print_alg(private_proposal_t *this, char **dst, size_t *len,
        enumerator_t *enumerator;
        size_t written = 0;
        u_int16_t alg, size;
-       
+
        enumerator = create_enumerator(this, kind);
        while (enumerator->enumerate(enumerator, &alg, &size))
        {
@@ -666,12 +666,12 @@ int proposal_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
        enumerator_t *enumerator;
        size_t written = 0;
        bool first = TRUE;
-       
+
        if (this == NULL)
        {
                return print_in_hook(dst, len, "(null)");
        }
-       
+
        if (spec->hash)
        {
                enumerator = list->create_enumerator(list);
@@ -690,7 +690,7 @@ int proposal_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
                enumerator->destroy(enumerator);
                return written;
        }
-       
+
        written = print_in_hook(dst, len, "%N:", protocol_id_names, this->protocol);
        written += print_alg(this, &dst, &len, ENCRYPTION_ALGORITHM,
                                                 encryption_algorithm_names, &first);
@@ -724,7 +724,7 @@ static void destroy(private_proposal_t *this)
 proposal_t *proposal_create(protocol_id_t protocol)
 {
        private_proposal_t *this = malloc_thing(private_proposal_t);
-       
+
        this->public.add_algorithm = (void (*)(proposal_t*,transform_type_t,u_int16_t,u_int16_t))add_algorithm;
        this->public.create_enumerator = (enumerator_t* (*)(proposal_t*,transform_type_t))create_enumerator;
        this->public.get_algorithm = (bool (*)(proposal_t*,transform_type_t,u_int16_t*,u_int16_t*))get_algorithm;
@@ -737,16 +737,16 @@ proposal_t *proposal_create(protocol_id_t protocol)
        this->public.equals = (bool(*)(proposal_t*, proposal_t *other))equals;
        this->public.clone = (proposal_t*(*)(proposal_t*))clone_;
        this->public.destroy = (void(*)(proposal_t*))destroy;
-       
+
        this->spi = 0;
        this->protocol = protocol;
-       
+
        this->encryption_algos = linked_list_create();
        this->integrity_algos = linked_list_create();
        this->prf_algos = linked_list_create();
        this->dh_groups = linked_list_create();
        this->esns = linked_list_create();
-       
+
        return &this->public;
 }
 
@@ -760,7 +760,7 @@ static void proposal_add_supported_ike(private_proposal_t *this)
        integrity_algorithm_t integrity;
        pseudo_random_function_t prf;
        diffie_hellman_group_t group;
-       
+
        enumerator = lib->crypto->create_crypter_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &encryption))
        {
@@ -787,10 +787,10 @@ static void proposal_add_supported_ike(private_proposal_t *this)
                                break;
                        default:
                                break;
-               }       
+               }
        }
        enumerator->destroy(enumerator);
-       
+
        enumerator = lib->crypto->create_signer_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &integrity))
        {
@@ -806,10 +806,10 @@ static void proposal_add_supported_ike(private_proposal_t *this)
                                break;
                        default:
                                break;
-               }       
+               }
        }
        enumerator->destroy(enumerator);
-       
+
        enumerator = lib->crypto->create_prf_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &prf))
        {
@@ -828,7 +828,7 @@ static void proposal_add_supported_ike(private_proposal_t *this)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &group))
        {
@@ -865,7 +865,7 @@ static void proposal_add_supported_ike(private_proposal_t *this)
 proposal_t *proposal_create_default(protocol_id_t protocol)
 {
        private_proposal_t *this = (private_proposal_t*)proposal_create(protocol);
-       
+
        switch (protocol)
        {
                case PROTO_IKE:
@@ -903,14 +903,14 @@ proposal_t *proposal_create_from_string(protocol_id_t protocol, const char *algs
        chunk_t string = {(void*)algs, strlen(algs)};
        chunk_t alg;
        status_t status = SUCCESS;
-       
+
        eat_whitespace(&string);
        if (string.len < 1)
        {
                destroy(this);
                return NULL;
        }
-       
+
        /* get all tokens, separated by '-' */
        while (extract_token(&alg, '-', &string))
        {
@@ -925,9 +925,9 @@ proposal_t *proposal_create_from_string(protocol_id_t protocol, const char *algs
                destroy(this);
                return NULL;
        }
-       
+
        check_proposal(this);
-       
+
        if (protocol == PROTO_AH || protocol == PROTO_ESP)
        {
                add_algorithm(this, EXTENDED_SEQUENCE_NUMBERS, NO_EXT_SEQ_NUMBERS, 0);
index bc7a8c5e73132ee78e07acdc3e7b7bc12bd61eae..f3857cbd2cf26fbe97dcd9f8e91454b2ff9a4d2e 100644 (file)
@@ -65,17 +65,17 @@ extern enum_name_t *extended_sequence_numbers_names;
 
 /**
  * Stores a set of algorithms used for an SA.
- * 
- * A proposal stores algorithms for a specific 
+ *
+ * A proposal stores algorithms for a specific
  * protocol. It can store algorithms for one protocol.
  * Proposals with multiple protocols are not supported,
  * as it's not specified in RFC4301 anymore.
  */
 struct proposal_t {
-       
+
        /**
         * Add an algorithm to the proposal.
-        * 
+        *
         * The algorithms are stored by priority, first added
         * is the most preferred.
         * Key size is only needed for encryption algorithms
@@ -84,27 +84,27 @@ struct proposal_t {
         * The alg parameter accepts encryption_algorithm_t,
         * integrity_algorithm_t, dh_group_number_t and
         * extended_sequence_numbers_t.
-        * 
+        *
         * @param type                  kind of algorithm
         * @param alg                   identifier for algorithm
         * @param key_size              key size to use
         */
        void (*add_algorithm) (proposal_t *this, transform_type_t type,
                                                   u_int16_t alg, u_int16_t key_size);
-       
+
        /**
         * Get an enumerator over algorithms for a specifc algo type.
-        * 
+        *
         * @param type                  kind of algorithm
         * @return                              enumerator over u_int16_t alg, u_int16_t key_size
         */
        enumerator_t *(*create_enumerator) (proposal_t *this, transform_type_t type);
-       
+
        /**
         * Get the algorithm for a type to use.
-        * 
+        *
         * If there are multiple algorithms, only the first is returned.
-        * 
+        *
         * @param type                  kind of algorithm
         * @param alg                   pointer which receives algorithm
         * @param key_size              pointer which receives the key size
@@ -112,53 +112,53 @@ struct proposal_t {
         */
        bool (*get_algorithm) (proposal_t *this, transform_type_t type,
                                                   u_int16_t *alg, u_int16_t *key_size);
-       
+
        /**
         * Check if the proposal has a specific DH group.
-        * 
+        *
         * @param group                 group to check for
         * @return                              TRUE if algorithm included
         */
        bool (*has_dh_group) (proposal_t *this, diffie_hellman_group_t group);
-       
+
        /**
         * Strip DH groups from proposal to use it without PFS.
         */
-       void (*strip_dh)(proposal_t *this);     
+       void (*strip_dh)(proposal_t *this);
 
        /**
         * Compare two proposal, and select a matching subset.
-        * 
+        *
         * If the proposals are for the same protocols (AH/ESP), they are
         * compared. If they have at least one algorithm of each type
         * in common, a resulting proposal of this kind is created.
-        * 
+        *
         * @param other                 proposal to compair agains
         * @return                              selected proposal, NULL if proposals don't match
         */
        proposal_t *(*select) (proposal_t *this, proposal_t *other);
-       
+
        /**
         * Get the protocol ID of the proposal.
         *
         * @return                              protocol of the proposal
         */
        protocol_id_t (*get_protocol) (proposal_t *this);
-       
+
        /**
         * Get the SPI of the proposal.
-        * 
+        *
         * @return                              spi for proto
         */
        u_int64_t (*get_spi) (proposal_t *this);
-       
+
        /**
         * Set the SPI of the proposal.
-        * 
+        *
         * @param spi                   spi to set for proto
         */
        void (*set_spi) (proposal_t *this, u_int64_t spi);
-       
+
        /**
         * Check for the eqality of two proposals.
         *
@@ -166,14 +166,14 @@ struct proposal_t {
         * @return                              TRUE if other equal to this
         */
        bool (*equals)(proposal_t *this, proposal_t *other);
-       
+
        /**
         * Clone a proposal.
-        * 
+        *
         * @return                              clone of proposal
         */
        proposal_t *(*clone) (proposal_t *this);
-       
+
        /**
         * Destroys the proposal object.
         */
@@ -214,7 +214,7 @@ proposal_t *proposal_create_from_string(protocol_id_t protocol, const char *algs
 /**
  * printf hook function for proposal_t.
  *
- * Arguments are: 
+ * Arguments are:
  *    proposal_t *proposal
  * With the #-specifier, arguments are:
  *    linked_list_t *list containing proposal_t*
index a8ea100082a25d072047389c1e7ed935c78a5d56..0168acc0ee85aecf376a7ec579cd181970074636 100644 (file)
@@ -42,24 +42,24 @@ struct private_traffic_selector_t {
         * Public part
         */
        traffic_selector_t public;
-       
+
        /**
         * Type of address
         */
        ts_type_t type;
-       
+
        /**
         * IP protocol (UDP, TCP, ICMP, ...)
         */
        u_int8_t protocol;
-       
+
        /**
         * narrow this traffic selector to hosts external ip
         * if set, from and to have no meaning until set_address() is called
         */
        bool dynamic;
-       
-       /** 
+
+       /**
         * begin of address range, network order
         */
        union {
@@ -70,7 +70,7 @@ struct private_traffic_selector_t {
                /** IPv6 address */
                u_int32_t from6[4];
        };
-       
+
        /**
         * end of address range, network order
         */
@@ -82,14 +82,14 @@ struct private_traffic_selector_t {
                /** IPv6 address */
                u_int32_t to6[4];
        };
-       
+
        /**
-        * begin of port range 
+        * begin of port range
         */
        u_int16_t from_port;
-       
+
        /**
-        * end of port range 
+        * end of port range
         */
        u_int16_t to_port;
 };
@@ -101,7 +101,7 @@ static void calc_range(private_traffic_selector_t *this, u_int8_t netbits)
 {
        int byte;
        size_t size = (this->type == TS_IPV4_ADDR_RANGE) ? 4 : 16;
-       
+
        /* go through the from address, starting at the tail. While we
         * have not processed the bits belonging to the host, set them to 1 on
         * the to address. If we reach the bits for the net, copy them from "from". */
@@ -109,7 +109,7 @@ static void calc_range(private_traffic_selector_t *this, u_int8_t netbits)
        {
                u_char mask = 0x00;
                int shift;
-               
+
                shift = (byte+1) * 8 - netbits;
                if (shift > 0)
                {
@@ -130,7 +130,7 @@ static u_int8_t calc_netbits(private_traffic_selector_t *this)
 {
        int byte, bit;
        size_t size = (this->type == TS_IPV4_ADDR_RANGE) ? 4 : 16;
-       
+
        /* go trough all bits of the addresses, beginning in the front.
         * as long as they are equal, the subnet gets larger
         */
@@ -169,12 +169,12 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
        bool has_ports;
        size_t written = 0;
        u_int32_t from[4], to[4];
-       
+
        if (this == NULL)
        {
                return print_in_hook(dst, len, "(null)");
        }
-       
+
        if (spec->hash)
        {
                iterator = list->create_iterator(list, TRUE);
@@ -186,11 +186,11 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
                iterator->destroy(iterator);
                return written;
        }
-       
+
        memset(from, 0, sizeof(from));
        memset(to, 0xFF, sizeof(to));
        if (this->dynamic &&
-               memeq(this->from, from, this->type == TS_IPV4_ADDR_RANGE ? 4 : 16) && 
+               memeq(this->from, from, this->type == TS_IPV4_ADDR_RANGE ? 4 : 16) &&
                memeq(this->to, to, this->type == TS_IPV4_ADDR_RANGE ? 4 : 16))
        {
                written += print_in_hook(dst, len, "dynamic");
@@ -208,7 +208,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
                mask = calc_netbits(this);
                written += print_in_hook(dst, len, "%s/%d", addr_str, mask);
        }
-       
+
        /* check if we have protocol and/or port selectors */
        has_proto = this->protocol != 0;
        has_ports = !(this->from_port == 0 && this->to_port == 0xFFFF);
@@ -235,7 +235,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
                        written += print_in_hook(dst, len, "%d", this->protocol);
                }
        }
-       
+
        if (has_proto && has_ports)
        {
                written += print_in_hook(dst, len, "/");
@@ -262,7 +262,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
                        written += print_in_hook(dst, len, "%d-%d", this->from_port, this->to_port);
                }
        }
-       
+
        written += print_in_hook(dst, len, "]");
 
        return written;
@@ -281,7 +281,7 @@ static traffic_selector_t *get_subset(private_traffic_selector_t *this, private_
                u_int8_t protocol;
                size_t size;
                private_traffic_selector_t *new_ts;
-               
+
                /* calculate the maximum port range allowed for both */
                from_port = max(this->from_port, other->from_port);
                to_port = min(this->to_port, other->to_port);
@@ -291,7 +291,7 @@ static traffic_selector_t *get_subset(private_traffic_selector_t *this, private_
                }
                /* select protocol, which is not zero */
                protocol = max(this->protocol, other->protocol);
-               
+
                switch (this->type)
                {
                        case TS_IPV4_ADDR_RANGE:
@@ -303,7 +303,7 @@ static traffic_selector_t *get_subset(private_traffic_selector_t *this, private_
                        default:
                                return NULL;
                }
-               
+
                /* get higher from-address */
                if (memcmp(this->from, other->from, size) > 0)
                {
@@ -327,14 +327,14 @@ static traffic_selector_t *get_subset(private_traffic_selector_t *this, private_
                {
                        return NULL;
                }
-               
+
                /* we have a match in protocol, port, and address: return it... */
                new_ts = traffic_selector_create(protocol, this->type, from_port, to_port);
                new_ts->type = this->type;
                new_ts->dynamic = this->dynamic || other->dynamic;
                memcpy(new_ts->from, from, size);
                memcpy(new_ts->to, to, size);
-               
+
                return &new_ts->public;
        }
        return NULL;
@@ -390,7 +390,7 @@ static chunk_t get_from_address(private_traffic_selector_t *this)
                        return chunk_empty;
        }
 }
-       
+
 /**
  * Implements traffic_selector_t.get_to_address.
  */
@@ -406,7 +406,7 @@ static chunk_t get_to_address(private_traffic_selector_t *this)
                        return chunk_empty;
        }
 }
-       
+
 /**
  * Implements traffic_selector_t.get_from_port.
  */
@@ -414,7 +414,7 @@ static u_int16_t get_from_port(private_traffic_selector_t *this)
 {
        return this->from_port;
 }
-       
+
 /**
  * Implements traffic_selector_t.get_to_port.
  */
@@ -448,7 +448,7 @@ static bool is_host(private_traffic_selector_t *this, host_t *host)
        {
                chunk_t addr;
                int family = host->get_family(host);
-               
+
                if ((family == AF_INET && this->type == TS_IPV4_ADDR_RANGE) ||
                        (family == AF_INET6 && this->type == TS_IPV6_ADDR_RANGE))
                {
@@ -463,12 +463,12 @@ static bool is_host(private_traffic_selector_t *this, host_t *host)
        else
        {
                size_t length = (this->type == TS_IPV4_ADDR_RANGE) ? 4 : 16;
-               
+
                if (this->dynamic)
                {
                        return TRUE;
                }
-               
+
                if (memeq(this->from, this->to, length))
                {
                        return TRUE;
@@ -494,7 +494,7 @@ static void set_address(private_traffic_selector_t *this, host_t *host)
        {
                this->type = host->get_family(host) == AF_INET ?
                                TS_IPV4_ADDR_RANGE : TS_IPV6_ADDR_RANGE;
-               
+
                if (host->is_anyaddr(host))
                {
                        memset(this->from6, 0x00, sizeof(this->from6));
@@ -517,9 +517,9 @@ static bool is_contained_in(private_traffic_selector_t *this,
 {
        private_traffic_selector_t *subset;
        bool contained_in = FALSE;
-       
+
        subset = (private_traffic_selector_t*)get_subset(this, other);
-       
+
        if (subset)
        {
                if (equals(subset, this))
@@ -528,7 +528,7 @@ static bool is_contained_in(private_traffic_selector_t *this,
                }
                free(subset);
        }
-       return contained_in;    
+       return contained_in;
 }
 
 /**
@@ -543,12 +543,12 @@ static bool includes(private_traffic_selector_t *this, host_t *host)
                (family == AF_INET6 && this->type == TS_IPV6_ADDR_RANGE))
        {
                addr = host->get_address(host);
-               
+
                return memcmp(this->from, addr.ptr, addr.len) <= 0 &&
                                memcmp(this->to, addr.ptr, addr.len) >= 0;
        }
 
-       return FALSE;   
+       return FALSE;
 }
 
 /**
@@ -557,15 +557,15 @@ static bool includes(private_traffic_selector_t *this, host_t *host)
 static void to_subnet(private_traffic_selector_t *this, host_t **net, u_int8_t *mask)
 {
        /* there is no way to do this cleanly, as the address range may
-        * be anything else but a subnet. We use from_addr as subnet 
+        * be anything else but a subnet. We use from_addr as subnet
         * and try to calculate a usable subnet mask.
         */
        int family, byte;
        u_int16_t port = 0;
        chunk_t net_chunk;
-       
+
        *mask = calc_netbits(this);
-       
+
        switch (this->type)
        {
                case TS_IPV4_ADDR_RANGE:
@@ -586,22 +586,22 @@ static void to_subnet(private_traffic_selector_t *this, host_t **net, u_int8_t *
                        return;
                }
        }
-       
+
        net_chunk.ptr = malloc(net_chunk.len);
        memcpy(net_chunk.ptr, this->from, net_chunk.len);
-       
+
        for (byte = net_chunk.len - 1; byte >= (*mask / 8); --byte)
        {
                int shift = (byte + 1) * 8 - *mask;
                net_chunk.ptr[byte] = net_chunk.ptr[byte] & (0xFF << shift);
        }
-       
+
        if (this->to_port == this->from_port)
        {
                port = this->to_port;
        }
-       
-       *net = host_create_from_chunk(family, net_chunk, port); 
+
+       *net = host_create_from_chunk(family, net_chunk, port);
        chunk_free(&net_chunk);
 }
 
@@ -611,10 +611,10 @@ static void to_subnet(private_traffic_selector_t *this, host_t **net, u_int8_t *
 static traffic_selector_t *clone_(private_traffic_selector_t *this)
 {
        private_traffic_selector_t *clone;
-       
-       clone = traffic_selector_create(this->protocol, this->type, 
+
+       clone = traffic_selector_create(this->protocol, this->type,
                                                                        this->from_port, this->to_port);
-       
+
        clone->dynamic = this->dynamic;
        switch (clone->type)
        {
@@ -650,13 +650,13 @@ static void destroy(private_traffic_selector_t *this)
  * see header
  */
 traffic_selector_t *traffic_selector_create_from_bytes(u_int8_t protocol,
-                                                                                               ts_type_t type, 
-                                                                                               chunk_t from, u_int16_t from_port, 
+                                                                                               ts_type_t type,
+                                                                                               chunk_t from, u_int16_t from_port,
                                                                                                chunk_t to, u_int16_t to_port)
 {
        private_traffic_selector_t *this = traffic_selector_create(protocol, type,
                                                                                                                        from_port, to_port);
-       
+
        switch (type)
        {
                case TS_IPV4_ADDR_RANGE:
@@ -684,7 +684,7 @@ traffic_selector_t *traffic_selector_create_from_bytes(u_int8_t protocol,
                default:
                {
                        free(this);
-                       return NULL;    
+                       return NULL;
                }
        }
        return (&this->public);
@@ -693,7 +693,7 @@ traffic_selector_t *traffic_selector_create_from_bytes(u_int8_t protocol,
 /*
  * see header
  */
-traffic_selector_t *traffic_selector_create_from_subnet(host_t *net, 
+traffic_selector_t *traffic_selector_create_from_subnet(host_t *net,
                                                        u_int8_t netbits, u_int8_t protocol, u_int16_t port)
 {
        private_traffic_selector_t *this = traffic_selector_create(protocol, 0, 0, 65535);
@@ -703,7 +703,7 @@ traffic_selector_t *traffic_selector_create_from_subnet(host_t *net,
                case AF_INET:
                {
                        chunk_t from;
-                       
+
                        this->type = TS_IPV4_ADDR_RANGE;
                        from = net->get_address(net);
                        memcpy(this->from4, from.ptr, from.len);
@@ -721,7 +721,7 @@ traffic_selector_t *traffic_selector_create_from_subnet(host_t *net,
                case AF_INET6:
                {
                        chunk_t from;
-                       
+
                        this->type = TS_IPV6_ADDR_RANGE;
                        from = net->get_address(net);
                        memcpy(this->from6, from.ptr, from.len);
@@ -782,7 +782,7 @@ traffic_selector_t *traffic_selector_create_from_string(
                                free(this);
                                return NULL;
                        }
-                       break;  
+                       break;
                }
                case TS_IPV6_ADDR_RANGE:
                {
@@ -805,17 +805,17 @@ traffic_selector_t *traffic_selector_create_from_string(
 /*
  * see header
  */
-traffic_selector_t *traffic_selector_create_dynamic(u_int8_t protocol, 
+traffic_selector_t *traffic_selector_create_dynamic(u_int8_t protocol,
                                                                        u_int16_t from_port, u_int16_t to_port)
 {
        private_traffic_selector_t *this = traffic_selector_create(
                                                        protocol, TS_IPV4_ADDR_RANGE, from_port, to_port);
-       
+
        memset(this->from6, 0, sizeof(this->from6));
        memset(this->to6, 0xFF, sizeof(this->to6));
-       
+
        this->dynamic = TRUE;
-       
+
        return &this->public;
 }
 
@@ -833,7 +833,7 @@ static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol,
        this->public.get_from_address = (chunk_t(*)(traffic_selector_t*))get_from_address;
        this->public.get_to_address = (chunk_t(*)(traffic_selector_t*))get_to_address;
        this->public.get_from_port = (u_int16_t(*)(traffic_selector_t*))get_from_port;
-       this->public.get_to_port = (u_int16_t(*)(traffic_selector_t*))get_to_port;      
+       this->public.get_to_port = (u_int16_t(*)(traffic_selector_t*))get_to_port;
        this->public.get_type = (ts_type_t(*)(traffic_selector_t*))get_type;
        this->public.get_protocol = (u_int8_t(*)(traffic_selector_t*))get_protocol;
        this->public.is_host = (bool(*)(traffic_selector_t*,host_t*))is_host;
@@ -844,13 +844,13 @@ static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol,
        this->public.to_subnet = (void(*)(traffic_selector_t*,host_t**,u_int8_t*))to_subnet;
        this->public.clone = (traffic_selector_t*(*)(traffic_selector_t*))clone_;
        this->public.destroy = (void(*)(traffic_selector_t*))destroy;
-       
+
        this->from_port = from_port;
        this->to_port = to_port;
        this->protocol = protocol;
        this->type = type;
        this->dynamic = FALSE;
-       
+
        return this;
 }
 
index a57da43a8b692af66b76146b3085be2377cad37b..e71a03119aba05e7c441289fdf12e233cbe00c8a 100644 (file)
@@ -33,7 +33,7 @@ typedef struct traffic_selector_t traffic_selector_t;
  * Traffic selector types.
  */
 enum ts_type_t {
-       
+
        /**
         * A range of IPv4 addresses, represented by two four (4) octet
      * values.  The first value is the beginning IPv4 address
@@ -42,7 +42,7 @@ enum ts_type_t {
      * addresses are considered to be within the list.
      */
        TS_IPV4_ADDR_RANGE = 7,
-       
+
        /**
         * A range of IPv6 addresses, represented by two sixteen (16)
      * octet values.  The first value is the beginning IPv6 address
@@ -65,7 +65,7 @@ extern enum_name_t *ts_type_name;
  * and a range of ports. IPv6 is not fully supported yet.
  */
 struct traffic_selector_t {
-       
+
        /**
         * Compare two traffic selectors, and create a new one
         * which is the largest subset of both (subnet & port).
@@ -77,16 +77,16 @@ struct traffic_selector_t {
         *                                      - created subset of them
         *                                      - or NULL if no match between this and other
         */
-       traffic_selector_t *(*get_subset)  (traffic_selector_t *this, 
+       traffic_selector_t *(*get_subset)  (traffic_selector_t *this,
                                                                                traffic_selector_t *other);
-       
+
        /**
         * Clone a traffic selector.
         *
         * @return                      clone of it
         */
        traffic_selector_t *(*clone) (traffic_selector_t *this);
-       
+
        /**
         * Get starting address of this ts as a chunk.
         *
@@ -95,7 +95,7 @@ struct traffic_selector_t {
         * @return                      chunk containing the address
         */
        chunk_t (*get_from_address) (traffic_selector_t *this);
-       
+
        /**
         * Get ending address of this ts as a chunk.
         *
@@ -104,17 +104,17 @@ struct traffic_selector_t {
         * @return                      chunk containing the address
         */
        chunk_t (*get_to_address) (traffic_selector_t *this);
-       
+
        /**
         * Get starting port of this ts.
-        * 
+        *
         * Port is in host order, since the parser converts it.
         * Size depends on protocol.
-        *  
+        *
         * @return                      port
         */
        u_int16_t (*get_from_port) (traffic_selector_t *this);
-       
+
        /**
         * Get ending port of this ts.
         *
@@ -124,21 +124,21 @@ struct traffic_selector_t {
         * @return                      port
         */
        u_int16_t (*get_to_port) (traffic_selector_t *this);
-       
+
        /**
         * Get the type of the traffic selector.
         *
         * @return                      ts_type_t specifying the type
         */
        ts_type_t (*get_type) (traffic_selector_t *this);
-       
+
        /**
         * Get the protocol id of this ts.
         *
         * @return                      protocol id
         */
        u_int8_t (*get_protocol) (traffic_selector_t *this);
-       
+
        /**
         * Check if the traffic selector is for a single host.
         *
@@ -151,14 +151,14 @@ struct traffic_selector_t {
         * @param host          host_t specifying the address range
         */
        bool (*is_host) (traffic_selector_t *this, host_t* host);
-       
+
        /**
         * Check if a traffic selector has been created by create_dynamic().
         *
         * @return                      TRUE if TS is dynamic
         */
        bool (*is_dynamic)(traffic_selector_t *this);
-       
+
        /**
         * Update the address of a traffic selector.
         *
@@ -168,15 +168,15 @@ struct traffic_selector_t {
         * @param host          host_t specifying the address
         */
        void (*set_address) (traffic_selector_t *this, host_t* host);
-       
+
        /**
         * Compare two traffic selectors for equality.
-        * 
+        *
         * @param other         ts to compare with this
         * @return                      TRUE if equal, FALSE otherwise
         */
        bool (*equals) (traffic_selector_t *this, traffic_selector_t *other);
-       
+
        /**
         * Check if a traffic selector is contained completly in another.
         *
@@ -188,24 +188,24 @@ struct traffic_selector_t {
        bool (*is_contained_in) (traffic_selector_t *this, traffic_selector_t *other);
 
        /**
-        * Check if a specific host is included in the address range of 
+        * Check if a specific host is included in the address range of
         * this traffic selector.
         *
         * @param host          the host to check
         */
        bool (*includes) (traffic_selector_t *this, host_t *host);
-       
+
        /**
         * Convert a traffic selector address range to a subnet
         * and its net mask.
         * If from and to ports of this traffic selector are equal,
         * the port of the returned host_t is set to that port.
-        * 
+        *
         * @param net           converted subnet (has to be freed)
         * @param mask          converted net mask
         */
        void (*to_subnet) (traffic_selector_t *this, host_t **net, u_int8_t *mask);
-       
+
        /**
         * Destroys the ts object
         */
@@ -214,7 +214,7 @@ struct traffic_selector_t {
 
 /**
  * Create a new traffic selector using human readable params.
- * 
+ *
  * @param protocol             protocol for this ts, such as TCP or UDP
  * @param type                 type of following addresses, such as TS_IPV4_ADDR_RANGE
  * @param from_addr            start of address range as string
@@ -232,11 +232,11 @@ traffic_selector_t *traffic_selector_create_from_string(
 
 /**
  * Create a new traffic selector using data read from the net.
- * 
+ *
  * There exists a mix of network and host order in the params.
  * But the parser gives us this data in this format, so we
  * don't have to convert twice.
- * 
+ *
  * @param protocol             protocol for this ts, such as TCP or UDP
  * @param type                 type of following addresses, such as TS_IPV4_ADDR_RANGE
  * @param from_address start of address range, network order
@@ -252,14 +252,14 @@ traffic_selector_t *traffic_selector_create_from_bytes(
 
 /**
  * Create a new traffic selector defining a whole subnet.
- * 
+ *
  * In most cases, definition of a traffic selector for full subnets
  * is sufficient. This constructor creates a traffic selector for
  * all protocols, all ports and the address range specified by the
  * subnet.
  * Additionally, a protocol and a port may be specified. Port ranges
  * are not supported via this constructor.
- * 
+ *
  * @param net                  subnet to use
  * @param netbits              size of the subnet, as used in e.g. 192.168.0.0/24 notation
  * @param protocol             protocol for this ts, such as TCP or UDP
@@ -269,17 +269,17 @@ traffic_selector_t *traffic_selector_create_from_bytes(
  *                                             - NULL if address family of net not supported
  */
 traffic_selector_t *traffic_selector_create_from_subnet(
-                                                                       host_t *net, u_int8_t netbits, 
+                                                                       host_t *net, u_int8_t netbits,
                                                                        u_int8_t protocol, u_int16_t port);
 
 /**
  * Create a traffic selector for host-to-host cases.
- * 
+ *
  * For host2host or virtual IP setups, the traffic selectors gets
  * created at runtime using the external/virtual IP. Using this constructor,
  * a call to set_address() sets this traffic selector to the supplied host.
- * 
- * 
+ *
+ *
  * @param protocol             upper layer protocl to allow
  * @param from_port            start of allowed port range
  * @param to_port              end of range
@@ -293,7 +293,7 @@ traffic_selector_t *traffic_selector_create_dynamic(u_int8_t protocol,
 /**
  * printf hook function for traffic_selector_t.
  *
- * Arguments are: 
+ * Arguments are:
  *    traffic_selector_t *ts
  * With the #-specifier, arguments are:
  *    linked_list_t *list containing traffic_selector_t*
index 97d7e33ea0c4cd4e3320f6bf3346d0ac9bac751e..94c64028c26249de0f193d70cd13ada5629d4d5f 100644 (file)
@@ -47,42 +47,42 @@ struct interface_listener_t {
         * public bus listener interface
         */
        listener_t public;
-       
+
        /**
         * status of the operation, return to method callers
         */
        status_t status;
-       
+
        /**
         *  interface callback (listener gets redirected to here)
         */
        controller_cb_t callback;
-       
+
        /**
         * user parameter to pass to callback
         */
        void *param;
-       
+
        /**
         * child configuration, used for initiate
         */
        child_cfg_t *child_cfg;
-       
+
        /**
         * peer configuration, used for initiate
         */
        peer_cfg_t *peer_cfg;
-       
+
        /**
         * IKE_SA to handle
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * CHILD_SA to handle
         */
        child_sa_t *child_sa;
-       
+
        /**
         * unique ID, used for various methods
         */
@@ -100,7 +100,7 @@ struct interface_job_t {
         * job interface
         */
        job_t public;
-       
+
        /**
         * associated listener
         */
@@ -138,7 +138,7 @@ static bool listener_ike_state(interface_listener_t *this, ike_sa_t *ike_sa,
                        case IKE_ESTABLISHED:
                        {       /* mediation connections are complete without CHILD_SA */
                                peer_cfg_t *peer_cfg = ike_sa->get_peer_cfg(ike_sa);
-                               
+
                                if (peer_cfg->is_mediation(peer_cfg))
                                {
                                        this->status = SUCCESS;
@@ -219,17 +219,17 @@ static status_t initiate_execute(interface_job_t *job)
        ike_sa_t *ike_sa;
        interface_listener_t *listener = &job->listener;
        peer_cfg_t *peer_cfg = listener->peer_cfg;
-       
+
        ike_sa = charon->ike_sa_manager->checkout_by_config(charon->ike_sa_manager,
                                                                                                                peer_cfg);
        listener->ike_sa = ike_sa;
-       
+
        if (ike_sa->get_peer_cfg(ike_sa) == NULL)
        {
                ike_sa->set_peer_cfg(ike_sa, peer_cfg);
        }
        peer_cfg->destroy(peer_cfg);
-       
+
        if (ike_sa->initiate(ike_sa, listener->child_cfg, 0, NULL, NULL) == SUCCESS)
        {
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
@@ -279,9 +279,9 @@ static status_t terminate_ike_execute(interface_job_t *job)
 {
        interface_listener_t *listener = &job->listener;
        ike_sa_t *ike_sa = listener->ike_sa;
-       
+
        charon->bus->set_sa(charon->bus, ike_sa);
-       
+
        if (ike_sa->delete(ike_sa) != DESTROY_ME)
        {
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
@@ -316,7 +316,7 @@ static status_t terminate_ike(controller_t *this, u_int32_t unique_id,
                        .destroy = (void*)recheckin,
                },
        };
-       
+
        ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
                                                                                                        unique_id, FALSE);
        if (ike_sa == NULL)
@@ -325,7 +325,7 @@ static status_t terminate_ike(controller_t *this, u_int32_t unique_id,
                return NOT_FOUND;
        }
        job.listener.ike_sa = ike_sa;
-       
+
        if (callback == NULL)
        {
                return terminate_ike_execute(&job);
@@ -342,7 +342,7 @@ static status_t terminate_child_execute(interface_job_t *job)
        interface_listener_t *listener = &job->listener;
        ike_sa_t *ike_sa = listener->ike_sa;
        child_sa_t *child_sa = listener->child_sa;
-       
+
        charon->bus->set_sa(charon->bus, ike_sa);
        if (ike_sa->delete_child_sa(ike_sa, child_sa->get_protocol(child_sa),
                                                                child_sa->get_spi(child_sa, TRUE)) != DESTROY_ME)
@@ -380,7 +380,7 @@ static status_t terminate_child(controller_t *this, u_int32_t reqid,
                        .destroy = (void*)recheckin,
                },
        };
-       
+
        ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
                                                                                                        reqid, TRUE);
        if (ike_sa == NULL)
@@ -390,7 +390,7 @@ static status_t terminate_child(controller_t *this, u_int32_t reqid,
                return NOT_FOUND;
        }
        job.listener.ike_sa = ike_sa;
-       
+
        iterator = ike_sa->create_child_sa_iterator(ike_sa);
        while (iterator->iterate(iterator, (void**)&child_sa))
        {
@@ -402,7 +402,7 @@ static status_t terminate_child(controller_t *this, u_int32_t reqid,
                child_sa = NULL;
        }
        iterator->destroy(iterator);
-       
+
        if (child_sa == NULL)
        {
                DBG1(DBG_IKE, "unable to terminate, established "
@@ -443,13 +443,13 @@ static void destroy(private_controller_t *this)
 controller_t *controller_create(void)
 {
        private_controller_t *this = malloc_thing(private_controller_t);
-       
+
        this->public.create_ike_sa_enumerator = (enumerator_t*(*)(controller_t*))create_ike_sa_enumerator;
        this->public.initiate = (status_t(*)(controller_t*,peer_cfg_t*,child_cfg_t*,controller_cb_t,void*))initiate;
        this->public.terminate_ike = (status_t(*)(controller_t*,u_int32_t,controller_cb_t, void*))terminate_ike;
        this->public.terminate_child = (status_t(*)(controller_t*,u_int32_t,controller_cb_t, void *param))terminate_child;
        this->public.destroy = (void (*)(controller_t*))destroy;
-       
+
        return &this->public;
 }
 
index 3c928d2eae6008861c6864d66f04a425f1112a3e..31b69c78cceb374a628b6db5105eb5284c7948d0 100644 (file)
@@ -95,7 +95,7 @@ struct controller_t {
         * Terminate an IKE_SA and all of its CHILD_SAs.
         *
         * The terminate() function is synchronous and thus blocks until the
-        * IKE_SA is properly deleted, or the delete timed out. 
+        * IKE_SA is properly deleted, or the delete timed out.
         * The terminate() function contains a thread cancellation point.
         *
         * @param unique_id             unique id of the IKE_SA to terminate.
@@ -106,9 +106,9 @@ struct controller_t {
         *                                              - NOT_FOUND, if no such CHILD_SA found
         *                                              - NEED_MORE, if callback returned FALSE
         */
-       status_t (*terminate_ike)(controller_t *this, u_int32_t unique_id, 
+       status_t (*terminate_ike)(controller_t *this, u_int32_t unique_id,
                                                          controller_cb_t callback, void *param);
-       
+
        /**
         * Terminate a CHILD_SA.
         *
@@ -120,9 +120,9 @@ struct controller_t {
         *                                              - NOT_FOUND, if no such CHILD_SA found
         *                                              - NEED_MORE, if callback returned FALSE
         */
-       status_t (*terminate_child)(controller_t *this, u_int32_t reqid, 
+       status_t (*terminate_child)(controller_t *this, u_int32_t reqid,
                                                                controller_cb_t callback, void *param);
-       
+
        /**
         * Destroy a controller_t instance.
         */
@@ -132,7 +132,7 @@ struct controller_t {
 
 /**
  * Creates a controller instance.
- * 
+ *
  * @return                     controller_t object
  */
 controller_t *controller_create(void);
index 78b0922ec5a2873fe0c02354a0924b696a722374..636d83bf18fbaced21db64d797e3bdc2de80e7e7 100644 (file)
@@ -41,27 +41,27 @@ struct private_credential_manager_t {
         * public functions
         */
        credential_manager_t public;
-       
+
        /**
         * list of credential sets
         */
        linked_list_t *sets;
-       
+
        /**
         * thread local set of credentials, linked_list_t with credential_set_t's
         */
        pthread_key_t local_sets;
-       
+
        /**
         * trust relationship and certificate cache
         */
        cert_cache_t *cache;
-       
+
        /**
         * certificates queued for persistent caching
         */
        linked_list_t *cache_queue;
-       
+
        /**
         * read-write lock to sets list
         */
@@ -149,7 +149,7 @@ static enumerator_t *create_sets_enumerator(private_credential_manager_t *this)
 {
        linked_list_t *local;
        sets_enumerator_t *enumerator = malloc_thing(sets_enumerator_t);
-       
+
        enumerator->public.enumerate = (void*)sets_enumerator_enumerate;
        enumerator->public.destroy = (void*)sets_enumerator_destroy;
        enumerator->global = this->sets->create_enumerator(this->sets);
@@ -176,7 +176,7 @@ static void destroy_cert_data(cert_data_t *data)
  */
 static enumerator_t *create_cert(credential_set_t *set, cert_data_t *data)
 {
-       return set->create_cert_enumerator(set, data->cert, data->key, 
+       return set->create_cert_enumerator(set, data->cert, data->key,
                                                                           data->id, data->trusted);
 }
 
@@ -193,7 +193,7 @@ static enumerator_t *create_cert_enumerator(private_credential_manager_t *this,
        data->key = key;
        data->id = id;
        data->trusted = trusted;
-       
+
        this->lock->read_lock(this->lock);
        return enumerator_create_nested(create_sets_enumerator(this),
                                                                        (void*)create_cert, data,
@@ -209,7 +209,7 @@ static certificate_t *get_cert(private_credential_manager_t *this,
 {
        certificate_t *current, *found = NULL;
        enumerator_t *enumerator;
-       
+
        enumerator = create_cert_enumerator(this, cert, key, id, trusted);
        if (enumerator->enumerate(enumerator, &current))
        {
@@ -247,7 +247,7 @@ static enumerator_t * create_cdp_enumerator(private_credential_manager_t *this,
        data->this = this;
        data->type = type;
        data->id = id;
-       
+
        this->lock->read_lock(this->lock);
        return enumerator_create_nested(create_sets_enumerator(this),
                                                                        (void*)create_cdp, data,
@@ -279,7 +279,7 @@ static enumerator_t* create_private_enumerator(
                                                                    key_type_t key, identification_t *keyid)
 {
        private_data_t *data;
-       
+
        data = malloc_thing(private_data_t);
        data->this = this;
        data->type = key;
@@ -292,13 +292,13 @@ static enumerator_t* create_private_enumerator(
 
 /**
  * Implementation of credential_manager_t.get_private_by_keyid.
- */   
+ */
 static private_key_t *get_private_by_keyid(private_credential_manager_t *this,
                                                                                key_type_t key, identification_t *keyid)
 {
        private_key_t *found = NULL;
        enumerator_t *enumerator;
-       
+
        enumerator = create_private_enumerator(this, key, keyid);
        if (enumerator->enumerate(enumerator, &found))
        {
@@ -328,7 +328,7 @@ static enumerator_t *create_shared(credential_set_t *set, shared_data_t *data)
 /**
  * Implementation of credential_manager_t.create_shared_enumerator.
  */
-static enumerator_t *create_shared_enumerator(private_credential_manager_t *this, 
+static enumerator_t *create_shared_enumerator(private_credential_manager_t *this,
                                                shared_key_type_t type,
                                                identification_t *me, identification_t *other)
 {
@@ -337,16 +337,16 @@ static enumerator_t *create_shared_enumerator(private_credential_manager_t *this
        data->type = type;
        data->me = me;
        data->other = other;
-       
+
        this->lock->read_lock(this->lock);
        return enumerator_create_nested(create_sets_enumerator(this),
-                                                                       (void*)create_shared, data, 
+                                                                       (void*)create_shared, data,
                                                                        (void*)destroy_shared_data);
 }
 
 /**
  * Implementation of credential_manager_t.get_shared.
- */   
+ */
 static shared_key_t *get_shared(private_credential_manager_t *this,
                                                                shared_key_type_t type, identification_t *me,
                                                                identification_t *other)
@@ -355,7 +355,7 @@ static shared_key_t *get_shared(private_credential_manager_t *this,
        id_match_t *best_me = ID_MATCH_NONE, *best_other = ID_MATCH_NONE;
        id_match_t *match_me, *match_other;
        enumerator_t *enumerator;
-       
+
        enumerator = create_shared_enumerator(this, type, me, other);
        while (enumerator->enumerate(enumerator, &current, &match_me, &match_other))
        {
@@ -396,7 +396,7 @@ static void remove_local_set(private_credential_manager_t *this,
                                                         credential_set_t *set)
 {
        linked_list_t *sets;
-       
+
        sets = pthread_getspecific(this->local_sets);
        sets->remove(sets, set, NULL);
 }
@@ -408,7 +408,7 @@ static void cache_cert(private_credential_manager_t *this, certificate_t *cert)
 {
        credential_set_t *set;
        enumerator_t *enumerator;
-       
+
        if (this->lock->try_write_lock(this->lock))
        {
                enumerator = this->sets->create_enumerator(this->sets);
@@ -434,7 +434,7 @@ static void cache_queue(private_credential_manager_t *this)
        credential_set_t *set;
        certificate_t *cert;
        enumerator_t *enumerator;
-       
+
        if (this->cache_queue->get_count(this->cache_queue) > 0 &&
                this->lock->try_write_lock(this->lock))
        {
@@ -454,7 +454,7 @@ static void cache_queue(private_credential_manager_t *this)
 }
 
 /**
- * forward declaration 
+ * forward declaration
  */
 static enumerator_t *create_trusted_enumerator(private_credential_manager_t *this,
                                        key_type_t type, identification_t *id, bool crl, bool ocsp);
@@ -467,7 +467,7 @@ static certificate_t *fetch_ocsp(private_credential_manager_t *this, char *url,
 {
        certificate_t *request, *response;
        chunk_t send, receive;
-       
+
        /* TODO: requestor name, signature */
        request = lib->creds->create(lib->creds,
                                                CRED_CERTIFICATE, CERT_X509_OCSP_REQUEST,
@@ -478,12 +478,12 @@ static certificate_t *fetch_ocsp(private_credential_manager_t *this, char *url,
                DBG1(DBG_CFG, "generating ocsp request failed");
                return NULL;
        }
-       
+
        send = request->get_encoding(request);
        request->destroy(request);
 
        DBG1(DBG_CFG, "  requesting ocsp status from '%s' ...", url);
-       if (lib->fetcher->fetch(lib->fetcher, url, &receive, 
+       if (lib->fetcher->fetch(lib->fetcher, url, &receive,
                                                        FETCH_REQUEST_DATA, send,
                                                        FETCH_REQUEST_TYPE, "application/ocsp-request",
                                                        FETCH_END) != SUCCESS)
@@ -493,7 +493,7 @@ static certificate_t *fetch_ocsp(private_credential_manager_t *this, char *url,
                return NULL;
        }
        chunk_free(&send);
-       
+
        response = lib->creds->create(lib->creds,
                                                                  CRED_CERTIFICATE, CERT_X509_OCSP_RESPONSE,
                                                                  BUILD_BLOB_ASN1_DER, receive, BUILD_END);
@@ -507,9 +507,9 @@ static certificate_t *fetch_ocsp(private_credential_manager_t *this, char *url,
 }
 
 /**
- * check the signature of an OCSP response 
+ * check the signature of an OCSP response
  */
-static bool verify_ocsp(private_credential_manager_t *this, 
+static bool verify_ocsp(private_credential_manager_t *this,
                                                ocsp_response_t *response)
 {
        certificate_t *issuer, *subject;
@@ -520,7 +520,7 @@ static bool verify_ocsp(private_credential_manager_t *this,
 
        wrapper = ocsp_response_wrapper_create((ocsp_response_t*)response);
        add_local_set(this, &wrapper->set);
-       
+
        subject = &response->certificate;
        responder = subject->get_issuer(subject);
        enumerator = create_trusted_enumerator(this, KEY_ANY, responder, FALSE, FALSE);
@@ -535,7 +535,7 @@ static bool verify_ocsp(private_credential_manager_t *this,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        remove_local_set(this, &wrapper->set);
        wrapper->destroy(wrapper);
        return verified;
@@ -553,7 +553,7 @@ static certificate_t *get_better_ocsp(private_credential_manager_t *this,
        time_t revocation, this_update, next_update, valid_until;
        crl_reason_t reason;
        bool revoked = FALSE;
-       
+
        response = (ocsp_response_t*)cand;
 
        /* check ocsp signature */
@@ -622,7 +622,7 @@ static certificate_t *get_better_ocsp(private_credential_manager_t *this,
  * validate a x509 certificate using OCSP
  */
 static cert_validation_t check_ocsp(private_credential_manager_t *this,
-                                                                   x509_t *subject, x509_t *issuer, 
+                                                                   x509_t *subject, x509_t *issuer,
                                                                    auth_cfg_t *auth)
 {
        enumerator_t *enumerator;
@@ -632,7 +632,7 @@ static cert_validation_t check_ocsp(private_credential_manager_t *this,
        public_key_t *public;
        chunk_t chunk;
        char *uri = NULL;
-       
+
        /** lookup cache for valid OCSP responses */
        enumerator = create_cert_enumerator(this, CERT_X509_OCSP_RESPONSE,
                                                                                KEY_ANY, NULL, FALSE);
@@ -648,7 +648,7 @@ static cert_validation_t check_ocsp(private_credential_manager_t *this,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        /* derive the authorityKeyIdentifier from the issuer's public key */
        current = &issuer->interface;
        public = current->get_public_key(current);
@@ -723,7 +723,7 @@ static certificate_t* fetch_crl(private_credential_manager_t *this, char *url)
 {
        certificate_t *crl;
        chunk_t chunk;
-       
+
        DBG1(DBG_CFG, "  fetching crl from '%s' ...", url);
        if (lib->fetcher->fetch(lib->fetcher, url, &chunk, FETCH_END) != SUCCESS)
        {
@@ -749,7 +749,7 @@ static bool verify_crl(private_credential_manager_t *this, certificate_t *crl)
        certificate_t *issuer;
        enumerator_t *enumerator;
        bool verified = FALSE;
-       
+
        enumerator = create_trusted_enumerator(this, KEY_ANY, crl->get_issuer(crl),
                                                                                   FALSE, FALSE);
        while (enumerator->enumerate(enumerator, &issuer, NULL))
@@ -763,7 +763,7 @@ static bool verify_crl(private_credential_manager_t *this, certificate_t *crl)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        return verified;
 }
 
@@ -788,7 +788,7 @@ static certificate_t *get_better_crl(private_credential_manager_t *this,
                cand->destroy(cand);
                return best;
        }
-       
+
        crl = (crl_t*)cand;
        enumerator = crl->create_enumerator(crl);
        while (enumerator->enumerate(enumerator, &serial, &revocation, &reason))
@@ -837,7 +837,7 @@ static certificate_t *get_better_crl(private_credential_manager_t *this,
  * validate a x509 certificate using CRL
  */
 static cert_validation_t check_crl(private_credential_manager_t *this,
-                                                                  x509_t *subject, x509_t *issuer, 
+                                                                  x509_t *subject, x509_t *issuer,
                                                                   auth_cfg_t *auth)
 {
        cert_validation_t valid = VALIDATION_SKIPPED;
@@ -848,16 +848,16 @@ static cert_validation_t check_crl(private_credential_manager_t *this,
        enumerator_t *enumerator;
        chunk_t chunk;
        char *uri = NULL;
-       
+
        /* derive the authorityKeyIdentifier from the issuer's public key */
        current = &issuer->interface;
        public = current->get_public_key(current);
        if (public && public->get_fingerprint(public, KEY_ID_PUBKEY_SHA1, &chunk))
        {
                keyid = identification_create_from_encoding(ID_KEY_ID, chunk);
-               
+
                /* find a cached crl by authorityKeyIdentifier */
-               enumerator = create_cert_enumerator(this, CERT_X509_CRL, KEY_ANY, 
+               enumerator = create_cert_enumerator(this, CERT_X509_CRL, KEY_ANY,
                                                                                        keyid, FALSE);
                while (enumerator->enumerate(enumerator, &current))
                {
@@ -871,12 +871,12 @@ static cert_validation_t check_crl(private_credential_manager_t *this,
                        }
                }
                enumerator->destroy(enumerator);
-               
+
                /* fallback to fetching crls from credential sets cdps */
                if (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
                {
                        enumerator = create_cdp_enumerator(this, CERT_X509_CRL, keyid);
-                       
+
                        while (enumerator->enumerate(enumerator, &uri))
                        {
                                current = fetch_crl(this, uri);
@@ -895,12 +895,12 @@ static cert_validation_t check_crl(private_credential_manager_t *this,
                keyid->destroy(keyid);
        }
        DESTROY_IF(public);
-       
+
        /* fallback to fetching crls from cdps from subject's certificate */
        if (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
        {
                enumerator = subject->create_crl_uri_enumerator(subject);
-               
+
                while (enumerator->enumerate(enumerator, &uri))
                {
                        current = fetch_crl(this, uri);
@@ -916,7 +916,7 @@ static cert_validation_t check_crl(private_credential_manager_t *this,
                }
                enumerator->destroy(enumerator);
        }
-       
+
        /* an uri was found, but no result. switch validation state to failed */
        if (valid == VALIDATION_SKIPPED && uri)
        {
@@ -947,7 +947,7 @@ static bool check_certificate(private_credential_manager_t *this,
                                                          bool crl, bool ocsp, auth_cfg_t *auth)
 {
        time_t not_before, not_after;
-       
+
        if (!subject->get_validity(subject, NULL, &not_before, &not_after))
        {
                DBG1(DBG_CFG, "subject certificate invalid (valid from %T to %T)",
@@ -1020,7 +1020,7 @@ static certificate_t *get_pretrusted_cert(private_credential_manager_t *this,
 {
        certificate_t *subject;
        public_key_t *public;
-       
+
        subject = get_cert(this, CERT_ANY, type, id, TRUE);
        if (!subject)
        {
@@ -1044,8 +1044,8 @@ static certificate_t *get_issuer_cert(private_credential_manager_t *this,
 {
        enumerator_t *enumerator;
        certificate_t *issuer = NULL, *candidate;
-       
-       enumerator = create_cert_enumerator(this, subject->get_type(subject), KEY_ANY, 
+
+       enumerator = create_cert_enumerator(this, subject->get_type(subject), KEY_ANY,
                                                                                subject->get_issuer(subject), trusted);
        while (enumerator->enumerate(enumerator, &candidate))
        {
@@ -1069,7 +1069,7 @@ static bool verify_trust_chain(private_credential_manager_t *this,
        certificate_t *current, *issuer;
        auth_cfg_t *auth;
        u_int level = 0;
-       
+
        auth = auth_cfg_create();
        current = subject->get_ref(subject);
        while (level++ < MAX_CA_LEVELS)
@@ -1110,7 +1110,7 @@ static bool verify_trust_chain(private_credential_manager_t *this,
                        }
                        else
                        {
-                               DBG1(DBG_CFG, "no issuer certificate found for \"%Y\"", 
+                               DBG1(DBG_CFG, "no issuer certificate found for \"%Y\"",
                                         current->get_subject(current));
                                break;
                        }
@@ -1173,10 +1173,10 @@ static bool trusted_enumerate(trusted_enumerator_t *this,
                                                          certificate_t **cert, auth_cfg_t **auth)
 {
        certificate_t *current;
-       
+
        DESTROY_IF(this->auth);
        this->auth = auth_cfg_create();
-       
+
        if (!this->candidates)
        {
                /* first invocation, build enumerator for next one */
@@ -1187,7 +1187,7 @@ static bool trusted_enumerate(trusted_enumerator_t *this,
                if (this->pretrusted)
                {
                        /* if we find a trusted self signed certificate, we just accept it.
-                        * However, in order to fulfill authorization rules, we try to build 
+                        * However, in order to fulfill authorization rules, we try to build
                         * the trust chain if it is not self signed */
                        if (this->this->cache->issued_by(this->this->cache,
                                                                   this->pretrusted, this->pretrusted) ||
@@ -1215,7 +1215,7 @@ static bool trusted_enumerate(trusted_enumerator_t *this,
                {       /* skip pretrusted certificate we already served */
                        continue;
                }
-       
+
                DBG1(DBG_CFG, "  using certificate \"%Y\"",
                         current->get_subject(current));
                if (verify_trust_chain(this->this, current, this->auth, FALSE,
@@ -1250,10 +1250,10 @@ static enumerator_t *create_trusted_enumerator(private_credential_manager_t *thi
                                        key_type_t type, identification_t *id, bool crl, bool ocsp)
 {
        trusted_enumerator_t *enumerator = malloc_thing(trusted_enumerator_t);
-       
+
        enumerator->public.enumerate = (void*)trusted_enumerate;
        enumerator->public.destroy = (void*)trusted_destroy;
-       
+
        enumerator->candidates = NULL;
        enumerator->this = this;
        enumerator->type = type;
@@ -1262,7 +1262,7 @@ static enumerator_t *create_trusted_enumerator(private_credential_manager_t *thi
        enumerator->ocsp = ocsp;
        enumerator->pretrusted = NULL;
        enumerator->auth = NULL;
-       
+
        return &enumerator->public;
 }
 
@@ -1289,7 +1289,7 @@ static bool public_enumerate(public_enumerator_t *this,
                                                         public_key_t **key, auth_cfg_t **auth)
 {
        certificate_t *cert;
-       
+
        while (this->inner->enumerate(this->inner, &cert, auth))
        {
                DESTROY_IF(this->current);
@@ -1316,7 +1316,7 @@ static void public_destroy(public_enumerator_t *this)
                this->wrapper->destroy(this->wrapper);
        }
        this->this->lock->unlock(this->this->lock);
-       
+
        /* check for delayed certificate cache queue */
        cache_queue(this->this);
        free(this);
@@ -1329,7 +1329,7 @@ static enumerator_t* create_public_enumerator(private_credential_manager_t *this
                                                key_type_t type, identification_t *id, auth_cfg_t *auth)
 {
        public_enumerator_t *enumerator = malloc_thing(public_enumerator_t);
-       
+
        enumerator->public.enumerate = (void*)public_enumerate;
        enumerator->public.destroy = (void*)public_destroy;
        enumerator->inner = create_trusted_enumerator(this, type, id, TRUE, TRUE);
@@ -1374,13 +1374,13 @@ static bool auth_contains_cacert(auth_cfg_t *auth, certificate_t *cert)
  */
 static auth_cfg_t *build_trustchain(private_credential_manager_t *this,
                                                                         certificate_t *subject, auth_cfg_t *auth)
-{      
+{
        certificate_t *issuer, *current;
        auth_cfg_t *trustchain;
        u_int level = 0;
-       
+
        trustchain = auth_cfg_create();
-       
+
        current = auth->get(auth, AUTH_RULE_CA_CERT);
        if (!current)
        {
@@ -1428,7 +1428,7 @@ static private_key_t *get_private_by_cert(private_credential_manager_t *this,
        identification_t *keyid;
        chunk_t chunk;
        public_key_t *public;
-       
+
        public = cert->get_public_key(cert);
        if (public)
        {
@@ -1454,13 +1454,13 @@ static private_key_t *get_private(private_credential_manager_t *this,
        certificate_t *cert;
        private_key_t *private = NULL;
        auth_cfg_t *trustchain;
-       
+
        /* check if this is a lookup by key ID, and do it if so */
        if (id && id->get_type(id) == ID_KEY_ID)
        {
                return get_private_by_keyid(this, type, id);
        }
-       
+
        /* if a specific certificate is preferred, check for a matching key */
        cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
        if (cert)
@@ -1477,7 +1477,7 @@ static private_key_t *get_private(private_credential_manager_t *this,
                        return private;
                }
        }
-       
+
        /* try to build a trust chain for each certificate found */
        enumerator = create_cert_enumerator(this, CERT_ANY, type, id, FALSE);
        while (enumerator->enumerate(enumerator, &cert))
@@ -1497,7 +1497,7 @@ static private_key_t *get_private(private_credential_manager_t *this,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        /* if no valid trustchain was found, fall back to the first usable cert */
        if (!private)
        {
@@ -1567,7 +1567,7 @@ static void destroy(private_credential_manager_t *this)
 credential_manager_t *credential_manager_create()
 {
        private_credential_manager_t *this = malloc_thing(private_credential_manager_t);
-       
+
        this->public.create_cert_enumerator = (enumerator_t *(*)(credential_manager_t *this,certificate_type_t cert, key_type_t key,identification_t *id,bool))create_cert_enumerator;
        this->public.create_shared_enumerator = (enumerator_t *(*)(credential_manager_t *this, shared_key_type_t type,identification_t *me, identification_t *other))create_shared_enumerator;
        this->public.create_cdp_enumerator = (enumerator_t *(*)(credential_manager_t*, certificate_type_t type, identification_t *id))create_cdp_enumerator;
@@ -1580,14 +1580,14 @@ credential_manager_t *credential_manager_create()
        this->public.add_set = (void(*)(credential_manager_t*, credential_set_t *set))add_set;
        this->public.remove_set = (void(*)(credential_manager_t*, credential_set_t *set))remove_set;
        this->public.destroy = (void(*)(credential_manager_t*))destroy;
-       
+
        this->sets = linked_list_create();
        pthread_key_create(&this->local_sets, (void*)this->sets->destroy);
        this->cache = cert_cache_create();
        this->cache_queue = linked_list_create();
        this->sets->insert_first(this->sets, this->cache);
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index 0af54c0b1590e78b3eb20eeb8b95b7136ba76838..192b348716d3518d52fce1cc262465a08e5f4690 100644 (file)
@@ -36,11 +36,11 @@ typedef struct credential_manager_t credential_manager_t;
  *
  * The credential manager is the entry point of the credential framework. It
  * uses so called "sets" to access credentials in a modular fashion, these
- * are implemented through the credential_set_t interface. 
+ * are implemented through the credential_set_t interface.
  * The manager additionally does trust chain verification and trust status
  * chaching. A set may call the managers methods if it needs credentials itself,
  * the manager uses recursive locking.
- * 
+ *
  * @verbatim
 
   +-------+        +----------------+
@@ -58,14 +58,14 @@ typedef struct credential_manager_t credential_manager_t;
   |   o   |                    may be recursive
   |   r   |
   +-------+
-    
-   @endverbatim                                       
+
+   @endverbatim
  *
  * The credential manager uses rwlocks for performance reasons, credential
  * sets must be fully thread save.
  */
 struct credential_manager_t {
-       
+
        /**
         * Create an enumerator over all certificates.
         *
@@ -90,7 +90,7 @@ struct credential_manager_t {
         * @param second        second subject between key is shared
         * @return                      enumerator over shared keys
         */
-       enumerator_t *(*create_shared_enumerator)(credential_manager_t *this, 
+       enumerator_t *(*create_shared_enumerator)(credential_manager_t *this,
                                                                shared_key_type_t type,
                                                                identification_t *first, identification_t *second);
        /**
@@ -121,14 +121,14 @@ struct credential_manager_t {
         * @param me            own identity
         * @param other         peers identity
         * @return                      shared_key_t, NULL if none found
-        */                        
+        */
        shared_key_t *(*get_shared)(credential_manager_t *this, shared_key_type_t type,
                                                                identification_t *me, identification_t *other);
        /**
         * Get a private key to create a signature.
         *
         * The get_private() method gets a secret private key identified by either
-        * the keyid itself or an id the key belongs to. 
+        * the keyid itself or an id the key belongs to.
         * The auth parameter contains additional information, such as receipients
         * trusted CA certs. Auth gets filled with subject and CA certificates
         * needed to validate a created signature.
@@ -140,12 +140,12 @@ struct credential_manager_t {
         */
        private_key_t* (*get_private)(credential_manager_t *this, key_type_t type,
                                                                  identification_t *id, auth_cfg_t *auth);
-       
+
        /**
         * Create an enumerator over trusted public keys.
         *
         * This method gets a an enumerator over trusted public keys to verify a
-        * signature created by id. The auth parameter contains additional 
+        * signature created by id. The auth parameter contains additional
         * authentication infos, e.g. peer and intermediate certificates.
         * The resulting enumerator enumerates over public_key_t *, auth_cfg_t *,
         * where the auth config helper contains rules for constraint checks.
@@ -157,14 +157,14 @@ struct credential_manager_t {
         */
        enumerator_t* (*create_public_enumerator)(credential_manager_t *this,
                                        key_type_t type, identification_t *id, auth_cfg_t *auth);
-       
+
        /**
         * Cache a certificate by invoking cache_cert() on all registerd sets.
         *
         * @param cert          certificate to cache
         */
        void (*cache_cert)(credential_manager_t *this, certificate_t *cert);
-       
+
        /**
         * Flush the certificate cache.
         *
@@ -174,21 +174,21 @@ struct credential_manager_t {
         * @param type          type of certificate to flush, or CERT_ANY
         */
        void (*flush_cache)(credential_manager_t *this, certificate_type_t type);
-               
+
        /**
         * Register a credential set to the manager.
         *
         * @param set           set to register
         */
        void (*add_set)(credential_manager_t *this, credential_set_t *set);
-       
+
        /**
         * Unregister a credential set from the manager.
         *
         * @param set           set to unregister
         */
        void (*remove_set)(credential_manager_t *this, credential_set_t *set);
-       
+
        /**
      * Destroy a credential_manager instance.
      */
index e9ad99bfdc656d87b4bb6eaff329828f8776b19f..274eb3feb56fef50b0273a81d8c5d0274c791702 100644 (file)
@@ -43,12 +43,12 @@ typedef struct credential_set_t credential_set_t;
  * enumerator is alive, so it is save to use a write lock there.
  */
 struct credential_set_t {
-       
+
        /**
         * Create an enumerator over private keys (private_key_t).
         *
         * The id is either a key identifier of the requested key, or an identity
-        * of the key owner. 
+        * of the key owner.
         *
         * @param type          type of requested private key
         * @param id            key identifier/owner
@@ -80,10 +80,10 @@ struct credential_set_t {
         * @param other         other identity who owns that secret
         * @return                      enumerator as described above
         */
-       enumerator_t *(*create_shared_enumerator)(credential_set_t *this, 
+       enumerator_t *(*create_shared_enumerator)(credential_set_t *this,
                                                shared_key_type_t type,
                                                identification_t *me, identification_t *other);
-       
+
        /**
         * Create an enumerator over certificate distribution points.
         *
@@ -93,7 +93,7 @@ struct credential_set_t {
         */
        enumerator_t *(*create_cdp_enumerator)(credential_set_t *this,
                                                certificate_type_t type, identification_t *id);
-       
+
        /**
         * Cache a certificate in the credential set.
         *
@@ -102,7 +102,7 @@ struct credential_set_t {
         *
         * @param cert          certificate to cache
         */
-       void (*cache_cert)(credential_set_t *this, certificate_t *cert);        
+       void (*cache_cert)(credential_set_t *this, certificate_t *cert);
 };
 
 #endif /** CREDENTIAL_SET_H_ @}*/
index b2cf5d9602e9180d23af3d7307f4660b7905b294..82e33d283e535ab6a6428b8c046aef0a53c1d69c 100644 (file)
@@ -29,7 +29,7 @@ struct private_auth_cfg_wrapper_t {
         * public functions
         */
        auth_cfg_wrapper_t public;
-       
+
        /**
         * wrapped auth info
         */
@@ -67,10 +67,10 @@ static bool fetch_cert(wrapper_enumerator_t *enumerator,
                /* fetching the certificate previously failed */
                return FALSE;
        }
-       
+
        chunk_t data;
        certificate_t *cert;
-       
+
        DBG1(DBG_CFG, "  fetching certificate from '%s' ...", url);
        if (lib->fetcher->fetch(lib->fetcher, url, &data, FETCH_END) != SUCCESS)
        {
@@ -80,11 +80,11 @@ static bool fetch_cert(wrapper_enumerator_t *enumerator,
                                                                  *rule, NULL);
                return FALSE;
        }
-       
+
        cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
                                                          BUILD_BLOB_ASN1_DER, data, BUILD_END);
        free(data.ptr);
-       
+
        if (!cert)
        {
                DBG1(DBG_CFG, "  parsing fetched certificate failed");
@@ -93,10 +93,10 @@ static bool fetch_cert(wrapper_enumerator_t *enumerator,
                                                                  *rule, NULL);
                return FALSE;
        }
-       
+
        DBG1(DBG_CFG, "  fetched certificate \"%Y\"", cert->get_subject(cert));
        charon->credentials->cache_cert(charon->credentials, cert);
-       
+
        if (*rule == AUTH_HELPER_IM_HASH_URL)
        {
                *rule = AUTH_HELPER_IM_CERT;
@@ -174,11 +174,11 @@ static void wrapper_enumerator_destroy(wrapper_enumerator_t *this)
  * implementation of auth_cfg_wrapper_t.set.create_cert_enumerator
  */
 static enumerator_t *create_enumerator(private_auth_cfg_wrapper_t *this,
-                                                                          certificate_type_t cert, key_type_t key, 
+                                                                          certificate_type_t cert, key_type_t key,
                                                                           identification_t *id, bool trusted)
 {
        wrapper_enumerator_t *enumerator;
-       
+
        if (trusted)
        {
                return NULL;
@@ -208,16 +208,16 @@ static void destroy(private_auth_cfg_wrapper_t *this)
 auth_cfg_wrapper_t *auth_cfg_wrapper_create(auth_cfg_t *auth)
 {
        private_auth_cfg_wrapper_t *this = malloc_thing(private_auth_cfg_wrapper_t);
-       
+
        this->public.set.create_private_enumerator = (void*)return_null;
        this->public.set.create_cert_enumerator = (void*)create_enumerator;
        this->public.set.create_shared_enumerator = (void*)return_null;
        this->public.set.create_cdp_enumerator = (void*)return_null;
        this->public.set.cache_cert = (void*)nop;
        this->public.destroy = (void(*)(auth_cfg_wrapper_t*))destroy;
-       
+
        this->auth = auth;
-       
+
        return &this->public;
 }
 
index dd5e0fff672489d89640a660c108170812fb17c3..1d9824182d4467f037b1ffcdcf85f4384f8c0a1f 100644 (file)
@@ -35,7 +35,7 @@ struct auth_cfg_wrapper_t {
         * implements credential_set_t
         */
        credential_set_t set;
-               
+
        /**
      * Destroy a auth_cfg_wrapper instance.
      */
index dee0463e681370dde9d47111ec29dcbc23ae4b61..de8994b8286aee964b9bca5acf94974c07da9de9 100644 (file)
@@ -35,22 +35,22 @@ typedef struct relation_t relation_t;
  * A trusted relation between subject and issuer
  */
 struct relation_t {
-       
+
        /**
         * subject of this relation
         */
        certificate_t *subject;
-       
+
        /**
         * issuer of this relation
         */
        certificate_t *issuer;
-       
+
        /**
         * Cache hits
         */
        u_int hits;
-       
+
        /**
         * Lock for this relation
         */
@@ -61,12 +61,12 @@ struct relation_t {
  * private data of cert_cache
  */
 struct private_cert_cache_t {
-       
+
        /**
         * public functions
         */
        cert_cache_t public;
-       
+
        /**
         * array of trusted subject-issuer relations
         */
@@ -82,12 +82,12 @@ static void cache(private_cert_cache_t *this,
        relation_t *rel;
        int i, offset, try;
        u_int total_hits = 0;
-       
+
        /* check for a unused relation slot first */
        for (i = 0; i < CACHE_SIZE; i++)
        {
                rel = &this->relations[i];
-               
+
                if (!rel->subject && rel->lock->try_write_lock(rel->lock))
                {
                        /* double-check having lock */
@@ -109,7 +109,7 @@ static void cache(private_cert_cache_t *this,
                for (i = 0; i < CACHE_SIZE; i++)
                {
                        rel = &this->relations[(i + offset) % CACHE_SIZE];
-                       
+
                        if (rel->hits > total_hits / CACHE_SIZE)
                        {       /* skip often used slots */
                                continue;
@@ -140,11 +140,11 @@ static bool issued_by(private_cert_cache_t *this,
 {
        relation_t *found = NULL, *current;
        int i;
-       
+
        for (i = 0; i < CACHE_SIZE; i++)
        {
                current = &this->relations[i];
-               
+
                current->lock->read_lock(current->lock);
                if (current->subject)
                {
@@ -203,14 +203,14 @@ static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
 {
        public_key_t *public;
        relation_t *rel;
-       
+
        if (this->locked >= 0)
        {
                rel = &this->relations[this->locked];
                rel->lock->unlock(rel->lock);
                this->locked = -1;
        }
-       
+
        while (++this->index < CACHE_SIZE)
        {
                rel = &this->relations[this->index];
@@ -219,7 +219,7 @@ static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
                if (rel->subject)
                {
                        /* CRL lookup is done using issuer/authkeyidentifier */
-                       if (this->key == KEY_ANY && this->id && 
+                       if (this->key == KEY_ANY && this->id &&
                                (this->cert == CERT_ANY || this->cert == CERT_X509_CRL) &&
                                rel->subject->get_type(rel->subject) == CERT_X509_CRL &&
                                rel->subject->has_issuer(rel->subject, this->id))
@@ -261,7 +261,7 @@ static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
 static void cert_enumerator_destroy(cert_enumerator_t *this)
 {
        relation_t *rel;
-       
+
        if (this->locked >= 0)
        {
                rel = &this->relations[this->locked];
@@ -274,11 +274,11 @@ static void cert_enumerator_destroy(cert_enumerator_t *this)
  * implementation of credential_set_t.create_cert_enumerator
  */
 static enumerator_t *create_enumerator(private_cert_cache_t *this,
-                                                                          certificate_type_t cert, key_type_t key, 
+                                                                          certificate_type_t cert, key_type_t key,
                                                                           identification_t *id, bool trusted)
 {
        cert_enumerator_t *enumerator;
-       
+
        if (trusted)
        {
                return NULL;
@@ -292,7 +292,7 @@ static enumerator_t *create_enumerator(private_cert_cache_t *this,
        enumerator->relations = this->relations;
        enumerator->index = -1;
        enumerator->locked = -1;
-       
+
        return &enumerator->public;
 }
 
@@ -303,7 +303,7 @@ static void flush(private_cert_cache_t *this, certificate_type_t type)
 {
        relation_t *rel;
        int i;
-       
+
        for (i = 0; i < CACHE_SIZE; i++)
        {
                rel = &this->relations[i];
@@ -346,7 +346,7 @@ static void destroy(private_cert_cache_t *this)
 {
        relation_t *rel;
        int i;
-       
+
        for (i = 0; i < CACHE_SIZE; i++)
        {
                rel = &this->relations[i];
@@ -367,7 +367,7 @@ cert_cache_t *cert_cache_create()
 {
        private_cert_cache_t *this;
        int i;
-       
+
        this = malloc_thing(private_cert_cache_t);
        this->public.set.create_private_enumerator = (void*)return_null;
        this->public.set.create_cert_enumerator = (void*)create_enumerator;
@@ -377,7 +377,7 @@ cert_cache_t *cert_cache_create()
        this->public.issued_by = (bool(*)(cert_cache_t*, certificate_t *subject, certificate_t *issuer))issued_by;
        this->public.flush = (void(*)(cert_cache_t*, certificate_type_t type))flush;
        this->public.destroy = (void(*)(cert_cache_t*))destroy;
-       
+
        for (i = 0; i < CACHE_SIZE; i++)
        {
                this->relations[i].subject = NULL;
index a2cae367c89ac9d9d3ed0681efcff5e623ebb6c6..d2721866e59f7b2d913294a47a503ee882aa5973 100644 (file)
@@ -39,7 +39,7 @@ struct cert_cache_t {
         * Implements credential_set_t.
         */
        credential_set_t set;
-       
+
        /**
         * Caching wrapper around certificate_t.issued_by.
         *
@@ -49,14 +49,14 @@ struct cert_cache_t {
         */
        bool (*issued_by)(cert_cache_t *this,
                                          certificate_t *subject, certificate_t *issuer);
-       
+
        /**
         * Flush the certificate cache.
         *
         * @param type                  type of certificate to flush, or CERT_ANY
         */
        void (*flush)(cert_cache_t *this, certificate_type_t type);
-               
+
        /**
         * Destroy a cert_cache instance.
         */
index e9faec4725007492366c7d3a4876d59233289b07..82079209a8630740632f2136571bb7b0c0bdf6b9 100644 (file)
@@ -26,7 +26,7 @@ struct private_ocsp_response_wrapper_t {
         * public functions
         */
        ocsp_response_wrapper_t public;
-       
+
        /**
         * wrapped OCSP response
         */
@@ -98,16 +98,16 @@ static void enumerator_destroy(wrapper_enumerator_t *this)
  * implementation of ocsp_response_wrapper_t.set.create_cert_enumerator
  */
 static enumerator_t *create_enumerator(private_ocsp_response_wrapper_t *this,
-                                                                          certificate_type_t cert, key_type_t key, 
+                                                                          certificate_type_t cert, key_type_t key,
                                                                           identification_t *id, bool trusted)
 {
        wrapper_enumerator_t *enumerator;
-       
+
        if (trusted)
        {
                return NULL;
        }
-       
+
        enumerator = malloc_thing(wrapper_enumerator_t);
        enumerator->cert = cert;
        enumerator->key = key;
@@ -132,16 +132,16 @@ static void destroy(private_ocsp_response_wrapper_t *this)
 ocsp_response_wrapper_t *ocsp_response_wrapper_create(ocsp_response_t *response)
 {
        private_ocsp_response_wrapper_t *this = malloc_thing(private_ocsp_response_wrapper_t);
-       
+
        this->public.set.create_private_enumerator = (void*)return_null;
        this->public.set.create_cert_enumerator = (void*)create_enumerator;
        this->public.set.create_shared_enumerator = (void*)return_null;
        this->public.set.create_cdp_enumerator = (void*)return_null;
        this->public.set.cache_cert = (void*)nop;
        this->public.destroy = (void(*)(ocsp_response_wrapper_t*))destroy;
-       
+
        this->response = response;
-       
+
        return &this->public;
 }
 
index 8f141f7a1c9b08ea3b1fccdd128cdd05d3a441c3..bf746320a9ff294471e4945b85675a0b20756c13 100644 (file)
@@ -35,7 +35,7 @@ struct ocsp_response_wrapper_t {
         * implements credential_set_t
         */
        credential_set_t set;
-               
+
        /**
      * Destroy a ocsp_response_wrapper instance.
      */
index 26858af6c7e12c0a67537c1fc500ef58763b1750..aa8a6a0b8a4030f24f4bb29c42d1512d047be1fc 100644 (file)
@@ -58,7 +58,7 @@ struct private_daemon_t {
         * Public members of daemon_t.
         */
        daemon_t public;
-       
+
        /**
         * Signal set used for signal handling.
         */
@@ -88,7 +88,7 @@ extern void (*dbg) (int level, char *fmt, ...);
 static void dbg_bus(int level, char *fmt, ...)
 {
        va_list args;
-       
+
        va_start(args, fmt);
        charon->bus->vlog(charon->bus, DBG_LIB, level, fmt, args);
        va_end(args);
@@ -100,7 +100,7 @@ static void dbg_bus(int level, char *fmt, ...)
 static void dbg_stderr(int level, char *fmt, ...)
 {
        va_list args;
-       
+
        if (level <= 1)
        {
                va_start(args, fmt);
@@ -117,18 +117,18 @@ static void dbg_stderr(int level, char *fmt, ...)
 static void run(private_daemon_t *this)
 {
        sigset_t set;
-       
+
        /* handle SIGINT, SIGHUP ans SIGTERM in this handler */
        sigemptyset(&set);
        sigaddset(&set, SIGINT);
        sigaddset(&set, SIGHUP);
        sigaddset(&set, SIGTERM);
-       
+
        while (TRUE)
        {
                int sig;
                int error;
-               
+
                error = sigwait(&set, &sig);
                if (error)
                {
@@ -200,7 +200,7 @@ static void destroy(private_daemon_t *this)
        DESTROY_IF(this->public.socket);
        /* wait until all threads are gone */
        DESTROY_IF(this->public.processor);
-       
+
        /* rehook library logging, shutdown logging */
        dbg = dbg_stderr;
        DESTROY_IF(this->public.bus);
@@ -257,7 +257,7 @@ static void drop_capabilities(private_daemon_t *this)
        {
                kill_daemon(this, "change to unprivileged user failed");
        }
-       
+
 #ifdef CAPABILITIES
        if (cap_set_proc(this->caps) != 0)
        {
@@ -287,7 +287,7 @@ static void lookup_uid_gid(private_daemon_t *this)
        {
                char buf[1024];
                struct passwd passwd, *pwp;
-       
+
                if (getpwnam_r(IPSEC_USER, &passwd, buf, sizeof(buf), &pwp) != 0 ||
                        pwp == NULL)
                {
@@ -300,7 +300,7 @@ static void lookup_uid_gid(private_daemon_t *this)
        {
                char buf[1024];
                struct group group, *grp;
-       
+
                if (getgrnam_r(IPSEC_GROUP, &group, buf, sizeof(buf), &grp) != 0 ||
                        grp == NULL)
                {
@@ -319,7 +319,7 @@ static void print_plugins()
        char buf[512], *plugin;
        int len = 0;
        enumerator_t *enumerator;
-       
+
        buf[0] = '\0';
        enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
        while (len < sizeof(buf) && enumerator->enumerate(enumerator, &plugin))
@@ -345,7 +345,7 @@ static void initialize_loggers(private_daemon_t *this, bool use_stderr,
        level_t  def;
        bool append;
        FILE *file;
-       
+
        /* setup sysloggers */
        enumerator = lib->settings->create_section_enumerator(lib->settings,
                                                                                                                  "charon.syslog");
@@ -378,7 +378,7 @@ static void initialize_loggers(private_daemon_t *this, bool use_stderr,
                this->public.bus->add_listener(this->public.bus, &sys_logger->listener);
        }
        enumerator->destroy(enumerator);
-       
+
        /* and file loggers */
        enumerator = lib->settings->create_section_enumerator(lib->settings,
                                                                                                                  "charon.filelog");
@@ -418,10 +418,10 @@ static void initialize_loggers(private_daemon_t *this, bool use_stderr,
                this->public.file_loggers->insert_last(this->public.file_loggers,
                                                                                           file_logger);
                this->public.bus->add_listener(this->public.bus, &file_logger->listener);
-       
+
        }
        enumerator->destroy(enumerator);
-       
+
        /* set up legacy style default loggers provided via command-line */
        if (!loggers_defined)
        {
@@ -443,7 +443,7 @@ static void initialize_loggers(private_daemon_t *this, bool use_stderr,
                                file_logger->set_level(file_logger, group, levels[group]);
                        }
                }
-               
+
                /* set up default auth sys_logger */
                sys_logger = sys_logger_create(LOG_AUTHPRIV);
                this->public.bus->add_listener(this->public.bus, &sys_logger->listener);
@@ -460,14 +460,14 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
 {
        /* for uncritical pseudo random numbers */
        srandom(time(NULL) + getpid());
-       
+
        /* setup bus and it's listeners first to enable log output */
        this->public.bus = bus_create();
        /* set up hook to log dbg message in library via charons message bus */
        dbg = dbg_bus;
-       
+
        initialize_loggers(this, !syslog, levels);
-       
+
        DBG1(DBG_DMN, "Starting IKEv2 charon daemon (strongSwan "VERSION")");
 
        if (lib->integrity)
@@ -489,14 +489,14 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
        this->public.kernel_interface = kernel_interface_create();
        this->public.socket = socket_create();
        this->public.traps = trap_manager_create();
-       
+
        /* load plugins, further infrastructure may need it */
        if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR,
                        lib->settings->get_str(lib->settings, "charon.load", PLUGINS)))
        {
                return FALSE;
        }
-       
+
        print_plugins();
 
        this->public.ike_sa_manager = ike_sa_manager_create();
@@ -510,7 +510,7 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
        {
                return FALSE;
        }
-       
+
 #ifdef ME
        this->public.connect_manager = connect_manager_create();
        if (this->public.connect_manager == NULL)
@@ -519,7 +519,7 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
        }
        this->public.mediation_manager = mediation_manager_create();
 #endif /* ME */
-       
+
        return TRUE;
 }
 
@@ -529,12 +529,12 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
 static void segv_handler(int signal)
 {
        backtrace_t *backtrace;
-       
+
        DBG1(DBG_DMN, "thread %u received %d", pthread_self(), signal);
        backtrace = backtrace_create(2);
        backtrace->log(backtrace, stderr);
        backtrace->destroy(backtrace);
-       
+
        DBG1(DBG_DMN, "killing ourself, received critical signal");
        raise(SIGKILL);
 }
@@ -546,11 +546,11 @@ private_daemon_t *daemon_create(void)
 {
        struct sigaction action;
        private_daemon_t *this = malloc_thing(private_daemon_t);
-               
+
        /* assign methods */
        this->public.kill = (void (*) (daemon_t*,char*))kill_daemon;
        this->public.keep_cap = (void(*)(daemon_t*, u_int cap))keep_cap;
-       
+
        /* NULL members for clean destruction */
        this->public.socket = NULL;
        this->public.ike_sa_manager = NULL;
@@ -575,7 +575,7 @@ private_daemon_t *daemon_create(void)
 #endif /* ME */
        this->public.uid = 0;
        this->public.gid = 0;
-       
+
        this->public.main_thread_id = pthread_self();
 #ifdef CAPABILITIES
        this->caps = cap_init();
@@ -585,7 +585,7 @@ private_daemon_t *daemon_create(void)
                keep_cap(this, CAP_SYS_NICE);
        }
 #endif /* CAPABILITIES */
-       
+
        /* add handler for SEGV and ILL,
         * add handler for USR1 (cancellation).
         * INT, TERM and HUP are handled by sigwait() in run() */
@@ -600,9 +600,9 @@ private_daemon_t *daemon_create(void)
        sigaction(SIGBUS, &action, NULL);
        action.sa_handler = SIG_IGN;
        sigaction(SIGPIPE, &action, NULL);
-       
+
        pthread_sigmask(SIG_SETMASK, &action.sa_mask, 0);
-       
+
        return this;
 }
 
@@ -613,7 +613,7 @@ static bool check_pidfile()
 {
        struct stat stb;
        FILE *file;
-       
+
        if (stat(PID_FILE, &stb) == 0)
        {
                file = fopen(PID_FILE, "r");
@@ -621,7 +621,7 @@ static bool check_pidfile()
                {
                        char buf[64];
                        pid_t pid = 0;
-                       
+
                        memset(buf, 0, sizeof(buf));
                        if (fread(buf, 1, sizeof(buf), file))
                        {
@@ -636,7 +636,7 @@ static bool check_pidfile()
                DBG1(DBG_DMN, "removing pidfile '"PID_FILE"', process not running");
                unlink(PID_FILE);
        }
-       
+
        /* create new pidfile */
        file = fopen(PID_FILE, "w");
        if (file)
@@ -679,17 +679,17 @@ int main(int argc, char *argv[])
        private_daemon_t *private_charon;
        level_t levels[DBG_MAX];
        int group;
-       
+
        /* logging for library during initialization, as we have no bus yet */
        dbg = dbg_stderr;
-       
+
        /* initialize library */
        if (!library_init(STRONGSWAN_CONF))
        {
                library_deinit();
                exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
        }
-       
+
        if (lib->integrity &&
                !lib->integrity->check_file(lib->integrity, "charon", argv[0]))
        {
@@ -697,7 +697,7 @@ int main(int argc, char *argv[])
                library_deinit();
                exit(SS_RC_DAEMON_INTEGRITY);
        }
-       
+
        lib->printf_hook->add_handler(lib->printf_hook, 'R',
                                                                  traffic_selector_printf_hook,
                                                                  PRINTF_HOOK_ARGTYPE_POINTER,
@@ -708,15 +708,15 @@ int main(int argc, char *argv[])
                                                                  PRINTF_HOOK_ARGTYPE_END);
        private_charon = daemon_create();
        charon = (daemon_t*)private_charon;
-       
+
        lookup_uid_gid(private_charon);
-       
+
        /* use CTRL loglevel for default */
        for (group = 0; group < DBG_MAX; group++)
        {
                levels[group] = LEVEL_CTRL;
        }
-       
+
        /* handle arguments */
        for (;;)
        {
@@ -737,7 +737,7 @@ int main(int argc, char *argv[])
                        { "debug-lib", required_argument, &group, DBG_LIB },
                        { 0,0,0,0 }
                };
-               
+
                int c = getopt_long(argc, argv, "", long_opts, NULL);
                switch (c)
                {
@@ -762,7 +762,7 @@ int main(int argc, char *argv[])
                }
                break;
        }
-       
+
        /* initialize daemon */
        if (!initialize(private_charon, use_syslog, levels))
        {
@@ -770,31 +770,31 @@ int main(int argc, char *argv[])
                destroy(private_charon);
                exit(SS_RC_INITIALIZATION_FAILED);
        }
-       
+
        if (check_pidfile())
        {
                DBG1(DBG_DMN, "charon already running (\""PID_FILE"\" exists)");
                destroy(private_charon);
                exit(-1);
        }
-       
+
        /* drop the capabilities we won't need */
        drop_capabilities(private_charon);
-       
+
        /* start the engine, go multithreaded */
        charon->processor->set_threads(charon->processor,
                                                lib->settings->get_int(lib->settings, "charon.threads",
                                                                                           DEFAULT_THREADS));
-       
+
        /* run daemon */
        run(private_charon);
-       
+
        /* normal termination, cleanup and exit */
        destroy(private_charon);
        unlink(PID_FILE);
-       
+
        library_deinit();
-       
+
        return 0;
 }
 
index 430654c8ea7325efe64a26232fe8e872d08a3349..e00a1afba06acab67da3f83755405e8fb6b87092 100644 (file)
@@ -199,104 +199,104 @@ typedef struct daemon_t daemon_t;
  * Main class of daemon, contains some globals.
  */
 struct daemon_t {
-       
+
        /**
         * A socket_t instance.
         */
        socket_t *socket;
-       
+
        /**
         * A ike_sa_manager_t instance.
         */
        ike_sa_manager_t *ike_sa_manager;
-       
+
        /**
         * Manager for triggering policies, called traps
         */
        trap_manager_t *traps;
-       
+
        /**
         * Manager for the different configuration backends.
         */
        backend_manager_t *backends;
-       
+
        /**
         * Manager for IKEv2 cfg payload attributes
         */
        attribute_manager_t *attributes;
-       
+
        /**
         * Manager for the credential backends
         */
        credential_manager_t *credentials;
-       
+
        /**
         * The Sender-Thread.
         */
        sender_t *sender;
-       
+
        /**
         * The Receiver-Thread.
         */
        receiver_t *receiver;
-       
+
        /**
         * The Scheduler-Thread.
         */
        scheduler_t *scheduler;
-       
+
        /**
         * Job processing using a thread pool.
         */
        processor_t *processor;
-       
+
        /**
         * The signaling bus.
         */
        bus_t *bus;
-       
+
        /**
         * A list of installed file_logger_t's
         */
        linked_list_t *file_loggers;
-       
+
        /**
         * A list of installed sys_logger_t's
         */
        linked_list_t *sys_loggers;
-       
+
        /**
         * Kernel Interface to communicate with kernel
         */
        kernel_interface_t *kernel_interface;
-       
+
        /**
         * Controller to control the daemon
         */
        controller_t *controller;
-       
+
        /**
         * EAP manager to maintain registered EAP methods
         */
        eap_manager_t *eap;
-       
+
        /**
         * SIM manager to maintain SIM cards/providers
         */
        sim_manager_t *sim;
-       
+
 #ifdef ME
        /**
         * Connect manager
         */
        connect_manager_t *connect_manager;
-       
+
        /**
         * Mediation manager
         */
        mediation_manager_t *mediation_manager;
 #endif /* ME */
-       
+
        /**
         * User ID the daemon will user after initialization
         */
@@ -306,12 +306,12 @@ struct daemon_t {
         * Group ID the daemon will use after initialization
         */
        gid_t gid;
-       
+
        /**
         * The thread_id of main-thread.
         */
        pthread_t main_thread_id;
-       
+
        /**
         * Do not drop a given capability after initialization.
         *
@@ -320,7 +320,7 @@ struct daemon_t {
         * drop these.
         */
        void (*keep_cap)(daemon_t *this, u_int cap);
-       
+
        /**
         * Shut down the daemon.
         *
index 406cfc6888e911cf159f6a2794307cd23838ee88..e8db55a7f3eaacf55947f7ef26af7bc21320cc8c 100644 (file)
@@ -53,55 +53,55 @@ struct private_generator_t {
         * Public part of a generator_t object.
         */
         generator_t public;
-       
+
        /**
         * Buffer used to generate the data into.
         */
        u_int8_t *buffer;
-       
+
        /**
         * Current write position in buffer (one byte aligned).
         */
        u_int8_t *out_position;
-       
+
        /**
         * Position of last byte in buffer.
         */
        u_int8_t *roof_position;
-       
+
        /**
         * Current bit writing to in current byte (between 0 and 7).
         */
        u_int8_t current_bit;
-       
+
        /**
         * Associated data struct to read informations from.
         */
        void *data_struct;
-       
+
        /*
         * Last payload length position offset in the buffer.
         */
        u_int32_t last_payload_length_position_offset;
-       
+
        /**
         * Offset of the header length field in the buffer.
         */
        u_int32_t header_length_position_offset;
-       
+
        /**
         * Last SPI size.
         */
        u_int8_t last_spi_size;
-       
+
        /**
         * Attribute format of the last generated transform attribute.
         *
-        * Used to check if a variable value field is used or not for 
+        * Used to check if a variable value field is used or not for
         * the transform attribute value.
         */
        bool attribute_format;
-       
+
        /**
         * Depending on the value of attribute_format this field is used
         * to hold the length of the transform attribute in bytes.
@@ -149,14 +149,14 @@ static void make_space_available(private_generator_t *this, int bits)
        while ((get_space(this) * 8 - this->current_bit) < bits)
        {
                int old_buffer_size, new_buffer_size, out_position_offset;
-               
+
                old_buffer_size = get_size(this);
                new_buffer_size = old_buffer_size + GENERATOR_DATA_BUFFER_INCREASE_VALUE;
                out_position_offset = this->out_position - this->buffer;
-               
-               DBG2(DBG_ENC, "increasing gen buffer from %d to %d byte", 
+
+               DBG2(DBG_ENC, "increasing gen buffer from %d to %d byte",
                         old_buffer_size, new_buffer_size);
-               
+
                this->buffer = realloc(this->buffer,new_buffer_size);
                this->out_position = (this->buffer + out_position_offset);
                this->roof_position = (this->buffer + new_buffer_size);
@@ -171,9 +171,9 @@ static void write_bytes_to_buffer(private_generator_t *this, void *bytes,
 {
        int i;
        u_int8_t *read_position = (u_int8_t *)bytes;
-       
+
        make_space_available(this, number_of_bytes * 8);
-       
+
        for (i = 0; i < number_of_bytes; i++)
        {
                *(this->out_position) = *(read_position);
@@ -192,14 +192,14 @@ static void write_bytes_to_buffer_at_offset(private_generator_t *this,
        u_int8_t *read_position = (u_int8_t *)bytes;
        u_int8_t *write_position;
        u_int32_t free_space_after_offset = get_size(this) - offset;
-       
-       /* check first if enough space for new data is available */     
+
+       /* check first if enough space for new data is available */
        if (number_of_bytes > free_space_after_offset)
        {
-               make_space_available(this, 
+               make_space_available(this,
                                                         (number_of_bytes - free_space_after_offset) * 8);
        }
-       
+
        write_position = this->buffer + offset;
        for (i = 0; i < number_of_bytes; i++)
        {
@@ -216,7 +216,7 @@ static void generate_u_int_type(private_generator_t *this,
                                                                encoding_type_t int_type,u_int32_t offset)
 {
        int number_of_bits = 0;
-       
+
        /* find out number of bits of each U_INT type to check for enough space */
        switch (int_type)
        {
@@ -251,14 +251,14 @@ static void generate_u_int_type(private_generator_t *this,
                         encoding_type_names, int_type);
                return;
        }
-       
+
        make_space_available(this, number_of_bits);
        switch (int_type)
        {
                case U_INT_4:
                {
                        u_int8_t high, low;
-                       
+
                        if (this->current_bit == 0)
                        {
                                /* high of current byte in buffer has to be set to the new value*/
@@ -303,7 +303,7 @@ static void generate_u_int_type(private_generator_t *this,
                {
                        u_int8_t attribute_format_flag;
                        u_int16_t val;
-                       
+
                        /* attribute type must not change first bit of current byte */
                        if (this->current_bit != 1)
                        {
@@ -325,7 +325,7 @@ static void generate_u_int_type(private_generator_t *this,
                        write_bytes_to_buffer(this, &val, sizeof(u_int16_t));
                        this->current_bit = 0;
                        break;
-                       
+
                }
                case U_INT_16:
                case CONFIGURATION_ATTRIBUTE_LENGTH:
@@ -372,11 +372,11 @@ static void generate_reserved_field(private_generator_t *this, int bits)
                return ;
        }
        make_space_available(this, bits);
-       
+
        if (bits == 1)
        {
                u_int8_t reserved_bit = ~(1 << (7 - this->current_bit));
-               
+
                *(this->out_position) = *(this->out_position) & reserved_bit;
                if (this->current_bit == 0)
                {
@@ -410,11 +410,11 @@ static void generate_flag(private_generator_t *this, u_int32_t offset)
 {
        u_int8_t flag_value;
        u_int8_t flag;
-       
+
        flag_value = (*((bool *) (this->data_struct + offset))) ? 1 : 0;
        /* get flag position */
        flag = (flag_value << (7 - this->current_bit));
-       
+
        /* make sure one bit is available in buffer */
        make_space_available(this, 1);
        if (this->current_bit == 0)
@@ -422,10 +422,10 @@ static void generate_flag(private_generator_t *this, u_int32_t offset)
                /* memory must be zero */
                *(this->out_position) = 0x00;
        }
-       
+
        *(this->out_position) = *(this->out_position) | flag;
        DBG3(DBG_ENC, "   => %d", *this->out_position);
-       
+
        this->current_bit++;
        if (this->current_bit >= 8)
        {
@@ -440,16 +440,16 @@ static void generate_flag(private_generator_t *this, u_int32_t offset)
 static void generate_from_chunk(private_generator_t *this, u_int32_t offset)
 {
        chunk_t *value;
-       
+
        if (this->current_bit != 0)
        {
                DBG1(DBG_ENC, "can not generate a chunk at Bitpos %d", this->current_bit);
                return ;
        }
-       
+
        value = (chunk_t *)(this->data_struct + offset);
        DBG3(DBG_ENC, "   => %B", value);
-       
+
        write_bytes_to_buffer(this, value->ptr, value->len);
 }
 
@@ -460,7 +460,7 @@ static void write_to_chunk(private_generator_t *this,chunk_t *data)
 {
        int data_length = get_length(this);
        u_int32_t header_length_field = data_length;
-       
+
        /* write length into header length field */
        if (this->header_length_position_offset > 0)
        {
@@ -468,14 +468,14 @@ static void write_to_chunk(private_generator_t *this,chunk_t *data)
                write_bytes_to_buffer_at_offset(this, &val, sizeof(u_int32_t),
                                                                                this->header_length_position_offset);
        }
-       
+
        if (this->current_bit > 0)
        {
                data_length++;
        }
        *data = chunk_alloc(data_length);
        memcpy(data->ptr, this->buffer, data_length);
-       
+
        DBG3(DBG_ENC, "generated data of this generator %B", data);
 }
 
@@ -488,20 +488,20 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
        size_t rule_count;
        encoding_rule_t *rules;
        payload_type_t payload_type;
-       
+
        this->data_struct = payload;
        payload_type = payload->get_type(payload);
        /* spi size has to get reseted */
        this->last_spi_size = 0;
-       
+
        offset_start = this->out_position - this->buffer;
-       
+
        DBG2(DBG_ENC, "generating payload of type %N",
                 payload_type_names, payload_type);
-       
+
        /* each payload has its own encoding rules */
        payload->get_encoding_rules(payload, &rules, &rule_count);
-       
+
        for (i = 0; i < rule_count;i++)
        {
                DBG2(DBG_ENC, "  generating rule %d %N",
@@ -529,7 +529,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                        {
                                generate_reserved_field(this, 8);
                                break;
-                       } 
+                       }
                        case FLAG:
                        {
                                generate_flag(this, rules[i].offset);
@@ -578,7 +578,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                u_int16_t length_of_payload;
                                u_int16_t header_length = 0;
                                u_int16_t length_in_network_order;
-                               
+
                                switch(rules[i].type)
                                {
                                        case KEY_EXCHANGE_DATA:
@@ -619,13 +619,13 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                                break;
                                }
                                generate_from_chunk(this, rules[i].offset);
-                               
+
                                payload_length_position_offset =
                                                                        this->last_payload_length_position_offset;
-                               
-                               length_of_payload = header_length + 
+
+                               length_of_payload = header_length +
                                                ((chunk_t *)(this->data_struct + rules[i].offset))->len;
-                               
+
                                length_in_network_order = htons(length_of_payload);
                                write_bytes_to_buffer_at_offset(this, &length_in_network_order,
                                                        sizeof(u_int16_t), payload_length_position_offset);
@@ -633,7 +633,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                        }
                        case PROPOSALS:
                        {
-                               u_int32_t payload_length_position_offset = 
+                               u_int32_t payload_length_position_offset =
                                                                        this->last_payload_length_position_offset;
                                /* Length of SA_PAYLOAD is calculated */
                                u_int16_t length_of_sa_payload = SA_PAYLOAD_HEADER_LENGTH;
@@ -642,13 +642,13 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                                                                (this->data_struct + rules[i].offset));
                                iterator_t *iterator;
                                payload_t *current_proposal;
-                               
+
                                iterator = proposals->create_iterator(proposals,TRUE);
                                while (iterator->iterate(iterator, (void**)&current_proposal))
                                {
                                        u_int32_t before_generate_position_offset;
                                        u_int32_t after_generate_position_offset;
-                                       
+
                                        before_generate_position_offset = get_offset(this);
                                        generate_payload(this, current_proposal);
                                        after_generate_position_offset = get_offset(this);
@@ -656,7 +656,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                                                                         before_generate_position_offset);
                                }
                                iterator->destroy(iterator);
-                               
+
                                int16_val = htons(length_of_sa_payload);
                                write_bytes_to_buffer_at_offset(this, &int16_val,
                                                        sizeof(u_int16_t),payload_length_position_offset);
@@ -664,36 +664,36 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                        }
                        case TRANSFORMS:
                        {
-                               u_int32_t payload_length_position_offset = 
+                               u_int32_t payload_length_position_offset =
                                                                        this->last_payload_length_position_offset;
-                               u_int16_t length_of_proposal = 
+                               u_int16_t length_of_proposal =
                                        PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH + this->last_spi_size;
                                u_int16_t int16_val;
                                linked_list_t *transforms = *((linked_list_t **)
                                                                                (this->data_struct + rules[i].offset));
                                iterator_t *iterator;
                                payload_t *current_transform;
-                               
+
                                iterator = transforms->create_iterator(transforms,TRUE);
                                while (iterator->iterate(iterator, (void**)&current_transform))
                                {
                                        u_int32_t before_generate_position_offset;
                                        u_int32_t after_generate_position_offset;
-                                       
+
                                        before_generate_position_offset = get_offset(this);
                                        generate_payload(this, current_transform);
                                        after_generate_position_offset = get_offset(this);
-                                       
+
                                        length_of_proposal += (after_generate_position_offset -
                                                                                   before_generate_position_offset);
                                }
                                iterator->destroy(iterator);
-                               
+
                                int16_val = htons(length_of_proposal);
                                write_bytes_to_buffer_at_offset(this, &int16_val,
                                                        sizeof(u_int16_t), payload_length_position_offset);
                                break;
-                       }       
+                       }
                        case TRANSFORM_ATTRIBUTES:
                        {
                                u_int32_t transform_length_position_offset =
@@ -705,32 +705,32 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                                                        (this->data_struct + rules[i].offset));
                                iterator_t *iterator;
                                payload_t *current_attribute;
-                               
+
                                iterator = transform_attributes->create_iterator(
                                                                                                        transform_attributes, TRUE);
                                while (iterator->iterate(iterator, (void**)&current_attribute))
                                {
                                        u_int32_t before_generate_position_offset;
                                        u_int32_t after_generate_position_offset;
-                                       
+
                                        before_generate_position_offset = get_offset(this);
                                        generate_payload(this, current_attribute);
                                        after_generate_position_offset = get_offset(this);
-                                       
+
                                        length_of_transform += (after_generate_position_offset -
                                                                                        before_generate_position_offset);
                                }
-                               
+
                                iterator->destroy(iterator);
-                               
+
                                int16_val = htons(length_of_transform);
-                               write_bytes_to_buffer_at_offset(this, &int16_val, 
+                               write_bytes_to_buffer_at_offset(this, &int16_val,
                                                        sizeof(u_int16_t),transform_length_position_offset);
                                break;
                        }
                        case CONFIGURATION_ATTRIBUTES:
                        {
-                               u_int32_t configurations_length_position_offset = 
+                               u_int32_t configurations_length_position_offset =
                                                                        this->last_payload_length_position_offset;
                                u_int16_t length_of_configurations = CP_PAYLOAD_HEADER_LENGTH;
                                u_int16_t int16_val;
@@ -738,29 +738,29 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                                                                (this->data_struct + rules[i].offset));
                                iterator_t *iterator;
                                payload_t *current_attribute;
-                               
+
                                iterator = configuration_attributes->create_iterator(
                                                                                                configuration_attributes,TRUE);
                                while (iterator->iterate(iterator, (void**)&current_attribute))
                                {
                                        u_int32_t before_generate_position_offset;
                                        u_int32_t after_generate_position_offset;
-                                       
+
                                        before_generate_position_offset = get_offset(this);
                                        generate_payload(this, current_attribute);
                                        after_generate_position_offset = get_offset(this);
-                                       
+
                                        length_of_configurations += after_generate_position_offset -
                                                                                        before_generate_position_offset;
                                }
-                               
+
                                iterator->destroy(iterator);
-                               
+
                                int16_val = htons(length_of_configurations);
-                               write_bytes_to_buffer_at_offset(this, &int16_val, 
+                               write_bytes_to_buffer_at_offset(this, &int16_val,
                                         sizeof(u_int16_t),configurations_length_position_offset);
                                break;
-                       }       
+                       }
                        case ATTRIBUTE_FORMAT:
                        {
                                generate_flag(this, rules[i].offset);
@@ -768,7 +768,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                this->attribute_format =
                                                        *((bool *)(this->data_struct + rules[i].offset));
                                break;
-                       }       
+                       }
 
                        case ATTRIBUTE_LENGTH_OR_VALUE:
                        {
@@ -797,7 +797,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                        }
                        case TRAFFIC_SELECTORS:
                        {
-                               u_int32_t payload_length_position_offset = 
+                               u_int32_t payload_length_position_offset =
                                                                        this->last_payload_length_position_offset;
                                u_int16_t length_of_ts_payload = TS_PAYLOAD_HEADER_LENGTH;
                                u_int16_t int16_val;
@@ -805,29 +805,29 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
                                                                                (this->data_struct + rules[i].offset));
                                iterator_t *iterator;
                                payload_t *current_tss;
-                               
+
                                iterator = traffic_selectors->create_iterator(
                                                                                                        traffic_selectors,TRUE);
                                while (iterator->iterate(iterator, (void **)&current_tss))
                                {
                                        u_int32_t before_generate_position_offset;
                                        u_int32_t after_generate_position_offset;
-                                       
+
                                        before_generate_position_offset = get_offset(this);
                                        generate_payload(this, current_tss);
                                        after_generate_position_offset = get_offset(this);
-                                       
+
                                        length_of_ts_payload += (after_generate_position_offset -
                                                                                         before_generate_position_offset);
                                }
                                iterator->destroy(iterator);
-                               
+
                                int16_val = htons(length_of_ts_payload);
                                write_bytes_to_buffer_at_offset(this, &int16_val,
                                                        sizeof(u_int16_t),payload_length_position_offset);
                                break;
-                       }       
-                       
+                       }
+
                        case ENCRYPTED_DATA:
                        {
                                generate_from_chunk(this, rules[i].offset);
@@ -869,10 +869,10 @@ generator_t *generator_create()
        this->public.generate_payload = (void(*)(generator_t*, payload_t *))generate_payload;
        this->public.destroy = (void(*)(generator_t*)) destroy;
        this->public.write_to_chunk = (void (*) (generator_t *,chunk_t *))write_to_chunk;
-       
+
        /* allocate memory for buffer */
        this->buffer = malloc(GENERATOR_DATA_BUFFER_SIZE);
-       
+
        /* initiate private variables */
        this->out_position = this->buffer;
        this->roof_position = this->buffer + GENERATOR_DATA_BUFFER_SIZE;
@@ -880,7 +880,7 @@ generator_t *generator_create()
        this->current_bit = 0;
        this->last_payload_length_position_offset = 0;
        this->header_length_position_offset = 0;
-       
+
        return &(this->public);
 }
 
index f6fb8981cef546c90fb15dcc630ce0e9dd8e63e9..2221c84af18f5f2484534140fad1b351b92eebe7 100644 (file)
@@ -44,7 +44,7 @@ typedef struct generator_t generator_t;
  * A generator_t class used to generate IKEv2 payloads.
  *
  * After creation, multiple payloads can be generated with the generate_payload
- * method. The generated bytes are appended. After all payloads are added, 
+ * method. The generated bytes are appended. After all payloads are added,
  * the write_to_chunk method writes out all generated data since
  * the creation of the generator. After that, the generator must be destroyed.
  * The generater uses a set of encoding rules, which it can get from
@@ -52,7 +52,7 @@ typedef struct generator_t generator_t;
  * the payload and all substructures automatically.
  */
 struct generator_t {
-       
+
        /**
         * Generates a specific payload from given payload object.
         *
@@ -61,14 +61,14 @@ struct generator_t {
         * @param payload               interface payload_t implementing object
         */
        void (*generate_payload) (generator_t *this,payload_t *payload);
-       
+
        /**
         * Writes all generated data of the generator to a chunk.
         *
         * @param data          chunk to write the data to
         */
        void (*write_to_chunk) (generator_t *this,chunk_t *data);
-       
+
        /**
         * Destroys a generator_t object.
         */
@@ -77,7 +77,7 @@ struct generator_t {
 
 /**
  * Constructor to create a generator.
- * 
+ *
  * @return generator_t object.
  */
 generator_t *generator_create(void);
index ff82a57c7b6b5dd8f9a88e21ec9a689b8144f831..5fe840604758aeb7fedbc932e447612e12dbbf61 100644 (file)
@@ -56,7 +56,7 @@ struct payload_rule_t {
         * Payload type.
         */
         payload_type_t payload_type;
-        
+
         /**
          * Minimal occurence of this payload.
          */
@@ -66,12 +66,12 @@ struct payload_rule_t {
          * Max occurence of this payload.
          */
         size_t max_occurence;
-        
+
         /**
          * TRUE if payload must be encrypted
          */
         bool encrypted;
-        
+
         /**
          * If this payload occurs, the message rule is
          * fullfilled in any case. This applies e.g. to
@@ -91,7 +91,7 @@ struct payload_order_t {
         * payload type
         */
        payload_type_t type;
-       
+
        /**
         * notify type, if payload == NOTIFY
         */
@@ -111,7 +111,7 @@ struct message_rule_t {
         * Type of message.
         */
        exchange_type_t exchange_type;
-       
+
        /**
         * Is message a request or response.
         */
@@ -121,22 +121,22 @@ struct message_rule_t {
         * Message contains encrypted content.
         */
        bool encrypted_content;
-       
+
        /**
         * Number of payload rules which will follow
         */
        int payload_rule_count;
-        
+
        /**
         * Pointer to first payload rule
         */
        payload_rule_t *payload_rules;
-       
+
        /**
         * Number of payload order rules
         */
        int payload_order_count;
-       
+
        /**
         * payload ordering rules
         */
@@ -536,12 +536,12 @@ struct private_message_t {
         * Minor version of message.
         */
        u_int8_t major_version;
-       
+
        /**
         * Major version of message.
         */
        u_int8_t minor_version;
-       
+
        /**
         * First Payload in message.
         */
@@ -556,32 +556,32 @@ struct private_message_t {
         * TRUE if message is a request, FALSE if a reply.
         */
        bool is_request;
-       
+
        /**
         * Message ID of this message.
         */
        u_int32_t message_id;
-       
+
        /**
         * ID of assigned IKE_SA.
         */
        ike_sa_id_t *ike_sa_id;
-       
+
        /**
         * Assigned UDP packet, stores incoming packet or last generated one.
         */
        packet_t *packet;
-        
+
        /**
         * Linked List where payload data are stored in.
         */
        linked_list_t *payloads;
-       
+
         /**
          * Assigned parser to parse Header and Body of this message.
          */
        parser_t *parser;
-       
+
        /**
         * The message rule for this message instance
         */
@@ -594,7 +594,7 @@ struct private_message_t {
 static  status_t set_message_rule(private_message_t *this)
 {
        int i;
-               
+
        for (i = 0; i < (sizeof(message_rules) / sizeof(message_rule_t)); i++)
        {
                if ((this->exchange_type == message_rules[i].exchange_type) &&
@@ -615,7 +615,7 @@ static  status_t set_message_rule(private_message_t *this)
 static status_t get_payload_rule(private_message_t *this, payload_type_t payload_type, payload_rule_t **payload_rule)
 {
        int i;
-       
+
        for (i = 0; i < this->message_rule->payload_rule_count;i++)
        {
                if (this->message_rule->payload_rules[i].payload_type == payload_type)
@@ -624,7 +624,7 @@ static status_t get_payload_rule(private_message_t *this, payload_type_t payload
                        return SUCCESS;
                }
        }
-       
+
        *payload_rule = NULL;
        return NOT_FOUND;
 }
@@ -757,7 +757,7 @@ static exchange_type_t get_request (private_message_t *this)
 static bool is_encoded(private_message_t *this)
 {
        chunk_t data = this->packet->get_data(this->packet);
-       
+
        if (data.ptr == NULL)
        {
                return FALSE;
@@ -796,7 +796,7 @@ static void add_notify(private_message_t *this, bool flush, notify_type_t type,
 {
        notify_payload_t *notify;
        payload_t *payload;
-       
+
        if (flush)
        {
                while (this->payloads->remove_last(this->payloads,
@@ -858,7 +858,7 @@ static payload_t *get_payload(private_message_t *this, payload_type_t type)
 {
        payload_t *current, *found = NULL;
        enumerator_t *enumerator;
-       
+
        enumerator = create_payload_enumerator(this);
        while (enumerator->enumerate(enumerator, &current))
        {
@@ -880,7 +880,7 @@ static notify_payload_t* get_notify(private_message_t *this, notify_type_t type)
        enumerator_t *enumerator;
        notify_payload_t *notify = NULL;
        payload_t *payload;
-       
+
        enumerator = create_payload_enumerator(this);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -907,10 +907,10 @@ static char* get_string(private_message_t *this, char *buf, int len)
        payload_t *payload;
        int written;
        char *pos = buf;
-       
+
        memset(buf, 0, len);
        len--;
-       
+
        written = snprintf(pos, len, "%N %s %d [",
                                           exchange_type_names, this->exchange_type,
                                           this->is_request ? "request" : "response",
@@ -921,7 +921,7 @@ static char* get_string(private_message_t *this, char *buf, int len)
        }
        pos += written;
        len -= written;
-       
+
        enumerator = create_payload_enumerator(this);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -947,7 +947,7 @@ static char* get_string(private_message_t *this, char *buf, int len)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        /* remove last space */
        snprintf(pos, len, " ]");
        return buf;
@@ -961,7 +961,7 @@ static void order_payloads(private_message_t *this)
        linked_list_t *list;
        payload_t *payload;
        int i;
-       
+
        /* move to temp list */
        list = linked_list_create();
        while (this->payloads->remove_last(this->payloads,
@@ -975,7 +975,7 @@ static void order_payloads(private_message_t *this)
                enumerator_t *enumerator;
                notify_payload_t *notify;
                payload_order_t order = this->message_rule->payload_order[i];
-               
+
                /* ... find all payload ... */
                enumerator = list->create_enumerator(list);
                while (enumerator->enumerate(enumerator, &payload))
@@ -984,7 +984,7 @@ static void order_payloads(private_message_t *this)
                        if (payload->get_type(payload) == order.type)
                        {
                                notify = (notify_payload_t*)payload;
-                       
+
                                /**... and check notify for type. */
                                if (order.type != NOTIFY || order.notify == 0 ||
                                        order.notify == notify->get_notify_type(notify))
@@ -1017,24 +1017,24 @@ static status_t encrypt_payloads(private_message_t *this,
        encryption_payload_t *encryption_payload = NULL;
        status_t status;
        linked_list_t *all_payloads;
-       
+
        if (!this->message_rule->encrypted_content)
        {
                DBG2(DBG_ENC, "message doesn't have to be encrypted");
                /* message contains no content to encrypt */
                return SUCCESS;
        }
-       
+
        if (!crypter || !signer)
        {
                DBG2(DBG_ENC, "no crypter or signer specified, do not encrypt message");
                /* message contains no content to encrypt */
                return SUCCESS;
        }
-       
+
        DBG2(DBG_ENC, "copy all payloads to a temporary list");
        all_payloads = linked_list_create();
-       
+
        /* first copy all payloads in a temporary list */
        while (this->payloads->get_count(this->payloads) > 0)
        {
@@ -1042,7 +1042,7 @@ static status_t encrypt_payloads(private_message_t *this,
                this->payloads->remove_first(this->payloads,&current_payload);
                all_payloads->insert_last(all_payloads,current_payload);
        }
-       
+
        encryption_payload = encryption_payload_create();
 
        DBG2(DBG_ENC, "check each payloads if they have to get encrypted");
@@ -1051,9 +1051,9 @@ static status_t encrypt_payloads(private_message_t *this,
                payload_rule_t *payload_rule;
                payload_t *current_payload;
                bool to_encrypt = FALSE;
-               
+
                all_payloads->remove_first(all_payloads,(void **)&current_payload);
-               
+
                status = get_payload_rule(this,
                                        current_payload->get_type(current_payload),&payload_rule);
                /* for payload types which are not found in supported payload list,
@@ -1064,7 +1064,7 @@ static status_t encrypt_payloads(private_message_t *this,
                                 payload_type_names, current_payload->get_type(current_payload));
                        to_encrypt = TRUE;
                }
-               
+
                if (to_encrypt)
                {
                        DBG2(DBG_ENC, "insert payload %N to encryption payload",
@@ -1085,9 +1085,9 @@ static status_t encrypt_payloads(private_message_t *this,
        status = encryption_payload->encrypt(encryption_payload);
        DBG2(DBG_ENC, "add encrypted payload to payload list");
        add_payload(this, (payload_t*)encryption_payload);
-       
+
        all_payloads->destroy(all_payloads);
-       
+
        return status;
 }
 
@@ -1104,20 +1104,20 @@ static status_t generate(private_message_t *this, crypter_t *crypter,
        status_t status;
        chunk_t packet_data;
        char str[256];
-       
+
        if (is_encoded(this))
        {
                /* already generated, return a new packet clone */
                *packet = this->packet->clone(this->packet);
                return SUCCESS;
        }
-       
+
        if (this->exchange_type == EXCHANGE_TYPE_UNDEFINED)
        {
                DBG1(DBG_ENC, "exchange type is not defined");
                return INVALID_STATE;
        }
-       
+
        if (this->packet->get_source(this->packet) == NULL ||
                this->packet->get_destination(this->packet) == NULL)
        {
@@ -1125,7 +1125,7 @@ static status_t generate(private_message_t *this, crypter_t *crypter,
                         !this->packet->get_source(this->packet) ? "source" : "destination");
                return INVALID_STATE;
        }
-       
+
        /* set the rules for this messge */
        status = set_message_rule(this);
        if (status != SUCCESS)
@@ -1133,11 +1133,11 @@ static status_t generate(private_message_t *this, crypter_t *crypter,
                DBG1(DBG_ENC, "no message rules specified for this message type");
                return NOT_SUPPORTED;
        }
-       
+
        order_payloads(this);
-       
+
        DBG1(DBG_ENC, "generating %s", get_string(this, str, sizeof(str)));
-       
+
        /* going to encrypt all content which have to be encrypted */
        status = encrypt_payloads(this, crypter, signer);
        if (status != SUCCESS)
@@ -1145,21 +1145,21 @@ static status_t generate(private_message_t *this, crypter_t *crypter,
                DBG1(DBG_ENC, "payload encryption failed");
                return status;
        }
-       
+
        /* build ike header */
        ike_header = ike_header_create();
-       
+
        ike_header->set_exchange_type(ike_header, this->exchange_type);
        ike_header->set_message_id(ike_header, this->message_id);
        ike_header->set_response_flag(ike_header, !this->is_request);
        ike_header->set_initiator_flag(ike_header, this->ike_sa_id->is_initiator(this->ike_sa_id));
        ike_header->set_initiator_spi(ike_header, this->ike_sa_id->get_initiator_spi(this->ike_sa_id));
        ike_header->set_responder_spi(ike_header, this->ike_sa_id->get_responder_spi(this->ike_sa_id));
-       
+
        generator = generator_create();
-       
+
        payload = (payload_t*)ike_header;
-       
+
        /* generate every payload expect last one, this is done later*/
        enumerator = create_payload_enumerator(this);
        while (enumerator->enumerate(enumerator, &next_payload))
@@ -1169,18 +1169,18 @@ static status_t generate(private_message_t *this, crypter_t *crypter,
                payload = next_payload;
        }
        enumerator->destroy(enumerator);
-       
+
        /* last payload has no next payload*/
        payload->set_next_type(payload, NO_PAYLOAD);
 
        generator->generate_payload(generator, payload);
 
        ike_header->destroy(ike_header);
-               
+
        /* build packet */
        generator->write_to_chunk(generator, &packet_data);
        generator->destroy(generator);
-       
+
        /* if last payload is of type encrypted, integrity checksum if necessary */
        if (payload->get_type(payload) == ENCRYPTED)
        {
@@ -1192,12 +1192,12 @@ static status_t generate(private_message_t *this, crypter_t *crypter,
                        return status;
                }
        }
-       
+
        this->packet->set_data(this->packet, packet_data);
-       
+
        /* clone packet for caller */
        *packet = this->packet->clone(this->packet);
-       
+
        DBG2(DBG_ENC, "message generated successfully");
        return SUCCESS;
 }
@@ -1233,18 +1233,18 @@ static status_t parse_header(private_message_t *this)
 {
        ike_header_t *ike_header;
        status_t status;
-       
+
        DBG2(DBG_ENC, "parsing header of message");
-       
+
        this->parser->reset_context(this->parser);
        status = this->parser->parse_payload(this->parser,HEADER,(payload_t **) &ike_header);
        if (status != SUCCESS)
        {
                DBG1(DBG_ENC, "header could not be parsed");
                return status;
-               
+
        }
-       
+
        /* verify payload */
        status = ike_header->payload_interface.verify(&(ike_header->payload_interface));
        if (status != SUCCESS)
@@ -1253,12 +1253,12 @@ static status_t parse_header(private_message_t *this)
                ike_header->destroy(ike_header);
                return status;
        }
-       
+
        if (this->ike_sa_id != NULL)
        {
                this->ike_sa_id->destroy(this->ike_sa_id);
        }
-       
+
        this->ike_sa_id = ike_sa_id_create(ike_header->get_initiator_spi(ike_header),
                                                                           ike_header->get_responder_spi(ike_header),
                                                                           ike_header->get_initiator_flag(ike_header));
@@ -1269,12 +1269,12 @@ static status_t parse_header(private_message_t *this)
        this->major_version = ike_header->get_maj_version(ike_header);
        this->minor_version = ike_header->get_min_version(ike_header);
        this->first_payload = ike_header->payload_interface.get_next_type(&(ike_header->payload_interface));
-       
+
        DBG2(DBG_ENC, "parsed a %N %s", exchange_type_names, this->exchange_type,
                 this->is_request ? "request" : "response");
-       
+
        ike_header->destroy(ike_header);
-       
+
        /* get the rules for this messge */
        status = set_message_rule(this);
        if (status != SUCCESS)
@@ -1283,7 +1283,7 @@ static status_t parse_header(private_message_t *this)
                         exchange_type_names, this->exchange_type,
                         this->is_request ? "request" : "response");
        }
-       
+
        return status;
 }
 
@@ -1306,20 +1306,20 @@ static status_t decrypt_payloads(private_message_t *this,crypter_t *crypter, sig
        {
                payload_rule_t *payload_rule;
                payload_type_t current_payload_type;
-               
+
                /* needed to check */
                current_payload_type = current_payload->get_type(current_payload);
-               
+
                DBG2(DBG_ENC, "process payload of type %N",
                         payload_type_names, current_payload_type);
-               
+
                if (current_payload_type == ENCRYPTED)
                {
                        encryption_payload_t *encryption_payload;
                        payload_t *current_encrypted_payload;
-                       
+
                        encryption_payload = (encryption_payload_t*)current_payload;
-                       
+
                        DBG2(DBG_ENC, "found an encryption payload");
 
                        if (payload_number != this->payloads->get_count(this->payloads))
@@ -1348,10 +1348,10 @@ static status_t decrypt_payloads(private_message_t *this,crypter_t *crypter, sig
                                iterator->destroy(iterator);
                                return PARSE_ERROR;
                        }
-                       
+
                        /* needed later to find out if a payload was encrypted */
                        current_payload_was_encrypted = TRUE;
-                       
+
                        /* check if there are payloads contained in the encryption payload */
                        if (encryption_payload->get_payload_count(encryption_payload) == 0)
                        {
@@ -1368,7 +1368,7 @@ static status_t decrypt_payloads(private_message_t *this,crypter_t *crypter, sig
                                iterator->replace(iterator,NULL,(void *) current_encrypted_payload);
                                current_payload_type = current_encrypted_payload->get_type(current_encrypted_payload);
                        }
-                       
+
                        /* is the current paylad the first in the message? */
                        if (previous_payload == NULL)
                        {
@@ -1380,7 +1380,7 @@ static status_t decrypt_payloads(private_message_t *this,crypter_t *crypter, sig
                                /* no, set the next_type of the previous payload to the current type */
                                previous_payload->set_next_type(previous_payload, current_payload_type);
                        }
-                       
+
                        /* all encrypted payloads are added to the payload list */
                        while (encryption_payload->get_payload_count(encryption_payload) > 0)
                        {
@@ -1389,7 +1389,7 @@ static status_t decrypt_payloads(private_message_t *this,crypter_t *crypter, sig
                                         payload_type_names, current_encrypted_payload->get_type(current_encrypted_payload));
                                this->payloads->insert_last(this->payloads,current_encrypted_payload);
                        }
-                       
+
                        /* encryption payload is processed, payloads are moved. Destroy it. */
                        encryption_payload->destroy(encryption_payload);
                }
@@ -1407,7 +1407,7 @@ static status_t decrypt_payloads(private_message_t *this,crypter_t *crypter, sig
                                iterator->destroy(iterator);
                                return VERIFY_ERROR;
                        }
-                       
+
                        /* check if the payload was encrypted, and if it should been have encrypted */
                        if (payload_rule->encrypted != current_payload_was_encrypted)
                        {
@@ -1437,24 +1437,24 @@ static status_t verify(private_message_t *this)
        enumerator_t *enumerator;
        payload_t *current_payload;
        size_t total_found_payloads = 0;
-       
+
        DBG2(DBG_ENC, "verifying message structure");
-       
+
        /* check for payloads with wrong count*/
        for (i = 0; i < this->message_rule->payload_rule_count; i++)
        {
                size_t found_payloads = 0;
                payload_rule_t *rule;
-               
+
                rule = &this->message_rule->payload_rules[i];
                enumerator = create_payload_enumerator(this);
-               
+
                /* check all payloads for specific rule */
                while (enumerator->enumerate(enumerator, &current_payload))
                {
                        payload_type_t current_payload_type;
                        unknown_payload_t *unknown_payload;
-                       
+
                        current_payload_type = current_payload->get_type(current_payload);
                        if (current_payload_type == UNKNOWN_PAYLOAD)
                        {
@@ -1474,7 +1474,7 @@ static status_t verify(private_message_t *this)
                                total_found_payloads++;
                                DBG2(DBG_ENC, "found payload of type %N", payload_type_names,
                                         rule->payload_type);
-                               
+
                                /* as soon as ohe payload occures more then specified,
                                 * the verification fails */
                                if (found_payloads >
@@ -1489,7 +1489,7 @@ static status_t verify(private_message_t *this)
                                }
                        }
                }
-               
+
                if (found_payloads < rule->min_occurence)
                {
                        DBG1(DBG_ENC, "payload of type %N not occured %d times (%d)",
@@ -1517,9 +1517,9 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
        status_t status = SUCCESS;
        payload_type_t current_payload_type;
        char str[256];
-               
+
        current_payload_type = this->first_payload;
-               
+
        DBG2(DBG_ENC, "parsing body of message, first payload is %N",
                 payload_type_names, current_payload_type);
 
@@ -1527,13 +1527,13 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
        while ((current_payload_type != NO_PAYLOAD))
        {
                payload_t *current_payload;
-               
+
                DBG2(DBG_ENC, "starting parsing a %N payload",
                         payload_type_names, current_payload_type);
-               
+
                /* parse current payload */
                status = this->parser->parse_payload(this->parser,current_payload_type,(payload_t **) &current_payload);
-               
+
                if (status != SUCCESS)
                {
                        DBG1(DBG_ENC, "payload type %N could not be parsed",
@@ -1543,7 +1543,7 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
 
                DBG2(DBG_ENC, "verifying payload of type %N",
                         payload_type_names, current_payload_type);
-               
+
                /* verify it, stop parsig if its invalid */
                status = current_payload->verify(current_payload);
                if (status != SUCCESS)
@@ -1553,11 +1553,11 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
                        current_payload->destroy(current_payload);
                        return VERIFY_ERROR;
                }
-               
+
                DBG2(DBG_ENC, "%N payload verified. Adding to payload list",
                         payload_type_names, current_payload_type);
                this->payloads->insert_last(this->payloads,current_payload);
-               
+
                /* an encryption payload is the last one, so STOP here. decryption is done later */
                if (current_payload_type == ENCRYPTED)
                {
@@ -1565,7 +1565,7 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
                                 payload_type_names, current_payload_type);
                        break;
                }
-               
+
                /* get next payload type */
                current_payload_type = current_payload->get_next_type(current_payload);
        }
@@ -1579,15 +1579,15 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
                        return status;
                }
        }
-       
+
        status = verify(this);
        if (status != SUCCESS)
        {
                return status;
        }
-       
+
        DBG1(DBG_ENC, "parsed %s", get_string(this, str, sizeof(str)));
-       
+
        return SUCCESS;
 }
 
@@ -1641,14 +1641,14 @@ message_t *message_create_from_packet(packet_t *packet)
        this->public.get_packet = (packet_t * (*) (message_t*)) get_packet;
        this->public.get_packet_data = (chunk_t (*) (message_t *this)) get_packet_data;
        this->public.destroy = (void(*)(message_t*))destroy;
-               
+
        /* private values */
        this->exchange_type = EXCHANGE_TYPE_UNDEFINED;
        this->is_request = TRUE;
        this->ike_sa_id = NULL;
        this->first_payload = NO_PAYLOAD;
        this->message_id = 0;
-       
+
        /* private values */
        if (packet == NULL)
        {
@@ -1657,10 +1657,10 @@ message_t *message_create_from_packet(packet_t *packet)
        this->message_rule = NULL;
        this->packet = packet;
        this->payloads = linked_list_create();
-       
+
        /* parser is created from data of packet */
        this->parser = parser_create(this->packet->get_data(this->packet));
-       
+
        return (&this->public);
 }
 
index 1db3ea0cc5b899955205ce3c4d0d1bf3b29e3242..2c7718f49d212fc8795b7103579f0f707b50ce47 100644 (file)
@@ -58,7 +58,7 @@ struct message_t {
         * @return                              major version of the message
         */
        u_int8_t (*get_major_version) (message_t *this);
-       
+
        /**
         * Sets the IKE minor version of the message.
         *
@@ -86,7 +86,7 @@ struct message_t {
         * @return                              message_id type of the message
         */
        u_int32_t (*get_message_id) (message_t *this);
-       
+
        /**
         * Gets the initiator SPI of the message.
         *
@@ -103,7 +103,7 @@ struct message_t {
 
        /**
         * Sets the IKE_SA ID of the message.
-        * 
+        *
         * ike_sa_id gets cloned.
         *
         * @param ike_sa_id             ike_sa_id to set
@@ -132,10 +132,10 @@ struct message_t {
         * @return                              exchange type of the message
         */
        exchange_type_t (*get_exchange_type) (message_t *this);
-       
+
        /**
         * Gets the payload type of the first payload.
-        * 
+        *
         * @return                              payload type of the first payload
         */
        payload_type_t (*get_first_payload_type) (message_t *this);
@@ -156,20 +156,20 @@ struct message_t {
 
        /**
         * Append a payload to the message.
-        * 
+        *
         * If the payload must be encrypted is not specified here. Encryption
         * of payloads is evaluated via internal rules for the messages and
         * is done before generation. The order of payloads may change, since
-        * all payloads to encrypt are added to the encryption payload, which is 
+        * all payloads to encrypt are added to the encryption payload, which is
         * always the last one.
         *
         * @param payload               payload to append
-        */     
+        */
        void (*add_payload) (message_t *this, payload_t *payload);
 
        /**
         * Build a notify payload and add it to the message.
-        * 
+        *
         * This is a helper method to create notify messages or add
         * notify payload to messages. The flush parameter specifies if existing
         * payloads should get removed before appending the notify.
@@ -177,13 +177,13 @@ struct message_t {
         * @param flush                 TRUE to remove existing payloads
         * @param type                  type of the notify
         * @param data                  a chunk of data to add to the notify, gets cloned
-        */     
-       void (*add_notify) (message_t *this, bool flush, notify_type_t type, 
+        */
+       void (*add_notify) (message_t *this, bool flush, notify_type_t type,
                                                chunk_t data);
 
        /**
         * Parses header of message.
-        * 
+        *
         * Begins parisng of a message created via message_create_from_packet().
         * The parsing context is stored, so a subsequent call to parse_body()
         * will continue the parsing process.
@@ -194,17 +194,17 @@ struct message_t {
         *                                      - FAILED if consistence check of header failed
         */
        status_t (*parse_header) (message_t *this);
-       
+
        /**
         * Parses body of message.
-        * 
-        * The body gets not only parsed, but rather it gets verified. 
-        * All payloads are verified if they are allowed to exist in the message 
-        * of this type and if their own structure is ok. 
-        * If there are encrypted payloads, they get decrypted via the supplied 
+        *
+        * The body gets not only parsed, but rather it gets verified.
+        * All payloads are verified if they are allowed to exist in the message
+        * of this type and if their own structure is ok.
+        * If there are encrypted payloads, they get decrypted via the supplied
         * crypter. Also the message integrity gets verified with the supplied
         * signer.
-        * Crypter/signer can be omitted (by passing NULL) when no encryption 
+        * Crypter/signer can be omitted (by passing NULL) when no encryption
         * payload is expected.
         *
         * @param crypter       crypter to decrypt encryption payloads
@@ -222,13 +222,13 @@ struct message_t {
 
        /**
         * Generates the UDP packet of specific message.
-        * 
+        *
         * Payloads which must be encrypted are generated first and added to
-        * an encryption payload. This encryption payload will get encrypted via 
+        * an encryption payload. This encryption payload will get encrypted via
         * the supplied crypter. Then all other payloads and the header get generated.
-        * After that, the checksum is added to the encryption payload over the full 
+        * After that, the checksum is added to the encryption payload over the full
         * message.
-        * Crypter/signer can be omitted (by passing NULL) when no encryption 
+        * Crypter/signer can be omitted (by passing NULL) when no encryption
         * payload is expected.
         * Generation is only done once, multiple calls will just return a packet copy.
         *
@@ -240,66 +240,66 @@ struct message_t {
         *                                      - INVALID_STATE if exchange type is currently not set
         *                                      - NOT_FOUND if no rules found for message generation
         *                                      - INVALID_STATE if crypter/signer not supplied but needed.
-        */     
+        */
        status_t (*generate) (message_t *this, crypter_t *crypter, signer_t *signer, packet_t **packet);
 
        /**
-        * Gets the source host informations. 
-        * 
-        * @warning Returned host_t object is not getting cloned, 
+        * Gets the source host informations.
+        *
+        * @warning Returned host_t object is not getting cloned,
         * do not destroy nor modify.
         *
         * @return                      host_t object representing source host
-        */     
+        */
        host_t * (*get_source) (message_t *this);
-       
+
        /**
-        * Sets the source host informations. 
-        * 
+        * Sets the source host informations.
+        *
         * @warning host_t object is not getting cloned and gets destroyed by
         *                      message_t.destroy or next call of message_t.set_source.
         *
         * @param host          host_t object representing source host
-        */     
+        */
        void (*set_source) (message_t *this, host_t *host);
 
        /**
-        * Gets the destination host informations. 
-        * 
-        * @warning Returned host_t object is not getting cloned, 
+        * Gets the destination host informations.
+        *
+        * @warning Returned host_t object is not getting cloned,
         * do not destroy nor modify.
         *
         * @return                      host_t object representing destination host
-        */     
+        */
        host_t * (*get_destination) (message_t *this);
 
        /**
-        * Sets the destination host informations. 
-        * 
+        * Sets the destination host informations.
+        *
         * @warning host_t object is not getting cloned and gets destroyed by
         *                      message_t.destroy or next call of message_t.set_destination.
         *
         * @param host          host_t object representing destination host
-        */     
+        */
        void (*set_destination) (message_t *this, host_t *host);
-       
+
        /**
         * Create an enumerator over all payloads.
         *
         * @return                      enumerator over payload_t
-        */     
+        */
        enumerator_t * (*create_payload_enumerator) (message_t *this);
-       
+
        /**
         * Find a payload of a specific type.
-        * 
-        * Returns the first occurance. 
+        *
+        * Returns the first occurance.
         *
         * @param type          type of the payload to find
         * @return                      payload, or NULL if no such payload found
-        */     
+        */
        payload_t* (*get_payload) (message_t *this, payload_type_t type);
-       
+
        /**
         * Get the first notify payload of a specific type.
         *
@@ -307,21 +307,21 @@ struct message_t {
         * @return                      notify payload, NULL if no such notify found
         */
        notify_payload_t* (*get_notify)(message_t *this, notify_type_t type);
-       
+
        /**
         * Returns a clone of the internal stored packet_t object.
         *
         * @return                      packet_t object as clone of internal one
-        */     
+        */
        packet_t * (*get_packet) (message_t *this);
-       
+
        /**
         * Returns a clone of the internal stored packet_t data.
         *
         * @return                      clone of the internal stored packet_t data.
-        */     
+        */
        chunk_t (*get_packet_data) (message_t *this);
-       
+
        /**
         * Destroys a message and all including objects.
         */
@@ -330,16 +330,16 @@ struct message_t {
 
 /**
  * Creates an message_t object from a incoming UDP Packet.
- * 
- * @warning the given packet_t object is not copied and gets 
+ *
+ * @warning the given packet_t object is not copied and gets
  *                     destroyed in message_t's destroy call.
- * 
+ *
  * - exchange_type is set to NOT_SET
  * - original_initiator is set to TRUE
  * - is_request is set to TRUE
  * Call message_t.parse_header afterwards.
- * 
- * @param packet               packet_t object which is assigned to message    
+ *
+ * @param packet               packet_t object which is assigned to message
  * @return                             message_t object
  */
 message_t * message_create_from_packet(packet_t *packet);
@@ -351,7 +351,7 @@ message_t * message_create_from_packet(packet_t *packet);
  * - exchange_type is set to NOT_SET
  * - original_initiator is set to TRUE
  * - is_request is set to TRUE
- * 
+ *
  * @return message_t object
  */
 message_t * message_create(void);
index ac2b78c286177a5205d6560b3efee0903c457b0c..9aa34b1bc86c4a94d84c014a684932622abe77c3 100644 (file)
@@ -50,7 +50,7 @@ typedef struct private_parser_t private_parser_t;
 
 /**
  * Private data stored in a context.
- * 
+ *
  * Contains pointers and counters to store current state.
  */
 struct private_parser_t {
@@ -58,27 +58,27 @@ struct private_parser_t {
         * Public members, see parser_t.
         */
        parser_t public;
-       
+
        /**
         * Current bit for reading in input data.
         */
        u_int8_t bit_pos;
-       
+
        /**
         * Current byte for reading in input data.
         */
        u_int8_t *byte_pos;
-       
+
        /**
         * Input data to parse.
         */
        u_int8_t *input;
-       
+
        /**
         * Roof of input, used for length-checking.
         */
        u_int8_t *input_roof;
-       
+
        /**
         * Set of encoding rules for this parsing session.
         */
@@ -277,11 +277,11 @@ static bool parse_bit(private_parser_t *this, int rule_number,
                return short_input(this, rule_number);
        }
        if (output_pos)
-       {       
+       {
                u_int8_t mask;
                mask = 0x01 << (7 - this->bit_pos);
                *output_pos = *this->byte_pos & mask;
-               
+
                if (*output_pos)
                {       /* set to a "clean", comparable true */
                        *output_pos = TRUE;
@@ -303,7 +303,7 @@ static bool parse_list(private_parser_t *this, int rule_number,
                        linked_list_t **output_pos, payload_type_t payload_type, int length)
 {
        linked_list_t *list = *output_pos;
-       
+
        if (length < 0)
        {
                return short_input(this, rule_number);
@@ -316,10 +316,10 @@ static bool parse_list(private_parser_t *this, int rule_number,
        {
                u_int8_t *pos_before = this->byte_pos;
                payload_t *payload;
-               
+
                DBG2(DBG_ENC, "  %d bytes left, parsing recursively %N",
                         length, payload_type_names, payload_type);
-               
+
                if (parse_payload(this, payload_type, &payload) != SUCCESS)
                {
                        DBG1(DBG_ENC, "  parsing of a %N substructure failed",
@@ -377,25 +377,25 @@ static status_t parse_payload(private_parser_t *this,
        bool attribute_format = FALSE;
        int rule_number;
        encoding_rule_t *rule;
-       
+
        /* create instance of the payload to parse */
        pld = payload_create(payload_type);
-       
+
        DBG2(DBG_ENC, "parsing %N payload, %d bytes left",
                 payload_type_names, payload_type, this->input_roof - this->byte_pos);
-       
+
        DBG3(DBG_ENC, "parsing payload from %b",
                 this->byte_pos, this->input_roof - this->byte_pos);
-       
+
        if (pld->get_type(pld) == UNKNOWN_PAYLOAD)
        {
                DBG1(DBG_ENC, "  payload type %d is unknown, handling as %N",
                         payload_type, payload_type_names, UNKNOWN_PAYLOAD);
        }
-       
+
        /* base pointer for output, avoids casting in every rule */
        output = pld;
-       
+
        /* parse the payload with its own rulse */
        pld->get_encoding_rules(pld, &this->rules, &rule_count);
        for (rule_number = 0; rule_number < rule_count; rule_number++)
@@ -765,7 +765,7 @@ static status_t parse_payload(private_parser_t *this,
                        case ADDRESS:
                        {
                                int address_length = (ts_type == TS_IPV4_ADDR_RANGE) ? 4 : 16;
-                               
+
                                if (!parse_chunk(this, rule_number, output + rule->offset,
                                                                 address_length))
                                {
@@ -808,7 +808,7 @@ static status_t parse_payload(private_parser_t *this,
                /* process next rulue */
                rule++;
        }
-       
+
        *payload = pld;
        DBG2(DBG_ENC, "parsing %N payload finished",
                 payload_type_names, payload_type);
@@ -846,17 +846,17 @@ static void destroy(private_parser_t *this)
 parser_t *parser_create(chunk_t data)
 {
        private_parser_t *this = malloc_thing(private_parser_t);
-       
+
        this->public.parse_payload = (status_t(*)(parser_t*,payload_type_t,payload_t**))parse_payload;
        this->public.reset_context = (void(*)(parser_t*)) reset_context;
        this->public.get_remaining_byte_count = (int (*) (parser_t *))get_remaining_byte_count;
        this->public.destroy = (void(*)(parser_t*)) destroy;
-       
+
        this->input = data.ptr;
        this->byte_pos = data.ptr;
        this->bit_pos = 0;
        this->input_roof = data.ptr + data.len;
-       
+
        return &this->public;
 }
 
index 23049243846d05ccf73815e07f7cbf23dc7cf5ae..27c5f03fed254decbd72babf3cd9aec1f68619c1 100644 (file)
@@ -36,32 +36,32 @@ typedef struct parser_t parser_t;
  * The parser remains the state until destroyed.
  */
 struct parser_t {
-       
+
        /**
         * Parses the next payload.
-        * 
+        *
         * @warning Caller is responsible for freeing allocated payload.
-        * 
+        *
         * Rules for parsing are described in the payload definition.
         *
         * @param payload_type  payload type to parse
         * @param payload               pointer where parsed payload was allocated
-        * @return                      
+        * @return
         *                                              - SUCCESSFUL if succeeded,
         *                                              - PARSE_ERROR if corrupted/invalid data found
         */
        status_t (*parse_payload) (parser_t *this, payload_type_t payload_type, payload_t **payload);
-       
+
        /**
         * Gets the remaining byte count which is not currently parsed.
         */
        int (*get_remaining_byte_count) (parser_t *this);
-       
+
        /**
         * Resets the current parser context.
         */
        void (*reset_context) (parser_t *this);
-       
+
        /**
         * Destroys a parser_t object.
         */
@@ -70,7 +70,7 @@ struct parser_t {
 
 /**
  * Constructor to create a parser_t object.
- * 
+ *
  * @param data         chunk of data to parse with this parser_t object
  * @return                     parser_t object
  */
index 53406f564f9eed0a1922b46f952d125db7a6d863..308af9bda50baaec383dfb648f2e68f6e072e3d8 100644 (file)
@@ -23,15 +23,15 @@ typedef struct private_auth_payload_t private_auth_payload_t;
 
 /**
  * Private data of an auth_payload_t object.
- * 
+ *
  */
 struct private_auth_payload_t {
-       
+
        /**
         * Public auth_payload_t interface.
         */
        auth_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -41,17 +41,17 @@ struct private_auth_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Method of the AUTH Data.
         */
        u_int8_t auth_method;
-       
+
        /**
         * The contained auth data value.
         */
@@ -60,8 +60,8 @@ struct private_auth_payload_t {
 
 /**
  * Encoding rules to parse or generate a AUTH payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_auth_payload_t.
  */
 encoding_rule_t auth_payload_encodings[] = {
@@ -221,8 +221,8 @@ static void destroy(private_auth_payload_t *this)
        {
                chunk_free(&(this->auth_data));
        }
-       
-       free(this);     
+
+       free(this);
 }
 
 /*
@@ -240,7 +240,7 @@ auth_payload_t *auth_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (auth_payload_t *)) destroy;
        this->public.set_auth_method = (void (*) (auth_payload_t *,auth_method_t)) set_auth_method;
@@ -248,7 +248,7 @@ auth_payload_t *auth_payload_create()
        this->public.set_data = (void (*) (auth_payload_t *,chunk_t)) set_data;
        this->public.get_data_clone = (chunk_t (*) (auth_payload_t *)) get_data_clone;
        this->public.get_data = (chunk_t (*) (auth_payload_t *)) get_data;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
index 4287f14d9b10f74439010e40970e4224e17d0b49..37ee149db58f376ee3a3dbadf63220dfd4ce48d1 100644 (file)
@@ -39,7 +39,7 @@ typedef struct auth_payload_t auth_payload_t;
  * The AUTH payload format is described in RFC section 3.8.
  */
 struct auth_payload_t {
-       
+
        /**
         * The payload_t interface.
         */
@@ -51,41 +51,41 @@ struct auth_payload_t {
         * @param method                auth_method_t to use
         */
        void (*set_auth_method) (auth_payload_t *this, auth_method_t method);
-       
+
        /**
         * Get the AUTH method.
         *
         * @return                              auth_method_t used
         */
        auth_method_t (*get_auth_method) (auth_payload_t *this);
-       
+
        /**
         * Set the AUTH data.
-        * 
+        *
         * Data gets cloned.
         *
         * @param data                  AUTH data as chunk_t
         */
        void (*set_data) (auth_payload_t *this, chunk_t data);
-       
+
        /**
         * Get the AUTH data.
-        * 
+        *
         * Returned data are a copy of the internal one.
         *
         * @return                              AUTH data as chunk_t
         */
        chunk_t (*get_data_clone) (auth_payload_t *this);
-       
+
        /**
         * Get the AUTH data.
-        * 
+        *
         * Returned data are NOT copied
         *
         * @return                              AUTH data as chunk_t
         */
        chunk_t (*get_data) (auth_payload_t *this);
-       
+
        /**
         * Destroys an auth_payload_t object.
         */
@@ -94,7 +94,7 @@ struct auth_payload_t {
 
 /**
  * Creates an empty auth_payload_t object.
- * 
+ *
  * @return auth_payload_t object
  */
 auth_payload_t *auth_payload_create(void);
index 54a8c1392c57d6b7bb733af3c1dff1912d66fff1..36a3bfb6b5f4426201c4f7dfe764de787e7ee1a8 100644 (file)
@@ -43,14 +43,14 @@ typedef struct private_cert_payload_t private_cert_payload_t;
 
 /**
  * Private data of an cert_payload_t object.
- * 
+ *
  */
 struct private_cert_payload_t {
        /**
         * Public cert_payload_t interface.
         */
        cert_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -60,22 +60,22 @@ struct private_cert_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Encoding of the CERT Data.
         */
        u_int8_t encoding;
-       
+
        /**
         * The contained cert data value.
         */
        chunk_t data;
-       
+
        /**
         * TRUE if the "Hash and URL" data is invalid
         */
@@ -84,10 +84,10 @@ struct private_cert_payload_t {
 
 /**
  * Encoding rules to parse or generate a CERT payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_cert_payload_t.
- * 
+ *
  */
 encoding_rule_t cert_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -139,7 +139,7 @@ static status_t verify(private_cert_payload_t *this)
                        this->invalid_hash_and_url = TRUE;
                        return SUCCESS;
                }
-               
+
                int i = 20; /* skipping the hash */
                for (; i < this->data.len; ++i)
                {
@@ -156,7 +156,7 @@ static status_t verify(private_cert_payload_t *this)
                                return SUCCESS;
                        }
                }
-               
+
                /* URL is not null terminated, correct that */
                chunk_t data = chunk_alloc(this->data.len + 1);
                memcpy(data.ptr, this->data.ptr, this->data.len);
@@ -268,7 +268,7 @@ static char *get_url(private_cert_payload_t *this)
 static void destroy(private_cert_payload_t *this)
 {
        chunk_free(&this->data);
-       free(this);     
+       free(this);
 }
 
 /*
@@ -285,13 +285,13 @@ cert_payload_t *cert_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t*,payload_type_t))set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t*))get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t*))destroy;
-       
+
        this->public.destroy = (void (*) (cert_payload_t*))destroy;
        this->public.get_cert = (certificate_t* (*) (cert_payload_t*))get_cert;
        this->public.get_cert_encoding = (cert_encoding_t (*) (cert_payload_t*))get_cert_encoding;
        this->public.get_hash = (chunk_t (*) (cert_payload_t*))get_hash;
        this->public.get_url = (char* (*) (cert_payload_t*))get_url;
-       
+
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
        this->payload_length = CERT_PAYLOAD_HEADER_LENGTH;
@@ -332,12 +332,12 @@ cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url)
 {
        private_cert_payload_t *this = (private_cert_payload_t*)cert_payload_create();
        chunk_t url_chunk;
-       
+
        this->encoding = ENC_X509_HASH_AND_URL;
-       
+
        url_chunk.ptr = url;
        url_chunk.len = strlen(url) + 1;
-       
+
        this->data = chunk_cat("cc", hash, url_chunk);
        this->payload_length = CERT_PAYLOAD_HEADER_LENGTH + this->data.len;
        return &this->public;
index fba404ee275f37f789393f9e0eb209b2af6d75a0..aa1c7bf5aa7f9e2fecdc1d237cf5346aadc78b7d 100644 (file)
@@ -65,45 +65,45 @@ extern enum_name_t *cert_encoding_names;
  * The CERT payload format is described in RFC section 3.6.
  */
 struct cert_payload_t {
-       
+
        /**
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Get the playoads encoded certifcate.
         *
         * @return                              certifcate copy
         */
        certificate_t *(*get_cert)(cert_payload_t *this);
-       
+
        /**
         * Get the encoding of the certificate.
-        * 
+        *
         * @return                              encoding
         */
        cert_encoding_t (*get_cert_encoding)(cert_payload_t *this);
-       
+
        /**
         * Get the hash if this is a hash and URL encoded certificate.
-        * 
+        *
         * This function returns internal data, do not free.
-        * 
+        *
         * @return                              hash
         */
        chunk_t (*get_hash)(cert_payload_t *this);
-       
+
        /**
         * Get the URL if this is a hash and URL encoded certificate.
-        * 
+        *
         * This function returns internal data, do not free.
-        * 
+        *
         * @return                              url
         */
        char *(*get_url)(cert_payload_t *this);
-       
-       
+
+
        /**
         * Destroys the cert_payload object.
         */
@@ -112,14 +112,14 @@ struct cert_payload_t {
 
 /**
  * Creates an empty certificate payload.
- * 
+ *
  * @return                                     cert_payload_t object
  */
 cert_payload_t *cert_payload_create(void);
 
 /**
  * Creates a certificate payload with an embedded certificate.
- * 
+ *
  * @param cert                         certificate to embed
  * @return                                     cert_payload_t object
  */
@@ -127,7 +127,7 @@ cert_payload_t *cert_payload_create_from_cert(certificate_t *cert);
 
 /**
  * Creates a certificate payload with hash and URL encoding of a certificate.
- * 
+ *
  * @param hash                         hash of the DER encoded certificate (get's cloned)
  * @param url                          the URL to locate the certificate (get's cloned)
  * @return                                     cert_payload_t object
index 50adedb283b50cd8e1ed62af1cae8d9e3da40953..9ff0bdde0af465666016d343f95958d1b51c33af 100644 (file)
@@ -27,14 +27,14 @@ typedef struct private_certreq_payload_t private_certreq_payload_t;
 
 /**
  * Private data of an certreq_payload_t object.
- * 
+ *
  */
 struct private_certreq_payload_t {
        /**
         * Public certreq_payload_t interface.
         */
        certreq_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -44,17 +44,17 @@ struct private_certreq_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Encoding of the CERT Data.
         */
        u_int8_t encoding;
-       
+
        /**
         * The contained certreq data value.
         */
@@ -63,10 +63,10 @@ struct private_certreq_payload_t {
 
 /**
  * Encoding rules to parse or generate a CERTREQ payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_certreq_payload_t.
- * 
+ *
  */
 encoding_rule_t certreq_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -160,7 +160,7 @@ static size_t get_length(private_certreq_payload_t *this)
 {
        return this->payload_length;
 }
-       
+
 /**
  * Implementation of certreq_payload_t.add_keyid.
  */
@@ -240,7 +240,7 @@ static certificate_type_t get_cert_type(private_certreq_payload_t *this)
 static void destroy(private_certreq_payload_t *this)
 {
        chunk_free(&this->data);
-       free(this);     
+       free(this);
 }
 
 /*
@@ -258,13 +258,13 @@ certreq_payload_t *certreq_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t*,payload_type_t))set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t*))get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t*))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (certreq_payload_t*)) destroy;
        this->public.create_keyid_enumerator = (enumerator_t*(*)(certreq_payload_t*))create_keyid_enumerator;
                this->public.get_cert_type = (certificate_type_t(*)(certreq_payload_t*))get_cert_type;
        this->public.add_keyid = (void(*)(certreq_payload_t*, chunk_t keyid))add_keyid;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
@@ -281,7 +281,7 @@ certreq_payload_t *certreq_payload_create()
 certreq_payload_t *certreq_payload_create_type(certificate_type_t type)
 {
        private_certreq_payload_t *this = (private_certreq_payload_t*)certreq_payload_create();
-       
+
        switch (type)
        {
                case CERT_X509:
index ff9814f8ac128138f183484339015368b4b5dced..914063628fdbd2971c36c4bf15a413bc9d5d28a8 100644 (file)
@@ -50,14 +50,14 @@ struct certreq_payload_t {
         * @return                      enumerator over chunk_t's.
         */
        enumerator_t* (*create_keyid_enumerator)(certreq_payload_t *this);
-       
+
        /**
         * Get the type of contained certificate keyids.
         *
         * @return                      certificate keyid type
         */
        certificate_type_t (*get_cert_type)(certreq_payload_t *this);
-       
+
        /**
         * Add a certificates keyid to the payload.
         *
@@ -65,7 +65,7 @@ struct certreq_payload_t {
         * @return
         */
        void (*add_keyid)(certreq_payload_t *this, chunk_t keyid);
-       
+
        /**
         * Destroys an certreq_payload_t object.
         */
@@ -74,14 +74,14 @@ struct certreq_payload_t {
 
 /**
  * Creates an empty certreq_payload_t object.
- * 
+ *
  * @return                             certreq payload
  */
 certreq_payload_t *certreq_payload_create(void);
 
 /**
  * Creates an empty certreq_payload_t for a kind of certificates.
- * 
+ *
  * @param type                 type of the added keyids
  * @return                             certreq payload
  */
index 674feedddf7e3c305f8dec331ae5910f46c4afeb..fb433666323ce0b4cdf46c1f6c533661150f057c 100644 (file)
@@ -27,19 +27,19 @@ typedef struct private_configuration_attribute_t private_configuration_attribute
 
 /**
  * Private data of an configuration_attribute_t object.
- * 
+ *
  */
 struct private_configuration_attribute_t {
        /**
         * Public configuration_attribute_t interface.
         */
        configuration_attribute_t public;
-       
+
        /**
         * Type of the attribute.
         */
        u_int16_t attribute_type;
-       
+
        /**
         * Length of the attribute.
         */
@@ -74,16 +74,16 @@ ENUM_END(configuration_attribute_type_names, INTERNAL_IP6_SERVER);
 
 /**
  * Encoding rules to parse or generate a configuration attribute.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_configuration_attribute_t.
- * 
+ *
  */
 encoding_rule_t configuration_attribute_encodings[] = {
 
        { RESERVED_BIT, 0                                                                                                                                                                       },
        /* type of the attribute as 15 bit unsigned integer */
-       { ATTRIBUTE_TYPE,                       offsetof(private_configuration_attribute_t, attribute_type)                             },      
+       { ATTRIBUTE_TYPE,                       offsetof(private_configuration_attribute_t, attribute_type)                             },
        /* Length of attribute value */
        { CONFIGURATION_ATTRIBUTE_LENGTH,               offsetof(private_configuration_attribute_t, attribute_length)},
        /* Value of attribute if attribute format flag is zero */
@@ -159,11 +159,11 @@ static status_t verify(private_configuration_attribute_t *this)
                        /* any length acceptable */
                        break;
                 default:
-                       DBG1(DBG_ENC, "unknown attribute type %N", 
+                       DBG1(DBG_ENC, "unknown attribute type %N",
                                 configuration_attribute_type_names, this->attribute_type);
                        break;
        }
-       
+
        if (failed)
        {
                DBG1(DBG_ENC, "invalid attribute length %d for %N",
@@ -222,12 +222,12 @@ static void set_value(private_configuration_attribute_t *this, chunk_t value)
        if (this->attribute_value.ptr != NULL)
        {
                /* free existing value */
-               chunk_free(&(this->attribute_value));           
+               chunk_free(&(this->attribute_value));
        }
-       
+
        this->attribute_value.ptr = clalloc(value.ptr,value.len);
        this->attribute_value.len = value.len;
-       
+
        this->attribute_length = this->attribute_value.len;
 }
 
@@ -272,7 +272,7 @@ static void destroy(private_configuration_attribute_t *this)
        if (this->attribute_value.ptr != NULL)
        {
                free(this->attribute_value.ptr);
-       }       
+       }
        free(this);
 }
 
@@ -291,7 +291,7 @@ configuration_attribute_t *configuration_attribute_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.set_value = (void (*) (configuration_attribute_t *,chunk_t)) set_value;
        this->public.get_value = (chunk_t (*) (configuration_attribute_t *)) get_value;
@@ -299,7 +299,7 @@ configuration_attribute_t *configuration_attribute_create()
        this->public.get_type = (u_int16_t (*) (configuration_attribute_t *)) get_attribute_type;
        this->public.get_length = (u_int16_t (*) (configuration_attribute_t *)) get_attribute_length;
        this->public.destroy = (void (*) (configuration_attribute_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->attribute_type = 0;
        this->attribute_value = chunk_empty;
index 40413011427e88f331d6181b86ae73bbd82ed90a..376fb4be62725d82b6fccae52ee1ec291a7379d3 100644 (file)
@@ -57,14 +57,14 @@ enum configuration_attribute_type_t {
        INTERNAL_IP6_SERVER = 23457
 };
 
-/** 
+/**
  * enum names for configuration_attribute_type_t.
  */
 extern enum_name_t *configuration_attribute_type_names;
 
 /**
  * Class representing an IKEv2-CONFIGURATION Attribute.
- * 
+ *
  * The CONFIGURATION ATTRIBUTE format is described in RFC section 3.15.1.
  */
 struct configuration_attribute_t {
@@ -75,43 +75,43 @@ struct configuration_attribute_t {
 
        /**
         * Returns the currently set value of the attribute.
-        *      
+        *
         * @warning Returned data are not copied.
-        * 
+        *
         * @return              chunk_t pointing to the value
         */
        chunk_t (*get_value) (configuration_attribute_t *this);
-       
+
        /**
         * Sets the value of the attribute.
-        *      
+        *
         * Value is getting copied.
-        * 
+        *
         * @param value chunk_t pointing to the value to set
         */
        void (*set_value) (configuration_attribute_t *this, chunk_t value);
 
        /**
         * Sets the type of the attribute.
-        *      
+        *
         * @param type  type to set (most significant bit is set to zero)
         */
        void (*set_type) (configuration_attribute_t *this, u_int16_t type);
-       
+
        /**
         * get the type of the attribute.
-        *      
+        *
         * @return              type of the value
         */
        u_int16_t (*get_type) (configuration_attribute_t *this);
-       
+
        /**
         * get the length of an attribute.
-        *      
+        *
         * @return              type of the value
         */
        u_int16_t (*get_length) (configuration_attribute_t *this);
-       
+
        /**
         * Destroys an configuration_attribute_t object.
         */
@@ -120,7 +120,7 @@ struct configuration_attribute_t {
 
 /**
  * Creates an empty configuration_attribute_t object.
- * 
+ *
  * @return                     created configuration_attribute_t object
  */
 configuration_attribute_t *configuration_attribute_create(void);
index b5f1b35c73b15748e1c260835b4efd3964031de2..6086ad102a155104c78e4445d6e899aa152843a0 100644 (file)
@@ -32,14 +32,14 @@ typedef struct private_cp_payload_t private_cp_payload_t;
 
 /**
  * Private data of an cp_payload_t object.
- * 
+ *
  */
 struct private_cp_payload_t {
        /**
         * Public cp_payload_t interface.
         */
        cp_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -49,17 +49,17 @@ struct private_cp_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Configuration Attributes in this payload are stored in a linked_list_t.
         */
        linked_list_t * attributes;
-       
+
        /**
         * Config Type.
         */
@@ -68,32 +68,32 @@ struct private_cp_payload_t {
 
 /**
  * Encoding rules to parse or generate a IKEv2-CP Payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_cp_payload_t.
- * 
+ *
  */
 encoding_rule_t cp_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
        { U_INT_8,              offsetof(private_cp_payload_t, next_payload)                    },
        /* the critical bit */
-       { FLAG,                 offsetof(private_cp_payload_t, critical)                                },      
+       { FLAG,                 offsetof(private_cp_payload_t, critical)                                },
        /* 7 Bit reserved bits, nowhere stored */
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
        /* Length of the whole CP payload*/
-       { PAYLOAD_LENGTH,               offsetof(private_cp_payload_t, payload_length)  },      
-       /* Proposals are stored in a proposal substructure, 
+       { PAYLOAD_LENGTH,               offsetof(private_cp_payload_t, payload_length)  },
+       /* Proposals are stored in a proposal substructure,
           offset points to a linked_list_t pointer */
        { U_INT_8,              offsetof(private_cp_payload_t, config_type)                             },
-       { RESERVED_BYTE,0                                                                                                               }, 
-       { RESERVED_BYTE,0                                                                                                               }, 
-       { RESERVED_BYTE,0                                                                                                               },      
+       { RESERVED_BYTE,0                                                                                                               },
+       { RESERVED_BYTE,0                                                                                                               },
+       { RESERVED_BYTE,0                                                                                                               },
        { CONFIGURATION_ATTRIBUTES,     offsetof(private_cp_payload_t, attributes)      }
 };
 
@@ -119,7 +119,7 @@ static status_t verify(private_cp_payload_t *this)
        status_t status = SUCCESS;
        iterator_t *iterator;
        configuration_attribute_t *attribute;
-       
+
        iterator = this->attributes->create_iterator(this->attributes,TRUE);
        while(iterator->iterate(iterator, (void**)&attribute))
        {
@@ -174,14 +174,14 @@ static void compute_length(private_cp_payload_t *this)
        iterator_t *iterator;
        payload_t *current_attribute;
        size_t length = CP_PAYLOAD_HEADER_LENGTH;
-       
+
        iterator = this->attributes->create_iterator(this->attributes,TRUE);
        while (iterator->iterate(iterator, (void**)&current_attribute))
        {
                length += current_attribute->get_length(current_attribute);
        }
        iterator->destroy(iterator);
-       
+
        this->payload_length = length;
 }
 
@@ -243,7 +243,7 @@ static void destroy(private_cp_payload_t *this)
 cp_payload_t *cp_payload_create()
 {
        private_cp_payload_t *this = malloc_thing(private_cp_payload_t);
-       
+
        /* public interface */
        this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
        this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
@@ -252,14 +252,14 @@ cp_payload_t *cp_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.create_attribute_iterator = (iterator_t* (*) (cp_payload_t *)) create_attribute_iterator;
        this->public.add_configuration_attribute = (void (*) (cp_payload_t *,configuration_attribute_t *)) add_configuration_attribute;
        this->public.set_config_type = (void (*) (cp_payload_t *, config_type_t)) set_config_type;
        this->public.get_config_type = (config_type_t (*) (cp_payload_t *)) get_config_type;
        this->public.destroy = (void (*) (cp_payload_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
index 6ffcca7082bc4589de9add065ebfc1b14d582067..11f5061b9f7d0a3a2b72ca73329db6dff042fcdf 100644 (file)
@@ -52,7 +52,7 @@ extern enum_name_t *config_type_names;
 
 /**
  * Class representing an IKEv2-CP Payload.
- * 
+ *
  * The CP Payload format is described in RFC section 3.15.
  */
 struct cp_payload_t {
@@ -60,41 +60,41 @@ struct cp_payload_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Creates an iterator of stored configuration_attribute_t objects.
-        * 
+        *
         * When deleting an attribute using this iterator, the length of this
         * configuration_attribute_t has to be refreshed by calling get_length()!
         *
         * @return                              created iterator_t object
         */
        iterator_t *(*create_attribute_iterator) (cp_payload_t *this);
-       
+
        /**
         * Adds a configuration_attribute_t object to this object.
-        * 
+        *
         * The added configuration_attribute_t object is getting destroyed in
         * destroy function of cp_payload_t.
         *
         * @param attribute             configuration_attribute_t object to add
         */
        void (*add_configuration_attribute) (cp_payload_t *this, configuration_attribute_t *attribute);
-       
+
        /**
         * Set the config type.
         *
         * @param config_type   config_type_t to set
         */
        void (*set_config_type) (cp_payload_t *this,config_type_t config_type);
-       
+
        /**
         * Get the config type.
         *
         * @return                              config_type_t
         */
        config_type_t (*get_config_type) (cp_payload_t *this);
-       
+
        /**
         * Destroys an cp_payload_t object.
         */
@@ -103,7 +103,7 @@ struct cp_payload_t {
 
 /**
  * Creates an empty cp_payload_t object
- * 
+ *
  * @return cp_payload_t object
  */
 cp_payload_t *cp_payload_create(void);
index c2be1e8b5eb5370df8457401feb37d0e7a62ab33..c4fa0f8ae253ff15c1d227f2179e3115ac57f859 100644 (file)
@@ -23,14 +23,14 @@ typedef struct private_delete_payload_t private_delete_payload_t;
 
 /**
  * Private data of an delete_payload_t object.
- * 
+ *
  */
 struct private_delete_payload_t {
        /**
         * Public delete_payload_t interface.
         */
        delete_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -40,12 +40,12 @@ struct private_delete_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Protocol ID.
         */
@@ -55,29 +55,29 @@ struct private_delete_payload_t {
         * SPI Size.
         */
        u_int8_t spi_size;
-       
+
        /**
         * Number of SPI's.
         */
        u_int16_t spi_count;
-       
+
        /**
         * The contained SPI's.
         */
        chunk_t spis;
-       
+
        /**
-        * List containing u_int32_t spis 
+        * List containing u_int32_t spis
         */
        linked_list_t *spi_list;
 };
 
 /**
  * Encoding rules to parse or generate a DELETE payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_delete_payload_t.
- * 
+ *
  */
 encoding_rule_t delete_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -223,7 +223,7 @@ static void add_spi(private_delete_payload_t *this, u_int32_t spi)
 static iterator_t* create_spi_iterator(private_delete_payload_t *this)
 {
        int i;
-       
+
        if (this->spi_list == NULL)
        {
                this->spi_list = linked_list_create();
@@ -253,7 +253,7 @@ static void destroy(private_delete_payload_t *this)
        {
                this->spi_list->destroy(this->spi_list);
        }
-       free(this);     
+       free(this);
 }
 
 /*
@@ -271,13 +271,13 @@ delete_payload_t *delete_payload_create(protocol_id_t protocol_id)
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (delete_payload_t *)) destroy;
        this->public.get_protocol_id = (protocol_id_t (*) (delete_payload_t *)) get_protocol_id;
        this->public.add_spi = (void (*) (delete_payload_t *,u_int32_t))add_spi;
        this->public.create_spi_iterator = (iterator_t* (*) (delete_payload_t *)) create_spi_iterator;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
index 58840741af9dcaae269d1077e45abee7e94a1978..3b62c1af1fa26a2ae439a1a9d297b4ed28a11a78 100644 (file)
@@ -43,21 +43,21 @@ struct delete_payload_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Get the protocol ID.
         *
         * @return                              protocol ID
         */
        protocol_id_t (*get_protocol_id) (delete_payload_t *this);
-       
+
        /**
         * Add an SPI to the list of deleted SAs.
         *
         * @param spi                   spi to add
         */
        void (*add_spi) (delete_payload_t *this, u_int32_t spi);
-       
+
        /**
         * Get an iterator over the SPIs.
         *
@@ -66,7 +66,7 @@ struct delete_payload_t {
         * @return                              iterator over SPIs
         */
        iterator_t *(*create_spi_iterator) (delete_payload_t *this);
-       
+
        /**
         * Destroys an delete_payload_t object.
         */
@@ -75,7 +75,7 @@ struct delete_payload_t {
 
 /**
  * Creates an empty delete_payload_t object.
- * 
+ *
  * @param protocol_id  protocol, such as AH|ESP
  * @return                             delete_payload_t object
  */
index 1199bac45276bf4e4a1da7f61bb1e8f325c19823..562faa22142f2866b8a2ddb4fb845b1d25221a74 100644 (file)
@@ -24,14 +24,14 @@ typedef struct private_eap_payload_t private_eap_payload_t;
 
 /**
  * Private data of an eap_payload_t object.
- * 
+ *
  */
 struct private_eap_payload_t {
        /**
         * Public eap_payload_t interface.
         */
        eap_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -41,12 +41,12 @@ struct private_eap_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * EAP message data, if available
         */
@@ -55,10 +55,10 @@ struct private_eap_payload_t {
 
 /**
  * Encoding rules to parse or generate a EAP payload.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_eap_payload_t.
- * 
+ *
  */
 encoding_rule_t eap_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -98,7 +98,7 @@ static status_t verify(private_eap_payload_t *this)
 {
        u_int16_t length;
        u_int8_t code;
-       
+
        if (this->data.len < 4)
        {
                DBG1(DBG_ENC, "EAP payloads EAP message too short (%d)", this->data.len);
@@ -264,7 +264,7 @@ static void destroy(private_eap_payload_t *this)
 eap_payload_t *eap_payload_create()
 {
        private_eap_payload_t *this = malloc_thing(private_eap_payload_t);
-       
+
        /* interface functions */
        this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
        this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
@@ -273,7 +273,7 @@ eap_payload_t *eap_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (eap_payload_t *)) destroy;
        this->public.get_data = (chunk_t (*) (eap_payload_t*))get_data;
@@ -281,13 +281,13 @@ eap_payload_t *eap_payload_create()
        this->public.get_code = (eap_code_t (*) (eap_payload_t*))get_code;
        this->public.get_identifier = (u_int8_t (*) (eap_payload_t*))get_identifier;
        this->public.get_type = (eap_type_t (*) (eap_payload_t*,u_int32_t*))get_type;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
        this->payload_length = EAP_PAYLOAD_HEADER_LENGTH;
        this->data = chunk_empty;
-       
+
        return &(this->public);
 }
 
@@ -297,7 +297,7 @@ eap_payload_t *eap_payload_create()
 eap_payload_t *eap_payload_create_data(chunk_t data)
 {
        eap_payload_t *this = eap_payload_create();
-       
+
        this->set_data(this, data);
        return this;
 }
@@ -309,11 +309,11 @@ eap_payload_t *eap_payload_create_code(eap_code_t code, u_int8_t identifier)
 {
        eap_payload_t *this = eap_payload_create();
        chunk_t data = chunk_alloca(4);
-       
+
        *(data.ptr + 0) = code;
        *(data.ptr + 1) = identifier;
        *(u_int16_t*)(data.ptr + 2) = htons(data.len);
-       
+
        this->set_data(this, data);
        return this;
 }
@@ -325,12 +325,12 @@ eap_payload_t *eap_payload_create_nak(u_int8_t identifier)
 {
        eap_payload_t *this = eap_payload_create();
        chunk_t data = chunk_alloca(5);
-       
+
        *(data.ptr + 0) = EAP_RESPONSE;
        *(data.ptr + 1) = identifier;
        *(u_int16_t*)(data.ptr + 2) = htons(data.len);
        *(data.ptr + 4) = EAP_NAK;
-       
+
        this->set_data(this, data);
        return this;
 }
index a4d8a38c6672481b07461ef762638f82aca650c2..0bde4b15e18c4c47572381d075b293ec4f764353 100644 (file)
@@ -39,12 +39,12 @@ typedef struct eap_payload_t eap_payload_t;
  * The EAP payload format is described in RFC section 3.16.
  */
 struct eap_payload_t {
-       
+
        /**
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Set the contained EAP data.
         *
@@ -54,7 +54,7 @@ struct eap_payload_t {
         * @param message       EAP data
         */
        void (*set_data) (eap_payload_t *this, chunk_t data);
-       
+
        /**
         * Get the contained EAP data.
         *
@@ -63,21 +63,21 @@ struct eap_payload_t {
         * @return                      EAP data (pointer to internal data)
         */
        chunk_t (*get_data) (eap_payload_t *this);
-       
+
        /**
         * Get the EAP code.
         *
         * @return                      EAP message as chunk_t
         */
        eap_code_t (*get_code) (eap_payload_t *this);
-       
+
        /**
         * Get the EAP identifier.
         *
         * @return                      unique identifier
         */
        u_int8_t (*get_identifier) (eap_payload_t *this);
-       
+
        /**
         * Get the EAP method type.
         *
@@ -85,7 +85,7 @@ struct eap_payload_t {
         * @return                      EAP method type, vendor specific if vendor != 0
         */
        eap_type_t (*get_type) (eap_payload_t *this, u_int32_t *vendor);
-       
+
        /**
         * Destroys an eap_payload_t object.
         */
@@ -109,7 +109,7 @@ eap_payload_t *eap_payload_create_data(chunk_t data);
 /**
  * Creates an eap_payload_t object with a code.
  *
- * Could should be either EAP_SUCCESS/EAP_FAILURE, use 
+ * Could should be either EAP_SUCCESS/EAP_FAILURE, use
  * constructor above otherwise.
  *
  * @param code                 EAP status code
index 03554f0afab7b9ed5a8112600e66ec0f619c3f23..23389481c31a03cbf95fc27b87a6e06122cba3fc 100644 (file)
@@ -28,266 +28,266 @@ typedef struct encoding_rule_t encoding_rule_t;
 #include <library.h>
 
 /**
- * All different kinds of encoding types. 
+ * All different kinds of encoding types.
  *
- * Each field of an IKEv2-Message (in header or payload) 
+ * Each field of an IKEv2-Message (in header or payload)
  * which has to be parsed or generated differently has its own
  * type defined here.
  *
- * Header is parsed like a payload and gets its one payload_id 
- * from PRIVATE USE space. Also the substructures 
- * of specific payload types get their own payload_id 
+ * Header is parsed like a payload and gets its one payload_id
+ * from PRIVATE USE space. Also the substructures
+ * of specific payload types get their own payload_id
  * from PRIVATE_USE space. See IKEv2-Draft for more informations.
  */
 enum encoding_type_t {
-       
+
        /**
         * Representing a 4 Bit unsigned int value.
-        * 
-        * 
+        *
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 4 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 4 bit forward afterwards.
         */
        U_INT_4,
-       
+
        /**
         * Representing a 8 Bit unsigned int value.
-        * 
-        * 
+        *
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 8 bit forward afterwards.
-        *  
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 8 bit forward afterwards.
         */
        U_INT_8,
-       
+
        /**
         * Representing a 16 Bit unsigned int value.
-        * 
-        * 
+        *
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 16 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 16 bit forward afterwards.
         */
        U_INT_16,
-       
+
        /**
         * Representing a 32 Bit unsigned int value.
-        * 
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 32 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 32 bit forward afterwards.
         */
        U_INT_32,
-       
+
        /**
         * represents a RESERVED_BIT used in FLAG-Bytes.
-        * 
-        * When generating, the next bit is set to zero and the current write 
+        *
+        * When generating, the next bit is set to zero and the current write
         * position is moved one bit forward.
         * No value is read from the associated data struct.
         * The current write position is moved 1 bit forward afterwards.
-        * 
+        *
         * When parsing, the current read pointer is moved one bit forward.
         * No value is written to the associated data struct.
         * The current read pointer is moved 1 bit forward afterwards.
         */
        RESERVED_BIT,
-       
+
        /**
         * represents a RESERVED_BYTE.
-        * 
-        * When generating, the next byte is set to zero and the current write 
+        *
+        * When generating, the next byte is set to zero and the current write
         * position is moved one byte forward.
         * No value is read from the associated data struct.
         * The current write position is moved 1 byte forward afterwards.
-        * 
+        *
         * When parsing, the current read pointer is moved one byte forward.
         * No value is written to the associated data struct.
         * The current read pointer is moved 1 byte forward afterwards.
         */
        RESERVED_BYTE,
-       
+
        /**
         * Representing a 1 Bit flag.
-        * 
-        * When generation, the next bit is set to 1 if the associated value 
-        * in the data struct is TRUE, 0 otherwise. The current write position 
+        *
+        * When generation, the next bit is set to 1 if the associated value
+        * in the data struct is TRUE, 0 otherwise. The current write position
         * is moved 1 bit forward afterwards.
         *
-        * When parsing, the next bit is read and stored in the associated data 
-        * struct. 0 means FALSE, 1 means TRUE, The current read pointer 
+        * When parsing, the next bit is read and stored in the associated data
+        * struct. 0 means FALSE, 1 means TRUE, The current read pointer
         * is moved 1 bit forward afterwards
         */
        FLAG,
-       
+
        /**
         * Representating a length field of a payload.
-        * 
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 16 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 16 bit forward afterwards.
         */
        PAYLOAD_LENGTH,
-       
+
        /**
         * Representating a length field of a header.
-        * 
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 32 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 32 bit forward afterwards.
         */
        HEADER_LENGTH,
-       
+
        /**
         * Representating a spi size field.
-        * 
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 8 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 8 bit forward afterwards.
         */
        SPI_SIZE,
-       
+
        /**
         * Representating a spi field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing SPI_SIZE bytes are read and written into the chunk pointing to.
         */
        SPI,
-       
+
        /**
         * Representating a Key Exchange Data field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
         */
        KEY_EXCHANGE_DATA,
-       
+
        /**
         * Representating a Notification field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - spi size - 8) bytes are read and written into the chunk pointing to.
         */
        NOTIFICATION_DATA,
-       
+
        /**
         * Representating one or more proposal substructures.
-        * 
+        *
         * The offset points to a linked_list_t pointer.
-        * 
-        * When generating the proposal_substructure_t objects are stored 
+        *
+        * When generating the proposal_substructure_t objects are stored
         * in the pointed linked_list.
-        * 
-        * When parsing the parsed proposal_substructure_t objects have 
+        *
+        * When parsing the parsed proposal_substructure_t objects have
         * to be stored in the pointed linked_list.
-        */     
+        */
        PROPOSALS,
-       
+
        /**
         * Representating one or more transform substructures.
-        * 
+        *
         * The offset points to a linked_list_t pointer.
-        * 
-        * When generating the transform_substructure_t objects are stored 
+        *
+        * When generating the transform_substructure_t objects are stored
         * in the pointed linked_list.
-        * 
-        * When parsing the parsed transform_substructure_t objects have 
+        *
+        * When parsing the parsed transform_substructure_t objects have
         * to be stored in the pointed linked_list.
-        */     
+        */
        TRANSFORMS,
-       
+
        /**
         * Representating one or more Attributes of a transform substructure.
-        * 
+        *
         * The offset points to a linked_list_t pointer.
-        * 
-        * When generating the transform_attribute_t objects are stored 
+        *
+        * When generating the transform_attribute_t objects are stored
         * in the pointed linked_list.
-        * 
-        * When parsing the parsed transform_attribute_t objects have 
+        *
+        * When parsing the parsed transform_attribute_t objects have
         * to be stored in the pointed linked_list.
-        */     
+        */
        TRANSFORM_ATTRIBUTES,
 
        /**
         * Representating one or more Attributes of a configuration payload.
-        * 
+        *
         * The offset points to a linked_list_t pointer.
-        * 
-        * When generating the configuration_attribute_t objects are stored 
+        *
+        * When generating the configuration_attribute_t objects are stored
         * in the pointed linked_list.
-        * 
-        * When parsing the parsed configuration_attribute_t objects have 
+        *
+        * When parsing the parsed configuration_attribute_t objects have
         * to be stored in the pointed linked_list.
-        */             
+        */
        CONFIGURATION_ATTRIBUTES,
-       
+
        /**
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
         */
        CONFIGURATION_ATTRIBUTE_VALUE,
-       
+
        /**
         * Representing a 1 Bit flag specifying the format of a transform attribute.
-        * 
-        * When generation, the next bit is set to 1 if the associated value 
-        * in the data struct is TRUE, 0 otherwise. The current write position 
+        *
+        * When generation, the next bit is set to 1 if the associated value
+        * in the data struct is TRUE, 0 otherwise. The current write position
         * is moved 1 bit forward afterwards.
         *
-        * When parsing, the next bit is read and stored in the associated data 
-        * struct. 0 means FALSE, 1 means TRUE, The current read pointer 
+        * When parsing, the next bit is read and stored in the associated data
+        * struct. 0 means FALSE, 1 means TRUE, The current read pointer
         * is moved 1 bit forward afterwards.
         */
        ATTRIBUTE_FORMAT,
        /**
-        * Representing a 15 Bit unsigned int value used as attribute type 
+        * Representing a 15 Bit unsigned int value used as attribute type
         * in an attribute transform.
-        * 
-        * 
+        *
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 15 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 15 bit forward afterwards.
@@ -298,11 +298,11 @@ enum encoding_type_t {
         * Depending on the field of type ATTRIBUTE_FORMAT
         * this field contains the length or the value of an transform attribute.
         * Its stored in a 16 unsigned integer field.
-        * 
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 16 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 16 bit forward afterwards.
@@ -312,11 +312,11 @@ enum encoding_type_t {
        /**
         * This field contains the length or the value of an configuration attribute.
         * Its stored in a 16 unsigned integer field.
-        * 
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 16 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 16 bit forward afterwards.
@@ -325,155 +325,155 @@ enum encoding_type_t {
 
        /**
         * Depending on the field of type ATTRIBUTE_FORMAT
-        * this field is available or missing and so parsed/generated 
+        * this field is available or missing and so parsed/generated
         * or not parsed/not generated.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing SPI_SIZE bytes are read and written into the chunk pointing to.
         */
        ATTRIBUTE_VALUE,
-       
+
        /**
         * Representating one or more Traffic selectors of a TS payload.
-        * 
+        *
         * The offset points to a linked_list_t pointer.
-        * 
-        * When generating the traffic_selector_substructure_t objects are stored 
+        *
+        * When generating the traffic_selector_substructure_t objects are stored
         * in the pointed linked_list.
-        * 
-        * When parsing the parsed traffic_selector_substructure_t objects have 
+        *
+        * When parsing the parsed traffic_selector_substructure_t objects have
         * to be stored in the pointed linked_list.
-        */     
+        */
        TRAFFIC_SELECTORS,
-       
+
        /**
         * Representating a Traffic selector type field.
-        * 
+        *
         * When generating it must be changed from host to network order.
         * The value is read from the associated data struct.
         * The current write position is moved 16 bit forward afterwards.
-        * 
+        *
         * When parsing it must be changed from network to host order.
         * The value is written to the associated data struct.
         * The current read pointer is moved 16 bit forward afterwards.
         */
        TS_TYPE,
-       
+
        /**
         * Representating an address field in a traffic selector.
-        * 
+        *
         * Depending on the last field of type TS_TYPE
         * this field is either 4 or 16 byte long.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing 4 or 16 bytes are read and written into the chunk pointing to.
         */
        ADDRESS,
 
        /**
         * Representating a Nonce Data field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
         */
        NONCE_DATA,
-       
+
        /**
         * Representating a ID Data field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
         */
        ID_DATA,
-       
+
        /**
         * Representating a AUTH Data field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
         */
        AUTH_DATA,
-       
+
        /**
         * Representating a CERT Data field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 5) bytes are read and written into the chunk pointing to.
         */
        CERT_DATA,
 
        /**
         * Representating a CERTREQ Data field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 5) bytes are read and written into the chunk pointing to.
         */
        CERTREQ_DATA,
-       
+
        /**
         * Representating an EAP message field.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
         */
        EAP_DATA,
-       
+
        /**
         * Representating the SPIS field in a DELETE payload.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
         */
        SPIS,
-       
+
        /**
         * Representating the VID DATA field in a VENDOR ID payload.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
         */
        VID_DATA,
-       
+
        /**
         * Representating the DATA of an unknown payload.
-        * 
-        * When generating the content of the chunkt pointing to 
+        *
+        * When generating the content of the chunkt pointing to
         * is written.
-        * 
+        *
         * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
         */
        UNKNOWN_DATA,
-       
+
        /**
         * Representating an IKE_SPI field in an IKEv2 Header.
-        * 
-        * When generating the value of the u_int64_t pointing to 
+        *
+        * When generating the value of the u_int64_t pointing to
         * is written (host and networ order is not changed).
-        * 
+        *
         * When parsing 8 bytes are read and written into the u_int64_t pointing to.
         */
        IKE_SPI,
-       
+
        /**
         * Representing the encrypted data body of a encryption payload.
         */
@@ -488,25 +488,25 @@ extern enum_name_t *encoding_type_names;
 /**
  * Rule how to en-/decode a payload field.
  *
- * An encoding rule is a mapping of a specific encoding type to 
+ * An encoding rule is a mapping of a specific encoding type to
  * a location in the data struct where the current field is stored to
  * or read from.
  * This rules are used by parser and generator.
  */
 struct encoding_rule_t {
-       
+
        /**
         * Encoding type.
         */
        encoding_type_t type;
-       
+
        /**
         * Offset in the data struct.
-        * 
-        * When parsing, data are written to this offset of the 
+        *
+        * When parsing, data are written to this offset of the
         * data struct.
-        * 
-        * When generating, data are read from this offset in the 
+        *
+        * When generating, data are read from this offset in the
         * data struct.
         */
        u_int32_t offset;
index 55a37bb252176f9094e5f651c6bf2bf797c61475..389ab09d75fadfd344942371befe837614b5e21e 100644 (file)
@@ -32,19 +32,19 @@ typedef struct private_encryption_payload_t private_encryption_payload_t;
 
 /**
  * Private data of an encryption_payload_t' Object.
- * 
+ *
  */
 struct private_encryption_payload_t {
-       
+
        /**
         * Public encryption_payload_t interface.
         */
        encryption_payload_t public;
-       
+
        /**
-        * There is no next payload for an encryption payload, 
+        * There is no next payload for an encryption payload,
         * since encryption payload MUST be the last one.
-        * next_payload means here the first payload of the 
+        * next_payload means here the first payload of the
         * contained, encrypted payload.
         */
        u_int8_t next_payload;
@@ -53,33 +53,33 @@ struct private_encryption_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload
         */
        u_int16_t payload_length;
-       
+
        /**
         * Chunk containing the iv, data, padding,
         * and (an eventually not calculated) signature.
         */
        chunk_t encrypted;
-       
+
        /**
         * Chunk containing the data in decrypted (unpadded) form.
         */
        chunk_t decrypted;
-       
+
        /**
         * Signer set by set_signer.
         */
        signer_t *signer;
-       
+
        /**
         * Crypter, supplied by encrypt/decrypt
         */
        crypter_t *crypter;
-       
+
        /**
         * Contained payloads of this encrpytion_payload.
         */
@@ -88,10 +88,10 @@ struct private_encryption_payload_t {
 
 /**
  * Encoding rules to parse or generate a IKEv2-Encryption Payload.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_encryption_payload_t.
- * 
+ *
  */
 encoding_rule_t encryption_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -170,7 +170,7 @@ static payload_type_t get_next_type(private_encryption_payload_t *this)
  */
 static void set_next_type(private_encryption_payload_t *this, payload_type_t type)
 {
-       /* set next type is not allowed, since this payload MUST be the last one 
+       /* set next type is not allowed, since this payload MUST be the last one
         * and so nothing is done in here*/
 }
 
@@ -190,7 +190,7 @@ static void compute_length(private_encryption_payload_t *this)
                length += current_payload->get_length(current_payload);
        }
        iterator->destroy(iterator);
-       
+
        if (this->crypter && this->signer)
        {
                /* append one byte for padding length */
@@ -268,13 +268,13 @@ static void generate(private_encryption_payload_t *this)
        payload_t *current_payload, *next_payload;
        generator_t *generator;
        iterator_t *iterator;
-       
+
        /* recalculate length before generating */
        compute_length(this);
-       
+
        /* create iterator */
        iterator = this->payloads->create_iterator(this->payloads, TRUE);
-       
+
        /* get first payload */
        if (iterator->iterate(iterator, (void**)&current_payload))
        {
@@ -289,9 +289,9 @@ static void generate(private_encryption_payload_t *this)
                iterator->destroy(iterator);
                return;
        }
-       
+
        generator = generator_create();
-       
+
        /* build all payload, except last */
        while(iterator->iterate(iterator, (void**)&next_payload))
        {
@@ -300,14 +300,14 @@ static void generate(private_encryption_payload_t *this)
                current_payload = next_payload;
        }
        iterator->destroy(iterator);
-       
+
        /* build last payload */
        current_payload->set_next_type(current_payload, NO_PAYLOAD);
        generator->generate_payload(generator, current_payload);
-       
+
        /* free already generated data */
        free(this->decrypted.ptr);
-       
+
        generator->write_to_chunk(generator, &(this->decrypted));
        generator->destroy(generator);
        DBG2(DBG_ENC, "successfully generated content in encryption payload");
@@ -321,13 +321,13 @@ static status_t encrypt(private_encryption_payload_t *this)
        chunk_t iv, padding, to_crypt, result;
        rng_t *rng;
        size_t block_size;
-       
+
        if (this->signer == NULL || this->crypter == NULL)
        {
                DBG1(DBG_ENC, "could not encrypt, signer/crypter not set");
                return INVALID_STATE;
        }
-       
+
        /* for random data in iv and padding */
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
@@ -337,15 +337,15 @@ static status_t encrypt(private_encryption_payload_t *this)
        }
        /* build payload chunk */
        generate(this);
-       
+
        DBG2(DBG_ENC, "encrypting payloads");
        DBG3(DBG_ENC, "data to encrypt %B", &this->decrypted);
-       
+
        /* build padding */
        block_size = this->crypter->get_block_size(this->crypter);
        padding.len = block_size - ((this->decrypted.len + 1) %  block_size);
        rng->allocate_bytes(rng, padding.len, &padding);
-       
+
        /* concatenate payload data, padding, padding len */
        to_crypt.len = this->decrypted.len + padding.len + 1;
        to_crypt.ptr = malloc(to_crypt.len);
@@ -353,36 +353,36 @@ static status_t encrypt(private_encryption_payload_t *this)
        memcpy(to_crypt.ptr, this->decrypted.ptr, this->decrypted.len);
        memcpy(to_crypt.ptr + this->decrypted.len, padding.ptr, padding.len);
        *(to_crypt.ptr + to_crypt.len - 1) = padding.len;
-               
+
        /* build iv */
        iv.len = block_size;
        rng->allocate_bytes(rng, iv.len, &iv);
        rng->destroy(rng);
-       
+
        DBG3(DBG_ENC, "data before encryption with padding %B", &to_crypt);
-       
+
        /* encrypt to_crypt chunk */
        free(this->encrypted.ptr);
        this->crypter->encrypt(this->crypter, to_crypt, iv, &result);
        free(padding.ptr);
        free(to_crypt.ptr);
-       
+
        DBG3(DBG_ENC, "data after encryption %B", &result);
-       
+
        /* build encrypted result with iv and signature */
        this->encrypted.len = iv.len + result.len + this->signer->get_block_size(this->signer);
        free(this->encrypted.ptr);
        this->encrypted.ptr = malloc(this->encrypted.len);
-       
+
        /* fill in result, signature is left out */
        memcpy(this->encrypted.ptr, iv.ptr, iv.len);
        memcpy(this->encrypted.ptr + iv.len, result.ptr, result.len);
-       
+
        free(result.ptr);
        free(iv.ptr);
        DBG3(DBG_ENC, "data after encryption with IV and (invalid) signature %B",
                 &this->encrypted);
-       
+
        return SUCCESS;
 }
 
@@ -394,16 +394,16 @@ static status_t parse(private_encryption_payload_t *this)
        parser_t *parser;
        status_t status;
        payload_type_t current_payload_type;
-       
+
        /* build a parser on the decrypted data */
        parser = parser_create(this->decrypted);
-       
+
        current_payload_type = this->next_payload;
        /* parse all payloads */
        while (current_payload_type != NO_PAYLOAD)
        {
-               payload_t *current_payload;     
-               
+               payload_t *current_payload;
+
                status = parser->parse_payload(parser, current_payload_type, (payload_t**)&current_payload);
                if (status != SUCCESS)
                {
@@ -423,7 +423,7 @@ static status_t parse(private_encryption_payload_t *this)
 
                /* get next payload type */
                current_payload_type = current_payload->get_next_type(current_payload);
-               
+
                this->payloads->insert_last(this->payloads,current_payload);
        }
        parser->destroy(parser);
@@ -438,50 +438,50 @@ static status_t decrypt(private_encryption_payload_t *this)
 {
        chunk_t iv, concatenated;
        u_int8_t padding_length;
-       
+
        DBG2(DBG_ENC, "decrypting encryption payload");
        DBG3(DBG_ENC, "data before decryption with IV and (invalid) signature %B",
                 &this->encrypted);
-       
+
        if (this->signer == NULL || this->crypter == NULL)
        {
                DBG1(DBG_ENC, "could not decrypt, no crypter/signer set");
                return INVALID_STATE;
        }
-       
+
        /* get IV */
        iv.len = this->crypter->get_block_size(this->crypter);
-       
+
        iv.ptr = this->encrypted.ptr;
-       
+
        /* point concatenated to data + padding + padding_length*/
        concatenated.ptr = this->encrypted.ptr + iv.len;
        concatenated.len = this->encrypted.len - iv.len -
                                                                this->signer->get_block_size(this->signer);
-               
+
        /* concatenated must be a multiple of block_size of crypter */
        if (concatenated.len < iv.len || concatenated.len % iv.len)
        {
                DBG1(DBG_ENC, "could not decrypt, invalid input");
                return FAILED;
        }
-       
+
        /* free previus data, if any */
        free(this->decrypted.ptr);
-       
+
        DBG3(DBG_ENC, "data before decryption %B", &concatenated);
-       
+
        this->crypter->decrypt(this->crypter, concatenated, iv, &this->decrypted);
 
        DBG3(DBG_ENC, "data after decryption with padding %B", &this->decrypted);
-       
+
        /* get padding length, sits just bevore signature */
        padding_length = *(this->decrypted.ptr + this->decrypted.len - 1);
-       /* add one byte to the padding length, since the padding_length field is 
+       /* add one byte to the padding length, since the padding_length field is
         * not included */
        padding_length++;
        this->decrypted.len -= padding_length;
-       
+
        /* check size again */
        if (padding_length > concatenated.len || this->decrypted.len < 0)
        {
@@ -489,7 +489,7 @@ static status_t decrypt(private_encryption_payload_t *this)
                /* decryption failed :-/ */
                return FAILED;
        }
-       
+
        /* free padding */
        this->decrypted.ptr = realloc(this->decrypted.ptr, this->decrypted.len);
        DBG3(DBG_ENC, "data after decryption without padding %B", &this->decrypted);
@@ -513,13 +513,13 @@ static status_t build_signature(private_encryption_payload_t *this, chunk_t data
 {
        chunk_t data_without_sig = data;
        chunk_t sig;
-       
+
        if (this->signer == NULL)
        {
                DBG1(DBG_ENC, "unable to build signature, no signer set");
                return INVALID_STATE;
        }
-       
+
        sig.len = this->signer->get_block_size(this->signer);
        data_without_sig.len -= sig.len;
        sig.ptr = data.ptr + data_without_sig.len;
@@ -535,7 +535,7 @@ static status_t verify_signature(private_encryption_payload_t *this, chunk_t dat
 {
        chunk_t sig, data_without_sig;
        bool valid;
-       
+
        if (this->signer == NULL)
        {
                DBG1(DBG_ENC, "unable to verify signature, no signer set");
@@ -549,18 +549,18 @@ static status_t verify_signature(private_encryption_payload_t *this, chunk_t dat
                return FAILED;
        }
        sig.ptr = data.ptr + data.len - sig.len;
-       
+
        /* verify it */
        data_without_sig.len = data.len - sig.len;
        data_without_sig.ptr = data.ptr;
        valid = this->signer->verify_signature(this->signer, data_without_sig, sig);
-       
+
        if (!valid)
        {
                DBG1(DBG_ENC, "signature verification failed");
                return FAILED;
        }
-       
+
        DBG2(DBG_ENC, "signature verification successful");
        return SUCCESS;
 }
@@ -582,7 +582,7 @@ static void destroy(private_encryption_payload_t *this)
 encryption_payload_t *encryption_payload_create()
 {
        private_encryption_payload_t *this = malloc_thing(private_encryption_payload_t);
-       
+
        /* payload_t interface functions */
        this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
        this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
@@ -591,20 +591,20 @@ encryption_payload_t *encryption_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.create_payload_iterator = (iterator_t * (*) (encryption_payload_t *,bool)) create_payload_iterator;
        this->public.add_payload = (void (*) (encryption_payload_t *,payload_t *)) add_payload;
        this->public.remove_first_payload = (status_t (*)(encryption_payload_t*, payload_t **)) remove_first_payload;
        this->public.get_payload_count = (size_t (*)(encryption_payload_t*)) get_payload_count;
-       
+
        this->public.encrypt = (status_t (*) (encryption_payload_t *)) encrypt;
        this->public.decrypt = (status_t (*) (encryption_payload_t *)) decrypt;
        this->public.set_transforms = (void (*) (encryption_payload_t*,crypter_t*,signer_t*)) set_transforms;
        this->public.build_signature = (status_t (*) (encryption_payload_t*, chunk_t)) build_signature;
        this->public.verify_signature = (status_t (*) (encryption_payload_t*, chunk_t)) verify_signature;
        this->public.destroy = (void (*) (encryption_payload_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
@@ -614,6 +614,6 @@ encryption_payload_t *encryption_payload_create()
        this->signer = NULL;
        this->crypter = NULL;
        this->payloads = linked_list_create();
-       
+
        return (&(this->public));
 }
index 3b94587ec4917e30d76b8820f070166151bf365d..ac5326b87163fbe6595f73e93b9c5c45e1ea718f 100644 (file)
@@ -39,7 +39,7 @@ typedef struct encryption_payload_t encryption_payload_t;
 /**
  * The encryption payload as described in RFC section 3.14.
  *
- * Before any crypt/decrypt/sign/verify operation can occur, 
+ * Before any crypt/decrypt/sign/verify operation can occur,
  * the transforms must be set. After that, a parsed encryption payload
  * can be decrypted, which also will parse the contained payloads.
  * Encryption is done the same way, added payloads will get generated
@@ -54,24 +54,24 @@ struct encryption_payload_t {
         * Implements payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Creates an iterator for all contained payloads.
-        * 
+        *
         * iterator_t object has to get destroyed by the caller.
         *
         * @param forward               iterator direction (TRUE: front to end)
         * return                               created iterator_t object
         */
         iterator_t *(*create_payload_iterator) (encryption_payload_t *this, bool forward);
-       
+
        /**
         * Adds a payload to this encryption payload.
         *
         * @param payload               payload_t object to add
         */
        void (*add_payload) (encryption_payload_t *this, payload_t *payload);
-       
+
        /**
         * Reove the last payload in the contained payload list.
         *
@@ -81,20 +81,20 @@ struct encryption_payload_t {
         *                                              - NOT_FOUND if list empty
         */
        status_t (*remove_first_payload) (encryption_payload_t *this, payload_t **payload);
-       
+
        /**
         * Get the number of payloads.
         *
         * @return                              number of contained payloads
         */
        size_t (*get_payload_count) (encryption_payload_t *this);
-       
+
        /**
         * Set transforms to use.
-        * 
+        *
         * To decryption, encryption, signature building and verifying,
         * the payload needs a crypter and a signer object.
-        * 
+        *
         * @warning Do NOT call this function again after encryption, since
         * the signer must be the same while encrypting and signature building!
         *
@@ -102,10 +102,10 @@ struct encryption_payload_t {
         * @param signer                signer_t to use for data signing/verifying
         */
        void (*set_transforms) (encryption_payload_t *this, crypter_t *crypter, signer_t *signer);
-       
+
        /**
         * Generate and encrypt contained payloads.
-        * 
+        *
         * This function generates the content for added payloads
         * and encrypts them. Signature is not built, since we need
         * additional data (the full message).
@@ -113,11 +113,11 @@ struct encryption_payload_t {
         * @return                              SUCCESS, or INVALID_STATE if transforms not set
         */
        status_t (*encrypt) (encryption_payload_t *this);
-       
+
        /**
         * Decrypt and parse contained payloads.
-        * 
-        * This function decrypts the contained data. After, 
+        *
+        * This function decrypts the contained data. After,
         * the payloads are parsed internally and are accessible
         * via the iterator.
         *
@@ -127,29 +127,29 @@ struct encryption_payload_t {
         *                                              - FAILED if data is invalid
         */
        status_t (*decrypt) (encryption_payload_t *this);
-       
+
        /**
         * Build the signature.
-        * 
+        *
         * The signature is built over the FULL message, so the header
         * and every payload (inclusive this one) must already be generated.
         * The generated message is supplied via the data paramater.
-        * 
+        *
         * @param data                  chunk contains the already generated message
         * @return
         *                                              - SUCCESS, or
         *                                              - INVALID_STATE if transforms not set
         */
        status_t (*build_signature) (encryption_payload_t *this, chunk_t data);
-               
+
        /**
         * Verify the signature.
-        * 
+        *
         * Since the signature is built over the full message, we need
         * this data to do the verification. The message data
         * is supplied via the data argument.
-        * 
-        * @param data                  chunk contains the message 
+        *
+        * @param data                  chunk contains the message
         * @return
         *                                              - SUCCESS, or
         *                                              - FAILED if signature invalid, or
@@ -165,7 +165,7 @@ struct encryption_payload_t {
 
 /**
  * Creates an empty encryption_payload_t object.
- * 
+ *
  * @return encryption_payload_t object
  */
 encryption_payload_t *encryption_payload_create(void);
index c30d2994248c6d58cad98ee12fddd3b2e6c00c5b..5b8848f11555dd6937b10d24375d0d386d8ff9fb 100644 (file)
@@ -23,34 +23,34 @@ typedef struct private_endpoint_notify_t private_endpoint_notify_t;
 
 /**
  * Private data of an notify_payload_t object.
- * 
+ *
  */
 struct private_endpoint_notify_t {
        /**
         * Public endpoint_notify_t interface.
         */
        endpoint_notify_t public;
-       
+
        /**
         * Priority
         */
        u_int32_t priority;
-       
+
        /**
         * Family
         */
        me_endpoint_family_t family;
-               
+
        /**
         * Endpoint type
         */
        me_endpoint_type_t type;
-       
+
        /**
         * Endpoint
         */
        host_t *endpoint;
-       
+
        /**
         * Base (used for server reflexive endpoints)
         */
@@ -65,7 +65,7 @@ struct private_endpoint_notify_t {
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       !     Family    !      Type     !              Port             !
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-      !                       IP Address (variable)                   
+      !                       IP Address (variable)
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 */
 
@@ -122,9 +122,9 @@ static status_t parse_notification_data(private_endpoint_notify_t *this, chunk_t
        chunk_t addr;
        u_int8_t *cur = data.ptr;
        u_int8_t *top = data.ptr + data.len;
-       
+
        DBG3(DBG_IKE, "me_endpoint_data %B", &data);
-       
+
        if (parse_uint32(&cur, top, &this->priority) != SUCCESS)
        {
                DBG1(DBG_IKE, "failed to parse ME_ENDPOINT: invalid priority");
@@ -136,20 +136,20 @@ static status_t parse_notification_data(private_endpoint_notify_t *this, chunk_t
                DBG1(DBG_IKE, "failed to parse ME_ENDPOINT: invalid family");
                return FAILED;
        }
-       
+
        this->family = (me_endpoint_family_t)family;
-       
+
        if (parse_uint8(&cur, top, &type) != SUCCESS || type >= MAX_TYPE)
        {
                DBG1(DBG_IKE, "failed to parse ME_ENDPOINT: invalid type");
                return FAILED;
        }
-       
+
        this->type = (me_endpoint_type_t)type;
-       
+
        addr_family = AF_INET;
        addr.len = 4;
-       
+
        switch(this->family)
        {
                case IPv6:
@@ -160,24 +160,24 @@ static status_t parse_notification_data(private_endpoint_notify_t *this, chunk_t
                        if (parse_uint16(&cur, top, &port) != SUCCESS)
                        {
                                DBG1(DBG_IKE, "failed to parse ME_ENDPOINT: invalid port");
-                               return FAILED;  
+                               return FAILED;
                        }
-                       
+
                        if (cur + addr.len > top)
                        {
                                DBG1(DBG_IKE, "failed to parse ME_ENDPOINT: invalid IP address");
                                return FAILED;
                        }
-                       
+
                        addr.ptr = cur;
-                       
+
                        this->endpoint = host_create_from_chunk(addr_family, addr, port);
                        break;
                case NO_FAMILY:
                default:
                        this->endpoint = NULL;
                        break;
-       }       
+       }
        return SUCCESS;
 }
 
@@ -192,14 +192,14 @@ static chunk_t build_notification_data(private_endpoint_notify_t *this)
        u_int32_t prio;
        u_int16_t port;
        u_int8_t family, type;
-       
+
        prio = htonl(this->priority);
        prio_chunk = chunk_from_thing(prio);
        family = this->family;
        family_chunk = chunk_from_thing(family);
        type = this->type;
        type_chunk = chunk_from_thing(type);
-       
+
        if (this->endpoint)
        {
                port = htons(this->endpoint->get_port(this->endpoint));
@@ -208,15 +208,15 @@ static chunk_t build_notification_data(private_endpoint_notify_t *this)
        else
        {
                port = 0;
-               addr_chunk = chunk_empty; 
+               addr_chunk = chunk_empty;
        }
        port_chunk = chunk_from_thing(port);
-       
+
        /* data = prio | family | type | port | addr */
        data = chunk_cat("ccccc", prio_chunk, family_chunk, type_chunk,
                        port_chunk, addr_chunk);
        DBG3(DBG_IKE, "me_endpoint_data %B", &data);
-       
+
        return data;
 }
 
@@ -226,14 +226,14 @@ static chunk_t build_notification_data(private_endpoint_notify_t *this)
 static notify_payload_t *build_notify(private_endpoint_notify_t *this)
 {
        chunk_t data;
-       notify_payload_t *notify;       
-       
+       notify_payload_t *notify;
+
        notify = notify_payload_create();
        notify->set_notify_type(notify, ME_ENDPOINT);
        data = build_notification_data(this);
        notify->set_notification_data(notify, data);
        chunk_free(&data);
-       
+
        return notify;
 }
 
@@ -291,7 +291,7 @@ static host_t *get_base(private_endpoint_notify_t *this)
 static endpoint_notify_t *_clone(private_endpoint_notify_t *this)
 {
        private_endpoint_notify_t *clone = (private_endpoint_notify_t*)endpoint_notify_create();
-       
+
        clone->priority = this->priority;
        clone->type = this->type;
        clone->family = this->family;
@@ -299,12 +299,12 @@ static endpoint_notify_t *_clone(private_endpoint_notify_t *this)
        {
                clone->endpoint = this->endpoint->clone(this->endpoint);
        }
-       
+
        if (this->base)
        {
                clone->base = this->base->clone(this->base);
        }
-       
+
        return &clone->public;
 }
 
@@ -336,14 +336,14 @@ endpoint_notify_t *endpoint_notify_create()
        this->public.build_notify = (notify_payload_t *(*) (endpoint_notify_t *)) build_notify;
        this->public.clone = (endpoint_notify_t *(*) (endpoint_notify_t *)) _clone;
        this->public.destroy = (void (*) (endpoint_notify_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->priority = 0;
        this->family = NO_FAMILY;
        this->type = NO_TYPE;
        this->endpoint = NULL;
        this->base = NULL;
-       
+
        return &this->public;
 }
 
@@ -353,34 +353,34 @@ endpoint_notify_t *endpoint_notify_create()
 endpoint_notify_t *endpoint_notify_create_from_host(me_endpoint_type_t type, host_t *host, host_t *base)
 {
        private_endpoint_notify_t *this = (private_endpoint_notify_t*)endpoint_notify_create();
-       
+
        this->type = type;
-       
+
        switch(type)
        {
                case HOST:
-                       this->priority = pow(2, 16) * ME_PRIO_HOST; 
+                       this->priority = pow(2, 16) * ME_PRIO_HOST;
                        break;
                case PEER_REFLEXIVE:
-                       this->priority = pow(2, 16) * ME_PRIO_PEER; 
+                       this->priority = pow(2, 16) * ME_PRIO_PEER;
                        break;
                case SERVER_REFLEXIVE:
-                       this->priority = pow(2, 16) * ME_PRIO_SERVER; 
+                       this->priority = pow(2, 16) * ME_PRIO_SERVER;
                        break;
                case RELAYED:
                default:
-                       this->priority = pow(2, 16) * ME_PRIO_RELAY; 
+                       this->priority = pow(2, 16) * ME_PRIO_RELAY;
                        break;
        }
-       
+
        /* FIXME: if there is more than one ip address we should vary this priority */
        this->priority += 65535;
-       
+
        if (!host)
        {
                return &this->public;
        }
-       
+
        switch(host->get_family(host))
        {
                case AF_INET:
@@ -394,14 +394,14 @@ endpoint_notify_t *endpoint_notify_create_from_host(me_endpoint_type_t type, hos
                         * (family is set to NO_FAMILY) */
                        return &this->public;
        }
-       
+
        this->endpoint = host->clone(host);
-       
+
        if (base)
        {
                this->base = base->clone(base);
        }
-       
+
        return &this->public;
 }
 
@@ -414,7 +414,7 @@ endpoint_notify_t *endpoint_notify_create_from_payload(notify_payload_t *notify)
        {
                return NULL;
        }
-       
+
        private_endpoint_notify_t *this = (private_endpoint_notify_t*)endpoint_notify_create();
        chunk_t data = notify->get_notification_data(notify);
        if (parse_notification_data(this, data) != SUCCESS)
index 66aabc68396ecac609af34c43bf198e03de8f8e0..120eef49a279529a68d7ff1db68071f8418de57e 100644 (file)
@@ -36,34 +36,34 @@ typedef struct endpoint_notify_t endpoint_notify_t;
  * ME endpoint families.
  */
 enum me_endpoint_family_t {
-       
+
        NO_FAMILY = 0,
-       
+
        IPv4 = 1,
-       
+
        IPv6 = 2,
-       
+
        MAX_FAMILY = 3
-       
+
 };
 
 /**
  * ME endpoint types.
  */
 enum me_endpoint_type_t {
-       
+
        NO_TYPE = 0,
-       
+
        HOST = 1,
-       
+
        PEER_REFLEXIVE = 2,
-       
+
        SERVER_REFLEXIVE = 3,
-       
+
        RELAYED = 4,
-       
+
        MAX_TYPE = 5
-       
+
 };
 
 /**
@@ -79,52 +79,52 @@ extern enum_name_t *me_endpoint_type_names;
 struct endpoint_notify_t {
        /**
         * Returns the priority of this endpoint.
-        * 
+        *
         * @return                      priority
         */
        u_int32_t (*get_priority) (endpoint_notify_t *this);
-       
+
        /**
         * Sets the priority of this endpoint.
-        * 
+        *
         * @param priority      priority
         */
        void (*set_priority) (endpoint_notify_t *this, u_int32_t priority);
-       
+
        /**
         * Returns the endpoint type of this endpoint.
-        * 
+        *
         * @return                      endpoint type
         */
        me_endpoint_type_t (*get_type) (endpoint_notify_t *this);
-       
+
        /**
         * Returns the endpoint family of this endpoint.
-        * 
+        *
         * @return                      endpoint family
         */
        me_endpoint_family_t (*get_family) (endpoint_notify_t *this);
-       
+
        /**
         * Returns the host of this endpoint.
-        * 
+        *
         * @return                      host
         */
        host_t *(*get_host) (endpoint_notify_t *this);
-       
+
        /**
         * Returns the base of this endpoint.
-        * 
+        *
         * If this is not a SERVER_REFLEXIVE endpoint, the returned host is the same
         * as the one returned by get_host.
-        * 
+        *
         * @return                      host
         */
        host_t *(*get_base) (endpoint_notify_t *this);
-       
+
        /**
-        * Generates a notification payload from this endpoint. 
-        *      
+        * Generates a notification payload from this endpoint.
+        *
         * @return                      built notify_payload_t
         */
        notify_payload_t *(*build_notify) (endpoint_notify_t *this);
@@ -135,7 +135,7 @@ struct endpoint_notify_t {
         * @return                      cloned object
         */
        endpoint_notify_t *(*clone) (endpoint_notify_t *this);
-       
+
        /**
         * Destroys an endpoint_notify_t object.
         */
@@ -144,7 +144,7 @@ struct endpoint_notify_t {
 
 /**
  * Creates an empty endpoint_notify_t object.
- * 
+ *
  * @return                     created endpoint_notify_t object
  */
 endpoint_notify_t *endpoint_notify_create(void);
@@ -152,7 +152,7 @@ endpoint_notify_t *endpoint_notify_create(void);
 
 /**
  * Creates an endpoint_notify_t object from a host.
- * 
+ *
  * @param type         the endpoint type
  * @param host         host to base the notify on (gets cloned)
  * @param base         base of the endpoint, applies only to reflexive endpoints (gets cloned)
@@ -163,7 +163,7 @@ endpoint_notify_t *endpoint_notify_create_from_host(me_endpoint_type_t type,
 
 /**
  * Creates an endpoint_notify_t object from a notify payload.
- * 
+ *
  * @param notify       the notify payload
  * @return                     - created endpoint_notify_t object
  *                                     - NULL if invalid payload
index 4a527cb24ff1985fcdc664959845c0c43d99a2c6..801f720b9395c95bf9e8f71e385888218c816987 100644 (file)
@@ -27,19 +27,19 @@ typedef struct private_id_payload_t private_id_payload_t;
 
 /**
  * Private data of an id_payload_t object.
- * 
+ *
  */
 struct private_id_payload_t {
        /**
         * Public id_payload_t interface.
         */
        id_payload_t public;
-       
+
        /**
         * one of ID_INITIATOR, ID_RESPONDER
         */
        payload_type_t payload_type;
-       
+
        /**
         * Next payload type.
         */
@@ -49,17 +49,17 @@ struct private_id_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Type of the ID Data.
         */
        u_int8_t id_type;
-       
+
        /**
         * The contained id data value.
         */
@@ -68,10 +68,10 @@ struct private_id_payload_t {
 
 /**
  * Encoding rules to parse or generate a ID payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_id_payload_t.
- * 
+ *
  */
 encoding_rule_t id_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -126,7 +126,7 @@ static status_t verify(private_id_payload_t *this)
                DBG1(DBG_ENC, "received ID with reserved type %d", this->id_type);
                return FAILED;
        }
-               
+
        return SUCCESS;
 }
 
@@ -242,7 +242,7 @@ static void destroy(private_id_payload_t *this)
        {
                chunk_free(&(this->id_data));
        }
-       free(this);     
+       free(this);
 }
 
 /*
@@ -260,7 +260,7 @@ id_payload_t *id_payload_create(payload_type_t payload_type)
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (id_payload_t *)) destroy;
        this->public.set_id_type = (void (*) (id_payload_t *,id_type_t)) set_id_type;
@@ -268,7 +268,7 @@ id_payload_t *id_payload_create(payload_type_t payload_type)
        this->public.set_data = (void (*) (id_payload_t *,chunk_t)) set_data;
        this->public.get_data = (chunk_t (*) (id_payload_t *)) get_data;
        this->public.get_data_clone = (chunk_t (*) (id_payload_t *)) get_data_clone;
-       
+
        this->public.get_identification = (identification_t * (*) (id_payload_t *this)) get_identification;
 
        /* private variables */
index 555b1324b6305943475835de6d9d4024134f9e1c..5502dc9615451305fd43d809cd23605fab29bb11 100644 (file)
@@ -51,35 +51,35 @@ struct id_payload_t {
         * @param type                  Type of ID
         */
        void (*set_id_type) (id_payload_t *this, id_type_t type);
-       
+
        /**
         * Get the ID type.
         *
-        * @return                              type of the ID 
+        * @return                              type of the ID
         */
        id_type_t (*get_id_type) (id_payload_t *this);
-       
+
        /**
         * Set the ID data.
-        * 
+        *
         * Data are getting cloned.
         *
         * @param data                  ID data as chunk_t
         */
        void (*set_data) (id_payload_t *this, chunk_t data);
-       
+
        /**
         * Get the ID data.
-        * 
+        *
         * Returned data are a copy of the internal one
         *
         * @return                              ID data as chunk_t
         */
        chunk_t (*get_data_clone) (id_payload_t *this);
-       
+
        /**
         * Get the ID data.
-        * 
+        *
         * Returned data are NOT copied.
         *
         * @return                              ID data as chunk_t
@@ -88,13 +88,13 @@ struct id_payload_t {
 
        /**
         * Creates an identification object of this id payload.
-        * 
+        *
         * Returned object has to get destroyed by the caller.
         *
-        * @return                              identification_t object 
+        * @return                              identification_t object
         */
        identification_t *(*get_identification) (id_payload_t *this);
-       
+
        /**
         * Destroys an id_payload_t object.
         */
@@ -103,7 +103,7 @@ struct id_payload_t {
 
 /**
  * Creates an empty id_payload_t object.
- * 
+ *
  * @param payload_type one of ID_INITIATOR, ID_RESPONDER
  * @return                             id_payload_t object
  */
@@ -111,7 +111,7 @@ id_payload_t *id_payload_create(payload_type_t payload_type);
 
 /**
  * Creates an id_payload_t from an existing identification_t object.
- * 
+ *
  * @param payload_type         one of ID_INITIATOR, ID_RESPONDER
  * @param identification       identification_t object
  * @return                                     id_payload_t object
index 614919fac9755738c5497b6257d386de8f6eb906..0ce1ca6b22c3a1cd18bf01766032340a1ba003b7 100644 (file)
@@ -33,7 +33,7 @@ struct private_ike_header_t {
         * Public interface.
         */
        ike_header_t public;
-       
+
        /**
         * SPI of the initiator.
         */
@@ -62,7 +62,7 @@ struct private_ike_header_t {
         * Exchange type .
         */
        u_int8_t  exchange_type;
-       
+
        /**
         * Flags of the Message.
         */
@@ -87,7 +87,7 @@ struct private_ike_header_t {
         * Associated Message-ID.
         */
        u_int32_t message_id;
-       
+
        /**
         * Length of the whole IKEv2-Message (header and all payloads).
         */
@@ -111,7 +111,7 @@ ENUM_END(exchange_type_names, INFORMATIONAL);
 
 /**
  * Encoding rules to parse or generate a IKEv2-Header.
- * 
+ *
  * The defined offsets are the positions in a object of type
  * ike_header_t.
  */
@@ -191,9 +191,9 @@ static status_t verify(private_ike_header_t *this)
                /* initiator spi not set */
                return FAILED;
        }
-       
+
        /* verification of version is not done in here */
-       
+
        return SUCCESS;
 }
 
@@ -372,7 +372,7 @@ static size_t get_length(payload_t *this)
 ike_header_t *ike_header_create()
 {
        private_ike_header_t *this = malloc_thing(private_ike_header_t);
-       
+
        this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
        this->public.payload_interface.get_encoding_rules = get_encoding_rules;
        this->public.payload_interface.get_length = get_length;
@@ -381,7 +381,7 @@ ike_header_t *ike_header_create()
        this->public.payload_interface.get_type = get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
        this->public.destroy = destroy;
-       
+
        this->public.get_initiator_spi = (u_int64_t (*) (ike_header_t*))get_initiator_spi;
        this->public.set_initiator_spi = (void (*) (ike_header_t*,u_int64_t))set_initiator_spi;
        this->public.get_responder_spi = (u_int64_t (*) (ike_header_t*))get_responder_spi;
@@ -397,7 +397,7 @@ ike_header_t *ike_header_create()
        this->public.set_exchange_type = (void (*) (ike_header_t*,u_int8_t))set_exchange_type;
        this->public.get_message_id = (u_int32_t (*) (ike_header_t*))get_message_id;
        this->public.set_message_id = (void (*) (ike_header_t*,u_int32_t))set_message_id;
-       
+
        /* set default values of the fields */
        this->initiator_spi = 0;
        this->responder_spi = 0;
@@ -410,6 +410,6 @@ ike_header_t *ike_header_create()
        this->flags.response = FALSE;
        this->message_id = 0;
        this->length = IKE_HEADER_LENGTH;
-       
+
        return (ike_header_t*)this;
 }
index 4514c23b736d3313431ec4fa4f3bb22782214392..e63e8bf06ad5789497cd5e483b95b20778e10416 100644 (file)
@@ -60,7 +60,7 @@ enum exchange_type_t{
         * EXCHANGE_TYPE_UNDEFINED. In private space, since not a official message type.
         */
        EXCHANGE_TYPE_UNDEFINED = 255,
-       
+
        /**
         * IKE_SA_INIT.
         */
@@ -106,56 +106,56 @@ struct ike_header_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Get the initiator spi.
         *
         * @return                              initiator_spi
         */
        u_int64_t (*get_initiator_spi) (ike_header_t *this);
-       
+
        /**
         * Set the initiator spi.
         *
         * @param initiator_spi initiator_spi
         */
        void (*set_initiator_spi) (ike_header_t *this, u_int64_t initiator_spi);
-       
+
        /**
         * Get the responder spi.
         *
         * @return                              responder_spi
         */
        u_int64_t (*get_responder_spi) (ike_header_t *this);
-       
+
        /**
         * Set the responder spi.
         *
         * @param responder_spi responder_spi
         */
        void (*set_responder_spi) (ike_header_t *this, u_int64_t responder_spi);
-       
+
        /**
         * Get the major version.
         *
         * @return                              major version
         */
        u_int8_t (*get_maj_version) (ike_header_t *this);
-       
+
        /**
         * Get the minor version.
         *
         * @return                              minor version
         */
        u_int8_t (*get_min_version) (ike_header_t *this);
-       
+
        /**
         * Get the response flag.
         *
         * @return                              response flag
         */
        bool (*get_response_flag) (ike_header_t *this);
-       
+
        /**
         * Set the response flag-
         *
@@ -168,14 +168,14 @@ struct ike_header_t {
         * @return                              version flag
         */
        bool (*get_version_flag) (ike_header_t *this);
-       
+
        /**
         * Get the initiator flag.
         *
         * @return                              initiator flag
         */
        bool (*get_initiator_flag) (ike_header_t *this);
-       
+
        /**
         * Set the initiator flag.
         *
@@ -189,28 +189,28 @@ struct ike_header_t {
         * @return                              exchange type
         */
        u_int8_t (*get_exchange_type) (ike_header_t *this);
-       
+
        /**
         * Set the  exchange type.
         *
         * @param exchange_type exchange type
         */
        void (*set_exchange_type) (ike_header_t *this, u_int8_t exchange_type);
-       
+
        /**
         * Get the message id.
         *
         * @return                              message id
         */
        u_int32_t (*get_message_id) (ike_header_t *this);
-       
+
        /**
         * Set the message id.
         *
         * @param initiator_spi message id
         */
        void (*set_message_id) (ike_header_t *this, u_int32_t message_id);
-       
+
        /**
         * Destroys a ike_header_t object.
         */
index aa3e075cab1bfc6eedc1614978fac8bf0bb7b2a1..343a50d2c22e78710e2be74c4dfe09cdf69fb5d3 100644 (file)
@@ -25,14 +25,14 @@ typedef struct private_ke_payload_t private_ke_payload_t;
 
 /**
  * Private data of an ke_payload_t object.
- * 
+ *
  */
 struct private_ke_payload_t {
        /**
         * Public ke_payload_t interface.
         */
        ke_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -42,17 +42,17 @@ struct private_ke_payload_t {
         * Critical flag.
         */
        bool critical;
-               
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * DH Group Number.
         */
        u_int16_t dh_group_number;
-       
+
        /**
         * Key Exchange Data of this KE payload.
         */
@@ -61,30 +61,30 @@ struct private_ke_payload_t {
 
 /**
  * Encoding rules to parse or generate a IKEv2-KE Payload.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_ke_payload_t.
- * 
+ *
  */
 encoding_rule_t ke_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
        { U_INT_8,                      offsetof(private_ke_payload_t, next_payload)            },
        /* the critical bit */
-       { FLAG,                         offsetof(private_ke_payload_t, critical)                        },      
+       { FLAG,                         offsetof(private_ke_payload_t, critical)                        },
        /* 7 Bit reserved bits, nowhere stored */
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
        /* Length of the whole payload*/
-       { PAYLOAD_LENGTH,       offsetof(private_ke_payload_t, payload_length)          },      
+       { PAYLOAD_LENGTH,       offsetof(private_ke_payload_t, payload_length)          },
        /* DH Group number as 16 bit field*/
        { U_INT_16,                     offsetof(private_ke_payload_t, dh_group_number)         },
-       { RESERVED_BYTE,        0                                                                                                       }, 
-       { RESERVED_BYTE,        0                                                                                                       }, 
+       { RESERVED_BYTE,        0                                                                                                       },
+       { RESERVED_BYTE,        0                                                                                                       },
        /* Key Exchange Data is from variable size */
        { KEY_EXCHANGE_DATA,    offsetof(private_ke_payload_t, key_exchange_data)}
 };
@@ -166,7 +166,7 @@ static void compute_length(private_ke_payload_t *this)
        if (this->key_exchange_data.ptr != NULL)
        {
                length += this->key_exchange_data.len;
-       }       
+       }
        this->payload_length = length;
 }
 
@@ -199,9 +199,9 @@ static void set_key_exchange_data(private_ke_payload_t *this, chunk_t key_exchan
                free(this->key_exchange_data.ptr);
                this->key_exchange_data.ptr = NULL;
                this->key_exchange_data.len = 0;
-               
+
        }
-       
+
        this->key_exchange_data = chunk_clone(key_exchange_data);
        compute_length(this);
 }
@@ -244,7 +244,7 @@ ke_payload_t *ke_payload_create()
        this->public.get_dh_group_number = (diffie_hellman_group_t (*) (ke_payload_t *)) get_dh_group_number;
        this->public.set_dh_group_number =(void (*) (ke_payload_t *,diffie_hellman_group_t)) set_dh_group_number;
        this->public.destroy = (void (*) (ke_payload_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
@@ -261,10 +261,10 @@ ke_payload_t *ke_payload_create()
 ke_payload_t *ke_payload_create_from_diffie_hellman(diffie_hellman_t *dh)
 {
        private_ke_payload_t *this = (private_ke_payload_t*)ke_payload_create();
-       
+
        dh->get_my_public_value(dh, &this->key_exchange_data);
        this->dh_group_number = dh->get_dh_group(dh);
        compute_length(this);
-       
+
        return &this->public;
 }
index 7e182d97008896b173a570409221fa731c342050..3ca05009eba5f4f958330103d3dfed0aa6a956e5 100644 (file)
@@ -45,38 +45,38 @@ struct ke_payload_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Returns the currently set key exchange data of this KE payload.
-        *      
+        *
         * @warning Returned data are not copied.
-        * 
+        *
         * @return              chunk_t pointing to the value
         */
        chunk_t (*get_key_exchange_data) (ke_payload_t *this);
-       
+
        /**
         * Sets the key exchange data of this KE payload.
-        *      
+        *
         * Value is getting copied.
-        * 
+        *
         * @param key_exchange_data chunk_t pointing to the value to set
         */
        void (*set_key_exchange_data) (ke_payload_t *this, chunk_t key_exchange_data);
 
        /**
         * Gets the Diffie-Hellman Group Number of this KE payload.
-        *      
+        *
         * @return                                      DH Group Number of this payload
         */
        diffie_hellman_group_t (*get_dh_group_number) (ke_payload_t *this);
 
        /**
         * Sets the Diffie-Hellman Group Number of this KE payload.
-        *      
+        *
         * @param dh_group_number       DH Group to set
         */
-       void (*set_dh_group_number) (ke_payload_t *this, 
+       void (*set_dh_group_number) (ke_payload_t *this,
                                                                 diffie_hellman_group_t dh_group_number);
 
        /**
@@ -87,14 +87,14 @@ struct ke_payload_t {
 
 /**
  * Creates an empty ke_payload_t object
- * 
+ *
  * @return ke_payload_t object
  */
 ke_payload_t *ke_payload_create(void);
 
 /**
  * Creates a ke_payload_t from a diffie_hellman_t
- * 
+ *
  * @param diffie_hellman       diffie hellman object containing group and key
  * @return                                     ke_payload_t object
  */
index f9e075380f249b30e2ba7d1adb1069530eb0dfed..3de889ec3a8b177e69da94597eb12aa4106d2abb 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /* offsetof macro */
 #include <stddef.h>
 
@@ -26,14 +26,14 @@ typedef struct private_nonce_payload_t private_nonce_payload_t;
 
 /**
  * Private data of an nonce_payload_t object.
- * 
+ *
  */
 struct private_nonce_payload_t {
        /**
         * Public nonce_payload_t interface.
         */
        nonce_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -43,12 +43,12 @@ struct private_nonce_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * The contained nonce value.
         */
@@ -57,26 +57,26 @@ struct private_nonce_payload_t {
 
 /**
  * Encoding rules to parse or generate a nonce payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_nonce_payload_t.
- * 
+ *
  */
 encoding_rule_t nonce_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
        { U_INT_8,                      offsetof(private_nonce_payload_t, next_payload)         },
        /* the critical bit */
-       { FLAG,                         offsetof(private_nonce_payload_t, critical)             },      
+       { FLAG,                         offsetof(private_nonce_payload_t, critical)             },
        /* 7 Bit reserved bits, nowhere stored */
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
        /* Length of the whole nonce payload*/
-       { PAYLOAD_LENGTH,       offsetof(private_nonce_payload_t, payload_length)       },      
+       { PAYLOAD_LENGTH,       offsetof(private_nonce_payload_t, payload_length)       },
        /* some nonce bytes, lenth is defined in PAYLOAD_LENGTH */
        { NONCE_DATA,                   offsetof(private_nonce_payload_t, nonce)                }
 };
@@ -102,7 +102,7 @@ static status_t verify(private_nonce_payload_t *this)
                /* nonce length is wrong */
                return FAILED;
        }
-       
+
        return SUCCESS;
 }
 
@@ -187,8 +187,8 @@ static void destroy(private_nonce_payload_t *this)
        {
                free(this->nonce.ptr);
        }
-       
-       free(this);     
+
+       free(this);
 }
 
 /*
@@ -206,12 +206,12 @@ nonce_payload_t *nonce_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (nonce_payload_t *)) destroy;
        this->public.set_nonce = (void (*) (nonce_payload_t *,chunk_t)) set_nonce;
        this->public.get_nonce = (chunk_t (*) (nonce_payload_t *)) get_nonce;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
index 4adaba481762f6d39edcd4da358d7bcae5465ac9..025d7752448b856a54a602446c94fcd36c091f34 100644 (file)
@@ -39,7 +39,7 @@ typedef struct nonce_payload_t nonce_payload_t;
 
 /**
  * Object representing an IKEv2 Nonce payload.
- * 
+ *
  * The Nonce payload format is described in RFC section 3.3.
  */
 struct nonce_payload_t {
@@ -54,14 +54,14 @@ struct nonce_payload_t {
         * @param nonce                 chunk containing the nonce, will be cloned
         */
        void (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
-       
+
        /**
         * Get the nonce value.
         *
         * @return                              a chunk containing the cloned nonce
         */
        chunk_t (*get_nonce) (nonce_payload_t *this);
-       
+
        /**
         * Destroys an nonce_payload_t object.
         */
@@ -70,7 +70,7 @@ struct nonce_payload_t {
 
 /**
  * Creates an empty nonce_payload_t object
- * 
+ *
  * @return nonce_payload_t object
  */
 nonce_payload_t *nonce_payload_create(void);
index d2a995ace0be20d0bedaeb276448ca95fb9ab123..838fae0cc780ccfdac2a6a7b280dc2401ebba3fd 100644 (file)
@@ -160,14 +160,14 @@ typedef struct private_notify_payload_t private_notify_payload_t;
 
 /**
  * Private data of an notify_payload_t object.
- * 
+ *
  */
 struct private_notify_payload_t {
        /**
         * Public notify_payload_t interface.
         */
        notify_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -177,27 +177,27 @@ struct private_notify_payload_t {
         * Critical flag.
         */
        bool critical;
-               
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-               
+
        /**
         * Protocol id.
         */
        u_int8_t protocol_id;
-       
+
        /**
         * Spi size.
         */
        u_int8_t spi_size;
-       
+
        /**
         * Notify message type.
         */
        u_int16_t notify_type;
-       
+
        /**
         * Security parameter index (spi).
         */
@@ -211,26 +211,26 @@ struct private_notify_payload_t {
 
 /**
  * Encoding rules to parse or generate a IKEv2-Notify Payload.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_notify_payload_t.
- * 
+ *
  */
 encoding_rule_t notify_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
        { U_INT_8,                      offsetof(private_notify_payload_t, next_payload)                },
        /* the critical bit */
-       { FLAG,                         offsetof(private_notify_payload_t, critical)                    },      
+       { FLAG,                         offsetof(private_notify_payload_t, critical)                    },
        /* 7 Bit reserved bits, nowhere stored */
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
        /* Length of the whole payload*/
-       { PAYLOAD_LENGTH,       offsetof(private_notify_payload_t, payload_length)              },      
+       { PAYLOAD_LENGTH,       offsetof(private_notify_payload_t, payload_length)              },
        /* Protocol ID as 8 bit field*/
        { U_INT_8,                      offsetof(private_notify_payload_t, protocol_id)                         },
        /* SPI Size as 8 bit field*/
@@ -279,7 +279,7 @@ static status_t verify(private_notify_payload_t *this)
                        DBG1(DBG_ENC, "Unknown protocol (%d)", this->protocol_id);
                        return FAILED;
        }
-       
+
        switch (this->notify_type)
        {
                case INVALID_KE_PAYLOAD:
@@ -567,7 +567,7 @@ notify_payload_t *notify_payload_create()
        this->public.get_notification_data = (chunk_t (*) (notify_payload_t *)) get_notification_data;
        this->public.set_notification_data = (void (*) (notify_payload_t *,chunk_t)) set_notification_data;
        this->public.destroy = (void (*) (notify_payload_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
@@ -579,7 +579,7 @@ notify_payload_t *notify_payload_create()
        this->spi_size = 0;
        this->notification_data.ptr = NULL;
        this->notification_data.len = 0;
-       
+
        return &this->public;
 }
 
@@ -592,6 +592,6 @@ notify_payload_t *notify_payload_create_from_protocol_and_type(protocol_id_t pro
 
        notify->set_notify_type(notify,notify_type);
        notify->set_protocol_id(notify,protocol_id);
-       
+
        return notify;
 }
index a5f501dcabdf0c56997f1b5f411ce4c51ad73344..c8dbd91714078e66a3596c3ae78fc485dd5d940c 100644 (file)
@@ -63,7 +63,7 @@ enum notify_type_t {
        UNEXPECTED_NAT_DETECTED = 41,
        /* IKE-ME, private use */
        ME_CONNECT_FAILED = 8192,
-       
+
        /* notify status messages */
        INITIAL_CONTACT = 16384,
        SET_WINDOW_SIZE = 16385,
@@ -116,7 +116,7 @@ extern enum_name_t *notify_type_short_names;
 
 /**
  * Class representing an IKEv2-Notify Payload.
- * 
+ *
  * The Notify Payload format is described in Draft section 3.10.
  */
 struct notify_payload_t {
@@ -124,67 +124,67 @@ struct notify_payload_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Gets the protocol id of this payload.
-        *      
+        *
         * @return                      protocol id of this payload
         */
        u_int8_t (*get_protocol_id) (notify_payload_t *this);
 
        /**
         * Sets the protocol id of this payload.
-        *      
+        *
         * @param protocol_id   protocol id to set
         */
        void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
 
        /**
         * Gets the notify message type of this payload.
-        *      
+        *
         * @return                      notify message type of this payload
         */
        notify_type_t (*get_notify_type) (notify_payload_t *this);
 
        /**
         * Sets notify message type of this payload.
-        *      
+        *
         * @param type          notify message type to set
         */
        void (*set_notify_type) (notify_payload_t *this, notify_type_t type);
 
        /**
         * Returns the currently set spi of this payload.
-        * 
+        *
         * This is only valid for notifys with protocol AH|ESP
         *
         * @return              SPI value
         */
        u_int32_t (*get_spi) (notify_payload_t *this);
-       
+
        /**
         * Sets the spi of this payload.
-        * 
+        *
         * This is only valid for notifys with protocol AH|ESP
-        * 
+        *
         * @param spi   SPI value
         */
        void (*set_spi) (notify_payload_t *this, u_int32_t spi);
 
        /**
         * Returns the currently set notification data of payload.
-        *      
+        *
         * Returned data are not copied.
-        * 
+        *
         * @return              chunk_t pointing to the value
         */
        chunk_t (*get_notification_data) (notify_payload_t *this);
-       
+
        /**
         * Sets the notification data of this payload.
-        *      
+        *
         * @warning Value is getting copied.
-        * 
+        *
         * @param notification_data     chunk_t pointing to the value to set
         */
        void (*set_notification_data) (notify_payload_t *this,
@@ -198,14 +198,14 @@ struct notify_payload_t {
 
 /**
  * Creates an empty notify_payload_t object
- * 
+ *
  * @return                     created notify_payload_t object
  */
 notify_payload_t *notify_payload_create(void);
 
 /**
  * Creates an notify_payload_t object of specific type for specific protocol id.
- * 
+ *
  * @param protocol_id                  protocol id (IKE, AH or ESP)
  * @param type                                 notify type (see notify_type_t)
  * @return                                             notify_payload_t object
index 95e702ff82ce09e89b8a1647da43c39af4349f69..2e783cb30938d3efa24dbf771fcefd66fe9ae9ba 100644 (file)
@@ -42,7 +42,7 @@ enum payload_type_t{
         * End of payload list in next_payload
         */
        NO_PAYLOAD = 0,
-       
+
        /**
         * The security association (SA) payload containing proposals.
         */
@@ -122,7 +122,7 @@ enum payload_type_t{
         * Extensible authentication payload (EAP).
         */
        EXTENSIBLE_AUTHENTICATION = 48,
-       
+
 #ifdef ME
        /**
         * Identification payload for peers has a value from
@@ -130,7 +130,7 @@ enum payload_type_t{
         */
        ID_PEER = 128,
 #endif /* ME */
-       
+
        /**
         * Header has a value of PRIVATE USE space.
         *
@@ -138,7 +138,7 @@ enum payload_type_t{
         * used internally to handle IKEv2-Header like a payload.
         */
        HEADER = 140,
-       
+
        /**
         * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
         *
@@ -154,7 +154,7 @@ enum payload_type_t{
         * used internally to handle a transform substructure like a payload.
         */
        TRANSFORM_SUBSTRUCTURE = 142,
-       
+
        /**
         * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
         *
@@ -170,7 +170,7 @@ enum payload_type_t{
         * used internally to handle a transform selector like a payload.
         */
        TRAFFIC_SELECTOR_SUBSTRUCTURE = 144,
-       
+
        /**
         * CONFIGURATION_ATTRIBUTE has a value of PRIVATE USE space.
         *
@@ -178,7 +178,7 @@ enum payload_type_t{
         * used internally to handle a transform attribute like a payload.
         */
        CONFIGURATION_ATTRIBUTE = 145,
-       
+
        /**
         * A unknown payload has a value of PRIVATE USE space.
         *
@@ -207,7 +207,7 @@ extern enum_name_t *payload_type_short_names;
  * handling of all payloads.
  */
 struct payload_t {
-       
+
        /**
         * Get encoding rules for this payload.
         *
@@ -229,7 +229,7 @@ struct payload_t {
         * @return                              type of next payload
         */
        payload_type_t (*get_next_type) (payload_t *this);
-       
+
        /**
         * Set type of next payload.
         *
@@ -243,14 +243,14 @@ struct payload_t {
         * @return                              length of this payload
         */
        size_t (*get_length) (payload_t *this);
-       
+
        /**
         * Verifies payload structure and makes consistence check.
         *
         * @return                              SUCCESS,  FAILED if consistence not given
         */
        status_t (*verify) (payload_t *this);
-       
+
        /**
         * Destroys a payload and all included substructures.
         */
index a8166023c1358e324e676859e05722b610abf86b..15630e7edff9a68748ff656572a9dc17db77c101 100644 (file)
@@ -35,14 +35,14 @@ typedef struct private_proposal_substructure_t private_proposal_substructure_t;
 
 /**
  * Private data of an proposal_substructure_t object.
- * 
+ *
  */
 struct private_proposal_substructure_t {
        /**
         * Public proposal_substructure_t interface.
         */
        proposal_substructure_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -52,12 +52,12 @@ struct private_proposal_substructure_t {
         * Length of this payload.
         */
        u_int16_t proposal_length;
-       
+
        /**
         * Proposal number.
         */
        u_int8_t proposal_number;
-       
+
        /**
         * Protocol ID.
         */
@@ -72,12 +72,12 @@ struct private_proposal_substructure_t {
         * Number of transforms.
         */
        u_int8_t  transforms_count;
-       
+
        /**
         * SPI is stored as chunk.
         */
        chunk_t spi;
-       
+
        /**
         * Transforms are stored in a linked_list_t.
         */
@@ -87,7 +87,7 @@ struct private_proposal_substructure_t {
 /**
  * Encoding rules to parse or generate a Proposal substructure.
  *
- * The defined offsets are the positions in a object of type 
+ * The defined offsets are the positions in a object of type
  * private_proposal_substructure_t.
  */
 encoding_rule_t proposal_substructure_encodings[] = {
@@ -107,7 +107,7 @@ encoding_rule_t proposal_substructure_encodings[] = {
        { U_INT_8,                              offsetof(private_proposal_substructure_t, transforms_count)     },
        /* SPI is a chunk of variable size*/
        { SPI,                                  offsetof(private_proposal_substructure_t, spi)                          },
-       /* Transforms are stored in a transform substructure, 
+       /* Transforms are stored in a transform substructure,
           offset points to a linked_list_t pointer */
        { TRANSFORMS,                   offsetof(private_proposal_substructure_t, transforms)           }
 };
@@ -136,7 +136,7 @@ static status_t verify(private_proposal_substructure_t *this)
        status_t status = SUCCESS;
        iterator_t *iterator;
        payload_t *current_transform;
-       
+
        if ((this->next_payload != NO_PAYLOAD) && (this->next_payload != 2))
        {
                /* must be 0 or 2 */
@@ -178,7 +178,7 @@ static status_t verify(private_proposal_substructure_t *this)
                DBG1(DBG_ENC, "invalid protocol");
                return FAILED;
        }
-       
+
        iterator = this->transforms->create_iterator(this->transforms,TRUE);
        while(iterator->iterate(iterator, (void**)&current_transform))
        {
@@ -190,8 +190,8 @@ static status_t verify(private_proposal_substructure_t *this)
                }
        }
        iterator->destroy(iterator);
-       
-       /* proposal number is checked in SA payload */  
+
+       /* proposal number is checked in SA payload */
        return status;
 }
 
@@ -236,7 +236,7 @@ static void compute_length(private_proposal_substructure_t *this)
        payload_t *current_transform;
        size_t transforms_count = 0;
        size_t length = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH;
-       
+
        iterator = this->transforms->create_iterator(this->transforms,TRUE);
        while (iterator->iterate(iterator, (void**)&current_transform))
        {
@@ -244,7 +244,7 @@ static void compute_length(private_proposal_substructure_t *this)
                transforms_count++;
        }
        iterator->destroy(iterator);
-       
+
        length += this->spi.len;
        this->transforms_count = transforms_count;
        this->proposal_length = length;
@@ -282,7 +282,7 @@ static void add_transform_substructure (private_proposal_substructure_t *this,tr
 
        }
        transform->set_is_last_transform(transform,TRUE);
-       
+
        this->transforms->insert_last(this->transforms,(void *) transform);
        compute_length(this);
 }
@@ -340,7 +340,7 @@ static void set_spi(private_proposal_substructure_t *this, chunk_t spi)
                this->spi.len = 0;
                compute_length(this);
        }
-       
+
        this->spi.ptr = clalloc(spi.ptr,spi.len);
        this->spi.len = spi.len;
        this->spi_size = spi.len;
@@ -355,7 +355,7 @@ static chunk_t get_spi(private_proposal_substructure_t *this)
        chunk_t spi;
        spi.ptr = this->spi.ptr;
        spi.len = this->spi.len;
-       
+
        return spi;
 }
 
@@ -384,24 +384,24 @@ proposal_t* get_proposal(private_proposal_substructure_t *this)
        transform_substructure_t *transform;
        proposal_t *proposal;
        u_int64_t spi;
-       
+
        proposal = proposal_create(this->protocol_id);
-       
+
        iterator = this->transforms->create_iterator(this->transforms, TRUE);
        while (iterator->iterate(iterator, (void**)&transform))
        {
                transform_type_t transform_type;
                u_int16_t transform_id;
                u_int16_t key_length = 0;
-               
+
                transform_type = transform->get_transform_type(transform);
                transform_id = transform->get_transform_id(transform);
                transform->get_key_length(transform, &key_length);
-               
+
                proposal->add_algorithm(proposal, transform_type, transform_id, key_length);
        }
        iterator->destroy(iterator);
-       
+
        switch (this->spi.len)
        {
                case 4:
@@ -414,7 +414,7 @@ proposal_t* get_proposal(private_proposal_substructure_t *this)
                        spi = 0;
        }
        proposal->set_spi(proposal, spi);
-       
+
        return proposal;
 }
 
@@ -426,7 +426,7 @@ static private_proposal_substructure_t* clone_(private_proposal_substructure_t *
        private_proposal_substructure_t *clone;
        iterator_t *transforms;
        transform_substructure_t *current_transform;
-       
+
        clone = (private_proposal_substructure_t *) proposal_substructure_create();
        clone->next_payload = this->next_payload;
        clone->proposal_number = this->proposal_number;
@@ -444,8 +444,8 @@ static private_proposal_substructure_t* clone_(private_proposal_substructure_t *
                current_transform = current_transform->clone(current_transform);
                clone->public.add_transform_substructure(&clone->public, current_transform);
        }
-       transforms->destroy(transforms);        
-       
+       transforms->destroy(transforms);
+
        return clone;
 }
 
@@ -468,16 +468,16 @@ proposal_substructure_t *proposal_substructure_create()
 {
        private_proposal_substructure_t *this = malloc_thing(private_proposal_substructure_t);
 
-       /* interface functions */       
+       /* interface functions */
        this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
        this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
        this->public.payload_interface.get_length = (size_t (*) (payload_t *)) get_length;
        this->public.payload_interface.get_next_type = (payload_type_t (*) (payload_t *)) get_next_type;
-       this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;   
+       this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
-       
+
+
        /* public functions */
        this->public.create_transform_substructure_iterator = (iterator_t* (*) (proposal_substructure_t *,bool)) create_transform_substructure_iterator;
        this->public.add_transform_substructure = (void (*) (proposal_substructure_t *,transform_substructure_t *)) add_transform_substructure;
@@ -490,10 +490,10 @@ proposal_substructure_t *proposal_substructure_create()
        this->public.set_spi = (void (*) (proposal_substructure_t *,chunk_t))set_spi;
        this->public.get_spi = (chunk_t (*) (proposal_substructure_t *)) get_spi;
        this->public.get_transform_count = (size_t (*) (proposal_substructure_t *)) get_transform_count;
-       this->public.get_spi_size = (size_t (*) (proposal_substructure_t *)) get_spi_size;      
+       this->public.get_spi_size = (size_t (*) (proposal_substructure_t *)) get_spi_size;
        this->public.clone = (proposal_substructure_t * (*) (proposal_substructure_t *)) clone_;
        this->public.destroy = (void (*) (proposal_substructure_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->next_payload = NO_PAYLOAD;
        this->proposal_length = 0;
@@ -503,9 +503,9 @@ proposal_substructure_t *proposal_substructure_create()
        this->spi_size = 0;
        this->spi.ptr = NULL;
        this->spi.len = 0;
-       
+
        this->transforms = linked_list_create();
-       
+
        return (&(this->public));
 }
 
@@ -518,9 +518,9 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
        private_proposal_substructure_t *this;
        u_int16_t alg, key_size;
        enumerator_t *enumerator;
-       
+
        this = (private_proposal_substructure_t*)proposal_substructure_create();
-       
+
        /* encryption algorithm is only availble in ESP */
        enumerator = proposal->create_enumerator(proposal, ENCRYPTION_ALGORITHM);
        while (enumerator->enumerate(enumerator, &alg, &key_size))
@@ -530,7 +530,7 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
                add_transform_substructure(this, transform);
        }
        enumerator->destroy(enumerator);
-       
+
        /* integrity algorithms */
        enumerator = proposal->create_enumerator(proposal, INTEGRITY_ALGORITHM);
        while (enumerator->enumerate(enumerator, &alg, &key_size))
@@ -540,7 +540,7 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
                add_transform_substructure(this, transform);
        }
        enumerator->destroy(enumerator);
-       
+
        /* prf algorithms */
        enumerator = proposal->create_enumerator(proposal, PSEUDO_RANDOM_FUNCTION);
        while (enumerator->enumerate(enumerator, &alg, &key_size))
@@ -550,17 +550,17 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
                add_transform_substructure(this, transform);
        }
        enumerator->destroy(enumerator);
-       
+
        /* dh groups */
        enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
        while (enumerator->enumerate(enumerator, &alg, NULL))
        {
-               transform = transform_substructure_create_type(DIFFIE_HELLMAN_GROUP, 
+               transform = transform_substructure_create_type(DIFFIE_HELLMAN_GROUP,
                                                                                                           alg, 0);
                add_transform_substructure(this, transform);
        }
        enumerator->destroy(enumerator);
-       
+
        /* extended sequence numbers */
        enumerator = proposal->create_enumerator(proposal, EXTENDED_SEQUENCE_NUMBERS);
        while (enumerator->enumerate(enumerator, &alg, NULL))
@@ -570,7 +570,7 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
                add_transform_substructure(this, transform);
        }
        enumerator->destroy(enumerator);
-       
+
        /* add SPI, if necessary */
        switch (proposal->get_protocol(proposal))
        {
@@ -593,6 +593,6 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
        }
        this->proposal_number = 0;
        this->protocol_id = proposal->get_protocol(proposal);
-       
+
        return &this->public;
 }
index 8ccb917d6bf1e2f057ff4825d20280df6dad0b06..4934802af213c96609ad39ba5f1da4aa530c7701 100644 (file)
@@ -38,7 +38,7 @@ typedef struct proposal_substructure_t proposal_substructure_t;
 
 /**
  * Class representing an IKEv2-PROPOSAL SUBSTRUCTURE.
- * 
+ *
  * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
  */
 struct proposal_substructure_t {
@@ -55,7 +55,7 @@ struct proposal_substructure_t {
         */
        iterator_t *(*create_transform_substructure_iterator) (
                                                                proposal_substructure_t *this, bool forward);
-       
+
        /**
         * Adds a transform_substructure_t object to this object.
         *
@@ -63,7 +63,7 @@ struct proposal_substructure_t {
         */
        void (*add_transform_substructure) (proposal_substructure_t *this,
                                                                                transform_substructure_t *transform);
-       
+
        /**
         * Sets the proposal number of current proposal.
         *
@@ -71,24 +71,24 @@ struct proposal_substructure_t {
         */
        void (*set_proposal_number) (proposal_substructure_t *this,
                                                                 u_int8_t proposal_number);
-       
+
        /**
         * get proposal number of current proposal.
-        * 
+        *
         * @return                      proposal number of current proposal substructure.
         */
        u_int8_t (*get_proposal_number) (proposal_substructure_t *this);
 
        /**
         * get the number of transforms in current proposal.
-        * 
+        *
         * @return                      transform count in current proposal
         */
        size_t (*get_transform_count) (proposal_substructure_t *this);
 
        /**
         * get size of the set spi in bytes.
-        * 
+        *
         * @return                      size of the spi in bytes
         */
        size_t (*get_spi_size) (proposal_substructure_t *this);
@@ -100,43 +100,43 @@ struct proposal_substructure_t {
         */
        void (*set_protocol_id) (proposal_substructure_t *this,
                                                         u_int8_t protocol_id);
-       
+
        /**
         * get protocol id of current proposal.
-        * 
+        *
         * @return                      protocol id of current proposal substructure.
         */
        u_int8_t (*get_protocol_id) (proposal_substructure_t *this);
-       
+
        /**
         * Sets the next_payload field of this substructure
-        * 
+        *
         * If this is the last proposal, next payload field is set to 0,
         * otherwise to 2
         *
         * @param is_last       When TRUE, next payload field is set to 0, otherwise to 2
         */
        void (*set_is_last_proposal) (proposal_substructure_t *this, bool is_last);
-       
+
        /**
         * Returns the currently set SPI of this proposal.
         *
         * @return                      chunk_t pointing to the value
         */
        chunk_t (*get_spi) (proposal_substructure_t *this);
-       
+
        /**
         * Sets the SPI of the current proposal.
-        *      
+        *
         * @warning SPI is getting copied
-        * 
+        *
         * @param spi           chunk_t pointing to the value to set
         */
        void (*set_spi) (proposal_substructure_t *this, chunk_t spi);
-       
+
        /**
         * Get a proposal_t from the propsal_substructure_t.
-        * 
+        *
         * @return                      proposal_t
         */
        proposal_t * (*get_proposal) (proposal_substructure_t *this);
@@ -156,7 +156,7 @@ struct proposal_substructure_t {
 
 /**
  * Creates an empty proposal_substructure_t object
- * 
+ *
  * @return proposal_substructure_t object
  */
 proposal_substructure_t *proposal_substructure_create(void);
index 3ca2f08c8ccdc2fda21db4c02dbe3b3ab3bc49af..6a9aac64511e388a530d3fc5f6df1a138eb61398 100644 (file)
@@ -27,14 +27,14 @@ typedef struct private_sa_payload_t private_sa_payload_t;
 
 /**
  * Private data of an sa_payload_t object.
- * 
+ *
  */
 struct private_sa_payload_t {
        /**
         * Public sa_payload_t interface.
         */
        sa_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -44,12 +44,12 @@ struct private_sa_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Proposals in this payload are stored in a linked_list_t.
         */
@@ -58,27 +58,27 @@ struct private_sa_payload_t {
 
 /**
  * Encoding rules to parse or generate a IKEv2-SA Payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_sa_payload_t.
- * 
+ *
  */
 encoding_rule_t sa_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
        { U_INT_8,              offsetof(private_sa_payload_t, next_payload)                    },
        /* the critical bit */
-       { FLAG,                 offsetof(private_sa_payload_t, critical)                                },      
+       { FLAG,                 offsetof(private_sa_payload_t, critical)                                },
        /* 7 Bit reserved bits, nowhere stored */
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
-       { RESERVED_BIT, 0                                                                                                               }, 
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
+       { RESERVED_BIT, 0                                                                                                               },
        /* Length of the whole SA payload*/
-       { PAYLOAD_LENGTH,               offsetof(private_sa_payload_t, payload_length)  },      
-       /* Proposals are stored in a proposal substructure, 
+       { PAYLOAD_LENGTH,               offsetof(private_sa_payload_t, payload_length)  },
+       /* Proposals are stored in a proposal substructure,
           offset points to a linked_list_t pointer */
        { PROPOSALS,            offsetof(private_sa_payload_t, proposals)                               }
 };
@@ -108,12 +108,12 @@ static status_t verify(private_sa_payload_t *this)
 
        /* check proposal numbering */
        iterator = this->proposals->create_iterator(this->proposals,TRUE);
-       
+
        while(iterator->iterate(iterator, (void**)&current_proposal))
        {
                current_number = current_proposal->get_proposal_number(current_proposal);
                if (current_number < expected_number)
-               {                       
+               {
                        if (current_number != (expected_number + 1))
                        {
                                DBG1(DBG_ENC, "proposal number is %d, expected %d or %d",
@@ -129,7 +129,7 @@ static status_t verify(private_sa_payload_t *this)
                        status = FAILED;
                        break;
                }
-               
+
                status = current_proposal->payload_interface.verify(&(current_proposal->payload_interface));
                if (status != SUCCESS)
                {
@@ -139,7 +139,7 @@ static status_t verify(private_sa_payload_t *this)
                first = FALSE;
                expected_number = current_number;
        }
-       
+
        iterator->destroy(iterator);
        return status;
 }
@@ -197,14 +197,14 @@ static void compute_length (private_sa_payload_t *this)
        iterator_t *iterator;
        payload_t *current_proposal;
        size_t length = SA_PAYLOAD_HEADER_LENGTH;
-       
+
        iterator = this->proposals->create_iterator(this->proposals,TRUE);
        while (iterator->iterate(iterator, (void **)&current_proposal))
        {
                length += current_proposal->get_length(current_proposal);
        }
        iterator->destroy(iterator);
-       
+
        this->payload_length = length;
 }
 
@@ -232,7 +232,7 @@ static void add_proposal_substructure(private_sa_payload_t *this,proposal_substr
 {
        status_t status;
        u_int proposal_count = this->proposals->get_count(this->proposals);
-       
+
        if (proposal_count > 0)
        {
                proposal_substructure_t *last_proposal;
@@ -252,7 +252,7 @@ static void add_proposal_substructure(private_sa_payload_t *this,proposal_substr
 static void add_proposal(private_sa_payload_t *this, proposal_t *proposal)
 {
        proposal_substructure_t *substructure;
-       
+
        substructure = proposal_substructure_create_from_proposal(proposal);
        add_proposal_substructure(this, substructure);
 }
@@ -267,10 +267,10 @@ static linked_list_t *get_proposals(private_sa_payload_t *this)
        iterator_t *iterator;
        proposal_substructure_t *proposal_struct;
        linked_list_t *proposal_list;
-       
+
        /* this list will hold our proposals */
        proposal_list = linked_list_create();
-       
+
        /* we do not support proposals split up to two proposal substructures, as
         * AH+ESP bundles are not supported in RFC4301 anymore.
         * To handle such structures safely, we just skip proposals with multiple
@@ -280,7 +280,7 @@ static linked_list_t *get_proposals(private_sa_payload_t *this)
        while (iterator->iterate(iterator, (void **)&proposal_struct))
        {
                proposal_t *proposal;
-               
+
                /* check if a proposal has a single protocol */
                if (proposal_struct->get_proposal_number(proposal_struct) == struct_number)
                {
@@ -310,7 +310,7 @@ static linked_list_t *get_proposals(private_sa_payload_t *this)
 sa_payload_t *sa_payload_create()
 {
        private_sa_payload_t *this = malloc_thing(private_sa_payload_t);
-       
+
        /* public interface */
        this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
        this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
@@ -319,14 +319,14 @@ sa_payload_t *sa_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.create_proposal_substructure_iterator = (iterator_t* (*) (sa_payload_t *,bool)) create_proposal_substructure_iterator;
        this->public.add_proposal_substructure = (void (*) (sa_payload_t *,proposal_substructure_t *)) add_proposal_substructure;
        this->public.add_proposal = (void (*) (sa_payload_t*,proposal_t*))add_proposal;
        this->public.get_proposals = (linked_list_t* (*) (sa_payload_t *)) get_proposals;
        this->public.destroy = (void (*) (sa_payload_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
@@ -343,7 +343,7 @@ sa_payload_t *sa_payload_create_from_proposal_list(linked_list_t *proposals)
        iterator_t *iterator;
        proposal_t *proposal;
        sa_payload_t *sa_payload = sa_payload_create();
-       
+
        /* add every payload from the list */
        iterator = proposals->create_iterator(proposals, TRUE);
        while (iterator->iterate(iterator, (void**)&proposal))
@@ -351,7 +351,7 @@ sa_payload_t *sa_payload_create_from_proposal_list(linked_list_t *proposals)
                add_proposal((private_sa_payload_t*)sa_payload, proposal);
        }
        iterator->destroy(iterator);
-       
+
        return sa_payload;
 }
 
@@ -361,8 +361,8 @@ sa_payload_t *sa_payload_create_from_proposal_list(linked_list_t *proposals)
 sa_payload_t *sa_payload_create_from_proposal(proposal_t *proposal)
 {
        sa_payload_t *sa_payload = sa_payload_create();
-       
+
        add_proposal((private_sa_payload_t*)sa_payload, proposal);
-       
+
        return sa_payload;
 }
index 58ae725446e59212a790360d4498cb92ec2a33bb..25f5a24075e4506e3ad4882b99355b4e554a1aac 100644 (file)
@@ -44,12 +44,12 @@ struct sa_payload_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Creates an iterator of stored proposal_substructure_t objects.
-        * 
-        * When deleting an proposal using this iterator, 
-        * the length of this transform substructure has to be refreshed 
+        *
+        * When deleting an proposal using this iterator,
+        * the length of this transform substructure has to be refreshed
         * by calling get_length()!
         *
         * @param forward               iterator direction (TRUE: front to end)
@@ -57,7 +57,7 @@ struct sa_payload_t {
         */
        iterator_t *(*create_proposal_substructure_iterator) (sa_payload_t *this,
                                                                                                                  bool forward);
-       
+
        /**
         * Adds a proposal_substructure_t object to this object.
         *
@@ -68,18 +68,18 @@ struct sa_payload_t {
 
        /**
         * Gets the proposals in this payload as a list.
-        * 
+        *
         * @return                                      a list containing proposal_t s
         */
        linked_list_t *(*get_proposals) (sa_payload_t *this);
-       
+
        /**
         * Add a child proposal (AH/ESP) to the payload.
-        * 
+        *
         * @param proposal                      child proposal to add to the payload
         */
        void (*add_proposal) (sa_payload_t *this, proposal_t *proposal);
-       
+
        /**
         * Destroys an sa_payload_t object.
         */
@@ -88,14 +88,14 @@ struct sa_payload_t {
 
 /**
  * Creates an empty sa_payload_t object
- * 
+ *
  * @return                                     created sa_payload_t object
  */
 sa_payload_t *sa_payload_create(void);
 
 /**
  * Creates a sa_payload_t object from a list of proposals.
- * 
+ *
  * @param proposals                    list of proposals to build the payload from
  * @return                                     sa_payload_t object
  */
@@ -103,10 +103,10 @@ sa_payload_t *sa_payload_create_from_proposal_list(linked_list_t *proposals);
 
 /**
  * Creates a sa_payload_t object from a single proposal.
- * 
+ *
  * This is only for convenience. Use sa_payload_create_from_proposal_list
  * if you want to add more than one proposal.
- * 
+ *
  * @param proposal                     proposal from which the payload should be built.
  * @return                                     sa_payload_t object
  */
index 7dcdce6aa306543d536628241273ac42c4967a45..a034adee276c0ea9aa9c1f0f2f6bba73fa422e91 100644 (file)
@@ -24,19 +24,19 @@ typedef struct private_traffic_selector_substructure_t private_traffic_selector_
 
 /**
  * Private data of an traffic_selector_substructure_t object.
- * 
+ *
  */
 struct private_traffic_selector_substructure_t {
        /**
         * Public traffic_selector_substructure_t interface.
         */
        traffic_selector_substructure_t public;
-       
+
        /**
         * Type of traffic selector.
         */
        u_int8_t ts_type;
-       
+
        /**
         * IP Protocol ID.
         */
@@ -46,7 +46,7 @@ struct private_traffic_selector_substructure_t {
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Start port number.
         */
@@ -56,7 +56,7 @@ struct private_traffic_selector_substructure_t {
         * End port number.
         */
        u_int16_t end_port;
-       
+
        /**
         * Starting address.
         */
@@ -70,17 +70,17 @@ struct private_traffic_selector_substructure_t {
 
 /**
  * Encoding rules to parse or generate a TS payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_traffic_selector_substructure_t.
- * 
+ *
  */
 encoding_rule_t traffic_selector_substructure_encodings[] = {
        /* 1 Byte next ts type*/
        { TS_TYPE,                      offsetof(private_traffic_selector_substructure_t, ts_type)                      },
        /* 1 Byte IP protocol id*/
        { U_INT_8,                      offsetof(private_traffic_selector_substructure_t, ip_protocol_id)       },
-       /* Length of the whole payload*/        
+       /* Length of the whole payload*/
        { PAYLOAD_LENGTH,       offsetof(private_traffic_selector_substructure_t, payload_length)               },
        /* 2 Byte start port*/
        { U_INT_16,             offsetof(private_traffic_selector_substructure_t, start_port)                   },
@@ -124,7 +124,7 @@ static status_t verify(private_traffic_selector_substructure_t *this)
        {
                case TS_IPV4_ADDR_RANGE:
                {
-                       if ((this->starting_address.len != 4) || 
+                       if ((this->starting_address.len != 4) ||
                                (this->ending_address.len != 4))
                        {
                                /* ipv4 address must be 4 bytes long */
@@ -148,7 +148,7 @@ static status_t verify(private_traffic_selector_substructure_t *this)
                        return FAILED;
                }
        }
-       
+
        return SUCCESS;
 }
 
@@ -182,7 +182,7 @@ static payload_type_t get_next_type(private_traffic_selector_substructure_t *thi
  */
 static void set_next_type(private_traffic_selector_substructure_t *this,payload_type_t type)
 {
-       
+
 }
 
 /**
@@ -199,8 +199,8 @@ static size_t get_length(private_traffic_selector_substructure_t *this)
 static traffic_selector_t *get_traffic_selector(private_traffic_selector_substructure_t *this)
 {
        traffic_selector_t *ts;
-       ts = traffic_selector_create_from_bytes(this->ip_protocol_id, this->ts_type, 
-                                                                                       this->starting_address, this->start_port, 
+       ts = traffic_selector_create_from_bytes(this->ip_protocol_id, this->ts_type,
+                                                                                       this->starting_address, this->start_port,
                                                                                        this->ending_address, this->end_port);
        return ts;
 }
@@ -221,7 +221,7 @@ static void destroy(private_traffic_selector_substructure_t *this)
 {
        free(this->starting_address.ptr);
        free(this->ending_address.ptr);
-       free(this);     
+       free(this);
 }
 
 /*
@@ -239,11 +239,11 @@ traffic_selector_substructure_t *traffic_selector_substructure_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.get_traffic_selector = (traffic_selector_t* (*)(traffic_selector_substructure_t*))get_traffic_selector;
        this->public.destroy = (void (*) (traffic_selector_substructure_t *)) destroy;
-       
+
        /* private variables */
        this->payload_length = TRAFFIC_SELECTOR_HEADER_LENGTH;
        this->start_port = 0;
@@ -269,8 +269,8 @@ traffic_selector_substructure_t *traffic_selector_substructure_create_from_traff
        this->end_port = traffic_selector->get_to_port(traffic_selector);
        this->starting_address = chunk_clone(traffic_selector->get_from_address(traffic_selector));
        this->ending_address = chunk_clone(traffic_selector->get_to_address(traffic_selector));
-       
+
        compute_length(this);
-       
+
        return &(this->public);
 }
index ee3e204a05b3570c84b1a9bc9bdea7ba4404260e..da4c9a4b2d0bf14ca015a530689316924835b9f2 100644 (file)
@@ -36,7 +36,7 @@ typedef struct traffic_selector_substructure_t traffic_selector_substructure_t;
 
 /**
  * Class representing an IKEv2 TRAFFIC SELECTOR.
- * 
+ *
  * The TRAFFIC SELECTOR format is described in RFC section 3.13.1.
  */
 struct traffic_selector_substructure_t {
@@ -44,49 +44,49 @@ struct traffic_selector_substructure_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Get the type of Traffic selector.
         *
         * @return                      type of traffic selector
-        *  
+        *
         */
        ts_type_t (*get_ts_type) (traffic_selector_substructure_t *this);
-       
+
        /**
         * Set the type of Traffic selector.
         *
-        * @param ts_type       type of traffic selector        
+        * @param ts_type       type of traffic selector
         */
        void (*set_ts_type) (traffic_selector_substructure_t *this,
                                                 ts_type_t ts_type);
-       
+
        /**
         * Get the IP protocol ID of Traffic selector.
         *
         * @return                      type of traffic selector
-        *  
+        *
         */
        u_int8_t (*get_protocol_id) (traffic_selector_substructure_t *this);
-       
+
        /**
         * Set the IP protocol ID of Traffic selector
         *
-        * @param protocol_id   protocol ID of traffic selector 
+        * @param protocol_id   protocol ID of traffic selector
         */
        void (*set_protocol_id) (traffic_selector_substructure_t *this,
                                                          u_int8_t protocol_id);
-       
+
        /**
         * Get the start port and address as host_t object.
         *
         * Returned host_t object has to get destroyed by the caller.
-        * 
+        *
         * @return                      start host as host_t object
-        *  
+        *
         */
        host_t *(*get_start_host) (traffic_selector_substructure_t *this);
-       
+
        /**
         * Set the start port and address as host_t object.
         *
@@ -94,17 +94,17 @@ struct traffic_selector_substructure_t {
         */
        void (*set_start_host) (traffic_selector_substructure_t *this,
                                                        host_t *start_host);
-       
+
        /**
         * Get the end port and address as host_t object.
         *
         * Returned host_t object has to get destroyed by the caller.
-        * 
+        *
         * @return                      end host as host_t object
-        *  
+        *
         */
        host_t *(*get_end_host) (traffic_selector_substructure_t *this);
-       
+
        /**
         * Set the end port and address as host_t object.
         *
@@ -112,17 +112,17 @@ struct traffic_selector_substructure_t {
         */
        void (*set_end_host) (traffic_selector_substructure_t *this,
                                                  host_t *end_host);
-       
+
        /**
         * Get a traffic_selector_t from this substructure.
         *
         * @warning traffic_selector_t must be destroyed after usage.
-        * 
+        *
         * @return                      contained traffic_selector_t
         */
        traffic_selector_t *(*get_traffic_selector) (
                                                                                traffic_selector_substructure_t *this);
-       
+
        /**
         * Destroys an traffic_selector_substructure_t object.
         */
@@ -133,7 +133,7 @@ struct traffic_selector_substructure_t {
  * Creates an empty traffic_selector_substructure_t object.
  *
  * TS type is set to default TS_IPV4_ADDR_RANGE!
- *  
+ *
  * @return                                     traffic_selector_substructure_t object
  */
 traffic_selector_substructure_t *traffic_selector_substructure_create(void);
@@ -141,7 +141,7 @@ traffic_selector_substructure_t *traffic_selector_substructure_create(void);
 /**
  * Creates an initialized traffif selector substructure using
  * the values from a traffic_selector_t.
- * 
+ *
  * @param traffic_selector     traffic_selector_t to use for initialization
  * @return                                     traffic_selector_substructure_t object
  */
index 507d04a34c0fd1aa8c9f7e5661dc4b2c33724145..8bf2ddef44449839f4f2c81798ef811679b886f0 100644 (file)
@@ -26,32 +26,32 @@ typedef struct private_transform_attribute_t private_transform_attribute_t;
 
 /**
  * Private data of an transform_attribute_t object.
- * 
+ *
  */
 struct private_transform_attribute_t {
        /**
         * Public transform_attribute_t interface.
         */
        transform_attribute_t public;
-       
+
        /**
         * Attribute Format Flag.
-        * 
+        *
         * - TRUE means value is stored in attribute_length_or_value
         * - FALSE means value is stored in attribute_value
         */
        bool attribute_format;
-       
+
        /**
         * Type of the attribute.
         */
        u_int16_t attribute_type;
-       
+
        /**
         * Attribute Length if attribute_format is 0, attribute Value otherwise.
         */
        u_int16_t attribute_length_or_value;
-       
+
        /**
         * Attribute value as chunk if attribute_format is 0 (FALSE).
         */
@@ -67,16 +67,16 @@ ENUM_END(transform_attribute_type_name, KEY_LENGTH);
 
 /**
  * Encoding rules to parse or generate a Transform attribute.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_transform_attribute_t.
- * 
+ *
  */
 encoding_rule_t transform_attribute_encodings[] = {
        /* Flag defining the format of this payload */
        { ATTRIBUTE_FORMAT,                     offsetof(private_transform_attribute_t, attribute_format)                       },
        /* type of the attribute as 15 bit unsigned integer */
-       { ATTRIBUTE_TYPE,                       offsetof(private_transform_attribute_t, attribute_type)                         },      
+       { ATTRIBUTE_TYPE,                       offsetof(private_transform_attribute_t, attribute_type)                         },
        /* Length or value, depending on the attribute format flag */
        { ATTRIBUTE_LENGTH_OR_VALUE,    offsetof(private_transform_attribute_t, attribute_length_or_value)      },
        /* Value of attribute if attribute format flag is zero */
@@ -104,7 +104,7 @@ static status_t verify(private_transform_attribute_t *this)
        {
                return FAILED;
        }
-       
+
        return SUCCESS;
 }
 
@@ -164,16 +164,16 @@ static void set_value_chunk(private_transform_attribute_t *this, chunk_t value)
                free(this->attribute_value.ptr);
                this->attribute_value.ptr = NULL;
                this->attribute_value.len = 0;
-               
+
        }
-       
+
        if (value.len > 2)
        {
                this->attribute_value.ptr = clalloc(value.ptr,value.len);
                this->attribute_value.len = value.len;
                this->attribute_length_or_value = value.len;
                /* attribute has not a fixed length */
-               this->attribute_format = FALSE;         
+               this->attribute_format = FALSE;
        }
        else
        {
@@ -192,7 +192,7 @@ static void set_value(private_transform_attribute_t *this, u_int16_t value)
                free(this->attribute_value.ptr);
                this->attribute_value.ptr = NULL;
                this->attribute_value.len = 0;
-               
+
        }
        this->attribute_length_or_value = value;
 }
@@ -207,14 +207,14 @@ static chunk_t get_value_chunk (private_transform_attribute_t *this)
        if (this->attribute_format == FALSE)
        {
                value.ptr = this->attribute_value.ptr;
-               value.len = this->attribute_value.len;          
+               value.len = this->attribute_value.len;
        }
        else
        {
                value.ptr = (void *) &(this->attribute_length_or_value);
                value.len = 2;
        }
-       
+
        return value;
 }
 
@@ -249,19 +249,19 @@ static u_int16_t get_attribute_type (private_transform_attribute_t *this)
 static transform_attribute_t * _clone(private_transform_attribute_t *this)
 {
        private_transform_attribute_t *new_clone;
-       
+
        new_clone = (private_transform_attribute_t *) transform_attribute_create();
-       
+
        new_clone->attribute_format = this->attribute_format;
        new_clone->attribute_type = this->attribute_type;
        new_clone->attribute_length_or_value = this->attribute_length_or_value;
-       
+
        if (!new_clone->attribute_format)
        {
-               new_clone->attribute_value.ptr = clalloc(this->attribute_value.ptr,this->attribute_value.len);          
+               new_clone->attribute_value.ptr = clalloc(this->attribute_value.ptr,this->attribute_value.len);
                new_clone->attribute_value.len = this->attribute_value.len;
        }
-       
+
        return (transform_attribute_t *) new_clone;
 }
 
@@ -273,7 +273,7 @@ static void destroy(private_transform_attribute_t *this)
        if (this->attribute_value.ptr != NULL)
        {
                free(this->attribute_value.ptr);
-       }       
+       }
        free(this);
 }
 
@@ -292,7 +292,7 @@ transform_attribute_t *transform_attribute_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.set_value_chunk = (void (*) (transform_attribute_t *,chunk_t)) set_value_chunk;
        this->public.set_value = (void (*) (transform_attribute_t *,u_int16_t)) set_value;
@@ -302,7 +302,7 @@ transform_attribute_t *transform_attribute_create()
        this->public.get_attribute_type = (u_int16_t (*) (transform_attribute_t *)) get_attribute_type;
        this->public.clone = (transform_attribute_t * (*) (transform_attribute_t *)) _clone;
        this->public.destroy = (void (*) (transform_attribute_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->attribute_format = TRUE;
        this->attribute_type = 0;
index f7d71a9df2c13534b7ad6cec27fe0867e46b87dd..a5fe0154bc897525f24116ddc1e264a0b4c6a7e1 100644 (file)
@@ -37,14 +37,14 @@ enum transform_attribute_type_t {
        KEY_LENGTH = 14
 };
 
-/** 
+/**
  * enum name for transform_attribute_type_t.
  */
 extern enum_name_t *transform_attribute_type_names;
 
 /**
  * Class representing an IKEv2- TRANSFORM Attribute.
- * 
+ *
  * The TRANSFORM ATTRIBUTE format is described in RFC section 3.3.5.
  */
 struct transform_attribute_t {
@@ -55,52 +55,52 @@ struct transform_attribute_t {
 
        /**
         * Returns the currently set value of the attribute.
-        *      
+        *
         * Returned data are not copied.
-        * 
+        *
         * @return              chunk_t pointing to the value
         */
        chunk_t (*get_value_chunk) (transform_attribute_t *this);
-       
+
        /**
         * Returns the currently set value of the attribute.
-        *      
+        *
         * Returned data are not copied.
-        * 
+        *
         * @return              value
         */
        u_int16_t (*get_value) (transform_attribute_t *this);
-       
+
        /**
         * Sets the value of the attribute.
-        *      
+        *
         * Value is getting copied.
-        * 
+        *
         * @param value chunk_t pointing to the value to set
         */
        void (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
 
        /**
         * Sets the value of the attribute.
-        * 
+        *
         * @param value value to set
         */
        void (*set_value) (transform_attribute_t *this, u_int16_t value);
 
        /**
         * Sets the type of the attribute.
-        *      
+        *
         * @param type  type to set (most significant bit is set to zero)
         */
        void (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
-       
+
        /**
         * get the type of the attribute.
-        *      
+        *
         * @return              type of the value
         */
        u_int16_t (*get_attribute_type) (transform_attribute_t *this);
-       
+
        /**
         * Clones an transform_attribute_t object.
         *
@@ -116,14 +116,14 @@ struct transform_attribute_t {
 
 /**
  * Creates an empty transform_attribute_t object.
- * 
+ *
  * @return                             transform_attribute_t object
  */
 transform_attribute_t *transform_attribute_create(void);
 
 /**
  * Creates an transform_attribute_t of type KEY_LENGTH.
- * 
+ *
  * @param key_length   key length in bytes
  * @return                             transform_attribute_t object
  */
index 497bd53b2013eeb89280f0902f4f4d99275b4db4..16156b7c634ce04521be94a0c5fea57670f30e38 100644 (file)
@@ -29,36 +29,36 @@ typedef struct private_transform_substructure_t private_transform_substructure_t
 
 /**
  * Private data of an transform_substructure_t object.
- * 
+ *
  */
 struct private_transform_substructure_t {
        /**
         * Public transform_substructure_t interface.
         */
        transform_substructure_t public;
-       
+
        /**
         * Next payload type.
         */
        u_int8_t  next_payload;
 
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t transform_length;
-       
-       
+
+
        /**
         * Type of the transform.
         */
        u_int8_t transform_type;
-       
+
        /**
         * Transform ID.
         */
        u_int16_t transform_id;
-       
+
        /**
         * Transforms Attributes are stored in a linked_list_t.
         */
@@ -68,25 +68,25 @@ struct private_transform_substructure_t {
 
 /**
  * Encoding rules to parse or generate a Transform substructure.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_transform_substructure_t.
- * 
+ *
  */
 encoding_rule_t transform_substructure_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
        { U_INT_8,                      offsetof(private_transform_substructure_t, next_payload)                },
        /* Reserved Byte is skipped */
-       { RESERVED_BYTE,                0                                                                                                                               },      
+       { RESERVED_BYTE,                0                                                                                                                               },
        /* Length of the whole transform substructure*/
-       { PAYLOAD_LENGTH,               offsetof(private_transform_substructure_t, transform_length)    },      
+       { PAYLOAD_LENGTH,               offsetof(private_transform_substructure_t, transform_length)    },
        /* transform type is a number of 8 bit */
-       { U_INT_8,                              offsetof(private_transform_substructure_t, transform_type)      },      
+       { U_INT_8,                              offsetof(private_transform_substructure_t, transform_type)      },
        /* Reserved Byte is skipped */
-       { RESERVED_BYTE,                0                                                                                                                               },      
+       { RESERVED_BYTE,                0                                                                                                                               },
        /* tranform ID is a number of 8 bit */
-       { U_INT_16,                             offsetof(private_transform_substructure_t, transform_id)                },      
-       /* Attributes are stored in a transform attribute, 
+       { U_INT_16,                             offsetof(private_transform_substructure_t, transform_id)                },
+       /* Attributes are stored in a transform attribute,
           offset points to a linked_list_t pointer */
        { TRANSFORM_ATTRIBUTES, offsetof(private_transform_substructure_t, attributes)          }
 };
@@ -114,7 +114,7 @@ static status_t verify(private_transform_substructure_t *this)
        status_t status = SUCCESS;
        iterator_t *iterator;
        payload_t *current_attributes;
-       
+
        if ((this->next_payload != NO_PAYLOAD) && (this->next_payload != 3))
        {
                /* must be 0 or 3 */
@@ -139,7 +139,7 @@ static status_t verify(private_transform_substructure_t *this)
                }
        }
        iterator = this->attributes->create_iterator(this->attributes,TRUE);
-       
+
        while(iterator->iterate(iterator, (void**)&current_attributes))
        {
                status = current_attributes->verify(current_attributes);
@@ -149,8 +149,8 @@ static status_t verify(private_transform_substructure_t *this)
                }
        }
        iterator->destroy(iterator);
-       
-       /* proposal number is checked in SA payload */  
+
+       /* proposal number is checked in SA payload */
        return status;
 }
 
@@ -187,14 +187,14 @@ static void compute_length (private_transform_substructure_t *this)
        iterator_t *iterator;
        payload_t *current_attribute;
        size_t length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH;
-       
+
        iterator = this->attributes->create_iterator(this->attributes,TRUE);
        while (iterator->iterate(iterator, (void**)&current_attribute))
        {
                length += current_attribute->get_length(current_attribute);
        }
        iterator->destroy(iterator);
-       
+
        this->transform_length = length;
 }
 
@@ -254,7 +254,7 @@ static void set_transform_type (private_transform_substructure_t *this,u_int8_t
 {
        this->transform_type = type;
 }
-       
+
 /**
  * Implementation of transform_substructure_t.get_transform_type.
  */
@@ -270,7 +270,7 @@ static void set_transform_id (private_transform_substructure_t *this,u_int16_t i
 {
        this->transform_id = id;
 }
-       
+
 /**
  * Implementation of transform_substructure_t.get_transform_id.
  */
@@ -287,20 +287,20 @@ static transform_substructure_t *clone_(private_transform_substructure_t *this)
        private_transform_substructure_t *clone;
        iterator_t *attributes;
        transform_attribute_t *current_attribute;
-       
+
        clone = (private_transform_substructure_t *) transform_substructure_create();
        clone->next_payload = this->next_payload;
        clone->transform_type = this->transform_type;
        clone->transform_id = this->transform_id;
-       
+
        attributes = this->attributes->create_iterator(this->attributes, FALSE);
        while (attributes->iterate(attributes, (void**)&current_attribute))
        {
                current_attribute = current_attribute->clone(current_attribute);
                clone->public.add_transform_attribute(&clone->public, current_attribute);
        }
-       attributes->destroy(attributes);        
-       
+       attributes->destroy(attributes);
+
        return &clone->public;
 }
 
@@ -312,14 +312,14 @@ static status_t get_key_length(private_transform_substructure_t *this, u_int16_t
 {
        iterator_t *attributes;
        transform_attribute_t *current_attribute;
-       
+
        attributes = this->attributes->create_iterator(this->attributes, TRUE);
        while (attributes->iterate(attributes, (void**)&current_attribute))
        {
                if (current_attribute->get_attribute_type(current_attribute) == KEY_LENGTH)
                {
                        *key_length = current_attribute->get_value(current_attribute);
-                       attributes->destroy(attributes);        
+                       attributes->destroy(attributes);
                        return SUCCESS;
                }
        }
@@ -350,10 +350,10 @@ transform_substructure_t *transform_substructure_create()
        this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
        this->public.payload_interface.get_length = (size_t (*) (payload_t *)) get_length;
        this->public.payload_interface.get_next_type = (payload_type_t (*) (payload_t *)) get_next_type;
-       this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;   
+       this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.create_transform_attribute_iterator = (iterator_t * (*) (transform_substructure_t *,bool)) create_transform_attribute_iterator;
        this->public.add_transform_attribute = (void (*) (transform_substructure_t *,transform_attribute_t *)) add_transform_attribute;
@@ -366,14 +366,14 @@ transform_substructure_t *transform_substructure_create()
        this->public.get_key_length = (status_t (*) (transform_substructure_t *,u_int16_t *)) get_key_length;
        this->public.clone = (transform_substructure_t* (*) (transform_substructure_t *)) clone_;
        this->public.destroy = (void (*) (transform_substructure_t *)) destroy;
-       
+
        /* set default values of the fields */
        this->next_payload = NO_PAYLOAD;
        this->transform_length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH;
        this->transform_id = 0;
        this->transform_type = 0;
        this->attributes = linked_list_create();
-       
+
        return (&(this->public));
 }
 
@@ -385,17 +385,17 @@ transform_substructure_t *transform_substructure_create_type(
                                                                u_int16_t transform_id, u_int16_t key_length)
 {
        transform_substructure_t *transform = transform_substructure_create();
-       
+
        transform->set_transform_type(transform,transform_type);
        transform->set_transform_id(transform,transform_id);
-       
+
        if (key_length)
        {
                transform_attribute_t *attribute;
-               
+
                attribute = transform_attribute_create_key_length(key_length);
                transform->add_transform_attribute(transform, attribute);
-       
+
        }
        return transform;
 }
index b02a94a6ccd6960f138d803fe394ec552837f314..5d31f8c0a07c311122a3fb3499f5a58fd606ea85 100644 (file)
@@ -48,7 +48,7 @@ typedef struct transform_substructure_t transform_substructure_t;
 
 /**
  * Class representing an IKEv2- TRANSFORM SUBSTRUCTURE.
- * 
+ *
  * The TRANSFORM SUBSTRUCTURE format is described in RFC section 3.3.2.
  */
 struct transform_substructure_t {
@@ -56,12 +56,12 @@ struct transform_substructure_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Creates an iterator of stored transform_attribute_t objects.
-        * 
-        * When deleting an transform attribute using this iterator, 
-        * the length of this transform substructure has to be refreshed 
+        *
+        * When deleting an transform attribute using this iterator,
+        * the length of this transform substructure has to be refreshed
         * by calling get_length().
         *
         * @param forward               iterator direction (TRUE: front to end)
@@ -69,7 +69,7 @@ struct transform_substructure_t {
         */
        iterator_t * (*create_transform_attribute_iterator) (
                                                                transform_substructure_t *this, bool forward);
-       
+
        /**
         * Adds a transform_attribute_t object to this object.
         *
@@ -77,59 +77,59 @@ struct transform_substructure_t {
         */
        void (*add_transform_attribute) (transform_substructure_t *this,
                                                                         transform_attribute_t *attribute);
-       
+
        /**
         * Sets the next_payload field of this substructure
-        * 
+        *
         * If this is the last transform, next payload field is set to 0,
         * otherwise to 3
         *
         * @param is_last       When TRUE, next payload field is set to 0, otherwise to 3
         */
        void (*set_is_last_transform) (transform_substructure_t *this, bool is_last);
-       
+
        /**
         * Checks if this is the last transform.
-        * 
+        *
         * @return                      TRUE if this is the last Transform, FALSE otherwise
         */
        bool (*get_is_last_transform) (transform_substructure_t *this);
-       
+
        /**
         * Sets transform type of the current transform substructure.
         *
         * @param type          type value to set
         */
        void (*set_transform_type) (transform_substructure_t *this, u_int8_t type);
-       
+
        /**
         * get transform type of the current transform.
-        * 
+        *
         * @return                      Transform type of current transform substructure.
         */
        u_int8_t (*get_transform_type) (transform_substructure_t *this);
-       
+
        /**
         * Sets transform id of the current transform substructure.
         *
         * @param id            transform id to set
         */
        void (*set_transform_id) (transform_substructure_t *this, u_int16_t id);
-       
+
        /**
         * get transform id of the current transform.
-        * 
+        *
         * @return                      Transform id of current transform substructure.
         */
        u_int16_t (*get_transform_id) (transform_substructure_t *this);
-       
+
        /**
         * get transform id of the current transform.
-        * 
-        * @param key_length    The key length is written to this location      
-        * @return                      
+        *
+        * @param key_length    The key length is written to this location
+        * @return
         *                                              - SUCCESS if a key length attribute is contained
-        *                                              - FAILED if no key length attribute is part of this 
+        *                                              - FAILED if no key length attribute is part of this
         *                                                transform or key length uses more then 16 bit!
         */
        status_t (*get_key_length) (transform_substructure_t *this,
@@ -150,18 +150,18 @@ struct transform_substructure_t {
 
 /**
  * Creates an empty transform_substructure_t object.
- * 
+ *
  * @return                     created transform_substructure_t object
  */
 transform_substructure_t *transform_substructure_create(void);
 
 /**
  * Creates an empty transform_substructure_t object.
- * 
+ *
  * The key length is used for the transport types ENCRYPTION_ALGORITHM,
- * PSEUDO_RANDOM_FUNCTION, INTEGRITY_ALGORITHM. For all 
+ * PSEUDO_RANDOM_FUNCTION, INTEGRITY_ALGORITHM. For all
  * other transport types the key_length parameter is not used
- * 
+ *
  * @param transform_type       type of transform to create
  * @param transform_id         transform id specifying the specific algorithm of a transform type
  * @param key_length           Key length for key lenght attribute
index 92ddc380fb033c503ac0807111e9c25efabc93c0..64891913795493a02908dccd8cfec129588ddb55 100644 (file)
@@ -25,19 +25,19 @@ typedef struct private_ts_payload_t private_ts_payload_t;
 
 /**
  * Private data of an ts_payload_t object.
- * 
+ *
  */
 struct private_ts_payload_t {
        /**
         * Public ts_payload_t interface.
         */
        ts_payload_t public;
-       
+
        /**
         * TRUE if this TS payload is of type TSi, FALSE for TSr.
         */
        bool is_initiator;
-       
+
        /**
         * Next payload type.
         */
@@ -47,17 +47,17 @@ struct private_ts_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * Number of traffic selectors
         */
        u_int8_t number_of_traffic_selectors;
-       
+
        /**
         * Contains the traffic selectors of type traffic_selector_substructure_t.
         */
@@ -66,10 +66,10 @@ struct private_ts_payload_t {
 
 /**
  * Encoding rules to parse or generate a TS payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_ts_payload_t.
- * 
+ *
  */
 encoding_rule_t ts_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -84,7 +84,7 @@ encoding_rule_t ts_payload_encodings[] = {
        { RESERVED_BIT, 0                                                                                                                               },
        { RESERVED_BIT, 0                                                                                                                               },
        { RESERVED_BIT, 0                                                                                                                               },
-       /* Length of the whole payload*/        
+       /* Length of the whole payload*/
        { PAYLOAD_LENGTH,       offsetof(private_ts_payload_t, payload_length)},
        /* 1 Byte TS type*/
        { U_INT_8,                      offsetof(private_ts_payload_t, number_of_traffic_selectors)     },
@@ -118,13 +118,13 @@ static status_t verify(private_ts_payload_t *this)
        iterator_t *iterator;
        payload_t *current_traffic_selector;
        status_t status = SUCCESS;
-       
+
        if (this->number_of_traffic_selectors != (this->traffic_selectors->get_count(this->traffic_selectors)))
        {
                /* must be the same */
                return FAILED;
        }
-       
+
        iterator = this->traffic_selectors->create_iterator(this->traffic_selectors,TRUE);
        while(iterator->iterate(iterator, (void**)&current_traffic_selector))
        {
@@ -135,7 +135,7 @@ static status_t verify(private_ts_payload_t *this)
                }
        }
        iterator->destroy(iterator);
-       
+
        return status;
 }
 
@@ -188,7 +188,7 @@ static void compute_length (private_ts_payload_t *this)
        size_t ts_count = 0;
        size_t length = TS_PAYLOAD_HEADER_LENGTH;
        payload_t *current_traffic_selector;
-       
+
        iterator = this->traffic_selectors->create_iterator(this->traffic_selectors,TRUE);
        while (iterator->iterate(iterator, (void**)&current_traffic_selector))
        {
@@ -196,9 +196,9 @@ static void compute_length (private_ts_payload_t *this)
                ts_count++;
        }
        iterator->destroy(iterator);
-       
+
        this->number_of_traffic_selectors= ts_count;
-       this->payload_length = length;  
+       this->payload_length = length;
 }
 
 /**
@@ -252,7 +252,7 @@ static linked_list_t *get_traffic_selectors(private_ts_payload_t *this)
        iterator_t *iterator;
        traffic_selector_substructure_t *ts_substructure;
        linked_list_t *ts_list = linked_list_create();
-       
+
        iterator = this->traffic_selectors->create_iterator(this->traffic_selectors, TRUE);
        while (iterator->iterate(iterator, (void**)&ts_substructure))
        {
@@ -260,7 +260,7 @@ static linked_list_t *get_traffic_selectors(private_ts_payload_t *this)
                ts_list->insert_last(ts_list, (void*)ts);
        }
        iterator->destroy(iterator);
-       
+
        return ts_list;
 }
 
@@ -289,7 +289,7 @@ ts_payload_t *ts_payload_create(bool is_initiator)
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (ts_payload_t *)) destroy;
        this->public.get_initiator = (bool (*) (ts_payload_t *)) get_initiator;
@@ -297,14 +297,14 @@ ts_payload_t *ts_payload_create(bool is_initiator)
        this->public.add_traffic_selector_substructure = (void (*) (ts_payload_t *,traffic_selector_substructure_t *)) add_traffic_selector_substructure;
        this->public.create_traffic_selector_substructure_iterator = (iterator_t* (*) (ts_payload_t *,bool)) create_traffic_selector_substructure_iterator;
        this->public.get_traffic_selectors = (linked_list_t *(*) (ts_payload_t *)) get_traffic_selectors;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
        this->payload_length =TS_PAYLOAD_HEADER_LENGTH;
        this->is_initiator = is_initiator;
        this->number_of_traffic_selectors = 0;
-       this->traffic_selectors = linked_list_create();  
+       this->traffic_selectors = linked_list_create();
 
        return &(this->public);
 }
@@ -318,9 +318,9 @@ ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator, linked
        traffic_selector_t *ts;
        traffic_selector_substructure_t *ts_substructure;
        private_ts_payload_t *this;
-       
+
        this = (private_ts_payload_t*)ts_payload_create(is_initiator);
-       
+
        iterator = traffic_selectors->create_iterator(traffic_selectors, TRUE);
        while (iterator->iterate(iterator, (void**)&ts))
        {
@@ -328,7 +328,7 @@ ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator, linked
                this->public.add_traffic_selector_substructure(&(this->public), ts_substructure);
        }
        iterator->destroy(iterator);
-       
+
        return &(this->public);
 }
 
index 3c8a6d595626dba33917037df6250d044e7339a8..1d198a6fa6ec54eba245d820b202689234edc537 100644 (file)
@@ -47,7 +47,7 @@ struct ts_payload_t {
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
         * Get the type of TSpayload (TSi or TSr).
         *
@@ -56,16 +56,16 @@ struct ts_payload_t {
         *                                              - FALSE if this payload is of type TSr
         */
        bool (*get_initiator) (ts_payload_t *this);
-       
+
        /**
         * Set the type of TS payload (TSi or TSr).
         *
-        * @param is_initiator  
+        * @param is_initiator
         *                                              - TRUE if this payload is of type TSi
         *                                              - FALSE if this payload is of type TSr
         */
        void (*set_initiator) (ts_payload_t *this,bool is_initiator);
-       
+
        /**
         * Adds a traffic_selector_substructure_t object to this object.
         *
@@ -73,12 +73,12 @@ struct ts_payload_t {
         */
        void (*add_traffic_selector_substructure) (ts_payload_t *this,
                                                        traffic_selector_substructure_t *traffic_selector);
-       
+
        /**
         * Creates an iterator of stored traffic_selector_substructure_t objects.
-        * 
-        * When removing an traffic_selector_substructure_t object 
-        * using this iterator, the length of this payload 
+        *
+        * When removing an traffic_selector_substructure_t object
+        * using this iterator, the length of this payload
         * has to get refreshed by calling payload_t.get_length!
         *
         * @param forward               iterator direction (TRUE: front to end)
@@ -86,10 +86,10 @@ struct ts_payload_t {
         */
        iterator_t *(*create_traffic_selector_substructure_iterator) (
                                                                                        ts_payload_t *this, bool forward);
-       
+
        /**
         * Get a list of nested traffic selectors as traffic_selector_t.
-        * 
+        *
         * Resulting list and its traffic selectors must be destroyed after usage
         *
         * @return                              list of traffic selectors
@@ -104,8 +104,8 @@ struct ts_payload_t {
 
 /**
  * Creates an empty ts_payload_t object.
- * 
- * @param is_initiator 
+ *
+ * @param is_initiator
  *                                             - TRUE if this payload is of type TSi
  *                                             - FALSE if this payload is of type TSr
  * @return                             ts_payload_t object
@@ -114,14 +114,14 @@ ts_payload_t *ts_payload_create(bool is_initiator);
 
 /**
  * Creates ts_payload with a list of traffic_selector_t
- * 
- * @param is_initiator 
+ *
+ * @param is_initiator
  *                                                     - TRUE if this payload is of type TSi
  *                                                     - FALSE if this payload is of type TSr
  * @param traffic_selectors    list of traffic selectors to include
  * @return                                     ts_payload_t object
  */
-ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator, 
+ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator,
                                                                                        linked_list_t *traffic_selectors);
 
 #endif /** TS_PAYLOAD_H_ @}*/
index 309663233c6da773d4c1bfca1f0a45edbe6402b5..3c31ab1a2198cc345ed28c2d7b931a6792716965 100644 (file)
@@ -26,12 +26,12 @@ typedef struct private_unknown_payload_t private_unknown_payload_t;
  * Private data of an unknown_payload_t object.
  */
 struct private_unknown_payload_t {
-       
+
        /**
         * Public unknown_payload_t interface.
         */
        unknown_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -41,12 +41,12 @@ struct private_unknown_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * The contained data.
         */
@@ -55,10 +55,10 @@ struct private_unknown_payload_t {
 
 /**
  * Encoding rules to parse an payload which is not further specified.
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_unknown_payload_t.
- * 
+ *
  */
 encoding_rule_t unknown_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -146,7 +146,7 @@ static size_t get_length(private_unknown_payload_t *this)
  */
 static bool is_critical(private_unknown_payload_t *this)
 {
-       return this->critical;  
+       return this->critical;
 }
 
 /**
@@ -166,8 +166,8 @@ static void destroy(private_unknown_payload_t *this)
        {
                chunk_free(&(this->data));
        }
-       
-       free(this);     
+
+       free(this);
 }
 
 /*
@@ -185,12 +185,12 @@ unknown_payload_t *unknown_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (unknown_payload_t *)) destroy;
        this->public.is_critical = (bool (*) (unknown_payload_t *)) is_critical;
        this->public.get_data = (chunk_t (*) (unknown_payload_t *)) get_data;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
index 44b6e1a717952537e79f23cc339dc6f1500a1190..c761ed2b6ca9825fe085de3f3fcf713a48d7d9ff 100644 (file)
@@ -40,29 +40,29 @@ typedef struct unknown_payload_t unknown_payload_t;
  * a check for the critical bit in the header.
  */
 struct unknown_payload_t {
-       
+
        /**
         * The payload_t interface.
         */
        payload_t payload_interface;
-       
+
        /**
-        * Get the raw data of this payload, without 
+        * Get the raw data of this payload, without
         * the generic payload header.
-        * 
+        *
         * Returned data are NOT copied and must not be freed.
         *
         * @return                              data as chunk_t
         */
        chunk_t (*get_data) (unknown_payload_t *this);
-       
+
        /**
         * Get the critical flag.
         *
         * @return                              TRUE if payload is critical, FALSE if not
         */
        bool (*is_critical) (unknown_payload_t *this);
-       
+
        /**
         * Destroys an unknown_payload_t object.
         */
@@ -71,7 +71,7 @@ struct unknown_payload_t {
 
 /**
  * Creates an empty unknown_payload_t object.
- * 
+ *
  * @return unknown_payload_t object
  */
 unknown_payload_t *unknown_payload_create(void);
index 52d9e12a5c0752b9f2253167cb4ddbe7df1984ff..dc16763e003769e97a6c68358ddb1640cc0b5727 100644 (file)
@@ -23,14 +23,14 @@ typedef struct private_vendor_id_payload_t private_vendor_id_payload_t;
 
 /**
  * Private data of an vendor_id_payload_t object.
- * 
+ *
  */
 struct private_vendor_id_payload_t {
        /**
         * Public vendor_id_payload_t interface.
         */
        vendor_id_payload_t public;
-       
+
        /**
         * Next payload type.
         */
@@ -40,12 +40,12 @@ struct private_vendor_id_payload_t {
         * Critical flag.
         */
        bool critical;
-       
+
        /**
         * Length of this payload.
         */
        u_int16_t payload_length;
-       
+
        /**
         * The contained vendor_id data value.
         */
@@ -54,10 +54,10 @@ struct private_vendor_id_payload_t {
 
 /**
  * Encoding rules to parse or generate a VENDOR ID payload
- * 
- * The defined offsets are the positions in a object of type 
+ *
+ * The defined offsets are the positions in a object of type
  * private_vendor_id_payload_t.
- * 
+ *
  */
 encoding_rule_t vendor_id_payload_encodings[] = {
        /* 1 Byte next payload type, stored in the field next_payload */
@@ -185,7 +185,7 @@ static void destroy(private_vendor_id_payload_t *this)
        {
                chunk_free(&(this->vendor_id_data));
        }
-       free(this);     
+       free(this);
 }
 
 /*
@@ -203,13 +203,13 @@ vendor_id_payload_t *vendor_id_payload_create()
        this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
        this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_payload_type;
        this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
-       
+
        /* public functions */
        this->public.destroy = (void (*) (vendor_id_payload_t *)) destroy;
        this->public.set_data = (void (*) (vendor_id_payload_t *,chunk_t)) set_data;
        this->public.get_data_clone = (chunk_t (*) (vendor_id_payload_t *)) get_data_clone;
        this->public.get_data = (chunk_t (*) (vendor_id_payload_t *)) get_data;
-       
+
        /* private variables */
        this->critical = FALSE;
        this->next_payload = NO_PAYLOAD;
index 9ee9ea1d416d643e4e7fcd849e928db12ccd8f1c..76d422e0ac86e9bffe590184ef074ec06bd58772 100644 (file)
@@ -46,31 +46,31 @@ struct vendor_id_payload_t {
 
        /**
         * Set the VID data.
-        * 
+        *
         * Data are getting cloned.
         *
         * @param data                  VID data as chunk_t
         */
        void (*set_data) (vendor_id_payload_t *this, chunk_t data);
-       
+
        /**
         * Get the VID data.
-        * 
+        *
         * Returned data are a copy of the internal one.
         *
         * @return                              VID data as chunk_t
         */
        chunk_t (*get_data_clone) (vendor_id_payload_t *this);
-       
+
        /**
         * Get the VID data.
-        * 
+        *
         * Returned data are NOT copied.
         *
         * @return                              VID data as chunk_t
         */
        chunk_t (*get_data) (vendor_id_payload_t *this);
-       
+
        /**
         * Destroys an vendor_id_payload_t object.
         */
@@ -79,7 +79,7 @@ struct vendor_id_payload_t {
 
 /**
  * Creates an empty vendor_id_payload_t object.
- * 
+ *
  * @return vendor_id_payload_t object
  */
 vendor_id_payload_t *vendor_id_payload_create(void);
index f3345138331edc20a42a6327c5bb425aa9526e3e..b1a1d703fea85dfae9bde712074bc61bcb03fb7b 100644 (file)
@@ -30,12 +30,12 @@ struct private_kernel_interface_t {
         * Public part of kernel_interface_t object.
         */
        kernel_interface_t public;
-       
+
        /**
         * ipsec interface
         */
        kernel_ipsec_t *ipsec;
-       
+
        /**
         * network interface
         */
@@ -45,7 +45,7 @@ struct private_kernel_interface_t {
 /**
  * Implementation of kernel_interface_t.get_spi
  */
-static status_t get_spi(private_kernel_interface_t *this, host_t *src, host_t *dst, 
+static status_t get_spi(private_kernel_interface_t *this, host_t *src, host_t *dst,
                                 protocol_id_t protocol, u_int32_t reqid, u_int32_t *spi)
 {
        if (!this->ipsec)
@@ -58,7 +58,7 @@ static status_t get_spi(private_kernel_interface_t *this, host_t *src, host_t *d
 /**
  * Implementation of kernel_interface_t.get_cpi
  */
-static status_t get_cpi(private_kernel_interface_t *this, host_t *src, host_t *dst, 
+static status_t get_cpi(private_kernel_interface_t *this, host_t *src, host_t *dst,
                                        u_int32_t reqid, u_int16_t *cpi)
 {
        if (!this->ipsec)
@@ -92,7 +92,7 @@ static status_t add_sa(private_kernel_interface_t *this, host_t *src, host_t *ds
  * Implementation of kernel_interface_t.update_sa
  */
 static status_t update_sa(private_kernel_interface_t *this, u_int32_t spi,
-                                  protocol_id_t protocol, u_int16_t cpi, host_t *src, host_t *dst, 
+                                  protocol_id_t protocol, u_int16_t cpi, host_t *src, host_t *dst,
                                   host_t *new_src, host_t *new_dst, bool encap, bool new_encap)
 {
        if (!this->ipsec)
@@ -289,13 +289,13 @@ static status_t get_address_by_ts(private_kernel_interface_t *this,
        host_t *host;
        int family;
        bool found = FALSE;
-       
+
        DBG2(DBG_KNL, "getting a local address in traffic selector %R", ts);
-       
+
        /* if we have a family which includes localhost, we do not
         * search for an IP, we use the default */
        family = ts->get_type(ts) == TS_IPV4_ADDR_RANGE ? AF_INET : AF_INET6;
-       
+
        if (family == AF_INET)
        {
                host = host_create_from_string("127.0.0.1", 0);
@@ -304,7 +304,7 @@ static status_t get_address_by_ts(private_kernel_interface_t *this,
        {
                host = host_create_from_string("::1", 0);
        }
-       
+
        if (ts->includes(ts, host))
        {
                *ip = host_create_any(family);
@@ -313,7 +313,7 @@ static status_t get_address_by_ts(private_kernel_interface_t *this,
                return SUCCESS;
        }
        host->destroy(host);
-       
+
        addrs = create_address_enumerator(this, TRUE, TRUE);
        while (addrs->enumerate(addrs, (void**)&host))
        {
@@ -325,13 +325,13 @@ static status_t get_address_by_ts(private_kernel_interface_t *this,
                }
        }
        addrs->destroy(addrs);
-       
+
        if (!found)
        {
                DBG1(DBG_KNL, "no local address found in traffic selector %R", ts);
                return FAILED;
        }
-       
+
        DBG2(DBG_KNL, "using host %H", *ip);
        return SUCCESS;
 }
@@ -395,7 +395,7 @@ static void destroy(private_kernel_interface_t *this)
 kernel_interface_t *kernel_interface_create()
 {
        private_kernel_interface_t *this = malloc_thing(private_kernel_interface_t);
-       
+
        this->public.get_spi = (status_t(*)(kernel_interface_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
        this->public.get_cpi = (status_t(*)(kernel_interface_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
        this->public.add_sa  = (status_t(*)(kernel_interface_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,lifetime_cfg_t*,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,u_int16_t,bool,bool))add_sa;
@@ -405,7 +405,7 @@ kernel_interface_t *kernel_interface_create()
        this->public.add_policy = (status_t(*)(kernel_interface_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
        this->public.query_policy = (status_t(*)(kernel_interface_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
        this->public.del_policy = (status_t(*)(kernel_interface_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
-       
+
        this->public.get_source_addr = (host_t*(*)(kernel_interface_t*, host_t *dest, host_t *src))get_source_addr;
        this->public.get_nexthop = (host_t*(*)(kernel_interface_t*, host_t *dest))get_nexthop;
        this->public.get_interface = (char*(*)(kernel_interface_t*,host_t*))get_interface;
@@ -414,18 +414,18 @@ kernel_interface_t *kernel_interface_create()
        this->public.del_ip = (status_t(*)(kernel_interface_t*,host_t*)) del_ip;
        this->public.add_route = (status_t(*)(kernel_interface_t*,chunk_t,u_int8_t,host_t*,host_t*,char*)) add_route;
        this->public.del_route = (status_t(*)(kernel_interface_t*,chunk_t,u_int8_t,host_t*,host_t*,char*)) del_route;
-       
+
        this->public.get_address_by_ts = (status_t(*)(kernel_interface_t*,traffic_selector_t*,host_t**))get_address_by_ts;
-       
+
        this->public.add_ipsec_interface = (void(*)(kernel_interface_t*, kernel_ipsec_constructor_t))add_ipsec_interface;
        this->public.remove_ipsec_interface = (void(*)(kernel_interface_t*, kernel_ipsec_constructor_t))remove_ipsec_interface;
        this->public.add_net_interface = (void(*)(kernel_interface_t*, kernel_net_constructor_t))add_net_interface;
        this->public.remove_net_interface = (void(*)(kernel_interface_t*, kernel_net_constructor_t))remove_net_interface;
-       
+
        this->public.destroy = (void (*)(kernel_interface_t*))destroy;
-       
+
        this->ipsec = NULL;
        this->net = NULL;
-       
+
        return &this->public;
 }
index f4247a260607777b1242d70dd0f88d0621f89f98..505fb1f5675fe6cde63328e620a7eba712ba5b56 100644 (file)
@@ -45,7 +45,7 @@ typedef kernel_net_t* (*kernel_net_constructor_t)(void);
 
 /**
  * Manager and wrapper for different kernel interfaces.
- * 
+ *
  * The kernel interface handles the communication with the kernel
  * for SA and policy management and interface and IP address management.
  */
@@ -61,21 +61,21 @@ struct kernel_interface_t {
         * @param spi           allocated spi
         * @return                              SUCCESS if operation completed
         */
-       status_t (*get_spi)(kernel_interface_t *this, host_t *src, host_t *dst, 
+       status_t (*get_spi)(kernel_interface_t *this, host_t *src, host_t *dst,
                                                protocol_id_t protocol, u_int32_t reqid, u_int32_t *spi);
-       
+
        /**
         * Get a Compression Parameter Index (CPI) from the kernel.
-        * 
+        *
         * @param src           source address of SA
         * @param dst           destination address of SA
         * @param reqid         unique ID for the corresponding SA
         * @param cpi           allocated cpi
         * @return                              SUCCESS if operation completed
         */
-       status_t (*get_cpi)(kernel_interface_t *this, host_t *src, host_t *dst, 
+       status_t (*get_cpi)(kernel_interface_t *this, host_t *src, host_t *dst,
                                                u_int32_t reqid, u_int16_t *cpi);
-       
+
        /**
         * Add an SA to the SAD.
         *
@@ -110,7 +110,7 @@ struct kernel_interface_t {
                                                u_int16_t int_alg, chunk_t int_key,
                                                ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
                                                bool encap, bool inbound);
-       
+
        /**
         * Update the hosts on an installed SA.
         *
@@ -133,13 +133,13 @@ struct kernel_interface_t {
         */
        status_t (*update_sa)(kernel_interface_t *this,
                                                  u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
-                                                 host_t *src, host_t *dst, 
+                                                 host_t *src, host_t *dst,
                                                  host_t *new_src, host_t *new_dst,
                                                  bool encap, bool new_encap);
-       
+
        /**
         * Query the number of bytes processed by an SA from the SAD.
-        * 
+        *
         * @param src                   source address for this SA
         * @param dst                   destination address for this SA
         * @param spi                   SPI allocated by us or remote peer
@@ -149,10 +149,10 @@ struct kernel_interface_t {
         */
        status_t (*query_sa) (kernel_interface_t *this, host_t *src, host_t *dst,
                                                  u_int32_t spi, protocol_id_t protocol, u_int64_t *bytes);
-       
+
        /**
         * Delete a previously installed SA from the SAD.
-        * 
+        *
         * @param src                   source address for this SA
         * @param dst                   destination address for this SA
         * @param spi                   SPI allocated by us or remote peer
@@ -162,13 +162,13 @@ struct kernel_interface_t {
         */
        status_t (*del_sa) (kernel_interface_t *this, host_t *src, host_t *dst,
                                                u_int32_t spi, protocol_id_t protocol, u_int16_t cpi);
-       
+
        /**
         * Add a policy to the SPD.
-        * 
+        *
         * A policy is always associated to an SA. Traffic which matches a
         * policy is handled by the SA with the same reqid.
-        * 
+        *
         * @param src                   source address of SA
         * @param dst                   dest address of SA
         * @param src_ts                traffic selector to match traffic source
@@ -191,13 +191,13 @@ struct kernel_interface_t {
                                                        protocol_id_t protocol, u_int32_t reqid,
                                                        ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
                                                        bool routed);
-       
+
        /**
         * Query the use time of a policy.
         *
         * The use time of a policy is the time the policy was used
         * for the last time.
-        * 
+        *
         * @param src_ts                traffic selector to match traffic source
         * @param dst_ts                traffic selector to match traffic dest
         * @param direction             direction of traffic, POLICY_IN, POLICY_OUT, POLICY_FWD
@@ -205,10 +205,10 @@ struct kernel_interface_t {
         * @return                              SUCCESS if operation completed
         */
        status_t (*query_policy) (kernel_interface_t *this,
-                                                         traffic_selector_t *src_ts, 
+                                                         traffic_selector_t *src_ts,
                                                          traffic_selector_t *dst_ts,
                                                          policy_dir_t direction, u_int32_t *use_time);
-       
+
        /**
         * Remove a policy from the SPD.
         *
@@ -224,11 +224,11 @@ struct kernel_interface_t {
         * @return                              SUCCESS if operation completed
         */
        status_t (*del_policy) (kernel_interface_t *this,
-                                                       traffic_selector_t *src_ts, 
+                                                       traffic_selector_t *src_ts,
                                                        traffic_selector_t *dst_ts,
                                                        policy_dir_t direction,
                                                        bool unrouted);
-       
+
        /**
         * Get our outgoing source address for a destination.
         *
@@ -243,7 +243,7 @@ struct kernel_interface_t {
         */
        host_t* (*get_source_addr)(kernel_interface_t *this,
                                                           host_t *dest, host_t *src);
-       
+
        /**
         * Get the next hop for a destination.
         *
@@ -254,7 +254,7 @@ struct kernel_interface_t {
         * @return                              next hop address, NULL if unreachable
         */
        host_t* (*get_nexthop)(kernel_interface_t *this, host_t *dest);
-       
+
        /**
         * Get the interface name of a local address.
         *
@@ -262,21 +262,21 @@ struct kernel_interface_t {
         * @return                              allocated interface name, or NULL if not found
         */
        char* (*get_interface) (kernel_interface_t *this, host_t *host);
-       
+
        /**
         * Creates an enumerator over all local addresses.
-        * 
+        *
         * This function blocks an internal cached address list until the
         * enumerator gets destroyed.
         * The hosts are read-only, do not modify of free.
-        * 
+        *
         * @param include_down_ifaces   TRUE to enumerate addresses from down interfaces
         * @param include_virtual_ips   TRUE to enumerate virtual ip addresses
         * @return                                              enumerator over host_t's
         */
        enumerator_t *(*create_address_enumerator) (kernel_interface_t *this,
                                                bool include_down_ifaces, bool include_virtual_ips);
-       
+
        /**
         * Add a virtual IP to an interface.
         *
@@ -291,7 +291,7 @@ struct kernel_interface_t {
         */
        status_t (*add_ip) (kernel_interface_t *this, host_t *virtual_ip,
                                                host_t *iface_ip);
-       
+
        /**
         * Remove a virtual IP from an interface.
         *
@@ -301,10 +301,10 @@ struct kernel_interface_t {
         * @return                              SUCCESS if operation completed
         */
        status_t (*del_ip) (kernel_interface_t *this, host_t *virtual_ip);
-       
+
        /**
         * Add a route.
-        * 
+        *
         * @param dst_net               destination net
         * @param prefixlen             destination net prefix length
         * @param gateway               gateway for this route
@@ -315,10 +315,10 @@ struct kernel_interface_t {
         */
        status_t (*add_route) (kernel_interface_t *this, chunk_t dst_net, u_int8_t prefixlen,
                                                                host_t *gateway, host_t *src_ip, char *if_name);
-       
+
        /**
         * Delete a route.
-        * 
+        *
         * @param dst_net               destination net
         * @param prefixlen             destination net prefix length
         * @param gateway               gateway for this route
@@ -328,50 +328,50 @@ struct kernel_interface_t {
         */
        status_t (*del_route) (kernel_interface_t *this, chunk_t dst_net, u_int8_t prefixlen,
                                                                host_t *gateway, host_t *src_ip, char *if_name);
-       
+
        /**
         * manager methods
         */
-       
+
        /**
         * Tries to find an ip address of a local interface that is included in the
         * supplied traffic selector.
-        * 
+        *
         * @param ts                    traffic selector
         * @param ip                    returned ip (has to be destroyed)
         * @return                              SUCCESS if address found
         */
        status_t (*get_address_by_ts) (kernel_interface_t *this,
                                                                                traffic_selector_t *ts, host_t **ip);
-       
+
        /**
         * Register an ipsec kernel interface constructor on the manager.
         *
         * @param create                        constructor to register
         */
        void (*add_ipsec_interface)(kernel_interface_t *this, kernel_ipsec_constructor_t create);
-       
+
        /**
         * Unregister an ipsec kernel interface constructor.
         *
         * @param create                        constructor to unregister
         */
        void (*remove_ipsec_interface)(kernel_interface_t *this, kernel_ipsec_constructor_t create);
-       
+
        /**
         * Register a network kernel interface constructor on the manager.
         *
         * @param create                        constructor to register
         */
        void (*add_net_interface)(kernel_interface_t *this, kernel_net_constructor_t create);
-       
+
        /**
         * Unregister a network kernel interface constructor.
         *
         * @param create                        constructor to unregister
         */
        void (*remove_net_interface)(kernel_interface_t *this, kernel_net_constructor_t create);
-       
+
        /**
         * Destroys a kernel_interface_manager_t object.
         */
index b21be849d8037616629cba3459c36a2b1c7cf99f..fdcc5f40a4c5bec4c9d2a449734dd9139b4f6300 100644 (file)
@@ -71,9 +71,9 @@ extern enum_name_t *policy_dir_names;
 
 /**
  * Interface to the ipsec subsystem of the kernel.
- * 
+ *
  * The kernel ipsec interface handles the communication with the kernel
- * for SA and policy management. It allows setup of these, and provides 
+ * for SA and policy management. It allows setup of these, and provides
  * further the handling of kernel events.
  * Policy information are cached in the interface. This is necessary to do
  * reference counting. The Linux kernel does not allow the same policy
@@ -81,7 +81,7 @@ extern enum_name_t *policy_dir_names;
  * when rekeying. Thats why we do reference counting of policies.
  */
 struct kernel_ipsec_t {
-       
+
        /**
         * Get a SPI from the kernel.
         *
@@ -92,21 +92,21 @@ struct kernel_ipsec_t {
         * @param spi           allocated spi
         * @return                              SUCCESS if operation completed
         */
-       status_t (*get_spi)(kernel_ipsec_t *this, host_t *src, host_t *dst, 
+       status_t (*get_spi)(kernel_ipsec_t *this, host_t *src, host_t *dst,
                                                protocol_id_t protocol, u_int32_t reqid, u_int32_t *spi);
-       
+
        /**
         * Get a Compression Parameter Index (CPI) from the kernel.
-        * 
+        *
         * @param src           source address of SA
         * @param dst           destination address of SA
         * @param reqid         unique ID for the corresponding SA
         * @param cpi           allocated cpi
         * @return                              SUCCESS if operation completed
         */
-       status_t (*get_cpi)(kernel_ipsec_t *this, host_t *src, host_t *dst, 
+       status_t (*get_cpi)(kernel_ipsec_t *this, host_t *src, host_t *dst,
                                                u_int32_t reqid, u_int16_t *cpi);
-       
+
        /**
         * Add an SA to the SAD.
         *
@@ -141,7 +141,7 @@ struct kernel_ipsec_t {
                                                u_int16_t int_alg, chunk_t int_key,
                                                ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
                                                bool encap, bool inbound);
-       
+
        /**
         * Update the hosts on an installed SA.
         *
@@ -164,13 +164,13 @@ struct kernel_ipsec_t {
         */
        status_t (*update_sa)(kernel_ipsec_t *this,
                                                  u_int32_t spi, protocol_id_t protocol, u_int16_t cpi,
-                                                 host_t *src, host_t *dst, 
+                                                 host_t *src, host_t *dst,
                                                  host_t *new_src, host_t *new_dst,
                                                  bool encap, bool new_encap);
-       
+
        /**
         * Query the number of bytes processed by an SA from the SAD.
-        * 
+        *
         * @param src                   source address for this SA
         * @param dst                   destination address for this SA
         * @param spi                   SPI allocated by us or remote peer
@@ -180,10 +180,10 @@ struct kernel_ipsec_t {
         */
        status_t (*query_sa) (kernel_ipsec_t *this, host_t *src, host_t *dst,
                                                  u_int32_t spi, protocol_id_t protocol, u_int64_t *bytes);
-       
+
        /**
         * Delete a previusly installed SA from the SAD.
-        * 
+        *
         * @param src                   source address for this SA
         * @param dst                   destination address for this SA
         * @param spi                   SPI allocated by us or remote peer
@@ -193,13 +193,13 @@ struct kernel_ipsec_t {
         */
        status_t (*del_sa) (kernel_ipsec_t *this, host_t *src, host_t *dst,
                                                u_int32_t spi, protocol_id_t protocol, u_int16_t cpi);
-       
+
        /**
         * Add a policy to the SPD.
-        * 
+        *
         * A policy is always associated to an SA. Traffic which matches a
         * policy is handled by the SA with the same reqid.
-        * 
+        *
         * @param src                   source address of SA
         * @param dst                   dest address of SA
         * @param src_ts                traffic selector to match traffic source
@@ -222,14 +222,14 @@ struct kernel_ipsec_t {
                                                        protocol_id_t protocol, u_int32_t reqid,
                                                        ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
                                                        bool routed);
-       
+
        /**
         * Query the use time of a policy.
         *
         * The use time of a policy is the time the policy was used for the last
         * time. It is not the system time, but a monotonic timestamp as returned
         * by time_monotonic.
-        * 
+        *
         * @param src_ts                traffic selector to match traffic source
         * @param dst_ts                traffic selector to match traffic dest
         * @param direction             direction of traffic, POLICY_IN, POLICY_OUT, POLICY_FWD
@@ -237,10 +237,10 @@ struct kernel_ipsec_t {
         * @return                              SUCCESS if operation completed
         */
        status_t (*query_policy) (kernel_ipsec_t *this,
-                                                         traffic_selector_t *src_ts, 
+                                                         traffic_selector_t *src_ts,
                                                          traffic_selector_t *dst_ts,
                                                          policy_dir_t direction, u_int32_t *use_time);
-       
+
        /**
         * Remove a policy from the SPD.
         *
@@ -256,11 +256,11 @@ struct kernel_ipsec_t {
         * @return                              SUCCESS if operation completed
         */
        status_t (*del_policy) (kernel_ipsec_t *this,
-                                                       traffic_selector_t *src_ts, 
+                                                       traffic_selector_t *src_ts,
                                                        traffic_selector_t *dst_ts,
                                                        policy_dir_t direction,
                                                        bool unrouted);
-       
+
        /**
         * Destroy the implementation.
         */
index 02242f3a8364d88affd8c5d0481965cce646734f..efb221f88853d439a51e675acb1233f50f422e86 100644 (file)
@@ -29,7 +29,7 @@ typedef struct kernel_net_t kernel_net_t;
 
 /**
  * Interface to the network subsystem of the kernel.
- * 
+ *
  * The kernel network interface handles the communication with the kernel
  * for interface and IP address management.
  */
@@ -48,7 +48,7 @@ struct kernel_net_t {
         * @return                              outgoing source address, NULL if unreachable
         */
        host_t* (*get_source_addr)(kernel_net_t *this, host_t *dest, host_t *src);
-       
+
        /**
         * Get the next hop for a destination.
         *
@@ -59,7 +59,7 @@ struct kernel_net_t {
         * @return                              next hop address, NULL if unreachable
         */
        host_t* (*get_nexthop)(kernel_net_t *this, host_t *dest);
-       
+
        /**
         * Get the interface name of a local address.
         *
@@ -67,21 +67,21 @@ struct kernel_net_t {
         * @return                              allocated interface name, or NULL if not found
         */
        char* (*get_interface) (kernel_net_t *this, host_t *host);
-       
+
        /**
         * Creates an enumerator over all local addresses.
-        * 
+        *
         * This function blocks an internal cached address list until the
         * enumerator gets destroyed.
         * The hosts are read-only, do not modify of free.
-        * 
+        *
         * @param include_down_ifaces   TRUE to enumerate addresses from down interfaces
         * @param include_virtual_ips   TRUE to enumerate virtual ip addresses
         * @return                                              enumerator over host_t's
         */
        enumerator_t *(*create_address_enumerator) (kernel_net_t *this,
                                                bool include_down_ifaces, bool include_virtual_ips);
-       
+
        /**
         * Add a virtual IP to an interface.
         *
@@ -96,7 +96,7 @@ struct kernel_net_t {
         */
        status_t (*add_ip) (kernel_net_t *this, host_t *virtual_ip,
                                                host_t *iface_ip);
-       
+
        /**
         * Remove a virtual IP from an interface.
         *
@@ -106,10 +106,10 @@ struct kernel_net_t {
         * @return                              SUCCESS if operation completed
         */
        status_t (*del_ip) (kernel_net_t *this, host_t *virtual_ip);
-       
+
        /**
         * Add a route.
-        * 
+        *
         * @param dst_net               destination net
         * @param prefixlen             destination net prefix length
         * @param gateway               gateway for this route
@@ -120,10 +120,10 @@ struct kernel_net_t {
         */
        status_t (*add_route) (kernel_net_t *this, chunk_t dst_net, u_int8_t prefixlen,
                                                                host_t *gateway, host_t *src_ip, char *if_name);
-       
+
        /**
         * Delete a route.
-        * 
+        *
         * @param dst_net               destination net
         * @param prefixlen             destination net prefix length
         * @param gateway               gateway for this route
@@ -133,7 +133,7 @@ struct kernel_net_t {
         */
        status_t (*del_route) (kernel_net_t *this, chunk_t dst_net, u_int8_t prefixlen,
                                                                host_t *gateway, host_t *src_ip, char *if_name);
-       
+
        /**
         * Destroy the implementation.
         */
index fd3a274bdc70dfbef6293baf57a5af8f139edfbd..19a62603dbdbed2da27b591f46926139d34dfbfb 100644 (file)
@@ -27,17 +27,17 @@ struct private_packet_t {
         * Public part of a packet_t object.
         */
        packet_t public;
-       
+
        /**
         * source address
         */
        host_t *source;
-               
+
        /**
         * destination address
         */
        host_t *destination;
-        
+
         /**
          * message data
          */
@@ -77,7 +77,7 @@ static host_t *get_destination(private_packet_t *this)
 {
        return this->destination;
 }
-       
+
 /**
  * Implements packet_t.get_data
  */
@@ -103,7 +103,7 @@ static void destroy(private_packet_t *this)
        if (this->source != NULL)
        {
                this->source->destroy(this->source);
-       }       
+       }
        if (this->destination != NULL)
        {
                this->destination->destroy(this->destination);
@@ -118,7 +118,7 @@ static void destroy(private_packet_t *this)
 static packet_t *clone_(private_packet_t *this)
 {
        private_packet_t *other = (private_packet_t*)packet_create();
-       
+
        if (this->destination != NULL)
        {
                other->destination = this->destination->clone(this->destination);
@@ -150,10 +150,10 @@ packet_t *packet_create(void)
        this->public.get_destination = (host_t*(*) (packet_t *)) get_destination;
        this->public.clone = (packet_t*(*) (packet_t *))clone_;
        this->public.destroy = (void(*) (packet_t *)) destroy;
-       
+
        this->destination = NULL;
        this->source = NULL;
        this->data = chunk_empty;
-       
+
        return &(this->public);
 }
index aacb203e943f5dd39acba763479cf16acc1702d6..18d82c6fcc0a8b1c76e0c33ba97cf71690484068 100644 (file)
@@ -34,71 +34,71 @@ struct packet_t {
 
        /**
         * Set the source address.
-        * 
+        *
         * Set host_t is now owned by packet_t, it will destroy
         * it if necessary.
-        * 
+        *
         * @param source        address to set as source
         */
        void (*set_source) (packet_t *packet, host_t *source);
-       
+
        /**
         * Set the destination address.
-        * 
+        *
         * Set host_t is now owned by packet_t, it will destroy
         * it if necessary.
-        * 
+        *
         * @param source        address to set as destination
         */
        void (*set_destination) (packet_t *packet, host_t *destination);
-       
+
        /**
         * Get the source address.
-        * 
+        *
         * Set host_t is still owned by packet_t, clone it
         * if needed.
-        * 
+        *
         * @return                      source address
         */
        host_t *(*get_source) (packet_t *packet);
-       
+
        /**
         * Get the destination address.
-        * 
+        *
         * Set host_t is still owned by packet_t, clone it
         * if needed.
-        * 
+        *
         * @return                      destination address
         */
        host_t *(*get_destination) (packet_t *packet);
-       
+
        /**
         * Get the data from the packet.
-        * 
-        * The data pointed by the chunk is still owned 
+        *
+        * The data pointed by the chunk is still owned
         * by the packet. Clone it if needed.
-        * 
+        *
         * @return                      chunk containing the data
         */
        chunk_t (*get_data) (packet_t *packet);
-       
+
        /**
         * Set the data in the packet.
-        * 
-        * Supplied chunk data is now owned by the 
+        *
+        * Supplied chunk data is now owned by the
         * packet. It will free it.
-        * 
+        *
         * @param data          chunk with data to set
         */
        void (*set_data) (packet_t *packet, chunk_t data);
-       
+
        /**
         * Clones a packet_t object.
-        *  
+        *
         * @param clone         clone of the packet
         */
        packet_t* (*clone) (packet_t *packet);
-       
+
        /**
         * Destroy the packet, freeing contained data.
         */
@@ -107,7 +107,7 @@ struct packet_t {
 
 /**
  * create an empty packet
- *  
+ *
  * @return packet_t object
  */
 packet_t *packet_create(void);
index 5c24a62700ae6b5fd50d247edb6d3b11838e0909..1a33251b6afcaab9d8ef0f87bffef525c471c1c4 100644 (file)
@@ -50,57 +50,57 @@ struct private_receiver_t {
         * Public part of a receiver_t object.
         */
        receiver_t public;
-        
+
        /**
         * Threads job receiving packets
         */
        callback_job_t *job;
-       
+
        /**
         * Assigned thread.
         */
        pthread_t assigned_thread;
-        
+
        /**
         * current secret to use for cookie calculation
         */
        char secret[SECRET_LENGTH];
-       
+
        /**
         * previous secret used to verify older cookies
         */
        char secret_old[SECRET_LENGTH];
-       
+
        /**
         * how many times we have used "secret" so far
         */
        u_int32_t secret_used;
-       
+
        /**
         * time we did the cookie switch
         */
        u_int32_t secret_switch;
-       
+
        /**
         * time offset to use, hides our system time
         */
        u_int32_t secret_offset;
-       
+
        /**
         * the RNG to use for secret generation
         */
        rng_t *rng;
-       
+
        /**
         * hasher to use for cookie calculation
         */
        hasher_t *hasher;
-       
+
        /**
         * require cookies after this many half open IKE_SAs
         */
        u_int32_t cookie_threshold;
-       
+
        /**
         * how many half open IKE_SAs per peer before blocking
         */
@@ -119,7 +119,7 @@ static void send_notify(message_t *request, notify_type_t type, chunk_t data)
                host_t *src, *dst;
                packet_t *packet;
                ike_sa_id_t *ike_sa_id;
-               
+
                response = message_create();
                dst = request->get_source(request);
                src = request->get_destination(request);
@@ -149,7 +149,7 @@ static chunk_t cookie_build(private_receiver_t *this, message_t *message,
        u_int64_t spi = message->get_initiator_spi(message);
        host_t *ip = message->get_source(message);
        chunk_t input, hash;
-       
+
        /* COOKIE = t | sha1( IPi | SPIi | t | secret ) */
        input = chunk_cata("cccc", ip->get_address(ip), chunk_from_thing(spi),
                                          chunk_from_thing(t), secret);
@@ -167,18 +167,18 @@ static bool cookie_verify(private_receiver_t *this, message_t *message,
        u_int32_t t, now;
        chunk_t reference;
        chunk_t secret;
-       
+
        now = time_monotonic(NULL);
        t = *(u_int32_t*)cookie.ptr;
-       
+
        if (cookie.len != sizeof(u_int32_t) +
-                       this->hasher->get_hash_size(this->hasher) || 
+                       this->hasher->get_hash_size(this->hasher) ||
                t < now - this->secret_offset - COOKIE_LIFETIME)
        {
                DBG2(DBG_NET, "received cookie lifetime expired, rejecting");
-               return FALSE;   
+               return FALSE;
        }
-       
+
        /* check if cookie is derived from old_secret */
        if (t + this->secret_offset > this->secret_switch)
        {
@@ -188,7 +188,7 @@ static bool cookie_verify(private_receiver_t *this, message_t *message,
        {
                secret = chunk_from_thing(this->secret_old);
        }
-       
+
        /* compare own calculation against received */
        reference = cookie_build(this, message, t, secret);
        if (chunk_equals(reference, cookie))
@@ -206,20 +206,20 @@ static bool cookie_verify(private_receiver_t *this, message_t *message,
 static bool cookie_required(private_receiver_t *this, message_t *message)
 {
        bool failed = FALSE;
-               
+
        if (charon->ike_sa_manager->get_half_open_count(charon->ike_sa_manager,
                                                                                                NULL) >= this->cookie_threshold)
        {
                /* check for a cookie. We don't use our parser here and do it
-                * quick and dirty for performance reasons. 
-                * we assume the cookie is the first payload (which is a MUST), and 
+                * quick and dirty for performance reasons.
+                * we assume the cookie is the first payload (which is a MUST), and
                 * the cookie's SPI length is zero. */
                packet_t *packet = message->get_packet(message);
                chunk_t data = packet->get_data(packet);
-               if (data.len < 
+               if (data.len <
                         IKE_HEADER_LENGTH + NOTIFY_PAYLOAD_HEADER_LENGTH +
                         sizeof(u_int32_t) + this->hasher->get_hash_size(this->hasher) ||
-                       *(data.ptr + 16) != NOTIFY || 
+                       *(data.ptr + 16) != NOTIFY ||
                        *(u_int16_t*)(data.ptr + IKE_HEADER_LENGTH + 6) != htons(COOKIE))
                {
                        /* no cookie found */
@@ -261,14 +261,14 @@ static job_requeue_t receive_packets(private_receiver_t *this)
        packet_t *packet;
        message_t *message;
        job_t *job;
-       
+
        /* read in a packet */
        if (charon->socket->receive(charon->socket, &packet) != SUCCESS)
        {
                DBG2(DBG_NET, "receiving from socket failed!");
                return JOB_REQUEUE_FAIR;
        }
-       
+
        /* parse message header */
        message = message_create_from_packet(packet);
        if (message->parse_header(message) != SUCCESS)
@@ -278,18 +278,18 @@ static job_requeue_t receive_packets(private_receiver_t *this)
                message->destroy(message);
                return JOB_REQUEUE_DIRECT;
        }
-       
+
        /* check IKE major version */
        if (message->get_major_version(message) != IKE_MAJOR_VERSION)
        {
                DBG1(DBG_NET, "received unsupported IKE version %d.%d from %H, "
-                        "sending INVALID_MAJOR_VERSION", message->get_major_version(message), 
+                        "sending INVALID_MAJOR_VERSION", message->get_major_version(message),
                         message->get_minor_version(message), packet->get_source(packet));
                send_notify(message, INVALID_MAJOR_VERSION, chunk_empty);
                message->destroy(message);
                return JOB_REQUEUE_DIRECT;
        }
-       
+
        if (message->get_request(message) &&
                message->get_exchange_type(message) == IKE_SA_INIT)
        {
@@ -299,7 +299,7 @@ static job_requeue_t receive_packets(private_receiver_t *this)
                        u_int32_t now = time_monotonic(NULL);
                        chunk_t cookie = cookie_build(this, message, now - this->secret_offset,
                                                                                  chunk_from_thing(this->secret));
-                       
+
                        DBG2(DBG_NET, "received packet from: %#H to %#H",
                                 message->get_source(message),
                                 message->get_destination(message));
@@ -312,7 +312,7 @@ static job_requeue_t receive_packets(private_receiver_t *this)
                                /* create new cookie */
                                DBG1(DBG_NET, "generating new cookie secret after %d uses",
                                         this->secret_used);
-                               memcpy(this->secret_old, this->secret, SECRET_LENGTH);  
+                               memcpy(this->secret_old, this->secret, SECRET_LENGTH);
                                this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret);
                                this->secret_switch = now;
                                this->secret_used = 0;
@@ -320,7 +320,7 @@ static job_requeue_t receive_packets(private_receiver_t *this)
                        message->destroy(message);
                        return JOB_REQUEUE_DIRECT;
                }
-               
+
                /* check if peer has not too many IKE_SAs half open */
                if (this->block_threshold && peer_to_aggressive(this, message))
                {
@@ -353,9 +353,9 @@ receiver_t *receiver_create()
 {
        private_receiver_t *this = malloc_thing(private_receiver_t);
        u_int32_t now = time_monotonic(NULL);
-       
+
        this->public.destroy = (void(*)(receiver_t*)) destroy;
-       
+
        this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_PREFERRED);
        if (this->hasher == NULL)
        {
@@ -385,11 +385,11 @@ receiver_t *receiver_create()
                this->cookie_threshold = 0;
                this->block_threshold = 0;
        }
-       
+
        this->job = callback_job_create((callback_job_cb_t)receive_packets,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public;
 }
 
index 87797634e64468c96e89e8ac66694a5d963ab85f..d4187cc66c6bf2aa0eaf005c10f66c1c46e40076 100644 (file)
@@ -29,7 +29,7 @@ typedef struct receiver_t receiver_t;
 
 /**
  * Receives packets from the socket and adds them to the job queue.
- * 
+ *
  * The receiver starts a thread, wich reads on the blocking socket. A received
  * packet is preparsed and a process_message_job is queued in the job queue.
  *
@@ -45,12 +45,12 @@ typedef struct receiver_t receiver_t;
  *
  * The secret is changed after a certain amount of cookies sent. The old
  * secret is stored to allow a clean migration between secret changes.
- * 
+ *
  * Further, the number of half-initiated IKE_SAs is limited per peer. This
  * mades it impossible for a peer to flood the server with its real IP address.
  */
 struct receiver_t {
-       
+
        /**
         * Destroys a receiver_t object.
         */
@@ -59,10 +59,10 @@ struct receiver_t {
 
 /**
  * Create a receiver_t object.
- * 
+ *
  * The receiver thread will start working, get data
  * from the socket and add those packets to the job queue.
- * 
+ *
  * @return     receiver_t object, NULL if initialization fails
  */
 receiver_t * receiver_create(void);
index 19f589115e6a97d9a458850c457ff7ef8f693897..402773f8906aa9dfea605c03f777a3cee812bbe6 100644 (file)
@@ -40,7 +40,7 @@ struct private_sender_t {
         * Sender threads job.
         */
        callback_job_t *job;
-        
+
        /**
         * The packets are stored in a linked list
         */
@@ -55,7 +55,7 @@ struct private_sender_t {
         * condvar to signal for packets added to list
         */
        condvar_t *got;
-       
+
        /**
         * condvar to signal for packets sent
         */
@@ -68,11 +68,11 @@ struct private_sender_t {
 static void send_(private_sender_t *this, packet_t *packet)
 {
        host_t *src, *dst;
-       
+
        src = packet->get_source(packet);
        dst = packet->get_destination(packet);
        DBG1(DBG_NET, "sending packet: from %#H to %#H", src, dst);
-       
+
        this->mutex->lock(this->mutex);
        this->list->insert_last(this->list, packet);
        this->got->signal(this->got);
@@ -86,23 +86,23 @@ static job_requeue_t send_packets(private_sender_t * this)
 {
        packet_t *packet;
        int oldstate;
-       
+
        this->mutex->lock(this->mutex);
        while (this->list->get_count(this->list) == 0)
        {
                /* add cleanup handler, wait for packet, remove cleanup handler */
                pthread_cleanup_push((void(*)(void*))this->mutex->unlock, this->mutex);
                pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
-               
+
                this->got->wait(this->got, this->mutex);
-               
+
                pthread_setcancelstate(oldstate, NULL);
                pthread_cleanup_pop(0);
        }
        this->list->remove_first(this->list, (void**)&packet);
        this->sent->signal(this->sent);
        this->mutex->unlock(this->mutex);
-       
+
        charon->socket->send(charon->socket, packet);
        packet->destroy(packet);
        return JOB_REQUEUE_DIRECT;
@@ -134,19 +134,19 @@ static void destroy(private_sender_t *this)
 sender_t * sender_create()
 {
        private_sender_t *this = malloc_thing(private_sender_t);
-       
+
        this->public.send = (void(*)(sender_t*,packet_t*))send_;
        this->public.destroy = (void(*)(sender_t*)) destroy;
-       
+
        this->list = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->got = condvar_create(CONDVAR_TYPE_DEFAULT);
        this->sent = condvar_create(CONDVAR_TYPE_DEFAULT);
-       
+
        this->job = callback_job_create((callback_job_cb_t)send_packets,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public;
 }
 
index 55f67af707b0a5d5693dfc5014c1f59665ecf114..0ac7755207346afda2e619c4caf2b8e1ad378044 100644 (file)
@@ -31,7 +31,7 @@ typedef struct sender_t sender_t;
  * Thread responsible for sending packets over the socket.
  */
 struct sender_t {
-       
+
        /**
         * Send a packet over the network.
         *
@@ -42,7 +42,7 @@ struct sender_t {
         * @param packet        packet to send
         */
        void (*send) (sender_t *this, packet_t *packet);
-       
+
        /**
         * Destroys a sender object.
         */
@@ -51,10 +51,10 @@ struct sender_t {
 
 /**
  * Create the sender thread.
- * 
+ *
  * The thread will start to work, getting packets
  * from its queue and sends them out.
- * 
+ *
  * @return             created sender object
  */
 sender_t * sender_create(void);
index 148be486c7a1b87cb99584dbfb3c4fcafdff58d1..18b31d637c9fa82372eccf741c0eb96c7b9d8c6c 100644 (file)
@@ -85,12 +85,12 @@ struct private_socket_t{
          * port used for nat-t
          */
         int natt_port;
-        
+
         /**
          * raw receiver socket for IPv4
          */
         int recv4;
-        
+
         /**
          * raw receiver socket for IPv6
          */
@@ -132,7 +132,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
        fd_set rfds;
 
        FD_ZERO(&rfds);
-       
+
        if (this->recv4)
        {
                FD_SET(this->recv4, &rfds);
@@ -141,9 +141,9 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
        {
                FD_SET(this->recv6, &rfds);
        }
-       
+
        DBG2(DBG_NET, "waiting for data on raw sockets");
-       
+
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        if (select(max(this->recv4, this->recv6) + 1, &rfds, NULL, NULL, NULL) <= 0)
        {
@@ -151,14 +151,14 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                return FAILED;
        }
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (this->recv4 && FD_ISSET(this->recv4, &rfds))
        {
                /* IPv4 raw sockets return the IP header. We read src/dest
                 * information directly from the raw header */
                struct iphdr *ip;
                struct sockaddr_in src, dst;
-               
+
                bytes_read = recv(this->recv4, buffer, MAX_PACKET, 0);
                if (bytes_read < 0)
                {
@@ -166,7 +166,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        return FAILED;
                }
                DBG3(DBG_NET, "received IPv4 packet %b", buffer, bytes_read);
-               
+
                /* read source/dest from raw IP/UDP header */
                if (bytes_read < IP_LEN + UDP_LEN + MARKER_LEN)
                {
@@ -184,13 +184,13 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                dst.sin_port = udp->dest;
                source = host_create_from_sockaddr((sockaddr_t*)&src);
                dest = host_create_from_sockaddr((sockaddr_t*)&dst);
-               
+
                pkt = packet_create();
                pkt->set_source(pkt, source);
                pkt->set_destination(pkt, dest);
                DBG2(DBG_NET, "received packet: from %#H to %#H", source, dest);
                data_offset = IP_LEN + UDP_LEN;
-               /* remove non esp marker */     
+               /* remove non esp marker */
                if (dest->get_port(dest) == IKEV2_NATT_PORT)
                {
                        data_offset += MARKER_LEN;
@@ -210,7 +210,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                struct sockaddr_in6 src, dst;
                struct iovec iov;
                char ancillary[64];
-               
+
                msg.msg_name = &src;
                msg.msg_namelen = sizeof(src);
                iov.iov_base = buffer;
@@ -220,7 +220,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                msg.msg_control = ancillary;
                msg.msg_controllen = sizeof(ancillary);
                msg.msg_flags = 0;
-               
+
                bytes_read = recvmsg(this->recv6, &msg, 0);
                if (bytes_read < 0)
                {
@@ -228,14 +228,14 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        return FAILED;
                }
                DBG3(DBG_NET, "received IPv6 packet %b", buffer, bytes_read);
-               
+
                if (bytes_read < IP_LEN + UDP_LEN + MARKER_LEN)
                {
                        DBG3(DBG_NET, "received IPv6 packet too short (%d bytes)",
                                 bytes_read);
                        return FAILED;
                }
-               
+
                /* read ancillary data to get destination address */
                for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL;
                         cmsgptr = CMSG_NXTHDR(&msg, cmsgptr))
@@ -244,13 +244,13 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        {
                                DBG1(DBG_NET, "error reading IPv6 ancillary data");
                                return FAILED;
-                       }       
+                       }
                        if (cmsgptr->cmsg_level == SOL_IPV6 &&
                                cmsgptr->cmsg_type == IPV6_2292PKTINFO)
                        {
                                struct in6_pktinfo *pktinfo;
                                pktinfo = (struct in6_pktinfo*)CMSG_DATA(cmsgptr);
-                               
+
                                memset(&dst, 0, sizeof(dst));
                                memcpy(&dst.sin6_addr, &pktinfo->ipi6_addr, sizeof(dst.sin6_addr));
                                dst.sin6_family = AF_INET6;
@@ -266,15 +266,15 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        DBG1(DBG_NET, "error reading IPv6 packet header");
                        return FAILED;
                }
-               
+
                source = host_create_from_sockaddr((sockaddr_t*)&src);
-               
+
                pkt = packet_create();
                pkt->set_source(pkt, source);
                pkt->set_destination(pkt, dest);
                DBG2(DBG_NET, "received packet: from %#H to %#H", source, dest);
                data_offset = UDP_LEN;
-               /* remove non esp marker */     
+               /* remove non esp marker */
                if (dest->get_port(dest) == IKEV2_NATT_PORT)
                {
                        data_offset += MARKER_LEN;
@@ -290,7 +290,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                /* oops, shouldn't happen */
                return FAILED;
        }
-       
+
        /* return packet */
        *packet = pkt;
        return SUCCESS;
@@ -308,13 +308,13 @@ status_t sender(private_socket_t *this, packet_t *packet)
        struct msghdr msg;
        struct cmsghdr *cmsg;
        struct iovec iov;
-       
+
        src = packet->get_source(packet);
        dst = packet->get_destination(packet);
        data = packet->get_data(packet);
 
        DBG2(DBG_NET, "sending packet: from %#H to %#H", src, dst);
-       
+
        /* send data */
        sport = src->get_port(src);
        family = dst->get_family(dst);
@@ -362,7 +362,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                DBG1(DBG_NET, "unable to locate a send socket for port %d", sport);
                return FAILED;
        }
-       
+
        memset(&msg, 0, sizeof(struct msghdr));
        msg.msg_name = dst->get_sockaddr(dst);;
        msg.msg_namelen = *dst->get_sockaddr_len(dst);
@@ -371,7 +371,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
        msg.msg_iov = &iov;
        msg.msg_iovlen = 1;
        msg.msg_flags = 0;
-       
+
        if (!src->is_anyaddr(src))
        {
                if (family == AF_INET)
@@ -379,7 +379,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                        char buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
                        struct in_pktinfo *pktinfo;
                        struct sockaddr_in *sin;
-                       
+
                        msg.msg_control = buf;
                        msg.msg_controllen = sizeof(buf);
                        cmsg = CMSG_FIRSTHDR(&msg);
@@ -396,7 +396,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                        char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
                        struct in6_pktinfo *pktinfo;
                        struct sockaddr_in6 *sin;
-                       
+
                        msg.msg_control = buf;
                        msg.msg_controllen = sizeof(buf);
                        cmsg = CMSG_FIRSTHDR(&msg);
@@ -409,7 +409,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                        memcpy(&pktinfo->ipi6_addr, &sin->sin6_addr, sizeof(struct in6_addr));
                }
        }
-       
+
        bytes_sent = sendmsg(skt, &msg, 0);
 
        if (bytes_sent != data.len)
@@ -430,7 +430,7 @@ static int open_send_socket(private_socket_t *this, int family, u_int16_t port)
        struct sockaddr_storage addr;
        u_int sol;
        int skt;
-       
+
        memset(&addr, 0, sizeof(addr));
        /* precalculate constants depending on address family */
        switch (family)
@@ -456,14 +456,14 @@ static int open_send_socket(private_socket_t *this, int family, u_int16_t port)
                default:
                        return 0;
        }
-       
+
        skt = socket(family, SOCK_DGRAM, IPPROTO_UDP);
        if (skt < 0)
        {
                DBG1(DBG_NET, "could not open send socket: %s", strerror(errno));
                return 0;
        }
-       
+
        if (setsockopt(skt, SOL_SOCKET, SO_REUSEADDR, (void*)&on, sizeof(on)) < 0)
        {
                DBG1(DBG_NET, "unable to set SO_REUSEADDR on send socket: %s",
@@ -471,7 +471,7 @@ static int open_send_socket(private_socket_t *this, int family, u_int16_t port)
                close(skt);
                return 0;
        }
-       
+
        /* bind the send socket */
        if (bind(skt, (struct sockaddr *)&addr, sizeof(addr)) < 0)
        {
@@ -480,7 +480,7 @@ static int open_send_socket(private_socket_t *this, int family, u_int16_t port)
                close(skt);
                return 0;
        }
-       
+
        if (family == AF_INET)
        {
                /* enable UDP decapsulation globally, only for one socket needed */
@@ -490,7 +490,7 @@ static int open_send_socket(private_socket_t *this, int family, u_int16_t port)
                                 strerror(errno));
                }
        }
-       
+
        return skt;
 }
 
@@ -502,7 +502,7 @@ static int open_recv_socket(private_socket_t *this, int family)
        int skt;
        int on = TRUE;
        u_int proto_offset, ip_len, sol, udp_header, ike_header;
-       
+
        /* precalculate constants depending on address family */
        switch (family)
        {
@@ -521,7 +521,7 @@ static int open_recv_socket(private_socket_t *this, int family)
        }
        udp_header = ip_len;
        ike_header = ip_len + UDP_LEN;
-       
+
        /* This filter code filters out all non-IKEv2 traffic on
         * a SOCK_RAW IP_PROTP_UDP socket. Handling of other
         * IKE versions is done in pluto.
@@ -560,7 +560,7 @@ static int open_recv_socket(private_socket_t *this, int family)
                sizeof(ikev2_filter_code) / sizeof(struct sock_filter),
                ikev2_filter_code
        };
-       
+
        /* set up a raw socket */
        skt = socket(family, SOCK_RAW, IPPROTO_UDP);
        if (skt < 0)
@@ -568,7 +568,7 @@ static int open_recv_socket(private_socket_t *this, int family)
                DBG1(DBG_NET, "unable to create raw socket: %s", strerror(errno));
                return 0;
        }
-       
+
        if (setsockopt(skt, SOL_SOCKET, SO_ATTACH_FILTER,
                                   &ikev2_filter, sizeof(ikev2_filter)) < 0)
        {
@@ -577,7 +577,7 @@ static int open_recv_socket(private_socket_t *this, int family)
                close(skt);
                return 0;
        }
-       
+
        if (family == AF_INET6 &&
                /* we use IPV6_2292PKTINFO, as IPV6_PKTINFO is defined as
                 * 2 or 50 depending on kernel header version */
@@ -588,7 +588,7 @@ static int open_recv_socket(private_socket_t *this, int family)
                close(skt);
                return 0;
        }
-       
+
        return skt;
 }
 
@@ -621,7 +621,7 @@ static bool enumerate(socket_enumerator_t *this, int *fd, int *family, int *port
                { offsetof(private_socket_t, send4_natt), AF_INET, IKEV2_NATT_PORT },
                { offsetof(private_socket_t, send6_natt), AF_INET6, IKEV2_NATT_PORT }
        };
-       
+
        while(++this->index < countof(sockets))
        {
                int sock = *(int*)((char*)this->socket + sockets[this->index].fd_offset);
@@ -643,7 +643,7 @@ static bool enumerate(socket_enumerator_t *this, int *fd, int *family, int *port
 static enumerator_t *create_enumerator(private_socket_t *this)
 {
        socket_enumerator_t *enumerator;
-       
+
        enumerator = malloc_thing(socket_enumerator_t);
        enumerator->index = -1;
        enumerator->socket = this;
@@ -690,20 +690,20 @@ static void destroy(private_socket_t *this)
 socket_t *socket_create()
 {
        private_socket_t *this = malloc_thing(private_socket_t);
-       
+
        /* public functions */
        this->public.send = (status_t(*)(socket_t*, packet_t*))sender;
        this->public.receive = (status_t(*)(socket_t*, packet_t**))receiver;
        this->public.create_enumerator = (enumerator_t*(*)(socket_t*))create_enumerator;
        this->public.destroy = (void(*)(socket_t*)) destroy;
-       
+
        this->recv4 = 0;
        this->recv6 = 0;
        this->send4 = 0;
        this->send6 = 0;
        this->send4_natt = 0;
        this->send6_natt = 0;
-       
+
        this->recv4 = open_recv_socket(this, AF_INET);
        if (this->recv4 == 0)
        {
@@ -726,7 +726,7 @@ socket_t *socket_create()
                        }
                }
        }
-       
+
        this->recv6 = open_recv_socket(this, AF_INET6);
        if (this->recv6 == 0)
        {
@@ -749,13 +749,13 @@ socket_t *socket_create()
                        }
                }
        }
-       
+
        if (!(this->send4 || this->send6) || !(this->recv4 || this->recv6))
        {
                DBG1(DBG_NET, "could not create any sockets");
                destroy(this);
                charon->kill(charon, "socket initialization failed");
        }
-       
+
        return (socket_t*)this;
 }
index 97c88be790a08a9baa049c1bf98c6671d24243fe..ab276aedc51e58eaf93e5da6d2ccb1f5b7754562 100644 (file)
@@ -86,22 +86,22 @@ struct private_socket_t {
         * public functions
         */
        socket_t public;
-       
+
        /**
         * IPv4 socket (500)
         */
        int ipv4;
-        
+
        /**
         * IPv4 socket for NATT (4500)
         */
        int ipv4_natt;
-       
+
        /**
         * IPv6 socket (500)
         */
        int ipv6;
-       
+
        /**
         * IPv6 socket for NATT (4500)
         */
@@ -122,9 +122,9 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
        fd_set rfds;
        int max_fd = 0, selected = 0;
        u_int16_t port = 0;
-       
+
        FD_ZERO(&rfds);
-       
+
        if (this->ipv4)
        {
                FD_SET(this->ipv4, &rfds);
@@ -142,7 +142,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                FD_SET(this->ipv6_natt, &rfds);
        }
        max_fd = max(max(this->ipv4, this->ipv4_natt), max(this->ipv6, this->ipv6_natt));
-       
+
        DBG2(DBG_NET, "waiting for data on sockets");
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        if (select(max_fd + 1, &rfds, NULL, NULL, NULL) <= 0)
@@ -151,7 +151,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                return FAILED;
        }
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (FD_ISSET(this->ipv4, &rfds))
        {
                port = IKEV2_UDP_PORT;
@@ -182,7 +182,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        struct sockaddr_in in4;
                        struct sockaddr_in6 in6;
                } src;
-               
+
                msg.msg_name = &src;
                msg.msg_namelen = sizeof(src);
                iov.iov_base = buffer;
@@ -199,14 +199,14 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        return FAILED;
                }
                DBG3(DBG_NET, "received packet %b", buffer, bytes_read);
-               
+
                if (bytes_read < MARKER_LEN)
                {
                        DBG3(DBG_NET, "received packet too short (%d bytes)",
                                 bytes_read);
                        return FAILED;
                }
-               
+
                /* read ancillary data to get destination address */
                for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL;
                         cmsgptr = CMSG_NXTHDR(&msg, cmsgptr))
@@ -216,14 +216,14 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                                DBG1(DBG_NET, "error reading ancillary data");
                                return FAILED;
                        }
-                       
+
                        if (cmsgptr->cmsg_level == SOL_IPV6 &&
                                cmsgptr->cmsg_type == IPV6_PKTINFO)
                        {
                                struct in6_pktinfo *pktinfo;
                                pktinfo = (struct in6_pktinfo*)CMSG_DATA(cmsgptr);
                                struct sockaddr_in6 dst;
-                               
+
                                memset(&dst, 0, sizeof(dst));
                                memcpy(&dst.sin6_addr, &pktinfo->ipi6_addr, sizeof(dst.sin6_addr));
                                dst.sin6_family = AF_INET6;
@@ -252,7 +252,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
 #endif
                                memset(&dst, 0, sizeof(dst));
                                memcpy(&dst.sin_addr, addr, sizeof(dst.sin_addr));
-                               
+
                                dst.sin_family = AF_INET;
                                dst.sin_port = htons(port);
                                dest = host_create_from_sockaddr((sockaddr_t*)&dst);
@@ -268,13 +268,13 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        return FAILED;
                }
                source = host_create_from_sockaddr((sockaddr_t*)&src);
-               
+
                pkt = packet_create();
                pkt->set_source(pkt, source);
                pkt->set_destination(pkt, dest);
                DBG2(DBG_NET, "received packet: from %#H to %#H", source, dest);
                data_offset = 0;
-               /* remove non esp marker */     
+               /* remove non esp marker */
                if (dest->get_port(dest) == IKEV2_NATT_PORT)
                {
                        data_offset += MARKER_LEN;
@@ -307,13 +307,13 @@ status_t sender(private_socket_t *this, packet_t *packet)
        struct msghdr msg;
        struct cmsghdr *cmsg;
        struct iovec iov;
-       
+
        src = packet->get_source(packet);
        dst = packet->get_destination(packet);
        data = packet->get_data(packet);
 
        DBG2(DBG_NET, "sending packet: from %#H to %#H", src, dst);
-       
+
        /* send data */
        sport = src->get_port(src);
        family = dst->get_family(dst);
@@ -361,7 +361,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                DBG1(DBG_NET, "unable to locate a send socket for port %d", sport);
                return FAILED;
        }
-       
+
        memset(&msg, 0, sizeof(struct msghdr));
        msg.msg_name = dst->get_sockaddr(dst);;
        msg.msg_namelen = *dst->get_sockaddr_len(dst);
@@ -370,7 +370,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
        msg.msg_iov = &iov;
        msg.msg_iovlen = 1;
        msg.msg_flags = 0;
-       
+
        if (!src->is_anyaddr(src))
        {
                if (family == AF_INET)
@@ -408,7 +408,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                        char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
                        struct in6_pktinfo *pktinfo;
                        struct sockaddr_in6 *sin;
-                       
+
                        msg.msg_control = buf;
                        msg.msg_controllen = sizeof(buf);
                        cmsg = CMSG_FIRSTHDR(&msg);
@@ -421,7 +421,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                        memcpy(&pktinfo->ipi6_addr, &sin->sin6_addr, sizeof(struct in6_addr));
                }
        }
-       
+
        bytes_sent = sendmsg(skt, &msg, 0);
 
        if (bytes_sent != data.len)
@@ -442,7 +442,7 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
        socklen_t addrlen;
        u_int sol, pktinfo = 0;
        int skt;
-       
+
        memset(&addr, 0, sizeof(addr));
        /* precalculate constants depending on address family */
        switch (family)
@@ -476,7 +476,7 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
                default:
                        return 0;
        }
-       
+
        skt = socket(family, SOCK_DGRAM, IPPROTO_UDP);
        if (skt < 0)
        {
@@ -489,7 +489,7 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
                close(skt);
                return 0;
        }
-       
+
        /* bind the socket */
        if (bind(skt, (struct sockaddr *)&addr, addrlen) < 0)
        {
@@ -497,7 +497,7 @@ static int open_socket(private_socket_t *this, int family, u_int16_t port)
                close(skt);
                return 0;
        }
-       
+
        /* get additional packet info on receive */
        if (pktinfo > 0)
        {
@@ -550,7 +550,7 @@ static bool enumerate(socket_enumerator_t *this, int *fd, int *family, int *port
                { offsetof(private_socket_t, ipv4_natt), AF_INET, IKEV2_NATT_PORT },
                { offsetof(private_socket_t, ipv6_natt), AF_INET6, IKEV2_NATT_PORT }
        };
-       
+
        while(++this->index < countof(sockets))
        {
                int sock = *(int*)((char*)this->socket + sockets[this->index].fd_offset);
@@ -572,7 +572,7 @@ static bool enumerate(socket_enumerator_t *this, int *fd, int *family, int *port
 static enumerator_t *create_enumerator(private_socket_t *this)
 {
        socket_enumerator_t *enumerator;
-       
+
        enumerator = malloc_thing(socket_enumerator_t);
        enumerator->index = -1;
        enumerator->socket = this;
@@ -617,7 +617,7 @@ socket_t *socket_create()
        this->public.receive = (status_t(*)(socket_t*, packet_t**))receiver;
        this->public.create_enumerator = (enumerator_t*(*)(socket_t*))create_enumerator;
        this->public.destroy = (void(*)(socket_t*)) destroy;
-       
+
        this->ipv4 = 0;
        this->ipv6 = 0;
        this->ipv4_natt = 0;
@@ -634,7 +634,7 @@ socket_t *socket_create()
                }
        }
 #endif
-       
+
        this->ipv4 = open_socket(this, AF_INET, IKEV2_UDP_PORT);
        if (this->ipv4 == 0)
        {
@@ -648,7 +648,7 @@ socket_t *socket_create()
                        DBG1(DBG_NET, "could not open IPv4 NAT-T socket");
                }
        }
-       
+
        this->ipv6 = open_socket(this, AF_INET6, IKEV2_UDP_PORT);
        if (this->ipv6 == 0)
        {
@@ -662,13 +662,13 @@ socket_t *socket_create()
                        DBG1(DBG_NET, "could not open IPv6 NAT-T socket");
                }
        }
-       
+
        if (!this->ipv4 && !this->ipv6)
        {
                DBG1(DBG_NET, "could not create any sockets");
                destroy(this);
                charon->kill(charon, "socket initialization failed");
-       }       
+       }
        return (socket_t*)this;
 }
 
index 81f2ec5fe56f43714803da0e7965f9220d789141..83bb9d4c94695bc867540f5b487c51d695554ec2 100644 (file)
@@ -44,48 +44,48 @@ typedef struct socket_t socket_t;
  * All available sockets are bound and the receive function
  * reads from them. There are actually two implementations:
  * The first uses raw sockets to allow binding of other daemons (pluto) to
- * UDP/500. An installed "Linux socket filter" filters out all non-IKEv2 
- * traffic and handles just IKEv2 messages. An other daemon (pluto) must 
- * handle all traffic separately, e.g. ignore IKEv2 traffic, since charon 
+ * UDP/500. An installed "Linux socket filter" filters out all non-IKEv2
+ * traffic and handles just IKEv2 messages. An other daemon (pluto) must
+ * handle all traffic separately, e.g. ignore IKEv2 traffic, since charon
  * handles that.
  * The other implementation uses normal sockets and is built if
  * --disable-pluto is given to the configure script.
  */
 struct socket_t {
-       
+
        /**
         * Receive a packet.
-        * 
+        *
         * Reads a packet from the socket and sets source/dest
         * appropriately.
-        * 
+        *
         * @param packet                pinter gets address from allocated packet_t
-        * @return                              
+        * @return
         *                                              - SUCCESS when packet successfully received
         *                                              - FAILED when unable to receive
         */
        status_t (*receive) (socket_t *this, packet_t **packet);
-       
+
        /**
         * Send a packet.
-        * 
+        *
         * Sends a packet to the net using source and destination addresses of
         * the packet.
-        * 
+        *
         * @param packet                packet_t to send
-        * @return                              
+        * @return
         *                                              - SUCCESS when packet successfully sent
         *                                              - FAILED when unable to send
         */
        status_t (*send) (socket_t *this, packet_t *packet);
-       
+
        /**
         * Enumerate all underlying socket file descriptors.
-        * 
+        *
         * @return                              enumerator over (int fd, int family, int port)
         */
        enumerator_t *(*create_enumerator) (socket_t *this);
-       
+
        /**
         * Destroy socket.
         */
index 9d553231063c3a25a444bb4ae86b88bd57b4d567..a3e83fe61bca6b5dcbc9a1be8f2aff6d475a3b15 100644 (file)
@@ -24,12 +24,12 @@ typedef struct private_attr_plugin_t private_attr_plugin_t;
  * private data of attr plugin
  */
 struct private_attr_plugin_t {
-       
+
        /**
         * implements plugin interface
         */
        attr_plugin_t public;
-       
+
        /**
         * CFG attributes provider
         */
@@ -52,12 +52,12 @@ static void destroy(private_attr_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_attr_plugin_t *this = malloc_thing(private_attr_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->provider = attr_provider_create();
        charon->attributes->add_provider(charon->attributes, &this->provider->provider);
-       
+
        return &this->public.plugin;
 }
 
index 9cbbd8bf563f7b218cbe3413c62109a67bc4e35f..9f31b60e18ad0fdc21e263310dbc22e2fa73658c 100644 (file)
@@ -32,7 +32,7 @@ typedef struct attr_plugin_t attr_plugin_t;
  * Plugin providing configuration attribute through strongswan.conf.
  */
 struct attr_plugin_t {
-       
+
        /**
         * implements plugin interface
         */
index 02fa11327c96cf786972d678a96d41cd97c8c732..88c5ed4c02666a13cf29dea512cddc15342bf09d 100644 (file)
@@ -28,12 +28,12 @@ typedef struct attribute_entry_t attribute_entry_t;
  * private data of attr_provider
  */
 struct private_attr_provider_t {
-       
+
        /**
         * public functions
         */
        attr_provider_t public;
-       
+
        /**
         * List of attributes, attribute_entry_t
         */
@@ -75,7 +75,7 @@ static enumerator_t* create_attribute_enumerator(
 static void destroy(private_attr_provider_t *this)
 {
        attribute_entry_t *entry;
-       
+
        while (this->attributes->remove_last(this->attributes,
                                                                                 (void**)&entry) == SUCCESS)
        {
@@ -95,7 +95,7 @@ static void add_entry(private_attr_provider_t *this, char *key, int nr,
        attribute_entry_t *entry;
        host_t *host;
        char *str;
-       
+
        str = lib->settings->get_str(lib->settings, "charon.%s%d", NULL, key, nr);
        if (str)
        {
@@ -103,7 +103,7 @@ static void add_entry(private_attr_provider_t *this, char *key, int nr,
                if (host)
                {
                        entry = malloc_thing(attribute_entry_t);
-                       
+
                        if (host->get_family(host) == AF_INET6)
                        {
                                switch (type)
@@ -133,22 +133,22 @@ attr_provider_t *attr_provider_create(database_t *db)
 {
        private_attr_provider_t *this;
        int i;
-       
+
        this = malloc_thing(private_attr_provider_t);
-       
+
        this->public.provider.acquire_address = (host_t*(*)(attribute_provider_t *this, char*, identification_t *, host_t *))return_null;
        this->public.provider.release_address = (bool(*)(attribute_provider_t *this, char*,host_t *, identification_t*))return_false;
        this->public.provider.create_attribute_enumerator = (enumerator_t*(*)(attribute_provider_t*, identification_t *id))create_attribute_enumerator;
        this->public.destroy = (void(*)(attr_provider_t*))destroy;
-       
+
        this->attributes = linked_list_create();
-       
+
        for (i = 1; i <= SERVER_MAX; i++)
        {
                add_entry(this, "dns", i, INTERNAL_IP4_DNS);
                add_entry(this, "nbns", i, INTERNAL_IP4_NBNS);
        }
-       
+
        return &this->public;
 }
 
index 03cbadb4e2310c0ea54ddbff8defba5bac173211..e867f2b20bb1354588059e2ed17479bec8b2d387 100644 (file)
@@ -29,12 +29,12 @@ typedef struct attr_provider_t attr_provider_t;
  * Provide configuration attributes through static strongswan.conf definition.
  */
 struct attr_provider_t {
-       
+
        /**
         * Implements attribute provider interface
         */
        attribute_provider_t provider;
-       
+
        /**
         * Destroy a attr_provider instance.
         */
index ebef744049f91d16f179b0f3ce6a9f0d197298be..0b85428f978d792a76308f1e9fbbad8c445038a5 100644 (file)
@@ -178,72 +178,72 @@ typedef struct private_eap_aka_t private_eap_aka_t;
  * Private data of an eap_aka_t object.
  */
 struct private_eap_aka_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        eap_aka_t public;
-       
+
        /**
         * ID of the server
         */
        identification_t *server;
-       
+
        /**
         * ID of the peer
         */
        identification_t *peer;
-       
+
        /**
         * SHA11 hasher
         */
        hasher_t *sha1;
-       
+
        /**
         * MAC function used in EAP-AKA
         */
        signer_t *signer;
-       
+
        /**
         * pseudo random function used in EAP-aka
         */
        prf_t *prf;
-       
+
        /**
         * Special keyed SHA1 hasher used in EAP-AKA, implemented as PRF
         */
        prf_t *keyed_prf;
-       
+
        /**
         * Key for EAP MAC
         */
        chunk_t k_auth;
-       
+
        /**
         * Key for EAP encryption
         */
        chunk_t k_encr;
-       
+
        /**
         * MSK
         */
        chunk_t msk;
-       
+
        /**
         * Extendend MSK
         */
        chunk_t emsk;
-       
+
        /**
         * Expected result from client XRES
         */
        chunk_t xres;
-       
+
        /**
         * Shared secret K from ipsec.conf (padded)
         */
        chunk_t k;
-       
+
        /**
         * random value RAND generated by server
         */
@@ -270,7 +270,7 @@ static chunk_t peer_sqn = chunk_from_buf(peer_sqn_buf);
 static void update_sqn(u_int8_t *sqn, time_t offset)
 {
        timeval_t time;
-       
+
        time_monotonic(&time);
        /* set sqb_sqn to an integer containing seconds followed by most
         * significant useconds */
@@ -322,7 +322,7 @@ static void mpz_mul_poly(mpz_t r, mpz_t a, mpz_t b)
 {
        mpz_t bm, rm;
        int current = 0, shifted = 0, shift;
-       
+
        mpz_init_set(bm, b);
        mpz_init_set_ui(rm, 0);
        /* scan through a, for each found bit: */
@@ -335,7 +335,7 @@ static void mpz_mul_poly(mpz_t r, mpz_t a, mpz_t b)
                mpz_xor(rm, rm, bm);
                current++;
        }
-       
+
        mpz_swap(r, rm);
        mpz_clear(rm);
        mpz_clear(bm);
@@ -361,13 +361,13 @@ static void mpz_mod_poly(mpz_t r, mpz_t a, mpz_t b)
         */
        int a_bit, b_bit, diff;
        mpz_t bm, am;
-       
+
        mpz_init_set(am, a);
        mpz_init(bm);
-       
+
        a_bit = mpz_sizeinbase(a, 2);
        b_bit = mpz_sizeinbase(b, 2);
-       
+
        /* don't do anything if b > a */
        if (a_bit >= b_bit)
        {
@@ -397,7 +397,7 @@ static void mpz_mod_poly(mpz_t r, mpz_t a, mpz_t b)
         * a = 00000010
         * which is the polynomial modulo
         */
-       
+
        mpz_swap(r, am);
        mpz_clear(am);
        mpz_clear(bm);
@@ -410,12 +410,12 @@ static void mpz_mod_poly(mpz_t r, mpz_t a, mpz_t b)
 static void step4(private_eap_aka_t *this, u_int8_t x[])
 {
        mpz_t xm, am, bm, gm;
-       
+
        mpz_init(xm);
        mpz_init(am);
        mpz_init(bm);
        mpz_init(gm);
-       
+
        mpz_import(xm, HASH_SIZE_SHA1, 1, 1, 1, 0, x);
        mpz_import(am, sizeof(a), 1, 1, 1, 0, a);
        mpz_import(bm, sizeof(b), 1, 1, 1, 0, b);
@@ -424,9 +424,9 @@ static void step4(private_eap_aka_t *this, u_int8_t x[])
        mpz_mul_poly(xm, am, xm);
        mpz_add_poly(xm, bm, xm);
        mpz_mod_poly(xm, xm, gm);
-       
+
        mpz_export(x, NULL, 1, HASH_SIZE_SHA1, 1, 0, xm);
-       
+
        mpz_clear(xm);
        mpz_clear(am);
        mpz_clear(bm);
@@ -441,7 +441,7 @@ static void step3(private_eap_aka_t *this,
                                  chunk_t k, chunk_t payload, u_int8_t h[])
 {
        u_int8_t buf[64];
-       
+
        if (payload.len < sizeof(buf))
        {
                /* pad c with zeros */
@@ -455,7 +455,7 @@ static void step3(private_eap_aka_t *this,
                /* not more than 512 bits can be G()-ed */
                payload.len = sizeof(buf);
        }
-       
+
        /* use the keyed hasher to build the hash */
        this->keyed_prf->set_key(this->keyed_prf, k);
        this->keyed_prf->get_bytes(this->keyed_prf, payload, h);
@@ -470,19 +470,19 @@ static void fx(private_eap_aka_t *this,
        chunk_t payload = chunk_alloca(PAYLOAD_LENGTH);
        u_int8_t h[HASH_SIZE_SHA1];
        u_int8_t i;
-       
+
        for (i = 0; i < 2; i++)
        {
                memset(payload.ptr, 0x5c, payload.len);
                payload.ptr[11] ^= f;
                memxor(payload.ptr + 12, fmk.ptr, fmk.len);
                memxor(payload.ptr + 24, rand.ptr, rand.len);
-               
+
                payload.ptr[3]  ^= i;
                payload.ptr[19] ^= i;
                payload.ptr[35] ^= i;
                payload.ptr[51] ^= i;
-               
+
                step3(this, k, payload, h);
                step4(this, h);
                memcpy(out + i * 8, h, 8);
@@ -502,14 +502,14 @@ static void f1x(private_eap_aka_t *this,
         */
        chunk_t payload = chunk_alloca(PAYLOAD_LENGTH);
        u_int8_t h[HASH_SIZE_SHA1];
-       
+
        memset(payload.ptr, 0x5c, PAYLOAD_LENGTH);
        payload.ptr[11] ^= f;
        memxor(payload.ptr + 12, fmk.ptr, fmk.len);
        memxor(payload.ptr + 16, rand.ptr, rand.len);
        memxor(payload.ptr + 34, sqn.ptr, sqn.len);
        memxor(payload.ptr + 42, amf.ptr, amf.len);
-       
+
        step3(this, k, payload, h);
        step4(this, h);
        memcpy(mac, h, MAC_LENGTH);
@@ -518,17 +518,17 @@ static void f1x(private_eap_aka_t *this,
 /**
  * Calculation function of f5() and f5star()
  */
-static void f5x(private_eap_aka_t *this, 
+static void f5x(private_eap_aka_t *this,
                                u_int8_t f, chunk_t k, chunk_t rand, u_int8_t ak[])
 {
        chunk_t payload = chunk_alloca(PAYLOAD_LENGTH);
        u_int8_t h[HASH_SIZE_SHA1];
-       
+
        memset(payload.ptr, 0x5c, payload.len);
        payload.ptr[11] ^= f;
        memxor(payload.ptr + 12, fmk.ptr, fmk.len);
        memxor(payload.ptr + 16, rand.ptr, rand.len);
-       
+
        step3(this, k, payload, h);
        step4(this, h);
        memcpy(ak, h, AK_LENGTH);
@@ -605,12 +605,12 @@ static void f5star(private_eap_aka_t *this, chunk_t k, chunk_t rand, u_int8_t ak
 static bool derive_keys(private_eap_aka_t *this, identification_t *id)
 {
        chunk_t ck, ik, mk, identity, tmp;
-       
+
        ck = chunk_alloca(CK_LENGTH);
        ik = chunk_alloca(IK_LENGTH);
        mk = chunk_alloca(MK_LENGTH);
        identity = id->get_encoding(id);
-       
+
        /* MK = SHA1( Identity | IK | CK ) */
        f3(this, this->k, this->rand, ck.ptr);
        f4(this, this->k, this->rand, ik.ptr);
@@ -618,7 +618,7 @@ static bool derive_keys(private_eap_aka_t *this, identification_t *id)
        tmp = chunk_cata("ccc", identity, ik, ck);
        DBG3(DBG_IKE, "Identity|IK|CK %B", &tmp);
        this->sha1->get_hash(this->sha1, tmp, mk.ptr);
-       
+
        /* K_encr | K_auth | MSK | EMSK = prf(0) | prf(0)
         * FIPS PRF has 320 bit block size, we need 160 byte for keys
         *  => run prf four times */
@@ -694,9 +694,9 @@ static aka_attribute_t read_attribute(chunk_t *data, chunk_t *attr_data)
 {
        aka_attribute_t attribute;
        size_t length;
-       
+
        DBG3(DBG_IKE, "reading attribute from %B", data);
-       
+
        if (data->len < 2)
        {
                return AT_END;
@@ -733,7 +733,7 @@ static eap_payload_t *build_aka_payload(private_eap_aka_t *this, eap_code_t code
        va_list args;
        aka_attribute_t attr;
        u_int8_t *mac_pos = NULL;
-       
+
        /* write EAP header, skip length bytes */
        *pos.ptr++ = code;
        *pos.ptr++ = identifier;
@@ -745,18 +745,18 @@ static eap_payload_t *build_aka_payload(private_eap_aka_t *this, eap_code_t code
        *pos.ptr++ = 0;
        *pos.ptr++ = 0;
        pos.len -= 4;
-       
+
        va_start(args, type);
        while ((attr = va_arg(args, aka_attribute_t)) != AT_END)
        {
                chunk_t data = va_arg(args, chunk_t);
-               
+
                DBG3(DBG_IKE, "building %N %B", aka_attribute_names, attr, &data);
-               
+
                /* write attribute header */
                *pos.ptr++ = attr;
                pos.len--;
-               
+
                switch (attr)
                {
                        case AT_RES:
@@ -804,11 +804,11 @@ static eap_payload_t *build_aka_payload(private_eap_aka_t *this, eap_code_t code
                }
        }
        va_end(args);
-       
+
        /* calculate message length, write into header */
        message.len = pos.ptr - message.ptr;
        *(u_int16_t*)(message.ptr + 2) = htons(message.len);
-       
+
        /* create MAC if AT_MAC attribte was included */
        if (mac_pos)
        {
@@ -818,10 +818,10 @@ static eap_payload_t *build_aka_payload(private_eap_aka_t *this, eap_code_t code
                this->signer->get_signature(this->signer, message, mac_pos);
                DBG3(DBG_IKE, "is %b", mac_pos, AT_MAC_LENGTH);
        }
-       
+
        /* payload constructor takes data with some bytes skipped */
        payload = eap_payload_create_data(message);
-       
+
        DBG3(DBG_IKE, "created EAP message %B", &message);
        return payload;
 }
@@ -832,7 +832,7 @@ static eap_payload_t *build_aka_payload(private_eap_aka_t *this, eap_code_t code
 static u_char get_identifier()
 {
        u_char id;
-       
+
        do {
                id = random();
        } while (!id);
@@ -847,12 +847,12 @@ static status_t server_initiate_challenge(private_eap_aka_t *this, chunk_t sqn,
 {
        rng_t *rng;
        chunk_t mac, ak, autn;
-       
+
        mac = chunk_alloca(MAC_LENGTH);
        ak = chunk_alloca(AK_LENGTH);
        chunk_free(&this->rand);
        chunk_free(&this->xres);
-       
+
        /* generate RAND:
         * we use a registered RNG, not f0() proposed in S.S0055
         */
@@ -864,16 +864,16 @@ static status_t server_initiate_challenge(private_eap_aka_t *this, chunk_t sqn,
        }
        rng->allocate_bytes(rng, RAND_LENGTH, &this->rand);
        rng->destroy(rng);
-       
+
 #      ifdef TEST_VECTORS
        /* Test vector for RAND */
        u_int8_t test_rand[] = {
                0x4b,0x05,0x2b,0x20,0xe2,0xa0,0x6c,0x8f,
                0xf7,0x00,0xda,0x51,0x2b,0x4e,0x11,0x1e,
        };
-       memcpy(this->rand.ptr, test_rand, this->rand.len); 
+       memcpy(this->rand.ptr, test_rand, this->rand.len);
 #      endif /* TEST_VECTORS */
-       
+
        /* Get the shared key K: */
        if (load_key(this->server, this->peer, &this->k) != SUCCESS)
        {
@@ -881,7 +881,7 @@ static status_t server_initiate_challenge(private_eap_aka_t *this, chunk_t sqn,
                                "with EAP-AKA", this->server, this->peer);
                return FAILED;
        }
-       
+
 #      ifdef TEST_VECTORS
        /* Test vector for K */
        u_int8_t test_k[] = {
@@ -890,26 +890,26 @@ static status_t server_initiate_challenge(private_eap_aka_t *this, chunk_t sqn,
        };
        memcpy(this->k.ptr, test_k, this->k.len);
 #      endif /* TEST_VECTORS */
-       
+
        /* generate MAC */
        f1(this, this->k, this->rand, sqn, amf, mac.ptr);
-       
+
        /* generate AK */
        f5(this, this->k, this->rand, ak.ptr);
-       
+
        /* precalculate XRES as expected from client */
        this->xres = chunk_alloc(RES_LENGTH);
        f2(this, this->k, this->rand, this->xres.ptr);
-       
+
        /* calculate AUTN = (SQN xor AK) || AMF || MAC */
        autn = chunk_cata("ccc", sqn, amf, mac);
        memxor(autn.ptr, ak.ptr, ak.len);
        DBG3(DBG_IKE, "AUTN %B", &autn);
-       
-       
+
+
        /* derive K_encr, K_auth, MSK, EMSK  */
        derive_keys(this, this->peer);
-       
+
        /* build payload */
        *out = build_aka_payload(this, EAP_REQUEST, get_identifier(), AKA_CHALLENGE,
                                                         AT_RAND, this->rand, AT_AUTN, autn, AT_MAC,
@@ -923,17 +923,17 @@ static status_t server_initiate_challenge(private_eap_aka_t *this, chunk_t sqn,
 static status_t server_initiate(private_eap_aka_t *this, eap_payload_t **out)
 {
        chunk_t sqn = chunk_alloca(SQN_LENGTH);
-       
+
        /* we use an offset of 3 minutes to tolerate clock inaccuracy
         * without the need to synchronize sequence numbers */
        update_sqn(sqn.ptr, 180);
-       
+
 #      ifdef TEST_VECTORS
        /* Test vector for SQN */
        u_int8_t test_sqn[] = {0x00,0x00,0x00,0x00,0x00,0x01};
-       memcpy(sqn.ptr, test_sqn, sqn.len); 
+       memcpy(sqn.ptr, test_sqn, sqn.len);
 #      endif /* TEST_VECTORS */
-       
+
        return server_initiate_challenge(this, sqn, out);
 }
 
@@ -942,11 +942,11 @@ static status_t server_process_synchronize(private_eap_aka_t *this,
 {
        chunk_t attr, auts = chunk_empty, pos, message, macs, xmacs, sqn, aks, amf;
        u_int i;
-       
+
        message = in->get_data(in);
        pos = message;
        read_header(&pos);
-       
+
        /* iterate over attributes */
        while (TRUE)
        {
@@ -971,19 +971,19 @@ static status_t server_process_synchronize(private_eap_aka_t *this,
                }
                break;
        }
-       
+
        if (auts.len != AUTS_LENGTH)
        {
                DBG1(DBG_IKE, "synchronization request didn't contain useable AUTS");
                return FAILED;
        }
-       
+
        chunk_split(auts, "mm", SQN_LENGTH, &sqn, MAC_LENGTH, &macs);
        aks = chunk_alloca(AK_LENGTH);
        f5star(this, this->k, this->rand, aks.ptr);
        /* decrypt serial number by XORing AKS */
        memxor(sqn.ptr, aks.ptr, aks.len);
-       
+
        /* verify MACS */
        xmacs = chunk_alloca(MAC_LENGTH);
        amf = chunk_alloca(AMF_LENGTH);
@@ -996,7 +996,7 @@ static status_t server_process_synchronize(private_eap_aka_t *this,
                DBG3(DBG_IKE, "MACS %B XMACS %B", &macs, &xmacs);
                return FAILED;
        }
-       
+
        /* retry the challenge with the received SQN + 1*/
        for (i = SQN_LENGTH - 1; i >= 0; i--)
        {
@@ -1014,11 +1014,11 @@ static status_t server_process_synchronize(private_eap_aka_t *this,
 static status_t server_process_challenge(private_eap_aka_t *this, eap_payload_t *in)
 {
        chunk_t attr, res = chunk_empty, at_mac = chunk_empty, pos, message;
-       
+
        message = in->get_data(in);
        pos = message;
        read_header(&pos);
-       
+
        /* iterate over attributes */
        while (TRUE)
        {
@@ -1055,7 +1055,7 @@ static status_t server_process_challenge(private_eap_aka_t *this, eap_payload_t
                }
                break;
        }
-       
+
        /* verify EAP message MAC AT_MAC */
        {
                this->signer->set_key(this->signer, this->k_auth);
@@ -1067,7 +1067,7 @@ static status_t server_process_challenge(private_eap_aka_t *this, eap_payload_t
                        return FAILED;
                }
        }
-       
+
        /* compare received RES against stored precalculated XRES */
        if (!chunk_equals(res, this->xres))
        {
@@ -1086,12 +1086,12 @@ static status_t server_process(private_eap_aka_t *this,
 {
        chunk_t message;
        aka_subtype_t type;
-       
+
        message = in->get_data(in);
        type = read_header(&message);
-       
+
        DBG3(DBG_IKE, "received EAP message %B",  &message);
-       
+
        switch (type)
        {
                case AKA_CHALLENGE:
@@ -1128,19 +1128,19 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
        chunk_t autn = chunk_empty, at_mac = chunk_empty;
        chunk_t ak, sqn, sqn_ak, mac, xmac, res, amf, message, pos;
        u_int8_t identifier;
-       
+
        ak = chunk_alloca(AK_LENGTH);
        xmac = chunk_alloca(MAC_LENGTH);
        res = chunk_alloca(RES_LENGTH);
        chunk_free(&this->rand);
-       
+
        message = in->get_data(in);
        pos = message;
        read_header(&pos);
        identifier = in->get_identifier(in);
-       
+
        DBG3(DBG_IKE, "reading attributes from %B", &pos);
-       
+
        /* iterate over attributes */
        while (TRUE)
        {
@@ -1178,7 +1178,7 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
                }
                break;
        }
-       
+
        if (this->rand.len != RAND_LENGTH || autn.len != AUTN_LENGTH)
        {
                /* required attributes wrong/not found, abort */
@@ -1188,11 +1188,11 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
                         aka_attribute_names, AT_CLIENT_ERROR_CODE, 0);
                return NEED_MORE;
        }
-       
+
        DBG3(DBG_IKE, "using autn %B", &autn);
        /* split up AUTN = SQN xor AK | AMF | MAC */
        chunk_split(autn, "mmm", SQN_LENGTH, &sqn_ak, AMF_LENGTH, &amf, MAC_LENGTH, &mac);
-       
+
        /* Get the shared key K: */
        chunk_free(&this->k);
        if (load_key(this->peer, this->server, &this->k) != SUCCESS)
@@ -1213,19 +1213,19 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
        };
        memcpy(this->k.ptr, test_k, this->k.len);
 #      endif /* TEST_VECTORS */
-       
+
        /* calculate anonymity key AK */
        f5(this, this->k, this->rand, ak.ptr);
        DBG3(DBG_IKE, "using rand %B", &this->rand);
        DBG3(DBG_IKE, "using ak %B", &ak);
        /* XOR AK into SQN to decrypt it */
-       
+
        sqn = chunk_clonea(sqn_ak);
-       
+
        DBG3(DBG_IKE, "using ak xor sqn %B", &sqn_ak);
        memxor(sqn.ptr, ak.ptr, sqn.len);
        DBG3(DBG_IKE, "using sqn %B", &sqn);
-       
+
        /* calculate expected MAC and compare against received one */
        f1(this, this->k, this->rand, sqn, amf, xmac.ptr);
        if (!chunk_equals(mac, xmac))
@@ -1243,13 +1243,13 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
        {
                /* sequence number invalid. send AUTS */
                chunk_t auts, macs, aks, amf;
-               
+
                macs = chunk_alloca(MAC_LENGTH);
                aks = chunk_alloca(AK_LENGTH);
                amf = chunk_alloca(AMF_LENGTH);
-               
+
                /* AMF is set to zero in AKA_SYNCHRONIZATION_FAILURE */
-               memset(amf.ptr, 0, amf.len);            
+               memset(amf.ptr, 0, amf.len);
                /* AKS = f5*(RAND) */
                f5star(this, this->k, this->rand, aks.ptr);
                /* MACS = f1*(RAND) */
@@ -1257,7 +1257,7 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
                /* AUTS = SQN xor AKS | MACS */
                memxor(aks.ptr, peer_sqn.ptr, aks.len);
                auts = chunk_cata("cc", aks, macs);
-               
+
                *out = build_aka_payload(this, EAP_RESPONSE, identifier,
                                                                 AKA_SYNCHRONIZATION_FAILURE,
                                                                 AT_AUTS, auts, AT_END);
@@ -1270,7 +1270,7 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
 
        /* derive K_encr, K_auth, MSK, EMSK  */
        derive_keys(this, this->peer);
-       
+
        /* verify EAP message MAC AT_MAC */
        DBG3(DBG_IKE, "verifying AT_MAC signature of %B", &message);
        DBG3(DBG_IKE, "using key %B", &this->k_auth);
@@ -1284,13 +1284,13 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
                         AT_CLIENT_ERROR_CODE, 0);
                return NEED_MORE;
        }
-       
+
        /* update stored SQN to the received one */
        memcpy(peer_sqn.ptr, sqn.ptr, sqn.len);
-       
+
        /* calculate RES */
        f2(this, this->k, this->rand, res.ptr);
-       
+
        /* build response */
        *out = build_aka_payload(this, EAP_RESPONSE, identifier, AKA_CHALLENGE,
                                                         AT_RES, res, AT_MAC, chunk_empty, AT_END);
@@ -1305,14 +1305,14 @@ static status_t peer_process_notification(private_eap_aka_t *this,
 {
        chunk_t message, pos, attr;
        u_int8_t identifier;
-       
+
        message = in->get_data(in);
        pos = message;
        read_header(&pos);
        identifier = in->get_identifier(in);
-       
+
        DBG3(DBG_IKE, "reading attributes from %B", &pos);
-       
+
        /* iterate over attributes */
        while (TRUE)
        {
@@ -1324,7 +1324,7 @@ static status_t peer_process_notification(private_eap_aka_t *this,
                        case AT_NOTIFICATION:
                        {
                                u_int16_t code;
-                       
+
                                if (attr.len != 2)
                                {
                                        DBG1(DBG_IKE, "received invalid AKA notification, ignored");
@@ -1333,7 +1333,7 @@ static status_t peer_process_notification(private_eap_aka_t *this,
                                code = ntohs(*(u_int16_t*)attr.ptr);
                                switch (code)
                                {
-                                       case 0: 
+                                       case 0:
                                                DBG1(DBG_IKE, "received AKA notification 'general "
                                                         "failure after authentication' (%d)", code);
                                                return FAILED;
@@ -1387,13 +1387,13 @@ static status_t peer_process(private_eap_aka_t *this,
        aka_subtype_t type;
        chunk_t message;
        u_int8_t identifier;
-       
+
        message = in->get_data(in);
        type = read_header(&message);
        identifier = in->get_identifier(in);
-       
+
        DBG3(DBG_IKE, "received EAP message %B",  &message);
-       
+
        switch (type)
        {
                case AKA_CHALLENGE:
@@ -1483,14 +1483,14 @@ static private_eap_aka_t *eap_aka_create_generic(identification_t *server,
                                                                                                 identification_t *peer)
 {
        private_eap_aka_t *this = malloc_thing(private_eap_aka_t);
-       
+
        this->public.eap_method_interface.initiate = NULL;
        this->public.eap_method_interface.process = NULL;
        this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
        this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
        this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
        this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
-       
+
        /* private data */
        this->server = server->clone(server);
        this->peer = peer->clone(peer);
@@ -1501,7 +1501,7 @@ static private_eap_aka_t *eap_aka_create_generic(identification_t *server,
        this->xres = chunk_empty;
        this->k = chunk_empty;
        this->rand = chunk_empty;
-       
+
        this->sha1 = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        this->signer = lib->crypto->create_signer(lib->crypto, AUTH_HMAC_SHA1_128);
        this->prf = lib->crypto->create_prf(lib->crypto, PRF_FIPS_SHA1_160);
@@ -1526,7 +1526,7 @@ static private_eap_aka_t *eap_aka_create_generic(identification_t *server,
 eap_aka_t *eap_aka_create_server(identification_t *server, identification_t *peer)
 {
        private_eap_aka_t *this = eap_aka_create_generic(server, peer);
-       
+
        if (this)
        {
                this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))server_initiate;
@@ -1541,12 +1541,12 @@ eap_aka_t *eap_aka_create_server(identification_t *server, identification_t *pee
 eap_aka_t *eap_aka_create_peer(identification_t *server, identification_t *peer)
 {
        private_eap_aka_t *this = eap_aka_create_generic(server, peer);
-       
+
        if (this)
        {
                this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))peer_initiate;
                this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))peer_process;
        }
-       return (eap_aka_t*)this;                        
+       return (eap_aka_t*)this;
 }
 
index e4a5326fe5d5648dbb5c97d9664048bf62faae4c..20c249d6b5150dab8e56efe62d9b73a8d8ebe04d 100644 (file)
@@ -37,14 +37,14 @@ static void destroy(eap_aka_plugin_t *this)
 plugin_t *plugin_create()
 {
        eap_aka_plugin_t *this = malloc_thing(eap_aka_plugin_t);
-       
+
        this->plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_SERVER,
                                                        (eap_constructor_t)eap_aka_create_server);
        charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_PEER,
                                                        (eap_constructor_t)eap_aka_create_peer);
-       
+
        return &this->plugin;
 }
 
index cb4ab2e593fa678952daa49943b59a57b788389f..f5e08bb6b67afa62f3ad5899239cf5446ca1a2d6 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "eap_gtc.h"
 
 #include <daemon.h>
@@ -30,22 +30,22 @@ typedef struct private_eap_gtc_t private_eap_gtc_t;
  * Private data of an eap_gtc_t object.
  */
 struct private_eap_gtc_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        eap_gtc_t public;
-       
+
        /**
         * ID of the server
         */
        identification_t *server;
-       
+
        /**
         * ID of the peer
         */
        identification_t *peer;
-       
+
        /**
         * EAP message identififier
         */
@@ -86,7 +86,7 @@ static int auth_conv(int num_msg, const struct pam_message **msg,
                         struct pam_response **resp, char *password)
 {
        struct pam_response *response;
-       
+
        if (num_msg != 1)
        {
                return PAM_CONV_ERR;
@@ -106,10 +106,10 @@ static bool authenticate(char *service, char *user, char *password)
     pam_handle_t *pamh = NULL;
        static struct pam_conv conv;
     int ret;
-       
+
        conv.conv = (void*)auth_conv;
        conv.appdata_ptr = password;
-       
+
        ret = pam_start(service, user, &conv, &pamh);
        if (ret != PAM_SUCCESS)
        {
@@ -143,7 +143,7 @@ static status_t initiate_server(private_eap_gtc_t *this, eap_payload_t **out)
 {
        eap_gtc_header_t *req;
        size_t len;
-       
+
        len = strlen(GTC_REQUEST_MSG);
        req = alloca(sizeof(eap_gtc_header_t) + len);
        req->length = htons(sizeof(eap_gtc_header_t) + len);
@@ -151,7 +151,7 @@ static status_t initiate_server(private_eap_gtc_t *this, eap_payload_t **out)
        req->identifier = this->identifier;
        req->type = EAP_GTC;
        memcpy(req->data, GTC_REQUEST_MSG, len);
-       
+
        *out = eap_payload_create_data(chunk_create((void*)req,
                                                                   sizeof(eap_gtc_header_t) + len));
        return NEED_MORE;
@@ -178,7 +178,7 @@ static status_t process_peer(private_eap_gtc_t *this,
        }
        key = shared->get_key(shared);
        len = key.len;
-       
+
        /* TODO: According to the draft we should "SASLprep" password, RFC4013. */
 
        res = alloca(sizeof(eap_gtc_header_t) + len);
@@ -187,9 +187,9 @@ static status_t process_peer(private_eap_gtc_t *this,
        res->identifier = in->get_identifier(in);
        res->type = EAP_GTC;
        memcpy(res->data, key.ptr, len);
-       
+
        shared->destroy(shared);
-       
+
        *out = eap_payload_create_data(chunk_create((void*)res,
                                                                   sizeof(eap_gtc_header_t) + len));
        return NEED_MORE;
@@ -203,14 +203,14 @@ static status_t process_server(private_eap_gtc_t *this,
 {
        chunk_t data, encoding;
        char *user, *password, *service, *pos;
-       
+
        data = chunk_skip(in->get_data(in), 5);
        if (this->identifier != in->get_identifier(in) || !data.len)
        {
                DBG1(DBG_IKE, "received invalid EAP-GTC message");
                return FAILED;
        }
-       
+
        encoding = this->peer->get_encoding(this->peer);
        /* if a RFC822_ADDR id is provided, we use the username part only */
        pos = memchr(encoding.ptr, '@', encoding.len);
@@ -221,14 +221,14 @@ static status_t process_server(private_eap_gtc_t *this,
        user = alloca(encoding.len + 1);
        memcpy(user, encoding.ptr, encoding.len);
        user[encoding.len] = '\0';
-       
+
        password = alloca(data.len + 1);
        memcpy(password, data.ptr, data.len);
        password[data.len] = '\0';
-       
+
        service = lib->settings->get_str(lib->settings,
                                                "charon.plugins.eap_gtc.pam_service", GTC_PAM_SERVICE);
-       
+
        if (!authenticate(service, user, password))
        {
                return FAILED;
@@ -278,19 +278,19 @@ static private_eap_gtc_t *eap_gtc_create_generic(identification_t *server,
                                                                                                 identification_t *peer)
 {
        private_eap_gtc_t *this = malloc_thing(private_eap_gtc_t);
-       
+
        this->public.eap_method_interface.initiate = NULL;
        this->public.eap_method_interface.process = NULL;
        this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
        this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
        this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
        this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
-       
+
        /* private data */
        this->peer = peer->clone(peer);
        this->server = server->clone(server);
        this->identifier = 0;
-       
+
        return this;
 }
 
@@ -300,7 +300,7 @@ static private_eap_gtc_t *eap_gtc_create_generic(identification_t *server,
 eap_gtc_t *eap_gtc_create_server(identification_t *server, identification_t *peer)
 {
        private_eap_gtc_t *this = eap_gtc_create_generic(server, peer);
-       
+
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_server;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_server;
 
@@ -318,7 +318,7 @@ eap_gtc_t *eap_gtc_create_server(identification_t *server, identification_t *pee
 eap_gtc_t *eap_gtc_create_peer(identification_t *server, identification_t *peer)
 {
        private_eap_gtc_t *this = eap_gtc_create_generic(server, peer);
-       
+
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_peer;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_peer;
 
index fda6c744a7eb94774784f2b6feecd3a7861845de..8550c254c2d36a06b1e61b3cc8e1c4fa291266c8 100644 (file)
@@ -40,17 +40,17 @@ static void destroy(eap_gtc_plugin_t *this)
 plugin_t *plugin_create()
 {
        eap_gtc_plugin_t *this = malloc_thing(eap_gtc_plugin_t);
-       
+
        this->plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        /* required for PAM authentication */
        charon->keep_cap(charon, CAP_AUDIT_WRITE);
-       
+
        charon->eap->add_method(charon->eap, EAP_GTC, 0, EAP_SERVER,
                                                        (eap_constructor_t)eap_gtc_create_server);
        charon->eap->add_method(charon->eap, EAP_GTC, 0, EAP_PEER,
                                                        (eap_constructor_t)eap_gtc_create_peer);
-       
+
        return &this->plugin;
 }
 
index e43c50c506515f6579b4f65910d45b8b822d03ae..ab082a955d7bdb3ebdcc919b141844129f4e6043 100644 (file)
@@ -24,17 +24,17 @@ typedef struct private_eap_identity_t private_eap_identity_t;
  * Private data of an eap_identity_t object.
  */
 struct private_eap_identity_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        eap_identity_t public;
-       
+
        /**
         * ID of the peer
         */
        identification_t *peer;
-       
+
        /**
         * received identity chunk
         */
@@ -68,17 +68,17 @@ static status_t process_peer(private_eap_identity_t *this,
        chunk_t id;
        eap_identity_header_t *hdr;
        size_t len;
-       
+
        id = this->peer->get_encoding(this->peer);
        len = sizeof(eap_identity_header_t) + id.len;
-       
+
        hdr = alloca(len);
        hdr->code = EAP_RESPONSE;
        hdr->identifier = in->get_identifier(in);
        hdr->length = htons(len);
        hdr->type = EAP_IDENTITY;
        memcpy(hdr->data, id.ptr, id.len);
-       
+
        *out = eap_payload_create_data(chunk_create((u_char*)hdr, len));
        return SUCCESS;
 }
@@ -99,7 +99,7 @@ static status_t process_server(private_eap_identity_t *this,
                                                           eap_payload_t *in, eap_payload_t **out)
 {
        chunk_t data;
-       
+
        data = chunk_skip(in->get_data(in), 5);
        if (data.len)
        {
@@ -114,12 +114,12 @@ static status_t process_server(private_eap_identity_t *this,
 static status_t initiate_server(private_eap_identity_t *this, eap_payload_t **out)
 {
        eap_identity_header_t hdr;
-       
+
        hdr.code = EAP_REQUEST;
        hdr.identifier = 0;
        hdr.length = htons(sizeof(eap_identity_header_t));
        hdr.type = EAP_IDENTITY;
-       
+
        *out = eap_payload_create_data(chunk_create((u_char*)&hdr,
                                                                                                sizeof(eap_identity_header_t)));
        return NEED_MORE;
@@ -172,17 +172,17 @@ static private_eap_identity_t *eap_identity_create(identification_t *server,
                                                                                                   identification_t *peer)
 {
        private_eap_identity_t *this = malloc_thing(private_eap_identity_t);
-       
+
        this->public.eap_method_interface.initiate = NULL;
        this->public.eap_method_interface.process = NULL;
        this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
        this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
        this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
        this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
-       
+
        this->peer = peer->clone(peer);
        this->identity = chunk_empty;
-       
+
        return this;
 }
 
@@ -193,11 +193,11 @@ eap_identity_t *eap_identity_create_peer(identification_t *server,
                                                                                 identification_t *peer)
 {
        private_eap_identity_t *this = eap_identity_create(server, peer);
-       
+
        /* public functions */
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_peer;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_peer;
-       
+
        return &this->public;
 }
 
@@ -208,11 +208,11 @@ eap_identity_t *eap_identity_create_server(identification_t *server,
                                                                                   identification_t *peer)
 {
        private_eap_identity_t *this = eap_identity_create(server, peer);
-       
+
        /* public functions */
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_server;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_server;
-       
+
        return &this->public;
 }
 
index 809254ccbb2874784d68a940840dbe81532279f8..a623e195175ef0b741215e6793d521191514bf57 100644 (file)
@@ -37,14 +37,14 @@ static void destroy(eap_identity_plugin_t *this)
 plugin_t *plugin_create()
 {
        eap_identity_plugin_t *this = malloc_thing(eap_identity_plugin_t);
-       
+
        this->plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->eap->add_method(charon->eap, EAP_IDENTITY, 0, EAP_SERVER,
                                                        (eap_constructor_t)eap_identity_create_server);
        charon->eap->add_method(charon->eap, EAP_IDENTITY, 0, EAP_PEER,
                                                        (eap_constructor_t)eap_identity_create_peer);
-       
+
        return &this->plugin;
 }
 
index 36d72694757ce4e487805223472e3646739466c1..27c20489d48a417b969e2df217475bcef4d2ecbc 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "eap_md5.h"
 
 #include <daemon.h>
@@ -25,27 +25,27 @@ typedef struct private_eap_md5_t private_eap_md5_t;
  * Private data of an eap_md5_t object.
  */
 struct private_eap_md5_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        eap_md5_t public;
-       
+
        /**
         * ID of the server
         */
        identification_t *server;
-       
+
        /**
         * ID of the peer
         */
        identification_t *peer;
-       
+
        /**
         * challenge sent by the server
         */
        chunk_t challenge;
-       
+
        /**
         * EAP message identififier
         */
@@ -79,7 +79,7 @@ struct eap_md5_header_t {
  * Hash the challenge string, create response
  */
 static status_t hash_challenge(private_eap_md5_t *this, chunk_t *response)
-{      
+{
        shared_key_t *shared;
        chunk_t concat;
        hasher_t *hasher;
@@ -92,7 +92,7 @@ static status_t hash_challenge(private_eap_md5_t *this, chunk_t *response)
                         this->server, this->peer);
                return NOT_FOUND;
        }
-       concat = chunk_cata("ccc", chunk_from_thing(this->identifier),  
+       concat = chunk_cata("ccc", chunk_from_thing(this->identifier),
                                                shared->get_key(shared), this->challenge);
        shared->destroy(shared);
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
@@ -122,7 +122,7 @@ static status_t initiate_server(private_eap_md5_t *this, eap_payload_t **out)
 {
        rng_t *rng;
        eap_md5_header_t *req;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
        {
@@ -130,7 +130,7 @@ static status_t initiate_server(private_eap_md5_t *this, eap_payload_t **out)
        }
        rng->allocate_bytes(rng, CHALLENGE_LEN, &this->challenge);
        rng->destroy(rng);
-       
+
        req = alloca(PAYLOAD_LEN);
        req->length = htons(PAYLOAD_LEN);
        req->code = EAP_REQUEST;
@@ -138,7 +138,7 @@ static status_t initiate_server(private_eap_md5_t *this, eap_payload_t **out)
        req->type = EAP_MD5;
        req->value_size = this->challenge.len;
        memcpy(req->value, this->challenge.ptr, this->challenge.len);
-       
+
        *out = eap_payload_create_data(chunk_create((void*)req, PAYLOAD_LEN));
        return NEED_MORE;
 }
@@ -152,7 +152,7 @@ static status_t process_peer(private_eap_md5_t *this,
        chunk_t response;
        chunk_t data;
        eap_md5_header_t *req;
-       
+
        this->identifier = in->get_identifier(in);
        data = in->get_data(in);
        this->challenge = chunk_clone(chunk_skip(data, 6));
@@ -173,7 +173,7 @@ static status_t process_peer(private_eap_md5_t *this,
        req->value_size = response.len;
        memcpy(req->value, response.ptr, response.len);
        chunk_free(&response);
-       
+
        *out = eap_payload_create_data(chunk_create((void*)req, PAYLOAD_LEN));
        return NEED_MORE;
 }
@@ -186,7 +186,7 @@ static status_t process_server(private_eap_md5_t *this,
 {
        chunk_t response, expected;
        chunk_t data;
-       
+
        if (this->identifier != in->get_identifier(in))
        {
                DBG1(DBG_IKE, "received invalid EAP-MD5 message");
@@ -198,7 +198,7 @@ static status_t process_server(private_eap_md5_t *this,
        }
        data = in->get_data(in);
        response = chunk_skip(data, 6);
-       
+
        if (response.len < expected.len ||
                !memeq(response.ptr, expected.ptr, expected.len))
        {
@@ -253,20 +253,20 @@ static private_eap_md5_t *eap_md5_create_generic(identification_t *server,
                                                                                                 identification_t *peer)
 {
        private_eap_md5_t *this = malloc_thing(private_eap_md5_t);
-       
+
        this->public.eap_method_interface.initiate = NULL;
        this->public.eap_method_interface.process = NULL;
        this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
        this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
        this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
        this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
-       
+
        /* private data */
        this->peer = peer->clone(peer);
        this->server = server->clone(server);
        this->challenge = chunk_empty;
        this->identifier = 0;
-       
+
        return this;
 }
 
@@ -276,7 +276,7 @@ static private_eap_md5_t *eap_md5_create_generic(identification_t *server,
 eap_md5_t *eap_md5_create_server(identification_t *server, identification_t *peer)
 {
        private_eap_md5_t *this = eap_md5_create_generic(server, peer);
-       
+
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_server;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_server;
 
@@ -294,7 +294,7 @@ eap_md5_t *eap_md5_create_server(identification_t *server, identification_t *pee
 eap_md5_t *eap_md5_create_peer(identification_t *server, identification_t *peer)
 {
        private_eap_md5_t *this = eap_md5_create_generic(server, peer);
-       
+
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_peer;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_peer;
 
index e30152fc580ec66d00e63190c58fb1bfdf220ac4..629255ebf73d26094594c0a6970e06b9c6392c29 100644 (file)
@@ -37,14 +37,14 @@ static void destroy(eap_md5_plugin_t *this)
 plugin_t *plugin_create()
 {
        eap_md5_plugin_t *this = malloc_thing(eap_md5_plugin_t);
-       
+
        this->plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->eap->add_method(charon->eap, EAP_MD5, 0, EAP_SERVER,
                                                        (eap_constructor_t)eap_md5_create_server);
        charon->eap->add_method(charon->eap, EAP_MD5, 0, EAP_PEER,
                                                        (eap_constructor_t)eap_md5_create_peer);
-       
+
        return &this->plugin;
 }
 
index 0e3fac780564f9ce3af75e70cd5cc8464617c475..26c6ffcb2c95ae4d15a700f029217f1ccdc6c290 100644 (file)
@@ -35,47 +35,47 @@ struct private_eap_mschapv2_t
         * Public authenticator_t interface.
         */
        eap_mschapv2_t public;
-       
+
        /**
         * ID of the server
         */
        identification_t *server;
-       
+
        /**
         * ID of the peer
         */
        identification_t *peer;
-       
+
        /**
         * challenge sent by the server
         */
        chunk_t challenge;
-       
+
        /**
         * generated NT-Response
         */
        chunk_t nt_response;
-       
+
        /**
         * generated Authenticator Response
         */
        chunk_t auth_response;
-       
+
        /**
         * generated MSK
         */
        chunk_t msk;
-       
+
        /**
         * EAP message identifier
         */
        u_int8_t identifier;
-       
+
        /**
         * MS-CHAPv2-ID (session ID, increases with each retry)
         */
        u_int8_t mschapv2id;
-       
+
        /**
         * Number of retries
         */
@@ -248,7 +248,7 @@ static chunk_t ExpandDESKey(chunk_t key)
        int i;
        u_char carry = 0;
        chunk_t expanded;
-       
+
        /* expand the 7 octets to 8 octets */
        expanded = chunk_alloc(8);
        for (i = 0; i < 7; i++)
@@ -257,7 +257,7 @@ static chunk_t ExpandDESKey(chunk_t key)
                carry = key.ptr[i] & ~bitmask[i];
        }
        expanded.ptr[7] = carry << 1;
-       
+
        /* add parity bits to each octet */
        for (i = 0; i < 8; i++)
        {
@@ -269,7 +269,7 @@ static chunk_t ExpandDESKey(chunk_t key)
 }
 
 /**
- * Calculate the NT password hash (i.e. hash the (unicode) password with MD4) 
+ * Calculate the NT password hash (i.e. hash the (unicode) password with MD4)
  */
 static status_t NtPasswordHash(chunk_t password, chunk_t *password_hash)
 {
@@ -287,7 +287,7 @@ static status_t NtPasswordHash(chunk_t password, chunk_t *password_hash)
 
 /**
  * Calculate the challenge hash (i.e. hash [peer_challenge | server_challenge |
- * username (without domain part)] with SHA1) 
+ * username (without domain part)] with SHA1)
  */
 static status_t ChallengeHash(chunk_t peer_challenge, chunk_t server_challenge,
                                                          chunk_t username, chunk_t *challenge_hash)
@@ -331,7 +331,7 @@ static status_t ChallengeResponse(chunk_t challenge_hash, chunk_t password_hash,
        memset(z_password_hash.ptr, 0, z_password_hash.len);
        memcpy(z_password_hash.ptr, password_hash.ptr, password_hash.len);
        chunk_split(z_password_hash, "mmm", 7, &keys[0], 7, &keys[1], 7, &keys[2]);
-       
+
        *response = chunk_alloc(24);
        for (i = 0; i < 3; i++)
        {
@@ -366,22 +366,22 @@ static status_t AuthenticatorResponse(chunk_t password_hash_hash,
                                  0x6E };
        static const chunk_t magic1 = chunk_from_buf(magic1_data);
        static const chunk_t magic2 = chunk_from_buf(magic2_data);
-       
+
        chunk_t digest = chunk_empty, concat;
        hasher_t *hasher;
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (hasher == NULL)
        {
                DBG1(DBG_IKE, "EAP-MS-CHAPv2 failed, SHA1 not supported");
                return FAILED;
        }
-       
+
        concat = chunk_cata("ccc", password_hash_hash, nt_response, magic1);
        hasher->allocate_hash(hasher, concat, &digest);
        concat = chunk_cata("ccc", digest, challenge_hash, magic2);
        hasher->allocate_hash(hasher, concat, response);
-       
+
        hasher->destroy(hasher);
        chunk_free(&digest);
        return SUCCESS;
@@ -433,31 +433,31 @@ static status_t GenerateMSK(chunk_t password_hash_hash,
        static const chunk_t shapad1 = chunk_from_buf(shapad1_data);
        static const chunk_t shapad2 = chunk_from_buf(shapad2_data);
        static const chunk_t keypad = { shapad1_data, 16 };
-       
+
        chunk_t concat, master_key, master_receive_key, master_send_key;
        hasher_t *hasher;
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (hasher == NULL)
        {
                DBG1(DBG_IKE, "EAP-MS-CHAPv2 failed, SHA1 not supported");
                return FAILED;
        }
-       
+
        concat = chunk_cata("ccc", password_hash_hash, nt_response, magic1);
        hasher->allocate_hash(hasher, concat, &master_key);
        master_key.len = 16;
-       
+
        concat = chunk_cata("cccc", master_key, shapad1, magic2, shapad2);
        hasher->allocate_hash(hasher, concat, &master_receive_key);
        master_receive_key.len = 16;
-       
+
        concat = chunk_cata("cccc", master_key, shapad1, magic3, shapad2);
        hasher->allocate_hash(hasher, concat, &master_send_key);
        master_send_key.len = 16;
-       
+
        *msk = chunk_cat("cccc", master_receive_key, master_send_key, keypad, keypad);
-       
+
        hasher->destroy(hasher);
        chunk_free(&master_key);
        chunk_free(&master_receive_key);
@@ -472,7 +472,7 @@ static status_t GenerateStuff(private_eap_mschapv2_t *this,
        status_t status = FAILED;
        chunk_t password_hash = chunk_empty, password_hash_hash = chunk_empty,
                        challenge_hash = chunk_empty;
-       
+
        if (NtPasswordHash(password, &password_hash) != SUCCESS)
        {
                goto error;
@@ -486,7 +486,7 @@ static status_t GenerateStuff(private_eap_mschapv2_t *this,
        {
                goto error;
        }
-       
+
        if (ChallengeResponse(challenge_hash, password_hash,
                                                  &this->nt_response) != SUCCESS)
        {
@@ -501,9 +501,9 @@ static status_t GenerateStuff(private_eap_mschapv2_t *this,
        {
                goto error;
        }
-       
+
        status = SUCCESS;
-       
+
 error:
        chunk_free(&password_hash);
        chunk_free(&password_hash_hash);
@@ -532,7 +532,7 @@ static chunk_t ascii_to_unicode(chunk_t ascii)
 static char* sanitize(char *str)
 {
        char *pos = str;
-       
+
        while (pos && *pos)
        {
                if (!isprint(*pos))
@@ -592,7 +592,7 @@ static status_t initiate_server(private_eap_mschapv2_t *this, eap_payload_t **ou
        eap_mschapv2_challenge_t *cha;
        const char *name = MSCHAPV2_HOST_NAME;
        u_int16_t len = CHALLENGE_PAYLOAD_LEN + sizeof(MSCHAPV2_HOST_NAME) - 1;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
        {
@@ -601,7 +601,7 @@ static status_t initiate_server(private_eap_mschapv2_t *this, eap_payload_t **ou
        }
        rng->allocate_bytes(rng, CHALLENGE_LEN, &this->challenge);
        rng->destroy(rng);
-       
+
        eap = alloca(len);
        eap->code = EAP_REQUEST;
        eap->identifier = this->identifier;
@@ -610,12 +610,12 @@ static status_t initiate_server(private_eap_mschapv2_t *this, eap_payload_t **ou
        eap->opcode = MSCHAPV2_CHALLENGE;
        eap->ms_chapv2_id = this->mschapv2id;
        set_ms_length(eap, len);
-       
+
        cha = (eap_mschapv2_challenge_t*)eap->data;
        cha->value_size = CHALLENGE_LEN;
        memcpy(cha->challenge, this->challenge.ptr, this->challenge.len);
        memcpy(cha->name, name, sizeof(MSCHAPV2_HOST_NAME) - 1);
-       
+
        *out = eap_payload_create_data(chunk_create((void*) eap, len));
        return NEED_MORE;
 }
@@ -634,29 +634,29 @@ static status_t process_peer_challenge(private_eap_mschapv2_t *this,
        shared_key_t *shared;
        chunk_t data, peer_challenge, username, password;
        u_int16_t len = RESPONSE_PAYLOAD_LEN;
-       
+
        data = in->get_data(in);
        eap = (eap_mschapv2_header_t*)data.ptr;
-       
+
        /* the name MUST be at least one octet long */
        if (data.len < CHALLENGE_PAYLOAD_LEN + 1)
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: too short");
                return FAILED;
        }
-       
+
        cha = (eap_mschapv2_challenge_t*)eap->data;
-                       
+
        if (cha->value_size != CHALLENGE_LEN)
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: "
                         "invalid challenge size");
                return FAILED;
        }
-                       
+
        this->mschapv2id = eap->ms_chapv2_id;
        this->challenge = chunk_clone(chunk_create(cha->challenge, CHALLENGE_LEN));
-                       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
        {
@@ -666,7 +666,7 @@ static status_t process_peer_challenge(private_eap_mschapv2_t *this,
        peer_challenge = chunk_alloca(CHALLENGE_LEN);
        rng->get_bytes(rng, CHALLENGE_LEN, peer_challenge.ptr);
        rng->destroy(rng);
-                       
+
        shared = charon->credentials->get_shared(charon->credentials,
                                                                                SHARED_EAP, this->peer, this->server);
        if (shared == NULL)
@@ -675,13 +675,13 @@ static status_t process_peer_challenge(private_eap_mschapv2_t *this,
                         this->server, this->peer);
                return NOT_FOUND;
        }
-       
+
        password = ascii_to_unicode(shared->get_key(shared));
        shared->destroy(shared);
-       
+
        username = extract_username(this->peer);
        len += username.len;
-                       
+
        if (GenerateStuff(this, this->challenge, peer_challenge, username, password) != SUCCESS)
        {
                DBG1(DBG_IKE, "EAP-MS-CHAPv2 generating NT-Response failed");
@@ -689,7 +689,7 @@ static status_t process_peer_challenge(private_eap_mschapv2_t *this,
                return FAILED;
        }
        chunk_clear(&password);
-                       
+
        eap = alloca(len);
        eap->code = EAP_RESPONSE;
        eap->identifier = this->identifier;
@@ -698,16 +698,16 @@ static status_t process_peer_challenge(private_eap_mschapv2_t *this,
        eap->opcode = MSCHAPV2_RESPONSE;
        eap->ms_chapv2_id = this->mschapv2id;
        set_ms_length(eap, len);
-       
+
        res = (eap_mschapv2_response_t*)eap->data;
        res->value_size = RESPONSE_LEN;
        memset(&res->response, 0, RESPONSE_LEN);
        memcpy(res->response.peer_challenge, peer_challenge.ptr, peer_challenge.len);
        memcpy(res->response.nt_response, this->nt_response.ptr, this->nt_response.len);
-       
+
        username = this->peer->get_encoding(this->peer);
        memcpy(res->name, username.ptr, username.len);
-       
+
        *out = eap_payload_create_data(chunk_create((void*) eap, len));
        return NEED_MORE;
 }
@@ -725,21 +725,21 @@ static status_t process_peer_success(private_eap_mschapv2_t *this,
        char *message, *token, *msg = NULL;
        int message_len;
        u_int16_t len = SHORT_HEADER_LEN;
-       
+
        data = in->get_data(in);
        eap = (eap_mschapv2_header_t*)data.ptr;
-       
+
        if (data.len < AUTH_RESPONSE_LEN)
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: too short");
                return FAILED;
        }
-       
+
        message_len = data.len - HEADER_LEN;
        message = malloc(message_len + 1);
        memcpy(message, eap->data, message_len);
        message[message_len] = '\0';
-       
+
        /* S=<auth_string> M=<msg> */
        enumerator = enumerator_create_token(message, " ", " ");
        while (enumerator->enumerate(enumerator, &token))
@@ -764,32 +764,32 @@ static status_t process_peer_success(private_eap_mschapv2_t *this,
                }
        }
        enumerator->destroy(enumerator);
-                       
-       if (auth_string.ptr == NULL)    
+
+       if (auth_string.ptr == NULL)
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: "
                         "auth string missing");
                goto error;
        }
-       
+
        if (!chunk_equals(this->auth_response, auth_string))
        {
                DBG1(DBG_IKE, "EAP-MS-CHAPv2 verification failed");
                goto error;
        }
-       
+
        DBG1(DBG_IKE, "EAP-MS-CHAPv2 succeeded: '%s'", sanitize(msg));
-       
+
        eap = alloca(len);
        eap->code = EAP_RESPONSE;
        eap->identifier = this->identifier;
        eap->length = htons(len);
        eap->type = EAP_MSCHAPV2;
        eap->opcode = MSCHAPV2_SUCCESS;
-       
+
        *out = eap_payload_create_data(chunk_create((void*) eap, len));
        status = NEED_MORE;
-       
+
 error:
        chunk_free(&auth_string);
        free(message);
@@ -807,21 +807,21 @@ static status_t process_peer_failure(private_eap_mschapv2_t *this,
        char *message, *token, *msg = NULL;
        int message_len, error, retryable;
        chunk_t challenge = chunk_empty;
-       
+
        data = in->get_data(in);
        eap = (eap_mschapv2_header_t*)data.ptr;
-       
+
        if (data.len < 3) /* we want at least an error code: E=e */
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: too short");
                return FAILED;
        }
-       
+
        message_len = data.len - HEADER_LEN;
        message = malloc(message_len + 1);
        memcpy(message, eap->data, message_len);
        message[message_len] = '\0';
-                       
+
        /* E=eeeeeeeeee R=r C=cccccccccccccccccccccccccccccccc V=vvvvvvvvvv M=<msg> */
        enumerator = enumerator_create_token(message, " ", " ");
        while (enumerator->enumerate(enumerator, &token))
@@ -862,28 +862,28 @@ static status_t process_peer_failure(private_eap_mschapv2_t *this,
                }
        }
        enumerator->destroy(enumerator);
-                       
+
        DBG1(DBG_IKE, "EAP-MS-CHAPv2 failed with error %N: '%s'",
                 mschapv2_error_names, error, sanitize(msg));
-                       
+
        /**
         * at this point, if the error is retryable, we MAY retry the authentication
         * or MAY send a Change Password packet.
-        * 
+        *
         * if the error is not retryable (or if we do neither of the above), we
         * SHOULD send a Failure Response packet.
         * windows clients don't do that, and since windows server 2008 r2 behaves
         * pretty odd if we do send a Failure Response, we just don't send one
         * either. windows 7 actually sends a delete notify (which, according to the
-        * logs, results in an error on windows server 2008 r2). 
-        * 
+        * logs, results in an error on windows server 2008 r2).
+        *
         * btw, windows server 2008 r2 does not send non-retryable errors for e.g.
         * a disabled account but returns the windows error code in a notify payload
         * of type 12345.
         */
-       
+
        status = FAILED;
-       
+
 error:
        chunk_free(&challenge);
        free(message);
@@ -899,7 +899,7 @@ static status_t process_peer(private_eap_mschapv2_t *this, eap_payload_t *in,
 {
        chunk_t data;
        eap_mschapv2_header_t *eap;
-       
+
        this->identifier = in->get_identifier(in);
        data = in->get_data(in);
        if (data.len < SHORT_HEADER_LEN)
@@ -907,9 +907,9 @@ static status_t process_peer(private_eap_mschapv2_t *this, eap_payload_t *in,
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message");
                return FAILED;
        }
-       
+
        eap = (eap_mschapv2_header_t*)data.ptr;
-               
+
        switch (eap->opcode)
        {
                case MSCHAPV2_CHALLENGE:
@@ -945,7 +945,7 @@ static status_t process_server_retry(private_eap_mschapv2_t *this,
        chunk_t hex;
        char msg[FAILURE_MESSAGE_LEN];
        u_int16_t len = HEADER_LEN + FAILURE_MESSAGE_LEN - 1; /* no null byte */
-       
+
        if (++this->retries > MAX_RETRIES)
        {
                /* we MAY send a Failure Request with R=0, but windows 7 does not
@@ -957,9 +957,9 @@ static status_t process_server_retry(private_eap_mschapv2_t *this,
                         "maximum number of retries reached");
                return FAILED;
        }
-       
+
        DBG1(DBG_IKE, "EAP-MS-CHAPv2 verification failed, retry (%d)", this->retries);
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
        {
@@ -968,11 +968,11 @@ static status_t process_server_retry(private_eap_mschapv2_t *this,
        }
        rng->get_bytes(rng, CHALLENGE_LEN, this->challenge.ptr);
        rng->destroy(rng);
-       
+
        chunk_free(&this->nt_response);
        chunk_free(&this->auth_response);
        chunk_free(&this->msk);
-       
+
        eap = alloca(len);
        eap->code = EAP_REQUEST;
        eap->identifier = ++this->identifier;
@@ -981,16 +981,16 @@ static status_t process_server_retry(private_eap_mschapv2_t *this,
        eap->opcode = MSCHAPV2_FAILURE;
        eap->ms_chapv2_id = this->mschapv2id++; /* increase for each retry */
        set_ms_length(eap, len);
-       
+
        hex = chunk_to_hex(this->challenge, NULL, TRUE);
        snprintf(msg, FAILURE_MESSAGE_LEN, "%s%s", FAILURE_MESSAGE, hex.ptr);
        chunk_free(&hex);
        memcpy(eap->data, msg, FAILURE_MESSAGE_LEN - 1); /* no null byte */
        *out = eap_payload_create_data(chunk_create((void*) eap, len));
-       
+
        /* delay the response for some time to make brute-force attacks harder */
        sleep(RETRY_DELAY);
-       
+
        return NEED_MORE;
 }
 
@@ -1007,25 +1007,25 @@ static status_t process_server_response(private_eap_mschapv2_t *this,
        shared_key_t *shared;
        int name_len;
        char buf[256];
-       
+
        data = in->get_data(in);
        eap = (eap_mschapv2_header_t*)data.ptr;
-       
+
        if (data.len < RESPONSE_PAYLOAD_LEN)
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: too short");
                return FAILED;
        }
-       
+
        res = (eap_mschapv2_response_t*)eap->data;
        peer_challenge = chunk_create(res->response.peer_challenge, CHALLENGE_LEN);
-       
+
        name_len = min(data.len - RESPONSE_PAYLOAD_LEN, 255);
        snprintf(buf, sizeof(buf), "%.*s", name_len, res->name);
        userid = identification_create_from_string(buf);
        DBG2(DBG_IKE, "EAP-MS-CHAPv2 username: '%Y'", userid);
        username = extract_username(userid);
-       
+
        shared = charon->credentials->get_shared(charon->credentials,
                                                                                         SHARED_EAP, this->server, userid);
        if (shared == NULL)
@@ -1041,27 +1041,27 @@ static status_t process_server_response(private_eap_mschapv2_t *this,
                userid->destroy(userid);
                return process_server_retry(this, out);
        }
-       
+
        password = ascii_to_unicode(shared->get_key(shared));
        shared->destroy(shared);
-       
+
        if (GenerateStuff(this, this->challenge, peer_challenge,
                                          username, password) != SUCCESS)
        {
-               DBG1(DBG_IKE, "EAP-MS-CHAPv2 verification failed");     
+               DBG1(DBG_IKE, "EAP-MS-CHAPv2 verification failed");
                userid->destroy(userid);
                chunk_clear(&password);
                return FAILED;
        }
        userid->destroy(userid);
        chunk_clear(&password);
-       
+
        if (memeq(res->response.nt_response, this->nt_response.ptr, this->nt_response.len))
        {
                chunk_t hex;
                char msg[AUTH_RESPONSE_LEN + sizeof(SUCCESS_MESSAGE)];
                u_int16_t len = HEADER_LEN + AUTH_RESPONSE_LEN + sizeof(SUCCESS_MESSAGE);
-               
+
                eap = alloca(len);
                eap->code = EAP_REQUEST;
                eap->identifier = ++this->identifier;
@@ -1070,7 +1070,7 @@ static status_t process_server_response(private_eap_mschapv2_t *this,
                eap->opcode = MSCHAPV2_SUCCESS;
                eap->ms_chapv2_id = this->mschapv2id;
                set_ms_length(eap, len);
-               
+
                hex = chunk_to_hex(this->auth_response, NULL, TRUE);
                snprintf(msg, AUTH_RESPONSE_LEN + sizeof(SUCCESS_MESSAGE),
                                          "S=%s%s", hex.ptr, SUCCESS_MESSAGE);
@@ -1091,23 +1091,23 @@ static status_t process_server(private_eap_mschapv2_t *this, eap_payload_t *in,
 {
        eap_mschapv2_header_t *eap;
        chunk_t data;
-       
+
        if (this->identifier != in->get_identifier(in))
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: "
                         "unexpected identifier");
                return FAILED;
        }
-       
+
        data = in->get_data(in);
        if (data.len < SHORT_HEADER_LEN)
        {
                DBG1(DBG_IKE, "received invalid EAP-MS-CHAPv2 message: too short");
                return FAILED;
        }
-       
+
        eap = (eap_mschapv2_header_t*)data.ptr;
-       
+
        switch (eap->opcode)
        {
                case MSCHAPV2_RESPONSE:
@@ -1182,14 +1182,14 @@ static void destroy(private_eap_mschapv2_t *this)
 static private_eap_mschapv2_t *eap_mschapv2_create_generic(identification_t *server, identification_t *peer)
 {
        private_eap_mschapv2_t *this = malloc_thing(private_eap_mschapv2_t);
-       
+
        this->public.eap_method_interface.initiate = NULL;
        this->public.eap_method_interface.process = NULL;
        this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
        this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
        this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
        this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
-       
+
        /* private data */
        this->peer = peer->clone(peer);
        this->server = server->clone(server);
@@ -1200,7 +1200,7 @@ static private_eap_mschapv2_t *eap_mschapv2_create_generic(identification_t *ser
        this->identifier = 0;
        this->mschapv2id = 0;
        this->retries = 0;
-       
+
        return this;
 }
 
@@ -1210,7 +1210,7 @@ static private_eap_mschapv2_t *eap_mschapv2_create_generic(identification_t *ser
 eap_mschapv2_t *eap_mschapv2_create_server(identification_t *server, identification_t *peer)
 {
        private_eap_mschapv2_t *this = eap_mschapv2_create_generic(server, peer);
-       
+
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_server;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*, eap_payload_t**))process_server;
 
@@ -1219,9 +1219,9 @@ eap_mschapv2_t *eap_mschapv2_create_server(identification_t *server, identificat
        {
                this->identifier = random();
        } while (!this->identifier);
-       
+
        this->mschapv2id = this->identifier;
-       
+
        return &this->public;
 }
 
@@ -1231,10 +1231,10 @@ eap_mschapv2_t *eap_mschapv2_create_server(identification_t *server, identificat
 eap_mschapv2_t *eap_mschapv2_create_peer(identification_t *server, identification_t *peer)
 {
        private_eap_mschapv2_t *this = eap_mschapv2_create_generic(server, peer);
-       
+
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_peer;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*, eap_payload_t**))process_peer;
-       
+
        return &this->public;
 }
 
index d0995c477eac17c4b621f5bc765b05831e384d88..404cecb2074f160fbabf58ef18b6cf7d357d73e0 100644 (file)
@@ -37,14 +37,14 @@ static void destroy(eap_mschapv2_plugin_t *this)
 plugin_t *plugin_create()
 {
        eap_mschapv2_plugin_t *this = malloc_thing(eap_mschapv2_plugin_t);
-       
+
        this->plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->eap->add_method(charon->eap, EAP_MSCHAPV2, 0, EAP_SERVER,
                                                        (eap_constructor_t)eap_mschapv2_create_server);
        charon->eap->add_method(charon->eap, EAP_MSCHAPV2, 0, EAP_PEER,
                                                        (eap_constructor_t)eap_mschapv2_create_peer);
-       
+
        return &this->plugin;
 }
 
index deb3b648bd45dc87e2a4343b07d7bc8b2dfb0676..f21d6b8595571196847e91554a34fffc8f4451f3 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "eap_radius.h"
 
 #include "radius_message.h"
@@ -26,47 +26,47 @@ typedef struct private_eap_radius_t private_eap_radius_t;
  * Private data of an eap_radius_t object.
  */
 struct private_eap_radius_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        eap_radius_t public;
-       
+
        /**
         * ID of the server
         */
        identification_t *server;
-       
+
        /**
         * ID of the peer
         */
        identification_t *peer;
-       
+
        /**
         * EAP method type we are proxying
         */
        eap_type_t type;
-       
+
        /**
         * EAP vendor, if any
         */
        u_int32_t vendor;
-       
+
        /**
         * EAP MSK, if method established one
         */
        chunk_t msk;
-       
+
        /**
         * RADIUS client instance
         */
        radius_client_t *client;
-       
+
        /**
         * TRUE to use EAP-Start, FALSE to send EAP-Identity Response directly
         */
        bool eap_start;
-       
+
        /**
         * Prefix to prepend to EAP identity
         */
@@ -93,11 +93,11 @@ static void add_eap_identity(private_eap_radius_t *this,
        } __attribute__((__packed__)) *hdr;
        chunk_t id, prefix;
        size_t len;
-       
+
        id = this->peer->get_encoding(this->peer);
        prefix = chunk_create(this->id_prefix, strlen(this->id_prefix));
        len = sizeof(*hdr) + prefix.len + id.len;
-       
+
        hdr = alloca(len);
        hdr->code = EAP_RESPONSE;
        hdr->identifier = 0;
@@ -105,7 +105,7 @@ static void add_eap_identity(private_eap_radius_t *this,
        hdr->type = EAP_IDENTITY;
        memcpy(hdr->data, prefix.ptr, prefix.len);
        memcpy(hdr->data + prefix.len, id.ptr, id.len);
-       
+
        request->add(request, RAT_EAP_MESSAGE, chunk_create((u_char*)hdr, len));
 }
 
@@ -119,7 +119,7 @@ static bool radius2ike(private_eap_radius_t *this,
        eap_payload_t *payload;
        chunk_t data;
        int type;
-       
+
        enumerator = msg->create_enumerator(msg);
        while (enumerator->enumerate(enumerator, &type, &data))
        {
@@ -144,12 +144,12 @@ static status_t initiate(private_eap_radius_t *this, eap_payload_t **out)
        radius_message_t *request, *response;
        status_t status = FAILED;
        chunk_t username;
-       
+
        request = radius_message_create_request();
        username = chunk_create(this->id_prefix, strlen(this->id_prefix));
        username = chunk_cata("cc", username, this->peer->get_encoding(this->peer));
        request->add(request, RAT_USER_NAME, username);
-       
+
        if (this->eap_start)
        {
                request->add(request, RAT_EAP_MESSAGE, chunk_empty);
@@ -158,7 +158,7 @@ static status_t initiate(private_eap_radius_t *this, eap_payload_t **out)
        {
                add_eap_identity(this, request);
        }
-       
+
        response = this->client->request(this->client, request);
        if (response)
        {
@@ -180,11 +180,11 @@ static status_t process(private_eap_radius_t *this,
 {
        radius_message_t *request, *response;
        status_t status = FAILED;
-       
+
        request = radius_message_create_request();
        request->add(request, RAT_USER_NAME, this->peer->get_encoding(this->peer));
        request->add(request, RAT_EAP_MESSAGE, in->get_data(in));
-       
+
        response = this->client->request(this->client, request);
        if (response)
        {
@@ -271,14 +271,14 @@ static void destroy(private_eap_radius_t *this)
 eap_radius_t *eap_radius_create(identification_t *server, identification_t *peer)
 {
        private_eap_radius_t *this = malloc_thing(private_eap_radius_t);
-       
+
        this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate;
        this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process;
        this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
        this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
        this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
        this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
-       
+
        this->client = radius_client_create();
        if (!this->client)
        {
@@ -291,7 +291,7 @@ eap_radius_t *eap_radius_create(identification_t *server, identification_t *peer
        this->type = EAP_RADIUS;
        this->vendor = 0;
        this->msk = chunk_empty;
-       this->eap_start = lib->settings->get_bool(lib->settings, 
+       this->eap_start = lib->settings->get_bool(lib->settings,
                                                                "charon.plugins.eap_radius.eap_start", FALSE);
        this->id_prefix = lib->settings->get_str(lib->settings,
                                                                "charon.plugins.eap_radius.id_prefix", "");
index 7c6a3c9ffbff695cb563ca75a557bef6943a4c51..51e6a69c85571dbba4e9d1dd3b6fc65c01b1268f 100644 (file)
@@ -36,19 +36,19 @@ static void destroy(eap_radius_plugin_t *this)
 plugin_t *plugin_create()
 {
        eap_radius_plugin_t *this;
-       
+
        if (!radius_client_init())
        {
                DBG1(DBG_CFG, "RADIUS plugin initialization failed");
                return NULL;
        }
-       
+
        this = malloc_thing(eap_radius_plugin_t);
        this->plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->eap->add_method(charon->eap, EAP_RADIUS, 0,
                                                        EAP_SERVER, (eap_constructor_t)eap_radius_create);
-       
+
        return &this->plugin;
 }
 
index de1bafc6d770b8fcfbae0a53a83b0d2b4ace1dfd..1b35cd2d69b88f21f96a572d5a7c240c4bb5fda6 100644 (file)
@@ -63,12 +63,12 @@ struct entry_t {
  * Private data of an radius_client_t object.
  */
 struct private_radius_client_t {
-       
+
        /**
         * Public radius_client_t interface.
         */
        radius_client_t public;
-       
+
        /**
         * RADIUS servers State attribute
         */
@@ -106,7 +106,7 @@ static chunk_t nas_identifier;
 void radius_client_cleanup()
 {
        entry_t *entry;
-       
+
        mutex->destroy(mutex);
        condvar->destroy(condvar);
        while (sockets->remove_last(sockets, (void**)&entry) == SUCCESS)
@@ -130,11 +130,11 @@ bool radius_client_init()
        entry_t *entry;
        host_t *host;
        char *server;
-       
+
        nas_identifier.ptr = lib->settings->get_str(lib->settings,
                                        "charon.plugins.eap_radius.nas_identifier", "strongSwan");
        nas_identifier.len = strlen(nas_identifier.ptr);
-       
+
        secret.ptr = lib->settings->get_str(lib->settings,
                                        "charon.plugins.eap_radius.secret", NULL);
        if (!secret.ptr)
@@ -159,7 +159,7 @@ bool radius_client_init()
        }
        count = lib->settings->get_int(lib->settings,
                                        "charon.plugins.eap_radius.sockets", 1);
-       
+
        sockets = linked_list_create();
        mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
@@ -214,7 +214,7 @@ bool radius_client_init()
 static entry_t* get_socket()
 {
        entry_t *entry;
-       
+
        mutex->lock(mutex);
        while (sockets->remove_first(sockets, (void**)&entry) != SUCCESS)
        {
@@ -243,7 +243,7 @@ static void save_state(private_radius_client_t *this, radius_message_t *msg)
        enumerator_t *enumerator;
        int type;
        chunk_t data;
-       
+
        enumerator = msg->create_enumerator(msg);
        while (enumerator->enumerate(enumerator, &type, &data))
        {
@@ -270,9 +270,9 @@ static radius_message_t* request(private_radius_client_t *this,
        entry_t *socket;
        chunk_t data;
        int i;
-       
+
        socket = get_socket();
-       
+
        /* set Message Identifier */
        req->set_identifier(req, socket->identifier++);
        /* we add the "Virtual" NAS-Port-Type, as we SHOULD include one */
@@ -286,7 +286,7 @@ static radius_message_t* request(private_radius_client_t *this,
        }
        /* sign the request */
        req->sign(req, socket->rng, socket->signer);
-       
+
        data = req->get_encoding(req);
        /* timeout after 2, 3, 4, 5 seconds */
        for (i = 2; i <= 5; i++)
@@ -297,7 +297,7 @@ static radius_message_t* request(private_radius_client_t *this,
                char buf[1024];
                fd_set fds;
                int res;
-               
+
                if (send(socket->fd, data.ptr, data.len, 0) != data.len)
                {
                        DBG1(DBG_CFG, "sending RADIUS message failed: %s", strerror(errno));
@@ -306,7 +306,7 @@ static radius_message_t* request(private_radius_client_t *this,
                }
                tv.tv_sec = i;
                tv.tv_usec = 0;
-               
+
                while (TRUE)
                {
                        FD_ZERO(&fds);
@@ -334,7 +334,7 @@ static radius_message_t* request(private_radius_client_t *this,
                        }
                        response = radius_message_parse_response(chunk_create(buf, res));
                        if (response)
-                       {       
+                       {
                                if (response->verify(response, req->get_authenticator(req),
                                                        secret, socket->hasher, socket->signer))
                                {
@@ -366,7 +366,7 @@ static chunk_t decrypt_mppe_key(private_radius_client_t *this, u_int16_t salt,
        chunk_t A, R, P, seed;
        u_char *c, *p;
        hasher_t *hasher;
-       
+
        /**
         * From RFC2548 (encryption):
         * b(1) = MD5(S + R + A)    c(1) = p(1) xor b(1)   C = c(1)
@@ -374,42 +374,42 @@ static chunk_t decrypt_mppe_key(private_radius_client_t *this, u_int16_t salt,
         *      . . .
         * b(i) = MD5(S + c(i-1))   c(i) = p(i) xor b(i)   C = C + c(i)
         */
-       
+
        if (C.len % HASH_SIZE_MD5 || C.len < HASH_SIZE_MD5)
        {
                return chunk_empty;
        }
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
        if (!hasher)
        {
                return chunk_empty;
        }
-       
+
        A = chunk_create((u_char*)&salt, sizeof(salt));
        R = chunk_create(request->get_authenticator(request), HASH_SIZE_MD5);
        P = chunk_alloca(C.len);
        p = P.ptr;
        c = C.ptr;
-       
+
        seed = chunk_cata("cc", R, A);
-       
+
        while (c < C.ptr + C.len)
        {
                /* b(i) = MD5(S + c(i-1)) */
                hasher->get_hash(hasher, secret, NULL);
                hasher->get_hash(hasher, seed, p);
-               
+
                /* p(i) = b(i) xor c(1) */
                memxor(p, c, HASH_SIZE_MD5);
-               
+
                /* prepare next round */
                seed = chunk_create(c, HASH_SIZE_MD5);
                c += HASH_SIZE_MD5;
                p += HASH_SIZE_MD5;
        }
        hasher->destroy(hasher);
-       
+
        /* remove truncation, first byte is key length */
        if (*P.ptr >= P.len)
        {       /* decryption failed? */
@@ -434,7 +434,7 @@ static chunk_t decrypt_msk(private_radius_client_t *this,
        enumerator_t *enumerator;
        chunk_t data, send = chunk_empty, recv = chunk_empty;
        int type;
-       
+
        enumerator = response->create_enumerator(response);
        while (enumerator->enumerate(enumerator, &type, &data))
        {
@@ -482,13 +482,13 @@ static void destroy(private_radius_client_t *this)
 radius_client_t *radius_client_create()
 {
        private_radius_client_t *this = malloc_thing(private_radius_client_t);
-       
+
        this->public.request = (radius_message_t*(*)(radius_client_t*, radius_message_t *msg))request;
        this->public.decrypt_msk = (chunk_t(*)(radius_client_t*, radius_message_t *, radius_message_t *))decrypt_msk;
        this->public.destroy = (void(*)(radius_client_t*))destroy;
-       
+
        this->state = chunk_empty;
-       
+
        return &this->public;
 }
 
index 889861a161f259f31480ce13a6148521be01a8dd..77ba94807ff5f9e1634c159142252190172b7f66 100644 (file)
@@ -33,11 +33,11 @@ typedef struct radius_client_t radius_client_t;
  * a socket during request() and releases it afterwards.
  */
 struct radius_client_t {
-       
+
        /**
         * Send a RADIUS request and wait for the response.
         *
-        * The client fills in RADIUS Message identifier, NAS-Identifier, 
+        * The client fills in RADIUS Message identifier, NAS-Identifier,
         * NAS-Port-Type, builds a Request-Authenticator and calculates the
         * Message-Authenticator attribute.
         * The received response gets verified using the Response-Identifier
@@ -47,7 +47,7 @@ struct radius_client_t {
         * @return                              response, NULL if timed out/verification failed
         */
        radius_message_t* (*request)(radius_client_t *this, radius_message_t *msg);
-       
+
        /**
         * Decrypt the MSK encoded in a messages MS-MPPE-Send/Recv-Key.
         *
@@ -57,7 +57,7 @@ struct radius_client_t {
         */
        chunk_t (*decrypt_msk)(radius_client_t *this, radius_message_t *response,
                                                   radius_message_t *request);
-       
+
        /**
         * Destroy the client, release the socket.
         */
index 59a639f31e01aede7beefd3c10f7616392b58107..8b7ef12d4fe46e158a3629c26a4ab6d8e79d0dc5 100644 (file)
@@ -54,12 +54,12 @@ struct rattr_t {
  * Private data of an radius_message_t object.
  */
 struct private_radius_message_t {
-       
+
        /**
         * Public radius_message_t interface.
         */
        radius_message_t public;
-       
+
        /**
         * message data, allocated
         */
@@ -247,12 +247,12 @@ static bool attribute_enumerate(attribute_enumerator_t *this,
 static enumerator_t* create_enumerator(private_radius_message_t *this)
 {
        attribute_enumerator_t *e;
-       
+
        if (ntohs(this->msg->length) < sizeof(rmsg_t) + sizeof(rattr_t))
        {
                return enumerator_create_empty();
        }
-       
+
        e = malloc_thing(attribute_enumerator_t);
        e->public.enumerate = (void*)attribute_enumerate;
        e->public.destroy = (void*)free;
@@ -268,7 +268,7 @@ static void add(private_radius_message_t *this, radius_attribute_type_t type,
                                chunk_t data)
 {
        rattr_t *attribute;
-       
+
        this->msg = realloc(this->msg,
                                                ntohs(this->msg->length) + sizeof(rattr_t) + data.len);
        attribute = ((void*)this->msg) + ntohs(this->msg->length);
@@ -284,10 +284,10 @@ static void add(private_radius_message_t *this, radius_attribute_type_t type,
 static void sign(private_radius_message_t *this, rng_t *rng, signer_t *signer)
 {
        char buf[HASH_SIZE_MD5];
-       
+
        /* build Request-Authenticator */
        rng->get_bytes(rng, HASH_SIZE_MD5, this->msg->authenticator);
-       
+
        /* build Message-Authenticator attribute, using 16 null bytes */
        memset(buf, 0, sizeof(buf));
        add(this, RAT_MESSAGE_AUTHENTICATOR, chunk_create(buf, sizeof(buf)));
@@ -307,12 +307,12 @@ static bool verify(private_radius_message_t *this, u_int8_t *req_auth,
        int type;
        chunk_t data, msg;
        bool has_eap = FALSE, has_auth = FALSE;
-       
+
        /* replace Response by Request Authenticator for verification */
        memcpy(res_auth, this->msg->authenticator, HASH_SIZE_MD5);
        memcpy(this->msg->authenticator, req_auth, HASH_SIZE_MD5);
        msg = chunk_create((u_char*)this->msg, ntohs(this->msg->length));
-       
+
        /* verify Response-Authenticator */
        hasher->get_hash(hasher, msg, NULL);
        hasher->get_hash(hasher, secret, buf);
@@ -321,7 +321,7 @@ static bool verify(private_radius_message_t *this, u_int8_t *req_auth,
                DBG1(DBG_CFG, "RADIUS Response-Authenticator verification failed");
                return FALSE;
        }
-       
+
        /* verify Message-Authenticator attribute */
        enumerator = create_enumerator(this);
        while (enumerator->enumerate(enumerator, &type, &data))
@@ -359,7 +359,7 @@ static bool verify(private_radius_message_t *this, u_int8_t *req_auth,
        enumerator->destroy(enumerator);
        /* restore Response-Authenticator */
        memcpy(this->msg->authenticator, res_auth, HASH_SIZE_MD5);
-       
+
        if (has_eap && !has_auth)
        {       /* Message-Authenticator is required if we have an EAP-Message */
                DBG1(DBG_CFG, "RADIUS Message-Authenticator attribute missing");
@@ -424,7 +424,7 @@ static void destroy(private_radius_message_t *this)
 static private_radius_message_t *radius_message_create()
 {
        private_radius_message_t *this = malloc_thing(private_radius_message_t);
-       
+
        this->public.create_enumerator = (enumerator_t*(*)(radius_message_t*))create_enumerator;
        this->public.add = (void(*)(radius_message_t*, radius_attribute_type_t,chunk_t))add;
        this->public.get_code = (radius_message_code_t(*)(radius_message_t*))get_code;
@@ -435,7 +435,7 @@ static private_radius_message_t *radius_message_create()
        this->public.sign = (void(*)(radius_message_t*, rng_t *rng, signer_t *signer))sign;
        this->public.verify = (bool(*)(radius_message_t*, u_int8_t *req_auth, chunk_t secret, hasher_t *hasher, signer_t *signer))verify;
        this->public.destroy = (void(*)(radius_message_t*))destroy;
-       
+
        return this;
 }
 
@@ -445,12 +445,12 @@ static private_radius_message_t *radius_message_create()
 radius_message_t *radius_message_create_request()
 {
        private_radius_message_t *this = radius_message_create();
-       
+
        this->msg = malloc_thing(rmsg_t);
        this->msg->code = RMC_ACCESS_REQUEST;
        this->msg->identifier = 0;
        this->msg->length = htons(sizeof(rmsg_t));
-       
+
        return &this->public;
 }
 
@@ -460,7 +460,7 @@ radius_message_t *radius_message_create_request()
 radius_message_t *radius_message_parse_response(chunk_t data)
 {
        private_radius_message_t *this = radius_message_create();
-       
+
        this->msg = malloc(data.len);
        memcpy(this->msg, data.ptr, data.len);
        if (data.len < sizeof(rmsg_t) ||
index d4eec8590bb2b46deb5bd994d16d12beaebf07b7..266839d3b0be16d991d8468950e6bdc9775ed58a 100644 (file)
@@ -181,14 +181,14 @@ extern enum_name_t *radius_attribute_type_names;
  * A RADIUS message, contains attributes.
  */
 struct radius_message_t {
-       
+
        /**
         * Create an enumerator over contained RADIUS attributes.
         *
         * @return                              enumerator over (int type, chunk_t data)
         */
        enumerator_t* (*create_enumerator)(radius_message_t *this);
-       
+
        /**
         * Add a RADIUS attribute to the message.
         *
@@ -197,42 +197,42 @@ struct radius_message_t {
         */
        void (*add)(radius_message_t *this, radius_attribute_type_t type,
                                chunk_t data);
-       
+
        /**
         * Get the message type (code).
         *
         * @return                              message code
         */
        radius_message_code_t (*get_code)(radius_message_t *this);
-       
+
        /**
         * Get the message identifier.
         *
         * @return                              message identifier
         */
        u_int8_t (*get_identifier)(radius_message_t *this);
-       
+
        /**
         * Set the message identifier.
         *
         * @param identifier    message identifier
         */
        void (*set_identifier)(radius_message_t *this, u_int8_t identifier);
-       
+
        /**
         * Get the 16 byte authenticator.
         *
         * @return                              pointer to the Authenticator field
         */
        u_int8_t* (*get_authenticator)(radius_message_t *this);
-       
+
        /**
         * Get the RADIUS message in its encoded form.
         *
         * @return                              chunk pointing to internal RADIUS message.
         */
        chunk_t (*get_encoding)(radius_message_t *this);
-       
+
        /**
         * Calculate and add the Message-Authenticator attribute to the message.
         *
@@ -240,7 +240,7 @@ struct radius_message_t {
         * @param signer                HMAC-MD5 signer with secret set
         */
        void (*sign)(radius_message_t *this, rng_t *rng, signer_t *signer);
-       
+
        /**
         * Verify the integrity of a received RADIUS response.
         *
@@ -251,7 +251,7 @@ struct radius_message_t {
         */
        bool (*verify)(radius_message_t *this, u_int8_t *req_auth, chunk_t secret,
                                   hasher_t *hasher, signer_t *signer);
-       
+
        /**
         * Destroy the message.
         */
index 2dd6e534b4ba335fd53f2c03f6afdcb9ae153987..f439bd2481fb7f50782aa10cab84095c9b94459f 100644 (file)
@@ -121,82 +121,82 @@ typedef struct private_eap_sim_t private_eap_sim_t;
  * Private data of an eap_sim_t object.
  */
 struct private_eap_sim_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        eap_sim_t public;
-       
+
        /**
         * ID of ourself
         */
        identification_t *peer;
-       
+
        /**
         * hashing function
         */
        hasher_t *hasher;
-       
+
        /**
         * prf
         */
        prf_t *prf;
-       
+
        /**
         * MAC function
         */
        signer_t *signer;
-       
+
        /**
         * how many times we try to authenticate
         */
        int tries;
-       
+
        /**
         * unique EAP identifier
         */
        u_int8_t identifier;
-       
+
        /**
         * EAP message type this role sends
         */
        u_int8_t type;
-       
+
        /**
         * version this implementation uses
         */
        chunk_t version;
-       
+
        /**
         * version list received from server
         */
        chunk_t version_list;
-       
+
        /**
         * Nonce value used in AT_NONCE_MT
         */
        chunk_t nonce;
-       
+
        /**
         * concatenated SRES values
         */
        chunk_t sreses;
-       
+
        /**
         * k_encr key derived from MK
         */
        chunk_t k_encr;
-       
+
        /**
         * k_auth key derived from MK, used for AT_MAC verification
         */
        chunk_t k_auth;
-       
+
        /**
         * MSK, used for EAP-SIM based IKEv2 authentication
         */
        chunk_t msk;
-       
+
        /**
         * EMSK, extended MSK for further uses
         */
@@ -257,9 +257,9 @@ static sim_attribute_t read_attribute(chunk_t *message, chunk_t *data)
 {
        sim_attribute_t attribute;
        size_t length;
-       
+
        DBG3(DBG_IKE, "reading attribute from %B", message);
-       
+
        if (message->len < 2)
        {
                return AT_END;
@@ -294,7 +294,7 @@ static eap_payload_t *build_payload(private_eap_sim_t *this, u_int8_t identifier
        sim_attribute_t attr;
        u_int8_t *mac_pos = NULL;
        chunk_t mac_data = chunk_empty;
-       
+
        /* write EAP header, skip length bytes */
        *pos.ptr++ = this->type;
        *pos.ptr++ = identifier;
@@ -306,18 +306,18 @@ static eap_payload_t *build_payload(private_eap_sim_t *this, u_int8_t identifier
        *pos.ptr++ = 0;
        *pos.ptr++ = 0;
        pos.len -= 4;
-       
+
        va_start(args, type);
        while ((attr = va_arg(args, sim_attribute_t)) != AT_END)
        {
                chunk_t data = va_arg(args, chunk_t);
-               
+
                DBG3(DBG_IKE, "building %N %B", sim_attribute_names, attr, &data);
-               
+
                /* write attribute header */
                *pos.ptr++ = attr;
                pos.len--;
-               
+
                switch (attr)
                {
                        case AT_CLIENT_ERROR_CODE:
@@ -387,11 +387,11 @@ static eap_payload_t *build_payload(private_eap_sim_t *this, u_int8_t identifier
                }
        }
        va_end(args);
-       
+
        /* calculate message length, write into header */
        message.len = pos.ptr - message.ptr;
        *(u_int16_t*)(message.ptr + 2) = htons(message.len);
-       
+
        /* create MAC if AT_MAC attribte was included. Append supplied va_arg
         * chunk mac_data to "to-sign" chunk */
        if (mac_pos)
@@ -402,9 +402,9 @@ static eap_payload_t *build_payload(private_eap_sim_t *this, u_int8_t identifier
                DBG3(DBG_IKE, "AT_MAC signature of %B\n is %b",
                         &mac_data, mac_pos, MAC_LEN);
        }
-       
+
        payload = eap_payload_create_data(message);
-       
+
        DBG3(DBG_IKE, "created EAP message %B", &message);
        return payload;
 }
@@ -495,7 +495,7 @@ static status_t peer_process_start(private_eap_sim_t *this, eap_payload_t *in,
                                break;
                }
        }
-       
+
        /* build payload. If "include_id" is AT_END, AT_IDENTITY is ommited */
        *out = build_payload(this, identifier, SIM_START,
                                                 AT_SELECTED_VERSION, this->version,
@@ -519,7 +519,7 @@ static void derive_keys(private_eap_sim_t *this, chunk_t kcs)
        mk = chunk_alloca(this->hasher->get_hash_size(this->hasher));
        this->hasher->get_hash(this->hasher, tmp, mk.ptr);
        DBG3(DBG_IKE, "MK = SHA1(%B\n) = %B", &tmp, &mk);
-       
+
        /* K_encr | K_auth | MSK | EMSK = prf() | prf() | prf() | prf()
         * FIPS PRF has 320 bit block size, we need 160 byte for keys
         *  => run prf four times */
@@ -549,7 +549,7 @@ static bool get_card_triplet(private_eap_sim_t *this,
        sim_card_t *card = NULL, *current;
        id_match_t match, best = ID_MATCH_NONE;
        bool success = FALSE;
-       
+
        /* find the best matching SIM */
        enumerator = charon->sim->create_card_enumerator(charon->sim);
        while (enumerator->enumerate(enumerator, &current))
@@ -584,7 +584,7 @@ static status_t peer_process_challenge(private_eap_sim_t *this,
        sim_attribute_t attribute;
        u_int8_t identifier;
        chunk_t mac = chunk_empty, rands = chunk_empty;
-       
+
        if (this->tries-- <= 0)
        {
                /* give up without notification. This hack is required as some buggy
@@ -643,7 +643,7 @@ static status_t peer_process_challenge(private_eap_sim_t *this,
                                break;
                }
        }
-       
+
        /* excepting two or three RAND, each 16 bytes. We require two valid
         * and different RANDs */
        if ((rands.len != 2 * RAND_LEN && rands.len != 3 * RAND_LEN) ||
@@ -663,12 +663,12 @@ static status_t peer_process_challenge(private_eap_sim_t *this,
                                                         AT_END);
                return NEED_MORE;
        }
-       
+
        /* get two or three KCs/SRESes from SIM using RANDs */
        kcs = kc = chunk_alloca(rands.len / 2);
        sreses = sres = chunk_alloca(rands.len / 4);
        while (rands.len >= RAND_LEN)
-       {               
+       {
                if (!get_card_triplet(this, rands.ptr, sres.ptr, kc.ptr))
                {
                        DBG1(DBG_IKE, "unable to get EAP-SIM triplet");
@@ -683,9 +683,9 @@ static status_t peer_process_challenge(private_eap_sim_t *this,
                sres = chunk_skip(sres, SRES_LEN);
                rands = chunk_skip(rands, RAND_LEN);
        }
-       
+
        derive_keys(this, kcs);
-       
+
        /* verify AT_MAC attribute, signature is over "EAP packet | NONCE_MT"  */
        this->signer->set_key(this->signer, this->k_auth);
        tmp = chunk_cata("cc", in->get_data(in), this->nonce);
@@ -697,7 +697,7 @@ static status_t peer_process_challenge(private_eap_sim_t *this,
                                                         AT_END);
                return NEED_MORE;
        }
-       
+
        /* build response, AT_MAC is built over "EAP packet | n*SRES" */
        *out = build_payload(this, identifier, SIM_CHALLENGE,
                                                 AT_MAC, sreses,
@@ -714,7 +714,7 @@ static status_t server_process_challenge(private_eap_sim_t *this,
        chunk_t message, data;
        sim_attribute_t attribute;
        chunk_t mac = chunk_empty, tmp;
-       
+
        message = in->get_data(in);
        read_header(&message);
 
@@ -761,7 +761,7 @@ static bool get_provider_triplet(private_eap_sim_t *this,
        enumerator_t *enumerator;
        sim_provider_t *provider;
        int tried = 0;
-       
+
        enumerator = charon->sim->create_provider_enumerator(charon->sim);
        while (enumerator->enumerate(enumerator, &provider))
        {
@@ -789,7 +789,7 @@ static status_t server_process_start(private_eap_sim_t *this,
        bool supported = FALSE;
        chunk_t rands, rand, kcs, kc, sreses, sres;
        int i;
-               
+
        message = in->get_data(in);
        read_header(&message);
 
@@ -820,7 +820,7 @@ static status_t server_process_start(private_eap_sim_t *this,
                DBG1(DBG_IKE, "received incomplete EAP-SIM/Response/Start");
                return FAILED;
        }
-       
+
        /* read triplets from provider */
        rand = rands = chunk_alloca(RAND_LEN * TRIPLET_COUNT);
        kc = kcs = chunk_alloca(KC_LEN * TRIPLET_COUNT);
@@ -843,7 +843,7 @@ static status_t server_process_start(private_eap_sim_t *this,
                kc = chunk_skip(kc, KC_LEN);
        }
        derive_keys(this, kcs);
-       
+
        /* build MAC over "EAP packet | NONCE_MT" */
        *out = build_payload(this, this->identifier++, SIM_CHALLENGE, AT_RAND,
                                                 rands, AT_MAC, this->nonce, AT_END);
@@ -859,7 +859,7 @@ static status_t peer_process_notification(private_eap_sim_t *this,
 {
        chunk_t message, data;
        sim_attribute_t attribute;
-       
+
        message = in->get_data(in);
        read_header(&message);
 
@@ -910,7 +910,7 @@ static status_t server_process_client_error(private_eap_sim_t *this,
 {
        chunk_t message, data;
        sim_attribute_t attribute;
-       
+
        message = in->get_data(in);
        read_header(&message);
 
@@ -943,10 +943,10 @@ static status_t peer_process(private_eap_sim_t *this,
 {
        sim_subtype_t type;
        chunk_t message;
-       
+
        message = in->get_data(in);
        type = read_header(&message);
-       
+
        switch (type)
        {
                case SIM_START:
@@ -972,10 +972,10 @@ static status_t server_process(private_eap_sim_t *this,
 {
        sim_subtype_t type;
        chunk_t message;
-       
+
        message = in->get_data(in);
        type = read_header(&message);
-       
+
        switch (type)
        {
                case SIM_START:
@@ -1070,7 +1070,7 @@ eap_sim_t *eap_sim_create_generic(eap_role_t role, identification_t *server,
 {
        private_eap_sim_t *this = malloc_thing(private_eap_sim_t);
        rng_t *rng;
-       
+
        this->nonce = chunk_empty;
        this->sreses = chunk_empty;
        this->peer = peer->clone(peer);
@@ -1086,7 +1086,7 @@ eap_sim_t *eap_sim_create_generic(eap_role_t role, identification_t *server,
        do {
                this->identifier = random();
        } while (!this->identifier);
-       
+
        switch (role)
        {
                case EAP_SERVER:
@@ -1116,7 +1116,7 @@ eap_sim_t *eap_sim_create_generic(eap_role_t role, identification_t *server,
        this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
        this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
        this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
-       
+
        this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        this->prf = lib->crypto->create_prf(lib->crypto, PRF_FIPS_SHA1_160);
        this->signer = lib->crypto->create_signer(lib->crypto, AUTH_HMAC_SHA1_128);
@@ -1146,4 +1146,4 @@ eap_sim_t *eap_sim_create_peer(identification_t *server,
 {
        return eap_sim_create_generic(EAP_PEER, server, peer);
 }
-                                                                
+
index cf18007c0c77732f8144730bfbbc7d96a59da61d..6a6878303fc2fe895ab5d2f164bb2ec4a9723acf 100644 (file)
@@ -37,14 +37,14 @@ static void destroy(eap_sim_plugin_t *this)
 plugin_t *plugin_create()
 {
        eap_sim_plugin_t *this = malloc_thing(eap_sim_plugin_t);
-       
+
        this->plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->eap->add_method(charon->eap, EAP_SIM, 0, EAP_SERVER,
                                                        (eap_constructor_t)eap_sim_create_server);
        charon->eap->add_method(charon->eap, EAP_SIM, 0, EAP_PEER,
                                                        (eap_constructor_t)eap_sim_create_peer);
-       
+
        return &this->plugin;
 }
 
index 7d441ffb29fffd8511eff6042116e4d54498c15b..2a854d367212b7229434f63b4405dce1b965c468 100644 (file)
@@ -21,17 +21,17 @@ typedef struct private_eap_sim_file_card_t private_eap_sim_file_card_t;
  * Private data of an eap_sim_file_card_t object.
  */
 struct private_eap_sim_file_card_t {
-       
+
        /**
         * Public eap_sim_file_card_t interface.
         */
        eap_sim_file_card_t public;
-       
+
        /**
         * IMSI, is ID_ANY for file implementation
         */
        identification_t *imsi;
-       
+
        /**
         * source of triplets
         */
@@ -49,9 +49,9 @@ static bool get_triplet(private_eap_sim_file_card_t *this,
        enumerator_t *enumerator;
        identification_t *id;
        char *c_rand, *c_sres, *c_kc;
-       
+
        DBG2(DBG_CFG, "looking for rand: %b", rand, RAND_LEN);
-       
+
        enumerator = this->triplets->create_enumerator(this->triplets);
        while (enumerator->enumerate(enumerator, &id, &c_rand, &c_sres, &c_kc))
        {
@@ -92,15 +92,15 @@ static void destroy(private_eap_sim_file_card_t *this)
 eap_sim_file_card_t *eap_sim_file_card_create(eap_sim_file_triplets_t *triplets)
 {
        private_eap_sim_file_card_t *this = malloc_thing(private_eap_sim_file_card_t);
-       
+
        this->public.card.get_triplet = (bool(*)(sim_card_t*, char *rand, char *sres, char *kc))get_triplet;
        this->public.card.get_imsi = (identification_t*(*)(sim_card_t*))get_imsi;
        this->public.destroy = (void(*)(eap_sim_file_card_t*))destroy;
-       
+
        /* this SIM card implementation does not have an ID, serve ID_ANY */
        this->imsi = identification_create_from_encoding(ID_ANY, chunk_empty);
        this->triplets = triplets;
-       
+
        return &this->public;
 }
 
index e7160a33b3517c29db0e3a27bf96e3c53807f32c..405fbcea612429622d507689f41ee943263ebcd0 100644 (file)
@@ -36,7 +36,7 @@ struct eap_sim_file_card_t {
         * Implements sim_card_t interface
         */
        sim_card_t card;
-       
+
        /**
         * Destroy a eap_sim_file_card_t.
         */
index eb6fb4c9cba1f586e75f091c1060dd6fc817d1c0..eedaa306072805c565800cdc423357f683bfb2a4 100644 (file)
@@ -28,22 +28,22 @@ typedef struct private_eap_sim_file_t private_eap_sim_file_t;
  * Private data of an eap_sim_file_t object.
  */
 struct private_eap_sim_file_t {
-       
+
        /**
         * Public eap_sim_file_plugin_t interface.
         */
        eap_sim_file_plugin_t public;
-       
+
        /**
         * SIM card
         */
        eap_sim_file_card_t *card;
-       
+
        /**
         * SIM provider
         */
        eap_sim_file_provider_t *provider;
-       
+
        /**
         * Triplet source
         */
@@ -69,16 +69,16 @@ static void destroy(private_eap_sim_file_t *this)
 plugin_t *plugin_create()
 {
        private_eap_sim_file_t *this = malloc_thing(private_eap_sim_file_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->triplets = eap_sim_file_triplets_create(TRIPLET_FILE);
        this->card = eap_sim_file_card_create(this->triplets);
        this->provider = eap_sim_file_provider_create(this->triplets);
-       
+
        charon->sim->add_card(charon->sim, &this->card->card);
        charon->sim->add_provider(charon->sim, &this->provider->provider);
-       
+
        return &this->public.plugin;
 }
 
index 89866ade6708424c5a9b80f662286ec44e99f81c..dc55911b8fc1c99dab3228d109d34f20a4271975 100644 (file)
@@ -21,12 +21,12 @@ typedef struct private_eap_sim_file_provider_t private_eap_sim_file_provider_t;
  * Private data of an eap_sim_file_provider_t object.
  */
 struct private_eap_sim_file_provider_t {
-       
+
        /**
         * Public eap_sim_file_provider_t interface.
         */
        eap_sim_file_provider_t public;
-       
+
        /**
         * source of triplets
         */
@@ -43,7 +43,7 @@ static bool get_triplet(private_eap_sim_file_provider_t *this,
        enumerator_t *enumerator;
        identification_t *id;
        char *c_rand, *c_sres, *c_kc;
-       
+
        enumerator = this->triplets->create_enumerator(this->triplets);
        while (enumerator->enumerate(enumerator, &id, &c_rand, &c_sres, &c_kc))
        {
@@ -75,12 +75,12 @@ eap_sim_file_provider_t *eap_sim_file_provider_create(
                                                                                        eap_sim_file_triplets_t *triplets)
 {
        private_eap_sim_file_provider_t *this = malloc_thing(private_eap_sim_file_provider_t);
-       
+
        this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *imsi, char rand[16], char sres[4], char kc[8]))get_triplet;
        this->public.destroy = (void(*)(eap_sim_file_provider_t*))destroy;
-       
+
        this->triplets = triplets;
-       
+
        return &this->public;
 }
 
index ec3bfb46950aa4f0e0bae3690736b2c5c7f2b1a1..72f29d51f9879c7149a516c391c3f4326d274b9a 100644 (file)
@@ -36,7 +36,7 @@ struct eap_sim_file_provider_t {
         * Implements sim_provider_t interface.
         */
        sim_provider_t provider;
-       
+
        /**
         * Destroy a eap_sim_file_provider_t.
         */
index e27ed68605f5559b1b61ee282300d8b2d52f9a53..b4686bf8f52d9c671a0ef13c4e4f9b666ae0159b 100644 (file)
@@ -28,17 +28,17 @@ typedef struct private_eap_sim_file_triplets_t private_eap_sim_file_triplets_t;
  * Private data of an eap_sim_file_triplets_t object.
  */
 struct private_eap_sim_file_triplets_t {
-       
+
        /**
         * Public eap_sim_file_triplets_t interface.
         */
        eap_sim_file_triplets_t public;
-       
+
        /**
         * List of triplets, as triplet_t
         */
        linked_list_t *triplets;
-       
+
        /**
         * mutex to lock triplets list
         */
@@ -103,7 +103,7 @@ static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **ims
                                                                 char **rand, char **sres, char **kc)
 {
        triplet_t *triplet;
-       
+
        if (e->inner->enumerate(e->inner, &triplet))
        {
                e->current = triplet;
@@ -123,14 +123,14 @@ static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **ims
 static enumerator_t* create_enumerator(private_eap_sim_file_triplets_t *this)
 {
        triplet_enumerator_t *enumerator = malloc_thing(triplet_enumerator_t);
-       
+
        this->mutex->lock(this->mutex);
        enumerator->public.enumerate = (void*)enumerator_enumerate;
        enumerator->public.destroy = (void*)enumerator_destroy;
        enumerator->inner = this->triplets->create_enumerator(this->triplets);
        enumerator->current = NULL;
        enumerator->this = this;
-       
+
        return &enumerator->public;
 }
 
@@ -140,7 +140,7 @@ static enumerator_t* create_enumerator(private_eap_sim_file_triplets_t *this)
 static void parse_token(char *to, char *from, size_t len)
 {
        chunk_t chunk;
-       
+
        chunk = chunk_create(from, min(strlen(from), len * 2));
        chunk = chunk_from_hex(chunk, NULL);
        memset(to, 0, len);
@@ -156,22 +156,22 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
        char line[512];
        FILE *file;
        int i, nr = 0;
-       
+
        file = fopen(path, "r");
        if (file == NULL)
        {
-               DBG1(DBG_CFG, "opening triplet file %s failed: %s", 
+               DBG1(DBG_CFG, "opening triplet file %s failed: %s",
                         path, strerror(errno));
                return;
        }
-       
+
        /* read line by line */
        while (fgets(line, sizeof(line), file))
        {
                triplet_t *triplet;
                enumerator_t *enumerator;
                char *token;
-               
+
                nr++;
                /* skip comments, empty lines */
                switch (line[0])
@@ -186,7 +186,7 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
                }
                triplet = malloc_thing(triplet_t);
                memset(triplet, 0, sizeof(triplet_t));
-               
+
                i = 0;
                enumerator = enumerator_create_token(line, ",", " \n\r#");
                while (enumerator->enumerate(enumerator, &token))
@@ -217,15 +217,15 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
                        triplet_destroy(triplet);
                        continue;
                }
-               
+
                DBG2(DBG_CFG, "triplet: imsi %Y\nrand %b\nsres %b\nkc %b",
                         triplet->imsi, triplet->rand, RAND_LEN,
                         triplet->sres, SRES_LEN, triplet->kc, KC_LEN);
-                        
+
                this->triplets->insert_last(this->triplets, triplet);
        }
        fclose(file);
-       
+
        DBG1(DBG_CFG, "read %d triplets from %s",
                 this->triplets->get_count(this->triplets), path);
 }
@@ -246,15 +246,15 @@ static void destroy(private_eap_sim_file_triplets_t *this)
 eap_sim_file_triplets_t *eap_sim_file_triplets_create(char *file)
 {
        private_eap_sim_file_triplets_t *this = malloc_thing(private_eap_sim_file_triplets_t);
-       
+
        this->public.create_enumerator = (enumerator_t*(*)(eap_sim_file_triplets_t*))create_enumerator;
        this->public.destroy = (void(*)(eap_sim_file_triplets_t*))destroy;
-       
+
        this->triplets = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
-       
+
        read_triplets(this, file);
-       
+
        return &this->public;
 }
 
index f0362c1a4ce374d4b9b3b5e69ca7a60be0d65cfa..0ae0beaef97e09058ad8ce85f916bb9d53e8c741 100644 (file)
@@ -78,7 +78,7 @@
 /** the prefix of the name of KLIPS ipsec devices */
 #define IPSEC_DEV_PREFIX "ipsec"
 /** this is the default number of ipsec devices */
-#define DEFAULT_IPSEC_DEV_COUNT 4 
+#define DEFAULT_IPSEC_DEV_COUNT 4
 /** TRUE if the given name matches an ipsec device */
 #define IS_IPSEC_DEV(name) (strneq((name), IPSEC_DEV_PREFIX, sizeof(IPSEC_DEV_PREFIX) - 1))
 
@@ -108,62 +108,62 @@ struct private_kernel_klips_ipsec_t
         * Public part of the kernel_klips_t object.
         */
        kernel_klips_ipsec_t public;
-       
+
        /**
         * mutex to lock access to various lists
         */
        mutex_t *mutex;
-       
+
        /**
         * List of installed policies (policy_entry_t)
         */
        linked_list_t *policies;
-       
+
        /**
         * List of allocated SPIs without installed SA (sa_entry_t)
         */
        linked_list_t *allocated_spis;
-       
+
        /**
         * List of installed SAs (sa_entry_t)
         */
        linked_list_t *installed_sas;
-       
+
        /**
         * whether to install routes along policies
         */
        bool install_routes;
-       
+
        /**
         * List of ipsec devices (ipsec_dev_t)
         */
        linked_list_t *ipsec_devices;
-       
+
        /**
         * job receiving PF_KEY events
         */
        callback_job_t *job;
-       
+
        /**
         * mutex to lock access to the PF_KEY socket
         */
        mutex_t *mutex_pfkey;
-       
+
        /**
         * PF_KEY socket to communicate with the kernel
         */
        int socket;
-       
+
        /**
         * PF_KEY socket to receive acquire and expire events
         */
        int socket_events;
-       
+
        /**
         * sequence number for messages sent to the kernel
         */
        int seq;
-       
+
 };
 
 
@@ -175,10 +175,10 @@ typedef struct ipsec_dev_t ipsec_dev_t;
 struct ipsec_dev_t {
        /** name of the virtual ipsec interface */
        char name[IFNAMSIZ];
-       
+
        /** name of the physical interface */
        char phys_name[IFNAMSIZ];
-       
+
        /** by how many CHILD_SA's this ipsec device is used */
        u_int refcount;
 };
@@ -229,14 +229,14 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
        struct ipsectunnelconf *itc = (struct ipsectunnelconf*)&req.ifr_data;
        short phys_flags;
        int mtu;
-       
+
        DBG2(DBG_KNL, "attaching virtual interface %s to %s", name, phys_name);
-       
+
        if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) <= 0)
        {
                return FAILED;
        }
-       
+
        strncpy(req.ifr_name, phys_name, IFNAMSIZ);
        if (ioctl(sock, SIOCGIFFLAGS, &req) < 0)
        {
@@ -251,18 +251,18 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
                close(sock);
                return FAILED;
        }
-       
+
        if (req.ifr_flags & IFF_UP)
        {
                /* if it's already up, it is already attached, detach it first */
                ioctl(sock, IPSEC_DEL_DEV, &req);
        }
-       
+
        /* attach it */
        strncpy(req.ifr_name, name, IFNAMSIZ);
        strncpy(itc->cf_name, phys_name, sizeof(itc->cf_name));
        ioctl(sock, IPSEC_SET_DEV, &req);
-       
+
        /* copy address from physical to virtual */
        strncpy(req.ifr_name, phys_name, IFNAMSIZ);
        if (ioctl(sock, SIOCGIFADDR, &req) == 0)
@@ -270,7 +270,7 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
                strncpy(req.ifr_name, name, IFNAMSIZ);
                ioctl(sock, SIOCSIFADDR, &req);
        }
-       
+
        /* copy net mask from physical to virtual */
        strncpy(req.ifr_name, phys_name, IFNAMSIZ);
        if (ioctl(sock, SIOCGIFNETMASK, &req) == 0)
@@ -278,7 +278,7 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
                strncpy(req.ifr_name, name, IFNAMSIZ);
                ioctl(sock, SIOCSIFNETMASK, &req);
        }
-       
+
        /* copy other flags and addresses */
        strncpy(req.ifr_name, name, IFNAMSIZ);
        if (ioctl(sock, SIOCGIFFLAGS, &req) == 0)
@@ -288,7 +288,7 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
                        req.ifr_flags |= IFF_POINTOPOINT;
                        req.ifr_flags &= ~IFF_BROADCAST;
                        ioctl(sock, SIOCSIFFLAGS, &req);
-                       
+
                        strncpy(req.ifr_name, phys_name, IFNAMSIZ);
                        if (ioctl(sock, SIOCGIFDSTADDR, &req) == 0)
                        {
@@ -301,7 +301,7 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
                        req.ifr_flags &= ~IFF_POINTOPOINT;
                        req.ifr_flags |= IFF_BROADCAST;
                        ioctl(sock, SIOCSIFFLAGS, &req);
-                       
+
                        strncpy(req.ifr_name, phys_name, IFNAMSIZ);
                        if (ioctl(sock, SIOCGIFBRDADDR, &req)==0)
                        {
@@ -324,7 +324,7 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
                /* guess MTU as physical MTU - ESP overhead [- NAT-T overhead]
                 * ESP overhead      : 73 bytes
                 * NAT-T overhead    :  8 bytes ==> 81 bytes
-                * 
+                *
                 * assuming tunnel mode with AES encryption and integrity
                 * outer IP header  : 20 bytes
                 * (NAT-T UDP header:  8 bytes)
@@ -338,19 +338,19 @@ static status_t attach_ipsec_dev(char* name, char *phys_name)
                ioctl(sock, SIOCGIFMTU, &req);
                mtu = req.ifr_mtu - 81;
        }
-       
+
        /* set MTU */
        strncpy(req.ifr_name, name, IFNAMSIZ);
        req.ifr_mtu = mtu;
        ioctl(sock, SIOCSIFMTU, &req);
-       
+
        /* bring ipsec device UP */
        if (ioctl(sock, SIOCGIFFLAGS, &req) == 0)
        {
                req.ifr_flags |= IFF_UP;
                ioctl(sock, SIOCSIFFLAGS, &req);
        }
-       
+
        close(sock);
        return SUCCESS;
 }
@@ -362,37 +362,37 @@ static status_t detach_ipsec_dev(char* name, char *phys_name)
 {
        int sock;
        struct ifreq req;
-       
+
        DBG2(DBG_KNL, "detaching virtual interface %s from %s", name,
                        strlen(phys_name) ? phys_name : "any physical interface");
-       
+
        if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) <= 0)
        {
                return FAILED;
        }
-       
+
        strncpy(req.ifr_name, name, IFNAMSIZ);
        if (ioctl(sock, SIOCGIFFLAGS, &req) < 0)
        {
                close(sock);
                return FAILED;
        }
-       
+
        /* shutting interface down */
        if (req.ifr_flags & IFF_UP)
        {
                req.ifr_flags &= ~IFF_UP;
                ioctl(sock, SIOCSIFFLAGS, &req);
        }
-       
+
        /* unset address */
        memset(&req.ifr_addr, 0, sizeof(req.ifr_addr));
        req.ifr_addr.sa_family = AF_INET;
        ioctl(sock, SIOCSIFADDR, &req);
-       
+
        /* detach interface */
        ioctl(sock, IPSEC_DEL_DEV, &req);
-       
+
        close(sock);
        return SUCCESS;
 }
@@ -415,10 +415,10 @@ typedef struct route_entry_t route_entry_t;
 struct route_entry_t {
        /** Name of the interface the route is bound to */
        char *if_name;
-       
+
        /** Source ip of the route */
        host_t *src_ip;
-       
+
        /** Gateway for this route */
        host_t *gateway;
 
@@ -447,13 +447,13 @@ typedef struct policy_entry_t policy_entry_t;
  * installed kernel policy.
  */
 struct policy_entry_t {
-       
+
        /** reqid of this policy, if setup as trap */
        u_int32_t reqid;
-       
+
        /** direction of this policy: in, out, forward */
        u_int8_t direction;
-       
+
        /** parameters of installed policy */
        struct {
                /** subnet and port */
@@ -463,13 +463,13 @@ struct policy_entry_t {
                /** protocol */
                u_int8_t proto;
        } src, dst;
-       
+
        /** associated route installed for this policy */
        route_entry_t *route;
-       
+
        /** by how many CHILD_SA's this policy is actively used */
        u_int activecount;
-       
+
        /** by how many CHILD_SA's this policy is trapped */
        u_int trapcount;
 };
@@ -499,22 +499,22 @@ static bool is_host_in_net(host_t *host, host_t *net, u_int8_t mask)
        static const u_char bitmask[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe };
        chunk_t host_chunk, net_chunk;
        int bytes = mask / 8, bits = mask % 8;
-       
+
        host_chunk = host->get_address(host);
        net_chunk = net->get_address(net);
-       
+
        if (host_chunk.len != net_chunk.len)
        {
                return FALSE;
        }
-       
+
        if (memeq(host_chunk.ptr, net_chunk.ptr, bytes))
        {
                return (bits == 0) ||
-                          (host_chunk.ptr[bytes] & bitmask[bits]) == 
+                          (host_chunk.ptr[bytes] & bitmask[bits]) ==
                                   (net_chunk.ptr[bytes] & bitmask[bits]);
        }
-       
+
        return FALSE;
 }
 
@@ -530,15 +530,15 @@ static policy_entry_t *create_policy_entry(traffic_selector_t *src_ts,
        policy->route = NULL;
        policy->activecount = 0;
        policy->trapcount = 0;
-       
+
        src_ts->to_subnet(src_ts, &policy->src.net, &policy->src.mask);
        dst_ts->to_subnet(dst_ts, &policy->dst.net, &policy->dst.mask);
-       
+
        /* src or dest proto may be "any" (0), use more restrictive one */
        policy->src.proto = max(src_ts->get_protocol(src_ts), dst_ts->get_protocol(dst_ts));
-       policy->src.proto = policy->src.proto ? policy->src.proto : 0; 
+       policy->src.proto = policy->src.proto ? policy->src.proto : 0;
        policy->dst.proto = policy->src.proto;
-       
+
        return policy;
 }
 
@@ -585,25 +585,25 @@ typedef struct sa_entry_t sa_entry_t;
  * - installed inbound SAs with enabled UDP encapsulation
  */
 struct sa_entry_t {
-       
+
        /** protocol of this SA */
        protocol_id_t protocol;
-       
+
        /** reqid of this SA */
        u_int32_t reqid;
-       
+
        /** SPI of this SA */
        u_int32_t spi;
-       
+
        /** src address of this SA */
        host_t *src;
-       
+
        /** dst address of this SA */
        host_t *dst;
-       
+
        /** TRUE if this SA uses UDP encapsulation */
        bool encap;
-       
+
        /** TRUE if this SA is inbound */
        bool inbound;
 };
@@ -672,8 +672,8 @@ struct pfkey_msg_t
         * PF_KEY message base
         */
        struct sadb_msg *msg;
-       
-       
+
+
        /**
         * PF_KEY message extensions
         */
@@ -761,7 +761,7 @@ struct kernel_algorithm_t {
         * Identifier specified in IKEv2
         */
        int ikev2;
-       
+
        /**
         * Identifier as defined in pfkeyv2.h
         */
@@ -884,7 +884,7 @@ static void add_encap_ext(struct sadb_msg *msg, host_t *src, host_t *dst,
 {
        struct sadb_x_nat_t_type* nat_type;
        struct sadb_x_nat_t_port* nat_port;
-       
+
        if (!ports_only)
        {
                nat_type = (struct sadb_x_nat_t_type*)PFKEY_EXT_ADD_NEXT(msg);
@@ -893,13 +893,13 @@ static void add_encap_ext(struct sadb_msg *msg, host_t *src, host_t *dst,
                nat_type->sadb_x_nat_t_type_type = UDP_ENCAP_ESPINUDP;
                PFKEY_EXT_ADD(msg, nat_type);
        }
-       
+
        nat_port = (struct sadb_x_nat_t_port*)PFKEY_EXT_ADD_NEXT(msg);
        nat_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_SPORT;
        nat_port->sadb_x_nat_t_port_len = PFKEY_LEN(sizeof(struct sadb_x_nat_t_port));
        nat_port->sadb_x_nat_t_port_port = src->get_port(src);
        PFKEY_EXT_ADD(msg, nat_port);
-       
+
        nat_port = (struct sadb_x_nat_t_port*)PFKEY_EXT_ADD_NEXT(msg);
        nat_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_DPORT;
        nat_port->sadb_x_nat_t_port_len = PFKEY_LEN(sizeof(struct sadb_x_nat_t_port));
@@ -917,19 +917,19 @@ static void build_addflow(struct sadb_msg *msg, u_int8_t satype, u_int32_t spi,
        struct sadb_sa *sa;
        struct sadb_protocol *proto;
        host_t *host;
-       
+
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_X_ADDFLOW;
        msg->sadb_msg_satype = satype;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_spi = spi;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_flags = replace ? SADB_X_SAFLAGS_REPLACEFLOW : 0;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        if (!src)
        {
                add_anyaddr_ext(msg, src_net->get_family(src_net), SADB_EXT_ADDRESS_SRC);
@@ -938,7 +938,7 @@ static void build_addflow(struct sadb_msg *msg, u_int8_t satype, u_int32_t spi,
        {
                add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC);
        }
-       
+
        if (!dst)
        {
                add_anyaddr_ext(msg, dst_net->get_family(dst_net), SADB_EXT_ADDRESS_DST);
@@ -947,18 +947,18 @@ static void build_addflow(struct sadb_msg *msg, u_int8_t satype, u_int32_t spi,
        {
                add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST);
        }
-       
+
        add_addr_ext(msg, src_net, SADB_X_EXT_ADDRESS_SRC_FLOW);
        add_addr_ext(msg, dst_net, SADB_X_EXT_ADDRESS_DST_FLOW);
-       
+
        host = mask2host(src_net->get_family(src_net), src_mask);
        add_addr_ext(msg, host, SADB_X_EXT_ADDRESS_SRC_MASK);
        host->destroy(host);
-       
+
        host = mask2host(dst_net->get_family(dst_net), dst_mask);
        add_addr_ext(msg, host, SADB_X_EXT_ADDRESS_DST_MASK);
        host->destroy(host);
-       
+
        proto = (struct sadb_protocol*)PFKEY_EXT_ADD_NEXT(msg);
        proto->sadb_protocol_exttype = SADB_X_EXT_PROTOCOL;
        proto->sadb_protocol_len = PFKEY_LEN(sizeof(struct sadb_protocol));
@@ -975,25 +975,25 @@ static void build_delflow(struct sadb_msg *msg, u_int8_t satype,
 {
        struct sadb_protocol *proto;
        host_t *host;
-       
+
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_X_DELFLOW;
        msg->sadb_msg_satype = satype;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        add_addr_ext(msg, src_net, SADB_X_EXT_ADDRESS_SRC_FLOW);
        add_addr_ext(msg, dst_net, SADB_X_EXT_ADDRESS_DST_FLOW);
-       
+
        host = mask2host(src_net->get_family(src_net),
                                         src_mask);
        add_addr_ext(msg, host, SADB_X_EXT_ADDRESS_SRC_MASK);
        host->destroy(host);
-       
+
        host = mask2host(dst_net->get_family(dst_net),
                                         dst_mask);
        add_addr_ext(msg, host, SADB_X_EXT_ADDRESS_DST_MASK);
        host->destroy(host);
-       
+
        proto = (struct sadb_protocol*)PFKEY_EXT_ADD_NEXT(msg);
        proto->sadb_protocol_exttype = SADB_X_EXT_PROTOCOL;
        proto->sadb_protocol_len = PFKEY_LEN(sizeof(struct sadb_protocol));
@@ -1008,15 +1008,15 @@ static status_t parse_pfkey_message(struct sadb_msg *msg, pfkey_msg_t *out)
 {
        struct sadb_ext* ext;
        size_t len;
-       
+
        memset(out, 0, sizeof(pfkey_msg_t));
        out->msg = msg;
-       
+
        len = msg->sadb_msg_len;
        len -= PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        ext = (struct sadb_ext*)(((char*)msg) + sizeof(struct sadb_msg));
-       
+
        while (len >= PFKEY_LEN(sizeof(struct sadb_ext)))
        {
                if (ext->sadb_ext_len < PFKEY_LEN(sizeof(struct sadb_ext)) ||
@@ -1025,19 +1025,19 @@ static status_t parse_pfkey_message(struct sadb_msg *msg, pfkey_msg_t *out)
                        DBG1(DBG_KNL, "length of PF_KEY extension (%d) is invalid", ext->sadb_ext_type);
                        break;
                }
-               
+
                if ((ext->sadb_ext_type > SADB_EXT_MAX) || (!ext->sadb_ext_type))
                {
                        DBG1(DBG_KNL, "type of PF_KEY extension (%d) is invalid", ext->sadb_ext_type);
                        break;
                }
-               
+
                if (out->ext[ext->sadb_ext_type])
                {
-                       DBG1(DBG_KNL, "duplicate PF_KEY extension of type (%d)", ext->sadb_ext_type);                   
+                       DBG1(DBG_KNL, "duplicate PF_KEY extension of type (%d)", ext->sadb_ext_type);
                        break;
                }
-               
+
                out->ext[ext->sadb_ext_type] = ext;
                ext = PFKEY_EXT_NEXT_LEN(ext, len);
        }
@@ -1047,7 +1047,7 @@ static status_t parse_pfkey_message(struct sadb_msg *msg, pfkey_msg_t *out)
                DBG1(DBG_KNL, "PF_KEY message length is invalid");
                return FAILED;
        }
-       
+
        return SUCCESS;
 }
 
@@ -1060,7 +1060,7 @@ static status_t pfkey_send_socket(private_kernel_klips_ipsec_t *this, int socket
        unsigned char buf[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg;
        int in_len, len;
-       
+
        this->mutex_pfkey->lock(this->mutex_pfkey);
 
        in->sadb_msg_seq = ++this->seq;
@@ -1093,13 +1093,13 @@ static status_t pfkey_send_socket(private_kernel_klips_ipsec_t *this, int socket
                }
                break;
        }
-       
+
        while (TRUE)
-       {       
+       {
                msg = (struct sadb_msg*)buf;
-               
+
                len = recv(socket, buf, sizeof(buf), 0);
-               
+
                if (len < 0)
                {
                        if (errno == EINTR)
@@ -1149,13 +1149,13 @@ static status_t pfkey_send_socket(private_kernel_klips_ipsec_t *this, int socket
                }
                break;
        }
-       
+
        *out_len = len;
        *out = (struct sadb_msg*)malloc(len);
        memcpy(*out, buf, len);
-               
+
        this->mutex_pfkey->unlock(this->mutex_pfkey);
-       
+
        return SUCCESS;
 }
 
@@ -1175,7 +1175,7 @@ static status_t pfkey_send_ack(private_kernel_klips_ipsec_t *this, struct sadb_m
 {
        struct sadb_msg *out;
        size_t len;
-       
+
        if (pfkey_send(this, in, &out, &len) != SUCCESS)
        {
                return FAILED;
@@ -1200,12 +1200,12 @@ static status_t add_eroute(private_kernel_klips_ipsec_t *this, u_int8_t satype,
 {
        unsigned char request[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg = (struct sadb_msg*)request;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        build_addflow(msg, satype, spi, src, dst, src_net, src_mask,
                        dst_net, dst_mask, protocol, replace);
-       
+
        return pfkey_send_ack(this, msg);
 }
 
@@ -1218,11 +1218,11 @@ static status_t del_eroute(private_kernel_klips_ipsec_t *this, u_int8_t satype,
 {
        unsigned char request[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg = (struct sadb_msg*)request;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        build_delflow(msg, satype, src_net, src_mask, dst_net, dst_mask, protocol);
-       
+
        return pfkey_send_ack(this, msg);
 }
 
@@ -1237,7 +1237,7 @@ static void process_acquire(private_kernel_klips_ipsec_t *this, struct sadb_msg*
        u_int8_t proto;
        policy_entry_t *policy;
        job_t *job;
-       
+
        switch (msg->sadb_msg_satype)
        {
                case SADB_SATYPE_UNSPEC:
@@ -1248,13 +1248,13 @@ static void process_acquire(private_kernel_klips_ipsec_t *this, struct sadb_msg*
                        /* acquire for AH/ESP only */
                        return;
        }
-       
+
        if (parse_pfkey_message(msg, &response) != SUCCESS)
        {
                DBG1(DBG_KNL, "parsing SADB_ACQUIRE from kernel failed");
                return;
        }
-       
+
        /* KLIPS provides us only with the source and destination address,
         * and the transport protocol of the packet that triggered the policy.
         * we use this information to find a matching policy in our cache.
@@ -1269,7 +1269,7 @@ static void process_acquire(private_kernel_klips_ipsec_t *this, struct sadb_msg*
                DBG1(DBG_KNL, "received an SADB_ACQUIRE with invalid hosts");
                return;
        }
-       
+
        DBG2(DBG_KNL, "received an SADB_ACQUIRE for %H == %H : %d", src, dst, proto);
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -1286,17 +1286,17 @@ static void process_acquire(private_kernel_klips_ipsec_t *this, struct sadb_msg*
                DBG1(DBG_KNL, "received an SADB_ACQUIRE, but policy is not routed anymore");
                return;
        }
-       
+
        /* add a broad %hold eroute that replaces the %trap eroute */
        add_eroute(this, SADB_X_SATYPE_INT, htonl(SPI_HOLD), NULL, NULL,
                        policy->src.net, policy->src.mask, policy->dst.net, policy->dst.mask,
                        policy->src.proto, TRUE);
-       
+
        /* remove the narrow %hold eroute installed by KLIPS */
        del_eroute(this, SADB_X_SATYPE_INT, src, 32, dst, 32, proto);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        DBG2(DBG_KNL, "received an SADB_ACQUIRE");
        DBG1(DBG_KNL, "creating acquire job for CHILD_SA with reqid {%d}", reqid);
        job = (job_t*)acquire_job_create(reqid, NULL, NULL);
@@ -1312,23 +1312,23 @@ static void process_mapping(private_kernel_klips_ipsec_t *this, struct sadb_msg*
        u_int32_t spi, reqid;
        host_t *old_src, *new_src;
        job_t *job;
-       
+
        DBG2(DBG_KNL, "received an SADB_X_NAT_T_NEW_MAPPING");
-       
+
        if (parse_pfkey_message(msg, &response) != SUCCESS)
        {
                DBG1(DBG_KNL, "parsing SADB_X_NAT_T_NEW_MAPPING from kernel failed");
                return;
        }
-       
+
        spi = response.sa->sadb_sa_spi;
-       
+
        if (proto_satype2ike(msg->sadb_msg_satype) == PROTO_ESP)
        {
                sa_entry_t *sa;
                sockaddr_t *addr = (sockaddr_t*)(response.src + 1);
                old_src = host_create_from_sockaddr(addr);
-               
+
                this->mutex->lock(this->mutex);
                if (!old_src || this->installed_sas->find_first(this->installed_sas,
                                (linked_list_match_t)sa_entry_match_encapbysrc,
@@ -1340,7 +1340,7 @@ static void process_mapping(private_kernel_klips_ipsec_t *this, struct sadb_msg*
                }
                reqid = sa->reqid;
                this->mutex->unlock(this->mutex);
-               
+
                addr = (sockaddr_t*)(response.dst + 1);
                switch (addr->sa_family)
                {
@@ -1352,7 +1352,7 @@ static void process_mapping(private_kernel_klips_ipsec_t *this, struct sadb_msg*
                        case AF_INET6:
                        {
                                struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)addr;
-                               sin6->sin6_port = htons(response.x_natt_dport->sadb_x_nat_t_port_port);                         
+                               sin6->sin6_port = htons(response.x_natt_dport->sadb_x_nat_t_port_port);
                        }
                        default:
                                break;
@@ -1376,11 +1376,11 @@ static job_requeue_t receive_events(private_kernel_klips_ipsec_t *this)
        unsigned char buf[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg = (struct sadb_msg*)buf;
        int len, oldstate;
-       
+
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        len = recv(this->socket_events, buf, sizeof(buf), 0);
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (len < 0)
        {
                switch (errno)
@@ -1397,7 +1397,7 @@ static job_requeue_t receive_events(private_kernel_klips_ipsec_t *this)
                                return JOB_REQUEUE_FAIR;
                }
        }
-       
+
        if (len < sizeof(struct sadb_msg) ||
                msg->sadb_msg_len < PFKEY_LEN(sizeof(struct sadb_msg)))
        {
@@ -1413,7 +1413,7 @@ static job_requeue_t receive_events(private_kernel_klips_ipsec_t *this)
                DBG1(DBG_KNL, "buffer was too small to receive the complete PF_KEY message");
                return JOB_REQUEUE_DIRECT;
        }
-       
+
        switch (msg->sadb_msg_type)
        {
                case SADB_ACQUIRE:
@@ -1433,7 +1433,7 @@ static job_requeue_t receive_events(private_kernel_klips_ipsec_t *this)
                default:
                        break;
        }
-       
+
        return JOB_REQUEUE_DIRECT;
 }
 
@@ -1473,11 +1473,11 @@ static job_requeue_t sa_expires(sa_expire_t *expire)
        sa_entry_t *cached_sa;
        linked_list_t *list;
        job_t *job;
-       
+
        /* for an expired SPI we first check whether the CHILD_SA got installed
         * in the meantime, for expired SAs we check whether they are still installed */
        list = expire->type == EXPIRE_TYPE_SPI ? this->allocated_spis : this->installed_sas;
-       
+
        this->mutex->lock(this->mutex);
        if (list->find_first(list, (linked_list_match_t)sa_entry_match_byid,
                        (void**)&cached_sa, &protocol, &spi, &reqid) != SUCCESS)
@@ -1494,10 +1494,10 @@ static job_requeue_t sa_expires(sa_expire_t *expire)
                sa_entry_destroy(cached_sa);
        }
        this->mutex->unlock(this->mutex);
-       
+
        DBG2(DBG_KNL, "%N CHILD_SA with SPI %.8x and reqid {%d} expired",
                        protocol_id_names, protocol, ntohl(spi), reqid);
-       
+
        DBG1(DBG_KNL, "creating %s job for %N CHILD_SA with SPI %.8x and reqid {%d}",
                 hard ? "delete" : "rekey",  protocol_id_names,
                 protocol, ntohl(spi), reqid);
@@ -1514,7 +1514,7 @@ static job_requeue_t sa_expires(sa_expire_t *expire)
 }
 
 /**
- * Schedule an expire job for an SA. Time is in seconds. 
+ * Schedule an expire job for an SA. Time is in seconds.
  */
 static void schedule_expire(private_kernel_klips_ipsec_t *this,
                                                        protocol_id_t protocol, u_int32_t spi,
@@ -1534,8 +1534,8 @@ static void schedule_expire(private_kernel_klips_ipsec_t *this,
 /**
  * Implementation of kernel_interface_t.get_spi.
  */
-static status_t get_spi(private_kernel_klips_ipsec_t *this, 
-                                               host_t *src, host_t *dst, 
+static status_t get_spi(private_kernel_klips_ipsec_t *this,
+                                               host_t *src, host_t *dst,
                                                protocol_id_t protocol, u_int32_t reqid,
                                                u_int32_t *spi)
 {
@@ -1545,7 +1545,7 @@ static status_t get_spi(private_kernel_klips_ipsec_t *this,
         */
        rng_t *rng;
        u_int32_t spi_gen;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
        {
@@ -1554,29 +1554,29 @@ static status_t get_spi(private_kernel_klips_ipsec_t *this,
        }
        rng->get_bytes(rng, sizeof(spi_gen), (void*)&spi_gen);
        rng->destroy(rng);
-       
+
        /* charon's SPIs lie within the range from 0xc0000000 to 0xcFFFFFFF */
        spi_gen = 0xc0000000 | (spi_gen & 0x0FFFFFFF);
-       
+
        DBG2(DBG_KNL, "allocated SPI %.8x for %N SA between %#H..%#H",
                        spi_gen, protocol_id_names, protocol, src, dst);
-       
+
        *spi = htonl(spi_gen);
-       
+
        this->mutex->lock(this->mutex);
        this->allocated_spis->insert_last(this->allocated_spis,
                        create_sa_entry(protocol, *spi, reqid, NULL, NULL, FALSE, TRUE));
        this->mutex->unlock(this->mutex);
        schedule_expire(this, protocol, *spi, reqid, EXPIRE_TYPE_SPI, SPI_TIMEOUT);
-       
+
        return SUCCESS;
 }
 
 /**
  * Implementation of kernel_interface_t.get_cpi.
  */
-static status_t get_cpi(private_kernel_klips_ipsec_t *this, 
-                                               host_t *src, host_t *dst, 
+static status_t get_cpi(private_kernel_klips_ipsec_t *this,
+                                               host_t *src, host_t *dst,
                                                u_int32_t reqid, u_int16_t *cpi)
 {
        return FAILED;
@@ -1592,27 +1592,27 @@ static status_t add_ipip_sa(private_kernel_klips_ipsec_t *this,
        struct sadb_msg *msg, *out;
        struct sadb_sa *sa;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "adding pseudo IPIP SA with SPI %.8x and reqid {%d}", ntohl(spi), reqid);
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_ADD;
        msg->sadb_msg_satype = SADB_X_SATYPE_IPIP;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_spi = spi;
        sa->sadb_sa_state = SADB_SASTATE_MATURE;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to add pseudo IPIP SA with SPI %.8x", ntohl(spi));
@@ -1625,7 +1625,7 @@ static status_t add_ipip_sa(private_kernel_klips_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        free(out);
        return SUCCESS;
 }
@@ -1642,41 +1642,41 @@ static status_t group_ipip_sa(private_kernel_klips_ipsec_t *this,
        struct sadb_sa *sa;
        struct sadb_x_satype *satype;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "grouping SAs with SPI %.8x and reqid {%d}", ntohl(spi), reqid);
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_X_GRPSA;
        msg->sadb_msg_satype = SADB_X_SATYPE_IPIP;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_spi = spi;
        sa->sadb_sa_state = SADB_SASTATE_MATURE;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST);
-       
+
        satype = (struct sadb_x_satype*)PFKEY_EXT_ADD_NEXT(msg);
        satype->sadb_x_satype_exttype = SADB_X_EXT_SATYPE2;
        satype->sadb_x_satype_len = PFKEY_LEN(sizeof(struct sadb_x_satype));
        satype->sadb_x_satype_satype = proto_ike2satype(protocol);
        PFKEY_EXT_ADD(msg, satype);
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_X_EXT_SA2;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_spi = spi;
        sa->sadb_sa_state = SADB_SASTATE_MATURE;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        add_addr_ext(msg, dst, SADB_X_EXT_ADDRESS_DST2);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to group SAs with SPI %.8x", ntohl(spi));
@@ -1689,7 +1689,7 @@ static status_t group_ipip_sa(private_kernel_klips_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        free(out);
        return SUCCESS;
 }
@@ -1711,7 +1711,7 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
        struct sadb_sa *sa;
        struct sadb_key *key;
        size_t len;
-       
+
        if (inbound)
        {
                /* for inbound SAs we allocated an SPI via get_spi, so we first check
@@ -1733,17 +1733,17 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
                }
                this->mutex->unlock(this->mutex);
        }
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "adding SAD entry with SPI %.8x and reqid {%d}", ntohl(spi), reqid);
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_ADD;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
@@ -1753,10 +1753,10 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
        sa->sadb_sa_auth = lookup_algorithm(integrity_algs, int_alg);
        sa->sadb_sa_encrypt = lookup_algorithm(encryption_algs, enc_alg);
        PFKEY_EXT_ADD(msg, sa);
-       
+
        add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST);
-       
+
        if (enc_alg != ENCR_UNDEFINED)
        {
                if (!sa->sadb_sa_encrypt)
@@ -1767,16 +1767,16 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
                }
                DBG2(DBG_KNL, "  using encryption algorithm %N with key size %d",
                         encryption_algorithm_names, enc_alg, enc_key.len * 8);
-               
+
                key = (struct sadb_key*)PFKEY_EXT_ADD_NEXT(msg);
                key->sadb_key_exttype = SADB_EXT_KEY_ENCRYPT;
                key->sadb_key_bits = enc_key.len * 8;
                key->sadb_key_len = PFKEY_LEN(sizeof(struct sadb_key) + enc_key.len);
                memcpy(key + 1, enc_key.ptr, enc_key.len);
-               
+
                PFKEY_EXT_ADD(msg, key);
        }
-       
+
        if (int_alg != AUTH_UNDEFINED)
        {
                if (!sa->sadb_sa_auth)
@@ -1787,26 +1787,26 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
                }
                DBG2(DBG_KNL, "  using integrity algorithm %N with key size %d",
                         integrity_algorithm_names, int_alg, int_key.len * 8);
-               
+
                key = (struct sadb_key*)PFKEY_EXT_ADD_NEXT(msg);
                key->sadb_key_exttype = SADB_EXT_KEY_AUTH;
                key->sadb_key_bits = int_key.len * 8;
                key->sadb_key_len = PFKEY_LEN(sizeof(struct sadb_key) + int_key.len);
                memcpy(key + 1, int_key.ptr, int_key.len);
-               
+
                PFKEY_EXT_ADD(msg, key);
        }
-       
+
        if (ipcomp != IPCOMP_NONE)
        {
                /*TODO*/
        }
-       
+
        if (encap)
        {
                add_encap_ext(msg, src, dst, FALSE);
        }
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to add SAD entry with SPI %.8x", ntohl(spi));
@@ -1820,7 +1820,7 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
                return FAILED;
        }
        free(out);
-       
+
        /* for tunnel mode SAs we have to install an additional IPIP SA and
         * group the two SAs together */
        if (mode == MODE_TUNNEL)
@@ -1832,7 +1832,7 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
                        return FAILED;
                }
        }
-       
+
        this->mutex->lock(this->mutex);
        /* we cache this SA for two reasons:
         * - in case an SADB_X_NAT_T_MAPPING_NEW event occurs (we need to find the reqid then)
@@ -1840,7 +1840,7 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
        this->installed_sas->insert_last(this->installed_sas,
                                create_sa_entry(protocol, spi, reqid, src, dst, encap, inbound));
        this->mutex->unlock(this->mutex);
-       
+
        /* Although KLIPS supports SADB_EXT_LIFETIME_SOFT/HARD, we handle the lifetime
         * of SAs manually in the plugin. Refer to the comments in receive_events()
         * for details. */
@@ -1848,12 +1848,12 @@ static status_t add_sa(private_kernel_klips_ipsec_t *this,
        {
                schedule_expire(this, protocol, spi, reqid, EXPIRE_TYPE_SOFT, lifetime->time.rekey);
        }
-       
+
        if (lifetime->time.life)
        {
                schedule_expire(this, protocol, spi, reqid, EXPIRE_TYPE_HARD, lifetime->time.life);
        }
-               
+
        return SUCCESS;
 }
 
@@ -1870,7 +1870,7 @@ static status_t update_sa(private_kernel_klips_ipsec_t *this,
        struct sadb_msg *msg, *out;
        struct sadb_sa *sa;
        size_t len;
-       
+
        /* we can't update the SA if any of the ip addresses have changed.
         * that's because we can't use SADB_UPDATE and by deleting and readding the
         * SA the sequence numbers would get lost */
@@ -1881,7 +1881,7 @@ static status_t update_sa(private_kernel_klips_ipsec_t *this,
                                " are not supported", ntohl(spi));
                return NOT_SUPPORTED;
        }
-       
+
        /* because KLIPS does not allow us to change the NAT-T type in an SADB_UPDATE,
         * we can't update the SA if the encap flag has changed since installing it */
        if (encap != new_encap)
@@ -1890,18 +1890,18 @@ static status_t update_sa(private_kernel_klips_ipsec_t *this,
                                " encapsulation is not supported", ntohl(spi));
                return NOT_SUPPORTED;
        }
-       
+
        DBG2(DBG_KNL, "updating SAD entry with SPI %.8x from %#H..%#H to %#H..%#H",
                 ntohl(spi), src, dst, new_src, new_dst);
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_UPDATE;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
@@ -1910,12 +1910,12 @@ static status_t update_sa(private_kernel_klips_ipsec_t *this,
        sa->sadb_sa_auth = SADB_AALG_SHA1HMAC; /* ignored */
        sa->sadb_sa_state = SADB_SASTATE_MATURE;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST);
-                       
+
        add_encap_ext(msg, new_src, new_dst, TRUE);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to update SAD entry with SPI %.8x", ntohl(spi));
@@ -1929,7 +1929,7 @@ static status_t update_sa(private_kernel_klips_ipsec_t *this,
                return FAILED;
        }
        free(out);
-       
+
        return SUCCESS;
 }
 
@@ -1955,13 +1955,13 @@ static status_t del_sa(private_kernel_klips_ipsec_t *this, host_t *src,
        struct sadb_sa *sa;
        sa_entry_t *cached_sa;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        /* all grouped SAs are automatically deleted by KLIPS as soon as
         * one of them is deleted, therefore we delete only the main one */
        DBG2(DBG_KNL, "deleting SAD entry with SPI %.8x", ntohl(spi));
-       
+
        this->mutex->lock(this->mutex);
        /* this should not fail, but we don't care if it does, let the kernel decide
         * whether this SA exists or not */
@@ -1973,24 +1973,24 @@ static status_t del_sa(private_kernel_klips_ipsec_t *this, host_t *src,
                sa_entry_destroy(cached_sa);
        }
        this->mutex->unlock(this->mutex);
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_DELETE;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_spi = spi;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        /* the kernel wants an SADB_EXT_ADDRESS_SRC to be present even though
         * it is not used for anything. */
        add_anyaddr_ext(msg, dst->get_family(dst), SADB_EXT_ADDRESS_SRC);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to delete SAD entry with SPI %.8x", ntohl(spi));
@@ -2003,7 +2003,7 @@ static status_t del_sa(private_kernel_klips_ipsec_t *this, host_t *src,
                free(out);
                return FAILED;
        }
-       
+
        DBG2(DBG_KNL, "deleted SAD entry with SPI %.8x", ntohl(spi));
        free(out);
        return SUCCESS;
@@ -2012,7 +2012,7 @@ static status_t del_sa(private_kernel_klips_ipsec_t *this, host_t *src,
 /**
  * Implementation of kernel_interface_t.add_policy.
  */
-static status_t add_policy(private_kernel_klips_ipsec_t *this, 
+static status_t add_policy(private_kernel_klips_ipsec_t *this,
                                                   host_t *src, host_t *dst,
                                                   traffic_selector_t *src_ts,
                                                   traffic_selector_t *dst_ts,
@@ -2025,21 +2025,21 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
        struct sadb_msg *msg, *out;
        policy_entry_t *policy, *found = NULL;
        u_int8_t satype;
-       size_t len;     
-       
+       size_t len;
+
        if (direction == POLICY_FWD)
        {
                /* no forward policies for KLIPS */
                return SUCCESS;
        }
-       
+
        /* tunnel mode policies direct the packets into the pseudo IPIP SA */
        satype = (mode == MODE_TUNNEL) ? SADB_X_SATYPE_IPIP :
                                                                         proto_ike2satype(protocol);
-       
+
        /* create a policy */
        policy = create_policy_entry(src_ts, dst_ts, direction);
-       
+
        /* find a matching policy */
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -2057,21 +2057,21 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
                /* apply the new one, if we have no such policy */
                this->policies->insert_last(this->policies, policy);
        }
-               
+
        if (routed)
        {
                /* we install this as a %trap eroute in the kernel, later to be
                 * triggered by packets matching the policy (-> ACQUIRE). */
                spi = htonl(SPI_TRAP);
                satype = SADB_X_SATYPE_INT;
-               
+
                /* the reqid is always set to the latest child SA that trapped this
                 * policy. we will need this reqid upon receiving an acquire. */
                policy->reqid = reqid;
-               
+
                /* increase the trap counter */
                policy->trapcount++;
-               
+
                if (policy->activecount)
                {
                        /* we do not replace the current policy in the kernel while a
@@ -2085,21 +2085,21 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
                /* increase the reference counter */
                policy->activecount++;
        }
-       
+
        DBG2(DBG_KNL, "adding policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
-       
+
        /* FIXME: SADB_X_SAFLAGS_INFLOW may be required, if we add an inbound policy for an IPIP SA */
        build_addflow(msg, satype, spi, routed ? NULL : src, routed ? NULL : dst,
                        policy->src.net, policy->src.mask, policy->dst.net, policy->dst.mask,
                        policy->src.proto, found != NULL);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to add policy %R === %R %N", src_ts, dst_ts,
@@ -2115,9 +2115,9 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
                return FAILED;
        }
        free(out);
-       
+
        this->mutex->lock(this->mutex);
-       
+
        /* we try to find the policy again and install the route if needed */
        if (this->policies->find_last(this->policies, NULL, (void**)&policy) != SUCCESS)
        {
@@ -2126,7 +2126,7 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
                                src_ts, dst_ts, policy_dir_names, direction);
                return SUCCESS;
        }
-       
+
        /* KLIPS requires a special route that directs traffic that matches this
         * policy to one of the virtual ipsec interfaces. The virtual interface
         * has to be attached to the physical one the traffic runs over.
@@ -2144,19 +2144,19 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
                ipsec_dev_t *dev;
                route_entry_t *route = malloc_thing(route_entry_t);
                route->src_ip = NULL;
-               
+
                if (mode != MODE_TRANSPORT && src->get_family(src) != AF_INET6 &&
                        this->install_routes)
                {
                        charon->kernel_interface->get_address_by_ts(charon->kernel_interface,
                                                src_ts, &route->src_ip);
                }
-               
+
                if (!route->src_ip)
                {
                        route->src_ip = host_create_any(src->get_family(src));
                }
-               
+
                /* find the virtual interface */
                iface = charon->kernel_interface->get_interface(charon->kernel_interface,
                                                                                                                src);
@@ -2203,13 +2203,13 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
                }
                free(iface);
                route->if_name = strdup(dev->name);
-               
+
                /* get the nexthop to dst */
                route->gateway = charon->kernel_interface->get_nexthop(
                                                                                charon->kernel_interface, dst);
                route->dst_net = chunk_clone(policy->dst.net->get_address(policy->dst.net));
                route->prefixlen = policy->dst.mask;
-               
+
                switch (charon->kernel_interface->add_route(charon->kernel_interface,
                                route->dst_net, route->prefixlen, route->gateway,
                                route->src_ip, route->if_name))
@@ -2227,10 +2227,10 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
                                policy->route = route;
                                break;
                }
-       }       
-       
-       this->mutex->unlock(this->mutex);       
-       
+       }
+
+       this->mutex->unlock(this->mutex);
+
        return SUCCESS;
 }
 
@@ -2238,7 +2238,7 @@ static status_t add_policy(private_kernel_klips_ipsec_t *this,
  * Implementation of kernel_interface_t.query_policy.
  */
 static status_t query_policy(private_kernel_klips_ipsec_t *this,
-                                                        traffic_selector_t *src_ts, 
+                                                        traffic_selector_t *src_ts,
                                                         traffic_selector_t *dst_ts,
                                                         policy_dir_t direction, u_int32_t *use_time)
 {
@@ -2250,19 +2250,19 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
        char *said = NULL, *pos;
        policy_entry_t *policy, *found = NULL;
        status_t status = FAILED;
-       
+
        if (direction == POLICY_FWD)
        {
                /* we do not install forward policies */
                return FAILED;
        }
-       
+
        DBG2(DBG_KNL, "querying policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
-       
+
        /* create a policy */
        policy = create_policy_entry(src_ts, dst_ts, direction);
-       
+
        /* find a matching policy */
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -2276,7 +2276,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
        }
        policy_entry_destroy(policy);
        policy = found;
-       
+
        /* src and dst selectors in KLIPS are of the form NET_ADDR/NETBITS:PROTO */
        snprintf(src, sizeof(src), "%H/%d:%d", policy->src.net, policy->src.mask,
                        policy->src.proto);
@@ -2284,9 +2284,9 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
        snprintf(dst, sizeof(dst), "%H/%d:%d", policy->dst.net, policy->dst.mask,
                        policy->dst.proto);
        dst[sizeof(dst) - 1] = '\0';
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        /* we try to find the matching eroute first */
        file = fopen(path_eroute, "r");
        if (file == NULL)
@@ -2295,7 +2295,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
                                dst_ts, policy_dir_names, direction, strerror(errno), errno);
                return FAILED;
        }
-       
+
        /* read line by line where each line looks like:
         * packets  src  ->  dst  =>  said */
        while (fgets(line, sizeof(line), file))
@@ -2303,7 +2303,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
                enumerator_t *enumerator;
                char *token;
                int i = 0;
-               
+
                enumerator = enumerator_create_token(line, " \t", " \t\n");
                while (enumerator->enumerate(enumerator, &token))
                {
@@ -2334,7 +2334,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
                        break;
                }
                enumerator->destroy(enumerator);
-               
+
                if (i == 5)
                {
                        /* eroute matched */
@@ -2342,19 +2342,19 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
                }
        }
        fclose(file);
-       
+
        if (said == NULL)
        {
                DBG1(DBG_KNL, "unable to query policy %R === %R %N: found no matching"
                                " eroute", src_ts, dst_ts, policy_dir_names, direction);
                return FAILED;
        }
-       
+
        /* compared with the one in the spi entry the SA ID from the eroute entry
         * has an additional ":PROTO" appended, which we need to cut off */
        pos = strrchr(said, ':');
        *pos = '\0';
-       
+
        /* now we try to find the matching spi entry */
        file = fopen(path_spi, "r");
        if (file == NULL)
@@ -2363,7 +2363,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
                                dst_ts, policy_dir_names, direction, strerror(errno), errno);
                return FAILED;
        }
-       
+
        while (fgets(line, sizeof(line), file))
        {
                if (strneq(line, said, strlen(said)))
@@ -2381,7 +2381,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
                                /* idle time not valid */
                                break;
                        }
-                       
+
                        *use_time = time_monotonic(NULL) - idle_time;
                        status = SUCCESS;
                        break;
@@ -2389,7 +2389,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
        }
        fclose(file);
        free(said);
-       
+
        return status;
 }
 
@@ -2397,7 +2397,7 @@ static status_t query_policy(private_kernel_klips_ipsec_t *this,
  * Implementation of kernel_interface_t.del_policy.
  */
 static status_t del_policy(private_kernel_klips_ipsec_t *this,
-                                                  traffic_selector_t *src_ts, 
+                                                  traffic_selector_t *src_ts,
                                                   traffic_selector_t *dst_ts,
                                                   policy_dir_t direction, bool unrouted)
 {
@@ -2406,19 +2406,19 @@ static status_t del_policy(private_kernel_klips_ipsec_t *this,
        policy_entry_t *policy, *found = NULL;
        route_entry_t *route;
        size_t len;
-       
+
        if (direction == POLICY_FWD)
        {
                /* no forward policies for KLIPS */
                return SUCCESS;
        }
-       
+
        DBG2(DBG_KNL, "deleting policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
-       
+
        /* create a policy */
        policy = create_policy_entry(src_ts, dst_ts, direction);
-       
+
        /* find a matching policy */
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -2431,10 +2431,10 @@ static status_t del_policy(private_kernel_klips_ipsec_t *this,
                return NOT_FOUND;
        }
        policy_entry_destroy(policy);
-       
+
        /* decrease appropriate counter */
        unrouted ? found->trapcount-- : found->activecount--;
-       
+
        if (found->trapcount == 0)
        {
                /* if this policy is finally unrouted, we reset the reqid because it
@@ -2442,7 +2442,7 @@ static status_t del_policy(private_kernel_klips_ipsec_t *this,
                 * this policy. */
                found->reqid = 0;
        }
-       
+
        if (found->activecount > 0)
        {
                /* is still used by SAs, keep in kernel */
@@ -2462,22 +2462,22 @@ static status_t del_policy(private_kernel_klips_ipsec_t *this,
                this->mutex->unlock(this->mutex);
                return pfkey_send_ack(this, msg);
        }
-       
+
        /* remove if last reference */
        this->policies->remove(this->policies, found, NULL);
        policy = found;
-       
+
        this->mutex->unlock(this->mutex);
-               
+
        memset(&request, 0, sizeof(request));
-       
+
        build_delflow(msg, 0, policy->src.net, policy->src.mask, policy->dst.net,
                        policy->dst.mask, policy->src.proto);
-       
+
        route = policy->route;
        policy->route = NULL;
        policy_entry_destroy(policy);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to delete policy %R === %R %N", src_ts, dst_ts,
@@ -2493,11 +2493,11 @@ static status_t del_policy(private_kernel_klips_ipsec_t *this,
                return FAILED;
        }
        free(out);
-       
+
        if (route)
        {
                ipsec_dev_t *dev;
-               
+
                if (charon->kernel_interface->del_route(charon->kernel_interface,
                                route->dst_net, route->prefixlen, route->gateway,
                                route->src_ip, route->if_name) != SUCCESS)
@@ -2506,11 +2506,11 @@ static status_t del_policy(private_kernel_klips_ipsec_t *this,
                                                  " policy %R === %R %N", src_ts, dst_ts,
                                                   policy_dir_names, direction);
                }
-               
+
                /* we have to detach the ipsec interface from the physical one over which
                 * this SA ran (if it is not used by any other) */
                this->mutex->lock(this->mutex);
-               
+
                if (find_ipsec_dev(this, route->if_name, &dev) == SUCCESS)
                {
                        /* fine, we found a matching device object, let's check if we have
@@ -2525,12 +2525,12 @@ static status_t del_policy(private_kernel_klips_ipsec_t *this,
                                dev->phys_name[0] = '\0';
                        }
                }
-               
+
                this->mutex->unlock(this->mutex);
-               
+
                route_entry_destroy(route);
        }
-       
+
        return SUCCESS;
 }
 
@@ -2542,7 +2542,7 @@ static void init_ipsec_devices(private_kernel_klips_ipsec_t *this)
        int i, count = lib->settings->get_int(lib->settings,
                                                "charon.plugins.kernel_klips.ipsec_dev_count",
                                                DEFAULT_IPSEC_DEV_COUNT);
-       
+
        for (i = 0; i < count; ++i)
        {
                ipsec_dev_t *dev = malloc_thing(ipsec_dev_t);
@@ -2551,7 +2551,7 @@ static void init_ipsec_devices(private_kernel_klips_ipsec_t *this)
                dev->phys_name[0] = '\0';
                dev->refcount = 0;
                this->ipsec_devices->insert_last(this->ipsec_devices, dev);
-               
+
                /* detach any previously attached ipsec device */
                detach_ipsec_dev(dev->name, dev->phys_name);
        }
@@ -2565,15 +2565,15 @@ static status_t register_pfkey_socket(private_kernel_klips_ipsec_t *this, u_int8
        unsigned char request[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg, *out;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_REGISTER;
        msg->sadb_msg_satype = satype;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        if (pfkey_send_socket(this, this->socket_events, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to register PF_KEY socket");
@@ -2613,7 +2613,7 @@ static void destroy(private_kernel_klips_ipsec_t *this)
 kernel_klips_ipsec_t *kernel_klips_ipsec_create()
 {
        private_kernel_klips_ipsec_t *this = malloc_thing(private_kernel_klips_ipsec_t);
-       
+
        /* public functions */
        this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
        this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
@@ -2624,7 +2624,7 @@ kernel_klips_ipsec_t *kernel_klips_ipsec_create()
        this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
        this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
        this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
-       
+
        this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
 
        /* private members */
@@ -2636,34 +2636,34 @@ kernel_klips_ipsec_t *kernel_klips_ipsec_create()
        this->mutex_pfkey = mutex_create(MUTEX_TYPE_DEFAULT);
        this->install_routes = lib->settings->get_bool(lib->settings, "charon.install_routes", TRUE);
        this->seq = 0;
-       
+
        /* initialize ipsec devices */
        init_ipsec_devices(this);
-       
+
        /* create a PF_KEY socket to communicate with the kernel */
        this->socket = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
        if (this->socket <= 0)
        {
                charon->kill(charon, "unable to create PF_KEY socket");
        }
-       
+
        /* create a PF_KEY socket for ACQUIRE & EXPIRE */
        this->socket_events = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
        if (this->socket_events <= 0)
        {
                charon->kill(charon, "unable to create PF_KEY event socket");
        }
-       
+
        /* register the event socket */
        if (register_pfkey_socket(this, SADB_SATYPE_ESP) != SUCCESS ||
                register_pfkey_socket(this, SADB_SATYPE_AH) != SUCCESS)
        {
                charon->kill(charon, "unable to register PF_KEY event socket");
        }
-       
+
        this->job = callback_job_create((callback_job_cb_t)receive_events,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public;
 }
index d153ea8afea1628bcde16c4165fd4d805c88d4a2..b0117c10c3cd398a527ba7979ce7beb60b3db11d 100644 (file)
@@ -47,10 +47,10 @@ static void destroy(private_kernel_klips_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_kernel_klips_plugin_t *this = malloc_thing(private_kernel_klips_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->kernel_interface->add_ipsec_interface(charon->kernel_interface, (kernel_ipsec_constructor_t)kernel_klips_ipsec_create);
-       
+
        return &this->public.plugin;
 }
index 78d3dfa917d4878ccf15073cfadc613f9cf2b1b9..20d1c298d4fbd0774c77b7a854c5e32d6197d493 100644 (file)
@@ -169,7 +169,7 @@ struct sadb_x_satype {
   uint8_t sadb_x_satype_satype;
   uint8_t sadb_x_satype_reserved[3];
 };
-  
+
 struct sadb_x_debug {
   uint16_t sadb_x_debug_len;
   uint16_t sadb_x_debug_exttype;
@@ -200,7 +200,7 @@ struct sadb_x_nat_t_port {
   uint16_t sadb_x_nat_t_port_port;
   uint16_t sadb_x_nat_t_port_reserved;
 };
-  
+
 /*
  * A protocol structure for passing through the transport level
  * protocol.  It contains more fields than are actually used/needed
index cdd2436c5a9e4d2b8db61a59b0a6af89326ab897..bce6016c57f7d37c903109ef66574edeeaf1c166 100644 (file)
@@ -75,8 +75,8 @@
 #define XFRMNLGRP(x) (1<<(XFRMNLGRP_##x-1))
 
 /**
- * returns a pointer to the first rtattr following the nlmsghdr *nlh and the 
- * 'usual' netlink data x like 'struct xfrm_usersa_info' 
+ * returns a pointer to the first rtattr following the nlmsghdr *nlh and the
+ * 'usual' netlink data x like 'struct xfrm_usersa_info'
  */
 #define XFRM_RTA(nlh, x) ((struct rtattr*)(NLMSG_DATA(nlh) + NLMSG_ALIGN(sizeof(x))))
 /**
@@ -85,8 +85,8 @@
  */
 #define XFRM_RTA_NEXT(rta) ((struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
 /**
- * returns the total size of attached rta data 
- * (after 'usual' netlink data x like 'struct xfrm_usersa_info') 
+ * returns the total size of attached rta data
+ * (after 'usual' netlink data x like 'struct xfrm_usersa_info')
  */
 #define XFRM_PAYLOAD(nlh, x) NLMSG_PAYLOAD(nlh, sizeof(x))
 
@@ -100,7 +100,7 @@ struct kernel_algorithm_t {
         * Identifier specified in IKEv2
         */
        int ikev2;
-               
+
        /**
         * Name of the algorithm in linux crypto API
         */
@@ -239,10 +239,10 @@ typedef struct route_entry_t route_entry_t;
 struct route_entry_t {
        /** Name of the interface the route is bound to */
        char *if_name;
-       
+
        /** Source ip of the route */
        host_t *src_ip;
-       
+
        /** gateway for this route */
        host_t *gateway;
 
@@ -271,16 +271,16 @@ typedef struct policy_entry_t policy_entry_t;
  * installed kernel policy.
  */
 struct policy_entry_t {
-       
+
        /** direction of this policy: in, out, forward */
        u_int8_t direction;
-       
+
        /** parameters of installed policy */
        struct xfrm_selector sel;
-       
+
        /** associated route installed for this policy */
        route_entry_t *route;
-       
+
        /** by how many CHILD_SA's this policy is used */
        u_int refcount;
 };
@@ -313,32 +313,32 @@ struct private_kernel_netlink_ipsec_t {
         * Public part of the kernel_netlink_t object.
         */
        kernel_netlink_ipsec_t public;
-       
+
        /**
         * mutex to lock access to various lists
         */
        mutex_t *mutex;
-       
+
        /**
         * Hash table of installed policies (policy_entry_t)
         */
        hashtable_t *policies;
-                
+
        /**
         * job receiving netlink events
         */
        callback_job_t *job;
-       
+
        /**
         * Netlink xfrm socket (IPsec)
         */
        netlink_socket_t *socket_xfrm;
-       
+
        /**
         * netlink xfrm socket to receive acquire and expire events
         */
        int socket_xfrm_events;
-       
+
        /**
         * whether to install routes along policies
         */
@@ -401,7 +401,7 @@ static u_int8_t mode2kernel(ipsec_mode_t mode)
 static void host2xfrm(host_t *host, xfrm_address_t *xfrm)
 {
        chunk_t chunk = host->get_address(host);
-       memcpy(xfrm, chunk.ptr, min(chunk.len, sizeof(xfrm_address_t)));        
+       memcpy(xfrm, chunk.ptr, min(chunk.len, sizeof(xfrm_address_t)));
 }
 
 /**
@@ -410,7 +410,7 @@ static void host2xfrm(host_t *host, xfrm_address_t *xfrm)
 static host_t* xfrm2host(int family, xfrm_address_t *xfrm, u_int16_t port)
 {
        chunk_t chunk;
-       
+
        switch (family)
        {
                case AF_INET:
@@ -428,12 +428,12 @@ static host_t* xfrm2host(int family, xfrm_address_t *xfrm, u_int16_t port)
 /**
  * convert a traffic selector address range to subnet and its mask.
  */
-static void ts2subnet(traffic_selector_t* ts, 
+static void ts2subnet(traffic_selector_t* ts,
                                          xfrm_address_t *net, u_int8_t *mask)
 {
        host_t *net_host;
        chunk_t net_chunk;
-       
+
        ts->to_subnet(ts, &net_host, mask);
        net_chunk = net_host->get_address(net_host);
        memcpy(net, net_chunk.ptr, net_chunk.len);
@@ -443,7 +443,7 @@ static void ts2subnet(traffic_selector_t* ts,
 /**
  * convert a traffic selector port range to port/portmask
  */
-static void ts2ports(traffic_selector_t* ts, 
+static void ts2ports(traffic_selector_t* ts,
                                         u_int16_t *port, u_int16_t *mask)
 {
        /* linux does not seem to accept complex portmasks. Only
@@ -451,10 +451,10 @@ static void ts2ports(traffic_selector_t* ts,
         * a port range, or to a specific, if we have one port only.
         */
        u_int16_t from, to;
-       
+
        from = ts->get_from_port(ts);
        to = ts->get_to_port(ts);
-       
+
        if (from == to)
        {
                *port = htons(from);
@@ -470,7 +470,7 @@ static void ts2ports(traffic_selector_t* ts,
 /**
  * convert a pair of traffic_selectors to a xfrm_selector
  */
-static struct xfrm_selector ts2selector(traffic_selector_t *src, 
+static struct xfrm_selector ts2selector(traffic_selector_t *src,
                                                                                traffic_selector_t *dst)
 {
        struct xfrm_selector sel;
@@ -485,12 +485,12 @@ static struct xfrm_selector ts2selector(traffic_selector_t *src,
        ts2ports(src, &sel.sport, &sel.sport_mask);
        sel.ifindex = 0;
        sel.user = 0;
-       
+
        return sel;
 }
 
 /**
- * convert a xfrm_selector to a src|dst traffic_selector 
+ * convert a xfrm_selector to a src|dst traffic_selector
  */
 static traffic_selector_t* selector2ts(struct xfrm_selector *sel, bool src)
 {
@@ -498,7 +498,7 @@ static traffic_selector_t* selector2ts(struct xfrm_selector *sel, bool src)
        u_int8_t prefixlen;
        u_int16_t port = 0;
        host_t *host = NULL;
-       
+
        if (src)
        {
                addr = (u_char*)&sel->saddr;
@@ -517,9 +517,9 @@ static traffic_selector_t* selector2ts(struct xfrm_selector *sel, bool src)
                        port = htons(sel->dport);
                }
        }
-       
+
        /* The Linux 2.6 kernel does not set the selector's family field,
-        * so as a kludge we additionally test the prefix length. 
+        * so as a kludge we additionally test the prefix length.
         */
        if (sel->family == AF_INET || sel->prefixlen_s == 32)
        {
@@ -529,7 +529,7 @@ static traffic_selector_t* selector2ts(struct xfrm_selector *sel, bool src)
        {
                host = host_create_from_chunk(AF_INET6, chunk_create(addr, 16), 0);
        }
-       
+
        if (host)
        {
                return traffic_selector_create_from_subnet(host, prefixlen,
@@ -550,7 +550,7 @@ static void process_acquire(private_kernel_netlink_ipsec_t *this, struct nlmsghd
        struct rtattr *rta;
        size_t rtasize;
        job_t *job;
-       
+
        acquire = (struct xfrm_user_acquire*)NLMSG_DATA(hdr);
        rta = XFRM_RTA(hdr, struct xfrm_user_acquire);
        rtasize = XFRM_PAYLOAD(hdr, struct xfrm_user_acquire);
@@ -598,21 +598,21 @@ static void process_expire(private_kernel_netlink_ipsec_t *this, struct nlmsghdr
        protocol_id_t protocol;
        u_int32_t spi, reqid;
        struct xfrm_user_expire *expire;
-       
+
        expire = (struct xfrm_user_expire*)NLMSG_DATA(hdr);
        protocol = proto_kernel2ike(expire->state.id.proto);
        spi = expire->state.id.spi;
        reqid = expire->state.reqid;
-       
+
        DBG2(DBG_KNL, "received a XFRM_MSG_EXPIRE");
-       
+
        if (protocol != PROTO_ESP && protocol != PROTO_AH)
        {
                DBG2(DBG_KNL, "ignoring XFRM_MSG_EXPIRE for SA with SPI %.8x and reqid {%u} "
                                          "which is not a CHILD_SA", ntohl(spi), reqid);
                return;
        }
-       
+
        DBG1(DBG_KNL, "creating %s job for %N CHILD_SA with SPI %.8x and reqid {%d}",
                 expire->hard ? "delete" : "rekey",  protocol_id_names,
                 protocol, ntohl(spi), reqid);
@@ -648,7 +648,7 @@ static void process_migrate(private_kernel_netlink_ipsec_t *this, struct nlmsghd
        rtasize = XFRM_PAYLOAD(hdr, struct xfrm_userpolicy_id);
 
        DBG2(DBG_KNL, "received a XFRM_MSG_MIGRATE");
-       
+
        src_ts = selector2ts(&policy_id->sel, TRUE);
        dst_ts = selector2ts(&policy_id->sel, FALSE);
        dir = (policy_dir_t)policy_id->dir;
@@ -717,13 +717,13 @@ static void process_mapping(private_kernel_netlink_ipsec_t *this,
        u_int32_t spi, reqid;
        struct xfrm_user_mapping *mapping;
        host_t *host;
-       
+
        mapping = (struct xfrm_user_mapping*)NLMSG_DATA(hdr);
        spi = mapping->id.spi;
        reqid = mapping->reqid;
-       
+
        DBG2(DBG_KNL, "received a XFRM_MSG_MAPPING");
-       
+
        if (proto_kernel2ike(mapping->id.proto) == PROTO_ESP)
        {
                host = xfrm2host(mapping->id.family, &mapping->new_saddr,
@@ -753,7 +753,7 @@ static job_requeue_t receive_events(private_kernel_netlink_ipsec_t *this)
        len = recvfrom(this->socket_xfrm_events, response, sizeof(response), 0,
                                   (struct sockaddr*)&addr, &addr_len);
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (len < 0)
        {
                switch (errno)
@@ -770,12 +770,12 @@ static job_requeue_t receive_events(private_kernel_netlink_ipsec_t *this)
                                return JOB_REQUEUE_FAIR;
                }
        }
-       
+
        if (addr.nl_pid != 0)
        {       /* not from kernel. not interested, try another one */
                return JOB_REQUEUE_DIRECT;
        }
-       
+
        while (NLMSG_OK(hdr, len))
        {
                switch (hdr->nlmsg_type)
@@ -813,9 +813,9 @@ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this,
        struct xfrm_userspi_info *userspi;
        u_int32_t received_spi = 0;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST;
        hdr->nlmsg_type = XFRM_MSG_ALLOCSPI;
@@ -830,7 +830,7 @@ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this,
        userspi->info.family = src->get_family(src);
        userspi->min = min;
        userspi->max = max;
-       
+
        if (this->socket_xfrm->send(this->socket_xfrm, hdr, &out, &len) == SUCCESS)
        {
                hdr = out;
@@ -847,7 +847,7 @@ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this,
                                case NLMSG_ERROR:
                                {
                                        struct nlmsgerr *err = NLMSG_DATA(hdr);
-                                       
+
                                        DBG1(DBG_KNL, "allocating SPI failed: %s (%d)",
                                                 strerror(-err->error), -err->error);
                                        break;
@@ -862,12 +862,12 @@ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this,
                }
                free(out);
        }
-       
+
        if (received_spi == 0)
        {
                return FAILED;
        }
-       
+
        *spi = received_spi;
        return SUCCESS;
 }
@@ -875,47 +875,47 @@ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this,
 /**
  * Implementation of kernel_interface_t.get_spi.
  */
-static status_t get_spi(private_kernel_netlink_ipsec_t *this, 
-                                               host_t *src, host_t *dst, 
+static status_t get_spi(private_kernel_netlink_ipsec_t *this,
+                                               host_t *src, host_t *dst,
                                                protocol_id_t protocol, u_int32_t reqid,
                                                u_int32_t *spi)
 {
        DBG2(DBG_KNL, "getting SPI for reqid {%u}", reqid);
-       
+
        if (get_spi_internal(this, src, dst, proto_ike2kernel(protocol),
                        0xc0000000, 0xcFFFFFFF, reqid, spi) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to get SPI for reqid {%u}", reqid);
                return FAILED;
        }
-       
+
        DBG2(DBG_KNL, "got SPI %.8x for reqid {%u}", ntohl(*spi), reqid);
-       
+
        return SUCCESS;
 }
 
 /**
  * Implementation of kernel_interface_t.get_cpi.
  */
-static status_t get_cpi(private_kernel_netlink_ipsec_t *this, 
-                                               host_t *src, host_t *dst, 
+static status_t get_cpi(private_kernel_netlink_ipsec_t *this,
+                                               host_t *src, host_t *dst,
                                                u_int32_t reqid, u_int16_t *cpi)
 {
        u_int32_t received_spi = 0;
 
        DBG2(DBG_KNL, "getting CPI for reqid {%u}", reqid);
-       
+
        if (get_spi_internal(this, src, dst,
                        IPPROTO_COMP, 0x100, 0xEFFF, reqid, &received_spi) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to get CPI for reqid {%u}", reqid);
                return FAILED;
        }
-       
+
        *cpi = htons((u_int16_t)ntohl(received_spi));
-       
+
        DBG2(DBG_KNL, "got CPI %.4x for reqid {%u}", ntohs(*cpi), reqid);
-       
+
        return SUCCESS;
 }
 
@@ -935,8 +935,8 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
        char *alg_name;
        struct nlmsghdr *hdr;
        struct xfrm_usersa_info *sa;
-       u_int16_t icv_size = 64;        
-       
+       u_int16_t icv_size = 64;
+
        /* if IPComp is used, we install an additional IPComp SA. if the cpi is 0
         * we are in the recursive call below */
        if (ipcomp != IPCOMP_NONE && cpi != 0)
@@ -947,17 +947,17 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
                           mode, ipcomp, 0, FALSE, inbound);
                ipcomp = IPCOMP_NONE;
        }
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "adding SAD entry with SPI %.8x and reqid {%u}",
                 ntohl(spi), reqid);
-       
+
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
        hdr->nlmsg_type = inbound ? XFRM_MSG_UPDSA : XFRM_MSG_NEWSA;
        hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_info));
-       
+
        sa = (struct xfrm_usersa_info*)NLMSG_DATA(hdr);
        host2xfrm(src, &sa->saddr);
        host2xfrm(dst, &sa->id.daddr);
@@ -980,9 +980,9 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
        sa->lft.hard_add_expires_seconds = lifetime->time.life;
        sa->lft.soft_use_expires_seconds = 0;
        sa->lft.hard_use_expires_seconds = 0;
-       
+
        struct rtattr *rthdr = XFRM_RTA(hdr, struct xfrm_usersa_info);
-       
+
        switch (enc_alg)
        {
                case ENCR_UNDEFINED:
@@ -1013,7 +1013,7 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
                        }
                        DBG2(DBG_KNL, "  using encryption algorithm %N with key size %d",
                                 encryption_algorithm_names, enc_alg, enc_key.len * 8);
-                       
+
                        rthdr->rta_type = XFRMA_ALG_AEAD;
                        rthdr->rta_len = RTA_LENGTH(sizeof(struct xfrm_algo_aead) + enc_key.len);
                        hdr->nlmsg_len += rthdr->rta_len;
@@ -1021,13 +1021,13 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
                        {
                                return FAILED;
                        }
-                       
+
                        algo = (struct xfrm_algo_aead*)RTA_DATA(rthdr);
                        algo->alg_key_len = enc_key.len * 8;
                        algo->alg_icv_len = icv_size;
                        strcpy(algo->alg_name, alg_name);
                        memcpy(algo->alg_key, enc_key.ptr, enc_key.len);
-                       
+
                        rthdr = XFRM_RTA_NEXT(rthdr);
                        break;
                }
@@ -1044,7 +1044,7 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
                        }
                        DBG2(DBG_KNL, "  using encryption algorithm %N with key size %d",
                                 encryption_algorithm_names, enc_alg, enc_key.len * 8);
-                       
+
                        rthdr->rta_type = XFRMA_ALG_CRYPT;
                        rthdr->rta_len = RTA_LENGTH(sizeof(struct xfrm_algo) + enc_key.len);
                        hdr->nlmsg_len += rthdr->rta_len;
@@ -1052,71 +1052,71 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
                        {
                                return FAILED;
                        }
-                       
+
                        algo = (struct xfrm_algo*)RTA_DATA(rthdr);
                        algo->alg_key_len = enc_key.len * 8;
                        strcpy(algo->alg_name, alg_name);
                        memcpy(algo->alg_key, enc_key.ptr, enc_key.len);
-                       
+
                        rthdr = XFRM_RTA_NEXT(rthdr);
                }
        }
-               
+
        if (int_alg  != AUTH_UNDEFINED)
        {
                rthdr->rta_type = XFRMA_ALG_AUTH;
                alg_name = lookup_algorithm(integrity_algs, int_alg);
                if (alg_name == NULL)
                {
-                       DBG1(DBG_KNL, "algorithm %N not supported by kernel!", 
+                       DBG1(DBG_KNL, "algorithm %N not supported by kernel!",
                                 integrity_algorithm_names, int_alg);
                        return FAILED;
                }
                DBG2(DBG_KNL, "  using integrity algorithm %N with key size %d",
                         integrity_algorithm_names, int_alg, int_key.len * 8);
-               
+
                rthdr->rta_len = RTA_LENGTH(sizeof(struct xfrm_algo) + int_key.len);
                hdr->nlmsg_len += rthdr->rta_len;
                if (hdr->nlmsg_len > sizeof(request))
                {
                        return FAILED;
                }
-               
+
                struct xfrm_algo* algo = (struct xfrm_algo*)RTA_DATA(rthdr);
                algo->alg_key_len = int_key.len * 8;
                strcpy(algo->alg_name, alg_name);
                memcpy(algo->alg_key, int_key.ptr, int_key.len);
-               
+
                rthdr = XFRM_RTA_NEXT(rthdr);
        }
-       
+
        if (ipcomp != IPCOMP_NONE)
        {
                rthdr->rta_type = XFRMA_ALG_COMP;
                alg_name = lookup_algorithm(compression_algs, ipcomp);
                if (alg_name == NULL)
                {
-                       DBG1(DBG_KNL, "algorithm %N not supported by kernel!", 
+                       DBG1(DBG_KNL, "algorithm %N not supported by kernel!",
                                 ipcomp_transform_names, ipcomp);
                        return FAILED;
                }
                DBG2(DBG_KNL, "  using compression algorithm %N",
                         ipcomp_transform_names, ipcomp);
-               
+
                rthdr->rta_len = RTA_LENGTH(sizeof(struct xfrm_algo));
                hdr->nlmsg_len += rthdr->rta_len;
                if (hdr->nlmsg_len > sizeof(request))
                {
                        return FAILED;
                }
-               
+
                struct xfrm_algo* algo = (struct xfrm_algo*)RTA_DATA(rthdr);
                algo->alg_key_len = 0;
                strcpy(algo->alg_name, alg_name);
-               
+
                rthdr = XFRM_RTA_NEXT(rthdr);
        }
-       
+
        if (encap)
        {
                rthdr->rta_type = XFRMA_ENCAP;
@@ -1133,13 +1133,13 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
                tmpl->encap_sport = htons(src->get_port(src));
                tmpl->encap_dport = htons(dst->get_port(dst));
                memset(&tmpl->encap_oa, 0, sizeof (xfrm_address_t));
-               /* encap_oa could probably be derived from the 
-                * traffic selectors [rfc4306, p39]. In the netlink kernel implementation 
-                * pluto does the same as we do here but it uses encap_oa in the 
-                * pfkey implementation. BUT as /usr/src/linux/net/key/af_key.c indicates 
+               /* encap_oa could probably be derived from the
+                * traffic selectors [rfc4306, p39]. In the netlink kernel implementation
+                * pluto does the same as we do here but it uses encap_oa in the
+                * pfkey implementation. BUT as /usr/src/linux/net/key/af_key.c indicates
                 * the kernel ignores it anyway
                 *   -> does that mean that NAT-T encap doesn't work in transport mode?
-                * No. The reason the kernel ignores NAT-OA is that it recomputes 
+                * No. The reason the kernel ignores NAT-OA is that it recomputes
                 * (or, rather, just ignores) the checksum. If packets pass
                 * the IPsec checks it marks them "checksum ok" so OA isn't needed. */
                rthdr = XFRM_RTA_NEXT(rthdr);
@@ -1166,24 +1166,24 @@ static status_t get_replay_state(private_kernel_netlink_ipsec_t *this,
        size_t len;
        struct rtattr *rta;
        size_t rtasize;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "querying replay state from SAD entry with SPI %.8x", ntohl(spi));
 
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST;
        hdr->nlmsg_type = XFRM_MSG_GETAE;
        hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_aevent_id));
-       
+
        aevent_id = (struct xfrm_aevent_id*)NLMSG_DATA(hdr);
        aevent_id->flags = XFRM_AE_RVAL;
-       
+
        host2xfrm(dst, &aevent_id->sa_id.daddr);
        aevent_id->sa_id.spi = spi;
        aevent_id->sa_id.proto = proto_ike2kernel(protocol);
        aevent_id->sa_id.family = dst->get_family(dst);
-       
+
        if (this->socket_xfrm->send(this->socket_xfrm, hdr, &out, &len) == SUCCESS)
        {
                hdr = out;
@@ -1212,7 +1212,7 @@ static status_t get_replay_state(private_kernel_netlink_ipsec_t *this,
                        break;
                }
        }
-       
+
        if (out_aevent == NULL)
        {
                DBG1(DBG_KNL, "unable to query replay state from SAD entry with SPI %.8x",
@@ -1220,7 +1220,7 @@ static status_t get_replay_state(private_kernel_netlink_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        rta = XFRM_RTA(out, struct xfrm_aevent_id);
        rtasize = XFRM_PAYLOAD(out, struct xfrm_aevent_id);
        while(RTA_OK(rta, rtasize))
@@ -1234,7 +1234,7 @@ static status_t get_replay_state(private_kernel_netlink_ipsec_t *this,
                }
                rta = RTA_NEXT(rta, rtasize);
        }
-       
+
        DBG1(DBG_KNL, "unable to query replay state from SAD entry with SPI %.8x",
                                  ntohl(spi));
        free(out);
@@ -1253,7 +1253,7 @@ static status_t query_sa(private_kernel_netlink_ipsec_t *this, host_t *src,
        struct xfrm_usersa_id *sa_id;
        struct xfrm_usersa_info *sa = NULL;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
 
        DBG2(DBG_KNL, "querying SAD entry with SPI %.8x", ntohl(spi));
@@ -1268,7 +1268,7 @@ static status_t query_sa(private_kernel_netlink_ipsec_t *this, host_t *src,
        sa_id->spi = spi;
        sa_id->proto = proto_ike2kernel(protocol);
        sa_id->family = dst->get_family(dst);
-       
+
        if (this->socket_xfrm->send(this->socket_xfrm, hdr, &out, &len) == SUCCESS)
        {
                hdr = out;
@@ -1297,7 +1297,7 @@ static status_t query_sa(private_kernel_netlink_ipsec_t *this, host_t *src,
                        break;
                }
        }
-       
+
        if (sa == NULL)
        {
                DBG2(DBG_KNL, "unable to query SAD entry with SPI %.8x", ntohl(spi));
@@ -1305,7 +1305,7 @@ static status_t query_sa(private_kernel_netlink_ipsec_t *this, host_t *src,
                return FAILED;
        }
        *bytes = sa->curlft.bytes;
-       
+
        free(out);
        return SUCCESS;
 }
@@ -1319,28 +1319,28 @@ static status_t del_sa(private_kernel_netlink_ipsec_t *this, host_t *src,
        netlink_buf_t request;
        struct nlmsghdr *hdr;
        struct xfrm_usersa_id *sa_id;
-       
+
        /* if IPComp was used, we first delete the additional IPComp SA */
        if (cpi)
        {
                del_sa(this, src, dst, htonl(ntohs(cpi)), IPPROTO_COMP, 0);
        }
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "deleting SAD entry with SPI %.8x", ntohl(spi));
-       
+
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
        hdr->nlmsg_type = XFRM_MSG_DELSA;
        hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_id));
-       
+
        sa_id = (struct xfrm_usersa_id*)NLMSG_DATA(hdr);
        host2xfrm(dst, &sa_id->daddr);
        sa_id->spi = spi;
        sa_id->proto = proto_ike2kernel(protocol);
        sa_id->family = dst->get_family(dst);
-       
+
        if (this->socket_xfrm->send_ack(this->socket_xfrm, hdr) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to delete SAD entry with SPI %.8x", ntohl(spi));
@@ -1370,30 +1370,30 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
        struct xfrm_encap_tmpl* tmpl = NULL;
        bool got_replay_state = FALSE;
        struct xfrm_replay_state replay;
-       
+
        /* if IPComp is used, we first update the IPComp SA */
        if (cpi)
        {
                update_sa(this, htonl(ntohs(cpi)), IPPROTO_COMP, 0,
                                  src, dst, new_src, new_dst, FALSE, FALSE);
        }
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "querying SAD entry with SPI %.8x for update", ntohl(spi));
-       
+
        /* query the existing SA first */
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST;
        hdr->nlmsg_type = XFRM_MSG_GETSA;
        hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_id));
-       
+
        sa_id = (struct xfrm_usersa_id*)NLMSG_DATA(hdr);
        host2xfrm(dst, &sa_id->daddr);
        sa_id->spi = spi;
        sa_id->proto = proto_ike2kernel(protocol);
        sa_id->family = dst->get_family(dst);
-       
+
        if (this->socket_xfrm->send(this->socket_xfrm, hdr, &out, &len) == SUCCESS)
        {
                hdr = out;
@@ -1428,13 +1428,13 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        /* try to get the replay state */
        if (get_replay_state(this, spi, protocol, dst, &replay) == SUCCESS)
        {
                got_replay_state = TRUE;
        }
-       
+
        /* delete the old SA (without affecting the IPComp SA) */
        if (del_sa(this, src, dst, spi, protocol, 0) != SUCCESS)
        {
@@ -1442,18 +1442,18 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        DBG2(DBG_KNL, "updating SAD entry with SPI %.8x from %#H..%#H to %#H..%#H",
                 ntohl(spi), src, dst, new_src, new_dst);
        /* copy over the SA from out to request */
        hdr = (struct nlmsghdr*)request;
        memcpy(hdr, out, min(out->nlmsg_len, sizeof(request)));
-       hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;   
+       hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
        hdr->nlmsg_type = XFRM_MSG_NEWSA;
        hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_info));
        sa = NLMSG_DATA(hdr);
        sa->family = new_dst->get_family(new_dst);
-       
+
        if (!src->ip_equals(src, new_src))
        {
                host2xfrm(new_src, &sa->saddr);
@@ -1462,7 +1462,7 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
        {
                host2xfrm(new_dst, &sa->id.daddr);
        }
-       
+
        rta = XFRM_RTA(out, struct xfrm_usersa_info);
        rtasize = XFRM_PAYLOAD(out, struct xfrm_usersa_info);
        pos = (u_char*)XFRM_RTA(hdr, struct xfrm_usersa_info);
@@ -1476,47 +1476,47 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
                                tmpl = (struct xfrm_encap_tmpl*)RTA_DATA(rta);
                                tmpl->encap_sport = ntohs(new_src->get_port(new_src));
                                tmpl->encap_dport = ntohs(new_dst->get_port(new_dst));
-                       }       
+                       }
                        memcpy(pos, rta, rta->rta_len);
                        pos += RTA_ALIGN(rta->rta_len);
                        hdr->nlmsg_len += RTA_ALIGN(rta->rta_len);
                }
                rta = RTA_NEXT(rta, rtasize);
        }
-       
+
        rta = (struct rtattr*)pos;
        if (tmpl == NULL && new_encap)
        {       /* add tmpl if we are enabling it */
                rta->rta_type = XFRMA_ENCAP;
                rta->rta_len = RTA_LENGTH(sizeof(struct xfrm_encap_tmpl));
-               
+
                hdr->nlmsg_len += rta->rta_len;
                if (hdr->nlmsg_len > sizeof(request))
                {
                        return FAILED;
                }
-               
+
                tmpl = (struct xfrm_encap_tmpl*)RTA_DATA(rta);
                tmpl->encap_type = UDP_ENCAP_ESPINUDP;
                tmpl->encap_sport = ntohs(new_src->get_port(new_src));
                tmpl->encap_dport = ntohs(new_dst->get_port(new_dst));
                memset(&tmpl->encap_oa, 0, sizeof (xfrm_address_t));
-               
+
                rta = XFRM_RTA_NEXT(rta);
        }
-       
+
        if (got_replay_state)
        {       /* copy the replay data if available */
                rta->rta_type = XFRMA_REPLAY_VAL;
                rta->rta_len = RTA_LENGTH(sizeof(struct xfrm_replay_state));
-               
+
                hdr->nlmsg_len += rta->rta_len;
                if (hdr->nlmsg_len > sizeof(request))
                {
                        return FAILED;
                }
                memcpy(RTA_DATA(rta), &replay, sizeof(replay));
-               
+
                rta = XFRM_RTA_NEXT(rta);
        }
 
@@ -1527,14 +1527,14 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
                return FAILED;
        }
        free(out);
-       
+
        return SUCCESS;
 }
 
 /**
  * Implementation of kernel_interface_t.add_policy.
  */
-static status_t add_policy(private_kernel_netlink_ipsec_t *this, 
+static status_t add_policy(private_kernel_netlink_ipsec_t *this,
                                                   host_t *src, host_t *dst,
                                                   traffic_selector_t *src_ts,
                                                   traffic_selector_t *dst_ts,
@@ -1548,13 +1548,13 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
        netlink_buf_t request;
        struct xfrm_userpolicy_info *policy_info;
        struct nlmsghdr *hdr;
-       
+
        /* create a policy */
        policy = malloc_thing(policy_entry_t);
        memset(policy, 0, sizeof(policy_entry_t));
        policy->sel = ts2selector(src_ts, dst_ts);
        policy->direction = direction;
-       
+
        /* find the policy, which matches EXACTLY */
        this->mutex->lock(this->mutex);
        current = this->policies->get(this->policies, policy);
@@ -1574,10 +1574,10 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
                this->policies->put(this->policies, policy, policy);
                policy->refcount = 1;
        }
-       
+
        DBG2(DBG_KNL, "adding policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
-       
+
        memset(&request, 0, sizeof(request));
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
@@ -1595,7 +1595,7 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
        policy_info->action = XFRM_POLICY_ALLOW;
        policy_info->share = XFRM_SHARE_ANY;
        this->mutex->unlock(this->mutex);
-       
+
        /* policies don't expire */
        policy_info->lft.soft_byte_limit = XFRM_INF;
        policy_info->lft.soft_packet_limit = XFRM_INF;
@@ -1605,19 +1605,19 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
        policy_info->lft.hard_add_expires_seconds = 0;
        policy_info->lft.soft_use_expires_seconds = 0;
        policy_info->lft.hard_use_expires_seconds = 0;
-       
+
        struct rtattr *rthdr = XFRM_RTA(hdr, struct xfrm_userpolicy_info);
        rthdr->rta_type = XFRMA_TMPL;
        rthdr->rta_len = RTA_LENGTH(sizeof(struct xfrm_user_tmpl));
-       
+
        hdr->nlmsg_len += rthdr->rta_len;
        if (hdr->nlmsg_len > sizeof(request))
        {
                return FAILED;
        }
-       
+
        struct xfrm_user_tmpl *tmpl = (struct xfrm_user_tmpl*)RTA_DATA(rthdr);
-       
+
        if (ipcomp != IPCOMP_NONE)
        {
                tmpl->reqid = reqid;
@@ -1626,10 +1626,10 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
                tmpl->mode = mode2kernel(mode);
                tmpl->optional = direction != POLICY_OUT;
                tmpl->family = src->get_family(src);
-               
+
                host2xfrm(src, &tmpl->saddr);
                host2xfrm(dst, &tmpl->id.daddr);
-               
+
                /* add an additional xfrm_user_tmpl */
                rthdr->rta_len += RTA_LENGTH(sizeof(struct xfrm_user_tmpl));
                hdr->nlmsg_len += RTA_LENGTH(sizeof(struct xfrm_user_tmpl));
@@ -1637,26 +1637,26 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
                {
                        return FAILED;
                }
-               
+
                tmpl++;
        }
-       
+
        tmpl->reqid = reqid;
        tmpl->id.proto = proto_ike2kernel(protocol);
        tmpl->aalgos = tmpl->ealgos = tmpl->calgos = ~0;
        tmpl->mode = mode2kernel(mode);
        tmpl->family = src->get_family(src);
-       
+
        host2xfrm(src, &tmpl->saddr);
        host2xfrm(dst, &tmpl->id.daddr);
-       
+
        if (this->socket_xfrm->send_ack(this->socket_xfrm, hdr) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to add policy %R === %R %N", src_ts, dst_ts,
                                           policy_dir_names, direction);
                return FAILED;
        }
-       
+
        /* install a route, if:
         * - we are NOT updating a policy
         * - this is a forward policy (to just get one for each child)
@@ -1669,7 +1669,7 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
                this->install_routes)
        {
                route_entry_t *route = malloc_thing(route_entry_t);
-               
+
                if (charon->kernel_interface->get_address_by_ts(charon->kernel_interface,
                                dst_ts, &route->src_ip) == SUCCESS)
                {
@@ -1681,9 +1681,9 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
                        route->dst_net = chunk_alloc(policy->sel.family == AF_INET ? 4 : 16);
                        memcpy(route->dst_net.ptr, &policy->sel.saddr, route->dst_net.len);
                        route->prefixlen = policy->sel.prefixlen_s;
-                       
+
                        if (route->if_name)
-                       {                       
+                       {
                                switch (charon->kernel_interface->add_route(
                                                                        charon->kernel_interface, route->dst_net,
                                                                        route->prefixlen, route->gateway,
@@ -1720,7 +1720,7 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
  * Implementation of kernel_interface_t.query_policy.
  */
 static status_t query_policy(private_kernel_netlink_ipsec_t *this,
-                                                        traffic_selector_t *src_ts, 
+                                                        traffic_selector_t *src_ts,
                                                         traffic_selector_t *dst_ts,
                                                         policy_dir_t direction, u_int32_t *use_time)
 {
@@ -1729,9 +1729,9 @@ static status_t query_policy(private_kernel_netlink_ipsec_t *this,
        struct xfrm_userpolicy_id *policy_id;
        struct xfrm_userpolicy_info *policy = NULL;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "querying policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
 
@@ -1743,7 +1743,7 @@ static status_t query_policy(private_kernel_netlink_ipsec_t *this,
        policy_id = (struct xfrm_userpolicy_id*)NLMSG_DATA(hdr);
        policy_id->sel = ts2selector(src_ts, dst_ts);
        policy_id->dir = direction;
-       
+
        if (this->socket_xfrm->send(this->socket_xfrm, hdr, &out, &len) == SUCCESS)
        {
                hdr = out;
@@ -1772,7 +1772,7 @@ static status_t query_policy(private_kernel_netlink_ipsec_t *this,
                        break;
                }
        }
-       
+
        if (policy == NULL)
        {
                DBG2(DBG_KNL, "unable to query policy %R === %R %N", src_ts, dst_ts,
@@ -1780,7 +1780,7 @@ static status_t query_policy(private_kernel_netlink_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        if (policy->curlft.use_time)
        {
                /* we need the monotonic time, but the kernel returns system time. */
@@ -1790,7 +1790,7 @@ static status_t query_policy(private_kernel_netlink_ipsec_t *this,
        {
                *use_time = 0;
        }
-       
+
        free(out);
        return SUCCESS;
 }
@@ -1799,7 +1799,7 @@ static status_t query_policy(private_kernel_netlink_ipsec_t *this,
  * Implementation of kernel_interface_t.del_policy.
  */
 static status_t del_policy(private_kernel_netlink_ipsec_t *this,
-                                                  traffic_selector_t *src_ts, 
+                                                  traffic_selector_t *src_ts,
                                                   traffic_selector_t *dst_ts,
                                                   policy_dir_t direction, bool unrouted)
 {
@@ -1808,15 +1808,15 @@ static status_t del_policy(private_kernel_netlink_ipsec_t *this,
        netlink_buf_t request;
        struct nlmsghdr *hdr;
        struct xfrm_userpolicy_id *policy_id;
-       
+
        DBG2(DBG_KNL, "deleting policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
-       
+
        /* create a policy */
        memset(&policy, 0, sizeof(policy_entry_t));
        policy.sel = ts2selector(src_ts, dst_ts);
        policy.direction = direction;
-       
+
        /* find the policy */
        this->mutex->lock(this->mutex);
        current = this->policies->get(this->policies, &policy);
@@ -1840,9 +1840,9 @@ static status_t del_policy(private_kernel_netlink_ipsec_t *this,
                                           dst_ts, policy_dir_names, direction);
                return NOT_FOUND;
        }
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
        hdr->nlmsg_type = XFRM_MSG_DELPOLICY;
@@ -1851,10 +1851,10 @@ static status_t del_policy(private_kernel_netlink_ipsec_t *this,
        policy_id = (struct xfrm_userpolicy_id*)NLMSG_DATA(hdr);
        policy_id->sel = to_delete->sel;
        policy_id->dir = direction;
-       
+
        route = to_delete->route;
        free(to_delete);
-       
+
        if (this->socket_xfrm->send_ack(this->socket_xfrm, hdr) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to delete policy %R === %R %N", src_ts, dst_ts,
@@ -1871,7 +1871,7 @@ static status_t del_policy(private_kernel_netlink_ipsec_t *this,
                        DBG1(DBG_KNL, "error uninstalling route installed with "
                                                  "policy %R === %R %N", src_ts, dst_ts,
                                                   policy_dir_names, direction);
-               }               
+               }
                route_entry_destroy(route);
        }
        return SUCCESS;
@@ -1884,7 +1884,7 @@ static void destroy(private_kernel_netlink_ipsec_t *this)
 {
        enumerator_t *enumerator;
        policy_entry_t *policy;
-       
+
        this->job->cancel(this->job);
        close(this->socket_xfrm_events);
        this->socket_xfrm->destroy(this->socket_xfrm);
@@ -1907,7 +1907,7 @@ static bool add_bypass_policies()
        int fd, family, port;
        enumerator_t *sockets;
        bool status = TRUE;
-       
+
        /* we open an AF_KEY socket to autoload the af_key module. Otherwise
         * setsockopt(IPSEC_POLICY) won't work. */
        fd = socket(AF_KEY, SOCK_RAW, PF_KEY_V2);
@@ -1917,13 +1917,13 @@ static bool add_bypass_policies()
                return FALSE;
        }
        close(fd);
-       
+
        sockets = charon->socket->create_enumerator(charon->socket);
        while (sockets->enumerate(sockets, &fd, &family, &port))
        {
                struct sadb_x_policy policy;
                u_int sol, ipsec_policy;
-               
+
                switch (family)
                {
                        case AF_INET:
@@ -1937,12 +1937,12 @@ static bool add_bypass_policies()
                        default:
                                continue;
                }
-               
+
                memset(&policy, 0, sizeof(policy));
                policy.sadb_x_policy_len = sizeof(policy) / sizeof(u_int64_t);
                policy.sadb_x_policy_exttype = SADB_X_EXT_POLICY;
                policy.sadb_x_policy_type = IPSEC_POLICY_BYPASS;
-       
+
                policy.sadb_x_policy_dir = IPSEC_DIR_OUTBOUND;
                if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
                {
@@ -1954,7 +1954,7 @@ static bool add_bypass_policies()
                policy.sadb_x_policy_dir = IPSEC_DIR_INBOUND;
                if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
                {
-                       DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s", 
+                       DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
                                 strerror(errno));
                        status = FALSE;
                        break;
@@ -1972,7 +1972,7 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
        private_kernel_netlink_ipsec_t *this = malloc_thing(private_kernel_netlink_ipsec_t);
        struct sockaddr_nl addr;
        int fd;
-       
+
        /* public functions */
        this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
        this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
@@ -1991,7 +1991,7 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->install_routes = lib->settings->get_bool(lib->settings,
                                        "charon.install_routes", TRUE);
-       
+
        /* disable lifetimes for allocated SPIs in kernel */
        fd = open("/proc/sys/net/core/xfrm_acq_expires", O_WRONLY);
        if (fd)
@@ -1999,18 +1999,18 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
                ignore_result(write(fd, "0", 1));
                close(fd);
        }
-       
+
        /* add bypass policies on the sockets used by charon */
        if (!add_bypass_policies())
        {
                charon->kill(charon, "unable to add bypass policies on sockets");
        }
-       
+
        this->socket_xfrm = netlink_socket_create(NETLINK_XFRM);
-       
+
        memset(&addr, 0, sizeof(addr));
        addr.nl_family = AF_NETLINK;
-       
+
        /* create and bind XFRM socket for ACQUIRE, EXPIRE, MIGRATE & MAPPING */
        this->socket_xfrm_events = socket(AF_NETLINK, SOCK_RAW, NETLINK_XFRM);
        if (this->socket_xfrm_events <= 0)
@@ -2023,10 +2023,10 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
        {
                charon->kill(charon, "unable to bind XFRM event socket");
        }
-       
+
        this->job = callback_job_create((callback_job_cb_t)receive_events,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public;
 }
index 0688607972168f48481431e1d97b65eba8fface5..4b2a05f8fe1f7ac5bfd4ad54534914dca382166b 100644 (file)
@@ -48,16 +48,16 @@ typedef struct addr_entry_t addr_entry_t;
  * IP address in an inface_entry_t
  */
 struct addr_entry_t {
-       
+
        /** The ip address */
        host_t *ip;
-       
+
        /** virtual IP managed by us */
        bool virtual;
-       
+
        /** scope of the address */
        u_char scope;
-       
+
        /** Number of times this IP is used, if virtual */
        u_int refcount;
 };
@@ -77,16 +77,16 @@ typedef struct iface_entry_t iface_entry_t;
  * A network interface on this system, containing addr_entry_t's
  */
 struct iface_entry_t {
-       
+
        /** interface index */
        int ifindex;
-       
+
        /** name of the interface */
        char ifname[IFNAMSIZ];
-       
+
        /** interface flags, as in netdevice(7) SIOCGIFFLAGS */
        u_int flags;
-       
+
        /** list of addresses as host_t */
        linked_list_t *addrs;
 };
@@ -110,57 +110,57 @@ struct private_kernel_netlink_net_t {
         * Public part of the kernel_netlink_net_t object.
         */
        kernel_netlink_net_t public;
-       
+
        /**
         * mutex to lock access to various lists
         */
        mutex_t *mutex;
-       
+
        /**
         * condition variable to signal virtual IP add/removal
         */
        condvar_t *condvar;
-       
+
        /**
         * Cached list of interfaces and its addresses (iface_entry_t)
         */
        linked_list_t *ifaces;
-        
+
        /**
         * job receiving netlink events
         */
        callback_job_t *job;
-       
+
        /**
         * netlink rt socket (routing)
         */
        netlink_socket_t *socket;
-       
+
        /**
         * Netlink rt socket to receive address change events
         */
        int socket_events;
-       
+
        /**
         * time of the last roam_job
         */
        timeval_t last_roam;
-       
+
        /**
         * routing table to install routes
         */
        int routing_table;
-       
+
        /**
         * priority of used routing table
         */
        int routing_table_prio;
-       
+
        /**
         * whether to react to RTM_NEWROUTE or RTM_DELROUTE events
         */
        bool process_route;
-       
+
        /**
         * whether to actually install virtual IPs
         */
@@ -176,7 +176,7 @@ static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip)
        iface_entry_t *iface;
        addr_entry_t *addr;
        int refcount = 0;
-       
+
        ifaces = this->ifaces->create_iterator(this->ifaces, TRUE);
        while (ifaces->iterate(ifaces, (void**)&iface))
        {
@@ -197,7 +197,7 @@ static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip)
                }
        }
        ifaces->destroy(ifaces);
-       
+
        return refcount;
 }
 
@@ -208,7 +208,7 @@ static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip)
 static void fire_roam_job(private_kernel_netlink_net_t *this, bool address)
 {
        timeval_t now;
-       
+
        time_monotonic(&now);
        if (timercmp(&now, &this->last_roam, >))
        {
@@ -237,7 +237,7 @@ static void process_link(private_kernel_netlink_net_t *this,
        iface_entry_t *current, *entry = NULL;
        char *name = NULL;
        bool update = FALSE;
-       
+
        while(RTA_OK(rta, rtasize))
        {
                switch (rta->rta_type)
@@ -252,7 +252,7 @@ static void process_link(private_kernel_netlink_net_t *this,
        {
                name = "(unknown)";
        }
-       
+
        this->mutex->lock(this->mutex);
        switch (hdr->nlmsg_type)
        {
@@ -305,7 +305,7 @@ static void process_link(private_kernel_netlink_net_t *this,
                        {
                                if (current->ifindex == msg->ifi_index)
                                {
-                                       /* we do not remove it, as an address may be added to a 
+                                       /* we do not remove it, as an address may be added to a
                                         * "down" interface and we wan't to know that. */
                                        current->flags = msg->ifi_flags;
                                        break;
@@ -316,7 +316,7 @@ static void process_link(private_kernel_netlink_net_t *this,
                }
        }
        this->mutex->unlock(this->mutex);
-       
+
        /* send an update to all IKE_SAs */
        if (update && event)
        {
@@ -339,7 +339,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
        addr_entry_t *addr;
        chunk_t local = chunk_empty, address = chunk_empty;
        bool update = FALSE, found = FALSE, changed = FALSE;
-       
+
        while(RTA_OK(rta, rtasize))
        {
                switch (rta->rta_type)
@@ -355,7 +355,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
                }
                rta = RTA_NEXT(rta, rtasize);
        }
-       
+
        /* For PPP interfaces, we need the IFA_LOCAL address,
         * IFA_ADDRESS is the peers address. But IFA_LOCAL is
         * not included in all cases (IPv6?), so fallback to IFA_ADDRESS. */
@@ -367,12 +367,12 @@ static void process_addr(private_kernel_netlink_net_t *this,
        {
                host = host_create_from_chunk(msg->ifa_family, address, 0);
        }
-       
+
        if (host == NULL)
        {       /* bad family? */
                return;
        }
-       
+
        this->mutex->lock(this->mutex);
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
@@ -403,7 +403,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
                                }
                        }
                        addrs->destroy(addrs);
-               
+
                        if (hdr->nlmsg_type == RTM_NEWADDR)
                        {
                                if (!found)
@@ -415,7 +415,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
                                        addr->virtual = FALSE;
                                        addr->refcount = 1;
                                        addr->scope = msg->ifa_scope;
-                                       
+
                                        iface->addrs->insert_last(iface->addrs, addr);
                                        if (event)
                                        {
@@ -433,7 +433,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
        ifaces->destroy(ifaces);
        this->mutex->unlock(this->mutex);
        host->destroy(host);
-       
+
        /* send an update to all IKE_SAs */
        if (update && event && changed)
        {
@@ -450,13 +450,13 @@ static void process_route(private_kernel_netlink_net_t *this, struct nlmsghdr *h
        struct rtattr *rta = RTM_RTA(msg);
        size_t rtasize = RTM_PAYLOAD(hdr);
        host_t *host = NULL;
-       
+
        /* ignore routes added by us */
        if (msg->rtm_table && msg->rtm_table == this->routing_table)
        {
                return;
        }
-       
+
        while (RTA_OK(rta, rtasize))
        {
                switch (rta->rta_type)
@@ -491,11 +491,11 @@ static job_requeue_t receive_events(private_kernel_netlink_net_t *this)
        socklen_t addr_len = sizeof(addr);
        int len, oldstate;
 
-       pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);       
+       pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        len = recvfrom(this->socket_events, response, sizeof(response), 0,
                                   (struct sockaddr*)&addr, &addr_len);
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (len < 0)
        {
                switch (errno)
@@ -512,12 +512,12 @@ static job_requeue_t receive_events(private_kernel_netlink_net_t *this)
                                return JOB_REQUEUE_FAIR;
                }
        }
-       
+
        if (addr.nl_pid != 0)
        {       /* not from kernel. not interested, try another one */
                return JOB_REQUEUE_DIRECT;
        }
-       
+
        while (NLMSG_OK(hdr, len))
        {
                /* looks good so far, dispatch netlink message */
@@ -553,7 +553,7 @@ typedef struct {
        private_kernel_netlink_net_t* this;
        /** whether to enumerate down interfaces */
        bool include_down_ifaces;
-       /** whether to enumerate virtual ip addresses */ 
+       /** whether to enumerate virtual ip addresses */
        bool include_virtual_ips;
 } address_enumerator_t;
 
@@ -615,7 +615,7 @@ static enumerator_t *create_address_enumerator(private_kernel_netlink_net_t *thi
        data->this = this;
        data->include_down_ifaces = include_down_ifaces;
        data->include_virtual_ips = include_virtual_ips;
-       
+
        this->mutex->lock(this->mutex);
        return enumerator_create_nested(
                                enumerator_create_filter(this->ifaces->create_enumerator(this->ifaces),
@@ -632,9 +632,9 @@ static char *get_interface_name(private_kernel_netlink_net_t *this, host_t* ip)
        iface_entry_t *iface;
        addr_entry_t *addr;
        char *name = NULL;
-       
+
        DBG2(DBG_KNL, "getting interface name for %H", ip);
-       
+
        this->mutex->lock(this->mutex);
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
@@ -656,7 +656,7 @@ static char *get_interface_name(private_kernel_netlink_net_t *this, host_t* ip)
        }
        ifaces->destroy(ifaces);
        this->mutex->unlock(this->mutex);
-       
+
        if (name)
        {
                DBG2(DBG_KNL, "%H is on interface %s", ip, name);
@@ -676,9 +676,9 @@ static int get_interface_index(private_kernel_netlink_net_t *this, char* name)
        enumerator_t *ifaces;
        iface_entry_t *iface;
        int ifindex = 0;
-       
+
        DBG2(DBG_KNL, "getting iface index for %s", name);
-       
+
        this->mutex->lock(this->mutex);
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
@@ -708,7 +708,7 @@ static bool is_interface_up(private_kernel_netlink_net_t *this, int index)
        iface_entry_t *iface;
        /* default to TRUE for interface we do not monitor (e.g. lo) */
        bool up = TRUE;
-       
+
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
        {
@@ -729,7 +729,7 @@ static bool addr_in_subnet(chunk_t addr, chunk_t net, int net_len)
 {
        static const u_char mask[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe };
        int byte = 0;
-       
+
        if (net_len == 0)
        {       /* any address matches a /0 network */
                return TRUE;
@@ -771,9 +771,9 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
        size_t len;
        int best = -1;
        host_t *src = NULL, *gtw = NULL;
-       
+
        DBG2(DBG_KNL, "getting address to reach %H", dest);
-       
+
        memset(&request, 0, sizeof(request));
 
        hdr = (struct nlmsghdr*)request;
@@ -790,7 +790,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
        }
        chunk = dest->get_address(dest);
        netlink_add_attribute(hdr, RTA_DST, chunk, sizeof(request));
-       
+
        if (this->socket->send(this->socket, hdr, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "getting address to %H failed", dest);
@@ -811,7 +811,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                chunk_t rta_gtw, rta_src, rta_dst;
                                u_int32_t rta_oif = 0;
                                host_t *new_src, *new_gtw;
-                               
+
                                rta_gtw = rta_src = rta_dst = chunk_empty;
                                msg = (struct rtmsg*)(NLMSG_DATA(current));
                                rta = RTM_RTA(msg);
@@ -855,7 +855,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                {       /* route destination does not contain dest */
                                        goto next;
                                }
-                               
+
                                if (nexthop)
                                {
                                        /* nexthop lookup, return gateway */
@@ -907,7 +907,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
        }
        free(out);
        this->mutex->unlock(this->mutex);
-       
+
        if (nexthop)
        {
                if (gtw)
@@ -947,23 +947,23 @@ static status_t manage_ipaddr(private_kernel_netlink_net_t *this, int nlmsg_type
        struct nlmsghdr *hdr;
        struct ifaddrmsg *msg;
        chunk_t chunk;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        chunk = ip->get_address(ip);
-    
+
     hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags;
-       hdr->nlmsg_type = nlmsg_type; 
+       hdr->nlmsg_type = nlmsg_type;
        hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
-       
+
        msg = (struct ifaddrmsg*)NLMSG_DATA(hdr);
     msg->ifa_family = ip->get_family(ip);
     msg->ifa_flags = 0;
     msg->ifa_prefixlen = 8 * chunk.len;
     msg->ifa_scope = RT_SCOPE_UNIVERSE;
     msg->ifa_index = if_index;
-       
+
        netlink_add_attribute(hdr, IFA_LOCAL, chunk, sizeof(request));
 
        return this->socket->send_ack(this->socket, hdr);
@@ -972,27 +972,27 @@ static status_t manage_ipaddr(private_kernel_netlink_net_t *this, int nlmsg_type
 /**
  * Implementation of kernel_net_t.add_ip.
  */
-static status_t add_ip(private_kernel_netlink_net_t *this, 
+static status_t add_ip(private_kernel_netlink_net_t *this,
                                                host_t *virtual_ip, host_t *iface_ip)
 {
        iface_entry_t *iface;
        addr_entry_t *addr;
        enumerator_t *addrs, *ifaces;
        int ifindex;
-       
+
        if (!this->install_virtual_ip)
        {       /* disabled by config */
                return SUCCESS;
        }
-       
+
        DBG2(DBG_KNL, "adding virtual IP %H", virtual_ip);
-       
+
        this->mutex->lock(this->mutex);
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
        {
                bool iface_found = FALSE;
-       
+
                addrs = iface->addrs->create_enumerator(iface->addrs);
                while (addrs->enumerate(addrs, &addr))
                {
@@ -1012,7 +1012,7 @@ static status_t add_ip(private_kernel_netlink_net_t *this,
                        }
                }
                addrs->destroy(addrs);
-               
+
                if (iface_found)
                {
                        ifindex = iface->ifindex;
@@ -1022,7 +1022,7 @@ static status_t add_ip(private_kernel_netlink_net_t *this,
                        addr->virtual = TRUE;
                        addr->scope = RT_SCOPE_UNIVERSE;
                        iface->addrs->insert_last(iface->addrs, addr);
-                       
+
                        if (manage_ipaddr(this, RTM_NEWADDR, NLM_F_CREATE | NLM_F_EXCL,
                                                          ifindex, virtual_ip) == SUCCESS)
                        {
@@ -1042,7 +1042,7 @@ static status_t add_ip(private_kernel_netlink_net_t *this,
        }
        ifaces->destroy(ifaces);
        this->mutex->unlock(this->mutex);
-       
+
        DBG1(DBG_KNL, "interface address %H not found, unable to install"
                 "virtual IP %H", iface_ip, virtual_ip);
        return FAILED;
@@ -1058,14 +1058,14 @@ static status_t del_ip(private_kernel_netlink_net_t *this, host_t *virtual_ip)
        enumerator_t *addrs, *ifaces;
        status_t status;
        int ifindex;
-       
+
        if (!this->install_virtual_ip)
        {       /* disabled by config */
                return SUCCESS;
        }
-       
+
        DBG2(DBG_KNL, "deleting virtual IP %H", virtual_ip);
-       
+
        this->mutex->lock(this->mutex);
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
@@ -1108,7 +1108,7 @@ static status_t del_ip(private_kernel_netlink_net_t *this, host_t *virtual_ip)
        }
        ifaces->destroy(ifaces);
        this->mutex->unlock(this->mutex);
-       
+
        DBG2(DBG_KNL, "virtual IP %H not cached, unable to delete", virtual_ip);
        return FAILED;
 }
@@ -1135,11 +1135,11 @@ static status_t manage_srcroute(private_kernel_netlink_net_t *this, int nlmsg_ty
                chunk_t half_net;
                u_int8_t half_prefixlen;
                status_t status;
-               
+
                half_net = chunk_alloca(dst_net.len);
                memset(half_net.ptr, 0, half_net.len);
                half_prefixlen = 1;
-               
+
                status = manage_srcroute(this, nlmsg_type, flags, half_net, half_prefixlen,
                                        gateway, src_ip, if_name);
                half_net.ptr[0] |= 0x80;
@@ -1147,7 +1147,7 @@ static status_t manage_srcroute(private_kernel_netlink_net_t *this, int nlmsg_ty
                                        gateway, src_ip, if_name);
                return status;
        }
-       
+
        memset(&request, 0, sizeof(request));
 
        hdr = (struct nlmsghdr*)request;
@@ -1162,7 +1162,7 @@ static status_t manage_srcroute(private_kernel_netlink_net_t *this, int nlmsg_ty
        msg->rtm_protocol = RTPROT_STATIC;
        msg->rtm_type = RTN_UNICAST;
        msg->rtm_scope = RT_SCOPE_UNIVERSE;
-       
+
        netlink_add_attribute(hdr, RTA_DST, dst_net, sizeof(request));
        chunk = src_ip->get_address(src_ip);
        netlink_add_attribute(hdr, RTA_PREFSRC, chunk, sizeof(request));
@@ -1185,7 +1185,7 @@ static status_t add_route(private_kernel_netlink_net_t *this, chunk_t dst_net,
        return manage_srcroute(this, RTM_NEWROUTE, NLM_F_CREATE | NLM_F_EXCL,
                                dst_net, prefixlen, gateway, src_ip, if_name);
 }
-       
+
 /**
  * Implementation of kernel_net_t.del_route.
  */
@@ -1208,9 +1208,9 @@ static status_t init_address_list(private_kernel_netlink_net_t *this)
        enumerator_t *ifaces, *addrs;
        iface_entry_t *iface;
        addr_entry_t *addr;
-       
+
        DBG1(DBG_KNL, "listening on interfaces:");
-       
+
        memset(&request, 0, sizeof(request));
 
        in = (struct nlmsghdr*)&request;
@@ -1218,7 +1218,7 @@ static status_t init_address_list(private_kernel_netlink_net_t *this)
        in->nlmsg_flags = NLM_F_REQUEST | NLM_F_MATCH | NLM_F_ROOT;
        msg = (struct rtgenmsg*)NLMSG_DATA(in);
        msg->rtgen_family = AF_UNSPEC;
-       
+
        /* get all links */
        in->nlmsg_type = RTM_GETLINK;
        if (this->socket->send(this->socket, in, &out, &len) != SUCCESS)
@@ -1242,7 +1242,7 @@ static status_t init_address_list(private_kernel_netlink_net_t *this)
                break;
        }
        free(out);
-       
+
        /* get all interface addresses */
        in->nlmsg_type = RTM_GETADDR;
        if (this->socket->send(this->socket, in, &out, &len) != SUCCESS)
@@ -1266,7 +1266,7 @@ static status_t init_address_list(private_kernel_netlink_net_t *this)
                break;
        }
        free(out);
-       
+
        this->mutex->lock(this->mutex);
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
@@ -1298,10 +1298,10 @@ static status_t manage_rule(private_kernel_netlink_net_t *this, int nlmsg_type,
        struct rtmsg *msg;
        chunk_t chunk;
 
-       memset(&request, 0, sizeof(request));    
+       memset(&request, 0, sizeof(request));
        hdr = (struct nlmsghdr*)request;
        hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
-       hdr->nlmsg_type = nlmsg_type; 
+       hdr->nlmsg_type = nlmsg_type;
        if (nlmsg_type == RTM_NEWRULE)
        {
                hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
@@ -1348,7 +1348,7 @@ kernel_netlink_net_t *kernel_netlink_net_create()
 {
        private_kernel_netlink_net_t *this = malloc_thing(private_kernel_netlink_net_t);
        struct sockaddr_nl addr;
-       
+
        /* public functions */
        this->public.interface.get_interface = (char*(*)(kernel_net_t*,host_t*))get_interface_name;
        this->public.interface.create_address_enumerator = (enumerator_t*(*)(kernel_net_t*,bool,bool))create_address_enumerator;
@@ -1373,34 +1373,34 @@ kernel_netlink_net_t *kernel_netlink_net_create()
                                        "charon.process_route", TRUE);
        this->install_virtual_ip = lib->settings->get_bool(lib->settings,
                                        "charon.install_virtual_ip", TRUE);
-       
+
        this->socket = netlink_socket_create(NETLINK_ROUTE);
-       
+
        memset(&addr, 0, sizeof(addr));
        addr.nl_family = AF_NETLINK;
-       
+
        /* create and bind RT socket for events (address/interface/route changes) */
        this->socket_events = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
        if (this->socket_events <= 0)
        {
                charon->kill(charon, "unable to create RT event socket");
        }
-       addr.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR | 
+       addr.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR |
                                         RTMGRP_IPV4_ROUTE | RTMGRP_IPV4_ROUTE | RTMGRP_LINK;
        if (bind(this->socket_events, (struct sockaddr*)&addr, sizeof(addr)))
        {
                charon->kill(charon, "unable to bind RT event socket");
        }
-       
+
        this->job = callback_job_create((callback_job_cb_t)receive_events,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        if (init_address_list(this) != SUCCESS)
        {
                charon->kill(charon, "unable to get interface list");
        }
-       
+
        if (this->routing_table)
        {
                if (manage_rule(this, RTM_NEWRULE, this->routing_table,
@@ -1409,6 +1409,6 @@ kernel_netlink_net_t *kernel_netlink_net_create()
                        DBG1(DBG_KNL, "unable to create routing table rule");
                }
        }
-       
+
        return &this->public;
 }
index 77005e8716cde0aa36503a1a837bfd2da579a1d6..cdf20f14a5db2bd1335011f1bee021bd11f39058 100644 (file)
@@ -49,11 +49,11 @@ static void destroy(private_kernel_netlink_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_kernel_netlink_plugin_t *this = malloc_thing(private_kernel_netlink_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->kernel_interface->add_ipsec_interface(charon->kernel_interface, (kernel_ipsec_constructor_t)kernel_netlink_ipsec_create);
        charon->kernel_interface->add_net_interface(charon->kernel_interface, (kernel_net_constructor_t)kernel_netlink_net_create);
-       
+
        return &this->public.plugin;
 }
index ec11870830b46e1e6ce08bfe6e48d2f435df146b..3d8ca880701893a4733ebb6078d28d7588eec72f 100644 (file)
@@ -34,7 +34,7 @@ struct private_netlink_socket_t {
         * public part of the netlink_socket_t object.
         */
        netlink_socket_t public;
-       
+
        /**
         * mutex to lock access to netlink socket
         */
@@ -46,12 +46,12 @@ struct private_netlink_socket_t {
        int seq;
 
        /**
-        * netlink socket protocol 
+        * netlink socket protocol
         */
        int protocol;
 
        /**
-        * netlink socket 
+        * netlink socket
         */
        int socket;
 };
@@ -71,12 +71,12 @@ static status_t netlink_send(private_netlink_socket_t *this, struct nlmsghdr *in
        struct sockaddr_nl addr;
        chunk_t result = chunk_empty, tmp;
        struct nlmsghdr *msg, peek;
-       
+
        this->mutex->lock(this->mutex);
-       
+
        in->nlmsg_seq = ++this->seq;
        in->nlmsg_pid = getpid();
-       
+
        memset(&addr, 0, sizeof(addr));
        addr.nl_family = AF_NETLINK;
        addr.nl_pid = 0;
@@ -91,11 +91,11 @@ static status_t netlink_send(private_netlink_socket_t *this, struct nlmsghdr *in
 
        while (TRUE)
        {
-               len = sendto(this->socket, in, in->nlmsg_len, 0, 
+               len = sendto(this->socket, in, in->nlmsg_len, 0,
                                         (struct sockaddr*)&addr, sizeof(addr));
-               
+
                if (len != in->nlmsg_len)
-               {       
+               {
                        if (errno == EINTR)
                        {
                                /* interrupted, try again */
@@ -107,23 +107,23 @@ static status_t netlink_send(private_netlink_socket_t *this, struct nlmsghdr *in
                }
                break;
        }
-       
+
        while (TRUE)
-       {       
+       {
                char buf[4096];
                tmp.len = sizeof(buf);
                tmp.ptr = buf;
                msg = (struct nlmsghdr*)tmp.ptr;
-               
+
                memset(&addr, 0, sizeof(addr));
                addr.nl_family = AF_NETLINK;
                addr.nl_pid = getpid();
                addr.nl_groups = 0;
                addr_len = sizeof(addr);
-               
+
                len = recvfrom(this->socket, tmp.ptr, tmp.len, 0,
                                           (struct sockaddr*)&addr, &addr_len);
-               
+
                if (len < 0)
                {
                        if (errno == EINTR)
@@ -155,17 +155,17 @@ static status_t netlink_send(private_netlink_socket_t *this, struct nlmsghdr *in
                        free(result.ptr);
                        return FAILED;
                }
-               
+
                tmp.len = len;
                result.ptr = realloc(result.ptr, result.len + tmp.len);
                memcpy(result.ptr + result.len, tmp.ptr, tmp.len);
                result.len += tmp.len;
-               
+
                /* NLM_F_MULTI flag does not seem to be set correctly, we use sequence
                 * numbers to detect multi header messages */
                len = recvfrom(this->socket, &peek, sizeof(peek), MSG_PEEK | MSG_DONTWAIT,
                                           (struct sockaddr*)&addr, &addr_len);
-               
+
                if (len == sizeof(peek) && peek.nlmsg_seq == this->seq)
                {
                        /* seems to be multipart */
@@ -173,12 +173,12 @@ static status_t netlink_send(private_netlink_socket_t *this, struct nlmsghdr *in
                }
                break;
        }
-       
+
        *out_len = result.len;
        *out = (struct nlmsghdr*)result.ptr;
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        return SUCCESS;
 }
 
@@ -202,7 +202,7 @@ static status_t netlink_send_ack(private_netlink_socket_t *this, struct nlmsghdr
                        case NLMSG_ERROR:
                        {
                                struct nlmsgerr* err = (struct nlmsgerr*)NLMSG_DATA(hdr);
-                               
+
                                if (err->error)
                                {
                                        if (-err->error == EEXIST)
@@ -247,7 +247,7 @@ static void destroy(private_netlink_socket_t *this)
 netlink_socket_t *netlink_socket_create(int protocol) {
        private_netlink_socket_t *this = malloc_thing(private_netlink_socket_t);
        struct sockaddr_nl addr;
-       
+
        /* public functions */
        this->public.send = (status_t(*)(netlink_socket_t*,struct nlmsghdr*, struct nlmsghdr**, size_t*))netlink_send;
        this->public.send_ack = (status_t(*)(netlink_socket_t*,struct nlmsghdr*))netlink_send_ack;
@@ -256,23 +256,23 @@ netlink_socket_t *netlink_socket_create(int protocol) {
        /* private members */
        this->seq = 200;
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
-       
+
        memset(&addr, 0, sizeof(addr));
        addr.nl_family = AF_NETLINK;
-       
+
        this->protocol = protocol;
        this->socket = socket(AF_NETLINK, SOCK_RAW, protocol);
        if (this->socket <= 0)
        {
                charon->kill(charon, "unable to create netlink socket");
        }
-       
+
        addr.nl_groups = 0;
        if (bind(this->socket, (struct sockaddr*)&addr, sizeof(addr)))
        {
                charon->kill(charon, "unable to bind netlink socket");
        }
-       
+
        return &this->public;
 }
 
@@ -283,13 +283,13 @@ void netlink_add_attribute(struct nlmsghdr *hdr, int rta_type, chunk_t data,
                                                  size_t buflen)
 {
        struct rtattr *rta;
-       
+
        if (NLMSG_ALIGN(hdr->nlmsg_len) + RTA_ALIGN(data.len) > buflen)
        {
                DBG1(DBG_KNL, "unable to add attribute, buffer too small");
                return;
        }
-       
+
        rta = (struct rtattr*)(((char*)hdr) + NLMSG_ALIGN(hdr->nlmsg_len));
        rta->rta_type = rta_type;
        rta->rta_len = RTA_LENGTH(data.len);
index 5a70e4d9b60665d2b130e3d979b305301deb14c3..dfd27a21a74ec587335efcc8cd3a8df01a501077 100644 (file)
@@ -37,20 +37,20 @@ struct netlink_socket_t {
 
        /**
         * Send a netlink message and wait for a reply.
-        * 
+        *
         * @param       in              netlink message to send
         * @param       out     received netlink message
         * @param       out_len length of the received message
         */
        status_t (*send)(netlink_socket_t *this, struct nlmsghdr *in, struct nlmsghdr **out, size_t *out_len);
-       
+
        /**
         * Send a netlink message and wait for its acknowledge.
-        * 
+        *
         * @param       in              netlink message to send
         */
        status_t (*send_ack)(netlink_socket_t *this, struct nlmsghdr *in);
-       
+
        /**
         * Destroy the socket.
         */
@@ -59,14 +59,14 @@ struct netlink_socket_t {
 
 /**
  * Create a netlink_socket_t object.
- * 
+ *
  * @param      protocol        protocol type (e.g. NETLINK_XFRM or NETLINK_ROUTE)
  */
 netlink_socket_t *netlink_socket_create(int protocol);
 
 /**
  * Creates an rtattr and adds it to the given netlink message.
- * 
+ *
  * @param      hdr                     netlink message
  * @param      rta_type        type of the rtattr
  * @param      data            data to add to the rtattr
index 002e1bee8fd6680b146384a60ffc54a75c1edaec..57e3a92e3b14330849807c5bf1aa30a8f84645af 100644 (file)
@@ -151,42 +151,42 @@ struct private_kernel_pfkey_ipsec_t
         * Public part of the kernel_pfkey_t object.
         */
        kernel_pfkey_ipsec_t public;
-       
+
        /**
         * mutex to lock access to various lists
         */
        mutex_t *mutex;
-       
+
        /**
         * List of installed policies (policy_entry_t)
         */
        linked_list_t *policies;
-       
+
        /**
         * whether to install routes along policies
         */
        bool install_routes;
-       
+
        /**
         * job receiving PF_KEY events
         */
        callback_job_t *job;
-       
+
        /**
         * mutex to lock access to the PF_KEY socket
         */
        mutex_t *mutex_pfkey;
-       
+
        /**
         * PF_KEY socket to communicate with the kernel
         */
        int socket;
-       
+
        /**
         * PF_KEY socket to receive acquire and expire events
         */
        int socket_events;
-       
+
        /**
         * sequence number for messages sent to the kernel
         */
@@ -201,10 +201,10 @@ typedef struct route_entry_t route_entry_t;
 struct route_entry_t {
        /** Name of the interface the route is bound to */
        char *if_name;
-       
+
        /** Source ip of the route */
        host_t *src_ip;
-       
+
        /** gateway for this route */
        host_t *gateway;
 
@@ -233,16 +233,16 @@ typedef struct policy_entry_t policy_entry_t;
  * installed kernel policy.
  */
 struct policy_entry_t {
-       
+
        /** reqid of this policy */
        u_int32_t reqid;
-       
+
        /** index assigned by the kernel */
        u_int32_t index;
-       
+
        /** direction of this policy: in, out, forward */
        u_int8_t direction;
-       
+
        /** parameters of installed policy */
        struct {
                /** subnet and port */
@@ -252,10 +252,10 @@ struct policy_entry_t {
                /** protocol */
                u_int8_t proto;
        } src, dst;
-       
+
        /** associated route installed for this policy */
        route_entry_t *route;
-       
+
        /** by how many CHILD_SA's this policy is used */
        u_int refcount;
 };
@@ -272,15 +272,15 @@ static policy_entry_t *create_policy_entry(traffic_selector_t *src_ts,
        policy->direction = dir;
        policy->route = NULL;
        policy->refcount = 0;
-       
+
        src_ts->to_subnet(src_ts, &policy->src.net, &policy->src.mask);
        dst_ts->to_subnet(dst_ts, &policy->dst.net, &policy->dst.mask);
-       
+
        /* src or dest proto may be "any" (0), use more restrictive one */
        policy->src.proto = max(src_ts->get_protocol(src_ts), dst_ts->get_protocol(dst_ts));
        policy->src.proto = policy->src.proto ? policy->src.proto : IPSEC_PROTO_ANY;
        policy->dst.proto = policy->src.proto;
-       
+
        return policy;
 }
 
@@ -328,7 +328,7 @@ struct pfkey_msg_t
         * PF_KEY message base
         */
        struct sadb_msg *msg;
-       
+
        /**
         * PF_KEY message extensions
         */
@@ -518,7 +518,7 @@ struct kernel_algorithm_t {
         * Identifier specified in IKEv2
         */
        int ikev2;
-       
+
        /**
         * Identifier as defined in pfkeyv2.h
         */
@@ -652,19 +652,19 @@ static void add_encap_ext(struct sadb_msg *msg, host_t *src, host_t *dst)
 {
        struct sadb_x_nat_t_type* nat_type;
        struct sadb_x_nat_t_port* nat_port;
-       
+
        nat_type = (struct sadb_x_nat_t_type*)PFKEY_EXT_ADD_NEXT(msg);
        nat_type->sadb_x_nat_t_type_exttype = SADB_X_EXT_NAT_T_TYPE;
        nat_type->sadb_x_nat_t_type_len = PFKEY_LEN(sizeof(struct sadb_x_nat_t_type));
        nat_type->sadb_x_nat_t_type_type = UDP_ENCAP_ESPINUDP;
        PFKEY_EXT_ADD(msg, nat_type);
-       
+
        nat_port = (struct sadb_x_nat_t_port*)PFKEY_EXT_ADD_NEXT(msg);
        nat_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_SPORT;
        nat_port->sadb_x_nat_t_port_len = PFKEY_LEN(sizeof(struct sadb_x_nat_t_port));
        nat_port->sadb_x_nat_t_port_port = htons(src->get_port(src));
        PFKEY_EXT_ADD(msg, nat_port);
-       
+
        nat_port = (struct sadb_x_nat_t_port*)PFKEY_EXT_ADD_NEXT(msg);
        nat_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_DPORT;
        nat_port->sadb_x_nat_t_port_len = PFKEY_LEN(sizeof(struct sadb_x_nat_t_port));
@@ -697,15 +697,15 @@ static status_t parse_pfkey_message(struct sadb_msg *msg, pfkey_msg_t *out)
 {
        struct sadb_ext* ext;
        size_t len;
-       
+
        memset(out, 0, sizeof(pfkey_msg_t));
        out->msg = msg;
-       
+
        len = msg->sadb_msg_len;
        len -= PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        ext = (struct sadb_ext*)(((char*)msg) + sizeof(struct sadb_msg));
-       
+
        while (len >= PFKEY_LEN(sizeof(struct sadb_ext)))
        {
                DBG3(DBG_KNL, "  %N", sadb_ext_type_names, ext->sadb_ext_type);
@@ -716,20 +716,20 @@ static status_t parse_pfkey_message(struct sadb_msg *msg, pfkey_msg_t *out)
                                                   sadb_ext_type_names, ext->sadb_ext_type);
                        break;
                }
-               
+
                if ((ext->sadb_ext_type > SADB_EXT_MAX) || (!ext->sadb_ext_type))
                {
                        DBG1(DBG_KNL, "type of PF_KEY extension (%d) is invalid", ext->sadb_ext_type);
                        break;
                }
-               
+
                if (out->ext[ext->sadb_ext_type])
                {
                        DBG1(DBG_KNL, "duplicate %N extension",
                                                   sadb_ext_type_names, ext->sadb_ext_type);
                        break;
                }
-               
+
                out->ext[ext->sadb_ext_type] = ext;
                ext = PFKEY_EXT_NEXT_LEN(ext, len);
        }
@@ -739,7 +739,7 @@ static status_t parse_pfkey_message(struct sadb_msg *msg, pfkey_msg_t *out)
                DBG1(DBG_KNL, "PF_KEY message length is invalid");
                return FAILED;
        }
-       
+
        return SUCCESS;
 }
 
@@ -752,7 +752,7 @@ static status_t pfkey_send_socket(private_kernel_pfkey_ipsec_t *this, int socket
        unsigned char buf[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg;
        int in_len, len;
-       
+
        this->mutex_pfkey->lock(this->mutex_pfkey);
 
        /* FIXME: our usage of sequence numbers is probably wrong. check RFC 2367,
@@ -779,13 +779,13 @@ static status_t pfkey_send_socket(private_kernel_pfkey_ipsec_t *this, int socket
                }
                break;
        }
-       
+
        while (TRUE)
        {
                msg = (struct sadb_msg*)buf;
-               
+
                len = recv(socket, buf, sizeof(buf), 0);
-               
+
                if (len < 0)
                {
                        if (errno == EINTR)
@@ -844,13 +844,13 @@ static status_t pfkey_send_socket(private_kernel_pfkey_ipsec_t *this, int socket
                }
                break;
        }
-       
+
        *out_len = len;
        *out = (struct sadb_msg*)malloc(len);
        memcpy(*out, buf, len);
-       
+
        this->mutex_pfkey->unlock(this->mutex_pfkey);
-       
+
        return SUCCESS;
 }
 
@@ -873,7 +873,7 @@ static void process_acquire(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
        traffic_selector_t *src_ts, *dst_ts;
        policy_entry_t *policy;
        job_t *job;
-       
+
        switch (msg->sadb_msg_satype)
        {
                case SADB_SATYPE_UNSPEC:
@@ -885,13 +885,13 @@ static void process_acquire(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
                        return;
        }
        DBG2(DBG_KNL, "received an SADB_ACQUIRE");
-       
+
        if (parse_pfkey_message(msg, &response) != SUCCESS)
        {
                DBG1(DBG_KNL, "parsing SADB_ACQUIRE from kernel failed");
                return;
        }
-       
+
        index = response.x_policy->sadb_x_policy_id;
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -907,7 +907,7 @@ static void process_acquire(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
        src_ts = sadb_address2ts(response.src);
        dst_ts = sadb_address2ts(response.dst);
        this->mutex->unlock(this->mutex);
-       
+
        DBG1(DBG_KNL, "creating acquire job for policy %R === %R with reqid {%u}",
                                   src_ts, dst_ts, reqid);
        job = (job_t*)acquire_job_create(reqid, src_ts, dst_ts);
@@ -924,27 +924,27 @@ static void process_expire(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
        u_int32_t spi, reqid;
        bool hard;
        job_t *job;
-       
+
        DBG2(DBG_KNL, "received an SADB_EXPIRE");
-       
+
        if (parse_pfkey_message(msg, &response) != SUCCESS)
        {
                DBG1(DBG_KNL, "parsing SADB_EXPIRE from kernel failed");
                return;
        }
-       
+
        protocol = proto_satype2ike(msg->sadb_msg_satype);
        spi = response.sa->sadb_sa_spi;
        reqid = response.x_sa2->sadb_x_sa2_reqid;
        hard = response.lft_hard != NULL;
-       
+
        if (protocol != PROTO_ESP && protocol != PROTO_AH)
        {
                DBG2(DBG_KNL, "ignoring SADB_EXPIRE for SA with SPI %.8x and reqid {%u} "
                                          "which is not a CHILD_SA", ntohl(spi), reqid);
                return;
        }
-       
+
        DBG1(DBG_KNL, "creating %s job for %N CHILD_SA with SPI %.8x and reqid {%u}",
                 hard ? "delete" : "rekey",  protocol_id_names,
                 protocol, ntohl(spi), reqid);
@@ -984,7 +984,7 @@ static void process_migrate(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
        dir = kernel2dir(response.x_policy->sadb_x_policy_dir);
        DBG2(DBG_KNL, "  policy %R === %R %N, id %u", src_ts, dst_ts,
                                         policy_dir_names, dir);
-       
+
        /* SADB_X_EXT_KMADDRESS is not present in unpatched kernels < 2.6.28 */
        if (response.x_kmaddress)
        {
@@ -999,7 +999,7 @@ static void process_migrate(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
                remote = host_create_from_sockaddr(remote_addr);
                DBG2(DBG_KNL, "  kmaddress: %H...%H", local, remote);
        }
-       
+
        if (src_ts && dst_ts && local && remote)
        {
                DBG1(DBG_KNL, "creating migrate job for policy %R === %R %N with reqid {%u}",
@@ -1028,24 +1028,24 @@ static void process_mapping(private_kernel_pfkey_ipsec_t *this, struct sadb_msg*
        u_int32_t spi, reqid;
        host_t *host;
        job_t *job;
-       
+
        DBG2(DBG_KNL, "received an SADB_X_NAT_T_NEW_MAPPING");
-       
+
        if (parse_pfkey_message(msg, &response) != SUCCESS)
        {
                DBG1(DBG_KNL, "parsing SADB_X_NAT_T_NEW_MAPPING from kernel failed");
                return;
        }
-       
+
        if (!response.x_sa2)
        {
                DBG1(DBG_KNL, "received SADB_X_NAT_T_NEW_MAPPING is missing required information");
                return;
        }
-       
+
        spi = response.sa->sadb_sa_spi;
        reqid = response.x_sa2->sadb_x_sa2_reqid;
-       
+
        if (proto_satype2ike(msg->sadb_msg_satype) == PROTO_ESP)
        {
                sockaddr_t *sa = (sockaddr_t*)(response.dst + 1);
@@ -1084,11 +1084,11 @@ static job_requeue_t receive_events(private_kernel_pfkey_ipsec_t *this)
        unsigned char buf[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg = (struct sadb_msg*)buf;
        int len, oldstate;
-       
+
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        len = recvfrom(this->socket_events, buf, sizeof(buf), 0, NULL, 0);
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (len < 0)
        {
                switch (errno)
@@ -1105,7 +1105,7 @@ static job_requeue_t receive_events(private_kernel_pfkey_ipsec_t *this)
                                return JOB_REQUEUE_FAIR;
                }
        }
-       
+
        if (len < sizeof(struct sadb_msg) ||
                msg->sadb_msg_len < PFKEY_LEN(sizeof(struct sadb_msg)))
        {
@@ -1121,7 +1121,7 @@ static job_requeue_t receive_events(private_kernel_pfkey_ipsec_t *this)
                DBG1(DBG_KNL, "buffer was too small to receive the complete PF_KEY message");
                return JOB_REQUEUE_DIRECT;
        }
-       
+
        switch (msg->sadb_msg_type)
        {
                case SADB_ACQUIRE:
@@ -1143,7 +1143,7 @@ static job_requeue_t receive_events(private_kernel_pfkey_ipsec_t *this)
                default:
                        break;
        }
-       
+
        return JOB_REQUEUE_DIRECT;
 }
 
@@ -1162,31 +1162,31 @@ static status_t get_spi(private_kernel_pfkey_ipsec_t *this,
        pfkey_msg_t response;
        u_int32_t received_spi = 0;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_GETSPI;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa2 = (struct sadb_x_sa2*)PFKEY_EXT_ADD_NEXT(msg);
        sa2->sadb_x_sa2_exttype = SADB_X_EXT_SA2;
        sa2->sadb_x_sa2_len = PFKEY_LEN(sizeof(struct sadb_spirange));
        sa2->sadb_x_sa2_reqid = reqid;
        PFKEY_EXT_ADD(msg, sa2);
-       
+
        add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC, 0, 0);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST, 0, 0);
-       
+
        range = (struct sadb_spirange*)PFKEY_EXT_ADD_NEXT(msg);
        range->sadb_spirange_exttype = SADB_EXT_SPIRANGE;
        range->sadb_spirange_len = PFKEY_LEN(sizeof(struct sadb_spirange));
        range->sadb_spirange_min = 0xc0000000;
        range->sadb_spirange_max = 0xcFFFFFFF;
        PFKEY_EXT_ADD(msg, range);
-       
+
        if (pfkey_send(this, msg, &out, &len) == SUCCESS)
        {
                if (out->sadb_msg_errno)
@@ -1200,12 +1200,12 @@ static status_t get_spi(private_kernel_pfkey_ipsec_t *this,
                }
                free(out);
        }
-       
+
        if (received_spi == 0)
        {
                return FAILED;
        }
-       
+
        *spi = received_spi;
        return SUCCESS;
 }
@@ -1239,11 +1239,11 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
        struct sadb_lifetime *lft;
        struct sadb_key *key;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "adding SAD entry with SPI %.8x and reqid {%u}", ntohl(spi), reqid);
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = inbound ? SADB_UPDATE : SADB_ADD;
@@ -1273,17 +1273,17 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
        sa->sadb_sa_auth = lookup_algorithm(integrity_algs, int_alg);
        sa->sadb_sa_encrypt = lookup_algorithm(encryption_algs, enc_alg);
        PFKEY_EXT_ADD(msg, sa);
-       
+
        sa2 = (struct sadb_x_sa2*)PFKEY_EXT_ADD_NEXT(msg);
        sa2->sadb_x_sa2_exttype = SADB_X_EXT_SA2;
        sa2->sadb_x_sa2_len = PFKEY_LEN(sizeof(struct sadb_spirange));
        sa2->sadb_x_sa2_mode = mode2kernel(mode);
        sa2->sadb_x_sa2_reqid = reqid;
        PFKEY_EXT_ADD(msg, sa2);
-       
+
        add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC, 0, 0);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST, 0, 0);
-       
+
        lft = (struct sadb_lifetime*)PFKEY_EXT_ADD_NEXT(msg);
        lft->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT;
        lft->sadb_lifetime_len = PFKEY_LEN(sizeof(struct sadb_lifetime));
@@ -1292,7 +1292,7 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
        lft->sadb_lifetime_addtime = lifetime->time.rekey;
        lft->sadb_lifetime_usetime = 0; /* we only use addtime */
        PFKEY_EXT_ADD(msg, lft);
-       
+
        lft = (struct sadb_lifetime*)PFKEY_EXT_ADD_NEXT(msg);
        lft->sadb_lifetime_exttype = SADB_EXT_LIFETIME_HARD;
        lft->sadb_lifetime_len = PFKEY_LEN(sizeof(struct sadb_lifetime));
@@ -1301,7 +1301,7 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
        lft->sadb_lifetime_addtime = lifetime->time.life;
        lft->sadb_lifetime_usetime = 0; /* we only use addtime */
        PFKEY_EXT_ADD(msg, lft);
-       
+
        if (enc_alg != ENCR_UNDEFINED)
        {
                if (!sa->sadb_sa_encrypt)
@@ -1312,16 +1312,16 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
                }
                DBG2(DBG_KNL, "  using encryption algorithm %N with key size %d",
                         encryption_algorithm_names, enc_alg, enc_key.len * 8);
-               
+
                key = (struct sadb_key*)PFKEY_EXT_ADD_NEXT(msg);
                key->sadb_key_exttype = SADB_EXT_KEY_ENCRYPT;
                key->sadb_key_bits = enc_key.len * 8;
                key->sadb_key_len = PFKEY_LEN(sizeof(struct sadb_key) + enc_key.len);
                memcpy(key + 1, enc_key.ptr, enc_key.len);
-               
+
                PFKEY_EXT_ADD(msg, key);
        }
-       
+
        if (int_alg != AUTH_UNDEFINED)
        {
                if (!sa->sadb_sa_auth)
@@ -1332,16 +1332,16 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
                }
                DBG2(DBG_KNL, "  using integrity algorithm %N with key size %d",
                         integrity_algorithm_names, int_alg, int_key.len * 8);
-               
+
                key = (struct sadb_key*)PFKEY_EXT_ADD_NEXT(msg);
                key->sadb_key_exttype = SADB_EXT_KEY_AUTH;
                key->sadb_key_bits = int_key.len * 8;
                key->sadb_key_len = PFKEY_LEN(sizeof(struct sadb_key) + int_key.len);
                memcpy(key + 1, int_key.ptr, int_key.len);
-               
+
                PFKEY_EXT_ADD(msg, key);
        }
-       
+
        if (ipcomp != IPCOMP_NONE)
        {
                /*TODO*/
@@ -1353,7 +1353,7 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
                add_encap_ext(msg, src, dst);
        }
 #endif /*HAVE_NATT*/
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to add SAD entry with SPI %.8x", ntohl(spi));
@@ -1366,7 +1366,7 @@ static status_t add_sa(private_kernel_pfkey_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        free(out);
        return SUCCESS;
 }
@@ -1385,7 +1385,7 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
        struct sadb_sa *sa;
        pfkey_msg_t response;
        size_t len;
-       
+
        /* we can't update the SA if any of the ip addresses have changed.
         * that's because we can't use SADB_UPDATE and by deleting and readding the
         * SA the sequence numbers would get lost */
@@ -1396,28 +1396,28 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
                                " are not supported", ntohl(spi));
                return NOT_SUPPORTED;
        }
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "querying SAD entry with SPI %.8x", ntohl(spi));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_GET;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_spi = spi;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        /* the kernel wants a SADB_EXT_ADDRESS_SRC to be present even though
         * it is not used for anything. */
        add_anyaddr_ext(msg, dst->get_family(dst), SADB_EXT_ADDRESS_SRC);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST, 0, 0);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to query SAD entry with SPI %.8x",
@@ -1438,18 +1438,18 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        DBG2(DBG_KNL, "updating SAD entry with SPI %.8x from %#H..%#H to %#H..%#H",
                 ntohl(spi), src, dst, new_src, new_dst);
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_UPDATE;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
 #ifdef __APPLE__
        {
                struct sadb_sa_2 *sa_2;
@@ -1466,32 +1466,32 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
        PFKEY_EXT_COPY(msg, response.sa);
 #endif
        PFKEY_EXT_COPY(msg, response.x_sa2);
-       
+
        PFKEY_EXT_COPY(msg, response.src);
        PFKEY_EXT_COPY(msg, response.dst);
-       
+
        PFKEY_EXT_COPY(msg, response.lft_soft);
        PFKEY_EXT_COPY(msg, response.lft_hard);
-       
+
        if (response.key_encr)
        {
                PFKEY_EXT_COPY(msg, response.key_encr);
        }
-       
+
        if (response.key_auth)
        {
                PFKEY_EXT_COPY(msg, response.key_auth);
        }
-       
+
 #ifdef HAVE_NATT
        if (new_encap)
        {
                add_encap_ext(msg, new_src, new_dst);
        }
 #endif /*HAVE_NATT*/
-       
+
        free(out);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to update SAD entry with SPI %.8x", ntohl(spi));
@@ -1505,7 +1505,7 @@ static status_t update_sa(private_kernel_pfkey_ipsec_t *this,
                return FAILED;
        }
        free(out);
-       
+
        return SUCCESS;
 }
 
@@ -1521,29 +1521,29 @@ static status_t query_sa(private_kernel_pfkey_ipsec_t *this, host_t *src,
        struct sadb_sa *sa;
        pfkey_msg_t response;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "querying SAD entry with SPI %.8x", ntohl(spi));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_GET;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_spi = spi;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        /* the Linux Kernel doesn't care for the src address, but other systems do
         * (e.g. FreeBSD)
         */
        add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC, 0, 0);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST, 0, 0);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to query SAD entry with SPI %.8x", ntohl(spi));
@@ -1579,29 +1579,29 @@ static status_t del_sa(private_kernel_pfkey_ipsec_t *this, host_t *src,
        struct sadb_msg *msg, *out;
        struct sadb_sa *sa;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "deleting SAD entry with SPI %.8x", ntohl(spi));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_DELETE;
        msg->sadb_msg_satype = proto_ike2satype(protocol);
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        sa = (struct sadb_sa*)PFKEY_EXT_ADD_NEXT(msg);
        sa->sadb_sa_exttype = SADB_EXT_SA;
        sa->sadb_sa_len = PFKEY_LEN(sizeof(struct sadb_sa));
        sa->sadb_sa_spi = spi;
        PFKEY_EXT_ADD(msg, sa);
-       
+
        /* the Linux Kernel doesn't care for the src address, but other systems do
         * (e.g. FreeBSD)
         */
        add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC, 0, 0);
        add_addr_ext(msg, dst, SADB_EXT_ADDRESS_DST, 0, 0);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to delete SAD entry with SPI %.8x", ntohl(spi));
@@ -1614,7 +1614,7 @@ static status_t del_sa(private_kernel_pfkey_ipsec_t *this, host_t *src,
                free(out);
                return FAILED;
        }
-       
+
        DBG2(DBG_KNL, "deleted SAD entry with SPI %.8x", ntohl(spi));
        free(out);
        return SUCCESS;
@@ -1639,16 +1639,16 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
        policy_entry_t *policy, *found = NULL;
        pfkey_msg_t response;
        size_t len;
-       
+
        if (dir2kernel(direction) == IPSEC_DIR_INVALID)
        {
                /* FWD policies are not supported on all platforms */
                return SUCCESS;
        }
-       
+
        /* create a policy */
        policy = create_policy_entry(src_ts, dst_ts, direction, reqid);
-       
+
        /* find a matching policy */
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -1668,18 +1668,18 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
                this->policies->insert_last(this->policies, policy);
                policy->refcount = 1;
        }
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        DBG2(DBG_KNL, "adding policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = found ? SADB_X_SPDUPDATE : SADB_X_SPDADD;
        msg->sadb_msg_satype = 0;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        pol = (struct sadb_x_policy*)PFKEY_EXT_ADD_NEXT(msg);
        pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
        pol->sadb_x_policy_len = PFKEY_LEN(sizeof(struct sadb_x_policy));
@@ -1693,7 +1693,7 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
        pol->sadb_x_policy_priority -= policy->src.proto != IPSEC_PROTO_ANY ? 2 : 0;
        pol->sadb_x_policy_priority -= policy->src.net->get_port(policy->src.net) ? 1 : 0;
 #endif
-       
+
        /* one or more sadb_x_ipsecrequest extensions are added to the sadb_x_policy extension */
        req = (struct sadb_x_ipsecrequest*)(pol + 1);
        req->sadb_x_ipsecrequest_proto = proto_ike2ip(protocol);
@@ -1713,15 +1713,15 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
                memcpy((u_int8_t*)(req + 1) + sl, sa, sl);
                req->sadb_x_ipsecrequest_len += sl * 2;
        }
-       
+
        pol->sadb_x_policy_len += PFKEY_LEN(req->sadb_x_ipsecrequest_len);
        PFKEY_EXT_ADD(msg, pol);
-       
+
        add_addr_ext(msg, policy->src.net, SADB_EXT_ADDRESS_SRC, policy->src.proto,
                                 policy->src.mask);
        add_addr_ext(msg, policy->dst.net, SADB_EXT_ADDRESS_DST, policy->dst.proto,
                                 policy->dst.mask);
-       
+
 #ifdef __FreeBSD__
        {       /* on FreeBSD a lifetime has to be defined to be able to later query
                 * the current use time. */
@@ -1733,9 +1733,9 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
                PFKEY_EXT_ADD(msg, lft);
        }
 #endif
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to add policy %R === %R %N", src_ts, dst_ts,
@@ -1757,9 +1757,9 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
                free(out);
                return FAILED;
        }
-       
+
        this->mutex->lock(this->mutex);
-       
+
        /* we try to find the policy again and update the kernel index */
        if (this->policies->find_last(this->policies, NULL, (void**)&policy) != SUCCESS)
        {
@@ -1771,7 +1771,7 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
        }
        policy->index = response.x_policy->sadb_x_policy_id;
        free(out);
-       
+
        /* install a route, if:
         * - we are NOT updating a policy
         * - this is a forward policy (to just get one for each child)
@@ -1784,7 +1784,7 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
                this->install_routes)
        {
                route_entry_t *route = malloc_thing(route_entry_t);
-               
+
                if (charon->kernel_interface->get_address_by_ts(charon->kernel_interface,
                                dst_ts, &route->src_ip) == SUCCESS)
                {
@@ -1795,7 +1795,7 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
                                                                        charon->kernel_interface, dst);
                        route->dst_net = chunk_clone(policy->src.net->get_address(policy->src.net));
                        route->prefixlen = policy->src.mask;
-                       
+
                        switch (charon->kernel_interface->add_route(charon->kernel_interface,
                                        route->dst_net, route->prefixlen, route->gateway,
                                        route->src_ip, route->if_name))
@@ -1819,9 +1819,9 @@ static status_t add_policy(private_kernel_pfkey_ipsec_t *this,
                        free(route);
                }
        }
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        return SUCCESS;
 }
 
@@ -1839,19 +1839,19 @@ static status_t query_policy(private_kernel_pfkey_ipsec_t *this,
        policy_entry_t *policy, *found = NULL;
        pfkey_msg_t response;
        size_t len;
-       
+
        if (dir2kernel(direction) == IPSEC_DIR_INVALID)
        {
                /* FWD policies are not supported on all platforms */
                return NOT_FOUND;
        }
-       
+
        DBG2(DBG_KNL, "querying policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
 
        /* create a policy */
        policy = create_policy_entry(src_ts, dst_ts, direction, 0);
-       
+
        /* find a matching policy */
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -1865,15 +1865,15 @@ static status_t query_policy(private_kernel_pfkey_ipsec_t *this,
        }
        policy_entry_destroy(policy);
        policy = found;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_X_SPDGET;
        msg->sadb_msg_satype = 0;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        pol = (struct sadb_x_policy*)PFKEY_EXT_ADD_NEXT(msg);
        pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
        pol->sadb_x_policy_id = policy->index;
@@ -1881,14 +1881,14 @@ static status_t query_policy(private_kernel_pfkey_ipsec_t *this,
        pol->sadb_x_policy_dir = dir2kernel(direction);
        pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
        PFKEY_EXT_ADD(msg, pol);
-       
+
        add_addr_ext(msg, policy->src.net, SADB_EXT_ADDRESS_SRC, policy->src.proto,
                                 policy->src.mask);
        add_addr_ext(msg, policy->dst.net, SADB_EXT_ADDRESS_DST, policy->dst.proto,
                                 policy->dst.mask);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to query policy %R === %R %N", src_ts, dst_ts,
@@ -1928,7 +1928,7 @@ static status_t query_policy(private_kernel_pfkey_ipsec_t *this,
                *use_time = 0;
        }
        free(out);
-       
+
        return SUCCESS;
 }
 
@@ -1946,19 +1946,19 @@ static status_t del_policy(private_kernel_pfkey_ipsec_t *this,
        policy_entry_t *policy, *found = NULL;
        route_entry_t *route;
        size_t len;
-       
+
        if (dir2kernel(direction) == IPSEC_DIR_INVALID)
        {
                /* FWD policies are not supported on all platforms */
                return SUCCESS;
        }
-       
+
        DBG2(DBG_KNL, "deleting policy %R === %R %N", src_ts, dst_ts,
                                   policy_dir_names, direction);
-       
+
        /* create a policy */
        policy = create_policy_entry(src_ts, dst_ts, direction, 0);
-       
+
        /* find a matching policy */
        this->mutex->lock(this->mutex);
        if (this->policies->find_first(this->policies,
@@ -1986,31 +1986,31 @@ static status_t del_policy(private_kernel_pfkey_ipsec_t *this,
                return NOT_FOUND;
        }
        this->mutex->unlock(this->mutex);
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_X_SPDDELETE;
        msg->sadb_msg_satype = 0;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        pol = (struct sadb_x_policy*)PFKEY_EXT_ADD_NEXT(msg);
        pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
        pol->sadb_x_policy_len = PFKEY_LEN(sizeof(struct sadb_x_policy));
        pol->sadb_x_policy_dir = dir2kernel(direction);
        pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
        PFKEY_EXT_ADD(msg, pol);
-       
+
        add_addr_ext(msg, policy->src.net, SADB_EXT_ADDRESS_SRC, policy->src.proto,
                                 policy->src.mask);
        add_addr_ext(msg, policy->dst.net, SADB_EXT_ADDRESS_DST, policy->dst.proto,
                                 policy->dst.mask);
-       
+
        route = policy->route;
        policy->route = NULL;
        policy_entry_destroy(policy);
-       
+
        if (pfkey_send(this, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to delete policy %R === %R %N", src_ts, dst_ts,
@@ -2026,7 +2026,7 @@ static status_t del_policy(private_kernel_pfkey_ipsec_t *this,
                return FAILED;
        }
        free(out);
-       
+
        if (route)
        {
                if (charon->kernel_interface->del_route(charon->kernel_interface,
@@ -2039,7 +2039,7 @@ static status_t del_policy(private_kernel_pfkey_ipsec_t *this,
                }
                route_entry_destroy(route);
        }
-       
+
        return SUCCESS;
 }
 
@@ -2051,15 +2051,15 @@ static status_t register_pfkey_socket(private_kernel_pfkey_ipsec_t *this, u_int8
        unsigned char request[PFKEY_BUFFER_SIZE];
        struct sadb_msg *msg, *out;
        size_t len;
-       
+
        memset(&request, 0, sizeof(request));
-       
+
        msg = (struct sadb_msg*)request;
        msg->sadb_msg_version = PF_KEY_V2;
        msg->sadb_msg_type = SADB_REGISTER;
        msg->sadb_msg_satype = satype;
        msg->sadb_msg_len = PFKEY_LEN(sizeof(struct sadb_msg));
-       
+
        if (pfkey_send_socket(this, this->socket_events, msg, &out, &len) != SUCCESS)
        {
                DBG1(DBG_KNL, "unable to register PF_KEY socket");
@@ -2098,13 +2098,13 @@ static bool add_bypass_policies(private_kernel_pfkey_ipsec_t *this)
        int fd, family, port;
        enumerator_t *sockets;
        bool status = TRUE;
-       
+
        sockets = charon->socket->create_enumerator(charon->socket);
        while (sockets->enumerate(sockets, &fd, &family, &port))
        {
                struct sadb_x_policy policy;
                u_int sol, ipsec_policy;
-               
+
                switch (family)
                {
                        case AF_INET:
@@ -2122,12 +2122,12 @@ static bool add_bypass_policies(private_kernel_pfkey_ipsec_t *this)
                        default:
                                continue;
                }
-               
+
                memset(&policy, 0, sizeof(policy));
                policy.sadb_x_policy_len = sizeof(policy) / sizeof(u_int64_t);
                policy.sadb_x_policy_exttype = SADB_X_EXT_POLICY;
                policy.sadb_x_policy_type = IPSEC_POLICY_BYPASS;
-               
+
                policy.sadb_x_policy_dir = IPSEC_DIR_OUTBOUND;
                if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
                {
@@ -2155,7 +2155,7 @@ static bool add_bypass_policies(private_kernel_pfkey_ipsec_t *this)
 kernel_pfkey_ipsec_t *kernel_pfkey_ipsec_create()
 {
        private_kernel_pfkey_ipsec_t *this = malloc_thing(private_kernel_pfkey_ipsec_t);
-       
+
        /* public functions */
        this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
        this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
@@ -2166,7 +2166,7 @@ kernel_pfkey_ipsec_t *kernel_pfkey_ipsec_create()
        this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
        this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
        this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
-       
+
        this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
 
        /* private members */
@@ -2176,37 +2176,37 @@ kernel_pfkey_ipsec_t *kernel_pfkey_ipsec_create()
        this->install_routes = lib->settings->get_bool(lib->settings,
                                                                                                "charon.install_routes", TRUE);
        this->seq = 0;
-       
+
        /* create a PF_KEY socket to communicate with the kernel */
        this->socket = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
        if (this->socket <= 0)
        {
                charon->kill(charon, "unable to create PF_KEY socket");
        }
-       
+
        /* create a PF_KEY socket for ACQUIRE & EXPIRE */
        this->socket_events = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
        if (this->socket_events <= 0)
        {
                charon->kill(charon, "unable to create PF_KEY event socket");
        }
-       
+
        /* add bypass policies on the sockets used by charon */
        if (!add_bypass_policies(this))
        {
                charon->kill(charon, "unable to add bypass policies on sockets");
        }
-       
+
        /* register the event socket */
        if (register_pfkey_socket(this, SADB_SATYPE_ESP) != SUCCESS ||
                register_pfkey_socket(this, SADB_SATYPE_AH) != SUCCESS)
        {
                charon->kill(charon, "unable to register PF_KEY event socket");
        }
-       
+
        this->job = callback_job_create((callback_job_cb_t)receive_events,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public;
 }
index 09dc4780d49bdbf03132d8fbcb520804f272adce..3380c328c375532700865cdd70976d262b1801ae 100644 (file)
@@ -47,10 +47,10 @@ static void destroy(private_kernel_pfkey_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_kernel_pfkey_plugin_t *this = malloc_thing(private_kernel_pfkey_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->kernel_interface->add_ipsec_interface(charon->kernel_interface, (kernel_ipsec_constructor_t)kernel_pfkey_ipsec_create);
-       
+
        return &this->public.plugin;
 }
index da97fcd83469e5736fc8886c1a3e7b28b9f35540..768810411032e3cc50a75b6e66a66504fe740157 100644 (file)
@@ -47,13 +47,13 @@ typedef struct addr_entry_t addr_entry_t;
  * IP address in an inface_entry_t
  */
 struct addr_entry_t {
-       
+
        /** The ip address */
        host_t *ip;
-       
+
        /** virtual IP managed by us */
        bool virtual;
-       
+
        /** Number of times this IP is used, if virtual */
        u_int refcount;
 };
@@ -73,16 +73,16 @@ typedef struct iface_entry_t iface_entry_t;
  * A network interface on this system, containing addr_entry_t's
  */
 struct iface_entry_t {
-       
+
        /** interface index */
        int ifindex;
-       
+
        /** name of the interface */
        char ifname[IFNAMSIZ];
-       
+
        /** interface flags, as in netdevice(7) SIOCGIFFLAGS */
        u_int flags;
-       
+
        /** list of addresses as host_t */
        linked_list_t *addrs;
 };
@@ -108,42 +108,42 @@ struct private_kernel_pfroute_net_t
         * Public part of the kernel_pfroute_t object.
         */
        kernel_pfroute_net_t public;
-       
+
        /**
         * mutex to lock access to various lists
         */
        mutex_t *mutex;
-       
+
        /**
         * Cached list of interfaces and their addresses (iface_entry_t)
         */
        linked_list_t *ifaces;
-       
+
        /**
         * job receiving PF_ROUTE events
         */
        callback_job_t *job;
-       
+
        /**
         * mutex to lock access to the PF_ROUTE socket
         */
        mutex_t *mutex_pfroute;
-       
+
        /**
         * PF_ROUTE socket to communicate with the kernel
         */
        int socket;
-       
+
        /**
         * PF_ROUTE socket to receive events
         */
        int socket_events;
-       
+
        /**
         * sequence number for messages sent to the kernel
         */
        int seq;
-       
+
        /**
         * time of last roam job
         */
@@ -157,7 +157,7 @@ struct private_kernel_pfroute_net_t
 static void fire_roam_job(private_kernel_pfroute_net_t *this, bool address)
 {
        timeval_t now;
-       
+
        time_monotonic(&now);
        if (timercmp(&now, &this->last_roam, >))
        {
@@ -187,7 +187,7 @@ static void process_addr(private_kernel_pfroute_net_t *this,
        addr_entry_t *addr;
        bool found = FALSE, changed = FALSE, roam = FALSE;
        int i;
-       
+
        for (i = 1; i < (1 << RTAX_MAX); i <<= 1)
        {
                if (ifa->ifam_addrs & i)
@@ -200,12 +200,12 @@ static void process_addr(private_kernel_pfroute_net_t *this,
                        sockaddr = (sockaddr_t*)((char*)sockaddr + sockaddr->sa_len);
                }
        }
-       
+
        if (!host)
        {
                return;
        }
-       
+
        this->mutex->lock(this->mutex);
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
@@ -236,7 +236,7 @@ static void process_addr(private_kernel_pfroute_net_t *this,
                                }
                        }
                        addrs->destroy(addrs);
-                       
+
                        if (!found && ifa->ifam_type == RTM_NEWADDR)
                        {
                                changed = TRUE;
@@ -247,7 +247,7 @@ static void process_addr(private_kernel_pfroute_net_t *this,
                                iface->addrs->insert_last(iface->addrs, addr);
                                DBG1(DBG_KNL, "%H appeared on %s", host, iface->ifname);
                        }
-                       
+
                        if (changed && (iface->flags & IFF_UP))
                        {
                                roam = TRUE;
@@ -258,7 +258,7 @@ static void process_addr(private_kernel_pfroute_net_t *this,
        ifaces->destroy(ifaces);
        this->mutex->unlock(this->mutex);
        host->destroy(host);
-       
+
        if (roam)
        {
                fire_roam_job(this, TRUE);
@@ -275,12 +275,12 @@ static void process_link(private_kernel_pfroute_net_t *this,
        enumerator_t *enumerator;
        iface_entry_t *iface;
        bool roam = FALSE;
-       
+
        if (msg->ifm_flags & IFF_LOOPBACK)
        {       /* ignore loopback interfaces */
                return;
        }
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->ifaces->create_enumerator(this->ifaces);
        while (enumerator->enumerate(enumerator, &iface))
@@ -303,7 +303,7 @@ static void process_link(private_kernel_pfroute_net_t *this,
        }
        enumerator->destroy(enumerator);
        this->mutex->unlock(this->mutex);
-       
+
        if (roam)
        {
                fire_roam_job(this, TRUE);
@@ -327,11 +327,11 @@ static job_requeue_t receive_events(private_kernel_pfroute_net_t *this)
        unsigned char buf[PFROUTE_BUFFER_SIZE];
        struct rt_msghdr *msg = (struct rt_msghdr*)buf;
        int len, oldstate;
-       
+
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        len = recvfrom(this->socket_events, buf, sizeof(buf), 0, NULL, 0);
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (len < 0)
        {
                switch (errno)
@@ -348,14 +348,14 @@ static job_requeue_t receive_events(private_kernel_pfroute_net_t *this)
                                return JOB_REQUEUE_FAIR;
                }
        }
-       
+
        if (len < sizeof(msg->rtm_msglen) || len < msg->rtm_msglen ||
                msg->rtm_version != RTM_VERSION)
        {
                DBG2(DBG_KNL, "received corrupted PF_ROUTE message");
                return JOB_REQUEUE_DIRECT;
        }
-       
+
        switch (msg->rtm_type)
        {
                case RTM_NEWADDR:
@@ -372,7 +372,7 @@ static job_requeue_t receive_events(private_kernel_pfroute_net_t *this)
                default:
                        break;
        }
-       
+
        return JOB_REQUEUE_DIRECT;
 }
 
@@ -491,7 +491,7 @@ static char *get_interface_name(private_kernel_pfroute_net_t *this, host_t* ip)
        }
        ifaces->destroy(ifaces);
        this->mutex->unlock(this->mutex);
-       
+
        if (name)
        {
                DBG2(DBG_KNL, "%H is on interface %s", ip, name);
@@ -564,15 +564,15 @@ static status_t init_address_list(private_kernel_pfroute_net_t *this)
        iface_entry_t *iface, *current;
        addr_entry_t *addr;
        enumerator_t *ifaces, *addrs;
-       
+
        DBG1(DBG_KNL, "listening on interfaces:");
-       
+
        if (getifaddrs(&ifap) < 0)
        {
                DBG1(DBG_KNL, "  failed to get interfaces!");
                return FAILED;
        }
-       
+
        for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next)
        {
                if (ifa->ifa_addr == NULL)
@@ -589,7 +589,7 @@ static status_t init_address_list(private_kernel_pfroute_net_t *this)
                                {       /* ignore loopback interfaces */
                                        continue;
                                }
-                               
+
                                iface = NULL;
                                ifaces = this->ifaces->create_enumerator(this->ifaces);
                                while (ifaces->enumerate(ifaces, &current))
@@ -601,7 +601,7 @@ static status_t init_address_list(private_kernel_pfroute_net_t *this)
                                        }
                                }
                                ifaces->destroy(ifaces);
-                               
+
                                if (!iface)
                                {
                                        iface = malloc_thing(iface_entry_t);
@@ -611,7 +611,7 @@ static status_t init_address_list(private_kernel_pfroute_net_t *this)
                                        iface->addrs = linked_list_create();
                                        this->ifaces->insert_last(this->ifaces, iface);
                                }
-                               
+
                                if (ifa->ifa_addr->sa_family != AF_LINK)
                                {
                                        addr = malloc_thing(addr_entry_t);
@@ -624,7 +624,7 @@ static status_t init_address_list(private_kernel_pfroute_net_t *this)
                }
        }
        freeifaddrs(ifap);
-       
+
        ifaces = this->ifaces->create_enumerator(this->ifaces);
        while (ifaces->enumerate(ifaces, &iface))
        {
@@ -640,7 +640,7 @@ static status_t init_address_list(private_kernel_pfroute_net_t *this)
                }
        }
        ifaces->destroy(ifaces);
-       
+
        return SUCCESS;
 }
 
@@ -664,7 +664,7 @@ static void destroy(private_kernel_pfroute_net_t *this)
 kernel_pfroute_net_t *kernel_pfroute_net_create()
 {
        private_kernel_pfroute_net_t *this = malloc_thing(private_kernel_pfroute_net_t);
-       
+
        /* public functions */
        this->public.interface.get_interface = (char*(*)(kernel_net_t*,host_t*))get_interface_name;
        this->public.interface.create_address_enumerator = (enumerator_t*(*)(kernel_net_t*,bool,bool))create_address_enumerator;
@@ -674,38 +674,38 @@ kernel_pfroute_net_t *kernel_pfroute_net_create()
        this->public.interface.del_ip = (status_t(*)(kernel_net_t*,host_t*)) del_ip;
        this->public.interface.add_route = (status_t(*)(kernel_net_t*,chunk_t,u_int8_t,host_t*,host_t*,char*)) add_route;
        this->public.interface.del_route = (status_t(*)(kernel_net_t*,chunk_t,u_int8_t,host_t*,host_t*,char*)) del_route;
-       
+
        this->public.interface.destroy = (void(*)(kernel_net_t*)) destroy;
-       
+
        /* private members */
        this->ifaces = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->mutex_pfroute = mutex_create(MUTEX_TYPE_DEFAULT);
-       
+
        this->seq = 0;
-       
+
        /* create a PF_ROUTE socket to communicate with the kernel */
        this->socket = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
        if (this->socket <= 0)
        {
                charon->kill(charon, "unable to create PF_ROUTE socket");
        }
-       
+
        /* create a PF_ROUTE socket to receive events */
        this->socket_events = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
        if (this->socket_events <= 0)
        {
                charon->kill(charon, "unable to create PF_ROUTE event socket");
        }
-       
+
        this->job = callback_job_create((callback_job_cb_t)receive_events,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        if (init_address_list(this) != SUCCESS)
        {
                charon->kill(charon, "unable to get interface list");
        }
-       
+
        return &this->public;
 }
index 767049bb019f022766cddb86dc5ba36fd5b7cd44..e73cbeafb5341caaa8c501f3332aa8357a36ad18 100644 (file)
@@ -48,11 +48,11 @@ static void destroy(private_kernel_pfroute_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_kernel_pfroute_plugin_t *this = malloc_thing(private_kernel_pfroute_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        charon->kernel_interface->add_net_interface(charon->kernel_interface,
                                                (kernel_net_constructor_t)kernel_pfroute_net_create);
-       
+
        return &this->public.plugin;
 }
index aecaf624f5830c017d8031bb7e23838b6a427188..74a62f667b730817d9238669c2c8bbf0453dc80d 100644 (file)
@@ -28,52 +28,52 @@ struct private_load_tester_config_t {
         * Public part
         */
        load_tester_config_t public;
-       
+
        /**
         * peer config
         */
        peer_cfg_t *peer_cfg;
-       
+
        /**
         * virtual IP, if any
         */
        host_t *vip;
-       
+
        /**
         * Remote address
         */
        char *remote;
-       
+
        /**
         * IP address pool
         */
        char *pool;
-       
+
        /**
         * IKE proposal
         */
        proposal_t *proposal;
-       
+
        /**
         * Authentication method(s) to use/expect from initiator
         */
        char *initiator_auth;
-       
+
        /**
         * Authentication method(s) use/expected from responder
         */
        char *responder_auth;
-       
+
        /**
         * IKE_SA rekeying delay
         */
        u_int ike_rekey;
-       
+
        /**
         * CHILD_SA rekeying delay
         */
        u_int child_rekey;
-       
+
        /**
         * incremental numbering of generated configs
         */
@@ -93,13 +93,13 @@ static void generate_auth_cfg(private_load_tester_config_t *this, char *str,
        eap_type_t type;
        char buf[128];
        int rnd = 0;
-       
+
        enumerator = enumerator_create_token(str, "|", " ");
        while (enumerator->enumerate(enumerator, &str))
        {
                auth = auth_cfg_create();
                rnd++;
-               
+
                if (streq(str, "psk"))
                {       /* PSK authentication, use FQDNs */
                        class = AUTH_CLASS_PSK;
@@ -188,7 +188,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
                        .jitter = 0
                }
        };
-       
+
        ike_cfg = ike_cfg_create(FALSE, FALSE, "0.0.0.0", this->remote);
        ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
        peer_cfg = peer_cfg_create("load-test", 2, ike_cfg,
@@ -208,7 +208,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
                generate_auth_cfg(this, this->responder_auth, peer_cfg, TRUE, num);
                generate_auth_cfg(this, this->initiator_auth, peer_cfg, FALSE, num);
        }
-       
+
        child_cfg = child_cfg_create("load-test", &lifetime, NULL, TRUE,
                                                                 MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE);
        proposal = proposal_create_from_string(PROTO_ESP, "aes128-sha1");
@@ -225,7 +225,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
  * Implementation of backend_t.create_peer_cfg_enumerator.
  */
 static enumerator_t* create_peer_cfg_enumerator(private_load_tester_config_t *this,
-                                                                                               identification_t *me, 
+                                                                                               identification_t *me,
                                                                                                identification_t *other)
 {
        return enumerator_create_single(this->peer_cfg, NULL);
@@ -273,12 +273,12 @@ static void destroy(private_load_tester_config_t *this)
 load_tester_config_t *load_tester_config_create()
 {
        private_load_tester_config_t *this = malloc_thing(private_load_tester_config_t);
-       
+
        this->public.backend.create_peer_cfg_enumerator = (enumerator_t*(*)(backend_t*, identification_t *me, identification_t *other))create_peer_cfg_enumerator;
        this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
        this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
        this->public.destroy = (void(*)(load_tester_config_t*))destroy;
-       
+
        this->vip = NULL;
        if (lib->settings->get_bool(lib->settings,
                                "charon.plugins.load_tester.request_virtual_ip", FALSE))
@@ -287,9 +287,9 @@ load_tester_config_t *load_tester_config_create()
        }
        this->pool = lib->settings->get_str(lib->settings,
                                "charon.plugins.load_tester.pool", NULL);
-       this->remote = lib->settings->get_str(lib->settings, 
+       this->remote = lib->settings->get_str(lib->settings,
                                "charon.plugins.load_tester.remote", "127.0.0.1");
-                               
+
        this->proposal = proposal_create_from_string(PROTO_IKE,
                        lib->settings->get_str(lib->settings,
                                "charon.plugins.load_tester.proposal", "aes128-sha1-modp768"));
@@ -302,15 +302,15 @@ load_tester_config_t *load_tester_config_create()
                                "charon.plugins.load_tester.ike_rekey", 0);
        this->child_rekey = lib->settings->get_int(lib->settings,
                                "charon.plugins.load_tester.child_rekey", 600);
-       
+
        this->initiator_auth = lib->settings->get_str(lib->settings,
                                "charon.plugins.load_tester.initiator_auth", "pubkey");
        this->responder_auth = lib->settings->get_str(lib->settings,
                                "charon.plugins.load_tester.responder_auth", "pubkey");
-       
+
        this->num = 1;
        this->peer_cfg = generate_config(this, 0);
-       
+
        return &this->public;
 }
 
index f09a3f8328feb8340df7ddad505ab7de7d74ae97..c22387743f83db85b88a330dd6c2445ac076a3c8 100644 (file)
@@ -34,11 +34,11 @@ struct load_tester_config_t {
         * Implements backend_t interface
         */
        backend_t backend;
-       
+
        /**
         * Destroy the backend.
         */
-       void (*destroy)(load_tester_config_t *this);    
+       void (*destroy)(load_tester_config_t *this);
 };
 
 /**
index b32380d306c8af1ea3f000cec9f8b181b76198ad..ec3606c0b509284bace9c77e19d12b2f2a9cbf7d 100644 (file)
@@ -32,27 +32,27 @@ struct private_load_tester_creds_t {
         * Public part
         */
        load_tester_creds_t public;
-       
+
        /**
         * Private key to create signatures
         */
        private_key_t *private;
-       
+
        /**
         * CA certificate, to issue/verify peer certificates
         */
        certificate_t *ca;
-       
+
        /**
         * serial number to issue certificates
         */
        u_int32_t serial;
-       
+
        /**
         * Preshared key
         */
        shared_key_t *shared;
-       
+
        /**
         * Identification for shared key
         */
@@ -196,7 +196,7 @@ static enumerator_t* create_private_enumerator(private_load_tester_creds_t *this
        if (id)
        {
                chunk_t keyid;
-               
+
                if (!this->private->get_fingerprint(this->private,
                                                                                        KEY_ID_PUBKEY_SHA1, &keyid) ||
                        !chunk_equals(keyid, id->get_encoding(id)))
@@ -219,7 +219,7 @@ static enumerator_t* create_cert_enumerator(private_load_tester_creds_t *this,
        u_int32_t serial;
        time_t now;
        chunk_t keyid;
-       
+
        if (this->ca == NULL)
        {
                return NULL;
@@ -278,7 +278,7 @@ static enumerator_t* create_cert_enumerator(private_load_tester_creds_t *this,
 /**
  * Implements credential_set_t.create_shared_enumerator
  */
-static enumerator_t* create_shared_enumerator(private_load_tester_creds_t *this, 
+static enumerator_t* create_shared_enumerator(private_load_tester_creds_t *this,
                                                        shared_key_type_t type, identification_t *me,
                                                        identification_t *other)
 {
@@ -319,17 +319,17 @@ load_tester_creds_t *load_tester_creds_create()
        this->public.credential_set.create_cdp_enumerator  = (enumerator_t*(*) (credential_set_t *,certificate_type_t, identification_t *))return_null;
        this->public.credential_set.cache_cert = (void (*)(credential_set_t *, certificate_t *))nop;
        this->public.destroy = (void(*) (load_tester_creds_t*))destroy;
-       
+
        this->private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                BUILD_BLOB_ASN1_DER, chunk_create(private, sizeof(private)),
                                BUILD_END);
-       
+
        this->ca = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
                                BUILD_BLOB_ASN1_DER, chunk_create(cert, sizeof(cert)),
                                BUILD_X509_FLAG, X509_CA,
                                BUILD_END);
-       
-       this->shared = shared_key_create(SHARED_IKE, 
+
+       this->shared = shared_key_create(SHARED_IKE,
                                                                         chunk_clone(chunk_create(psk, sizeof(psk))));
        this->id = identification_create_from_string("CN=*, OU=load-test, O=strongSwan");
        this->serial = 0;
index 60cf67795d16bb1f687fbea336804d0ab3597495..fb3541164b98ca259eb834d83c61f4941a4a7e35 100644 (file)
@@ -34,11 +34,11 @@ struct load_tester_creds_t {
         * Implements credential set interface.
         */
        credential_set_t credential_set;
-       
+
        /**
         * Destroy the backend.
         */
-       void (*destroy)(load_tester_creds_t *this);     
+       void (*destroy)(load_tester_creds_t *this);
 };
 
 /**
index 87d9ef42bbfd7ce01dec03b593c8949a6f5bebf1..d5ec3599b8511bddfabeb4f8a20c7bf782777e83 100644 (file)
@@ -49,19 +49,19 @@ load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
                                                                                                diffie_hellman_group_t group)
 {
        load_tester_diffie_hellman_t *this;
-       
+
        if (group != MODP_NULL)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(load_tester_diffie_hellman_t);
-       
+
        this->dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *))get_shared_secret;
        this->dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t ))nop;
        this->dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *))get_my_public_value;
        this->dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *))get_dh_group;
        this->dh.destroy = (void (*)(diffie_hellman_t *))free;
-       
+
        return this;
 }
index 045c4bb4a8898a083be973e7a5332af1f1c0f39e..1014429a96aa27a12fb120458767ee4f1490c1e5 100644 (file)
@@ -29,7 +29,7 @@ typedef struct load_tester_diffie_hellman_t load_tester_diffie_hellman_t;
  * A NULL Diffie Hellman implementation to avoid calculation overhead in tests.
  */
 struct load_tester_diffie_hellman_t {
-       
+
        /**
         * Implements diffie_hellman_t interface.
         */
@@ -38,7 +38,7 @@ struct load_tester_diffie_hellman_t {
 
 /**
  * Creates a new gmp_diffie_hellman_t object.
- * 
+ *
  * @param group                        Diffie Hellman group, supports MODP_NULL only
  * @return                             gmp_diffie_hellman_t object
  */
index 76460c3e1d42a624ed94932b9e629d3b1ed64398..b6c9f6bbfd9b8afd5290499538f7ccc9756aa1e4 100644 (file)
@@ -27,7 +27,7 @@ struct private_load_tester_ipsec_t {
         * Public interface.
         */
        load_tester_ipsec_t public;
-       
+
        /**
         * faked SPI counter
         */
@@ -37,8 +37,8 @@ struct private_load_tester_ipsec_t {
 /**
  * Implementation of kernel_interface_t.get_spi.
  */
-static status_t get_spi(private_load_tester_ipsec_t *this, 
-                                               host_t *src, host_t *dst, 
+static status_t get_spi(private_load_tester_ipsec_t *this,
+                                               host_t *src, host_t *dst,
                                                protocol_id_t protocol, u_int32_t reqid,
                                                u_int32_t *spi)
 {
@@ -49,8 +49,8 @@ static status_t get_spi(private_load_tester_ipsec_t *this,
 /**
  * Implementation of kernel_interface_t.get_cpi.
  */
-static status_t get_cpi(private_load_tester_ipsec_t *this, 
-                                               host_t *src, host_t *dst, 
+static status_t get_cpi(private_load_tester_ipsec_t *this,
+                                               host_t *src, host_t *dst,
                                                u_int32_t reqid, u_int16_t *cpi)
 {
        return FAILED;
@@ -122,7 +122,7 @@ static status_t add_policy(private_load_tester_ipsec_t *this,
  * Implementation of kernel_interface_t.query_policy.
  */
 static status_t query_policy(private_load_tester_ipsec_t *this,
-                                                        traffic_selector_t *src_ts, 
+                                                        traffic_selector_t *src_ts,
                                                         traffic_selector_t *dst_ts,
                                                         policy_dir_t direction, u_int32_t *use_time)
 {
@@ -134,7 +134,7 @@ static status_t query_policy(private_load_tester_ipsec_t *this,
  * Implementation of kernel_interface_t.del_policy.
  */
 static status_t del_policy(private_load_tester_ipsec_t *this,
-                                                  traffic_selector_t *src_ts, 
+                                                  traffic_selector_t *src_ts,
                                                   traffic_selector_t *dst_ts,
                                                   policy_dir_t direction, bool unrouted)
 {
@@ -155,7 +155,7 @@ static void destroy(private_load_tester_ipsec_t *this)
 load_tester_ipsec_t *load_tester_ipsec_create()
 {
        private_load_tester_ipsec_t *this = malloc_thing(private_load_tester_ipsec_t);
-       
+
        /* public functions */
        this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
        this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
@@ -167,9 +167,9 @@ load_tester_ipsec_t *load_tester_ipsec_create()
        this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
        this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
        this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
-       
+
        this->spi = 0;
-       
+
        return &this->public;
 }
 
index fe9a90aed87d6387311e96fad5506b0b602f7d43..0708b35b672c3549220885a1b842c9f5f8d75d3f 100644 (file)
@@ -30,7 +30,7 @@ struct private_load_tester_listener_t {
         * Public part
         */
        load_tester_listener_t public;
-       
+
        /**
         * Delete IKE_SA after it has been established
         */
@@ -40,7 +40,7 @@ struct private_load_tester_listener_t {
         * Number of established SAs
         */
        u_int established;
-       
+
        /**
         * Shutdown the daemon if we have established this SA count
         */
@@ -56,13 +56,13 @@ static bool ike_state_change(private_load_tester_listener_t *this,
        if (state == IKE_ESTABLISHED)
        {
                ike_sa_id_t *id = ike_sa->get_id(ike_sa);
-       
+
                if (this->delete_after_established)
                {
                        charon->processor->queue_job(charon->processor,
                                                                        (job_t*)delete_ike_sa_job_create(id, TRUE));
                }
-               
+
                if (id->is_initiator(id))
                {
                        if (this->shutdown_on == ++this->established)
@@ -86,17 +86,17 @@ static void destroy(private_load_tester_listener_t *this)
 load_tester_listener_t *load_tester_listener_create(u_int shutdown_on)
 {
        private_load_tester_listener_t *this = malloc_thing(private_load_tester_listener_t);
-       
+
        memset(&this->public.listener, 0, sizeof(listener_t));
        this->public.listener.ike_state_change = (void*)ike_state_change;
        this->public.destroy = (void(*) (load_tester_listener_t*))destroy;
-       
+
        this->delete_after_established = lib->settings->get_bool(lib->settings,
                                "charon.plugins.load_tester.delete_after_established", FALSE);
-       
+
        this->shutdown_on = shutdown_on;
        this->established = 0;
-       
+
        return &this->public;
 }
 
index 6842b35326125745ea3617fdfe092db3fcc3e5f0..b9599294cdec303be5533f6d5c08d7eabdf43970 100644 (file)
@@ -34,11 +34,11 @@ struct load_tester_listener_t {
         * Implements listener set interface.
         */
        listener_t listener;
-       
+
        /**
         * Destroy the backend.
         */
-       void (*destroy)(load_tester_listener_t *this);  
+       void (*destroy)(load_tester_listener_t *this);
 };
 
 /**
index 93ed2e3c5927d5c98f247ecaddd7f43a6f1c6de0..d857a460273c87fcb6527b5511915ad6c14773f7 100644 (file)
@@ -37,47 +37,47 @@ struct private_load_tester_plugin_t {
         * implements plugin interface
         */
        load_tester_plugin_t public;
-       
+
        /**
         * load_tester configuration backend
         */
        load_tester_config_t *config;
-       
+
        /**
         * load_tester credential set implementation
         */
        load_tester_creds_t *creds;
-       
+
        /**
         * event handler, listens on bus
         */
        load_tester_listener_t *listener;
-       
+
        /**
         * number of iterations per thread
         */
        int iterations;
-       
+
        /**
         * number desired initiator threads
         */
        int initiators;
-       
+
        /**
         * currenly running initiators
         */
        int running;
-       
+
        /**
         * delay between initiations, in ms
         */
        int delay;
-       
+
        /**
         * mutex to lock running field
         */
        mutex_t *mutex;
-       
+
        /**
         * condvar to wait for initiators
         */
@@ -90,7 +90,7 @@ struct private_load_tester_plugin_t {
 static job_requeue_t do_load_test(private_load_tester_plugin_t *this)
 {
        int i, s = 0, ms = 0;
-       
+
        this->mutex->lock(this->mutex);
        if (!this->running)
        {
@@ -102,13 +102,13 @@ static job_requeue_t do_load_test(private_load_tester_plugin_t *this)
                s = this->delay / 1000;
                ms = this->delay % 1000;
        }
-       
+
        for (i = 0; this->iterations == 0 || i < this->iterations; i++)
        {
                peer_cfg_t *peer_cfg;
                child_cfg_t *child_cfg = NULL;
                enumerator_t *enumerator;
-       
+
                peer_cfg = charon->backends->get_peer_cfg_by_name(charon->backends,
                                                                                                                  "load-test");
                if (!peer_cfg)
@@ -122,7 +122,7 @@ static job_requeue_t do_load_test(private_load_tester_plugin_t *this)
                        break;
                }
                enumerator->destroy(enumerator);
-               
+
                charon->controller->initiate(charon->controller,
                                        peer_cfg, child_cfg->get_ref(child_cfg),
                                        NULL, NULL);
@@ -176,20 +176,20 @@ plugin_t *plugin_create()
 {
        private_load_tester_plugin_t *this;
        u_int i, shutdown_on = 0;
-       
+
        if (!lib->settings->get_bool(lib->settings,
                                                                 "charon.plugins.load_tester.enable", FALSE))
        {
                DBG1(DBG_CFG, "disabling load-tester plugin, not configured");
                return NULL;
        }
-       
+
        this = malloc_thing(private_load_tester_plugin_t);
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
-       lib->crypto->add_dh(lib->crypto, MODP_NULL, 
+
+       lib->crypto->add_dh(lib->crypto, MODP_NULL,
                                                (dh_constructor_t)load_tester_diffie_hellman_create);
-       
+
        this->delay = lib->settings->get_int(lib->settings,
                                        "charon.plugins.load_tester.delay", 0);
        this->iterations = lib->settings->get_int(lib->settings,
@@ -201,7 +201,7 @@ plugin_t *plugin_create()
        {
                shutdown_on = this->iterations * this->initiators;
        }
-       
+
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
        this->config = load_tester_config_create();
@@ -210,17 +210,17 @@ plugin_t *plugin_create()
        charon->backends->add_backend(charon->backends, &this->config->backend);
        charon->credentials->add_set(charon->credentials, &this->creds->credential_set);
        charon->bus->add_listener(charon->bus, &this->listener->listener);
-       
+
        if (lib->settings->get_bool(lib->settings,
                                        "charon.plugins.load_tester.fake_kernel", FALSE))
        {
-               charon->kernel_interface->add_ipsec_interface(charon->kernel_interface, 
+               charon->kernel_interface->add_ipsec_interface(charon->kernel_interface,
                                                (kernel_ipsec_constructor_t)load_tester_ipsec_create);
        }
        this->running = 0;
        for (i = 0; i < this->initiators; i++)
        {
-               charon->processor->queue_job(charon->processor, 
+               charon->processor->queue_job(charon->processor,
                                        (job_t*)callback_job_create((callback_job_cb_t)do_load_test,
                                                                                                this, NULL, NULL));
        }
index 87e8914e09c1b580130c88b9b92c695b746515c5..e33f06ac73b91a31ce393b54e73eedd816376a16 100644 (file)
@@ -31,7 +31,7 @@ typedef struct load_tester_plugin_t load_tester_plugin_t;
 /**
  * Load tester plugin to inspect system core under high load.
  *
- * This plugin 
+ * This plugin
  */
 struct load_tester_plugin_t {
 
index 9d3998757c72b93d3d41605c122404c8fab9af1c..505e744e1486e7f32530d349ff4e0d3f1b3d133e 100644 (file)
@@ -32,22 +32,22 @@ struct private_medcli_config_t {
         * Public part
         */
        medcli_config_t public;
-       
+
        /**
         * database connection
         */
        database_t *db;
-       
+
        /**
         * rekey time
         */
        int rekey;
-       
+
        /**
         * dpd delay
         */
        int dpd;
-       
+
        /**
         * default ike config
         */
@@ -64,7 +64,7 @@ static traffic_selector_t *ts_from_string(char *str)
                int netbits = 32;
                host_t *net;
                char *pos;
-               
+
                str = strdupa(str);
                pos = strchr(str, '/');
                if (pos)
@@ -107,9 +107,9 @@ static peer_cfg_t *get_peer_cfg_by_name(private_medcli_config_t *this, char *nam
                        .jitter = this->rekey
                }
        };
-       
+
        /* query mediation server config:
-        * - build ike_cfg/peer_cfg for mediation connection on-the-fly 
+        * - build ike_cfg/peer_cfg for mediation connection on-the-fly
         */
        e = this->db->query(this->db,
                        "SELECT Address, ClientConfig.KeyId, MediationServerConfig.KeyId "
@@ -124,14 +124,14 @@ static peer_cfg_t *get_peer_cfg_by_name(private_medcli_config_t *this, char *nam
        ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
        med_cfg = peer_cfg_create(
                "mediation", 2, ike_cfg,
-               CERT_NEVER_SEND, UNIQUE_REPLACE, 
+               CERT_NEVER_SEND, UNIQUE_REPLACE,
                1, this->rekey*60, 0,                   /* keytries, rekey, reauth */
                this->rekey*5, this->rekey*3,   /* jitter, overtime */
                TRUE, this->dpd,                                /* mobike, dpddelay */
                NULL, NULL,                                     /* vip, pool */
                TRUE, NULL, NULL);                              /* mediation, med by, peer id */
        e->destroy(e);
-       
+
        auth = auth_cfg_create();
        auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
        auth->add(auth, AUTH_RULE_IDENTITY,
@@ -142,7 +142,7 @@ static peer_cfg_t *get_peer_cfg_by_name(private_medcli_config_t *this, char *nam
        auth->add(auth, AUTH_RULE_IDENTITY,
                          identification_create_from_encoding(ID_KEY_ID, other));
        med_cfg->add_auth_cfg(med_cfg, auth, FALSE);
-       
+
        /* query mediated config:
         * - use any-any ike_cfg
         * - build peer_cfg on-the-fly using med_cfg
@@ -161,14 +161,14 @@ static peer_cfg_t *get_peer_cfg_by_name(private_medcli_config_t *this, char *nam
        }
        peer_cfg = peer_cfg_create(
                name, 2, this->ike->get_ref(this->ike),
-               CERT_NEVER_SEND, UNIQUE_REPLACE, 
+               CERT_NEVER_SEND, UNIQUE_REPLACE,
                1, this->rekey*60, 0,                   /* keytries, rekey, reauth */
                this->rekey*5, this->rekey*3,   /* jitter, overtime */
                TRUE, this->dpd,                                /* mobike, dpddelay */
                NULL, NULL,                                     /* vip, pool */
                FALSE, med_cfg,                                 /* mediation, med by */
                identification_create_from_encoding(ID_KEY_ID, other));
-       
+
        auth = auth_cfg_create();
        auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
        auth->add(auth, AUTH_RULE_IDENTITY,
@@ -179,7 +179,7 @@ static peer_cfg_t *get_peer_cfg_by_name(private_medcli_config_t *this, char *nam
        auth->add(auth, AUTH_RULE_IDENTITY,
                          identification_create_from_encoding(ID_KEY_ID, other));
        peer_cfg->add_auth_cfg(peer_cfg, auth, FALSE);
-       
+
        child_cfg = child_cfg_create(name, &lifetime, NULL, TRUE,
                                                          MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE);
        child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
@@ -240,13 +240,13 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
        }
        this->current = peer_cfg_create(
                                name, 2, this->ike->get_ref(this->ike),
-                               CERT_NEVER_SEND, UNIQUE_REPLACE, 
+                               CERT_NEVER_SEND, UNIQUE_REPLACE,
                                1, this->rekey*60, 0,                   /* keytries, rekey, reauth */
                                this->rekey*5, this->rekey*3,   /* jitter, overtime */
                                TRUE, this->dpd,                                /* mobike, dpddelay */
                                NULL, NULL,                                     /* vip, pool */
                                FALSE, NULL, NULL);                     /* mediation, med by, peer id */
-       
+
        auth = auth_cfg_create();
        auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
        auth->add(auth, AUTH_RULE_IDENTITY,
@@ -257,7 +257,7 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
        auth->add(auth, AUTH_RULE_IDENTITY,
                          identification_create_from_encoding(ID_KEY_ID, other));
        this->current->add_auth_cfg(this->current, auth, FALSE);
-       
+
        child_cfg = child_cfg_create(name, &lifetime, NULL, TRUE, MODE_TUNNEL,
                                                                 ACTION_NONE, ACTION_NONE, FALSE);
        child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
@@ -286,7 +286,7 @@ static enumerator_t* create_peer_cfg_enumerator(private_medcli_config_t *this,
                                                                                                identification_t *other)
 {
        peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
-       
+
        e->current = NULL;
        e->ike = this->ike;
        e->rekey = this->rekey;
@@ -300,12 +300,12 @@ static enumerator_t* create_peer_cfg_enumerator(private_medcli_config_t *this,
                        "Connection.LocalSubnet, Connection.RemoteSubnet "
                        "FROM ClientConfig JOIN Connection "
                        "WHERE Active AND "
-                       "(? OR ClientConfig.KeyId = ?) AND (? OR Connection.KeyId = ?)", 
-                       DB_INT, me == NULL || me->get_type(me) == ID_ANY, 
-                       DB_BLOB, me && me->get_type(me) == ID_KEY_ID ? 
+                       "(? OR ClientConfig.KeyId = ?) AND (? OR Connection.KeyId = ?)",
+                       DB_INT, me == NULL || me->get_type(me) == ID_ANY,
+                       DB_BLOB, me && me->get_type(me) == ID_KEY_ID ?
                                me->get_encoding(me) : chunk_empty,
-                       DB_INT, other == NULL || other->get_type(other) == ID_ANY, 
-                       DB_BLOB, other && other->get_type(other) == ID_KEY_ID ? 
+                       DB_INT, other == NULL || other->get_type(other) == ID_ANY,
+                       DB_BLOB, other && other->get_type(other) == ID_KEY_ID ?
                                other->get_encoding(other) : chunk_empty,
                        DB_TEXT, DB_BLOB, DB_BLOB, DB_TEXT, DB_TEXT);
        if (!e->inner)
@@ -323,7 +323,7 @@ static job_requeue_t initiate_config(peer_cfg_t *peer_cfg)
 {
        enumerator_t *enumerator;
        child_cfg_t *child_cfg = NULL;;
-       
+
        enumerator = peer_cfg->create_child_cfg_enumerator(peer_cfg);
        enumerator->enumerate(enumerator, &child_cfg);
        if (child_cfg)
@@ -348,7 +348,7 @@ static void schedule_autoinit(private_medcli_config_t *this)
 {
        enumerator_t *e;
        char *name;
-       
+
        e = this->db->query(this->db, "SELECT Alias FROM Connection WHERE Active",
                                                DB_TEXT);
        if (e)
@@ -356,7 +356,7 @@ static void schedule_autoinit(private_medcli_config_t *this)
                while (e->enumerate(e, &name))
                {
                        peer_cfg_t *peer_cfg;
-                       
+
                        peer_cfg = get_peer_cfg_by_name(this, name);
                        if (peer_cfg)
                        {
@@ -391,15 +391,15 @@ medcli_config_t *medcli_config_create(database_t *db)
        this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
        this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
        this->public.destroy = (void(*)(medcli_config_t*))destroy;
-       
+
        this->db = db;
        this->rekey = lib->settings->get_time(lib->settings, "medcli.rekey", 1200);
        this->dpd = lib->settings->get_time(lib->settings, "medcli.dpd", 300);
        this->ike = ike_cfg_create(FALSE, FALSE, "0.0.0.0", "0.0.0.0");
        this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
-       
+
        schedule_autoinit(this);
-       
+
        return &this->public;
 }
 
index a37280bd0c4b1a2745890687c19763a0c057b42e..36c20adf7bb2549295a89a4ce15c3d99cade0e64 100644 (file)
@@ -35,11 +35,11 @@ struct medcli_config_t {
         * Implements backend_t interface
         */
        backend_t backend;
-       
+
        /**
         * Destroy the backend.
         */
-       void (*destroy)(medcli_config_t *this); 
+       void (*destroy)(medcli_config_t *this);
 };
 
 /**
index d3c66ae3559ff67bb2f78907067e0f6ac8165ac3..77791362845ee11cabd0f27f50fa3e3b7bf63b3a 100644 (file)
@@ -30,7 +30,7 @@ struct private_medcli_creds_t {
         * Public part
         */
        medcli_creds_t public;
-       
+
        /**
         * underlying database handle
         */
@@ -90,21 +90,21 @@ static enumerator_t* create_private_enumerator(private_medcli_creds_t *this,
                                                                                key_type_t type, identification_t *id)
 {
        private_enumerator_t *e;
-       
+
        if ((type != KEY_RSA && type != KEY_ANY) ||
                id == NULL || id->get_type(id) != ID_KEY_ID)
        {
                DBG1(DBG_CFG, "%N - %Y", key_type_names, type, id);
                return NULL;
        }
-       
+
        e = malloc_thing(private_enumerator_t);
        e->current = NULL;
        e->public.enumerate = (void*)private_enumerator_enumerate;
        e->public.destroy = (void*)private_enumerator_destroy;
        e->inner = this->db->query(this->db,
                                                "SELECT PrivateKey FROM ClientConfig WHERE KeyId = ?",
-                                               DB_BLOB, id->get_encoding(id), 
+                                               DB_BLOB, id->get_encoding(id),
                                                DB_BLOB);
        if (!e->inner)
        {
@@ -185,13 +185,13 @@ static enumerator_t* create_cert_enumerator(private_medcli_creds_t *this,
                                                                                identification_t *id, bool trusted)
 {
        cert_enumerator_t *e;
-       
+
        if ((cert != CERT_TRUSTED_PUBKEY && cert != CERT_ANY) ||
                id == NULL || id->get_type(id) != ID_KEY_ID)
        {
                return NULL;
        }
-       
+
        e = malloc_thing(cert_enumerator_t);
        e->current = NULL;
        e->type = key;
@@ -235,9 +235,9 @@ medcli_creds_t *medcli_creds_create(database_t *db)
        this->public.set.cache_cert = (void*)nop;
 
        this->public.destroy = (void (*)(medcli_creds_t*))destroy;
-       
+
        this->db = db;
-       
+
        return &this->public;
 }
 
index 97bf1c226773be0cc706df52d4745ce60f837003..4b5402653835e11d088dd98badfe7bd685beb3f8 100644 (file)
@@ -35,11 +35,11 @@ struct medcli_creds_t {
         * Implements credential_set_t interface
         */
        credential_set_t set;
-       
+
        /**
         * Destroy the credentials databse.
         */
-       void (*destroy)(medcli_creds_t *this);  
+       void (*destroy)(medcli_creds_t *this);
 };
 
 /**
index 4d058c0cdb6d6400f213a3c0d255255577cfb5be..142f02e6cf5c4ecab0552da5fe62e15119d3b36e 100644 (file)
@@ -39,7 +39,7 @@ struct private_medcli_listener_t {
         * Public part
         */
        medcli_listener_t public;
-       
+
        /**
         * underlying database handle
         */
@@ -117,17 +117,17 @@ static void destroy(private_medcli_listener_t *this)
 medcli_listener_t *medcli_listener_create(database_t *db)
 {
        private_medcli_listener_t *this = malloc_thing(private_medcli_listener_t);
-       
+
        memset(&this->public.listener, 0, sizeof(listener_t));
-       
+
        this->public.listener.ike_state_change = (void*)ike_state_change;
        this->public.listener.child_state_change = (void*)child_state_change;
        this->public.destroy = (void (*)(medcli_listener_t*))destroy;
-       
+
        this->db = db;
        db->execute(db, NULL, "UPDATE Connection SET Status = ?",
                                DB_UINT, STATE_DOWN);
-       
+
        return &this->public;
 }
 
index c6881f88ab90b37fb235a3830744b875bcfc9ff8..4768beccd06e15c6209808f699e2ddbd49fc6490 100644 (file)
@@ -35,11 +35,11 @@ struct medcli_listener_t {
         * Implements bus_listener_t interface
         */
        listener_t listener;
-       
+
        /**
         * Destroy the credentials databse.
         */
-       void (*destroy)(medcli_listener_t *this);       
+       void (*destroy)(medcli_listener_t *this);
 };
 
 /**
index 908b144f097282b4e2a7f01b595097251827cd0f..148eded618fbe9b73be6f7ff5e1672589eb7acf2 100644 (file)
@@ -32,22 +32,22 @@ struct private_medcli_plugin_t {
         * implements plugin interface
         */
        medcli_plugin_t public;
-       
+
        /**
         * database connection instance
         */
        database_t *db;
-       
+
        /**
         * medcli credential set instance
         */
        medcli_creds_t *creds;
-       
+
        /**
         * medcli config database
         */
        medcli_config_t *config;
-       
+
        /**
         * Listener to update database connection state
         */
@@ -76,9 +76,9 @@ plugin_t *plugin_create()
 {
        char *uri;
        private_medcli_plugin_t *this = malloc_thing(private_medcli_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        uri = lib->settings->get_str(lib->settings,
                                                                 "medcli.database", NULL);
        if (!uri)
@@ -87,7 +87,7 @@ plugin_t *plugin_create()
                free(this);
                return NULL;
        }
-       
+
        this->db = lib->db->create(lib->db, uri);
        if (this->db == NULL)
        {
@@ -95,15 +95,15 @@ plugin_t *plugin_create()
                free(this);
                return NULL;
        }
-       
+
        this->creds = medcli_creds_create(this->db);
        this->config = medcli_config_create(this->db);
        this->listener = medcli_listener_create(this->db);
-       
+
        charon->credentials->add_set(charon->credentials, &this->creds->set);
        charon->backends->add_backend(charon->backends, &this->config->backend);
        charon->bus->add_listener(charon->bus, &this->listener->listener);
-       
+
        return &this->public.plugin;
 }
 
index 1ab7f386421a2af8a2ff4ce7a00bb9d32f6e1eb5..3df7209675009b666b4b26737fde4c079204528f 100644 (file)
@@ -30,22 +30,22 @@ struct private_medsrv_config_t {
         * Public part
         */
        medsrv_config_t public;
-       
+
        /**
         * database connection
         */
        database_t *db;
-       
+
        /**
         * rekey time
         */
        int rekey;
-       
+
        /**
         * dpd delay
         */
        int dpd;
-       
+
        /**
         * default ike config
         */
@@ -77,7 +77,7 @@ static enumerator_t* create_peer_cfg_enumerator(private_medsrv_config_t *this,
                                                                                                identification_t *other)
 {
        enumerator_t *e;
-       
+
        if (!me || !other || other->get_type(other) != ID_KEY_ID)
        {
                return NULL;
@@ -92,7 +92,7 @@ static enumerator_t* create_peer_cfg_enumerator(private_medsrv_config_t *this,
                peer_cfg_t *peer_cfg;
                auth_cfg_t *auth;
                char *name;
-               
+
                if (e->enumerate(e, &name))
                {
                        peer_cfg = peer_cfg_create(
@@ -104,7 +104,7 @@ static enumerator_t* create_peer_cfg_enumerator(private_medsrv_config_t *this,
                                NULL, NULL,                                     /* vip, pool */
                                TRUE, NULL, NULL);                              /* mediation, med by, peer id */
                        e->destroy(e);
-                       
+
                        auth = auth_cfg_create();
                        auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
                        auth->add(auth, AUTH_RULE_IDENTITY, me->clone(me));
@@ -113,7 +113,7 @@ static enumerator_t* create_peer_cfg_enumerator(private_medsrv_config_t *this,
                        auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
                        auth->add(auth, AUTH_RULE_IDENTITY, other->clone(other));
                        peer_cfg->add_auth_cfg(peer_cfg, auth, FALSE);
-                       
+
                        return enumerator_create_single(peer_cfg, (void*)peer_cfg->destroy);
                }
                e->destroy(e);
@@ -141,13 +141,13 @@ medsrv_config_t *medsrv_config_create(database_t *db)
        this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
        this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
        this->public.destroy = (void(*)(medsrv_config_t*))destroy;
-       
+
        this->db = db;
        this->rekey = lib->settings->get_time(lib->settings, "medsrv.rekey", 1200);
        this->dpd = lib->settings->get_time(lib->settings, "medsrv.dpd", 300);
        this->ike = ike_cfg_create(FALSE, FALSE, "0.0.0.0", "0.0.0.0");
        this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
-       
+
        return &this->public;
 }
 
index 2ed63bca706d89f7d240ede8cedd798fff3999f0..fc8b0e972ec682f00713615256e6157bfaa3af59 100644 (file)
@@ -35,11 +35,11 @@ struct medsrv_config_t {
         * Implements backend_t interface
         */
        backend_t backend;
-       
+
        /**
         * Destroy the backend.
         */
-       void (*destroy)(medsrv_config_t *this); 
+       void (*destroy)(medsrv_config_t *this);
 };
 
 /**
index 7dac37f1ffa2854955d7ddedac820ebe466696d9..2127f56602e72b0e96f7a3404eb97723804c05df 100644 (file)
@@ -30,7 +30,7 @@ struct private_medsrv_creds_t {
         * Public part
         */
        medsrv_creds_t public;
-       
+
        /**
         * underlying database handle
         */
@@ -109,13 +109,13 @@ static enumerator_t* create_cert_enumerator(private_medsrv_creds_t *this,
                                                                                identification_t *id, bool trusted)
 {
        cert_enumerator_t *e;
-       
+
        if ((cert != CERT_TRUSTED_PUBKEY && cert != CERT_ANY) ||
                id == NULL || id->get_type(id) != ID_KEY_ID)
        {
                return NULL;
        }
-       
+
        e = malloc_thing(cert_enumerator_t);
        e->current = NULL;
        e->type = key;
@@ -155,9 +155,9 @@ medsrv_creds_t *medsrv_creds_create(database_t *db)
        this->public.set.cache_cert = (void*)nop;
 
        this->public.destroy = (void (*)(medsrv_creds_t*))destroy;
-       
+
        this->db = db;
-       
+
        return &this->public;
 }
 
index da23220c2e01fd474ddfc7fbeb0ae3a0287ac847..d08adf3bfc308be7624caf0271253e117c1c578e 100644 (file)
@@ -35,11 +35,11 @@ struct medsrv_creds_t {
         * Implements credential_set_t interface
         */
        credential_set_t set;
-       
+
        /**
         * Destroy the credentials databse.
         */
-       void (*destroy)(medsrv_creds_t *this);  
+       void (*destroy)(medsrv_creds_t *this);
 };
 
 /**
index 4340d79917172bcffd71f25e0cea84dc2168e03c..7c533f10e64f4a793b196c04e9ce198d582e33c3 100644 (file)
@@ -31,17 +31,17 @@ struct private_medsrv_plugin_t {
         * implements plugin interface
         */
        medsrv_plugin_t public;
-       
+
        /**
         * database connection instance
         */
        database_t *db;
-       
+
        /**
         * medsrv credential set instance
         */
        medsrv_creds_t *creds;
-       
+
        /**
         * medsrv config database
         */
@@ -68,9 +68,9 @@ plugin_t *plugin_create()
 {
        char *uri;
        private_medsrv_plugin_t *this = malloc_thing(private_medsrv_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        uri = lib->settings->get_str(lib->settings,
                                                                 "medsrv.database", NULL);
        if (!uri)
@@ -79,7 +79,7 @@ plugin_t *plugin_create()
                free(this);
                return NULL;
        }
-       
+
        this->db = lib->db->create(lib->db, uri);
        if (this->db == NULL)
        {
@@ -87,13 +87,13 @@ plugin_t *plugin_create()
                free(this);
                return NULL;
        }
-       
+
        this->creds = medsrv_creds_create(this->db);
        this->config = medsrv_config_create(this->db);
-       
+
        charon->credentials->add_set(charon->credentials, &this->creds->set);
        charon->backends->add_backend(charon->backends, &this->config->backend);
-       
+
        return &this->public.plugin;
 }
 
index 84b3387e17a43bac949bad21f2cf8b6bc34bb3ef..4ff926b22365cb15671cfa7441f927efdb25ba6d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2008 Martin Willi
  * Hochschule fuer Technik Rapperswil
- * Copyright (C) 2004 Dan Williams 
+ * Copyright (C) 2004 Dan Williams
  * Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@ static char *lookup_password(char *name, char *service)
        for (iter = list; iter; iter = iter->next)
        {
                GnomeKeyringNetworkPasswordData *data = iter->data;
-               
+
                if (strcmp(data->object, "password") == 0 && data->password)
                {
                        pass = g_strdup(data->password);
@@ -97,7 +97,7 @@ static char* get_connection_type(char *uuid)
        }
        g_slist_foreach(list, (GFunc)g_free, NULL);
        g_slist_free(list);
-       
+
        if (found)
        {
                key = g_strdup_printf ("%s/%s/%s", found,
@@ -139,14 +139,14 @@ int main (int argc, char *argv[])
                                                                argc, argv,
                                                                GNOME_PARAM_GOPTION_CONTEXT, context,
                                                                GNOME_PARAM_NONE);
-       
+
        if (uuid == NULL || name == NULL || service == NULL)
        {
                fprintf (stderr, "Have to supply UUID, name, and service\n");
                g_object_unref (program);
                return 1;
        }
-       
+
        if (strcmp(service, NM_DBUS_SERVICE_STRONGSWAN) != 0)
        {
                fprintf(stderr, "This dialog only works with the '%s' service\n",
@@ -154,7 +154,7 @@ int main (int argc, char *argv[])
                g_object_unref (program);
                return 1;
        }
-       
+
        type = get_connection_type(uuid);
        if (!type)
        {
@@ -221,7 +221,7 @@ int main (int argc, char *argv[])
                else
                {
                        dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR,
-                                                 GTK_BUTTONS_OK, 
+                                                 GTK_BUTTONS_OK,
                                                  _("Configuration uses ssh-agent for authentication, "
                                                  "but ssh-agent is not running!"));
                        gtk_dialog_run (GTK_DIALOG (dialog));
index 18bf097ea3198790966e7b2bc3379949113c9996..0c55d3abcb687826cb3f990d541f671731764d4f 100644 (file)
@@ -158,7 +158,7 @@ settings_changed_cb (GtkWidget *widget, gpointer user_data)
 {
        StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (user_data);
        StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
-       
+
        if (widget == glade_xml_get_widget (priv->xml, "method-combo"))
        {
                update_layout(glade_xml_get_widget (priv->xml, "method-combo"), priv);
@@ -173,7 +173,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
        NMSettingVPN *settings;
        GtkWidget *widget;
        const char *value;
-       
+
        settings = NM_SETTING_VPN(nm_connection_get_setting(connection, NM_TYPE_SETTING_VPN));
        widget = glade_xml_get_widget (priv->xml, "address-entry");
        value = nm_setting_vpn_get_data_item (settings, "address");
@@ -218,7 +218,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
        }
        update_layout (widget, priv);
        g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self);
-       
+
        widget = glade_xml_get_widget (priv->xml, "usercert-label");
        gtk_widget_set_no_show_all (widget, TRUE);
        widget = glade_xml_get_widget (priv->xml, "usercert-button");
@@ -227,7 +227,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
        if (value)
                gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value);
        g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self);
-       
+
        widget = glade_xml_get_widget (priv->xml, "userkey-label");
        gtk_widget_set_no_show_all (widget, TRUE);
        widget = glade_xml_get_widget (priv->xml, "userkey-button");
@@ -236,7 +236,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
        if (value)
                gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value);
        g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self);
-       
+
        widget = glade_xml_get_widget (priv->xml, "virtual-check");
        value = nm_setting_vpn_get_data_item (settings, "virtual");
        if (value && strcmp(value, "yes") == 0)
@@ -244,7 +244,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
        }
        g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self);
-       
+
        widget = glade_xml_get_widget (priv->xml, "encap-check");
        value = nm_setting_vpn_get_data_item (settings, "encap");
        if (value && strcmp(value, "yes") == 0)
@@ -252,7 +252,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
        }
        g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self);
-       
+
        widget = glade_xml_get_widget (priv->xml, "ipcomp-check");
        value = nm_setting_vpn_get_data_item (settings, "ipcomp");
        if (value && strcmp(value, "yes") == 0)
@@ -288,7 +288,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
        if (!check_validity (self, error))
                return FALSE;
        settings = NM_SETTING_VPN (nm_setting_vpn_new ());
-       
+
        g_object_set (settings, NM_SETTING_VPN_SERVICE_TYPE,
                                  NM_DBUS_SERVICE_STRONGSWAN, NULL);
 
@@ -303,7 +303,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
        if (str) {
                nm_setting_vpn_add_data_item (settings, "certificate", str);
        }
-       
+
        widget = glade_xml_get_widget (priv->xml, "method-combo");
        switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)))
        {
@@ -339,15 +339,15 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
                        break;
        }
        nm_setting_vpn_add_data_item (settings, "method", str);
-       
+
        widget = glade_xml_get_widget (priv->xml, "virtual-check");
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        nm_setting_vpn_add_data_item (settings, "virtual", active ? "yes" : "no");
-                            
+
        widget = glade_xml_get_widget (priv->xml, "encap-check");
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        nm_setting_vpn_add_data_item (settings, "encap", active ? "yes" : "no");
-                            
+
        widget = glade_xml_get_widget (priv->xml, "ipcomp-check");
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        nm_setting_vpn_add_data_item (settings, "ipcomp", active ? "yes" : "no");
index 2ebd4bed15767fe282e86024e3c35f8bd55be8f6..e2b66bb157cc444dc7e9b9db6d27727ced953d7f 100644 (file)
@@ -28,7 +28,7 @@ typedef enum
        STRONGSWAN_PLUGIN_UI_ERROR_MISSING_PROPERTY
 } StrongswanPluginUiError;
 
-#define STRONGSWAN_TYPE_PLUGIN_UI_ERROR (strongswan_plugin_ui_error_get_type ()) 
+#define STRONGSWAN_TYPE_PLUGIN_UI_ERROR (strongswan_plugin_ui_error_get_type ())
 GType strongswan_plugin_ui_error_get_type (void);
 
 #define STRONGSWAN_TYPE_PLUGIN_UI            (strongswan_plugin_ui_get_type ())
index 9d1b0b8953b812c9931ba2ed8b612b20be45a0bd..1a35105cfd3be92ef58c9c71bcb3360d098fd6fb 100644 (file)
@@ -29,32 +29,32 @@ struct private_nm_creds_t {
         * public functions
         */
        nm_creds_t public;
-       
+
        /**
         * gateway certificate
         */
        certificate_t *cert;
-       
+
        /**
         * User name
         */
        identification_t *user;
-       
+
        /**
         * User password
         */
        char *pass;
-       
+
        /**
         * users certificate
         */
        certificate_t *usercert;
-       
+
        /**
         * users private key
         */
        private_key_t *key;
-       
+
        /**
         * read/write lock
         */
@@ -68,13 +68,13 @@ static enumerator_t *create_usercert_enumerator(private_nm_creds_t *this,
                                                        certificate_type_t cert, key_type_t key)
 {
        public_key_t *public;
-       
+
        if (cert != CERT_ANY && cert != this->usercert->get_type(this->usercert))
        {
                return NULL;
        }
        if (key != KEY_ANY)
-       {       
+       {
                public = this->usercert->get_public_key(this->usercert);
                if (!public)
                {
@@ -121,7 +121,7 @@ static enumerator_t* create_cert_enumerator(private_nm_creds_t *this,
        if (key != KEY_ANY)
        {
                public_key_t *public;
-       
+
                public = this->cert->get_public_key(this->cert);
                if (!public)
                {
@@ -156,7 +156,7 @@ static enumerator_t* create_private_enumerator(private_nm_creds_t *this,
        if (id && id->get_type(id) != ID_ANY)
        {
                chunk_t keyid;
-               
+
                if (id->get_type(id) != ID_KEY_ID ||
                        !this->key->get_fingerprint(this->key, KEY_ID_PUBKEY_SHA1, &keyid) ||
                        !chunk_equals(keyid, id->get_encoding(id)))
@@ -208,7 +208,7 @@ static void shared_destroy(shared_enumerator_t *this)
 /**
  * Implements credential_set_t.create_cert_enumerator
  */
-static enumerator_t* create_shared_enumerator(private_nm_creds_t *this, 
+static enumerator_t* create_shared_enumerator(private_nm_creds_t *this,
                                                        shared_key_type_t type, identification_t *me,
                                                        identification_t *other)
 {
@@ -226,7 +226,7 @@ static enumerator_t* create_shared_enumerator(private_nm_creds_t *this,
        {
                return NULL;
        }
-       
+
        enumerator = malloc_thing(shared_enumerator_t);
        enumerator->public.enumerate = (void*)shared_enumerate;
        enumerator->public.destroy = (void*)shared_destroy;
@@ -267,7 +267,7 @@ static void set_username_password(private_nm_creds_t *this, identification_t *id
 /**
  * Implementation of nm_creds_t.set_cert_and_key
  */
-static void set_cert_and_key(private_nm_creds_t *this, certificate_t *cert,    
+static void set_cert_and_key(private_nm_creds_t *this, certificate_t *cert,
                                                         private_key_t *key)
 {
        this->lock->write_lock(this->lock);
@@ -276,7 +276,7 @@ static void set_cert_and_key(private_nm_creds_t *this, certificate_t *cert,
        this->key = key;
        this->usercert = cert;
        this->lock->unlock(this->lock);
-}      
+}
 
 /**
  * Implementation of nm_creds_t.clear
@@ -311,7 +311,7 @@ static void destroy(private_nm_creds_t *this)
 nm_creds_t *nm_creds_create()
 {
        private_nm_creds_t *this = malloc_thing(private_nm_creds_t);
-       
+
        this->public.set.create_private_enumerator = (void*)create_private_enumerator;
        this->public.set.create_cert_enumerator = (void*)create_cert_enumerator;
        this->public.set.create_shared_enumerator = (void*)create_shared_enumerator;
@@ -322,15 +322,15 @@ nm_creds_t *nm_creds_create()
        this->public.set_cert_and_key = (void(*)(nm_creds_t*, certificate_t *cert, private_key_t *key))set_cert_and_key;
        this->public.clear = (void(*)(nm_creds_t*))clear;
        this->public.destroy = (void(*)(nm_creds_t*))destroy;
-       
+
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        this->cert = NULL;
        this->user = NULL;
        this->pass = NULL;
        this->usercert = NULL;
        this->key = NULL;
-       
+
        return &this->public;
 }
 
index 421442c81fb4dc225d5083aaafc49e040238ad8c..754fe53dfa4b303d36a4ca7c699ee1ebfab3e571 100644 (file)
@@ -35,14 +35,14 @@ struct nm_creds_t {
         * Implements credential_set_t
         */
        credential_set_t set;
-       
+
        /**
         * Set the trusted gateway certificate to serve by this set.
         *
         * @param cert          certificate to serve
         */
        void (*set_certificate)(nm_creds_t *this, certificate_t *cert);
-       
+
        /**
         * Set the username/password for authentication.
         *
index 026c47af2b6990a16cd85b84b558d441a3b6c465..7b9c10b65062bccf9006d3dc1b9dbb156298a7d7 100644 (file)
@@ -23,17 +23,17 @@ typedef struct private_nm_handler_t private_nm_handler_t;
  * Private data of an nm_handler_t object.
  */
 struct private_nm_handler_t {
-       
+
        /**
         * Public nm_handler_t interface.
         */
        nm_handler_t public;
-       
+
        /**
         * list of received DNS server attributes, pointer to 4 byte data
         */
        linked_list_t *dns;
-       
+
        /**
         * list of received NBNS server attributes, pointer to 4 byte data
         */
@@ -47,7 +47,7 @@ static bool handle(private_nm_handler_t *this, ike_sa_t *ike_sa,
                                   configuration_attribute_type_t type, chunk_t data)
 {
        linked_list_t *list;
-       
+
        switch (type)
        {
                case INTERNAL_IP4_DNS:
@@ -83,7 +83,7 @@ static enumerator_t* create_enumerator(private_nm_handler_t *this,
                                                                           configuration_attribute_type_t type)
 {
        linked_list_t *list;
-       
+
        switch (type)
        {
                case INTERNAL_IP4_DNS:
@@ -105,7 +105,7 @@ static enumerator_t* create_enumerator(private_nm_handler_t *this,
 static void reset(private_nm_handler_t *this)
 {
        void *data;
-       
+
        while (this->dns->remove_last(this->dns, (void**)&data) == SUCCESS)
        {
                free(data);
@@ -133,16 +133,16 @@ static void destroy(private_nm_handler_t *this)
 nm_handler_t *nm_handler_create()
 {
        private_nm_handler_t *this = malloc_thing(private_nm_handler_t);
-       
+
        this->public.handler.handle = (bool(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))handle;
        this->public.handler.release = (void(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))nop;
        this->public.create_enumerator = (enumerator_t*(*)(nm_handler_t*, configuration_attribute_type_t type))create_enumerator;
        this->public.reset = (void(*)(nm_handler_t*))reset;
        this->public.destroy = (void(*)(nm_handler_t*))destroy;
-       
+
        this->dns = linked_list_create();
        this->nbns = linked_list_create();
-       
+
        return &this->public;
 }
 
index d537bb8de527472c42478c57807030851b70b47f..3904ce1f0f8a3db5e543e77273d274778a6c35c4 100644 (file)
@@ -29,12 +29,12 @@ typedef struct nm_handler_t nm_handler_t;
  * Handles DNS/NBNS attributes to pass to NM.
  */
 struct nm_handler_t {
-       
+
        /**
         * Implements attribute handler interface
         */
        attribute_handler_t handler;
-       
+
        /**
         * Create an enumerator over received attributes of a given kind.
         *
@@ -47,7 +47,7 @@ struct nm_handler_t {
         * Reset state, flush all received attributes.
         */
        void (*reset)(nm_handler_t *this);
-       
+
        /**
         * Destroy a nm_handler_t.
         */
index 1fb46f814335c07f4d5bd6d23ea01418e6e5264e..46cc9c39e04c512de9d1ba67b410975f9c9f97e8 100644 (file)
@@ -34,22 +34,22 @@ struct private_nm_plugin_t {
         * implements plugin interface
         */
        nm_plugin_t public;
-       
+
        /**
         * NetworkManager service (VPNPlugin)
         */
        NMStrongswanPlugin *plugin;
-       
+
        /**
         * Glib main loop for a thread, handles DBUS calls
         */
        GMainLoop *loop;
-       
+
        /**
         * credential set registered at the daemon
         */
        nm_creds_t *creds;
-       
+
        /**
         * attribute handler regeisterd at the daemon
         */
@@ -96,16 +96,16 @@ static void destroy(private_nm_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_nm_plugin_t *this = malloc_thing(private_nm_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->loop = NULL;
        g_type_init ();
        if (!g_thread_supported())
        {
                g_thread_init(NULL);
        }
-       
+
        this->creds = nm_creds_create();
        this->handler = nm_handler_create();
        charon->credentials->add_set(charon->credentials, &this->creds->set);
@@ -117,13 +117,13 @@ plugin_t *plugin_create()
                destroy(this);
                return NULL;
        }
-       
+
        /* bypass file permissions to read from users ssh-agent */
        charon->keep_cap(charon, CAP_DAC_OVERRIDE);
-       
-       charon->processor->queue_job(charon->processor, 
+
+       charon->processor->queue_job(charon->processor,
                 (job_t*)callback_job_create((callback_job_cb_t)run, this, NULL, NULL));
-       
+
        return &this->public.plugin;
 }
 
index 6aa5561f1a81074b6c982da1bb3c980d53f086a7..d896a432d3d2b22b9b2fd6aa4261241b6e0d68e2 100644 (file)
@@ -59,7 +59,7 @@ static GValue* handler_to_val(nm_handler_t *handler,
        GArray *array;
        enumerator_t *enumerator;
        chunk_t chunk;
-       
+
        enumerator = handler->create_enumerator(handler, type);
        array = g_array_new (FALSE, TRUE, sizeof (guint32));
        while (enumerator->enumerate(enumerator, &chunk))
@@ -70,7 +70,7 @@ static GValue* handler_to_val(nm_handler_t *handler,
        val = g_slice_new0 (GValue);
        g_value_init (val, DBUS_TYPE_G_UINT_ARRAY);
        g_value_set_boxed (val, array);
-       
+
        return val;
 }
 
@@ -84,37 +84,37 @@ static void signal_ipv4_config(NMVPNPlugin *plugin,
        GHashTable *config;
        host_t *me, *other;
        nm_handler_t *handler;
-       
+
        config = g_hash_table_new(g_str_hash, g_str_equal);
        me = ike_sa->get_my_host(ike_sa);
        other = ike_sa->get_other_host(ike_sa);
        handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->handler;
-       
+
        /* NM requires a tundev, but netkey does not use one. Passing an invalid
         * iface makes NM complain, but it accepts it without fiddling on eth0. */
        val = g_slice_new0 (GValue);
        g_value_init (val, G_TYPE_STRING);
        g_value_set_string (val, "none");
        g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, val);
-       
+
        val = g_slice_new0(GValue);
        g_value_init(val, G_TYPE_UINT);
        g_value_set_uint(val, *(u_int32_t*)me->get_address(me).ptr);
        g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, val);
-       
+
        val = g_slice_new0(GValue);
        g_value_init(val, G_TYPE_UINT);
        g_value_set_uint(val, me->get_address(me).len * 8);
        g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
-       
+
        val = handler_to_val(handler, INTERNAL_IP4_DNS);
        g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_DNS, val);
-       
+
        val = handler_to_val(handler, INTERNAL_IP4_NBNS);
        g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_NBNS, val);
-       
+
        handler->reset(handler);
-       
+
        nm_vpn_plugin_set_ip4_config(plugin, config);
 }
 
@@ -124,11 +124,11 @@ static void signal_ipv4_config(NMVPNPlugin *plugin,
 static void signal_failure(NMVPNPlugin *plugin, NMVPNPluginFailure failure)
 {
        nm_handler_t *handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->handler;
-       
+
        handler->reset(handler);
-       
+
        /* TODO: NM does not handle this failure!? */
-       nm_vpn_plugin_failure(plugin, failure); 
+       nm_vpn_plugin_failure(plugin, failure);
        nm_vpn_plugin_set_state(plugin, NM_VPN_SERVICE_STATE_STOPPED);
 }
 
@@ -139,7 +139,7 @@ static bool ike_state_change(listener_t *listener, ike_sa_t *ike_sa,
                                                         ike_sa_state_t state)
 {
        NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
-       
+
        if (private->ike_sa == ike_sa && state == IKE_DESTROYING)
        {
                signal_failure(private->plugin, NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
@@ -155,7 +155,7 @@ static bool child_state_change(listener_t *listener, ike_sa_t *ike_sa,
                                                           child_sa_t *child_sa, child_sa_state_t state)
 {
        NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
-       
+
        if (private->ike_sa == ike_sa && state == CHILD_DESTROYING)
        {
                signal_failure(private->plugin, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
@@ -171,7 +171,7 @@ static bool child_updown(listener_t *listener, ike_sa_t *ike_sa,
                                                 child_sa_t *child_sa, bool up)
 {
        NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
-       
+
        if (private->ike_sa == ike_sa)
        {
                if (up)
@@ -195,7 +195,7 @@ static bool child_updown(listener_t *listener, ike_sa_t *ike_sa,
 static bool ike_rekey(listener_t *listener, ike_sa_t *old, ike_sa_t *new)
 {
        NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
-       
+
        if (private->ike_sa == old)
        {       /* follow a rekeyed IKE_SA */
                private->ike_sa = new;
@@ -232,7 +232,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                        .jitter = 300 /* 5min */
                }
        };
-       
+
        /**
         * Read parameters
         */
@@ -280,12 +280,12 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                        auth_class = AUTH_CLASS_PUBKEY;
                }
        }
-       
+
        /**
         * Register credentials
         */
        priv->creds->clear(priv->creds);
-       
+
        /* gateway/CA cert */
        str = nm_setting_vpn_get_data_item(vpn, "certificate");
        if (str)
@@ -315,7 +315,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                gateway = gateway->clone(gateway);
                DBG1(DBG_CFG, "using gateway certificate, identity '%Y'", gateway);
        }
-       
+
        if (auth_class == AUTH_CLASS_EAP)
        {
                /* username/password authentication ... */
@@ -327,7 +327,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                        priv->creds->set_username_password(priv->creds, user, (char*)str);
                }
        }
-       
+
        if (auth_class == AUTH_CLASS_PUBKEY)
        {
                /* ... or certificate/private key authenitcation */
@@ -336,7 +336,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                {
                        public_key_t *public;
                        private_key_t *private = NULL;
-                       
+
                        cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
                                                                          BUILD_FROM_FILE, str, BUILD_END);
                        if (!cert)
@@ -347,7 +347,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                                gateway->destroy(gateway);
                                return FALSE;
                        }
-                       /* try agent */  
+                       /* try agent */
                        str = nm_setting_vpn_get_secret(vpn, "agent");
                        if (agent && str)
                        {
@@ -368,12 +368,12 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                                                                "Connecting to SSH agent failed.");
                                }
                        }
-                       /* ... or key file */  
+                       /* ... or key file */
                        str = nm_setting_vpn_get_data_item(vpn, "userkey");
                        if (!agent && str)
                        {
                                chunk_t secret;
-                               
+
                                secret.ptr = (char*)nm_setting_vpn_get_secret(vpn, "password");
                                if (secret.ptr)
                                {
@@ -403,7 +403,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                        }
                }
        }
-       
+
        if (!user)
        {
                g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
@@ -411,7 +411,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                gateway->destroy(gateway);
                return FALSE;
        }
-       
+
        /**
         * Set up configurations
         */
@@ -432,7 +432,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
        auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
        auth->add(auth, AUTH_RULE_IDENTITY, gateway);
        peer_cfg->add_auth_cfg(peer_cfg, auth, FALSE);
-       
+
        child_cfg = child_cfg_create(priv->name, &lifetime,
                                                                 NULL, TRUE, MODE_TUNNEL, /* updown, hostaccess */
                                                                 ACTION_NONE, ACTION_NONE, ipcomp);
@@ -444,7 +444,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
                                                                                         "255.255.255.255", 65535);
        child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
        peer_cfg->add_child_cfg(peer_cfg, child_cfg);
-       
+
        /**
         * Prepare IKE_SA
         */
@@ -458,7 +458,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
        {
                peer_cfg->destroy(peer_cfg);
        }
-       
+
        /**
         * Register listener, enable  initiate-failure-detection hooks
         */
@@ -466,7 +466,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
        priv->listener.ike_state_change = ike_state_change;
        priv->listener.child_state_change = child_state_change;
        charon->bus->add_listener(charon->bus, &priv->listener);
-       
+
        /**
         * Initiate
         */
@@ -474,7 +474,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
        {
                charon->bus->remove_listener(charon->bus, &priv->listener);
                charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, ike_sa);
-               
+
                g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
                                    "Initiating failed.");
                return FALSE;
@@ -484,14 +484,14 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
 }
 
 /**
- * NeedSecrets called from NM via DBUS 
+ * NeedSecrets called from NM via DBUS
  */
 static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection,
                                                         char **setting_name, GError **error)
 {
        NMSettingVPN *settings;
        const char *method, *path;
-       
+
        settings = NM_SETTING_VPN(nm_connection_get_setting(connection,
                                                                                                                NM_TYPE_SETTING_VPN));
        method = nm_setting_vpn_get_data_item(settings, "method");
@@ -518,7 +518,7 @@ static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection,
                        {
                                private_key_t *key;
                                chunk_t secret;
-                               
+
                                secret.ptr = (char*)nm_setting_vpn_get_secret(settings, "password");
                                if (secret.ptr)
                                {
@@ -541,7 +541,7 @@ static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection,
 }
 
 /**
- * Disconnect called from NM via DBUS 
+ * Disconnect called from NM via DBUS
  */
 static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
 {
@@ -549,7 +549,7 @@ static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
        enumerator_t *enumerator;
        ike_sa_t *ike_sa;
        u_int id;
-       
+
        /* our ike_sa pointer might be invalid, lookup sa */
        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
        while (enumerator->enumerate(enumerator, &ike_sa))
@@ -564,7 +564,7 @@ static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_GENERAL,
                                "Connection not found.");
        return FALSE;
@@ -576,7 +576,7 @@ static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
 static void nm_strongswan_plugin_init(NMStrongswanPlugin *plugin)
 {
        NMStrongswanPluginPrivate *priv;
-       
+
        priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
        priv->plugin = NM_VPN_PLUGIN(plugin);
        memset(&priv->listener.log, 0, sizeof(listener_t));
@@ -591,7 +591,7 @@ static void nm_strongswan_plugin_class_init(
                                                                        NMStrongswanPluginClass *strongswan_class)
 {
        NMVPNPluginClass *parent_class = NM_VPN_PLUGIN_CLASS(strongswan_class);
-       
+
        g_type_class_add_private(G_OBJECT_CLASS(strongswan_class),
                                                         sizeof(NMStrongswanPluginPrivate));
        parent_class->connect = connect_;
@@ -612,7 +612,7 @@ NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds,
        if (plugin)
        {
                NMStrongswanPluginPrivate *priv;
-               
+
                priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
                priv->creds = creds;
                priv->handler = handler;
index 749cfbc5bf75bf87ea74318f9395241aef92f344..47e04416c0578426e53f4d94e0faca19bb14f0c6 100644 (file)
@@ -26,17 +26,17 @@ typedef struct private_resolv_conf_handler_t private_resolv_conf_handler_t;
  * Private data of an resolv_conf_handler_t object.
  */
 struct private_resolv_conf_handler_t {
-       
+
        /**
         * Public resolv_conf_handler_t interface.
         */
        resolv_conf_handler_t public;
-       
+
        /**
         * resolv.conf file to use
         */
        char *file;
-       
+
        /**
         * Mutex to access file exclusively
         */
@@ -55,7 +55,7 @@ static bool handle(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
        int family;
        size_t len;
        bool handled = FALSE;
-       
+
        switch (type)
        {
                case INTERNAL_IP4_DNS:
@@ -67,9 +67,9 @@ static bool handle(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
                default:
                        return FALSE;
        }
-       
+
        this->mutex->lock(this->mutex);
-       
+
        in = fopen(this->file, "r");
        /* allows us to stream from in to out */
        unlink(this->file);
@@ -82,7 +82,7 @@ static bool handle(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
                DBG1(DBG_IKE, "installing DNS server %H to %s", addr, this->file);
                addr->destroy(addr);
                handled = TRUE;
-               
+
                /* copy rest of the file */
                if (in)
                {
@@ -94,7 +94,7 @@ static bool handle(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
                }
                fclose(out);
        }
-       
+
        if (!handled)
        {
                DBG1(DBG_IKE, "adding DNS server failed", this->file);
@@ -113,7 +113,7 @@ static void release(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
        char line[1024], matcher[512], *pos;
        host_t *addr;
        int family;
-       
+
        switch (type)
        {
                case INTERNAL_IP4_DNS:
@@ -125,9 +125,9 @@ static void release(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
                default:
                        return;
        }
-       
+
        this->mutex->lock(this->mutex);
-       
+
        in = fopen(this->file, "r");
        if (in)
        {
@@ -140,7 +140,7 @@ static void release(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
                        snprintf(matcher, sizeof(matcher),
                                         "nameserver %H   # by strongSwan, from %Y\n",
                                         addr, ike_sa->get_other_id(ike_sa));
-                       
+
                        /* copy all, but matching line */
                        while ((pos = fgets(line, sizeof(line), in)))
                        {
@@ -159,7 +159,7 @@ static void release(private_resolv_conf_handler_t *this, ike_sa_t *ike_sa,
                }
                fclose(in);
        }
-       
+
        this->mutex->unlock(this->mutex);
 }
 
@@ -178,15 +178,15 @@ static void destroy(private_resolv_conf_handler_t *this)
 resolv_conf_handler_t *resolv_conf_handler_create()
 {
        private_resolv_conf_handler_t *this = malloc_thing(private_resolv_conf_handler_t);
-       
+
        this->public.handler.handle = (bool(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))handle;
        this->public.handler.release = (void(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))release;
        this->public.destroy = (void(*)(resolv_conf_handler_t*))destroy;
-       
+
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->file = lib->settings->get_str(lib->settings,
                                                                "charon.plugins.resolv-conf.file", RESOLV_CONF);
-       
+
        return &this->public;
 }
 
index 2635bb802f09b59d109fd009fca91354b89dd0b7..5aa17cadadda7230124e09201455cd37b4a035e2 100644 (file)
@@ -29,12 +29,12 @@ typedef struct resolv_conf_handler_t resolv_conf_handler_t;
  * Handle DNS configuration attributes by mangling a resolv.conf file.
  */
 struct resolv_conf_handler_t {
-       
+
        /**
         * Implements the attribute_handler_t interface
         */
        attribute_handler_t handler;
-       
+
        /**
         * Destroy a resolv_conf_handler_t.
         */
index ff9d96eb34ff78d9953076d0543301faead44607..418820115bdd28f1205e0b012debcf690f0f0fc8 100644 (file)
@@ -29,7 +29,7 @@ struct private_resolv_conf_plugin_t {
         * implements plugin interface
         */
        resolv_conf_plugin_t public;
-       
+
        /**
         * The registerd DNS attribute handler
         */
@@ -53,12 +53,12 @@ static void destroy(private_resolv_conf_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_resolv_conf_plugin_t *this = malloc_thing(private_resolv_conf_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->handler = resolv_conf_handler_create();
        charon->attributes->add_handler(charon->attributes, &this->handler->handler);
-       
+
        return &this->public.plugin;
 }
 
index f5943d9a318ba70af6996245e600cb33df953d24..7cbeab86cf6e3b312ef2251f66c04f60d408d8ba 100644 (file)
@@ -32,7 +32,7 @@ typedef struct resolv_conf_plugin_t resolv_conf_plugin_t;
  * Plugin that writes received DNS servers in a resolv.conf file.
  */
 struct resolv_conf_plugin_t {
-       
+
        /**
         * implements plugin interface
         */
index 562add06d31f378e3c1873c553a7b854da39568f..8a4c27ce05d8b8863ec3312331b78b29188e2528 100644 (file)
@@ -44,12 +44,12 @@ struct private_smp_t {
         * Public part of smp_t object.
         */
        smp_t public;
-       
+
        /**
         * XML unix socket fd
         */
        int socket;
-       
+
        /**
         * job accepting stroke messages
         */
@@ -146,7 +146,7 @@ static void write_networks(xmlTextWriterPtr writer, char *element,
 {
        enumerator_t *enumerator;
        traffic_selector_t *ts;
-       
+
        xmlTextWriterStartElement(writer, element);
        enumerator = list->create_enumerator(list);
        while (enumerator->enumerate(enumerator, (void**)&ts))
@@ -167,26 +167,26 @@ static void write_networks(xmlTextWriterPtr writer, char *element,
 static void write_childend(xmlTextWriterPtr writer, child_sa_t *child, bool local)
 {
        linked_list_t *list;
-       
-       xmlTextWriterWriteFormatElement(writer, "spi", "%lx", 
+
+       xmlTextWriterWriteFormatElement(writer, "spi", "%lx",
                                                                        htonl(child->get_spi(child, local)));
        list = child->get_traffic_selectors(child, local);
        write_networks(writer, "networks", list);
 }
 
 /**
- * write a child_sa_t 
+ * write a child_sa_t
  */
 static void write_child(xmlTextWriterPtr writer, child_sa_t *child)
 {
        child_cfg_t *config;
-       
+
        config = child->get_config(child);
 
        xmlTextWriterStartElement(writer, "childsa");
        xmlTextWriterWriteFormatElement(writer, "reqid", "%d",
                                                                        child->get_reqid(child));
-       xmlTextWriterWriteFormatElement(writer, "childconfig", "%s", 
+       xmlTextWriterWriteFormatElement(writer, "childconfig", "%s",
                                                                        config->get_name(config));
        xmlTextWriterStartElement(writer, "local");
        write_childend(writer, child, TRUE);
@@ -207,7 +207,7 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
 
        /* <ikesalist> */
        xmlTextWriterStartElement(writer, "ikesalist");
-       
+
        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
@@ -215,18 +215,18 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
                host_t *local, *remote;
                iterator_t *children;
                child_sa_t *child_sa;
-               
+
                id = ike_sa->get_id(ike_sa);
-               
+
                xmlTextWriterStartElement(writer, "ikesa");
                xmlTextWriterWriteFormatElement(writer, "id", "%d",
                                                        ike_sa->get_unique_id(ike_sa));
-               xmlTextWriterWriteFormatElement(writer, "status", "%N", 
+               xmlTextWriterWriteFormatElement(writer, "status", "%N",
                                                        ike_sa_state_lower_names, ike_sa->get_state(ike_sa));
                xmlTextWriterWriteElement(writer, "role",
                                                        id->is_initiator(id) ? "initiator" : "responder");
                xmlTextWriterWriteElement(writer, "peerconfig", ike_sa->get_name(ike_sa));
-               
+
                /* <local> */
                local = ike_sa->get_my_host(ike_sa);
                xmlTextWriterStartElement(writer, "local");
@@ -243,7 +243,7 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
                }
                xmlTextWriterEndElement(writer);
                /* </local> */
-               
+
                /* <remote> */
                remote = ike_sa->get_other_host(ike_sa);
                xmlTextWriterStartElement(writer, "remote");
@@ -259,8 +259,8 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
                        write_bool(writer, "nat", ike_sa->has_condition(ike_sa, COND_NAT_THERE));
                }
                xmlTextWriterEndElement(writer);
-               /* </remote> */         
-               
+               /* </remote> */
+
                /* <childsalist> */
                xmlTextWriterStartElement(writer, "childsalist");
                children = ike_sa->create_child_sa_iterator(ike_sa);
@@ -270,13 +270,13 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
                }
                children->destroy(children);
                /* </childsalist> */
-               xmlTextWriterEndElement(writer);                
-               
+               xmlTextWriterEndElement(writer);
+
                /* </ikesa> */
                xmlTextWriterEndElement(writer);
        }
        enumerator->destroy(enumerator);
-       
+
        /* </ikesalist> */
        xmlTextWriterEndElement(writer);
 }
@@ -291,7 +291,7 @@ static void request_query_config(xmlTextReaderPtr reader, xmlTextWriterPtr write
 
        /* <configlist> */
        xmlTextWriterStartElement(writer, "configlist");
-       
+
        enumerator = charon->backends->create_peer_cfg_enumerator(charon->backends,
                                                                                                                NULL, NULL, NULL, NULL);
        while (enumerator->enumerate(enumerator, &peer_cfg))
@@ -300,18 +300,18 @@ static void request_query_config(xmlTextReaderPtr reader, xmlTextWriterPtr write
                child_cfg_t *child_cfg;
                ike_cfg_t *ike_cfg;
                linked_list_t *list;
-               
+
                if (peer_cfg->get_ike_version(peer_cfg) != 2)
                {       /* only IKEv2 connections yet */
                        continue;
                }
-               
+
                /* <peerconfig> */
                xmlTextWriterStartElement(writer, "peerconfig");
                xmlTextWriterWriteElement(writer, "name", peer_cfg->get_name(peer_cfg));
-               
+
                /* TODO: write auth_cfgs */
-               
+
                /* <ikeconfig> */
                ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
                xmlTextWriterStartElement(writer, "ikeconfig");
@@ -319,14 +319,14 @@ static void request_query_config(xmlTextReaderPtr reader, xmlTextWriterPtr write
                xmlTextWriterWriteElement(writer, "remote", ike_cfg->get_other_addr(ike_cfg));
                xmlTextWriterEndElement(writer);
                /* </ikeconfig> */
-               
+
                /* <childconfiglist> */
                xmlTextWriterStartElement(writer, "childconfiglist");
                children = peer_cfg->create_child_cfg_enumerator(peer_cfg);
                while (children->enumerate(children, &child_cfg))
                {
                        /* <childconfig> */
-                       xmlTextWriterStartElement(writer, "childconfig");               
+                       xmlTextWriterStartElement(writer, "childconfig");
                        xmlTextWriterWriteElement(writer, "name",
                                                                          child_cfg->get_name(child_cfg));
                        list = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
@@ -334,7 +334,7 @@ static void request_query_config(xmlTextReaderPtr reader, xmlTextWriterPtr write
                        list->destroy_offset(list, offsetof(traffic_selector_t, destroy));
                        list = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
                        write_networks(writer, "remote", list);
-                       list->destroy_offset(list, offsetof(traffic_selector_t, destroy));              
+                       list->destroy_offset(list, offsetof(traffic_selector_t, destroy));
                        xmlTextWriterEndElement(writer);
                        /* </childconfig> */
                }
@@ -342,7 +342,7 @@ static void request_query_config(xmlTextReaderPtr reader, xmlTextWriterPtr write
                /* </childconfiglist> */
                xmlTextWriterEndElement(writer);
                /* </peerconfig> */
-               xmlTextWriterEndElement(writer);        
+               xmlTextWriterEndElement(writer);
        }
        enumerator->destroy(enumerator);
        /* </configlist> */
@@ -381,7 +381,7 @@ static void request_control_terminate(xmlTextReaderPtr reader,
                const char *str;
                u_int32_t id;
                status_t status;
-       
+
                str = xmlTextReaderConstValue(reader);
                if (str == NULL)
                {
@@ -393,7 +393,7 @@ static void request_control_terminate(xmlTextReaderPtr reader,
                {
                        enumerator_t *enumerator;
                        ike_sa_t *ike_sa;
-               
+
                        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
                        while (enumerator->enumerate(enumerator, &ike_sa))
                        {
@@ -411,21 +411,21 @@ static void request_control_terminate(xmlTextReaderPtr reader,
                        DBG1(DBG_CFG, "error parsing XML id string");
                        return;
                }
-               
+
                DBG1(DBG_CFG, "terminating %s_SA %d", ike ? "IKE" : "CHILD", id);
-               
+
                /* <log> */
                xmlTextWriterStartElement(writer, "log");
                if (ike)
                {
                        status = charon->controller->terminate_ike(
-                                       charon->controller,     id, 
+                                       charon->controller,     id,
                                        (controller_cb_t)xml_callback, writer);
                }
                else
                {
                        status = charon->controller->terminate_child(
-                                       charon->controller,     id, 
+                                       charon->controller,     id,
                                        (controller_cb_t)xml_callback, writer);
                }
                /* </log> */
@@ -448,7 +448,7 @@ static void request_control_initiate(xmlTextReaderPtr reader,
                peer_cfg_t *peer;
                child_cfg_t *child = NULL;
                enumerator_t *enumerator;
-                       
+
                str = xmlTextReaderConstValue(reader);
                if (str == NULL)
                {
@@ -456,7 +456,7 @@ static void request_control_initiate(xmlTextReaderPtr reader,
                        return;
                }
                DBG1(DBG_CFG, "initiating %s_SA %s", ike ? "IKE" : "CHILD", str);
-               
+
                /* <log> */
                xmlTextWriterStartElement(writer, "log");
                peer = charon->backends->get_peer_cfg_by_name(charon->backends, (char*)str);
@@ -571,7 +571,7 @@ static void request_control(xmlTextReaderPtr reader, xmlTextWriterPtr writer)
 static void request(xmlTextReaderPtr reader, char *id, int fd)
 {
        xmlTextWriterPtr writer;
-       
+
        writer = xmlNewTextWriter(xmlOutputBufferCreateFd(fd, NULL));
        if (writer == NULL)
        {
@@ -627,7 +627,7 @@ static job_requeue_t process(int *fdp)
        size_t len;
        xmlTextReaderPtr reader;
        char *id = NULL, *type = NULL;
-       
+
        pthread_cleanup_push((void*)closefdp, (void*)&fd);
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        len = read(fd, buffer, sizeof(buffer));
@@ -640,14 +640,14 @@ static job_requeue_t process(int *fdp)
                return JOB_REQUEUE_NONE;
        }
        DBG3(DBG_CFG, "got XML request: %b", buffer, len);
-       
+
        reader = xmlReaderForMemory(buffer, len, NULL, NULL, 0);
        if (reader == NULL)
        {
                DBG1(DBG_CFG, "opening SMP XML reader failed");
                return JOB_REQUEUE_FAIR;;
        }
-       
+
        /* read message type and id */
     while (xmlTextReaderRead(reader))
     {
@@ -659,7 +659,7 @@ static job_requeue_t process(int *fdp)
                        break;
                }
     }
-    
+
     /* process message */
     if (id && type)
        {
@@ -684,24 +684,24 @@ static job_requeue_t dispatch(private_smp_t *this)
        struct sockaddr_un strokeaddr;
        int oldstate, fd, *fdp, strokeaddrlen = sizeof(strokeaddr);
        callback_job_t *job;
-       
+
        /* wait for connections, but allow thread to terminate */
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        fd = accept(this->socket, (struct sockaddr *)&strokeaddr, &strokeaddrlen);
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (fd < 0)
        {
                DBG1(DBG_CFG, "accepting SMP XML socket failed: %s", strerror(errno));
                sleep(1);
                return JOB_REQUEUE_FAIR;;
        }
-       
+
        fdp = malloc_thing(int);
        *fdp = fd;
        job = callback_job_create((callback_job_cb_t)process, fdp, free, this->job);
        charon->processor->queue_job(charon->processor, (job_t*)job);
-       
+
        return JOB_REQUEUE_DIRECT;
 }
 
@@ -725,7 +725,7 @@ plugin_t *plugin_create()
        mode_t old;
 
        this->public.plugin.destroy = (void (*)(plugin_t*))destroy;
-       
+
        /* set up unix socket */
        this->socket = socket(AF_UNIX, SOCK_STREAM, 0);
        if (this->socket == -1)
@@ -734,7 +734,7 @@ plugin_t *plugin_create()
                free(this);
                return NULL;
        }
-       
+
        unlink(unix_addr.sun_path);
        old = umask(~(S_IRWXU | S_IRWXG));
        if (bind(this->socket, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0)
@@ -749,7 +749,7 @@ plugin_t *plugin_create()
        {
                DBG1(DBG_CFG, "changing XML socket permissions failed: %s", strerror(errno));
        }
-       
+
        if (listen(this->socket, 5) < 0)
        {
                DBG1(DBG_CFG, "could not listen on XML socket: %s", strerror(errno));
@@ -760,7 +760,7 @@ plugin_t *plugin_create()
 
        this->job = callback_job_create((callback_job_cb_t)dispatch, this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public.plugin;
 }
 
index ef119c9664e5b687826d625ca59bd160d31f87c0..c029dea24efab18be0a167dd0e0ae1a0425348d3 100644 (file)
@@ -43,7 +43,7 @@ static u_int get_pool_size(chunk_t start, chunk_t end)
 
        if (start.len < sizeof(u_int) || end.len < sizeof(u_int))
        {
-               return 0;       
+               return 0;
        }
        start_ptr = (u_int*)(start.ptr + start.len - sizeof(u_int));
        end_ptr = (u_int*)(end.ptr + end.len - sizeof(u_int));
@@ -103,7 +103,7 @@ static void status(void)
 {
        enumerator_t *pool, *lease;
        bool found = FALSE;
-       
+
        pool = db->query(db, "SELECT id, name, start, end, timeout FROM pools",
                                         DB_INT, DB_TEXT, DB_BLOB, DB_BLOB, DB_UINT);
        if (pool)
@@ -112,7 +112,7 @@ static void status(void)
                chunk_t start_chunk, end_chunk;
                host_t *start, *end;
                u_int id, timeout, online = 0, used = 0, size = 0;
-       
+
                while (pool->enumerate(pool, &id, &name,
                                                           &start_chunk, &end_chunk, &timeout))
                {
@@ -122,7 +122,7 @@ static void status(void)
                                           "end", "timeout", "size", "online", "usage");
                                found = TRUE;
                        }
-                       
+
                        start = host_create_from_chunk(AF_UNSPEC, start_chunk, 0);
                        end = host_create_from_chunk(AF_UNSPEC, end_chunk, 0);
                        size = get_pool_size(start_chunk, end_chunk);
@@ -159,7 +159,7 @@ static void status(void)
                                lease->destroy(lease);
                        }
                        printf("%5d (%2d%%) ", used, used*100/size);
-                       
+
                        printf("\n");
                        DESTROY_IF(start);
                        DESTROY_IF(end);
@@ -180,7 +180,7 @@ static void add(char *name, host_t *start, host_t *end, int timeout)
 {
        chunk_t start_addr, end_addr, cur_addr;
        u_int id, count;
-       
+
        start_addr = start->get_address(start);
        end_addr = end->get_address(end);
        cur_addr = chunk_clonea(start_addr);
@@ -224,7 +224,7 @@ static void add(char *name, host_t *start, host_t *end, int timeout)
                db->execute(db, NULL, "END TRANSACTION");
        }
        printf("done.\n", count);
-       
+
        exit(0);
 }
 
@@ -236,7 +236,7 @@ static void del(char *name)
        enumerator_t *query;
        u_int id;
        bool found = FALSE;
-       
+
        query = db->query(db, "SELECT id FROM pools WHERE name = ?",
                                          DB_TEXT, name, DB_UINT);
        if (!query)
@@ -277,9 +277,9 @@ static void resize(char *name, host_t *end)
        enumerator_t *query;
        chunk_t old_addr, new_addr, cur_addr;
        u_int id, count;
-       
+
        new_addr = end->get_address(end);
-       
+
        query = db->query(db, "SELECT id, end FROM pools WHERE name = ?",
                                          DB_TEXT, name, DB_UINT, DB_BLOB);
        if (!query || !query->enumerate(query, &id, &old_addr))
@@ -306,7 +306,7 @@ static void resize(char *name, host_t *end)
                fprintf(stderr, "pool '%s' not found.\n", name);
                exit(-1);
        }
-       
+
        printf("allocating %d new addresses... ", count);
        fflush(stdout);
        if (db->get_driver(db) == DB_SQLITE)
@@ -326,7 +326,7 @@ static void resize(char *name, host_t *end)
                db->execute(db, NULL, "END TRANSACTION");
        }
        printf("done.\n", count);
-       
+
        exit(0);
 }
 
@@ -356,7 +356,7 @@ static enumerator_t *create_lease_query(char *filter)
                [FIL_STATE] = "status",
                NULL
        };
-       
+
        /* if the filter string contains a distinguished name as a ID, we replace
         * ", " by "/ " in order to not confuse the getsubopt parser */
        pos = filter;
@@ -368,7 +368,7 @@ static enumerator_t *create_lease_query(char *filter)
                }
                pos++;
        }
-       
+
        while (filter && *filter != '\0')
        {
                switch (getsubopt(&filter, token, &value))
@@ -493,7 +493,7 @@ static void leases(char *filter, bool utc)
        host_t *address;
        identification_t *identity;
        bool found = FALSE;
-       
+
        query = create_lease_query(filter);
        if (!query)
        {
@@ -513,7 +513,7 @@ static void leases(char *filter, bool utc)
                }
                address = host_create_from_chunk(AF_UNSPEC, address_chunk, 0);
                identity = identification_create_from_encoding(identity_type, identity_chunk);
-               
+
                printf("%-8s %-15H ", name, address);
                if (released == 0)
                {
@@ -531,7 +531,7 @@ static void leases(char *filter, bool utc)
                {
                        printf("%-7s ", "expired");
                }
-               
+
                printf(" %T  ", &acquired, utc);
                if (released)
                {
@@ -564,7 +564,7 @@ static void leases(char *filter, bool utc)
 static void purge(char *name)
 {
        int purged = 0;
-       
+
        purged = db->execute(db, NULL,
                                "DELETE FROM leases WHERE address IN ("
                                " SELECT id FROM addresses WHERE pool IN ("
@@ -595,7 +595,7 @@ static void cleanup(void)
 static void dbg_stderr(int level, char *fmt, ...)
 {
        va_list args;
-       
+
        if (level <= 1)
        {
                va_start(args, fmt);
@@ -639,7 +639,7 @@ int main(int argc, char *argv[])
        {
                exit(SS_RC_INITIALIZATION_FAILED);
        }
-       
+
        uri = lib->settings->get_str(lib->settings, "charon.plugins.sql.database", NULL);
        if (!uri)
        {
@@ -653,14 +653,14 @@ int main(int argc, char *argv[])
                exit(SS_RC_INITIALIZATION_FAILED);
        }
        atexit(cleanup);
-       
+
        while (TRUE)
        {
                int c;
-               
+
                struct option long_opts[] = {
                        { "help", no_argument, NULL, 'h' },
-               
+
                        { "utc", no_argument, NULL, 'u' },
                        { "status", no_argument, NULL, 'w' },
                        { "add", required_argument, NULL, 'a' },
@@ -668,14 +668,14 @@ int main(int argc, char *argv[])
                        { "resize", required_argument, NULL, 'r' },
                        { "leases", no_argument, NULL, 'l' },
                        { "purge", required_argument, NULL, 'p' },
-                       
+
                        { "start", required_argument, NULL, 's' },
                        { "end", required_argument, NULL, 'e' },
                        { "timeout", required_argument, NULL, 't' },
                        { "filter", required_argument, NULL, 'f' },
                        { 0,0,0,0 }
                };
-               
+
                c = getopt_long(argc, argv, "", long_opts, NULL);
                switch (c)
                {
@@ -744,7 +744,7 @@ int main(int argc, char *argv[])
                }
                break;
        }
-       
+
        switch (operation)
        {
                case OP_USAGE:
index 77601e6126fab8f8aabefce4165582d5009caef0..9045f7739ea55a08f47bcacf403c45210809d39c 100644 (file)
@@ -30,12 +30,12 @@ struct private_sql_attribute_t {
         * public functions
         */
        sql_attribute_t public;
-       
+
        /**
         * database connection
         */
        database_t *db;
-       
+
        /**
         * wheter to record lease history in lease table
         */
@@ -49,13 +49,13 @@ static u_int get_identity(private_sql_attribute_t *this, identification_t *id)
 {
        enumerator_t *e;
        u_int row;
-       
+
        /* look for peer identity in the identities table */
        e = this->db->query(this->db,
                                                "SELECT id FROM identities WHERE type = ? AND data = ?",
                                                DB_INT, id->get_type(id), DB_BLOB, id->get_encoding(id),
                                                DB_UINT);
-                                               
+
        if (e && e->enumerate(e, &row))
        {
                e->destroy(e);
@@ -111,7 +111,7 @@ static host_t* check_lease(private_sql_attribute_t *this, char *name,
                if (!e || !e->enumerate(e, &id, &address))
                {
                        DESTROY_IF(e);
-                       break;  
+                       break;
                }
                address = chunk_clonea(address);
                e->destroy(e);
@@ -172,11 +172,11 @@ static host_t* get_lease(private_sql_attribute_t *this, char *name,
                if (!e || !e->enumerate(e, &id, &address))
                {
                        DESTROY_IF(e);
-                       break;  
+                       break;
                }
                address = chunk_clonea(address);
                e->destroy(e);
-                       
+
                if (timeout)
                {
                        hits = this->db->execute(this->db, NULL,
@@ -290,12 +290,12 @@ static bool release_address(private_sql_attribute_t *this,
        enumerator_t *enumerator;
        bool found = FALSE;
        time_t now = time(NULL);
-       
+
        enumerator = enumerator_create_token(name, ",", " ");
        while (enumerator->enumerate(enumerator, &name))
        {
                u_int pool, timeout;
-               
+
                pool = get_pool(this, name, &timeout);
                if (pool)
                {
@@ -337,16 +337,16 @@ sql_attribute_t *sql_attribute_create(database_t *db)
 {
        private_sql_attribute_t *this = malloc_thing(private_sql_attribute_t);
        time_t now = time(NULL);
-       
+
        this->public.provider.acquire_address = (host_t*(*)(attribute_provider_t *this, char*, identification_t *, host_t *))acquire_address;
        this->public.provider.release_address = (bool(*)(attribute_provider_t *this, char*,host_t *, identification_t*))release_address;
        this->public.provider.create_attribute_enumerator = (enumerator_t*(*)(attribute_provider_t*, identification_t *id))enumerator_create_empty;
        this->public.destroy = (void(*)(sql_attribute_t*))destroy;
-       
+
        this->db = db;
        this->history = lib->settings->get_bool(lib->settings,
                                                                        "charon.plugins.sql.lease_history", TRUE);
-       
+
        /* close any "online" leases in the case we crashed */
        if (this->history)
        {
index 23700dea980b15097b6232b194f05233992a6357..6d4958d3292ec71436da08d45d1eda60bea38a02 100644 (file)
@@ -34,7 +34,7 @@ struct sql_attribute_t {
         * Implements attribute provider interface
         */
        attribute_provider_t provider;
-       
+
        /**
      * Destroy a sql_attribute instance.
      */
index 67b5c3b64d0862ddf9454932a6e222b3d9bbb566..7c76c572d59f86ea5f0b2532d95ce943d3fe193d 100644 (file)
@@ -30,7 +30,7 @@ struct private_sql_config_t {
         * Public part
         */
        sql_config_t public;
-       
+
        /**
         * database connection
         */
@@ -58,7 +58,7 @@ static traffic_selector_t *build_traffic_selector(private_sql_config_t *this,
                TS_LOCAL_DYNAMIC = 2,
                TS_REMOTE_DYNAMIC = 3,
        } kind;
-       
+
        while (e->enumerate(e, &kind, &type, &protocol,
                                                &start_addr, &end_addr, &start_port, &end_port))
        {
@@ -99,7 +99,7 @@ static void add_traffic_selectors(private_sql_config_t *this,
        enumerator_t *e;
        traffic_selector_t *ts;
        bool local;
-       
+
        e = this->db->query(this->db,
                        "SELECT kind, type, protocol, "
                        "start_addr, end_addr, start_port, end_port "
@@ -126,8 +126,8 @@ static child_cfg_t *build_child_cfg(private_sql_config_t *this, enumerator_t *e)
        int id, lifetime, rekeytime, jitter, hostaccess, mode, dpd, close, ipcomp;
        char *name, *updown;
        child_cfg_t *child_cfg;
-       
-       if (e->enumerate(e, &id, &name, &lifetime, &rekeytime, &jitter, 
+
+       if (e->enumerate(e, &id, &name, &lifetime, &rekeytime, &jitter,
                                                &updown, &hostaccess, &mode, &dpd, &close, &ipcomp))
        {
                lifetime_cfg_t lft = {
@@ -150,7 +150,7 @@ static void add_child_cfgs(private_sql_config_t *this, peer_cfg_t *peer, int id)
 {
        enumerator_t *e;
        child_cfg_t *child_cfg;
-       
+
        e = this->db->query(this->db,
                        "SELECT id, name, lifetime, rekeytime, jitter, "
                        "updown, hostaccess, mode, dpd_action, close_action, ipcomp "
@@ -177,11 +177,11 @@ static ike_cfg_t *build_ike_cfg(private_sql_config_t *this, enumerator_t *e,
 {
        int certreq, force_encap;
        char *local, *remote;
-       
+
        while (e->enumerate(e, &certreq, &force_encap, &local, &remote))
        {
                ike_cfg_t *ike_cfg;
-               
+
                ike_cfg = ike_cfg_create(certreq, force_encap, local, remote);
                /* TODO: read proposal from db */
                ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
@@ -197,7 +197,7 @@ static ike_cfg_t* get_ike_cfg_by_id(private_sql_config_t *this, int id)
 {
        enumerator_t *e;
        ike_cfg_t *ike_cfg = NULL;
-       
+
        e = this->db->query(this->db,
                        "SELECT certreq, force_encap, local, remote "
                        "FROM ike_configs WHERE id = ?",
@@ -218,7 +218,7 @@ static peer_cfg_t *get_peer_cfg_by_id(private_sql_config_t *this, int id)
 {
        enumerator_t *e;
        peer_cfg_t *peer_cfg = NULL;
-       
+
        e = this->db->query(this->db,
                        "SELECT c.id, name, ike_cfg, l.type, l.data, r.type, r.data, "
                        "cert_policy, uniqueid, auth_method, eap_type, eap_vendor, "
@@ -232,8 +232,8 @@ static peer_cfg_t *get_peer_cfg_by_id(private_sql_config_t *this, int id)
                        "WHERE id = ?",
                        DB_INT, id,
                        DB_INT, DB_TEXT, DB_INT, DB_INT, DB_BLOB, DB_INT, DB_BLOB,
-                       DB_INT, DB_INT, DB_INT, DB_INT, DB_INT, 
-                       DB_INT, DB_INT, DB_INT, DB_INT, DB_INT, DB_INT, 
+                       DB_INT, DB_INT, DB_INT, DB_INT, DB_INT,
+                       DB_INT, DB_INT, DB_INT, DB_INT, DB_INT, DB_INT,
                        DB_INT, DB_TEXT, DB_TEXT,
                        DB_INT, DB_INT, DB_INT, DB_BLOB);
        if (e)
@@ -256,11 +256,11 @@ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e,
                mediation, mediated_by, p_type;
        chunk_t l_data, r_data, p_data;
        char *name, *virtual, *pool;
-       
+
        while (e->enumerate(e,
                        &id, &name, &ike_cfg, &l_type, &l_data, &r_type, &r_data,
                        &cert_policy, &uniqueid, &auth_method, &eap_type, &eap_vendor,
-                       &keyingtries, &rekeytime, &reauthtime, &jitter, &overtime, &mobike, 
+                       &keyingtries, &rekeytime, &reauthtime, &jitter, &overtime, &mobike,
                        &dpd_delay,     &virtual, &pool,
                        &mediation, &mediated_by, &p_type, &p_data))
        {
@@ -269,7 +269,7 @@ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e,
                ike_cfg_t *ike;
                host_t *vip = NULL;
                auth_cfg_t *auth;
-               
+
                local_id = identification_create_from_encoding(l_type, l_data);
                remote_id = identification_create_from_encoding(r_type, r_data);
                if ((me && !me->matches(me, local_id)) ||
@@ -331,7 +331,7 @@ static peer_cfg_t *get_peer_cfg_by_name(private_sql_config_t *this, char *name)
 {
        enumerator_t *e;
        peer_cfg_t *peer_cfg = NULL;
-       
+
        e = this->db->query(this->db,
                        "SELECT c.id, name, ike_cfg, l.type, l.data, r.type, r.data, "
                        "cert_policy, uniqueid, auth_method, eap_type, eap_vendor, "
@@ -404,14 +404,14 @@ static enumerator_t* create_ike_cfg_enumerator(private_sql_config_t *this,
                                                                                           host_t *me, host_t *other)
 {
        ike_enumerator_t *e = malloc_thing(ike_enumerator_t);
-       
+
        e->this = this;
        e->me = me;
        e->other = other;
        e->current = NULL;
        e->public.enumerate = (void*)ike_enumerator_enumerate;
        e->public.destroy = (void*)ike_enumerator_destroy;
-       
+
        e->inner = this->db->query(this->db,
                        "SELECT certreq, force_encap, local, remote "
                        "FROM ike_configs",
@@ -473,7 +473,7 @@ static enumerator_t* create_peer_cfg_enumerator(private_sql_config_t *this,
                                                                                                identification_t *other)
 {
        peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
-       
+
        e->this = this;
        e->me = me;
        e->other = other;
@@ -526,9 +526,9 @@ sql_config_t *sql_config_create(database_t *db)
        this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
        this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
        this->public.destroy = (void(*)(sql_config_t*))destroy;
-       
+
        this->db = db;
-       
+
        return &this->public;
 }
 
index abc6ef3823ec62c476ef6b46c4f15d3dfc3c9119..700d00a9712f7306fb3e82fa2527fe8e5f20203b 100644 (file)
@@ -35,11 +35,11 @@ struct sql_config_t {
         * Implements backend_t interface
         */
        backend_t backend;
-       
+
        /**
         * Destry the backend.
         */
-       void (*destroy)(sql_config_t *this);    
+       void (*destroy)(sql_config_t *this);
 };
 
 /**
index f8b7a35c12a1d64d1bdda9d914e62562b4490f84..12f4ab04525453391f808315d5114dc578c534e6 100644 (file)
@@ -30,7 +30,7 @@ struct private_sql_cred_t {
         * Public part
         */
        sql_cred_t public;
-       
+
        /**
         * database connection
         */
@@ -92,7 +92,7 @@ static enumerator_t* create_private_enumerator(private_sql_cred_t *this,
                                                                                           identification_t *id)
 {
        private_enumerator_t *e;
-       
+
        e = malloc_thing(private_enumerator_t);
        e->current = NULL;
        e->public.enumerate = (void*)private_enumerator_enumerate;
@@ -178,7 +178,7 @@ static enumerator_t* create_cert_enumerator(private_sql_cred_t *this,
                                                                                identification_t *id, bool trusted)
 {
        cert_enumerator_t *e;
-       
+
        e = malloc_thing(cert_enumerator_t);
        e->current = NULL;
        e->public.enumerate = (void*)cert_enumerator_enumerate;
@@ -275,11 +275,11 @@ static void shared_enumerator_destroy(shared_enumerator_t *this)
  * Implementation of credential_set_t.create_shared_enumerator.
  */
 static enumerator_t* create_shared_enumerator(private_sql_cred_t *this,
-                                                                 shared_key_type_t type, 
+                                                                 shared_key_type_t type,
                                                                  identification_t *me, identification_t *other)
 {
        shared_enumerator_t *e;
-       
+
        e = malloc_thing(shared_enumerator_t);
        e->me = me;
        e->other = other;
@@ -306,12 +306,12 @@ static enumerator_t* create_shared_enumerator(private_sql_cred_t *this,
                                DB_INT, me->get_type(me), DB_BLOB, me->get_encoding(me),
                                DB_INT, other->get_type(other), DB_BLOB, other->get_encoding(other),
                                DB_INT, type == SHARED_ANY, DB_INT, type,
-                               DB_INT, DB_BLOB);                               
+                               DB_INT, DB_BLOB);
        }
        else
        {
                identification_t *id = me ? me : other;
-               
+
                e->inner = this->db->query(this->db,
                                "SELECT s.type, s.data FROM shared_secrets AS s "
                                "JOIN shared_secret_identity AS si ON s.id = si.shared_secret "
@@ -350,16 +350,16 @@ static void destroy(private_sql_cred_t *this)
 sql_cred_t *sql_cred_create(database_t *db)
 {
        private_sql_cred_t *this = malloc_thing(private_sql_cred_t);
-       
+
        this->public.set.create_private_enumerator = (void*)create_private_enumerator;
        this->public.set.create_cert_enumerator = (void*)create_cert_enumerator;
        this->public.set.create_shared_enumerator = (void*)create_shared_enumerator;
        this->public.set.create_cdp_enumerator = (void*)return_null;
        this->public.set.cache_cert = (void*)cache_cert;
        this->public.destroy = (void(*)(sql_cred_t*))destroy;
-       
+
        this->db = db;
-       
+
        return &this->public;
 }
 
index 2a9a96df1e36b50ebabfd0824eb9c12472e46271..7f387398e73a9be5c6a91a236b4985412c76ecd7 100644 (file)
@@ -35,11 +35,11 @@ struct sql_cred_t {
         * Implements credential_set_t interface
         */
        credential_set_t set;
-       
+
        /**
         * Destry the backend.
         */
-       void (*destroy)(sql_cred_t *this);      
+       void (*destroy)(sql_cred_t *this);
 };
 
 /**
index 20d42662b6c3d30cdc5cb1a007a68b684330119b..d350c4c3dc4bb5926c41835d0aeb5c245553a8ef 100644 (file)
@@ -30,17 +30,17 @@ struct private_sql_logger_t {
         * Public part
         */
        sql_logger_t public;
-       
+
        /**
         * database connection
         */
        database_t *db;
-       
+
        /**
         * logging level
         */
        int level;
-       
+
        /**
         * avoid recursive logging
         */
@@ -67,7 +67,7 @@ static bool log_(private_sql_logger_t *this, debug_t group, level_t level,
                identification_t *local_id, *remote_id;
                u_int64_t ispi, rspi;
                ike_sa_id_t *id;
-       
+
                id = ike_sa->get_id(ike_sa);
                ispi = id->get_initiator_spi(id);
                rspi = id->get_responder_spi(id);
@@ -86,9 +86,9 @@ static bool log_(private_sql_logger_t *this, debug_t group, level_t level,
                remote_id = ike_sa->get_other_id(ike_sa);
                local_host = ike_sa->get_my_host(ike_sa);
                remote_host = ike_sa->get_other_host(ike_sa);
-               
+
                vsnprintf(buffer, sizeof(buffer), format, args);
-               
+
                this->db->execute(this->db, NULL, "REPLACE INTO ike_sas ("
                                                  "local_spi, remote_spi, id, initiator, "
                                                  "local_id_type, local_id_data, "
@@ -129,17 +129,17 @@ static void destroy(private_sql_logger_t *this)
 sql_logger_t *sql_logger_create(database_t *db)
 {
        private_sql_logger_t *this = malloc_thing(private_sql_logger_t);
-       
+
        memset(&this->public.listener, 0, sizeof(listener_t));
        this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
        this->public.destroy = (void(*)(sql_logger_t*))destroy;
-       
+
        this->db = db;
        this->recursive = FALSE;
-       
+
        this->level = lib->settings->get_int(lib->settings,
                                                                                 "charon.plugins.sql.loglevel", -1);
-       
+
        return &this->public;
 }
 
index 3636c2293d9df6bc14d6c15243361f7c4f077fdb..a933705daa6b49d4138b621fa85f9ab02eea3be0 100644 (file)
@@ -35,11 +35,11 @@ struct sql_logger_t {
         * Implements bus_listener_t interface
         */
        listener_t listener;
-       
+
        /**
         * Destry the backend.
         */
-       void (*destroy)(sql_logger_t *this);    
+       void (*destroy)(sql_logger_t *this);
 };
 
 /**
index e5a4afd1d8af6eb6062e8555c77c5f5e5d1a0691..65691cc00c5c6e5969ecf28842373f07fccf50ec 100644 (file)
@@ -32,27 +32,27 @@ struct private_sql_plugin_t {
         * implements plugin interface
         */
        sql_plugin_t public;
-       
+
        /**
         * database connection instance
         */
        database_t *db;
-       
+
        /**
         * configuration backend
         */
        sql_config_t *config;
-       
+
        /**
         * credential set
         */
        sql_cred_t *cred;
-       
+
        /**
         * CFG attributes
         */
        sql_attribute_t *attribute;
-       
+
        /**
         * bus listener/logger
         */
@@ -83,18 +83,18 @@ plugin_t *plugin_create()
 {
        char *uri;
        private_sql_plugin_t *this;
-       
+
        uri = lib->settings->get_str(lib->settings, "charon.plugins.sql.database", NULL);
        if (!uri)
        {
                DBG1(DBG_CFG, "sql plugin: database URI not set");
                return NULL;
        }
-       
+
        this = malloc_thing(private_sql_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->db = lib->db->create(lib->db, uri);
        if (!this->db)
        {
@@ -106,12 +106,12 @@ plugin_t *plugin_create()
        this->cred = sql_cred_create(this->db);
        this->attribute = sql_attribute_create(this->db);
        this->logger = sql_logger_create(this->db);
-       
+
        charon->backends->add_backend(charon->backends, &this->config->backend);
        charon->credentials->add_set(charon->credentials, &this->cred->set);
        charon->attributes->add_provider(charon->attributes, &this->attribute->provider);
        charon->bus->add_listener(charon->bus, &this->logger->listener);
-       
+
        return &this->public.plugin;
 }
 
index d3211fd673a8d215258fa4c99d4840084610a3b3..14464e0bd2cfa76ab2437f9235824a6b95d2d8f9 100644 (file)
@@ -33,12 +33,12 @@ struct private_stroke_attribute_t {
         * public functions
         */
        stroke_attribute_t public;
-       
+
        /**
         * list of pools, contains pool_t
         */
        linked_list_t *pools;
-       
+
        /**
         * mutex to lock access to pools
         */
@@ -85,7 +85,7 @@ static void pool_destroy(pool_t *this)
 {
        enumerator_t *enumerator;
        identification_t *id;
-       
+
        enumerator = this->ids->create_enumerator(this->ids);
        while (enumerator->enumerate(enumerator, &id, NULL))
        {
@@ -107,7 +107,7 @@ static pool_t *find_pool(private_stroke_attribute_t *this, char *name)
 {
        enumerator_t *enumerator;
        pool_t *current, *found = NULL;
-       
+
        enumerator = this->pools->create_enumerator(this->pools);
        while (enumerator->enumerate(enumerator, &current))
        {
@@ -129,13 +129,13 @@ host_t* offset2host(pool_t *pool, int offset)
        chunk_t addr;
        host_t *host;
        u_int32_t *pos;
-       
+
        offset--;
        if (offset > pool->size)
        {
                return NULL;
        }
-       
+
        addr = chunk_clone(pool->base->get_address(pool->base));
        if (pool->base->get_family(pool->base) == AF_INET6)
        {
@@ -158,7 +158,7 @@ int host2offset(pool_t *pool, host_t *addr)
 {
        chunk_t host, base;
        u_int32_t hosti, basei;
-       
+
        if (addr->get_family(addr) != pool->base->get_family(pool->base))
        {
                return -1;
@@ -195,7 +195,7 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
        uintptr_t offset = 0;
        enumerator_t *enumerator;
        identification_t *old_id;
-       
+
        this->mutex->lock(this->mutex);
        pool = find_pool(this, name);
        while (pool)
@@ -206,7 +206,7 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
                        this->mutex->unlock(this->mutex);
                        return requested->clone(requested);
                }
-               
+
                if (!requested->is_anyaddr(requested) &&
                        requested->get_family(requested) !=
                        pool->base->get_family(pool->base))
@@ -214,7 +214,7 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
                        DBG1(DBG_CFG, "IP pool address family mismatch");
                        break;
                }
-               
+
                /* check for a valid offline lease, refresh */
                offset = (uintptr_t)pool->offline->remove(pool->offline, id);
                if (offset)
@@ -227,7 +227,7 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
                                break;
                        }
                }
-               
+
                /* check for a valid online lease, reassign */
                offset = (uintptr_t)pool->online->get(pool->online, id);
                if (offset && offset == host2offset(pool, requested))
@@ -235,7 +235,7 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
                        DBG1(DBG_CFG, "reassigning online lease to '%Y'", id);
                        break;
                }
-               
+
                if (pool->unused < pool->size)
                {
                        /* assigning offset, starting by 1. Handling 0 in hashtable
@@ -270,7 +270,7 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
                        }
                }
                enumerator->destroy(enumerator);
-               
+
                DBG1(DBG_CFG, "pool '%s' is full, unable to assign address", name);
                break;
        }
@@ -291,7 +291,7 @@ static bool release_address(private_stroke_attribute_t *this,
        pool_t *pool;
        bool found = FALSE;
        uintptr_t offset;
-       
+
        this->mutex->lock(this->mutex);
        pool = find_pool(this, name);
        if (pool)
@@ -323,7 +323,7 @@ static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
        if (msg->add_conn.other.sourceip_size)
        {
                pool_t *pool;
-               
+
                pool = malloc_thing(pool_t);
                pool->base = NULL;
                pool->size = 0;
@@ -335,17 +335,17 @@ static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
                                                                                (hashtable_equals_t)id_equals, 16);
                pool->ids = hashtable_create((hashtable_hash_t)id_hash,
                                                                                (hashtable_equals_t)id_equals, 16);
-               
+
                /* if %config, add an empty pool, otherwise */
                if (msg->add_conn.other.sourceip)
                {
                        u_int32_t bits;
                        int family;
-               
-                       DBG1(DBG_CFG, "adding virtual IP address pool '%s': %s/%d", 
-                                msg->add_conn.name, msg->add_conn.other.sourceip, 
+
+                       DBG1(DBG_CFG, "adding virtual IP address pool '%s': %s/%d",
+                                msg->add_conn.name, msg->add_conn.other.sourceip,
                                 msg->add_conn.other.sourceip_size);
-               
+
                        pool->base = host_create_from_string(msg->add_conn.other.sourceip, 0);
                        if (!pool->base)
                        {
@@ -363,7 +363,7 @@ static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
                                         (family == AF_INET ? 32 : 128) - bits);
                        }
                        pool->size = 1 << (bits);
-                       
+
                        if (pool->size > 2)
                        {       /* do not use first and last addresses of a block */
                                pool->unused++;
@@ -383,7 +383,7 @@ static void del_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
 {
        enumerator_t *enumerator;
        pool_t *pool;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->pools->create_enumerator(this->pools);
        while (enumerator->enumerate(enumerator, &pool))
@@ -407,7 +407,7 @@ static bool pool_filter(void *mutex, pool_t **poolp, char **name,
                                                void *d3, u_int *offline)
 {
        pool_t *pool = *poolp;
-       
+
        *name = pool->name;
        *size = pool->size;
        *online = pool->online->get_count(pool->online);
@@ -450,10 +450,10 @@ static bool lease_enumerate(lease_enumerator_t *this, identification_t **id_out,
 {
        identification_t *id;
        uintptr_t offset;
-       
+
        DESTROY_IF(this->current);
        this->current = NULL;
-       
+
        if (this->inner->enumerate(this->inner, &id, NULL))
        {
                offset = (uintptr_t)this->pool->online->get(this->pool->online, id);
@@ -494,7 +494,7 @@ static enumerator_t* create_lease_enumerator(private_stroke_attribute_t *this,
                                                                                         char *pool)
 {
        lease_enumerator_t *enumerator;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = malloc_thing(lease_enumerator_t);
        enumerator->pool = find_pool(this, pool);
@@ -528,7 +528,7 @@ static void destroy(private_stroke_attribute_t *this)
 stroke_attribute_t *stroke_attribute_create()
 {
        private_stroke_attribute_t *this = malloc_thing(private_stroke_attribute_t);
-       
+
        this->public.provider.acquire_address = (host_t*(*)(attribute_provider_t *this, char*, identification_t *,host_t *))acquire_address;
        this->public.provider.release_address = (bool(*)(attribute_provider_t *this, char*,host_t *, identification_t*))release_address;
        this->public.provider.create_attribute_enumerator = (enumerator_t*(*)(attribute_provider_t*, identification_t *id))enumerator_create_empty;
@@ -537,10 +537,10 @@ stroke_attribute_t *stroke_attribute_create()
        this->public.create_pool_enumerator = (enumerator_t*(*)(stroke_attribute_t*))create_pool_enumerator;
        this->public.create_lease_enumerator = (enumerator_t*(*)(stroke_attribute_t*, char *pool))create_lease_enumerator;
        this->public.destroy = (void(*)(stroke_attribute_t*))destroy;
-       
+
        this->pools = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
-       
+
        return &this->public;
 }
 
index fc273d1cb1559116e142143c46f64e8dea90bd15..0bb8ae4bf189780a13b6dd0cf777b60df80ce028 100644 (file)
@@ -30,12 +30,12 @@ typedef struct stroke_attribute_t stroke_attribute_t;
  * Stroke IKEv2 cfg attribute provider
  */
 struct stroke_attribute_t {
-       
+
        /**
         * Implements attribute provider interface
         */
        attribute_provider_t provider;
-       
+
        /**
         * Add a virtual IP address.
         *
@@ -43,24 +43,24 @@ struct stroke_attribute_t {
         * @param end           end of stroke message that contains virtual IP.
         */
        void (*add_pool)(stroke_attribute_t *this, stroke_msg_t *msg);
-       
+
        /**
         * Remove a virtual IP address.
         *
         * @param msg           stroke message
         */
        void (*del_pool)(stroke_attribute_t *this, stroke_msg_t *msg);
-       
+
        /**
         * Create an enumerator over installed pools.
         *
-        * Enumerator enumerates over 
+        * Enumerator enumerates over
         * char *pool, u_int size, u_int offline, u_int online.
         *
         * @return                      enumerator
         */
        enumerator_t* (*create_pool_enumerator)(stroke_attribute_t *this);
-       
+
        /**
         * Create an enumerator over the leases of a pool.
         *
index 2f87ba0aa9630195d7568e7a0e2759757d0ec336..2c3e2936e22afe369feca8e3b0cabc358f5d1038 100644 (file)
@@ -34,17 +34,17 @@ struct private_stroke_ca_t {
         * public functions
         */
        stroke_ca_t public;
-       
+
        /**
         * read-write lock to lists
         */
        rwlock_t *lock;
-       
+
        /**
         * list of starters CA sections and its certificates (ca_section_t)
         */
        linked_list_t *sections;
-       
+
        /**
         * stroke credentials, stores our CA certificates
         */
@@ -62,27 +62,27 @@ struct ca_section_t {
         * name of the CA section
         */
        char *name;
-       
+
        /**
         * reference to cert in trusted_credential_t
         */
        certificate_t *cert;
-       
+
        /**
         * CRL URIs
         */
        linked_list_t *crl;
-       
+
        /**
         * OCSP URIs
         */
        linked_list_t *ocsp;
-       
+
        /**
         * Hashes of certificates issued by this CA
         */
        linked_list_t *hashes;
-       
+
        /**
         * Base URI used for certificates from this CA
         */
@@ -90,12 +90,12 @@ struct ca_section_t {
 };
 
 /**
- * create a new CA section 
+ * create a new CA section
  */
 static ca_section_t *ca_section_create(char *name, certificate_t *cert)
 {
        ca_section_t *ca = malloc_thing(ca_section_t);
-       
+
        ca->name = strdup(name);
        ca->crl = linked_list_create();
        ca->ocsp = linked_list_create();
@@ -145,7 +145,7 @@ static enumerator_t *create_inner_cdp(ca_section_t *section, cdp_data_t *data)
        chunk_t keyid;
        enumerator_t *enumerator = NULL;
        linked_list_t *list;
-       
+
        if (data->type == CERT_X509_OCSP_RESPONSE)
        {
                list = section->ocsp;
@@ -154,7 +154,7 @@ static enumerator_t *create_inner_cdp(ca_section_t *section, cdp_data_t *data)
        {
                list = section->crl;
        }
-       
+
        public = section->cert->get_public_key(section->cert);
        if (public)
        {
@@ -182,25 +182,25 @@ static enumerator_t *create_inner_cdp_hashandurl(ca_section_t *section, cdp_data
 {
        enumerator_t *enumerator = NULL, *hash_enum;
        identification_t *current;
-       
+
        if (!data->id || !section->certuribase)
        {
                return NULL;
        }
-       
+
        hash_enum = section->hashes->create_enumerator(section->hashes);
        while (hash_enum->enumerate(hash_enum, &current))
-       {       
+       {
                if (current->matches(current, data->id))
                {
                        char *url, *hash;
-                       
+
                        url = malloc(strlen(section->certuribase) + 40 + 1);
                        strcpy(url, section->certuribase);
                        hash = chunk_to_hex(current->get_encoding(current), NULL, FALSE).ptr;
                        strncat(url, hash, 40);
                        free(hash);
-                       
+
                        enumerator = enumerator_create_single(url, free);
                        break;
                }
@@ -231,7 +231,7 @@ static enumerator_t *create_cdp_enumerator(private_stroke_ca_t *this,
        data->this = this;
        data->type = type;
        data->id = id;
-       
+
        this->lock->read_lock(this->lock);
        return enumerator_create_nested(this->sections->create_enumerator(this->sections),
                        (type == CERT_X509) ? (void*)create_inner_cdp_hashandurl : (void*)create_inner_cdp,
@@ -244,12 +244,12 @@ static void add(private_stroke_ca_t *this, stroke_msg_t *msg)
 {
        certificate_t *cert;
        ca_section_t *ca;
-       
+
        if (msg->add_ca.cacert == NULL)
        {
                DBG1(DBG_CFG, "missing cacert parameter");
                return;
-       }       
+       }
        cert = this->cred->load_ca(this->cred, msg->add_ca.cacert);
        if (cert)
        {
@@ -288,7 +288,7 @@ static void del(private_stroke_ca_t *this, stroke_msg_t *msg)
 {
        enumerator_t *enumerator;
        ca_section_t *ca = NULL;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->sections->create_enumerator(this->sections);
        while (enumerator->enumerate(enumerator, &ca))
@@ -344,14 +344,14 @@ static void check_for_hash_and_url(private_stroke_ca_t *this, certificate_t* cer
 {
        ca_section_t *section;
        enumerator_t *enumerator;
-       
+
        hasher_t *hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (hasher == NULL)
        {
                DBG1(DBG_IKE, "unable to use hash-and-url: sha1 not supported");
                return;
        }
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->sections->create_enumerator(this->sections);
        while (enumerator->enumerate(enumerator, (void**)&section))
@@ -369,7 +369,7 @@ static void check_for_hash_and_url(private_stroke_ca_t *this, certificate_t* cer
        }
        enumerator->destroy(enumerator);
        this->lock->unlock(this->lock);
-       
+
        hasher->destroy(hasher);
 }
 
@@ -381,7 +381,7 @@ static void list(private_stroke_ca_t *this, stroke_msg_t *msg, FILE *out)
        bool first = TRUE;
        ca_section_t *section;
        enumerator_t *enumerator;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->sections->create_enumerator(this->sections);
        while (enumerator->enumerate(enumerator, (void**)&section))
@@ -389,7 +389,7 @@ static void list(private_stroke_ca_t *this, stroke_msg_t *msg, FILE *out)
                certificate_t *cert = section->cert;
                public_key_t *public = cert->get_public_key(cert);
                chunk_t chunk;
-               
+
                if (first)
                {
                        fprintf(out, "\n");
@@ -398,7 +398,7 @@ static void list(private_stroke_ca_t *this, stroke_msg_t *msg, FILE *out)
                }
                fprintf(out, "\n");
                fprintf(out, "  authname:    \"%Y\"\n", cert->get_subject(cert));
-               
+
                /* list authkey and keyid */
                if (public)
                {
@@ -439,7 +439,7 @@ static void destroy(private_stroke_ca_t *this)
 stroke_ca_t *stroke_ca_create(stroke_cred_t *cred)
 {
        private_stroke_ca_t *this = malloc_thing(private_stroke_ca_t);
-       
+
        this->public.set.create_private_enumerator = (void*)return_null;
        this->public.set.create_cert_enumerator = (void*)return_null;
        this->public.set.create_shared_enumerator = (void*)return_null;
@@ -450,11 +450,11 @@ stroke_ca_t *stroke_ca_create(stroke_cred_t *cred)
        this->public.list = (void(*)(stroke_ca_t*, stroke_msg_t *msg, FILE *out))list;
        this->public.check_for_hash_and_url = (void(*)(stroke_ca_t*, certificate_t*))check_for_hash_and_url;
        this->public.destroy = (void(*)(stroke_ca_t*))destroy;
-       
+
        this->sections = linked_list_create();
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
        this->cred = cred;
-       
+
        return &this->public;
 }
 
index c882d7b4e990abe3433d0c24b3f86d0e1a352745..ae55fe8e72a6eca1e8e75b064cf8806e6725a8b4 100644 (file)
@@ -37,35 +37,35 @@ struct stroke_ca_t {
         * Implements credential_set_t
         */
        credential_set_t set;
-       
+
        /**
         * Add a CA to the set using a stroke_msg_t.
         *
         * @param msg           stroke message containing CA info
         */
        void (*add)(stroke_ca_t *this, stroke_msg_t *msg);
-       
+
        /**
         * Remove a CA from the set using a stroke_msg_t.
         *
         * @param msg           stroke message containing CA info
         */
        void (*del)(stroke_ca_t *this, stroke_msg_t *msg);
-       
+
        /**
         * List CA sections to stroke console.
         *
         * @param msg           stroke message
         */
        void (*list)(stroke_ca_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Check if a certificate can be made available through hash and URL.
-        * 
+        *
         * @param cert          peer certificate
         */
        void (*check_for_hash_and_url)(stroke_ca_t *this, certificate_t* cert);
-       
+
        /**
      * Destroy a stroke_ca instance.
      */
index 4404f7078a8c6539aeefbcfcba188e0da0deb3b7..2da1948db198dc612e3702cc1d57b4f6b7660343 100644 (file)
@@ -30,22 +30,22 @@ struct private_stroke_config_t {
         * public functions
         */
        stroke_config_t public;
-       
+
        /**
         * list of peer_cfg_t
         */
        linked_list_t *list;
-       
+
        /**
         * mutex to lock config list
         */
        mutex_t *mutex;
-       
+
        /**
         * ca sections
         */
        stroke_ca_t *ca;
-       
+
        /**
         * credentials
         */
@@ -93,7 +93,7 @@ static peer_cfg_t *get_peer_cfg_by_name(private_stroke_config_t *this, char *nam
        enumerator_t *e1, *e2;
        peer_cfg_t *current, *found = NULL;
        child_cfg_t *child;
-       
+
        this->mutex->lock(this->mutex);
        e1 = this->list->create_enumerator(this->list);
        while (e1->enumerate(e1, &current))
@@ -139,7 +139,7 @@ static void add_proposals(private_stroke_config_t *this, char *string,
                char *strict;
                proposal_t *proposal;
                protocol_id_t proto = PROTO_ESP;
-               
+
                if (ike_cfg)
                {
                        proto = PROTO_IKE;
@@ -195,7 +195,7 @@ static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg
        ike_cfg_t *ike_cfg;
        char *interface;
        host_t *host;
-       
+
        host = host_create_from_dns(msg->add_conn.other.address, 0, 0);
        if (host)
        {
@@ -227,7 +227,7 @@ static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg
                                {
                                        free(interface);
                                }
-                               
+
                        }
                }
        }
@@ -275,7 +275,7 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
        stroke_end_t *end, *other_end;
        auth_cfg_t *cfg;
        char eap_buf[32];
-       
+
        /* select strings */
        if (local)
        {
@@ -317,7 +317,7 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
                        ca = other_end->ca2;
                }
        }
-       
+
        if (!auth)
        {
                if (primary)
@@ -366,9 +366,9 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
                        return NULL;
                }
        }
-       
+
        cfg = auth_cfg_create();
-       
+
        /* add identity and peer certifcate */
        identity = identification_create_from_string(id);
        if (cert)
@@ -394,7 +394,7 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
                }
        }
        cfg->add(cfg, AUTH_RULE_IDENTITY, identity);
-       
+
        /* CA constraint */
        if (ca)
        {
@@ -412,13 +412,13 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
                                 "constraint", ca);
                }
        }
-       
+
        /* AC groups */
        if (end->groups)
        {
                enumerator_t *enumerator;
                char *group;
-               
+
                enumerator = enumerator_create_token(end->groups, ",", " ");
                while (enumerator->enumerate(enumerator, &group))
                {
@@ -428,7 +428,7 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
                }
                enumerator->destroy(enumerator);
        }
-       
+
        /* authentication metod (class, actually) */
        if (streq(auth, "pubkey") ||
                streq(auth, "rsasig") || streq(auth, "rsa") ||
@@ -446,9 +446,9 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
                enumerator_t *enumerator;
                char *str;
                int i = 0, type = 0, vendor;
-               
+
                cfg->add(cfg, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_EAP);
-               
+
                /* parse EAP string, format: eap[-type[-vendor]] */
                enumerator = enumerator_create_token(auth, "-", " ");
                while (enumerator->enumerate(enumerator, &str))
@@ -488,7 +488,7 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
                        i++;
                }
                enumerator->destroy(enumerator);
-               
+
                if (msg->add_conn.eap_identity)
                {
                        if (streq(msg->add_conn.eap_identity, "%identity"))
@@ -529,7 +529,7 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
        u_int32_t rekey = 0, reauth = 0, over, jitter;
        peer_cfg_t *peer_cfg;
        auth_cfg_t *auth_cfg;
-       
+
 #ifdef ME
        if (msg->add_conn.ikeme.mediation && msg->add_conn.ikeme.mediated_by)
        {
@@ -537,13 +537,13 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
                         "at the same time, aborting");
                return NULL;
        }
-       
+
        if (msg->add_conn.ikeme.mediation)
        {
                /* force unique connections for mediation connections */
                msg->add_conn.unique = 1;
        }
-       
+
        if (msg->add_conn.ikeme.mediated_by)
        {
                mediated_by = charon->backends->get_peer_cfg_by_name(charon->backends,
@@ -572,7 +572,7 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
                }
        }
 #endif /* ME */
-       
+
        jitter = msg->add_conn.rekey.margin * msg->add_conn.rekey.fuzz / 100;
        over = msg->add_conn.rekey.margin;
        if (msg->add_conn.rekey.reauth)
@@ -632,7 +632,7 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
        {       /* dpdaction=none disables DPD */
                msg->add_conn.dpd.delay = 0;
        }
-       
+
        /* other.sourceip is managed in stroke_attributes. If it is set, we define
         * the pool name as the connection name, which the attribute provider
         * uses to serve pool addresses. */
@@ -644,7 +644,7 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
                vip, msg->add_conn.other.sourceip_size ?
                                                        msg->add_conn.name : msg->add_conn.other.sourceip,
                msg->add_conn.ikeme.mediation, mediated_by, peer_id);
-       
+
        /* build leftauth= */
        auth_cfg = build_auth_cfg(this, msg, TRUE, TRUE);
        if (auth_cfg)
@@ -684,7 +684,7 @@ static void add_ts(private_stroke_config_t *this,
                                   stroke_end_t *end, child_cfg_t *child_cfg, bool local)
 {
        traffic_selector_t *ts;
-       
+
        if (end->tohost)
        {
                ts = traffic_selector_create_dynamic(end->protocol,
@@ -694,7 +694,7 @@ static void add_ts(private_stroke_config_t *this,
        else
        {
                host_t *net;
-               
+
                if (!end->subnets)
                {
                        net = host_create_from_string(end->address, IKEV2_UDP_PORT);
@@ -708,12 +708,12 @@ static void add_ts(private_stroke_config_t *this,
                else
                {
                        char *del, *start, *bits;
-                       
+
                        start = end->subnets;
                        do
                        {
                                int intbits = 0;
-                               
+
                                del = strchr(start, ',');
                                if (del)
                                {
@@ -725,7 +725,7 @@ static void add_ts(private_stroke_config_t *this,
                                        *bits = '\0';
                                        intbits = atoi(bits + 1);
                                }
-                               
+
                                net = host_create_from_string(start, IKEV2_UDP_PORT);
                                if (net)
                                {
@@ -769,7 +769,7 @@ static child_cfg_t *build_child_cfg(private_stroke_config_t *this,
                        .jitter = msg->add_conn.rekey.margin_packets * msg->add_conn.rekey.fuzz / 100
                }
        };
-       
+
        switch (msg->add_conn.dpd.action)
        {       /* map startes magic values to our action type */
                case 2: /* =hold */
@@ -782,7 +782,7 @@ static child_cfg_t *build_child_cfg(private_stroke_config_t *this,
                        dpd = ACTION_NONE;
                        break;
        }
-       
+
        child_cfg = child_cfg_create(
                                msg->add_conn.name, &lifetime,
                                msg->add_conn.me.updown, msg->add_conn.me.hostaccess,
@@ -791,9 +791,9 @@ static child_cfg_t *build_child_cfg(private_stroke_config_t *this,
                                                                                        msg->add_conn.install_policy);
        add_ts(this, &msg->add_conn.me, child_cfg, TRUE);
        add_ts(this, &msg->add_conn.other, child_cfg, FALSE);
-       
+
        add_proposals(this, msg->add_conn.algorithms.esp, NULL, child_cfg);
-       
+
        return child_cfg;
 }
 
@@ -819,7 +819,7 @@ static void add(private_stroke_config_t *this, stroke_msg_t *msg)
                ike_cfg->destroy(ike_cfg);
                return;
        }
-       
+
        enumerator = create_peer_cfg_enumerator(this, NULL, NULL);
        while (enumerator->enumerate(enumerator, &existing))
        {
@@ -837,7 +837,7 @@ static void add(private_stroke_config_t *this, stroke_msg_t *msg)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        child_cfg = build_child_cfg(this, msg);
        if (!child_cfg)
        {
@@ -845,7 +845,7 @@ static void add(private_stroke_config_t *this, stroke_msg_t *msg)
                return;
        }
        peer_cfg->add_child_cfg(peer_cfg, child_cfg);
-       
+
        if (use_existing)
        {
                peer_cfg->destroy(peer_cfg);
@@ -869,13 +869,13 @@ static void del(private_stroke_config_t *this, stroke_msg_t *msg)
        peer_cfg_t *peer;
        child_cfg_t *child;
        bool deleted = FALSE;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->list->create_enumerator(this->list);
        while (enumerator->enumerate(enumerator, (void**)&peer))
        {
                bool keep = FALSE;
-               
+
                /* remove any child with such a name */
                children = peer->create_child_cfg_enumerator(peer);
                while (children->enumerate(children, &child))
@@ -892,7 +892,7 @@ static void del(private_stroke_config_t *this, stroke_msg_t *msg)
                        }
                }
                children->destroy(children);
-               
+
                /* if peer config matches, or has no children anymore, remove it */
                if (!keep || streq(peer->get_name(peer), msg->del_conn.name))
                {
@@ -903,7 +903,7 @@ static void del(private_stroke_config_t *this, stroke_msg_t *msg)
        }
        enumerator->destroy(enumerator);
        this->mutex->unlock(this->mutex);
-       
+
        if (deleted)
        {
                DBG1(DBG_CFG, "deleted connection '%s'", msg->del_conn.name);
@@ -930,19 +930,19 @@ static void destroy(private_stroke_config_t *this)
 stroke_config_t *stroke_config_create(stroke_ca_t *ca, stroke_cred_t *cred)
 {
        private_stroke_config_t *this = malloc_thing(private_stroke_config_t);
-       
+
        this->public.backend.create_peer_cfg_enumerator = (enumerator_t*(*)(backend_t*, identification_t *me, identification_t *other))create_peer_cfg_enumerator;
        this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
        this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
        this->public.add = (void(*)(stroke_config_t*, stroke_msg_t *msg))add;
        this->public.del = (void(*)(stroke_config_t*, stroke_msg_t *msg))del;
        this->public.destroy = (void(*)(stroke_config_t*))destroy;
-       
+
        this->list = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
        this->ca = ca;
        this->cred = cred;
-       
+
        return &this->public;
 }
 
index 270795e4ac1b9d499419535f27ea0714c4146ea6..3ed2f994ff653dd5ad409351767fd5536a7a62e7 100644 (file)
@@ -37,21 +37,21 @@ struct stroke_config_t {
         * Implements the backend_t interface
         */
        backend_t backend;
-       
+
        /**
         * Add a configuration to the backend.
         *
         * @param msg           received stroke message containing config
         */
        void (*add)(stroke_config_t *this, stroke_msg_t *msg);
-       
+
        /**
         * Remove a configuration from the backend.
         *
         * @param msg           received stroke message containing config name
         */
        void (*del)(stroke_config_t *this, stroke_msg_t *msg);
-       
+
        /**
      * Destroy a stroke_config instance.
      */
index c572117a2c62ff97779608df04b0f9679db40a23..a03aef69709cc653c94300f19ed7b00a18606774 100644 (file)
@@ -43,7 +43,7 @@ struct stroke_log_info_t {
         * level to log up to
         */
        level_t level;
-       
+
        /**
         * where to write log
         */
@@ -75,7 +75,7 @@ static child_cfg_t* get_child_from_peer(peer_cfg_t *peer_cfg, char *name)
 {
        child_cfg_t *current, *found = NULL;
        enumerator_t *enumerator;
-       
+
        enumerator = peer_cfg->create_child_cfg_enumerator(peer_cfg);
        while (enumerator->enumerate(enumerator, &current))
        {
@@ -98,7 +98,7 @@ static void initiate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *ou
        peer_cfg_t *peer_cfg;
        child_cfg_t *child_cfg;
        stroke_log_info_t info;
-       
+
        peer_cfg = charon->backends->get_peer_cfg_by_name(charon->backends,
                                                                                                          msg->initiate.name);
        if (peer_cfg == NULL)
@@ -113,7 +113,7 @@ static void initiate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *ou
                peer_cfg->destroy(peer_cfg);
                return;
        }
-       
+
        child_cfg = get_child_from_peer(peer_cfg, msg->initiate.name);
        if (child_cfg == NULL)
        {
@@ -121,7 +121,7 @@ static void initiate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *ou
                peer_cfg->destroy(peer_cfg);
                return;
        }
-       
+
        if (msg->output_verbosity < 0)
        {
                charon->controller->initiate(charon->controller, peer_cfg, child_cfg,
@@ -150,9 +150,9 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
        linked_list_t *ike_list, *child_list;
        stroke_log_info_t info;
        uintptr_t del;
-       
+
        string = msg->terminate.name;
-       
+
        len = strlen(string);
        if (len < 1)
        {
@@ -174,7 +174,7 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
                        child = FALSE;
                        break;
        }
-       
+
        if (name)
        {
                /* is a single name */
@@ -202,10 +202,10 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
                        }
                }
        }
-       
+
        info.out = out;
        info.level = msg->output_verbosity;
-       
+
        if (id)
        {
                if (child)
@@ -220,7 +220,7 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
                }
                return;
        }
-       
+
        ike_list = linked_list_create();
        child_list = linked_list_create();
        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
@@ -228,7 +228,7 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
        {
                child_sa_t *child_sa;
                iterator_t *children;
-               
+
                if (child)
                {
                        children = ike_sa->create_child_sa_iterator(ike_sa);
@@ -261,7 +261,7 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
                }
        }
        enumerator->destroy(enumerator);
-       
+
        enumerator = child_list->create_enumerator(child_list);
        while (enumerator->enumerate(enumerator, &del))
        {
@@ -269,7 +269,7 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
                                                                        (controller_cb_t)stroke_log, &info);
        }
        enumerator->destroy(enumerator);
-       
+
        enumerator = ike_list->create_enumerator(ike_list);
        while (enumerator->enumerate(enumerator, &del))
        {
@@ -277,7 +277,7 @@ static void terminate(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
                                                                        (controller_cb_t)stroke_log, &info);
        }
        enumerator->destroy(enumerator);
-       
+
        if (child_list->get_count(child_list) == 0 &&
                ike_list->get_count(ike_list) == 0)
        {
@@ -298,7 +298,7 @@ static void terminate_srcip(private_stroke_control_t *this,
        ike_sa_t *ike_sa;
        host_t *start = NULL, *end = NULL, *vip;
        chunk_t chunk_start, chunk_end = chunk_empty, chunk_vip;
-       
+
        if (msg->terminate_srcip.start)
        {
                start = host_create_from_string(msg->terminate_srcip.start, 0);
@@ -320,7 +320,7 @@ static void terminate_srcip(private_stroke_control_t *this,
                }
                chunk_end = end->get_address(end);
        }
-       
+
        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
@@ -369,10 +369,10 @@ static void purge_ike(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
        linked_list_t *list;
        uintptr_t del;
        stroke_log_info_t info;
-       
+
        info.out = out;
        info.level = msg->output_verbosity;
-       
+
        list = linked_list_create();
        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
        while (enumerator->enumerate(enumerator, &ike_sa))
@@ -386,7 +386,7 @@ static void purge_ike(private_stroke_control_t *this, stroke_msg_t *msg, FILE *o
                iterator->destroy(iterator);
        }
        enumerator->destroy(enumerator);
-       
+
        enumerator = list->create_enumerator(list);
        while (enumerator->enumerate(enumerator, &del))
        {
@@ -404,7 +404,7 @@ static void route(private_stroke_control_t *this, stroke_msg_t *msg, FILE *out)
 {
        peer_cfg_t *peer_cfg;
        child_cfg_t *child_cfg;
-       
+
        peer_cfg = charon->backends->get_peer_cfg_by_name(charon->backends,
                                                                                                          msg->route.name);
        if (peer_cfg == NULL)
@@ -417,7 +417,7 @@ static void route(private_stroke_control_t *this, stroke_msg_t *msg, FILE *out)
                peer_cfg->destroy(peer_cfg);
                return;
        }
-       
+
        child_cfg = get_child_from_peer(peer_cfg, msg->route.name);
        if (child_cfg == NULL)
        {
@@ -425,7 +425,7 @@ static void route(private_stroke_control_t *this, stroke_msg_t *msg, FILE *out)
                peer_cfg->destroy(peer_cfg);
                return;
        }
-       
+
        if (charon->traps->install(charon->traps, peer_cfg, child_cfg))
        {
                fprintf(out, "configuration '%s' routed\n", msg->route.name);
@@ -446,7 +446,7 @@ static void unroute(private_stroke_control_t *this, stroke_msg_t *msg, FILE *out
        child_sa_t *child_sa;
        enumerator_t *enumerator;
        u_int32_t id;
-       
+
        enumerator = charon->traps->create_enumerator(charon->traps);
        while (enumerator->enumerate(enumerator, NULL, &child_sa))
        {
@@ -477,7 +477,7 @@ static void destroy(private_stroke_control_t *this)
 stroke_control_t *stroke_control_create()
 {
        private_stroke_control_t *this = malloc_thing(private_stroke_control_t);
-       
+
        this->public.initiate = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))initiate;
        this->public.terminate = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))terminate;
        this->public.terminate_srcip = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))terminate_srcip;
@@ -485,7 +485,7 @@ stroke_control_t *stroke_control_create()
        this->public.route = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))route;
        this->public.unroute = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))unroute;
        this->public.destroy = (void(*)(stroke_control_t*))destroy;
-       
+
        return &this->public;
 }
 
index 5a61a90a4f09d1babcaa8ca0c1c7cbc9a7dcccfd..9b49bdc31bc3047b315ad1976522c61d5adb657a 100644 (file)
@@ -38,42 +38,42 @@ struct stroke_control_t {
         * @param msg           stroke message
         */
        void (*initiate)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Terminate a connection.
         *
         * @param msg           stroke message
         */
        void (*terminate)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Terminate a connection by peers virtual IP.
         *
         * @param msg           stroke message
         */
        void (*terminate_srcip)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Delete IKE_SAs without a CHILD_SA.
         *
         * @param msg           stroke message
         */
        void (*purge_ike)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Route a connection.
         *
         * @param msg           stroke message
         */
        void (*route)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Unroute a connection.
         *
         * @param msg           stroke message
         */
        void (*unroute)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Destroy a stroke_control instance.
         */
index 57a02c7a13f12ba096541358910de699daee7608..9133a1380a656ef7727766f9576737234f1cb220 100644 (file)
@@ -55,7 +55,7 @@ struct private_stroke_cred_t {
         * public functions
         */
        stroke_cred_t public;
-       
+
        /**
         * list of trusted peer/signer/CA certificates (certificate_t)
         */
@@ -70,12 +70,12 @@ struct private_stroke_cred_t {
         * list of private keys (private_key_t)
         */
        linked_list_t *private;
-       
+
        /**
         * read-write lock to lists
         */
        rwlock_t *lock;
-       
+
        /**
         * cache CRLs to disk?
         */
@@ -107,7 +107,7 @@ static bool private_filter(id_data_t *data,
 {
        private_key_t *key;
        chunk_t keyid;
-       
+
        key = *in;
        if (data->id == NULL)
        {
@@ -134,7 +134,7 @@ static enumerator_t* create_private_enumerator(private_stroke_cred_t *this,
        data = malloc_thing(id_data_t);
        data->this = this;
        data->id = id;
-       
+
        this->lock->read_lock(this->lock);
        return enumerator_create_filter(this->private->create_enumerator(this->private),
                                                                        (void*)private_filter, data,
@@ -149,7 +149,7 @@ static bool certs_filter(id_data_t *data, certificate_t **in, certificate_t **ou
        public_key_t *public;
        certificate_t *cert = *in;
        chunk_t keyid;
-       
+
        if (cert->get_type(cert) == CERT_X509_CRL ||
                cert->get_type(cert) == CERT_X509_AC)
        {
@@ -160,7 +160,7 @@ static bool certs_filter(id_data_t *data, certificate_t **in, certificate_t **ou
                *out = *in;
                return TRUE;
        }
-       
+
        public = cert->get_public_key(cert);
        if (public)
        {
@@ -182,7 +182,7 @@ static bool certs_filter(id_data_t *data, certificate_t **in, certificate_t **ou
 static bool crl_filter(id_data_t *data, certificate_t **in, certificate_t **out)
 {
        certificate_t *cert = *in;
-       
+
        if (cert->get_type(cert) != CERT_X509_CRL)
        {
                return FALSE;
@@ -202,7 +202,7 @@ static bool crl_filter(id_data_t *data, certificate_t **in, certificate_t **out)
 static bool ac_filter(id_data_t *data, certificate_t **in, certificate_t **out)
 {
        certificate_t *cert = *in;
-       
+
        if (cert->get_type(cert) != CERT_X509_AC)
        {
                return FALSE;
@@ -224,7 +224,7 @@ static enumerator_t* create_cert_enumerator(private_stroke_cred_t *this,
                                                        identification_t *id, bool trusted)
 {
        id_data_t *data;
-       
+
        if (cert == CERT_X509_CRL || cert == CERT_X509_AC)
        {
                if (trusted)
@@ -234,7 +234,7 @@ static enumerator_t* create_cert_enumerator(private_stroke_cred_t *this,
                data = malloc_thing(id_data_t);
                data->this = this;
                data->id = id;
-               
+
                this->lock->read_lock(this->lock);
                return enumerator_create_filter(this->certs->create_enumerator(this->certs),
                                        (cert == CERT_X509_CRL)? (void*)crl_filter : (void*)ac_filter,
@@ -247,7 +247,7 @@ static enumerator_t* create_cert_enumerator(private_stroke_cred_t *this,
        data = malloc_thing(id_data_t);
        data->this = this;
        data->id = id;
-       
+
        this->lock->read_lock(this->lock);
        return enumerator_create_filter(this->certs->create_enumerator(this->certs),
                                                                        (void*)certs_filter, data,
@@ -286,7 +286,7 @@ static bool shared_filter(shared_data_t *data,
        {
                return FALSE;
        }
-       
+
        my_match = stroke->has_owner(stroke, data->me);
        other_match = stroke->has_owner(stroke, data->other);
        if (!my_match && !other_match)
@@ -308,12 +308,12 @@ static bool shared_filter(shared_data_t *data,
 /**
  * Implements credential_set_t.create_shared_enumerator
  */
-static enumerator_t* create_shared_enumerator(private_stroke_cred_t *this, 
+static enumerator_t* create_shared_enumerator(private_stroke_cred_t *this,
                                                        shared_key_type_t type, identification_t *me,
                                                        identification_t *other)
 {
        shared_data_t *data = malloc_thing(shared_data_t);
-       
+
        data->this = this;
        data->me = me;
        data->other = other;
@@ -331,7 +331,7 @@ static certificate_t* add_cert(private_stroke_cred_t *this, certificate_t *cert)
 {
        certificate_t *current;
        enumerator_t *enumerator;
-       bool new = TRUE;        
+       bool new = TRUE;
 
        this->lock->read_lock(this->lock);
        enumerator = this->certs->create_enumerator(this->certs);
@@ -355,7 +355,7 @@ static certificate_t* add_cert(private_stroke_cred_t *this, certificate_t *cert)
        this->lock->unlock(this->lock);
        return cert;
 }
-       
+
 /**
  * Implementation of stroke_cred_t.load_ca.
  */
@@ -363,7 +363,7 @@ static certificate_t* load_ca(private_stroke_cred_t *this, char *filename)
 {
        certificate_t *cert;
        char path[PATH_MAX];
-       
+
        if (*filename == '/')
        {
                snprintf(path, sizeof(path), "%s", filename);
@@ -372,7 +372,7 @@ static certificate_t* load_ca(private_stroke_cred_t *this, char *filename)
        {
                snprintf(path, sizeof(path), "%s/%s", CA_CERTIFICATE_DIR, filename);
        }
-       
+
        cert = lib->creds->create(lib->creds,
                                                          CRED_CERTIFICATE, CERT_X509,
                                                          BUILD_FROM_FILE, path,
@@ -380,7 +380,7 @@ static certificate_t* load_ca(private_stroke_cred_t *this, char *filename)
        if (cert)
        {
                x509_t *x509 = (x509_t*)cert;
-               
+
                if (!(x509->get_flags(x509) & X509_CA))
                {
                        DBG1(DBG_CFG, "  ca certificate '%Y' misses ca basic constraint, "
@@ -400,7 +400,7 @@ static bool add_crl(private_stroke_cred_t *this, crl_t* crl)
 {
        certificate_t *current, *cert = &crl->certificate;
        enumerator_t *enumerator;
-       bool new = TRUE, found = FALSE; 
+       bool new = TRUE, found = FALSE;
 
        this->lock->write_lock(this->lock);
        enumerator = this->certs->create_enumerator(this->certs);
@@ -411,7 +411,7 @@ static bool add_crl(private_stroke_cred_t *this, crl_t* crl)
                        crl_t *crl_c = (crl_t*)current;
                        chunk_t authkey = crl->get_authKeyIdentifier(crl);
                        chunk_t authkey_c = crl_c->get_authKeyIdentifier(crl_c);
-                       
+
                        /* if compare authorityKeyIdentifiers if available */
                        if (authkey.ptr && authkey_c.ptr && chunk_equals(authkey, authkey_c))
                        {
@@ -421,7 +421,7 @@ static bool add_crl(private_stroke_cred_t *this, crl_t* crl)
                        {
                                identification_t *issuer = cert->get_issuer(cert);
                                identification_t *issuer_c = current->get_issuer(current);
-                               
+
                                /* otherwise compare issuer distinguished names */
                                if (issuer->equals(issuer, issuer_c))
                                {
@@ -444,7 +444,7 @@ static bool add_crl(private_stroke_cred_t *this, crl_t* crl)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        if (new)
        {
                this->certs->insert_last(this->certs, cert);
@@ -482,7 +482,7 @@ static certificate_t* load_peer(private_stroke_cred_t *this, char *filename)
        {
                snprintf(path, sizeof(path), "%s/%s", CERTIFICATE_DIR, filename);
        }
-       
+
        cert = lib->creds->create(lib->creds,
                                                          CRED_CERTIFICATE, CERT_X509,
                                                          BUILD_FROM_FILE, path,
@@ -508,7 +508,7 @@ static void load_certdir(private_stroke_cred_t *this, char *path,
 {
        struct stat st;
        char *file;
-       
+
        enumerator_t *enumerator = enumerator_create_directory(path);
 
        if (!enumerator)
@@ -538,7 +538,7 @@ static void load_certdir(private_stroke_cred_t *this, char *path,
                                        if (cert)
                                        {
                                                x509_t *x509 = (x509_t*)cert;
-                                               
+
                                                if (!(x509->get_flags(x509) & X509_CA))
                                                {
                                                        DBG1(DBG_CFG, "  ca certificate '%Y' misses "
@@ -629,18 +629,18 @@ static void cache_cert(private_stroke_cred_t *this, certificate_t *cert)
        {
                /* CRLs get written to /etc/ipsec.d/crls/<authkeyId>.crl */
                crl_t *crl = (crl_t*)cert;
-               
+
                cert->get_ref(cert);
                if (add_crl(this, crl))
                {
                        char buf[BUF_LEN];
                        chunk_t chunk, hex;
-                       
+
                        chunk = crl->get_authKeyIdentifier(crl);
                        hex = chunk_to_hex(chunk, NULL, FALSE);
                        snprintf(buf, sizeof(buf), "%s/%s.crl", CRL_DIR, hex);
                        free(hex.ptr);
-                       
+
                        chunk = cert->get_encoding(cert);
                        chunk_write(chunk, buf, "crl", 022, TRUE);
                        free(chunk.ptr);
@@ -695,7 +695,7 @@ static err_t extract_secret(chunk_t *secret, chunk_t *line)
        }
 
        if (quotes)
-       {       
+       {
                /* treat as an ASCII string */
                *secret = chunk_clone(raw_secret);
                return NULL;
@@ -736,7 +736,7 @@ typedef struct {
 chunk_t passphrase_cb(passphrase_cb_data_t *data, int try)
 {
        chunk_t secret = chunk_empty;;
-       
+
        if (try > 5)
        {
                fprintf(data->prompt, "invalid passphrase, too many trials\n");
@@ -809,7 +809,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        private->destroy(private);
                }
        }
-       
+
        while (fetchline(&src, &line))
        {
                chunk_t ids, token;
@@ -827,7 +827,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        glob_t buf;
                        char **expanded, *dir, pattern[PATH_MAX];
                        u_char *pos;
-                       
+
                        if (level > MAX_SECRETS_RECURSION)
                        {
                                DBG1(DBG_CFG, "maximum level of %d includes reached, ignored",
@@ -854,7 +854,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        {       /* use directory of current file if relative */
                                dir = strdup(file);
                                dir = dirname(dir);
-                               
+
                                if (line.len + 1 + strlen(dir) + 1 > sizeof(pattern))
                                {
                                        DBG1(DBG_CFG, "include pattern too long, ignored");
@@ -880,7 +880,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        globfree(&buf);
                        continue;
                }
-               
+
                if (line.len > 2 && strneq(": ", line.ptr, 2))
                {
                        /* no ids, skip the ':' */
@@ -932,7 +932,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        else
                        {
                                /* relative path name */
-                               snprintf(path, sizeof(path), "%s/%.*s", PRIVATE_KEY_DIR, 
+                               snprintf(path, sizeof(path), "%s/%.*s", PRIVATE_KEY_DIR,
                                                 filename.len, filename.ptr);
                        }
 
@@ -951,7 +951,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                                if (prompt)
                                {
                                        passphrase_cb_data_t data;
-                                       
+
                                        data.prompt = prompt;
                                        data.file = path;
                                        key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
@@ -984,9 +984,9 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        char smartcard[32], keyid[22], pin[32];
                        private_key_t *key;
                        u_int slot;
-                       
+
                        err_t ugh = extract_value(&sc, &line);
-                       
+
                        if (ugh != NULL)
                        {
                                DBG1(DBG_CFG, "line %d: %s", line_nr, ugh);
@@ -999,7 +999,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        }
                        snprintf(smartcard, sizeof(smartcard), "%.*s", sc.len, sc.ptr);
                        smartcard[sizeof(smartcard) - 1] = '\0';
-                       
+
                        /* parse slot and key id. only two formats are supported.
                         * first try %smartcard<slot>:<keyid> */
                        if (sscanf(smartcard, "%%smartcard%u:%s", &slot, keyid) == 2)
@@ -1017,7 +1017,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                                                " supported or invalid", line_nr);
                                goto error;
                        }
-                       
+
                        if (!eat_whitespace(&line))
                        {
                                DBG1(DBG_CFG, "line %d: expected PIN", line_nr);
@@ -1031,12 +1031,12 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        }
                        snprintf(pin, sizeof(pin), "%.*s", secret.len, secret.ptr);
                        pin[sizeof(pin) - 1] = '\0';
-                       
+
                        /* we assume an RSA key */
                        key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                                         BUILD_SMARTCARD_KEYID, smartcard,
                                                                         BUILD_SMARTCARD_PIN, pin, BUILD_END);
-                       
+
                        if (key)
                        {
                                DBG1(DBG_CFG, "  loaded private key from %.*s", sc.len, sc.ptr);
@@ -1063,7 +1063,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                        DBG1(DBG_CFG, "  loaded %N secret for %s", shared_key_type_names, type,
                                 ids.len > 0 ? (char*)ids.ptr : "%any");
                        DBG4(DBG_CFG, "  secret: %#B", &secret);
-                       
+
                        this->shared->insert_last(this->shared, shared_key);
                        while (ids.len > 0)
                        {
@@ -1080,7 +1080,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                                {
                                        continue;
                                }
-                               
+
                                /* NULL terminate the ID string */
                                *(id.ptr + id.len) = '\0';
                                peer_id = identification_create_from_string(id.ptr);
@@ -1089,7 +1089,7 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
                                        peer_id->destroy(peer_id);
                                        continue;
                                }
-                               
+
                                shared_key->add_owner(shared_key, peer_id);
                                any = FALSE;
                        }
@@ -1201,7 +1201,7 @@ static void destroy(private_stroke_cred_t *this)
 stroke_cred_t *stroke_cred_create()
 {
        private_stroke_cred_t *this = malloc_thing(private_stroke_cred_t);
-       
+
        this->public.set.create_private_enumerator = (void*)create_private_enumerator;
        this->public.set.create_cert_enumerator = (void*)create_cert_enumerator;
        this->public.set.create_shared_enumerator = (void*)create_shared_enumerator;
@@ -1212,7 +1212,7 @@ stroke_cred_t *stroke_cred_create()
        this->public.load_peer = (certificate_t*(*)(stroke_cred_t*, char *filename))load_peer;
        this->public.cachecrl = (void(*)(stroke_cred_t*, bool enabled))cachecrl;
        this->public.destroy = (void(*)(stroke_cred_t*))destroy;
-       
+
        this->certs = linked_list_create();
        this->shared = linked_list_create();
        this->private = linked_list_create();
@@ -1220,9 +1220,9 @@ stroke_cred_t *stroke_cred_create()
 
        load_certs(this);
        load_secrets(this, SECRETS_FILE, 0, NULL);
-       
+
        this->cachecrl = FALSE;
-       
+
        return &this->public;
 }
 
index 3924ccbc1d7aa5aeeaf37b375c91129849e957a4..ccee7d87c97844b3fec58d29b5f943e309276c30 100644 (file)
@@ -38,7 +38,7 @@ struct stroke_cred_t {
         * Implements credential_set_t
         */
        credential_set_t set;
-       
+
        /**
         * Reread secrets from config files.
         *
@@ -46,7 +46,7 @@ struct stroke_cred_t {
         * @param prompt        I/O channel to prompt for private key passhprase
         */
        void (*reread)(stroke_cred_t *this, stroke_msg_t *msg, FILE *prompt);
-       
+
        /**
         * Load a CA certificate, and serve it through the credential_set.
         *
@@ -54,7 +54,7 @@ struct stroke_cred_t {
         * @return                              reference to loaded certificate, or NULL
         */
        certificate_t* (*load_ca)(stroke_cred_t *this, char *filename);
-       
+
        /**
         * Load a peer certificate and serve it rhrough the credential_set.
         *
@@ -62,14 +62,14 @@ struct stroke_cred_t {
         * @return                              reference to loaded certificate, or NULL
         */
        certificate_t* (*load_peer)(stroke_cred_t *this, char *filename);
-       
+
        /**
         * Enable/Disable CRL caching to disk.
         *
         * @param enabled               TRUE to enable, FALSE to disable
         */
        void (*cachecrl)(stroke_cred_t *this, bool enabled);
-       
+
        /**
         * Destroy a stroke_cred instance.
         */
index d6754482f75299d4c39ea28aa9e48bfe617358b5..ced627f501aa2cd0204653382194e15dd4cfffae 100644 (file)
@@ -40,12 +40,12 @@ struct private_stroke_list_t {
         * public functions
         */
        stroke_list_t public;
-       
+
        /**
         * timestamp of daemon start
         */
        time_t uptime;
-       
+
        /**
         * strokes attribute provider
         */
@@ -59,44 +59,44 @@ static void log_ike_sa(FILE *out, ike_sa_t *ike_sa, bool all)
 {
        ike_sa_id_t *id = ike_sa->get_id(ike_sa);
        time_t now = time_monotonic(NULL);
-       
+
        fprintf(out, "%12s[%d]: %N",
                        ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
                        ike_sa_state_names, ike_sa->get_state(ike_sa));
-       
+
        if (ike_sa->get_state(ike_sa) == IKE_ESTABLISHED)
        {
                time_t established;
-               
+
                established = ike_sa->get_statistic(ike_sa, STAT_ESTABLISHED);
                fprintf(out, " %V ago", &now, &established);
        }
-       
+
        fprintf(out, ", %H[%Y]...%H[%Y]\n",
                        ike_sa->get_my_host(ike_sa), ike_sa->get_my_id(ike_sa),
                        ike_sa->get_other_host(ike_sa), ike_sa->get_other_id(ike_sa));
-       
+
        if (all)
        {
                proposal_t *ike_proposal;
-               
+
                ike_proposal = ike_sa->get_proposal(ike_sa);
-               
+
                fprintf(out, "%12s[%d]: IKE SPIs: %.16llx_i%s %.16llx_r%s",
                                ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
                                id->get_initiator_spi(id), id->is_initiator(id) ? "*" : "",
                                id->get_responder_spi(id), id->is_initiator(id) ? "" : "*");
-               
-               
+
+
                if (ike_sa->get_state(ike_sa) == IKE_ESTABLISHED)
                {
                        time_t rekey, reauth;
                        peer_cfg_t *peer_cfg;
-                       
+
                        rekey = ike_sa->get_statistic(ike_sa, STAT_REKEY);
                        reauth = ike_sa->get_statistic(ike_sa, STAT_REAUTH);
                        peer_cfg = ike_sa->get_peer_cfg(ike_sa);
-                       
+
                        if (rekey)
                        {
                                fprintf(out, ", rekeying in %V", &rekey, &now);
@@ -106,7 +106,7 @@ static void log_ike_sa(FILE *out, ike_sa_t *ike_sa, bool all)
                                bool first = TRUE;
                                enumerator_t *enumerator;
                                auth_cfg_t *auth;
-                               
+
                                fprintf(out, ", ");
                                enumerator = peer_cfg->create_auth_cfg_enumerator(peer_cfg, TRUE);
                                while (enumerator->enumerate(enumerator, &auth))
@@ -128,11 +128,11 @@ static void log_ike_sa(FILE *out, ike_sa_t *ike_sa, bool all)
                        }
                }
                fprintf(out, "\n");
-               
+
                if (ike_proposal)
                {
                        char buf[BUF_LEN];
-                       
+
                        snprintf(buf, BUF_LEN, "%P", ike_proposal);
                        fprintf(out, "%12s[%d]: IKE proposal: %s\n",
                                        ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
@@ -150,14 +150,14 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
        u_int64_t bytes_in, bytes_out;
        proposal_t *proposal;
        child_cfg_t *config = child_sa->get_config(child_sa);
-       
-       
-       fprintf(out, "%12s{%d}:  %N, %N%s", 
+
+
+       fprintf(out, "%12s{%d}:  %N, %N%s",
                        child_sa->get_name(child_sa), child_sa->get_reqid(child_sa),
                        child_sa_state_names, child_sa->get_state(child_sa),
                        ipsec_mode_names, child_sa->get_mode(child_sa),
                        config->use_proxy_mode(config) ? "_PROXY" : "");
-       
+
        if (child_sa->get_state(child_sa) == CHILD_INSTALLED)
        {
                fprintf(out, ", %N%s SPIs: %.8x_i %.8x_o",
@@ -165,30 +165,30 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
                                child_sa->has_encap(child_sa) ? " in UDP" : "",
                                ntohl(child_sa->get_spi(child_sa, TRUE)),
                                ntohl(child_sa->get_spi(child_sa, FALSE)));
-               
+
                if (child_sa->get_ipcomp(child_sa) != IPCOMP_NONE)
                {
                        fprintf(out, ", IPCOMP CPIs: %.4x_i %.4x_o",
                                        ntohs(child_sa->get_cpi(child_sa, TRUE)),
                                        ntohs(child_sa->get_cpi(child_sa, FALSE)));
                }
-               
+
                if (all)
                {
-                       fprintf(out, "\n%12s{%d}:  ", child_sa->get_name(child_sa), 
+                       fprintf(out, "\n%12s{%d}:  ", child_sa->get_name(child_sa),
                                        child_sa->get_reqid(child_sa));
-                       
+
                        proposal = child_sa->get_proposal(child_sa);
                        if (proposal)
                        {
                                u_int16_t encr_alg = ENCR_UNDEFINED, int_alg = AUTH_UNDEFINED;
                                u_int16_t encr_size = 0, int_size = 0;
-                               
+
                                proposal->get_algorithm(proposal, ENCRYPTION_ALGORITHM,
                                                                                &encr_alg, &encr_size);
                                proposal->get_algorithm(proposal, INTEGRITY_ALGORITHM,
                                                                                &int_alg, &int_size);
-                               
+
                                if (encr_alg != ENCR_UNDEFINED)
                                {
                                        fprintf(out, "%N", encryption_algorithm_names, encr_alg);
@@ -206,7 +206,7 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
                                        }
                                }
                        }
-                       
+
                        now = time_monotonic(NULL);
                        child_sa->get_usestats(child_sa, TRUE, &use_in, &bytes_in);
                        fprintf(out, ", %llu bytes_i", bytes_in);
@@ -222,7 +222,7 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
                                fprintf(out, " (%ds ago)", now - use_out);
                        }
                        fprintf(out, ", rekeying ");
-                       
+
                        rekey = child_sa->get_lifetime(child_sa, FALSE);
                        if (rekey)
                        {
@@ -239,10 +239,10 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
                        {
                                fprintf(out, "disabled");
                        }
-                       
+
                }
        }
-       
+
        fprintf(out, "\n%12s{%d}:   %#R=== %#R\n",
                        child_sa->get_name(child_sa), child_sa->get_reqid(child_sa),
                        child_sa->get_traffic_selectors(child_sa, TRUE),
@@ -262,9 +262,9 @@ static void log_auth_cfgs(FILE *out, peer_cfg_t *peer_cfg, bool local)
        certificate_t *cert;
        cert_validation_t valid;
        char *name;
-       
+
        name = peer_cfg->get_name(peer_cfg);
-       
+
        enumerator = peer_cfg->create_auth_cfg_enumerator(peer_cfg, local);
        while (enumerator->enumerate(enumerator, &auth))
        {
@@ -329,7 +329,7 @@ static void log_auth_cfgs(FILE *out, peer_cfg_t *peer_cfg, bool local)
                        fprintf(out, "%12s:    ocsp:  status must be GOOD%s\n", name,
                                        (valid == VALIDATION_SKIPPED) ? " or SKIPPED" : "");
                }
-               
+
                valid = (uintptr_t)auth->get(auth, AUTH_RULE_CRL_VALIDATION);
                if (valid != VALIDATION_FAILED)
                {
@@ -362,7 +362,7 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
        ike_sa_t *ike_sa;
        bool first, found = FALSE;
        char *name = msg->status.name;
-       
+
        if (all)
        {
                peer_cfg_t *peer_cfg;
@@ -371,10 +371,10 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                u_int32_t dpd;
                time_t since, now;
                u_int size, online, offline;
-               
+
                now = time_monotonic(NULL);
                since = time(NULL) - (now - this->uptime);
-               
+
                fprintf(out, "Status of IKEv2 charon daemon (strongSwan "VERSION"):\n");
                fprintf(out, "  uptime: %V, since %T\n", &now, &this->uptime, &since, FALSE);
                fprintf(out, "  worker threads: %d idle of %d,",
@@ -392,7 +392,7 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                }
                enumerator->destroy(enumerator);
                fprintf(out, "\n");
-               
+
                first = TRUE;
                enumerator = this->attribute->create_pool_enumerator(this->attribute);
                while (enumerator->enumerate(enumerator, &pool, &size, &online, &offline))
@@ -409,7 +409,7 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                        fprintf(out, "  %s: %u/%u/%u\n", pool, size, online, offline);
                }
                enumerator->destroy(enumerator);
-               
+
                enumerator = charon->kernel_interface->create_address_enumerator(
                                                                charon->kernel_interface, FALSE, FALSE);
                fprintf(out, "Listening IP addresses:\n");
@@ -418,7 +418,7 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                        fprintf(out, "  %H\n", host);
                }
                enumerator->destroy(enumerator);
-       
+
                fprintf(out, "Connections:\n");
                enumerator = charon->backends->create_peer_cfg_enumerator(
                                                                        charon->backends, NULL, NULL, NULL, NULL);
@@ -429,33 +429,33 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                        {
                                continue;
                        }
-                       
+
                        ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
                        fprintf(out, "%12s:  %s...%s", peer_cfg->get_name(peer_cfg),
                                ike_cfg->get_my_addr(ike_cfg), ike_cfg->get_other_addr(ike_cfg));
-                       
+
                        dpd = peer_cfg->get_dpd(peer_cfg);
                        if (dpd)
                        {
                                fprintf(out, ", dpddelay=%us", dpd);
                        }
                        fprintf(out, "\n");
-                       
+
                        log_auth_cfgs(out, peer_cfg, TRUE);
                        log_auth_cfgs(out, peer_cfg, FALSE);
-                       
+
                        children = peer_cfg->create_child_cfg_enumerator(peer_cfg);
                        while (children->enumerate(children, &child_cfg))
                        {
                                linked_list_t *my_ts, *other_ts;
-                               
+
                                my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
                                other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
                                fprintf(out, "%12s:   child:  %#R=== %#R", child_cfg->get_name(child_cfg),
                                                my_ts, other_ts);
                                my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
                                other_ts->destroy_offset(other_ts, offsetof(traffic_selector_t, destroy));
-                               
+
                                if (dpd)
                                {
                                        fprintf(out, ", dpdaction=%N", action_names,
@@ -468,7 +468,7 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                enumerator->destroy(enumerator);
        }
 
-       first = TRUE;   
+       first = TRUE;
        enumerator = charon->traps->create_enumerator(charon->traps);
        while (enumerator->enumerate(enumerator, NULL, &child_sa))
        {
@@ -480,14 +480,14 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                log_child_sa(out, child_sa, all);
        }
        enumerator->destroy(enumerator);
-       
+
        fprintf(out, "Security Associations:\n");
        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
                bool ike_printed = FALSE;
                iterator_t *children = ike_sa->create_child_sa_iterator(ike_sa);
-               
+
                if (name == NULL || streq(name, ike_sa->get_name(ike_sa)))
                {
                        log_ike_sa(out, ike_sa, all);
@@ -506,12 +506,12 @@ static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bo
                                        ike_printed = TRUE;
                                }
                                log_child_sa(out, child_sa, all);
-                       }       
+                       }
                }
                children->destroy(children);
        }
        enumerator->destroy(enumerator);
-       
+
        if (!found)
        {
                if (name)
@@ -536,14 +536,14 @@ static linked_list_t* create_unique_cert_list(certificate_type_t type)
                                                                        charon->credentials, type, KEY_ANY,
                                                                        NULL, FALSE);
        certificate_t *cert;
-       
+
        while (enumerator->enumerate(enumerator, (void**)&cert))
        {
                iterator_t *iterator = list->create_iterator(list, TRUE);
                identification_t *issuer = cert->get_issuer(cert);
                bool previous_same, same = FALSE, last = TRUE;
                certificate_t *list_cert;
-               
+
                while (iterator->iterate(iterator, (void**)&list_cert))
                {
                        /* exit if we have a duplicate? */
@@ -581,7 +581,7 @@ static void list_public_key(public_key_t *public, FILE *out)
        private_key_t *private = NULL;
        chunk_t keyid;
        identification_t *id;
-       
+
        if (public->get_fingerprint(public, KEY_ID_PUBKEY_SHA1, &keyid))
        {
                id = identification_create_from_encoding(ID_KEY_ID, keyid);
@@ -610,14 +610,14 @@ static void list_public_key(public_key_t *public, FILE *out)
 static void stroke_list_pubkeys(linked_list_t *list, bool utc, FILE *out)
 {
        bool first = TRUE;
-       
+
        enumerator_t *enumerator = list->create_enumerator(list);
        certificate_t *cert;
-       
+
        while (enumerator->enumerate(enumerator, (void**)&cert))
        {
                public_key_t *public = cert->get_public_key(cert);
-               
+
                if (public)
                {
                        if (first)
@@ -627,7 +627,7 @@ static void stroke_list_pubkeys(linked_list_t *list, bool utc, FILE *out)
                                first = FALSE;
                        }
                        fprintf(out, "\n");
-                       
+
                        list_public_key(public, out);
                        public->destroy(public);
                }
@@ -638,7 +638,7 @@ static void stroke_list_pubkeys(linked_list_t *list, bool utc, FILE *out)
 /**
  * list all X.509 certificates matching the flags
  */
-static void stroke_list_certs(linked_list_t *list, char *label, 
+static void stroke_list_certs(linked_list_t *list, char *label,
                                                          x509_flag_t flags, bool utc, FILE *out)
 {
        bool first = TRUE;
@@ -650,7 +650,7 @@ static void stroke_list_certs(linked_list_t *list, char *label,
        {
                x509_t *x509 = (x509_t*)cert;
                x509_flag_t x509_flags = x509->get_flags(x509);
-               
+
                /* list only if flag is set, or flags == 0 (ignoring self-signed) */
                if ((x509_flags & flags) || (flags == (x509_flags & ~X509_SELF_SIGNED)))
                {
@@ -660,7 +660,7 @@ static void stroke_list_certs(linked_list_t *list, char *label,
                        chunk_t serial, authkey;
                        time_t notBefore, notAfter;
                        public_key_t *public;
-                       
+
                        if (first)
                        {
                                fprintf(out, "\n");
@@ -668,7 +668,7 @@ static void stroke_list_certs(linked_list_t *list, char *label,
                                first = FALSE;
                        }
                        fprintf(out, "\n");
-                       
+
                        /* list subjectAltNames */
                        enumerator = x509->create_subjectAltName_enumerator(x509);
                        while (enumerator->enumerate(enumerator, (void**)&altName))
@@ -689,12 +689,12 @@ static void stroke_list_certs(linked_list_t *list, char *label,
                                fprintf(out, "\n");
                        }
                        enumerator->destroy(enumerator);
-                       
+
                        fprintf(out, "  subject:  \"%Y\"\n", cert->get_subject(cert));
                        fprintf(out, "  issuer:   \"%Y\"\n", cert->get_issuer(cert));
                        serial = x509->get_serial(x509);
                        fprintf(out, "  serial:    %#B\n", &serial);
-                       
+
                        /* list validity */
                        cert->get_validity(cert, &now, &notBefore, &notAfter);
                        fprintf(out, "  validity:  not before %T, ", &notBefore, utc);
@@ -720,14 +720,14 @@ static void stroke_list_certs(linked_list_t *list, char *label,
                                }
                                fprintf(out, " \n");
                        }
-                       
+
                        public = cert->get_public_key(cert);
                        if (public)
                        {
                                list_public_key(public, out);
                                public->destroy(public);
                        }
-                       
+
                        /* list optional authorityKeyIdentifier */
                        authkey = x509->get_authKeyIdentifier(x509);
                        if (authkey.ptr)
@@ -754,7 +754,7 @@ static void stroke_list_acerts(linked_list_t *list, bool utc, FILE *out)
                ac_t *ac = (ac_t*)cert;
                identification_t *id;
                chunk_t chunk;
-               
+
                if (first)
                {
                        fprintf(out, "\n");
@@ -762,7 +762,7 @@ static void stroke_list_acerts(linked_list_t *list, bool utc, FILE *out)
                        first = FALSE;
                }
                fprintf(out, "\n");
-               
+
                id = cert->get_subject(cert);
                if (id)
                {
@@ -799,7 +799,7 @@ static void stroke_list_acerts(linked_list_t *list, bool utc, FILE *out)
                        }
                        fprintf(out, " \n");
                }
-               
+
                /* list optional authorityKeyIdentifier */
                chunk = ac->get_authKeyIdentifier(ac);
                if (chunk.ptr)
@@ -819,12 +819,12 @@ static void stroke_list_crls(linked_list_t *list, bool utc, FILE *out)
        time_t thisUpdate, nextUpdate, now = time(NULL);
        enumerator_t *enumerator = list->create_enumerator(list);
        certificate_t *cert;
-       
+
        while (enumerator->enumerate(enumerator, (void**)&cert))
        {
                crl_t *crl = (crl_t*)cert;
                chunk_t chunk;
-               
+
                if (first)
                {
                        fprintf(out, "\n");
@@ -832,21 +832,21 @@ static void stroke_list_crls(linked_list_t *list, bool utc, FILE *out)
                        first = FALSE;
                }
                fprintf(out, "\n");
-               
+
                fprintf(out, "  issuer:   \"%Y\"\n", cert->get_issuer(cert));
-               
+
                /* list optional crlNumber */
                chunk = crl->get_serial(crl);
                if (chunk.ptr)
                {
                        fprintf(out, "  serial:    %#B\n", &chunk);
                }
-               
+
                /* count the number of revoked certificates */
                {
                        int count = 0;
                        enumerator_t *enumerator = crl->create_enumerator(crl);
-                       
+
                        while (enumerator->enumerate(enumerator, NULL, NULL, NULL))
                        {
                                count++;
@@ -855,7 +855,7 @@ static void stroke_list_crls(linked_list_t *list, bool utc, FILE *out)
                                                        (count == 1)? "" : "s");
                        enumerator->destroy(enumerator);
                }
-               
+
                /* list validity */
                cert->get_validity(cert, &now, &thisUpdate, &nextUpdate);
                fprintf(out, "  updates:   this %T\n",  &thisUpdate, utc);
@@ -873,7 +873,7 @@ static void stroke_list_crls(linked_list_t *list, bool utc, FILE *out)
                        }
                        fprintf(out, " \n");
                }
-               
+
                /* list optional authorityKeyIdentifier */
                chunk = crl->get_authKeyIdentifier(crl);
                if (chunk.ptr)
@@ -892,7 +892,7 @@ static void stroke_list_ocsp(linked_list_t* list, bool utc, FILE *out)
        bool first = TRUE;
        enumerator_t *enumerator = list->create_enumerator(list);
        certificate_t *cert;
-       
+
        while (enumerator->enumerate(enumerator, (void**)&cert))
        {
                if (first)
@@ -919,7 +919,7 @@ static void list_algs(FILE *out)
        hash_algorithm_t hash;
        pseudo_random_function_t prf;
        diffie_hellman_group_t group;
-       
+
        fprintf(out, "\n");
        fprintf(out, "List of registered IKEv2 Algorithms:\n");
        fprintf(out, "\n  encryption: ");
@@ -972,7 +972,7 @@ static void list(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out)
                linked_list_t *pubkey_list = create_unique_cert_list(CERT_TRUSTED_PUBKEY);
 
                stroke_list_pubkeys(pubkey_list, msg->list.utc, out);
-               pubkey_list->destroy_offset(pubkey_list, offsetof(certificate_t, destroy)); 
+               pubkey_list->destroy_offset(pubkey_list, offsetof(certificate_t, destroy));
        }
        if (msg->list.flags & (LIST_CERTS | LIST_CACERTS | LIST_OCSPCERTS | LIST_AACERTS))
        {
@@ -1003,22 +1003,22 @@ static void list(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out)
                linked_list_t *ac_list = create_unique_cert_list(CERT_X509_AC);
 
                stroke_list_acerts(ac_list, msg->list.utc, out);
-               ac_list->destroy_offset(ac_list, offsetof(certificate_t, destroy)); 
+               ac_list->destroy_offset(ac_list, offsetof(certificate_t, destroy));
        }
        if (msg->list.flags & LIST_CRLS)
        {
                linked_list_t *crl_list = create_unique_cert_list(CERT_X509_CRL);
 
                stroke_list_crls(crl_list, msg->list.utc, out);
-               crl_list->destroy_offset(crl_list, offsetof(certificate_t, destroy)); 
+               crl_list->destroy_offset(crl_list, offsetof(certificate_t, destroy));
        }
        if (msg->list.flags & LIST_OCSP)
        {
                linked_list_t *ocsp_list = create_unique_cert_list(CERT_X509_OCSP_RESPONSE);
 
                stroke_list_ocsp(ocsp_list, msg->list.utc, out);
-               
-               ocsp_list->destroy_offset(ocsp_list, offsetof(certificate_t, destroy)); 
+
+               ocsp_list->destroy_offset(ocsp_list, offsetof(certificate_t, destroy));
        }
        if (msg->list.flags & LIST_ALGS)
        {
@@ -1038,7 +1038,7 @@ static void pool_leases(private_stroke_list_t *this, FILE *out, char *pool,
        host_t *lease;
        bool on;
        int found = 0;
-       
+
        fprintf(out, "Leases in pool '%s', usage: %lu/%lu, %lu online\n",
                        pool, online + offline, size, online);
        enumerator = this->attribute->create_lease_enumerator(this->attribute, pool);
@@ -1068,12 +1068,12 @@ static void leases(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out)
        host_t *address = NULL;
        char *pool;
        int found = 0;
-       
+
        if (msg->leases.address)
        {
                address = host_create_from_string(msg->leases.address, 0);
        }
-       
+
        enumerator = this->attribute->create_pool_enumerator(this->attribute);
        while (enumerator->enumerate(enumerator, &pool, &size, &online, &offline))
        {
@@ -1112,15 +1112,15 @@ static void destroy(private_stroke_list_t *this)
 stroke_list_t *stroke_list_create(stroke_attribute_t *attribute)
 {
        private_stroke_list_t *this = malloc_thing(private_stroke_list_t);
-       
+
        this->public.list = (void(*)(stroke_list_t*, stroke_msg_t *msg, FILE *out))list;
        this->public.status = (void(*)(stroke_list_t*, stroke_msg_t *msg, FILE *out,bool))status;
        this->public.leases = (void(*)(stroke_list_t*, stroke_msg_t *msg, FILE *out))leases;
        this->public.destroy = (void(*)(stroke_list_t*))destroy;
-       
+
        this->uptime = time_monotonic(NULL);
        this->attribute = attribute;
-       
+
        return &this->public;
 }
 
index 2430abfbb3e78cf359831518939cad9f5a8d8e8f..b5bedc6c25a11c69bb0140aca66a6aaee349f7cb 100644 (file)
@@ -40,7 +40,7 @@ struct stroke_list_t {
         * @param out           stroke console stream
         */
        void (*list)(stroke_list_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Log status information to stroke console.
         *
@@ -49,7 +49,7 @@ struct stroke_list_t {
         * @param all           TRUE for "statusall"
         */
        void (*status)(stroke_list_t *this, stroke_msg_t *msg, FILE *out, bool all);
-       
+
        /**
         * Log pool leases to stroke console.
         *
@@ -57,7 +57,7 @@ struct stroke_list_t {
         * @param out           stroke console stream
         */
        void (*leases)(stroke_list_t *this, stroke_msg_t *msg, FILE *out);
-       
+
        /**
         * Destroy a stroke_list instance.
         */
index 22c1125a1ea128fbbfb00cf441e4c8013e7ae9b5..61ae1095389e7679376c0811c48a937e8e011c84 100644 (file)
@@ -29,7 +29,7 @@ struct private_stroke_plugin_t {
         * public functions
         */
        stroke_plugin_t public;
-       
+
        /**
         * stroke socket, receives strokes
         */
@@ -51,9 +51,9 @@ static void destroy(private_stroke_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_stroke_plugin_t *this = malloc_thing(private_stroke_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->socket = stroke_socket_create();
        if (this->socket == NULL)
        {
index 6e9d556ad35a5f350ff6e618a551fb809d65f8e0..3a1e81df6378bda3ac8a2239ea4fef70f19f0c0d 100644 (file)
@@ -20,7 +20,7 @@
  * @defgroup stroke_plugin stroke_plugin
  * @{ @ingroup stroke
  */
+
 #ifndef STROKE_PLUGIN_H_
 #define STROKE_PLUGIN_H_
 
index 8f53f509d5eab728fa4565d2e1ad673e984030ca..4f716e83a4495f5d2335980ad4a5dcf9b38c88f9 100644 (file)
@@ -28,7 +28,7 @@ struct private_stroke_shared_key_t {
         * implements shared_key_t
         */
        stroke_shared_key_t public;
-       
+
        /**
         * type of this key
         */
@@ -43,7 +43,7 @@ struct private_stroke_shared_key_t {
         * list of key owners, as identification_t
         */
        linked_list_t *owners;
-       
+
        /**
         * reference counter
         */
@@ -73,8 +73,8 @@ static private_stroke_shared_key_t* get_ref(private_stroke_shared_key_t *this)
 static chunk_t get_key(private_stroke_shared_key_t *this)
 {
        return this->key;
-}      
-       
+}
+
 /**
  * Implementation of stroke_shared_key_t.has_owner.
  */
@@ -83,7 +83,7 @@ static id_match_t has_owner(private_stroke_shared_key_t *this, identification_t
        enumerator_t *enumerator;
        id_match_t match, best = ID_MATCH_NONE;
        identification_t *current;
-       
+
        enumerator = this->owners->create_enumerator(this->owners);
        while (enumerator->enumerate(enumerator, &current))
        {
@@ -135,6 +135,6 @@ stroke_shared_key_t *stroke_shared_key_create(shared_key_type_t type, chunk_t ke
        this->type = type;
        this->key = key;
        this->ref = 1;
-       
+
        return &this->public;
 }
index 2240621007b636cd7176397284931d322258b5c3..05ad550833eaab6323ae8d11b30ed735b6cc8ba6 100644 (file)
@@ -35,21 +35,21 @@ struct stroke_shared_key_t {
         * Implements the shared_key_t interface.
         */
        shared_key_t shared;
-       
+
        /**
         * Add an owner to the key.
         *
         * @param owner         owner to add
         */
        void (*add_owner)(stroke_shared_key_t *this, identification_t *owner);
-       
+
        /**
         * Check if a key has a specific owner.
         *
         * @param owner         owner to check
         * @return                      best match found
         */
-       id_match_t (*has_owner)(stroke_shared_key_t *this, identification_t *owner);    
+       id_match_t (*has_owner)(stroke_shared_key_t *this, identification_t *owner);
 };
 
 /**
index f420266cd866af793f851ee815216e41eda6d169..7ae00d118bbf50c99519b5229273f130a4190f2e 100644 (file)
@@ -48,42 +48,42 @@ struct private_stroke_socket_t {
         * public functions
         */
        stroke_socket_t public;
-               
+
        /**
         * Unix socket to listen for strokes
         */
        int socket;
-       
+
        /**
         * job accepting stroke messages
         */
        callback_job_t *job;
-       
+
        /**
         * configuration backend
         */
        stroke_config_t *config;
-       
+
        /**
         * attribute provider
         */
        stroke_attribute_t *attribute;
-       
+
        /**
         * controller to control daemon
         */
        stroke_control_t *control;
-       
+
        /**
         * credential set
         */
        stroke_cred_t *cred;
-       
+
        /**
         * CA sections
         */
        stroke_ca_t *ca;
-       
+
        /**
         * Status information logging
         */
@@ -99,7 +99,7 @@ struct stroke_job_context_t {
         * file descriptor to read from
         */
        int fd;
-       
+
        /**
         * global stroke interface
         */
@@ -152,7 +152,7 @@ static void pop_end(stroke_msg_t *msg, const char* label, stroke_end_t *end)
        pop_string(msg, &end->ca2);
        pop_string(msg, &end->groups);
        pop_string(msg, &end->updown);
-       
+
        DBG2(DBG_CFG, "  %s=%s", label, end->address);
        DBG2(DBG_CFG, "  %ssubnet=%s", label, end->subnets);
        DBG2(DBG_CFG, "  %ssourceip=%s", label, end->sourceip);
@@ -202,7 +202,7 @@ static void stroke_del_conn(private_stroke_socket_t *this, stroke_msg_t *msg)
 {
        pop_string(msg, &msg->del_conn.name);
        DBG1(DBG_CFG, "received stroke: delete connection '%s'", msg->del_conn.name);
-       
+
        this->config->del(this->config, msg);
        this->attribute->del_pool(this->attribute, msg);
 }
@@ -214,7 +214,7 @@ static void stroke_initiate(private_stroke_socket_t *this, stroke_msg_t *msg, FI
 {
        pop_string(msg, &msg->initiate.name);
        DBG1(DBG_CFG, "received stroke: initiate '%s'", msg->initiate.name);
-       
+
        this->control->initiate(this->control, msg, out);
 }
 
@@ -227,7 +227,7 @@ static void stroke_terminate(private_stroke_socket_t *this, stroke_msg_t *msg, F
        DBG1(DBG_CFG, "received stroke: terminate '%s'", msg->terminate.name);
 
        this->control->terminate(this->control, msg, out);
-}      
+}
 
 /**
  * terminate a connection by peers virtual IP
@@ -250,7 +250,7 @@ static void stroke_route(private_stroke_socket_t *this, stroke_msg_t *msg, FILE
 {
        pop_string(msg, &msg->route.name);
        DBG1(DBG_CFG, "received stroke: route '%s'", msg->route.name);
-       
+
        this->control->route(this->control, msg, out);
 }
 
@@ -261,7 +261,7 @@ static void stroke_unroute(private_stroke_socket_t *this, stroke_msg_t *msg, FIL
 {
        pop_string(msg, &msg->terminate.name);
        DBG1(DBG_CFG, "received stroke: unroute '%s'", msg->route.name);
-       
+
        this->control->unroute(this->control, msg, out);
 }
 
@@ -287,7 +287,7 @@ static void stroke_add_ca(private_stroke_socket_t *this,
        DBG2(DBG_CFG, "  ocspuri=%s",     msg->add_ca.ocspuri);
        DBG2(DBG_CFG, "  ocspuri2=%s",    msg->add_ca.ocspuri2);
        DBG2(DBG_CFG, "  certuribase=%s", msg->add_ca.certuribase);
-       
+
        this->ca->add(this->ca, msg);
 }
 
@@ -299,7 +299,7 @@ static void stroke_del_ca(private_stroke_socket_t *this,
 {
        pop_string(msg, &msg->del_ca.name);
        DBG1(DBG_CFG, "received stroke: delete ca '%s'", msg->del_ca.name);
-       
+
        this->ca->del(this->ca, msg);
 }
 
@@ -311,7 +311,7 @@ static void stroke_status(private_stroke_socket_t *this,
                                                  stroke_msg_t *msg, FILE *out, bool all)
 {
        pop_string(msg, &(msg->status.name));
-       
+
        this->list->status(this->list, msg, out, all);
 }
 
@@ -361,7 +361,7 @@ static void stroke_leases(private_stroke_socket_t *this,
 {
        pop_string(msg, &msg->leases.pool);
        pop_string(msg, &msg->leases.address);
-       
+
        this->list->leases(this->list, msg, out);
 }
 
@@ -390,11 +390,11 @@ static void stroke_loglevel(private_stroke_socket_t *this,
        sys_logger_t *sys_logger;
        file_logger_t *file_logger;
        debug_t group;
-       
+
        pop_string(msg, &(msg->loglevel.type));
        DBG1(DBG_CFG, "received stroke: loglevel %d for %s",
                 msg->loglevel.level, msg->loglevel.type);
-       
+
        group = get_group_from_name(msg->loglevel.type);
        if (group < 0)
        {
@@ -448,7 +448,7 @@ static job_requeue_t process(stroke_job_context_t *ctx)
        FILE *out;
        private_stroke_socket_t *this = ctx->this;
        int strokefd = ctx->fd;
-       
+
        /* peek the length */
        bytes_read = recv(strokefd, &msg_length, sizeof(msg_length), MSG_PEEK);
        if (bytes_read != sizeof(msg_length))
@@ -457,7 +457,7 @@ static job_requeue_t process(stroke_job_context_t *ctx)
                         strerror(errno));
                return JOB_REQUEUE_NONE;
        }
-       
+
        /* read message */
        msg = alloca(msg_length);
        bytes_read = recv(strokefd, msg, msg_length, 0);
@@ -466,16 +466,16 @@ static job_requeue_t process(stroke_job_context_t *ctx)
                DBG1(DBG_CFG, "reading stroke message failed: %s", strerror(errno));
                return JOB_REQUEUE_NONE;
        }
-       
+
        out = fdopen(strokefd, "w+");
        if (out == NULL)
        {
                DBG1(DBG_CFG, "opening stroke output channel failed: %s", strerror(errno));
                return JOB_REQUEUE_NONE;
        }
-       
+
        DBG3(DBG_CFG, "stroke message %b", (void*)msg, msg_length);
-       
+
        switch (msg->type)
        {
                case STR_INITIATE:
@@ -550,24 +550,24 @@ static job_requeue_t receive(private_stroke_socket_t *this)
        int oldstate;
        callback_job_t *job;
        stroke_job_context_t *ctx;
-       
+
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        strokefd = accept(this->socket, (struct sockaddr *)&strokeaddr, &strokeaddrlen);
        pthread_setcancelstate(oldstate, NULL);
-       
+
        if (strokefd < 0)
        {
                DBG1(DBG_CFG, "accepting stroke connection failed: %s", strerror(errno));
                return JOB_REQUEUE_FAIR;
        }
-       
+
        ctx = malloc_thing(stroke_job_context_t);
        ctx->fd = strokefd;
        ctx->this = this;
        job = callback_job_create((callback_job_cb_t)process,
                                                          ctx, (void*)stroke_job_context_destroy, this->job);
        charon->processor->queue_job(charon->processor, (job_t*)job);
-       
+
        return JOB_REQUEUE_FAIR;
 }
 
@@ -582,7 +582,7 @@ static bool open_socket(private_stroke_socket_t *this)
 
        socket_addr.sun_family = AF_UNIX;
        strcpy(socket_addr.sun_path, STROKE_SOCKET);
-       
+
        /* set up unix socket */
        this->socket = socket(AF_UNIX, SOCK_STREAM, 0);
        if (this->socket == -1)
@@ -590,7 +590,7 @@ static bool open_socket(private_stroke_socket_t *this)
                DBG1(DBG_CFG, "could not create stroke socket");
                return FALSE;
        }
-       
+
        unlink(socket_addr.sun_path);
        old = umask(~(S_IRWXU | S_IRWXG));
        if (bind(this->socket, (struct sockaddr *)&socket_addr, sizeof(socket_addr)) < 0)
@@ -605,7 +605,7 @@ static bool open_socket(private_stroke_socket_t *this)
                DBG1(DBG_CFG, "changing stroke socket permissions failed: %s",
                         strerror(errno));
        }
-       
+
        if (listen(this->socket, 10) < 0)
        {
                DBG1(DBG_CFG, "could not listen on stroke socket: %s", strerror(errno));
@@ -641,31 +641,31 @@ static void destroy(private_stroke_socket_t *this)
 stroke_socket_t *stroke_socket_create()
 {
        private_stroke_socket_t *this = malloc_thing(private_stroke_socket_t);
-       
+
        this->public.destroy = (void(*)(stroke_socket_t*))destroy;
-       
+
        if (!open_socket(this))
        {
                free(this);
                return NULL;
        }
-       
+
        this->cred = stroke_cred_create();
        this->attribute = stroke_attribute_create();
        this->ca = stroke_ca_create(this->cred);
        this->config = stroke_config_create(this->ca, this->cred);
        this->control = stroke_control_create();
        this->list = stroke_list_create(this->attribute);
-       
+
        charon->credentials->add_set(charon->credentials, &this->ca->set);
        charon->credentials->add_set(charon->credentials, &this->cred->set);
        charon->backends->add_backend(charon->backends, &this->config->backend);
        charon->attributes->add_provider(charon->attributes, &this->attribute->provider);
-       
+
        this->job = callback_job_create((callback_job_cb_t)receive,
                                                                        this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public;
 }
 
index 6073f51331ccb724c27f7968e076f67eb63d1ef8..ae548167783acfbd71d28727fbf1163392f01602 100644 (file)
@@ -27,7 +27,7 @@ typedef struct stroke_socket_t stroke_socket_t;
  * Stroke socket, opens UNIX communication socket, reads and dispatches.
  */
 struct stroke_socket_t {
-               
+
        /**
      * Destroy a stroke_socket instance.
      */
index e81e49af79d09573a7e329e3fdedbde7d65ddcfa..d53d057503be408b2aa1de3050be6b4659d8edb7 100644 (file)
@@ -34,7 +34,7 @@ struct private_uci_config_t {
         * Public part
         */
        uci_config_t public;
-       
+
        /**
         * UCI parser context
         */
@@ -59,7 +59,7 @@ typedef struct {
 static proposal_t *create_proposal(char *string, protocol_id_t proto)
 {
        proposal_t *proposal = NULL;
-       
+
        if (string)
        {
                proposal = proposal_create_from_string(proto, string);
@@ -68,12 +68,12 @@ static proposal_t *create_proposal(char *string, protocol_id_t proto)
        {       /* UCI default is aes/sha1 only */
                if (proto == PROTO_IKE)
                {
-                       proposal = proposal_create_from_string(proto, 
+                       proposal = proposal_create_from_string(proto,
                                                                "aes128-aes192-aes256-sha1-modp1536-modp2048");
                }
                else
                {
-                       proposal = proposal_create_from_string(proto, 
+                       proposal = proposal_create_from_string(proto,
                                                                "aes128-aes192-aes256-sha1");
                }
        }
@@ -90,7 +90,7 @@ static traffic_selector_t *create_ts(char *string)
                int netbits = 32;
                host_t *net;
                char *pos;
-               
+
                string = strdupa(string);
                pos = strchr(string, '/');
                if (pos)
@@ -120,7 +120,7 @@ static traffic_selector_t *create_ts(char *string)
 static u_int create_rekey(char *string)
 {
        u_int rekey = 0;
-       
+
        if (string)
        {
                rekey = atoi(string);
@@ -151,7 +151,7 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
                        .jitter = 300
                }
        };
-       
+
        /* defaults */
        name = "unnamed";
        local_id = NULL;
@@ -164,7 +164,7 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
        esp_proposal = NULL;
        ike_rekey = NULL;
        esp_rekey = NULL;
-       
+
        if (this->inner->enumerate(this->inner, &name, &local_id, &remote_id,
                        &local_addr, &remote_addr, &local_net, &remote_net,
                        &ike_proposal, &esp_proposal, &ike_rekey, &esp_rekey))
@@ -184,7 +184,7 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
                auth->add(auth, AUTH_RULE_IDENTITY,
                                  identification_create_from_string(local_id));
                this->peer_cfg->add_auth_cfg(this->peer_cfg, auth, TRUE);
-               
+
                auth = auth_cfg_create();
                auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PSK);
                if (remote_id)
@@ -193,7 +193,7 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
                                          identification_create_from_string(remote_id));
                }
                this->peer_cfg->add_auth_cfg(this->peer_cfg, auth, FALSE);
-               
+
                child_cfg = child_cfg_create(name, &lifetime, NULL, TRUE, MODE_TUNNEL,
                                                                         ACTION_NONE, ACTION_NONE, FALSE);
                child_cfg->add_proposal(child_cfg, create_proposal(esp_proposal, PROTO_ESP));
@@ -220,15 +220,15 @@ static void peer_enumerator_destroy(peer_enumerator_t *this)
  * Implementation of backend_t.create_peer_cfg_enumerator.
  */
 static enumerator_t* create_peer_cfg_enumerator(private_uci_config_t *this,
-                                                                                               identification_t *me, 
+                                                                                               identification_t *me,
                                                                                                identification_t *other)
 {
        peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
-       
+
        e->public.enumerate = (void*)peer_enumerator_enumerate;
        e->public.destroy = (void*)peer_enumerator_destroy;
        e->peer_cfg = NULL;
-       e->inner = this->parser->create_section_enumerator(this->parser, 
+       e->inner = this->parser->create_section_enumerator(this->parser,
                                        "local_id", "remote_id", "local_addr", "remote_addr",
                                        "local_net", "remote_net", "ike_proposal", "esp_proposal",
                                        "ike_rekey", "esp_rekey", NULL);
@@ -258,12 +258,12 @@ typedef struct {
 static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
 {
        char *local_addr, *remote_addr, *ike_proposal;
-       
+
        /* defaults */
        local_addr = "0.0.0.0";
        remote_addr = "0.0.0.0";
        ike_proposal = NULL;
-       
+
        if (this->inner->enumerate(this->inner, NULL,
                                                           &local_addr, &remote_addr, &ike_proposal))
        {
@@ -295,11 +295,11 @@ static enumerator_t* create_ike_cfg_enumerator(private_uci_config_t *this,
                                                                                           host_t *me, host_t *other)
 {
        ike_enumerator_t *e = malloc_thing(ike_enumerator_t);
-       
+
        e->public.enumerate = (void*)ike_enumerator_enumerate;
        e->public.destroy = (void*)ike_enumerator_destroy;
        e->ike_cfg = NULL;
-       e->inner = this->parser->create_section_enumerator(this->parser, 
+       e->inner = this->parser->create_section_enumerator(this->parser,
                                                        "local_addr", "remote_addr", "ike_proposal", NULL);
        if (!e->inner)
        {
@@ -316,7 +316,7 @@ static peer_cfg_t *get_peer_cfg_by_name(private_uci_config_t *this, char *name)
 {
        enumerator_t *enumerator;
        peer_cfg_t *current, *found = NULL;
-               
+
        enumerator = create_peer_cfg_enumerator(this, NULL, NULL);
        if (enumerator)
        {
index eac05b1df4704859d745567a13413f9acd834d3e..130f15d85c828550c67d375c5c29793e49ba9994 100644 (file)
@@ -37,11 +37,11 @@ struct uci_config_t {
         * Implements backend_t interface
         */
        backend_t backend;
-       
+
        /**
         * Destroy the backend.
         */
-       void (*destroy)(uci_config_t *this);    
+       void (*destroy)(uci_config_t *this);
 };
 
 /**
index f74224fa70e8694fd4e8e72f6da6b85daffa9522..9bfc4eceecefe49ef190efcb843c345ecda8db16 100644 (file)
@@ -37,14 +37,14 @@ typedef struct private_uci_control_t private_uci_control_t;
  * private data of uci_control_t
  */
 struct private_uci_control_t {
-       
+
        /**
         * Public part
         */
        uci_control_t public;
-       
+
        /**
-        * Job 
+        * Job
         */
        callback_job_t *job;
 };
@@ -56,7 +56,7 @@ static void write_fifo(private_uci_control_t *this, char *format, ...)
 {
        va_list args;
        FILE *out;
-       
+
        out = fopen(FIFO_FILE, "w");
        if (out)
        {
@@ -83,7 +83,7 @@ static void status(private_uci_control_t *this, char *name)
        peer_cfg_t *peer_cfg;
        char buf[2048];
        FILE *out = NULL;
-       
+
        configs = charon->backends->create_peer_cfg_enumerator(charon->backends,
                                                                                                                NULL, NULL, NULL, NULL);
        while (configs->enumerate(configs, &peer_cfg))
@@ -109,7 +109,7 @@ static void status(private_uci_control_t *this, char *name)
                        }
                        fprintf(out, "%-8s %-20D %-16H ", ike_sa->get_name(ike_sa),
                                ike_sa->get_other_id(ike_sa), ike_sa->get_other_host(ike_sa));
-                       
+
                        children = ike_sa->create_child_sa_iterator(ike_sa);
                        while (children->iterate(children, (void**)&child_sa))
                        {
@@ -141,7 +141,7 @@ static void initiate(private_uci_control_t *this, char *name)
        peer_cfg_t *peer_cfg;
        child_cfg_t *child_cfg;
        enumerator_t *enumerator;
-       
+
        peer_cfg = charon->backends->get_peer_cfg_by_name(charon->backends, name);
        if (peer_cfg)
        {
@@ -173,7 +173,7 @@ static void terminate(private_uci_control_t *this, char *name)
        enumerator_t *enumerator;
        ike_sa_t *ike_sa;
        u_int id;
-       
+
        enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
@@ -197,7 +197,7 @@ static void terminate(private_uci_control_t *this, char *name)
 static void process(private_uci_control_t *this, char *message)
 {
        enumerator_t* enumerator;
-       
+
        enumerator = enumerator_create_token(message, " \n", "");
        if (enumerator->enumerate(enumerator, &message))
        {
@@ -217,7 +217,7 @@ static void process(private_uci_control_t *this, char *message)
                {
                        initiate(this, message);
                }
-               else if (streq(message, "down") && 
+               else if (streq(message, "down") &&
                                 enumerator->enumerate(enumerator, &message))
                {
                        terminate(this, message);
@@ -239,7 +239,7 @@ static job_requeue_t receive(private_uci_control_t *this)
        char message[128];
        int oldstate, len;
        FILE *in;
-       
+
        memset(message, 0, sizeof(message));
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        in = fopen(FIFO_FILE, "r");
@@ -280,9 +280,9 @@ static void destroy(private_uci_control_t *this)
 uci_control_t *uci_control_create()
 {
        private_uci_control_t *this = malloc_thing(private_uci_control_t);
-       
+
        this->public.destroy = (void(*)(uci_control_t*))destroy;
-       
+
        unlink(FIFO_FILE);
        if (mkfifo(FIFO_FILE, S_IRUSR|S_IWUSR) != 0)
        {
index 527ed82e707ec00bec431811243f4e5b14833eac..794220aa1de6a228d3bece3842902be31f48f97d 100644 (file)
@@ -27,7 +27,7 @@ typedef struct uci_control_t uci_control_t;
  * UCI control interface, uses a simple FIFO file
  */
 struct uci_control_t {
-       
+
        /**
         * Destroy the controller
         */
index 05bc6e109e711cf5b1cc03a852f565daffa014a9..4d664feb25fbbc805ac1881fbf07f8f0adcac624 100644 (file)
@@ -31,7 +31,7 @@ struct private_uci_creds_t {
         * Public part
         */
        uci_creds_t public;
-       
+
        /**
         * UCI parser context
         */
@@ -66,7 +66,7 @@ static bool shared_enumerator_enumerate(shared_enumerator_t *this,
                local_id = "%any";
                remote_id = "%any";
                psk = NULL;
-               
+
                if (!this->inner->enumerate(this->inner, NULL,
                                                                        &local_id, &remote_id, &psk))
                {
@@ -122,23 +122,23 @@ static void shared_enumerator_destroy(shared_enumerator_t *this)
  */
 static enumerator_t* create_shared_enumerator(private_uci_creds_t *this,
                                                                                          shared_key_type_t type,
-                                                                                         identification_t *me, 
+                                                                                         identification_t *me,
                                                                                          identification_t *other)
 {
        shared_enumerator_t *e;
-       
+
        if (type != SHARED_IKE)
        {
                return NULL;
        }
-       
+
        e = malloc_thing(shared_enumerator_t);
        e->current = NULL;
        e->public.enumerate = (void*)shared_enumerator_enumerate;
        e->public.destroy = (void*)shared_enumerator_destroy;
        e->me = me;
        e->other = other;
-       e->inner = this->parser->create_section_enumerator(this->parser, 
+       e->inner = this->parser->create_section_enumerator(this->parser,
                                                                "local_id", "remote_id", "psk", NULL);
        if (!e->inner)
        {
@@ -166,7 +166,7 @@ uci_creds_t *uci_creds_create(uci_parser_t *parser)
        this->public.credential_set.create_cdp_enumerator  = (enumerator_t*(*) (credential_set_t *,certificate_type_t, identification_t *))return_null;
        this->public.credential_set.cache_cert = (void (*)(credential_set_t *, certificate_t *))nop;
        this->public.destroy = (void(*) (uci_creds_t*))destroy;
-       
+
        this->parser = parser;
 
        return &this->public;
index de50984a9254ee3c4bd2eb5880a8d94d433f5fb6..a283ed9f57e48e213fcc7fb7073c3ba0b7064e33 100644 (file)
@@ -37,11 +37,11 @@ struct uci_creds_t {
         * Implements credential set interface.
         */
        credential_set_t credential_set;
-       
+
        /**
         * Destroy the backend.
         */
-       void (*destroy)(uci_creds_t *this);     
+       void (*destroy)(uci_creds_t *this);
 };
 
 /**
index f994e36f7be5b7759a44fa44e2a827eb1be2a1f7..76019a3b4a621a015e1f16340d8a1ee580175490 100644 (file)
@@ -32,7 +32,7 @@ struct private_uci_parser_t {
         * Public part
         */
        uci_parser_t public;
-       
+
        /**
         * UCI package name this parser reads
         */
@@ -66,12 +66,12 @@ static bool section_enumerator_enumerate(section_enumerator_t *this, ...)
        char **value;
        va_list args;
        int i;
-       
+
        if (&this->current->list == this->list)
        {
                return FALSE;
        }
-       
+
        va_start(args, this);
 
        value = va_arg(args, char**);
@@ -87,7 +87,7 @@ static bool section_enumerator_enumerate(section_enumerator_t *this, ...)
                        *value = uci_to_section(this->current)->type;
                }
        }
-       
+
        /* followed by keyword parameters */
        for (i = 0; this->keywords[i]; i++)
        {
@@ -99,7 +99,7 @@ static bool section_enumerator_enumerate(section_enumerator_t *this, ...)
                }
        }
        va_end(args);
-       
+
        this->current = list_to_element(this->current->list.next);
        return TRUE;
 }
@@ -121,7 +121,7 @@ static enumerator_t* create_section_enumerator(private_uci_parser_t *this, ...)
        section_enumerator_t *e;
        va_list args;
        int i;
-       
+
        /* allocate enumerator large enought to hold keyword pointers */
        i = 1;
        va_start(args, this);
@@ -133,16 +133,16 @@ static enumerator_t* create_section_enumerator(private_uci_parser_t *this, ...)
        e = malloc(sizeof(section_enumerator_t) + sizeof(char*) * i);
        i = 0;
        va_start(args, this);
-       do 
+       do
        {
                e->keywords[i] = va_arg(args, char*);
        }
        while (e->keywords[i++]);
        va_end(args);
-       
+
        e->public.enumerate = (void*)section_enumerator_enumerate;
        e->public.destroy = (void*)section_enumerator_destroy;
-       
+
        /* load uci context */
        e->ctx = uci_alloc_context();
        if (uci_load(e->ctx, this->package, &e->package) != UCI_OK)
@@ -178,9 +178,9 @@ uci_parser_t *uci_parser_create(char *package)
 
        this->public.create_section_enumerator = (enumerator_t*(*)(uci_parser_t*, ...))create_section_enumerator;
        this->public.destroy = (void(*)(uci_parser_t*))destroy;
-       
+
        this->package = strdup(package);
-       
+
        return &this->public;
 }
 
index ef3d7b0f5c2f01518b2119d24ed93e3a44f6f6eb..7217e507a6df453d55d0e76433ebde45749bd933 100644 (file)
@@ -41,11 +41,11 @@ struct uci_parser_t {
         * @return                      enumerator over sections
         */
        enumerator_t* (*create_section_enumerator)(uci_parser_t *this, ...);
-       
+
        /**
         * Destroy the parser.
         */
-       void (*destroy)(uci_parser_t *this);    
+       void (*destroy)(uci_parser_t *this);
 };
 
 /**
index 3ab4c92f8902c00802db286b8fe0894265efb8d3..2a79b91091e90c98273ff4c6dba061d22c8bde62 100644 (file)
@@ -36,17 +36,17 @@ struct private_uci_plugin_t {
         * implements plugin interface
         */
        uci_plugin_t public;
-       
+
        /**
         * UCI configuration backend
         */
        uci_config_t *config;
-       
+
        /**
         * UCI credential set implementation
         */
        uci_creds_t *creds;
-       
+
        /**
         * UCI parser wrapper
         */
@@ -78,16 +78,16 @@ static void destroy(private_uci_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_uci_plugin_t *this = malloc_thing(private_uci_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->parser = uci_parser_create(UCI_PACKAGE);
        this->config = uci_config_create(this->parser);
        this->creds = uci_creds_create(this->parser);
        this->control = uci_control_create();
        charon->backends->add_backend(charon->backends, &this->config->backend);
        charon->credentials->add_set(charon->credentials, &this->creds->credential_set);
-       
+
        return &this->public.plugin;
 }
 
index b99940c1a1b38dbde36ef4b5a53570436caca544..96313d39022e73ea89738062d7e6b3ebb042b7aa 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 /**
- * @defgroup tests tests 
+ * @defgroup tests tests
  * @{ @ingroup unit_tester
  */
 
index fd76b9cf551d62aa0c08d094e847fcaa741de2c4..21cb8b7778677c196dae2af087c32426bbd48d9c 100644 (file)
@@ -25,14 +25,14 @@ bool test_agent()
        chunk_t sig, data = chunk_from_buf(buf);
        private_key_t *private;
        public_key_t *public;
-       
+
        path = getenv("SSH_AUTH_SOCK");
        if (!path)
        {
                DBG1(DBG_CFG, "ssh-agent not found.");
                return FALSE;
        }
-       
+
        private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                                 BUILD_AGENT_SOCKET, path, BUILD_END);
        if (!private)
@@ -58,10 +58,10 @@ bool test_agent()
        {
                return FALSE;
        }
-       
+
        private->destroy(private);
        public->destroy(public);
-       
+
        return TRUE;
 }
 
index 37bdd10879a78cc57477ddccb8e797559c99f4c9..6de34b2a15eb9cb38a668716928f501ebadcccd3 100644 (file)
@@ -83,7 +83,7 @@ bool test_auth_cfg()
        int round = 0;
        void *value;
        auth_rule_t type;
-       
+
        c1 = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
                                                        BUILD_BLOB_ASN1_DER, certchunk,
                                                        BUILD_END);
@@ -91,7 +91,7 @@ bool test_auth_cfg()
        {
                return FALSE;
        }
-       
+
        auth->add(auth, AUTH_RULE_SUBJECT_CERT, c1->get_ref(c1));
        c2 = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
        if (!c2)
@@ -102,7 +102,7 @@ bool test_auth_cfg()
        {
                return FALSE;
        }
-       
+
        enumerator = auth->create_enumerator(auth);
        while (enumerator->enumerate(enumerator, &type, &value))
        {
@@ -114,11 +114,11 @@ bool test_auth_cfg()
                return FALSE;
        }
        enumerator->destroy(enumerator);
-       
+
        auth2 = auth_cfg_create();
        auth2->add(auth2, AUTH_RULE_CA_CERT, c1->get_ref(c1));
        auth2->merge(auth2, auth, FALSE);
-       
+
        round = 0;
        enumerator = auth2->create_enumerator(auth2);
        while (enumerator->enumerate(enumerator, &type, &value))
index 95ab289df7654c1e314714eb918a3f5be2900217..3b00421f8cdb7aeeb6efccf6c6018f77d8b1dc56 100644 (file)
@@ -28,10 +28,10 @@ bool test_cert_x509()
        identification_t *issuer, *subject;
        u_int32_t serial = htonl(0);
        chunk_t encoding;
-       
+
        issuer = identification_create_from_string("CN=CA, OU=Test, O=strongSwan");
        subject = identification_create_from_string("CN=Peer, OU=Test, O=strongSwan");
-       
+
        ca_key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                BUILD_KEY_SIZE, 1024, BUILD_END);
        peer_key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
@@ -50,7 +50,7 @@ bool test_cert_x509()
        {
                return FALSE;
        }
-       
+
        encoding = ca_cert->get_encoding(ca_cert);
        parsed = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
                                                BUILD_BLOB_ASN1_DER, encoding,
@@ -65,7 +65,7 @@ bool test_cert_x509()
                return FALSE;
        }
        parsed->destroy(parsed);
-       
+
        serial = htonl(ntohl(serial) + 1);
        public = peer_key->get_public_key(peer_key);
        peer_cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
@@ -80,7 +80,7 @@ bool test_cert_x509()
        {
                return FALSE;
        }
-       
+
        encoding = peer_cert->get_encoding(peer_cert);
        parsed = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
                                                BUILD_BLOB_ASN1_DER, encoding,
@@ -95,7 +95,7 @@ bool test_cert_x509()
                return FALSE;
        }
        parsed->destroy(parsed);
-       
+
        ca_cert->destroy(ca_cert);
        ca_key->destroy(ca_key);
        peer_cert->destroy(peer_cert);
index 5356c1d968fac732be78864a90b27eeb8a104921..2e0905b2c46a4ab5621019e2ec46e54fbd2b491a 100644 (file)
@@ -31,12 +31,12 @@ bool test_chunk_base64()
         * BASE64("fooba") = "Zm9vYmE="
         * BASE64("foobar") = "Zm9vYmFy"
         */
-       
+
        typedef struct {
                char *in;
                char *out;
        } testdata_t;
-       
+
        testdata_t test[] = {
                {"", ""},
                {"f", "Zg=="},
@@ -47,31 +47,31 @@ bool test_chunk_base64()
                {"foobar", "Zm9vYmFy"},
        };
        int i;
-       
+
        for (i = 0; i < countof(test); i++)
        {
                chunk_t out;
-               
+
                out = chunk_to_base64(chunk_create(test[i].in, strlen(test[i].in)), NULL);
-               
+
                if (!streq(out.ptr, test[i].out))
                {
-                       DBG1(DBG_CFG, "base64 conversion error - should %s, is %s", 
+                       DBG1(DBG_CFG, "base64 conversion error - should %s, is %s",
                                test[i].out, out.ptr);
                        return FALSE;
                }
                free(out.ptr);
        }
-       
+
        for (i = 0; i < countof(test); i++)
        {
                chunk_t out;
-               
+
                out = chunk_from_base64(chunk_create(test[i].out, strlen(test[i].out)), NULL);
-               
+
                if (!strneq(out.ptr, test[i].in, out.len))
                {
-                       DBG1(DBG_CFG, "base64 conversion error - should %s, is %#B", 
+                       DBG1(DBG_CFG, "base64 conversion error - should %s, is %#B",
                                test[i].in, &out);
                        return FALSE;
                }
index c011617a7995aedba7ab2e0dd10d7c378319b568..21656a94e3bb061789cc005af6a2dfb5d85777b4 100644 (file)
 bool test_curl_get()
 {
        chunk_t chunk;
-       
+
        if (lib->fetcher->fetch(lib->fetcher, "http://www.strongswan.org",
                                                        &chunk, FETCH_END) != SUCCESS)
        {
                return FALSE;
        }
        free(chunk.ptr);
-       
+
        if (lib->fetcher->fetch(lib->fetcher, "http://www.google.com",
                                                        &chunk, FETCH_END) != SUCCESS)
        {
index 6898084fcfbcc0fab8481394df0ac322bdae30a6..edbf0f5bb269ddd93b6e51dbba6e5138a3b3a893 100644 (file)
@@ -23,7 +23,7 @@ bool test_list_remove()
 {
        void *a = (void*)1, *b = (void*)2;
        linked_list_t *list;
-       
+
        list = linked_list_create();
        list->insert_last(list, a);
        if (list->remove(list, a, NULL) != 1)
@@ -67,15 +67,15 @@ bool test_enumerate()
        void *a = (void*)4, *b = (void*)3, *c = (void*)2, *d = (void*)5, *e = (void*)1;
        linked_list_t *list;
        enumerator_t *enumerator;
-       
+
        list = linked_list_create();
-       
+
        list->insert_last(list, a);
        list->insert_first(list, b);
        list->insert_first(list, c);
        list->insert_last(list, d);
        list->insert_first(list, e);
-       
+
        round = 1;
        enumerator = list->create_enumerator(list);
        while (enumerator->enumerate(enumerator, &x))
@@ -87,7 +87,7 @@ bool test_enumerate()
                round++;
        }
        enumerator->destroy(enumerator);
-       
+
        list->destroy(list);
        return TRUE;
 }
@@ -122,7 +122,7 @@ bool test_enumerate_nested()
        void *a = (void*)1, *b = (void*)2, *c = (void*)3, *d = (void*)4, *e = (void*)5;
        linked_list_t *list, *l1, *l2, *l3;
        enumerator_t *enumerator;
-       
+
        bad_data = FALSE;
        list = linked_list_create();
        l1 = linked_list_create();
@@ -131,13 +131,13 @@ bool test_enumerate_nested()
        list->insert_last(list, l1);
        list->insert_last(list, l2);
        list->insert_last(list, l3);
-       
+
        l1->insert_last(l1, a);
        l1->insert_last(l1, b);
        l3->insert_last(l3, c);
        l3->insert_last(l3, d);
        l3->insert_last(l3, e);
-       
+
        round = 1;
        enumerator = enumerator_create_nested(list->create_enumerator(list),
                                        (void*)create_inner, (void*)101, destroy_data);
@@ -150,7 +150,7 @@ bool test_enumerate_nested()
                round++;
        }
        enumerator->destroy(enumerator);
-       
+
        list->destroy(list);
        l1->destroy(l1);
        l2->destroy(l2);
@@ -185,16 +185,16 @@ bool test_enumerate_filtered()
        void *a = (void*)1, *b = (void*)2, *c = (void*)3, *d = (void*)4, *e = (void*)5;
        linked_list_t *list;
        enumerator_t *enumerator;
-       
+
        bad_data = FALSE;
        list = linked_list_create();
-       
+
        list->insert_last(list, a);
        list->insert_last(list, b);
        list->insert_last(list, c);
        list->insert_last(list, d);
        list->insert_last(list, e);
-       
+
        round = 1;
        enumerator = enumerator_create_filter(list->create_enumerator(list),
                                                                        (void*)filter, (void*)101, destroy_data);
@@ -208,7 +208,7 @@ bool test_enumerate_filtered()
                round++;
        }
        enumerator->destroy(enumerator);
-       
+
        list->destroy(list);
        return !bad_data;
 }
@@ -216,7 +216,7 @@ bool test_enumerate_filtered()
 /*******************************************************************************
  * token parser test
  ******************************************************************************/
+
 bool test_enumerate_token()
 {
        enumerator_t *enumerator;
@@ -240,7 +240,7 @@ bool test_enumerate_token()
                {"a.b,c", ",.", ""},
                {"  a   b  c  ", " ", " "},
        };
-       
+
        for (num = 0; num < countof(tests1); num++)
        {
                i = 0;
@@ -270,7 +270,7 @@ bool test_enumerate_token()
                }
                enumerator->destroy(enumerator);
        }
-       
+
        for (num = 0; num < countof(tests2); num++)
        {
                i = 0;
@@ -300,7 +300,7 @@ bool test_enumerate_token()
                }
                enumerator->destroy(enumerator);
        }
-       
+
        return TRUE;
 }
 
index a1ef76be8403b49626f10c8a4d9b4d3d67d30ec5..868a2ca8b8846a2a6b4c7893f497c25ddcc6026d 100644 (file)
@@ -25,9 +25,9 @@ bool test_id_parts()
        id_part_t part;
        chunk_t data;
        int i = 0;
-       
+
        id = identification_create_from_string("C=CH, O=strongSwan, CN=tester");
-       
+
        enumerator = id->create_part_enumerator(id);
        while (enumerator->enumerate(enumerator, &part, &data))
        {
@@ -75,7 +75,7 @@ static bool test_id_wildcards_has(char *string)
 {
        identification_t *id;
        bool contains;
-       
+
        id = identification_create_from_string(string);
        contains = id->contains_wildcards(id);
        id->destroy(id);
@@ -115,7 +115,7 @@ static bool test_id_equals_one(identification_t *a, char *b_str)
 {
        identification_t *b;
        bool equals;
-       
+
        b = identification_create_from_string(b_str);
        equals = a->equals(a, b);
        b->destroy(b);
@@ -127,10 +127,10 @@ bool test_id_equals()
        identification_t *a;
        chunk_t encoding, fuzzed;
        int i;
-       
+
        a = identification_create_from_string(
                                                           "C=CH, E=martin@strongswan.org, CN=martin");
-       
+
        if (!test_id_equals_one(a, "C=CH, E=martin@strongswan.org, CN=martin"))
        {
                return FALSE;
@@ -153,7 +153,7 @@ bool test_id_equals()
        }
        encoding = chunk_clone(a->get_encoding(a));
        a->destroy(a);
-       
+
        /* simple fuzzing, increment each byte of encoding */
        for (i = 0; i < encoding.len; i++)
        {
@@ -171,7 +171,7 @@ bool test_id_equals()
                a->destroy(a);
                free(fuzzed.ptr);
        }
-       
+
        /* and decrement each byte of encoding */
        for (i = 0; i < encoding.len; i++)
        {
@@ -201,7 +201,7 @@ static id_match_t test_id_matches_one(identification_t *a, char *b_str)
 {
        identification_t *b;
        id_match_t match;
-       
+
        b = identification_create_from_string(b_str);
        match = a->matches(a, b);
        b->destroy(b);
@@ -211,10 +211,10 @@ static id_match_t test_id_matches_one(identification_t *a, char *b_str)
 bool test_id_matches()
 {
        identification_t *a;
-       
+
        a = identification_create_from_string(
                                                           "C=CH, E=martin@strongswan.org, CN=martin");
-       
+
        if (test_id_matches_one(a, "C=CH, E=martin@strongswan.org, CN=martin")
                                                                                                                        != ID_MATCH_PERFECT)
        {
index da517958ebc2b89ab331d1f6cdd8296aed5e81fb..c5c15d1c2aeaf84b594fb3252477f83c61ba64f3 100644 (file)
@@ -36,7 +36,7 @@ bool test_med_db()
        public_key_t *public;
        auth_cfg_t *auth;
        bool good = FALSE;
-       
+
        id = identification_create_from_encoding(ID_KEY_ID, keyid);
        enumerator = charon->credentials->create_public_enumerator(
                                                                        charon->credentials, KEY_ANY, id, NULL);
index cb315276b0c4f3fdd8524529acf2506ceff44d55..cfe00cc7cda1745661f7a0669bb84fc4ef1c4d47 100644 (file)
@@ -46,7 +46,7 @@ static void* run(void* null)
                if (locked > 1)
                {
                        failed = TRUE;
-               }       
+               }
                locked--;
                mutex->unlock(mutex);
                mutex->unlock(mutex);
@@ -64,9 +64,9 @@ bool test_mutex()
 {
        int i;
        pthread_t threads[THREADS];
-       
+
        mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
-       
+
        for (i = 0; i < 10; i++)
        {
                mutex->lock(mutex);
@@ -80,9 +80,9 @@ bool test_mutex()
        {
                mutex->unlock(mutex);
        }
-       
+
        pthread_barrier_init(&barrier, NULL, THREADS);
-       
+
        for (i = 0; i < THREADS; i++)
        {
                pthread_create(&threads[i], NULL, run, NULL);
@@ -92,9 +92,9 @@ bool test_mutex()
                pthread_join(threads[i], NULL);
        }
        pthread_barrier_destroy(&barrier);
-       
+
        mutex->destroy(mutex);
-       
+
        return !failed;
 }
 
index ff3d38ad8c3509b7f69e085744c9bd9741b75ce3..cd63a5f7899ac5f4c629cccb3e8376b04c9438d7 100644 (file)
@@ -31,7 +31,7 @@ bool test_mysql()
        char *qtxt;
        bool good = FALSE;
        enumerator_t *enumerator;
-       
+
        db = lib->db->create(lib->db, "mysql://testuser:testpass@localhost/test");
        if (!db)
        {
index f32cd58206cbc4ff7f958e6f647527e8bd90a305..f9a776a820feea87dc976618f567b4d02c8dec71 100644 (file)
@@ -27,33 +27,33 @@ static void* testing(void *thread)
        int i;
        host_t *addr[ALLOCS];
        identification_t *id[ALLOCS];
-       
+
        /* prepare identities */
        for (i = 0; i < ALLOCS; i++)
        {
                char buf[256];
-               
+
                snprintf(buf, sizeof(buf), "%d-%d@strongswan.org", (uintptr_t)thread, i);
                id[i] = identification_create_from_string(buf);
        }
-       
+
        /* allocate addresses */
        for (i = 0; i < ALLOCS; i++)
        {
-               addr[i] = charon->attributes->acquire_address(charon->attributes, 
+               addr[i] = charon->attributes->acquire_address(charon->attributes,
                                                                                                          "test", id[i], NULL);
                if (!addr[i])
                {
                        return (void*)FALSE;
                }
        }
-       
+
        /* release addresses */
        for (i = 0; i < ALLOCS; i++)
        {
                charon->attributes->release_address(charon->attributes, "test", addr[i], id[i]);
        }
-       
+
        /* cleanup */
        for (i = 0; i < ALLOCS; i++)
        {
@@ -72,7 +72,7 @@ bool test_pool()
        uintptr_t i;
        void *res;
        pthread_t thread[THREADS];
-       
+
        for (i = 0; i < THREADS; i++)
        {
                if (pthread_create(&thread[i], NULL, (void*)testing, (void*)i) < 0)
index 1b7af63ee33b82a3603dbc3637c200988ca0b884..a449112ecba39f382751fa56f6a8c607e5a573a7 100644 (file)
@@ -26,7 +26,7 @@ bool test_rsa_gen()
        private_key_t *private;
        public_key_t *public;
        u_int key_size;
-       
+
        for (key_size = 512; key_size <= 2048; key_size *= 2)
        {
                private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
@@ -113,7 +113,7 @@ bool test_rsa_load_any()
 {
        chunk_t chunk = chunk_from_buf(public_any);
        public_key_t *public;
-       
+
        public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
                                                                BUILD_BLOB_ASN1_DER, chunk,
                                                                BUILD_END);
index d152fc594cf662b021b82bf89735c5a6a3438c08..4dcc5bad11a0bdfcb56c67ca59345d7f6a79929a 100644 (file)
@@ -36,7 +36,7 @@ bool test_sqlite()
        char *qtxt;
        bool good = FALSE;
        enumerator_t *enumerator;
-       
+
        db = lib->db->create(lib->db, "sqlite://" DBFILE);
        if (!db)
        {
index c9651e60143f7ced2fdcf72ea2917b73fdc6c143..3c39688c6940c67ab294b6c2ee33a70d5de82c3a 100644 (file)
@@ -33,17 +33,17 @@ struct private_unit_tester_t {
 };
 
 struct unit_test_t {
-       
+
        /**
         * name of the test
         */
        char *name;
-       
+
        /**
         * test function
         */
        bool (*test)(void);
-       
+
        /**
         * run the test?
         */
@@ -62,10 +62,10 @@ static unit_test_t tests[] = {
 static void run_tests(private_unit_tester_t *this)
 {
        int i, run = 0, failed = 0, success = 0, skipped = 0;
-       
+
        DBG1(DBG_CFG, "running unit tests, %d tests registered",
                 sizeof(tests)/sizeof(unit_test_t));
-       
+
        for (i = 0; i < sizeof(tests)/sizeof(unit_test_t); i++)
        {
                if (tests[i].enabled)
@@ -106,11 +106,11 @@ static void destroy(private_unit_tester_t *this)
 plugin_t *plugin_create()
 {
        private_unit_tester_t *this = malloc_thing(private_unit_tester_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        run_tests(this);
-       
+
        return &this->public.plugin;
 }
 
index 33b13313d661833aebb23e401d90d525317c34c1..79d5bc02113ecd54e6871855ed052f591f1c48dd 100644 (file)
@@ -28,7 +28,7 @@ typedef struct unit_tester_t unit_tester_t;
 /**
  * Unit testing plugin.
  *
- * The unit testing plugin runs tests on plugin initialization. Tests are 
+ * The unit testing plugin runs tests on plugin initialization. Tests are
  * defined in tests.h using the DEFINE_TEST macro. Implementation of the
  * tests is done in the tests folder. Each test has uses a function which
  * returns TRUE for success or FALSE for failure.
index a6be35690215568aa2c1e224a8469741bca297c0..10a94726a7a43edb8ee025f1ace51c8b9c541db7 100644 (file)
@@ -27,12 +27,12 @@ typedef struct private_updown_listener_t private_updown_listener_t;
  * Private data of an updown_listener_t object.
  */
 struct private_updown_listener_t {
-       
+
        /**
         * Public updown_listener_t interface.
         */
        updown_listener_t public;
-       
+
        /**
         * List of cached interface names
         */
@@ -58,10 +58,10 @@ static void cache_iface(private_updown_listener_t *this, u_int32_t reqid,
                                                char *iface)
 {
        cache_entry_t *entry = malloc_thing(cache_entry_t);
-       
+
        entry->reqid = reqid;
        entry->iface = strdup(iface);
-       
+
        this->iface_cache->insert_first(this->iface_cache, entry);
 }
 
@@ -73,7 +73,7 @@ static char* uncache_iface(private_updown_listener_t *this, u_int32_t reqid)
        enumerator_t *enumerator;
        cache_entry_t *entry;
        char *iface = NULL;
-       
+
        enumerator = this->iface_cache->create_enumerator(this->iface_cache);
        while (enumerator->enumerate(enumerator, &entry))
        {
@@ -100,18 +100,18 @@ static void updown(private_updown_listener_t *this, ike_sa_t *ike_sa,
        child_cfg_t *config;
        host_t *vip, *me, *other;
        char *script;
-       
+
        config = child_sa->get_config(child_sa);
        vip = ike_sa->get_virtual_ip(ike_sa, TRUE);
        script = config->get_updown(config);
        me = ike_sa->get_my_host(ike_sa);
        other = ike_sa->get_other_host(ike_sa);
-       
+
        if (script == NULL)
        {
                return;
        }
-       
+
        enumerator = child_sa->create_policy_enumerator(child_sa);
        while (enumerator->enumerate(enumerator, &my_ts, &other_ts))
        {
@@ -160,7 +160,7 @@ static void updown(private_updown_listener_t *this, ike_sa_t *ike_sa,
                                virtual_ip = NULL;
                        }
                }
-               
+
                if (up)
                {
                        iface = charon->kernel_interface->get_interface(
@@ -174,7 +174,7 @@ static void updown(private_updown_listener_t *this, ike_sa_t *ike_sa,
                {
                        iface = uncache_iface(this, child_sa->get_reqid(child_sa));
                }
-               
+
                /* build the command with all env variables.
                 * TODO: PLUTO_PEER_CA and PLUTO_NEXT_HOP are currently missing
                 */
@@ -225,7 +225,7 @@ static void updown(private_updown_listener_t *this, ike_sa_t *ike_sa,
                free(other_client);
                free(virtual_ip);
                free(iface);
-               
+
                DBG3(DBG_CHD, "running updown script: %s", command);
                shell = popen(command, "r");
 
@@ -234,11 +234,11 @@ static void updown(private_updown_listener_t *this, ike_sa_t *ike_sa,
                        DBG1(DBG_CHD, "could not execute updown script '%s'", script);
                        return;
                }
-               
+
                while (TRUE)
                {
                        char resp[128];
-                       
+
                        if (fgets(resp, sizeof(resp), shell) == NULL)
                        {
                                if (ferror(shell))
@@ -273,11 +273,11 @@ static bool child_state_change(private_updown_listener_t *this, ike_sa_t *ike_sa
                                                           child_sa_t *child_sa, child_sa_state_t state)
 {
        child_sa_state_t old;
-       
+
        if (ike_sa)
        {
                old = child_sa->get_state(child_sa);
-               
+
                if ((old == CHILD_INSTALLED && state != CHILD_REKEYING ) ||
                        (old == CHILD_DELETING && state == CHILD_DESTROYING))
                {
@@ -306,13 +306,13 @@ static void destroy(private_updown_listener_t *this)
 updown_listener_t *updown_listener_create()
 {
        private_updown_listener_t *this = malloc_thing(private_updown_listener_t);
-       
+
        memset(&this->public.listener, 0, sizeof(listener_t));
        this->public.listener.child_state_change = (void*)child_state_change;
        this->public.destroy = (void(*)(updown_listener_t*))destroy;
-       
+
        this->iface_cache = linked_list_create();
-       
+
        return &this->public;
 }
 
index cc59f61c68b648a73d8fe9d66beacb6dd504610e..7b978b0cc44a42fda033f7d22caed2c6072dc729 100644 (file)
@@ -29,12 +29,12 @@ typedef struct updown_listener_t updown_listener_t;
  * Listener which invokes the scripts on CHILD_SA up/down.
  */
 struct updown_listener_t {
-       
+
        /**
         * Implements listener_t.
         */
        listener_t listener;
-       
+
        /**
         * Destroy a updown_listener_t.
         */
index 4f0483fac521e659449ab0d348a3ee48f75e348b..6cb0efdcd73fd19eeeae6b64dfe595806cca4df8 100644 (file)
@@ -29,7 +29,7 @@ struct private_updown_plugin_t {
         * implements plugin interface
         */
        updown_plugin_t public;
-       
+
        /**
         * Listener interface, listens to CHILD_SA state changes
         */
@@ -52,12 +52,12 @@ static void destroy(private_updown_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_updown_plugin_t *this = malloc_thing(private_updown_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->listener = updown_listener_create();
        charon->bus->add_listener(charon->bus, &this->listener->listener);
-       
+
        return &this->public.plugin;
 }
 
index 90b221b847996f002f6572a8c8b685d77f05b488..45ace931208716a34207cf0e0bebb235a7bf0cd0 100644 (file)
@@ -28,17 +28,17 @@ struct private_acquire_job_t {
         * Public acquire_job_t interface.
         */
        acquire_job_t public;
-       
+
        /**
         * reqid of the child to rekey
         */
        u_int32_t reqid;
-       
+
        /**
         * acquired source traffic selector
         */
        traffic_selector_t *src_ts;
-       
+
        /**
         * acquired destination traffic selector
         */
@@ -73,14 +73,14 @@ acquire_job_t *acquire_job_create(u_int32_t reqid,
                                                                  traffic_selector_t *dst_ts)
 {
        private_acquire_job_t *this = malloc_thing(private_acquire_job_t);
-       
+
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
-       
+
        this->reqid = reqid;
        this->src_ts = src_ts;
        this->dst_ts = dst_ts;
-       
+
        return &this->public;
 }
 
index a78e5274d6e03529bb4f6d497bda4014fb367467..766e4db90fdd45d01d2d0deb29a26eb71f288340 100644 (file)
@@ -29,7 +29,7 @@ typedef struct acquire_job_t acquire_job_t;
 
 /**
  * Class representing an ACQUIRE Job.
- * 
+ *
  * This job initiates a CHILD SA on kernel request.
  */
 struct acquire_job_t {
index f4beb5abd80eeca9d0fec1cc412376cac5968a56..ee71fc5570423354d396ddf31d4f29202f1e428c 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "callback_job.h"
 
 #include <pthread.h>
@@ -30,7 +30,7 @@ struct private_callback_job_t {
         * Public callback_job_t interface.
         */
        callback_job_t public;
-       
+
        /**
         * Callback to call on execution
         */
@@ -40,27 +40,27 @@ struct private_callback_job_t {
         * parameter to supply to callback
         */
        void *data;
-       
+
        /**
         * cleanup function for data
         */
        callback_job_cleanup_t cleanup;
-       
+
        /**
         * thread ID of the job, if running
         */
        pthread_t thread;
-       
+
        /**
         * mutex to access jobs interna
         */
        mutex_t *mutex;
-       
+
        /**
         * list of asociated child jobs
         */
        linked_list_t *children;
-       
+
        /**
         * parent of this job, or NULL
         */
@@ -90,7 +90,7 @@ static void unregister(private_callback_job_t *this)
        {
                iterator_t *iterator;
                private_callback_job_t *child;
-               
+
                this->parent->mutex->lock(this->parent->mutex);
                iterator = this->parent->children->create_iterator(this->parent->children, TRUE);
                while (iterator->iterate(iterator, (void**)&child))
@@ -112,14 +112,14 @@ static void unregister(private_callback_job_t *this)
 static void cancel(private_callback_job_t *this)
 {
        pthread_t thread;
-       
+
        this->mutex->lock(this->mutex);
        thread = this->thread;
-       
+
        /* terminate its children */
        this->children->invoke_offset(this->children, offsetof(callback_job_t, cancel));
        this->mutex->unlock(this->mutex);
-       
+
        /* terminate thread */
        if (thread)
        {
@@ -138,7 +138,7 @@ static void execute(private_callback_job_t *this)
        this->mutex->lock(this->mutex);
        this->thread = pthread_self();
        this->mutex->unlock(this->mutex);
-       
+
        pthread_cleanup_push((void*)destroy, this);
        while (TRUE)
        {
@@ -175,7 +175,7 @@ callback_job_t *callback_job_create(callback_job_cb_t cb, void *data,
                                                                        callback_job_t *parent)
 {
        private_callback_job_t *this = malloc_thing(private_callback_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
@@ -189,7 +189,7 @@ callback_job_t *callback_job_create(callback_job_cb_t cb, void *data,
        this->thread = 0;
        this->children = linked_list_create();
        this->parent = (private_callback_job_t*)parent;
-       
+
        /* register us at parent */
        if (parent)
        {
@@ -197,7 +197,7 @@ callback_job_t *callback_job_create(callback_job_cb_t cb, void *data,
                this->parent->children->insert_last(this->parent->children, this);
                this->parent->mutex->unlock(this->parent->mutex);
        }
-       
+
        return &this->public;
 }
 
index 2bb209cb778d5c37c47b5f13a3d14f28e383936e..5435bc09cc7b31ba3dddf2e199b56e6e55e0f50e 100644 (file)
@@ -41,12 +41,12 @@ enum job_requeue_t {
         * Do not requeue job, destroy it
         */
        JOB_REQUEUE_NONE,
-       
+
        /**
         * Reque the job fairly, meaning it has to requeue as any other job
         */
        JOB_REQUEUE_FAIR,
-       
+
        /**
         * Reexecute the job directly, without the need of requeueing it
         */
@@ -88,7 +88,7 @@ struct callback_job_t {
         * The job_t interface.
         */
        job_t job_interface;
-       
+
        /**
         * Cancel the jobs thread and wait for its termination.
         */
@@ -103,7 +103,7 @@ struct callback_job_t {
  * If parent is not NULL, the specified job gets an association. Whenever
  * the parent gets cancelled (or runs out), all of its children are cancelled,
  * too.
- * 
+ *
  * @param cb                           callback to call from the processor
  * @param data                         user data to supply to callback
  * @param cleanup                      destructor for data on destruction, or NULL
index 206f076176d7cc27dca80970c6fb10f64d14ab78..ca55721f2476e0bb701f24b19ee66e23a408f891 100644 (file)
@@ -29,17 +29,17 @@ struct private_delete_child_sa_job_t {
         * Public delete_child_sa_job_t interface.
         */
        delete_child_sa_job_t public;
-       
+
        /**
         * reqid of the CHILD_SA
         */
        u_int32_t reqid;
-       
+
        /**
         * protocol of the CHILD_SA (ESP/AH)
         */
        protocol_id_t protocol;
-       
+
        /**
         * inbound SPI of the CHILD_SA
         */
@@ -60,7 +60,7 @@ static void destroy(private_delete_child_sa_job_t *this)
 static void execute(private_delete_child_sa_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
        ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
                                                                                                        this->reqid, TRUE);
        if (ike_sa == NULL)
@@ -71,7 +71,7 @@ static void execute(private_delete_child_sa_job_t *this)
        else
        {
                ike_sa->delete_child_sa(ike_sa, this->protocol, this->spi);
-               
+
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
        }
        destroy(this);
@@ -80,21 +80,21 @@ static void execute(private_delete_child_sa_job_t *this)
 /*
  * Described in header
  */
-delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid, 
-                                                                                                 protocol_id_t protocol, 
+delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
+                                                                                                 protocol_id_t protocol,
                                                                                                  u_int32_t spi)
 {
        private_delete_child_sa_job_t *this = malloc_thing(private_delete_child_sa_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
-       
+
        /* private variables */
        this->reqid = reqid;
        this->protocol = protocol;
        this->spi = spi;
-       
+
        return &this->public;
 }
 
index 9bf6ee42306182a173473afdc48b5a3e987e3c05..662a7b7c7648084e21a218b975c809a81424e11d 100644 (file)
@@ -31,7 +31,7 @@ typedef struct delete_child_sa_job_t delete_child_sa_job_t;
 
 /**
  * Class representing an DELETE_CHILD_SA Job.
- * 
+ *
  * This job initiates the delete of a CHILD SA.
  */
 struct delete_child_sa_job_t {
@@ -52,8 +52,8 @@ struct delete_child_sa_job_t {
  * @param spi          security parameter index of the CHILD_SA
  * @return                     delete_child_sa_job_t object
  */
-delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid, 
-                                                                                                 protocol_id_t protocol, 
+delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
+                                                                                                 protocol_id_t protocol,
                                                                                                  u_int32_t spi);
 
 #endif /** DELETE_CHILD_SA_JOB_H_ @}*/
index 6d4639fad795bf23cb6a79506678fa08fca6baff..dffd08ba3804db0f26d0fd35b2e0379bda68663c 100644 (file)
@@ -28,12 +28,12 @@ struct private_delete_ike_sa_job_t {
         * public delete_ike_sa_job_t interface
         */
        delete_ike_sa_job_t public;
-       
+
        /**
         * ID of the ike_sa to delete
         */
        ike_sa_id_t *ike_sa_id;
-       
+
        /**
         * Should the IKE_SA be deleted if it is in ESTABLISHED state?
         */
@@ -56,7 +56,7 @@ static void destroy(private_delete_ike_sa_job_t *this)
 static void execute(private_delete_ike_sa_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
        ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                                                                          this->ike_sa_id);
        if (ike_sa)
@@ -99,18 +99,18 @@ static void execute(private_delete_ike_sa_job_t *this)
 /*
  * Described in header
  */
-delete_ike_sa_job_t *delete_ike_sa_job_create(ike_sa_id_t *ike_sa_id, 
+delete_ike_sa_job_t *delete_ike_sa_job_create(ike_sa_id_t *ike_sa_id,
                                                                                          bool delete_if_established)
 {
        private_delete_ike_sa_job_t *this = malloc_thing(private_delete_ike_sa_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*)(job_t *)) destroy;;
-       
+
        /* private variables */
        this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
        this->delete_if_established = delete_if_established;
-       
+
        return &(this->public);
 }
index 8209977f9d90f8d92f3185c8d19038ebcae9d168..f641deea38774f29bc16c4ee9a77779c5e1f365b 100644 (file)
@@ -18,7 +18,7 @@
  * @defgroup delete_child_sa_job delete_child_sa_job
  * @{ @ingroup jobs
  */
+
 #ifndef DELETE_IKE_SA_JOB_H_
 #define DELETE_IKE_SA_JOB_H_
 
@@ -32,12 +32,12 @@ typedef struct delete_ike_sa_job_t delete_ike_sa_job_t;
 /**
  * Class representing an DELETE_IKE_SA Job.
  *
- * This job is responsible for deleting established or half open IKE_SAs. 
+ * This job is responsible for deleting established or half open IKE_SAs.
  * A half open IKE_SA is every IKE_SA which hasn't reache the SA_ESTABLISHED
  * state.
  */
 struct delete_ike_sa_job_t {
-       
+
        /**
         * The job_t interface.
         */
@@ -46,7 +46,7 @@ struct delete_ike_sa_job_t {
 
 /**
  * Creates a job of type DELETE_IKE_SA.
- * 
+ *
  * @param ike_sa_id                            id of the IKE_SA to delete
  * @param delete_if_established        should the IKE_SA be deleted if it is established?
  * @return                                             created delete_ike_sa_job_t object
index 157d843419e090f46af165237a8d20ed30e3c393..d3828e190e2145aafa3e867c67409d0a23cfd85b 100644 (file)
@@ -29,12 +29,12 @@ struct private_initiate_mediation_job_t {
         * public initiate_mediation_job_t interface
         */
        initiate_mediation_job_t public;
-       
+
        /**
         * ID of the IKE_SA of the mediated connection.
         */
        ike_sa_id_t *mediated_sa_id;
-       
+
        /**
         * ID of the IKE_SA of the mediation connection.
         */
@@ -68,26 +68,26 @@ static bool initiate_callback(private_initiate_mediation_job_t *this,
 
 /**
  * Implementation of job_t.execute.
- */ 
+ */
 static void initiate(private_initiate_mediation_job_t *this)
 {
        ike_sa_t *mediated_sa, *mediation_sa;
        peer_cfg_t *mediated_cfg, *mediation_cfg;
        enumerator_t *enumerator;
        auth_cfg_t *auth_cfg;
-       
+
        mediated_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                                                                                   this->mediated_sa_id);
        if (mediated_sa)
        {
                mediated_cfg = mediated_sa->get_peer_cfg(mediated_sa);
-               mediated_cfg->get_ref(mediated_cfg); 
-               
+               mediated_cfg->get_ref(mediated_cfg);
+
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediated_sa);
-               
+
                mediation_cfg = mediated_cfg->get_mediated_by(mediated_cfg);
                mediation_cfg->get_ref(mediation_cfg);
-               
+
                enumerator = mediation_cfg->create_auth_cfg_enumerator(mediation_cfg,
                                                                                                                           TRUE);
                if (!enumerator->enumerate(enumerator, &auth_cfg) ||
@@ -99,7 +99,7 @@ static void initiate(private_initiate_mediation_job_t *this)
                        destroy(this);
                        return;
                }
-               
+
                if (charon->connect_manager->check_and_register(charon->connect_manager,
                                auth_cfg->get(auth_cfg, AUTH_RULE_IDENTITY),
                                mediated_cfg->get_peer_id(mediated_cfg),
@@ -107,7 +107,7 @@ static void initiate(private_initiate_mediation_job_t *this)
                {
                        mediated_cfg->destroy(mediated_cfg);
                        mediation_cfg->destroy(mediation_cfg);
-                       
+
                        mediated_sa = charon->ike_sa_manager->checkout(
                                                                charon->ike_sa_manager, this->mediated_sa_id);
                        if (mediated_sa)
@@ -121,7 +121,7 @@ static void initiate(private_initiate_mediation_job_t *this)
                        return;
                }
                /* we need an additional reference because initiate consumes one */
-               mediation_cfg->get_ref(mediation_cfg); 
+               mediation_cfg->get_ref(mediation_cfg);
 
                if (charon->controller->initiate(charon->controller, mediation_cfg,
                                        NULL, (controller_cb_t)initiate_callback, this) != SUCCESS)
@@ -143,7 +143,7 @@ static void initiate(private_initiate_mediation_job_t *this)
 
                mediation_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                this->mediation_sa_id);
-               
+
                if (mediation_sa)
                {
                        if (mediation_sa->initiate_mediation(mediation_sa,
@@ -163,10 +163,10 @@ static void initiate(private_initiate_mediation_job_t *this)
                                destroy(this);
                                return;
                        }
-                       
+
                        charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediation_sa);
                }
-               
+
                mediated_cfg->destroy(mediated_cfg);
        }
        destroy(this);
@@ -174,12 +174,12 @@ static void initiate(private_initiate_mediation_job_t *this)
 
 /**
  * Implementation of job_t.execute.
- */ 
+ */
 static void reinitiate(private_initiate_mediation_job_t *this)
 {
        ike_sa_t *mediated_sa, *mediation_sa;
        peer_cfg_t *mediated_cfg;
-       
+
        mediated_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                                                                          this->mediated_sa_id);
        if (mediated_sa)
@@ -187,7 +187,7 @@ static void reinitiate(private_initiate_mediation_job_t *this)
                mediated_cfg = mediated_sa->get_peer_cfg(mediated_sa);
                mediated_cfg->get_ref(mediated_cfg);
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediated_sa);
-               
+
                mediation_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                this->mediation_sa_id);
                if (mediation_sa)
@@ -211,7 +211,7 @@ static void reinitiate(private_initiate_mediation_job_t *this)
                        }
                        charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediation_sa);
                }
-               
+
                mediated_cfg->destroy(mediated_cfg);
        }
        destroy(this);
@@ -223,10 +223,10 @@ static void reinitiate(private_initiate_mediation_job_t *this)
 static private_initiate_mediation_job_t *initiate_mediation_job_create_empty()
 {
        private_initiate_mediation_job_t *this = malloc_thing(private_initiate_mediation_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-       
+
        /* private variables */
        this->mediation_sa_id = NULL;
        this->mediated_sa_id = NULL;
@@ -240,9 +240,9 @@ static private_initiate_mediation_job_t *initiate_mediation_job_create_empty()
 initiate_mediation_job_t *initiate_mediation_job_create(ike_sa_id_t *ike_sa_id)
 {
        private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
-       
+
        this->public.job_interface.execute = (void (*) (job_t *)) initiate;
-       
+
        this->mediated_sa_id = ike_sa_id->clone(ike_sa_id);
 
        return &this->public;
@@ -255,11 +255,11 @@ initiate_mediation_job_t *reinitiate_mediation_job_create(ike_sa_id_t *mediation
                ike_sa_id_t *mediated_sa_id)
 {
        private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
-       
+
        this->public.job_interface.execute = (void (*) (job_t *)) reinitiate;
-       
+
        this->mediation_sa_id = mediation_sa_id->clone(mediation_sa_id);
        this->mediated_sa_id = mediated_sa_id->clone(mediated_sa_id);
-       
-       return &this->public; 
+
+       return &this->public;
 }
index 084e1b9fd97c6c85917e62b0fab0338c1d4678ff..f23317941cef3b94319cb314a2451f4e38d35612 100644 (file)
@@ -28,7 +28,7 @@ typedef struct initiate_mediation_job_t initiate_mediation_job_t;
 
 /**
  * Class representing a INITIATE_MEDIATION Job.
- * 
+ *
  * This job will initiate a mediation on behalf of a mediated connection.
  * If required the mediation connection is established.
  */
@@ -41,7 +41,7 @@ struct initiate_mediation_job_t {
 
 /**
  * Creates a job of type INITIATE_MEDIATION.
- * 
+ *
  * @param ike_sa_id            identification of the ike_sa as ike_sa_id_t object (gets cloned)
  * @return                             job object
  */
@@ -50,7 +50,7 @@ initiate_mediation_job_t *initiate_mediation_job_create(ike_sa_id_t *ike_sa_id);
 /**
  * Creates a special job of type INITIATE_MEDIATION that reinitiates a
  * specific connection.
- * 
+ *
  * @param mediation_sa_id              identification of the mediation sa (gets cloned)
  * @param mediated_sa_id               identification of the mediated sa (gets cloned)
  * @return                                             job object
index acc88b124bbfe810bef9ead956aa5dfcdce005cd..0f1c16ebe9a526f4bd835258024a4ed82184276b 100644 (file)
@@ -33,7 +33,7 @@ struct job_t {
 
        /**
         * Execute a job.
-        * 
+        *
         * The processing facility executes a job using this method. Jobs are
         * one-shot, they destroy themself after execution, so don't use a job
         * once it has been executed.
index cf522faffa5b247660973a4369a83408b1e66443..b5b8af3b3fefbf647885dc926d8a4568181f527d 100644 (file)
@@ -29,37 +29,37 @@ struct private_mediation_job_t {
         * public mediation_job_t interface
         */
        mediation_job_t public;
-       
+
        /**
         * ID of target peer.
         */
        identification_t *target;
-       
+
        /**
         * ID of the source peer.
         */
        identification_t *source;
-       
+
        /**
         * ME_CONNECTID
         */
        chunk_t connect_id;
-       
+
        /**
         * ME_CONNECTKEY
         */
        chunk_t connect_key;
-       
+
        /**
         * Submitted endpoints
         */
        linked_list_t *endpoints;
-       
+
        /**
         * Is this a callback job?
         */
        bool callback;
-       
+
        /**
         * Is this a response?
         */
@@ -81,13 +81,13 @@ static void destroy(private_mediation_job_t *this)
 
 /**
  * Implementation of job_t.execute.
- */ 
+ */
 static void execute(private_mediation_job_t *this)
 {
        ike_sa_id_t *target_sa_id;
-       
+
        target_sa_id = charon->mediation_manager->check(charon->mediation_manager, this->target);
-       
+
        if (target_sa_id)
        {
                ike_sa_t *target_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
@@ -120,7 +120,7 @@ static void execute(private_mediation_job_t *this)
                                        return;
                                }
                        }
-                       
+
                        charon->ike_sa_manager->checkin(charon->ike_sa_manager, target_sa);
                }
                else
@@ -143,11 +143,11 @@ static void execute(private_mediation_job_t *this)
 static private_mediation_job_t *mediation_job_create_empty()
 {
        private_mediation_job_t *this = malloc_thing(private_mediation_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-       
+
        /* private variables */
        this->target = NULL;
        this->source = NULL;
@@ -156,7 +156,7 @@ static private_mediation_job_t *mediation_job_create_empty()
        this->connect_key = chunk_empty;
        this->endpoints = NULL;
        this->response = FALSE;
-       
+
        return this;
 }
 
@@ -175,7 +175,7 @@ mediation_job_t *mediation_job_create(identification_t *peer_id,
        this->connect_key = chunk_clone(connect_key);
        this->endpoints = endpoints->clone_offset(endpoints, offsetof(endpoint_notify_t, clone));
        this->response = response;
-       
+
        return &this->public;
 }
 
@@ -186,10 +186,10 @@ mediation_job_t *mediation_callback_job_create(identification_t *requester,
                identification_t *peer_id)
 {
        private_mediation_job_t *this = mediation_job_create_empty();
-       
+
        this->target = requester->clone(requester);
        this->source = peer_id->clone(peer_id);
        this->callback = TRUE;
-       
+
        return &this->public;
 }
index 583ea8230fd3577a99b066d4c4703321b6f278b9..0574c65eb1456dd3556b26b60f28a6c7354830dc 100644 (file)
@@ -30,7 +30,7 @@ typedef struct mediation_job_t mediation_job_t;
 
 /**
  * Class representing a MEDIATION Job.
- * 
+ *
  * This job handles the mediation on the mediation server.
  */
 struct mediation_job_t {
@@ -42,9 +42,9 @@ struct mediation_job_t {
 
 /**
  * Creates a job of type MEDIATION.
- * 
+ *
  * Parameters get cloned.
- * 
+ *
  * @param peer_id              ID of the requested peer
  * @param requester            ID of the requesting peer
  * @param connect_id   content of ME_CONNECTID (could be NULL)
@@ -61,9 +61,9 @@ mediation_job_t *mediation_job_create(identification_t *peer_id,
 /**
  * Creates a special job of type MEDIATION that is used to send a callback
  * notification to a peer.
- * 
+ *
  * Parameters get cloned.
- * 
+ *
  * @param requester            ID of the waiting peer
  * @param peer_id              ID of the requested peer
  * @return                             job object
index a57d0478b5fc069fb581d9ab6bba1daff1a8eff5..53a6575a315d90ab9469144bcc5162d8391588a2 100644 (file)
@@ -30,7 +30,7 @@ struct private_migrate_job_t {
         * Public migrate_job_t interface.
         */
        migrate_job_t public;
-       
+
        /**
         * reqid of the CHILD_SA if it already exists
         */
@@ -75,7 +75,7 @@ static void destroy(private_migrate_job_t *this)
 static void execute(private_migrate_job_t *this)
 {
        ike_sa_t *ike_sa = NULL;
-       
+
        if (this->reqid)
        {
                ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
@@ -134,17 +134,17 @@ migrate_job_t *migrate_job_create(u_int32_t reqid,
                                                                  host_t *local, host_t *remote)
 {
        private_migrate_job_t *this = malloc_thing(private_migrate_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
-       
+
        /* private variables */
        this->reqid = reqid;
        this->src_ts = (dir == POLICY_OUT) ? src_ts : dst_ts;
        this->dst_ts = (dir == POLICY_OUT) ? dst_ts : src_ts;
        this->local = local;
        this->remote = remote;
-       
+
        return &this->public;
 }
index 672a09b0a46473a4a1d3cc5a097dc022a6ceb25e..e63318d179aee86982807861973f6acc23342c19 100644 (file)
@@ -31,8 +31,8 @@ typedef struct migrate_job_t migrate_job_t;
 
 /**
  * Class representing a MIGRATE Job.
- * 
- * This job sets a routed CHILD_SA for an existing IPsec policy. 
+ *
+ * This job sets a routed CHILD_SA for an existing IPsec policy.
  */
 struct migrate_job_t {
        /**
index 2703e5775b19d2e41f0398349707c7741fce160d..a47d48e3852367b26fbbfef783fd91a547e07854 100644 (file)
@@ -28,7 +28,7 @@ struct private_process_message_job_t {
         * public process_message_job_t interface
         */
        process_message_job_t public;
-       
+
        /**
         * Message associated with this job
         */
@@ -50,7 +50,7 @@ static void destroy(private_process_message_job_t *this)
 static void execute(private_process_message_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
 #ifdef ME
        /* if this is an unencrypted INFORMATIONAL exchange it is likely a
         * connectivity check. */
@@ -67,7 +67,7 @@ static void execute(private_process_message_job_t *this)
                return;
        }
 #endif /* ME */
-       
+
        ike_sa = charon->ike_sa_manager->checkout_by_message(charon->ike_sa_manager,
                                                                                                                 this->message);
        if (ike_sa)
@@ -98,9 +98,9 @@ process_message_job_t *process_message_job_create(message_t *message)
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void(*)(job_t*))destroy;
-       
+
        /* private variables */
        this->message = message;
-       
+
        return &(this->public);
 }
index b01d388f902f3a2d0c064cba22b2431d65a7f61b..5e3f44d1f923257072158710b8dc192d4fc5a428 100644 (file)
@@ -40,7 +40,7 @@ struct process_message_job_t {
 
 /**
  * Creates a job of type PROCESS_MESSAGE.
- * 
+ *
  * @param message              message to process
  * @return                             created process_message_job_t object
  */
index 17fcf641bb22f09f0c0405d9dd5e1aabff614c0b..b797d181edd00887c0a58d9611fe14024a609aca 100644 (file)
@@ -28,17 +28,17 @@ struct private_rekey_child_sa_job_t {
         * Public rekey_child_sa_job_t interface.
         */
        rekey_child_sa_job_t public;
-       
+
        /**
         * reqid of the child to rekey
         */
        u_int32_t reqid;
-       
+
        /**
         * protocol of the CHILD_SA (ESP/AH)
         */
        protocol_id_t protocol;
-       
+
        /**
         * inbound SPI of the CHILD_SA
         */
@@ -59,7 +59,7 @@ static void destroy(private_rekey_child_sa_job_t *this)
 static void execute(private_rekey_child_sa_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
        ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
                                                                                                        this->reqid, TRUE);
        if (ike_sa == NULL)
@@ -69,7 +69,7 @@ static void execute(private_rekey_child_sa_job_t *this)
        }
        else
        {
-               ike_sa->rekey_child_sa(ike_sa, this->protocol, this->spi);      
+               ike_sa->rekey_child_sa(ike_sa, this->protocol, this->spi);
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
        }
        destroy(this);
@@ -78,20 +78,20 @@ static void execute(private_rekey_child_sa_job_t *this)
 /*
  * Described in header
  */
-rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid, 
-                                                                                               protocol_id_t protocol, 
+rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid,
+                                                                                               protocol_id_t protocol,
                                                                                                u_int32_t spi)
 {
        private_rekey_child_sa_job_t *this = malloc_thing(private_rekey_child_sa_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
-               
+
        /* private variables */
        this->reqid = reqid;
        this->protocol = protocol;
        this->spi = spi;
-       
+
        return &this->public;
 }
index 2e2eef36140be58f6eb7662df136d714e4b67270..62887d6b90796c17a0ef2b642242ff2ebb697fa2 100644 (file)
@@ -51,7 +51,7 @@ struct rekey_child_sa_job_t {
  * @param spi          security parameter index of the CHILD_SA
  * @return                     rekey_child_sa_job_t object
  */
-rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid, 
+rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid,
                                                                                                protocol_id_t protocol,
                                                                                                u_int32_t spi);
 #endif /** REKEY_CHILD_SA_JOB_H_ @}*/
index 1ceb1e144d09575b24b1767f2b96455733b58d5d..5ec0b1b884897ddaa1861dec8d29a6294b873f8c 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "rekey_ike_sa_job.h"
 
 #include <daemon.h>
@@ -27,12 +27,12 @@ struct private_rekey_ike_sa_job_t {
         * Public rekey_ike_sa_job_t interface.
         */
        rekey_ike_sa_job_t public;
-       
+
        /**
         * ID of the IKE_SA to rekey
         */
        ike_sa_id_t *ike_sa_id;
-       
+
        /**
         * force reauthentication of the peer (full IKE_SA setup)
         */
@@ -55,7 +55,7 @@ static void execute(private_rekey_ike_sa_job_t *this)
 {
        ike_sa_t *ike_sa;
        status_t status = SUCCESS;
-       
+
        ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                                                                          this->ike_sa_id);
        if (ike_sa == NULL)
@@ -72,7 +72,7 @@ static void execute(private_rekey_ike_sa_job_t *this)
                {
                        status = ike_sa->rekey(ike_sa);
                }
-               
+
                if (status == DESTROY_ME)
                {
                        charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, ike_sa);
@@ -91,14 +91,14 @@ static void execute(private_rekey_ike_sa_job_t *this)
 rekey_ike_sa_job_t *rekey_ike_sa_job_create(ike_sa_id_t *ike_sa_id, bool reauth)
 {
        private_rekey_ike_sa_job_t *this = malloc_thing(private_rekey_ike_sa_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
-               
+
        /* private variables */
        this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
        this->reauth = reauth;
-       
+
        return &(this->public);
 }
index 0d830e13478bf75ce8ed1b399fe61b42f4d64ec8..a5c1028aa4e916eb320b5058a36372e9c8d9731a 100644 (file)
@@ -29,7 +29,7 @@ typedef struct rekey_ike_sa_job_t rekey_ike_sa_job_t;
 
 /**
  * Class representing an REKEY_IKE_SA Job.
- * 
+ *
  * This job initiates the rekeying of an IKE_SA.
  */
 struct rekey_ike_sa_job_t {
index 122cad8530a183bc83906175c053e5b8d56d0fdc..fc787f208a916d49e672f68700dcc6f1f0ca1c53 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "retransmit_job.h"
 
 #include <daemon.h>
@@ -28,7 +28,7 @@ struct private_retransmit_job_t {
         * Public retransmit_job_t interface.
         */
        retransmit_job_t public;
-       
+
        /**
         * Message ID of the request to resend.
         */
@@ -55,7 +55,7 @@ static void destroy(private_retransmit_job_t *this)
 static void execute(private_retransmit_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
        ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                                                                          this->ike_sa_id);
        if (ike_sa)
@@ -80,7 +80,7 @@ static void execute(private_retransmit_job_t *this)
 retransmit_job_t *retransmit_job_create(u_int32_t message_id,ike_sa_id_t *ike_sa_id)
 {
        private_retransmit_job_t *this = malloc_thing(private_retransmit_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
@@ -88,6 +88,6 @@ retransmit_job_t *retransmit_job_create(u_int32_t message_id,ike_sa_id_t *ike_sa
        /* private variables */
        this->message_id = message_id;
        this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
-       
+
        return &this->public;
 }
index 4c9bea1c8b4356a91f0eb3dc1612b2dcb9cab695..c8c13479bd7f53d1958ad919a6bfe55854f1fdf4 100644 (file)
@@ -44,7 +44,7 @@ struct retransmit_job_t {
 
 /**
  * Creates a job of type retransmit.
- * 
+ *
  * @param message_id           message_id of the request to resend
  * @param ike_sa_id                    identification of the ike_sa as ike_sa_id_t
  * @return                                     retransmit_job_t object
index c01f83248c37476e7b8205fa99f36a814efc9e79..adc884a8abbf3bd2635e68579eb746ff9e4ae412 100644 (file)
@@ -31,7 +31,7 @@ struct private_roam_job_t {
         * public roam_job_t interface
         */
        roam_job_t public;
-       
+
        /**
         * has the address list changed, or the routing only?
         */
@@ -47,16 +47,16 @@ static void destroy(private_roam_job_t *this)
 }
 
 /**
- * Implementation of job_t.execute. 
- */ 
+ * Implementation of job_t.execute.
+ */
 static void execute(private_roam_job_t *this)
 {
        ike_sa_t *ike_sa;
        linked_list_t *list;
        ike_sa_id_t *id;
        enumerator_t *enumerator;
-       
-       /* enumerator over all IKE_SAs gives us no way to checkin_and_destroy 
+
+       /* enumerator over all IKE_SAs gives us no way to checkin_and_destroy
         * after a DESTROY_ME, so we check out each available IKE_SA by hand. */
        list = linked_list_create();
        enumerator = charon->ike_sa_manager->create_enumerator(charon->ike_sa_manager);
@@ -66,7 +66,7 @@ static void execute(private_roam_job_t *this)
                list->insert_last(list, id->clone(id));
        }
        enumerator->destroy(enumerator);
-       
+
        while (list->remove_last(list, (void**)&id) == SUCCESS)
        {
                ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager, id);
@@ -95,10 +95,10 @@ static void execute(private_roam_job_t *this)
 roam_job_t *roam_job_create(bool address)
 {
        private_roam_job_t *this = malloc_thing(private_roam_job_t);
-       
+
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-       
+
        this->address = address;
 
        return &this->public;
index 7bb1227f5242af4b0c2659103e6011bd311c39f6..55bdf2b280bd06743ba0a710d19ddb54fe49869a 100644 (file)
@@ -29,7 +29,7 @@ typedef struct roam_job_t roam_job_t;
 
 /**
  * A job to inform IKE_SAs about changed local address setup.
- * 
+ *
  * If a local address appears or disappears, the kernel fires this job to
  * update all IKE_SAs.
  */
@@ -43,7 +43,7 @@ struct roam_job_t {
 
 /**
  * Creates a job to inform IKE_SAs about an updated address list.
- * 
+ *
  * @param address              TRUE if address list changed, FALSE if routing changed
  * @return                             initiate_ike_sa_job_t object
  */
index c6e81a56f8c28473d3e8cfb60de09d8f666f0141..1c2da52b83d5e5f228bedf0143c6c6eabba6a3b2 100644 (file)
@@ -31,7 +31,7 @@ struct private_send_dpd_job_t {
         * public send_dpd_job_t interface
         */
        send_dpd_job_t public;
-       
+
        /**
         * ID of the IKE_SA which the message belongs to.
         */
@@ -48,12 +48,12 @@ static void destroy(private_send_dpd_job_t *this)
 }
 
 /**
- * Implementation of job_t.execute. 
- */ 
+ * Implementation of job_t.execute.
+ */
 static void execute(private_send_dpd_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
        ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                                                                          this->ike_sa_id);
        if (ike_sa)
@@ -76,11 +76,11 @@ static void execute(private_send_dpd_job_t *this)
 send_dpd_job_t *send_dpd_job_create(ike_sa_id_t *ike_sa_id)
 {
        private_send_dpd_job_t *this = malloc_thing(private_send_dpd_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-       
+
        /* private variables */
        this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
 
index 91556a9d1857b52c977111d4d647a85e8591d89c..8078a38bc244789bd02affa85b467195dd11241d 100644 (file)
@@ -29,7 +29,7 @@ typedef struct send_dpd_job_t send_dpd_job_t;
 
 /**
  * Class representing a SEND_DPD Job.
- * 
+ *
  * Job to periodically send a Dead Peer Detection (DPD) request,
  * ie. an IKE request with no payloads other than the encrypted payload
  * required by the syntax.
@@ -43,7 +43,7 @@ struct send_dpd_job_t {
 
 /**
  * Creates a job of type SEND_DPD.
- * 
+ *
  * @param ike_sa_id            identification of the ike_sa as ike_sa_id_t object (gets cloned)
  * @return                             initiate_ike_sa_job_t object
  */
index 5d3cfb5300cbd2ed1ced94999cd16442068c02af..3d02cea2ec9fbbaafd225e38f365109a0359d251 100644 (file)
@@ -31,7 +31,7 @@ struct private_send_keepalive_job_t {
         * public send_keepalive_job_t interface
         */
        send_keepalive_job_t public;
-       
+
        /**
         * ID of the IKE_SA which the message belongs to.
         */
@@ -49,11 +49,11 @@ static void destroy(private_send_keepalive_job_t *this)
 
 /**
  * Implementation of job_t.execute.
- */ 
+ */
 static void execute(private_send_keepalive_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
        ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
                                                                                          this->ike_sa_id);
        if (ike_sa)
@@ -70,11 +70,11 @@ static void execute(private_send_keepalive_job_t *this)
 send_keepalive_job_t *send_keepalive_job_create(ike_sa_id_t *ike_sa_id)
 {
        private_send_keepalive_job_t *this = malloc_thing(private_send_keepalive_job_t);
-       
+
        /* interface functions */
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-       
+
        /* private variables */
        this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
 
index f92e6217a54f1da9440edeea9cdbccb127ed4cc1..cda83cd7e1c78962895564b4bc262e1cf15bab59 100644 (file)
@@ -29,7 +29,7 @@ typedef struct send_keepalive_job_t send_keepalive_job_t;
 
 /**
  * Class representing a SEND_KEEPALIVE Job.
- * 
+ *
  * This job will send a NAT keepalive packet if the IKE SA is still alive,
  * and reinsert itself into the event queue.
  */
@@ -42,7 +42,7 @@ struct send_keepalive_job_t {
 
 /**
  * Creates a job of type SEND_KEEPALIVE.
- * 
+ *
  * @param ike_sa_id            identification of the ike_sa as ike_sa_id_t object (gets cloned)
  * @return                             initiate_ike_sa_job_t object
  */
index 5e6c83942c615b0d2cbb0cf5751064f5107bb468..17dce2548d97e67602230a2cda8ec6cda822f4c4 100644 (file)
@@ -31,12 +31,12 @@ struct private_update_sa_job_t {
         * public update_sa_job_t interface
         */
        update_sa_job_t public;
-       
+
        /**
         * reqid of the CHILD_SA
         */
        u_int32_t reqid;
-       
+
        /**
         * New SA address and port
         */
@@ -53,12 +53,12 @@ static void destroy(private_update_sa_job_t *this)
 }
 
 /**
- * Implementation of job_t.execute. 
- */ 
+ * Implementation of job_t.execute.
+ */
 static void execute(private_update_sa_job_t *this)
 {
        ike_sa_t *ike_sa;
-       
+
        ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
                                                                                                        this->reqid, TRUE);
        if (ike_sa == NULL)
@@ -84,10 +84,10 @@ static void execute(private_update_sa_job_t *this)
 update_sa_job_t *update_sa_job_create(u_int32_t reqid, host_t *new)
 {
        private_update_sa_job_t *this = malloc_thing(private_update_sa_job_t);
-       
+
        this->public.job_interface.execute = (void (*) (job_t *)) execute;
        this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-       
+
        this->reqid = reqid;
        this->new = new;
 
index 93262d46fb3f29274dc8948744edd1fb7bd9c7d8..11d1ac9b693b84d8d14180c783677c72cadfa0fc 100644 (file)
@@ -40,7 +40,7 @@ struct update_sa_job_t {
 
 /**
  * Creates a job to update IKE and CHILD_SA addresses.
- * 
+ *
  * @param reqid                        reqid of the CHILD_SA
  * @param new                  new address and port
  * @return                             update_sa_job_t object
index 4a3943323c7479ab68c24c142da55563704fb9b9..a364017c2bb80de179908637649b7748ebd286d3 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include <stdlib.h>
 #include <pthread.h>
 #include <string.h>
@@ -41,12 +41,12 @@ struct private_processor_t {
         * Number of running threads
         */
        u_int total_threads;
-       
+
        /**
         * Desired number of threads
         */
        u_int desired_threads;
-       
+
        /**
         * Number of threads waiting for work
         */
@@ -56,7 +56,7 @@ struct private_processor_t {
         * The jobs are stored in a linked list
         */
        linked_list_t *list;
-       
+
        /**
         * access to linked_list is locked through this mutex
         */
@@ -66,7 +66,7 @@ struct private_processor_t {
         * Condvar to wait for new jobs
         */
        condvar_t *job_added;
-       
+
        /**
         * Condvar to wait for terminated threads
         */
@@ -81,7 +81,7 @@ static void process_jobs(private_processor_t *this);
 static void restart(private_processor_t *this)
 {
        pthread_t thread;
-       
+
        /* respawn thread if required */
        if (this->desired_threads == 0 ||
                pthread_create(&thread, NULL, (void*)process_jobs, this) != 0)
@@ -99,16 +99,16 @@ static void restart(private_processor_t *this)
 static void process_jobs(private_processor_t *this)
 {
        int oldstate;
-       
+
        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
-       
+
        DBG2(DBG_JOB, "started worker thread, thread_ID: %06u", (int)pthread_self());
-       
+
        this->mutex->lock(this->mutex);
        while (this->desired_threads >= this->total_threads)
        {
                job_t *job;
-               
+
                if (this->list->get_count(this->list) == 0)
                {
                        this->idle_threads++;
@@ -136,7 +136,7 @@ static u_int get_total_threads(private_processor_t *this)
 {
        u_int count;
        this->mutex->lock(this->mutex);
-       count = this->total_threads; 
+       count = this->total_threads;
        this->mutex->unlock(this->mutex);
        return count;
 }
@@ -175,7 +175,7 @@ static void queue_job(private_processor_t *this, job_t *job)
        this->job_added->signal(this->job_added);
        this->mutex->unlock(this->mutex);
 }
-       
+
 /**
  * Implementation of processor_t.set_threads.
  */
@@ -186,7 +186,7 @@ static void set_threads(private_processor_t *this, u_int count)
        {       /* increase thread count */
                int i;
                pthread_t current;
-               
+
                this->desired_threads = count;
                DBG1(DBG_JOB, "spawning %d worker threads", count - this->total_threads);
                for (i = this->total_threads; i < count; i++)
@@ -231,14 +231,14 @@ static void destroy(private_processor_t *this)
 processor_t *processor_create(size_t pool_size)
 {
        private_processor_t *this = malloc_thing(private_processor_t);
-       
+
        this->public.get_total_threads = (u_int(*)(processor_t*))get_total_threads;
        this->public.get_idle_threads = (u_int(*)(processor_t*))get_idle_threads;
        this->public.get_job_load = (u_int(*)(processor_t*))get_job_load;
        this->public.queue_job = (void(*)(processor_t*, job_t*))queue_job;
        this->public.set_threads = (void(*)(processor_t*, u_int))set_threads;
        this->public.destroy = (void(*)(processor_t*))destroy;
-       
+
        this->list = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->job_added = condvar_create(CONDVAR_TYPE_DEFAULT);
@@ -246,7 +246,7 @@ processor_t *processor_create(size_t pool_size)
        this->total_threads = 0;
        this->desired_threads = 0;
        this->idle_threads = 0;
-       
+
        return &this->public;
 }
 
index e56e69382e3689e205f9185e125aceb0b96c9cb1..58222ab815e17decc7f2887ca99262621da2bfd2 100644 (file)
@@ -33,21 +33,21 @@ typedef struct processor_t processor_t;
  * The processor uses threads to process queued jobs.
  */
 struct processor_t {
-       
+
        /**
         * Get the total number of threads used by the processor.
-        *      
+        *
         * @return                              size of thread pool
         */
        u_int (*get_total_threads) (processor_t *this);
-       
+
        /**
         * Get the number of threads currently waiting.
-        *      
+        *
         * @return                              number of idle threads
         */
        u_int (*get_idle_threads) (processor_t *this);
-       
+
        /**
         * Get the number of queued jobs.
         *
@@ -63,7 +63,7 @@ struct processor_t {
         * @param job                   job to add to the queue
         */
        void (*queue_job) (processor_t *this, job_t *job);
-       
+
        /**
         * Set the number of threads to use in the processor.
         *
@@ -75,7 +75,7 @@ struct processor_t {
         * @param count                 number of threads to allocate
         */
        void (*set_threads)(processor_t *this, u_int count);
-       
+
        /**
         * Destroy a processor object.
         */
index f53ccb99ad914a209d41b1ab95e3c9b9615607e8..d09b384c39c4f86a248d7683e7814719dbe608b6 100644 (file)
@@ -38,7 +38,7 @@ struct event_t {
         * Time to fire the event.
         */
        timeval_t time;
-       
+
        /**
         * Every event has its assigned job.
         */
@@ -60,37 +60,37 @@ typedef struct private_scheduler_t private_scheduler_t;
  * Private data of a scheduler_t object.
  */
 struct private_scheduler_t {
-       
+
        /**
         * Public part of a scheduler_t object.
         */
         scheduler_t public;
-       
+
        /**
         * Job which queues scheduled jobs to the processor.
         */
        callback_job_t *job;
-       
+
        /**
         * The heap in which the events are stored.
         */
        event_t **heap;
-       
+
        /**
         * The size of the heap.
         */
        u_int heap_size;
-       
+
        /**
         * The number of scheduled events.
         */
        u_int event_count;
-       
+
        /**
         * Exclusive access to list
         */
        mutex_t *mutex;
-       
+
        /**
         * Condvar to wait for next job.
         */
@@ -140,12 +140,12 @@ static event_t *remove_event(private_scheduler_t *this)
        {
                return NULL;
        }
-       
+
        /* store the value to return */
        event = this->heap[1];
        /* move the bottom event to the top */
        top = this->heap[1] = this->heap[this->event_count];
-               
+
        if (--this->event_count > 1)
        {
                /* seep down the top event */
@@ -153,7 +153,7 @@ static event_t *remove_event(private_scheduler_t *this)
                while ((position << 1) <= this->event_count)
                {
                        u_int child = position << 1;
-                       
+
                        if ((child + 1) <= this->event_count &&
                                timeval_cmp(&this->heap[child + 1]->time,
                                                        &this->heap[child]->time) < 0)
@@ -161,14 +161,14 @@ static event_t *remove_event(private_scheduler_t *this)
                                /* the "right" child is smaller */
                                child++;
                        }
-                       
+
                        if (timeval_cmp(&top->time, &this->heap[child]->time) <= 0)
                        {
                                /* the top event fires before the smaller of the two children,
                                 * stop */
                                break;
                        }
-                       
+
                        /* swap with the smaller child */
                        this->heap[position] = this->heap[child];
                        position = child;
@@ -187,11 +187,11 @@ static job_requeue_t schedule(private_scheduler_t * this)
        event_t *event;
        int oldstate;
        bool timed = FALSE;
-       
+
        this->mutex->lock(this->mutex);
-       
+
        time_monotonic(&now);
-       
+
        if ((event = peek_event(this)) != NULL)
        {
                if (timeval_cmp(&now, &event->time) >= 0)
@@ -217,7 +217,7 @@ static job_requeue_t schedule(private_scheduler_t * this)
        }
        pthread_cleanup_push((void*)this->mutex->unlock, this->mutex);
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
-       
+
        if (timed)
        {
                this->condvar->timed_wait_abs(this->condvar, this->mutex, event->time);
@@ -251,13 +251,13 @@ static void schedule_job_tv(private_scheduler_t *this, job_t *job, timeval_t tv)
 {
        event_t *event;
        u_int position;
-       
+
        event = malloc_thing(event_t);
        event->job = job;
        event->time = tv;
-       
+
        this->mutex->lock(this->mutex);
-       
+
        this->event_count++;
        if (this->event_count > this->heap_size)
        {
@@ -268,7 +268,7 @@ static void schedule_job_tv(private_scheduler_t *this, job_t *job, timeval_t tv)
        }
        /* "put" the event to the bottom */
        position = this->event_count;
-       
+
        /* then bubble it up */
        while (position > 1 && timeval_cmp(&this->heap[position >> 1]->time,
                                                                           &event->time) > 0)
@@ -278,7 +278,7 @@ static void schedule_job_tv(private_scheduler_t *this, job_t *job, timeval_t tv)
                position >>= 1;
        }
        this->heap[position] = event;
-       
+
        this->condvar->signal(this->condvar);
        this->mutex->unlock(this->mutex);
 }
@@ -289,10 +289,10 @@ static void schedule_job_tv(private_scheduler_t *this, job_t *job, timeval_t tv)
 static void schedule_job(private_scheduler_t *this, job_t *job, u_int32_t s)
 {
        timeval_t tv;
-       
+
        time_monotonic(&tv);
        tv.tv_sec += s;
-       
+
        schedule_job_tv(this, job, tv);
 }
 
@@ -302,13 +302,13 @@ static void schedule_job(private_scheduler_t *this, job_t *job, u_int32_t s)
 static void schedule_job_ms(private_scheduler_t *this, job_t *job, u_int32_t ms)
 {
        timeval_t tv, add;
-       
+
        time_monotonic(&tv);
        add.tv_sec = ms / 1000;
        add.tv_usec = (ms % 1000) * 1000;
-       
+
        timeradd(&tv, &add, &tv);
-       
+
        schedule_job_tv(this, job, tv);
 }
 
@@ -335,24 +335,24 @@ static void destroy(private_scheduler_t *this)
 scheduler_t * scheduler_create()
 {
        private_scheduler_t *this = malloc_thing(private_scheduler_t);
-       
+
        this->public.get_job_load = (u_int (*) (scheduler_t *this)) get_job_load;
        this->public.schedule_job = (void (*) (scheduler_t *this, job_t *job, u_int32_t s)) schedule_job;
        this->public.schedule_job_ms = (void (*) (scheduler_t *this, job_t *job, u_int32_t ms)) schedule_job_ms;
        this->public.schedule_job_tv = (void (*) (scheduler_t *this, job_t *job, timeval_t tv)) schedule_job_tv;
        this->public.destroy = (void(*)(scheduler_t*)) destroy;
-       
+
        /* Note: the root of the heap is at index 1 */
        this->event_count = 0;
        this->heap_size = HEAP_SIZE_DEFAULT;
        this->heap = (event_t**)calloc(this->heap_size + 1, sizeof(event_t*));
-       
+
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
-       
+
        this->job = callback_job_create((callback_job_cb_t)schedule, this, NULL, NULL);
        charon->processor->queue_job(charon->processor, (job_t*)this->job);
-       
+
        return &this->public;
 }
 
index 2bb85e4e68ca6e716a56ce20f4a5e60dac18bf3d..5f5d2a563a129e7aacd29371999988773be4462f 100644 (file)
@@ -79,7 +79,7 @@ typedef struct scheduler_t scheduler_t;
  * children has a smaller key or it is again a leaf node.
  */
 struct scheduler_t {
-       
+
        /**
         * Adds a event to the queue, using a relative time offset in s.
         *
@@ -87,7 +87,7 @@ struct scheduler_t {
         * @param time                  relative time to schedule job, in s
         */
        void (*schedule_job) (scheduler_t *this, job_t *job, u_int32_t s);
-       
+
        /**
         * Adds a event to the queue, using a relative time offset in ms.
         *
@@ -95,7 +95,7 @@ struct scheduler_t {
         * @param time                  relative time to schedule job, in ms
         */
        void (*schedule_job_ms) (scheduler_t *this, job_t *job, u_int32_t ms);
-       
+
        /**
         * Adds a event to the queue, using an absolut time.
         *
@@ -106,14 +106,14 @@ struct scheduler_t {
         * @param time                  absolut time to schedule job
         */
        void (*schedule_job_tv) (scheduler_t *this, job_t *job, timeval_t tv);
-       
+
        /**
         * Returns number of jobs scheduled.
         *
         * @return                              number of scheduled jobs
         */
        u_int (*get_job_load) (scheduler_t *this);
-       
+
        /**
         * Destroys a scheduler object.
         */
index ea8a16279dd43e3489a4c68755ee3aaed1b90303..13586a23e23b1a68235dbb5f0afe1ecd5e3a0978 100644 (file)
@@ -75,7 +75,7 @@ authenticator_t *authenticator_create_verifier(
                                                                        chunk_t received_init, chunk_t sent_init)
 {
        auth_payload_t *auth_payload;
-       
+
        auth_payload = (auth_payload_t*)message->get_payload(message, AUTHENTICATION);
        if (auth_payload == NULL)
        {
index c60881629a58ecd97ea4694b0303994ebf0ed708..299b9e6e72b6cf97804d7a09b64c1d51b38ee50a 100644 (file)
@@ -36,34 +36,34 @@ typedef struct authenticator_t authenticator_t;
  */
 enum auth_method_t {
        /**
-        * Computed as specified in section 2.15 of RFC using 
+        * Computed as specified in section 2.15 of RFC using
         * an RSA private key over a PKCS#1 padded hash.
         */
        AUTH_RSA = 1,
-       
+
        /**
-        * Computed as specified in section 2.15 of RFC using the 
-        * shared key associated with the identity in the ID payload 
+        * Computed as specified in section 2.15 of RFC using the
+        * shared key associated with the identity in the ID payload
         * and the negotiated prf function
         */
        AUTH_PSK = 2,
-       
+
        /**
-        * Computed as specified in section 2.15 of RFC using a 
+        * Computed as specified in section 2.15 of RFC using a
         * DSS private key over a SHA-1 hash.
         */
        AUTH_DSS = 3,
-       
+
        /**
         * ECDSA with SHA-256 on the P-256 curve as specified in RFC 4754
         */
        AUTH_ECDSA_256 = 9,
-       
+
        /**
         * ECDSA with SHA-384 on the P-384 curve as specified in RFC 4754
         */
        AUTH_ECDSA_384 = 10,
-       
+
        /**
         * ECDSA with SHA-512 on the P-521 curve as specified in RFC 4754
         */
@@ -115,7 +115,7 @@ struct authenticator_t {
         *                                              - NEED_MORE if another exchange required
         */
        status_t (*process)(authenticator_t *this, message_t *message);
-       
+
        /**
         * Attach authentication data to an outgoing message.
         *
@@ -126,7 +126,7 @@ struct authenticator_t {
         *                                              - NEED_MORE if another exchange required
         */
        status_t (*build)(authenticator_t *this, message_t *message);
-       
+
        /**
         * Destroy authenticator instance.
         */
@@ -151,7 +151,7 @@ authenticator_t *authenticator_create_builder(
 
 /**
  * Create an authenticator to verify signatures.
- * 
+ *
  * @param ike_sa                       associated ike_sa
  * @param message                      message containing authentication data
  * @param received_nonce       nonce received in IKE_SA_INIT
index 24a4fd6ed78ea9be8343614336e7657a47682df2..eb4cb0c2d1e15011c26f33c593f5deedb4b53d4c 100644 (file)
@@ -25,22 +25,22 @@ typedef struct eap_entry_t eap_entry_t;
  * EAP constructor entry
  */
 struct eap_entry_t {
-       
+
        /**
         * EAP method type, vendor specific if vendor is set
         */
        eap_type_t type;
-       
+
        /**
         * vendor ID, 0 for default EAP methods
         */
        u_int32_t vendor;
-       
+
        /**
         * Role of the method returned by the constructor, EAP_SERVER or EAP_PEER
         */
        eap_role_t role;
-       
+
        /**
         * constructor function to create instance
         */
@@ -56,12 +56,12 @@ struct private_eap_manager_t {
         * public functions
         */
        eap_manager_t public;
-       
+
        /**
         * list of eap_entry_t's
         */
        linked_list_t *methods;
-       
+
        /**
         * rwlock to lock methods
         */
@@ -76,7 +76,7 @@ static void add_method(private_eap_manager_t *this, eap_type_t type,
                                           eap_constructor_t constructor)
 {
        eap_entry_t *entry = malloc_thing(eap_entry_t);
-       
+
        entry->type = type;
        entry->vendor = vendor;
        entry->role = role;
@@ -94,7 +94,7 @@ static void remove_method(private_eap_manager_t *this, eap_constructor_t constru
 {
        enumerator_t *enumerator;
        eap_entry_t *entry;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->methods->create_enumerator(this->methods);
        while (enumerator->enumerate(enumerator, &entry))
@@ -120,7 +120,7 @@ static eap_method_t* create_instance(private_eap_manager_t *this,
        enumerator_t *enumerator;
        eap_entry_t *entry;
        eap_method_t *method = NULL;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->methods->create_enumerator(this->methods);
        while (enumerator->enumerate(enumerator, &entry))
@@ -156,15 +156,15 @@ static void destroy(private_eap_manager_t *this)
 eap_manager_t *eap_manager_create()
 {
        private_eap_manager_t *this = malloc_thing(private_eap_manager_t);
-       
+
        this->public.add_method = (void(*)(eap_manager_t*, eap_type_t type, u_int32_t vendor, eap_role_t role, eap_constructor_t constructor))add_method;
        this->public.remove_method = (void(*)(eap_manager_t*, eap_constructor_t constructor))remove_method;
        this->public.create_instance = (eap_method_t*(*)(eap_manager_t*, eap_type_t type, u_int32_t vendor, eap_role_t role, identification_t*,identification_t*))create_instance;
        this->public.destroy = (void(*)(eap_manager_t*))destroy;
-       
+
        this->methods = linked_list_create();
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index 667c54a8e58ada966ba4b53fe65a32894c37c410..271bfc2bf9a89c6d9600d5c7a20b4372798d0af3 100644 (file)
@@ -45,14 +45,14 @@ struct eap_manager_t {
         */
        void (*add_method)(eap_manager_t *this, eap_type_t type, u_int32_t vendor,
                                           eap_role_t role, eap_constructor_t constructor);
-       
+
        /**
         * Unregister a EAP method implementation using it's constructor.
         *
         * @param constructor   constructor function to remove, as added in add_method
         */
        void (*remove_method)(eap_manager_t *this, eap_constructor_t constructor);
-       
+
        /**
         * Create a new EAP method instance.
         *
@@ -67,7 +67,7 @@ struct eap_manager_t {
                                                                         u_int32_t vendor, eap_role_t role,
                                                                         identification_t *server,
                                                                         identification_t *peer);
-       
+
        /**
      * Destroy a eap_manager instance.
      */
index 1d1900301202c4f364ec6be610d61dd0444a584e..791ab2dd9cdf85dc9f603cf1ac491ff16a7a6c91 100644 (file)
@@ -53,7 +53,7 @@ eap_type_t eap_type_from_string(char *name)
                {"mschapv2",    EAP_MSCHAPV2},
                {"radius",              EAP_RADIUS},
        };
-       
+
        for (i = 0; i < countof(types); i++)
        {
                if (strcaseeq(name, types[i].name))
index 578b89e962f2c8fb8b666de3a4b0e9377bf93686..61e8e2caaea6df356ab67f6d39d60523d96297ac 100644 (file)
@@ -107,7 +107,7 @@ extern enum_name_t *eap_code_names;
  * EAP-Identity exchange always uses identifier 0.
  */
 struct eap_method_t {
-       
+
        /**
         * Initiate the EAP exchange.
         *
@@ -121,7 +121,7 @@ struct eap_method_t {
         *                                      - FAILED, if unable to create eap request payload
         */
        status_t (*initiate) (eap_method_t *this, eap_payload_t **out);
-       
+
        /**
         * Process a received EAP message.
         *
@@ -136,7 +136,7 @@ struct eap_method_t {
         */
        status_t (*process) (eap_method_t *this, eap_payload_t *in,
                                                 eap_payload_t **out);
-       
+
        /**
         * Get the EAP type implemented in this method.
         *
@@ -144,17 +144,17 @@ struct eap_method_t {
         * @return                      type of the EAP method
         */
        eap_type_t (*get_type) (eap_method_t *this, u_int32_t *vendor);
-       
+
        /**
         * Check if this EAP method authenticates the server.
         *
-        * Some EAP methods provide mutual authentication and 
+        * Some EAP methods provide mutual authentication and
         * allow authentication using only EAP, if the peer supports it.
         *
         * @return                      TRUE if methods provides mutual authentication
         */
        bool (*is_mutual) (eap_method_t *this);
-       
+
        /**
         * Get the MSK established by this EAP method.
         *
@@ -167,7 +167,7 @@ struct eap_method_t {
         *                                      - FAILED, if MSK not established (yet)
         */
        status_t (*get_msk) (eap_method_t *this, chunk_t *msk);
-       
+
        /**
         * Destroys a eap_method_t object.
         */
index 51cd4fb3f82f3428b45634900a45a4b6ab7ba9d9..b5edb75e218b674074bbf5b3327644ec1d895293 100644 (file)
@@ -23,17 +23,17 @@ typedef struct private_sim_manager_t private_sim_manager_t;
  * Private data of an sim_manager_t object.
  */
 struct private_sim_manager_t {
-       
+
        /**
         * Public sim_manager_t interface.
         */
        sim_manager_t public;
-       
+
        /**
         * list of added cards
         */
        linked_list_t *cards;
-       
+
        /**
         * list of added provider
         */
@@ -106,7 +106,7 @@ static void destroy(private_sim_manager_t *this)
 sim_manager_t *sim_manager_create()
 {
        private_sim_manager_t *this = malloc_thing(private_sim_manager_t);
-       
+
        this->public.add_card = (void(*)(sim_manager_t*, sim_card_t *card))add_card;
        this->public.remove_card = (void(*)(sim_manager_t*, sim_card_t *card))remove_card;
        this->public.create_card_enumerator = (enumerator_t*(*)(sim_manager_t*))create_card_enumerator;
@@ -114,10 +114,10 @@ sim_manager_t *sim_manager_create()
        this->public.remove_provider = (void(*)(sim_manager_t*, sim_provider_t *provider))remove_provider;
        this->public.create_provider_enumerator = (enumerator_t*(*)(sim_manager_t*))create_provider_enumerator;
        this->public.destroy = (void(*)(sim_manager_t*))destroy;
-       
+
        this->cards = linked_list_create();
        this->provider = linked_list_create();
-       
+
        return &this->public;
 }
 
index 3c6d66dfefbb27cd97e290100b305495ed74fdc0..260e73038dda20f4bfd5f7a148c14e80889b93ad 100644 (file)
@@ -42,7 +42,7 @@ struct sim_card_t {
         * @return              identity
         */
        identification_t* (*get_imsi)(sim_card_t *this);
-       
+
        /**
         * Calculate SRES/KC from a RAND.
         *
@@ -59,7 +59,7 @@ struct sim_card_t {
  * Interface for a triplet provider (used as EAP server).
  */
 struct sim_provider_t {
-       
+
        /**
         * Get a single triplet to authenticate a EAP client.
         *
@@ -77,49 +77,49 @@ struct sim_provider_t {
  * The EAP-SIM manager handles multiple SIM cards and providers.
  */
 struct sim_manager_t {
-       
+
        /**
         * Register a SIM card (client) at the manager.
         *
         * @param card          sim card to register
         */
        void (*add_card)(sim_manager_t *this, sim_card_t *card);
-       
+
        /**
         * Unregister a previously registered card from the manager.
         *
         * @param card          sim card to unregister
         */
        void (*remove_card)(sim_manager_t *this, sim_card_t *card);
-       
+
        /**
         * Create an enumerator over all registered cards.
         *
         * @return                      enumerator over sim_card_t's
         */
        enumerator_t* (*create_card_enumerator)(sim_manager_t *this);
-       
+
        /**
         * Register a triplet provider (server) at the manager.
         *
         * @param card          sim card to register
         */
        void (*add_provider)(sim_manager_t *this, sim_provider_t *provider);
-       
+
        /**
         * Unregister a previously registered provider from the manager.
         *
         * @param card          sim card to unregister
         */
        void (*remove_provider)(sim_manager_t *this, sim_provider_t *provider);
-       
+
        /**
         * Create an enumerator over all registered provider.
         *
         * @return                      enumerator over sim_provider_t's
         */
        enumerator_t* (*create_provider_enumerator)(sim_manager_t *this);
-       
+
        /**
         * Destroy a manager instance.
         */
index 2abdf7a0207f0b2612ee7e79113e6e1ec0cf6e86..30803dff0961dd560fd0d86710c13d5c387e466d 100644 (file)
@@ -26,62 +26,62 @@ typedef struct private_eap_authenticator_t private_eap_authenticator_t;
  * Private data of an eap_authenticator_t object.
  */
 struct private_eap_authenticator_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        eap_authenticator_t public;
-       
+
        /**
         * Assigned IKE_SA
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * others nonce to include in AUTH calculation
         */
        chunk_t received_nonce;
-       
+
        /**
         * our nonce to include in AUTH calculation
         */
        chunk_t sent_nonce;
-       
+
        /**
         * others IKE_SA_INIT message data to include in AUTH calculation
         */
        chunk_t received_init;
-       
+
        /**
         * our IKE_SA_INIT message data to include in AUTH calculation
         */
        chunk_t sent_init;
-       
+
        /**
         * Current EAP method processing
         */
        eap_method_t *method;
-       
+
        /**
         * MSK used to build and verify auth payload
         */
        chunk_t msk;
-       
+
        /**
         * EAP authentication method completed successfully
         */
        bool eap_complete;
-       
+
        /**
         * authentication payload verified successfully
         */
        bool auth_complete;
-       
+
        /**
         * generated EAP payload
         */
        eap_payload_t *eap_payload;
-       
+
        /**
         * EAP identity of peer
         */
@@ -95,7 +95,7 @@ static eap_method_t *load_method(private_eap_authenticator_t *this,
                                                        eap_type_t type, u_int32_t vendor, eap_role_t role)
 {
        identification_t *server, *peer;
-       
+
        if (role == EAP_SERVER)
        {
                server = this->ike_sa->get_my_id(this->ike_sa);
@@ -125,9 +125,9 @@ static eap_payload_t* server_initiate_eap(private_eap_authenticator_t *this,
        identification_t *id;
        u_int32_t vendor;
        eap_payload_t *out;
-       
+
        auth = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
-       
+
        /* initiate EAP-Identity exchange if required */
        if (!this->eap_identity && do_identity)
        {
@@ -157,7 +157,7 @@ static eap_payload_t* server_initiate_eap(private_eap_authenticator_t *this,
                if (vendor)
                {
                        DBG1(DBG_IKE, "initiating EAP vendor type %d-%d", type, vendor);
-                       
+
                }
                else
                {
@@ -186,14 +186,14 @@ static eap_payload_t* server_process_eap(private_eap_authenticator_t *this,
        u_int32_t vendor, received_vendor;
        eap_payload_t *out;
        auth_cfg_t *cfg;
-       
+
        if (in->get_code(in) != EAP_RESPONSE)
        {
                DBG1(DBG_IKE, "received %N, sending %N",
                         eap_code_names, in->get_code(in), eap_code_names, EAP_FAILURE);
                return eap_payload_create_code(EAP_FAILURE, in->get_identifier(in));
        }
-       
+
        type = this->method->get_type(this->method, &vendor);
        received_type = in->get_type(in, &received_vendor);
        if (type != received_type || vendor != received_vendor)
@@ -210,7 +210,7 @@ static eap_payload_t* server_process_eap(private_eap_authenticator_t *this,
                }
                return eap_payload_create_code(EAP_FAILURE, in->get_identifier(in));
        }
-       
+
        switch (this->method->process(this->method, in, &out))
        {
                case NEED_MORE:
@@ -220,7 +220,7 @@ static eap_payload_t* server_process_eap(private_eap_authenticator_t *this,
                        {
                                chunk_t data;
                                char buf[256];
-                               
+
                                if (this->method->get_msk(this->method, &data) == SUCCESS)
                                {
                                        snprintf(buf, sizeof(buf), "%.*s", data.len, data.ptr);
@@ -262,7 +262,7 @@ static eap_payload_t* server_process_eap(private_eap_authenticator_t *this,
                        if (vendor)
                        {
                                DBG1(DBG_IKE, "EAP vendor specific method %d-%d failed for "
-                                        "peer %Y", type, vendor, 
+                                        "peer %Y", type, vendor,
                                         this->ike_sa->get_other_id(this->ike_sa));
                        }
                        else
@@ -286,9 +286,9 @@ static eap_payload_t* client_process_eap(private_eap_authenticator_t *this,
        auth_cfg_t *auth;
        eap_payload_t *out;
        identification_t *id;
-       
+
        type = in->get_type(in, &vendor);
-       
+
        if (!vendor && type == EAP_IDENTITY)
        {
                DESTROY_IF(this->eap_identity);
@@ -301,7 +301,7 @@ static eap_payload_t* client_process_eap(private_eap_authenticator_t *this,
                DBG1(DBG_IKE, "server requested %N, sending '%Y'",
                         eap_type_names, type, id);
                this->eap_identity = id->clone(id);
-               
+
                this->method = load_method(this, type, vendor, EAP_PEER);
                if (this->method)
                {
@@ -337,14 +337,14 @@ static eap_payload_t* client_process_eap(private_eap_authenticator_t *this,
                        return eap_payload_create_nak(in->get_identifier(in));
                }
        }
-       
+
        type = this->method->get_type(this->method, &vendor);
-       
+
        if (this->method->process(this->method, in, &out) == NEED_MORE)
        {       /* client methods should never return SUCCESS */
                return out;
        }
-       
+
        if (vendor)
        {
                DBG1(DBG_IKE, "vendor specific EAP method %d-%d failed", type, vendor);
@@ -367,7 +367,7 @@ static bool verify_auth(private_eap_authenticator_t *this, message_t *message,
        identification_t *other_id;
        auth_cfg_t *auth;
        keymat_t *keymat;
-       
+
        auth_payload = (auth_payload_t*)message->get_payload(message,
                                                                                                                 AUTHENTICATION);
        if (!auth_payload)
@@ -388,7 +388,7 @@ static bool verify_auth(private_eap_authenticator_t *this, message_t *message,
                return FALSE;
        }
        chunk_free(&auth_data);
-       
+
        DBG1(DBG_IKE, "authentication of '%Y' with %N successful",
                 other_id, auth_class_names, AUTH_CLASS_EAP);
        this->auth_complete = TRUE;
@@ -407,13 +407,13 @@ static void build_auth(private_eap_authenticator_t *this, message_t *message,
        identification_t *my_id;
        chunk_t auth_data;
        keymat_t *keymat;
-       
+
        my_id = this->ike_sa->get_my_id(this->ike_sa);
        keymat = this->ike_sa->get_keymat(this->ike_sa);
-       
+
        DBG1(DBG_IKE, "authentication of '%Y' (myself) with %N",
                 my_id, auth_class_names, AUTH_CLASS_EAP);
-       
+
        auth_data = keymat->get_psk_sig(keymat, FALSE, init, nonce, this->msk, my_id);
        auth_payload = auth_payload_create();
        auth_payload->set_auth_method(auth_payload, AUTH_PSK);
@@ -429,7 +429,7 @@ static status_t process_server(private_eap_authenticator_t *this,
                                                           message_t *message)
 {
        eap_payload_t *eap_payload;
-       
+
        if (this->eap_complete)
        {
                if (!verify_auth(this, message, this->sent_nonce, this->received_init))
@@ -438,7 +438,7 @@ static status_t process_server(private_eap_authenticator_t *this,
                }
                return NEED_MORE;
        }
-       
+
        if (!this->method)
        {
                this->eap_payload = server_initiate_eap(this, TRUE);
@@ -465,7 +465,7 @@ static status_t build_server(private_eap_authenticator_t *this,
        if (this->eap_payload)
        {
                eap_code_t code;
-               
+
                code = this->eap_payload->get_code(this->eap_payload);
                message->add_payload(message, (payload_t*)this->eap_payload);
                this->eap_payload = NULL;
@@ -490,7 +490,7 @@ static status_t process_client(private_eap_authenticator_t *this,
                                                           message_t *message)
 {
        eap_payload_t *eap_payload;
-       
+
        if (this->eap_complete)
        {
                if (!verify_auth(this, message, this->sent_nonce, this->received_init))
@@ -499,7 +499,7 @@ static status_t process_client(private_eap_authenticator_t *this,
                }
                return SUCCESS;
        }
-       
+
        eap_payload = (eap_payload_t*)message->get_payload(message,
                                                                                                        EXTENSIBLE_AUTHENTICATION);
        if (eap_payload)
@@ -520,7 +520,7 @@ static status_t process_client(private_eap_authenticator_t *this,
                                eap_type_t type;
                                u_int32_t vendor;
                                auth_cfg_t *cfg;
-                               
+
                                if (this->method->get_msk(this->method, &this->msk) == SUCCESS)
                                {
                                        this->msk = chunk_clone(this->msk);
@@ -561,7 +561,7 @@ static status_t process_client(private_eap_authenticator_t *this,
 /**
  * Implementation of authenticator_t.build for a client
  */
-static status_t build_client(private_eap_authenticator_t *this,        
+static status_t build_client(private_eap_authenticator_t *this,
                                                         message_t *message)
 {
        if (this->eap_payload)
@@ -598,11 +598,11 @@ eap_authenticator_t *eap_authenticator_create_builder(ike_sa_t *ike_sa,
                                                                        chunk_t received_init, chunk_t sent_init)
 {
        private_eap_authenticator_t *this = malloc_thing(private_eap_authenticator_t);
-       
+
        this->public.authenticator.build = (status_t(*)(authenticator_t*, message_t *message))build_client;
        this->public.authenticator.process = (status_t(*)(authenticator_t*, message_t *message))process_client;
        this->public.authenticator.destroy = (void(*)(authenticator_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->received_init = received_init;
        this->received_nonce = received_nonce;
@@ -614,7 +614,7 @@ eap_authenticator_t *eap_authenticator_create_builder(ike_sa_t *ike_sa,
        this->eap_complete = FALSE;
        this->auth_complete = FALSE;
        this->eap_identity = NULL;
-       
+
        return &this->public;
 }
 
@@ -626,11 +626,11 @@ eap_authenticator_t *eap_authenticator_create_verifier(ike_sa_t *ike_sa,
                                                                        chunk_t received_init, chunk_t sent_init)
 {
        private_eap_authenticator_t *this = malloc_thing(private_eap_authenticator_t);
-       
+
        this->public.authenticator.build = (status_t(*)(authenticator_t*, message_t *messageh))build_server;
        this->public.authenticator.process = (status_t(*)(authenticator_t*, message_t *message))process_server;
        this->public.authenticator.destroy = (void(*)(authenticator_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->received_init = received_init;
        this->received_nonce = received_nonce;
@@ -642,7 +642,7 @@ eap_authenticator_t *eap_authenticator_create_verifier(ike_sa_t *ike_sa,
        this->eap_complete = FALSE;
        this->auth_complete = FALSE;
        this->eap_identity = NULL;
-       
+
        return &this->public;
 }
 
index b90a6f4df917849516dc1e88ed411311a00d1135..41eb6a8c900eb9b72a23db77dd5be2761591f9e5 100644 (file)
@@ -83,7 +83,7 @@ eap_authenticator_t *eap_authenticator_create_builder(ike_sa_t *ike_sa,
 
 /**
  * Create an authenticator to authenticate EAP clients.
- * 
+ *
  * @param ike_sa                       associated ike_sa
  * @param received_nonce       nonce received in IKE_SA_INIT
  * @param sent_nonce           nonce sent in IKE_SA_INIT
index 742b677895152189d699e68962fc74707c7c1423..83a4b22726fe0587ca6eac266c93a75fc0ba660f 100644 (file)
@@ -35,12 +35,12 @@ struct private_psk_authenticator_t {
         * Assigned IKE_SA
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * nonce to include in AUTH calculation
         */
        chunk_t nonce;
-       
+
        /**
         * IKE_SA_INIT message data to include in AUTH calculation
         */
@@ -57,7 +57,7 @@ static status_t build(private_psk_authenticator_t *this, message_t *message)
        shared_key_t *key;
        chunk_t auth_data;
        keymat_t *keymat;
-       
+
        keymat = this->ike_sa->get_keymat(this->ike_sa);
        my_id = this->ike_sa->get_my_id(this->ike_sa);
        other_id = this->ike_sa->get_other_id(this->ike_sa);
@@ -79,7 +79,7 @@ static status_t build(private_psk_authenticator_t *this, message_t *message)
        auth_payload->set_data(auth_payload, auth_data);
        chunk_free(&auth_data);
        message->add_payload(message, (payload_t*)auth_payload);
-       
+
        return SUCCESS;
 }
 
@@ -97,7 +97,7 @@ static status_t process(private_psk_authenticator_t *this, message_t *message)
        bool authenticated = FALSE;
        int keys_found = 0;
        keymat_t *keymat;
-       
+
        auth_payload = (auth_payload_t*)message->get_payload(message, AUTHENTICATION);
        if (!auth_payload)
        {
@@ -112,7 +112,7 @@ static status_t process(private_psk_authenticator_t *this, message_t *message)
        while (!authenticated && enumerator->enumerate(enumerator, &key, NULL, NULL))
        {
                keys_found++;
-               
+
                auth_data = keymat->get_psk_sig(keymat, TRUE, this->ike_sa_init,
                                                                        this->nonce, key->get_key(key), other_id);
                if (auth_data.len && chunk_equals(auth_data, recv_auth_data))
@@ -124,7 +124,7 @@ static status_t process(private_psk_authenticator_t *this, message_t *message)
                chunk_free(&auth_data);
        }
        enumerator->destroy(enumerator);
-       
+
        if (!authenticated)
        {
                if (keys_found == 0)
@@ -136,7 +136,7 @@ static status_t process(private_psk_authenticator_t *this, message_t *message)
                         keys_found, keys_found == 1 ? "" : "s", my_id, other_id);
                return FAILED;
        }
-       
+
        auth = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
        auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PSK);
        return SUCCESS;
@@ -166,15 +166,15 @@ psk_authenticator_t *psk_authenticator_create_builder(ike_sa_t *ike_sa,
                                                                        chunk_t received_nonce, chunk_t sent_init)
 {
        private_psk_authenticator_t *this = malloc_thing(private_psk_authenticator_t);
-       
+
        this->public.authenticator.build = (status_t(*)(authenticator_t*, message_t *message))build;
        this->public.authenticator.process = (status_t(*)(authenticator_t*, message_t *message))return_failed;
        this->public.authenticator.destroy = (void(*)(authenticator_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->ike_sa_init = sent_init;
        this->nonce = received_nonce;
-       
+
        return &this->public;
 }
 
@@ -185,15 +185,15 @@ psk_authenticator_t *psk_authenticator_create_verifier(ike_sa_t *ike_sa,
                                                                        chunk_t sent_nonce, chunk_t received_init)
 {
        private_psk_authenticator_t *this = malloc_thing(private_psk_authenticator_t);
-       
+
        this->public.authenticator.build = (status_t(*)(authenticator_t*, message_t *messageh))return_failed;
        this->public.authenticator.process = (status_t(*)(authenticator_t*, message_t *message))process;
        this->public.authenticator.destroy = (void(*)(authenticator_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->ike_sa_init = received_init;
        this->nonce = sent_nonce;
-       
+
        return &this->public;
 }
 
index 5bb743d935cec52e6c13e91bb44882a78981e74d..0fab1109505c2b34ab0c419787059df17e5e975f 100644 (file)
@@ -49,7 +49,7 @@ psk_authenticator_t *psk_authenticator_create_builder(ike_sa_t *ike_sa,
 
 /**
  * Create an authenticator to verify PSK signatures.
- * 
+ *
  * @param ike_sa                       associated ike_sa
  * @param sent_nonce           nonce sent in IKE_SA_INIT
  * @param received_init                received IKE_SA_INIT message data
index 44cabfb94c555614966eb9b10373378f891fc556..7e558db61685052c558a6d77d15640f2ac2e31c8 100644 (file)
@@ -26,22 +26,22 @@ typedef struct private_pubkey_authenticator_t private_pubkey_authenticator_t;
  * Private data of an pubkey_authenticator_t object.
  */
 struct private_pubkey_authenticator_t {
-       
+
        /**
         * Public authenticator_t interface.
         */
        pubkey_authenticator_t public;
-       
+
        /**
         * Assigned IKE_SA
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * nonce to include in AUTH calculation
         */
        chunk_t nonce;
-       
+
        /**
         * IKE_SA_INIT message data to include in AUTH calculation
         */
@@ -72,11 +72,11 @@ static status_t build(private_pubkey_authenticator_t *this, message_t *message)
                DBG1(DBG_IKE, "no private key found for '%Y'", id);
                return NOT_FOUND;
        }
-       
+
        switch (private->get_type(private))
        {
                case KEY_RSA:
-                       /* we currently use always SHA1 for signatures, 
+                       /* we currently use always SHA1 for signatures,
                         * TODO: support other hashes depending on configuration/auth */
                        scheme = SIGN_RSA_EMSA_PKCS1_SHA1;
                        auth_method = AUTH_RSA;
@@ -86,7 +86,7 @@ static status_t build(private_pubkey_authenticator_t *this, message_t *message)
                        switch (private->get_keysize(private))
                        {
                                case 32:
-                                       scheme = SIGN_ECDSA_256; 
+                                       scheme = SIGN_ECDSA_256;
                                        auth_method = AUTH_ECDSA_256;
                                        break;
                                case 48:
@@ -121,11 +121,11 @@ static status_t build(private_pubkey_authenticator_t *this, message_t *message)
                status = SUCCESS;
        }
        DBG1(DBG_IKE, "authentication of '%Y' (myself) with %N %s", id,
-                auth_method_names, auth_method, 
+                auth_method_names, auth_method,
                 (status == SUCCESS)? "successful":"failed");
        chunk_free(&octets);
        private->destroy(private);
-       
+
        return status;
 }
 
@@ -145,7 +145,7 @@ static status_t process(private_pubkey_authenticator_t *this, message_t *message
        signature_scheme_t scheme;
        status_t status = NOT_FOUND;
        keymat_t *keymat;
-       
+
        auth_payload = (auth_payload_t*)message->get_payload(message, AUTHENTICATION);
        if (!auth_payload)
        {
@@ -231,15 +231,15 @@ pubkey_authenticator_t *pubkey_authenticator_create_builder(ike_sa_t *ike_sa,
                                                                        chunk_t received_nonce, chunk_t sent_init)
 {
        private_pubkey_authenticator_t *this = malloc_thing(private_pubkey_authenticator_t);
-       
+
        this->public.authenticator.build = (status_t(*)(authenticator_t*, message_t *message))build;
        this->public.authenticator.process = (status_t(*)(authenticator_t*, message_t *message))return_failed;
        this->public.authenticator.destroy = (void(*)(authenticator_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->ike_sa_init = sent_init;
        this->nonce = received_nonce;
-       
+
        return &this->public;
 }
 
@@ -250,14 +250,14 @@ pubkey_authenticator_t *pubkey_authenticator_create_verifier(ike_sa_t *ike_sa,
                                                                        chunk_t sent_nonce, chunk_t received_init)
 {
        private_pubkey_authenticator_t *this = malloc_thing(private_pubkey_authenticator_t);
-       
+
        this->public.authenticator.build = (status_t(*)(authenticator_t*, message_t *message))return_failed;
        this->public.authenticator.process = (status_t(*)(authenticator_t*, message_t *message))process;
        this->public.authenticator.destroy = (void(*)(authenticator_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->ike_sa_init = received_init;
        this->nonce = sent_nonce;
-       
+
        return &this->public;
 }
index e67f020ff6e9ce7a400f436d34866e2a923e78f3..be369cb89b4c31ba53a970b938a43cdb7f99da34 100644 (file)
@@ -50,7 +50,7 @@ pubkey_authenticator_t *pubkey_authenticator_create_builder(ike_sa_t *ike_sa,
 
 /**
  * Create an authenticator to verify public key signatures.
- * 
+ *
  * @param ike_sa                       associated ike_sa
  * @param sent_nonce           nonce sent in IKE_SA_INIT
  * @param received_init                received IKE_SA_INIT message data
index a3dfeffa5596840b164d5ef5d711a3a4c0f35d22..1ea1befa2925a9cde57d9fe660fdac7579f81cae 100644 (file)
@@ -46,67 +46,67 @@ struct private_child_sa_t {
         * Public interface of child_sa_t.
         */
        child_sa_t public;
-       
+
        /**
         * address of us
         */
        host_t *my_addr;
-       
+
        /**
         * address of remote
         */
        host_t *other_addr;
-       
+
        /**
         * our actually used SPI, 0 if unused
         */
        u_int32_t my_spi;
-       
+
        /**
         * others used SPI, 0 if unused
         */
        u_int32_t other_spi;
-       
+
        /**
         * our Compression Parameter Index (CPI) used, 0 if unused
         */
        u_int16_t my_cpi;
-       
+
        /**
         * others Compression Parameter Index (CPI) used, 0 if unused
         */
        u_int16_t other_cpi;
-       
+
        /**
         * List for local traffic selectors
         */
        linked_list_t *my_ts;
-       
+
        /**
         * List for remote traffic selectors
         */
        linked_list_t *other_ts;
-       
+
        /**
         * Protocol used to protect this SA, ESP|AH
         */
        protocol_id_t protocol;
-       
+
        /**
         * reqid used for this child_sa
         */
        u_int32_t reqid;
-       
+
        /**
         * absolute time when rekeying is scheduled
         */
        time_t rekey_time;
-       
+
        /**
         * absolute time when the SA expires
         */
        time_t expire_time;
-       
+
        /**
         * state of the CHILD_SA
         */
@@ -116,22 +116,22 @@ struct private_child_sa_t {
         * Specifies if UDP encapsulation is enabled (NAT traversal)
         */
        bool encap;
-       
+
        /**
         * Specifies the IPComp transform used (IPCOMP_NONE if disabled)
         */
        ipcomp_transform_t ipcomp;
-       
+
        /**
         * mode this SA uses, tunnel/transport
         */
        ipsec_mode_t mode;
-       
+
        /**
         * selected proposal
         */
        proposal_t *proposal;
-       
+
        /**
         * config used to create this child
         */
@@ -320,7 +320,7 @@ static bool policy_enumerate(policy_enumerator_t *this,
                                 traffic_selector_t **my_out, traffic_selector_t **other_out)
 {
        traffic_selector_t *other_ts;
-       
+
        while (this->ts || this->mine->enumerate(this->mine, &this->ts))
        {
                if (!this->other->enumerate(this->other, &other_ts))
@@ -363,14 +363,14 @@ static void policy_destroy(policy_enumerator_t *this)
 static enumerator_t* create_policy_enumerator(private_child_sa_t *this)
 {
        policy_enumerator_t *e = malloc_thing(policy_enumerator_t);
-       
+
        e->public.enumerate = (void*)policy_enumerate;
        e->public.destroy = (void*)policy_destroy;
        e->mine = this->my_ts->create_enumerator(this->my_ts);
        e->other = this->other_ts->create_enumerator(this->other_ts);
        e->list = this->other_ts;
        e->ts = NULL;
-       
+
        return &e->public;
 }
 
@@ -384,7 +384,7 @@ static status_t update_usebytes(private_child_sa_t *this, bool inbound)
 {
        status_t status = FAILED;
        u_int64_t bytes;
-       
+
        if (inbound)
        {
                if (this->my_spi)
@@ -434,12 +434,12 @@ static void update_usetime(private_child_sa_t *this, bool inbound)
        enumerator_t *enumerator;
        traffic_selector_t *my_ts, *other_ts;
        u_int32_t last_use = 0;
-       
+
        enumerator = create_policy_enumerator(this);
        while (enumerator->enumerate(enumerator, &my_ts, &other_ts))
        {
                u_int32_t in, out, fwd;
-               
+
                if (inbound)
                {
                        if (charon->kernel_interface->query_policy(charon->kernel_interface,
@@ -552,7 +552,7 @@ static status_t install(private_child_sa_t *this, chunk_t encr, chunk_t integ,
        host_t *src, *dst;
        status_t status;
        bool update = FALSE;
-       
+
        /* now we have to decide which spi to use. Use self allocated, if "in",
         * or the one in the proposal, if not "in" (others). Additionally,
         * source and dest host switch depending on the role */
@@ -574,20 +574,20 @@ static status_t install(private_child_sa_t *this, chunk_t encr, chunk_t integ,
                this->other_spi = spi;
                this->other_cpi = cpi;
        }
-       
+
        DBG2(DBG_CHD, "adding %s %N SA", inbound ? "inbound" : "outbound",
                 protocol_id_names, this->protocol);
-       
+
        /* send SA down to the kernel */
        DBG2(DBG_CHD, "  SPI 0x%.8x, src %H dst %H", ntohl(spi), src, dst);
-       
+
        this->proposal->get_algorithm(this->proposal, ENCRYPTION_ALGORITHM,
                                                                  &enc_alg, &size);
        this->proposal->get_algorithm(this->proposal, INTEGRITY_ALGORITHM,
                                                                  &int_alg, &size);
-       
+
        lifetime = this->config->get_lifetime(this->config);
-       
+
        now = time_monotonic(NULL);
        if (lifetime->time.rekey)
        {
@@ -597,19 +597,19 @@ static status_t install(private_child_sa_t *this, chunk_t encr, chunk_t integ,
        {
                this->expire_time = now + lifetime->time.life;
        }
-       
+
        if (!lifetime->time.jitter && !inbound)
        {       /* avoid triggering multiple rekey events */
                lifetime->time.rekey = 0;
        }
-       
+
        status = charon->kernel_interface->add_sa(charon->kernel_interface,
                                src, dst, spi, this->protocol, this->reqid, lifetime,
                                enc_alg, encr, int_alg, integ, this->mode, this->ipcomp, cpi,
                                this->encap, update);
-       
+
        free(lifetime);
-       
+
        return status;
 }
 
@@ -623,7 +623,7 @@ static status_t add_policies(private_child_sa_t *this,
        traffic_selector_t *my_ts, *other_ts;
        status_t status = SUCCESS;
        bool routed = (this->state == CHILD_CREATED);
-       
+
        /* apply traffic selectors */
        enumerator = my_ts_list->create_enumerator(my_ts_list);
        while (enumerator->enumerate(enumerator, &my_ts))
@@ -637,7 +637,7 @@ static status_t add_policies(private_child_sa_t *this,
                this->other_ts->insert_last(this->other_ts, other_ts->clone(other_ts));
        }
        enumerator->destroy(enumerator);
-       
+
        if (this->config->install_policy(this->config))
        {
                /* enumerate pairs of traffic selectors */
@@ -649,7 +649,7 @@ static status_t add_policies(private_child_sa_t *this,
                                        this->my_addr, this->other_addr, my_ts, other_ts, POLICY_OUT,
                                        this->other_spi, this->protocol, this->reqid, this->mode,
                                        this->ipcomp, this->other_cpi, routed);
-                       
+
                        status |= charon->kernel_interface->add_policy(charon->kernel_interface,
                                        this->other_addr, this->my_addr, other_ts, my_ts, POLICY_IN,
                                        this->my_spi, this->protocol, this->reqid, this->mode,
@@ -661,7 +661,7 @@ static status_t add_policies(private_child_sa_t *this,
                                        this->my_spi, this->protocol, this->reqid, this->mode,
                                        this->ipcomp, this->my_cpi, routed);
                        }
-                       
+
                        if (status != SUCCESS)
                        {
                                break;
@@ -669,7 +669,7 @@ static status_t add_policies(private_child_sa_t *this,
                }
                enumerator->destroy(enumerator);
        }
-       
+
        if (status == SUCCESS && this->state == CHILD_CREATED)
        {       /* switch to routed state if no SAD entry set up */
                set_state(this, CHILD_ROUTED);
@@ -685,19 +685,19 @@ static status_t update(private_child_sa_t *this,  host_t *me, host_t *other,
 {
        child_sa_state_t old;
        bool transport_proxy_mode;
-       
+
        /* anything changed at all? */
        if (me->equals(me, this->my_addr) &&
                other->equals(other, this->other_addr) && this->encap == encap)
        {
                return SUCCESS;
        }
-       
+
        old = this->state;
        set_state(this, CHILD_UPDATING);
        transport_proxy_mode = this->config->use_proxy_mode(this->config) &&
                                                   this->mode == MODE_TRANSPORT;
-       
+
        if (!transport_proxy_mode)
        {
                /* update our (initator) SA */
@@ -712,7 +712,7 @@ static status_t update(private_child_sa_t *this,  host_t *me, host_t *other,
                                return NOT_SUPPORTED;
                        }
                }
-               
+
                /* update his (responder) SA */
                if (this->other_spi)
                {
@@ -726,7 +726,7 @@ static status_t update(private_child_sa_t *this,  host_t *me, host_t *other,
                        }
                }
        }
-       
+
        if (this->config->install_policy(this->config))
        {
                /* update policies */
@@ -735,7 +735,7 @@ static status_t update(private_child_sa_t *this,  host_t *me, host_t *other,
                {
                        enumerator_t *enumerator;
                        traffic_selector_t *my_ts, *other_ts;
-                       
+
                        /* always use high priorities, as hosts getting updated are INSTALLED */
                        enumerator = create_policy_enumerator(this);
                        while (enumerator->enumerate(enumerator, &my_ts, &other_ts))
@@ -750,7 +750,7 @@ static status_t update(private_child_sa_t *this,  host_t *me, host_t *other,
                                        charon->kernel_interface->del_policy(charon->kernel_interface,
                                                                                        other_ts, my_ts, POLICY_FWD, FALSE);
                                }
-                               
+
                                /* check whether we have to update a "dynamic" traffic selector */
                                if (!me->ip_equals(me, this->my_addr) &&
                                        my_ts->is_host(my_ts, this->my_addr))
@@ -762,7 +762,7 @@ static status_t update(private_child_sa_t *this,  host_t *me, host_t *other,
                                {
                                        other_ts->set_address(other_ts, other);
                                }
-                               
+
                                /* we reinstall the virtual IP to handle interface roaming
                                 * correctly */
                                if (vip)
@@ -770,7 +770,7 @@ static status_t update(private_child_sa_t *this,  host_t *me, host_t *other,
                                        charon->kernel_interface->del_ip(charon->kernel_interface, vip);
                                        charon->kernel_interface->add_ip(charon->kernel_interface, vip, me);
                                }
-                               
+
                                /* reinstall updated policies */
                                charon->kernel_interface->add_policy(charon->kernel_interface,
                                                me, other, my_ts, other_ts, POLICY_OUT, this->other_spi,
@@ -821,9 +821,9 @@ static void destroy(private_child_sa_t *this)
        enumerator_t *enumerator;
        traffic_selector_t *my_ts, *other_ts;
        bool unrouted = (this->state == CHILD_ROUTED);
-       
+
        set_state(this, CHILD_DESTROYING);
-       
+
        /* delete SAs in the kernel, if they are set up */
        if (this->my_spi)
        {
@@ -843,7 +843,7 @@ static void destroy(private_child_sa_t *this)
                                        this->my_addr, this->other_addr, this->other_spi,
                                        this->protocol, this->other_cpi);
        }
-       
+
        if (this->config->install_policy(this->config))
        {
                /* delete all policies in the kernel */
@@ -862,7 +862,7 @@ static void destroy(private_child_sa_t *this)
                }
                enumerator->destroy(enumerator);
        }
-       
+
        this->my_ts->destroy_offset(this->my_ts, offsetof(traffic_selector_t, destroy));
        this->other_ts->destroy_offset(this->other_ts, offsetof(traffic_selector_t, destroy));
        this->my_addr->destroy(this->my_addr);
@@ -908,7 +908,7 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
        this->public.get_traffic_selectors = (linked_list_t*(*)(child_sa_t*,bool))get_traffic_selectors;
        this->public.create_policy_enumerator = (enumerator_t*(*)(child_sa_t*))create_policy_enumerator;
        this->public.destroy = (void(*)(child_sa_t*))destroy;
-       
+
        /* private data */
        this->my_addr = me->clone(me);
        this->other_addr = other->clone(other);
@@ -934,7 +934,7 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
        this->expire_time = 0;
        this->config = config;
        config->get_ref(config);
-       
+
        /* MIPv6 proxy transport mode sets SA endpoints to TS hosts */
        if (config->get_mode(config) == MODE_TRANSPORT &&
            config->use_proxy_mode(config))
@@ -946,9 +946,9 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
                enumerator_t *enumerator;
                linked_list_t *my_ts_list, *other_ts_list;
                traffic_selector_t *my_ts, *other_ts;
-               
+
                this->mode = MODE_TRANSPORT;
-               
+
                my_ts_list = config->get_traffic_selectors(config, TRUE, NULL, me);
                enumerator = my_ts_list->create_enumerator(my_ts_list);
                if (enumerator->enumerate(enumerator, &my_ts))
@@ -969,7 +969,7 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
                }
                enumerator->destroy(enumerator);
                my_ts_list->destroy_offset(my_ts_list, offsetof(traffic_selector_t, destroy));
-               
+
                other_ts_list = config->get_traffic_selectors(config, FALSE, NULL, other);
                enumerator = other_ts_list->create_enumerator(other_ts_list);
                if (enumerator->enumerate(enumerator, &other_ts))
@@ -991,6 +991,6 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
                enumerator->destroy(enumerator);
                other_ts_list->destroy_offset(other_ts_list, offsetof(traffic_selector_t, destroy));
        }
-       
+
        return &this->public;
 }
index 3931d5186bb4faf448907dd78969b0ad2115c8fe..a45b4c3e44aa2e8bd57b0edcbac28f49c47a6544 100644 (file)
@@ -36,42 +36,42 @@ typedef struct child_sa_t child_sa_t;
  * States of a CHILD_SA
  */
 enum child_sa_state_t {
-       
+
        /**
         * Just created, uninstalled CHILD_SA
         */
        CHILD_CREATED,
-       
+
        /**
         * Installed SPD, but no SAD entries
         */
        CHILD_ROUTED,
-       
+
        /**
         * Installing an in-use CHILD_SA
         */
        CHILD_INSTALLING,
-       
+
        /**
         * Installed an in-use CHILD_SA
         */
        CHILD_INSTALLED,
-       
+
        /**
         * While updating hosts, in update_hosts()
         */
        CHILD_UPDATING,
-       
+
        /**
         * CHILD_SA which is rekeying
         */
        CHILD_REKEYING,
-       
+
        /**
         * CHILD_SA in progress of delete
         */
        CHILD_DELETING,
-       
+
        /**
         * CHILD_SA object gets destroyed
         */
@@ -102,14 +102,14 @@ extern enum_name_t *child_sa_state_names;
  * Once SAs are set up, policies can be added using add_policies.
  */
 struct child_sa_t {
-       
+
        /**
         * Get the name of the config this CHILD_SA uses.
         *
         * @return                      name
         */
        char* (*get_name) (child_sa_t *this);
-       
+
        /**
         * Get the reqid of the CHILD SA.
         *
@@ -119,28 +119,28 @@ struct child_sa_t {
         * @return                      reqid of the CHILD SA
         */
        u_int32_t (*get_reqid)(child_sa_t *this);
-       
+
        /**
         * Get the config used to set up this child sa.
         *
         * @return                      child_cfg
         */
        child_cfg_t* (*get_config) (child_sa_t *this);
-       
+
        /**
         * Get the state of the CHILD_SA.
         *
         * @return                      CHILD_SA state
         */
        child_sa_state_t (*get_state) (child_sa_t *this);
-       
+
        /**
         * Set the state of the CHILD_SA.
         *
         * @param state         state to set on CHILD_SA
         */
        void (*set_state) (child_sa_t *this, child_sa_state_t state);
-       
+
        /**
         * Get the SPI of this CHILD_SA.
         *
@@ -152,7 +152,7 @@ struct child_sa_t {
         * @return                      SPI of the CHILD SA
         */
        u_int32_t (*get_spi) (child_sa_t *this, bool inbound);
-       
+
        /**
         * Get the CPI of this CHILD_SA.
         *
@@ -171,63 +171,63 @@ struct child_sa_t {
         * @return                      AH | ESP
         */
        protocol_id_t (*get_protocol) (child_sa_t *this);
-       
+
        /**
         * Set the negotiated protocol to use for this CHILD_SA.
         *
         * @param protocol      AH | ESP
         */
        void (*set_protocol)(child_sa_t *this, protocol_id_t protocol);
-       
+
        /**
         * Get the IPsec mode of this CHILD_SA.
         *
         * @return                      TUNNEL | TRANSPORT | BEET
         */
        ipsec_mode_t (*get_mode)(child_sa_t *this);
-       
+
        /**
         * Set the negotiated IPsec mode to use.
         *
         * @param mode          TUNNEL | TRANPORT | BEET
         */
        void (*set_mode)(child_sa_t *this, ipsec_mode_t mode);
-       
+
        /**
         * Get the used IPComp algorithm.
         *
         * @return                      IPComp compression algorithm.
         */
        ipcomp_transform_t (*get_ipcomp)(child_sa_t *this);
-       
+
        /**
         * Set the IPComp algorithm to use.
         *
         * @param ipcomp        the IPComp transform to use
         */
        void (*set_ipcomp)(child_sa_t *this, ipcomp_transform_t ipcomp);
-       
+
        /**
         * Get the selected proposal.
         *
         * @return                      selected proposal
         */
        proposal_t* (*get_proposal)(child_sa_t *this);
-       
+
        /**
         * Set the negotiated proposal.
         *
         * @param proposal      selected proposal
         */
        void (*set_proposal)(child_sa_t *this, proposal_t *proposal);
-       
+
        /**
         * Check if this CHILD_SA uses UDP encapsulation.
         *
         * @return                      TRUE if SA encapsulates ESP packets
         */
        bool (*has_encap)(child_sa_t *this);
-       
+
        /**
         * Get the absolute time when the CHILD_SA expires or gets rekeyed.
         *
@@ -235,7 +235,7 @@ struct child_sa_t {
         * @return                      absolute time
         */
        time_t (*get_lifetime)(child_sa_t *this, bool hard);
-       
+
        /**
         * Get last use time and the number of bytes processed.
         *
@@ -245,7 +245,7 @@ struct child_sa_t {
         */
        void (*get_usestats)(child_sa_t *this, bool inbound, time_t *time,
                                                 u_int64_t *bytes);
-       
+
        /**
         * Get the traffic selectors list added for one side.
         *
@@ -253,14 +253,14 @@ struct child_sa_t {
         * @return                      list of traffic selectors
         */
        linked_list_t* (*get_traffic_selectors) (child_sa_t *this, bool local);
-       
+
        /**
         * Create an enumerator over installed policies.
         *
         * @return                      enumerator over pairs of traffic selectors.
         */
        enumerator_t* (*create_policy_enumerator)(child_sa_t *this);
-       
+
        /**
         * Allocate an SPI to include in a proposal.
         *
@@ -269,14 +269,14 @@ struct child_sa_t {
         * @return                      SPI, 0 on failure
         */
        u_int32_t (*alloc_spi)(child_sa_t *this, protocol_id_t protocol);
-       
+
        /**
         * Allocate a CPI to use for IPComp.
         *
         * @return                      CPI, 0 on failure
         */
        u_int16_t (*alloc_cpi)(child_sa_t *this);
-       
+
        /**
         * Install an IPsec SA for one direction.
         *
index f26cf9405564c54d1d13ca556cd349fb0722e87e..75a3242fcd168bc50a4dbc9f40b590db21a751b0 100644 (file)
@@ -53,22 +53,22 @@ struct private_connect_manager_t {
         * Public interface of connect_manager_t.
         */
         connect_manager_t public;
-       
+
         /**
          * Lock for exclusivly accessing the manager.
          */
         mutex_t *mutex;
-        
+
         /**
          * Hasher to generate signatures
          */
         hasher_t *hasher;
-        
+
         /**
          * Linked list with initiated mediated connections
          */
         linked_list_t *initiated;
-        
+
         /**
          * Linked list with checklists (hash table with connect ID as key would be better).
          */
@@ -93,22 +93,22 @@ typedef struct endpoint_pair_t endpoint_pair_t;
 struct endpoint_pair_t {
        /** pair id */
        u_int32_t id;
-       
+
        /** priority */
        u_int64_t priority;
-       
+
        /** local endpoint */
     host_t *local;
-    
+
     /** remote endpoint */
     host_t *remote;
-    
+
     /** state */
     check_state_t state;
-    
+
     /** number of retransmissions */
     u_int32_t retransmitted;
-    
+
     /** the generated packet */
     packet_t *packet;
 };
@@ -131,22 +131,22 @@ static endpoint_pair_t *endpoint_pair_create(endpoint_notify_t *initiator,
                endpoint_notify_t *responder, bool initiator_is_local)
 {
        endpoint_pair_t *this = malloc_thing(endpoint_pair_t);
-       
+
        this->id = 0;
-       
+
        u_int32_t pi = initiator->get_priority(initiator);
        u_int32_t pr = responder->get_priority(responder);
        this->priority = pow(2, 32) * min(pi, pr) + 2 * max(pi, pr) + (pi > pr ? 1 : 0);
-       
+
        this->local = initiator_is_local ? initiator->get_base(initiator) : responder->get_base(responder);
        this->local = this->local->clone(this->local);
        this->remote = initiator_is_local ? responder->get_host(responder) : initiator->get_host(initiator);
        this->remote = this->remote->clone(this->remote);
-       
+
        this->state = CHECK_WAITING;
        this->retransmitted = 0;
        this->packet = NULL;
-    
+
        return this;
 }
 
@@ -157,50 +157,50 @@ typedef struct check_list_t check_list_t;
  * An entry in the linked list.
  */
 struct check_list_t {
-       
+
        struct {
                /** initiator's id */
                identification_t *id;
-               
+
                /** initiator's key */
                chunk_t key;
-               
+
                /** initiator's endpoints */
                linked_list_t *endpoints;
        } initiator;
-       
+
        struct {
                /** responder's id */
                identification_t *id;
-               
+
                /** responder's key */
                chunk_t key;
-               
+
                /** responder's endpoints */
                linked_list_t *endpoints;
        } responder;
-       
+
        /** connect id */
        chunk_t connect_id;
-       
+
     /** list of endpoint pairs */
     linked_list_t *pairs;
-    
+
     /** pairs queued for triggered checks */
     linked_list_t *triggered;
-    
+
     /** state */
     check_state_t state;
-    
+
     /** TRUE if this is the initiator */
        bool is_initiator;
-       
+
        /** TRUE if the initiator is finishing the checks */
        bool is_finishing;
-       
+
        /** the current sender job */
        job_t *sender;
-       
+
 };
 
 /**
@@ -210,18 +210,18 @@ static void check_list_destroy(check_list_t *this)
 {
        DESTROY_IF(this->initiator.id);
        DESTROY_IF(this->responder.id);
-       
+
        chunk_free(&this->connect_id);
        chunk_free(&this->initiator.key);
        chunk_free(&this->responder.key);
-       
+
        DESTROY_OFFSET_IF(this->initiator.endpoints, offsetof(endpoint_notify_t, destroy));
        DESTROY_OFFSET_IF(this->responder.endpoints, offsetof(endpoint_notify_t, destroy));
-       
+
        DESTROY_FUNCTION_IF(this->pairs, (void*)endpoint_pair_destroy);
        /* this list contains some of the same elements as contained in this->pairs */
-       DESTROY_IF(this->triggered); 
-       
+       DESTROY_IF(this->triggered);
+
        free(this);
 }
 
@@ -233,23 +233,23 @@ static check_list_t *check_list_create(identification_t *initiator, identificati
                bool is_initiator)
 {
        check_list_t *this = malloc_thing(check_list_t);
-       
+
        this->connect_id = chunk_clone(connect_id);
-       
+
        this->initiator.id = initiator->clone(initiator);
        this->initiator.key = chunk_clone(initiator_key);
        this->initiator.endpoints = initiator_endpoints->clone_offset(initiator_endpoints, offsetof(endpoint_notify_t, clone));
-       
+
        this->responder.id = responder->clone(responder);
        this->responder.key = chunk_empty;
     this->responder.endpoints = NULL;
-    
+
     this->pairs = linked_list_create();
     this->triggered = linked_list_create();
     this->state = CHECK_NONE;
     this->is_initiator = is_initiator;
     this->is_finishing = FALSE;
-    
+
        return this;
 }
 
@@ -261,10 +261,10 @@ typedef struct initiated_t initiated_t;
 struct initiated_t {
        /** my id */
        identification_t *id;
-       
+
        /** peer id */
        identification_t *peer_id;
-       
+
        /** list of mediated sas */
        linked_list_t *mediated;
 };
@@ -286,11 +286,11 @@ static void initiated_destroy(initiated_t *this)
 static initiated_t *initiated_create(identification_t *id, identification_t *peer_id)
 {
        initiated_t *this = malloc_thing(initiated_t);
-       
+
        this->id = id->clone(id);
        this->peer_id = peer_id->clone(peer_id);
        this->mediated = linked_list_create();
-    
+
        return this;
 }
 
@@ -303,22 +303,22 @@ typedef struct check_t check_t;
 struct check_t {
        /** message id */
        u_int32_t mid;
-       
+
        /** source of the connectivity check */
        host_t *src;
-       
+
        /** destination of the connectivity check */
        host_t *dst;
-       
+
        /** connect id */
        chunk_t connect_id;
-       
+
        /** endpoint */
        endpoint_notify_t *endpoint;
-       
+
        /** raw endpoint payload (to verify the signature) */
        chunk_t endpoint_raw;
-       
+
     /** connect auth */
     chunk_t auth;
 };
@@ -343,16 +343,16 @@ static void check_destroy(check_t *this)
 static check_t *check_create()
 {
        check_t *this = malloc_thing(check_t);
-       
+
        this->connect_id = chunk_empty;
        this->auth = chunk_empty;
        this->endpoint_raw = chunk_empty;
        this->src = NULL;
        this->dst = NULL;
        this->endpoint = NULL;
-       
+
        this->mid = 0;
-       
+
        return this;
 }
 
@@ -364,10 +364,10 @@ typedef struct callback_data_t callback_data_t;
 struct callback_data_t {
        /** connect manager */
        private_connect_manager_t *connect_manager;
-       
+
        /** connect id */
        chunk_t connect_id;
-       
+
        /** message (pair) id */
        u_int32_t mid;
 };
@@ -387,7 +387,7 @@ static void callback_data_destroy(callback_data_t *this)
 static callback_data_t *callback_data_create(private_connect_manager_t *connect_manager,
                chunk_t connect_id)
 {
-       callback_data_t *this = malloc_thing(callback_data_t);  
+       callback_data_t *this = malloc_thing(callback_data_t);
        this->connect_manager = connect_manager;
        this->connect_id = chunk_clone(connect_id);
        this->mid = 0;
@@ -413,7 +413,7 @@ typedef struct initiate_data_t initiate_data_t;
 struct initiate_data_t {
        /** checklist */
        check_list_t *checklist;
-       
+
        /** waiting mediated connections */
        initiated_t *initiated;
 };
@@ -434,7 +434,7 @@ static void initiate_data_destroy(initiate_data_t *this)
 static initiate_data_t *initiate_data_create(check_list_t *checklist, initiated_t *initiated)
 {
        initiate_data_t *this = malloc_thing(initiate_data_t);
-       
+
        this->checklist = checklist;
        this->initiated = initiated;
 
@@ -465,7 +465,7 @@ static void remove_initiated(private_connect_manager_t *this, initiated_t *initi
 {
        iterator_t *iterator;
        initiated_t *current;
-       
+
        iterator = this->initiated->create_iterator(this->initiated, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
@@ -501,7 +501,7 @@ static void remove_checklist(private_connect_manager_t *this, check_list_t *chec
 {
        iterator_t *iterator;
        check_list_t *current;
-       
+
        iterator = this->checklists->create_iterator(this->checklists, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
@@ -537,7 +537,7 @@ static void insert_pair_by_priority(linked_list_t *pairs, endpoint_pair_t *pair)
        iterator_t *iterator;
        endpoint_pair_t *current;
        bool inserted = FALSE;
-       
+
        iterator = pairs->create_iterator(pairs, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
@@ -549,7 +549,7 @@ static void insert_pair_by_priority(linked_list_t *pairs, endpoint_pair_t *pair)
                }
        }
        iterator->destroy(iterator);
-       
+
        if (!inserted)
        {
                pairs->insert_last(pairs, pair);
@@ -592,7 +592,7 @@ static bool match_succeeded_pair(endpoint_pair_t *current)
 }
 
 /**
- * Returns the best pair of state CHECK_SUCCEEDED from a checklist. 
+ * Returns the best pair of state CHECK_SUCCEEDED from a checklist.
  */
 static status_t get_best_valid_pair(check_list_t *checklist, endpoint_pair_t **pair)
 {
@@ -607,19 +607,19 @@ static bool match_waiting_pair(endpoint_pair_t *current)
 }
 
 /**
- * Returns and *removes* the first triggered pair in state CHECK_WAITING. 
+ * Returns and *removes* the first triggered pair in state CHECK_WAITING.
  */
 static status_t get_triggered_pair(check_list_t *checklist, endpoint_pair_t **pair)
 {
        iterator_t *iterator;
        endpoint_pair_t *current;
        status_t status = NOT_FOUND;
-       
+
        iterator = checklist->triggered->create_iterator(checklist->triggered, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
                iterator->remove(iterator);
-               
+
                if (current->state == CHECK_WAITING)
                {
                        if (pair)
@@ -631,7 +631,7 @@ static status_t get_triggered_pair(check_list_t *checklist, endpoint_pair_t **pa
                }
        }
        iterator->destroy(iterator);
-       
+
        return status;
 }
 
@@ -642,7 +642,7 @@ static void print_checklist(check_list_t *checklist)
 {
        iterator_t *iterator;
        endpoint_pair_t *current;
-       
+
        DBG1(DBG_IKE, "pairs on checklist %#B:", &checklist->connect_id);
        iterator = checklist->pairs->create_iterator(checklist->pairs, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
@@ -662,20 +662,20 @@ static void prune_pairs(linked_list_t *pairs)
        iterator_t *iterator, *search;
        endpoint_pair_t *current, *other;
        u_int32_t id = 0;
-       
+
        iterator = pairs->create_iterator(pairs, TRUE);
        search = pairs->create_iterator(pairs, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
                current->id = ++id;
-               
+
                while (search->iterate(search, (void**)&other))
                {
                        if (current == other)
                        {
                                continue;
                        }
-                       
+
                        if (current->local->equals(current->local, other->local) &&
                                        current->remote->equals(current->remote, other->remote))
                        {
@@ -703,7 +703,7 @@ static void build_pairs(check_list_t *checklist)
        /* FIXME: limit endpoints and pairs */
        iterator_t *iterator_i, *iterator_r;
        endpoint_notify_t *initiator, *responder;
-       
+
        iterator_i = checklist->initiator.endpoints->create_iterator(checklist->initiator.endpoints, TRUE);
        while (iterator_i->iterate(iterator_i, (void**)&initiator))
        {
@@ -714,14 +714,14 @@ static void build_pairs(check_list_t *checklist)
                        {
                                continue;
                        }
-                       
+
                        insert_pair_by_priority(checklist->pairs,
                                        endpoint_pair_create(initiator, responder, checklist->is_initiator));
                }
                iterator_r->destroy(iterator_r);
        }
        iterator_i->destroy(iterator_i);
-       
+
        print_checklist(checklist);
 
        prune_pairs(checklist->pairs);
@@ -744,9 +744,9 @@ static status_t process_payloads(message_t *message, check_t *check)
                                        "connectivity check", payload_type_names, payload->get_type(payload));
                        continue;
                }
-               
+
                notify_payload_t *notify = (notify_payload_t*)payload;
-               
+
                switch (notify->get_notify_type(notify))
                {
                        case ME_ENDPOINT:
@@ -756,7 +756,7 @@ static status_t process_payloads(message_t *message, check_t *check)
                                        DBG1(DBG_IKE, "connectivity check contains multiple ME_ENDPOINT notifies");
                                        break;
                                }
-                               
+
                                endpoint_notify_t *endpoint = endpoint_notify_create_from_payload(notify);
                                if (!endpoint)
                                {
@@ -795,38 +795,38 @@ static status_t process_payloads(message_t *message, check_t *check)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        if (!check->connect_id.ptr || !check->endpoint || !check->auth.ptr)
        {
                DBG1(DBG_IKE, "at least one payload was missing from the connectivity check");
                return FAILED;
        }
-       
+
        return SUCCESS;
 }
 
 /**
  * Builds the signature for a connectivity check
  */
-static chunk_t build_signature(private_connect_manager_t *this, 
+static chunk_t build_signature(private_connect_manager_t *this,
                check_list_t *checklist, check_t *check, bool outbound)
 {
        u_int32_t mid;
        chunk_t mid_chunk, key_chunk, sig_chunk;
        chunk_t sig_hash;
-       
+
        mid = htonl(check->mid);
        mid_chunk = chunk_from_thing(mid);
-       
+
        key_chunk = (checklist->is_initiator && outbound) || (!checklist->is_initiator && !outbound)
                                        ? checklist->initiator.key : checklist->responder.key;
-       
+
        /* signature = SHA1( MID | ME_CONNECTID | ME_ENDPOINT | ME_CONNECTKEY ) */
        sig_chunk = chunk_cat("cccc", mid_chunk, check->connect_id, check->endpoint_raw, key_chunk);
        this->hasher->allocate_hash(this->hasher, sig_chunk, &sig_hash);
        DBG3(DBG_IKE, "sig_chunk %#B", &sig_chunk);
        DBG3(DBG_IKE, "sig_hash %#B", &sig_hash);
-       
+
        chunk_free(&sig_chunk);
        return sig_hash;
 }
@@ -837,7 +837,7 @@ static void finish_checks(private_connect_manager_t *this, check_list_t *checkli
 
 /**
  * After one of the initiator's pairs has succeeded we finish the checks without
- * waiting for all the timeouts  
+ * waiting for all the timeouts
  */
 static job_requeue_t initiator_finish(callback_data_t *data)
 {
@@ -853,11 +853,11 @@ static job_requeue_t initiator_finish(callback_data_t *data)
                this->mutex->unlock(this->mutex);
                return JOB_REQUEUE_NONE;
        }
-       
+
        finish_checks(this, checklist);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        return JOB_REQUEUE_NONE;
 }
 
@@ -891,7 +891,7 @@ static void update_checklist_state(private_connect_manager_t *this, check_list_t
                }
        }
        iterator->destroy(iterator);
-       
+
        if (checklist->is_initiator && succeeded && !checklist->is_finishing)
        {
                /* instead of waiting until all checks have finished (i.e. all
@@ -899,13 +899,13 @@ static void update_checklist_state(private_connect_manager_t *this, check_list_t
                 * right after the first check has succeeded. to allow a probably
                 * better pair to succeed, we still wait a certain time */
                DBG2(DBG_IKE, "fast finishing checks for checklist '%#B'", &checklist->connect_id);
-               
+
                callback_data_t *data = callback_data_create(this, checklist->connect_id);
                job_t *job = (job_t*)callback_job_create((callback_job_cb_t)initiator_finish, data, (callback_job_cleanup_t)callback_data_destroy, NULL);
                charon->scheduler->schedule_job_ms(charon->scheduler, job, ME_WAIT_TO_FINISH);
                checklist->is_finishing = TRUE;
        }
-       
+
        if (in_progress)
        {
                checklist->state = CHECK_IN_PROGRESS;
@@ -926,7 +926,7 @@ static void update_checklist_state(private_connect_manager_t *this, check_list_t
 static job_requeue_t retransmit(callback_data_t *data)
 {
        private_connect_manager_t *this = data->connect_manager;
-       
+
        this->mutex->lock(this->mutex);
 
        check_list_t *checklist;
@@ -937,7 +937,7 @@ static job_requeue_t retransmit(callback_data_t *data)
                this->mutex->unlock(this->mutex);
                return JOB_REQUEUE_NONE;
        }
-       
+
        endpoint_pair_t *pair;
        if (get_pair_by_id(checklist, data->mid, &pair) != SUCCESS)
        {
@@ -945,14 +945,14 @@ static job_requeue_t retransmit(callback_data_t *data)
                                data->mid);
                goto retransmit_end;
        }
-       
+
        if (pair->state != CHECK_IN_PROGRESS)
        {
                DBG2(DBG_IKE, "pair with id '%d' is in wrong state [%d], don't retransmit the connectivity check",
                                data->mid, pair->state);
                goto retransmit_end;
        }
-       
+
        if (++pair->retransmitted > ME_MAX_RETRANS)
        {
                DBG2(DBG_IKE, "pair with id '%d' failed after %d retransmissions",
@@ -960,14 +960,14 @@ static job_requeue_t retransmit(callback_data_t *data)
                pair->state = CHECK_FAILED;
                goto retransmit_end;
        }
-       
+
        charon->sender->send(charon->sender, pair->packet->clone(pair->packet));
-       
+
        queue_retransmission(this, checklist, pair);
 
 retransmit_end:
        update_checklist_state(this, checklist);
-       
+
        switch(checklist->state)
        {
                case CHECK_SUCCEEDED:
@@ -977,9 +977,9 @@ retransmit_end:
                default:
                        break;
        }
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        /* we reschedule it manually */
        return JOB_REQUEUE_NONE;
 }
@@ -991,7 +991,7 @@ static void queue_retransmission(private_connect_manager_t *this, check_list_t *
 {
        callback_data_t *data = retransmit_data_create(this, checklist->connect_id, pair->id);
        job_t *job = (job_t*)callback_job_create((callback_job_cb_t)retransmit, data, (callback_job_cleanup_t)callback_data_destroy, NULL);
-       
+
        u_int32_t retransmission = pair->retransmitted + 1;
        u_int32_t rto = ME_INTERVAL;
        if (retransmission > ME_BOOST)
@@ -999,7 +999,7 @@ static void queue_retransmission(private_connect_manager_t *this, check_list_t *
                rto = (u_int32_t)(ME_INTERVAL * pow(ME_RETRANS_BASE, retransmission - ME_BOOST));
        }
        DBG2(DBG_IKE, "scheduling retransmission %d of pair '%d' in %dms", retransmission, pair->id, rto);
-       
+
        charon->scheduler->schedule_job_ms(charon->scheduler, (job_t*)job, rto);
 }
 
@@ -1015,28 +1015,28 @@ static void send_check(private_connect_manager_t *this, check_list_t *checklist,
        message->set_request(message, request);
        message->set_destination(message, check->dst->clone(check->dst));
        message->set_source(message, check->src->clone(check->src));
-       
+
        ike_sa_id_t *ike_sa_id = ike_sa_id_create(0, 0, request);
        message->set_ike_sa_id(message, ike_sa_id);
        ike_sa_id->destroy(ike_sa_id);
 
        message->add_notify(message, FALSE, ME_CONNECTID, check->connect_id);
        DBG2(DBG_IKE, "send ME_CONNECTID %#B", &check->connect_id);
-       
+
        notify_payload_t *endpoint = check->endpoint->build_notify(check->endpoint);
        check->endpoint_raw = chunk_clone(endpoint->get_notification_data(endpoint));
        message->add_payload(message, (payload_t*)endpoint);
        DBG2(DBG_IKE, "send ME_ENDPOINT notify");
-       
+
        check->auth = build_signature(this, checklist, check, TRUE);
        message->add_notify(message, FALSE, ME_CONNECTAUTH, check->auth);
        DBG2(DBG_IKE, "send ME_CONNECTAUTH %#B", &check->auth);
-       
+
        packet_t *packet;
        if (message->generate(message, NULL, NULL, &packet) == SUCCESS)
        {
                charon->sender->send(charon->sender, packet->clone(packet));
-               
+
                if (request)
                {
                        DESTROY_IF(pair->packet);
@@ -1055,13 +1055,13 @@ static void send_check(private_connect_manager_t *this, check_list_t *checklist,
 /**
  * Queues a triggered check
  */
-static void queue_triggered_check(private_connect_manager_t *this, 
+static void queue_triggered_check(private_connect_manager_t *this,
                check_list_t *checklist, endpoint_pair_t *pair)
 {
        DBG2(DBG_IKE, "queueing triggered check for pair '%d'", pair->id);
        pair->state = CHECK_WAITING;
        checklist->triggered->insert_last(checklist->triggered, pair);
-       
+
        if (!checklist->sender)
        {
                /* if the sender is not running we restart it */
@@ -1077,7 +1077,7 @@ static job_requeue_t sender(callback_data_t *data)
        private_connect_manager_t *this = data->connect_manager;
 
        this->mutex->lock(this->mutex);
-       
+
        check_list_t *checklist;
        if (get_checklist_by_id(this, data->connect_id, &checklist) != SUCCESS)
        {
@@ -1086,15 +1086,15 @@ static job_requeue_t sender(callback_data_t *data)
                this->mutex->unlock(this->mutex);
                return JOB_REQUEUE_NONE;
        }
-       
+
        /* reset the sender */
        checklist->sender = NULL;
-       
+
        endpoint_pair_t *pair;
        if (get_triggered_pair(checklist, &pair) != SUCCESS)
        {
                DBG1(DBG_IKE, "no triggered check queued, sending an ordinary check");
-               
+
                if (checklist->pairs->find_first(checklist->pairs,
                                (linked_list_match_t)match_waiting_pair, (void**)&pair) != SUCCESS)
                {
@@ -1114,18 +1114,18 @@ static job_requeue_t sender(callback_data_t *data)
        check->dst = pair->remote->clone(pair->remote);
        check->connect_id = chunk_clone(checklist->connect_id);
        check->endpoint = endpoint_notify_create();
-       
+
        pair->state = CHECK_IN_PROGRESS;
-       
+
        send_check(this, checklist, check, pair, TRUE);
-       
+
        check_destroy(check);
-       
+
        /* schedule this job again */
        schedule_checks(this, checklist, ME_INTERVAL);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        /* we reschedule it manually */
        return JOB_REQUEUE_NONE;
 }
@@ -1147,7 +1147,7 @@ static job_requeue_t initiate_mediated(initiate_data_t *data)
 {
        check_list_t *checklist = data->checklist;
        initiated_t *initiated = data->initiated;
-       
+
        endpoint_pair_t *pair;
        if (get_best_valid_pair(checklist, &pair) == SUCCESS)
        {
@@ -1169,7 +1169,7 @@ static job_requeue_t initiate_mediated(initiate_data_t *data)
        {
                /* this should (can?) not happen */
        }
-       
+
        return JOB_REQUEUE_NONE;
 }
 
@@ -1186,7 +1186,7 @@ static void finish_checks(private_connect_manager_t *this, check_list_t *checkli
                {
                        remove_checklist(this, checklist);
                        remove_initiated(this, initiated);
-                       
+
                        initiate_data_t *data = initiate_data_create(checklist, initiated);
                        job_t *job = (job_t*)callback_job_create((callback_job_cb_t)initiate_mediated, data, (callback_job_cleanup_t)initiate_data_destroy, NULL);
                        charon->processor->queue_job(charon->processor, job);
@@ -1216,10 +1216,10 @@ static void process_response(private_connect_manager_t *this, check_t *check,
                                        pair->local, pair->remote);
                        pair->state = CHECK_SUCCEEDED;
                }
-               
+
                linked_list_t *local_endpoints = checklist->is_initiator ?
                        checklist->initiator.endpoints : checklist->responder.endpoints;
-               
+
                endpoint_notify_t *local_endpoint;
                if (endpoints_contain(local_endpoints,
                                check->endpoint->get_host(check->endpoint), &local_endpoint) != SUCCESS)
@@ -1229,9 +1229,9 @@ static void process_response(private_connect_manager_t *this, check_t *check,
                        local_endpoint->set_priority(local_endpoint, check->endpoint->get_priority(check->endpoint));
                        local_endpoints->insert_last(local_endpoints, local_endpoint);
                }
-               
+
                update_checklist_state(this, checklist);
-               
+
                switch(checklist->state)
                {
                        case CHECK_SUCCEEDED:
@@ -1253,17 +1253,17 @@ static void process_request(private_connect_manager_t *this, check_t *check,
 {
        linked_list_t *remote_endpoints = checklist->is_initiator ?
                                checklist->responder.endpoints : checklist->initiator.endpoints;
-               
+
        endpoint_notify_t *peer_reflexive, *remote_endpoint;
        peer_reflexive = endpoint_notify_create_from_host(PEER_REFLEXIVE, check->src, NULL);
        peer_reflexive->set_priority(peer_reflexive, check->endpoint->get_priority(check->endpoint));
-               
+
        if (endpoints_contain(remote_endpoints, check->src, &remote_endpoint) != SUCCESS)
        {
                remote_endpoint = peer_reflexive->clone(peer_reflexive);
                remote_endpoints->insert_last(remote_endpoints, remote_endpoint);
        }
-       
+
        endpoint_pair_t *pair;
        if (get_pair_by_hosts(checklist->pairs, check->dst, check->src, &pair) == SUCCESS)
        {
@@ -1286,31 +1286,31 @@ static void process_request(private_connect_manager_t *this, check_t *check,
        else
        {
                endpoint_notify_t *local_endpoint = endpoint_notify_create_from_host(HOST, check->dst, NULL);
-               
+
                endpoint_notify_t *initiator = checklist->is_initiator ? local_endpoint : remote_endpoint;
                endpoint_notify_t *responder = checklist->is_initiator ? remote_endpoint : local_endpoint;
-               
+
                pair = endpoint_pair_create(initiator, responder, checklist->is_initiator);
                pair->id = checklist->pairs->get_count(checklist->pairs) + 1;
-               
+
                insert_pair_by_priority(checklist->pairs, pair);
-               
+
                queue_triggered_check(this, checklist, pair);
-               
+
                local_endpoint->destroy(local_endpoint);
        }
-       
-       
+
+
        check_t *response = check_create();
-       
+
        response->mid = check->mid;
        response->src = check->dst->clone(check->dst);
        response->dst = check->src->clone(check->src);
        response->connect_id = chunk_clone(check->connect_id);
        response->endpoint = peer_reflexive;
-       
+
        send_check(this, checklist, response, pair, FALSE);
-       
+
        check_destroy(response);
 }
 
@@ -1327,14 +1327,14 @@ static void process_check(private_connect_manager_t *this, message_t *message)
                         message->get_message_id(message));
                return;
        }
-       
+
        check_t *check = check_create();
        check->mid = message->get_message_id(message);
        check->src = message->get_source(message);
        check->src = check->src->clone(check->src);
        check->dst = message->get_destination(message);
        check->dst = check->dst->clone(check->dst);
-       
+
        if (process_payloads(message, check) != SUCCESS)
        {
                DBG1(DBG_IKE, "invalid connectivity check %s received",
@@ -1342,9 +1342,9 @@ static void process_check(private_connect_manager_t *this, message_t *message)
                check_destroy(check);
                return;
        }
-       
+
        this->mutex->lock(this->mutex);
-       
+
        check_list_t *checklist;
        if (get_checklist_by_id(this, check->connect_id, &checklist) != SUCCESS)
        {
@@ -1354,8 +1354,8 @@ static void process_check(private_connect_manager_t *this, message_t *message)
                this->mutex->unlock(this->mutex);
                return;
        }
-       
-       chunk_t sig = build_signature(this, checklist, check, FALSE); 
+
+       chunk_t sig = build_signature(this, checklist, check, FALSE);
        if (!chunk_equals(sig, check->auth))
        {
                DBG1(DBG_IKE, "connectivity check verification failed");
@@ -1365,7 +1365,7 @@ static void process_check(private_connect_manager_t *this, message_t *message)
                return;
        }
        chunk_free(&sig);
-       
+
        if (message->get_request(message))
        {
                process_request(this, check, checklist);
@@ -1374,9 +1374,9 @@ static void process_check(private_connect_manager_t *this, message_t *message)
        {
                process_response(this, check, checklist);
        }
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        check_destroy(check);
 }
 
@@ -1399,8 +1399,8 @@ static bool check_and_register(private_connect_manager_t *this,
                this->initiated->insert_last(this->initiated, initiated);
                already_there = FALSE;
        }
-       
-       if (initiated->mediated->find_first(initiated->mediated, 
+
+       if (initiated->mediated->find_first(initiated->mediated,
                        (linked_list_match_t)mediated_sa->equals, NULL, mediated_sa) != SUCCESS)
        {
                initiated->mediated->insert_last(initiated->mediated, mediated_sa->clone(mediated_sa));
@@ -1427,7 +1427,7 @@ static void check_and_initiate(private_connect_manager_t *this, ike_sa_id_t *med
                this->mutex->unlock(this->mutex);
                return;
        }
-       
+
        ike_sa_id_t *waiting_sa;
        iterator_t *iterator = initiated->mediated->create_iterator(initiated->mediated, TRUE);
        while (iterator->iterate(iterator, (void**)&waiting_sa))
@@ -1448,9 +1448,9 @@ static status_t set_initiator_data(private_connect_manager_t *this,
                chunk_t connect_id, chunk_t key, linked_list_t *endpoints, bool is_initiator)
 {
        check_list_t *checklist;
-       
-       this->mutex->lock(this->mutex); 
-       
+
+       this->mutex->lock(this->mutex);
+
        if (get_checklist_by_id(this, connect_id, NULL) == SUCCESS)
        {
                DBG1(DBG_IKE, "checklist with id '%#B' already exists, aborting",
@@ -1458,12 +1458,12 @@ static status_t set_initiator_data(private_connect_manager_t *this,
                this->mutex->unlock(this->mutex);
                return FAILED;
        }
-       
+
        checklist = check_list_create(initiator, responder, connect_id, key, endpoints, is_initiator);
        this->checklists->insert_last(this->checklists, checklist);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        return SUCCESS;
 }
 
@@ -1476,7 +1476,7 @@ static status_t set_responder_data(private_connect_manager_t *this,
        check_list_t *checklist;
 
        this->mutex->lock(this->mutex);
-       
+
        if (get_checklist_by_id(this, connect_id, &checklist) != SUCCESS)
        {
                DBG1(DBG_IKE, "checklist with id '%#B' not found",
@@ -1484,18 +1484,18 @@ static status_t set_responder_data(private_connect_manager_t *this,
                this->mutex->unlock(this->mutex);
                return NOT_FOUND;
        }
-       
+
        checklist->responder.key = chunk_clone(key);
        checklist->responder.endpoints = endpoints->clone_offset(endpoints, offsetof(endpoint_notify_t, clone));
        checklist->state = CHECK_WAITING;
-       
+
        build_pairs(checklist);
-       
+
        /* send the first check immediately */
        schedule_checks(this, checklist, 0);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        return SUCCESS;
 }
 
@@ -1507,7 +1507,7 @@ static status_t stop_checks(private_connect_manager_t *this, chunk_t connect_id)
        check_list_t *checklist;
 
        this->mutex->lock(this->mutex);
-       
+
        if (get_checklist_by_id(this, connect_id, &checklist) != SUCCESS)
        {
                DBG1(DBG_IKE, "checklist with id '%#B' not found",
@@ -1515,14 +1515,14 @@ static status_t stop_checks(private_connect_manager_t *this, chunk_t connect_id)
                this->mutex->unlock(this->mutex);
                return NOT_FOUND;
        }
-       
+
        DBG1(DBG_IKE, "removing checklist with id '%#B'", &connect_id);
-       
+
        remove_checklist(this, checklist);
        check_list_destroy(checklist);
-       
+
        this->mutex->unlock(this->mutex);
-       
+
        return SUCCESS;
 }
 
@@ -1532,12 +1532,12 @@ static status_t stop_checks(private_connect_manager_t *this, chunk_t connect_id)
 static void destroy(private_connect_manager_t *this)
 {
        this->mutex->lock(this->mutex);
-       
+
        this->hasher->destroy(this->hasher);
        this->checklists->destroy_function(this->checklists, (void*)check_list_destroy);
        this->initiated->destroy_function(this->initiated, (void*)initiated_destroy);
-       
-       this->mutex->unlock(this->mutex);       
+
+       this->mutex->unlock(this->mutex);
        this->mutex->destroy(this->mutex);
        free(this);
 }
@@ -1556,7 +1556,7 @@ connect_manager_t *connect_manager_create()
        this->public.set_responder_data = (status_t(*)(connect_manager_t*,chunk_t,chunk_t,linked_list_t*))set_responder_data;
        this->public.process_check = (void(*)(connect_manager_t*,message_t*))process_check;
        this->public.stop_checks = (status_t(*)(connect_manager_t*,chunk_t))stop_checks;
-       
+
        this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (this->hasher == NULL)
        {
@@ -1564,11 +1564,11 @@ connect_manager_t *connect_manager_create()
                free(this);
                return NULL;
        }
-       
+
        this->checklists = linked_list_create();
        this->initiated = linked_list_create();
-       
+
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
-       
+
        return (connect_manager_t*)this;
 }
index b5abc853c7d49b0c7df0182d3a279814928b1452..d21b5af28519793a1f342cc6af9bd216db79d862 100644 (file)
@@ -32,34 +32,34 @@ typedef struct connect_manager_t connect_manager_t;
  * connection with another peer.
  */
 struct connect_manager_t {
-       
+
        /**
         * Checks if a there is already a mediated connection registered
         * between two peers.
-        * 
+        *
         * @param id                            my id
         * @param peer_id                       the other peer's id
         * @param mediated_sa           the IKE_SA ID of the mediated connection
-        * @returns                             
+        * @returns
         *                                                      - TRUE, if there was already a mediated connection registered
         *                                                      - FALSE, otherwise
         */
        bool (*check_and_register) (connect_manager_t *this,
                        identification_t *id, identification_t *peer_id, ike_sa_id_t *mediated_sa);
-       
+
        /**
         * Checks if there are waiting connections with a specific peer.
         * If so, reinitiate them.
-        * 
+        *
         * @param id                            my id
         * @param peer_id                       the other peer's id
         */
        void (*check_and_initiate) (connect_manager_t *this, ike_sa_id_t *mediation_sa,
                        identification_t *id, identification_t *peer_id);
-       
+
        /**
         * Creates a checklist and sets the initiator's data.
-        * 
+        *
         * @param initiator                     ID of the initiator
         * @param responder                     ID of the responder
         * @param connect_id            the connect ID provided by the initiator
@@ -72,39 +72,39 @@ struct connect_manager_t {
        status_t (*set_initiator_data) (connect_manager_t *this,
                identification_t *initiator, identification_t *responder,
                chunk_t connect_id, chunk_t key, linked_list_t *endpoints, bool is_initiator);
-       
+
        /**
         * Updates a checklist and sets the responder's data. The checklist's
         * state is advanced to WAITING which means that checks will be sent.
-        * 
+        *
         * @param connect_id            the connect ID
         * @param chunk_t                       the responder's key
-        * @param endpoints                     the responder's endpoints 
-        * @returns                             
+        * @param endpoints                     the responder's endpoints
+        * @returns
         *                                                      - NOT_FOUND, if the checklist has not been found
         *                                                      - SUCCESS, otherwise
         */
        status_t (*set_responder_data) (connect_manager_t *this,
                chunk_t connect_id, chunk_t key, linked_list_t *endpoints);
-       
+
        /**
         * Stops checks for a checklist. Used after the responder received an IKE_SA_INIT
         * request which contains a ME_CONNECTID payload.
-        * 
+        *
         * @param connect_id            the connect ID
         * @returns
         *                                                      - NOT_FOUND, if the checklist has not been found
         *                                                      - SUCCESS, otherwise
         */
        status_t (*stop_checks) (connect_manager_t *this, chunk_t connect_id);
-       
+
        /**
         * Processes a connectivity check
-        * 
+        *
         * @param message                       the received message
         */
        void (*process_check) (connect_manager_t *this, message_t *message);
-       
+
        /**
         * Destroys the manager with all data.
         */
@@ -113,7 +113,7 @@ struct connect_manager_t {
 
 /**
  * Create a manager.
- * 
+ *
  * @returns    connect_manager_t object
  */
 connect_manager_t *connect_manager_create(void);
index e54a331d28f1b31d8cc196edc48e3b275d301473..157031dbec3409cf2d4cf7bfc9b15bd1dc058e06 100644 (file)
@@ -71,169 +71,169 @@ typedef struct attribute_entry_t attribute_entry_t;
  * Private data of an ike_sa_t object.
  */
 struct private_ike_sa_t {
-       
+
        /**
         * Public members
         */
        ike_sa_t public;
-       
+
        /**
         * Identifier for the current IKE_SA.
         */
        ike_sa_id_t *ike_sa_id;
-       
+
        /**
         * unique numerical ID for this IKE_SA.
         */
        u_int32_t unique_id;
-       
+
        /**
         * Current state of the IKE_SA
         */
        ike_sa_state_t state;
-       
+
        /**
         * IKE configuration used to set up this IKE_SA
         */
        ike_cfg_t *ike_cfg;
-       
+
        /**
         * Peer and authentication information to establish IKE_SA.
         */
        peer_cfg_t *peer_cfg;
-       
+
        /**
         * currently used authentication ruleset, local (as auth_cfg_t)
         */
        auth_cfg_t *my_auth;
-       
+
        /**
         * currently used authentication constraints, remote (as auth_cfg_t)
         */
        auth_cfg_t *other_auth;
-       
+
        /**
         * Selected IKE proposal
         */
        proposal_t *proposal;
-       
+
        /**
         * Juggles tasks to process messages
         */
        task_manager_t *task_manager;
-       
+
        /**
         * Address of local host
         */
        host_t *my_host;
-       
+
        /**
         * Address of remote host
         */
        host_t *other_host;
-       
+
 #ifdef ME
        /**
         * Are we mediation server
         */
        bool is_mediation_server;
-       
+
        /**
         * Server reflexive host
         */
        host_t *server_reflexive_host;
-       
+
        /**
         * Connect ID
         */
        chunk_t connect_id;
 #endif /* ME */
-       
+
        /**
         * Identification used for us
         */
        identification_t *my_id;
-       
+
        /**
         * Identification used for other
         */
        identification_t *other_id;
-       
+
        /**
         * EAP Identity exchange in EAP-Identity method
         */
        identification_t *eap_identity;;
-       
+
        /**
         * set of extensions the peer supports
         */
        ike_extension_t extensions;
-       
+
        /**
         * set of condition flags currently enabled for this IKE_SA
         */
        ike_condition_t conditions;
-       
+
        /**
         * Linked List containing the child sa's of the current IKE_SA.
         */
        linked_list_t *child_sas;
-       
+
        /**
         * keymat of this IKE_SA
         */
        keymat_t *keymat;
-       
+
        /**
         * Virtual IP on local host, if any
         */
        host_t *my_virtual_ip;
-       
+
        /**
         * Virtual IP on remote host, if any
         */
        host_t *other_virtual_ip;
-       
+
        /**
         * List of configuration attributes (attribute_entry_t)
         */
        linked_list_t *attributes;
-       
+
        /**
         * list of peers additional addresses, transmitted via MOBIKE
         */
        linked_list_t *additional_addresses;
-       
+
        /**
         * previously value of received DESTINATION_IP hash
         */
        chunk_t nat_detection_dest;
-       
+
        /**
         * number pending UPDATE_SA_ADDRESS (MOBIKE)
         */
        u_int32_t pending_updates;
-       
+
        /**
         * NAT keep alive interval
         */
        u_int32_t keepalive_interval;
-       
+
        /**
         * Timestamps for this IKE_SA
         */
        u_int32_t stats[STAT_MAX];
-       
+
        /**
         * how many times we have retried so far (keyingtries)
         */
        u_int32_t keyingtry;
-       
+
        /**
         * local host address to be used for IKE, set via MIGRATE kernel message
         */
        host_t *local_host;
-       
+
        /**
         * remote host address to be used for IKE, set via MIGRATE kernel message
         */
@@ -260,7 +260,7 @@ static time_t get_use_time(private_ike_sa_t* this, bool inbound)
        enumerator_t *enumerator;
        child_sa_t *child_sa;
        time_t use_time, current;
-       
+
        if (inbound)
        {
                use_time = this->stats[STAT_INBOUND];
@@ -276,7 +276,7 @@ static time_t get_use_time(private_ike_sa_t* this, bool inbound)
                use_time = max(use_time, current);
        }
        enumerator->destroy(enumerator);
-       
+
        return use_time;
 }
 
@@ -362,7 +362,7 @@ static void set_peer_cfg(private_ike_sa_t *this, peer_cfg_t *peer_cfg)
        DESTROY_IF(this->peer_cfg);
        peer_cfg->get_ref(peer_cfg);
        this->peer_cfg = peer_cfg;
-       
+
        if (this->ike_cfg == NULL)
        {
                this->ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
@@ -421,22 +421,22 @@ static void send_keepalive(private_ike_sa_t *this)
 {
        send_keepalive_job_t *job;
        time_t last_out, now, diff;
-       
+
        if (!(this->conditions & COND_NAT_HERE) || this->keepalive_interval == 0)
        {       /* disable keep alives if we are not NATed anymore */
                return;
        }
-       
+
        last_out = get_use_time(this, FALSE);
        now = time_monotonic(NULL);
-       
+
        diff = now - last_out;
-       
+
        if (diff >= this->keepalive_interval)
        {
                packet_t *packet;
                chunk_t data;
-               
+
                packet = packet_create();
                packet->set_source(packet, this->my_host->clone(this->my_host));
                packet->set_destination(packet, this->other_host->clone(this->other_host));
@@ -551,15 +551,15 @@ static status_t send_dpd(private_ike_sa_t *this)
 {
        job_t *job;
        time_t diff, delay;
-       
+
        delay = this->peer_cfg->get_dpd(this->peer_cfg);
-       
+
        if (delay == 0)
        {
                /* DPD disabled */
                return SUCCESS;
        }
-       
+
        if (this->task_manager->busy(this->task_manager))
        {
                /* an exchange is in the air, no need to start a DPD check */
@@ -577,7 +577,7 @@ static status_t send_dpd(private_ike_sa_t *this)
                        /* to long ago, initiate dead peer detection */
                        task_t *task;
                        ike_mobike_t *mobike;
-                       
+
                        if (supports_extension(this, EXT_MOBIKE) &&
                                has_condition(this, COND_NAT_HERE))
                        {
@@ -592,7 +592,7 @@ static status_t send_dpd(private_ike_sa_t *this)
                        }
                        diff = 0;
                        DBG1(DBG_IKE, "sending DPD request");
-                       
+
                        this->task_manager->queue_task(this->task_manager, task);
                        this->task_manager->initiate(this->task_manager);
                }
@@ -620,7 +620,7 @@ static void set_state(private_ike_sa_t *this, ike_sa_state_t state)
                 get_name(this), this->unique_id,
                 ike_sa_state_names, this->state,
                 ike_sa_state_names, state);
-       
+
        switch (state)
        {
                case IKE_ESTABLISHED:
@@ -630,10 +630,10 @@ static void set_state(private_ike_sa_t *this, ike_sa_state_t state)
                        {
                                job_t *job;
                                u_int32_t t;
-                       
+
                                /* calculate rekey, reauth and lifetime */
                                this->stats[STAT_ESTABLISHED] = time_monotonic(NULL);
-                               
+
                                /* schedule rekeying if we have a time which is smaller than
                                 * an already scheduled rekeying */
                                t = this->peer_cfg->get_rekey_time(this->peer_cfg);
@@ -676,7 +676,7 @@ static void set_state(private_ike_sa_t *this, ike_sa_state_t state)
                                        charon->scheduler->schedule_job(charon->scheduler, job, t);
                                        DBG1(DBG_IKE, "maximum IKE_SA lifetime %ds", t);
                                }
-                               
+
                                /* start DPD checks */
                                send_dpd(this);
                        }
@@ -707,9 +707,9 @@ static void reset(private_ike_sa_t *this)
        {
                this->ike_sa_id->set_responder_spi(this->ike_sa_id, 0);
        }
-       
+
        set_state(this, IKE_CREATED);
-       
+
        this->task_manager->reset(this->task_manager, 0, 0);
 }
 
@@ -776,7 +776,7 @@ static void add_additional_address(private_ike_sa_t *this, host_t *host)
 {
        this->additional_addresses->insert_last(this->additional_addresses, host);
 }
-       
+
 /**
  * Implementation of ike_sa_t.create_additional_address_iterator.
  */
@@ -827,7 +827,7 @@ static u_int32_t get_pending_updates(private_ike_sa_t *this)
 static void update_hosts(private_ike_sa_t *this, host_t *me, host_t *other)
 {
        bool update = FALSE;
-       
+
        if (me == NULL)
        {
                me = this->my_host;
@@ -836,7 +836,7 @@ static void update_hosts(private_ike_sa_t *this, host_t *me, host_t *other)
        {
                other = this->other_host;
        }
-       
+
        /* apply hosts on first received message */
        if (this->my_host->is_anyaddr(this->my_host) ||
                this->other_host->is_anyaddr(this->other_host))
@@ -853,7 +853,7 @@ static void update_hosts(private_ike_sa_t *this, host_t *me, host_t *other)
                        set_my_host(this, me->clone(me));
                        update = TRUE;
                }
-               
+
                if (!other->equals(other, this->other_host))
                {
                        /* update others adress if we are NOT NATed,
@@ -866,13 +866,13 @@ static void update_hosts(private_ike_sa_t *this, host_t *me, host_t *other)
                        }
                }
        }
-       
+
        /* update all associated CHILD_SAs, if required */
        if (update)
        {
                iterator_t *iterator;
                child_sa_t *child_sa;
-       
+
                iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
                while (iterator->iterate(iterator, (void**)&child_sa))
                {
@@ -910,7 +910,7 @@ static void send_notify_response(private_ike_sa_t *this, message_t *request,
 {
        message_t *response;
        packet_t *packet;
-       
+
        response = message_create();
        response->set_exchange_type(response, request->get_exchange_type(request));
        response->set_request(response, FALSE);
@@ -1052,7 +1052,7 @@ static status_t initiate_mediated(private_ike_sa_t *this, host_t *me,
 static void resolve_hosts(private_ike_sa_t *this)
 {
        host_t *host;
-       
+
        if (this->remote_host)
        {
                host = this->remote_host->clone(this->remote_host);
@@ -1067,7 +1067,7 @@ static void resolve_hosts(private_ike_sa_t *this)
        {
                set_other_host(this, host);
        }
-       
+
        if (this->local_host)
        {
                host = this->local_host->clone(this->local_host);
@@ -1078,7 +1078,7 @@ static void resolve_hosts(private_ike_sa_t *this)
                host = host_create_from_dns(this->ike_cfg->get_my_addr(this->ike_cfg),
                                                                        this->my_host->get_family(this->my_host),
                                                                        IKEV2_UDP_PORT);
-       
+
                if (host && host->is_anyaddr(host) &&
                        !this->other_host->is_anyaddr(this->other_host))
                {
@@ -1111,11 +1111,11 @@ static status_t initiate(private_ike_sa_t *this,
                                                 traffic_selector_t *tsi, traffic_selector_t *tsr)
 {
        task_t *task;
-       
+
        if (this->state == IKE_CREATED)
        {
                resolve_hosts(this);
-               
+
                if (this->other_host->is_anyaddr(this->other_host)
 #ifdef ME
                        && !this->peer_cfg->get_mediated_by(this->peer_cfg)
@@ -1126,9 +1126,9 @@ static status_t initiate(private_ike_sa_t *this,
                        DBG1(DBG_IKE, "unable to initiate to %%any");
                        return DESTROY_ME;
                }
-               
+
                set_condition(this, COND_ORIGINAL_INITIATOR, TRUE);
-               
+
                task = (task_t*)ike_init_create(&this->public, TRUE, NULL);
                this->task_manager->queue_task(this->task_manager, task);
                task = (task_t*)ike_natd_create(&this->public, TRUE);
@@ -1190,7 +1190,7 @@ static status_t initiate(private_ike_sa_t *this,
                }
 #endif /* ME */
        }
-       
+
        return this->task_manager->initiate(this->task_manager);
 }
 
@@ -1201,20 +1201,20 @@ static status_t process_message(private_ike_sa_t *this, message_t *message)
 {
        status_t status;
        bool is_request;
-       
+
        if (this->state == IKE_PASSIVE)
        {       /* do not handle messages in passive state */
                return FAILED;
        }
-       
+
        is_request = message->get_request(message);
-       
+
        status = message->parse_body(message,
                                                                 this->keymat->get_crypter(this->keymat, TRUE),
                                                                 this->keymat->get_signer(this->keymat, TRUE));
        if (status != SUCCESS)
        {
-               
+
                if (is_request)
                {
                        switch (status)
@@ -1258,7 +1258,7 @@ static status_t process_message(private_ike_sa_t *this, message_t *message)
                         exchange_type_names, message->get_exchange_type(message),
                         message->get_request(message) ? "request" : "response",
                         message->get_message_id(message));
-               
+
                if (this->state == IKE_CREATED)
                {       /* invalid initiation attempt, close SA */
                        return DESTROY_ME;
@@ -1268,10 +1268,10 @@ static status_t process_message(private_ike_sa_t *this, message_t *message)
        else
        {
                host_t *me, *other;
-               
+
                me = message->get_destination(message);
                other = message->get_source(message);
-               
+
                /* if this IKE_SA is virgin, we check for a config */
                if (this->ike_cfg == NULL)
                {
@@ -1380,7 +1380,7 @@ static child_sa_t* get_child_sa(private_ike_sa_t *this, protocol_id_t protocol,
 {
        iterator_t *iterator;
        child_sa_t *current, *found = NULL;
-       
+
        iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
@@ -1409,7 +1409,7 @@ static status_t rekey_child_sa(private_ike_sa_t *this, protocol_id_t protocol,
                                                           u_int32_t spi)
 {
        child_rekey_t *child_rekey;
-       
+
        child_rekey = child_rekey_create(&this->public, protocol, spi);
        this->task_manager->queue_task(this->task_manager, &child_rekey->task);
        return this->task_manager->initiate(this->task_manager);
@@ -1422,7 +1422,7 @@ static status_t delete_child_sa(private_ike_sa_t *this, protocol_id_t protocol,
                                                                u_int32_t spi)
 {
        child_delete_t *child_delete;
-       
+
        child_delete = child_delete_create(&this->public, protocol, spi);
        this->task_manager->queue_task(this->task_manager, &child_delete->task);
        return this->task_manager->initiate(this->task_manager);
@@ -1437,7 +1437,7 @@ static status_t destroy_child_sa(private_ike_sa_t *this, protocol_id_t protocol,
        iterator_t *iterator;
        child_sa_t *child_sa;
        status_t status = NOT_FOUND;
-       
+
        iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
        while (iterator->iterate(iterator, (void**)&child_sa))
        {
@@ -1487,9 +1487,9 @@ static status_t delete_(private_ike_sa_t *this)
 static status_t rekey(private_ike_sa_t *this)
 {
        ike_rekey_t *ike_rekey;
-       
+
        ike_rekey = ike_rekey_create(&this->public, TRUE);
-       
+
        this->task_manager->queue_task(this->task_manager, &ike_rekey->task);
        return this->task_manager->initiate(this->task_manager);
 }
@@ -1516,7 +1516,7 @@ static status_t reauth(private_ike_sa_t *this)
                        )
                {
                        time_t now = time_monotonic(NULL);
-                       
+
                        DBG1(DBG_IKE, "IKE_SA will timeout in %V",
                                 &now, &this->stats[STAT_DELETE]);
                        return FAILED;
@@ -1545,7 +1545,7 @@ static status_t reestablish(private_ike_sa_t *this)
        child_cfg_t *child_cfg;
        bool required = FALSE;
        status_t status = FAILED;
-       
+
        /* check if we have children to keep up at all */
        iterator = create_child_sa_iterator(this);
        while (iterator->iterate(iterator, (void**)&child_sa))
@@ -1580,7 +1580,7 @@ static status_t reestablish(private_ike_sa_t *this)
        {
                return FAILED;
        }
-       
+
        /* check if we are able to reestablish this IKE_SA */
        if (!has_condition(this, COND_ORIGINAL_INITIATOR) &&
                (this->other_virtual_ip != NULL ||
@@ -1593,7 +1593,7 @@ static status_t reestablish(private_ike_sa_t *this)
                DBG1(DBG_IKE, "unable to reestablish IKE_SA due asymetric setup");
                return FAILED;
        }
-       
+
        new = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager, TRUE);
        new->set_peer_cfg(new, this->peer_cfg);
        host = this->other_host;
@@ -1606,7 +1606,7 @@ static status_t reestablish(private_ike_sa_t *this)
        {
                new->set_virtual_ip(new, TRUE, host);
        }
-       
+
 #ifdef ME
        if (this->peer_cfg->is_mediation(this->peer_cfg))
        {
@@ -1649,7 +1649,7 @@ static status_t reestablish(private_ike_sa_t *this)
                }
                iterator->destroy(iterator);
        }
-       
+
        if (status == DESTROY_ME)
        {
                charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, new);
@@ -1745,7 +1745,7 @@ static status_t roam(private_ike_sa_t *this, bool address)
 {
        host_t *src;
        ike_mobike_t *mobike;
-       
+
        switch (this->state)
        {
                case IKE_CREATED:
@@ -1768,7 +1768,7 @@ static status_t roam(private_ike_sa_t *this, bool address)
                }
                return SUCCESS;
        }
-       
+
        /* keep existing path if possible */
        src = charon->kernel_interface->get_source_addr(charon->kernel_interface,
                                                                                        this->other_host, this->my_host);
@@ -1783,14 +1783,14 @@ static status_t roam(private_ike_sa_t *this, bool address)
                        return SUCCESS;
                }
                src->destroy(src);
-               
+
        }
        else
        {
                /* check if we find a route at all */
                enumerator_t *enumerator;
                host_t *addr;
-               
+
                src = charon->kernel_interface->get_source_addr(charon->kernel_interface,
                                                                                                                this->other_host, NULL);
                if (!src)
@@ -1819,7 +1819,7 @@ static status_t roam(private_ike_sa_t *this, bool address)
                src->destroy(src);
        }
        set_condition(this, COND_STALE, FALSE);
-       
+
        /* update addresses with mobike, if supported ... */
        if (supports_extension(this, EXT_MOBIKE))
        {
@@ -1842,7 +1842,7 @@ static void add_configuration_attribute(private_ike_sa_t *this,
 {
        attribute_entry_t *entry;
        attribute_handler_t *handler;
-       
+
        handler = charon->attributes->handle(charon->attributes,
                                                                                 &this->public, type, data);
        if (handler)
@@ -1851,7 +1851,7 @@ static void add_configuration_attribute(private_ike_sa_t *this,
                entry->handler = handler;
                entry->type = type;
                entry->data = chunk_clone(data);
-               
+
                this->attributes->insert_last(this->attributes, entry);
        }
 }
@@ -1863,7 +1863,7 @@ static status_t inherit(private_ike_sa_t *this, private_ike_sa_t *other)
 {
        child_sa_t *child_sa;
        attribute_entry_t *entry;
-       
+
        /* apply hosts and ids */
        this->my_host->destroy(this->my_host);
        this->other_host->destroy(this->other_host);
@@ -1873,7 +1873,7 @@ static status_t inherit(private_ike_sa_t *this, private_ike_sa_t *other)
        this->other_host = other->other_host->clone(other->other_host);
        this->my_id = other->my_id->clone(other->my_id);
        this->other_id = other->other_id->clone(other->other_id);
-       
+
        /* apply virtual assigned IPs... */
        if (other->my_virtual_ip)
        {
@@ -1885,7 +1885,7 @@ static status_t inherit(private_ike_sa_t *this, private_ike_sa_t *other)
                this->other_virtual_ip = other->other_virtual_ip;
                other->other_virtual_ip = NULL;
        }
-       
+
        /* ... and configuration attributes */
        while (other->attributes->remove_last(other->attributes,
                                                                                  (void**)&entry) == SUCCESS)
@@ -1899,7 +1899,7 @@ static status_t inherit(private_ike_sa_t *this, private_ike_sa_t *other)
        {
                send_keepalive(this);
        }
-       
+
 #ifdef ME
        if (other->is_mediation_server)
        {
@@ -1918,15 +1918,15 @@ static status_t inherit(private_ike_sa_t *this, private_ike_sa_t *other)
        {
                this->child_sas->insert_first(this->child_sas, (void*)child_sa);
        }
-       
+
        /* move pending tasks to the new IKE_SA */
        this->task_manager->adopt_tasks(this->task_manager, other->task_manager);
-       
+
        /* reauthentication timeout survives a rekeying */
        if (other->stats[STAT_REAUTH])
        {
                time_t reauth, delete, now = time_monotonic(NULL);
-       
+
                this->stats[STAT_REAUTH] = other->stats[STAT_REAUTH];
                reauth = this->stats[STAT_REAUTH] - now;
                delete = reauth + this->peer_cfg->get_over_time(this->peer_cfg);
@@ -1948,11 +1948,11 @@ static status_t inherit(private_ike_sa_t *this, private_ike_sa_t *other)
 static void destroy(private_ike_sa_t *this)
 {
        attribute_entry_t *entry;
-       
+
        charon->bus->set_sa(charon->bus, &this->public);
-       
+
        set_state(this, IKE_DESTROYING);
-       
+
        /* remove attributes first, as we pass the IKE_SA to the handler */
        while (this->attributes->remove_last(this->attributes,
                                                                                 (void**)&entry) == SUCCESS)
@@ -1963,15 +1963,15 @@ static void destroy(private_ike_sa_t *this)
                free(entry);
        }
        this->attributes->destroy(this->attributes);
-       
+
        this->child_sas->destroy_offset(this->child_sas, offsetof(child_sa_t, destroy));
-       
+
        /* unset SA after here to avoid usage by the listeners */
        charon->bus->set_sa(charon->bus, NULL);
-       
+
        this->task_manager->destroy(this->task_manager);
        this->keymat->destroy(this->keymat);
-       
+
        if (this->my_virtual_ip)
        {
                charon->kernel_interface->del_ip(charon->kernel_interface,
@@ -2000,7 +2000,7 @@ static void destroy(private_ike_sa_t *this)
        chunk_free(&this->connect_id);
 #endif /* ME */
        free(this->nat_detection_dest.ptr);
-       
+
        DESTROY_IF(this->my_host);
        DESTROY_IF(this->other_host);
        DESTROY_IF(this->my_id);
@@ -2008,13 +2008,13 @@ static void destroy(private_ike_sa_t *this)
        DESTROY_IF(this->local_host);
        DESTROY_IF(this->remote_host);
        DESTROY_IF(this->eap_identity);
-       
+
        DESTROY_IF(this->ike_cfg);
        DESTROY_IF(this->peer_cfg);
        DESTROY_IF(this->proposal);
        this->my_auth->destroy(this->my_auth);
        this->other_auth->destroy(this->other_auth);
-       
+
        this->ike_sa_id->destroy(this->ike_sa_id);
        free(this);
 }
@@ -2026,7 +2026,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
 {
        private_ike_sa_t *this = malloc_thing(private_ike_sa_t);
        static u_int32_t unique_id = 0;
-       
+
        /* Public functions */
        this->public.get_state = (ike_sa_state_t (*)(ike_sa_t*)) get_state;
        this->public.set_state = (void (*)(ike_sa_t*,ike_sa_state_t)) set_state;
@@ -2099,7 +2099,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
        this->public.callback = (status_t (*)(ike_sa_t*,identification_t*)) callback;
        this->public.respond = (status_t (*)(ike_sa_t*,identification_t*,chunk_t)) respond;
 #endif /* ME */
-       
+
        /* initialize private fields */
        this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
        this->child_sas = linked_list_create();
@@ -2138,6 +2138,6 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
        this->server_reflexive_host = NULL;
        this->connect_id = chunk_empty;
 #endif /* ME */
-       
+
        return &this->public;
 }
index 1f216fd7177db874e1d11ec06f5d4dbfcc4a3e75..525e80b0a5e4670c53b6353704eaf49585acfb3d 100644 (file)
@@ -66,7 +66,7 @@ typedef struct ike_sa_t ike_sa_t;
  * Extensions (or optional features) the peer supports
  */
 enum ike_extension_t {
-       
+
        /**
         * peer supports NAT traversal as specified in RFC4306
         */
@@ -76,12 +76,12 @@ enum ike_extension_t {
         * peer supports MOBIKE (RFC4555)
         */
        EXT_MOBIKE = (1<<1),
-       
+
        /**
         * peer supports HTTP cert lookups as specified in RFC4306
         */
        EXT_HASH_AND_URL = (1<<2),
-       
+
        /**
         * peer supports multiple authentication exchanges, RFC4739
         */
@@ -92,42 +92,42 @@ enum ike_extension_t {
  * Conditions of an IKE_SA, change during its lifetime
  */
 enum ike_condition_t {
-       
+
        /**
         * Connection is natted (or faked) somewhere
         */
        COND_NAT_ANY = (1<<0),
-       
+
        /**
         * we are behind NAT
         */
        COND_NAT_HERE = (1<<1),
-       
+
        /**
         * other is behind NAT
         */
        COND_NAT_THERE = (1<<2),
-       
+
        /**
         * Faking NAT to enforce UDP encapsulation
         */
        COND_NAT_FAKE = (1<<3),
-       
+
        /**
         * peer has been authenticated using EAP at least once
         */
        COND_EAP_AUTHENTICATED = (1<<4),
-       
+
        /**
         * received a certificate request from the peer
         */
        COND_CERTREQ_SEEN = (1<<5),
-       
+
        /**
         * Local peer is the "original" IKE initiator. Unaffected from rekeying.
         */
        COND_ORIGINAL_INITIATOR = (1<<6),
-       
+
        /**
         * IKE_SA is stale, the peer is currently unreachable (MOBIKE)
         */
@@ -150,7 +150,7 @@ enum statistic_t {
        STAT_INBOUND,
        /** Timestamp of last outbound IKE packet */
        STAT_OUTBOUND,
-       
+
        STAT_MAX
 };
 
@@ -192,37 +192,37 @@ enum statistic_t {
    @endverbatim
  */
 enum ike_sa_state_t {
-       
+
        /**
         * IKE_SA just got created, but is not initiating nor responding yet.
         */
        IKE_CREATED,
-       
+
        /**
         * IKE_SA gets initiated actively or passively
         */
        IKE_CONNECTING,
-       
+
        /**
         * IKE_SA is fully established
         */
        IKE_ESTABLISHED,
-       
+
        /**
         * IKE_SA is managed externally and does not process messages
         */
        IKE_PASSIVE,
-       
+
        /**
         * IKE_SA rekeying in progress
         */
        IKE_REKEYING,
-       
+
        /**
         * IKE_SA is in progress of deletion
         */
        IKE_DELETING,
-       
+
        /**
         * IKE_SA object gets destroyed
         */
@@ -252,35 +252,35 @@ struct ike_sa_t {
         * @return                              ike_sa's ike_sa_id_t
         */
        ike_sa_id_t* (*get_id) (ike_sa_t *this);
-       
+
        /**
         * Get the numerical ID uniquely defining this IKE_SA.
         *
         * @return                              unique ID
         */
        u_int32_t (*get_unique_id) (ike_sa_t *this);
-       
+
        /**
         * Get the state of the IKE_SA.
         *
         * @return                              state of the IKE_SA
         */
        ike_sa_state_t (*get_state) (ike_sa_t *this);
-       
+
        /**
         * Set the state of the IKE_SA.
         *
         * @param state                 state to set for the IKE_SA
         */
        void (*set_state) (ike_sa_t *this, ike_sa_state_t ike_sa);
-       
+
        /**
         * Get the name of the connection this IKE_SA uses.
         *
         * @return                              name
         */
        char* (*get_name) (ike_sa_t *this);
-       
+
        /**
         * Get statistic values from the IKE_SA.
         *
@@ -288,35 +288,35 @@ struct ike_sa_t {
         * @return                              value as integer
         */
        u_int32_t (*get_statistic)(ike_sa_t *this, statistic_t kind);
-       
+
        /**
         * Get the own host address.
         *
         * @return                              host address
         */
        host_t* (*get_my_host) (ike_sa_t *this);
-       
+
        /**
         * Set the own host address.
         *
         * @param me                    host address
         */
        void (*set_my_host) (ike_sa_t *this, host_t *me);
-       
+
        /**
         * Get the other peers host address.
         *
         * @return                              host address
         */
        host_t* (*get_other_host) (ike_sa_t *this);
-       
+
        /**
         * Set the others host address.
         *
         * @param other                 host address
         */
        void (*set_other_host) (ike_sa_t *this, host_t *other);
-       
+
        /**
         * Update the IKE_SAs host.
         *
@@ -326,35 +326,35 @@ struct ike_sa_t {
         * @param other                 new remote host address, or NULL
         */
        void (*update_hosts)(ike_sa_t *this, host_t *me, host_t *other);
-       
+
        /**
         * Get the own identification.
         *
         * @return                              identification
         */
        identification_t* (*get_my_id) (ike_sa_t *this);
-       
+
        /**
         * Set the own identification.
         *
         * @param me                    identification
         */
        void (*set_my_id) (ike_sa_t *this, identification_t *me);
-       
+
        /**
         * Get the other peer's identification.
         *
         * @return                              identification
         */
        identification_t* (*get_other_id) (ike_sa_t *this);
-       
+
        /**
         * Set the other peer's identification.
         *
         * @param other                 identification
         */
        void (*set_other_id) (ike_sa_t *this, identification_t *other);
-       
+
        /**
         * Get the peers EAP identity.
         *
@@ -363,21 +363,21 @@ struct ike_sa_t {
         * @return                              identification, NULL if none set
         */
        identification_t* (*get_eap_identity) (ike_sa_t *this);
-       
+
        /**
         * Set the peer's EAP identity.
         *
         * @param id                    identification
         */
        void (*set_eap_identity) (ike_sa_t *this, identification_t *id);
-       
+
        /**
         * Get the config used to setup this IKE_SA.
         *
         * @return                              ike_config
         */
        ike_cfg_t* (*get_ike_cfg) (ike_sa_t *this);
-       
+
        /**
         * Set the config to setup this IKE_SA.
         *
@@ -391,14 +391,14 @@ struct ike_sa_t {
         * @return                              peer_config
         */
        peer_cfg_t* (*get_peer_cfg) (ike_sa_t *this);
-       
+
        /**
         * Set the peer config to use with this IKE_SA.
         *
         * @param config                peer_config to use
         */
        void (*set_peer_cfg) (ike_sa_t *this, peer_cfg_t *config);
-       
+
        /**
         * Get the authentication config with rules of the current auth round.
         *
@@ -406,21 +406,21 @@ struct ike_sa_t {
         * @return                              current cfg
         */
        auth_cfg_t* (*get_auth_cfg)(ike_sa_t *this, bool local);
-       
+
        /**
         * Get the selected proposal of this IKE_SA.
         *
         * @return                              selected proposal
         */
        proposal_t* (*get_proposal)(ike_sa_t *this);
-       
+
        /**
         * Set the proposal selected for this IKE_SA.
         *
         * @param                               selected proposal
         */
        void (*set_proposal)(ike_sa_t *this, proposal_t *proposal);
-       
+
        /**
         * Set the message id of the IKE_SA.
         *
@@ -431,7 +431,7 @@ struct ike_sa_t {
         * @param mid                   message id to set
         */
        void (*set_message_id)(ike_sa_t *this, bool initiate, u_int32_t mid);
-       
+
        /**
         * Add an additional address for the peer.
         *
@@ -443,14 +443,14 @@ struct ike_sa_t {
         * @param host                  host to add to list
         */
        void (*add_additional_address)(ike_sa_t *this, host_t *host);
-       
+
        /**
         * Create an iterator over all additional addresses of the peer.
         *
         * @return                              iterator over addresses
         */
        iterator_t* (*create_additional_address_iterator)(ike_sa_t *this);
-       
+
        /**
         * Check if mappings have changed on a NAT for our source address.
         *
@@ -458,7 +458,7 @@ struct ike_sa_t {
         * @return                              TRUE if mappings have changed
         */
        bool (*has_mapping_changed)(ike_sa_t *this, chunk_t hash);
-       
+
        /**
         * Enable an extension the peer supports.
         *
@@ -468,7 +468,7 @@ struct ike_sa_t {
         * @param extension             extension to enable
         */
        void (*enable_extension)(ike_sa_t *this, ike_extension_t extension);
-       
+
        /**
         * Check if the peer supports an extension.
         *
@@ -476,7 +476,7 @@ struct ike_sa_t {
         * @return                              TRUE if peer supports it, FALSE otherwise
         */
        bool (*supports_extension)(ike_sa_t *this, ike_extension_t extension);
-       
+
        /**
         * Enable/disable a condition flag for this IKE_SA.
         *
@@ -492,48 +492,48 @@ struct ike_sa_t {
         * @return                              TRUE if condition flag set, FALSE otherwise
         */
        bool (*has_condition) (ike_sa_t *this, ike_condition_t condition);
-       
+
        /**
         * Get the number of queued MOBIKE address updates.
         *
         * @return                              number of pending updates
         */
        u_int32_t (*get_pending_updates)(ike_sa_t *this);
-       
+
        /**
         * Set the number of queued MOBIKE address updates.
         *
         * @param updates               number of pending updates
         */
        void (*set_pending_updates)(ike_sa_t *this, u_int32_t updates);
-       
+
 #ifdef ME
        /**
         * Activate mediation server functionality for this IKE_SA.
         */
        void (*act_as_mediation_server) (ike_sa_t *this);
-       
+
        /**
         * Get the server reflexive host.
         *
         * @return                              server reflexive host
         */
        host_t* (*get_server_reflexive_host) (ike_sa_t *this);
-       
+
        /**
         * Set the server reflexive host.
         *
         * @param host                  server reflexive host
         */
        void (*set_server_reflexive_host) (ike_sa_t *this, host_t *host);
-       
+
        /**
         * Get the connect ID.
         *
         * @return                              connect ID
         */
        chunk_t (*get_connect_id) (ike_sa_t *this);
-       
+
        /**
         * Initiate the mediation of a mediated connection (i.e. initiate a
         * ME_CONNECT exchange to a mediation server).
@@ -544,7 +544,7 @@ struct ike_sa_t {
         *                                              - DESTROY_ME if initialization failed
         */
        status_t (*initiate_mediation) (ike_sa_t *this, peer_cfg_t *mediated_cfg);
-       
+
        /**
         * Initiate the mediated connection
         *
@@ -557,7 +557,7 @@ struct ike_sa_t {
         */
        status_t (*initiate_mediated) (ike_sa_t *this, host_t *me, host_t *other,
                                                                   chunk_t connect_id);
-       
+
        /**
         * Relay data from one peer to another (i.e. initiate a ME_CONNECT exchange
         * to a peer).
@@ -576,7 +576,7 @@ struct ike_sa_t {
        status_t (*relay) (ike_sa_t *this, identification_t *requester,
                                           chunk_t connect_id, chunk_t connect_key,
                                           linked_list_t *endpoints, bool response);
-       
+
        /**
         * Send a callback to a peer.
         *
@@ -588,7 +588,7 @@ struct ike_sa_t {
         *                                              - DESTROY_ME if response failed
         */
        status_t (*callback) (ike_sa_t *this, identification_t *peer_id);
-       
+
        /**
         * Respond to a ME_CONNECT request.
         *
@@ -603,7 +603,7 @@ struct ike_sa_t {
        status_t (*respond) (ike_sa_t *this, identification_t *peer_id,
                                                 chunk_t connect_id);
 #endif /* ME */
-       
+
        /**
         * Initiate a new connection.
         *
@@ -622,7 +622,7 @@ struct ike_sa_t {
        status_t (*initiate) (ike_sa_t *this, child_cfg_t *child_cfg,
                                                  u_int32_t reqid, traffic_selector_t *tsi,
                                                  traffic_selector_t *tsr);
-       
+
        /**
         * Initiates the deletion of an IKE_SA.
         *
@@ -637,7 +637,7 @@ struct ike_sa_t {
         *                                                deleted (but destroyed).
         */
        status_t (*delete) (ike_sa_t *this);
-       
+
        /**
         * Update IKE_SAs after network interfaces have changed.
         *
@@ -651,7 +651,7 @@ struct ike_sa_t {
         * @return                              SUCCESS, FAILED, DESTROY_ME
         */
        status_t (*roam)(ike_sa_t *this, bool address);
-       
+
        /**
         * Processes a incoming IKEv2-Message.
         *
@@ -666,7 +666,7 @@ struct ike_sa_t {
         *                                              - DESTROY_ME if this IKE_SA MUST be deleted
         */
        status_t (*process_message) (ike_sa_t *this, message_t *message);
-       
+
        /**
         * Generate a IKE message to send it to the peer.
         *
@@ -682,7 +682,7 @@ struct ike_sa_t {
         */
        status_t (*generate_message) (ike_sa_t *this, message_t *message,
                                                                  packet_t **packet);
-       
+
        /**
         * Retransmits a request.
         *
@@ -692,7 +692,7 @@ struct ike_sa_t {
         *                                              - NOT_FOUND if request doesn't have to be retransmited
         */
        status_t (*retransmit) (ike_sa_t *this, u_int32_t message_id);
-       
+
        /**
         * Sends a DPD request to the peer.
         *
@@ -705,7 +705,7 @@ struct ike_sa_t {
         *                                              - DESTROY_ME, if peer did not respond
         */
        status_t (*send_dpd) (ike_sa_t *this);
-       
+
        /**
         * Sends a keep alive packet.
         *
@@ -715,21 +715,21 @@ struct ike_sa_t {
         * was sent.
         */
        void (*send_keepalive) (ike_sa_t *this);
-       
+
        /**
         * Get the keying material of this IKE_SA.
         *
         * @return                              per IKE_SA keymat instance
         */
        keymat_t* (*get_keymat)(ike_sa_t *this);
-       
+
        /**
         * Associates a child SA to this IKE SA
         *
         * @param child_sa              child_sa to add
         */
        void (*add_child_sa) (ike_sa_t *this, child_sa_t *child_sa);
-       
+
        /**
         * Get a CHILD_SA identified by protocol and SPI.
         *
@@ -740,14 +740,14 @@ struct ike_sa_t {
         */
        child_sa_t* (*get_child_sa) (ike_sa_t *this, protocol_id_t protocol,
                                                                 u_int32_t spi, bool inbound);
-       
+
        /**
         * Create an iterator over all CHILD_SAs.
         *
         * @return                              iterator
         */
        iterator_t* (*create_child_sa_iterator) (ike_sa_t *this);
-       
+
        /**
         * Rekey the CHILD SA with the specified reqid.
         *
@@ -816,14 +816,14 @@ struct ike_sa_t {
         * @return                              DESTROY_ME to destroy the IKE_SA
         */
        status_t (*reestablish) (ike_sa_t *this);
-       
+
        /**
         * Set the lifetime limit received from a AUTH_LIFETIME notify.
         *
         * @param lifetime              lifetime in seconds
         */
        void (*set_auth_lifetime)(ike_sa_t *this, u_int32_t lifetime);
-       
+
        /**
         * Set the virtual IP to use for this IKE_SA and its children.
         *
@@ -834,7 +834,7 @@ struct ike_sa_t {
         * @param ip                    IP to set as virtual IP
         */
        void (*set_virtual_ip) (ike_sa_t *this, bool local, host_t *ip);
-       
+
        /**
         * Get the virtual IP configured.
         *
@@ -842,7 +842,7 @@ struct ike_sa_t {
         * @return                              host_t *virtual IP
         */
        host_t* (*get_virtual_ip) (ike_sa_t *this, bool local);
-       
+
        /**
         * Register a configuration attribute to the IKE_SA.
         *
@@ -856,7 +856,7 @@ struct ike_sa_t {
         */
        void (*add_configuration_attribute)(ike_sa_t *this,
                                                        configuration_attribute_type_t type, chunk_t data);
-       
+
        /**
         * Set local and remote host addresses to be used for IKE.
         *
@@ -867,7 +867,7 @@ struct ike_sa_t {
         * @param remote                remote kmaddress
         */
        void (*set_kmaddress) (ike_sa_t *this, host_t *local, host_t *remote);
-       
+
        /**
         * Inherit all attributes of other to this after rekeying.
         *
@@ -879,12 +879,12 @@ struct ike_sa_t {
         * @return                              DESTROY_ME if initiation of inherited task failed
         */
        status_t (*inherit) (ike_sa_t *this, ike_sa_t *other);
-               
+
        /**
         * Reset the IKE_SA, useable when initiating fails
         */
        void (*reset) (ike_sa_t *this);
-       
+
        /**
         * Destroys a ike_sa_t object.
         */
index 377e64e8a7c4eb36fa4435b3da99a88cf9fe9ebe..0e7d7ea45c7cafdaa8f1785fdf516c28bc4605ee 100644 (file)
@@ -67,7 +67,7 @@ struct ike_sa_id_t {
 
        /**
         * Check if two ike_sa_id_t objects are equal.
-        * 
+        *
         * Two ike_sa_id_t objects are equal if both SPI values and the role matches.
         *
         * @param other                         ike_sa_id_t object to check if equal
@@ -78,7 +78,7 @@ struct ike_sa_id_t {
        /**
         * Replace all values of a given ike_sa_id_t object with values.
         * from another ike_sa_id_t object.
-        * 
+        *
         * After calling this function, both objects are equal.
         *
         * @param other                         ike_sa_id_t object from which values will be taken
@@ -94,7 +94,7 @@ struct ike_sa_id_t {
 
        /**
         * Switche the original initiator flag.
-        * 
+        *
         * @return                                      TRUE if we are the original initator after switch, FALSE otherwise
         */
        bool (*switch_initiator) (ike_sa_id_t *this);
index ec1a7f741e5096c1d67945db7bc6d9a77cec97bb..0ad39f3e553abe42235ebe345494eb426dab465b 100644 (file)
@@ -41,67 +41,67 @@ typedef struct entry_t entry_t;
  * An entry in the linked list, contains IKE_SA, locking and lookup data.
  */
 struct entry_t {
-       
+
        /**
         * Number of threads waiting for this ike_sa_t object.
         */
        int waiting_threads;
-       
+
        /**
         * Condvar where threads can wait until ike_sa_t object is free for use again.
         */
        condvar_t *condvar;
-       
+
        /**
         * Is this ike_sa currently checked out?
         */
        bool checked_out;
-       
+
        /**
         * Does this SA drives out new threads?
         */
        bool driveout_new_threads;
-       
+
        /**
         * Does this SA drives out waiting threads?
         */
        bool driveout_waiting_threads;
-       
+
        /**
         * Identification of an IKE_SA (SPIs).
         */
        ike_sa_id_t *ike_sa_id;
-       
+
        /**
         * The contained ike_sa_t object.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * hash of the IKE_SA_INIT message, used to detect retransmissions
         */
        chunk_t init_hash;
-       
+
        /**
         * remote host address, required for DoS detection
         */
        host_t *other;
-       
+
        /**
         * As responder: Is this SA half-open?
         */
        bool half_open;
-               
+
        /**
         * own identity, required for duplicate checking
         */
        identification_t *my_id;
-       
+
        /**
         * remote identity, required for duplicate checking
         */
        identification_t *other_id;
-       
+
        /**
         * message ID currently processing, if any
         */
@@ -131,10 +131,10 @@ static status_t entry_destroy(entry_t *this)
 static entry_t *entry_create()
 {
        entry_t *this = malloc_thing(entry_t);
-       
+
        this->waiting_threads = 0;
        this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
-       
+
        /* we set checkout flag when we really give it out */
        this->checked_out = FALSE;
        this->driveout_new_threads = FALSE;
@@ -147,7 +147,7 @@ static entry_t *entry_create()
        this->other_id = NULL;
        this->ike_sa_id = NULL;
        this->ike_sa = NULL;
-       
+
        return this;
 }
 
@@ -171,7 +171,7 @@ static bool entry_match_by_id(entry_t *entry, ike_sa_id_t *id)
        if (id->equals(id, entry->ike_sa_id))
        {
                return TRUE;
-       }       
+       }
        if ((id->get_responder_spi(id) == 0 ||
                 entry->ike_sa_id->get_responder_spi(entry->ike_sa_id) == 0) &&
                id->is_initiator(id) == entry->ike_sa_id->is_initiator(entry->ike_sa_id) &&
@@ -208,7 +208,7 @@ typedef struct half_open_t half_open_t;
 struct half_open_t {
        /** chunk of remote host address */
        chunk_t other;
-       
+
        /** the number of half-open IKE_SAs with that host */
        u_int count;
 };
@@ -235,10 +235,10 @@ typedef struct connected_peers_t connected_peers_t;
 struct connected_peers_t {
        /** own identity */
        identification_t *my_id;
-       
+
        /** remote identity */
        identification_t *other_id;
-       
+
        /** list of ike_sa_id_t objects of IKE_SAs between the two identities */
        linked_list_t *sas;
 };
@@ -269,7 +269,7 @@ typedef struct segment_t segment_t;
 struct segment_t {
        /** mutex to access a segment exclusively */
        mutex_t *mutex;
-       
+
        /** the number of entries in this segment */
        u_int count;
 };
@@ -282,7 +282,7 @@ typedef struct shareable_segment_t shareable_segment_t;
 struct shareable_segment_t {
        /** rwlock to access a segment non-/exclusively */
        rwlock_t *lock;
-       
+
        /** the number of entries in this segment - in case of the "half-open table"
         * it's the sum of all half_open_t.count in a segment. */
        u_int count;
@@ -298,67 +298,67 @@ struct private_ike_sa_manager_t {
         * Public interface of ike_sa_manager_t.
         */
         ike_sa_manager_t public;
-       
+
         /**
          * Hash table with entries for the ike_sa_t objects.
          */
         linked_list_t **ike_sa_table;
-        
+
         /**
          * The size of the hash table.
          */
         u_int table_size;
-        
+
         /**
          * Mask to map the hashes to table rows.
          */
         u_int table_mask;
-        
+
         /**
          * Segments of the hash table.
          */
         segment_t *segments;
-        
+
         /**
          * The number of segments.
          */
         u_int segment_count;
-        
+
         /**
          * Mask to map a table row to a segment.
          */
         u_int segment_mask;
-        
+
         /**
          * Hash table with half_open_t objects.
          */
         linked_list_t **half_open_table;
-        
+
         /**
          * Segments of the "half-open" hash table.
          */
         shareable_segment_t *half_open_segments;
-        
+
         /**
          * Hash table with connected_peers_t objects.
          */
         linked_list_t **connected_peers_table;
-        
+
         /**
          * Segments of the "connected peers" hash table.
          */
         shareable_segment_t *connected_peers_segments;
-        
+
         /**
          * RNG to get random SPIs for our side
          */
         rng_t *rng;
-        
+
         /**
          * SHA1 hasher for IKE_SA_INIT retransmit detection
          */
         hasher_t *hasher;
-       
+
        /**
         * reuse existing IKE_SAs in checkout_by_config
         */
@@ -372,7 +372,7 @@ struct private_ike_sa_manager_t {
 static void lock_single_segment(private_ike_sa_manager_t *this, u_int index)
 {
        mutex_t *lock = this->segments[index & this->segment_mask].mutex;
-       
+
        lock->lock(lock);
 }
 
@@ -383,7 +383,7 @@ static void lock_single_segment(private_ike_sa_manager_t *this, u_int index)
 static void unlock_single_segment(private_ike_sa_manager_t *this, u_int index)
 {
        mutex_t *lock = this->segments[index & this->segment_mask].mutex;
-       
+
        lock->unlock(lock);
 }
 
@@ -393,7 +393,7 @@ static void unlock_single_segment(private_ike_sa_manager_t *this, u_int index)
 static void lock_all_segments(private_ike_sa_manager_t *this)
 {
        u_int i;
-       
+
        for (i = 0; i < this->segment_count; ++i)
        {
                this->segments[i].mutex->lock(this->segments[i].mutex);
@@ -406,7 +406,7 @@ static void lock_all_segments(private_ike_sa_manager_t *this)
 static void unlock_all_segments(private_ike_sa_manager_t *this)
 {
        u_int i;
-       
+
        for (i = 0; i < this->segment_count; ++i)
        {
                this->segments[i].mutex->unlock(this->segments[i].mutex);
@@ -424,27 +424,27 @@ struct private_enumerator_t {
         * implements enumerator interface
         */
        enumerator_t enumerator;
-       
+
        /**
         * associated ike_sa_manager_t
         */
        private_ike_sa_manager_t *manager;
-       
+
        /**
         * current segment index
         */
        u_int segment;
-       
+
        /**
         * currently enumerating entry
         */
        entry_t *entry;
-       
+
        /**
         * current table row index
         */
        u_int row;
-       
+
        /**
         * enumerator for the current table row
         */
@@ -468,7 +468,7 @@ static bool enumerate(private_enumerator_t *this, entry_t **entry, u_int *segmen
                        if (this->current)
                        {
                                entry_t *item;
-                               
+
                                if (this->current->enumerate(this->current, &item))
                                {
                                        *entry = this->entry = item;
@@ -482,7 +482,7 @@ static bool enumerate(private_enumerator_t *this, entry_t **entry, u_int *segmen
                        else
                        {
                                linked_list_t *list;
-                               
+
                                lock_single_segment(this->manager, this->segment);
                                if ((list = this->manager->ike_sa_table[this->row]) != NULL &&
                                         list->get_count(list))
@@ -523,7 +523,7 @@ static void enumerator_destroy(private_enumerator_t *this)
 static enumerator_t* create_table_enumerator(private_ike_sa_manager_t *this)
 {
        private_enumerator_t *enumerator = malloc_thing(private_enumerator_t);
-       
+
        enumerator->enumerator.enumerate = (void*)enumerate;
        enumerator->enumerator.destroy = (void*)enumerator_destroy;
        enumerator->manager = this;
@@ -531,7 +531,7 @@ static enumerator_t* create_table_enumerator(private_ike_sa_manager_t *this)
        enumerator->entry = NULL;
        enumerator->row = 0;
        enumerator->current = NULL;
-       
+
        return &enumerator->enumerator;
 }
 
@@ -544,7 +544,7 @@ static u_int put_entry(private_ike_sa_manager_t *this, entry_t *entry)
        linked_list_t *list;
        u_int row = ike_sa_id_hash(entry->ike_sa_id) & this->table_mask;
        u_int segment = row & this->segment_mask;
-       
+
        lock_single_segment(this, segment);
        if ((list = this->ike_sa_table[row]) == NULL)
        {
@@ -564,7 +564,7 @@ static void remove_entry(private_ike_sa_manager_t *this, entry_t *entry)
        linked_list_t *list;
        u_int row = ike_sa_id_hash(entry->ike_sa_id) & this->table_mask;
        u_int segment = row & this->segment_mask;
-       
+
        if ((list = this->ike_sa_table[row]) != NULL)
        {
                entry_t *current;
@@ -609,7 +609,7 @@ static status_t get_entry_by_match_function(private_ike_sa_manager_t *this,
        linked_list_t *list;
        u_int row = ike_sa_id_hash(ike_sa_id) & this->table_mask;
        u_int seg = row & this->segment_mask;
-       
+
        lock_single_segment(this, seg);
        if ((list = this->ike_sa_table[row]) != NULL)
        {
@@ -632,7 +632,7 @@ static status_t get_entry_by_match_function(private_ike_sa_manager_t *this,
 static status_t get_entry_by_id(private_ike_sa_manager_t *this,
                                                ike_sa_id_t *ike_sa_id, entry_t **entry, u_int *segment)
 {
-       return get_entry_by_match_function(this, ike_sa_id, entry, segment, 
+       return get_entry_by_match_function(this, ike_sa_id, entry, segment,
                                (linked_list_match_t)entry_match_by_id, ike_sa_id, NULL);
 }
 
@@ -670,7 +670,7 @@ static bool wait_for_entry(private_ike_sa_manager_t *this, entry_t *entry,
                /* we are not allowed to get this */
                return FALSE;
        }
-       while (entry->checked_out && !entry->driveout_waiting_threads)  
+       while (entry->checked_out && !entry->driveout_waiting_threads)
        {
                /* so wait until we can get it for us.
                 * we register us as waiting. */
@@ -698,7 +698,7 @@ static void put_half_open(private_ike_sa_manager_t *this, entry_t *entry)
        chunk_t addr = entry->other->get_address(entry->other);
        u_int row = chunk_hash(addr) & this->table_mask;
        u_int segment = row & this->segment_mask;
-       
+
        rwlock_t *lock = this->half_open_segments[segment].lock;
        lock->write_lock(lock);
        if ((list = this->half_open_table[row]) == NULL)
@@ -716,7 +716,7 @@ static void put_half_open(private_ike_sa_manager_t *this, entry_t *entry)
                        this->half_open_segments[segment].count++;
                }
        }
-       
+
        if (!half_open)
        {
                half_open = malloc_thing(half_open_t);
@@ -737,7 +737,7 @@ static void remove_half_open(private_ike_sa_manager_t *this, entry_t *entry)
        chunk_t addr = entry->other->get_address(entry->other);
        u_int row = chunk_hash(addr) & this->table_mask;
        u_int segment = row & this->segment_mask;
-       
+
        rwlock_t *lock = this->half_open_segments[segment].lock;
        lock->write_lock(lock);
        if ((list = this->half_open_table[row]) != NULL)
@@ -773,7 +773,7 @@ static void put_connected_peers(private_ike_sa_manager_t *this, entry_t *entry)
                        other_id = entry->other_id->get_encoding(entry->other_id);
        u_int row = chunk_hash_inc(other_id, chunk_hash(my_id)) & this->table_mask;
        u_int segment = row & this->segment_mask;
-       
+
        rwlock_t *lock = this->connected_peers_segments[segment].lock;
        lock->write_lock(lock);
        if ((list = this->connected_peers_table[row]) == NULL)
@@ -796,7 +796,7 @@ static void put_connected_peers(private_ike_sa_manager_t *this, entry_t *entry)
                        }
                }
        }
-       
+
        if (!connected_peers)
        {
                connected_peers = malloc_thing(connected_peers_t);
@@ -821,7 +821,7 @@ static void remove_connected_peers(private_ike_sa_manager_t *this, entry_t *entr
                        other_id = entry->other_id->get_encoding(entry->other_id);
        u_int row = chunk_hash_inc(other_id, chunk_hash(my_id)) & this->table_mask;
        u_int segment = row & this->segment_mask;
-       
+
        rwlock_t *lock = this->connected_peers_segments[segment].lock;
        lock->write_lock(lock);
        if ((list = this->connected_peers_table[row]) != NULL)
@@ -864,7 +864,7 @@ static void remove_connected_peers(private_ike_sa_manager_t *this, entry_t *entr
 static u_int64_t get_next_spi(private_ike_sa_manager_t *this)
 {
        u_int64_t spi;
-       
+
        this->rng->get_bytes(this->rng, sizeof(spi), (u_int8_t*)&spi);
        return spi;
 }
@@ -877,9 +877,9 @@ static ike_sa_t* checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id
        ike_sa_t *ike_sa = NULL;
        entry_t *entry;
        u_int segment;
-       
+
        DBG2(DBG_MGR, "checkout IKE_SA");
-       
+
        if (get_entry_by_id(this, ike_sa_id, &entry, &segment) == SUCCESS)
        {
                if (wait_for_entry(this, entry, segment))
@@ -903,7 +903,7 @@ static ike_sa_t *checkout_new(private_ike_sa_manager_t* this, bool initiator)
        ike_sa_t *ike_sa;
        entry_t *entry;
        u_int segment;
-       
+
        if (initiator)
        {
                ike_sa_id = ike_sa_id_create(get_next_spi(this), 0, TRUE);
@@ -913,15 +913,15 @@ static ike_sa_t *checkout_new(private_ike_sa_manager_t* this, bool initiator)
                ike_sa_id = ike_sa_id_create(0, get_next_spi(this), FALSE);
        }
        ike_sa = ike_sa_create(ike_sa_id);
-       
+
        DBG2(DBG_MGR, "created IKE_SA");
-       
+
        if (!initiator)
        {
                ike_sa_id->destroy(ike_sa_id);
                return ike_sa;
        }
-       
+
        entry = entry_create();
        entry->ike_sa_id = ike_sa_id;
        entry->ike_sa = ike_sa;
@@ -944,19 +944,19 @@ static ike_sa_t* checkout_by_message(private_ike_sa_manager_t* this,
 
        id = id->clone(id);
        id->switch_initiator(id);
-       
+
        DBG2(DBG_MGR, "checkout IKE_SA by message");
-       
+
        if (message->get_request(message) &&
                message->get_exchange_type(message) == IKE_SA_INIT)
        {
                /* IKE_SA_INIT request. Check for an IKE_SA with such a message hash. */
                chunk_t data, hash;
-                       
+
                data = message->get_packet_data(message);
                this->hasher->allocate_hash(this->hasher, data, &hash);
                chunk_free(&data);
-               
+
                if (get_entry_by_hash(this, id, hash, &entry, &segment) == SUCCESS)
                {
                        if (entry->message_id == 0)
@@ -976,7 +976,7 @@ static ike_sa_t* checkout_by_message(private_ike_sa_manager_t* this,
                        }
                        unlock_single_segment(this, segment);
                }
-               
+
                if (ike_sa == NULL)
                {
                        if (id->get_responder_spi(id) == 0 &&
@@ -987,15 +987,15 @@ static ike_sa_t* checkout_by_message(private_ike_sa_manager_t* this,
                                entry = entry_create();
                                entry->ike_sa = ike_sa_create(id);
                                entry->ike_sa_id = id->clone(id);
-                               
+
                                segment = put_entry(this, entry);
                                entry->checked_out = TRUE;
                                unlock_single_segment(this, segment);
-                               
-                               entry->message_id = message->get_message_id(message);                           
+
+                               entry->message_id = message->get_message_id(message);
                                entry->init_hash = hash;
                                ike_sa = entry->ike_sa;
-                               
+
                                DBG2(DBG_MGR, "created IKE_SA");
                        }
                        else
@@ -1012,7 +1012,7 @@ static ike_sa_t* checkout_by_message(private_ike_sa_manager_t* this,
                charon->bus->set_sa(charon->bus, ike_sa);
                return ike_sa;
        }
-       
+
        if (get_entry_by_id(this, id, &entry, &segment) == SUCCESS)
        {
                /* only check out if we are not processing this request */
@@ -1053,14 +1053,14 @@ static ike_sa_t* checkout_by_config(private_ike_sa_manager_t *this,
        peer_cfg_t *current_peer;
        ike_cfg_t *current_ike;
        u_int segment;
-       
+
        if (!this->reuse_ikesa)
        {       /* IKE_SA reuse disable by config */
-               ike_sa = checkout_new(this, TRUE);      
+               ike_sa = checkout_new(this, TRUE);
                charon->bus->set_sa(charon->bus, ike_sa);
                return ike_sa;
        }
-       
+
        enumerator = create_table_enumerator(this);
        while (enumerator->enumerate(enumerator, &entry, &segment))
        {
@@ -1072,7 +1072,7 @@ static ike_sa_t* checkout_by_config(private_ike_sa_manager_t *this,
                {       /* skip IKE_SAs which are not usable */
                        continue;
                }
-               
+
                current_peer = entry->ike_sa->get_peer_cfg(entry->ike_sa);
                if (current_peer && current_peer->equals(current_peer, peer_cfg))
                {
@@ -1088,10 +1088,10 @@ static ike_sa_t* checkout_by_config(private_ike_sa_manager_t *this,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        if (!ike_sa)
        {       /* no IKE_SA using such a config, hand out a new */
-               ike_sa = checkout_new(this, TRUE);      
+               ike_sa = checkout_new(this, TRUE);
        }
        charon->bus->set_sa(charon->bus, ike_sa);
        return ike_sa;
@@ -1109,7 +1109,7 @@ static ike_sa_t* checkout_by_id(private_ike_sa_manager_t *this, u_int32_t id,
        ike_sa_t *ike_sa = NULL;
        child_sa_t *child_sa;
        u_int segment;
-       
+
        enumerator = create_table_enumerator(this);
        while (enumerator->enumerate(enumerator, &entry, &segment))
        {
@@ -1125,7 +1125,7 @@ static ike_sa_t* checkout_by_id(private_ike_sa_manager_t *this, u_int32_t id,
                                        {
                                                ike_sa = entry->ike_sa;
                                                break;
-                                       }               
+                                       }
                                }
                                children->destroy(children);
                        }
@@ -1145,7 +1145,7 @@ static ike_sa_t* checkout_by_id(private_ike_sa_manager_t *this, u_int32_t id,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        charon->bus->set_sa(charon->bus, ike_sa);
        return ike_sa;
 }
@@ -1162,7 +1162,7 @@ static ike_sa_t* checkout_by_name(private_ike_sa_manager_t *this, char *name,
        ike_sa_t *ike_sa = NULL;
        child_sa_t *child_sa;
        u_int segment;
-       
+
        enumerator = create_table_enumerator(this);
        while (enumerator->enumerate(enumerator, &entry, &segment))
        {
@@ -1178,7 +1178,7 @@ static ike_sa_t* checkout_by_name(private_ike_sa_manager_t *this, char *name,
                                        {
                                                ike_sa = entry->ike_sa;
                                                break;
-                                       }               
+                                       }
                                }
                                children->destroy(children);
                        }
@@ -1198,13 +1198,13 @@ static ike_sa_t* checkout_by_name(private_ike_sa_manager_t *this, char *name,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        charon->bus->set_sa(charon->bus, ike_sa);
        return ike_sa;
 }
 
 /**
- * enumerator filter function 
+ * enumerator filter function
  */
 static bool enumerator_filter(private_ike_sa_manager_t *this,
                                                          entry_t **in, ike_sa_t **out, u_int *segment)
@@ -1243,14 +1243,14 @@ static void checkin(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
        host_t *other;
        identification_t *my_id, *other_id;
        u_int segment;
-       
+
        ike_sa_id = ike_sa->get_id(ike_sa);
        my_id = ike_sa->get_my_id(ike_sa);
        other_id = ike_sa->get_other_id(ike_sa);
        other = ike_sa->get_other_host(ike_sa);
-       
+
        DBG2(DBG_MGR, "checkin IKE_SA");
-       
+
        /* look for the entry */
        if (get_entry_by_sa(this, ike_sa_id, ike_sa, &entry, &segment) == SUCCESS)
        {
@@ -1293,7 +1293,7 @@ static void checkin(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
                entry->ike_sa = ike_sa;
                segment = put_entry(this, entry);
        }
-       
+
        /* apply identities for duplicate test (only as responder) */
        if (!entry->ike_sa_id->is_initiator(entry->ike_sa_id) &&
                ike_sa->get_state(ike_sa) == IKE_ESTABLISHED &&
@@ -1303,9 +1303,9 @@ static void checkin(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
                entry->other_id = other_id->clone(other_id);
                put_connected_peers(this, entry);
        }
-       
+
        unlock_single_segment(this, segment);
-       
+
        charon->bus->set_sa(charon->bus, NULL);
 }
 
@@ -1322,11 +1322,11 @@ static void checkin_and_destroy(private_ike_sa_manager_t *this, ike_sa_t *ike_sa
        entry_t *entry;
        ike_sa_id_t *ike_sa_id;
        u_int segment;
-       
+
        ike_sa_id = ike_sa->get_id(ike_sa);
-       
+
        DBG2(DBG_MGR, "checkin and destroy IKE_SA");
-       
+
        if (get_entry_by_sa(this, ike_sa_id, ike_sa, &entry, &segment) == SUCCESS)
        {
                /* drive out waiting threads, as we are in hurry */
@@ -1343,7 +1343,7 @@ static void checkin_and_destroy(private_ike_sa_manager_t *this, ike_sa_t *ike_sa
                }
                remove_entry(this, entry);
                unlock_single_segment(this, segment);
-               
+
                if (entry->half_open)
                {
                        remove_half_open(this, entry);
@@ -1353,9 +1353,9 @@ static void checkin_and_destroy(private_ike_sa_manager_t *this, ike_sa_t *ike_sa
                {
                        remove_connected_peers(this, entry);
                }
-               
+
                entry_destroy(entry);
-               
+
                DBG2(DBG_MGR, "check-in and destroy of IKE_SA successful");
        }
        else
@@ -1366,7 +1366,7 @@ static void checkin_and_destroy(private_ike_sa_manager_t *this, ike_sa_t *ike_sa
        charon->bus->set_sa(charon->bus, NULL);
 }
 
-       
+
 /**
  * Implementation of ike_sa_manager_t.check_uniqueness.
  */
@@ -1381,27 +1381,27 @@ static bool check_uniqueness(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
        identification_t *me, *other;
        u_int row, segment;
        rwlock_t *lock;
-       
+
        peer_cfg = ike_sa->get_peer_cfg(ike_sa);
        policy = peer_cfg->get_unique_policy(peer_cfg);
        if (policy == UNIQUE_NO)
        {
                return FALSE;
        }
-       
+
        me = ike_sa->get_my_id(ike_sa);
        other = ike_sa->get_other_id(ike_sa);
-       
+
        row = chunk_hash_inc(other->get_encoding(other),
                                                 chunk_hash(me->get_encoding(me))) & this->table_mask;
        segment = row & this->segment_mask;
-       
+
        lock = this->connected_peers_segments[segment & this->segment_mask].lock;
        lock->read_lock(lock);
        if ((list = this->connected_peers_table[row]) != NULL)
        {
                connected_peers_t *current;
-               
+
                if (list->find_first(list, (linked_list_match_t)connected_peers_match,
                                                         (void**)&current, me, other) == SUCCESS)
                {
@@ -1411,18 +1411,18 @@ static bool check_uniqueness(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
                }
        }
        lock->unlock(lock);
-       
+
        if (!duplicate_ids)
        {
                return FALSE;
        }
-       
+
        enumerator = duplicate_ids->create_enumerator(duplicate_ids);
        while (enumerator->enumerate(enumerator, &duplicate_id))
        {
                status_t status = SUCCESS;
                ike_sa_t *duplicate;
-               
+
                duplicate = checkout(this, duplicate_id);
                if (!duplicate)
                {
@@ -1485,13 +1485,13 @@ static int get_half_open_count(private_ike_sa_manager_t *this, host_t *ip)
                chunk_t addr = ip->get_address(ip);
                u_int row = chunk_hash(addr) & this->table_mask;
                u_int segment = row & this->segment_mask;
-               
+
                rwlock_t *lock = this->half_open_segments[segment & this->segment_mask].lock;
                lock->read_lock(lock);
                if ((list = this->half_open_table[row]) != NULL)
                {
                        half_open_t *current;
-                       
+
                        if (list->find_first(list, (linked_list_match_t)half_open_match,
                                                                 (void**)&current, &addr) == SUCCESS)
                        {
@@ -1503,7 +1503,7 @@ static int get_half_open_count(private_ike_sa_manager_t *this, host_t *ip)
        else
        {
                u_int segment;
-               
+
                for (segment = 0; segment < this->segment_count; ++segment)
                {
                        rwlock_t *lock;
@@ -1513,7 +1513,7 @@ static int get_half_open_count(private_ike_sa_manager_t *this, host_t *ip)
                        lock->unlock(lock);
                }
        }
-       
+
        return count;
 }
 
@@ -1526,7 +1526,7 @@ static void flush(private_ike_sa_manager_t *this)
        enumerator_t *enumerator;
        entry_t *entry;
        u_int segment;
-       
+
        lock_all_segments(this);
        DBG2(DBG_MGR, "going to destroy IKE_SA manager and all managed IKE_SA's");
        /* Step 1: drive out all waiting threads  */
@@ -1536,7 +1536,7 @@ static void flush(private_ike_sa_manager_t *this)
        {
                /* do not accept new threads, drive out waiting threads */
                entry->driveout_new_threads = TRUE;
-               entry->driveout_waiting_threads = TRUE; 
+               entry->driveout_waiting_threads = TRUE;
        }
        enumerator->destroy(enumerator);
        DBG2(DBG_MGR, "wait for all threads to leave IKE_SA's");
@@ -1573,7 +1573,7 @@ static void flush(private_ike_sa_manager_t *this)
                entry->ike_sa->delete(entry->ike_sa);
        }
        enumerator->destroy(enumerator);
-       
+
        DBG2(DBG_MGR, "destroy all entries");
        /* Step 4: destroy all entries */
        enumerator = create_table_enumerator(this);
@@ -1633,7 +1633,7 @@ static void destroy(private_ike_sa_manager_t *this)
        free(this->segments);
        free(this->half_open_segments);
        free(this->connected_peers_segments);
-       
+
        this->rng->destroy(this->rng);
        this->hasher->destroy(this->hasher);
        free(this);
@@ -1648,7 +1648,7 @@ static void destroy(private_ike_sa_manager_t *this)
 static u_int get_nearest_powerof2(u_int n)
 {
        u_int i;
-       
+
        --n;
        for (i = 1; i < sizeof(u_int) * 8; i <<= 1)
        {
@@ -1679,7 +1679,7 @@ ike_sa_manager_t *ike_sa_manager_create()
        this->public.checkin = (void(*)(ike_sa_manager_t*,ike_sa_t*))checkin;
        this->public.checkin_and_destroy = (void(*)(ike_sa_manager_t*,ike_sa_t*))checkin_and_destroy;
        this->public.get_half_open_count = (int(*)(ike_sa_manager_t*,host_t*))get_half_open_count;
-       
+
        /* initialize private variables */
        this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_PREFERRED);
        if (this->hasher == NULL)
@@ -1700,21 +1700,21 @@ ike_sa_manager_t *ike_sa_manager_create()
                                                "charon.ikesa_table_size", DEFAULT_HASHTABLE_SIZE));
        this->table_size = max(1, min(this->table_size, MAX_HASHTABLE_SIZE));
        this->table_mask = this->table_size - 1;
-       
+
        this->segment_count = get_nearest_powerof2(lib->settings->get_int(lib->settings,
                                                "charon.ikesa_table_segments", DEFAULT_SEGMENT_COUNT));
        this->segment_count = max(1, min(this->segment_count, this->table_size));
        this->segment_mask = this->segment_count - 1;
-       
+
        this->ike_sa_table = calloc(this->table_size, sizeof(linked_list_t*));
-       
+
        this->segments = (segment_t*)calloc(this->segment_count, sizeof(segment_t));
        for (i = 0; i < this->segment_count; ++i)
        {
                this->segments[i].mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
                this->segments[i].count = 0;
        }
-       
+
        /* we use the same table parameters for the table to track half-open SAs */
        this->half_open_table = calloc(this->table_size, sizeof(linked_list_t*));
        this->half_open_segments = calloc(this->segment_count, sizeof(shareable_segment_t));
@@ -1723,7 +1723,7 @@ ike_sa_manager_t *ike_sa_manager_create()
                this->half_open_segments[i].lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
                this->half_open_segments[i].count = 0;
        }
-       
+
        /* also for the hash table used for duplicate tests */
        this->connected_peers_table = calloc(this->table_size, sizeof(linked_list_t*));
        this->connected_peers_segments = calloc(this->segment_count, sizeof(shareable_segment_t));
@@ -1732,7 +1732,7 @@ ike_sa_manager_t *ike_sa_manager_create()
                this->connected_peers_segments[i].lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
                this->connected_peers_segments[i].count = 0;
        }
-       
+
        this->reuse_ikesa = lib->settings->get_bool(lib->settings,
                                                                                                "charon.reuse_ikesa", TRUE);
        return &this->public;
index 6da768080926be7be79d5733393249151dc96f5a..c141052e77d189a75351505df6ef21ca683e0cb7 100644 (file)
@@ -38,20 +38,20 @@ typedef struct ike_sa_manager_t ike_sa_manager_t;
  * by the owning thread.
  */
 struct ike_sa_manager_t {
-       
+
        /**
         * Checkout an existing IKE_SA.
-        * 
+        *
         * @param ike_sa_id                     the SA identifier, will be updated
-        * @returns                                     
+        * @returns
         *                                                      - checked out IKE_SA if found
         *                                                      - NULL, if specified IKE_SA is not found.
         */
        ike_sa_t* (*checkout) (ike_sa_manager_t* this, ike_sa_id_t *sa_id);
-       
+
        /**
         * Create and check out a new IKE_SA.
-        * 
+        *
         * @note If initiator equals FALSE, the returned IKE_SA is not registered
         * in the manager.
         *
@@ -59,30 +59,30 @@ struct ike_sa_manager_t {
         * @returns                             created and checked out IKE_SA
         */
        ike_sa_t* (*checkout_new) (ike_sa_manager_t* this, bool initiator);
-       
+
        /**
         * Checkout an IKE_SA by a message.
-        * 
+        *
         * In some situations, it is necessary that the manager knows the
         * message to use for the checkout. This has the following reasons:
-        * 
+        *
         * 1. If the targeted IKE_SA is already processing a message, we do not
         *    check it out if the message ID is the same.
-        * 2. If it is an IKE_SA_INIT request, we have to check if it is a 
+        * 2. If it is an IKE_SA_INIT request, we have to check if it is a
         *    retransmission. If so, we have to drop the message, we would
         *    create another unneeded IKE_SA for each retransmitted packet.
         *
         * A call to checkout_by_message() returns a (maybe new created) IKE_SA.
         * If processing the message does not make sense (for the reasons above),
         * NULL is returned.
-        * 
+        *
         * @param ike_sa_id                     the SA identifier, will be updated
-        * @returns                                     
+        * @returns
         *                                                      - checked out/created IKE_SA
         *                                                      - NULL to not process message further
         */
        ike_sa_t* (*checkout_by_message) (ike_sa_manager_t* this, message_t *message);
-       
+
        /**
         * Checkout an IKE_SA for initiation by a peer_config.
         *
@@ -98,26 +98,26 @@ struct ike_sa_manager_t {
         */
        ike_sa_t* (*checkout_by_config) (ike_sa_manager_t* this,
                                                                         peer_cfg_t *peer_cfg);
-       
+
        /**
         * Check for duplicates of the given IKE_SA.
-        * 
+        *
         * Measures are taken according to the uniqueness policy of the IKE_SA.
         * The return value indicates whether duplicates have been found and if
         * further measures should be taken (e.g. cancelling an IKE_AUTH exchange).
         * check_uniqueness() must be called before the IKE_SA is complete,
         * deadlocks occur otherwise.
-        * 
+        *
         * @param ike_sa                        ike_sa to check
         * @return                                      TRUE, if the given IKE_SA has duplicates and
         *                                                      should be deleted
         */
        bool (*check_uniqueness)(ike_sa_manager_t *this, ike_sa_t *ike_sa);
-       
+
        /**
         * Check out an IKE_SA a unique ID.
         *
-        * Every IKE_SA and every CHILD_SA is uniquely identified by an ID. 
+        * Every IKE_SA and every CHILD_SA is uniquely identified by an ID.
         * These checkout function uses, depending
         * on the child parameter, the unique ID of the IKE_SA or the reqid
         * of one of a IKE_SAs CHILD_SA.
@@ -130,7 +130,7 @@ struct ike_sa_manager_t {
         */
        ike_sa_t* (*checkout_by_id) (ike_sa_manager_t* this, u_int32_t id,
                                                                 bool child);
-       
+
        /**
         * Check out an IKE_SA by the policy/connection name.
         *
@@ -145,7 +145,7 @@ struct ike_sa_manager_t {
         */
        ike_sa_t* (*checkout_by_name) (ike_sa_manager_t* this, char *name,
                                                                   bool child);
-       
+
        /**
         * Create an enumerator over all stored IKE_SAs.
         *
@@ -155,7 +155,7 @@ struct ike_sa_manager_t {
         * @return                                      enumerator over all IKE_SAs.
         */
        enumerator_t *(*create_enumerator) (ike_sa_manager_t* this);
-       
+
        /**
         * Checkin the SA after usage.
         *
@@ -165,7 +165,7 @@ struct ike_sa_manager_t {
         * @param ike_sa                        checked out SA
         */
        void (*checkin) (ike_sa_manager_t* this, ike_sa_t *ike_sa);
-       
+
        /**
         * Destroy a checked out SA.
         *
@@ -179,7 +179,7 @@ struct ike_sa_manager_t {
         * @param ike_sa                        SA to delete
         */
        void (*checkin_and_destroy) (ike_sa_manager_t* this, ike_sa_t *ike_sa);
-       
+
        /**
         * Get the number of IKE_SAs which are in the connecting state.
         *
@@ -189,19 +189,19 @@ struct ike_sa_manager_t {
         * If a host is supplied, only the number of half open IKE_SAs initiated
         * from this IP are counted.
         * Only SAs for which we are the responder are counted.
-        * 
+        *
         * @param ip                            NULL for all, IP for half open IKE_SAs with IP
         * @return                                      number of half open IKE_SAs
         */
        int (*get_half_open_count) (ike_sa_manager_t *this, host_t *ip);
-       
+
        /**
         * Delete all existing IKE_SAs and destroy them immediately.
-        * 
+        *
         * Threads will be driven out, so all SAs can be deleted cleanly.
         */
        void (*flush)(ike_sa_manager_t *this);
-       
+
        /**
         * Destroys the manager with all associated SAs.
         *
@@ -212,7 +212,7 @@ struct ike_sa_manager_t {
 
 /**
  * Create the IKE_SA manager.
- * 
+ *
  * @returns    ike_sa_manager_t object, NULL if initialization fails
  */
 ike_sa_manager_t *ike_sa_manager_create(void);
index 46fb79587a98ad32195e98df06c5f37ce755cd6b..e7224fe52f13002805708bf9bd0bf0d911357f8c 100644 (file)
@@ -24,52 +24,52 @@ typedef struct private_keymat_t private_keymat_t;
  * Private data of an keymat_t object.
  */
 struct private_keymat_t {
-       
+
        /**
         * Public keymat_t interface.
         */
        keymat_t public;
-       
+
        /**
         * IKE_SA Role, initiator or responder
         */
        bool initiator;
-       
+
        /**
         * inbound signer (verify)
         */
        signer_t *signer_in;
-       
+
        /**
         * outbound signer (sign)
         */
        signer_t *signer_out;
-       
+
        /**
         * inbound crypter (decrypt)
         */
        crypter_t *crypter_in;
-       
+
        /**
         * outbound crypter (encrypt)
         */
        crypter_t *crypter_out;
-       
+
        /**
         * General purpose PRF
         */
        prf_t *prf;
-       
+
        /**
         * Negotiated PRF algorithm
         */
        pseudo_random_function_t prf_alg;
-       
+
        /**
         * Key to derive key material from for CHILD_SAs, rekeying
         */
        chunk_t skd;
-       
+
        /**
         * Key to build outging authentication data (SKp)
         */
@@ -158,15 +158,15 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
        prf_plus_t *prf_plus;
        u_int16_t alg, key_size;
        prf_t *rekey_prf = NULL;
-       
+
        spi_i = chunk_alloca(sizeof(u_int64_t));
        spi_r = chunk_alloca(sizeof(u_int64_t));
-       
+
        if (dh->get_shared_secret(dh, &secret) != SUCCESS)
        {
                return FALSE;
        }
-       
+
        /* Create SAs general purpose PRF first, we may use it here */
        if (!proposal->get_algorithm(proposal, PSEUDO_RANDOM_FUNCTION, &alg, NULL))
        {
@@ -206,8 +206,8 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
        *((u_int64_t*)spi_i.ptr) = id->get_initiator_spi(id);
        *((u_int64_t*)spi_r.ptr) = id->get_responder_spi(id);
        prf_plus_seed = chunk_cat("ccc", full_nonce, spi_i, spi_r);
-       
-       /* KEYMAT = prf+ (SKEYSEED, Ni | Nr | SPIi | SPIr) 
+
+       /* KEYMAT = prf+ (SKEYSEED, Ni | Nr | SPIi | SPIr)
         *
         * if we are rekeying, SKEYSEED is built on another way
         */
@@ -221,7 +221,7 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
        }
        else
        {
-               /* SKEYSEED = prf(SK_d (old), [g^ir (new)] | Ni | Nr) 
+               /* SKEYSEED = prf(SK_d (old), [g^ir (new)] | Ni | Nr)
                 * use OLD SAs PRF functions for both prf_plus and prf */
                rekey_prf = lib->crypto->create_prf(lib->crypto, rekey_function);
                if (!rekey_prf)
@@ -240,20 +240,20 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
                prf_plus = prf_plus_create(rekey_prf, prf_plus_seed);
        }
        DBG4(DBG_IKE, "SKEYSEED %B", &skeyseed);
-       
+
        chunk_clear(&skeyseed);
        chunk_clear(&secret);
        chunk_free(&full_nonce);
        chunk_free(&fixed_nonce);
        chunk_clear(&prf_plus_seed);
-       
+
        /* KEYMAT = SK_d | SK_ai | SK_ar | SK_ei | SK_er | SK_pi | SK_pr */
-       
+
        /* SK_d is used for generating CHILD_SA key mat => store for later use */
        key_size = this->prf->get_key_size(this->prf);
        prf_plus->allocate_bytes(prf_plus, key_size, &this->skd);
        DBG4(DBG_IKE, "Sk_d secret %B", &this->skd);
-       
+
        /* SK_ai/SK_ar used for integrity protection => signer_in/signer_out */
        if (!proposal->get_algorithm(proposal, INTEGRITY_ALGORITHM, &alg, NULL))
        {
@@ -275,17 +275,17 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
                return FALSE;
        }
        key_size = signer_i->get_key_size(signer_i);
-       
+
        prf_plus->allocate_bytes(prf_plus, key_size, &key);
        DBG4(DBG_IKE, "Sk_ai secret %B", &key);
        signer_i->set_key(signer_i, key);
        chunk_clear(&key);
-       
+
        prf_plus->allocate_bytes(prf_plus, key_size, &key);
        DBG4(DBG_IKE, "Sk_ar secret %B", &key);
        signer_r->set_key(signer_r, key);
        chunk_clear(&key);
-       
+
        if (this->initiator)
        {
                this->signer_in = signer_r;
@@ -296,7 +296,7 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
                this->signer_in = signer_i;
                this->signer_out = signer_r;
        }
-       
+
        /* SK_ei/SK_er used for encryption => crypter_in/crypter_out */
        if (!proposal->get_algorithm(proposal, ENCRYPTION_ALGORITHM, &alg, &key_size))
        {
@@ -318,17 +318,17 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
                return FALSE;
        }
        key_size = crypter_i->get_key_size(crypter_i);
-       
+
        prf_plus->allocate_bytes(prf_plus, key_size, &key);
        DBG4(DBG_IKE, "Sk_ei secret %B", &key);
        crypter_i->set_key(crypter_i, key);
        chunk_clear(&key);
-       
+
        prf_plus->allocate_bytes(prf_plus, key_size, &key);
        DBG4(DBG_IKE, "Sk_er secret %B", &key);
        crypter_r->set_key(crypter_r, key);
        chunk_clear(&key);
-       
+
        if (this->initiator)
        {
                this->crypter_in = crypter_r;
@@ -339,8 +339,8 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
                this->crypter_in = crypter_i;
                this->crypter_out = crypter_r;
        }
-       
-       /* SK_pi/SK_pr used for authentication => stored for later */   
+
+       /* SK_pi/SK_pr used for authentication => stored for later */
        key_size = this->prf->get_key_size(this->prf);
        prf_plus->allocate_bytes(prf_plus, key_size, &key);
        DBG4(DBG_IKE, "Sk_pi secret %B", &key);
@@ -362,11 +362,11 @@ static bool derive_ike_keys(private_keymat_t *this, proposal_t *proposal,
        {
                this->skp_build = key;
        }
-       
+
        /* all done, prf_plus not needed anymore */
        prf_plus->destroy(prf_plus);
        DESTROY_IF(rekey_prf);
-       
+
        return TRUE;
 }
 
@@ -382,7 +382,7 @@ static bool derive_child_keys(private_keymat_t *this,
        u_int16_t enc_alg, int_alg, enc_size = 0, int_size = 0;
        chunk_t seed, secret = chunk_empty;
        prf_plus_t *prf_plus;
-       
+
        if (dh)
        {
                if (dh->get_shared_secret(dh, &secret) != SUCCESS)
@@ -393,13 +393,13 @@ static bool derive_child_keys(private_keymat_t *this,
        }
        seed = chunk_cata("mcc", secret, nonce_i, nonce_r);
        DBG4(DBG_CHD, "seed %B", &seed);
-       
+
        if (proposal->get_algorithm(proposal, ENCRYPTION_ALGORITHM,
                                                                &enc_alg, &enc_size))
        {
-               DBG2(DBG_CHD, "  using %N for encryption", 
+               DBG2(DBG_CHD, "  using %N for encryption",
                         encryption_algorithm_names, enc_alg);
-               
+
                if (!enc_size)
                {
                        enc_size = lookup_keylen(keylen_enc, enc_alg);
@@ -412,7 +412,7 @@ static bool derive_child_keys(private_keymat_t *this,
                }
                /* to bytes */
                enc_size /= 8;
-               
+
                /* CCM/GCM/CTR needs additional bytes */
                switch (enc_alg)
                {
@@ -434,13 +434,13 @@ static bool derive_child_keys(private_keymat_t *this,
                                break;
                }
        }
-       
+
        if (proposal->get_algorithm(proposal, INTEGRITY_ALGORITHM,
                                                                &int_alg, &int_size))
        {
                DBG2(DBG_CHD, "  using %N for integrity",
                         integrity_algorithm_names, int_alg);
-               
+
                if (!int_size)
                {
                        int_size = lookup_keylen(keylen_int, int_alg);
@@ -454,17 +454,17 @@ static bool derive_child_keys(private_keymat_t *this,
                /* to bytes */
                int_size /= 8;
        }
-       
+
        this->prf->set_key(this->prf, this->skd);
        prf_plus = prf_plus_create(this->prf, seed);
-       
+
        prf_plus->allocate_bytes(prf_plus, enc_size, encr_i);
        prf_plus->allocate_bytes(prf_plus, int_size, integ_i);
        prf_plus->allocate_bytes(prf_plus, enc_size, encr_r);
        prf_plus->allocate_bytes(prf_plus, int_size, integ_r);
-       
+
        prf_plus->destroy(prf_plus);
-       
+
        if (enc_size)
        {
                DBG4(DBG_CHD, "encryption initiator key %B", encr_i);
@@ -512,19 +512,19 @@ static chunk_t get_auth_octets(private_keymat_t *this, bool verify,
 {
        chunk_t chunk, idx, octets;
        chunk_t skp;
-       
+
        skp = verify ? this->skp_verify : this->skp_build;
-       
+
        chunk = chunk_alloca(4);
        memset(chunk.ptr, 0, chunk.len);
        chunk.ptr[0] = id->get_type(id);
        idx = chunk_cata("cc", chunk, id->get_encoding(id));
-       
+
        DBG3(DBG_IKE, "IDx' %B", &idx);
        DBG3(DBG_IKE, "SK_p %B", &skp);
        this->prf->set_key(this->prf, skp);
        this->prf->allocate_bytes(this->prf, idx, &chunk);
-       
+
        octets = chunk_cat("ccm", ike_sa_init, nonce, chunk);
        DBG3(DBG_IKE, "octets = message + nonce + prf(Sk_px, IDx') %B", &octets);
        return octets;
@@ -539,12 +539,12 @@ static chunk_t get_auth_octets(private_keymat_t *this, bool verify,
 /**
  * Implementation of keymat_t.get_psk_sig
  */
-static chunk_t get_psk_sig(private_keymat_t *this, bool verify, 
+static chunk_t get_psk_sig(private_keymat_t *this, bool verify,
                                                   chunk_t ike_sa_init, chunk_t nonce, chunk_t secret,
                                                   identification_t *id)
 {
        chunk_t key_pad, key, sig, octets;
-       
+
        if (!secret.len)
        {       /* EAP uses SK_p if no MSK has been established */
                secret = verify ? this->skp_verify : this->skp_build;
@@ -561,7 +561,7 @@ static chunk_t get_psk_sig(private_keymat_t *this, bool verify,
        DBG3(DBG_IKE, "AUTH = prf(prf(secret, keypad), octets) %B", &sig);
        chunk_free(&octets);
        chunk_free(&key);
-       
+
        return sig;
 }
 
@@ -587,7 +587,7 @@ static void destroy(private_keymat_t *this)
 keymat_t *keymat_create(bool initiator)
 {
        private_keymat_t *this = malloc_thing(private_keymat_t);
-       
+
        this->public.create_dh = (diffie_hellman_t*(*)(keymat_t*, diffie_hellman_group_t group))create_dh;
        this->public.derive_ike_keys = (bool(*)(keymat_t*, proposal_t *proposal, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id, pseudo_random_function_t,chunk_t))derive_ike_keys;
        this->public.derive_child_keys = (bool(*)(keymat_t*, proposal_t *proposal, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r, chunk_t *encr_i, chunk_t *integ_i, chunk_t *encr_r, chunk_t *integ_r))derive_child_keys;
@@ -597,9 +597,9 @@ keymat_t *keymat_create(bool initiator)
        this->public.get_auth_octets = (chunk_t(*)(keymat_t *, bool verify, chunk_t ike_sa_init, chunk_t nonce, identification_t *id))get_auth_octets;
        this->public.get_psk_sig = (chunk_t(*)(keymat_t*, bool verify, chunk_t ike_sa_init, chunk_t nonce, chunk_t secret, identification_t *id))get_psk_sig;
        this->public.destroy = (void(*)(keymat_t*))destroy;
-       
+
        this->initiator = initiator;
-       
+
        this->signer_in = NULL;
        this->signer_out = NULL;
        this->crypter_in = NULL;
@@ -609,7 +609,7 @@ keymat_t *keymat_create(bool initiator)
        this->skd = chunk_empty;
        this->skp_verify = chunk_empty;
        this->skp_build = chunk_empty;
-       
+
        return &this->public;
 }
 
index 43b9dd113429ade1d3d7ade8cf78c2d0fdd4554f..cc0a3e1e6a0d44fc89d39517574321b538c7f485 100644 (file)
@@ -35,7 +35,7 @@ typedef struct keymat_t keymat_t;
  * Derivation an management of sensitive keying material.
  */
 struct keymat_t {
-       
+
        /**
         * Create a diffie hellman object for key agreement.
         *
@@ -47,7 +47,7 @@ struct keymat_t {
         * @return                              DH object, NULL if group not supported
         */
        diffie_hellman_t* (*create_dh)(keymat_t *this, diffie_hellman_group_t group);
-       
+
        /**
         * Derive keys for the IKE_SA.
         *
@@ -86,7 +86,7 @@ struct keymat_t {
         * @param integ_r       chunk to write responders integrity key to
         * @return                      TRUE on success
         */
-       bool (*derive_child_keys)(keymat_t *this, 
+       bool (*derive_child_keys)(keymat_t *this,
                                                          proposal_t *proposal, diffie_hellman_t *dh,
                                                          chunk_t nonce_i, chunk_t nonce_r,
                                                          chunk_t *encr_i, chunk_t *integ_i,
@@ -98,7 +98,7 @@ struct keymat_t {
         * @return                      PRF function to derive keymat
         */
        pseudo_random_function_t (*get_skd)(keymat_t *this, chunk_t *skd);
-       
+
        /**
         * Get a signer to sign/verify IKE messages.
         *
@@ -106,7 +106,7 @@ struct keymat_t {
         * @return                      signer
         */
        signer_t* (*get_signer)(keymat_t *this, bool in);
-       
+
        /*
         * Get a crypter to en-/decrypt IKE messages.
         *
@@ -114,7 +114,7 @@ struct keymat_t {
         * @return                      crypter
         */
        crypter_t* (*get_crypter)(keymat_t *this, bool in);
-       
+
        /**
         * Generate octets to use for authentication procedure (RFC4306 2.15).
         *
index a69c0017348bf3e6c0b57da390aeec0367458687..b91a6616304f92b762fb37a33eb27828e136931b 100644 (file)
@@ -31,8 +31,8 @@ struct peer_t {
     identification_t *id;
 
        /** sa id of the peer, NULL if offline */
-    ike_sa_id_t *ike_sa_id;   
-    
+    ike_sa_id_t *ike_sa_id;
+
     /** list of peer ids that reuested this peer */
     linked_list_t *requested_by;
 };
@@ -54,12 +54,12 @@ static void peer_destroy(peer_t *this)
 static peer_t *peer_create(identification_t *id, ike_sa_id_t* ike_sa_id)
 {
        peer_t *this = malloc_thing(peer_t);
-       
+
        /* clone everything */
        this->id = id->clone(id);
     this->ike_sa_id = ike_sa_id ? ike_sa_id->clone(ike_sa_id) : NULL;
     this->requested_by = linked_list_create();
-    
+
        return this;
 }
 
@@ -74,7 +74,7 @@ struct private_mediation_manager_t {
         * Public interface of mediation_manager_t.
         */
         mediation_manager_t public;
-       
+
         /**
          * Lock for exclusivly accessing the manager.
          */
@@ -93,7 +93,7 @@ static void register_peer(peer_t *peer, identification_t *peer_id)
 {
        iterator_t *iterator;
        identification_t *current;
-       
+
        iterator = peer->requested_by->create_iterator(peer->requested_by, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
@@ -104,7 +104,7 @@ static void register_peer(peer_t *peer, identification_t *peer_id)
                }
        }
        iterator->destroy(iterator);
-       
+
        peer->requested_by->insert_last(peer->requested_by, peer_id->clone(peer_id));
 }
 
@@ -117,7 +117,7 @@ static status_t get_peer_by_id(private_mediation_manager_t *this,
        iterator_t *iterator;
        peer_t *current;
        status_t status = NOT_FOUND;
-       
+
        iterator = this->peers->create_iterator(this->peers, TRUE);
        while (iterator->iterate(iterator, (void**)&current))
        {
@@ -161,7 +161,7 @@ static void unregister_peer(private_mediation_manager_t *this, identification_t
                        }
                }
                iterator_r->destroy(iterator_r);
-               
+
                if (!peer->ike_sa_id && !peer->requested_by->get_count(peer->requested_by))
                {
                        iterator->remove(iterator);
@@ -181,16 +181,16 @@ static void remove_sa(private_mediation_manager_t *this, ike_sa_id_t *ike_sa_id)
        peer_t *peer;
 
        this->mutex->lock(this->mutex);
-       
+
        iterator = this->peers->create_iterator(this->peers, TRUE);
        while (iterator->iterate(iterator, (void**)&peer))
        {
                if (ike_sa_id->equals(ike_sa_id, peer->ike_sa_id))
                {
                        iterator->remove(iterator);
-                       
+
                        unregister_peer(this, peer->id);
-                       
+
                        peer_destroy(peer);
                        break;
                }
@@ -222,7 +222,7 @@ static void update_sa_id(private_mediation_manager_t *this, identification_t *pe
                }
        }
        iterator->destroy(iterator);
-       
+
        if (!found)
        {
                DBG2(DBG_IKE, "adding peer '%Y'", peer_id);
@@ -230,9 +230,9 @@ static void update_sa_id(private_mediation_manager_t *this, identification_t *pe
                this->peers->insert_last(this->peers, peer);
        }
 
-       DBG2(DBG_IKE, "changing registered IKE_SA ID of peer '%Y'", peer_id);                   
+       DBG2(DBG_IKE, "changing registered IKE_SA ID of peer '%Y'", peer_id);
        peer->ike_sa_id = ike_sa_id ? ike_sa_id->clone(ike_sa_id) : NULL;
-       
+
        /* send callbacks to registered peers */
        identification_t *requester;
        while(peer->requested_by->remove_last(peer->requested_by, (void**)&requester) == SUCCESS)
@@ -241,7 +241,7 @@ static void update_sa_id(private_mediation_manager_t *this, identification_t *pe
                charon->processor->queue_job(charon->processor, job);
                requester->destroy(requester);
        }
-       
+
        this->mutex->unlock(this->mutex);
 }
 
@@ -286,7 +286,7 @@ static ike_sa_id_t *check_and_register(private_mediation_manager_t *this,
                peer = peer_create(peer_id, NULL);
                this->peers->insert_last(this->peers, peer);
        }
-       
+
        if (!peer->ike_sa_id)
        {
                /* the peer is not online */
@@ -309,9 +309,9 @@ static ike_sa_id_t *check_and_register(private_mediation_manager_t *this,
 static void destroy(private_mediation_manager_t *this)
 {
        this->mutex->lock(this->mutex);
-       
+
        this->peers->destroy_function(this->peers, (void*)peer_destroy);
-       
+
        this->mutex->unlock(this->mutex);
        this->mutex->destroy(this->mutex);
        free(this);
@@ -329,9 +329,9 @@ mediation_manager_t *mediation_manager_create()
        this->public.update_sa_id = (void(*)(mediation_manager_t*,identification_t*,ike_sa_id_t*))update_sa_id;
        this->public.check = (ike_sa_id_t*(*)(mediation_manager_t*,identification_t*))check;
        this->public.check_and_register = (ike_sa_id_t*(*)(mediation_manager_t*,identification_t*,identification_t*))check_and_register;
-       
+
        this->peers = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
-       
+
        return (mediation_manager_t*)this;
 }
index 29e16d84f86a727306cf963db7e733cb4d9cfb9e..60d2ccf766e1fd08162661a04d0134d873a2a052 100644 (file)
@@ -31,48 +31,48 @@ typedef struct mediation_manager_t mediation_manager_t;
  * peers and registered requests for offline peers on the mediation server.
  */
 struct mediation_manager_t {
-       
+
        /**
         * Remove the IKE_SA of a peer.
-        * 
+        *
         * @param ike_sa_id                     the IKE_SA ID of the peer's SA
         */
        void (*remove) (mediation_manager_t* this, ike_sa_id_t *ike_sa_id);
-       
+
        /**
         * Update the ike_sa_id that is assigned to a peer's ID. If the peer
-        * is new, it gets a new record assigned. 
-        * 
+        * is new, it gets a new record assigned.
+        *
         * @param peer_id                       the peer's ID
         * @param ike_sa_id                     the IKE_SA ID of the peer's SA
         */
        void (*update_sa_id) (mediation_manager_t* this, identification_t *peer_id,
                        ike_sa_id_t *ike_sa_id);
-       
+
        /**
         * Checks if a specific peer is online.
-        * 
+        *
         * @param peer_id                       the peer's ID
-        * @returns                                     
+        * @returns
         *                                                      - IKE_SA ID of the peer's SA.
         *                                                      - NULL, if the peer is not online.
         */
        ike_sa_id_t* (*check) (mediation_manager_t* this,
                        identification_t *peer_id);
-       
+
        /**
         * Checks if a specific peer is online and registers the requesting
         * peer if it is not.
-        * 
+        *
         * @param peer_id                       the peer's ID
         * @param requester                     the requesters ID
-        * @returns                                     
+        * @returns
         *                                                      - IKE_SA ID of the peer's SA.
         *                                                      - NULL, if the peer is not online.
         */
        ike_sa_id_t* (*check_and_register) (mediation_manager_t* this,
                        identification_t *peer_id, identification_t *requester);
-       
+
        /**
         * Destroys the manager with all data.
         */
@@ -81,7 +81,7 @@ struct mediation_manager_t {
 
 /**
  * Create a manager.
- * 
+ *
  * @returns    mediation_manager_t object
  */
 mediation_manager_t *mediation_manager_create(void);
index b3d678bf3e5d73f24b29aaf6b5c695ae24a60caf..0504cde4550d2864dbd108697736fcffd30db945 100644 (file)
@@ -46,12 +46,12 @@ typedef struct exchange_t exchange_t;
  * An exchange in the air, used do detect and handle retransmission
  */
 struct exchange_t {
-       
+
        /**
         * Message ID used for this transaction
         */
        u_int32_t mid;
-       
+
        /**
         * generated packet for retransmission
         */
@@ -64,17 +64,17 @@ typedef struct private_task_manager_t private_task_manager_t;
  * private data of the task manager
  */
 struct private_task_manager_t {
-       
+
        /**
         * public functions
         */
        task_manager_t public;
-       
+
        /**
         * associated IKE_SA we are serving
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Exchange we are currently handling as responder
         */
@@ -83,14 +83,14 @@ struct private_task_manager_t {
                 * Message ID of the exchange
                 */
                u_int32_t mid;
-               
+
                /**
                 * packet for retransmission
                 */
                packet_t *packet;
-               
+
        } responding;
-       
+
        /**
         * Exchange we are currently handling as initiator
         */
@@ -99,7 +99,7 @@ struct private_task_manager_t {
                 * Message ID of the exchange
                 */
                u_int32_t mid;
-               
+
                /**
                 * how many times we have retransmitted so far
                 */
@@ -109,29 +109,29 @@ struct private_task_manager_t {
                 * packet for retransmission
                 */
                packet_t *packet;
-               
+
                /**
                 * type of the initated exchange
                 */
                exchange_type_t type;
-       
+
        } initiating;
-       
+
        /**
         * List of queued tasks not yet in action
         */
        linked_list_t *queued_tasks;
-       
+
        /**
         * List of active tasks, initiated by ourselve
         */
        linked_list_t *active_tasks;
-       
+
        /**
         * List of tasks initiated by peer
         */
        linked_list_t *passive_tasks;
-       
+
        /**
         * the task manager has been reset
         */
@@ -162,7 +162,7 @@ static bool activate_task(private_task_manager_t *this, task_type_t type)
        iterator_t *iterator;
        task_t *task;
        bool found = FALSE;
-       
+
        iterator = this->queued_tasks->create_iterator(this->queued_tasks, TRUE);
        while (iterator->iterate(iterator, (void**)&task))
        {
@@ -192,7 +192,7 @@ static status_t retransmit(private_task_manager_t *this, u_int32_t message_id)
                packet_t *packet;
                task_t *task;
                ike_mobike_t *mobike = NULL;
-               
+
                /* check if we are retransmitting a MOBIKE routability check */
                iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
                while (iterator->iterate(iterator, (void*)&task))
@@ -226,7 +226,7 @@ static status_t retransmit(private_task_manager_t *this, u_int32_t message_id)
                                }
                                return DESTROY_ME;
                        }
-                       
+
                        if (this->initiating.retransmitted)
                        {
                                DBG1(DBG_IKE, "retransmit %d of request with message ID %d",
@@ -247,7 +247,7 @@ static status_t retransmit(private_task_manager_t *this, u_int32_t message_id)
                                charon->bus->ike_updown(charon->bus, this->ike_sa, FALSE);
                                return DESTROY_ME;
                        }
-                       
+
                        if (this->initiating.retransmitted)
                        {
                                DBG1(DBG_IKE, "path probing attempt %d",
@@ -256,9 +256,9 @@ static status_t retransmit(private_task_manager_t *this, u_int32_t message_id)
                        packet = this->initiating.packet->clone(this->initiating.packet);
                        mobike->transmit(mobike, packet);
                }
-               
+
                charon->sender->send(charon->sender, packet);
-               
+
                this->initiating.retransmitted++;
                job = (job_t*)retransmit_job_create(this->initiating.mid,
                                                                                        this->ike_sa->get_id(this->ike_sa));
@@ -279,14 +279,14 @@ static status_t build_request(private_task_manager_t *this)
        host_t *me, *other;
        status_t status;
        exchange_type_t exchange = 0;
-       
+
        if (this->initiating.type != EXCHANGE_TYPE_UNDEFINED)
        {
                DBG2(DBG_IKE, "delaying task initiation, exchange in progress");
                /* do not initiate if we already have a message in the air */
                return SUCCESS;
        }
-       
+
        if (this->active_tasks->get_count(this->active_tasks) == 0)
        {
                DBG2(DBG_IKE, "activating new tasks");
@@ -402,17 +402,17 @@ static status_t build_request(private_task_manager_t *this)
                }
                iterator->destroy(iterator);
        }
-       
+
        if (exchange == 0)
        {
                DBG2(DBG_IKE, "nothing to initiate");
                /* nothing to do yet... */
                return SUCCESS;
        }
-       
+
        me = this->ike_sa->get_my_host(this->ike_sa);
        other = this->ike_sa->get_other_host(this->ike_sa);
-       
+
        message = message_create();
        message->set_message_id(message, this->initiating.mid);
        message->set_source(message, me->clone(me));
@@ -420,7 +420,7 @@ static status_t build_request(private_task_manager_t *this)
        message->set_exchange_type(message, exchange);
        this->initiating.type = exchange;
        this->initiating.retransmitted = 0;
-       
+
        iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
        while (iterator->iterate(iterator, (void*)&task))
        {
@@ -450,10 +450,10 @@ static status_t build_request(private_task_manager_t *this)
                }
        }
        iterator->destroy(iterator);
-       
+
        /* update exchange type if a task changed it */
        this->initiating.type = message->get_exchange_type(message);
-       
+
        status = this->ike_sa->generate_message(this->ike_sa, message,
                                                                                        &this->initiating.packet);
        if (status != SUCCESS)
@@ -465,10 +465,10 @@ static status_t build_request(private_task_manager_t *this)
                charon->bus->ike_updown(charon->bus, this->ike_sa, FALSE);
                return DESTROY_ME;
        }
-       
+
        charon->bus->message(charon->bus, message, FALSE);
        message->destroy(message);
-       
+
        return retransmit(this, this->initiating.mid);
 }
 
@@ -480,7 +480,7 @@ static status_t process_response(private_task_manager_t *this,
 {
        iterator_t *iterator;
        task_t *task;
-       
+
        if (message->get_exchange_type(message) != this->initiating.type)
        {
                DBG1(DBG_IKE, "received %N response, but expected %N",
@@ -489,7 +489,7 @@ static status_t process_response(private_task_manager_t *this,
                charon->bus->ike_updown(charon->bus, this->ike_sa, FALSE);
                return DESTROY_ME;
        }
-       
+
        /* catch if we get resetted while processing */
        this->reset = FALSE;
        iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
@@ -524,12 +524,12 @@ static status_t process_response(private_task_manager_t *this,
                }
        }
        iterator->destroy(iterator);
-       
+
        this->initiating.mid++;
        this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
        this->initiating.packet->destroy(this->initiating.packet);
        this->initiating.packet = NULL;
-       
+
        return build_request(this);
 }
 
@@ -541,9 +541,9 @@ static void handle_collisions(private_task_manager_t *this, task_t *task)
        iterator_t *iterator;
        task_t *active;
        task_type_t type;
-       
+
        type = task->get_type(task);
-       
+
        /* do we have to check  */
        if (type == IKE_REKEY || type == CHILD_REKEY ||
                type == CHILD_DELETE || type == IKE_DELETE || type == IKE_REAUTH)
@@ -594,10 +594,10 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
        host_t *me, *other;
        bool delete = FALSE;
        status_t status;
-       
+
        me = request->get_destination(request);
        other = request->get_source(request);
-       
+
        message = message_create();
        message->set_exchange_type(message, request->get_exchange_type(request));
        /* send response along the path the request came in */
@@ -605,7 +605,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
        message->set_destination(message, other->clone(other));
        message->set_message_id(message, this->responding.mid);
        message->set_request(message, FALSE);
-       
+
        iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
        while (iterator->iterate(iterator, (void*)&task))
        {
@@ -633,14 +633,14 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
                }
        }
        iterator->destroy(iterator);
-       
+
        /* remove resonder SPI if IKE_SA_INIT failed */
        if (delete && request->get_exchange_type(request) == IKE_SA_INIT)
        {
                ike_sa_id_t *id = this->ike_sa->get_id(this->ike_sa);
                id->set_responder_spi(id, 0);
        }
-       
+
        /* message complete, send it */
        DESTROY_IF(this->responding.packet);
        this->responding.packet = NULL;
@@ -653,7 +653,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
                charon->bus->ike_updown(charon->bus, this->ike_sa, FALSE);
                return DESTROY_ME;
        }
-       
+
        charon->sender->send(charon->sender,
                                                 this->responding.packet->clone(this->responding.packet));
        if (delete)
@@ -675,7 +675,7 @@ static status_t process_request(private_task_manager_t *this,
        payload_t *payload;
        notify_payload_t *notify;
        delete_payload_t *delete;
-       
+
        if (this->passive_tasks->get_count(this->passive_tasks) == 0)
        {       /* create tasks depending on request type, if not already some queued */
                switch (message->get_exchange_type(message))
@@ -737,7 +737,7 @@ static status_t process_request(private_task_manager_t *this,
                                        }
                                }
                                enumerator->destroy(enumerator);
-                               
+
                                if (ts_found)
                                {
                                        if (notify_found)
@@ -816,7 +816,7 @@ static status_t process_request(private_task_manager_t *this,
                                        }
                                }
                                enumerator->destroy(enumerator);
-                       
+
                                if (task == NULL)
                                {
                                        task = (task_t*)ike_dpd_create(FALSE);
@@ -835,7 +835,7 @@ static status_t process_request(private_task_manager_t *this,
                                break;
                }
        }
-       
+
        /* let the tasks process the message */
        iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
        while (iterator->iterate(iterator, (void*)&task))
@@ -863,7 +863,7 @@ static status_t process_request(private_task_manager_t *this,
                }
        }
        iterator->destroy(iterator);
-       
+
        return build_response(this, message);
 }
 
@@ -873,7 +873,7 @@ static status_t process_request(private_task_manager_t *this,
 static status_t process_message(private_task_manager_t *this, message_t *msg)
 {
        u_int32_t mid = msg->get_message_id(msg);
-       
+
        if (msg->get_request(msg))
        {
                if (mid == this->responding.mid)
@@ -890,7 +890,7 @@ static status_t process_message(private_task_manager_t *this, message_t *msg)
                {
                        packet_t *clone;
                        host_t *me, *other;
-                       
+
                        DBG1(DBG_IKE, "received retransmit of request with ID %d, "
                                 "retransmitting response", mid);
                        clone = this->responding.packet->clone(this->responding.packet);
@@ -935,7 +935,7 @@ static void queue_task(private_task_manager_t *this, task_t *task)
        {       /*  there is no need to queue more than one mobike task */
                iterator_t *iterator;
                task_t *current;
-               
+
                iterator = this->queued_tasks->create_iterator(this->queued_tasks, TRUE);
                while (iterator->iterate(iterator, (void**)&current))
                {
@@ -958,7 +958,7 @@ static void queue_task(private_task_manager_t *this, task_t *task)
 static void adopt_tasks(private_task_manager_t *this, private_task_manager_t *other)
 {
        task_t *task;
-       
+
        /* move queued tasks from other to this */
        while (other->queued_tasks->remove_last(other->queued_tasks,
                                                                                                (void**)&task) == SUCCESS)
@@ -984,7 +984,7 @@ static void reset(private_task_manager_t *this,
                                  u_int32_t initiate, u_int32_t respond)
 {
        task_t *task;
-       
+
        /* reset message counters and retransmit packets */
        DESTROY_IF(this->responding.packet);
        DESTROY_IF(this->initiating.packet);
@@ -999,7 +999,7 @@ static void reset(private_task_manager_t *this,
                this->responding.mid = respond;
        }
        this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
-       
+
        /* reset active tasks */
        while (this->active_tasks->remove_last(this->active_tasks,
                                                                                   (void**)&task) == SUCCESS)
@@ -1007,7 +1007,7 @@ static void reset(private_task_manager_t *this,
                task->migrate(task, this->ike_sa);
                this->queued_tasks->insert_first(this->queued_tasks, task);
        }
-       
+
        this->reset = TRUE;
 }
 
@@ -1017,11 +1017,11 @@ static void reset(private_task_manager_t *this,
 static void destroy(private_task_manager_t *this)
 {
        flush(this);
-       
+
        this->active_tasks->destroy(this->active_tasks);
        this->queued_tasks->destroy(this->queued_tasks);
        this->passive_tasks->destroy(this->passive_tasks);
-       
+
        DESTROY_IF(this->responding.packet);
        DESTROY_IF(this->initiating.packet);
        free(this);
@@ -1033,7 +1033,7 @@ static void destroy(private_task_manager_t *this)
 task_manager_t *task_manager_create(ike_sa_t *ike_sa)
 {
        private_task_manager_t *this = malloc_thing(private_task_manager_t);
-       
+
        this->public.process_message = (status_t(*)(task_manager_t*,message_t*))process_message;
        this->public.queue_task = (void(*)(task_manager_t*,task_t*))queue_task;
        this->public.initiate = (status_t(*)(task_manager_t*))build_request;
@@ -1042,7 +1042,7 @@ task_manager_t *task_manager_create(ike_sa_t *ike_sa)
        this->public.adopt_tasks = (void(*)(task_manager_t*,task_manager_t*))adopt_tasks;
        this->public.busy = (bool(*)(task_manager_t*))busy;
        this->public.destroy = (void(*)(task_manager_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->responding.packet = NULL;
        this->initiating.packet = NULL;
@@ -1053,6 +1053,6 @@ task_manager_t *task_manager_create(ike_sa_t *ike_sa)
        this->active_tasks = linked_list_create();
        this->passive_tasks = linked_list_create();
        this->reset = FALSE;
-       
+
        return &this->public;
 }
index 9c3b2cc8756baf6b74e4c1c3df4ce9b548e108b5..11c85a83769c7eaa06a34d6ebe7cd8d3e4bd29b0 100644 (file)
@@ -69,7 +69,7 @@ typedef struct task_manager_t task_manager_t;
  * For the initial IKE_SA setup, several tasks are queued: One for the
  * unauthenticated IKE_SA setup, one for authentication, one for CHILD_SA setup
  * and maybe one for virtual IP assignement.
- * The task manager is also responsible for retransmission. It uses a backoff 
+ * The task manager is also responsible for retransmission. It uses a backoff
  * algorithm. The timeout is calculated using
  * RETRANSMIT_TIMEOUT * (RETRANSMIT_BASE ** try).
  * When try reaches RETRANSMIT_TRIES, retransmission is given up.
@@ -84,7 +84,7 @@ typedef struct task_manager_t task_manager_t;
    4s * (1.8 ** 3) =   23s        47s
    4s * (1.8 ** 4) =   42s        89s
    4s * (1.8 ** 5) =   76s       165s
+
    @endverbatim
  * The peer is considered dead after 2min 45s when no reply comes in.
  */
@@ -92,7 +92,7 @@ struct task_manager_t {
 
        /**
         * Process an incoming message.
-        * 
+        *
         * @param message               message to add payloads to
         * @return
         *                                              - DESTROY_ME if IKE_SA must be closed
@@ -118,24 +118,24 @@ struct task_manager_t {
         * A return value of INVALID_STATE means that the message was already
         * acknowledged and has not to be retransmitted. A return value of SUCCESS
         * means retransmission was required and the message has been resent.
-        * 
+        *
         * @param message_id    ID of the message to retransmit
         * @return
         *                                              - INVALID_STATE if retransmission not required
         *                                              - SUCCESS if retransmission sent
         */
        status_t (*retransmit) (task_manager_t *this, u_int32_t message_id);
-       
+
        /**
         * Migrate all tasks from other to this.
         *
         * To rekey or reestablish an IKE_SA completely, all queued or active
         * tasks should get migrated to the new IKE_SA.
-        * 
+        *
         * @param other                 manager which gives away its tasks
         */
        void (*adopt_tasks) (task_manager_t *this, task_manager_t *other);
-       
+
        /**
         * Reset message ID counters of the task manager.
         *
@@ -149,14 +149,14 @@ struct task_manager_t {
         * @param respond               message ID to respond to exchanges (expect)
         */
        void (*reset) (task_manager_t *this, u_int32_t initiate, u_int32_t respond);
-       
+
        /**
         * Check if we are currently waiting for a reply.
         *
         * @return                              TRUE if we are waiting, FALSE otherwise
         */
        bool (*busy) (task_manager_t *this);
-       
+
        /**
         * Destroy the task_manager_t.
         */
index 558938f2eb7eaef96dbd641c729e6792c96bcdf5..def190d230cc32738d87b4c3ba6ee09726c4f921 100644 (file)
@@ -33,132 +33,132 @@ typedef struct private_child_create_t private_child_create_t;
  * Private members of a child_create_t task.
  */
 struct private_child_create_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        child_create_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * nonce chosen by us
         */
        chunk_t my_nonce;
-       
+
        /**
         * nonce chosen by peer
         */
        chunk_t other_nonce;
-       
+
        /**
         * config to create the CHILD_SA from
         */
        child_cfg_t *config;
-       
+
        /**
         * list of proposal candidates
         */
        linked_list_t *proposals;
-       
+
        /**
         * selected proposal to use for CHILD_SA
         */
        proposal_t *proposal;
-       
+
        /**
         * traffic selectors for initiators side
         */
        linked_list_t *tsi;
-       
+
        /**
         * traffic selectors for responders side
         */
        linked_list_t *tsr;
-       
+
        /**
         * source of triggering packet
         */
        traffic_selector_t *packet_tsi;
-       
+
        /**
         * destination of triggering packet
         */
        traffic_selector_t *packet_tsr;
-       
+
        /**
         * optional diffie hellman exchange
         */
        diffie_hellman_t *dh;
-       
+
        /**
         * group used for DH exchange
         */
        diffie_hellman_group_t dh_group;
-       
+
        /**
         * IKE_SAs keymat
         */
        keymat_t *keymat;
-       
+
        /**
         * mode the new CHILD_SA uses (transport/tunnel/beet)
         */
        ipsec_mode_t mode;
-       
+
        /**
         * IPComp transform to use
         */
        ipcomp_transform_t ipcomp;
-       
+
        /**
         * IPComp transform proposed or accepted by the other peer
         */
        ipcomp_transform_t ipcomp_received;
-       
+
        /**
         * Own allocated SPI
         */
        u_int32_t my_spi;
-       
+
        /**
         * SPI received in proposal
         */
        u_int32_t other_spi;
-       
+
        /**
         * Own allocated Compression Parameter Index (CPI)
         */
        u_int16_t my_cpi;
-       
+
        /**
         * Other Compression Parameter Index (CPI), received via IPCOMP_SUPPORTED
         */
        u_int16_t other_cpi;
-       
+
        /**
         * reqid to use if we are rekeying
         */
        u_int32_t reqid;
-       
+
        /**
         * CHILD_SA which gets established
         */
        child_sa_t *child_sa;
-       
+
        /**
         * successfully established the CHILD?
         */
        bool established;
-       
+
        /**
         * whether the CHILD_SA rekeys an existing one
         */
@@ -171,7 +171,7 @@ struct private_child_create_t {
 static status_t get_nonce(message_t *message, chunk_t *nonce)
 {
        nonce_payload_t *payload;
-       
+
        payload = (nonce_payload_t*)message->get_payload(message, NONCE);
        if (payload == NULL)
        {
@@ -187,7 +187,7 @@ static status_t get_nonce(message_t *message, chunk_t *nonce)
 static status_t generate_nonce(chunk_t *nonce)
 {
        rng_t *rng;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
        {
@@ -207,7 +207,7 @@ static bool ts_list_is_host(linked_list_t *list, host_t *host)
        traffic_selector_t *ts;
        bool is_host = TRUE;
        iterator_t *iterator = list->create_iterator(list, TRUE);
-       
+
        while (is_host && iterator->iterate(iterator, (void**)&ts))
        {
                is_host = is_host && ts->is_host(ts, host);
@@ -223,8 +223,8 @@ static bool allocate_spi(private_child_create_t *this)
 {
        enumerator_t *enumerator;
        proposal_t *proposal;
-       
-       /* TODO: allocate additional SPI for AH if we have such proposals */ 
+
+       /* TODO: allocate additional SPI for AH if we have such proposals */
        this->my_spi = this->child_sa->alloc_spi(this->child_sa, PROTO_ESP);
        if (this->my_spi)
        {
@@ -260,7 +260,7 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
        chunk_t integ_i = chunk_empty, integ_r = chunk_empty;
        linked_list_t *my_ts, *other_ts;
        host_t *me, *other, *other_vip, *my_vip;
-       
+
        if (this->proposals == NULL)
        {
                DBG1(DBG_IKE, "SA payload missing in message");
@@ -271,12 +271,12 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
                DBG1(DBG_IKE, "TS payloads missing in message");
                return NOT_FOUND;
        }
-       
+
        me = this->ike_sa->get_my_host(this->ike_sa);
        other = this->ike_sa->get_other_host(this->ike_sa);
        my_vip = this->ike_sa->get_virtual_ip(this->ike_sa, TRUE);
        other_vip = this->ike_sa->get_virtual_ip(this->ike_sa, FALSE);
-       
+
        this->proposal = this->config->select_proposal(this->config, this->proposals,
                                                                                                   no_dh);
        if (this->proposal == NULL)
@@ -285,18 +285,18 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
                return FAILED;
        }
        this->other_spi = this->proposal->get_spi(this->proposal);
-       
+
        if (!this->initiator && !allocate_spi(this))
        {       /* responder has no SPI allocated yet */
                DBG1(DBG_IKE, "allocating SPI failed");
                return FAILED;
        }
        this->child_sa->set_proposal(this->child_sa, this->proposal);
-       
+
        if (!this->proposal->has_dh_group(this->proposal, this->dh_group))
        {
                u_int16_t group;
-               
+
                if (this->proposal->get_algorithm(this->proposal, DIFFIE_HELLMAN_GROUP,
                                                                                  &group, NULL))
                {
@@ -312,7 +312,7 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
                        return FAILED;
                }
        }
-       
+
        if (my_vip == NULL)
        {
                my_vip = me;
@@ -321,7 +321,7 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
        {
                other_vip = other;
        }
-       
+
        if (this->initiator)
        {
                nonce_i = this->my_nonce;
@@ -338,9 +338,9 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
        }
        my_ts = this->config->get_traffic_selectors(this->config, TRUE, my_ts,
                                                                                                my_vip);
-       other_ts = this->config->get_traffic_selectors(this->config, FALSE, other_ts, 
+       other_ts = this->config->get_traffic_selectors(this->config, FALSE, other_ts,
                                                                                                   other_vip);
-       
+
        if (my_ts->get_count(my_ts) == 0 || other_ts->get_count(other_ts) == 0)
        {
                my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
@@ -348,7 +348,7 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
                DBG1(DBG_IKE, "no acceptable traffic selectors found");
                return NOT_FOUND;
        }
-       
+
        this->tsr->destroy_offset(this->tsr, offsetof(traffic_selector_t, destroy));
        this->tsi->destroy_offset(this->tsi, offsetof(traffic_selector_t, destroy));
        if (this->initiator)
@@ -361,7 +361,7 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
                this->tsr = my_ts;
                this->tsi = other_ts;
        }
-       
+
        if (!this->initiator)
        {
                /* check if requested mode is acceptable, downgrade if required */
@@ -394,13 +394,13 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
                                break;
                }
        }
-       
+
        this->child_sa->set_state(this->child_sa, CHILD_INSTALLING);
        this->child_sa->set_ipcomp(this->child_sa, this->ipcomp);
        this->child_sa->set_mode(this->child_sa, this->mode);
        this->child_sa->set_protocol(this->child_sa,
                                                                 this->proposal->get_protocol(this->proposal));
-       
+
        if (this->my_cpi == 0 || this->other_cpi == 0 || this->ipcomp == IPCOMP_NONE)
        {
                this->my_cpi = this->other_cpi = 0;
@@ -429,7 +429,7 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
        chunk_clear(&integ_r);
        chunk_clear(&encr_i);
        chunk_clear(&encr_r);
-       
+
        if (status_i != SUCCESS || status_o != SUCCESS)
        {
                DBG1(DBG_IKE, "unable to install %s%s%sIPsec SA (SAD) in kernel",
@@ -438,17 +438,17 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
                        (status_o != SUCCESS) ? "outbound " : "");
                return FAILED;
        }
-       
+
        status = this->child_sa->add_policies(this->child_sa, my_ts, other_ts);
        if (status != SUCCESS)
-       {       
+       {
                DBG1(DBG_IKE, "unable to install IPsec policies (SPD) in kernel");
                return NOT_FOUND;
        }
-       
+
        charon->bus->child_keys(charon->bus, this->child_sa, this->dh,
                                                        nonce_i, nonce_r);
-       
+
        /* add to IKE_SA, and remove from task */
        this->child_sa->set_state(this->child_sa, CHILD_INSTALLED);
        this->ike_sa->add_child_sa(this->ike_sa, this->child_sa);
@@ -476,7 +476,7 @@ static void build_payloads(private_child_create_t *this, message_t *message)
                sa_payload = sa_payload_create_from_proposal(this->proposal);
        }
        message->add_payload(message, (payload_t*)sa_payload);
-       
+
        /* add nonce payload if not in IKE_AUTH */
        if (message->get_exchange_type(message) == CREATE_CHILD_SA)
        {
@@ -484,14 +484,14 @@ static void build_payloads(private_child_create_t *this, message_t *message)
                nonce_payload->set_nonce(nonce_payload, this->my_nonce);
                message->add_payload(message, (payload_t*)nonce_payload);
        }
-       
+
        /* diffie hellman exchange, if PFS enabled */
        if (this->dh)
        {
                ke_payload = ke_payload_create_from_diffie_hellman(this->dh);
                message->add_payload(message, (payload_t*)ke_payload);
        }
-       
+
        /* add TSi/TSr payloads */
        ts_payload = ts_payload_create_from_traffic_selectors(TRUE, this->tsi);
        message->add_payload(message, (payload_t*)ts_payload);
@@ -524,12 +524,12 @@ static void add_ipcomp_notify(private_child_create_t *this,
                         "IPComp disabled");
                return;
        }
-       
+
        this->my_cpi = this->child_sa->alloc_cpi(this->child_sa);
        if (this->my_cpi)
        {
                this->ipcomp = ipcomp;
-               message->add_notify(message, FALSE, IPCOMP_SUPPORTED, 
+               message->add_notify(message, FALSE, IPCOMP_SUPPORTED,
                                                        chunk_cata("cc", chunk_from_thing(this->my_cpi),
                                                                           chunk_from_thing(ipcomp)));
        }
@@ -557,7 +557,7 @@ static void handle_notify(private_child_create_t *this, notify_payload_t *notify
                        ipcomp_transform_t ipcomp;
                        u_int16_t cpi;
                        chunk_t data;
-                       
+
                        data = notify->get_notification_data(notify);
                        cpi = *(u_int16_t*)data.ptr;
                        ipcomp = (ipcomp_transform_t)(*(data.ptr + 2));
@@ -591,7 +591,7 @@ static void process_payloads(private_child_create_t *this, message_t *message)
        sa_payload_t *sa_payload;
        ke_payload_t *ke_payload;
        ts_payload_t *ts_payload;
-       
+
        /* defaults to TUNNEL mode */
        this->mode = MODE_TUNNEL;
 
@@ -620,7 +620,7 @@ static void process_payloads(private_child_create_t *this, message_t *message)
                        case TRAFFIC_SELECTOR_INITIATOR:
                                ts_payload = (ts_payload_t*)payload;
                                this->tsi = ts_payload->get_traffic_selectors(ts_payload);
-                               break;  
+                               break;
                        case TRAFFIC_SELECTOR_RESPONDER:
                                ts_payload = (ts_payload_t*)payload;
                                this->tsr = ts_payload->get_traffic_selectors(ts_payload);
@@ -642,7 +642,7 @@ static status_t build_i(private_child_create_t *this, message_t *message)
 {
        host_t *me, *other, *vip;
        peer_cfg_t *peer_cfg;
-       
+
        switch (message->get_exchange_type(message))
        {
                case IKE_SA_INIT:
@@ -668,7 +668,7 @@ static status_t build_i(private_child_create_t *this, message_t *message)
                default:
                        break;
        }
-       
+
        if (this->reqid)
        {
                DBG0(DBG_IKE, "establishing CHILD_SA %s{%d}",
@@ -679,7 +679,7 @@ static status_t build_i(private_child_create_t *this, message_t *message)
                DBG0(DBG_IKE, "establishing CHILD_SA %s",
                         this->config->get_name(this->config));
        }
-       
+
        /* reuse virtual IP if we already have one */
        me = this->ike_sa->get_virtual_ip(this->ike_sa, TRUE);
        if (me == NULL)
@@ -691,7 +691,7 @@ static status_t build_i(private_child_create_t *this, message_t *message)
        {
                other = this->ike_sa->get_other_host(this->ike_sa);
        }
-       
+
        /* check if we want a virtual IP, but don't have one */
        peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
        vip = peer_cfg->get_virtual_ip(peer_cfg);
@@ -708,9 +708,9 @@ static status_t build_i(private_child_create_t *this, message_t *message)
                this->tsi = this->config->get_traffic_selectors(this->config, TRUE,
                                                                                                                NULL, me);
        }
-       this->tsr = this->config->get_traffic_selectors(this->config, FALSE, 
+       this->tsr = this->config->get_traffic_selectors(this->config, FALSE,
                                                                                                        NULL, other);
-       
+
        if (this->packet_tsi)
        {
                this->tsi->insert_first(this->tsi,
@@ -724,37 +724,37 @@ static status_t build_i(private_child_create_t *this, message_t *message)
        this->proposals = this->config->get_proposals(this->config,
                                                                                                  this->dh_group == MODP_NONE);
        this->mode = this->config->get_mode(this->config);
-       
+
        this->child_sa = child_sa_create(this->ike_sa->get_my_host(this->ike_sa),
                        this->ike_sa->get_other_host(this->ike_sa), this->config, this->reqid,
                        this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY));
-       
+
        if (!allocate_spi(this))
        {
                DBG1(DBG_IKE, "unable to allocate SPIs from kernel");
                return FAILED;
        }
-       
+
        if (this->dh_group != MODP_NONE)
        {
                this->dh = this->keymat->create_dh(this->keymat, this->dh_group);
        }
-       
+
        if (this->config->use_ipcomp(this->config))
        {
                /* IPCOMP_DEFLATE is the only transform we support at the moment */
                add_ipcomp_notify(this, message, IPCOMP_DEFLATE);
        }
-       
+
        build_payloads(this, message);
-       
+
        this->tsi->destroy_offset(this->tsi, offsetof(traffic_selector_t, destroy));
        this->tsr->destroy_offset(this->tsr, offsetof(traffic_selector_t, destroy));
        this->proposals->destroy_offset(this->proposals, offsetof(proposal_t, destroy));
        this->tsi = NULL;
        this->tsr = NULL;
        this->proposals = NULL;
-       
+
        return NEED_MORE;
 }
 
@@ -779,9 +779,9 @@ static status_t process_r(private_child_create_t *this, message_t *message)
                default:
                        break;
        }
-       
+
        process_payloads(this, message);
-       
+
        return NEED_MORE;
 }
 
@@ -813,7 +813,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
        payload_t *payload;
        enumerator_t *enumerator;
        bool no_dh = TRUE;
-       
+
        switch (message->get_exchange_type(message))
        {
                case IKE_SA_INIT:
@@ -835,19 +835,19 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                default:
                        break;
        }
-       
+
        if (this->ike_sa->get_state(this->ike_sa) == IKE_REKEYING)
        {
                DBG1(DBG_IKE, "unable to create CHILD_SA while rekeying IKE_SA");
                message->add_notify(message, TRUE, NO_ADDITIONAL_SAS, chunk_empty);
                return SUCCESS;
        }
-       
+
        peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
        if (peer_cfg && this->tsi && this->tsr)
        {
                host_t *me, *other;
-               
+
                me = this->ike_sa->get_virtual_ip(this->ike_sa, TRUE);
                if (me == NULL)
                {
@@ -861,7 +861,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                this->config = peer_cfg->select_child_cfg(peer_cfg, this->tsr,
                                                                                                  this->tsi, me, other);
        }
-       
+
        if (this->config == NULL)
        {
                DBG1(DBG_IKE, "traffic selectors %#R=== %#R inacceptable",
@@ -870,7 +870,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                handle_child_sa_failure(this, message);
                return SUCCESS;
        }
-       
+
        /* check if ike_config_t included non-critical error notifies */
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
@@ -878,7 +878,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                if (payload->get_type(payload) == NOTIFY)
                {
                        notify_payload_t *notify = (notify_payload_t*)payload;
-                       
+
                        switch (notify->get_notify_type(notify))
                        {
                                case INTERNAL_ADDRESS_FAILURE:
@@ -896,11 +896,11 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        this->child_sa = child_sa_create(this->ike_sa->get_my_host(this->ike_sa),
                        this->ike_sa->get_other_host(this->ike_sa), this->config, this->reqid,
                        this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY));
-       
+
        if (this->ipcomp_received != IPCOMP_NONE)
        {
                if (this->config->use_ipcomp(this->config))
@@ -913,7 +913,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                                 notify_type_names, IPCOMP_SUPPORTED);
                }
        }
-       
+
        switch (select_and_install(this, no_dh))
        {
                case SUCCESS:
@@ -936,9 +936,9 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                        handle_child_sa_failure(this, message);
                        return SUCCESS;
        }
-       
+
        build_payloads(this, message);
-       
+
        DBG0(DBG_IKE, "CHILD_SA %s{%d} established "
                 "with SPIs %.8x_i %.8x_o and TS %#R=== %#R",
                 this->child_sa->get_name(this->child_sa),
@@ -947,7 +947,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
                 ntohl(this->child_sa->get_spi(this->child_sa, FALSE)),
                 this->child_sa->get_traffic_selectors(this->child_sa, TRUE),
                 this->child_sa->get_traffic_selectors(this->child_sa, FALSE));
-       
+
        if (!this->rekey)
        {       /* invoke the child_up() hook if we are not rekeying */
                charon->bus->child_updown(charon->bus, this->child_sa, TRUE);
@@ -989,7 +989,7 @@ static status_t process_i(private_child_create_t *this, message_t *message)
                {
                        notify_payload_t *notify = (notify_payload_t*)payload;
                        notify_type_t type = notify->get_notify_type(notify);
-                       
+
                        switch (type)
                        {
                                /* handle notify errors related to CHILD_SA only */
@@ -1012,14 +1012,14 @@ static status_t process_i(private_child_create_t *this, message_t *message)
                                {
                                        chunk_t data;
                                        diffie_hellman_group_t bad_group;
-                                       
+
                                        bad_group = this->dh_group;
                                        data = notify->get_notification_data(notify);
                                        this->dh_group = ntohs(*((u_int16_t*)data.ptr));
                                        DBG1(DBG_IKE, "peer didn't accept DH group %N, "
                                                 "it requested %N", diffie_hellman_group_names,
                                                 bad_group, diffie_hellman_group_names, this->dh_group);
-                                       
+
                                        this->public.task.migrate(&this->public.task, this->ike_sa);
                                        enumerator->destroy(enumerator);
                                        return NEED_MORE;
@@ -1030,9 +1030,9 @@ static status_t process_i(private_child_create_t *this, message_t *message)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        process_payloads(this, message);
-       
+
        if (this->ipcomp == IPCOMP_NONE && this->ipcomp_received != IPCOMP_NONE)
        {
                DBG1(DBG_IKE, "received an IPCOMP_SUPPORTED notify without requesting"
@@ -1053,7 +1053,7 @@ static status_t process_i(private_child_create_t *this, message_t *message)
                handle_child_sa_failure(this, message);
                return SUCCESS;
        }
-       
+
        if (select_and_install(this, no_dh) == SUCCESS)
        {
                DBG0(DBG_IKE, "CHILD_SA %s{%d} established "
@@ -1064,7 +1064,7 @@ static status_t process_i(private_child_create_t *this, message_t *message)
                         ntohl(this->child_sa->get_spi(this->child_sa, FALSE)),
                         this->child_sa->get_traffic_selectors(this->child_sa, TRUE),
                         this->child_sa->get_traffic_selectors(this->child_sa, FALSE));
-               
+
                if (!this->rekey)
                {       /* invoke the child_up() hook if we are not rekeying */
                        charon->bus->child_updown(charon->bus, this->child_sa, TRUE);
@@ -1105,7 +1105,7 @@ static child_sa_t* get_child(private_child_create_t *this)
  * Implementation of child_create_t.get_lower_nonce
  */
 static chunk_t get_lower_nonce(private_child_create_t *this)
-{      
+{
        if (memcmp(this->my_nonce.ptr, this->other_nonce.ptr,
                           min(this->my_nonce.len, this->other_nonce.len)) < 0)
        {
@@ -1139,7 +1139,7 @@ static void migrate(private_child_create_t *this, ike_sa_t *ike_sa)
        {
                this->proposals->destroy_offset(this->proposals, offsetof(proposal_t, destroy));
        }
-       
+
        this->ike_sa = ike_sa;
        this->keymat = ike_sa->get_keymat(ike_sa);
        this->proposal = NULL;
@@ -1183,7 +1183,7 @@ static void destroy(private_child_create_t *this)
        {
                this->proposals->destroy_offset(this->proposals, offsetof(proposal_t, destroy));
        }
-       
+
        DESTROY_IF(this->config);
        free(this);
 }
@@ -1216,7 +1216,7 @@ child_create_t *child_create_create(ike_sa_t *ike_sa,
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
                this->initiator = FALSE;
        }
-       
+
        this->ike_sa = ike_sa;
        this->config = config;
        this->my_nonce = chunk_empty;
@@ -1241,6 +1241,6 @@ child_create_t *child_create_create(ike_sa_t *ike_sa,
        this->reqid = 0;
        this->established = FALSE;
        this->rekey = rekey;
-       
+
        return &this->public;
 }
index 41f4fe2c8b9c8c25007a8a4ccfb9f94dbdc68aec..5dedeb8b1f41478c01e74459980ba233f29c71bf 100644 (file)
@@ -31,7 +31,7 @@ typedef struct child_create_t child_create_t;
 /**
  * Task of type CHILD_CREATE, established a new CHILD_SA.
  *
- * This task may be included in the IKE_AUTH message or in a separate 
+ * This task may be included in the IKE_AUTH message or in a separate
  * CREATE_CHILD_SA exchange.
  */
 struct child_create_t {
@@ -40,24 +40,24 @@ struct child_create_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Use a specific reqid for the CHILD_SA.
         *
         * When this task is used for rekeying, the same reqid is used
-        * for the new CHILD_SA. 
+        * for the new CHILD_SA.
         *
         * @param reqid         reqid to use
         */
        void (*use_reqid) (child_create_t *this, u_int32_t reqid);
-       
+
        /**
         * Get the lower of the two nonces, used for rekey collisions.
         *
         * @return                      lower nonce
         */
        chunk_t (*get_lower_nonce) (child_create_t *this);
-       
+
        /**
         * Get the CHILD_SA established/establishing by this task.
         *
index 849767854b58f8f8c3d020967a3c117b88f47911..d7c6b05414a12612184d461c4b26298d45432260 100644 (file)
@@ -25,42 +25,42 @@ typedef struct private_child_delete_t private_child_delete_t;
  * Private members of a child_delete_t task.
  */
 struct private_child_delete_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        child_delete_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * Protocol of CHILD_SA to delete
         */
        protocol_id_t protocol;
-       
+
        /**
         * Inbound SPI of CHILD_SA to delete
         */
        u_int32_t spi;
-       
+
        /**
         * whether to enforce delete action policy
         */
        bool check_delete_action;
-       
+
        /**
         * is this delete exchange following a rekey?
         */
        bool rekeyed;
-       
+
        /**
         * CHILD_SAs which get deleted
         */
@@ -75,10 +75,10 @@ static void build_payloads(private_child_delete_t *this, message_t *message)
        delete_payload_t *ah = NULL, *esp = NULL;
        iterator_t *iterator;
        child_sa_t *child_sa;
-       
+
        iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
        while (iterator->iterate(iterator, (void**)&child_sa))
-       {       
+       {
                protocol_id_t protocol = child_sa->get_protocol(child_sa);
                u_int32_t spi = child_sa->get_spi(child_sa, TRUE);
 
@@ -91,7 +91,7 @@ static void build_payloads(private_child_delete_t *this, message_t *message)
                                        message->add_payload(message, (payload_t*)esp);
                                }
                                esp->add_spi(esp, spi);
-                               DBG1(DBG_IKE, "sending DELETE for %N CHILD_SA with SPI %.8x", 
+                               DBG1(DBG_IKE, "sending DELETE for %N CHILD_SA with SPI %.8x",
                                                           protocol_id_names, protocol, ntohl(spi));
                                break;
                        case PROTO_AH:
@@ -101,7 +101,7 @@ static void build_payloads(private_child_delete_t *this, message_t *message)
                                        message->add_payload(message, (payload_t*)ah);
                                }
                                ah->add_spi(ah, spi);
-                               DBG1(DBG_IKE, "sending DELETE for %N CHILD_SA with SPI %.8x", 
+                               DBG1(DBG_IKE, "sending DELETE for %N CHILD_SA with SPI %.8x",
                                                           protocol_id_names, protocol, ntohl(spi));
                                break;
                        default:
@@ -124,7 +124,7 @@ static void process_payloads(private_child_delete_t *this, message_t *message)
        u_int32_t *spi;
        protocol_id_t protocol;
        child_sa_t *child_sa;
-       
+
        payloads = message->create_payload_enumerator(message);
        while (payloads->enumerate(payloads, &payload))
        {
@@ -147,9 +147,9 @@ static void process_payloads(private_child_delete_t *this, message_t *message)
                                                 "but no such SA", protocol_id_names, protocol, ntohl(*spi));
                                        continue;
                                }
-                               DBG1(DBG_IKE, "received DELETE for %N CHILD_SA with SPI %.8x", 
+                               DBG1(DBG_IKE, "received DELETE for %N CHILD_SA with SPI %.8x",
                                                protocol_id_names, protocol, ntohl(*spi));
-                               
+
                                switch (child_sa->get_state(child_sa))
                                {
                                        case CHILD_REKEYING:
@@ -172,7 +172,7 @@ static void process_payloads(private_child_delete_t *this, message_t *message)
                                        default:
                                                break;
                                }
-                               
+
                                this->child_sas->insert_last(this->child_sas, child_sa);
                        }
                        spis->destroy(spis);
@@ -192,7 +192,7 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
        protocol_id_t protocol;
        u_int32_t spi;
        status_t status = SUCCESS;
-       
+
        iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
        while (iterator->iterate(iterator, (void**)&child_sa))
        {
@@ -215,7 +215,7 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
                                        status = this->ike_sa->initiate(this->ike_sa, child_cfg, 0,
                                                                                                        NULL, NULL);
                                        break;
-                               case ACTION_ROUTE:      
+                               case ACTION_ROUTE:
                                        charon->traps->install(charon->traps,
                                                        this->ike_sa->get_peer_cfg(this->ike_sa), child_cfg);
                                        break;
@@ -241,13 +241,13 @@ static void log_children(private_child_delete_t *this)
        iterator_t *iterator;
        child_sa_t *child_sa;
        u_int64_t bytes_in, bytes_out;
-       
+
        iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
        while (iterator->iterate(iterator, (void**)&child_sa))
        {
                child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
                child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out);
-               
+
                DBG0(DBG_IKE, "closing CHILD_SA %s{%d} "
                         "with SPIs %.8x_i (%llu bytes) %.8x_o (%llu bytes) and TS %#R=== %#R",
                         child_sa->get_name(child_sa), child_sa->get_reqid(child_sa),
@@ -265,7 +265,7 @@ static void log_children(private_child_delete_t *this)
 static status_t build_i(private_child_delete_t *this, message_t *message)
 {
        child_sa_t *child_sa;
-       
+
        child_sa = this->ike_sa->get_child_sa(this->ike_sa, this->protocol,
                                                                                  this->spi, TRUE);
        if (!child_sa)
@@ -297,7 +297,7 @@ static status_t process_i(private_child_delete_t *this, message_t *message)
        /* flush the list before adding new SAs */
        this->child_sas->destroy(this->child_sas);
        this->child_sas = linked_list_create();
-       
+
        process_payloads(this, message);
        DBG1(DBG_IKE, "CHILD_SA closed");
        return destroy_and_reestablish(this);
@@ -321,7 +321,7 @@ static status_t build_r(private_child_delete_t *this, message_t *message)
        /* if we are rekeying, we send an empty informational */
        if (this->ike_sa->get_state(this->ike_sa) != IKE_REKEYING)
        {
-               build_payloads(this, message);  
+               build_payloads(this, message);
        }
        DBG1(DBG_IKE, "CHILD_SA closed");
        return destroy_and_reestablish(this);
@@ -352,7 +352,7 @@ static void migrate(private_child_delete_t *this, ike_sa_t *ike_sa)
 {
        this->check_delete_action = FALSE;
        this->ike_sa = ike_sa;
-       
+
        this->child_sas->destroy(this->child_sas);
        this->child_sas = linked_list_create();
 }
@@ -378,14 +378,14 @@ child_delete_t *child_delete_create(ike_sa_t *ike_sa, protocol_id_t protocol,
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        this->ike_sa = ike_sa;
        this->check_delete_action = FALSE;
        this->child_sas = linked_list_create();
        this->protocol = protocol;
        this->spi = spi;
        this->rekeyed = FALSE;
-       
+
        if (protocol != PROTO_NONE)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
index 27d847035ce50023b10592ac2fcae780e6ba4d03..365807c687c8b9943eb684809c913adafdd33426 100644 (file)
@@ -37,7 +37,7 @@ struct child_delete_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Get the CHILD_SA to delete by this task.
         *
index 06027d1126f2fdf3d676b8f2b3ea42f57afb183b..9db7ff4f79989da584354a6eb57f6b3302e4d3ed 100644 (file)
@@ -30,47 +30,47 @@ typedef struct private_child_rekey_t private_child_rekey_t;
  * Private members of a child_rekey_t task.
  */
 struct private_child_rekey_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        child_rekey_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * Protocol of CHILD_SA to rekey
         */
        protocol_id_t protocol;
-       
+
        /**
         * Inbound SPI of CHILD_SA to rekey
         */
        u_int32_t spi;
-       
+
        /**
         * the CHILD_CREATE task which is reused to simplify rekeying
         */
        child_create_t *child_create;
-       
+
        /**
         * the CHILD_DELETE task to delete rekeyed CHILD_SA
         */
        child_delete_t *child_delete;
-       
+
        /**
         * CHILD_SA which gets rekeyed
         */
        child_sa_t *child_sa;
-       
+
        /**
         * colliding task, may be delete or rekey
         */
@@ -84,7 +84,7 @@ static status_t build_i_delete(private_child_rekey_t *this, message_t *message)
 {
        /* update exchange type to INFORMATIONAL for the delete */
        message->set_exchange_type(message, INFORMATIONAL);
-       
+
        return this->child_delete->task.build(&this->child_delete->task, message);
 }
 
@@ -104,13 +104,13 @@ static void find_child(private_child_rekey_t *this, message_t *message)
        notify_payload_t *notify;
        protocol_id_t protocol;
        u_int32_t spi;
-       
+
        notify = message->get_notify(message, REKEY_SA);
        if (notify)
        {
                protocol = notify->get_protocol_id(notify);
                spi = notify->get_spi(notify);
-               
+
                if (protocol == PROTO_ESP || protocol == PROTO_AH)
                {
                        this->child_sa = this->ike_sa->get_child_sa(this->ike_sa, protocol,
@@ -127,7 +127,7 @@ static status_t build_i(private_child_rekey_t *this, message_t *message)
        notify_payload_t *notify;
        u_int32_t reqid;
        child_cfg_t *config;
-       
+
        this->child_sa = this->ike_sa->get_child_sa(this->ike_sa, this->protocol,
                                                                                                this->spi, TRUE);
        if (!this->child_sa)
@@ -144,22 +144,22 @@ static status_t build_i(private_child_rekey_t *this, message_t *message)
                this->spi = this->child_sa->get_spi(this->child_sa, TRUE);
        }
        config = this->child_sa->get_config(this->child_sa);
-       
+
        /* we just need the rekey notify ... */
        notify = notify_payload_create_from_protocol_and_type(this->protocol,
                                                                                                                  REKEY_SA);
        notify->set_spi(notify, this->spi);
        message->add_payload(message, (payload_t*)notify);
-       
+
        /* ... our CHILD_CREATE task does the hard work for us. */
        reqid = this->child_sa->get_reqid(this->child_sa);
        this->child_create = child_create_create(this->ike_sa, config, TRUE,
                                                                                         NULL, NULL);
        this->child_create->use_reqid(this->child_create, reqid);
        this->child_create->task.build(&this->child_create->task, message);
-       
+
        this->child_sa->set_state(this->child_sa, CHILD_REKEYING);
-       
+
        return NEED_MORE;
 }
 
@@ -170,9 +170,9 @@ static status_t process_r(private_child_rekey_t *this, message_t *message)
 {
        /* let the CHILD_CREATE task process the message */
        this->child_create->task.process(&this->child_create->task, message);
-       
+
        find_child(this, message);
-       
+
        return NEED_MORE;
 }
 
@@ -190,21 +190,21 @@ static status_t build_r(private_child_rekey_t *this, message_t *message)
                message->add_notify(message, TRUE, NO_PROPOSAL_CHOSEN, chunk_empty);
                return SUCCESS;
        }
-       
+
        /* let the CHILD_CREATE task build the response */
        reqid = this->child_sa->get_reqid(this->child_sa);
        this->child_create->use_reqid(this->child_create, reqid);
        this->child_create->task.build(&this->child_create->task, message);
-       
+
        if (message->get_payload(message, SECURITY_ASSOCIATION) == NULL)
        {
                /* rekeying failed, reuse old child */
                this->child_sa->set_state(this->child_sa, CHILD_INSTALLED);
                return SUCCESS;
        }
-       
+
        this->child_sa->set_state(this->child_sa, CHILD_REKEYING);
-       
+
        /* invoke rekey hook */
        charon->bus->child_rekey(charon->bus, this->child_sa,
                                                         this->child_create->get_child(this->child_create));
@@ -219,7 +219,7 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
        protocol_id_t protocol;
        u_int32_t spi;
        child_sa_t *to_delete;
-       
+
        if (message->get_notify(message, NO_ADDITIONAL_SAS))
        {
                DBG1(DBG_IKE, "peer seems to not support CHILD_SA rekeying, "
@@ -230,7 +230,7 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
                                                        this->ike_sa->get_id(this->ike_sa), TRUE));
                return SUCCESS;
        }
-       
+
        if (this->child_create->task.process(&this->child_create->task,
                                                                                 message) == NEED_MORE)
        {
@@ -242,12 +242,12 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
        {
                /* establishing new child failed, reuse old. but not when we
                 * recieved a delete in the meantime */
-               if (!(this->collision && 
+               if (!(this->collision &&
                          this->collision->get_type(this->collision) == CHILD_DELETE))
                {
                        job_t *job;
                        u_int32_t retry = RETRY_INTERVAL - (random() % RETRY_JITTER);
-                       
+
                        job = (job_t*)rekey_child_sa_job_create(
                                                                this->child_sa->get_reqid(this->child_sa),
                                                                this->child_sa->get_protocol(this->child_sa),
@@ -259,22 +259,22 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
                }
                return SUCCESS;
        }
-       
+
        to_delete = this->child_sa;
-       
+
        /* check for rekey collisions */
        if (this->collision &&
                this->collision->get_type(this->collision) == CHILD_REKEY)
        {
                chunk_t this_nonce, other_nonce;
                private_child_rekey_t *other = (private_child_rekey_t*)this->collision;
-               
+
                this_nonce = this->child_create->get_lower_nonce(this->child_create);
                other_nonce = other->child_create->get_lower_nonce(other->child_create);
-               
+
                /* if we have the lower nonce, delete rekeyed SA. If not, delete
                 * the redundant. */
-               if (memcmp(this_nonce.ptr, other_nonce.ptr, 
+               if (memcmp(this_nonce.ptr, other_nonce.ptr,
                                   min(this_nonce.len, other_nonce.len)) < 0)
                {
                        DBG1(DBG_IKE, "CHILD_SA rekey collision won, deleting rekeyed child");
@@ -290,21 +290,21 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
                        }
                }
        }
-       
+
        if (to_delete != this->child_create->get_child(this->child_create))
        {       /* invoke rekey hook if rekeying successful */
                charon->bus->child_rekey(charon->bus, this->child_sa,
                                                        this->child_create->get_child(this->child_create));
        }
-       
+
        spi = to_delete->get_spi(to_delete, TRUE);
        protocol = to_delete->get_protocol(to_delete);
-       
+
        /* rekeying done, delete the obsolete CHILD_SA using a subtask */
        this->child_delete = child_delete_create(this->ike_sa, protocol, spi);
        this->public.task.build = (status_t(*)(task_t*,message_t*))build_i_delete;
        this->public.task.process = (status_t(*)(task_t*,message_t*))process_i_delete;
-       
+
        return NEED_MORE;
 }
 
@@ -321,7 +321,7 @@ static task_type_t get_type(private_child_rekey_t *this)
  */
 static void collide(private_child_rekey_t *this, task_t *other)
 {
-       /* the task manager only detects exchange collision, but not if 
+       /* the task manager only detects exchange collision, but not if
         * the collision is for the same child. we check it here. */
        if (other->get_type(other) == CHILD_REKEY)
        {
@@ -338,7 +338,7 @@ static void collide(private_child_rekey_t *this, task_t *other)
                child_delete_t *del = (child_delete_t*)other;
                if (del == NULL || del->get_child(del) != this->child_sa)
                {
-                       /* not the same child => no collision */ 
+                       /* not the same child => no collision */
                        other->destroy(other);
                        return;
                }
@@ -357,7 +357,7 @@ static void collide(private_child_rekey_t *this, task_t *other)
  * Implementation of task_t.migrate
  */
 static void migrate(private_child_rekey_t *this, ike_sa_t *ike_sa)
-{      
+{
        if (this->child_create)
        {
                this->child_create->task.migrate(&this->child_create->task, ike_sa);
@@ -367,7 +367,7 @@ static void migrate(private_child_rekey_t *this, ike_sa_t *ike_sa)
                this->child_delete->task.migrate(&this->child_delete->task, ike_sa);
        }
        DESTROY_IF(this->collision);
-       
+
        this->ike_sa = ike_sa;
        this->collision = NULL;
 }
@@ -396,7 +396,7 @@ child_rekey_t *child_rekey_create(ike_sa_t *ike_sa, protocol_id_t protocol,
                                                                  u_int32_t spi)
 {
        private_child_rekey_t *this = malloc_thing(private_child_rekey_t);
-       
+
        this->public.collide = (void (*)(child_rekey_t*,task_t*))collide;
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
@@ -415,13 +415,13 @@ child_rekey_t *child_rekey_create(ike_sa_t *ike_sa, protocol_id_t protocol,
                this->initiator = FALSE;
                this->child_create = child_create_create(ike_sa, NULL, TRUE, NULL, NULL);
        }
-       
+
        this->ike_sa = ike_sa;
        this->child_sa = NULL;
        this->protocol = protocol;
        this->spi = spi;
        this->collision = NULL;
        this->child_delete = NULL;
-       
+
        return &this->public;
 }
index 5aae2fb39145b8809830bcb7e5cc37f7257088c7..0a624796d9fc146b14eb00f88aef9786d9bf2b8c 100644 (file)
@@ -37,7 +37,7 @@ struct child_rekey_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Register a rekeying task which collides with this one
         *
index d0b2a7e91cc672fa898bf7bb853e1e40c1f70d11..9f8fc89a21200f9ece3721b5fea34d289598dd88 100644 (file)
@@ -31,82 +31,82 @@ typedef struct private_ike_auth_t private_ike_auth_t;
  * Private members of a ike_auth_t task.
  */
 struct private_ike_auth_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_auth_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * Nonce chosen by us in ike_init
         */
        chunk_t my_nonce;
-       
+
        /**
         * Nonce chosen by peer in ike_init
         */
        chunk_t other_nonce;
-       
+
        /**
         * IKE_SA_INIT message sent by us
         */
        packet_t *my_packet;
-       
+
        /**
         * IKE_SA_INIT message sent by peer
         */
        packet_t *other_packet;
-       
+
        /**
         * completed authentication configs initiated by us (auth_cfg_t)
         */
        linked_list_t *my_cfgs;
-       
+
        /**
         * completed authentication configs initiated by other (auth_cfg_t)
         */
        linked_list_t *other_cfgs;;
-       
+
        /**
         * currently active authenticator, to authenticate us
         */
        authenticator_t *my_auth;
-       
+
        /**
         * currently active authenticator, to authenticate peer
         */
        authenticator_t *other_auth;
-       
+
        /**
         * peer_cfg candidates, ordered by priority
         */
        linked_list_t *candidates;
-       
+
        /**
         * selected peer config (might change when using multiple authentications)
         */
        peer_cfg_t *peer_cfg;
-       
+
        /**
         * have we planned an(other) authentication exchange?
         */
        bool do_another_auth;
-       
+
        /**
         * has the peer announced another authentication exchange?
         */
        bool expect_another_auth;
-       
+
        /**
         * should we send a AUTHENTICATION_FAILED notify?
         */
@@ -129,7 +129,7 @@ static status_t collect_my_init_data(private_ike_auth_t *this,
                                                                         message_t *message)
 {
        nonce_payload_t *nonce;
-       
+
        /* get the nonce that was generated in ike_init */
        nonce = (nonce_payload_t*)message->get_payload(message, NONCE);
        if (nonce == NULL)
@@ -137,14 +137,14 @@ static status_t collect_my_init_data(private_ike_auth_t *this,
                return FAILED;
        }
        this->my_nonce = nonce->get_nonce(nonce);
-       
+
        /* pre-generate the message, keep a copy */
        if (this->ike_sa->generate_message(this->ike_sa, message,
                                                                           &this->my_packet) != SUCCESS)
        {
                return FAILED;
        }
-       return NEED_MORE; 
+       return NEED_MORE;
 }
 
 /**
@@ -155,7 +155,7 @@ static status_t collect_other_init_data(private_ike_auth_t *this,
 {
        /* we collect the needed information in the IKE_SA_INIT exchange */
        nonce_payload_t *nonce;
-       
+
        /* get the nonce that was generated in ike_init */
        nonce = (nonce_payload_t*)message->get_payload(message, NONCE);
        if (nonce == NULL)
@@ -163,10 +163,10 @@ static status_t collect_other_init_data(private_ike_auth_t *this,
                return FAILED;
        }
        this->other_nonce = nonce->get_nonce(nonce);
-       
+
        /* keep a copy of the received packet */
        this->other_packet = message->get_packet(message);
-       return NEED_MORE; 
+       return NEED_MORE;
 }
 
 /**
@@ -176,13 +176,13 @@ static auth_cfg_t *get_auth_cfg(private_ike_auth_t *this, bool local)
 {
        enumerator_t *e1, *e2;
        auth_cfg_t *c1, *c2, *next = NULL;
-       
+
        /* find an available config not already done */
        e1 = this->peer_cfg->create_auth_cfg_enumerator(this->peer_cfg, local);
        while (e1->enumerate(e1, &c1))
        {
                bool found = FALSE;
-               
+
                if (local)
                {
                        e2 = this->my_cfgs->create_enumerator(this->my_cfgs);
@@ -218,12 +218,12 @@ static bool do_another_auth(private_ike_auth_t *this)
        bool do_another = FALSE;
        enumerator_t *done, *todo;
        auth_cfg_t *done_cfg, *todo_cfg;
-       
+
        if (!this->ike_sa->supports_extension(this->ike_sa, EXT_MULTIPLE_AUTH))
        {
                return FALSE;
        }
-       
+
        done = this->my_cfgs->create_enumerator(this->my_cfgs);
        todo = this->peer_cfg->create_auth_cfg_enumerator(this->peer_cfg, TRUE);
        while (todo->enumerate(todo, &todo_cfg))
@@ -252,12 +252,12 @@ static bool load_cfg_candidates(private_ike_auth_t *this)
        peer_cfg_t *peer_cfg;
        host_t *me, *other;
        identification_t *my_id, *other_id;
-       
+
        me = this->ike_sa->get_my_host(this->ike_sa);
        other = this->ike_sa->get_other_host(this->ike_sa);
        my_id = this->ike_sa->get_my_id(this->ike_sa);
        other_id = this->ike_sa->get_other_id(this->ike_sa);
-       
+
        enumerator = charon->backends->create_peer_cfg_enumerator(charon->backends,
                                                                                                        me, other, my_id, other_id);
        while (enumerator->enumerate(enumerator, &peer_cfg))
@@ -296,10 +296,10 @@ static bool update_cfg_candidates(private_ike_auth_t *this, bool strict)
                        bool complies = TRUE;
                        enumerator_t *e1, *e2, *tmp;
                        auth_cfg_t *c1, *c2;
-                       
+
                        e1 = this->other_cfgs->create_enumerator(this->other_cfgs);
                        e2 = this->peer_cfg->create_auth_cfg_enumerator(this->peer_cfg, FALSE);
-                       
+
                        if (strict)
                        {       /* swap lists in strict mode: all configured rounds must be
                                 * fulfilled. If !strict, we check only the rounds done so far. */
@@ -342,7 +342,7 @@ static bool update_cfg_candidates(private_ike_auth_t *this, bool strict)
                }
        }
        while (this->peer_cfg);
-       
+
        return this->peer_cfg != NULL;
 }
 
@@ -352,39 +352,39 @@ static bool update_cfg_candidates(private_ike_auth_t *this, bool strict)
 static status_t build_i(private_ike_auth_t *this, message_t *message)
 {
        auth_cfg_t *cfg;
-       
+
        if (message->get_exchange_type(message) == IKE_SA_INIT)
        {
                return collect_my_init_data(this, message);
        }
-       
+
        if (this->peer_cfg == NULL)
        {
                this->peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
                this->peer_cfg->get_ref(this->peer_cfg);
        }
-       
+
        if (message->get_message_id(message) == 1 &&
                this->ike_sa->supports_extension(this->ike_sa, EXT_MULTIPLE_AUTH))
        {       /* in the first IKE_AUTH, indicate support for multiple authentication */
                message->add_notify(message, FALSE, MULTIPLE_AUTH_SUPPORTED, chunk_empty);
        }
-       
+
        if (!this->do_another_auth && !this->my_auth)
        {       /* we have done our rounds */
                return NEED_MORE;
        }
-       
+
        /* check if an authenticator is in progress */
        if (this->my_auth == NULL)
        {
                identification_t *id;
                id_payload_t *id_payload;
-               
+
                /* clean up authentication config from a previous round */
                cfg = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
                cfg->purge(cfg, TRUE);
-               
+
                /* add (optional) IDr */
                cfg = get_auth_cfg(this, FALSE);
                if (cfg)
@@ -410,7 +410,7 @@ static status_t build_i(private_ike_auth_t *this, message_t *message)
                this->ike_sa->set_my_id(this->ike_sa, id->clone(id));
                id_payload = id_payload_create_from_identification(ID_INITIATOR, id);
                message->add_payload(message, (payload_t*)id_payload);
-               
+
                /* build authentication data */
                this->my_auth = authenticator_create_builder(this->ike_sa, cfg,
                                                        this->other_nonce, this->my_nonce,
@@ -436,7 +436,7 @@ static status_t build_i(private_ike_auth_t *this, message_t *message)
                default:
                        return FAILED;
        }
-       
+
        /* check for additional authentication rounds */
        if (do_another_auth(this))
        {
@@ -460,12 +460,12 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
        auth_cfg_t *cfg, *cand;
        id_payload_t *id_payload;
        identification_t *id;
-       
+
        if (message->get_exchange_type(message) == IKE_SA_INIT)
        {
                return collect_other_init_data(this, message);
        }
-       
+
        if (this->my_auth == NULL && this->do_another_auth)
        {
                /* handle (optional) IDr payload, apply proposed identity */
@@ -480,7 +480,7 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
                }
                this->ike_sa->set_my_id(this->ike_sa, id);
        }
-       
+
        if (!this->expect_another_auth)
        {
                return NEED_MORE;
@@ -489,7 +489,7 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
        {
                this->ike_sa->enable_extension(this->ike_sa, EXT_MULTIPLE_AUTH);
        }
-       
+
        if (this->other_auth == NULL)
        {
                /* handle IDi payload */
@@ -503,7 +503,7 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
                this->ike_sa->set_other_id(this->ike_sa, id);
                cfg = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
                cfg->add(cfg, AUTH_RULE_IDENTITY, id->clone(id));
-               
+
                if (this->peer_cfg == NULL)
                {
                        if (!load_cfg_candidates(this))
@@ -530,7 +530,7 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
                        }
                        cfg->merge(cfg, cand, TRUE);
                }
-               
+
                /* verify authentication data */
                this->other_auth = authenticator_create_verifier(this->ike_sa,
                                                        message, this->other_nonce, this->my_nonce,
@@ -558,12 +558,12 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
                        this->authentication_failed = TRUE;
                        return NEED_MORE;
        }
-       
+
        /* store authentication information */
        cfg = auth_cfg_create();
        cfg->merge(cfg, this->ike_sa->get_auth_cfg(this->ike_sa, FALSE), FALSE);
        this->other_cfgs->insert_last(this->other_cfgs, cfg);
-       
+
        /* another auth round done, invoke authorize hook */
        if (!charon->bus->authorize(charon->bus, this->other_cfgs, FALSE))
        {
@@ -572,13 +572,13 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
                this->authentication_failed = TRUE;
                return NEED_MORE;
        }
-       
+
        if (!update_cfg_candidates(this, FALSE))
        {
                this->authentication_failed = TRUE;
                return NEED_MORE;
        }
-       
+
        if (message->get_notify(message, ANOTHER_AUTH_FOLLOWS) == NULL)
        {
                this->expect_another_auth = FALSE;
@@ -597,7 +597,7 @@ static status_t process_r(private_ike_auth_t *this, message_t *message)
 static status_t build_r(private_ike_auth_t *this, message_t *message)
 {
        auth_cfg_t *cfg;
-       
+
        if (message->get_exchange_type(message) == IKE_SA_INIT)
        {
                if (multiple_auth_enabled())
@@ -607,23 +607,23 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
                }
                return collect_my_init_data(this, message);
        }
-       
+
        if (this->authentication_failed || this->peer_cfg == NULL)
        {
                message->add_notify(message, TRUE, AUTHENTICATION_FAILED, chunk_empty);
                return FAILED;
        }
-       
+
        if (this->my_auth == NULL && this->do_another_auth)
        {
                identification_t *id, *id_cfg;
                id_payload_t *id_payload;
-               
+
                /* add IDr */
                cfg = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
                cfg->purge(cfg, TRUE);
                cfg->merge(cfg, get_auth_cfg(this, TRUE), TRUE);
-               
+
                id_cfg = cfg->get(cfg, AUTH_RULE_IDENTITY);
                id = this->ike_sa->get_my_id(this->ike_sa);
                if (id->get_type(id) == ID_ANY)
@@ -648,10 +648,10 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
                                return FAILED;
                        }
                }
-               
+
                id_payload = id_payload_create_from_identification(ID_RESPONDER, id);
                message->add_payload(message, (payload_t*)id_payload);
-               
+
                /* build authentication data */
                this->my_auth = authenticator_create_builder(this->ike_sa, cfg,
                                                        this->other_nonce, this->my_nonce,
@@ -663,7 +663,7 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
                        return FAILED;
                }
        }
-       
+
        if (this->other_auth)
        {
                switch (this->other_auth->build(this->other_auth, message))
@@ -703,7 +703,7 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
                                return FAILED;
                }
        }
-       
+
        /* check for additional authentication rounds */
        if (do_another_auth(this))
        {
@@ -735,7 +735,7 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
                         this->ike_sa->get_name(this->ike_sa),
                         this->ike_sa->get_unique_id(this->ike_sa),
                         this->ike_sa->get_my_host(this->ike_sa),
-                        this->ike_sa->get_my_id(this->ike_sa), 
+                        this->ike_sa->get_my_id(this->ike_sa),
                         this->ike_sa->get_other_host(this->ike_sa),
                         this->ike_sa->get_other_id(this->ike_sa));
                charon->bus->ike_updown(charon->bus, this->ike_sa, TRUE);
@@ -752,7 +752,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
        enumerator_t *enumerator;
        payload_t *payload;
        auth_cfg_t *cfg;
-       
+
        if (message->get_exchange_type(message) == IKE_SA_INIT)
        {
                if (message->get_notify(message, MULTIPLE_AUTH_SUPPORTED) &&
@@ -762,7 +762,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                }
                return collect_other_init_data(this, message);
        }
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -770,7 +770,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                {
                        notify_payload_t *notify = (notify_payload_t*)payload;
                        notify_type_t type = notify->get_notify_type(notify);
-                       
+
                        switch (type)
                        {
                                case NO_PROPOSAL_CHOSEN:
@@ -801,7 +801,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                                                DBG1(DBG_IKE, "received %N notify error",
                                                         notify_type_names, type);
                                                enumerator->destroy(enumerator);
-                                               return FAILED;  
+                                               return FAILED;
                                        }
                                        DBG2(DBG_IKE, "received %N notify",
                                                notify_type_names, type);
@@ -811,7 +811,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        if (this->my_auth)
        {
                switch (this->my_auth->process(this->my_auth, message))
@@ -831,21 +831,21 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                                return FAILED;
                }
        }
-       
+
        if (this->expect_another_auth)
        {
                if (this->other_auth == NULL)
                {
                        id_payload_t *id_payload;
                        identification_t *id;
-                       
+
                        /* responder is not allowed to do EAP */
                        if (!message->get_payload(message, AUTHENTICATION))
                        {
                                DBG1(DBG_IKE, "AUTH payload missing");
                                return FAILED;
                        }
-                       
+
                        /* handle IDr payload */
                        id_payload = (id_payload_t*)message->get_payload(message,
                                                                                                                         ID_RESPONDER);
@@ -858,7 +858,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                        this->ike_sa->set_other_id(this->ike_sa, id);
                        cfg = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
                        cfg->add(cfg, AUTH_RULE_IDENTITY, id->clone(id));
-                       
+
                        /* verify authentication data */
                        this->other_auth = authenticator_create_verifier(this->ike_sa,
                                                        message, this->other_nonce, this->my_nonce,
@@ -884,7 +884,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                this->other_cfgs->insert_last(this->other_cfgs, cfg);
                this->other_auth->destroy(this->other_auth);
                this->other_auth = NULL;
-               
+
                /* another auth round done, invoke authorize hook */
                if (!charon->bus->authorize(charon->bus, this->other_cfgs, FALSE))
                {
@@ -893,7 +893,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                        return FAILED;
                }
        }
-       
+
        if (message->get_notify(message, ANOTHER_AUTH_FOLLOWS) == NULL)
        {
                this->expect_another_auth = FALSE;
@@ -914,7 +914,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                         this->ike_sa->get_name(this->ike_sa),
                         this->ike_sa->get_unique_id(this->ike_sa),
                         this->ike_sa->get_my_host(this->ike_sa),
-                        this->ike_sa->get_my_id(this->ike_sa), 
+                        this->ike_sa->get_my_id(this->ike_sa),
                         this->ike_sa->get_other_host(this->ike_sa),
                         this->ike_sa->get_other_id(this->ike_sa));
                charon->bus->ike_updown(charon->bus, this->ike_sa, TRUE);
@@ -946,7 +946,7 @@ static void migrate(private_ike_auth_t *this, ike_sa_t *ike_sa)
        this->my_cfgs->destroy_offset(this->my_cfgs, offsetof(auth_cfg_t, destroy));
        this->other_cfgs->destroy_offset(this->other_cfgs, offsetof(auth_cfg_t, destroy));
        this->candidates->destroy_offset(this->candidates, offsetof(peer_cfg_t, destroy));
-       
+
        this->my_packet = NULL;
        this->other_packet = NULL;
        this->ike_sa = ike_sa;
@@ -985,11 +985,11 @@ static void destroy(private_ike_auth_t *this)
 ike_auth_t *ike_auth_create(ike_sa_t *ike_sa, bool initiator)
 {
        private_ike_auth_t *this = malloc_thing(private_ike_auth_t);
-       
+
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -1000,7 +1000,7 @@ ike_auth_t *ike_auth_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
        this->my_nonce = chunk_empty;
@@ -1016,7 +1016,7 @@ ike_auth_t *ike_auth_create(ike_sa_t *ike_sa, bool initiator)
        this->do_another_auth = TRUE;
        this->expect_another_auth = TRUE;
        this->authentication_failed = FALSE;
-       
+
        return &this->public;
 }
 
index 819ac47bfb558cbb7f93375fb064a9a66e025e21..75ff351684098a3182aad22c829d0b0f15226cef 100644 (file)
@@ -27,12 +27,12 @@ typedef struct private_ike_auth_lifetime_t private_ike_auth_lifetime_t;
  * Private members of a ike_auth_lifetime_t task.
  */
 struct private_ike_auth_lifetime_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_auth_lifetime_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
@@ -46,7 +46,7 @@ static void add_auth_lifetime(private_ike_auth_lifetime_t *this, message_t *mess
 {
        chunk_t chunk;
        u_int32_t lifetime;
-       
+
        lifetime = this->ike_sa->get_statistic(this->ike_sa, STAT_REAUTH);
        if (lifetime)
        {
@@ -65,7 +65,7 @@ static void process_payloads(private_ike_auth_lifetime_t *this, message_t *messa
        notify_payload_t *notify;
        chunk_t data;
        u_int32_t lifetime;
-       
+
        notify = message->get_notify(message, AUTH_LIFETIME);
        if (notify)
        {
@@ -163,7 +163,7 @@ ike_auth_lifetime_t *ike_auth_lifetime_create(ike_sa_t *ike_sa, bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -174,9 +174,9 @@ ike_auth_lifetime_t *ike_auth_lifetime_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
-       
+
        return &this->public;
 }
 
index 812caaf439c492b87041e65967f822a8b36f6525..4c65c8d3c4677cc69bfb649922456419ccd21afe 100644 (file)
@@ -30,7 +30,7 @@ typedef struct ike_auth_lifetime_t ike_auth_lifetime_t;
 /**
  * Task of type IKE_AUTH_LIFETIME, implements RFC4478.
  *
- * This task exchanges lifetimes for IKE_AUTH to force a client to 
+ * This task exchanges lifetimes for IKE_AUTH to force a client to
  * reauthenticate before the responders lifetime reaches the limit.
  */
 struct ike_auth_lifetime_t {
index 9967a969f13e8c886cc949fc1739095c742196ff..e6ecce0b5c6b5b1e93d3dc2e885dd4ee7fc187a2 100644 (file)
@@ -30,17 +30,17 @@ typedef struct private_ike_cert_post_t private_ike_cert_post_t;
  * Private members of a ike_cert_post_t task.
  */
 struct private_ike_cert_post_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_cert_post_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
@@ -58,23 +58,23 @@ static cert_payload_t *build_cert_payload(private_ike_cert_post_t *this,
        chunk_t hash, encoded ;
        enumerator_t *enumerator;
        char *url;
-       
+
        if (!this->ike_sa->supports_extension(this->ike_sa, EXT_HASH_AND_URL))
        {
                return cert_payload_create_from_cert(cert);
        }
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (!hasher)
        {
                DBG1(DBG_IKE, "unable to use hash-and-url: sha1 not supported");
                return cert_payload_create_from_cert(cert);
        }
-       
+
        encoded = cert->get_encoding(cert);
        hasher->allocate_hash(hasher, encoded, &hash);
        id = identification_create_from_encoding(ID_KEY_ID, hash);
-       
+
        enumerator = charon->credentials->create_cdp_enumerator(
                                                                                charon->credentials, CERT_X509, id);
        if (!enumerator->enumerate(enumerator, &url))
@@ -82,7 +82,7 @@ static cert_payload_t *build_cert_payload(private_ike_cert_post_t *this,
                url = NULL;
        }
        enumerator->destroy(enumerator);
-       
+
        id->destroy(id);
        chunk_free(&hash);
        chunk_free(&encoded);
@@ -101,14 +101,14 @@ static void build_certs(private_ike_cert_post_t *this, message_t *message)
 {
        peer_cfg_t *peer_cfg;
        auth_payload_t *payload;
-       
+
        payload = (auth_payload_t*)message->get_payload(message, AUTHENTICATION);
        peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
        if (!peer_cfg || !payload || payload->get_auth_method(payload) == AUTH_PSK)
        {       /* no CERT payload for EAP/PSK */
                return;
        }
-       
+
        switch (peer_cfg->get_cert_policy(peer_cfg))
        {
                case CERT_NEVER_SEND:
@@ -126,9 +126,9 @@ static void build_certs(private_ike_cert_post_t *this, message_t *message)
                        certificate_t *cert;
                        auth_rule_t type;
                        auth_cfg_t *auth;
-                       
+
                        auth = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
-                       
+
                        /* get subject cert first, then issuing certificates */
                        cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
                        if (!cert)
@@ -143,7 +143,7 @@ static void build_certs(private_ike_cert_post_t *this, message_t *message)
                        DBG1(DBG_IKE, "sending end entity cert \"%Y\"",
                                 cert->get_subject(cert));
                        message->add_payload(message, (payload_t*)payload);
-                       
+
                        enumerator = auth->create_enumerator(auth);
                        while (enumerator->enumerate(enumerator, &type, &cert))
                        {
@@ -159,7 +159,7 @@ static void build_certs(private_ike_cert_post_t *this, message_t *message)
                                }
                        }
                        enumerator->destroy(enumerator);
-               }       
+               }
        }
 }
 
@@ -169,7 +169,7 @@ static void build_certs(private_ike_cert_post_t *this, message_t *message)
 static status_t build_i(private_ike_cert_post_t *this, message_t *message)
 {
        build_certs(this, message);
-       
+
        return NEED_MORE;
 }
 
@@ -177,7 +177,7 @@ static status_t build_i(private_ike_cert_post_t *this, message_t *message)
  * Implementation of task_t.process for responder
  */
 static status_t process_r(private_ike_cert_post_t *this, message_t *message)
-{      
+{
        return NEED_MORE;
 }
 
@@ -187,7 +187,7 @@ static status_t process_r(private_ike_cert_post_t *this, message_t *message)
 static status_t build_r(private_ike_cert_post_t *this, message_t *message)
 {
        build_certs(this, message);
-       
+
        if (this->ike_sa->get_state(this->ike_sa) != IKE_ESTABLISHED)
        {       /* stay alive, we might have additional rounds with certs */
                return NEED_MORE;
@@ -241,7 +241,7 @@ ike_cert_post_t *ike_cert_post_create(ike_sa_t *ike_sa, bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -252,10 +252,10 @@ ike_cert_post_t *ike_cert_post_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
-       
+
        return &this->public;
 }
 
index d7f5f55d1791a23f2fa1f9b8b03cf33359db11be..0805d0290681475816455418733213cc49b09515 100644 (file)
@@ -29,27 +29,27 @@ typedef struct private_ike_cert_pre_t private_ike_cert_pre_t;
  * Private members of a ike_cert_pre_t task.
  */
 struct private_ike_cert_pre_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_cert_pre_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * Do we accept HTTP certificate lookup requests
         */
        bool do_http_lookup;
-       
+
        /**
         * wheter this is the final authentication round
         */
@@ -57,16 +57,16 @@ struct private_ike_cert_pre_t {
 };
 
 /**
- * read certificate requests 
+ * read certificate requests
  */
 static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
 {
        enumerator_t *enumerator;
        payload_t *payload;
        auth_cfg_t *auth;
-       
+
        auth = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -77,9 +77,9 @@ static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
                                certreq_payload_t *certreq = (certreq_payload_t*)payload;
                                enumerator_t *enumerator;
                                chunk_t keyid;
-                               
+
                                this->ike_sa->set_condition(this->ike_sa, COND_CERTREQ_SEEN, TRUE);
-                               
+
                                if (certreq->get_cert_type(certreq) != CERT_X509)
                                {
                                        DBG1(DBG_IKE, "cert payload %N not supported - ignored",
@@ -91,9 +91,9 @@ static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
                                {
                                        identification_t *id;
                                        certificate_t *cert;
-                                       
+
                                        id = identification_create_from_encoding(ID_KEY_ID, keyid);
-                                       cert = charon->credentials->get_cert(charon->credentials, 
+                                       cert = charon->credentials->get_cert(charon->credentials,
                                                                                        CERT_X509, KEY_ANY, id, TRUE);
                                        if (cert)
                                        {
@@ -114,7 +114,7 @@ static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
                        case NOTIFY:
                        {
                                notify_payload_t *notify = (notify_payload_t*)payload;
-                               
+
                                /* we only handle one type of notify here */
                                if (notify->get_notify_type(notify) == HTTP_CERT_LOOKUP_SUPPORTED)
                                {
@@ -134,11 +134,11 @@ static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
  * tries to extract a certificate from the cert payload or the credential
  * manager (based on the hash of a "Hash and URL" encoded cert).
  * Note: the returned certificate (if any) has to be destroyed
- */ 
+ */
 static certificate_t *try_get_cert(cert_payload_t *cert_payload)
 {
        certificate_t *cert = NULL;
-       
+
        switch (cert_payload->get_cert_encoding(cert_payload))
        {
                case ENC_X509_SIGNATURE:
@@ -156,7 +156,7 @@ static certificate_t *try_get_cert(cert_payload_t *cert_payload)
                                break;
                        }
                        id = identification_create_from_encoding(ID_KEY_ID, hash);
-                       cert = charon->credentials->get_cert(charon->credentials, 
+                       cert = charon->credentials->get_cert(charon->credentials,
                                                                                                 CERT_X509, KEY_ANY, id, FALSE);
                        id->destroy(id);
                        break;
@@ -178,9 +178,9 @@ static void process_certs(private_ike_cert_pre_t *this, message_t *message)
        payload_t *payload;
        auth_cfg_t *auth;
        bool first = TRUE;
-       
+
        auth = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -190,10 +190,10 @@ static void process_certs(private_ike_cert_pre_t *this, message_t *message)
                        cert_encoding_t encoding;
                        certificate_t *cert;
                        char *url;
-                       
+
                        cert_payload = (cert_payload_t*)payload;
                        encoding = cert_payload->get_cert_encoding(cert_payload);
-                       
+
                        switch (encoding)
                        {
                                case ENC_X509_HASH_AND_URL:
@@ -285,7 +285,7 @@ static void add_certreq(certreq_payload_t **req, certificate_t *cert)
                        public_key_t *public;
                        chunk_t keyid;
                        x509_t *x509 = (x509_t*)cert;
-                       
+
                        if (!(x509->get_flags(x509) & X509_CA))
                        {       /* no CA cert, skip */
                                break;
@@ -321,7 +321,7 @@ static void add_certreqs(certreq_payload_t **req, auth_cfg_t *auth)
        enumerator_t *enumerator;
        auth_rule_t type;
        void *value;
-       
+
        enumerator = auth->create_enumerator(auth);
        while (enumerator->enumerate(enumerator, &type, &value))
        {
@@ -348,13 +348,13 @@ static void build_certreqs(private_ike_cert_pre_t *this, message_t *message)
        certificate_t *cert;
        auth_cfg_t *auth;
        certreq_payload_t *req = NULL;
-       
+
        ike_cfg = this->ike_sa->get_ike_cfg(this->ike_sa);
        if (!ike_cfg->send_certreq(ike_cfg))
        {
                return;
        }
-       
+
        /* check if we require a specific CA for that peer */
        peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
        if (peer_cfg)
@@ -366,7 +366,7 @@ static void build_certreqs(private_ike_cert_pre_t *this, message_t *message)
                }
                enumerator->destroy(enumerator);
        }
-       
+
        if (!req)
        {
                /* otherwise add all trusted CA certificates */
@@ -378,11 +378,11 @@ static void build_certreqs(private_ike_cert_pre_t *this, message_t *message)
                }
                enumerator->destroy(enumerator);
        }
-       
+
        if (req)
        {
                message->add_payload(message, (payload_t*)req);
-               
+
                if (lib->settings->get_bool(lib->settings, "charon.hash_and_url", FALSE))
                {
                        message->add_notify(message, FALSE, HTTP_CERT_LOOKUP_SUPPORTED,
@@ -413,7 +413,7 @@ static bool final_auth(message_t *message)
  * Implementation of task_t.process for initiator
  */
 static status_t build_i(private_ike_cert_pre_t *this, message_t *message)
-{      
+{
        if (message->get_message_id(message) == 1)
        {       /* initiator sends CERTREQs in first IKE_AUTH */
                build_certreqs(this, message);
@@ -461,7 +461,7 @@ static status_t process_i(private_ike_cert_pre_t *this, message_t *message)
                process_certreqs(this, message);
        }
        process_certs(this, message);
-       
+
        if (final_auth(message))
        {
                return SUCCESS;
@@ -503,7 +503,7 @@ ike_cert_pre_t *ike_cert_pre_create(ike_sa_t *ike_sa, bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -514,11 +514,11 @@ ike_cert_pre_t *ike_cert_pre_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
        this->do_http_lookup = FALSE;
        this->final = FALSE;
-       
+
        return &this->public;
 }
index 1f75521b6c827f1e560945a7cc67010d02129a85..bb5779e50d5bb9b32fc4363669303cf5ecdeda7d 100644 (file)
@@ -28,22 +28,22 @@ typedef struct private_ike_config_t private_ike_config_t;
  * Private members of a ike_config_t task.
  */
 struct private_ike_config_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_config_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * virtual ip
         */
@@ -57,9 +57,9 @@ static void build_vip(private_ike_config_t *this, host_t *vip, cp_payload_t *cp)
 {
        configuration_attribute_t *ca;
        chunk_t chunk, prefix;
-       
+
        ca = configuration_attribute_create();
-       
+
        if (vip->get_family(vip) == AF_INET)
        {
                ca->set_type(ca, INTERNAL_IP4_ADDRESS);
@@ -100,7 +100,7 @@ static void process_attribute(private_ike_config_t *this,
        host_t *ip;
        chunk_t addr;
        int family = AF_INET6;
-       
+
        switch (ca->get_type(ca))
        {
                case INTERNAL_IP4_ADDRESS:
@@ -118,7 +118,7 @@ static void process_attribute(private_ike_config_t *this,
                                /* skip prefix byte in IPv6 payload*/
                                if (family == AF_INET6)
                                {
-                                       addr.len--; 
+                                       addr.len--;
                                }
                                ip = host_create_from_chunk(family, addr, 0);
                        }
@@ -150,7 +150,7 @@ static void process_payloads(private_ike_config_t *this, message_t *message)
        enumerator_t *enumerator;
        iterator_t *attributes;
        payload_t *payload;
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -172,7 +172,7 @@ static void process_payloads(private_ike_config_t *this, message_t *message)
                                        break;
                                }
                                default:
-                                       DBG1(DBG_IKE, "ignoring %N config payload", 
+                                       DBG1(DBG_IKE, "ignoring %N config payload",
                                                 config_type_names, cp->get_config_type(cp));
                                        break;
                        }
@@ -190,7 +190,7 @@ static status_t build_i(private_ike_config_t *this, message_t *message)
        {       /* in first IKE_AUTH only */
                peer_cfg_t *config;
                host_t *vip;
-               
+
                /* reuse virtual IP if we already have one */
                vip = this->ike_sa->get_virtual_ip(this->ike_sa, TRUE);
                if (!vip)
@@ -202,12 +202,12 @@ static status_t build_i(private_ike_config_t *this, message_t *message)
                {
                        configuration_attribute_t *ca;
                        cp_payload_t *cp;
-                       
+
                        cp = cp_payload_create();
                        cp->set_config_type(cp, CFG_REQUEST);
-                       
+
                        build_vip(this, vip, cp);
-                       
+
                        /* we currently always add a DNS request if we request an IP */
                        ca = configuration_attribute_create();
                        if (vip->get_family(vip) == AF_INET)
@@ -245,7 +245,7 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
        if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
        {       /* in last IKE_AUTH exchange */
                peer_cfg_t *config = this->ike_sa->get_peer_cfg(this->ike_sa);
-               
+
                if (config && this->virtual_ip)
                {
                        enumerator_t *enumerator;
@@ -254,11 +254,11 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
                        chunk_t value;
                        cp_payload_t *cp;
                        host_t *vip = NULL;
-                       
+
                        DBG1(DBG_IKE, "peer requested virtual IP %H", this->virtual_ip);
                        if (config->get_pool(config))
                        {
-                               vip = charon->attributes->acquire_address(charon->attributes, 
+                               vip = charon->attributes->acquire_address(charon->attributes,
                                                                        config->get_pool(config),
                                                                        this->ike_sa->get_other_id(this->ike_sa),
                                                                        this->virtual_ip);
@@ -273,13 +273,13 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
                        }
                        DBG1(DBG_IKE, "assigning virtual IP %H to peer", vip);
                        this->ike_sa->set_virtual_ip(this->ike_sa, FALSE, vip);
-                       
+
                        cp = cp_payload_create();
                        cp->set_config_type(cp, CFG_REPLY);
-                       
+
                        build_vip(this, vip, cp);
                        vip->destroy(vip);
-                       
+
                        /* if we add an IP, we also look for other attributes */
                        enumerator = charon->attributes->create_attribute_enumerator(
                                charon->attributes, this->ike_sa->get_other_id(this->ike_sa));
@@ -291,7 +291,7 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
                                cp->add_configuration_attribute(cp, ca);
                        }
                        enumerator->destroy(enumerator);
-                       
+
                        message->add_payload(message, (payload_t*)cp);
                }
                return SUCCESS;
@@ -306,9 +306,9 @@ static status_t process_i(private_ike_config_t *this, message_t *message)
 {
        if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
        {       /* in last IKE_AUTH exchange */
-               
+
                process_payloads(this, message);
-               
+
                if (this->virtual_ip)
                {
                        this->ike_sa->set_virtual_ip(this->ike_sa, TRUE, this->virtual_ip);
@@ -332,7 +332,7 @@ static task_type_t get_type(private_ike_config_t *this)
 static void migrate(private_ike_config_t *this, ike_sa_t *ike_sa)
 {
        DESTROY_IF(this->virtual_ip);
-       
+
        this->ike_sa = ike_sa;
        this->virtual_ip = NULL;
 }
@@ -352,15 +352,15 @@ static void destroy(private_ike_config_t *this)
 ike_config_t *ike_config_create(ike_sa_t *ike_sa, bool initiator)
 {
        private_ike_config_t *this = malloc_thing(private_ike_config_t);
-       
+
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        this->initiator = initiator;
        this->ike_sa = ike_sa;
        this->virtual_ip = NULL;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -371,7 +371,7 @@ ike_config_t *ike_config_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        return &this->public;
 }
 
index cde11793495f0da86aed33ff88d4682077435021..130948836ab4af4414e051e825acd56229c79bdd 100644 (file)
@@ -25,27 +25,27 @@ typedef struct private_ike_delete_t private_ike_delete_t;
  * Private members of a ike_delete_t task.
  */
 struct private_ike_delete_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_delete_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * are we deleting a rekeyed SA?
         */
        bool rekeyed;
-       
+
        /**
         * are we responding to a delete, but have initated our own?
         */
@@ -69,7 +69,7 @@ static status_t build_i(private_ike_delete_t *this, message_t *message)
 
        delete_payload = delete_payload_create(PROTO_IKE);
        message->add_payload(message, (payload_t*)delete_payload);
-       
+
        if (this->ike_sa->get_state(this->ike_sa) == IKE_REKEYING)
        {
                this->rekeyed = TRUE;
@@ -189,7 +189,7 @@ ike_delete_t *ike_delete_create(ike_sa_t *ike_sa, bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -200,11 +200,11 @@ ike_delete_t *ike_delete_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
        this->rekeyed = FALSE;
        this->simultaneous = FALSE;
-       
+
        return &this->public;
 }
index 3aa714049d747fa970fbe54ae901696e4e0cb914..4c6ba7662f9787cafad006d9011cc13f83cf42a2 100644 (file)
@@ -24,7 +24,7 @@ typedef struct private_ike_dpd_t private_ike_dpd_t;
  * Private members of a ike_dpd_t task.
  */
 struct private_ike_dpd_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
@@ -83,7 +83,7 @@ ike_dpd_t *ike_dpd_create(bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))return_need_more;
@@ -94,6 +94,6 @@ ike_dpd_t *ike_dpd_create(bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))return_success;
                this->public.task.process = (status_t(*)(task_t*,message_t*))return_need_more;
        }
-       
+
        return &this->public;
 }
index a64ec3d53087ed2ef8c4ccbf747d185805184dfb..7968c265df38f92864abafc76471ecfeee5e82db 100644 (file)
@@ -35,67 +35,67 @@ typedef struct private_ike_init_t private_ike_init_t;
  * Private members of a ike_init_t task.
  */
 struct private_ike_init_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_init_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * IKE config to establish
         */
        ike_cfg_t *config;
-       
+
        /**
         * diffie hellman group to use
         */
        diffie_hellman_group_t dh_group;
-       
+
        /**
         * diffie hellman key exchange
         */
        diffie_hellman_t *dh;
-       
+
        /**
         * Keymat derivation (from IKE_SA)
         */
        keymat_t *keymat;
-       
+
        /**
         * nonce chosen by us
         */
        chunk_t my_nonce;
-       
+
        /**
         * nonce chosen by peer
         */
        chunk_t other_nonce;
-       
+
        /**
         * Negotiated proposal used for IKE_SA
         */
        proposal_t *proposal;
-       
+
        /**
         * Old IKE_SA which gets rekeyed
         */
        ike_sa_t *old_sa;
-       
+
        /**
         * cookie received from responder
         */
        chunk_t cookie;
-       
+
        /**
         * retries done so far after failure (cookie or bad dh group)
         */
@@ -114,9 +114,9 @@ static void build_payloads(private_ike_init_t *this, message_t *message)
        ike_sa_id_t *id;
        proposal_t *proposal;
        iterator_t *iterator;
-       
+
        id = this->ike_sa->get_id(this->ike_sa);
-       
+
        this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
 
        if (this->initiator)
@@ -132,7 +132,7 @@ static void build_payloads(private_ike_init_t *this, message_t *message)
                        }
                        iterator->destroy(iterator);
                }
-               
+
                sa_payload = sa_payload_create_from_proposal_list(proposal_list);
                proposal_list->destroy_offset(proposal_list, offsetof(proposal_t, destroy));
        }
@@ -146,11 +146,11 @@ static void build_payloads(private_ike_init_t *this, message_t *message)
                sa_payload = sa_payload_create_from_proposal(this->proposal);
        }
        message->add_payload(message, (payload_t*)sa_payload);
-       
+
        nonce_payload = nonce_payload_create();
        nonce_payload->set_nonce(nonce_payload, this->my_nonce);
        ke_payload = ke_payload_create_from_diffie_hellman(this->dh);
-       
+
        if (this->old_sa)
        {       /* payload order differs if we are rekeying */
                message->add_payload(message, (payload_t*)nonce_payload);
@@ -170,7 +170,7 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
 {
        enumerator_t *enumerator;
        payload_t *payload;
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -180,7 +180,7 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
                        {
                                sa_payload_t *sa_payload = (sa_payload_t*)payload;
                                linked_list_t *proposal_list;
-                               
+
                                proposal_list = sa_payload->get_proposals(sa_payload);
                                this->proposal = this->config->select_proposal(this->config,
                                                                                                                           proposal_list);
@@ -191,7 +191,7 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
                        case KEY_EXCHANGE:
                        {
                                ke_payload_t *ke_payload = (ke_payload_t*)payload;
-                               
+
                                this->dh_group = ke_payload->get_dh_group_number(ke_payload);
                                if (!this->initiator)
                                {
@@ -232,20 +232,20 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
 static status_t build_i(private_ike_init_t *this, message_t *message)
 {
        rng_t *rng;
-       
+
        this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
        DBG0(DBG_IKE, "initiating IKE_SA %s[%d] to %H",
                 this->ike_sa->get_name(this->ike_sa),
                 this->ike_sa->get_unique_id(this->ike_sa),
                 this->ike_sa->get_other_host(this->ike_sa));
        this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);
-       
+
        if (this->retry++ >= MAX_RETRIES)
        {
                DBG1(DBG_IKE, "giving up after %d retries", MAX_RETRIES);
                return FAILED;
        }
-       
+
        /* if the DH group is set via use_dh_group(), we already have a DH object */
        if (!this->dh)
        {
@@ -258,7 +258,7 @@ static status_t build_i(private_ike_init_t *this, message_t *message)
                        return FAILED;
                }
        }
-       
+
        /* generate nonce only when we are trying the first time */
        if (this->my_nonce.ptr == NULL)
        {
@@ -271,12 +271,12 @@ static status_t build_i(private_ike_init_t *this, message_t *message)
                rng->allocate_bytes(rng, NONCE_SIZE, &this->my_nonce);
                rng->destroy(rng);
        }
-       
+
        if (this->cookie.ptr)
        {
                message->add_notify(message, FALSE, COOKIE, this->cookie);
        }
-       
+
        build_payloads(this, message);
 
 #ifdef ME
@@ -288,7 +288,7 @@ static status_t build_i(private_ike_init_t *this, message_t *message)
                }
        }
 #endif /* ME */
-       
+
        return NEED_MORE;
 }
 
@@ -298,7 +298,7 @@ static status_t build_i(private_ike_init_t *this, message_t *message)
 static status_t process_r(private_ike_init_t *this, message_t *message)
 {
        rng_t *rng;
-       
+
        this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
        DBG0(DBG_IKE, "%H is initiating an IKE_SA", message->get_source(message));
        this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);
@@ -311,7 +311,7 @@ static status_t process_r(private_ike_init_t *this, message_t *message)
        }
        rng->allocate_bytes(rng, NONCE_SIZE, &this->my_nonce);
        rng->destroy(rng);
-       
+
 #ifdef ME
        {
                notify_payload_t *notify = message->get_notify(message, ME_CONNECTID);
@@ -324,9 +324,9 @@ static status_t process_r(private_ike_init_t *this, message_t *message)
                }
        }
 #endif /* ME */
-       
+
        process_payloads(this, message);
-       
+
        return NEED_MORE;
 }
 
@@ -340,7 +340,7 @@ static bool derive_keys(private_ike_init_t *this,
        pseudo_random_function_t prf_alg = PRF_UNDEFINED;
        chunk_t skd = chunk_empty;
        ike_sa_id_t *id;
-       
+
        id = this->ike_sa->get_id(this->ike_sa);
        if (this->old_sa)
        {
@@ -380,12 +380,12 @@ static status_t build_r(private_ike_init_t *this, message_t *message)
                return FAILED;
        }
        this->ike_sa->set_proposal(this->ike_sa, this->proposal);
-       
+
        if (this->dh == NULL ||
                !this->proposal->has_dh_group(this->proposal, this->dh_group))
        {
                u_int16_t group;
-               
+
                if (this->proposal->get_algorithm(this->proposal, DIFFIE_HELLMAN_GROUP,
                                                                                  &group, NULL))
                {
@@ -403,7 +403,7 @@ static status_t build_r(private_ike_init_t *this, message_t *message)
                }
                return FAILED;
        }
-       
+
        if (!derive_keys(this, this->other_nonce, this->my_nonce))
        {
                DBG1(DBG_IKE, "key derivation failed");
@@ -421,7 +421,7 @@ static status_t process_i(private_ike_init_t *this, message_t *message)
 {
        enumerator_t *enumerator;
        payload_t *payload;
-       
+
        /* check for erronous notifies */
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
@@ -430,26 +430,26 @@ static status_t process_i(private_ike_init_t *this, message_t *message)
                {
                        notify_payload_t *notify = (notify_payload_t*)payload;
                        notify_type_t type = notify->get_notify_type(notify);
-                       
+
                        switch (type)
                        {
                                case INVALID_KE_PAYLOAD:
                                {
                                        chunk_t data;
                                        diffie_hellman_group_t bad_group;
-                                       
+
                                        bad_group = this->dh_group;
                                        data = notify->get_notification_data(notify);
                                        this->dh_group = ntohs(*((u_int16_t*)data.ptr));
                                        DBG1(DBG_IKE, "peer didn't accept DH group %N, "
                                                 "it requested %N", diffie_hellman_group_names,
                                                 bad_group, diffie_hellman_group_names, this->dh_group);
-                                                
+
                                        if (this->old_sa == NULL)
                                        {       /* reset the IKE_SA if we are not rekeying */
                                                this->ike_sa->reset(this->ike_sa);
                                        }
-                                       
+
                                        enumerator->destroy(enumerator);
                                        return NEED_MORE;
                                }
@@ -486,7 +486,7 @@ static status_t process_i(private_ike_init_t *this, message_t *message)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        process_payloads(this, message);
 
        /* check if we have everything */
@@ -497,14 +497,14 @@ static status_t process_i(private_ike_init_t *this, message_t *message)
                return FAILED;
        }
        this->ike_sa->set_proposal(this->ike_sa, this->proposal);
-       
+
        if (this->dh == NULL ||
                !this->proposal->has_dh_group(this->proposal, this->dh_group))
        {
                DBG1(DBG_IKE, "peer DH group selection invalid");
                return FAILED;
        }
-       
+
        if (!derive_keys(this, this->my_nonce, this->other_nonce))
        {
                DBG1(DBG_IKE, "key derivation failed");
@@ -544,7 +544,7 @@ static void migrate(private_ike_init_t *this, ike_sa_t *ike_sa)
 {
        DESTROY_IF(this->proposal);
        chunk_free(&this->other_nonce);
-       
+
        this->ike_sa = ike_sa;
        this->proposal = NULL;
        DESTROY_IF(this->dh);
@@ -585,7 +585,7 @@ ike_init_t *ike_init_create(ike_sa_t *ike_sa, bool initiator, ike_sa_t *old_sa)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
        this->dh_group = MODP_NONE;
@@ -598,6 +598,6 @@ ike_init_t *ike_init_create(ike_sa_t *ike_sa, bool initiator, ike_sa_t *old_sa)
        this->config = NULL;
        this->old_sa = old_sa;
        this->retry = 0;
-       
+
        return &this->public;
 }
index 8d3810ef2d684cd350bcc26d0efdfc909a75d900..7bd784cff9a8e64ce9200cf673aeddba63ada302 100644 (file)
@@ -38,7 +38,7 @@ struct ike_init_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Get the lower of the two nonces, used for rekey collisions.
         *
index d359aa339a6c3a61d93bb535f795b4fd94157716..0eb602b106a702179332b93ca333e006ca5ec4bf 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "ike_me.h"
 
 #include <string.h>
@@ -33,71 +33,71 @@ typedef struct private_ike_me_t private_ike_me_t;
  * Private members of a ike_me_t task.
  */
 struct private_ike_me_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_me_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * Is this a mediation connection?
         */
        bool mediation;
-       
+
        /**
         * Is this the response from another peer?
         */
        bool response;
-       
+
        /**
         * Gathered endpoints
         */
        linked_list_t *local_endpoints;
-       
+
        /**
         * Parsed endpoints
         */
        linked_list_t *remote_endpoints;
-       
+
        /**
         * Did the peer request a callback?
         */
        bool callback;
-       
+
        /**
         * Did the connect fail?
         */
        bool failed;
-       
+
        /**
         * Was there anything wrong with the payloads?
         */
        bool invalid_syntax;
-       
+
        /**
         * The requested peer
         */
-       identification_t *peer_id;      
+       identification_t *peer_id;
        /**
         * Received ID used for connectivity checks
         */
        chunk_t connect_id;
-       
+
        /**
         * Received key used for connectivity checks
         */
        chunk_t connect_key;
-       
+
        /**
         * Peer config of the mediated connection
         */
@@ -112,7 +112,7 @@ static void add_endpoints_to_message(message_t *message, linked_list_t *endpoint
 {
        iterator_t *iterator;
        endpoint_notify_t *endpoint;
-       
+
        iterator = endpoints->create_iterator(endpoints, TRUE);
        while (iterator->iterate(iterator, (void**)&endpoint))
        {
@@ -129,25 +129,25 @@ static void gather_and_add_endpoints(private_ike_me_t *this, message_t *message)
        enumerator_t *enumerator;
        host_t *addr, *host;
        u_int16_t port;
-       
+
        /* get the port that is used to communicate with the ms */
        host = this->ike_sa->get_my_host(this->ike_sa);
        port = host->get_port(host);
-       
+
        enumerator = charon->kernel_interface->create_address_enumerator(
                                                                                charon->kernel_interface, FALSE, FALSE);
        while (enumerator->enumerate(enumerator, (void**)&addr))
        {
                host = addr->clone(addr);
                host->set_port(host, port);
-               
+
                this->local_endpoints->insert_last(this->local_endpoints,
                                endpoint_notify_create_from_host(HOST, host, NULL));
-               
+
                host->destroy(host);
        }
        enumerator->destroy(enumerator);
-       
+
        host = this->ike_sa->get_server_reflexive_host(this->ike_sa);
        if (host)
        {
@@ -155,7 +155,7 @@ static void gather_and_add_endpoints(private_ike_me_t *this, message_t *message)
                                endpoint_notify_create_from_host(SERVER_REFLEXIVE, host,
                                                this->ike_sa->get_my_host(this->ike_sa)));
        }
-       
+
        add_endpoints_to_message(message, this->local_endpoints);
 }
 
@@ -166,7 +166,7 @@ static void process_payloads(private_ike_me_t *this, message_t *message)
 {
        enumerator_t *enumerator;
        payload_t *payload;
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -174,9 +174,9 @@ static void process_payloads(private_ike_me_t *this, message_t *message)
                {
                        continue;
                }
-               
+
                notify_payload_t *notify = (notify_payload_t*)payload;
-               
+
                switch (notify->get_notify_type(notify))
                {
                        case ME_CONNECT_FAILED:
@@ -201,7 +201,7 @@ static void process_payloads(private_ike_me_t *this, message_t *message)
                                }
                                DBG1(DBG_IKE, "received %N ME_ENDPOINT %#H", me_endpoint_type_names,
                                        endpoint->get_type(endpoint), endpoint->get_host(endpoint));
-                               
+
                                this->remote_endpoints->insert_last(this->remote_endpoints, endpoint);
                                break;
                        }
@@ -273,14 +273,14 @@ static status_t build_i(private_ike_me_t *this, message_t *message)
                {
                        id_payload_t *id_payload;
                        rng_t *rng;
-                       
+
                        id_payload = id_payload_create_from_identification(ID_PEER, this->peer_id);
                        message->add_payload(message, (payload_t*)id_payload);
-                       
+
                        rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
                        if (!rng)
                        {
-                               DBG1(DBG_IKE, "unable to generate connect ID for ME_CONNECT");  
+                               DBG1(DBG_IKE, "unable to generate connect ID for ME_CONNECT");
                                return FAILED;
                        }
                        if (!this->response)
@@ -291,10 +291,10 @@ static status_t build_i(private_ike_me_t *this, message_t *message)
                        }
                        rng->allocate_bytes(rng, ME_CONNECTKEY_LEN, &this->connect_key);
                        rng->destroy(rng);
-                       
+
                        message->add_notify(message, FALSE, ME_CONNECTID, this->connect_id);
                        message->add_notify(message, FALSE, ME_CONNECTKEY, this->connect_key);
-                       
+
                        if (this->response)
                        {
                                message->add_notify(message, FALSE, ME_RESPONSE, chunk_empty);
@@ -304,9 +304,9 @@ static status_t build_i(private_ike_me_t *this, message_t *message)
                                /* FIXME: should we make that configurable? */
                                message->add_notify(message, FALSE, ME_CALLBACK, chunk_empty);
                        }
-                       
+
                        gather_and_add_endpoints(this, message);
-                       
+
                        break;
                }
                default:
@@ -332,36 +332,36 @@ static status_t process_r(private_ike_me_t *this, message_t *message)
                                break;
                        }
                        this->peer_id = id_payload->get_identification(id_payload);
-                       
+
                        process_payloads(this, message);
-                       
+
                        if (this->callback)
                        {
                                DBG1(DBG_IKE, "received ME_CALLBACK for '%Y'", this->peer_id);
                                break;
-                       }                       
-                       
+                       }
+
                        if (!this->connect_id.ptr)
                        {
                                DBG1(DBG_IKE, "received ME_CONNECT without ME_CONNECTID notify, aborting");
                                this->invalid_syntax = TRUE;
                                break;
                        }
-                       
+
                        if (!this->connect_key.ptr)
                        {
                                DBG1(DBG_IKE, "received ME_CONNECT without ME_CONNECTKEY notify, aborting");
                                this->invalid_syntax = TRUE;
                                break;
                        }
-                       
+
                        if (!this->remote_endpoints->get_count(this->remote_endpoints))
                        {
                                DBG1(DBG_IKE, "received ME_CONNECT without any ME_ENDPOINT payloads, aborting");
                                this->invalid_syntax = TRUE;
                                break;
                        }
-                       
+
                        DBG1(DBG_IKE, "received ME_CONNECT");
                        break;
                }
@@ -385,7 +385,7 @@ static status_t build_r(private_ike_me_t *this, message_t *message)
                                message->add_notify(message, TRUE, INVALID_SYNTAX, chunk_empty);
                                break;
                        }
-                       
+
                        if (this->callback)
                        {
                                charon->connect_manager->check_and_initiate(charon->connect_manager,
@@ -393,7 +393,7 @@ static status_t build_r(private_ike_me_t *this, message_t *message)
                                                this->ike_sa->get_my_id(this->ike_sa), this->peer_id);
                                return SUCCESS;
                        }
-                       
+
                        if (this->response)
                        {
                                /* FIXME: handle result of set_responder_data
@@ -434,13 +434,13 @@ static status_t process_i(private_ike_me_t *this, message_t *message)
                case IKE_SA_INIT:
                {
                        process_payloads(this, message);
-               
+
                        if (!this->mediation)
                        {
                                DBG1(DBG_IKE, "server did not return a ME_MEDIATION, aborting");
                                return FAILED;
                        }
-       
+
                        return NEED_MORE;
                }
                case IKE_AUTH:
@@ -449,24 +449,24 @@ static status_t process_i(private_ike_me_t *this, message_t *message)
                        /* FIXME: we should update the server reflexive endpoint somehow,
                         * if mobike notices a change */
                        endpoint_notify_t *reflexive;
-                       if (this->remote_endpoints->get_first(this->remote_endpoints, 
+                       if (this->remote_endpoints->get_first(this->remote_endpoints,
                                                                                        (void**)&reflexive) == SUCCESS &&
                                reflexive->get_type(reflexive) == SERVER_REFLEXIVE)
-                       {       /* FIXME: should we accept this endpoint even if we did not send 
+                       {       /* FIXME: should we accept this endpoint even if we did not send
                                 * a request? */
                                host_t *endpoint = reflexive->get_host(reflexive);
-                               
+
                                this->ike_sa->set_server_reflexive_host(this->ike_sa, endpoint->clone(endpoint));
                        }
                        /* FIXME: what if it failed? e.g. AUTH failure */
                        DBG1(DBG_IKE, "established mediation connection successfully");
-                       
+
                        break;
                }
                case ME_CONNECT:
                {
                        process_payloads(this, message);
-                       
+
                        if (this->failed)
                        {
                                DBG1(DBG_IKE, "peer '%Y' is not online", this->peer_id);
@@ -512,7 +512,7 @@ static status_t build_i_ms(private_ike_me_t *this, message_t *message)
                {
                        id_payload_t *id_payload = id_payload_create_from_identification(ID_PEER, this->peer_id);
                        message->add_payload(message, (payload_t*)id_payload);
-                       
+
                        if (this->callback)
                        {
                                message->add_notify(message, FALSE, ME_CALLBACK, chunk_empty);
@@ -522,10 +522,10 @@ static status_t build_i_ms(private_ike_me_t *this, message_t *message)
                                if (this->response)
                                {
                                        message->add_notify(message, FALSE, ME_RESPONSE, chunk_empty);
-                               }       
+                               }
                                message->add_notify(message, FALSE, ME_CONNECTID, this->connect_id);
                                message->add_notify(message, FALSE, ME_CONNECTKEY, this->connect_key);
-                               
+
                                add_endpoints_to_message(message, this->remote_endpoints);
                        }
                        break;
@@ -533,7 +533,7 @@ static status_t build_i_ms(private_ike_me_t *this, message_t *message)
                default:
                        break;
        }
-       
+
        return NEED_MORE;
 }
 
@@ -574,25 +574,25 @@ static status_t process_r_ms(private_ike_me_t *this, message_t *message)
                                this->invalid_syntax = TRUE;
                                break;
                        }
-                       
+
                        this->peer_id = id_payload->get_identification(id_payload);
-                       
+
                        process_payloads(this, message);
-                       
+
                        if (!this->connect_id.ptr)
                        {
                                DBG1(DBG_IKE, "received ME_CONNECT without ME_CONNECTID notify, aborting");
                                this->invalid_syntax = TRUE;
                                break;
                        }
-                       
+
                        if (!this->connect_key.ptr)
                        {
                                DBG1(DBG_IKE, "received ME_CONNECT without ME_CONNECTKEY notify, aborting");
                                this->invalid_syntax = TRUE;
                                break;
                        }
-                       
+
                        if (!this->remote_endpoints->get_count(this->remote_endpoints))
                        {
                                DBG1(DBG_IKE, "received ME_CONNECT without any ME_ENDPOINT payloads, aborting");
@@ -604,7 +604,7 @@ static status_t process_r_ms(private_ike_me_t *this, message_t *message)
                default:
                        break;
        }
-       
+
        return NEED_MORE;
 }
 
@@ -627,30 +627,30 @@ static status_t build_r_ms(private_ike_me_t *this, message_t *message)
                                        endpoint->get_type(endpoint) == SERVER_REFLEXIVE)
                        {
                                host_t *host = this->ike_sa->get_other_host(this->ike_sa);
-                               
+
                                DBG2(DBG_IKE, "received request for a server reflexive endpoint "
                                                "sending: %#H", host);
-                               
-                               endpoint = endpoint_notify_create_from_host(SERVER_REFLEXIVE, host, NULL);                                                              
+
+                               endpoint = endpoint_notify_create_from_host(SERVER_REFLEXIVE, host, NULL);
                                message->add_payload(message, (payload_t*)endpoint->build_notify(endpoint));
                                endpoint->destroy(endpoint);
                        }
-                       
+
                        /* FIXME: we actually must delete any existing IKE_SAs with the same remote id */
                        this->ike_sa->act_as_mediation_server(this->ike_sa);
-                       
+
                        DBG1(DBG_IKE, "established mediation connection successfully");
-                       
+
                        break;
                }
                case ME_CONNECT:
-               {       
+               {
                        if (this->invalid_syntax)
                        {
                                message->add_notify(message, TRUE, INVALID_SYNTAX, chunk_empty);
                                break;
                        }
-                       
+
                        ike_sa_id_t *peer_sa;
                        if (this->callback)
                        {
@@ -662,19 +662,19 @@ static status_t build_r_ms(private_ike_me_t *this, message_t *message)
                                peer_sa = charon->mediation_manager->check(charon->mediation_manager,
                                                this->peer_id);
                        }
-                       
+
                        if (!peer_sa)
                        {
                                /* the peer is not online */
                                message->add_notify(message, TRUE, ME_CONNECT_FAILED, chunk_empty);
                                break;
                        }
-                       
+
                        job_t *job = (job_t*)mediation_job_create(this->peer_id,
                                        this->ike_sa->get_other_id(this->ike_sa), this->connect_id,
                                        this->connect_key, this->remote_endpoints, this->response);
                        charon->processor->queue_job(charon->processor, job);
-                       
+
                        break;
                }
                default:
@@ -706,7 +706,7 @@ static void me_connect(private_ike_me_t *this, identification_t *peer_id)
 /**
  * Implementation of ike_me.respond
  */
-static void me_respond(private_ike_me_t *this, identification_t *peer_id, 
+static void me_respond(private_ike_me_t *this, identification_t *peer_id,
                chunk_t connect_id)
 {
        this->peer_id = peer_id->clone(peer_id);
@@ -732,10 +732,10 @@ static void relay(private_ike_me_t *this, identification_t *requester, chunk_t c
        this->peer_id = requester->clone(requester);
        this->connect_id = chunk_clone(connect_id);
        this->connect_key = chunk_clone(connect_key);
-       
+
        this->remote_endpoints->destroy_offset(this->remote_endpoints, offsetof(endpoint_notify_t, destroy));
        this->remote_endpoints = endpoints->clone_offset(endpoints, offsetof(endpoint_notify_t, clone));
-       
+
        this->response = response;
 }
 
@@ -761,13 +761,13 @@ static void migrate(private_ike_me_t *this, ike_sa_t *ike_sa)
 static void destroy(private_ike_me_t *this)
 {
        DESTROY_IF(this->peer_id);
-       
+
        chunk_free(&this->connect_id);
        chunk_free(&this->connect_key);
-       
+
        this->local_endpoints->destroy_offset(this->local_endpoints, offsetof(endpoint_notify_t, destroy));
        this->remote_endpoints->destroy_offset(this->remote_endpoints, offsetof(endpoint_notify_t, destroy));
-       
+
        DESTROY_IF(this->mediated_cfg);
        free(this);
 }
@@ -782,7 +782,7 @@ ike_me_t *ike_me_create(ike_sa_t *ike_sa, bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (ike_sa->has_condition(ike_sa, COND_ORIGINAL_INITIATOR))
        {
                if (initiator)
@@ -810,15 +810,15 @@ ike_me_t *ike_me_create(ike_sa_t *ike_sa, bool initiator)
                        this->public.task.process = (status_t(*)(task_t*,message_t*))process_r_ms;
                }
        }
-       
+
        this->public.connect = (void(*)(ike_me_t*,identification_t*))me_connect;
        this->public.respond = (void(*)(ike_me_t*,identification_t*,chunk_t))me_respond;
        this->public.callback = (void(*)(ike_me_t*,identification_t*))me_callback;
        this->public.relay = (void(*)(ike_me_t*,identification_t*,chunk_t,chunk_t,linked_list_t*,bool))relay;
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
-       
+
        this->peer_id = NULL;
        this->connect_id = chunk_empty;
        this->connect_key = chunk_empty;
@@ -829,8 +829,8 @@ ike_me_t *ike_me_create(ike_sa_t *ike_sa, bool initiator)
        this->callback = FALSE;
        this->failed = FALSE;
        this->invalid_syntax = FALSE;
-       
+
        this->mediated_cfg = NULL;
-       
+
        return &this->public;
 }
index 4b35c313cd61f90c9db16bd7e12ebe0d80c318b5..43ba655c761deda60ebad10c6551238cc81902df 100644 (file)
@@ -34,7 +34,7 @@ typedef struct ike_me_t ike_me_t;
  * connection, allows to initiate mediated connections using ME_CONNECT
  * exchanges and to request reflexive addresses from the mediation server using
  * ME_ENDPOINT notifies.
- * 
+ *
  * @note This task has to be activated before the IKE_AUTH task, because that
  * task generates the IKE_SA_INIT message so that no more payloads can be added
  * to it afterwards.
@@ -45,7 +45,7 @@ struct ike_me_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Initiates a connection with another peer (i.e. sends a ME_CONNECT
         * to the mediation server)
@@ -53,28 +53,28 @@ struct ike_me_t {
         * @param peer_id                       ID of the other peer (gets cloned)
         */
        void (*connect)(ike_me_t *this, identification_t *peer_id);
-       
+
        /**
         * Responds to a ME_CONNECT from another peer (i.e. sends a ME_CONNECT
         * to the mediation server)
-        * 
+        *
         * @param peer_id                       ID of the other peer (gets cloned)
         * @param connect_id            the connect ID as provided by the initiator (gets cloned)
         */
        void (*respond)(ike_me_t *this, identification_t *peer_id, chunk_t connect_id);
-       
+
        /**
         * Sends a ME_CALLBACK to a peer that previously requested another peer.
-        * 
+        *
         * @param peer_id                       ID of the other peer (gets cloned)
         */
        void (*callback)(ike_me_t *this, identification_t *peer_id);
-       
+
        /**
         * Relays data to another peer (i.e. sends a ME_CONNECT to the peer)
-        * 
+        *
         * Data gets cloned.
-        * 
+        *
         * @param requester                     ID of the requesting peer
         * @param connect_id            content of the ME_CONNECTID notify
         * @param connect_key           content of the ME_CONNECTKEY notify
index 9a1afe744f410175064043aa488cb6d0b5d284e8..f93d48f6816eaedb2b4d787b20e8a10116c50ba3 100644 (file)
@@ -30,42 +30,42 @@ typedef struct private_ike_mobike_t private_ike_mobike_t;
  * Private members of a ike_mobike_t task.
  */
 struct private_ike_mobike_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_mobike_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * cookie2 value to verify new addresses
         */
        chunk_t cookie2;
-       
+
        /**
         * NAT discovery reusing the IKE_NATD task
         */
        ike_natd_t *natd;
-       
+
        /**
         * use task to update addresses
         */
        bool update;
-       
+
        /**
         * do routability check
         */
        bool check;
-       
+
        /**
         * include address list update
         */
@@ -79,7 +79,7 @@ static void flush_additional_addresses(private_ike_mobike_t *this)
 {
        iterator_t *iterator;
        host_t *host;
-       
+
        iterator = this->ike_sa->create_additional_address_iterator(this->ike_sa);
        while (iterator->iterate(iterator, (void**)&host))
        {
@@ -98,7 +98,7 @@ static void process_payloads(private_ike_mobike_t *this, message_t *message)
        enumerator_t *enumerator;
        payload_t *payload;
        bool first = TRUE;
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -106,7 +106,7 @@ static void process_payloads(private_ike_mobike_t *this, message_t *message)
                notify_payload_t *notify;
                chunk_t data;
                host_t *host;
-               
+
                if (payload->get_type(payload) != NOTIFY)
                {
                        continue;
@@ -117,9 +117,9 @@ static void process_payloads(private_ike_mobike_t *this, message_t *message)
                        case MOBIKE_SUPPORTED:
                        {
                                peer_cfg_t *peer_cfg;
-                               
+
                                peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
-                               if (!this->initiator && 
+                               if (!this->initiator &&
                                        peer_cfg && !peer_cfg->use_mobike(peer_cfg))
                                {
                                        DBG1(DBG_IKE, "peer supports MOBIKE, but disabled in config");
@@ -191,7 +191,7 @@ static void build_address_list(private_ike_mobike_t *this, message_t *message)
        host_t *host, *me;
        notify_type_t type;
        int added = 0;
-       
+
        me = this->ike_sa->get_my_host(this->ike_sa);
        enumerator = charon->kernel_interface->create_address_enumerator(
                                                                                charon->kernel_interface, FALSE, FALSE);
@@ -227,7 +227,7 @@ static void build_address_list(private_ike_mobike_t *this, message_t *message)
 }
 
 /**
- * build a cookie and add it to the message 
+ * build a cookie and add it to the message
  */
 static void build_cookie(private_ike_mobike_t *this, message_t *message)
 {
@@ -250,12 +250,12 @@ static void update_children(private_ike_mobike_t *this)
 {
        iterator_t *iterator;
        child_sa_t *child_sa;
-       
+
        iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
        while (iterator->iterate(iterator, (void**)&child_sa))
        {
                if (child_sa->update(child_sa,
-                               this->ike_sa->get_my_host(this->ike_sa), 
+                               this->ike_sa->get_my_host(this->ike_sa),
                                this->ike_sa->get_other_host(this->ike_sa),
                                this->ike_sa->get_virtual_ip(this->ike_sa, TRUE),
                                this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY)) == NOT_SUPPORTED)
@@ -276,7 +276,7 @@ static void transmit(private_ike_mobike_t *this, packet_t *packet)
        host_t *me, *other, *me_old, *other_old;
        iterator_t *iterator;
        packet_t *copy;
-       
+
        if (!this->check)
        {
                return;
@@ -284,7 +284,7 @@ static void transmit(private_ike_mobike_t *this, packet_t *packet)
 
        me_old = this->ike_sa->get_my_host(this->ike_sa);
        other_old = this->ike_sa->get_other_host(this->ike_sa);
-       
+
        me = charon->kernel_interface->get_source_addr(
                                                                        charon->kernel_interface, other_old, NULL);
        if (me)
@@ -293,7 +293,7 @@ static void transmit(private_ike_mobike_t *this, packet_t *packet)
                                         me_old->get_port(me_old) : IKEV2_NATT_PORT);
                packet->set_source(packet, me);
        }
-       
+
        iterator = this->ike_sa->create_additional_address_iterator(this->ike_sa);
        while (iterator->iterate(iterator, (void**)&other))
        {
@@ -338,8 +338,8 @@ static status_t build_i(private_ike_mobike_t *this, message_t *message)
        else if (message->get_exchange_type(message) == INFORMATIONAL)
        {
                host_t *old, *new;
-               
-               /* we check if the existing address is still valid */ 
+
+               /* we check if the existing address is still valid */
                old = message->get_source(message);
                new = charon->kernel_interface->get_source_addr(charon->kernel_interface,
                                                                                message->get_destination(message), old);
@@ -388,13 +388,13 @@ static status_t process_r(private_ike_mobike_t *this, message_t *message)
                if (this->update)
                {
                        host_t *me, *other;
-                       
+
                        me = message->get_destination(message);
                        other = message->get_source(message);
                        this->ike_sa->set_my_host(this->ike_sa, me->clone(me));
                        this->ike_sa->set_other_host(this->ike_sa, other->clone(other));
                }
-               
+
                if (this->natd)
                {
                        this->natd->task.process(&this->natd->task, message);
@@ -461,7 +461,7 @@ static status_t process_i(private_ike_mobike_t *this, message_t *message)
                if (this->cookie2.ptr)
                {       /* check cookie if we included one */
                        chunk_t cookie2;
-                       
+
                        cookie2 = this->cookie2;
                        this->cookie2 = chunk_empty;
                        process_payloads(this, message);
@@ -496,17 +496,17 @@ static status_t process_i(private_ike_mobike_t *this, message_t *message)
                if (this->check)
                {
                        host_t *me_new, *me_old, *other_new, *other_old;
-                       
+
                        me_new = message->get_destination(message);
                        other_new = message->get_source(message);
                        me_old = this->ike_sa->get_my_host(this->ike_sa);
                        other_old = this->ike_sa->get_other_host(this->ike_sa);
-                       
+
                        if (!me_new->equals(me_new, me_old))
                        {
                                this->update = TRUE;
                                this->ike_sa->set_my_host(this->ike_sa, me_new->clone(me_new));
-                       }                       
+                       }
                        if (!other_new->equals(other_new, other_old))
                        {
                                this->update = TRUE;
@@ -538,7 +538,7 @@ static void roam(private_ike_mobike_t *this, bool address)
 {
        this->check = TRUE;
        this->address = address;
-       this->ike_sa->set_pending_updates(this->ike_sa, 
+       this->ike_sa->set_pending_updates(this->ike_sa,
                                                        this->ike_sa->get_pending_updates(this->ike_sa) + 1);
 }
 
@@ -552,7 +552,7 @@ static void dpd(private_ike_mobike_t *this)
                this->natd = ike_natd_create(this->ike_sa, this->initiator);
        }
        this->address = FALSE;
-       this->ike_sa->set_pending_updates(this->ike_sa, 
+       this->ike_sa->set_pending_updates(this->ike_sa,
                                                        this->ike_sa->get_pending_updates(this->ike_sa) + 1);
 }
 
@@ -612,7 +612,7 @@ ike_mobike_t *ike_mobike_create(ike_sa_t *ike_sa, bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -623,7 +623,7 @@ ike_mobike_t *ike_mobike_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
        this->update = FALSE;
@@ -631,7 +631,7 @@ ike_mobike_t *ike_mobike_create(ike_sa_t *ike_sa, bool initiator)
        this->address = TRUE;
        this->cookie2 = chunk_empty;
        this->natd = NULL;
-       
+
        return &this->public;
 }
 
index 919b5ddd3bb62c21e59fc52bbf4f9b9d390ab8ce..7d6dd584079bf4f69e74ab193d8f197c5bc148e6 100644 (file)
@@ -35,7 +35,7 @@ typedef struct ike_mobike_t ike_mobike_t;
  * and IPsec tunnel addresses.
  * This tasks handles the MOBIKE_SUPPORTED notify exchange to detect MOBIKE
  * support, allows the exchange of ADDITIONAL_*_ADDRESS to exchange additional
- * endpoints and handles the UPDATE_SA_ADDRESS notify to finally update 
+ * endpoints and handles the UPDATE_SA_ADDRESS notify to finally update
  * endpoints.
  */
 struct ike_mobike_t {
@@ -44,36 +44,36 @@ struct ike_mobike_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Use the task to roam to other addresses.
         *
         * @param address               TRUE to include address list update
         */
        void (*roam)(ike_mobike_t *this, bool address);
-       
+
        /**
         * Use the task for a DPD check which detects changes in NAT mappings.
         */
        void (*dpd)(ike_mobike_t *this);
-       
+
        /**
         * Transmision hook, called by task manager.
         *
-        * The task manager calls this hook whenever it transmits a packet. It 
+        * The task manager calls this hook whenever it transmits a packet. It
         * allows the mobike task to send the packet on multiple paths to do path
         * probing.
         *
         * @param packet                the packet to transmit
         */
        void (*transmit)(ike_mobike_t *this, packet_t *packet);
-       
+
        /**
         * Check if this task is probing for routability.
         *
         * @return                              TRUE if task is probing
         */
-       bool (*is_probing)(ike_mobike_t *this); 
+       bool (*is_probing)(ike_mobike_t *this);
 };
 
 /**
index f3a70c7424e11db2b32e5486437e7a1b976b056b..9121fe2ea1524465cc36024de7a8b64e8d03dd50 100644 (file)
@@ -30,47 +30,47 @@ typedef struct private_ike_natd_t private_ike_natd_t;
  * Private members of a ike_natd_t task.
  */
 struct private_ike_natd_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_natd_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * Hasher used to build NAT detection hashes
         */
        hasher_t *hasher;
-       
+
        /**
         * Did we process any NAT detection notifys for a source address?
         */
        bool src_seen;
-       
+
        /**
         * Did we process any NAT detection notifys for a destination address?
         */
        bool dst_seen;
-       
+
        /**
         * Have we found a matching source address NAT hash?
         */
        bool src_matched;
-       
+
        /**
         * Have we found a matching destination address NAT hash?
         */
        bool dst_matched;
-       
+
        /**
         * whether NAT mappings for our NATed address has changed
         */
@@ -88,7 +88,7 @@ static chunk_t generate_natd_hash(private_ike_natd_t *this,
        chunk_t natd_hash;
        u_int64_t spi_i, spi_r;
        u_int16_t port;
-       
+
        /* prepare all required chunks */
        spi_i = ike_sa_id->get_initiator_spi(ike_sa_id);
        spi_r = ike_sa_id->get_responder_spi(ike_sa_id);
@@ -100,13 +100,13 @@ static chunk_t generate_natd_hash(private_ike_natd_t *this,
        port_chunk.ptr = (void*)&port;
        port_chunk.len = sizeof(port);
        addr_chunk = host->get_address(host);
-               
+
        /*  natd_hash = SHA1( spi_i | spi_r | address | port ) */
        natd_chunk = chunk_cat("cccc", spi_i_chunk, spi_r_chunk, addr_chunk, port_chunk);
        this->hasher->allocate_hash(this->hasher, natd_chunk, &natd_hash);
        DBG3(DBG_IKE, "natd_chunk %B", &natd_chunk);
        DBG3(DBG_IKE, "natd_hash %B", &natd_hash);
-       
+
        chunk_free(&natd_chunk);
        return natd_hash;
 }
@@ -118,7 +118,7 @@ static chunk_t generate_natd_hash_faked(private_ike_natd_t *this)
 {
        rng_t *rng;
        chunk_t chunk;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (!rng)
        {
@@ -140,7 +140,7 @@ static notify_payload_t *build_natd_payload(private_ike_natd_t *this,
        notify_payload_t *notify;
        ike_sa_id_t *ike_sa_id;
        ike_cfg_t *config;
-       
+
        ike_sa_id = this->ike_sa->get_id(this->ike_sa);
        config = this->ike_sa->get_ike_cfg(this->ike_sa);
        if (config->force_encap(config) && type == NAT_DETECTION_SOURCE_IP)
@@ -155,7 +155,7 @@ static notify_payload_t *build_natd_payload(private_ike_natd_t *this,
        notify->set_notify_type(notify, type);
        notify->set_notification_data(notify, hash);
        chunk_free(&hash);
-       
+
        return notify;
 }
 
@@ -171,17 +171,17 @@ static void process_payloads(private_ike_natd_t *this, message_t *message)
        ike_sa_id_t *ike_sa_id;
        host_t *me, *other;
        ike_cfg_t *config;
-       
+
        /* Precompute NAT-D hashes for incoming NAT notify comparison */
        ike_sa_id = message->get_ike_sa_id(message);
        me = message->get_destination(message);
        other = message->get_source(message);
        dst_hash = generate_natd_hash(this, ike_sa_id, me);
        src_hash = generate_natd_hash(this, ike_sa_id, other);
-       
+
        DBG3(DBG_IKE, "precalculated src_hash %B", &src_hash);
        DBG3(DBG_IKE, "precalculated dst_hash %B", &dst_hash);
-       
+
        enumerator = message->create_payload_enumerator(message);
        while (enumerator->enumerate(enumerator, &payload))
        {
@@ -234,10 +234,10 @@ static void process_payloads(private_ike_natd_t *this, message_t *message)
                }
        }
        enumerator->destroy(enumerator);
-       
+
        chunk_free(&src_hash);
        chunk_free(&dst_hash);
-       
+
        if (this->src_seen && this->dst_seen)
        {
                this->ike_sa->enable_extension(this->ike_sa, EXT_NATT);
@@ -261,7 +261,7 @@ static void process_payloads(private_ike_natd_t *this, message_t *message)
 static status_t process_i(private_ike_natd_t *this, message_t *message)
 {
        process_payloads(this, message);
-       
+
        if (message->get_exchange_type(message) == IKE_SA_INIT)
        {
                peer_cfg_t *peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
@@ -275,7 +275,7 @@ static status_t process_i(private_ike_natd_t *this, message_t *message)
                        return SUCCESS;
                }
 #endif /* ME */
-               
+
                if (this->ike_sa->has_condition(this->ike_sa, COND_NAT_ANY) ||
 #ifdef ME
                        /* if we are on a mediation connection we switch to port 4500 even
@@ -288,7 +288,7 @@ static status_t process_i(private_ike_natd_t *this, message_t *message)
                         this->ike_sa->supports_extension(this->ike_sa, EXT_NATT)))
                {
                        host_t *me, *other;
-               
+
                        /* do not switch if we have a custom port from mobike/NAT */
                        me = this->ike_sa->get_my_host(this->ike_sa);
                        if (me->get_port(me) == IKEV2_UDP_PORT)
@@ -302,7 +302,7 @@ static status_t process_i(private_ike_natd_t *this, message_t *message)
                        }
                }
        }
-       
+
        return SUCCESS;
 }
 
@@ -314,18 +314,18 @@ static status_t build_i(private_ike_natd_t *this, message_t *message)
        notify_payload_t *notify;
        enumerator_t *enumerator;
        host_t *host;
-       
+
        if (this->hasher == NULL)
        {
                DBG1(DBG_IKE, "unable to build NATD payloads, SHA1 not supported");
                return NEED_MORE;
        }
-       
+
        /* destination is always set */
        host = message->get_destination(message);
        notify = build_natd_payload(this, NAT_DETECTION_DESTINATION_IP, host);
        message->add_payload(message, (payload_t*)notify);
-       
+
        /* source may be any, we have 3 possibilities to get our source address:
         * 1. It is defined in the config => use the one of the IKE_SA
         * 2. We do a routing lookup in the kernel interface
@@ -374,7 +374,7 @@ static status_t build_r(private_ike_natd_t *this, message_t *message)
 {
        notify_payload_t *notify;
        host_t *me, *other;
-       
+
        /* only add notifies on successfull responses. */
        if (message->get_exchange_type(message) == IKE_SA_INIT &&
                message->get_payload(message, SECURITY_ASSOCIATION) == NULL)
@@ -389,12 +389,12 @@ static status_t build_r(private_ike_natd_t *this, message_t *message)
                        DBG1(DBG_IKE, "unable to build NATD payloads, SHA1 not supported");
                        return SUCCESS;
                }
-       
+
                /* initiator seems to support NAT detection, add response */
                me = message->get_source(message);
                notify = build_natd_payload(this, NAT_DETECTION_SOURCE_IP, me);
                message->add_payload(message, (payload_t*)notify);
-               
+
                other = message->get_destination(message);
                notify = build_natd_payload(this, NAT_DETECTION_DESTINATION_IP, other);
                message->add_payload(message, (payload_t*)notify);
@@ -408,7 +408,7 @@ static status_t build_r(private_ike_natd_t *this, message_t *message)
 static status_t process_r(private_ike_natd_t *this, message_t *message)
 {
        process_payloads(this, message);
-       
+
        return NEED_MORE;
 }
 
@@ -460,7 +460,7 @@ ike_natd_t *ike_natd_create(ike_sa_t *ike_sa, bool initiator)
        this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
        this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
        this->public.task.destroy = (void(*)(task_t*))destroy;
-       
+
        if (initiator)
        {
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
@@ -471,9 +471,9 @@ ike_natd_t *ike_natd_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->public.has_mapping_changed = (bool(*)(ike_natd_t*))has_mapping_changed;
-       
+
        this->ike_sa = ike_sa;
        this->initiator = initiator;
        this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
@@ -482,6 +482,6 @@ ike_natd_t *ike_natd_create(ike_sa_t *ike_sa, bool initiator)
        this->src_matched = FALSE;
        this->dst_matched = FALSE;
        this->mapping_changed = FALSE;
-       
+
        return &this->public;
 }
index 69839484295c8479106f84c1f00b59debe2f4c45..97b652eada449ecbd482fcf48f9a7a4c0d8c3c7d 100644 (file)
@@ -36,7 +36,7 @@ struct ike_natd_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Check if the NAT mapping has changed for our address.
         *
index 3d8b7e2564979d0dc9973c2baa5629f125db44f8..ac89c358b9e3401f41d5770d00d2d9d426b499ea 100644 (file)
@@ -25,17 +25,17 @@ typedef struct private_ike_reauth_t private_ike_reauth_t;
  * Private members of a ike_reauth_t task.
  */
 struct private_ike_reauth_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_reauth_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * reused ike_delete task
         */
@@ -60,12 +60,12 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
        iterator_t *iterator;
        child_sa_t *child_sa;
        peer_cfg_t *peer_cfg;
-       
+
        /* process delete response first */
        this->ike_delete->task.process(&this->ike_delete->task, message);
 
        peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
-       
+
        /* reauthenticate only if we have children */
        iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
        if (iterator->get_count(iterator) == 0
@@ -79,9 +79,9 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
                iterator->destroy(iterator);
                return FAILED;
        }
-       
+
        new = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager, TRUE);
-       
+
        new->set_peer_cfg(new, peer_cfg);
        host = this->ike_sa->get_other_host(this->ike_sa);
        new->set_other_host(new, host->clone(host));
@@ -93,7 +93,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
        {
                new->set_virtual_ip(new, TRUE, host);
        }
-       
+
 #ifdef ME
        /* we initiate the new IKE_SA of the mediation connection without CHILD_SA */
        if (peer_cfg->is_mediation(peer_cfg))
@@ -109,7 +109,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
                }
        }
 #endif /* ME */
-       
+
        while (iterator->iterate(iterator, (void**)&child_sa))
        {
                switch (child_sa->get_state(child_sa))
@@ -144,7 +144,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
        charon->ike_sa_manager->checkin(charon->ike_sa_manager, new);
        /* set threads active IKE_SA after checkin */
        charon->bus->set_sa(charon->bus, this->ike_sa);
-       
+
        /* we always return failed to delete the obsolete IKE_SA */
        return FAILED;
 }
@@ -187,10 +187,10 @@ ike_reauth_t *ike_reauth_create(ike_sa_t *ike_sa)
        this->public.task.destroy = (void(*)(task_t*))destroy;
        this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
        this->public.task.process = (status_t(*)(task_t*,message_t*))process_i;
-       
+
        this->ike_sa = ike_sa;
        this->ike_delete = ike_delete_create(ike_sa, TRUE);
-       
+
        return &this->public;
 }
 
index e9f5d5f879c3330b5a3bf9fe845dacd2a7bd576d..2b5892af7b903e38ad6a47869cff463b1456df16 100644 (file)
@@ -30,37 +30,37 @@ typedef struct private_ike_rekey_t private_ike_rekey_t;
  * Private members of a ike_rekey_t task.
  */
 struct private_ike_rekey_t {
-       
+
        /**
         * Public methods and task_t interface.
         */
        ike_rekey_t public;
-       
+
        /**
         * Assigned IKE_SA.
         */
        ike_sa_t *ike_sa;
-       
+
        /**
         * New IKE_SA which replaces the current one
         */
        ike_sa_t *new_sa;
-       
+
        /**
         * Are we the initiator?
         */
        bool initiator;
-       
+
        /**
         * the IKE_INIT task which is reused to simplify rekeying
         */
        ike_init_t *ike_init;
-       
+
        /**
         * IKE_DELETE task to delete the old IKE_SA after rekeying was successful
         */
        ike_delete_t *ike_delete;
-       
+
        /**
         * colliding task detected by the task manager
         */
@@ -74,7 +74,7 @@ static status_t build_i_delete(private_ike_rekey_t *this, message_t *message)
 {
        /* update exchange type to INFORMATIONAL for the delete */
        message->set_exchange_type(message, INFORMATIONAL);
-       
+
        return this->ike_delete->task.build(&this->ike_delete->task, message);
 }
 
@@ -93,13 +93,13 @@ static status_t build_i(private_ike_rekey_t *this, message_t *message)
 {
        peer_cfg_t *peer_cfg;
        host_t *other_host;
-       
+
        /* create new SA only on first try */
        if (this->new_sa == NULL)
        {
                this->new_sa = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
                                                                                                                        TRUE);
-               
+
                peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
                other_host = this->ike_sa->get_other_host(this->ike_sa);
                this->new_sa->set_peer_cfg(this->new_sa, peer_cfg);
@@ -120,7 +120,7 @@ static status_t process_r(private_ike_rekey_t *this, message_t *message)
        peer_cfg_t *peer_cfg;
        iterator_t *iterator;
        child_sa_t *child_sa;
-       
+
        if (this->ike_sa->get_state(this->ike_sa) == IKE_DELETING)
        {
                DBG1(DBG_IKE, "peer initiated rekeying, but we are deleting");
@@ -144,15 +144,15 @@ static status_t process_r(private_ike_rekey_t *this, message_t *message)
                }
        }
        iterator->destroy(iterator);
-       
+
        this->new_sa = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
                                                                                                                FALSE);
-       
+
        peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
        this->new_sa->set_peer_cfg(this->new_sa, peer_cfg);
        this->ike_init = ike_init_create(this->new_sa, FALSE, this->ike_sa);
        this->ike_init->task.process(&this->ike_init->task, message);
-       
+
        return NEED_MORE;
 }
 
@@ -167,12 +167,12 @@ static status_t build_r(private_ike_rekey_t *this, message_t *message)
                message->add_notify(message, TRUE, NO_PROPOSAL_CHOSEN, chunk_empty);
                return SUCCESS;
        }
-       
+
        if (this->ike_init->task.build(&this->ike_init->task, message) == FAILED)
        {
                return SUCCESS;
        }
-       
+
        this->ike_sa->set_state(this->ike_sa, IKE_REKEYING);
        this->new_sa->set_state(this->new_sa, IKE_ESTABLISHED);
        DBG0(DBG_IKE, "IKE_SA %s[%d] established between %H[%Y]...%H[%Y]",
@@ -182,7 +182,7 @@ static status_t build_r(private_ike_rekey_t *this, message_t *message)
                 this->ike_sa->get_my_id(this->ike_sa),
                 this->ike_sa->get_other_host(this->ike_sa),
                 this->ike_sa->get_other_id(this->ike_sa));
-       
+
        return SUCCESS;
 }
 
@@ -201,7 +201,7 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
                                                        this->ike_sa->get_id(this->ike_sa), TRUE));
                return SUCCESS;
        }
-       
+
        switch (this->ike_init->task.process(&this->ike_init->task, message))
        {
                case FAILED:
@@ -227,7 +227,7 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
                default:
                        break;
        }
-       
+
        this->new_sa->set_state(this->new_sa, IKE_ESTABLISHED);
        DBG0(DBG_IKE, "IKE_SA %s[%d] established between %H[%Y]...%H[%Y]",
                 this->new_sa->get_name(this->new_sa),
@@ -236,7 +236,7 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
                 this->ike_sa->get_my_id(this->ike_sa),
                 this->ike_sa->get_other_host(this->ike_sa),
                 this->ike_sa->get_other_id(this->ike_sa));
-       
+
        /* check for collisions */
        if (this->collision &&
                this->collision->get_type(this->collision) == IKE_REKEY)
@@ -244,13 +244,13 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
                chunk_t this_nonce, other_nonce;
                host_t *host;
                private_ike_rekey_t *other = (private_ike_rekey_t*)this->collision;
-               
+
                this_nonce = this->ike_init->get_lower_nonce(this->ike_init);
                other_nonce = other->ike_init->get_lower_nonce(other->ike_init);
-               
+
                /* if we have the lower nonce, delete rekeyed SA. If not, delete
                 * the redundant. */
-               if (memcmp(this_nonce.ptr, other_nonce.ptr, 
+               if (memcmp(this_nonce.ptr, other_nonce.ptr,
                                   min(this_nonce.len, other_nonce.len)) < 0)
                {
                        /* peer should delete this SA. Add a timeout just in case. */
@@ -290,12 +290,12 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
                /* set threads active IKE_SA after checkin */
                charon->bus->set_sa(charon->bus, this->ike_sa);
        }
-       
+
        /* rekeying successful, delete the IKE_SA using a subtask */
        this->ike_delete = ike_delete_create(this->ike_sa, TRUE);
        this->public.task.build = (status_t(*)(task_t*,message_t*))build_i_delete;
        this->public.task.process = (status_t(*)(task_t*,message_t*))process_i_delete;
-       
+
        return NEED_MORE;
 }
 
@@ -334,7 +334,7 @@ static void migrate(private_ike_rekey_t *this, ike_sa_t *ike_sa)
                charon->bus->set_sa(charon->bus, this->ike_sa);
        }
        DESTROY_IF(this->collision);
-       
+
        this->collision = NULL;
        this->ike_sa = ike_sa;
        this->new_sa = NULL;
@@ -397,13 +397,13 @@ ike_rekey_t *ike_rekey_create(ike_sa_t *ike_sa, bool initiator)
                this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
                this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
        }
-       
+
        this->ike_sa = ike_sa;
        this->new_sa = NULL;
        this->ike_init = NULL;
        this->ike_delete = NULL;
        this->initiator = initiator;
        this->collision = NULL;
-       
+
        return &this->public;
 }
index 6748279ab53658650438271fc1979a50e44a30da..b9c02220d31bb4e864d0eabc837c20efc7a4ff7e 100644 (file)
@@ -36,7 +36,7 @@ struct ike_rekey_t {
         * Implements the task_t interface
         */
        task_t task;
-       
+
        /**
         * Register a rekeying task which collides with this one.
         *
index 0e0af072fdb70e3bf8a714175fc88eeada5697dc..b53b2cc1faadec0dbd2474f9a11d2802673adf50 100644 (file)
@@ -123,7 +123,7 @@ struct task_t {
         * Get the type of the task implementation.
         */
        task_type_t (*get_type) (task_t *this);
-       
+
        /**
         * Migrate a task to a new IKE_SA.
         *
@@ -138,7 +138,7 @@ struct task_t {
         * @param ike_sa                new IKE_SA this task works for
         */
        void (*migrate) (task_t *this, ike_sa_t *ike_sa);
-       
+
        /**
         * Destroys a task_t object.
         */
index 570335eb407fb09074d395a269d0e34675477bac..c9090250db513b13164b604b8905f763ddc1567c 100644 (file)
@@ -27,12 +27,12 @@ typedef struct trap_listener_t trap_listener_t;
  * listener to track acquires
  */
 struct trap_listener_t {
-       
+
        /**
         * Implements listener interface
         */
        listener_t listener;
-       
+
        /**
         * points to trap_manager
         */
@@ -43,22 +43,22 @@ struct trap_listener_t {
  * Private data of an trap_manager_t object.
  */
 struct private_trap_manager_t {
-       
+
        /**
         * Public trap_manager_t interface.
         */
        trap_manager_t public;
-       
+
        /**
         * Installed traps, as entry_t
         */
        linked_list_t *traps;
-       
+
        /**
         * read write lock for traps list
         */
        rwlock_t *lock;
-       
+
        /**
         * listener to track acquiring IKE_SAs
         */
@@ -102,7 +102,7 @@ static u_int32_t install(private_trap_manager_t *this, peer_cfg_t *peer,
        bool found = FALSE;
        status_t status;
        u_int32_t reqid;
-       
+
        /* check if not already done */
        this->lock->read_lock(this->lock);
        enumerator = this->traps->create_enumerator(this->traps);
@@ -123,10 +123,10 @@ static u_int32_t install(private_trap_manager_t *this, peer_cfg_t *peer,
                         child->get_name(child));
                return 0;
        }
-       
+
        /* try to resolve addresses */
        ike_cfg = peer->get_ike_cfg(peer);
-       other = host_create_from_dns(ike_cfg->get_other_addr(ike_cfg), 
+       other = host_create_from_dns(ike_cfg->get_other_addr(ike_cfg),
                                                                 0, IKEV2_UDP_PORT);
        if (!other)
        {
@@ -148,14 +148,14 @@ static u_int32_t install(private_trap_manager_t *this, peer_cfg_t *peer,
                }
                me->set_port(me, IKEV2_UDP_PORT);
        }
-       
+
        /* create and route CHILD_SA */
        child_sa = child_sa_create(me, other, child, 0, FALSE);
        my_ts = child->get_traffic_selectors(child, TRUE, NULL, me);
        other_ts = child->get_traffic_selectors(child, FALSE, NULL, other);
        me->destroy(me);
        other->destroy(other);
-       
+
        /* while we don't know the finally negotiated protocol (ESP|AH), we
         * could iterate all proposals for a best guest (TODO). But as we
         * support ESP only for now, we set here. */
@@ -170,17 +170,17 @@ static u_int32_t install(private_trap_manager_t *this, peer_cfg_t *peer,
                DBG1(DBG_CFG, "installing trap failed");
                return 0;
        }
-       
+
        reqid = child_sa->get_reqid(child_sa);
        entry = malloc_thing(entry_t);
        entry->child_sa = child_sa;
        entry->peer_cfg = peer->get_ref(peer);
        entry->pending = NULL;
-       
+
        this->lock->write_lock(this->lock);
        this->traps->insert_last(this->traps, entry);
        this->lock->unlock(this->lock);
-       
+
        return reqid;
 }
 
@@ -191,7 +191,7 @@ static bool uninstall(private_trap_manager_t *this, u_int32_t reqid)
 {
        enumerator_t *enumerator;
        entry_t *entry, *found = NULL;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->traps->create_enumerator(this->traps);
        while (enumerator->enumerate(enumerator, &entry))
@@ -205,13 +205,13 @@ static bool uninstall(private_trap_manager_t *this, u_int32_t reqid)
        }
        enumerator->destroy(enumerator);
        this->lock->unlock(this->lock);
-       
+
        if (!found)
        {
                DBG1(DBG_CFG, "trap %d not found to uninstall", reqid);
                return FALSE;
        }
-       
+
        destroy_entry(found);
        return TRUE;
 }
@@ -255,7 +255,7 @@ static void acquire(private_trap_manager_t *this, u_int32_t reqid,
        peer_cfg_t *peer;
        child_cfg_t *child;
        ike_sa_t *ike_sa;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->traps->create_enumerator(this->traps);
        while (enumerator->enumerate(enumerator, &entry))
@@ -267,7 +267,7 @@ static void acquire(private_trap_manager_t *this, u_int32_t reqid,
                }
        }
        enumerator->destroy(enumerator);
-       
+
        if (!found)
        {
                DBG1(DBG_CFG, "trap not found, unable to acquire reqid %d",reqid);
@@ -311,7 +311,7 @@ static bool ike_state_change(trap_listener_t *listener, ike_sa_t *ike_sa,
        private_trap_manager_t *this;
        enumerator_t *enumerator;
        entry_t *entry;
-       
+
        switch (state)
        {
                case IKE_ESTABLISHED:
@@ -320,7 +320,7 @@ static bool ike_state_change(trap_listener_t *listener, ike_sa_t *ike_sa,
                default:
                        return TRUE;
        }
-       
+
        this = listener->traps;
        this->lock->read_lock(this->lock);
        enumerator = this->traps->create_enumerator(this->traps);
@@ -354,22 +354,22 @@ static void destroy(private_trap_manager_t *this)
 trap_manager_t *trap_manager_create()
 {
        private_trap_manager_t *this = malloc_thing(private_trap_manager_t);
-       
+
        this->public.install = (u_int(*)(trap_manager_t*, peer_cfg_t *peer, child_cfg_t *child))install;
        this->public.uninstall = (bool(*)(trap_manager_t*, u_int32_t id))uninstall;
        this->public.create_enumerator = (enumerator_t*(*)(trap_manager_t*))create_enumerator;
        this->public.acquire = (void(*)(trap_manager_t*, u_int32_t reqid, traffic_selector_t *src, traffic_selector_t *dst))acquire;
        this->public.destroy = (void(*)(trap_manager_t*))destroy;
-       
+
        this->traps = linked_list_create();
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        /* register listener for IKE state changes */
        this->listener.traps = this;
        memset(&this->listener.listener, 0, sizeof(listener_t));
        this->listener.listener.ike_state_change = (void*)ike_state_change;
        charon->bus->add_listener(charon->bus, &this->listener.listener);
-       
+
        return &this->public;
 }
 
index cb6907cdc5d16674bb122562ebc5019851657906..9a39229e6267cea81dd10fe34d77220ffbfcd364 100644 (file)
@@ -31,7 +31,7 @@ typedef struct trap_manager_t trap_manager_t;
  * Manage policies to create SAs from traffic.
  */
 struct trap_manager_t {
-       
+
        /**
         * Install a policy as a trap.
         *
@@ -41,7 +41,7 @@ struct trap_manager_t {
         */
        u_int32_t (*install)(trap_manager_t *this, peer_cfg_t *peer,
                                                 child_cfg_t *child);
-       
+
        /**
         * Uninstall a trap policy.
         *
@@ -49,14 +49,14 @@ struct trap_manager_t {
         * @return                      TRUE if uninstalled successfully
         */
        bool (*uninstall)(trap_manager_t *this, u_int32_t reqid);
-       
+
        /**
         * Create an enumerator over all installed traps.
         *
         * @return                      enumerator over (peer_cfg_t, child_sa_t)
         */
        enumerator_t* (*create_enumerator)(trap_manager_t *this);
-       
+
        /**
         * Acquire an SA triggered by an installed trap.
         *
@@ -66,7 +66,7 @@ struct trap_manager_t {
         */
        void (*acquire)(trap_manager_t *this, u_int32_t reqid,
                                        traffic_selector_t *src, traffic_selector_t *dst);
-       
+
        /**
         * Destroy a trap_manager_t.
         */
index ff20fe3693a397d34bb0519eb9f136432d29413c..54f4539ff895edc51fb1caf3ddccf21d196026e1 100644 (file)
@@ -28,14 +28,14 @@ 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);
-       
+
        integrity = integrity_checker_create(NULL);
-       
+
        printf("/**\n");
        printf(" * checksums of files and loaded code segments.\n");
        printf(" * created by %s\n", argv[0]);
@@ -55,7 +55,7 @@ int main(int argc, char* argv[])
                size_t ssize = 0;
 
                path = argv[i];
-               
+
                if ((name = strstr(path, "libstrongswan-")))
                {
                        name = strdup(name + strlen("libstrongswan-"));
@@ -98,7 +98,7 @@ int main(int argc, char* argv[])
                        fprintf(stderr, "don't know how to handle '%s', ignored", path);
                        continue;
                }
-               
+
                fsum = integrity->build_file(integrity, path, &fsize);
                ssum = 0;
                if (sname)
@@ -124,7 +124,7 @@ int main(int argc, char* argv[])
                }
                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", 
+               fprintf(stderr, "\"%-20s%7u / 0x%08x       %6u / 0x%08x\n",
                                name, fsize, fsum, ssize, ssum);
                free(name);
        }
@@ -133,7 +133,7 @@ int main(int argc, char* argv[])
        printf("int checksum_count = countof(checksums);\n");
        printf("\n");
        integrity->destroy(integrity);
-       
+
        exit(0);
 }
 
index 209e54fc1bc0f5224cd24ebc4b85c95439878ad8..592fecefd0177f6f6fe2f1456c5e11bca3a35b82 100644 (file)
@@ -36,7 +36,7 @@ struct private_bridge_t {
  * defined in iface.c
  */
 bool iface_control(char *name, bool up);
-       
+
 /**
  * Implementation of bridge_t.get_name.
  */
@@ -149,7 +149,7 @@ static void destroy(private_bridge_t *this)
 bridge_t *bridge_create(char *name)
 {
        private_bridge_t *this;
-       
+
        if (instances == 0)
        {
                if (br_init() != 0)
@@ -158,7 +158,7 @@ bridge_t *bridge_create(char *name)
                        return NULL;
                }
        }
-       
+
        this = malloc_thing(private_bridge_t);
        this->public.get_name = (char*(*)(bridge_t*))get_name;
        this->public.create_iface_enumerator = (enumerator_t*(*)(bridge_t*))create_iface_enumerator;
index 37b22a03e5097f83e607a04a5bf50bfee921047b..c557de994bbdd264d839b2d9bb9bf18d3ab0e9f1 100644 (file)
@@ -27,14 +27,14 @@ typedef struct bridge_t bridge_t;
  * Interface in a guest, connected to a tap device on the host.
  */
 struct bridge_t {
-       
+
        /**
         * Get the name of the bridge.
         *
         * @return                      name of the bridge
         */
        char* (*get_name)(bridge_t *this);
-       
+
        /**
         * Add an interface to a bridge.
         *
@@ -42,7 +42,7 @@ struct bridge_t {
         * @return                      TRUE if interface added
         */
        bool (*connect_iface)(bridge_t *this, iface_t *iface);
-       
+
        /**
         * Remove an interface from a bridge.
         *
@@ -50,14 +50,14 @@ struct bridge_t {
         * @return                      TRUE if interface removed
         */
        bool (*disconnect_iface)(bridge_t *this, iface_t *iface);
-       
+
        /**
         * Create an enumerator over all interfaces.
         *
         * @return                      enumerator over iface_t's
         */
-       enumerator_t* (*create_iface_enumerator)(bridge_t *this);       
-       
+       enumerator_t* (*create_iface_enumerator)(bridge_t *this);
+
        /**
         * Destroy a bridge
         */
index 69f008976d2ab66487f8997ee2012dbae80f15dc..0e83b77b165994b6a36696cc1a075a7d4ba95f6d 100644 (file)
@@ -96,7 +96,7 @@ static void rel(const char **path)
 static int get_rd(const char *path)
 {
        private_cowfs_t *this = get_this();
-       
+
        if (this->over_fd > 0 && faccessat(this->over_fd, path, F_OK, 0) == 0)
        {
                return this->over_fd;
@@ -130,7 +130,7 @@ static bool clone_path(int rd, int wr, const char *path)
        struct stat st;
        full = strdupa(path);
        pos = full;
-       
+
        while ((pos = strchr(pos, '/')))
        {
                *pos = '\0';
@@ -162,10 +162,10 @@ static int copy(const char *path)
        int rd, wr;
        int from, to;
        struct stat st;
-       
+
        rd = get_rd(path);
        wr = get_wr(path);
-       
+
        if (rd == wr)
        {
                /* already writeable */
@@ -223,7 +223,7 @@ static int copy(const char *path)
 static int cowfs_getattr(const char *path, struct stat *stbuf)
 {
        rel(&path);
-       
+
        if (fstatat(get_rd(path), path, stbuf, AT_SYMLINK_NOFOLLOW) < 0)
        {
                return -errno;
@@ -237,7 +237,7 @@ static int cowfs_getattr(const char *path, struct stat *stbuf)
 static int cowfs_access(const char *path, int mask)
 {
        rel(&path);
-       
+
        if (faccessat(get_rd(path), path, mask, 0) < 0)
        {
                return -errno;
@@ -251,9 +251,9 @@ static int cowfs_access(const char *path, int mask)
 static int cowfs_readlink(const char *path, char *buf, size_t size)
 {
        int res;
-       
+
        rel(&path);
-       
+
        res = readlinkat(get_rd(path), path, buf, size - 1);
        if (res < 0)
        {
@@ -269,16 +269,16 @@ static int cowfs_readlink(const char *path, char *buf, size_t size)
 static DIR* get_dir(char *dir, const char *subdir)
 {
        char *full;
-       
+
        if (dir == NULL)
        {
                return NULL;
        }
-       
+
        full = alloca(strlen(dir) + strlen(subdir) + 1);
        strcpy(full, dir);
        strcat(full, subdir);
-       
+
        return opendir(full);
 }
 
@@ -290,7 +290,7 @@ static bool contains_dir(DIR *d, char *dirname)
        if (d)
        {
                struct dirent *ent;
-               
+
                rewinddir(d);
                while ((ent = readdir(d)))
                {
@@ -313,13 +313,13 @@ static int cowfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
        DIR *d1, *d2, *d3;
        struct stat st;
        struct dirent *ent;
-       
+
        memset(&st, 0, sizeof(st));
-       
+
        d1 = get_dir(this->master, path);
        d2 = get_dir(this->host, path);
        d3 = get_dir(this->over, path);
-       
+
        if (d1)
        {
                while ((ent = readdir(d1)))
@@ -369,13 +369,13 @@ static int cowfs_mknod(const char *path, mode_t mode, dev_t rdev)
 {
        int fd;
        rel(&path);
-       
+
        fd = get_wr(path);
        if (!clone_path(get_rd(path), fd, path))
        {
                return -errno;
        }
-       
+
        if (mknodat(fd, path, mode, rdev) < 0)
        {
                return -errno;
@@ -390,7 +390,7 @@ static int cowfs_mkdir(const char *path, mode_t mode)
 {
        int fd;
        rel(&path);
-       
+
        fd = get_wr(path);
        if (!clone_path(get_rd(path), fd, path))
        {
@@ -409,7 +409,7 @@ static int cowfs_mkdir(const char *path, mode_t mode)
 static int cowfs_unlink(const char *path)
 {
        rel(&path);
-       
+
        /* TODO: whiteout master */
        if (unlinkat(get_wr(path), path, 0) < 0)
        {
@@ -424,7 +424,7 @@ static int cowfs_unlink(const char *path)
 static int cowfs_rmdir(const char *path)
 {
        rel(&path);
-       
+
        /* TODO: whiteout master */
        if (unlinkat(get_wr(path), path, AT_REMOVEDIR) < 0)
        {
@@ -440,10 +440,10 @@ static int cowfs_symlink(const char *from, const char *to)
 {
        int fd;
        const char *fromrel = from;
-       
+
        rel(&to);
        rel(&fromrel);
-       
+
        fd = get_wr(to);
        if (!clone_path(get_rd(fromrel), fd, fromrel))
        {
@@ -462,10 +462,10 @@ static int cowfs_symlink(const char *from, const char *to)
 static int cowfs_rename(const char *from, const char *to)
 {
        int fd;
-       
+
        rel(&from);
        rel(&to);
-       
+
        fd = copy(from);
        if (fd < 0)
        {
@@ -484,13 +484,13 @@ static int cowfs_rename(const char *from, const char *to)
 static int cowfs_link(const char *from, const char *to)
 {
        int rd, wr;
-       
+
        rel(&from);
        rel(&to);
-       
+
        rd = get_rd(from);
        wr = get_wr(to);
-       
+
        if (!clone_path(rd, wr, to))
        {
                DBG1("cloning path '%s' failed", to);
@@ -511,7 +511,7 @@ static int cowfs_chmod(const char *path, mode_t mode)
 {
        int fd;
        struct stat st;
-       
+
        rel(&path);
        fd = get_rd(path);
        if (fstatat(fd, path, &st, 0) < 0)
@@ -541,7 +541,7 @@ static int cowfs_chown(const char *path, uid_t uid, gid_t gid)
 {
        int fd;
        struct stat st;
-       
+
        rel(&path);
        fd = get_rd(path);
        if (fstatat(fd, path, &st, 0) < 0)
@@ -571,7 +571,7 @@ static int cowfs_truncate(const char *path, off_t size)
 {
        int fd;
        struct stat st;
-       
+
        rel(&path);
        fd = get_rd(path);
        if (fstatat(fd, path, &st, 0) < 0)
@@ -608,19 +608,19 @@ static int cowfs_utimens(const char *path, const struct timespec ts[2])
 {
        struct timeval tv[2];
        int fd;
-       
+
        rel(&path);
        fd = copy(path);
        if (fd < 0)
        {
                return -errno;
        }
-       
+
        tv[0].tv_sec = ts[0].tv_sec;
        tv[0].tv_usec = ts[0].tv_nsec / 1000;
        tv[1].tv_sec = ts[1].tv_sec;
        tv[1].tv_usec = ts[1].tv_nsec / 1000;
-       
+
        if (futimesat(fd, path, tv) < 0)
        {
                return -errno;
@@ -634,10 +634,10 @@ static int cowfs_utimens(const char *path, const struct timespec ts[2])
 static int cowfs_open(const char *path, struct fuse_file_info *fi)
 {
        int fd;
-       
+
        rel(&path);
        fd = get_rd(path);
-       
+
        fd = openat(fd, path, fi->flags);
        if (fd < 0)
        {
@@ -654,17 +654,17 @@ static int cowfs_read(const char *path, char *buf, size_t size, off_t offset,
                                          struct fuse_file_info *fi)
 {
        int file, fd, res;
-       
+
        rel(&path);
-       
+
        fd = get_rd(path);
-       
+
        file = openat(fd, path, O_RDONLY);
        if (file < 0)
        {
                return -errno;
        }
-       
+
        res = pread(file, buf, size, offset);
        if (res < 0)
        {
@@ -681,9 +681,9 @@ static int cowfs_write(const char *path, const char *buf, size_t size,
                                           off_t offset, struct fuse_file_info *fi)
 {
        int file, fd, res;
-       
+
        rel(&path);
-       
+
        fd = copy(path);
        if (fd < 0)
        {
@@ -709,25 +709,25 @@ static int cowfs_write(const char *path, const char *buf, size_t size,
 static int cowfs_statfs(const char *path, struct statvfs *stbuf)
 {
        int fd;
-       
+
        fd = get_rd(path);
        if (fstatvfs(fd, stbuf) < 0)
        {
                return -errno;
        }
-       
+
        return 0;
 }
 
-/** 
+/**
  * FUSE init method
  */
 static void *cowfs_init(struct fuse_conn_info *conn)
 {
        struct fuse_context *ctx;
-       
+
        ctx = fuse_get_context();
-       
+
        return ctx->private_data;
 }
 
@@ -814,10 +814,10 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount)
 {
        struct fuse_args args = {0, NULL, 0};
        private_cowfs_t *this = malloc_thing(private_cowfs_t);
-       
+
        this->public.set_overlay = (bool(*)(cowfs_t*, char *path))set_overlay;
        this->public.destroy = (void(*)(cowfs_t*))destroy;
-       
+
        this->master_fd = open(master, O_RDONLY | O_DIRECTORY);
        if (this->master_fd < 0)
        {
@@ -834,7 +834,7 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount)
                return NULL;
        }
        this->over_fd = -1;
-       
+
        this->chan = fuse_mount(mount, &args);
        if (this->chan == NULL)
        {
@@ -844,7 +844,7 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount)
                free(this);
                return NULL;
        }
-       
+
        this->fuse = fuse_new(this->chan, &args, &cowfs_operations,
                                                  sizeof(cowfs_operations), this);
        if (this->fuse == NULL)
@@ -856,12 +856,12 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount)
                free(this);
                return NULL;
        }
-       
+
        this->mount = strdup(mount);
        this->master = strdup(master);
        this->host = strdup(host);
        this->over = NULL;
-       
+
        if (pthread_create(&this->thread, NULL, (void*)fuse_loop, this->fuse) != 0)
        {
                DBG1("creating thread to handle FUSE failed");
@@ -874,7 +874,7 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount)
                free(this);
                return NULL;
        }
-       
+
        return &this->public;
 }
 
index bb589f158311cf58be283d3512379fd66d6f352c..d430597a81a5ae9230e51400480bc1986b56bfdb 100644 (file)
@@ -25,7 +25,7 @@ typedef struct cowfs_t cowfs_t;
  *
  */
 struct cowfs_t {
-       
+
        /**
         * Set an additional copy on write overlay.
         *
@@ -33,7 +33,7 @@ struct cowfs_t {
         * @return                      FALSE if failed
         */
        bool (*set_overlay)(cowfs_t *this, char *path);
-       
+
        /**
         * Stop, umount and destroy a cowfs FUSE filesystem.
         */
index 2cb1235e1f84d29521fd53c19506d8d2b226e5c4..0e8ab43f3da422cc5ab5f0b351e52d519d888eca 100644 (file)
@@ -52,11 +52,11 @@ struct private_dumm_t {
 /**
  * Implementation of dumm_t.create_guest.
  */
-static guest_t* create_guest(private_dumm_t *this, char *name, char *kernel, 
+static guest_t* create_guest(private_dumm_t *this, char *name, char *kernel,
                                                         char *master, char *args)
 {
        guest_t *guest;
-       
+
        guest = guest_create(this->guest_dir, name, kernel, master, args);
        if (guest)
        {
@@ -82,7 +82,7 @@ static void delete_guest(private_dumm_t *this, guest_t *guest)
        {
                char buf[512];
                int len;
-               
+
                len = snprintf(buf, sizeof(buf), "rm -Rf %s/%s",
                                           this->guest_dir, guest->get_name(guest));
                guest->destroy(guest);
@@ -99,7 +99,7 @@ static void delete_guest(private_dumm_t *this, guest_t *guest)
 static bridge_t* create_bridge(private_dumm_t *this, char *name)
 {
        bridge_t *bridge;
-       
+
        bridge = bridge_create(name);
        if (bridge)
        {
@@ -128,16 +128,16 @@ static void delete_bridge(private_dumm_t *this, bridge_t *bridge)
 }
 
 /**
- * disable the currently enabled template 
+ * disable the currently enabled template
  */
 static void clear_template(private_dumm_t *this)
 {
        enumerator_t *enumerator;
        guest_t *guest;
-       
+
        free(this->template);
        this->template = NULL;
-       
+
        enumerator = this->guests->create_enumerator(this->guests);
        while (enumerator->enumerate(enumerator, (void**)&guest))
        {
@@ -153,9 +153,9 @@ static bool load_template(private_dumm_t *this, char *dir)
 {
        enumerator_t *enumerator;
        guest_t *guest;
-       
+
        clear_template(this);
-       
+
        if (dir == NULL)
        {
                return TRUE;
@@ -165,7 +165,7 @@ static bool load_template(private_dumm_t *this, char *dir)
                DBG1("template directory string '%s' is too long", dir);
                return FALSE;
        }
-       
+
        if (asprintf(&this->template, "%s/%s", TEMPLATE_DIR, dir) < 0)
        {
                this->template = NULL;
@@ -210,7 +210,7 @@ static bool template_enumerate(template_enumerator_t *this, char **template)
 {
        struct stat st;
        char *rel;
-       
+
        while (this->inner->enumerate(this->inner, &rel, NULL, &st))
        {
                if (S_ISDIR(st.st_mode) && *rel != '.')
@@ -237,12 +237,12 @@ static void template_enumerator_destroy(template_enumerator_t *this)
 static enumerator_t* create_template_enumerator(private_dumm_t *this)
 {
        template_enumerator_t *enumerator;
-       
+
        enumerator = malloc_thing(template_enumerator_t);
        enumerator->public.enumerate = (void*)template_enumerate;
        enumerator->public.destroy = (void*)template_enumerator_destroy;
        enumerator->inner = enumerator_create_directory(TEMPLATE_DIR);
-       
+
        return &enumerator->public;
 }
 
@@ -253,16 +253,16 @@ static void destroy(private_dumm_t *this)
 {
        enumerator_t *enumerator;
        guest_t *guest;
-       
+
        this->bridges->destroy_offset(this->bridges, offsetof(bridge_t, destroy));
-       
+
        enumerator = this->guests->create_enumerator(this->guests);
        while (enumerator->enumerate(enumerator, (void**)&guest))
        {
                guest->stop(guest, NULL);
        }
        enumerator->destroy(enumerator);
-       
+
        while (this->guests->remove_last(this->guests, (void**)&guest) == SUCCESS)
        {
                guest->destroy(guest);
@@ -282,13 +282,13 @@ static void load_guests(private_dumm_t *this)
        DIR *dir;
        struct dirent *ent;
        guest_t *guest;
-       
+
        dir = opendir(this->guest_dir);
        if (dir == NULL)
        {
                return;
        }
-       
+
        while ((ent = readdir(dir)))
        {
                if (*ent->d_name == '.')
@@ -315,7 +315,7 @@ dumm_t *dumm_create(char *dir)
 {
        char cwd[PATH_MAX];
        private_dumm_t *this = malloc_thing(private_dumm_t);
-       
+
        this->public.create_guest = (guest_t*(*)(dumm_t*,char*,char*,char*,char*))create_guest;
        this->public.create_guest_enumerator = (enumerator_t*(*)(dumm_t*))create_guest_enumerator;
        this->public.delete_guest = (void(*)(dumm_t*,guest_t*))delete_guest;
@@ -325,7 +325,7 @@ dumm_t *dumm_create(char *dir)
        this->public.load_template = (bool(*)(dumm_t*, char *name))load_template;
        this->public.create_template_enumerator = (enumerator_t*(*)(dumm_t*))create_template_enumerator;
        this->public.destroy = (void(*)(dumm_t*))destroy;
-       
+
        if (dir && *dir == '/')
        {
                this->dir = strdup(dir);
@@ -356,7 +356,7 @@ dumm_t *dumm_create(char *dir)
        }
        this->guests = linked_list_create();
        this->bridges = linked_list_create();
-       
+
        if (this->dir == NULL || this->guest_dir == NULL ||
                (mkdir(this->guest_dir, PERME) < 0 && errno != EEXIST))
        {
@@ -364,7 +364,7 @@ dumm_t *dumm_create(char *dir)
                destroy(this);
                return NULL;
        }
-       
+
        load_guests(this);
        return &this->public;
 }
index 5f2e0542af96155ef660498a1e4dd8e8f88042b2..54c3fbc03869192018019a3b184d8cc6f462d9bc 100644 (file)
@@ -43,23 +43,23 @@ struct dumm_t {
         * @param args          additional args to pass to kernel
         * @return                      guest if started, NULL if failed
         */
-       guest_t* (*create_guest) (dumm_t *this, char *name, char *kernel, 
+       guest_t* (*create_guest) (dumm_t *this, char *name, char *kernel,
                                                          char *master, char *args);
-       
+
        /**
         * Create an enumerator over all guests.
         *
         * @return                      enumerator over guest_t's
         */
        enumerator_t* (*create_guest_enumerator) (dumm_t *this);
-       
+
        /**
         * Delete a guest from disk.
         *
         * @param guest         guest to destroy
         */
        void (*delete_guest) (dumm_t *this, guest_t *guest);
-       
+
        /**
         * Create a new bridge.
         *
@@ -67,21 +67,21 @@ struct dumm_t {
         * @return                      created bridge
         */
        bridge_t* (*create_bridge)(dumm_t *this, char *name);
-       
+
        /**
         * Create an enumerator over all bridges.
         *
         * @return                      enumerator over bridge_t's
         */
        enumerator_t* (*create_bridge_enumerator)(dumm_t *this);
-       
+
        /**
         * Delete a bridge.
         *
         * @param bridge        bridge to destroy
         */
        void (*delete_bridge) (dumm_t *this, bridge_t *bridge);
-       
+
        /**
         * Loads a template, create a new one if it does not exist.
         *
@@ -89,14 +89,14 @@ struct dumm_t {
         * @return                      FALSE if load/create failed
         */
        bool (*load_template)(dumm_t *this, char *dir);
-       
+
        /**
         * Create an enumerator over all available templates.
         *
         * @return                      enumerator over char*
         */
        enumerator_t* (*create_template_enumerator)(dumm_t *this);
-       
+
        /**
         * stop all guests and destroy the modeler
         */
index f7caf252d557136b2f8fa7fe860fd3c009f3f563..ed667ccc0206303c47738c03431a1a9a949953ca 100644 (file)
@@ -45,7 +45,7 @@ static VALUE rbc_template;
 static pid_t invoke(void *null, guest_t *guest, char *args[], int argc)
 {
        pid_t pid;
-       
+
        pid = fork();
        switch (pid)
        {
@@ -71,7 +71,7 @@ static void sigchld_handler(int signal, siginfo_t *info, void* ptr)
 {
        enumerator_t *enumerator;
        guest_t *guest;
-       
+
        enumerator = dumm->create_guest_enumerator(dumm);
        while (enumerator->enumerate(enumerator, &guest))
        {
@@ -91,7 +91,7 @@ static VALUE guest_find(VALUE class, VALUE key)
 {
        enumerator_t *enumerator;
        guest_t *guest, *found = NULL;
-       
+
        if (TYPE(key) == T_SYMBOL)
        {
                key = rb_convert_type(key, T_STRING, "String", "to_s");
@@ -128,7 +128,7 @@ static VALUE guest_each(int argc, VALUE *argv, VALUE class)
        linked_list_t *list;
        enumerator_t *enumerator;
        guest_t *guest;
-       
+
        if (!rb_block_given_p())
        {
                rb_raise(rb_eArgError, "must be called with a block");
@@ -152,7 +152,7 @@ static VALUE guest_new(VALUE class, VALUE name, VALUE kernel,
                                           VALUE master, VALUE args)
 {
        guest_t *guest;
-       
+
        guest = dumm->create_guest(dumm, StringValuePtr(name), StringValuePtr(kernel),
                                                           StringValuePtr(master), StringValuePtr(args));
        if (!guest)
@@ -165,7 +165,7 @@ static VALUE guest_new(VALUE class, VALUE name, VALUE kernel,
 static VALUE guest_to_s(VALUE self)
 {
        guest_t *guest;
-       
+
        Data_Get_Struct(self, guest_t, guest);
        return rb_str_new2(guest->get_name(guest));
 }
@@ -173,9 +173,9 @@ static VALUE guest_to_s(VALUE self)
 static VALUE guest_start(VALUE self)
 {
        guest_t *guest;
-       
+
        Data_Get_Struct(self, guest_t, guest);
-       
+
        if (!guest->start(guest, invoke, NULL, NULL))
        {
                rb_raise(rb_eRuntimeError, "starting guest failed");
@@ -186,7 +186,7 @@ static VALUE guest_start(VALUE self)
 static VALUE guest_stop(VALUE self)
 {
        guest_t *guest;
-       
+
        Data_Get_Struct(self, guest_t, guest);
        guest->stop(guest, NULL);
        return self;
@@ -195,7 +195,7 @@ static VALUE guest_stop(VALUE self)
 static VALUE guest_running(VALUE self)
 {
        guest_t *guest;
-       
+
        Data_Get_Struct(self, guest_t, guest);
        return guest->get_pid(guest) ? Qtrue : Qfalse;
 }
@@ -210,7 +210,7 @@ static VALUE guest_exec(VALUE self, VALUE cmd)
        guest_t *guest;
        bool block;
        int ret;
-       
+
        block = rb_block_given_p();
        Data_Get_Struct(self, guest_t, guest);
        if ((ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
@@ -226,7 +226,7 @@ static VALUE guest_mconsole(VALUE self, VALUE cmd)
        guest_t *guest;
        bool block;
        int ret;
-       
+
        block = rb_block_given_p();
        Data_Get_Struct(self, guest_t, guest);
        if ((ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL,
@@ -241,7 +241,7 @@ static VALUE guest_add_iface(VALUE self, VALUE name)
 {
        guest_t *guest;
        iface_t *iface;
-       
+
        Data_Get_Struct(self, guest_t, guest);
        iface = guest->create_iface(guest, StringValuePtr(name));
        if (!iface)
@@ -256,7 +256,7 @@ static VALUE guest_find_iface(VALUE self, VALUE key)
        enumerator_t *enumerator;
        iface_t *iface, *found = NULL;
        guest_t *guest;
-       
+
        if (TYPE(key) == T_SYMBOL)
        {
                key = rb_convert_type(key, T_STRING, "String", "to_s");
@@ -295,7 +295,7 @@ static VALUE guest_each_iface(int argc, VALUE *argv, VALUE self)
        linked_list_t *list;
        guest_t *guest;
        iface_t *iface;
-       
+
        if (!rb_block_given_p())
        {
                rb_raise(rb_eArgError, "must be called with a block");
@@ -319,7 +319,7 @@ static VALUE guest_each_iface(int argc, VALUE *argv, VALUE self)
 static VALUE guest_delete(VALUE self)
 {
        guest_t *guest;
-       
+
        Data_Get_Struct(self, guest_t, guest);
        if (guest->get_pid(guest))
        {
@@ -334,13 +334,13 @@ static void guest_init()
        rbc_guest = rb_define_class_under(rbm_dumm , "Guest", rb_cObject);
        rb_include_module(rb_class_of(rbc_guest), rb_mEnumerable);
        rb_include_module(rbc_guest, rb_mEnumerable);
-       
+
        rb_define_singleton_method(rbc_guest, "[]", guest_get, 1);
        rb_define_singleton_method(rbc_guest, "each", guest_each, -1);
        rb_define_singleton_method(rbc_guest, "new", guest_new, 4);
        rb_define_singleton_method(rbc_guest, "include?", guest_find, 1);
        rb_define_singleton_method(rbc_guest, "guest?", guest_find, 1);
-       
+
        rb_define_method(rbc_guest, "to_s", guest_to_s, 0);
        rb_define_method(rbc_guest, "start", guest_start, 0);
        rb_define_method(rbc_guest, "stop", guest_stop, 0);
@@ -362,7 +362,7 @@ static VALUE bridge_find(VALUE class, VALUE key)
 {
        enumerator_t *enumerator;
        bridge_t *bridge, *found = NULL;
-       
+
        if (TYPE(key) == T_SYMBOL)
        {
                key = rb_convert_type(key, T_STRING, "String", "to_s");
@@ -399,7 +399,7 @@ static VALUE bridge_each(int argc, VALUE *argv, VALUE class)
        enumerator_t *enumerator;
        linked_list_t *list;
        bridge_t *bridge;
-       
+
        if (!rb_block_given_p())
        {
                rb_raise(rb_eArgError, "must be called with a block");
@@ -423,7 +423,7 @@ static VALUE bridge_new(VALUE class, VALUE name)
 
 {
        bridge_t *bridge;
-       
+
        bridge = dumm->create_bridge(dumm, StringValuePtr(name));
        if (!bridge)
        {
@@ -435,7 +435,7 @@ static VALUE bridge_new(VALUE class, VALUE name)
 static VALUE bridge_to_s(VALUE self)
 {
        bridge_t *bridge;
-       
+
        Data_Get_Struct(self, bridge_t, bridge);
        return rb_str_new2(bridge->get_name(bridge));
 }
@@ -446,7 +446,7 @@ static VALUE bridge_each_iface(int argc, VALUE *argv, VALUE self)
        linked_list_t *list;
        bridge_t *bridge;
        iface_t *iface;
-       
+
        if (!rb_block_given_p())
        {
                rb_raise(rb_eArgError, "must be called with a block");
@@ -470,7 +470,7 @@ static VALUE bridge_each_iface(int argc, VALUE *argv, VALUE self)
 static VALUE bridge_delete(VALUE self)
 {
        bridge_t *bridge;
-       
+
        Data_Get_Struct(self, bridge_t, bridge);
        dumm->delete_bridge(dumm, bridge);
        return Qnil;
@@ -481,13 +481,13 @@ static void bridge_init()
        rbc_bridge = rb_define_class_under(rbm_dumm , "Bridge", rb_cObject);
        rb_include_module(rb_class_of(rbc_bridge), rb_mEnumerable);
        rb_include_module(rbc_bridge, rb_mEnumerable);
-       
+
        rb_define_singleton_method(rbc_bridge, "[]", bridge_get, 1);
        rb_define_singleton_method(rbc_bridge, "each", bridge_each, -1);
        rb_define_singleton_method(rbc_bridge, "new", bridge_new, 1);
        rb_define_singleton_method(rbc_bridge, "include?", bridge_find, 1);
        rb_define_singleton_method(rbc_bridge, "bridge?", bridge_find, 1);
-       
+
        rb_define_method(rbc_bridge, "to_s", bridge_to_s, 0);
        rb_define_method(rbc_bridge, "each", bridge_each_iface, -1);
        rb_define_method(rbc_bridge, "delete", bridge_delete, 0);
@@ -499,7 +499,7 @@ static void bridge_init()
 static VALUE iface_to_s(VALUE self)
 {
        iface_t *iface;
-       
+
        Data_Get_Struct(self, iface_t, iface);
        return rb_str_new2(iface->get_hostif(iface));
 }
@@ -508,7 +508,7 @@ static VALUE iface_connect(VALUE self, VALUE vbridge)
 {
        iface_t *iface;
        bridge_t *bridge;
-       
+
        Data_Get_Struct(self, iface_t, iface);
        Data_Get_Struct(vbridge, bridge_t, bridge);
        if (!bridge->connect_iface(bridge, iface))
@@ -522,7 +522,7 @@ static VALUE iface_disconnect(VALUE self)
 {
        iface_t *iface;
        bridge_t *bridge;
-       
+
        Data_Get_Struct(self, iface_t, iface);
        bridge = iface->get_bridge(iface);
        if (!bridge || !bridge->disconnect_iface(bridge, iface))
@@ -536,7 +536,7 @@ static VALUE iface_add_addr(VALUE self, VALUE name)
 {
        iface_t *iface;
        host_t *addr;
-       
+
        addr = host_create_from_string(StringValuePtr(name), 0);
        if (!addr)
        {
@@ -563,7 +563,7 @@ static VALUE iface_each_addr(int argc, VALUE *argv, VALUE self)
        iface_t *iface;
        host_t *addr;
        char buf[64];
-       
+
        if (!rb_block_given_p())
        {
                rb_raise(rb_eArgError, "must be called with a block");
@@ -589,7 +589,7 @@ static VALUE iface_del_addr(VALUE self, VALUE vaddr)
 {
        iface_t *iface;
        host_t *addr;
-       
+
        addr = host_create_from_string(StringValuePtr(vaddr), 0);
        if (!addr)
        {
@@ -613,7 +613,7 @@ static VALUE iface_delete(VALUE self)
 {
        guest_t *guest;
        iface_t *iface;
-       
+
        Data_Get_Struct(self, iface_t, iface);
        guest = iface->get_guest(iface);
        guest->destroy_iface(guest, iface);
@@ -624,7 +624,7 @@ static void iface_init()
 {
        rbc_iface = rb_define_class_under(rbm_dumm , "Iface", rb_cObject);
        rb_include_module(rbc_iface, rb_mEnumerable);
-       
+
        rb_define_method(rbc_iface, "to_s", iface_to_s, 0);
        rb_define_method(rbc_iface, "connect", iface_connect, 1);
        rb_define_method(rbc_iface, "disconnect", iface_disconnect, 0);
@@ -656,7 +656,7 @@ static VALUE template_each(int argc, VALUE *argv, VALUE class)
 {
        enumerator_t *enumerator;
        char *template;
-       
+
        if (!rb_block_given_p())
        {
                rb_raise(rb_eArgError, "must be called with a block");
@@ -673,7 +673,7 @@ static VALUE template_each(int argc, VALUE *argv, VALUE class)
 static void template_init()
 {
        rbc_template = rb_define_class_under(rbm_dumm , "Template", rb_cObject);
-       
+
        rb_define_singleton_method(rbc_template, "load", template_load, 1);
        rb_define_singleton_method(rbc_template, "unload", template_unload, 0);
        rb_define_singleton_method(rbc_template, "each", template_each, -1);
@@ -685,14 +685,14 @@ static void template_init()
 void Final_dumm()
 {
        struct sigaction action;
-       
+
        dumm->destroy(dumm);
-       
+
        sigemptyset(&action.sa_mask);
        action.sa_handler = SIG_DFL;
        action.sa_flags = 0;
        sigaction(SIGCHLD, &action, NULL);
-       
+
        library_deinit();
 }
 
@@ -702,25 +702,25 @@ void Final_dumm()
 void Init_dumm()
 {
        struct sigaction action;
-       
+
        /* there are too many to report, rubyruby... */
        setenv("LEAK_DETECTIVE_DISABLE", "1", 1);
-       
+
        library_init(NULL);
-       
+
        dumm = dumm_create(NULL);
-       
+
        rbm_dumm = rb_define_module("Dumm");
-       
+
        guest_init();
        bridge_init();
        iface_init();
        template_init();
-       
+
        sigemptyset(&action.sa_mask);
        action.sa_sigaction = sigchld_handler;
        action.sa_flags = SA_SIGINFO;
        sigaction(SIGCHLD, &action, NULL);
-       
+
        rb_set_end_proc(Final_dumm, 0);
 }
index 969a2a99d3decdbfc7c19b6eb75866f2c4abfb26..112adb4414a8d3a7febf1675a14453fae8b0f8dd 100644 (file)
@@ -97,13 +97,13 @@ static iface_t* create_iface(private_guest_t *this, char *name)
 {
        enumerator_t *enumerator;
        iface_t *iface;
-       
+
        if (this->state != GUEST_RUNNING)
        {
                DBG1("guest '%s' not running, unable to add interface", this->name);
                return NULL;
        }
-       
+
        enumerator = this->ifaces->create_enumerator(this->ifaces);
        while (enumerator->enumerate(enumerator, (void**)&iface))
        {
@@ -131,7 +131,7 @@ static void destroy_iface(private_guest_t *this, iface_t *iface)
 {
        enumerator_t *enumerator;
        iface_t *current;
-       
+
        enumerator = this->ifaces->create_enumerator(this->ifaces);
        while (enumerator->enumerate(enumerator, (void**)&current))
        {
@@ -152,7 +152,7 @@ static enumerator_t* create_iface_enumerator(private_guest_t *this)
 {
        return this->ifaces->create_enumerator(this->ifaces);
 }
-       
+
 /**
  * Implementation of guest_t.get_state.
  */
@@ -224,7 +224,7 @@ static void stop(private_guest_t *this, idle_function_t idle)
 void savepid(private_guest_t *this)
 {
        FILE *file;
-       
+
        file = fdopen(openat(this->dir, PID_FILE, O_RDWR | O_CREAT | O_TRUNC,
                                                 PERM), "w");
        if (file)
@@ -246,18 +246,18 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data,
        char *args[32];
        int i = 0;
        size_t left = sizeof(buf);
-       
+
        memset(args, 0, sizeof(args));
-       
+
        if (this->state != GUEST_STOPPED)
        {
                DBG1("unable to start guest in state %N", guest_state_names, this->state);
                return FALSE;
        }
        this->state = GUEST_STARTING;
-       
+
        notify = write_arg(&pos, &left, "%s/%s", this->dirname, NOTIFY_FILE);
-       
+
        args[i++] = write_arg(&pos, &left, "nice");
        args[i++] = write_arg(&pos, &left, "%s/%s", this->dirname, KERNEL_FILE);
        args[i++] = write_arg(&pos, &left, "root=/dev/root");
@@ -271,7 +271,7 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data,
        {
                args[i++] = this->args;
        }
-         
+
        this->pid = invoke(data, &this->public, args, i);
        if (!this->pid)
        {
@@ -279,7 +279,7 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data,
                return FALSE;
        }
        savepid(this);
-       
+
        /* open mconsole */
        this->mconsole = mconsole_create(notify, idle);
        if (this->mconsole == NULL)
@@ -288,11 +288,11 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data,
                stop(this, NULL);
                return FALSE;
        }
-       
+
        this->state = GUEST_RUNNING;
        return TRUE;
-}      
-       
+}
+
 /**
  * Implementation of guest_t.load_template.
  */
@@ -300,12 +300,12 @@ static bool load_template(private_guest_t *this, char *path)
 {
        char dir[PATH_MAX];
        size_t len;
-       
+
        if (path == NULL)
        {
-               return this->cowfs->set_overlay(this->cowfs, NULL);     
+               return this->cowfs->set_overlay(this->cowfs, NULL);
        }
-       
+
        len = snprintf(dir, sizeof(dir), "%s/%s", path, this->name);
        if (len < 0 || len >= sizeof(dir))
        {
@@ -334,11 +334,11 @@ static int vexec(private_guest_t *this, void(*cb)(void*,char*,size_t), void *dat
 {
        char buf[1024];
        size_t len;
-       
+
        if (this->mconsole)
        {
                len = vsnprintf(buf, sizeof(buf), cmd, args);
-               
+
                if (len > 0 && len < sizeof(buf))
                {
                        return this->mconsole->exec(this->mconsole, cb, data, buf);
@@ -389,7 +389,7 @@ static void exec_str_cb(exec_str_t *data, char *buf, size_t len)
                }
                strncat(data->buf.ptr, buf, len);
        }
-       
+
        if (data->cb)
        {
                char *nl;
@@ -477,7 +477,7 @@ static bool mount_unionfs(private_guest_t *this)
                snprintf(master, sizeof(master), "%s/%s", this->dirname, MASTER_DIR);
                snprintf(diff, sizeof(diff), "%s/%s", this->dirname, DIFF_DIR);
                snprintf(mount, sizeof(mount), "%s/%s", this->dirname, UNION_DIR);
-               
+
                this->cowfs = cowfs_create(master, diff, mount);
                if (this->cowfs)
                {
@@ -494,7 +494,7 @@ char *loadargs(private_guest_t *this)
 {
        FILE *file;
        char buf[512], *args = NULL;
-       
+
        file = fdopen(openat(this->dir, ARGS_FILE, O_RDONLY, PERM), "r");
        if (file)
        {
@@ -514,7 +514,7 @@ bool saveargs(private_guest_t *this, char *args)
 {
        FILE *file;
        bool retval = FALSE;
-       
+
        file = fdopen(openat(this->dir, ARGS_FILE, O_RDWR | O_CREAT | O_TRUNC,
                                                 PERM), "w");
        if (file)
@@ -554,7 +554,7 @@ static private_guest_t *guest_create_generic(char *parent, char *name,
 {
        char cwd[PATH_MAX];
        private_guest_t *this = malloc_thing(private_guest_t);
-       
+
        this->public.get_name = (void*)get_name;
        this->public.get_pid = (pid_t(*)(guest_t*))get_pid;
        this->public.get_state = (guest_state_t(*)(guest_t*))get_state;
@@ -568,7 +568,7 @@ static private_guest_t *guest_create_generic(char *parent, char *name,
        this->public.exec_str = (int(*)(guest_t*, void(*cb)(void*,char*),bool,void*,char*,...))exec_str;
        this->public.sigchild = (void(*)(guest_t*))sigchild;
        this->public.destroy = (void*)destroy;
-               
+
        if (*parent == '/' || getcwd(cwd, sizeof(cwd)) == NULL)
        {
                if (asprintf(&this->dirname, "%s/%s", parent, name) < 0)
@@ -607,7 +607,7 @@ static private_guest_t *guest_create_generic(char *parent, char *name,
        this->args = NULL;
        this->name = strdup(name);
        this->cowfs = NULL;
-       
+
        return this;
 }
 
@@ -618,7 +618,7 @@ static bool make_symlink(private_guest_t *this, char *old, char *new)
 {
        char cwd[PATH_MAX];
        char buf[PATH_MAX];
-       
+
        if (*old == '/' || getcwd(cwd, sizeof(cwd)) == NULL)
        {
                snprintf(buf, sizeof(buf), "%s", old);
@@ -632,18 +632,18 @@ static bool make_symlink(private_guest_t *this, char *old, char *new)
 
 
 /**
- * create the guest instance, including required dirs and mounts 
+ * create the guest instance, including required dirs and mounts
  */
 guest_t *guest_create(char *parent, char *name, char *kernel,
                                          char *master, char *args)
 {
        private_guest_t *this = guest_create_generic(parent, name, TRUE);
-       
+
        if (this == NULL)
        {
                return NULL;
        }
-       
+
        if (!make_symlink(this, master, MASTER_DIR) ||
                !make_symlink(this, kernel, KERNEL_FILE))
        {
@@ -651,22 +651,22 @@ guest_t *guest_create(char *parent, char *name, char *kernel,
                destroy(this);
                return NULL;
        }
-       
-       if (mkdirat(this->dir, UNION_DIR, PERME) != 0 || 
+
+       if (mkdirat(this->dir, UNION_DIR, PERME) != 0 ||
                mkdirat(this->dir, DIFF_DIR, PERME) != 0)
        {
                DBG1("unable to create directories for '%s': %m", name);
                destroy(this);
                return NULL;
        }
-       
+
        this->args = args;
        if (args && !saveargs(this, args))
        {
                destroy(this);
                return NULL;
        }
-       
+
        if (!mount_unionfs(this))
        {
                destroy(this);
@@ -682,20 +682,20 @@ guest_t *guest_create(char *parent, char *name, char *kernel,
 guest_t *guest_load(char *parent, char *name)
 {
        private_guest_t *this = guest_create_generic(parent, name, FALSE);
-       
+
        if (this == NULL)
        {
                return NULL;
        }
-       
+
        this->args = loadargs(this);
-       
+
        if (!mount_unionfs(this))
        {
                destroy(this);
                return NULL;
        }
-       
+
        return &this->public;
 }
 
index a1e4966ac47c34f76bfce3852b6f1476ad6c292e..5f812f8ebe3f7e2aae197f9d8c87948ec409e2be 100644 (file)
@@ -56,10 +56,10 @@ extern enum_name_t *guest_state_names;
  * @param guest                guest to start
  * @param args         args to use for guest invocation, args[0] is kernel
  * @param argc         number of elements in args
- * @param idle         
+ * @param idle
  * @return                     PID of child, 0 if failed
  */
-typedef pid_t (*invoke_function_t)(void *data, guest_t *guest, 
+typedef pid_t (*invoke_function_t)(void *data, guest_t *guest,
                                                                   char *args[], int argc);
 
 /**
@@ -71,28 +71,28 @@ typedef void (*idle_function_t)(void);
  * A guest is a UML instance running on the host.
  **/
 struct guest_t {
-       
+
        /**
         * Get the name of this guest.
         *
         * @return              name of the guest
         */
        char* (*get_name) (guest_t *this);
-       
+
        /**
         * Get the process ID of the guest child process.
         *
         * @return              name of the guest
         */
        pid_t (*get_pid) (guest_t *this);
-       
+
        /**
         * Get the state of the guest (stopped, started, etc.).
         *
         * @return              guests state
         */
-       guest_state_t (*get_state)(guest_t *this);      
-       
+       guest_state_t (*get_state)(guest_t *this);
+
        /**
         * Start the guest.
         *
@@ -103,14 +103,14 @@ struct guest_t {
         */
        bool (*start) (guest_t *this, invoke_function_t invoke, void *data,
                                   idle_function_t idle);
-       
+
        /**
         * Kill the guest.
         *
         * @param idle          idle function to call while waiting to termination
         */
        void (*stop) (guest_t *this, idle_function_t idle);
-       
+
        /**
         * Create a new interface in the current scenario.
         *
@@ -118,21 +118,21 @@ struct guest_t {
         * @return              created interface, or NULL if failed
         */
        iface_t* (*create_iface)(guest_t *this, char *name);
-       
+
        /**
         * Destroy an interface on guest.
         *
         * @param iface interface to destroy
         */
        void (*destroy_iface)(guest_t *this, iface_t *iface);
-       
+
        /**
         * Create an enumerator over all guest interfaces.
         *
         * @return              enumerator over iface_t's
         */
        enumerator_t* (*create_iface_enumerator)(guest_t *this);
-       
+
        /**
         * Set the template COWFS overlay to use.
         *
@@ -140,7 +140,7 @@ struct guest_t {
         * @return                      FALSE if failed
         */
        bool (*load_template)(guest_t *this, char *parent);
-       
+
        /**
         * Execute a command on the guests mconsole.
         *
@@ -152,15 +152,15 @@ struct guest_t {
         */
        int (*exec)(guest_t *this, void(*cb)(void*,char*,size_t), void *data,
                                char *cmd, ...);
-       
+
        /**
         * Execute a command on the guests mconsole, with output formatter.
-        * 
+        *
         * If lines is TRUE, callback is invoked for each output line. Otherwise
         * the full result is returned in one callback invocation.
-        * 
+        *
         * @note This function does not work with binary output.
-        * 
+        *
         * @param cb            callback to call for each line or for the complete output
         * @param lines         TRUE if the callback should be called for each line
         * @param data          data to pass to callback
@@ -170,15 +170,15 @@ struct guest_t {
         */
        int (*exec_str)(guest_t *this, void(*cb)(void*,char*), bool lines,
                                        void *data, char *cmd, ...);
-       
+
        /**
         * Called whenever a SIGCHILD for the guests PID is received.
         */
        void (*sigchild)(guest_t *this);
-       
+
        /**
         * Close and destroy a guest with all interfaces
-        */     
+        */
        void (*destroy) (guest_t *this);
 };
 
index bf73c82a51c6af8e70f059ef4c4cd99699a7976f..ed895af37fb2865e72707ca65f80a7626096e035 100644 (file)
@@ -55,10 +55,10 @@ bool iface_control(char *name, bool up)
        int s;
        bool good = FALSE;
        struct ifreq ifr;
-       
+
        memset(&ifr, 0, sizeof(struct ifreq));
        strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
-       
+
        s = socket(AF_INET, SOCK_DGRAM, 0);
        if (!s)
        {
@@ -104,7 +104,7 @@ static char* get_hostif(private_iface_t *this)
  */
 static bool add_address(private_iface_t *this, host_t *addr)
 {
-       return (this->guest->exec(this->guest, NULL, NULL, 
+       return (this->guest->exec(this->guest, NULL, NULL,
                                  "exec ip addr add %H dev %s", addr, this->guestif) == 0);
 }
 
@@ -185,7 +185,7 @@ static guest_t* get_guest(private_iface_t *this)
 {
        return this->guest;
 }
-       
+
 /**
  * destroy the tap device
  */
@@ -193,7 +193,7 @@ static bool destroy_tap(private_iface_t *this)
 {
        struct ifreq ifr;
        int tap;
-       
+
        if (!iface_control(this->hostif, FALSE))
        {
                DBG1("bringing iface down failed: %m");
@@ -201,7 +201,7 @@ static bool destroy_tap(private_iface_t *this)
        memset(&ifr, 0, sizeof(ifr));
        ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
        strncpy(ifr.ifr_name, this->hostif, sizeof(ifr.ifr_name) - 1);
-       
+
        tap = open(TAP_DEVICE, O_RDWR);
        if (tap < 0)
        {
@@ -245,7 +245,7 @@ static char* create_tap(private_iface_t *this)
                DBG1("creating new tap device failed: %m");
                close(tap);
                return NULL;
-    } 
+    }
        close(tap);
        return strdup(ifr.ifr_name);
 }
@@ -274,7 +274,7 @@ static void destroy(private_iface_t *this)
 iface_t *iface_create(char *name, guest_t *guest, mconsole_t *mconsole)
 {
        private_iface_t *this = malloc_thing(private_iface_t);
-       
+
        this->public.get_hostif = (char*(*)(iface_t*))get_hostif;
        this->public.get_guestif = (char*(*)(iface_t*))get_guestif;
        this->public.add_address = (bool(*)(iface_t*, host_t *addr))add_address;
index 7aef95c01ef9c5f1721d5b0891d5e44b794df60f..dabefaa17f5ae0fdaabb27d99507433222b6219f 100644 (file)
@@ -32,21 +32,21 @@ typedef struct iface_t iface_t;
  * Interface in a guest, connected to a tap device on the host.
  */
 struct iface_t {
-       
+
        /**
         * Get the interface name in the guest (e.g. eth0).
         *
         * @return                      guest interface name
         */
        char* (*get_guestif)(iface_t *this);
-       
+
        /**
         * Get the interface name at the host (e.g. tap0).
         *
         * @return                      host interface (tap device) name
         */
        char* (*get_hostif)(iface_t *this);
-       
+
        /**
         * Add an address to the interface.
         *
@@ -54,43 +54,43 @@ struct iface_t {
         * @return                      TRUE if address added
         */
        bool (*add_address)(iface_t *this, host_t *addr);
-       
+
        /**
         * Create an enumerator over all installed addresses.
         *
         * @return                      enumerator over host_t*
         */
        enumerator_t* (*create_address_enumerator)(iface_t *this);
-       
+
        /**
         * Remove an address from an interface.
         *
         * @param addr          address to remove
         * @return                      TRUE if address removed
         */
-       bool (*delete_address)(iface_t *this, host_t *addr);    
-       
+       bool (*delete_address)(iface_t *this, host_t *addr);
+
        /**
         * Set the bridge this interface is attached to.
         *
         * @param bridge        assigned bridge, or NULL for none
         */
        void (*set_bridge)(iface_t *this, bridge_t *bridge);
-       
+
        /**
         * Get the bridge this iface is connected, or NULL.
         *
         * @return                      connected bridge, or NULL
         */
        bridge_t* (*get_bridge)(iface_t *this);
-       
+
        /**
         * Get the guest this iface belongs to.
         *
         * @return                      guest of this iface
         */
        guest_t* (*get_guest)(iface_t *this);
-       
+
        /**
         * Destroy an interface
         */
index bca8ce1dbb54bb50386531a430b064342180488b..cf7f3423a3712a7e0c7f5d9243ea3393cf6aa0c7 100644 (file)
@@ -26,10 +26,10 @@ int main(int argc, char *argv[])
 {
        int state, i;
        char buf[512];
-       
+
        ruby_init();
        ruby_init_loadpath();
-       
+
        rb_eval_string_protect("require 'dumm' and include Dumm", &state);
        if (state)
        {
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
        {
                rb_p(ruby_errinfo);
        }
-       
+
        ruby_finalize();
        return 0;
 }
index ba2801760b64eb401f7d7b7cbe6ee0f958a36a5e..b91c76e7a20bd13918bfa1f885daff172ac4311f 100644 (file)
@@ -62,7 +62,7 @@ static void child_exited(VteReaper *vtereaper, gint pid, gint status)
 {
        enumerator_t *enumerator;
        page_t *page;
-       
+
        enumerator = pages->create_enumerator(pages);
        while (enumerator->enumerate(enumerator, (void**)&page))
        {
@@ -81,7 +81,7 @@ static page_t* get_page(int num)
 {
        enumerator_t *enumerator;
        page_t *page, *found = NULL;
-       
+
        enumerator = pages->create_enumerator(pages);
        while (enumerator->enumerate(enumerator, (void**)&page))
        {
@@ -114,7 +114,7 @@ void idle(void)
 static void start_guest()
 {
        page_t *page;
-       
+
        page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
        if (page && page->guest->get_state(page->guest) == GUEST_STOPPED)
        {
@@ -128,7 +128,7 @@ static void start_all_guests()
 {
        enumerator_t *enumerator;
        page_t *page;
-       
+
        enumerator = pages->create_enumerator(pages);
        while (enumerator->enumerate(enumerator, (void**)&page))
        {
@@ -146,7 +146,7 @@ static void start_all_guests()
 static void stop_guest()
 {
        page_t *page;
-       
+
        page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
        if (page && page->guest->get_state(page->guest) == GUEST_RUNNING)
        {
@@ -163,12 +163,12 @@ static void quit()
        page_t *page;
 
        dumm->load_template(dumm, NULL);
-       
+
        enumerator = pages->create_enumerator(pages);
        while (enumerator->enumerate(enumerator, &page))
        {
                if (page->guest->get_state(page->guest) != GUEST_STOPPED)
-               {                       
+               {
                        page->guest->stop(page->guest, idle);
                }
        }
@@ -191,32 +191,32 @@ static void create_switch()
 {
        GtkWidget *dialog, *table, *label, *name;
        bridge_t *bridge;
-       
+
        dialog = gtk_dialog_new_with_buttons("Create new switch", GTK_WINDOW(window),
                                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                                        GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                                        GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL);
-       
+
        table = gtk_table_new(1, 2, TRUE);
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
-       
+
        label = gtk_label_new("Switch name");
        gtk_table_attach(GTK_TABLE(table), label,  0, 1, 0, 1, 0, 0, 0, 0);
        gtk_widget_show(label);
-       
+
        name = gtk_entry_new();
        gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1,
                                         GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
        gtk_widget_show(name);
-       
+
        gtk_widget_show(table);
-       
+
        while (TRUE)
        {
                switch (gtk_dialog_run(GTK_DIALOG(dialog)))
                {
                        case GTK_RESPONSE_ACCEPT:
-                       {                       
+                       {
                                if (streq(gtk_entry_get_text(GTK_ENTRY(name)), ""))
                                {
                                        continue;
@@ -250,34 +250,34 @@ static void connect_guest()
        bridge_t *bridge;
        iface_t *iface;
        enumerator_t *enumerator;
-       
+
        page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
        if (!page || page->guest->get_state(page->guest) != GUEST_RUNNING)
        {
                return;
        }
-       
+
        dialog = gtk_dialog_new_with_buttons("Connect guest", GTK_WINDOW(window),
                                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                                        GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                                        GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL);
-       
+
        table = gtk_table_new(2, 2, TRUE);
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
-       
+
        label = gtk_label_new("Interface name");
        gtk_table_attach(GTK_TABLE(table), label,  0, 1, 0, 1, 0, 0, 0, 0);
        gtk_widget_show(label);
-       
+
        name = gtk_entry_new();
        gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1,
                                         GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
        gtk_widget_show(name);
-       
+
        label = gtk_label_new("Connected switch");
        gtk_table_attach(GTK_TABLE(table), label,  0, 1, 1, 2, 0, 0, 0, 0);
        gtk_widget_show(label);
-       
+
        box = gtk_combo_box_new_text();
        gtk_table_attach(GTK_TABLE(table), box, 1, 2, 1, 2,
                                         GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
@@ -288,20 +288,20 @@ static void connect_guest()
        }
        enumerator->destroy(enumerator);
        gtk_widget_show(box);
-       
+
        gtk_widget_show(table);
-       
+
        while (TRUE)
        {
                switch (gtk_dialog_run(GTK_DIALOG(dialog)))
                {
                        case GTK_RESPONSE_ACCEPT:
-                       {                       
+                       {
                                if (streq(gtk_entry_get_text(GTK_ENTRY(name)), ""))
                                {
                                        continue;
                                }
-                               
+
                                iface = page->guest->create_iface(page->guest,
                                                                        (char*)gtk_entry_get_text(GTK_ENTRY(name)));
                                if (!iface)
@@ -337,7 +337,7 @@ static void disconnect_guest()
 static void delete_guest()
 {
        page_t *page;
-       
+
        page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
        if (page)
        {
@@ -356,7 +356,7 @@ static page_t* create_page(guest_t *guest)
 {
        GtkWidget *label;
        page_t *page;
-       
+
        page = g_new(page_t, 1);
        page->guest = guest;
        page->vte = vte_terminal_new();
@@ -375,55 +375,55 @@ static void create_guest()
 {
        guest_t *guest;
        GtkWidget *dialog, *table, *label, *name, *kernel, *master, *args;
-       
+
        dialog = gtk_dialog_new_with_buttons("Create new guest", GTK_WINDOW(window),
                                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                                        GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                                        GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL);
-       
+
        table = gtk_table_new(4, 2, TRUE);
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
-       
+
        label = gtk_label_new("Guest name");
        gtk_table_attach(GTK_TABLE(table), label,  0, 1, 0, 1, 0, 0, 0, 0);
        gtk_widget_show(label);
-       
+
        label = gtk_label_new("UML kernel");
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, 0, 0, 0, 0);
        gtk_widget_show(label);
-       
+
        label = gtk_label_new("Master filesystem");
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, 0, 0, 0, 0);
        gtk_widget_show(label);
-       
+
        label = gtk_label_new("Kernel arguments");
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, 0, 0, 0, 0);
        gtk_widget_show(label);
-       
+
        name = gtk_entry_new();
        gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1,
                                         GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
        gtk_widget_show(name);
-       
+
        kernel = gtk_file_chooser_button_new("Select UML kernel image",
                                                                                 GTK_FILE_CHOOSER_ACTION_OPEN);
        gtk_table_attach(GTK_TABLE(table), kernel, 1, 2, 1, 2,
                                         GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
        gtk_widget_show(kernel);
-       
+
        master = gtk_file_chooser_button_new("Select master filesystem",
                                                                                 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
        gtk_table_attach(GTK_TABLE(table), master, 1, 2, 2, 3,
                                         GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
        gtk_widget_show(master);
-       
+
        args = gtk_entry_new();
        gtk_table_attach(GTK_TABLE(table), args, 1, 2, 3, 4,
                                         GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
        gtk_widget_show(args);
-       
+
        gtk_widget_show(table);
-       
+
        while (TRUE)
        {
                switch (gtk_dialog_run(GTK_DIALOG(dialog)))
@@ -432,12 +432,12 @@ static void create_guest()
                        {
                                char *sname, *skernel, *smaster, *sargs;
                                page_t *page;
-                               
+
                                sname = (char*)gtk_entry_get_text(GTK_ENTRY(name));
                                skernel = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(kernel));
                                smaster = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(master));
                                sargs = (char*)gtk_entry_get_text(GTK_ENTRY(args));
-                       
+
                                if (!sname[0] || !skernel || !smaster)
                                {
                                        continue;
@@ -469,10 +469,10 @@ int main(int argc, char *argv[])
        GtkWidget *dummMenu, *guestMenu, *switchMenu;
        enumerator_t *enumerator;
        guest_t *guest;
-       
+
        library_init(NULL);
        gtk_init(&argc, &argv);
-       
+
        pages = linked_list_create();
        dumm = dumm_create(NULL);
 
@@ -483,7 +483,7 @@ int main(int argc, char *argv[])
        gtk_window_set_default_size(GTK_WINDOW (window), 1000, 500);
        g_signal_connect(G_OBJECT(vte_reaper_get()), "child-exited",
                                         G_CALLBACK(child_exited), NULL);
-       
+
        /* add vbox with menubar, notebook */
        vbox = gtk_vbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(window), vbox);
@@ -500,7 +500,7 @@ int main(int argc, char *argv[])
        gtk_menu_bar_append(GTK_MENU_BAR(menubar), dummMenu);
        gtk_widget_show(dummMenu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(dummMenu), menu);
-       
+
        /* Dumm -> exit */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
@@ -514,57 +514,57 @@ int main(int argc, char *argv[])
        gtk_menu_bar_append(GTK_MENU_BAR(menubar), guestMenu);
        gtk_widget_show(guestMenu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(guestMenu), menu);
-       
+
        /* Guest -> new */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                                         G_CALLBACK(create_guest), NULL);
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        /* Guest -> delete */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                                         G_CALLBACK(delete_guest), NULL);
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        menuitem = gtk_separator_menu_item_new();
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        /* Guest -> start */
        menuitem = gtk_menu_item_new_with_mnemonic("_Start");
        g_signal_connect(G_OBJECT(menuitem), "activate",
                                         G_CALLBACK(start_guest), NULL);
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        /* Guest -> startall */
        menuitem = gtk_menu_item_new_with_mnemonic("Start _all");
        g_signal_connect(G_OBJECT(menuitem), "activate",
                                         G_CALLBACK(start_all_guests), NULL);
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        /* Guest -> stop */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_STOP, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                                         G_CALLBACK(stop_guest), NULL);
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        menuitem = gtk_separator_menu_item_new();
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        /* Guest -> connect */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_CONNECT, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                                         G_CALLBACK(connect_guest), NULL);
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        /* Guest -> disconnect */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DISCONNECT, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
@@ -579,14 +579,14 @@ int main(int argc, char *argv[])
        gtk_menu_bar_append(GTK_MENU_BAR(menubar), switchMenu);
        gtk_widget_show(switchMenu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(switchMenu), menu);
-       
+
        /* Switch -> new */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                                         G_CALLBACK(create_switch), NULL);
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_show(menuitem);
-       
+
        /* Switch -> delete */
        menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
@@ -594,13 +594,13 @@ int main(int argc, char *argv[])
        gtk_menu_append(GTK_MENU(menu), menuitem);
        gtk_widget_set_sensitive(menuitem, FALSE);
        gtk_widget_show(menuitem);
-       
+
        /* show widgets */
        gtk_widget_show(menubar);
        gtk_widget_show(notebook);
        gtk_widget_show(vbox);
        gtk_widget_show(window);
-       
+
        /* fill notebook with guests */
        enumerator = dumm->create_guest_enumerator(dumm);
        while (enumerator->enumerate(enumerator, (void**)&guest))
@@ -608,12 +608,12 @@ int main(int argc, char *argv[])
                create_page(guest);
        }
        enumerator->destroy(enumerator);
-       
+
        gtk_main();
-       
+
        dumm->destroy(dumm);
        pages->destroy_function(pages, g_free);
-       
+
        library_deinit();
        return 0;
 }
index 2ed96d5622a63847982e1395846a364849347f5f..cba00bb5dc27d9e2a3c2b463c765fd95319eee74 100644 (file)
@@ -95,14 +95,14 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
        mconsole_reply reply;
        int len, flags = 0;
        va_list args;
-       
+
        memset(&request, 0, sizeof(request));
        request.magic = MCONSOLE_MAGIC;
        request.version = MCONSOLE_VERSION;
        va_start(args, command);
        request.len = vsnprintf(request.data, sizeof(request.data), command, args);
        va_end(args);
-       
+
        if (this->idle)
        {
                flags = MSG_DONTWAIT;
@@ -117,13 +117,13 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
                                         (struct sockaddr*)&this->uml, sizeof(this->uml));
        }
        while (len < 0 && (errno == EINTR || errno == EAGAIN));
-       
+
        if (len < 0)
        {
                DBG1("sending mconsole command to UML failed: %m");
                return -1;
        }
-       do 
+       do
        {
                len = recv(this->console, &reply, sizeof(reply), flags);
                if (len < 0 && (errno == EINTR || errno == EAGAIN))
@@ -157,7 +157,7 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
                }
        }
        while (reply.more);
-       
+
        return reply.err;
 }
 
@@ -174,7 +174,7 @@ static void ignore(void *data, char *buf, size_t len)
 static bool add_iface(private_mconsole_t *this, char *guest, char *host)
 {
        int tries = 0;
-       
+
        while (tries++ < 5)
        {
                if (request(this, ignore, NULL, "config %s=tuntap,%s", guest, host) == 0)
@@ -190,7 +190,7 @@ static bool add_iface(private_mconsole_t *this, char *guest, char *host)
  * Implementation of mconsole_t.del_iface.
  */
 static bool del_iface(private_mconsole_t *this, char *guest)
-{      
+{
        if (request(this, NULL, NULL, "remove %s", guest) != 0)
        {
                return FALSE;
@@ -270,7 +270,7 @@ static bool wait_for_notify(private_mconsole_t *this, char *nsock)
                len = recvfrom(this->notify, &notify, sizeof(notify), flags, NULL, 0);
        }
        while (len < 0 && (errno == EINTR || errno == EAGAIN));
-       
+
        if (len < 0 || len >= sizeof(notify))
        {
                DBG1("reading from mconsole notify socket failed: %m");
@@ -300,7 +300,7 @@ static bool wait_for_notify(private_mconsole_t *this, char *nsock)
 static bool setup_console(private_mconsole_t *this)
 {
        struct sockaddr_un addr;
-       
+
        this->console = socket(AF_UNIX, SOCK_DGRAM, 0);
        if (this->console < 0)
        {
@@ -326,20 +326,20 @@ static bool setup_console(private_mconsole_t *this)
 mconsole_t *mconsole_create(char *notify, void(*idle)(void))
 {
        private_mconsole_t *this = malloc_thing(private_mconsole_t);
-       
+
        this->public.add_iface = (bool(*)(mconsole_t*, char *guest, char *host))add_iface;
        this->public.del_iface = (bool(*)(mconsole_t*, char *guest))del_iface;
        this->public.exec = (int(*)(mconsole_t*,  void(*cb)(void*,char*,size_t), void *data, char *cmd))exec;
        this->public.destroy = (void*)destroy;
-       
+
        this->idle = idle;
-       
+
        if (!wait_for_notify(this, notify))
        {
                free(this);
                return NULL;
        }
-       
+
        if (!setup_console(this))
        {
                close(this->notify);
@@ -348,9 +348,9 @@ mconsole_t *mconsole_create(char *notify, void(*idle)(void))
                return NULL;
        }
        unlink(notify);
-       
+
        wait_bootup(this);
-       
+
        return &this->public;
 }
 
index a4d93e48eaea628e52c9d43d785ae5a155114800..9fa2755ef030e9bfb281d0ce5771023a2113c6c8 100644 (file)
@@ -24,7 +24,7 @@ typedef struct mconsole_t mconsole_t;
  * UML mconsole, change running UML configuration using mconsole.
  */
 struct mconsole_t {
-       
+
        /**
         * Create a guest interface and connect it to tap host interface.
         *
@@ -33,7 +33,7 @@ struct mconsole_t {
         * @return                              TRUE if interface created
         */
        bool (*add_iface)(mconsole_t *this, char *guest, char *host);
-       
+
        /**
         * Delete a guest interface.
         *
@@ -41,7 +41,7 @@ struct mconsole_t {
         * @return                              TRUE if interface deleted
         */
        bool (*del_iface)(mconsole_t *this, char *guest);
-       
+
        /**
         * Execute a command on the mconsole.
         *
@@ -52,7 +52,7 @@ struct mconsole_t {
         */
        int (*exec)(mconsole_t *this, void(*cb)(void*,char*,size_t), void *data,
                                char *cmd);
-       
+
        /**
         * Destroy the mconsole instance
         */
index af65dc499249d45bbc410f42ab4faf7ed7eabb8f..811a3c42caf5774141a6b39ab87750a383e78da6 100644 (file)
@@ -14,7 +14,7 @@
 #define NETLINK_SELINUX                7       /* SELinux event notifications */
 #define NETLINK_ISCSI          8       /* Open-iSCSI */
 #define NETLINK_AUDIT          9       /* auditing */
-#define NETLINK_FIB_LOOKUP     10      
+#define NETLINK_FIB_LOOKUP     10
 #define NETLINK_CONNECTOR      11
 #define NETLINK_NETFILTER      12      /* netfilter subsystem */
 #define NETLINK_IP6_FW         13
@@ -22,7 +22,7 @@
 #define NETLINK_KOBJECT_UEVENT 15      /* Kernel messages to userspace */
 #define NETLINK_GENERIC                16
 
-#define MAX_LINKS 32           
+#define MAX_LINKS 32
 
 struct sockaddr_nl
 {
index 56bf7b01c0ec78956952e6400e7953c7c25230bb..93201a4fb685bac777f7feb06819a4d06d5545f9 100644 (file)
@@ -104,7 +104,7 @@ enum {
 #define RTM_NR_FAMILIES        (RTM_NR_MSGTYPES >> 2)
 #define RTM_FAM(cmd)   (((cmd) - RTM_BASE) >> 2)
 
-/* 
+/*
    Generic structure for encapsulation of optional route information.
    It is reminiscent of sockaddr, but with sa_family replaced
    with attribute type.
@@ -146,7 +146,7 @@ struct rtmsg
 
        unsigned char           rtm_table;      /* Routing table id */
        unsigned char           rtm_protocol;   /* Routing protocol; see below  */
-       unsigned char           rtm_scope;      /* See below */ 
+       unsigned char           rtm_scope;      /* See below */
        unsigned char           rtm_type;       /* See below    */
 
        unsigned                rtm_flags;
@@ -632,7 +632,7 @@ struct ifinfomsg
 };
 
 /********************************************************************
- *             prefix information 
+ *             prefix information
  ****/
 
 struct prefixmsg
@@ -647,7 +647,7 @@ struct prefixmsg
        unsigned char   prefix_pad3;
 };
 
-enum 
+enum
 {
        PREFIX_UNSPEC,
        PREFIX_ADDRESS,
@@ -691,7 +691,7 @@ struct rtnl_link_stats
        __u32   tx_fifo_errors;
        __u32   tx_heartbeat_errors;
        __u32   tx_window_errors;
-       
+
        /* for cslip etc */
        __u32   rx_compressed;
        __u32   tx_compressed;
@@ -902,7 +902,7 @@ struct tcamsg
 };
 #define TA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
-#define TCA_ACT_TAB 1 /* attr type must be >=1 */      
+#define TCA_ACT_TAB 1 /* attr type must be >=1 */
 #define TCAA_MAX 1
 
 /* End of information exported to user level */
@@ -941,7 +941,7 @@ extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const voi
 #define RTA_PUT(skb, attrtype, attrlen, data) \
 ({     if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
                 goto rtattr_failure; \
-       __rta_fill(skb, attrtype, attrlen, data); }) 
+       __rta_fill(skb, attrtype, attrlen, data); })
 
 #define RTA_APPEND(skb, attrlen, data) \
 ({     if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
@@ -1021,7 +1021,7 @@ extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const voi
 
 #define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
 #define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
-               
+
 static __inline__ struct rtattr *
 __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
 {
index 48b3c5e2381accf644c3906471d4b68a95015073..4f8d11d2c3ac15a75f5c47f55101f3aeae8688e3 100644 (file)
@@ -32,7 +32,7 @@ typedef context_t *(*context_constructor_t)(void *param);
  * User specific session context, to extend.
  */
 struct context_t {
-       
+
        /**
         * Destroy the context_t.
         */
index 55ba6f58a551976ea0671e3f3e3b9554a2fbd407..1edf72e9043dee4cd8fe39f5c4992c494dc4bcbf 100644 (file)
@@ -42,14 +42,14 @@ typedef controller_t *(*controller_constructor_t)(context_t* context, void *para
  * The controller handle function is called for each incoming request.
  */
 struct controller_t {
-       
+
        /**
         * Get the name of the controller.
         *
         * @return                              name of the controller
         */
        char* (*get_name)(controller_t *this);
-       
+
        /**
         * Handle a HTTP request for that controller.
         *
@@ -67,7 +67,7 @@ struct controller_t {
         */
        void (*handle)(controller_t *this, request_t *request,
                                   char *p1, char *p2, char *p3, char *p4, char *p5);
-               
+
        /**
         * Destroy the controller instance.
         */
index 9f4cc014a03fd245ef069e11186e4febe8befc12..bae6a28e8a544de8636480e35d2be804acdc5359 100644 (file)
@@ -37,57 +37,57 @@ struct private_dispatcher_t {
         * public functions
         */
        dispatcher_t public;
-       
+
        /**
         * fcgi socket fd
         */
        int fd;
-       
+
        /**
         * thread list
         */
        pthread_t *threads;
-       
+
        /**
         * number of threads in "threads"
         */
        int thread_count;
-       
+
        /**
         * session locking mutex
         */
        pthread_mutex_t mutex;
-       
+
        /**
         * List of sessions
         */
        linked_list_t *sessions;
-       
+
        /**
         * session timeout
         */
        time_t timeout;
-       
+
        /**
         * running in debug mode?
         */
        bool debug;
-       
+
        /**
         * List of controllers controller_constructor_t
         */
        linked_list_t *controllers;
-       
+
        /**
         * List of filters filter_constructor_t
         */
        linked_list_t *filters;
-       
-       /** 
+
+       /**
         * constructor function to create session context (in controller_entry_t)
         */
        context_constructor_t context_constructor;
-       
+
        /**
         * user param to context constructor
         */
@@ -135,13 +135,13 @@ static session_t* load_session(private_dispatcher_t *this)
        context_t *context = NULL;
        controller_t *controller;
        filter_t *filter;
-       
+
        if (this->context_constructor)
        {
                context = this->context_constructor(this->param);
        }
        session = session_create(context);
-       
+
        iterator = this->controllers->create_iterator(this->controllers, TRUE);
        while (iterator->iterate(iterator, (void**)&centry))
        {
@@ -149,7 +149,7 @@ static session_t* load_session(private_dispatcher_t *this)
                session->add_controller(session, controller);
        }
        iterator->destroy(iterator);
-       
+
        iterator = this->filters->create_iterator(this->filters, TRUE);
        while (iterator->iterate(iterator, (void**)&fentry))
        {
@@ -157,7 +157,7 @@ static session_t* load_session(private_dispatcher_t *this)
                session->add_filter(session, filter);
        }
        iterator->destroy(iterator);
-       
+
        return session;
 }
 
@@ -168,7 +168,7 @@ static session_entry_t *session_entry_create(private_dispatcher_t *this,
                                                                                         char *host)
 {
        session_entry_t *entry;
-       
+
        entry = malloc_thing(session_entry_t);
        entry->in_use = FALSE;
        entry->closed = FALSE;
@@ -176,7 +176,7 @@ static session_entry_t *session_entry_create(private_dispatcher_t *this,
        entry->session = load_session(this);
        entry->used = time_monotonic(NULL);
        entry->host = strdup(host);
-       
+
        return entry;
 }
 
@@ -194,7 +194,7 @@ static void add_controller(private_dispatcher_t *this,
                                                   controller_constructor_t constructor, void *param)
 {
        controller_entry_t *entry = malloc_thing(controller_entry_t);
-       
+
        entry->constructor = constructor;
        entry->param = param;
        this->controllers->insert_last(this->controllers, entry);
@@ -207,14 +207,14 @@ static void add_filter(private_dispatcher_t *this,
                                           filter_constructor_t constructor, void *param)
 {
        filter_entry_t *entry = malloc_thing(filter_entry_t);
-       
+
        entry->constructor = constructor;
        entry->param = param;
        this->filters->insert_last(this->filters, entry);
 }
 
 /**
- * Actual dispatching code 
+ * Actual dispatching code
  */
 static void dispatch(private_dispatcher_t *this)
 {
@@ -227,7 +227,7 @@ static void dispatch(private_dispatcher_t *this)
                iterator_t *iterator;
                time_t now;
                char *sid;
-               
+
                pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                request = request_create(this->fd, this->debug);
                pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
@@ -238,13 +238,13 @@ static void dispatch(private_dispatcher_t *this)
                }
                sid = request->get_cookie(request, "SID");
                now = time_monotonic(NULL);
-               
+
                /* find session */
                pthread_mutex_lock(&this->mutex);
                iterator = this->sessions->create_iterator(this->sessions, TRUE);
                while (iterator->iterate(iterator, (void**)&current))
                {
-                       /* check all sessions for timeout or close flag 
+                       /* check all sessions for timeout or close flag
                         * TODO: use a seperate cleanup thread */
                        if (!current->in_use &&
                                (current->used < now - this->timeout || current->closed))
@@ -262,7 +262,7 @@ static void dispatch(private_dispatcher_t *this)
                        }
                }
                iterator->destroy(iterator);
-               
+
                if (found)
                {
                        /* wait until session is unused */
@@ -278,18 +278,18 @@ static void dispatch(private_dispatcher_t *this)
                }
                found->in_use = TRUE;
                pthread_mutex_unlock(&this->mutex);
-       
+
                /* start processing */
                found->session->process(found->session, request);
                found->used = time_monotonic(NULL);
-               
+
                /* release session */
                pthread_mutex_lock(&this->mutex);
                found->in_use = FALSE;
                found->closed = request->session_closed(request);
                pthread_cond_signal(&found->cond);
                pthread_mutex_unlock(&this->mutex);
-               
+
                /* cleanup */
                request->destroy(request);
        }
@@ -319,7 +319,7 @@ static void waitsignal(private_dispatcher_t *this)
 {
        sigset_t set;
        int sig;
-       
+
        sigemptyset(&set);
        sigaddset(&set, SIGINT);
        sigaddset(&set, SIGTERM);
@@ -359,7 +359,7 @@ dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
        this->public.run = (void(*)(dispatcher_t*, int threads))run;
        this->public.waitsignal = (void(*)(dispatcher_t*))waitsignal;
        this->public.destroy = (void(*)(dispatcher_t*))destroy;
-       
+
        this->sessions = linked_list_create();
        this->controllers = linked_list_create();
        this->filters = linked_list_create();
@@ -370,9 +370,9 @@ dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
     this->timeout = timeout;
     this->debug = debug;
     this->threads = NULL;
-       
+
     FCGX_Init();
-    
+
     if (socket)
     {
                unlink(socket);
index 5b4e3f9479fd69ba5022584bc4220d506cd8b27f..17a288b8f9ef0e244c9c334a5df7be70d209306f 100644 (file)
  * the webserver. It is multithreaded and really fast.
  *
  * The application has a global context and a session context. The global
- * context is accessed from all sessions simultaneously and therefore 
+ * context is accessed from all sessions simultaneously and therefore
  * needs to be threadsave. Often a database wrapper is the global context.
  * The session context is instanciated per session. Sessions are managed
  * automatically through session cookies. The session context is kept alive
  * until the session times out. It must implement the context_t interface and
- * a #context_constructor_t is needed to create instances. To each session, 
- * a set of controllers gets instanciated. The controller instances are per 
+ * a #context_constructor_t is needed to create instances. To each session,
+ * a set of controllers gets instanciated. The controller instances are per
  * session, so you can hold private data for each user.
- * Controllers need to implement the controller_t interface and need a 
+ * Controllers need to implement the controller_t interface and need a
  * #controller_constructor_t function to create instances.
  *
  * A small example shows how to set up libfast:
  * @code
        dispatcher_t *dispatcher;
        your_global_context_implementation_t *global;
+
        global = initialize_your_global_context();
+
        dispatcher = dispatcher_create(NULL, FALSE, 180,
                        (context_constructor_t)your_session_context_create, global);
        dispatcher->add_controller(dispatcher, your_controller1_create, param1);
        dispatcher->add_controller(dispatcher, your_controller2_create, param2);
-       
+
        dispatcher->run(dispatcher, 20);
-       
+
        dispatcher->waitsignal(dispatcher);
-       
+
        dispatcher->destroy(dispatcher);
        global->destroy();
    @endcode
@@ -76,7 +76,7 @@ typedef struct dispatcher_t dispatcher_t;
  * constructor added with add_controller.
  */
 struct dispatcher_t {
-       
+
        /**
         * Register a controller to the dispatcher.
         *
@@ -96,8 +96,8 @@ struct dispatcher_t {
         * @param param                 param to pass to constructor
         */
        void (*add_filter)(dispatcher_t *this,
-                                          filter_constructor_t constructor, void *param);      
-       
+                                          filter_constructor_t constructor, void *param);
+
        /**
         * Start with dispatching.
         *
@@ -106,13 +106,13 @@ struct dispatcher_t {
         * @param threads               number of dispatching threads
         */
        void (*run)(dispatcher_t *this, int threads);
-       
+
        /**
         * Wait for a relevant signal action.
         *
         */
        void (*waitsignal)(dispatcher_t *this);
-       
+
        /**
         * Destroy the dispatcher_t.
         */
index d2602db9d79c16d161e1be4c5b0d6d2df5e7c58f..305a8bb6e038b9621c9688fd24499537ce242866 100644 (file)
@@ -39,7 +39,7 @@ typedef filter_t *(*filter_constructor_t)(context_t* context, void *param);
  * Filter interface, to be implemented by users filters.
  */
 struct filter_t {
-       
+
        /**
         * Called before the controller handles the request.
         *
@@ -53,7 +53,7 @@ struct filter_t {
         */
        bool (*run)(filter_t *this, request_t *request,
                                char *p0, char *p1, char *p2, char *p3, char *p4, char *p5);
-       
+
        /**
         * Destroy the filter instance.
         */
index 96dfab8e756f9eeed82bebdbd8b2adde77812116..1e4badaeb1184f49f039637c16dfbf6a56c4f474 100644 (file)
@@ -35,32 +35,32 @@ struct private_request_t {
         * public functions
         */
        request_t public;
-       
+
        /**
         * FastCGI request object
         */
        FCGX_Request req;
-       
+
        /**
         * length of the req.envp array
         */
        int req_env_len;
-       
+
        /**
         * ClearSilver CGI Kit context
         */
        CGI *cgi;
-       
+
        /**
         * ClearSilver HDF dataset for this request
         */
        HDF *hdf;
-       
-       /** 
+
+       /**
         * close the session?
         */
        bool closed;
-       
+
        /**
         * reference count
         */
@@ -85,7 +85,7 @@ pthread_once_t once = PTHREAD_ONCE_INIT;
 static int read_cb(void *null, char *buf, int size)
 {
        private_request_t *this = (private_request_t*)pthread_getspecific(this_key);
-       
+
        return FCGX_GetStr(buf, size, this->req.in);
 }
 
@@ -95,7 +95,7 @@ static int read_cb(void *null, char *buf, int size)
 static int writef_cb(void *null, const char *format, va_list args)
 {
        private_request_t *this = (private_request_t*)pthread_getspecific(this_key);
-       
+
        FCGX_VFPrintF(this->req.out, format, args);
        return 0;
 }
@@ -105,7 +105,7 @@ static int writef_cb(void *null, const char *format, va_list args)
 static int write_cb(void *null, const char *buf, int size)
 {
        private_request_t *this = (private_request_t*)pthread_getspecific(this_key);
-       
+
        return FCGX_PutStr(buf, size, this->req.out);
 }
 
@@ -116,7 +116,7 @@ static char *getenv_cb(void *null, const char *key)
 {
        char *value;
        private_request_t *this = (private_request_t*)pthread_getspecific(this_key);
-       
+
        value = FCGX_GetParam(key, this->req.envp);
        return value ? strdup(value) : NULL;
 }
@@ -157,7 +157,7 @@ static int iterenv_cb(void *null, int num, char **key, char **value)
        }
        return 0;
 }
-       
+
 /**
  * Implementation of request_t.get_cookie.
  */
@@ -165,7 +165,7 @@ static char* get_cookie(private_request_t *this, char *name)
 {
        return hdf_get_valuef(this->hdf, "Cookie.%s", name);
 }
-       
+
 /**
  * Implementation of request_t.get_path.
  */
@@ -211,7 +211,7 @@ static void add_cookie(private_request_t *this, char *name, char *value)
                                        FCGX_GetParam("SCRIPT_NAME", this->req.envp),
                                        NULL, NULL, 0, 0);
 }
-       
+
 /**
  * Implementation of request_t.redirect.
  */
@@ -246,7 +246,7 @@ static char* get_base(private_request_t *this)
 {
        return FCGX_GetParam("SCRIPT_NAME", this->req.envp);
 }
-       
+
 /**
  * Implementation of request_t.session_closed.
  */
@@ -279,7 +279,7 @@ static void serve(private_request_t *this, char *headers, chunk_t chunk)
 static void render(private_request_t *this, char *template)
 {
        NEOERR* err;
-       
+
        pthread_setspecific(this_key, this);
        err = cgi_display(this->cgi, template);
        if (err)
@@ -327,8 +327,8 @@ static void setf(private_request_t *this, char *format, ...)
        va_start(args, format);
        hdf_set_valuevf(this->hdf, format, args);
        va_end(args);
-}      
-       
+}
+
 /**
  * Implementation of request_t.get_ref.
  */
@@ -371,7 +371,7 @@ request_t *request_create(int fd, bool debug)
        NEOERR* err;
        private_request_t *this = malloc_thing(private_request_t);
        bool failed = FALSE;
-       
+
        pthread_cleanup_push(free, this);
        if (FCGX_InitRequest(&this->req, fd, 0) != 0 ||
                FCGX_Accept_r(&this->req) != 0)
@@ -402,18 +402,18 @@ request_t *request_create(int fd, bool debug)
        this->public.setf = (void(*)(request_t*, char *format, ...))setf;
        this->public.get_ref = (request_t*(*)(request_t*))get_ref;
        this->public.destroy = (void(*)(request_t*))destroy;
-       
+
        pthread_once(&once, init);
        pthread_setspecific(this_key, this);
-       
+
        this->ref = 1;
        this->closed = FALSE;
-       this->req_env_len = 0;  
+       this->req_env_len = 0;
        while (this->req.envp[this->req_env_len] != NULL)
        {
                this->req_env_len++;
        }
-       
+
        err = hdf_init(&this->hdf);
        if (!err)
        {
@@ -425,7 +425,7 @@ request_t *request_create(int fd, bool debug)
                        hdf_set_value(this->hdf, "Config.CompressionEnabled", "1");
                        hdf_set_value(this->hdf, "Config.WhiteSpaceStrip", "2");
                }
-       
+
                err = cgi_init(&this->cgi, this->hdf);
                if (!err)
                {
index b9ea888309bdec985fed7a4e3139ecc32d02aa00..61e2d59f076b5e6dbe441708ac77041fa4965862 100644 (file)
@@ -32,7 +32,7 @@ typedef struct request_t request_t;
  * The response is also handled through the request object.
  */
 struct request_t {
-       
+
        /**
         * Add a cookie to the reply (Set-Cookie header).
         *
@@ -40,7 +40,7 @@ struct request_t {
         * @param value         value of the cookie
         */
        void (*add_cookie)(request_t *this, char *name, char *value);
-       
+
        /**
         * Get a cookie the client sent in the request.
         *
@@ -48,35 +48,35 @@ struct request_t {
         * @return                      cookie value, NULL if no such cookie found
         */
        char* (*get_cookie)(request_t *this, char *name);
-       
+
        /**
         * Get the request path relative to the application.
         *
         * @return                      path
         */
        char* (*get_path)(request_t *this);
-       
+
        /**
         * Get the base path of the application.
         *
         * @return                      base path
         */
        char* (*get_base)(request_t *this);
-       
+
        /**
         * Get the remote host address of this request.
         *
         * @return                      host address as string
         */
        char* (*get_host)(request_t *this);
-       
+
        /**
         * Get the user agent string.
         *
         * @return                      user agent string
         */
        char* (*get_user_agent)(request_t *this);
-               
+
        /**
         * Get a post/get variable included in the request.
         *
@@ -84,19 +84,19 @@ struct request_t {
         * @return                      value, NULL if not found
         */
        char* (*get_query_data)(request_t *this, char *name);
-       
+
        /**
         * Close the session and it's context after handling.
         */
        void (*close_session)(request_t *this);
-       
+
        /**
         * Has the session been closed by close_session()?
         *
         * @return                      TRUE if session has been closed
         */
        bool (*session_closed)(request_t *this);
-       
+
        /**
         * Redirect the client to another location.
         *
@@ -104,12 +104,12 @@ struct request_t {
         * @param ...           variable argument for fmt
         */
        void (*redirect)(request_t *this, char *fmt, ...);
-       
+
        /**
         * Redirect the client to the referer.
         */
        void (*to_referer)(request_t *this);
-               
+
        /**
         * Set a template value.
         *
@@ -117,7 +117,7 @@ struct request_t {
         * @param value         value to set key to
         */
        void (*set)(request_t *this, char *key, char *value);
-       
+
        /**
         * Set a template value using format strings.
         *
@@ -128,7 +128,7 @@ struct request_t {
         * @param ...           variable argument list
         */
        void (*setf)(request_t *this, char *format, ...);
-       
+
        /**
         * Render a template.
         *
@@ -139,7 +139,7 @@ struct request_t {
         * @param template      clearsilver template file location
         */
        void (*render)(request_t *this, char *template);
-       
+
        /**
         * Stream a format string to the client.
         *
@@ -151,7 +151,7 @@ struct request_t {
         * @return                      number of streamed bytes, < 0 if stream closed
         */
        int (*streamf)(request_t *this, char *format, ...);
-       
+
        /**
         * Serve a request with headers and a body.
         *
@@ -159,14 +159,14 @@ struct request_t {
         * @param chunk         body to write to output
         */
        void (*serve)(request_t *this, char *headers, chunk_t chunk);
-       
+
        /**
         * Increase the reference count to the stream.
         *
         * @return                      this with increased refcount
         */
        request_t* (*get_ref)(request_t *this);
-       
+
        /**
         * Destroy the request_t.
         */
index 455c8d5e19afb023058df8e5db58590307fb938b..39c01c39471250eb3fd0e3005d332ea23189ef7c 100644 (file)
@@ -34,22 +34,22 @@ struct private_session_t {
         * public functions
         */
        session_t public;
-       
+
        /**
         * session ID
         */
        char *sid;
-       
+
        /**
         * list of controller instances controller_t
         */
        linked_list_t *controllers;
-       
+
        /**
         * list of filter instances filter_t
         */
        linked_list_t *filters;
-       
+
        /**
         * user defined session context
         */
@@ -80,7 +80,7 @@ static void create_sid(private_session_t *this, request_t *request)
        char buf[16];
        chunk_t chunk = chunk_from_buf(buf);
        rng_t *rng;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (rng)
        {
@@ -99,7 +99,7 @@ static bool run_filter(private_session_t *this, request_t *request, char *p0,
 {
        enumerator_t *enumerator;
        filter_t *filter;
-       
+
        enumerator = this->filters->create_enumerator(this->filters);
        while (enumerator->enumerate(enumerator, &filter))
        {
@@ -123,12 +123,12 @@ static void process(private_session_t *this, request_t *request)
        bool handled = FALSE;
        controller_t *current;
        int i = 0;
-       
+
        if (this->sid == NULL)
        {
                create_sid(this, request);
        }
-       
+
        start = request->get_path(request);
        if (start)
        {
@@ -142,15 +142,15 @@ static void process(private_session_t *this, request_t *request)
                        start = pos + 1;
                }
                param[i] = strdupa(start);
-               
-               if (run_filter(this, request, param[0], param[1], param[2], param[3], 
+
+               if (run_filter(this, request, param[0], param[1], param[2], param[3],
                                            param[4], param[5]))
                {
                        enumerator = this->controllers->create_enumerator(this->controllers);
                        while (enumerator->enumerate(enumerator, &current))
                        {
                                if (streq(current->get_name(current), param[0]))
-                               {       
+                               {
                                        current->handle(current, request, param[1], param[2],
                                                                        param[3], param[4], param[5]);
                                        handled = TRUE;
@@ -211,7 +211,7 @@ session_t *session_create(context_t *context)
        this->controllers = linked_list_create();
        this->filters = linked_list_create();
        this->context = context;
-       
+
        return &this->public;
 }
 
index 524e60f46de311ad7666b08328748e4b9301700c..bd35de31ac00ea6f9c7932b0cfc0eb6fc11ca4b8 100644 (file)
@@ -31,35 +31,35 @@ typedef struct session_t session_t;
  * Session handling class, instanciated for each user session.
  */
 struct session_t {
-       
+
        /**
         * Get the session ID of the session.
         *
         * @return                              session ID
         */
        char* (*get_sid)(session_t *this);
-       
+
        /**
         * Add a controller instance to the session.
         *
         * @param controller    controller to add
         */
        void (*add_controller)(session_t *this, controller_t *controller);
-       
+
        /**
         * @brief Add a filter instance to the session.
         *
         * @param filter                filter to add
         */
        void (*add_filter)(session_t *this, filter_t *filter);
-       
+
        /**
         * Process a request in this session.
         *
         * @param request               request to process
         */
        void (*process)(session_t *this, request_t *request);
-       
+
        /**
         * Destroy the session_t.
         *
index 7acfa5ded745f2ab52cf784410d80f2d9d3dbff7..e1c71da3c42f7b71d098b506e6a6c0b76d155067 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * addresses to ASCII
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 6efdfccca0646c6e67dbf6db5d38503820d18740..b4b853bbb3d368553705c3a32127aa532ee2f6d4 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * addresses to text
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
@@ -279,11 +279,11 @@ regress()
 
                if (n == 0 && r->output == NULL)
                        {}              /* okay, error expected */
-               
+
                else if (n == 0) {
                        printf("`%s' atoasr failed\n", r->input);
                        status = 1;
-                       
+
                } else if (r->output == NULL) {
                        printf("`%s' atoasr succeeded unexpectedly '%c'\n",
                                                        r->input, r->format);
index f402eca70d11d8809896e33a567a3f2b462a32dd..ee3cc998fb348a609f1dc9f5e1c01dada996ad85 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * extract parts of an ip_address
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index f2eb8d07a1c7705a366426bef4e6c14949c5f740..5b7691b7b4edd7c4474c8e9ee2797977b1703028 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * special addresses
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index cbda541d3d5e8102f8f16e7728763d18ca1dd720..8f1be0a842ec935feb24a072b98a7fdd076ca24c 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * conversion from ASCII forms of addresses to internal ones
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index ef8412fe877abd87e844759c96fa9abc71df384f..ad62ef46bd247f976fd553ee7cbbfca0aa5161f9 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from ASCII form of address/subnet/range to binary
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index aeb5742e164b55051d8a5baf0f8a723e8733467f..7339b4c3e87064c556cc3a92ec0b8ac56b8c3f6d 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from ASCII form of SA ID to binary
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index a123a39da163d09b329645566e37c0e11c3d12a4..8b2bfa17ec92013d77392abd1c081bd18113ca59 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from ASCII form of subnet specification to binary
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 7e51de8fee1b9668934967a14b96ab9c2c572851..d8e1528cbf06d3f7042e72a27dc222d77b76ee3f 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from ASCII form of unsigned long to binary
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index b18d4b050464c2571613e7aa5df04141d0f4dfc8..3e2aed76decfa24e38c2b22d83c8824b0be37cb5 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from binary data (e.g. key) to text form
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 77ce8f2be2bbdd1b49110ea2b5760744ee36bba1..342f599871ff9bf095e0ec955fa7088a4f798e56 100644 (file)
@@ -3,12 +3,12 @@
  * header file for FreeS/WAN library functions
  * Copyright (C) 1998, 1999, 2000  Henry Spencer.
  * Copyright (C) 1999, 2000, 2001  Richard Guy Briggs
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
@@ -391,7 +391,7 @@ extern unsigned int pfkey_lib_debug;  /* bits selecting what to report */
 
 /*
  * pluto and lwdnsq need to know the maximum size of the commands to,
- * and replies from lwdnsq. 
+ * and replies from lwdnsq.
  */
 
 #define LWDNSQ_CMDBUF_LEN      1024
index a2d51de0cb84e603217d7a8fdfab1b2e09e06a41..66edae20f4378461abba3c0bf5eb3b1601227f30 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * minor utilities for subnet-mask manipulation
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
@@ -17,7 +17,7 @@
 
 /*
  - goodmask - is this a good (^1*0*$) subnet mask?
- * You are not expected to understand this.  See Henry S. Warren Jr, 
+ * You are not expected to understand this.  See Henry S. Warren Jr,
  * "Functions realizable with word-parallel logical and two's-complement
  * addition instructions", CACM 20.6 (June 1977), p.439.
  */
index c30efb812efb9247329d98fbe71daf87c1e9599b..c84006f475dd95db9b2f1fccc861f87f42f90065 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * initialize address structure
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index fb8187422312a31eeb36e1eac73b51246178558f..4e4bc9a357fab6ea1b39096c3d7f8e460695080a 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * initialize SA ID structure
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 0e19098c55ee1fce97a883aa62c56755613dc583..27faddabc7cf90e6751bdcbd441d0d0120d01344 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * initialize subnet structure
  * Copyright (C) 2000, 2002  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index fa24f7d2dd66a669749b02f9aaebe51c4ebe47c9..832c8a53d7f1bab00c28fc28f237eac962fb332b 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * internal definitions for use within the library; do not export!
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index b0ee845a533291abdf36204a3d7648068f090a39..93426b8eeb13089d97d04bcc4ae372fe86532fb1 100644 (file)
@@ -3,19 +3,19 @@
  *
  * Copyright (C) 2001  Richard Guy Briggs  <rgb@freeswan.org>
  *                 and Michael Richardson  <mcr@freeswan.org>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
 
-/* 
+/*
  * This file provides a set of #define's which may be tuned by various
  * people/configurations. It keeps all compile-time tunables in one place.
  *
 # define IPSEC_SA_REF_TABLE_IDX_WIDTH 16
 #endif
 
-#ifndef IPSEC_SA_REF_MAINTABLE_IDX_WIDTH 
-# define IPSEC_SA_REF_MAINTABLE_IDX_WIDTH 4 
+#ifndef IPSEC_SA_REF_MAINTABLE_IDX_WIDTH
+# define IPSEC_SA_REF_MAINTABLE_IDX_WIDTH 4
 #endif
 
-#ifndef IPSEC_SA_REF_FREELIST_NUM_ENTRIES 
+#ifndef IPSEC_SA_REF_FREELIST_NUM_ENTRIES
 # define IPSEC_SA_REF_FREELIST_NUM_ENTRIES 256
 #endif
 
-#ifndef IPSEC_SA_REF_CODE 
-# define IPSEC_SA_REF_CODE 1 
+#ifndef IPSEC_SA_REF_CODE
+# define IPSEC_SA_REF_CODE 1
 #endif
 
 #define _IPSEC_PARAM_H_
index 118e613916322e5c5dd622f71507d6df6bc1c89b..89ab5fced52eb920ff4db8aefda1bccade11d79d 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * generate printable key IDs
  * Copyright (C) 2002  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index ba0010bc7505a628e31cfa164ecd874062fc597f..993678c8be4447f06406e0c9dcf24669783c0d50 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * FreeS/WAN specific PF_KEY headers
  * Copyright (C) 1999, 2000, 2001  Richard Guy Briggs.
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
index ddc21040fa7a31f4161144825c61109a2eb0304f..c0bb369cbcda226044264dfcc262cfc3c12e7135 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * RFC2367 PF_KEYv2 Key management API message parser
  * Copyright (C) 1999, 2000, 2001  Richard Guy Briggs.
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@@ -48,7 +48,7 @@ void
 pfkey_extensions_init(struct sadb_ext *extensions[SADB_EXT_MAX + 1])
 {
        int i;
-       
+
        for (i = 0; i != SADB_EXT_MAX + 1; i++) {
                extensions[i] = NULL;
        }
@@ -58,7 +58,7 @@ void
 pfkey_extensions_free(struct sadb_ext *extensions[SADB_EXT_MAX + 1])
 {
        int i;
-       
+
        if (!extensions) {
                return;
        }
@@ -68,7 +68,7 @@ pfkey_extensions_free(struct sadb_ext *extensions[SADB_EXT_MAX + 1])
                FREE(extensions[0]);
                extensions[0] = NULL;
        }
-       
+
        for (i = 1; i != SADB_EXT_MAX + 1; i++) {
                if(extensions[i]) {
                        memset(extensions[i], 0, extensions[i]->sadb_ext_len * IPSEC_PFKEYv2_ALIGN);
@@ -135,7 +135,7 @@ pfkey_msg_hdr_build(struct sadb_ext**       pfkey_ext,
        if (satype > SADB_SATYPE_MAX) {
                DEBUGGING(
                        "pfkey_msg_hdr_build: "
-                       "satype %d > max %d\n", 
+                       "satype %d > max %d\n",
                        satype, SADB_SATYPE_MAX);
                SENDERR(EINVAL);
        }
@@ -169,7 +169,7 @@ pfkey_msg_hdr_build(struct sadb_ext**       pfkey_ext,
                *pfkey_ext);
 errlab:
        return error;
-}      
+}
 
 int
 pfkey_sa_ref_build(struct sadb_ext **          pfkey_ext,
@@ -254,7 +254,7 @@ pfkey_sa_ref_build(struct sadb_ext **               pfkey_ext,
                        SADB_SASTATE_DEAD);
                SENDERR(EINVAL);
        }
-       
+
        if ((IPSEC_SAREF_NULL != ref) && (ref >= (1 << IPSEC_SA_REF_TABLE_IDX_WIDTH))) {
                DEBUGGING(
                          "pfkey_sa_build: "
@@ -264,7 +264,7 @@ pfkey_sa_ref_build(struct sadb_ext **               pfkey_ext,
                          IPSEC_SA_REF_TABLE_NUM_ENTRIES);
                SENDERR(EINVAL);
        }
-       
+
        pfkey_sa = (struct sadb_sa*)MALLOC(sizeof(struct sadb_sa));
        *pfkey_ext = (struct sadb_ext*)pfkey_sa;
 
@@ -275,7 +275,7 @@ pfkey_sa_ref_build(struct sadb_ext **               pfkey_ext,
                SENDERR(ENOMEM);
        }
        memset(pfkey_sa, 0, sizeof(struct sadb_sa));
-       
+
        pfkey_sa->sadb_sa_len = sizeof(*pfkey_sa) / IPSEC_PFKEYv2_ALIGN;
        pfkey_sa->sadb_sa_exttype = exttype;
        pfkey_sa->sadb_sa_spi = spi;
@@ -284,11 +284,11 @@ pfkey_sa_ref_build(struct sadb_ext **             pfkey_ext,
        pfkey_sa->sadb_sa_auth = auth;
        pfkey_sa->sadb_sa_encrypt = encrypt;
        pfkey_sa->sadb_sa_flags = flags;
-       pfkey_sa->sadb_x_sa_ref = ref;  
+       pfkey_sa->sadb_x_sa_ref = ref;
 
 errlab:
        return error;
-}      
+}
 
 int
 pfkey_sa_build(struct sadb_ext **      pfkey_ext,
@@ -377,7 +377,7 @@ pfkey_address_build(struct sadb_ext**       pfkey_ext,
        int saddr_len = 0;
        char ipaddr_txt[ADDRTOT_BUF + 6/*extra for port number*/];
        struct sadb_address *pfkey_address = (struct sadb_address *)*pfkey_ext;
-       
+
        DEBUGGING(
                "pfkey_address_build: "
                "exttype=%d proto=%d prefixlen=%d\n",
@@ -397,8 +397,8 @@ pfkey_address_build(struct sadb_ext**       pfkey_ext,
                                  "address is NULL\n");
                        SENDERR(EINVAL);
        }
-       
-       switch(exttype) {       
+
+       switch(exttype) {
        case SADB_EXT_ADDRESS_SRC:
        case SADB_EXT_ADDRESS_DST:
        case SADB_EXT_ADDRESS_PROXY:
@@ -410,11 +410,11 @@ pfkey_address_build(struct sadb_ext**     pfkey_ext,
        case SADB_X_EXT_NAT_T_OA:
                break;
        default:
-               DEBUGGING( 
+               DEBUGGING(
                        "pfkey_address_build: "
-                       "unrecognised ext_type=%d.\n", 
-                       exttype); 
-               SENDERR(EINVAL); 
+                       "unrecognised ext_type=%d.\n",
+                       exttype);
+               SENDERR(EINVAL);
        }
 
        switch (address->sa_family) {
@@ -479,10 +479,10 @@ pfkey_address_build(struct sadb_ext**     pfkey_ext,
               0,
               ALIGN_N(sizeof(struct sadb_address) + saddr_len,
                     IPSEC_PFKEYv2_ALIGN));
-              
+
        pfkey_address->sadb_address_len = DIVUP(sizeof(struct sadb_address) + saddr_len,
                                                IPSEC_PFKEYv2_ALIGN);
-       
+
        pfkey_address->sadb_address_exttype = exttype;
        pfkey_address->sadb_address_proto = proto;
        pfkey_address->sadb_address_prefixlen = prefixlen;
@@ -540,7 +540,7 @@ pfkey_key_build(struct sadb_ext**   pfkey_ext,
        }
 
        pfkey_key = (struct sadb_key*)
-               MALLOC(sizeof(struct sadb_key) + 
+               MALLOC(sizeof(struct sadb_key) +
                        DIVUP(key_bits, 64) * IPSEC_PFKEYv2_ALIGN);
        *pfkey_ext = (struct sadb_ext*)pfkey_key;
 
@@ -554,7 +554,7 @@ pfkey_key_build(struct sadb_ext**   pfkey_ext,
               0,
               sizeof(struct sadb_key) +
               DIVUP(key_bits, 64) * IPSEC_PFKEYv2_ALIGN);
-       
+
        pfkey_key->sadb_key_len = DIVUP(sizeof(struct sadb_key) * IPSEC_PFKEYv2_ALIGN + key_bits,
                                        64);
        pfkey_key->sadb_key_exttype = exttype;
@@ -622,12 +622,12 @@ pfkey_ident_build(struct sadb_ext**       pfkey_ext,
                        "string required to allocate size of extension.\n");
                SENDERR(EINVAL);
        }
-       
+
 #if 0
        if (ident_type == SADB_IDENTTYPE_USERFQDN) {
        }
 #endif
-           
+
        pfkey_ident = (struct sadb_ident*)
                MALLOC(ident_len * IPSEC_PFKEYv2_ALIGN);
        *pfkey_ext = (struct sadb_ext*)pfkey_ident;
@@ -639,7 +639,7 @@ pfkey_ident_build(struct sadb_ext** pfkey_ext,
                SENDERR(ENOMEM);
        }
        memset(pfkey_ident, 0, ident_len * IPSEC_PFKEYv2_ALIGN);
-       
+
        pfkey_ident->sadb_ident_len = ident_len;
        pfkey_ident->sadb_ident_exttype = exttype;
        pfkey_ident->sadb_ident_type = ident_type;
@@ -699,7 +699,7 @@ pfkey_sens_build(struct sadb_ext**  pfkey_ext,
               0,
               sizeof(struct sadb_sens) +
               (sens_len + integ_len) * sizeof(uint64_t));
-       
+
        pfkey_sens->sadb_sens_len = (sizeof(struct sadb_sens) +
                    (sens_len + integ_len) * sizeof(uint64_t)) / IPSEC_PFKEYv2_ALIGN;
        pfkey_sens->sadb_sens_exttype = SADB_EXT_SENSITIVITY;
@@ -761,7 +761,7 @@ pfkey_prop_build(struct sadb_ext**  pfkey_ext,
               0,
               sizeof(struct sadb_prop) +
                    comb_num * sizeof(struct sadb_comb));
-       
+
        pfkey_prop->sadb_prop_len = (sizeof(struct sadb_prop) +
                    comb_num * sizeof(struct sadb_comb)) / IPSEC_PFKEYv2_ALIGN;
 
@@ -846,7 +846,7 @@ pfkey_supported_build(struct sadb_ext**     pfkey_ext,
               sizeof(struct sadb_supported) +
                                               alg_num *
                                               sizeof(struct sadb_alg));
-       
+
        pfkey_supported->sadb_supported_len = (sizeof(struct sadb_supported) +
                                               alg_num *
                                               sizeof(struct sadb_alg)) /
@@ -860,7 +860,7 @@ pfkey_supported_build(struct sadb_ext**     pfkey_ext,
                pfkey_alg->sadb_alg_reserved = 0;
                pfkey_alg++;
        }
-       
+
 #if 0
        DEBUGGING(
                "pfkey_supported_build: "
@@ -886,7 +886,7 @@ pfkey_spirange_build(struct sadb_ext**      pfkey_ext,
 {
        int error = 0;
        struct sadb_spirange *pfkey_spirange = (struct sadb_spirange *)*pfkey_ext;
-       
+
        /* sanity checks... */
        if (pfkey_spirange) {
                DEBUGGING(
@@ -894,7 +894,7 @@ pfkey_spirange_build(struct sadb_ext**      pfkey_ext,
                        "why is pfkey_spirange already pointing to something?\n");
                SENDERR(EINVAL);
        }
-       
+
         if (ntohl(max) < ntohl(min)) {
                DEBUGGING(
                        "pfkey_spirange_build: "
@@ -903,7 +903,7 @@ pfkey_spirange_build(struct sadb_ext**      pfkey_ext,
                        ntohl(max));
                 SENDERR(EINVAL);
         }
-       
+
        if (ntohl(min) <= 255) {
                DEBUGGING(
                        "pfkey_spirange_build: "
@@ -911,7 +911,7 @@ pfkey_spirange_build(struct sadb_ext**      pfkey_ext,
                        ntohl(min));
                SENDERR(EEXIST);
        }
-       
+
        pfkey_spirange = (struct sadb_spirange*)
                MALLOC(sizeof(struct sadb_spirange));
        *pfkey_ext = (struct sadb_ext*)pfkey_spirange;
@@ -925,7 +925,7 @@ pfkey_spirange_build(struct sadb_ext**      pfkey_ext,
        memset(pfkey_spirange,
               0,
               sizeof(struct sadb_spirange));
-       
+
         pfkey_spirange->sadb_spirange_len = sizeof(struct sadb_spirange) / IPSEC_PFKEYv2_ALIGN;
 
        pfkey_spirange->sadb_spirange_exttype = SADB_EXT_SPIRANGE;
@@ -949,7 +949,7 @@ pfkey_x_kmprivate_build(struct sadb_ext**   pfkey_ext)
                        "why is pfkey_x_kmprivate already pointing to something?\n");
                SENDERR(EINVAL);
        }
-       
+
        pfkey_x_kmprivate->sadb_x_kmprivate_reserved = 0;
 
        DEBUGGING(
@@ -971,7 +971,7 @@ pfkey_x_kmprivate_build(struct sadb_ext**   pfkey_ext)
        memset(pfkey_x_kmprivate,
               0,
               sizeof(struct sadb_x_kmprivate));
-       
+
         pfkey_x_kmprivate->sadb_x_kmprivate_len =
                sizeof(struct sadb_x_kmprivate) / IPSEC_PFKEYv2_ALIGN;
 
@@ -998,7 +998,7 @@ pfkey_x_satype_build(struct sadb_ext**      pfkey_ext,
                        "why is pfkey_x_satype already pointing to something?\n");
                SENDERR(EINVAL);
        }
-       
+
        if (!satype) {
                DEBUGGING(
                        "pfkey_x_satype_build: "
@@ -1009,7 +1009,7 @@ pfkey_x_satype_build(struct sadb_ext**    pfkey_ext,
        if (satype > SADB_SATYPE_MAX) {
                DEBUGGING(
                        "pfkey_x_satype_build: "
-                       "satype %d > max %d\n", 
+                       "satype %d > max %d\n",
                        satype, SADB_SATYPE_MAX);
                SENDERR(EINVAL);
        }
@@ -1028,7 +1028,7 @@ pfkey_x_satype_build(struct sadb_ext**    pfkey_ext,
        memset(pfkey_x_satype,
               0,
               sizeof(struct sadb_x_satype));
-       
+
         pfkey_x_satype->sadb_x_satype_len = sizeof(struct sadb_x_satype) / IPSEC_PFKEYv2_ALIGN;
 
        pfkey_x_satype->sadb_x_satype_exttype = SADB_X_EXT_SATYPE2;
@@ -1069,7 +1069,7 @@ pfkey_x_debug_build(struct sadb_ext**     pfkey_ext,
                        "why is pfkey_x_debug already pointing to something?\n");
                SENDERR(EINVAL);
        }
-       
+
        DEBUGGING(
                "pfkey_x_debug_build: "
                "tunnel=%x netlink=%x xform=%x eroute=%x spi=%x radij=%x esp=%x ah=%x rcv=%x pfkey=%x ipcomp=%x verbose=%x?\n",
@@ -1090,7 +1090,7 @@ pfkey_x_debug_build(struct sadb_ext**     pfkey_ext,
               0,
               sizeof(struct sadb_x_debug));
 #endif
-       
+
         pfkey_x_debug->sadb_x_debug_len = sizeof(struct sadb_x_debug) / IPSEC_PFKEYv2_ALIGN;
        pfkey_x_debug->sadb_x_debug_exttype = SADB_X_EXT_DEBUG;
 
@@ -1132,7 +1132,7 @@ pfkey_x_nat_t_type_build(struct sadb_ext**        pfkey_ext,
                        "why is pfkey_x_nat_t_type already pointing to something?\n");
                SENDERR(EINVAL);
        }
-       
+
        DEBUGGING(
                "pfkey_x_nat_t_type_build: "
                "type=%d\n", type);
@@ -1147,7 +1147,7 @@ pfkey_x_nat_t_type_build(struct sadb_ext**        pfkey_ext,
                        "memory allocation failed\n");
                SENDERR(ENOMEM);
        }
-       
+
        pfkey_x_nat_t_type->sadb_x_nat_t_type_len = sizeof(struct sadb_x_nat_t_type) / IPSEC_PFKEYv2_ALIGN;
        pfkey_x_nat_t_type->sadb_x_nat_t_type_exttype = SADB_X_EXT_NAT_T_TYPE;
        pfkey_x_nat_t_type->sadb_x_nat_t_type_type = type;
@@ -1176,17 +1176,17 @@ pfkey_x_nat_t_port_build(struct sadb_ext**      pfkey_ext,
                        "why is pfkey_x_nat_t_port already pointing to something?\n");
                SENDERR(EINVAL);
        }
-       
-       switch (exttype) {      
+
+       switch (exttype) {
        case SADB_X_EXT_NAT_T_SPORT:
        case SADB_X_EXT_NAT_T_DPORT:
                break;
        default:
-               DEBUGGING( 
+               DEBUGGING(
                        "pfkey_nat_t_port_build: "
-                       "unrecognised ext_type=%d.\n", 
-                       exttype); 
-               SENDERR(EINVAL); 
+                       "unrecognised ext_type=%d.\n",
+                       exttype);
+               SENDERR(EINVAL);
        }
 
        DEBUGGING(
@@ -1203,7 +1203,7 @@ pfkey_x_nat_t_port_build(struct sadb_ext**        pfkey_ext,
                        "memory allocation failed\n");
                SENDERR(ENOMEM);
        }
-       
+
        pfkey_x_nat_t_port->sadb_x_nat_t_port_len = sizeof(struct sadb_x_nat_t_port) / IPSEC_PFKEYv2_ALIGN;
        pfkey_x_nat_t_port->sadb_x_nat_t_port_exttype = exttype;
        pfkey_x_nat_t_port->sadb_x_nat_t_port_port = port;
@@ -1281,7 +1281,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
        struct sadb_ext *pfkey_ext;
        int extensions_seen = 0;
        struct sadb_ext *extensions_check[SADB_EXT_MAX + 1];
-       
+
        if (!extensions[0]) {
                DEBUGGING(
                        "pfkey_msg_build: "
@@ -1294,7 +1294,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
                if(extensions[ext]) {
                        total_size += (extensions[ext])->sadb_ext_len;
                }
-        }                
+        }
 
        if (!(*pfkey_msg = (struct sadb_msg*)MALLOC(total_size * IPSEC_PFKEYv2_ALIGN))) {
                DEBUGGING(
@@ -1320,14 +1320,14 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
 
        for (ext = 1; ext <= SADB_EXT_MAX; ext++) {
                /* copy from extension[ext] to buffer */
-               if (extensions[ext]) {    
+               if (extensions[ext]) {
                        /* Is this type of extension permitted for this type of message? */
                        if (!(extensions_bitmaps[dir][EXT_BITS_PERM][(*pfkey_msg)->sadb_msg_type] &
                             1<<ext)) {
                                DEBUGGING(
                                        "pfkey_msg_build: "
-                                       "ext type %d not permitted, exts_perm=%08x, 1<<type=%08x\n", 
-                                       ext, 
+                                       "ext type %d not permitted, exts_perm=%08x, 1<<type=%08x\n",
+                                       ext,
                                        extensions_bitmaps[dir][EXT_BITS_PERM][(*pfkey_msg)->sadb_msg_type],
                                        1<<ext);
                                SENDERR(EINVAL);
@@ -1342,7 +1342,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
                        memcpy(pfkey_ext,
                               extensions[ext],
                               (extensions[ext])->sadb_ext_len * IPSEC_PFKEYv2_ALIGN);
-                       {      
+                       {
                                char *pfkey_ext_c = (char *)pfkey_ext;
 
                                pfkey_ext_c += (extensions[ext])->sadb_ext_len * IPSEC_PFKEYv2_ALIGN;
@@ -1360,7 +1360,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
                extensions_bitmaps[dir][EXT_BITS_PERM][(*pfkey_msg)->sadb_msg_type],
                extensions_seen,
                extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]);
-       
+
        if ((extensions_seen &
            extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]) !=
            extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]) {
@@ -1372,7 +1372,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
                         extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]) );
                SENDERR(EINVAL);
        }
-       
+
        error = pfkey_msg_parse(*pfkey_msg, NULL, extensions_check, dir);
        if (error) {
                DEBUGGING(
index 0256e2a03aba725712df22537279b920deee5655..0217538a0b30055f71e8dd9d1ac6cb73ffd743c5 100644 (file)
@@ -3,12 +3,12 @@
  *
  * Copyright (C) 2001  Richard Guy Briggs  <rgb@freeswan.org>
  *                 and Michael Richardson  <mcr@freeswan.org>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@@ -22,7 +22,7 @@
 #include "pfkeyv2.h"
 #include "pfkey.h"
 
-/* 
+/*
  * This file provides ASCII translations of PF_KEY magic numbers.
  *
  */
index b6ef4496dad2aa265c7675a236d53105ec48ca97..49b4aa567aa4a0da0587a08c703af02a002262d7 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * RFC2367 PF_KEYv2 Key management API message parser
  * Copyright (C) 1999, 2000, 2001  Richard Guy Briggs.
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
index 7ee08978cf7a7c02e6f5c8e2f570360889f08cfd..49d5cdf4aadb9af8f645554e66635210ff39d94d 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * RFC2367 PF_KEYv2 Key management API message parser
  * Copyright (C) 1999, 2000, 2001  Richard Guy Briggs.
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@@ -107,7 +107,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
 #if 0
        struct sadb_sa sav2;
 #endif
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
                  "pfkey_sa_parse: entry\n");
        /* sanity checks... */
@@ -117,7 +117,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          "NULL pointer passed in.\n");
                SENDERR(EINVAL);
        }
-       
+
 #if 0
        /* check if this structure is short, and if so, fix it up.
         * XXX this is NOT the way to do things.
@@ -129,7 +129,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                memcpy(&sav2, pfkey_sa, sizeof(struct sadb_sa_v1));
                sav2.sadb_x_sa_ref=-1;
                sav2.sadb_sa_len = sizeof(struct sadb_sa) / IPSEC_PFKEYv2_ALIGN;
-               
+
                pfkey_sa = &sav2;
        }
 #endif
@@ -143,7 +143,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          (int)sizeof(struct sadb_sa));
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_sa->sadb_sa_encrypt > SADB_EALG_MAX) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_sa_parse: "
@@ -152,7 +152,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          SADB_EALG_MAX);
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_sa->sadb_sa_auth > SADB_AALG_MAX) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_sa_parse: "
@@ -161,7 +161,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          SADB_AALG_MAX);
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_sa->sadb_sa_state > SADB_SASTATE_MAX) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_sa_parse: "
@@ -170,7 +170,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          SADB_SASTATE_MAX);
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_sa->sadb_sa_state == SADB_SASTATE_DEAD) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_sa_parse: "
@@ -179,7 +179,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          SADB_SASTATE_DEAD);
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_sa->sadb_sa_replay > 64) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_sa_parse: "
@@ -187,7 +187,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          pfkey_sa->sadb_sa_replay);
                SENDERR(EINVAL);
        }
-       
+
        if(! ((pfkey_sa->sadb_sa_exttype ==  SADB_EXT_SA) ||
              (pfkey_sa->sadb_sa_exttype ==  SADB_X_EXT_SA2)))
        {
@@ -209,7 +209,7 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                          IPSEC_SA_REF_TABLE_NUM_ENTRIES);
                SENDERR(EINVAL);
        }
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
                  "pfkey_sa_parse: "
                  "successfully found len=%d exttype=%d(%s) spi=%08lx replay=%d state=%d auth=%d encrypt=%d flags=%d ref=%d.\n",
@@ -223,10 +223,10 @@ pfkey_sa_parse(struct sadb_ext *pfkey_ext)
                  pfkey_sa->sadb_sa_encrypt,
                  pfkey_sa->sadb_sa_flags,
                  pfkey_sa->sadb_x_sa_ref);
-       
+
  errlab:
        return error;
-}      
+}
 
 DEBUG_NO_STATIC int
 pfkey_lifetime_parse(struct sadb_ext  *pfkey_ext)
@@ -259,21 +259,21 @@ pfkey_lifetime_parse(struct sadb_ext  *pfkey_ext)
           (pfkey_lifetime->sadb_lifetime_exttype != SADB_EXT_LIFETIME_CURRENT)) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_lifetime_parse: "
-                         "unexpected ext_type=%d.\n", 
-                         pfkey_lifetime->sadb_lifetime_exttype); 
+                         "unexpected ext_type=%d.\n",
+                         pfkey_lifetime->sadb_lifetime_exttype);
                SENDERR(EINVAL);
        }
 
        DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
                  "pfkey_lifetime_parse: "
-                 "life_type=%d(%s) alloc=%u bytes=%u add=%u use=%u pkts=%u.\n", 
+                 "life_type=%d(%s) alloc=%u bytes=%u add=%u use=%u pkts=%u.\n",
                  pfkey_lifetime->sadb_lifetime_exttype,
                  pfkey_v2_sadb_ext_string(pfkey_lifetime->sadb_lifetime_exttype),
                  pfkey_lifetime->sadb_lifetime_allocations,
                  (unsigned)pfkey_lifetime->sadb_lifetime_bytes,
                  (unsigned)pfkey_lifetime->sadb_lifetime_addtime,
                  (unsigned)pfkey_lifetime->sadb_lifetime_usetime,
-                 pfkey_lifetime->sadb_x_lifetime_packets); 
+                 pfkey_lifetime->sadb_x_lifetime_packets);
 errlab:
        return error;
 }
@@ -286,7 +286,7 @@ pfkey_address_parse(struct sadb_ext *pfkey_ext)
        struct sadb_address *pfkey_address = (struct sadb_address *)pfkey_ext;
        struct sockaddr* s = (struct sockaddr*)((char*)pfkey_address + sizeof(*pfkey_address));
        char ipaddr_txt[ADDRTOT_BUF];
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
                "pfkey_address_parse:enter\n");
        /* sanity checks... */
@@ -296,7 +296,7 @@ pfkey_address_parse(struct sadb_ext *pfkey_ext)
                        "NULL pointer passed in.\n");
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_address->sadb_address_len <
           (sizeof(struct sadb_address) + sizeof(struct sockaddr))/
           IPSEC_PFKEYv2_ALIGN) {
@@ -308,7 +308,7 @@ pfkey_address_parse(struct sadb_ext *pfkey_ext)
                          (int)sizeof(struct sockaddr));
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_address->sadb_address_reserved) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_address_parse: "
@@ -316,8 +316,8 @@ pfkey_address_parse(struct sadb_ext *pfkey_ext)
                          pfkey_address->sadb_address_reserved);
                SENDERR(EINVAL);
        }
-       
-       switch(pfkey_address->sadb_address_exttype) {   
+
+       switch(pfkey_address->sadb_address_exttype) {
        case SADB_EXT_ADDRESS_SRC:
        case SADB_EXT_ADDRESS_DST:
        case SADB_EXT_ADDRESS_PROXY:
@@ -329,7 +329,7 @@ pfkey_address_parse(struct sadb_ext *pfkey_ext)
        case SADB_X_EXT_NAT_T_OA:
                break;
        default:
-               DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM, 
+               DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_address_parse: "
                        "unexpected ext_type=%d.\n",
                        pfkey_address->sadb_address_exttype);
@@ -382,7 +382,7 @@ pfkey_address_parse(struct sadb_ext *pfkey_ext)
                        s->sa_family);
                SENDERR(EPFNOSUPPORT);
        }
-       
+
        if(pfkey_address->sadb_address_len !=
           DIVUP(sizeof(struct sadb_address) + saddr_len, IPSEC_PFKEYv2_ALIGN)) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
@@ -393,16 +393,16 @@ pfkey_address_parse(struct sadb_ext *pfkey_ext)
                          saddr_len);
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_address->sadb_address_prefixlen != 0) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_address_parse: "
                        "address prefixes not supported yet.\n");
                SENDERR(EAFNOSUPPORT); /* not supported yet */
        }
-       
+
        /* XXX check if port!=0 */
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
                "pfkey_address_parse: successful.\n");
  errlab:
@@ -452,7 +452,7 @@ pfkey_key_parse(struct sadb_ext *pfkey_ext)
                        pfkey_key->sadb_key_len);
                SENDERR(EINVAL);
        }
-       
+
        if(pfkey_key->sadb_key_reserved) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_key_parse: "
@@ -527,7 +527,7 @@ pfkey_ident_parse(struct sadb_ext *pfkey_ext)
                        SENDERR(EINVAL);
                }
        }
-       
+
        if( ! ((pfkey_ident->sadb_ident_exttype == SADB_EXT_IDENTITY_SRC) ||
               (pfkey_ident->sadb_ident_exttype == SADB_EXT_IDENTITY_DST))) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
@@ -578,7 +578,7 @@ pfkey_prop_parse(struct sadb_ext *pfkey_ext)
        struct sadb_comb *pfkey_comb = (struct sadb_comb *)((char*)pfkey_ext + sizeof(struct sadb_prop));
 
        /* sanity checks... */
-       if((pfkey_prop->sadb_prop_len < sizeof(struct sadb_prop) / IPSEC_PFKEYv2_ALIGN) || 
+       if((pfkey_prop->sadb_prop_len < sizeof(struct sadb_prop) / IPSEC_PFKEYv2_ALIGN) ||
           (((pfkey_prop->sadb_prop_len * IPSEC_PFKEYv2_ALIGN) - sizeof(struct sadb_prop)) % sizeof(struct sadb_comb))) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_prop_parse: "
@@ -596,7 +596,7 @@ pfkey_prop_parse(struct sadb_ext *pfkey_ext)
                        pfkey_prop->sadb_prop_replay);
                SENDERR(EINVAL);
        }
-       
+
        for(i=0; i<3; i++) {
                if(pfkey_prop->sadb_prop_reserved[i]) {
                        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
@@ -869,7 +869,7 @@ pfkey_supported_parse(struct sadb_ext *pfkey_ext)
                }
                pfkey_alg++;
        }
-       
+
  errlab:
        return error;
 }
@@ -879,7 +879,7 @@ pfkey_spirange_parse(struct sadb_ext *pfkey_ext)
 {
        int error = 0;
        struct sadb_spirange *pfkey_spirange = (struct sadb_spirange *)pfkey_ext;
-       
+
        /* sanity checks... */
         if(pfkey_spirange->sadb_spirange_len !=
           sizeof(struct sadb_spirange) / IPSEC_PFKEYv2_ALIGN) {
@@ -890,7 +890,7 @@ pfkey_spirange_parse(struct sadb_ext *pfkey_ext)
                          (int)sizeof(struct sadb_spirange));
                 SENDERR(EINVAL);
         }
-       
+
         if(pfkey_spirange->sadb_spirange_reserved) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_spirange_parse: "
@@ -898,7 +898,7 @@ pfkey_spirange_parse(struct sadb_ext *pfkey_ext)
                        pfkey_spirange->sadb_spirange_reserved);
                 SENDERR(EINVAL);
         }
-       
+
         if(ntohl(pfkey_spirange->sadb_spirange_max) < ntohl(pfkey_spirange->sadb_spirange_min)) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_spirange_parse: "
@@ -907,7 +907,7 @@ pfkey_spirange_parse(struct sadb_ext *pfkey_ext)
                        ntohl(pfkey_spirange->sadb_spirange_max));
                 SENDERR(EINVAL);
         }
-       
+
        if(ntohl(pfkey_spirange->sadb_spirange_min) <= 255) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_spirange_parse: "
@@ -915,7 +915,7 @@ pfkey_spirange_parse(struct sadb_ext *pfkey_ext)
                        ntohl(pfkey_spirange->sadb_spirange_min));
                SENDERR(EEXIST);
        }
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
                  "pfkey_spirange_parse: "
                  "ext_len=%u ext_type=%u(%s) min=%u max=%u res=%u.\n",
@@ -983,7 +983,7 @@ pfkey_x_satype_parse(struct sadb_ext *pfkey_ext)
                          (int)sizeof(struct sadb_x_satype));
                SENDERR(EINVAL);
        }
-       
+
        if(!pfkey_x_satype->sadb_x_satype_satype) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_x_satype_parse: "
@@ -994,7 +994,7 @@ pfkey_x_satype_parse(struct sadb_ext *pfkey_ext)
        if(pfkey_x_satype->sadb_x_satype_satype > SADB_SATYPE_MAX) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_x_satype_parse: "
-                       "satype %d > max %d, invalid.\n", 
+                       "satype %d > max %d, invalid.\n",
                        pfkey_x_satype->sadb_x_satype_satype, SADB_SATYPE_MAX);
                SENDERR(EINVAL);
        }
@@ -1016,7 +1016,7 @@ pfkey_x_satype_parse(struct sadb_ext *pfkey_ext)
                        SENDERR(EINVAL);
                }
        }
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
                  "pfkey_x_satype_parse: "
                  "len=%u ext=%u(%s) satype=%u(%s) res=%u,%u,%u.\n",
@@ -1051,7 +1051,7 @@ pfkey_x_ext_debug_parse(struct sadb_ext *pfkey_ext)
                          (int)sizeof(struct sadb_x_debug));
                SENDERR(EINVAL);
        }
-       
+
        for(i = 0; i < 4; i++) {
                if(pfkey_x_debug->sadb_x_debug_reserved[i]) {
                        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
@@ -1061,7 +1061,7 @@ pfkey_x_ext_debug_parse(struct sadb_ext *pfkey_ext)
                        SENDERR(EINVAL);
                }
        }
-       
+
 errlab:
        return error;
 }
@@ -1071,17 +1071,17 @@ pfkey_x_ext_protocol_parse(struct sadb_ext *pfkey_ext)
 {
        int error = 0;
        struct sadb_protocol *p = (struct sadb_protocol *)pfkey_ext;
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM, "pfkey_x_protocol_parse:\n");
        /* sanity checks... */
-       
+
        if (p->sadb_protocol_len != sizeof(*p)/IPSEC_PFKEYv2_ALIGN) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_x_protocol_parse: size wrong ext_len=%d, key_ext_len=%d.\n",
                          p->sadb_protocol_len, (int)sizeof(*p));
                SENDERR(EINVAL);
        }
-       
+
        if (p->sadb_protocol_reserved2 != 0) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                          "pfkey_protocol_parse: res=%d, must be zero.\n",
@@ -1168,10 +1168,10 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
        int remain;
        struct sadb_ext *pfkey_ext;
        int extensions_seen = 0;
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
                  "pfkey_msg_parse: "
-                 "parsing message ver=%d, type=%d(%s), errno=%d, satype=%d(%s), len=%d, res=%d, seq=%d, pid=%d.\n", 
+                 "parsing message ver=%d, type=%d(%s), errno=%d, satype=%d(%s), len=%d, res=%d, seq=%d, pid=%d.\n",
                  pfkey_msg->sadb_msg_version,
                  pfkey_msg->sadb_msg_type,
                  pfkey_v2_sadb_type_string(pfkey_msg->sadb_msg_type),
@@ -1182,20 +1182,20 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                  pfkey_msg->sadb_msg_reserved,
                  pfkey_msg->sadb_msg_seq,
                  pfkey_msg->sadb_msg_pid);
-       
+
        if(ext_parsers == NULL) ext_parsers = ext_default_parsers;
-       
+
        pfkey_extensions_init(extensions);
-       
+
        remain = pfkey_msg->sadb_msg_len;
        remain -= sizeof(struct sadb_msg) / IPSEC_PFKEYv2_ALIGN;
-       
+
        pfkey_ext = (struct sadb_ext*)((char*)pfkey_msg +
                                       sizeof(struct sadb_msg));
-       
+
        extensions[0] = (struct sadb_ext *) pfkey_msg;
-       
-       
+
+
        if(pfkey_msg->sadb_msg_version != PF_KEY_V2) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_msg_parse: "
@@ -1261,7 +1261,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
        default:
                break;
        }
-       
+
        /* errno must not be set in downward messages */
        /* this is not entirely true... a response to an ACQUIRE could return an error */
        if((dir == EXT_BITS_IN) && (pfkey_msg->sadb_msg_type != SADB_ACQUIRE) && pfkey_msg->sadb_msg_errno) {
@@ -1274,54 +1274,54 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
 
        DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
                  "pfkey_msg_parse: "
-                 "remain=%d, ext_type=%d(%s), ext_len=%d.\n", 
+                 "remain=%d, ext_type=%d(%s), ext_len=%d.\n",
                  remain,
                  pfkey_ext->sadb_ext_type,
                  pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type),
                  pfkey_ext->sadb_ext_len);
-       
+
        DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
                "pfkey_msg_parse: "
                "extensions permitted=%08x, required=%08x.\n",
                extensions_bitmaps[dir][EXT_BITS_PERM][pfkey_msg->sadb_msg_type],
                extensions_bitmaps[dir][EXT_BITS_REQ][pfkey_msg->sadb_msg_type]);
-       
+
        extensions_seen = 1;
-       
+
        while( (remain * IPSEC_PFKEYv2_ALIGN) >= sizeof(struct sadb_ext) ) {
                /* Is there enough message left to support another extension header? */
                if(remain < pfkey_ext->sadb_ext_len) {
                        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                                "pfkey_msg_parse: "
-                               "remain %d less than ext len %d.\n", 
+                               "remain %d less than ext len %d.\n",
                                remain, pfkey_ext->sadb_ext_len);
                        SENDERR(EINVAL);
                }
-               
+
                DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
                        "pfkey_msg_parse: "
                        "parsing ext type=%d(%s) remain=%d.\n",
                        pfkey_ext->sadb_ext_type,
                        pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type),
                        remain);
-               
+
                /* Is the extension header type valid? */
                if((pfkey_ext->sadb_ext_type > SADB_EXT_MAX) || (!pfkey_ext->sadb_ext_type)) {
                        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                                "pfkey_msg_parse: "
-                               "ext type %d(%s) invalid, SADB_EXT_MAX=%d.\n", 
+                               "ext type %d(%s) invalid, SADB_EXT_MAX=%d.\n",
                                pfkey_ext->sadb_ext_type,
                                pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type),
                                SADB_EXT_MAX);
                        SENDERR(EINVAL);
                }
-               
+
                /* Have we already seen this type of extension? */
                if((extensions_seen & ( 1 << pfkey_ext->sadb_ext_type )) != 0)
                {
                        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                                "pfkey_msg_parse: "
-                               "ext type %d(%s) already seen.\n", 
+                               "ext type %d(%s) already seen.\n",
                                pfkey_ext->sadb_ext_type,
                                pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type));
                        SENDERR(EINVAL);
@@ -1331,7 +1331,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                if(ext_parsers[pfkey_ext->sadb_ext_type]==NULL) {
                        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                                "pfkey_msg_parse: "
-                               "ext type %d(%s) unknown, ignoring.\n", 
+                               "ext type %d(%s) unknown, ignoring.\n",
                                pfkey_ext->sadb_ext_type,
                                pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type));
                        goto next_ext;
@@ -1342,8 +1342,8 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                     1<<pfkey_ext->sadb_ext_type)) {
                        DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                                "pfkey_msg_parse: "
-                               "ext type %d(%s) not permitted, exts_perm_in=%08x, 1<<type=%08x\n", 
-                               pfkey_ext->sadb_ext_type, 
+                               "ext type %d(%s) not permitted, exts_perm_in=%08x, 1<<type=%08x\n",
+                               pfkey_ext->sadb_ext_type,
                                pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type),
                                extensions_bitmaps[dir][EXT_BITS_PERM][pfkey_msg->sadb_msg_type],
                                1<<pfkey_ext->sadb_ext_type);
@@ -1359,7 +1359,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                          pfkey_ext->sadb_ext_len,
                          pfkey_ext,
                          ext_parsers[pfkey_ext->sadb_ext_type]->parser_name);
-               
+
                /* Parse the extension */
                if((error =
                    (*ext_parsers[pfkey_ext->sadb_ext_type]->parser)(pfkey_ext))) {
@@ -1368,7 +1368,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                                "extension parsing for type %d(%s) failed with error %d.\n",
                                pfkey_ext->sadb_ext_type,
                                pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type),
-                               error); 
+                               error);
                        SENDERR(-error);
                }
                DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
@@ -1376,12 +1376,12 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                        "Extension %d(%s) parsed.\n",
                        pfkey_ext->sadb_ext_type,
                        pfkey_v2_sadb_ext_string(pfkey_ext->sadb_ext_type));
-               
+
                /* Mark that we have seen this extension and remember the header location */
                extensions_seen |= ( 1 << pfkey_ext->sadb_ext_type );
                extensions[pfkey_ext->sadb_ext_type] = pfkey_ext;
 
-       next_ext:               
+       next_ext:
                /* Calculate how much message remains */
                remain -= pfkey_ext->sadb_ext_len;
 
@@ -1396,7 +1396,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
        if(remain) {
                DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
                        "pfkey_msg_parse: "
-                       "unexpected remainder of %d.\n", 
+                       "unexpected remainder of %d.\n",
                        remain);
                /* why is there still something remaining? */
                SENDERR(EINVAL);
@@ -1427,7 +1427,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                         extensions_bitmaps[dir][EXT_BITS_REQ][pfkey_msg->sadb_msg_type]));
                SENDERR(EINVAL);
        }
-       
+
        if((dir == EXT_BITS_IN) && (pfkey_msg->sadb_msg_type == SADB_X_DELFLOW)
           && ((extensions_seen & SADB_X_EXT_ADDRESS_DELFLOW)
               != SADB_X_EXT_ADDRESS_DELFLOW)
@@ -1443,7 +1443,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                        (1<<SADB_EXT_SA) - (extensions_seen & (1<<SADB_EXT_SA)));
                SENDERR(EINVAL);
        }
-       
+
        switch(pfkey_msg->sadb_msg_type) {
        case SADB_ADD:
        case SADB_UPDATE:
@@ -1457,7 +1457,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                                SADB_SASTATE_MATURE);
                        SENDERR(EINVAL);
                }
-               
+
                /* check AH and ESP */
                switch(((struct sadb_msg*)extensions[SADB_EXT_RESERVED])->sadb_msg_satype) {
                case SADB_SATYPE_AH:
@@ -1529,7 +1529,7 @@ pfkey_msg_parse(struct sadb_msg *pfkey_msg,
                                ntohl(((struct sadb_sa*)(extensions[SADB_EXT_SA]))->sadb_sa_spi));
                        SENDERR(EINVAL);
                }
-       default:        
+       default:
                break;
        }
 errlab:
index 461299c787602f71fbb0fa20fe490609ea99e4c0..8a30d1edb1a65c91da248f72c608d44aa809833d 100644 (file)
@@ -182,7 +182,7 @@ struct sadb_x_satype {
   uint8_t sadb_x_satype_satype;
   uint8_t sadb_x_satype_reserved[3];
 };
-  
+
 struct sadb_x_policy {
   uint16_t sadb_x_policy_len;
   uint16_t sadb_x_policy_exttype;
@@ -192,7 +192,7 @@ struct sadb_x_policy {
   uint32_t sadb_x_policy_id;
   uint32_t sadb_x_policy_reserved2;
 };
+
 struct sadb_x_debug {
   uint16_t sadb_x_debug_len;
   uint16_t sadb_x_debug_exttype;
index 6d06473ad2bd9036a448a243246fa4a154be6459..c44b839f3e903912787c0f1605127f6b704453fc 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * low-level ip_address ugliness
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 6cb84e48463ebac7398f02c2e4b103ecac0c7526..347f13f893192474565e600d06ca20a27da3778d 100644 (file)
@@ -2,12 +2,12 @@
  * crypto-class pseudorandom number generator
  * currently uses same algorithm as RC4(TM), from Schneier 2nd ed p397
  * Copyright (C) 2002  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index c5a7ddfda92fcf0b6abe78701f6fc8df889d13ef..70455824814cadad9b4280894086f45c06eb3e01 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert binary form of address range to ASCII
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 0defa0739962d0f627ac6181523511c66f919398..2a989300e18c32e55f16921b319275d1bcdd5780 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * express an address range as a subnet (if possible)
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 653b94c30a7884e4d1319d0da99e55d26c4934dd..47daaa4eeee433c4420e47b946b5b38f57337bdc 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * comparisons
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index fe7fb2ea0d195150ae61da39730b3c7a0e520e68..09a152727fd4ce02a4febf1985c810eac04ec5f2 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from binary form of SA ID to ASCII
  * Copyright (C) 1998, 1999, 2001  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index a16d62840f37517a11ba5530d5ecc73afabdf68a..e70036482fd09e960a05d8923d1fc3b6db9adf46 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from binary form of SA ID to text
  * Copyright (C) 2000, 2001  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
@@ -91,7 +91,7 @@ size_t dstlen;
                                                        PASSTHROUGH6NAME);
                len = strlen(buf);
        }
-       
+
        if (sa->proto == SA_INT && addrtypeof(&sa->dst) == AF_INET &&
                                                isunspecaddr(&sa->dst)) {
                switch (ntohl(sa->spi)) {
index 55786a2e414af8eeb3770b6dfaa56e9295eae03d..ec9b8ec7d536126ab39e61e515c932fc51db4733 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * minor network-address manipulation utilities
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index e8d98168d4672c901d21db4c46b11cec8ec64139..694fa40daa8a5bd77b1043126c0b77d7f9c8d436 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert binary form of subnet description to ASCII
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 03d2e1e5741d578864a41f505bacacd4fd60692c..64d511ba2397578ecb30ed3fc9f580235cbc9e84 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert binary form of subnet description to text
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 9fa15a7d58b26e2e267973d51e2b5792affda8f1..96c283c04af9fea298fce15733ba4402a3af9221 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * extract parts of an ip_subnet, and related
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index bda2be5ed88efb3d718295e287ab0005be94f16d..234c9d8e71700e758dd31a8ed87752057917ea6b 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * conversion from text forms of addresses to internal ones
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
@@ -61,7 +61,7 @@ ip_address *dst;
        case AF_INET6:
        case 0:                  /* guess */
                break;
-           
+
        default:
                return "invalid address family";
        }
@@ -78,7 +78,7 @@ ip_address *dst;
            {
                af = AF_INET6;
            }
-           
+
                if (af != AF_INET6)
                        return "non-ipv6 address may not contain `:'";
                return colon(src, srclen, dst);
@@ -127,7 +127,7 @@ ip_address *dst;
                }
                return "does not appear to be either IPv4 or IPv6 numeric address";
                break;
-           
+
        case AF_INET6:
                return colon(src, srclen, dst);
                break;
index b0d5e4d01a4daec8db1d22e2943e5ea7884d9284..ef3717797039cc9342830a215fdb1ad6e25d9c64 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from text form of arbitrary data (e.g., keys) to binary
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
@@ -125,7 +125,7 @@ unsigned int flags;
                        else if (!(skipSpace && (*src == ' ' || *src == '\t')))
                                stage[sl++] = *src;
                }
-               
+
                nbytes = (*decode)(stage, buf, sizeof(buf));
                switch (nbytes) {
                case BADCH0:
@@ -229,7 +229,7 @@ size_t dstlen;              /* not large enough is a failure */
 
        if (dstlen < 1)
                return SHORT;
-       
+
        p = strchr(hex, *src);
        if (p == NULL)
                p = strchr(hex, tolower(*src));
@@ -659,7 +659,7 @@ char *pgm;
                                break;
                        }
                }
-               
+
                if (base >= IGNORESPACE_BIAS) {
                        base = base - IGNORESPACE_BIAS;
                        check(r, buf, n, ttodatav(r->ascii, 0, base, buf, sizeof(buf), &n, NULL, 0, TTODATAV_IGNORESPACE), &status);
index c3d033168ea72b54385cfb9ef8e2a702d9d19a5f..e75b206be3bc7adad10a1a4c66276ef91add2217 100644 (file)
@@ -72,7 +72,7 @@ bool *has_port_wildcard;      /* set if port is %any */
 
     /* is there a port wildcard? */
     *has_port_wildcard = (strcmp(service_name, "%any") == 0);
-   
+
     if (*has_port_wildcard)
     {
        *port = 0;
index 20e01b152b5748ae87b9ec6d9447b33f6284175e..9873231c0d53ecc54bc523b5a2300b7b2083a213 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from text form of SA ID to binary
  * Copyright (C) 2000, 2001  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 36c039a96778dfe1a181e7d06e3571623d74cb2e..a18a3f32626f8c2880d41f56d3a1cd52e08be033 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from text form of subnet specification to binary
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 853a6130c0b8bd45c13453f89cf8f4fddc3b0904..7524789c4996c52ffbbb4937acbc9738c5083100 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert from text form of unsigned long to binary
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index ef45366a1cbbcf934f120d16d4d2a25d0e60f1f8..16ddd2c1e9fce157cb640fc046b41691aeffb255 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert unsigned long to ASCII
  * Copyright (C) 1998, 1999  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index c4f2d78842a61f72323f80fb9a67c523d46f9eb7..6685f8f7c0ee62bafb1ac7ead7b96f760e479591 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * convert unsigned long to text
  * Copyright (C) 2000  Henry Spencer.
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
index 2d402f72a4bb737712aa15aa2f4ee1aa3537b39a..69bb6523f436be58b4cbdbdaeb0467503a01d2e1 100644 (file)
@@ -44,7 +44,7 @@ const chunk_t ASN1_INTEGER_2 = chunk_from_buf(ASN1_INTEGER_2_str);
 chunk_t asn1_algorithmIdentifier(int oid)
 {
        chunk_t parameters;
-       
+
        /* some algorithmIdentifiers have a NULL parameters field and some do not */
        switch (oid)
        {
@@ -68,7 +68,7 @@ chunk_t asn1_algorithmIdentifier(int oid)
 int asn1_known_oid(chunk_t object)
 {
        int oid = 0;
-       
+
        while (object.len)
        {
                if (oid_names[oid].octet == *object.ptr)
@@ -104,17 +104,17 @@ chunk_t asn1_build_known_oid(int n)
 {
        chunk_t oid;
        int i;
-       
+
        if (n < 0 || n >= OID_MAX)
        {
                return chunk_empty;
        }
-       
+
        i = oid_names[n].level + 1;
        oid = chunk_alloc(2 + i);
        oid.ptr[0] = ASN1_OID;
        oid.ptr[1] = i;
-       
+
        do
        {
                if (oid_names[n].level >= i)
@@ -125,7 +125,7 @@ chunk_t asn1_build_known_oid(int n)
                oid.ptr[--i + 2] = oid_names[n--].octet;
        }
        while (i > 0);
-       
+
        return oid;
 }
 
@@ -136,18 +136,18 @@ size_t asn1_length(chunk_t *blob)
 {
        u_char n;
        size_t len;
-       
+
        if (blob->len < 2)
        {
                DBG2("insufficient number of octets to parse ASN.1 length");
                return ASN1_INVALID_LENGTH;
        }
-       
+
        /* read length field, skip tag and length */
        n = blob->ptr[1];
        *blob = chunk_skip(*blob, 2);
-       
-       if ((n & 0x80) == 0) 
+
+       if ((n & 0x80) == 0)
        {       /* single length octet */
                if (n > blob->len)
                {
@@ -156,25 +156,25 @@ size_t asn1_length(chunk_t *blob)
                }
                return n;
        }
-       
+
        /* composite length, determine number of length octets */
        n &= 0x7f;
-       
+
        if (n == 0 || n > blob->len)
        {
                DBG2("number of length octets invalid");
                return ASN1_INVALID_LENGTH;
        }
-       
+
        if (n > sizeof(len))
        {
-               DBG2("number of length octets is larger than limit of %d octets", 
+               DBG2("number of length octets is larger than limit of %d octets",
                         (int)sizeof(len));
                return ASN1_INVALID_LENGTH;
        }
-       
+
        len = 0;
-       
+
        while (n-- > 0)
        {
                len = 256*len + *blob->ptr++;
@@ -196,7 +196,7 @@ int asn1_unwrap(chunk_t *blob, chunk_t *inner)
        chunk_t res;
        u_char len;
        int type;
-       
+
        if (blob->len < 2)
        {
                return ASN1_INVALID;
@@ -204,7 +204,7 @@ int asn1_unwrap(chunk_t *blob, chunk_t *inner)
        type = blob->ptr[0];
        len = blob->ptr[1];
        *blob = chunk_skip(*blob, 2);
-       
+
        if ((len & 0x80) == 0)
        {       /* single length octet */
                res.len = len;
@@ -250,7 +250,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
        int tz_hour, tz_min, tz_offset;
        time_t tm_secs;
        u_char *eot = NULL;
-       
+
        if ((eot = memchr(utctime->ptr, 'Z', utctime->len)) != NULL)
        {
                tz_offset = 0; /* Zulu time with a zero time zone offset */
@@ -275,19 +275,19 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
        {
                return 0; /* error in time format */
        }
-       
+
        /* parse ASN.1 time string */
        {
                const char* format = (type == ASN1_UTCTIME)? "%2d%2d%2d%2d%2d":
                                                                                                         "%4d%2d%2d%2d%2d";
-       
+
                if (sscanf(utctime->ptr, format, &tm_year, &tm_mon, &tm_day,
                                                                                 &tm_hour, &tm_min) != 5)
                {
                        return 0; /* error in [yy]yymmddhhmm time format */
                }
        }
-       
+
        /* is there a seconds field? */
        if ((eot - utctime->ptr) == ((type == ASN1_UTCTIME)?12:14))
        {
@@ -300,13 +300,13 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
        {
                tm_sec = 0;
        }
-       
+
        /* representation of two-digit years */
        if (type == ASN1_UTCTIME)
        {
                tm_year += (tm_year < 50) ? 2000 : 1900;
        }
-       
+
        /* prevent large 32 bit integer overflows */
        if (sizeof(time_t) == 4 && tm_year > 2038)
        {
@@ -319,7 +319,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
                return 0; /* error in month format */
        }
        tm_mon--;
-       
+
        /* representation of days as 0..30 */
        tm_day--;
 
@@ -352,7 +352,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type)
        char buf[BUF_LEN];
        chunk_t formatted_time;
        struct tm t;
-       
+
        gmtime_r(time, &t);
        if (type == ASN1_GENERALIZEDTIME)
        {
@@ -364,7 +364,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type)
                format = "%02d%02d%02d%02d%02d%02dZ";
                offset = (t.tm_year < 100)? 0 : -100;
        }
-       snprintf(buf, BUF_LEN, format, t.tm_year + offset, 
+       snprintf(buf, BUF_LEN, format, t.tm_year + offset,
                         t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
        formatted_time.ptr = buf;
        formatted_time.len = strlen(buf);
@@ -377,7 +377,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type)
 void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
 {
        int oid;
-       
+
        switch (type)
        {
                case ASN1_OID:
@@ -422,30 +422,30 @@ void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
 bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level, const char* name)
 {
        size_t len;
-       
+
        /* an ASN.1 object must possess at least a tag and length field */
        if (object->len < 2)
        {
                DBG2("L%d - %s:  ASN.1 object smaller than 2 octets", level, name);
                return FALSE;
        }
-       
+
        if (*object->ptr != type)
        {
                DBG2("L%d - %s: ASN1 tag 0x%02x expected, but is 0x%02x",
                         level, name, type, *object->ptr);
                return FALSE;
        }
-       
+
        len = asn1_length(object);
-       
+
        if (len == ASN1_INVALID_LENGTH || object->len < len)
        {
                DBG2("L%d - %s:  length of ASN.1 object invalid or too large",
                         level, name);
                return FALSE;
        }
-       
+
        DBG2("L%d - %s:", level, name);
        asn1_debug_simple_object(*object, type, FALSE);
        return TRUE;
@@ -473,10 +473,10 @@ int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters
        chunk_t object;
        int objectID;
        int alg = OID_UNKNOWN;
-       
+
        parser = asn1_parser_create(algorithmIdentifierObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                switch (objectID)
@@ -538,7 +538,7 @@ bool asn1_is_printablestring(chunk_t str)
        const char printablestring_charset[] =
                "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 '()+,-./:=?";
        u_int i;
-       
+
        for (i = 0; i < str.len; i++)
        {
                if (strchr(printablestring_charset, str.ptr[i]) == NULL)
@@ -588,24 +588,24 @@ u_char* asn1_build_object(chunk_t *object, asn1_t type, size_t datalen)
        u_char length_buf[4];
        chunk_t length = { length_buf, 0 };
        u_char *pos;
-       
+
        /* code the asn.1 length field */
        asn1_code_length(datalen, &length);
-       
+
        /* allocate memory for the asn.1 TLV object */
        object->len = 1 + length.len + datalen;
        object->ptr = malloc(object->len);
-       
+
        /* set position pointer at the start of the object */
        pos = object->ptr;
-       
+
        /* copy the asn.1 tag field and advance the pointer */
        *pos++ = type;
-       
+
        /* copy the asn.1 length field and advance the pointer */
-       memcpy(pos, length.ptr, length.len); 
+       memcpy(pos, length.ptr, length.len);
        pos += length.len;
-       
+
        return pos;
 }
 
@@ -615,11 +615,11 @@ u_char* asn1_build_object(chunk_t *object, asn1_t type, size_t datalen)
 chunk_t asn1_simple_object(asn1_t tag, chunk_t content)
 {
        chunk_t object;
-       
+
        u_char *pos = asn1_build_object(&object, tag, content.len);
-       memcpy(pos, content.ptr, content.len); 
+       memcpy(pos, content.ptr, content.len);
        pos += content.len;
-       
+
        return object;
 }
 
@@ -686,8 +686,8 @@ chunk_t asn1_wrap(asn1_t type, const char *mode, ...)
        u_char *pos;
        int i;
        int count = strlen(mode);
-       
-       /* sum up lengths of individual chunks */ 
+
+       /* sum up lengths of individual chunks */
        va_start(chunks, mode);
        construct.len = 0;
        for (i = 0; i < count; i++)
@@ -696,16 +696,16 @@ chunk_t asn1_wrap(asn1_t type, const char *mode, ...)
                construct.len += ch.len;
        }
        va_end(chunks);
-       
+
        /* allocate needed memory for construct */
        pos = asn1_build_object(&construct, type, construct.len);
-       
+
        /* copy or move the chunks */
        va_start(chunks, mode);
        for (i = 0; i < count; i++)
        {
                chunk_t ch = va_arg(chunks, chunk_t);
-               
+
                memcpy(pos, ch.ptr, ch.len);
                pos += ch.len;
 
@@ -722,7 +722,7 @@ chunk_t asn1_wrap(asn1_t type, const char *mode, ...)
                }
        }
        va_end(chunks);
-       
+
        return construct;
 }
 
@@ -748,10 +748,10 @@ time_t asn1_parse_time(chunk_t blob, int level0)
        chunk_t object;
        int objectID;
        time_t utc_time = 0;
-       
+
        parser= asn1_parser_create(timeObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                if (objectID == TIME_UTC || objectID == TIME_GENERALIZED)
index 6552401364384f7a2666739993342ed82600cc8b..f79a53a3047afc82b2eed520a45c428447e36a0a 100644 (file)
@@ -14,7 +14,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup asn1i asn1
  * @{ @ingroup asn1
@@ -103,7 +103,7 @@ chunk_t asn1_algorithmIdentifier(int oid);
  * Converts an ASN.1 OID into a known OID index
  *
  * @param object       body of an OID
- * @return                     index into the oid_names[] table or OID_UNKNOWN  
+ * @return                     index into the oid_names[] table or OID_UNKNOWN
  */
 int asn1_known_oid(chunk_t object);
 
@@ -139,7 +139,7 @@ int asn1_unwrap(chunk_t *blob, chunk_t *content);
  * @param blob         ASN.1 coded blob
  * @param level0       top-most level offset
  * @param params       returns optional [ASN.1 coded] parameters
- * @return                     known OID index or OID_UNKNOWN  
+ * @return                     known OID index or OID_UNKNOWN
  */
 int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *params);
 
@@ -178,7 +178,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type);
  *
  * @param time         time_t in UTC
  * @param type         ASN1_UTCTIME or ASN1_GENERALIZEDTIME
- * @return                     body of an ASN.1 code time object                       
+ * @return                     body of an ASN.1 code time object
  */
 chunk_t asn1_from_time(const time_t *time, asn1_t type);
 
@@ -187,7 +187,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type);
  *
  * @param blob         ASN.1 coded time object
  * @param level0       top-most level offset
- * @return                     time_t in UTC   
+ * @return                     time_t in UTC
  */
 time_t asn1_parse_time(chunk_t blob, int level0);
 
index bc4c0b50f4f38638e77e7734a3ba1c581e059dc9..5f635ec2c8fd719af5035914508f0a5417a0e54f 100644 (file)
@@ -54,7 +54,7 @@ struct private_asn1_parser_t {
        bool success;
 
        /**
-        * Declare object data as private - use debug level 4 to log it 
+        * Declare object data as private - use debug level 4 to log it
         */
        bool private;
 
@@ -88,7 +88,7 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
        u_char *start_ptr;
        u_int level;
        asn1Object_t obj;
-       
+
        *object = chunk_empty;
 
        /* Advance to the next object syntax definition line */
@@ -99,7 +99,7 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
        {
                return FALSE;
        }
-               
+
        if (obj.flags & ASN1_END)  /* end of loop or option found */
        {
                if (this->loopAddr[obj.level] && this->blobs[obj.level+1].len > 0)
@@ -113,12 +113,12 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
                        goto end;
                }
        }
-       
+
        level = this->level0 + obj.level;
        blob = this->blobs + obj.level;
        blob1 = blob + 1;
        start_ptr = blob->ptr;
-       
+
        /* handle ASN.1 defaults values */
        if ((obj.flags & ASN1_DEF) && (blob->len == 0 || *start_ptr != obj.type) )
        {
@@ -130,9 +130,9 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
                }
                goto end;
        }
-       
+
        /* handle ASN.1 options */
-       
+
        if ((obj.flags & ASN1_OPT)
                        && (blob->len == 0 || *start_ptr != obj.type))
        {
@@ -145,9 +145,9 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
                                 (this->objects[this->line].level == obj.level)));
                goto end;
        }
-               
+
        /* an ASN.1 object must possess at least a tag and length field */
-       
+
        if (blob->len < 2)
        {
                DBG1("L%d - %s:  ASN.1 object smaller than 2 octets",
@@ -155,22 +155,22 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
                this->success = FALSE;
                goto end;
        }
-       
+
        blob1->len = asn1_length(blob);
-       
+
        if (blob1->len == ASN1_INVALID_LENGTH)
        {
-               DBG1("L%d - %s:  length of ASN.1 object invalid or too large", 
+               DBG1("L%d - %s:  length of ASN.1 object invalid or too large",
                                        level, obj.name);
                this->success = FALSE;
        }
-       
+
        blob1->ptr = blob->ptr;
        blob->ptr += blob1->len;
        blob->len -= blob1->len;
-       
+
        /* return raw ASN.1 object without prior type checking */
-       
+
        if (obj.flags & ASN1_RAW)
        {
                DBG2("L%d - %s:", level, obj.name);
@@ -187,10 +187,10 @@ static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
                this->success = FALSE;
                goto end;
        }
-       
+
        DBG2("L%d - %s:", level, obj.name);
-       
-       /* In case of "SEQUENCE OF" or "SET OF" start a loop */ 
+
+       /* In case of "SEQUENCE OF" or "SET OF" start a loop */
        if (obj.flags & ASN1_LOOP)
        {
                if (blob1->len > 0)
index b2f4133a172ccca447d7b40da239159848975086..ee6ec57fd115d2832b64110d442b3b5b295d9754 100644 (file)
@@ -14,7 +14,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup asn1_parser asn1_parser
  * @{ @ingroup asn1
@@ -57,7 +57,7 @@ struct asn1Object_t{
 typedef struct asn1_parser_t asn1_parser_t;
 
 /**
- * Public interface of an ASN.1 parser 
+ * Public interface of an ASN.1 parser
  */
 struct asn1_parser_t {
 
@@ -106,7 +106,7 @@ struct asn1_parser_t {
         */
        void (*destroy)(asn1_parser_t *this);
 };
+
 /**
  * Create an ASN.1 parser
  *
index acf3db1f48ccfbbbe607f12528da4bdcd1901f00..86436e99768d569d0d18c875c29367be47b9be87 100644 (file)
@@ -46,14 +46,14 @@ chunk_t chunk_empty = { NULL, 0 };
 chunk_t chunk_create_clone(u_char *ptr, chunk_t chunk)
 {
        chunk_t clone = chunk_empty;
-       
+
        if (chunk.ptr && chunk.len > 0)
        {
                clone.ptr = ptr;
                clone.len = chunk.len;
                memcpy(clone.ptr, chunk.ptr, chunk.len);
        }
-       
+
        return clone;
 }
 
@@ -64,7 +64,7 @@ size_t chunk_length(const char* mode, ...)
 {
        va_list chunks;
        size_t length = 0;
-       
+
        va_start(chunks, mode);
        while (TRUE)
        {
@@ -94,13 +94,13 @@ chunk_t chunk_create_cat(u_char *ptr, const char* mode, ...)
 {
        va_list chunks;
        chunk_t construct = chunk_create(ptr, 0);
-       
+
        va_start(chunks, mode);
        while (TRUE)
        {
                bool free_chunk = FALSE, clear_chunk = FALSE;
                chunk_t ch;
-               
+
                switch (*mode++)
                {
                        case 's':
@@ -111,7 +111,7 @@ chunk_t chunk_create_cat(u_char *ptr, const char* mode, ...)
                                /* FALL */
                        case 'c':
                                ch = va_arg(chunks, chunk_t);
-                               memcpy(ptr, ch.ptr, ch.len); 
+                               memcpy(ptr, ch.ptr, ch.len);
                                ptr += ch.len;
                                construct.len += ch.len;
                                if (clear_chunk)
@@ -129,7 +129,7 @@ chunk_t chunk_create_cat(u_char *ptr, const char* mode, ...)
                break;
        }
        va_end(chunks);
-       
+
        return construct;
 }
 
@@ -141,7 +141,7 @@ void chunk_split(chunk_t chunk, const char *mode, ...)
        va_list chunks;
        u_int len;
        chunk_t *ch;
-       
+
        va_start(chunks, mode);
        while (TRUE)
        {
@@ -262,19 +262,19 @@ chunk_t chunk_to_hex(chunk_t chunk, char *buf, bool uppercase)
 {
        int i, len;
        char *hexdig = hexdig_lower;
-       
+
        if (uppercase)
        {
                hexdig = hexdig_upper;
        }
-       
+
        len = chunk.len * 2;
        if (!buf)
        {
                buf = malloc(len + 1);
        }
        buf[len] = '\0';
-       
+
        for (i = 0; i < chunk.len; i++)
        {
                buf[i*2]   = hexdig[(chunk.ptr[i] >> 4) & 0xF];
@@ -308,7 +308,7 @@ chunk_t chunk_from_hex(chunk_t hex, char *buf)
 {
        int i, len;
        bool odd = FALSE;
-       
+
        len = (hex.len / 2);
        if (hex.len % 2)
        {
@@ -334,7 +334,7 @@ chunk_t chunk_from_hex(chunk_t hex, char *buf)
 }
 
 /** base 64 conversion digits */
-static char b64digits[] = 
+static char b64digits[] =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 /**
@@ -344,7 +344,7 @@ chunk_t chunk_to_base64(chunk_t chunk, char *buf)
 {
        int i, len;
        char *pos;
-       
+
        len = chunk.len + ((3 - chunk.len % 3) % 3);
        if (!buf)
        {
@@ -408,7 +408,7 @@ chunk_t chunk_from_base64(chunk_t base64, char *buf)
 {
        u_char *pos, byte[4];
        int i, j, len, outlen;
-       
+
        len = base64.len / 4 * 3;
        if (!buf)
        {
@@ -456,7 +456,7 @@ int chunk_compare(chunk_t a, chunk_t b)
 bool chunk_increment(chunk_t chunk)
 {
        int i;
-       
+
        for (i = chunk.len - 1; i >= 0; i--)
        {
                if (++chunk.ptr[i] != 0)
@@ -474,7 +474,7 @@ bool chunk_printable(chunk_t chunk, chunk_t *sane, char replace)
 {
        bool printable = TRUE;
        int i;
-       
+
        if (sane)
        {
                *sane = chunk_clone(chunk);
@@ -495,7 +495,7 @@ bool chunk_printable(chunk_t chunk, chunk_t *sane, char replace)
 
 /**
  * Described in header.
- * 
+ *
  * The implementation is based on Paul Hsieh's SuperFastHash:
  *      http://www.azillionmonkeys.com/qed/hash.html
  */
@@ -505,15 +505,15 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
        size_t len = chunk.len;
        u_int32_t tmp;
        int rem;
-       
+
        if (!len || data == NULL)
        {
                return 0;
        }
-       
+
        rem = len & 3;
        len >>= 2;
-       
+
        /* Main loop */
        for (; len > 0; --len)
        {
@@ -523,7 +523,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
                data += 2 * sizeof(u_int16_t);
                hash += hash >> 11;
        }
-       
+
        /* Handle end cases */
        switch (rem)
        {
@@ -550,7 +550,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
                        break;
                }
        }
-       
+
        /* Force "avalanching" of final 127 bits */
        hash ^= hash << 3;
        hash += hash >> 5;
@@ -558,7 +558,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash)
        hash += hash >> 17;
        hash ^= hash << 25;
        hash += hash >> 6;
-       
+
        return hash;
 }
 
@@ -580,13 +580,13 @@ int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
        bool first = TRUE;
        chunk_t copy = *chunk;
        int written = 0;
-       
+
        if (!spec->hash)
        {
                const void *new_args[] = {&chunk->ptr, &chunk->len};
                return mem_printf_hook(dst, len, spec, new_args);
        }
-       
+
        while (copy.len > 0)
        {
                if (first)
index 3329a4a27f7577b977d4f80b6b0b740c885b82c6..81e683ac8d7533bc1dc9187cf5b2f305c00a8235 100644 (file)
@@ -92,7 +92,7 @@ void chunk_split(chunk_t chunk, const char *mode, ...);
  *
  * @param chunk                        contents to write to file
  * @param path                 path where file is written to
- * @param label                        label specifying file type 
+ * @param label                        label specifying file type
  * @param mask                 file mode creation mask
  * @param force                        overwrite existing file by force
  * @return                             TRUE if write operation was successful
@@ -273,7 +273,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash);
 /**
  * printf hook function for chunk_t.
  *
- * Arguments are: 
+ * Arguments are:
  *    chunk_t *chunk
  * Use #-modifier to print a compact version
  */
index 650d05251336d38e9404f7bc1e9bfd0e294323d2..a5ce7e13eb449ecf846fc811ff31e3ff7a2aad1f 100644 (file)
@@ -130,14 +130,14 @@ struct builder_t {
        /**
         * Add a part to the construct.
         *
-        * Any added parts are cloned/refcounted by the builder implementation, a 
+        * Any added parts are cloned/refcounted by the builder implementation, a
         * caller may need to free the passed ressources themself.
         *
         * @param part          kind of part
         * @param ...           part specific variable argument
         */
        void (*add)(builder_t *this, builder_part_t part, ...);
-       
+
        /**
         * Build the construct with all supplied parts.
         *
index e617d56b0f167d215345143f72781d282e3c052f..50fd7887840b88c610d5440ce0c162d7307673dc 100644 (file)
@@ -41,35 +41,35 @@ struct ac_t {
         * Implements the certificate_t interface
         */
        certificate_t certificate;
-       
+
        /**
         * Get the attribute certificate's serial number.
         *
         * @return                      chunk pointing to serialNumber
         */
        chunk_t (*get_serial)(ac_t *this);
-       
+
        /**
         * Get the serial number of the holder certificate.
         *
         * @return                      chunk pointing to serialNumber
         */
        chunk_t (*get_holderSerial)(ac_t *this);
-       
+
        /**
         * Get the issuer of the holder certificate.
         *
         * @return                      holderIssuer as identification_t*
         */
        identification_t* (*get_holderIssuer)(ac_t *this);
-       
+
        /**
         * Get the thauthorityKeyIdentifier.
         *
         * @return                      authKeyIdentifier as chunk_t, to internal data
         */
        chunk_t (*get_authKeyIdentifier)(ac_t *this);
-       
+
        /**
         * @brief Checks if two attribute certificates belong to the same holder
         *
index ef26a437a9f660a4b997746472afd71e62348e83..f58580579f00186605200e72bd47b2ba514a1588 100644 (file)
@@ -88,7 +88,7 @@ extern enum_name_t *cert_validation_names;
 /**
  * An abstract certificate.
  *
- * A certificate designs a subject-issuer relationship. It may have an 
+ * A certificate designs a subject-issuer relationship. It may have an
  * associated public key.
  */
 struct certificate_t {
@@ -106,7 +106,7 @@ struct certificate_t {
         * @return                      subject identity
         */
        identification_t* (*get_subject)(certificate_t *this);
-       
+
        /**
         * Check if certificate contains a subject ID.
         *
@@ -117,14 +117,14 @@ struct certificate_t {
         * @return                      matching value of best match
         */
        id_match_t (*has_subject)(certificate_t *this, identification_t *subject);
-               
+
        /**
         * Get the issuer which signed this certificate.
         *
         * @return                      issuer identity
         */
        identification_t* (*get_issuer)(certificate_t *this);
-       
+
        /**
         * Check if certificate contains an issuer ID.
         *
@@ -135,7 +135,7 @@ struct certificate_t {
         * @return                      matching value of best match
         */
        id_match_t (*has_issuer)(certificate_t *this, identification_t *issuer);
-       
+
        /**
         * Check if this certificate is issued and signed by a specific issuer.
         *
@@ -143,14 +143,14 @@ struct certificate_t {
         * @return                      TRUE if certificate issued by issuer and trusted
         */
        bool (*issued_by)(certificate_t *this, certificate_t *issuer);
-       
+
        /**
         * Get the public key associated to this certificate.
         *
         * @return                      newly referenced public_key, NULL if none available
         */
        public_key_t* (*get_public_key)(certificate_t *this);
-       
+
        /**
         * Check the lifetime of the certificate.
         *
@@ -161,21 +161,21 @@ struct certificate_t {
         */
        bool (*get_validity)(certificate_t *this, time_t *when,
                                                 time_t *not_before, time_t *not_after);
-       
+
        /**
         * Is this newer than that?
         *
         * @return                      TRUE if newer, FALSE otherwise
         */
        bool (*is_newer)(certificate_t *this, certificate_t *that);
-       
+
        /**
         * Get the certificate in an encoded form.
         *
         * @return                              allocated chunk of encoded cert
         */
        chunk_t (*get_encoding)(certificate_t *this);
-       
+
        /**
         * Check if two certificates are equal.
         *
@@ -183,14 +183,14 @@ struct certificate_t {
         * @return                              TRUE if certificates are equal
         */
        bool (*equals)(certificate_t *this, certificate_t *other);
-       
+
        /**
         * Get a new reference to the certificate.
         *
-        * @return                      this, with an increased refcount 
+        * @return                      this, with an increased refcount
         */
        certificate_t* (*get_ref)(certificate_t *this);
-       
+
        /**
      * Destroy a certificate.
      */
index 3d47961743b390786c2e908da0dc138e225e8f5d..e7d216bd118ea57677cb1f313f8c73a86e0a7c24 100644 (file)
@@ -56,21 +56,21 @@ struct crl_t {
         * Implements (parts of) the certificate_t interface
         */
        certificate_t certificate;
-       
+
        /**
         * Get the CRL serial number.
         *
         * @return                      chunk pointing to internal crlNumber
         */
        chunk_t (*get_serial)(crl_t *this);
-       
+
        /**
         * Get the the authorityKeyIdentifier.
         *
         * @return                      authKeyIdentifier chunk, point to internal data
         */
        chunk_t (*get_authKeyIdentifier)(crl_t *this);
-       
+
        /**
         * Create an enumerator over all revoked certificates.
         *
@@ -80,7 +80,7 @@ struct crl_t {
         * @return                      enumerator over revoked certificates.
         */
        enumerator_t* (*create_enumerator)(crl_t *this);
-       
+
 };
 
 #endif /** CRL_H_ @}*/
index a70f3eee49a0c23229f949ca213eff2adc6ac2c6..157577458cb709c7427b9749a41dfb994deba549 100644 (file)
@@ -28,7 +28,7 @@ typedef struct ocsp_response_t ocsp_response_t;
 typedef enum ocsp_status_t ocsp_status_t;
 
 /**
- * OCSP response status 
+ * OCSP response status
  */
 enum ocsp_status_t {
        OCSP_SUCCESSFUL                 = 0,
@@ -53,7 +53,7 @@ struct ocsp_response_t {
         * Implements certificiate_t interface
         */
        certificate_t certificate;
-       
+
        /**
         * Check the status of a certificate by this OCSP response.
         *
@@ -65,18 +65,18 @@ struct ocsp_response_t {
         * @param next_update           exptected time of next revocation list
         * @return                                      certificate revocation status
         */
-       cert_validation_t (*get_status)(ocsp_response_t *this, 
+       cert_validation_t (*get_status)(ocsp_response_t *this,
                                                                        x509_t *subject, x509_t *issuer,
                                                                        time_t *revocation_time,
                                                                        crl_reason_t *revocation_reason,
                                                                        time_t *this_update, time_t *next_update);
-       
+
        /**
         * Create an enumerator over the contained certificates.
         *
         * @return                                      enumerator over certificate_t*
         */
-       enumerator_t* (*create_cert_enumerator)(ocsp_response_t *this); 
+       enumerator_t* (*create_cert_enumerator)(ocsp_response_t *this);
 };
 
 #endif /** OCSP_RESPONSE_H_ @}*/
index 0e63d357f985e99f03c4119dbde4b769309a8923..540eb988bec4ae83570911cbcc4e046f81b68801 100644 (file)
@@ -58,42 +58,42 @@ struct x509_t {
         * Implements certificate_t.
         */
        certificate_t interface;
-       
+
        /**
         * Get the flags set for this certificate.
         *
         * @return                      set of flags
         */
        x509_flag_t (*get_flags)(x509_t *this);
-       
+
        /**
         * Get the certificate serial number.
         *
         * @return                      chunk pointing to internal serial number
         */
        chunk_t (*get_serial)(x509_t *this);
-       
+
        /**
         * Get the the authorityKeyIdentifier.
         *
         * @return                      authKeyIdentifier as chunk_t, internal data
         */
        chunk_t (*get_authKeyIdentifier)(x509_t *this);
-       
+
        /**
         * Create an enumerator over all subjectAltNames.
         *
         * @return                      enumerator over subjectAltNames as identification_t*
         */
        enumerator_t* (*create_subjectAltName_enumerator)(x509_t *this);
-       
+
        /**
         * Create an enumerator over all CRL URIs.
         *
         * @return                      enumerator over URIs as char*
         */
        enumerator_t* (*create_crl_uri_enumerator)(x509_t *this);
-       
+
        /**
         * Create an enumerator over all OCSP URIs.
         *
index ac1f05beb3ebb19a53d5c32d78bcf49548e3e18d..6201cd6c9430573259b0912aef379e7f0e68ff05 100644 (file)
@@ -41,17 +41,17 @@ struct private_credential_factory_t {
         * public functions
         */
        credential_factory_t public;
-       
+
        /**
         * list with entry_t
         */
        linked_list_t *constructors;
-       
+
        /**
         * Thread specific recursiveness counter
         */
        pthread_key_t recursive;
-       
+
        /**
         * lock access to builders
         */
@@ -74,7 +74,7 @@ struct entry_t {
 static bool builder_filter(entry_t *data, entry_t **in, builder_t **out)
 {
        builder_t *builder;
-       
+
        if (data->type == (*in)->type &&
                data->subtype == (*in)->subtype)
        {
@@ -95,15 +95,15 @@ static enumerator_t* create_builder_enumerator(
                private_credential_factory_t *this,     credential_type_t type, int subtype)
 {
        entry_t *data = malloc_thing(entry_t);
-       
+
        data->type = type;
        data->subtype = subtype;
-       
+
        this->lock->read_lock(this->lock);
        return enumerator_create_cleaner(
                                enumerator_create_filter(
                                        this->constructors->create_enumerator(this->constructors),
-                                       (void*)builder_filter, data, free), 
+                                       (void*)builder_filter, data, free),
                                (void*)this->lock->unlock, this->lock);
 }
 
@@ -115,7 +115,7 @@ static void add_builder(private_credential_factory_t *this,
                                                builder_constructor_t constructor)
 {
        entry_t *entry = malloc_thing(entry_t);
-       
+
        entry->type = type;
        entry->subtype = subtype;
        entry->constructor = constructor;
@@ -132,7 +132,7 @@ static void remove_builder(private_credential_factory_t *this,
 {
        enumerator_t *enumerator;
        entry_t *entry;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->constructors->create_enumerator(this->constructors);
        while (enumerator->enumerate(enumerator, &entry))
@@ -160,10 +160,10 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
        void* construct = NULL, *fn, *data;
        int failures = 0;
        uintptr_t level;
-       
+
        level = (uintptr_t)pthread_getspecific(this->recursive);
        pthread_setspecific(this->recursive, (void*)level + 1);
-       
+
        enumerator = create_builder_enumerator(this, type, subtype);
        while (enumerator->enumerate(enumerator, &builder))
        {
@@ -231,7 +231,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
                        break;
                }
                va_end(args);
-               
+
                construct = builder->build(builder);
                if (construct)
                {
@@ -243,7 +243,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
        if (!construct && !level)
        {
                enum_name_t *names = key_type_names;
-               
+
                if (type == CRED_CERTIFICATE)
                {
                        names = certificate_type_names;
@@ -278,11 +278,11 @@ credential_factory_t *credential_factory_create()
        this->public.add_builder = (void(*)(credential_factory_t*,credential_type_t type, int subtype, builder_constructor_t constructor))add_builder;
        this->public.remove_builder = (void(*)(credential_factory_t*,builder_constructor_t constructor))remove_builder;
        this->public.destroy = (void(*)(credential_factory_t*))destroy;
-       
+
        this->constructors = linked_list_create();
        pthread_key_create(&this->recursive, NULL);
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index 69a55cf364c1f81212fcf0d87e8e973e1b00a8da..20a13db65b946069460a65406da419d36ab91e7b 100644 (file)
@@ -47,7 +47,7 @@ extern enum_name_t *credential_type_names;
  * Manages credential construction functions and creates instances.
  */
 struct credential_factory_t {
-       
+
        /**
         * Create a credential using a list of builder_part_t's.
         *
@@ -64,12 +64,12 @@ struct credential_factory_t {
         */
        void* (*create)(credential_factory_t *this, credential_type_t type,
                                        int subtype, ...);
-       
+
        /**
         * Create an enumerator for a builder type.
         *
-        * The build() method has to be called on each enumerated builder to 
-        * cleanup associated ressources. 
+        * The build() method has to be called on each enumerated builder to
+        * cleanup associated ressources.
         *
         * @param type                  type of credentials the builder creates
         * @param subtype               type specific subtype, such as certificate_type_t
@@ -77,7 +77,7 @@ struct credential_factory_t {
         */
        enumerator_t* (*create_builder_enumerator)(credential_factory_t *this,
                                                                                credential_type_t type, int subtype);
-       
+
        /**
         * Register a builder_t constructor function.
         *
@@ -85,16 +85,16 @@ struct credential_factory_t {
         * @param constructor   builder constructor function to register
         */
        void (*add_builder)(credential_factory_t *this,
-                                               credential_type_t type, int subtype, 
+                                               credential_type_t type, int subtype,
                                                builder_constructor_t constructor);
        /**
         * Unregister a builder_t constructor function.
         *
         * @param constructor   constructor function to unregister.
         */
-       void (*remove_builder)(credential_factory_t *this, 
+       void (*remove_builder)(credential_factory_t *this,
                                                   builder_constructor_t constructor);
-       
+
        /**
         * Destroy a credential_factory instance.
         */
index 601ce2a53407102267b50591985ca102a79e96be..7c09b9f9502648a46acfd483be5eeaa4e058fc2e 100644 (file)
@@ -27,22 +27,22 @@ typedef struct private_key_encoding_t private_key_encoding_t;
  * Private data of an key_encoding_t object.
  */
 struct private_key_encoding_t {
-       
+
        /**
         * Public key_encoding_t interface.
         */
        key_encoding_t public;
-       
+
        /**
         * cached encodings, a table for each encoding_type_t, containing chunk_t*
         */
        hashtable_t *cache[KEY_ENCODING_MAX];
-       
+
        /**
         * Registered encoding fuctions, key_encoder_t
         */
        linked_list_t *encoders;
-       
+
        /**
         * lock to access cache/encoders
         */
@@ -56,14 +56,14 @@ bool key_encoding_args(va_list args, ...)
 {
        va_list parts, copy;
        bool failed = FALSE;
-       
+
        va_start(parts, args);
-       
+
        while (!failed)
        {
                key_encoding_part_t current, target;
                chunk_t *out, data;
-               
+
                /* get the part we are looking for */
                target = va_arg(parts, key_encoding_part_t);
                if (target == KEY_PART_END)
@@ -71,7 +71,7 @@ bool key_encoding_args(va_list args, ...)
                        break;
                }
                out = va_arg(parts, chunk_t*);
-               
+
                va_copy(copy, args);
                while (!failed)
                {
@@ -117,7 +117,7 @@ static bool get_cache(private_key_encoding_t *this, key_encoding_type_t type,
                                          void *cache, chunk_t *encoding)
 {
        chunk_t *chunk;
-       
+
        if (type >= KEY_ENCODING_MAX || type < 0)
        {
                return FALSE;
@@ -143,7 +143,7 @@ static bool encode(private_key_encoding_t *this, key_encoding_type_t type,
        key_encoder_t encode;
        bool success = FALSE;
        chunk_t *chunk;
-       
+
        if (type >= KEY_ENCODING_MAX || type < 0)
        {
                return FALSE;
@@ -192,7 +192,7 @@ static void cache(private_key_encoding_t *this, key_encoding_type_t type,
                                  void *cache, chunk_t encoding)
 {
        chunk_t *chunk;
-       
+
        if (type >= KEY_ENCODING_MAX || type < 0)
        {
                return free(encoding.ptr);
@@ -217,7 +217,7 @@ static void clear_cache(private_key_encoding_t *this, void *cache)
 {
        key_encoding_type_t type;
        chunk_t *chunk;
-       
+
        this->lock->write_lock(this->lock);
        for (type = 0; type < KEY_ENCODING_MAX; type++)
        {
@@ -257,7 +257,7 @@ static void remove_encoder(private_key_encoding_t *this, key_encoder_t encoder)
 static void destroy(private_key_encoding_t *this)
 {
        key_encoding_type_t type;
-       
+
        for (type = 0; type < KEY_ENCODING_MAX; type++)
        {
                /* We explicitly do not free remaining encodings. All keys should
@@ -278,7 +278,7 @@ key_encoding_t *key_encoding_create()
 {
        private_key_encoding_t *this = malloc_thing(private_key_encoding_t);
        key_encoding_type_t type;
-       
+
        this->public.encode = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding, ...))encode;
        this->public.get_cache = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding))get_cache;
        this->public.cache = (void(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t encoding))cache;
@@ -286,14 +286,14 @@ key_encoding_t *key_encoding_create()
        this->public.add_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))add_encoder;
        this->public.remove_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))remove_encoder;
        this->public.destroy = (void(*)(key_encoding_t*))destroy;
-       
+
        for (type = 0; type < KEY_ENCODING_MAX; type++)
        {
                this->cache[type] = hashtable_create(hash, equals, 8);
        }
        this->encoders = linked_list_create();
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index 0f70186c27981dc963b21c8ddd5cd048c2935620..3e6945a88fcd5a6e73c643c9d380906bb64a8964 100644 (file)
@@ -71,7 +71,7 @@ enum key_encoding_type_t {
        KEY_ID_PGPV3,
        /** PGPv4 fingerprint */
        KEY_ID_PGPV4,
-       
+
        /** PKCS#1 and similar ASN.1 key encoding */
        KEY_PUB_ASN1_DER,
        KEY_PRIV_ASN1_DER,
@@ -83,7 +83,7 @@ enum key_encoding_type_t {
        /** PGP key encoding */
        KEY_PUB_PGP,
        KEY_PRIV_PGP,
-       
+
        KEY_ENCODING_MAX,
 };
 
@@ -115,7 +115,7 @@ enum key_encoding_part_t {
        KEY_PART_ECDSA_PUB_ASN1_DER,
        /** a DER encoded ECDSA private key */
        KEY_PART_ECDSA_PRIV_ASN1_DER,
-       
+
        KEY_PART_END,
 };
 
@@ -141,14 +141,14 @@ struct key_encoding_t {
         */
        bool (*encode)(key_encoding_t *this, key_encoding_type_t type, void *cache,
                                   chunk_t *encoding, ...);
-       
+
        /**
         * Clear all cached encodings of a given cache key.
         *
         * @param cache                 key used in encode() for caching
         */
        void (*clear_cache)(key_encoding_t *this, void *cache);
-       
+
        /**
         * Check for a cached encoding.
         *
@@ -159,7 +159,7 @@ struct key_encoding_t {
         */
        bool (*get_cache)(key_encoding_t *this, key_encoding_type_t type,
                                          void *cache, chunk_t *encoding);
-       
+
        /**
         * Cache a key encoding created externally.
         *
@@ -172,21 +172,21 @@ struct key_encoding_t {
         */
        void (*cache)(key_encoding_t *this, key_encoding_type_t type, void *cache,
                                  chunk_t encoding);
-       
+
        /**
         * Register a key encoder function.
         *
         * @param encoder               key encoder function to add
         */
        void (*add_encoder)(key_encoding_t *this, key_encoder_t encoder);
-       
+
        /**
         * Unregister a previously registered key encoder function.
         *
         * @param encoder               key encoder function to remove
         */
        void (*remove_encoder)(key_encoding_t *this, key_encoder_t encoder);
-       
+
        /**
         * Destroy a key_encoding_t.
         */
index a334370a4e54c650f832b55c3867a468a490458b..05f01e36023fe9c9ac7ecba5ba52d45da0af76b0 100644 (file)
@@ -22,12 +22,12 @@ bool private_key_equals(private_key_t *this, private_key_t *other)
 {
        key_encoding_type_t type;
        chunk_t a, b;
-       
+
        if (this == other)
        {
                return TRUE;
        }
-       
+
        for (type = 0; type < KEY_ENCODING_MAX; type++)
        {
                if (this->get_fingerprint(this, type, &a) &&
@@ -46,7 +46,7 @@ bool private_key_belongs_to(private_key_t *private, public_key_t *public)
 {
        key_encoding_type_t type;
        chunk_t a, b;
-       
+
        for (type = 0; type < KEY_ENCODING_MAX; type++)
        {
                if (private->get_fingerprint(private, type, &a) &&
index 3bea9c244f8fd9e3a002e058f0ae8009309f14e2..79fc9441b48192cf516ff2d42404dc164eb78ebe 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup private_key private_key
  * @{ @ingroup keys
@@ -29,14 +29,14 @@ typedef struct private_key_t private_key_t;
  * Abstract private key interface.
  */
 struct private_key_t {
-       
+
        /**
         * Get the key type.
         *
         * @return                      type of the key
         */
        key_type_t (*get_type)(private_key_t *this);
-       
+
        /**
         * Create a signature over a chunk of data.
         *
@@ -45,7 +45,7 @@ struct private_key_t {
         * @param signature     where to allocate created signature
         * @return                      TRUE if signature created
         */
-       bool (*sign)(private_key_t *this, signature_scheme_t scheme, 
+       bool (*sign)(private_key_t *this, signature_scheme_t scheme,
                                 chunk_t data, chunk_t *signature);
        /**
         * Decrypt a chunk of data.
@@ -55,37 +55,37 @@ struct private_key_t {
         * @return                      TRUE if data decrypted and plaintext allocated
         */
        bool (*decrypt)(private_key_t *this, chunk_t crypto, chunk_t *plain);
-       
+
        /**
         * Get the strength of the key in bytes.
-        * 
+        *
         * @return                      strength of the key in bytes
         */
        size_t (*get_keysize) (private_key_t *this);
-       
+
        /**
         * Get the public part from the private key.
         *
         * @return                      public key
         */
        public_key_t* (*get_public_key)(private_key_t *this);
-       
+
        /**
         * Check if two private keys are equal.
-        * 
+        *
         * @param other         other private key
         * @return                      TRUE, if equality
         */
        bool (*equals) (private_key_t *this, private_key_t *other);
-       
+
        /**
         * Check if a private key belongs to a public key.
-        * 
+        *
         * @param public        public key
         * @return                      TRUE, if keys belong together
         */
        bool (*belongs_to) (private_key_t *this, public_key_t *public);
-       
+
        /**
         * Get the fingerprint of the key.
         *
@@ -95,7 +95,7 @@ struct private_key_t {
         */
        bool (*get_fingerprint)(private_key_t *this, key_encoding_type_t type,
                                                        chunk_t *fp);
-       
+
        /**
         * Get the key in an encoded form as a chunk.
         *
@@ -105,14 +105,14 @@ struct private_key_t {
         */
        bool (*get_encoding)(private_key_t *this, key_encoding_type_t type,
                                                 chunk_t *encoding);
-       
+
        /**
         * Increase the refcount to this private key.
         *
         * @return                      this, with an increased refcount
         */
        private_key_t* (*get_ref)(private_key_t *this);
-               
+
        /**
         * Decrease refcount, destroy private_key if no more references.
         */
index 8958a35762502d47680d4eb9ec046abe670f283b..fc2b996ebc1028b40adecc2b4b51c52908d9edef 100644 (file)
@@ -49,12 +49,12 @@ bool public_key_equals(public_key_t *this, public_key_t *other)
 {
        key_encoding_type_t type;
        chunk_t a, b;
-       
+
        if (this == other)
        {
                return TRUE;
        }
-       
+
        for (type = 0; type < KEY_ENCODING_MAX; type++)
        {
                if (this->get_fingerprint(this, type, &a) &&
index 984c8c02f7004aa4fa85c97ca7b77aba9b577ff0..f490d1324717ea25848485cb7c742ebb42c2a38c 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup public_key public_key
  * @{ @ingroup keys
@@ -53,7 +53,7 @@ extern enum_name_t *key_type_names;
  * Signature scheme for signature creation
  *
  * EMSA-PKCS1 signatures are defined in PKCS#1 standard.
- * A prepended ASN.1 encoded digestInfo field contains the 
+ * A prepended ASN.1 encoded digestInfo field contains the
  * OID of the used hash algorithm.
  */
 enum signature_scheme_t {
@@ -107,7 +107,7 @@ struct public_key_t {
         * @return                      type of the key
         */
        key_type_t (*get_type)(public_key_t *this);
-       
+
        /**
         * Verifies a signature against a chunk of data.
         *
@@ -116,9 +116,9 @@ struct public_key_t {
         * @param signature     signature to check
         * @return                      TRUE if signature matches
         */
-       bool (*verify)(public_key_t *this, signature_scheme_t scheme, 
+       bool (*verify)(public_key_t *this, signature_scheme_t scheme,
                                   chunk_t data, chunk_t signature);
-       
+
        /**
         * Encrypt a chunk of data.
         *
@@ -127,10 +127,10 @@ struct public_key_t {
         * @return                      TRUE if data successfully encrypted
         */
        bool (*encrypt)(public_key_t *this, chunk_t plain, chunk_t *crypto);
-       
+
        /**
         * Check if two public keys are equal.
-        * 
+        *
         * @param other         other public key
         * @return                      TRUE, if equality
         */
@@ -138,11 +138,11 @@ struct public_key_t {
 
        /**
         * Get the strength of the key in bytes.
-        * 
+        *
         * @return                      strength of the key in bytes
         */
        size_t (*get_keysize) (public_key_t *this);
-       
+
        /**
         * Get the fingerprint of the key.
         *
@@ -152,7 +152,7 @@ struct public_key_t {
         */
        bool (*get_fingerprint)(public_key_t *this, key_encoding_type_t type,
                                                        chunk_t *fp);
-       
+
        /**
         * Get the key in an encoded form as a chunk.
         *
@@ -162,14 +162,14 @@ struct public_key_t {
         */
        bool (*get_encoding)(public_key_t *this, key_encoding_type_t type,
                                                 chunk_t *encoding);
-       
+
        /**
         * Increase the refcount of the key.
         *
         * @return                      this with an increased refcount
         */
        public_key_t* (*get_ref)(public_key_t *this);
-       
+
        /**
         * Destroy a public_key instance.
         */
@@ -187,7 +187,7 @@ bool public_key_equals(public_key_t *this, public_key_t *other);
 
 /**
  * Conversion of ASN.1 signature or hash OID to signature scheme.
- * 
+ *
  * @param oid                  ASN.1 OID
  * @return                             signature_scheme, SIGN_UNKNOWN if OID is unsupported
  */
index c6f14144680751c0d2d5bfe62fad1fe353747a2c..f695c078d9a59bbe9ab92c3a7b60ddf1f5a578a4 100644 (file)
@@ -34,17 +34,17 @@ struct private_shared_key_t {
         * public functions
         */
        shared_key_t public;
-       
+
        /**
         * type of this shared key
         */
        shared_key_type_t type;
-       
+
        /**
         * associated shared key data
         */
        chunk_t key;
-       
+
        /**
         * reference counter
         */
@@ -94,16 +94,16 @@ static void destroy(private_shared_key_t *this)
 shared_key_t *shared_key_create(shared_key_type_t type, chunk_t key)
 {
        private_shared_key_t *this = malloc_thing(private_shared_key_t);
-       
+
        this->public.get_type = (shared_key_type_t (*)(shared_key_t *this))get_type;
        this->public.get_key = (chunk_t (*)(shared_key_t *this))get_key;
        this->public.get_ref = (shared_key_t* (*)(shared_key_t *this))get_ref;
        this->public.destroy = (void(*)(shared_key_t*))destroy;
-       
+
        this->type = type;
        this->key = key;
        this->ref = 1;
-       
+
        return &this->public;
 }
 
index ceb1309b7af83a893b5e96825d1741f0d6b48e8f..33d734b50b3100d0f065b61fe7bd115bbbb2c451 100644 (file)
@@ -55,28 +55,28 @@ extern enum_name_t *shared_key_type_names;
  * reading.
  */
 struct shared_key_t {
-       
+
        /**
         * Get the kind of this key.
         *
         * @return                      type of the key
         */
        shared_key_type_t (*get_type)(shared_key_t *this);
-       
+
        /**
         * Get the shared key data.
         *
         * @return                      chunk pointing to the internal key
         */
        chunk_t (*get_key)(shared_key_t *this);
-       
-       /** 
+
+       /**
         * Increase refcount of the key.
         *
-        * @return                      this with an increased refcount 
+        * @return                      this with an increased refcount
         */
        shared_key_t* (*get_ref)(shared_key_t *this);
-               
+
        /**
      * Destroy a shared_key instance if all references are gone.
      */
index 2879e24c063643f67a53d3f023927562869d5e1d..dc3c3a7ff34de612741fdf75c57a8d47ddbff71e 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup crypter crypter
  * @{ @ingroup crypto
@@ -76,7 +76,7 @@ extern enum_name_t *encryption_algorithm_names;
  * Generic interface for symmetric encryption algorithms.
  */
 struct crypter_t {
-       
+
        /**
         * Encrypt a chunk of data and allocate space for the encrypted value.
         *
@@ -90,14 +90,14 @@ struct crypter_t {
         */
        void (*encrypt) (crypter_t *this, chunk_t data, chunk_t iv,
                                         chunk_t *encrypted);
-       
+
        /**
         * Decrypt a chunk of data and allocate space for the decrypted value.
         *
         * The length of the iv must equal to get_block_size(), while the length
         * of data must be a multiple it.
         * If decrpyted is NULL, the encryption is done in-place (overwriting data).
-        * 
+        *
         * @param data                  data to decrypt
         * @param iv                    initializing vector
         * @param encrypted             chunk to allocate decrypted data, or NULL
@@ -107,18 +107,18 @@ struct crypter_t {
 
        /**
         * Get the block size of the crypto algorithm.
-        * 
+        *
         * @return                                      block size in bytes
         */
        size_t (*get_block_size) (crypter_t *this);
 
        /**
         * Get the key size of the crypto algorithm.
-        * 
+        *
         * @return                                      key size in bytes
         */
        size_t (*get_key_size) (crypter_t *this);
-       
+
        /**
         * Set the key.
         *
@@ -127,7 +127,7 @@ struct crypter_t {
         * @param key                           key to set
         */
        void (*set_key) (crypter_t *this, chunk_t key);
-       
+
        /**
         * Destroys a crypter_t object.
         */
@@ -136,7 +136,7 @@ struct crypter_t {
 
 /**
  * Conversion of ASN.1 OID to encryption algorithm.
- * 
+ *
  * @param oid                  ASN.1 OID
  * @param key_size             returns size of encryption key in bits
  * @return                             encryption algorithm, ENCR_UNDEFINED if OID unsupported
@@ -145,7 +145,7 @@ encryption_algorithm_t encryption_algorithm_from_oid(int oid, size_t *key_size);
 
 /**
  * Conversion of encryption algorithm to ASN.1 OID.
- * 
+ *
  * @param alg                  encryption algorithm
  * @param key_size             size of encryption key in bits
  * @return                             ASN.1 OID, OID_UNKNOWN if OID is unknown
index e928e8cdf370613cf57cfe98ead0ecd3e1737df2..ceb44b0b3f4bc39efc498b93e27dde1894cd626d 100644 (file)
@@ -46,52 +46,52 @@ struct private_crypto_factory_t {
         * public functions
         */
        crypto_factory_t public;
-       
+
        /**
         * registered crypters, as entry_t
         */
        linked_list_t *crypters;
-       
+
        /**
         * registered signers, as entry_t
         */
        linked_list_t *signers;
-       
+
        /**
         * registered hashers, as entry_t
         */
        linked_list_t *hashers;
-       
+
        /**
         * registered prfs, as entry_t
         */
        linked_list_t *prfs;
-       
+
        /**
         * registered rngs, as entry_t
         */
        linked_list_t *rngs;
-       
+
        /**
         * registered diffie hellman, as entry_t
         */
        linked_list_t *dhs;
-       
+
        /**
         * test manager to test crypto algorithms
         */
        crypto_tester_t *tester;
-       
+
        /**
         * whether to test algorithms during registration
         */
        bool test_on_add;
-       
+
        /**
         * whether to test algorithms on each crypto primitive construction
         */
        bool test_on_create;
-       
+
        /**
         * rwlock to lock access to modules
         */
@@ -107,7 +107,7 @@ static crypter_t* create_crypter(private_crypto_factory_t *this,
        enumerator_t *enumerator;
        entry_t *entry;
        crypter_t *crypter = NULL;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->crypters->create_enumerator(this->crypters);
        while (enumerator->enumerate(enumerator, &entry))
@@ -141,7 +141,7 @@ static signer_t* create_signer(private_crypto_factory_t *this,
        enumerator_t *enumerator;
        entry_t *entry;
        signer_t *signer = NULL;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->signers->create_enumerator(this->signers);
        while (enumerator->enumerate(enumerator, &entry))
@@ -163,7 +163,7 @@ static signer_t* create_signer(private_crypto_factory_t *this,
        }
        enumerator->destroy(enumerator);
        this->lock->unlock(this->lock);
-       
+
        return signer;
 }
 
@@ -243,7 +243,7 @@ static rng_t* create_rng(private_crypto_factory_t *this, rng_quality_t quality)
        entry_t *entry;
        u_int diff = ~0;
        rng_constructor_t constr = NULL;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->rngs->create_enumerator(this->rngs);
        while (enumerator->enumerate(enumerator, &entry))
@@ -311,7 +311,7 @@ static void add_crypter(private_crypto_factory_t *this,
                this->tester->test_crypter(this->tester, algo, 0, create))
        {
                entry_t *entry = malloc_thing(entry_t);
-               
+
                entry->algo = algo;
                entry->create_crypter = create;
                this->lock->write_lock(this->lock);
@@ -328,7 +328,7 @@ static void remove_crypter(private_crypto_factory_t *this,
 {
        entry_t *entry;
        enumerator_t *enumerator;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->crypters->create_enumerator(this->crypters);
        while (enumerator->enumerate(enumerator, &entry))
@@ -353,7 +353,7 @@ static void add_signer(private_crypto_factory_t *this,
                this->tester->test_signer(this->tester, algo, create))
        {
                entry_t *entry = malloc_thing(entry_t);
-               
+
                entry->algo = algo;
                entry->create_signer = create;
                this->lock->write_lock(this->lock);
@@ -370,7 +370,7 @@ static void remove_signer(private_crypto_factory_t *this,
 {
        entry_t *entry;
        enumerator_t *enumerator;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->signers->create_enumerator(this->signers);
        while (enumerator->enumerate(enumerator, &entry))
@@ -395,7 +395,7 @@ static void add_hasher(private_crypto_factory_t *this, hash_algorithm_t algo,
                this->tester->test_hasher(this->tester, algo, create))
        {
                entry_t *entry = malloc_thing(entry_t);
-               
+
                entry->algo = algo;
                entry->create_hasher = create;
                this->lock->write_lock(this->lock);
@@ -412,7 +412,7 @@ static void remove_hasher(private_crypto_factory_t *this,
 {
        entry_t *entry;
        enumerator_t *enumerator;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->hashers->create_enumerator(this->hashers);
        while (enumerator->enumerate(enumerator, &entry))
@@ -437,7 +437,7 @@ static void add_prf(private_crypto_factory_t *this,
                this->tester->test_prf(this->tester, algo, create))
        {
                entry_t *entry = malloc_thing(entry_t);
-               
+
                entry->algo = algo;
                entry->create_prf = create;
                this->lock->write_lock(this->lock);
@@ -453,7 +453,7 @@ static void remove_prf(private_crypto_factory_t *this, prf_constructor_t create)
 {
        entry_t *entry;
        enumerator_t *enumerator;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->prfs->create_enumerator(this->prfs);
        while (enumerator->enumerate(enumerator, &entry))
@@ -478,7 +478,7 @@ static void add_rng(private_crypto_factory_t *this, rng_quality_t quality,
                this->tester->test_rng(this->tester, quality, create))
        {
                entry_t *entry = malloc_thing(entry_t);
-               
+
                entry->algo = quality;
                entry->create_rng = create;
                this->lock->write_lock(this->lock);
@@ -494,7 +494,7 @@ static void remove_rng(private_crypto_factory_t *this, rng_constructor_t create)
 {
        entry_t *entry;
        enumerator_t *enumerator;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->rngs->create_enumerator(this->rngs);
        while (enumerator->enumerate(enumerator, &entry))
@@ -516,7 +516,7 @@ static void add_dh(private_crypto_factory_t *this, diffie_hellman_group_t group,
                                   dh_constructor_t create)
 {
        entry_t *entry = malloc_thing(entry_t);
-       
+
        entry->algo = group;
        entry->create_dh = create;
        this->lock->write_lock(this->lock);
@@ -531,7 +531,7 @@ static void remove_dh(private_crypto_factory_t *this, dh_constructor_t create)
 {
        entry_t *entry;
        enumerator_t *enumerator;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->dhs->create_enumerator(this->dhs);
        while (enumerator->enumerate(enumerator, &entry))
@@ -713,7 +713,7 @@ static void destroy(private_crypto_factory_t *this)
 crypto_factory_t *crypto_factory_create()
 {
        private_crypto_factory_t *this = malloc_thing(private_crypto_factory_t);
-       
+
        this->public.create_crypter = (crypter_t*(*)(crypto_factory_t*, encryption_algorithm_t, size_t))create_crypter;
        this->public.create_signer = (signer_t*(*)(crypto_factory_t*, integrity_algorithm_t))create_signer;
        this->public.create_hasher = (hasher_t*(*)(crypto_factory_t*, hash_algorithm_t))create_hasher;
@@ -739,7 +739,7 @@ crypto_factory_t *crypto_factory_create()
        this->public.create_dh_enumerator = (enumerator_t*(*)(crypto_factory_t*))create_dh_enumerator;
        this->public.add_test_vector = (void(*)(crypto_factory_t*, transform_type_t type, ...))add_test_vector;
        this->public.destroy = (void(*)(crypto_factory_t*))destroy;
-       
+
        this->crypters = linked_list_create();
        this->signers = linked_list_create();
        this->hashers = linked_list_create();
@@ -752,7 +752,7 @@ crypto_factory_t *crypto_factory_create()
                                                                "libstrongswan.crypto_test.on_add", FALSE);
        this->test_on_create = lib->settings->get_bool(lib->settings,
                                                                "libstrongswan.crypto_test.on_create", FALSE);
-       
+
        return &this->public;
 }
 
index f1ebcf90a11c2485f2cf563e450bbc5cb28783cc..9c6effd26be5206ee01a30cac1309c43d49df951 100644 (file)
@@ -76,7 +76,7 @@ struct crypto_factory_t {
         */
        crypter_t* (*create_crypter)(crypto_factory_t *this,
                                                                 encryption_algorithm_t algo, size_t key_size);
-       
+
        /**
         * Create a symmetric signer instance.
         *
@@ -93,7 +93,7 @@ struct crypto_factory_t {
         * @return                              hasher_t instance, NULL if not supported
         */
        hasher_t* (*create_hasher)(crypto_factory_t *this, hash_algorithm_t algo);
-       
+
        /**
         * Create a pseudo random function instance.
         *
@@ -101,7 +101,7 @@ struct crypto_factory_t {
         * @return                              prf_t instance, NULL if not supported
         */
        prf_t* (*create_prf)(crypto_factory_t *this, pseudo_random_function_t algo);
-       
+
        /**
         * Create a source of randomness.
         *
@@ -109,7 +109,7 @@ struct crypto_factory_t {
         * @return                              rng_t instance, NULL if no RNG with such a quality
         */
        rng_t* (*create_rng)(crypto_factory_t *this, rng_quality_t quality);
-       
+
        /**
         * Create a diffie hellman instance.
         *
@@ -118,7 +118,7 @@ struct crypto_factory_t {
         */
        diffie_hellman_t* (*create_dh)(crypto_factory_t *this,
                                                                   diffie_hellman_group_t group);
-       
+
        /**
         * Register a crypter constructor.
         *
@@ -128,14 +128,14 @@ struct crypto_factory_t {
         */
        void (*add_crypter)(crypto_factory_t *this, encryption_algorithm_t algo,
                                                crypter_constructor_t create);
-       
+
        /**
         * Unregister a crypter constructor.
         *
         * @param create                constructor function to unregister
         */
        void (*remove_crypter)(crypto_factory_t *this, crypter_constructor_t create);
-       
+
        /**
         * Register a signer constructor.
         *
@@ -145,14 +145,14 @@ struct crypto_factory_t {
         */
        void (*add_signer)(crypto_factory_t *this, integrity_algorithm_t algo,
                                           signer_constructor_t create);
-       
+
        /**
         * Unregister a signer constructor.
         *
         * @param create                constructor function to unregister
         */
        void (*remove_signer)(crypto_factory_t *this, signer_constructor_t create);
-       
+
        /**
         * Register a hasher constructor.
         *
@@ -165,14 +165,14 @@ struct crypto_factory_t {
         */
        void (*add_hasher)(crypto_factory_t *this, hash_algorithm_t algo,
                                           hasher_constructor_t create);
-       
+
        /**
         * Unregister a hasher constructor.
         *
         * @param create                constructor function to unregister
         */
        void (*remove_hasher)(crypto_factory_t *this, hasher_constructor_t create);
-       
+
        /**
         * Register a prf constructor.
         *
@@ -182,14 +182,14 @@ struct crypto_factory_t {
         */
        void (*add_prf)(crypto_factory_t *this, pseudo_random_function_t algo,
                                        prf_constructor_t create);
-       
+
        /**
         * Unregister a prf constructor.
         *
         * @param create                constructor function to unregister
         */
        void (*remove_prf)(crypto_factory_t *this, prf_constructor_t create);
-       
+
        /**
         * Register a source of randomness.
         *
@@ -197,14 +197,14 @@ struct crypto_factory_t {
         * @param create                constructor function for such a quality
         */
        void (*add_rng)(crypto_factory_t *this, rng_quality_t quality, rng_constructor_t create);
-       
+
        /**
         * Unregister a source of randomness.
         *
         * @param create                constructor function to unregister
         */
        void (*remove_rng)(crypto_factory_t *this, rng_constructor_t create);
-       
+
        /**
         * Register a diffie hellman constructor.
         *
@@ -214,49 +214,49 @@ struct crypto_factory_t {
         */
        void (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
                                   dh_constructor_t create);
-       
+
        /**
         * Unregister a diffie hellman constructor.
         *
         * @param create                constructor function to unregister
         */
        void (*remove_dh)(crypto_factory_t *this, dh_constructor_t create);
-       
+
        /**
         * Create an enumerator over all registered crypter algorithms.
         *
         * @return                              enumerator over encryption_algorithm_t
         */
        enumerator_t* (*create_crypter_enumerator)(crypto_factory_t *this);
-       
+
        /**
         * Create an enumerator over all registered signer algorithms.
         *
         * @return                              enumerator over integrity_algorithm_t
         */
        enumerator_t* (*create_signer_enumerator)(crypto_factory_t *this);
-       
+
        /**
         * Create an enumerator over all registered hasher algorithms.
         *
         * @return                              enumerator over hash_algorithm_t
         */
        enumerator_t* (*create_hasher_enumerator)(crypto_factory_t *this);
-       
+
        /**
         * Create an enumerator over all registered PRFs.
         *
         * @return                              enumerator over pseudo_random_function_t
         */
        enumerator_t* (*create_prf_enumerator)(crypto_factory_t *this);
-       
+
        /**
         * Create an enumerator over all registered diffie hellman groups.
         *
         * @return                              enumerator over diffie_hellman_group_t
         */
        enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
-       
+
        /**
         * Add a test vector to the crypto factory.
         *
@@ -264,7 +264,7 @@ struct crypto_factory_t {
         * @param ...                   pointer to a test vector, defined in crypto_tester.h
         */
        void (*add_test_vector)(crypto_factory_t *this, transform_type_t type, ...);
-       
+
        /**
         * Destroy a crypto_factory instance.
         */
index 4d13474a100529cfb000ba6ff17400839e95d3cf..86daf65f91d53316874d5d82dc5d308a7dd57f17 100644 (file)
@@ -24,42 +24,42 @@ typedef struct private_crypto_tester_t private_crypto_tester_t;
  * Private data of an crypto_tester_t object.
  */
 struct private_crypto_tester_t {
-       
+
        /**
         * Public crypto_tester_t interface.
         */
        crypto_tester_t public;
-       
+
        /**
         * List of crypter test vectors
         */
        linked_list_t *crypter;
-       
+
        /**
         * List of signer test vectors
         */
        linked_list_t *signer;
-       
+
        /**
         * List of hasher test vectors
         */
        linked_list_t *hasher;
-       
+
        /**
         * List of PRF test vectors
         */
        linked_list_t *prf;
-       
+
        /**
         * List of RNG test vectors
         */
        linked_list_t *rng;
-       
+
        /**
         * Is a test vector required to pass a test?
         */
        bool required;
-       
+
        /**
         * should we run RNG_TRUE tests? Enough entropy?
         */
@@ -76,13 +76,13 @@ static bool test_crypter(private_crypto_tester_t *this,
        crypter_test_vector_t *vector;
        bool failed = FALSE;
        u_int tested = 0;
-       
+
        enumerator = this->crypter->create_enumerator(this->crypter);
        while (enumerator->enumerate(enumerator, &vector))
        {
                crypter_t *crypter;
                chunk_t key, plain, cipher, iv;
-               
+
                if (vector->alg != alg)
                {
                        continue;
@@ -96,14 +96,14 @@ static bool test_crypter(private_crypto_tester_t *this,
                {       /* key size not supported... */
                        continue;
                }
-               
+
                failed = FALSE;
                tested++;
-               
+
                key = chunk_create(vector->key, crypter->get_key_size(crypter));
                crypter->set_key(crypter, key);
                iv = chunk_create(vector->iv, crypter->get_block_size(crypter));
-               
+
                /* allocated encryption */
                plain = chunk_create(vector->plain, vector->len);
                crypter->encrypt(crypter, plain, iv, &cipher);
@@ -132,7 +132,7 @@ static bool test_crypter(private_crypto_tester_t *this,
                        failed = TRUE;
                }
                free(plain.ptr);
-               
+
                crypter->destroy(crypter);
                if (failed)
                {
@@ -167,18 +167,18 @@ static bool test_signer(private_crypto_tester_t *this,
        signer_test_vector_t *vector;
        bool failed = FALSE;
        u_int tested = 0;
-       
+
        enumerator = this->signer->create_enumerator(this->signer);
        while (enumerator->enumerate(enumerator, &vector))
        {
                signer_t *signer;
                chunk_t key, data, mac;
-               
+
                if (vector->alg != alg)
                {
                        continue;
                }
-               
+
                tested++;
                signer = create(alg);
                if (!signer)
@@ -188,12 +188,12 @@ static bool test_signer(private_crypto_tester_t *this,
                        failed = TRUE;
                        break;
                }
-               
+
                failed = FALSE;
-               
+
                key = chunk_create(vector->key, signer->get_key_size(signer));
                signer->set_key(signer, key);
-               
+
                /* allocated signature */
                data = chunk_create(vector->data, vector->len);
                signer->allocate_signature(signer, data, &mac);
@@ -236,7 +236,7 @@ static bool test_signer(private_crypto_tester_t *this,
                        }
                }
                free(mac.ptr);
-               
+
                signer->destroy(signer);
                if (failed)
                {
@@ -271,18 +271,18 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
        hasher_test_vector_t *vector;
        bool failed = FALSE;
        u_int tested = 0;
-       
+
        enumerator = this->hasher->create_enumerator(this->hasher);
        while (enumerator->enumerate(enumerator, &vector))
        {
                hasher_t *hasher;
                chunk_t data, hash;
-               
+
                if (vector->alg != alg)
                {
                        continue;
                }
-               
+
                tested++;
                hasher = create(alg);
                if (!hasher)
@@ -292,9 +292,9 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
                        failed = TRUE;
                        break;
                }
-               
+
                failed = FALSE;
-               
+
                /* allocated hash */
                data = chunk_create(vector->data, vector->len);
                hasher->allocate_hash(hasher, data, &hash);
@@ -326,7 +326,7 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
                        }
                }
                free(hash.ptr);
-               
+
                hasher->destroy(hasher);
                if (failed)
                {
@@ -361,18 +361,18 @@ static bool test_prf(private_crypto_tester_t *this,
        prf_test_vector_t *vector;
        bool failed = FALSE;
        u_int tested = 0;
-       
+
        enumerator = this->prf->create_enumerator(this->prf);
        while (enumerator->enumerate(enumerator, &vector))
        {
                prf_t *prf;
                chunk_t key, seed, out;
-               
+
                if (vector->alg != alg)
                {
                        continue;
                }
-               
+
                tested++;
                prf = create(alg);
                if (!prf)
@@ -382,12 +382,12 @@ static bool test_prf(private_crypto_tester_t *this,
                        failed = TRUE;
                        break;
                }
-               
+
                failed = FALSE;
-               
+
                key = chunk_create(vector->key, vector->key_size);
                prf->set_key(prf, key);
-               
+
                /* allocated bytes */
                seed = chunk_create(vector->seed, vector->len);
                prf->allocate_bytes(prf, seed, &out);
@@ -427,7 +427,7 @@ static bool test_prf(private_crypto_tester_t *this,
                        }
                }
                free(out.ptr);
-               
+
                prf->destroy(prf);
                if (failed)
                {
@@ -462,25 +462,25 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
        rng_test_vector_t *vector;
        bool failed = FALSE;
        u_int tested = 0;
-       
+
        if (!this->rng_true && quality == RNG_TRUE)
        {
                DBG1("enabled  %N: skipping test (disabled by config)",
                         rng_quality_names, quality);
                return TRUE;
        }
-       
+
        enumerator = this->rng->create_enumerator(this->rng);
        while (enumerator->enumerate(enumerator, &vector))
        {
                rng_t *rng;
                chunk_t data;
-               
+
                if (vector->quality != quality)
                {
                        continue;
                }
-               
+
                tested++;
                rng = create(quality);
                if (!rng)
@@ -490,9 +490,9 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
                        failed = TRUE;
                        break;
                }
-               
+
                failed = FALSE;
-               
+
                /* allocated bytes */
                rng->allocate_bytes(rng, vector->len, &data);
                if (data.len != vector->len)
@@ -511,7 +511,7 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
                        failed = TRUE;
                }
                free(data.ptr);
-               
+
                rng->destroy(rng);
                if (failed)
                {
@@ -600,7 +600,7 @@ static void destroy(private_crypto_tester_t *this)
 crypto_tester_t *crypto_tester_create()
 {
        private_crypto_tester_t *this = malloc_thing(private_crypto_tester_t);
-       
+
        this->public.test_crypter = (bool(*)(crypto_tester_t*, encryption_algorithm_t alg,size_t key_size, crypter_constructor_t create))test_crypter;
        this->public.test_signer = (bool(*)(crypto_tester_t*, integrity_algorithm_t alg, signer_constructor_t create))test_signer;
        this->public.test_hasher = (bool(*)(crypto_tester_t*, hash_algorithm_t alg, hasher_constructor_t create))test_hasher;
@@ -612,18 +612,18 @@ crypto_tester_t *crypto_tester_create()
        this->public.add_prf_vector = (void(*)(crypto_tester_t*, prf_test_vector_t *vector))add_prf_vector;
        this->public.add_rng_vector = (void(*)(crypto_tester_t*, rng_test_vector_t *vector))add_rng_vector;
        this->public.destroy = (void(*)(crypto_tester_t*))destroy;
-       
+
        this->crypter = linked_list_create();
        this->signer = linked_list_create();
        this->hasher = linked_list_create();
        this->prf = linked_list_create();
        this->rng = linked_list_create();
-       
+
        this->required = lib->settings->get_bool(lib->settings,
                                                                "libstrongswan.crypto_test.required", FALSE);
        this->rng_true = lib->settings->get_bool(lib->settings,
                                                                "libstrongswan.crypto_test.rng_true", FALSE);
-       
+
        return &this->public;
 }
 
index d2929f33d05e793861c38b18a71dda9682867887..ddab48dd6b68dc5651f6acc03a27aa4d83c8560e 100644 (file)
@@ -109,12 +109,12 @@ struct rng_test_vector_t {
  * Cryptographic primitive testing framework.
  */
 struct crypto_tester_t {
-       
+
        /**
         * Test a crypter algorithm, optionally using a specified key size.
         *
         * @param alg                   algorithm to test
-        * @param key_size              key size to test, 0 for all 
+        * @param key_size              key size to test, 0 for all
         * @param create                constructor function for the crypter
         * @return                              TRUE if test passed
         */
@@ -183,14 +183,14 @@ struct crypto_tester_t {
         * @param vector                pointer to test vector
         */
        void (*add_prf_vector)(crypto_tester_t *this, prf_test_vector_t *vector);
-       
+
        /**
         * Add a test vector to test a RNG.
         *
         * @param vector                pointer to test vector
         */
        void (*add_rng_vector)(crypto_tester_t *this, rng_test_vector_t *vector);
-       
+
        /**
         * Destroy a crypto_tester_t.
         */
index a40a735260e578a7168143251c906c2381ef77e1..842938c3b2f87f035cb49cfb53e27f8f7d555044 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup diffie_hellman diffie_hellman
  * @{ @ingroup crypto
@@ -32,7 +32,7 @@ typedef struct diffie_hellman_t diffie_hellman_t;
  *
  * The modulus (or group) to use for a Diffie-Hellman calculation.
  * See IKEv2 RFC 3.3.2 and RFC 3526.
- * 
+ *
  * ECP groups are defined in RFC 4753 and RFC 5114.
  */
 enum diffie_hellman_group_t {
@@ -63,39 +63,39 @@ extern enum_name_t *diffie_hellman_group_names;
  * Implementation of the Diffie-Hellman algorithm, as in RFC2631.
  */
 struct diffie_hellman_t {
-               
+
        /**
         * Returns the shared secret of this diffie hellman exchange.
-        *      
-        * Space for returned secret is allocated and must be 
+        *
+        * Space for returned secret is allocated and must be
         * freed by the caller.
-        * 
+        *
         * @param secret        shared secret will be written into this chunk
         * @return                      SUCCESS, FAILED if not both DH values are set
         */
        status_t (*get_shared_secret) (diffie_hellman_t *this, chunk_t *secret);
-       
+
        /**
         * Sets the public value of partner.
-        *      
+        *
         * Chunk gets cloned and can be destroyed afterwards.
-        * 
+        *
         * @param value         public value of partner
         */
        void (*set_other_public_value) (diffie_hellman_t *this, chunk_t value);
-       
+
        /**
         * Gets the own public value to transmit.
-        *      
+        *
         * Space for returned chunk is allocated and must be freed by the caller.
-        * 
+        *
         * @param value         public value of caller is stored at this location
         */
        void (*get_my_public_value) (diffie_hellman_t *this, chunk_t *value);
-       
+
        /**
         * Get the DH group used.
-        * 
+        *
         * @return                      DH group set in construction
         */
        diffie_hellman_group_t (*get_dh_group) (diffie_hellman_t *this);
index 6deed37ab800591c562c53290a1d0b8e5ed44b2f..21652d724036b2b7890605d5c776bef12f9def55 100644 (file)
@@ -14,7 +14,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup hasher hasher
  * @{ @ingroup crypto
@@ -66,43 +66,43 @@ extern enum_name_t *hash_algorithm_names;
 struct hasher_t {
        /**
         * Hash data and write it in the buffer.
-        * 
+        *
         * If the parameter hash is NULL, no result is written back
         * and more data can be appended to already hashed data.
         * If not, the result is written back and the hasher is reset.
-        * 
+        *
         * The hash output parameter must hold at least
         * hash_t.get_block_size() bytes.
-        * 
+        *
         * @param data          data to hash
         * @param hash          pointer where the hash will be written
         */
        void (*get_hash) (hasher_t *this, chunk_t data, u_int8_t *hash);
-       
+
        /**
         * Hash data and allocate space for the hash.
-        * 
+        *
         * If the parameter hash is NULL, no result is written back
         * and more data can be appended to already hashed data.
         * If not, the result is written back and the hasher is reset.
-        * 
+        *
         * @param data          chunk with data to hash
         * @param hash          chunk which will hold allocated hash
         */
        void (*allocate_hash) (hasher_t *this, chunk_t data, chunk_t *hash);
-       
+
        /**
         * Get the size of the resulting hash.
-        * 
+        *
         * @return                      hash size in bytes
         */
        size_t (*get_hash_size) (hasher_t *this);
-       
+
        /**
         * Resets the hashers state.
         */
        void (*reset) (hasher_t *this);
-       
+
        /**
         * Destroys a hasher object.
         */
@@ -111,7 +111,7 @@ struct hasher_t {
 
 /**
  * Conversion of ASN.1 OID to hash algorithm.
- * 
+ *
  * @param oid                  ASN.1 OID
  * @return                             hash algorithm, HASH_UNKNOWN if OID unsuported
  */
@@ -119,7 +119,7 @@ hash_algorithm_t hasher_algorithm_from_oid(int oid);
 
 /**
  * Conversion of hash algorithm into ASN.1 OID.
- * 
+ *
  * @param alg                  hash algorithm
  * @return                             ASN.1 OID, or OID_UNKNOW
  */
@@ -127,7 +127,7 @@ int hasher_algorithm_to_oid(hash_algorithm_t alg);
 
 /**
  * Conversion of hash signature algorithm into ASN.1 OID.
- * 
+ *
  * @param alg                  hash algorithm
  * @return                             ASN.1 OID if, or OID_UNKNOW
  */
index e0ea9a35590df59db9c4ee4de26801827e19f29c..f3ec2d839f5d52392d187e6d10cefe0d5e521d01 100644 (file)
@@ -114,13 +114,13 @@ static char ASN1_pkcs7_encrypted_data_oid_str[] = {
                  0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06
 };
 
-static const chunk_t ASN1_pkcs7_data_oid = 
+static const chunk_t ASN1_pkcs7_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_data_oid_str);
 static const chunk_t ASN1_pkcs7_signed_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_signed_data_oid_str);
 static const chunk_t ASN1_pkcs7_enveloped_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_enveloped_data_oid_str);
-static const chunk_t ASN1_pkcs7_signed_enveloped_data_oid = 
+static const chunk_t ASN1_pkcs7_signed_enveloped_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_signed_enveloped_data_oid_str);
 static const chunk_t ASN1_pkcs7_digested_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_digested_data_oid_str);
@@ -140,7 +140,7 @@ static u_char ASN1_des_cbc_oid_str[] = {
                  0x2B, 0x0E, 0x03, 0x02, 0x07
 };
 
-static const chunk_t ASN1_3des_ede_cbc_oid = 
+static const chunk_t ASN1_3des_ede_cbc_oid =
                                                chunk_from_buf(ASN1_3des_ede_cbc_oid_str);
 static const chunk_t ASN1_des_cbc_oid =
                                                chunk_from_buf(ASN1_des_cbc_oid_str);
@@ -769,7 +769,7 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
         */
        {
                rng_t *rng;
-               
+
                rng = lib->crypto->create_rng(lib->crypto, RNG_TRUE);
                rng->allocate_bytes(rng, crypter->get_key_size(crypter), &symmetricKey);
                DBG4("  symmetric encryption key: %B", &symmetricKey);
@@ -808,12 +808,12 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
        chunk_clear(&in);
     DBG3("  encrypted data: %B", &out);
 
-       /* build pkcs7 enveloped data object */ 
+       /* build pkcs7 enveloped data object */
        {
                chunk_t contentEncryptionAlgorithm = asn1_wrap(ASN1_SEQUENCE, "cm",
                                        alg_oid,
                                        asn1_wrap(ASN1_OCTET_STRING, "m", iv));
-       
+
                chunk_t encryptedContentInfo = asn1_wrap(ASN1_SEQUENCE, "cmm",
                                        ASN1_pkcs7_data_oid,
                                        contentEncryptionAlgorithm,
@@ -866,7 +866,7 @@ bool build_signedData(private_pkcs7_t *this, rsa_private_key_t *private_key,
                if(this->data.ptr != NULL)
                {
                        hasher_t *hasher;
-               
+
                        hasher = lib->crypto->create_hasher(lib->crypto, alg);
                        if (hasher == NULL)
                        {
@@ -874,13 +874,13 @@ bool build_signedData(private_pkcs7_t *this, rsa_private_key_t *private_key,
                                         hash_algorithm_names, alg);
                                return FALSE;
                        }
-               
+
                        /* take the current time as signingTime */
                        time_t now = time(NULL);
                        chunk_t signingTime = asn1_from_time(&now, ASN1_UTCTIME);
 
                        chunk_t messageDigest, attributes;
-       
+
                        hasher->allocate_hash(hasher, this->data, &messageDigest);
                        hasher->destroy(hasher);
                        this->attributes->set_attribute(this->attributes,
@@ -1008,7 +1008,7 @@ end:
 static private_pkcs7_t *pkcs7_create_empty(void)
 {
        private_pkcs7_t *this = malloc_thing(private_pkcs7_t);
-       
+
        /* initialize */
        this->type = OID_UNKNOWN;
        this->content = chunk_empty;
@@ -1043,7 +1043,7 @@ static private_pkcs7_t *pkcs7_create_empty(void)
 pkcs7_t *pkcs7_create_from_chunk(chunk_t chunk, u_int level)
 {
        private_pkcs7_t *this = pkcs7_create_empty();
-       
+
        this->level = level + 2;
        if (!parse_contentInfo(chunk, level, this))
        {
index 49684f3f8c288faf3dbe577463dc9aa020dcc637..c4d452286d0511691df01d00eb68ce2856b3f627 100644 (file)
@@ -14,7 +14,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup pkcs7 pkcs7
  * @{ @ingroup crypto
@@ -38,35 +38,35 @@ typedef struct pkcs7_t pkcs7_t;
 struct pkcs7_t {
        /**
         * Check if the PKCS#7 contentType is data
-        * 
+        *
         * @return                              TRUE if the contentType is data
         */
        bool (*is_data) (pkcs7_t *this);
 
        /**
         * Check if the PKCS#7 contentType is signedData
-        * 
+        *
         * @return                              TRUE if the contentType is signedData
         */
        bool (*is_signedData) (pkcs7_t *this);
 
        /**
         * Check if the PKCS#7 contentType is envelopedData
-        * 
+        *
         * @return                              TRUE if the contentType is envelopedData
         */
        bool (*is_envelopedData) (pkcs7_t *this);
 
        /**
         * Parse a PKCS#7 data content.
-        * 
+        *
         * @return                              TRUE if parsing was successful
         */
        bool (*parse_data) (pkcs7_t *this);
 
        /**
         * Parse a PKCS#7 signedData content.
-        * 
+        *
         * @param cacert                cacert used to verify the signature
         * @return                              TRUE if parsing was successful
         */
@@ -74,7 +74,7 @@ struct pkcs7_t {
 
        /**
         * Parse a PKCS#7 envelopedData content.
-        * 
+        *
         * @param serialNumber  serialNumber of the request
         * @param key                   private key used to decrypt the symmetric key
         * @return                              TRUE if parsing was successful
@@ -97,21 +97,21 @@ struct pkcs7_t {
 
        /**
         * Create an iterator for the certificates.
-        * 
+        *
         * @return                              iterator for the certificates
         */
        iterator_t *(*create_certificate_iterator) (pkcs7_t *this);
 
        /**
         * Add a certificate.
-        * 
+        *
         * @param cert                  certificate to be included
         */
        void (*set_certificate) (pkcs7_t *this, x509_t *cert);
 
        /**
         * Add authenticated attributes.
-        * 
+        *
         * @param attributes    attributes to be included
         */
        void (*set_attributes) (pkcs7_t *this, pkcs9_t *attributes);
@@ -151,7 +151,7 @@ struct pkcs7_t {
 
 /**
  * Read a PKCS#7 contentInfo object from a DER encoded chunk.
- * 
+ *
  * @param chunk                chunk containing DER encoded data
  * @param level                ASN.1 parsing start level
  * @return                     created pkcs7_contentInfo object, or NULL if invalid.
@@ -160,7 +160,7 @@ pkcs7_t *pkcs7_create_from_chunk(chunk_t chunk, u_int level);
 
 /**
  * Create a PKCS#7 contentInfo object
- * 
+ *
  * @param data                 chunk containing data
  * @return                             created pkcs7_contentInfo object.
  */
index 525ea9db57f67f29a92de098ea17d0b84ae4e558..9585e54f15f98eec151cfd42521c68ea852e5b48 100644 (file)
@@ -68,7 +68,7 @@ struct attribute_t {
 
        /**
         * Destroys the attribute.
-        * 
+        *
         * @param this                  attribute to destroy
         */
        void (*destroy) (attribute_t *this);
@@ -243,7 +243,7 @@ static void build_encoding(private_pkcs9_t *this)
        /* allocate memory for the attributes and build the encoding */
        {
                u_char *pos = asn1_build_object(&this->encoding, ASN1_SET, attributes_len);
-               
+
                iterator = this->attributes->create_iterator(this->attributes, TRUE);
 
                while (iterator->iterate(iterator, (void**)&attribute))
@@ -346,7 +346,7 @@ static void destroy(private_pkcs9_t *this)
 static private_pkcs9_t *pkcs9_create_empty(void)
 {
        private_pkcs9_t *this = malloc_thing(private_pkcs9_t);
-       
+
        /* initialize */
        this->encoding = chunk_empty;
        this->attributes = linked_list_create();
@@ -452,7 +452,7 @@ end:
 pkcs9_t *pkcs9_create_from_chunk(chunk_t chunk, u_int level)
 {
        private_pkcs9_t *this = pkcs9_create_empty();
-       
+
        this->encoding = chunk_clone(chunk);
 
        if (!parse_attributes(chunk, level, this))
index 80d9157010dd6363644add284f23176fbe7becd7..5b85692d61dc21f05eb7e0ba854c9b935559b816 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup pkcs9 pkcs9
  * @{ @ingroup crypto
@@ -29,7 +29,7 @@ typedef struct pkcs9_t pkcs9_t;
  * PKCS#9 attributes.
  */
 struct pkcs9_t {
-       
+
        /**
         * Generate ASN.1 encoding of attribute list
         */
@@ -54,7 +54,7 @@ struct pkcs9_t {
         * Adds a PKCS#9 attribute
         *
         * @param oid                   OID of the attribute
-        * @param value                 ASN.1 encoded value of the attribute 
+        * @param value                 ASN.1 encoded value of the attribute
         */
        void (*set_attribute) (pkcs9_t *this, int oid, chunk_t value);
 
@@ -68,7 +68,7 @@ struct pkcs9_t {
        /**
         * Add a PKCS#9 messageDigest attribute
         *
-        * @param value                 messageDigest 
+        * @param value                 messageDigest
         */
        void (*set_messageDigest) (pkcs9_t *this, chunk_t value);
 
@@ -80,7 +80,7 @@ struct pkcs9_t {
 
 /**
  * Read a PKCS#9 attribute list from a DER encoded chunk.
- * 
+ *
  * @param chunk                chunk containing DER encoded data
  * @param level                ASN.1 parsing start level
  * @return                     created pkcs9 attribute list, or NULL if invalid.
@@ -89,7 +89,7 @@ pkcs9_t *pkcs9_create_from_chunk(chunk_t chunk, u_int level);
 
 /**
  * Create an empty PKCS#9 attribute list
- * 
+ *
  * @return                             created pkcs9 attribute list.
  */
 pkcs9_t *pkcs9_create(void);
index a4fc377efa29dc9a6958626548ca6a8346032eae..6bd0f74650b8a38599127b39218dfd8b68a0d4eb 100644 (file)
@@ -22,34 +22,34 @@ typedef struct private_prf_plus_t private_prf_plus_t;
 
 /**
  * Private data of an prf_plus_t object.
- * 
+ *
  */
 struct private_prf_plus_t {
        /**
         * Public interface of prf_plus_t.
         */
        prf_plus_t public;
-       
+
        /**
         * PRF to use.
         */
        prf_t *prf;
-       
+
        /**
         * Initial seed.
         */
        chunk_t seed;
-       
+
        /**
         * Buffer to store current PRF result.
         */
        chunk_t buffer;
-               
+
        /**
         * Already given out bytes in current buffer.
         */
        size_t given_out;
-       
+
        /**
         * Octet which will be appended to the seed.
         */
@@ -60,18 +60,18 @@ struct private_prf_plus_t {
  * Implementation of prf_plus_t.get_bytes.
  */
 static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
-{      
+{
        chunk_t appending_chunk;
        size_t bytes_in_round;
        size_t total_bytes_written = 0;
-       
+
        appending_chunk.ptr = &(this->appending_octet);
        appending_chunk.len = 1;
-       
+
        while (length > 0)
        {       /* still more to do... */
                if (this->buffer.len == this->given_out)
-               {       /* no bytes left in buffer, get next*/  
+               {       /* no bytes left in buffer, get next*/
                        this->prf->get_bytes(this->prf, this->buffer, NULL);
                        this->prf->get_bytes(this->prf, this->seed, NULL);
                        this->prf->get_bytes(this->prf, appending_chunk, this->buffer.ptr);
@@ -82,7 +82,7 @@ static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
                bytes_in_round = min(length, this->buffer.len - this->given_out);
                /* copy bytes from buffer with offset */
                memcpy(buffer + total_bytes_written, this->buffer.ptr + this->given_out, bytes_in_round);
-               
+
                length -= bytes_in_round;
                this->given_out += bytes_in_round;
                total_bytes_written += bytes_in_round;
@@ -91,7 +91,7 @@ static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
 
 /**
  * Implementation of prf_plus_t.allocate_bytes.
- */    
+ */
 static void allocate_bytes(private_prf_plus_t *this, size_t length, chunk_t *chunk)
 {
        if (length)
@@ -123,23 +123,23 @@ prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed)
 {
        private_prf_plus_t *this;
        chunk_t appending_chunk;
-       
+
        this = malloc_thing(private_prf_plus_t);
 
        /* set public methods */
        this->public.get_bytes = (void (*)(prf_plus_t *,size_t,u_int8_t*))get_bytes;
        this->public.allocate_bytes = (void (*)(prf_plus_t *,size_t,chunk_t*))allocate_bytes;
        this->public.destroy = (void (*)(prf_plus_t *))destroy;
-       
+
        /* take over prf */
        this->prf = prf;
-       
+
        /* allocate buffer for prf output */
        this->buffer.len = prf->get_block_size(prf);
        this->buffer.ptr = malloc(this->buffer.len);
 
        this->appending_octet = 0x01;
-       
+
        /* clone seed */
        this->seed.ptr = clalloc(seed.ptr, seed.len);
        this->seed.len = seed.len;
@@ -151,6 +151,6 @@ prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed)
        this->prf->get_bytes(this->prf, appending_chunk, this->buffer.ptr);
        this->given_out = 0;
        this->appending_octet++;
-       
+
        return &(this->public);
 }
index 2e5b66152547a681a4af2e47cb1e6a6e45df2f42..4179f2695a6f2ef1281c338da9928d05df346005 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup prf_plus prf_plus
  * @{ @ingroup crypto
@@ -36,26 +36,26 @@ typedef struct prf_plus_t prf_plus_t;
 struct prf_plus_t {
        /**
         * Get pseudo random bytes.
-        * 
+        *
         * Get the next few bytes of the prf+ output. Space
         * must be allocated by the caller.
-        * 
+        *
         * @param length        number of bytes to get
         * @param buffer        pointer where the generated bytes will be written
         */
        void (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
-       
+
        /**
         * Allocate pseudo random bytes.
-        * 
+        *
         * Get the next few bytes of the prf+ output. This function
         * will allocate the required space.
-        * 
+        *
         * @param length        number of bytes to get
         * @param chunk         chunk which will hold generated bytes
         */
        void (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
-       
+
        /**
         * Destroys a prf_plus_t object.
         */
@@ -64,11 +64,11 @@ struct prf_plus_t {
 
 /**
  * Creates a new prf_plus_t object.
- * 
+ *
  * Seed will be cloned. prf will
  * not be cloned, must be destroyed outside after
  * prf_plus_t usage.
- * 
+ *
  * @param prf                          prf object to use
  * @param seed                         input seed for prf
  * @return                                     prf_plus_t object
index f2a5afc45f9f64fde1698d0daa457262f7c72e56..6e853444f4cee1088b1bfdae7da7da0cc0e55722 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup prf prf
  * @{ @ingroup crypto
@@ -55,7 +55,7 @@ enum pseudo_random_function_t {
        PRF_FIPS_SHA1_160 = 1025,
        /** FIPS 186-2-change1, uses fixed output size of 160bit */
        PRF_FIPS_DES = 1026,
-       /** 
+       /**
         * Keyed hash algorithm using SHA1, used in EAP-AKA:
         * This PRF uses SHA1, but XORs the key into the IV. No "Final()" operation
         * is applied to the SHA1 state. */
@@ -78,39 +78,39 @@ struct prf_t {
         * @param buffer        pointer where the generated bytes will be written
         */
        void (*get_bytes) (prf_t *this, chunk_t seed, u_int8_t *buffer);
-       
+
        /**
         * Generates pseudo random bytes and allocate space for them.
-        * 
+        *
         * @param seed          a chunk containing the seed for the next bytes
         * @param chunk         chunk which will hold generated bytes
         */
        void (*allocate_bytes) (prf_t *this, chunk_t seed, chunk_t *chunk);
-       
+
        /**
         * Get the block size of this prf_t object.
-        * 
+        *
         * @return                      block size in bytes
         */
        size_t (*get_block_size) (prf_t *this);
-       
+
        /**
         * Get the key size of this prf_t object.
         *
         * This is a suggestion only, all implemented PRFs accept variable key
         * length.
-        * 
+        *
         * @return                      key size in bytes
         */
        size_t (*get_key_size) (prf_t *this);
-       
+
        /**
         * Set the key for this prf_t object.
-        * 
+        *
         * @param key           key to set
         */
        void (*set_key) (prf_t *this, chunk_t key);
-       
+
        /**
         * Destroys a prf object.
         */
index 86cb7ef092cbf27d2839440376420750be03776d..fb2c846307952b350cad0eddd8f9c5e36fcbbedd 100644 (file)
@@ -24,7 +24,7 @@ struct proposal_token {
     char             *name;
     transform_type_t  type;
        u_int16_t         algorithm;
-    u_int16_t         keysize;  
+    u_int16_t         keysize;
 };
 
 extern const proposal_token_t* proposal_get_token(register const char *str,
index 89bc2f2de5ca11177cc21a22449cf1f2df63c195..36ef52bb498e04507ed50cb1dcfe523bfbc49b02 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup rng rng
  * @{ @ingroup crypto
@@ -55,15 +55,15 @@ struct rng_t {
         * @param buffer        pointer where the generated bytes will be written
         */
        void (*get_bytes) (rng_t *this, size_t len, u_int8_t *buffer);
-       
+
        /**
         * Generates random bytes and allocate space for them.
-        * 
+        *
         * @param len           number of bytes to get
         * @param chunk         chunk which will hold generated bytes
         */
        void (*allocate_bytes) (rng_t *this, size_t len, chunk_t *chunk);
-       
+
        /**
         * Destroys a rng object.
         */
index 0d9bfc5af6ffab38b236d87d271eef3ebcdd6ff1..c222af8ea549026adfc4ef423baf6fced33254f4 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup signer signer
  * @{ @ingroup crypto
@@ -80,53 +80,53 @@ struct signer_t {
         *
         * If buffer is NULL, data is processed and prepended to a next call until
         * buffer is a valid pointer.
-        * 
+        *
         * @param data          a chunk containing the data to sign
         * @param buffer        pointer where the signature will be written
         */
        void (*get_signature) (signer_t *this, chunk_t data, u_int8_t *buffer);
-       
+
        /**
         * Generate a signature and allocate space for it.
         *
         * If chunk is NULL, data is processed and prepended to a next call until
         * chunk is a valid chunk pointer.
-        * 
+        *
         * @param data          a chunk containing the data to sign
         * @param chunk         chunk which will hold the allocated signature
         */
        void (*allocate_signature) (signer_t *this, chunk_t data, chunk_t *chunk);
-       
+
        /**
         * Verify a signature.
-        * 
+        *
         * @param data          a chunk containing the data to verify
         * @param signature     a chunk containing the signature
         * @return                      TRUE, if signature is valid, FALSE otherwise
         */
        bool (*verify_signature) (signer_t *this, chunk_t data, chunk_t signature);
-       
+
        /**
         * Get the block size of this signature algorithm.
-        * 
+        *
         * @return                      block size in bytes
         */
        size_t (*get_block_size) (signer_t *this);
-       
+
        /**
         * Get the key size of the signature algorithm.
-        * 
+        *
         * @return                      key size in bytes
         */
        size_t (*get_key_size) (signer_t *this);
-       
+
        /**
         * Set the key for this object.
-        * 
+        *
         * @param key           key to set
         */
        void (*set_key) (signer_t *this, chunk_t key);
-       
+
        /**
         * Destroys a signer_t object.
         */
index 16472d869a8870b7ece172c91b30bf4a06ff3c67..42f1f8d5b18e78ba5a6f8cfa7762ab07e99f0320 100644 (file)
@@ -63,12 +63,12 @@ enum db_driver_t {
    char *atext;
    database_t *db;
    enumerator_t *enumerator;
-   
+
    db = lib->database->create("mysql://user:pass@host/database");
    affected = db->execute(db, &rowid, "INSERT INTO table VALUES (?, ?)",
                                                  DB_INT, 77, DB_TEXT, "a text");
    printf("inserted %d row, new row ID: %d\n", affected, rowid);
-   
+
    enumerator = db->query(db, "SELECT aint, atext FROM table WHERE aint > ?",
                                                  DB_INT, 10,           // 1 argument to SQL string
                                                  DB_INT, DB_TEXT); // 2 enumerated types in query
@@ -83,7 +83,7 @@ enum db_driver_t {
    @endcode
  */
 struct database_t {
-       
+
        /**
         * Run a query which returns rows, such as a SELECT.
         *
@@ -93,7 +93,7 @@ struct database_t {
         * @return                      enumerator as defined with arguments, NULL on failure
         */
        enumerator_t* (*query)(database_t *this, char *sql, ...);
-       
+
        /**
         * Execute a query which dows not return rows, such as INSERT.
         *
@@ -103,7 +103,7 @@ struct database_t {
         * @return                      number of affected rows, < 0 on failure
         */
        int (*execute)(database_t *this, int *rowid, char *sql, ...);
-       
+
        /**
         * Get the database implementation type.
         *
@@ -113,7 +113,7 @@ struct database_t {
         * @return                      database implementation type
         */
        db_driver_t (*get_driver)(database_t *this);
-       
+
        /**
      * Destroy a database connection.
      */
index ef69278743e984b72999aba154c7b32e8367764a..c0c666138db20bc2c2366d58f44d48ef4c8a1875 100644 (file)
@@ -29,12 +29,12 @@ struct private_database_factory_t {
         * public functions
         */
        database_factory_t public;
-       
+
        /**
         * list of registered database_t implementations
         */
        linked_list_t *databases;
-       
+
        /**
         * mutex to lock access to databases
         */
@@ -49,7 +49,7 @@ static database_t* create(private_database_factory_t *this, char *uri)
        enumerator_t *enumerator;
        database_t *database = NULL;
        database_constructor_t create;
-       
+
        this->mutex->lock(this->mutex);
        enumerator = this->databases->create_enumerator(this->databases);
        while (enumerator->enumerate(enumerator, &create))
@@ -103,15 +103,15 @@ static void destroy(private_database_factory_t *this)
 database_factory_t *database_factory_create()
 {
        private_database_factory_t *this = malloc_thing(private_database_factory_t);
-       
+
        this->public.create = (database_t*(*)(database_factory_t*, char *url))create;
        this->public.add_database = (void(*)(database_factory_t*, database_constructor_t))add_database;
        this->public.remove_database = (void(*)(database_factory_t*, database_constructor_t))remove_database;
        this->public.destroy = (void(*)(database_factory_t*))destroy;
-       
+
        this->databases = linked_list_create();
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index 8875adad78206b22c1b1196100ff385f8694c252..04ca3da13ffd0e840f6f2414b9db895d89e48f0e 100644 (file)
@@ -44,21 +44,21 @@ struct database_factory_t {
         * @return                      database_t instance, NULL if not supported/failed
         */
        database_t* (*create)(database_factory_t *this, char *uri);
-       
+
        /**
         * Register a database constructor.
         *
         * @param create        database constructor to register
         */
        void (*add_database)(database_factory_t *this, database_constructor_t create);
-       
+
        /**
         * Unregister a previously registered database constructor.
         *
         * @param create        database constructor to unregister
         */
        void (*remove_database)(database_factory_t *this, database_constructor_t create);
-       
+
        /**
      * Destroy a database_factory instance.
      */
index b4a84cf76d28189cca2ac4e81375570bb9d7a53d..3db58ba748b45f7767573b4763fd283a4f739c4d 100644 (file)
@@ -26,7 +26,7 @@ void dbg_default(int level, char *fmt, ...)
        if (level <= 1)
        {
                va_list args;
-       
+
                va_start(args, fmt);
                vfprintf(stderr, fmt, args);
                fprintf(stderr, "\n");
index 1413ff54e91c017ba4c0e39e295d6d5721235211..c54eb293ca3c51087391f16f99e9e1e939ae46e3 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup debug debug
  * @{ @ingroup libstrongswan
index 3f3ca1172a14b9a07948059f531ff44360790421..5536f46eaaccc56447b773f228bd86fdc68aec5f 100644 (file)
@@ -98,7 +98,7 @@ struct enum_name_t {
  *
  * This is a convenience macro to use when a enum_name list contains only
  * one range, and is equal as defining ENUM_BEGIN followed by ENUM_END.
- * 
+ *
  * @param name name of the enum_name list
  * @param first        enum value of the first enum string
  * @param last enum value of the last enum string
@@ -109,7 +109,7 @@ struct enum_name_t {
 /**
  * printf hook function for enum_names_t.
  *
- * Arguments are: 
+ * Arguments are:
  *    enum_names_t *names, int value
  */
 int enum_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
index 70d14bf973e7e78ab9128be0709c29fe666e533e..f312206bb39c47d6f22bd2b6cfe61da70846d0e5 100644 (file)
@@ -33,36 +33,36 @@ typedef enum fetcher_option_t fetcher_option_t;
  */
 enum fetcher_option_t {
 
-       /** 
+       /**
         * Data to include in fetch request, e.g. on a HTTP post.
         * Additional argument is a chunk_t
         */
        FETCH_REQUEST_DATA,
-       
-       /** 
+
+       /**
         * Mime-Type of data included in FETCH_REQUEST_DATA.
         * Additional argument is a char*.
         */
        FETCH_REQUEST_TYPE,
-       
-       /** 
+
+       /**
         * HTTP header to be sent with with the fetch request.
         * Additional argument is a char*.
         */
        FETCH_REQUEST_HEADER,
 
-       /** 
+       /**
         * Use HTTP Version 1.0 instead of 1.1.
         * No additional argument is needed.
         */
        FETCH_HTTP_VERSION_1_0,
 
-       /** 
+       /**
         * Timeout to use for fetch, in seconds.
         * Additional argument is u_int
         */
        FETCH_TIMEOUT,
-       
+
        /**
         * end of fetching options
         */
@@ -96,7 +96,7 @@ struct fetcher_t {
         *                                      - FAILED, NOT_FOUND, PARSE_ERROR on failure
         */
        status_t (*fetch)(fetcher_t *this, char *uri, chunk_t *result);
-       
+
        /**
         * Set a fetcher option, as defined in fetcher_option_t.
         *
@@ -107,11 +107,11 @@ struct fetcher_t {
         * @return                      TRUE if option supported, FALSE otherwise
         */
        bool (*set_option)(fetcher_t *this, fetcher_option_t option, ...);
-       
+
        /**
         * Destroy the fetcher instance.
         */
-       void (*destroy)(fetcher_t *this);       
+       void (*destroy)(fetcher_t *this);
 };
 
 #endif /** FETCHER_H_ @}*/
index 1f87412c8c378375957057c6e9370f3ca9ca8a31..7a31f17c36ae3922b6c4a06716a0581ea0de6b42 100644 (file)
@@ -30,12 +30,12 @@ struct private_fetcher_manager_t {
         * public functions
         */
        fetcher_manager_t public;
-       
+
        /**
         * list of registered fetchers, as entry_t
         */
        linked_list_t *fetchers;
-       
+
        /**
         * read write lock to list
         */
@@ -68,7 +68,7 @@ static status_t fetch(private_fetcher_manager_t *this,
        status_t status = NOT_SUPPORTED;
        entry_t *entry;
        bool capable = FALSE;
-       
+
        this->lock->read_lock(this->lock);
        enumerator = this->fetchers->create_enumerator(this->fetchers);
        while (enumerator->enumerate(enumerator, &entry))
@@ -119,7 +119,7 @@ static status_t fetch(private_fetcher_manager_t *this,
                        fetcher->destroy(fetcher);
                        continue;
                }
-               
+
                status = fetcher->fetch(fetcher, url, response);
                fetcher->destroy(fetcher);
                /* try another fetcher only if this one does not support that URL */
@@ -142,11 +142,11 @@ static status_t fetch(private_fetcher_manager_t *this,
 /**
  * Implementation of fetcher_manager_t.add_fetcher.
  */
-static void add_fetcher(private_fetcher_manager_t *this,       
+static void add_fetcher(private_fetcher_manager_t *this,
                                                fetcher_constructor_t create, char *url)
 {
        entry_t *entry = malloc_thing(entry_t);
-       
+
        entry->url = strdup(url);
        entry->create = create;
 
@@ -163,7 +163,7 @@ static void remove_fetcher(private_fetcher_manager_t *this,
 {
        enumerator_t *enumerator;
        entry_t *entry;
-       
+
        this->lock->write_lock(this->lock);
        enumerator = this->fetchers->create_enumerator(this->fetchers);
        while (enumerator->enumerate(enumerator, &entry))
@@ -194,15 +194,15 @@ static void destroy(private_fetcher_manager_t *this)
 fetcher_manager_t *fetcher_manager_create()
 {
        private_fetcher_manager_t *this = malloc_thing(private_fetcher_manager_t);
-       
+
        this->public.fetch = (status_t(*)(fetcher_manager_t*, char *url, chunk_t *response, ...))fetch;
        this->public.add_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t,char*))add_fetcher;
        this->public.remove_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t))remove_fetcher;
        this->public.destroy = (void(*)(fetcher_manager_t*))destroy;
-       
+
        this->fetchers = linked_list_create();
        this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-       
+
        return &this->public;
 }
 
index 183964d6c23a12cde16e24aef38fdf899a310f42..273e0809902f00c11d27533baca94b7c95e669ea 100644 (file)
@@ -51,15 +51,15 @@ struct fetcher_manager_t {
         */
        void (*add_fetcher)(fetcher_manager_t *this,
                                                fetcher_constructor_t constructor, char *url);
-       
+
        /**
         * Unregister a previously registered fetcher implementation.
         *
         * @param constructor   fetcher constructor function to unregister
         */
-       void (*remove_fetcher)(fetcher_manager_t *this, 
+       void (*remove_fetcher)(fetcher_manager_t *this,
                                                   fetcher_constructor_t constructor);
-       
+
        /**
      * Destroy a fetcher_manager instance.
      */
index 32a296d79e988fc75ba7b3613d1c714bbb037b21..51da4e725b10dbcc1085ec554377708c42c9a5cf 100644 (file)
@@ -35,22 +35,22 @@ typedef struct private_integrity_checker_t private_integrity_checker_t;
  * Private data of an integrity_checker_t object.
  */
 struct private_integrity_checker_t {
-       
+
        /**
         * Public integrity_checker_t interface.
         */
        integrity_checker_t public;
-       
+
        /**
         * dlopen handle to checksum library
         */
        void *handle;
-       
+
        /**
         * checksum array
         */
        integrity_checksum_t *checksums;
-       
+
        /**
         * number of checksums in array
         */
@@ -68,21 +68,21 @@ static u_int32_t build_file(private_integrity_checker_t *this, char *file,
        struct stat sb;
        void *addr;
        int fd;
-       
+
        fd = open(file, O_RDONLY);
        if (fd == -1)
        {
                DBG1("  opening '%s' failed: %s", file, strerror(errno));
                return 0;
        }
-       
+
        if (fstat(fd, &sb) == -1)
        {
                DBG1("  getting file size of '%s' failed: %s", file, strerror(errno));
                close(fd);
                return 0;
        }
-       
+
        addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
        if (addr == MAP_FAILED)
        {
@@ -91,13 +91,13 @@ static u_int32_t build_file(private_integrity_checker_t *this, char *file,
                return 0;
        }
 
-       *len = sb.st_size;      
+       *len = sb.st_size;
        contents = chunk_create(addr, sb.st_size);
        checksum = chunk_hash(contents);
-       
+
        munmap(addr, sb.st_size);
        close(fd);
-       
+
        return checksum;
 }
 
@@ -116,11 +116,11 @@ static int callback(struct dl_phdr_info *dlpi, size_t size, Dl_info *dli)
                dlpi->dlpi_name && *dlpi->dlpi_name)
        {
                int i;
-               
+
                for (i = 0; i < dlpi->dlpi_phnum; i++)
                {
                        const ElfW(Phdr) *sgmt = &dlpi->dlpi_phdr[i];
-                       
+
                        /* we are interested in the executable LOAD segment */
                        if (sgmt->p_type == PT_LOAD && (sgmt->p_flags & PF_X))
                        {
@@ -143,7 +143,7 @@ static u_int32_t build_segment(private_integrity_checker_t *this, void *sym,
 {
        chunk_t segment;
        Dl_info dli;
-       
+
        if (dladdr(sym, &dli) == 0)
        {
                DBG1("  unable to locate symbol: %s", dlerror());
@@ -155,7 +155,7 @@ static u_int32_t build_segment(private_integrity_checker_t *this, void *sym,
                DBG1("  executable section not found");
                return 0;
        }
-       
+
        segment = chunk_create(dli.dli_fbase, dli.dli_saddr - dli.dli_fbase);
        *len = segment.len;
        return chunk_hash(segment);
@@ -168,7 +168,7 @@ static integrity_checksum_t *find_checksum(private_integrity_checker_t *this,
                                                                                   char *name)
 {
        int i;
-       
+
        for (i = 0; i < this->checksum_count; i++)
        {
                if (streq(this->checksums[i].name, name))
@@ -188,7 +188,7 @@ static bool check_file(private_integrity_checker_t *this,
        integrity_checksum_t *cs;
        u_int32_t sum;
        size_t len = 0;
-       
+
        cs = find_checksum(this, name);
        if (!cs)
        {
@@ -225,7 +225,7 @@ static bool check_segment(private_integrity_checker_t *this,
        integrity_checksum_t *cs;
        u_int32_t sum;
        size_t len = 0;
-       
+
        cs = find_checksum(this, name);
        if (!cs)
        {
@@ -259,7 +259,7 @@ static bool check_segment(private_integrity_checker_t *this,
 static bool check(private_integrity_checker_t *this, char *name, void *sym)
 {
        Dl_info dli;
-       
+
        if (dladdr(sym, &dli) == 0)
        {
                DBG1("unable to locate symbol: %s", dlerror());
@@ -294,14 +294,14 @@ static void destroy(private_integrity_checker_t *this)
 integrity_checker_t *integrity_checker_create(char *checksum_library)
 {
        private_integrity_checker_t *this = malloc_thing(private_integrity_checker_t);
-       
+
        this->public.check_file = (bool(*)(integrity_checker_t*, char *name, char *file))check_file;
        this->public.build_file = (u_int32_t(*)(integrity_checker_t*, char *file, size_t *len))build_file;
        this->public.check_segment = (bool(*)(integrity_checker_t*, char *name, void *sym))check_segment;
        this->public.build_segment = (u_int32_t(*)(integrity_checker_t*, void *sym, size_t *len))build_segment;
        this->public.check = (bool(*)(integrity_checker_t*, char *name, void *sym))check;
        this->public.destroy = (void(*)(integrity_checker_t*))destroy;
-       
+
        this->checksum_count = 0;
        this->handle = NULL;
        if (checksum_library)
@@ -310,7 +310,7 @@ integrity_checker_t *integrity_checker_create(char *checksum_library)
                if (this->handle)
                {
                        int *checksum_count;
-               
+
                        this->checksums = dlsym(this->handle, "checksums");
                        checksum_count = dlsym(this->handle, "checksum_count");
                        if (this->checksums && checksum_count)
index d078dd6fb0a452699345c1423a0d87d6a0fef935..332997b17f37c1c6b961bde8c2fceee7528f5153 100644 (file)
@@ -34,11 +34,11 @@ struct integrity_checksum_t {
        /* name of the checksum */
        char *name;
        /* size in bytes of the file on disk */
-       size_t file_len; 
+       size_t file_len;
        /* checksum of the file on disk */
        u_int32_t file;
        /* size in bytes of executable segment in memory */
-       size_t segment_len; 
+       size_t segment_len;
        /* checksum of the executable segment in memory */
        u_int32_t segment;
 };
@@ -59,7 +59,7 @@ struct integrity_checker_t {
         * @return                      TRUE if integrity tested successfully
         */
        bool (*check_file)(integrity_checker_t *this, char *name, char *file);
-       
+
        /**
         * Build the integrity checksum of a file on disk.
         *
@@ -68,7 +68,7 @@ struct integrity_checker_t {
         * @return                      checksum, 0 on error
         */
        u_int32_t (*build_file)(integrity_checker_t *this, char *file, size_t *len);
-       
+
        /**
         * Check the integrity of the code segment in memory.
         *
@@ -85,7 +85,7 @@ struct integrity_checker_t {
         * @return                      checksum, 0 on error
         */
        u_int32_t (*build_segment)(integrity_checker_t *this, void *sym, size_t *len);
-       
+
        /**
         * Check both, on disk file integrity and loaded segment.
         *
@@ -94,7 +94,7 @@ struct integrity_checker_t {
         * @return                      TRUE if integrity tested successfully
         */
        bool (*check)(integrity_checker_t *this, char *name, void *sym);
-       
+
        /**
         * Destroy a integrity_checker_t.
         */
index b4203e70410e9763fc667f920c783d8af2353a2c..001f5380966c88fae54e5667dfafeb91c09c0a8d 100644 (file)
@@ -73,7 +73,7 @@ void library_deinit()
        {
                this->public.integrity->destroy(this->public.integrity);
        }
-       
+
 #ifdef LEAK_DETECTIVE
        if (this->detective)
        {
@@ -92,16 +92,16 @@ bool library_init(char *settings)
        printf_hook_t *pfh;
        private_library_t *this = malloc_thing(private_library_t);
        lib = &this->public;
-       
+
        lib->leak_detective = FALSE;
-       
+
 #ifdef LEAK_DETECTIVE
        this->detective = leak_detective_create();
 #endif /* LEAK_DETECTIVE */
 
        pfh = printf_hook_create();
        this->public.printf_hook = pfh;
-       
+
        pfh->add_handler(pfh, 'b', mem_printf_hook,
                                         PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT,
                                         PRINTF_HOOK_ARGTYPE_END);
@@ -120,7 +120,7 @@ bool library_init(char *settings)
                                         PRINTF_HOOK_ARGTYPE_END);
        pfh->add_handler(pfh, 'Y', identification_printf_hook,
                                         PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_END);
-       
+
        this->public.settings = settings_create(settings);
        this->public.crypto = crypto_factory_create();
        this->public.creds = credential_factory_create();
@@ -129,7 +129,7 @@ bool library_init(char *settings)
        this->public.db = database_factory_create();
        this->public.plugins = plugin_loader_create();
        this->public.integrity = NULL;
-       
+
        if (lib->settings->get_bool(lib->settings,
                                                                "libstrongswan.integrity_test", FALSE))
        {
index 0e086c08f595cc86e45b31a66312c3c8967a0b8e..c4c6d80d2f0f272d4f920b102b52574718406c87 100644 (file)
@@ -75,47 +75,47 @@ struct library_t {
         * Printf hook registering facility
         */
        printf_hook_t *printf_hook;
-       
+
        /**
         * crypto algorithm registry and factory
         */
        crypto_factory_t *crypto;
-       
+
        /**
         * credential constructor registry and factory
         */
        credential_factory_t *creds;
-       
+
        /**
         * key encoding registry and factory
         */
        key_encoding_t *encoding;
-       
+
        /**
         * URL fetching facility
         */
        fetcher_manager_t *fetcher;
-       
+
        /**
         * database construction factory
         */
        database_factory_t *db;
-       
+
        /**
         * plugin loading facility
         */
        plugin_loader_t *plugins;
-       
+
        /**
         * various settings loaded from settings file
         */
        settings_t *settings;
-       
+
        /**
         * integrity checker to verify code integrity
         */
        integrity_checker_t *integrity;
-       
+
        /**
         * is leak detective running?
         */
index c5b091750ce41e5231655e2343c134bb627224e7..10d48cf67ff3561a932b24eb60de5606f9e86860 100644 (file)
@@ -14,7 +14,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include "aes_crypter.h"
 
 /*
@@ -36,26 +36,26 @@ typedef struct private_aes_crypter_t private_aes_crypter_t;
 
 /**
  * Class implementing the AES symmetric encryption algorithm.
- * 
+ *
  * @ingroup crypters
  */
 struct private_aes_crypter_t {
-       
+
        /**
         * Public part of this class.
         */
        aes_crypter_t public;
-       
+
        /**
         * Number of words in the key input block.
         */
        u_int32_t    aes_Nkey;
-       
+
        /**
         * The number of cipher rounds.
         */
        u_int32_t    aes_Nrnd;
-       
+
        /**
        * The encryption key schedule.
        */
@@ -65,7 +65,7 @@ struct private_aes_crypter_t {
        * The decryption key schedule.
        */
        u_int32_t    aes_d_key[AES_KS_LENGTH];
-       
+
        /**
        * Key size of this AES cypher object.
        */
@@ -84,13 +84,13 @@ struct private_aes_crypter_t {
  *     is not defined, individually declared 32-bit words are used.
  * 6.  Define FAST_VARIABLE if a high speed variable block implementation
  *     is needed (essentially three separate fixed block size code sequences)
- * 7.  Define either ONE_TABLE or FOUR_TABLES for a fast table driven 
+ * 7.  Define either ONE_TABLE or FOUR_TABLES for a fast table driven
  *     version using 1 table (2 kbytes of table space) or 4 tables (8
  *     kbytes of table space) for higher speed.
- * 8.  Define either ONE_LR_TABLE or FOUR_LR_TABLES for a further speed 
+ * 8.  Define either ONE_LR_TABLE or FOUR_LR_TABLES for a further speed
  *     increase by using tables for the last rounds but with more table
  *     space (2 or 8 kbytes extra).
- * 9.  If neither ONE_TABLE nor FOUR_TABLES is defined, a compact but 
+ * 9.  If neither ONE_TABLE nor FOUR_TABLES is defined, a compact but
  *     slower version is provided.
  * 10. If fast decryption key scheduling is needed define ONE_IM_TABLE
  *     or FOUR_IM_TABLES for higher speed (2 or 8 kbytes extra).
@@ -131,17 +131,17 @@ struct private_aes_crypter_t {
 
 #if defined(AES_BLOCK_SIZE) && AES_BLOCK_SIZE != 16 && AES_BLOCK_SIZE != 24 && AES_BLOCK_SIZE != 32
 #error an illegal block size has been specified
-#endif  
+#endif
 
 /**
- * Rotates bytes within words by n positions, moving bytes 
+ * Rotates bytes within words by n positions, moving bytes
  * to higher index positions with wrap around into low positions.
- */ 
+ */
 #define upr(x,n)        (((x) << 8 * (n)) | ((x) >> (32 - 8 * (n))))
 /**
- * Moves bytes by n positions to higher index positions in 
+ * Moves bytes by n positions to higher index positions in
  * words but without wrap around.
- */ 
+ */
 #define ups(x,n)        ((x) << 8 * (n))
 
 /**
@@ -154,7 +154,7 @@ struct private_aes_crypter_t {
 
 /* little endian processor without data alignment restrictions: AES_LE_OK */
 /* original code: i386 */
-#if defined(i386) || defined(_I386) || defined(__i386__) || defined(__i386) 
+#if defined(i386) || defined(_I386) || defined(__i386__) || defined(__i386)
 #define        AES_LE_OK 1
 /* added (tested): alpha  --jjo */
 #elif defined(__alpha__)|| defined (__alpha)
@@ -220,9 +220,9 @@ struct private_aes_crypter_t {
 // give improved performance if a fast 32-bit multiply is not available. Note
 // that a temporary variable u needs to be defined where FFmulX is used.
 
-// #define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6)) 
+// #define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6))
 // #define m4  0x1b1b1b1b
-// #define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4) 
+// #define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4)
 
 // perform column mix operation on four bytes in parallel
 
@@ -343,7 +343,7 @@ static const u_int32_t rcon_tab[29] =
 #define w2(p)        0x00##p##0000
 #define w3(p)        0x##p##000000
 
-#if defined(FIXED_TABLES) && (defined(ONE_TABLE) || defined(FOUR_TABLES)) 
+#if defined(FIXED_TABLES) && (defined(ONE_TABLE) || defined(FOUR_TABLES))
 
 //  data for forward tables (other than last round)
 
@@ -526,7 +526,7 @@ static const u_int32_t it_tab[4][256] =
 
 #endif
 
-#if defined(FIXED_TABLES) && (defined(ONE_LR_TABLE) || defined(FOUR_LR_TABLES)) 
+#if defined(FIXED_TABLES) && (defined(ONE_LR_TABLE) || defined(FOUR_LR_TABLES))
 
 //  data for inverse tables (last round)
 
@@ -608,7 +608,7 @@ static const u_int32_t il_tab[4][256] =
 
 #endif
 
-#if defined(FIXED_TABLES) && (defined(ONE_IM_TABLE) || defined(FOUR_IM_TABLES)) 
+#if defined(FIXED_TABLES) && (defined(ONE_IM_TABLE) || defined(FOUR_IM_TABLES))
 
 #define m_table \
     r(00,00,00,00), r(0b,0d,09,0e), r(16,1a,12,1c), r(1d,17,1b,12),\
@@ -733,8 +733,8 @@ static u_int32_t  im_tab[4][256];
 
 #if !defined(FF_TABLES)
 
-// It will generally be sensible to use tables to compute finite 
-// field multiplies and inverses but where memory is scarse this 
+// It will generally be sensible to use tables to compute finite
+// field multiplies and inverses but where memory is scarse this
 // code might sometimes be better.
 
 // return 2 ^ (n - 1) where n is the bit number of the highest bit
@@ -743,7 +743,7 @@ static u_int32_t  im_tab[4][256];
 
 static unsigned char hibit(const u_int32_t x)
 {   unsigned char r = (unsigned char)((x >> 1) | (x >> 2));
-    
+
     r |= (r >> 2);
     r |= (r >> 4);
     return (r + 1) >> 1;
@@ -761,14 +761,14 @@ static unsigned char FFinv(const unsigned char x)
         if(!n1) return v1;
 
         while(n2 >= n1)
-        {   
+        {
             n2 /= n1; p2 ^= p1 * n2; v2 ^= v1 * n2; n2 = hibit(p2);
         }
-        
+
         if(!n2) return v2;
 
         while(n1 >= n2)
-        {   
+        {
             n1 /= n2; p1 ^= p2 * n1; v1 ^= v2 * n1; n1 = hibit(p1);
         }
     }
@@ -815,9 +815,9 @@ static void gen_tabs(void)
     // 0x011b as modular polynomial - the simplest primitive
     // root is 0x03, used here to generate the tables
 
-    i = 0; w = 1; 
+    i = 0; w = 1;
     do
-    {   
+    {
         pow[i] = (unsigned char)w;
         pow[i + 255] = (unsigned char)w;
         log[w] = (unsigned char)i++;
@@ -987,8 +987,8 @@ switch(nc) \
 // is being computed, return the input state variables which are
 // needed for each row (r) of the state
 
-// For the fixed block size options, compilers reduce these two 
-// expressions to fixed variable references. For variable block 
+// For the fixed block size options, compilers reduce these two
+// expressions to fixed variable references. For variable block
 // size code conditional clauses will sometimes be returned
 
 #define unused  77  // Sunset Strip
@@ -1226,17 +1226,17 @@ static void encrypt_block(const private_aes_crypter_t *this, const unsigned char
 
     switch(this->aes_Nrnd)
     {
-    case 14:    round(fwd_rnd,  b1, b0, kp         ); 
+    case 14:    round(fwd_rnd,  b1, b0, kp         );
                 round(fwd_rnd,  b0, b1, kp + nc    ); kp += 2 * nc;
-    case 12:    round(fwd_rnd,  b1, b0, kp         ); 
+    case 12:    round(fwd_rnd,  b1, b0, kp         );
                 round(fwd_rnd,  b0, b1, kp + nc    ); kp += 2 * nc;
-    case 10:    round(fwd_rnd,  b1, b0, kp         );             
+    case 10:    round(fwd_rnd,  b1, b0, kp         );
                 round(fwd_rnd,  b0, b1, kp +     nc);
-                round(fwd_rnd,  b1, b0, kp + 2 * nc); 
+                round(fwd_rnd,  b1, b0, kp + 2 * nc);
                 round(fwd_rnd,  b0, b1, kp + 3 * nc);
-                round(fwd_rnd,  b1, b0, kp + 4 * nc); 
+                round(fwd_rnd,  b1, b0, kp + 4 * nc);
                 round(fwd_rnd,  b0, b1, kp + 5 * nc);
-                round(fwd_rnd,  b1, b0, kp + 6 * nc); 
+                round(fwd_rnd,  b1, b0, kp + 6 * nc);
                 round(fwd_rnd,  b0, b1, kp + 7 * nc);
                 round(fwd_rnd,  b1, b0, kp + 8 * nc);
                 round(fwd_lrnd, b0, b1, kp + 9 * nc);
@@ -1247,7 +1247,7 @@ static void encrypt_block(const private_aes_crypter_t *this, const unsigned char
 
         for(rnd = 0; rnd < (this->aes_Nrnd >> 1) - 1; ++rnd)
         {
-            round(fwd_rnd, b1, b0, kp); 
+            round(fwd_rnd, b1, b0, kp);
             round(fwd_rnd, b0, b1, kp + nc); kp += 2 * nc;
         }
 
@@ -1259,7 +1259,7 @@ static void encrypt_block(const private_aes_crypter_t *this, const unsigned char
 
         for(rnd = 0; rnd < this->aes_Nrnd - 1; ++rnd)
         {
-            round(fwd_rnd, b1, b0, kp); 
+            round(fwd_rnd, b1, b0, kp);
             l_copy(b0, b1); kp += nc;
         }
 
@@ -1278,7 +1278,7 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
     const u_int32_t  *kp = this->aes_d_key;
 
 #if !defined(ONE_TABLE) && !defined(FOUR_TABLES)
-    u_int32_t        f2, f4, f8, f9; 
+    u_int32_t        f2, f4, f8, f9;
 #endif
 
     state_in(b0, in_blk, kp); kp += nc;
@@ -1291,13 +1291,13 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
                 round(inv_rnd,  b0, b1, kp + nc    ); kp += 2 * nc;
     case 12:    round(inv_rnd,  b1, b0, kp         );
                 round(inv_rnd,  b0, b1, kp + nc    ); kp += 2 * nc;
-    case 10:    round(inv_rnd,  b1, b0, kp         );             
+    case 10:    round(inv_rnd,  b1, b0, kp         );
                 round(inv_rnd,  b0, b1, kp +     nc);
-                round(inv_rnd,  b1, b0, kp + 2 * nc); 
+                round(inv_rnd,  b1, b0, kp + 2 * nc);
                 round(inv_rnd,  b0, b1, kp + 3 * nc);
-                round(inv_rnd,  b1, b0, kp + 4 * nc); 
+                round(inv_rnd,  b1, b0, kp + 4 * nc);
                 round(inv_rnd,  b0, b1, kp + 5 * nc);
-                round(inv_rnd,  b1, b0, kp + 6 * nc); 
+                round(inv_rnd,  b1, b0, kp + 6 * nc);
                 round(inv_rnd,  b0, b1, kp + 7 * nc);
                 round(inv_rnd,  b1, b0, kp + 8 * nc);
                 round(inv_lrnd, b0, b1, kp + 9 * nc);
@@ -1308,7 +1308,7 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
 
         for(rnd = 0; rnd < (this->aes_Nrnd >> 1) - 1; ++rnd)
         {
-            round(inv_rnd, b1, b0, kp); 
+            round(inv_rnd, b1, b0, kp);
             round(inv_rnd, b0, b1, kp + nc); kp += 2 * nc;
         }
 
@@ -1320,7 +1320,7 @@ static void decrypt_block(const private_aes_crypter_t *this, const unsigned char
 
         for(rnd = 0; rnd < this->aes_Nrnd - 1; ++rnd)
         {
-            round(inv_rnd, b1, b0, kp); 
+            round(inv_rnd, b1, b0, kp);
             l_copy(b0, b1); kp += nc;
         }
 
@@ -1340,7 +1340,7 @@ static void decrypt(private_aes_crypter_t *this, chunk_t data, chunk_t iv,
        int pos;
        const u_int32_t *iv_i;
        u_int8_t *in, *out;
-       
+
        if (decrypted)
        {
                *decrypted = chunk_alloc(data.len);
@@ -1351,7 +1351,7 @@ static void decrypt(private_aes_crypter_t *this, chunk_t data, chunk_t iv,
                out = data.ptr;
        }
        in = data.ptr;
-       
+
        pos = data.len-16;
        in += pos;
        out += pos;
@@ -1386,7 +1386,7 @@ static void encrypt (private_aes_crypter_t *this, chunk_t data, chunk_t iv,
        int pos;
        const u_int32_t *iv_i;
        u_int8_t *in, *out;
-       
+
        in = data.ptr;
        out = data.ptr;
        if (encrypted)
@@ -1394,7 +1394,7 @@ static void encrypt (private_aes_crypter_t *this, chunk_t data, chunk_t iv,
                *encrypted = chunk_alloc(data.len);
                out = encrypted->ptr;
        }
-       
+
        pos=0;
        while(pos<data.len)
        {
@@ -1440,18 +1440,18 @@ static void set_key (private_aes_crypter_t *this, chunk_t key)
 {
        u_int32_t    *kf, *kt, rci, f = 0;
        u_int8_t *in_key = key.ptr;
-       
-       this->aes_Nrnd = (this->aes_Nkey > (nc) ? this->aes_Nkey : (nc)) + 6; 
-       
+
+       this->aes_Nrnd = (this->aes_Nkey > (nc) ? this->aes_Nkey : (nc)) + 6;
+
        this->aes_e_key[0] = const_word_in(in_key     );
        this->aes_e_key[1] = const_word_in(in_key +  4);
        this->aes_e_key[2] = const_word_in(in_key +  8);
        this->aes_e_key[3] = const_word_in(in_key + 12);
-       
-       kf = this->aes_e_key; 
-       kt = kf + nc * (this->aes_Nrnd + 1) - this->aes_Nkey; 
+
+       kf = this->aes_e_key;
+       kt = kf + nc * (this->aes_Nrnd + 1) - this->aes_Nkey;
        rci = 0;
-       
+
        switch(this->aes_Nkey)
        {
        case 4: do
@@ -1463,7 +1463,7 @@ static void set_key (private_aes_crypter_t *this, chunk_t key)
                        }
                        while(kf < kt);
                        break;
-       
+
        case 6: this->aes_e_key[4] = const_word_in(in_key + 16);
                        this->aes_e_key[5] = const_word_in(in_key + 20);
                        do
@@ -1496,18 +1496,18 @@ static void set_key (private_aes_crypter_t *this, chunk_t key)
                        while (kf < kt);
                        break;
        }
-       
+
        if(!f)
     {
                u_int32_t    i;
 
                kt = this->aes_d_key + nc * this->aes_Nrnd;
                kf = this->aes_e_key;
-               
+
                cpy(kt, kf); kt -= 2 * nc;
-               
+
                for(i = 1; i < this->aes_Nrnd; ++i)
-               { 
+               {
 #if defined(ONE_TABLE) || defined(FOUR_TABLES)
 #if !defined(ONE_IM_TABLE) && !defined(FOUR_IM_TABLES)
                        u_int32_t    f2, f4, f8, f9;
@@ -1536,18 +1536,18 @@ static void destroy (private_aes_crypter_t *this)
 aes_crypter_t *aes_crypter_create(encryption_algorithm_t algo, size_t key_size)
 {
        private_aes_crypter_t *this;
-       
+
        if (algo != ENCR_AES_CBC)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_aes_crypter_t);
-       
+
        #if !defined(FIXED_TABLES)
        if(!tab_gen) { gen_tabs(); tab_gen = 1; }
        #endif
-       
+
        this->key_size = key_size;
        switch(key_size)
        {
@@ -1564,13 +1564,13 @@ aes_crypter_t *aes_crypter_create(encryption_algorithm_t algo, size_t key_size)
                free(this);
                return NULL;
        }
-       
+
        this->public.crypter_interface.encrypt = (void (*) (crypter_t *, chunk_t,chunk_t, chunk_t *)) encrypt;
        this->public.crypter_interface.decrypt = (void (*) (crypter_t *, chunk_t , chunk_t, chunk_t *)) decrypt;
        this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *)) get_block_size;
        this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *)) get_key_size;
        this->public.crypter_interface.set_key = (void (*) (crypter_t *,chunk_t)) set_key;
        this->public.crypter_interface.destroy = (void (*) (crypter_t *)) destroy;
-       
+
        return &(this->public);
 }
index 19ea6b4b7a54e3eea959bfdb30cc9122675fdf4e..061d72fd6fc871261a179f100d6c2a226cfc6fd4 100644 (file)
@@ -30,7 +30,7 @@ typedef struct aes_crypter_t aes_crypter_t;
  * Class implementing the AES encryption algorithm.
  */
 struct aes_crypter_t {
-       
+
        /**
         * The crypter_t interface.
         */
@@ -39,7 +39,7 @@ struct aes_crypter_t {
 
 /**
  * Constructor to create aes_crypter_t objects.
- * 
+ *
  * @param key_size             key size in bytes
  * @param algo                 algorithm to implement
  * @return                             aes_crypter_t object, NULL if not supported
index 63fa483301654d86e0f7de91104241e4ace925cf..c6215cc7f419fe91597d9c53be2c44caec82eec8 100644 (file)
@@ -47,12 +47,12 @@ static void destroy(private_aes_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_aes_plugin_t *this = malloc_thing(private_aes_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
                                                         (crypter_constructor_t)aes_crypter_create);
-       
+
        return &this->public.plugin;
 }
 
index 84b85d4bd3d6ff733fd9b6f449c530fafaa11524..a8588a99000451560255c6bbfe008f32befd3a2a 100644 (file)
@@ -47,9 +47,9 @@ static void destroy(private_agent_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_agent_plugin_t *this = malloc_thing(private_agent_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                        (builder_constructor_t)agent_private_key_builder);
        return &this->public.plugin;
index 33a5dcb53bb22d532c686ba9fa1893d9d4976b2c..e49af42d8dd43aa20570a7b9376992ee17fea31a 100644 (file)
@@ -16,7 +16,7 @@
 /**
  * @defgroup agent_p agent
  * @ingroup plugins
- * 
+ *
  * @defgroup agent_plugin agent_plugin
  * @{ @ingroup agent_p
  */
index 4e0a8d646834d1e77015d89cce0f3eadda11b303..f5ab36acbf0c81a55cc3d9699237122a706e93ef 100644 (file)
@@ -42,22 +42,22 @@ struct private_agent_private_key_t {
         * Public interface for this signer.
         */
        agent_private_key_t public;
-       
+
        /**
         * ssh-agent unix socket connection
         */
        int socket;
-       
+
        /**
         * key identity blob in ssh format
         */
        chunk_t key;
-       
+
        /**
         * keysize in bytes
         */
        size_t key_size;
-       
+
        /**
         * reference count
         */
@@ -115,7 +115,7 @@ static chunk_t read_string(chunk_t *blob)
 {
        int len;
        chunk_t str;
-       
+
        len = read_uint32(blob);
        if (len > blob->len)
        {
@@ -140,11 +140,11 @@ static int open_connection(char *path)
                DBG1("opening ssh-agent socket %s failed: %s:", path, strerror(errno));
                return -1;
        }
-       
+
        addr.sun_family = AF_UNIX;
        addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
        strncpy(addr.sun_path, path, UNIX_PATH_MAX - 1);
-       
+
        if (connect(s, (struct sockaddr*)&addr, SUN_LEN(&addr)) != 0)
        {
                DBG1("connecting to ssh-agent socket failed: %s", strerror(errno));
@@ -154,7 +154,7 @@ static int open_connection(char *path)
        return s;
 }
 
-/** 
+/**
  * Get the first usable key from the agent
  */
 static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
@@ -162,7 +162,7 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
        int len, count;
        char buf[2048];
        chunk_t blob = chunk_from_buf(buf), key, type, n;
-       
+
        len = htonl(1);
        buf[0] = SSH_AGENT_ID_REQUEST;
        if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
@@ -171,9 +171,9 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
                DBG1("writing to ssh-agent failed");
                return FALSE;
        }
-       
+
        blob.len = read(this->socket, blob.ptr, blob.len);
-       
+
        if (blob.len < sizeof(u_int32_t) + sizeof(u_char) ||
                read_uint32(&blob) != blob.len ||
                read_byte(&blob) != SSH_AGENT_ID_RESPONSE)
@@ -182,7 +182,7 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
                return FALSE;
        }
        count = read_uint32(&blob);
-       
+
        while (blob.len)
        {
                key = read_string(&blob);
@@ -221,20 +221,20 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
 /**
  * Implementation of agent_private_key.destroy.
  */
-static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme, 
+static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
                                 chunk_t data, chunk_t *signature)
 {
        u_int32_t len, flags;
        char buf[2048];
        chunk_t blob = chunk_from_buf(buf);
-       
+
        if (scheme != SIGN_RSA_EMSA_PKCS1_SHA1)
        {
                DBG1("signature scheme %N not supported by ssh-agent",
                         signature_scheme_names, scheme);
                return FALSE;
        }
-       
+
        len = htonl(1 + sizeof(u_int32_t) * 3 + this->key.len + data.len);
        buf[0] = SSH_AGENT_SIGN_REQUEST;
        if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
@@ -243,7 +243,7 @@ static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
                DBG1("writing to ssh-agent failed");
                return FALSE;
        }
-       
+
        len = htonl(this->key.len);
        if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
                write(this->socket, this->key.ptr, this->key.len) != this->key.len)
@@ -251,7 +251,7 @@ static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
                DBG1("writing to ssh-agent failed");
                return FALSE;
        }
-       
+
        len = htonl(data.len);
        if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
                write(this->socket, data.ptr, data.len) != data.len)
@@ -259,14 +259,14 @@ static bool sign(private_agent_private_key_t *this, signature_scheme_t scheme,
                DBG1("writing to ssh-agent failed");
                return FALSE;
        }
-       
+
        flags = htonl(0);
        if (write(this->socket, &flags, sizeof(flags)) != sizeof(flags))
        {
                DBG1("writing to ssh-agent failed");
                return FALSE;
        }
-       
+
        blob.len = read(this->socket, blob.ptr, blob.len);
        if (blob.len < sizeof(u_int32_t) + sizeof(u_char) ||
                read_uint32(&blob) != blob.len ||
@@ -322,12 +322,12 @@ static size_t get_keysize(private_agent_private_key_t *this)
 static public_key_t* get_public_key(private_agent_private_key_t *this)
 {
        chunk_t key, n, e;
-       
+
        key = this->key;
        read_string(&key);
        e = read_string(&key);
        n = read_string(&key);
-       
+
        return lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END);
 }
@@ -348,7 +348,7 @@ static bool get_fingerprint(private_agent_private_key_t *this,
                                                        key_encoding_type_t type, chunk_t *fp)
 {
        chunk_t n, e, key;
-       
+
        if (lib->encoding->get_cache(lib->encoding, type, this, fp))
        {
                return TRUE;
@@ -357,7 +357,7 @@ static bool get_fingerprint(private_agent_private_key_t *this,
        read_string(&key);
        e = read_string(&key);
        n = read_string(&key);
-       
+
        return lib->encoding->encode(lib->encoding, type, this, fp,
                                KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
 }
@@ -392,7 +392,7 @@ static agent_private_key_t *agent_private_key_create(char *path,
                                                                                                         public_key_t *pubkey)
 {
        private_agent_private_key_t *this = malloc_thing(private_agent_private_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type;
        this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign;
        this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt;
@@ -404,7 +404,7 @@ static agent_private_key_t *agent_private_key_create(char *path,
        this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref;
        this->public.interface.destroy = (void (*)(private_key_t *this))destroy;
-       
+
        this->socket = open_connection(path);
        if (this->socket < 0)
        {
@@ -413,7 +413,7 @@ static agent_private_key_t *agent_private_key_create(char *path,
        }
        this->key = chunk_empty;
        this->ref = 1;
-       
+
        if (!read_key(this, pubkey))
        {
                destroy(this);
@@ -442,7 +442,7 @@ struct private_builder_t {
 static agent_private_key_t *build(private_builder_t *this)
 {
        agent_private_key_t *key = NULL;
-       
+
        if (this->socket)
        {
                key = agent_private_key_create(this->socket, this->pubkey);
@@ -457,7 +457,7 @@ static agent_private_key_t *build(private_builder_t *this)
 static void add(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_AGENT_SOCKET:
@@ -486,19 +486,19 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *agent_private_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->pubkey = NULL;
        this->socket = NULL;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index c2f3ce2e8a473d6f4f5b6587de0f2948ddb300ec..ebcc5dbdfbc28fb8c39a4fabb074d1dbf7626867 100644 (file)
@@ -5,21 +5,21 @@
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * The licence and distribution terms for any publically available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
index 283bf4c43b5d4e01fc08c62f9a2816a6f421f9e1..1375a0aa99dfcfc18af4c417c84abc4f4b55da2f 100644 (file)
@@ -5,21 +5,21 @@
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * The licence and distribution terms for any publically available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
index 9949513c682199b311a5dddc551f6081694306a0..79d23db6ce1d7cf27e537d8e9bc89ac691274021 100644 (file)
@@ -5,21 +5,21 @@
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * The licence and distribution terms for any publically available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
@@ -64,262 +64,262 @@ static const BF_KEY bf_init= {
        0xc0ac29b7L, 0xc97c50ddL, 0x3f84d5b5L, 0xb5470917L,
        0x9216d5d9L, 0x8979fb1b
        },{
-       0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L, 
-       0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L, 
-       0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L, 
-       0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL, 
-       0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL, 
-       0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L, 
-       0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL, 
-       0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL, 
-       0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L, 
-       0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L, 
-       0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL, 
-       0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL, 
-       0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL, 
-       0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L, 
-       0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L, 
-       0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L, 
-       0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L, 
-       0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L, 
-       0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL, 
-       0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L, 
-       0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L, 
-       0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L, 
-       0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L, 
-       0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL, 
-       0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L, 
-       0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL, 
-       0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL, 
-       0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L, 
-       0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL, 
-       0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L, 
-       0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL, 
-       0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L, 
-       0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L, 
-       0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL, 
-       0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L, 
-       0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L, 
-       0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL, 
-       0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L, 
-       0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL, 
-       0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L, 
-       0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L, 
-       0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL, 
-       0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L, 
-       0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L, 
-       0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L, 
-       0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L, 
-       0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L, 
-       0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL, 
-       0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL, 
-       0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L, 
-       0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L, 
-       0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L, 
-       0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L, 
-       0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL, 
-       0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L, 
-       0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL, 
-       0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL, 
-       0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L, 
-       0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L, 
-       0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L, 
-       0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L, 
-       0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L, 
-       0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L, 
-       0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL, 
-       0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L, 
-       0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L, 
-       0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L, 
-       0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL, 
-       0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L, 
-       0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L, 
-       0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL, 
-       0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L, 
-       0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L, 
-       0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L, 
-       0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL, 
-       0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL, 
-       0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L, 
-       0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L, 
-       0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L, 
-       0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L, 
-       0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL, 
-       0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL, 
-       0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL, 
-       0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L, 
-       0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL, 
-       0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L, 
-       0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L, 
-       0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL, 
-       0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL, 
-       0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L, 
-       0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL, 
-       0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L, 
-       0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL, 
-       0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL, 
-       0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L, 
-       0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L, 
-       0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L, 
-       0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L, 
-       0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L, 
-       0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L, 
-       0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L, 
-       0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL, 
-       0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L, 
-       0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL, 
-       0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L, 
-       0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L, 
-       0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L, 
-       0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L, 
-       0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L, 
-       0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L, 
-       0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L, 
-       0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L, 
-       0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L, 
-       0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L, 
-       0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L, 
-       0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L, 
-       0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L, 
-       0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L, 
-       0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L, 
-       0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L, 
-       0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL, 
-       0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL, 
-       0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L, 
-       0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL, 
-       0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L, 
-       0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L, 
-       0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L, 
-       0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L, 
-       0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L, 
-       0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L, 
-       0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL, 
-       0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L, 
-       0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L, 
-       0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L, 
-       0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL, 
-       0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL, 
-       0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL, 
-       0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L, 
-       0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L, 
-       0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL, 
-       0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L, 
-       0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL, 
-       0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L, 
-       0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL, 
-       0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L, 
-       0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL, 
-       0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L, 
-       0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL, 
-       0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L, 
-       0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L, 
-       0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL, 
-       0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L, 
-       0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L, 
-       0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L, 
-       0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L, 
-       0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL, 
-       0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L, 
-       0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL, 
-       0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L, 
-       0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL, 
-       0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L, 
-       0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL, 
-       0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL, 
-       0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL, 
-       0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L, 
-       0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L, 
-       0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL, 
-       0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL, 
-       0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL, 
-       0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL, 
-       0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL, 
-       0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L, 
-       0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L, 
-       0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L, 
-       0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L, 
-       0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL, 
-       0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL, 
-       0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L, 
-       0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L, 
-       0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L, 
-       0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L, 
-       0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L, 
-       0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L, 
-       0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L, 
-       0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L, 
-       0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L, 
-       0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L, 
-       0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL, 
-       0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L, 
-       0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL, 
-       0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L, 
-       0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L, 
-       0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL, 
-       0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL, 
-       0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL, 
-       0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L, 
-       0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L, 
-       0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L, 
-       0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L, 
-       0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L, 
-       0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L, 
-       0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L, 
-       0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L, 
-       0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L, 
-       0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L, 
-       0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L, 
-       0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L, 
-       0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL, 
-       0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL, 
-       0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L, 
-       0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL, 
-       0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL, 
-       0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL, 
-       0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L, 
-       0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL, 
-       0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL, 
-       0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L, 
-       0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L, 
-       0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L, 
-       0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L, 
-       0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL, 
-       0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL, 
-       0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L, 
-       0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L, 
-       0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L, 
-       0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL, 
-       0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L, 
-       0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L, 
-       0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L, 
-       0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL, 
-       0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L, 
-       0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L, 
-       0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L, 
-       0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL, 
-       0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL, 
-       0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L, 
-       0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L, 
-       0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L, 
-       0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L, 
-       0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL, 
-       0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L, 
-       0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL, 
-       0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL, 
-       0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L, 
-       0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L, 
-       0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL, 
-       0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L, 
-       0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL, 
-       0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L, 
-       0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL, 
-       0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L, 
-       0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L, 
-       0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL, 
-       0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L, 
-       0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL, 
-       0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L, 
+       0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L,
+       0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L,
+       0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L,
+       0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL,
+       0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL,
+       0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L,
+       0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL,
+       0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL,
+       0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L,
+       0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L,
+       0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL,
+       0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL,
+       0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL,
+       0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L,
+       0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L,
+       0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L,
+       0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L,
+       0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L,
+       0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL,
+       0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L,
+       0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L,
+       0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L,
+       0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L,
+       0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL,
+       0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L,
+       0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL,
+       0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL,
+       0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L,
+       0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL,
+       0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L,
+       0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL,
+       0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L,
+       0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L,
+       0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL,
+       0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L,
+       0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L,
+       0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL,
+       0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L,
+       0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL,
+       0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L,
+       0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L,
+       0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL,
+       0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L,
+       0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L,
+       0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L,
+       0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L,
+       0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L,
+       0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL,
+       0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL,
+       0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L,
+       0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L,
+       0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L,
+       0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L,
+       0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL,
+       0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L,
+       0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL,
+       0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL,
+       0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L,
+       0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L,
+       0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L,
+       0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L,
+       0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L,
+       0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L,
+       0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL,
+       0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L,
+       0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L,
+       0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L,
+       0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL,
+       0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L,
+       0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L,
+       0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL,
+       0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L,
+       0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L,
+       0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L,
+       0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL,
+       0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL,
+       0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L,
+       0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L,
+       0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L,
+       0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L,
+       0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL,
+       0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL,
+       0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL,
+       0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L,
+       0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL,
+       0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L,
+       0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L,
+       0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL,
+       0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL,
+       0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L,
+       0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL,
+       0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L,
+       0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL,
+       0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL,
+       0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L,
+       0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L,
+       0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L,
+       0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L,
+       0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L,
+       0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L,
+       0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L,
+       0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL,
+       0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L,
+       0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL,
+       0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L,
+       0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L,
+       0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L,
+       0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L,
+       0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L,
+       0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L,
+       0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L,
+       0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L,
+       0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L,
+       0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L,
+       0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L,
+       0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L,
+       0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L,
+       0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L,
+       0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L,
+       0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L,
+       0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL,
+       0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL,
+       0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L,
+       0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL,
+       0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L,
+       0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L,
+       0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L,
+       0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L,
+       0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L,
+       0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L,
+       0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL,
+       0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L,
+       0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L,
+       0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L,
+       0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL,
+       0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL,
+       0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL,
+       0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L,
+       0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L,
+       0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL,
+       0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L,
+       0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL,
+       0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L,
+       0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL,
+       0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L,
+       0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL,
+       0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L,
+       0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL,
+       0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L,
+       0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L,
+       0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL,
+       0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L,
+       0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L,
+       0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L,
+       0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L,
+       0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL,
+       0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L,
+       0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL,
+       0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L,
+       0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL,
+       0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L,
+       0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL,
+       0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL,
+       0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL,
+       0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L,
+       0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L,
+       0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL,
+       0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL,
+       0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL,
+       0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL,
+       0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL,
+       0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L,
+       0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L,
+       0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L,
+       0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L,
+       0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL,
+       0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL,
+       0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L,
+       0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L,
+       0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L,
+       0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L,
+       0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L,
+       0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L,
+       0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L,
+       0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L,
+       0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L,
+       0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L,
+       0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL,
+       0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L,
+       0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL,
+       0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L,
+       0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L,
+       0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL,
+       0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL,
+       0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL,
+       0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L,
+       0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L,
+       0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L,
+       0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L,
+       0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L,
+       0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L,
+       0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L,
+       0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L,
+       0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L,
+       0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L,
+       0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L,
+       0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L,
+       0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL,
+       0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL,
+       0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L,
+       0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL,
+       0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL,
+       0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL,
+       0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L,
+       0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL,
+       0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL,
+       0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L,
+       0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L,
+       0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L,
+       0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L,
+       0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL,
+       0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL,
+       0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L,
+       0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L,
+       0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L,
+       0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL,
+       0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L,
+       0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L,
+       0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L,
+       0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL,
+       0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L,
+       0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L,
+       0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L,
+       0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL,
+       0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL,
+       0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L,
+       0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L,
+       0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L,
+       0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L,
+       0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL,
+       0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L,
+       0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL,
+       0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL,
+       0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L,
+       0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L,
+       0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL,
+       0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L,
+       0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL,
+       0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L,
+       0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL,
+       0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L,
+       0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L,
+       0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL,
+       0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L,
+       0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL,
+       0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L,
        }
        };
 
index 8cdbbd2836471d2bdd780fe326282bdab9dfe0cf..ceec3b8d40fad27977c828d68e5fec0f783d1433 100644 (file)
@@ -5,21 +5,21 @@
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * The licence and distribution terms for any publically available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
index ccb97e2728c1ee11509df5cf5e7aca7a00c907f2..9aa30df4b2c1718139a7b407a0cf5e6322d279e1 100644 (file)
@@ -5,21 +5,21 @@
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * The licence and distribution terms for any publically available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
@@ -90,7 +90,7 @@ extern "C" {
  * So I've chosen long...
  *                                     <appro@fy.chalmers.se>
  */
-       
+
 /* des.h-like hack <jjo-ipsec@mendoza.gov.ar> */
 #ifndef BF_LONG
 #ifdef __KERNEL__
@@ -110,7 +110,7 @@ typedef struct bf_key_st
        BF_LONG S[4*256];
        } BF_KEY;
 
+
 void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
 
 void BF_encrypt(BF_LONG *data,const BF_KEY *key);
index 5064bfef6696c585e99e75da67823e04f03a6d87..fb856ed37be98b95b44977245b704c03dbfcbbc5 100644 (file)
@@ -4,21 +4,21 @@
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -48,7 +48,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * The licence and distribution terms for any publically available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
  * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
  * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
  */
+
 #include "blowfish_crypter.h"
 
 typedef struct private_blowfish_crypter_t private_blowfish_crypter_t;
 
 /**
  * Class implementing the Blowfish symmetric encryption algorithm.
- * 
+ *
  * @ingroup crypters
  */
 struct private_blowfish_crypter_t {
-       
+
        /**
         * Public part of this class.
         */
        blowfish_crypter_t public;
-       
+
        /**
         * Blowfish key schedule
         */
@@ -96,7 +96,7 @@ static void decrypt(private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
                                        chunk_t *decrypted)
 {
        u_int8_t *in, *out;
-       
+
        if (decrypted)
        {
                *decrypted = chunk_alloc(data.len);
@@ -121,7 +121,7 @@ static void encrypt (private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
                                         chunk_t *encrypted)
 {
        u_int8_t *in, *out;
-       
+
        if (encrypted)
        {
                *encrypted = chunk_alloc(data.len);
@@ -177,14 +177,14 @@ static void destroy (private_blowfish_crypter_t *this)
 blowfish_crypter_t *blowfish_crypter_create(encryption_algorithm_t algo, size_t key_size)
 {
        private_blowfish_crypter_t *this;
-       
+
        if (algo != ENCR_BLOWFISH)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_blowfish_crypter_t);
-       
+
        this->key_size = key_size;
        this->public.crypter_interface.encrypt = (void (*) (crypter_t *, chunk_t,chunk_t, chunk_t *)) encrypt;
        this->public.crypter_interface.decrypt = (void (*) (crypter_t *, chunk_t , chunk_t, chunk_t *)) decrypt;
@@ -192,6 +192,6 @@ blowfish_crypter_t *blowfish_crypter_create(encryption_algorithm_t algo, size_t
        this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *)) get_key_size;
        this->public.crypter_interface.set_key = (void (*) (crypter_t *,chunk_t)) set_key;
        this->public.crypter_interface.destroy = (void (*) (crypter_t *)) destroy;
-       
+
        return &(this->public);
 }
index 2bb896e6490a0ff03a62d1685dc0d5912bfa6c89..71cc09cd0e818efa53b16da3ccc087f20f290d3d 100644 (file)
@@ -30,7 +30,7 @@ typedef struct blowfish_crypter_t blowfish_crypter_t;
  * Class implementing the Blowfish encryption algorithm.
  */
 struct blowfish_crypter_t {
-       
+
        /**
         * The crypter_t interface.
         */
@@ -39,7 +39,7 @@ struct blowfish_crypter_t {
 
 /**
  * Constructor to create blowfish_crypter_t objects.
- * 
+ *
  * @param key_size             key size in bytes
  * @param algo                 algorithm to implement
  * @return                             blowfish_crypter_t object, NULL if not supported
index 6e2f6d4fab2655b30c7a81c165a8da4562c87d77..993dc8b3b98d4cb3c5fb9cb2177daf8d8727dbe2 100644 (file)
@@ -48,12 +48,12 @@ static void destroy(private_blowfish_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_blowfish_plugin_t *this = malloc_thing(private_blowfish_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH,
                                                         (crypter_constructor_t)blowfish_crypter_create);
-       
+
        return &this->public.plugin;
 }
 
index 7ee9fa1bdae8b649d458c7d01650f7ff373ccd55..9c729175beddaac31ea797385645d769e34994a2 100644 (file)
@@ -33,12 +33,12 @@ struct private_curl_fetcher_t {
         * Public data
         */
        curl_fetcher_t public;
-       
+
        /**
         * CURL handle
         */
        CURL* curl;
-       
+
        /**
      * Optional HTTP headers
         */
@@ -51,7 +51,7 @@ struct private_curl_fetcher_t {
 static size_t append(void *ptr, size_t size, size_t nmemb, chunk_t *data)
 {
        size_t realsize = size * nmemb;
-       
+
        data->ptr = (u_char*)realloc(data->ptr, data->len + realsize);
        if (data->ptr)
        {
@@ -68,9 +68,9 @@ static status_t fetch(private_curl_fetcher_t *this, char *uri, chunk_t *result)
 {
        char error[CURL_ERROR_SIZE];
        status_t status;
-       
+
        *result = chunk_empty;
-       
+
        if (curl_easy_setopt(this->curl, CURLOPT_URL, uri) != CURLE_OK)
        {       /* URL type not supported by curl */
                return NOT_SUPPORTED;
@@ -85,7 +85,7 @@ static status_t fetch(private_curl_fetcher_t *this, char *uri, chunk_t *result)
        {
                curl_easy_setopt(this->curl, CURLOPT_HTTPHEADER, this->headers);
        }
-       
+
        DBG2("  sending http request to '%s'...", uri);
        switch (curl_easy_perform(this->curl))
        {
@@ -109,7 +109,7 @@ static status_t fetch(private_curl_fetcher_t *this, char *uri, chunk_t *result)
 static bool set_option(private_curl_fetcher_t *this, fetcher_option_t option, ...)
 {
        va_list args;
-       
+
        va_start(args, option);
        switch (option)
        {
@@ -170,7 +170,7 @@ static void destroy(private_curl_fetcher_t *this)
 curl_fetcher_t *curl_fetcher_create()
 {
        private_curl_fetcher_t *this = malloc_thing(private_curl_fetcher_t);
-       
+
        this->curl = curl_easy_init();
        if (this->curl == NULL)
        {
@@ -178,11 +178,11 @@ curl_fetcher_t *curl_fetcher_create()
                return NULL;
        }
        this->headers = NULL;
-       
+
        this->public.interface.fetch = (status_t(*)(fetcher_t*,char*,chunk_t*))fetch;
        this->public.interface.set_option = (bool(*)(fetcher_t*, fetcher_option_t option, ...))set_option;
        this->public.interface.destroy = (void (*)(fetcher_t*))destroy;
-       
+
        return &this->public;
 }
 
index 043beb83400d4fe390bc921c5aa0e1eaac331b4f..d82992d3204edb003e31b009bf66a705435b2eed 100644 (file)
@@ -32,7 +32,7 @@ struct curl_fetcher_t {
         * Implements fetcher interface
         */
        fetcher_t interface;
-               
+
        /**
      * Destroy a curl_fetcher instance.
      */
index 97fa07866d0719f3c1cbd682c52a31f26f39ee55..f35170bdda4b1de24247cb40a9705530c6dc357b 100644 (file)
@@ -52,24 +52,24 @@ plugin_t *plugin_create()
 {
        CURLcode res;
        private_curl_plugin_t *this = malloc_thing(private_curl_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        res = curl_global_init(CURL_GLOBAL_NOTHING);
        if (res == CURLE_OK)
        {
                lib->fetcher->add_fetcher(lib->fetcher,
                                                (fetcher_constructor_t)curl_fetcher_create, "file://");
-               lib->fetcher->add_fetcher(lib->fetcher, 
+               lib->fetcher->add_fetcher(lib->fetcher,
                                                (fetcher_constructor_t)curl_fetcher_create, "http://");
                lib->fetcher->add_fetcher(lib->fetcher,
                                                (fetcher_constructor_t)curl_fetcher_create, "https://");
-               lib->fetcher->add_fetcher(lib->fetcher, 
+               lib->fetcher->add_fetcher(lib->fetcher,
                                                (fetcher_constructor_t)curl_fetcher_create, "ftp://");
     }
     else
     {
-       DBG1("global libcurl initializing failed: %s, curl disabled", 
+       DBG1("global libcurl initializing failed: %s, curl disabled",
                         curl_easy_strerror(res));
     }
        return &this->public.plugin;
index 680fe8b6aed8af430448a3bf1cb71c08b8ff9007..142e79613ba931c99d4144ee8bd247f91fdcc052 100644 (file)
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -73,17 +73,17 @@ typedef struct private_des_crypter_t private_des_crypter_t;
  * Private data for des_crypter_t
  */
 struct private_des_crypter_t {
-       
+
        /**
         * Public part of this class.
         */
        des_crypter_t public;
-       
+
        /**
         * Key size, depends on algoritm...
         */
        size_t key_size;
-       
+
        union {
                /** key schedule for single des */
                des_key_schedule ks;
@@ -141,7 +141,7 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
    even newer MIPS CPU's, but at the moment one size fits all for
    optimization options.  Older Sparc's work better with only UNROLL, but
    there's no way to tell at compile time what it is you're running on */
+
 #if defined( sun )             /* Newer Sparc's */
 #define DES_PTR
 #define DES_RISC1
@@ -879,7 +879,7 @@ static int des_set_key(des_cblock *key, des_key_schedule *schedule)
        c2l(in,c);
        c2l(in,d);
 
-       /* do PC1 in 60 simple operations */ 
+       /* do PC1 in 60 simple operations */
 /*     PERM_OP(d,c,t,4,0x0f0f0f0fL);
        HPERM_OP(c,t,-2, 0xcccc0000L);
        HPERM_OP(c,t,-1, 0xaaaa0000L);
@@ -1037,7 +1037,7 @@ static void des_encrypt(DES_LONG *data, des_key_schedule ks, int enc)
 /**
  * DES CBC encrypt decrypt routine
  */
-static void des_cbc_encrypt(des_cblock *input, des_cblock *output, long length, 
+static void des_cbc_encrypt(des_cblock *input, des_cblock *output, long length,
                                                    des_key_schedule schedule, des_cblock *ivec, int enc)
 {
        register DES_LONG tin0,tin1;
@@ -1110,7 +1110,7 @@ static void des_cbc_encrypt(des_cblock *input, des_cblock *output, long length,
 /**
  * DES ECB encrypt decrypt routine
  */
-static void des_ecb_encrypt(des_cblock *input, des_cblock *output, long length, 
+static void des_ecb_encrypt(des_cblock *input, des_cblock *output, long length,
                                                    des_key_schedule schedule, int enc)
 {
        register DES_LONG tin0,tin1;
@@ -1260,7 +1260,7 @@ static void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
 /**
  * Single block 3DES EDE encrypt routine
  */
-static void des_encrypt3(DES_LONG *data, des_key_schedule ks1, 
+static void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
                                                 des_key_schedule ks2, des_key_schedule ks3)
 {
        register DES_LONG l,r;
@@ -1283,7 +1283,7 @@ static void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
 /**
  * Single block 3DES EDE decrypt routine
  */
-static void des_decrypt3(DES_LONG *data, des_key_schedule ks1, 
+static void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
                                                 des_key_schedule ks2, des_key_schedule ks3)
 {
        register DES_LONG l,r;
@@ -1391,7 +1391,7 @@ static void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, long len
                {
                        c2l(in,tin0);
                        c2l(in,tin1);
-                       
+
                        t0=tin0;
                        t1=tin1;
 
@@ -1400,7 +1400,7 @@ static void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, long len
                        des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
                        tout0=tin[0];
                        tout1=tin[1];
-               
+
                        tout0^=xor0;
                        tout1^=xor1;
                        l2cn(tout0,tout1,out,l+8);
@@ -1424,7 +1424,7 @@ static void decrypt(private_des_crypter_t *this, chunk_t data, chunk_t iv,
 {
        des_cblock ivb;
        u_int8_t *out;
-       
+
        out = data.ptr;
        if (decrypted)
        {
@@ -1445,7 +1445,7 @@ static void encrypt(private_des_crypter_t *this, chunk_t data, chunk_t iv,
 {
        des_cblock ivb;
        u_int8_t *out;
-       
+
        out = data.ptr;
        if (encrypted)
        {
@@ -1464,7 +1464,7 @@ static void decrypt_ecb(private_des_crypter_t *this, chunk_t data, chunk_t iv,
                                                chunk_t *decrypted)
 {
        u_int8_t *out;
-       
+
        out = data.ptr;
        if (decrypted)
        {
@@ -1482,7 +1482,7 @@ static void encrypt_ecb(private_des_crypter_t *this, chunk_t data, chunk_t iv,
                                                chunk_t *encrypted)
 {
        u_int8_t *out;
-       
+
        out = data.ptr;
        if (encrypted)
        {
@@ -1501,7 +1501,7 @@ static void decrypt3(private_des_crypter_t *this, chunk_t data, chunk_t iv,
 {
        des_cblock ivb;
        u_int8_t *out;
-       
+
        out = data.ptr;
        if (decrypted)
        {
@@ -1522,7 +1522,7 @@ static void encrypt3(private_des_crypter_t *this, chunk_t data, chunk_t iv,
 {
        des_cblock ivb;
        u_int8_t *out;
-       
+
        out = data.ptr;
        if (encrypted)
        {
@@ -1563,7 +1563,7 @@ static void set_key(private_des_crypter_t *this, chunk_t key)
  * Implementation of crypter_t.set_key for 3DES.
  */
 static void set_key3(private_des_crypter_t *this, chunk_t key)
-{      
+{
        des_set_key((des_cblock*)(key.ptr) + 0, &this->ks3[0]);
        des_set_key((des_cblock*)(key.ptr) + 1, &this->ks3[1]);
        des_set_key((des_cblock*)(key.ptr) + 2, &this->ks3[2]);
@@ -1583,12 +1583,12 @@ static void destroy(private_des_crypter_t *this)
 des_crypter_t *des_crypter_create(encryption_algorithm_t algo)
 {
        private_des_crypter_t *this = malloc_thing(private_des_crypter_t);
-       
-       /* functions of crypter_t interface */  
+
+       /* functions of crypter_t interface */
        this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *)) get_block_size;
        this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *)) get_key_size;
        this->public.crypter_interface.destroy = (void (*) (crypter_t *)) destroy;
-       
+
        /* use functions depending on algorithm */
        switch (algo)
        {
index 623b292fc8970a0690d55aecdcb0a51507659706..cffbd4ce30ae2060743e4fd0485da330e4b29080 100644 (file)
@@ -30,7 +30,7 @@ typedef struct des_crypter_t des_crypter_t;
  * Class implementing the DES and 3DES encryption algorithms.
  */
 struct des_crypter_t {
-       
+
        /**
         * The crypter_t interface.
         */
@@ -39,7 +39,7 @@ struct des_crypter_t {
 
 /**
  * Constructor to create des_crypter_t objects.
- * 
+ *
  * @param algo         ENCR_DES for single DES, ENCR_3DES for triple DES
  * @return                     des_crypter_t object, NULL if algo not supported
  */
index e16b475d4309566ddb27c981397f781fb0dd925e..649d224aba90affd8af6c664a7f8d2fc46984af4 100644 (file)
@@ -47,16 +47,16 @@ static void destroy(private_des_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_des_plugin_t *this = malloc_thing(private_des_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
                                                         (crypter_constructor_t)des_crypter_create);
        lib->crypto->add_crypter(lib->crypto, ENCR_DES,
                                                         (crypter_constructor_t)des_crypter_create);
        lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB,
                                                         (crypter_constructor_t)des_crypter_create);
-       
+
        return &this->public.plugin;
 }
 
index 6d79d589ceb08c2fb9f24a90fdbc82b47f2758d7..792e7c160f6afb21fb2eb5ec77fc8f23da3eebc7 100644 (file)
@@ -49,14 +49,14 @@ enum dnskey_algorithm_t {
 static public_key_t *parse_public_key(chunk_t blob)
 {
        dnskey_rr_t *rr = (dnskey_rr_t*)blob.ptr;
-       
+
        if (blob.len < sizeof(dnskey_rr_t))
        {
                DBG1("DNSKEY too short");
                return NULL;
        }
        blob = chunk_skip(blob, sizeof(dnskey_rr_t));
-       
+
        switch (rr->algorithm)
        {
                case DNSKEY_ALG_RSA_SHA1:
@@ -74,13 +74,13 @@ static public_key_t *parse_public_key(chunk_t blob)
 static public_key_t *parse_rsa_public_key(chunk_t blob)
 {
        chunk_t n, e;
-       
+
        if (blob.len < 3)
        {
                DBG1("RFC 3110 public key blob too short for exponent length");
                return NULL;
        }
-       
+
        if (blob.ptr[0])
        {
                e.len = blob.ptr[0];
@@ -98,7 +98,7 @@ static public_key_t *parse_rsa_public_key(chunk_t blob)
                return NULL;
        }
        n = chunk_skip(blob, e.len);
-       
+
        return lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e,
                                                BUILD_END);
@@ -124,7 +124,7 @@ struct private_builder_t {
 static public_key_t *build_public(private_builder_t *this)
 {
        public_key_t *key = NULL;
-       
+
        switch (this->type)
        {
                case KEY_ANY:
@@ -146,7 +146,7 @@ static public_key_t *build_public(private_builder_t *this)
 static void add_public(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_BLOB_DNSKEY:
@@ -168,19 +168,19 @@ static void add_public(private_builder_t *this, builder_part_t part, ...)
 builder_t *dnskey_public_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_ANY && type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->blob = chunk_empty;
        this->type = type;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_public;
        this->public.build = (void*(*)(builder_t *this))build_public;
-       
+
        return &this->public;
 }
 
index 9f4dd4827ab8cb3a6100b03970e12cf31ea51d01..d2cf6e4b54a2a99e47ecb031214bc572bc336137 100644 (file)
@@ -47,14 +47,14 @@ static void destroy(private_dnskey_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_dnskey_plugin_t *this = malloc_thing(private_dnskey_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
                                                        (builder_constructor_t)dnskey_public_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                        (builder_constructor_t)dnskey_public_key_builder);
-       
+
        return &this->public.plugin;
 }
 
index be28f10bc8e006afc7bf83e5a79a21b0bd1e52e4..ba8158367f2485a46661c558f52f72a1dffe1d45 100644 (file)
@@ -29,22 +29,22 @@ struct private_fips_prf_t {
         * Public fips_prf_t interface.
         */
        fips_prf_t public;
-       
+
        /**
         * key of prf function, "b" long
         */
        u_int8_t *key;
-       
+
        /**
         * size of "b" in bytes
         */
        size_t b;
-       
+
        /**
         * Keyed SHA1 prf: It does not use SHA1Final operation
         */
        prf_t *keyed_prf;
-       
+
        /**
         * G function, either SHA1 or DES
         */
@@ -57,11 +57,11 @@ struct private_fips_prf_t {
 static void add_mod(size_t length, u_int8_t a[], u_int8_t b[], u_int8_t sum[])
 {
        int i, c = 0;
-       
+
        for(i = length - 1; i >= 0; i--)
        {
                u_int32_t tmp;
-               
+
                tmp = a[i] + b[i] + c;
                sum[i] = 0xff & tmp;
                c = tmp >> 8;
@@ -115,13 +115,13 @@ static void get_bytes(private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
        u_int8_t *xkey = this->key;
        u_int8_t one[this->b];
        chunk_t xval_chunk = chunk_from_buf(xval);
-       
+
        memset(one, 0, this->b);
        one[this->b - 1] = 0x01;
-       
+
        /* 3.1 */
        chunk_mod(this->b, seed, xseed);
-       
+
        /* 3.2 */
        for (i = 0; i < 2; i++) /* twice */
        {
@@ -136,7 +136,7 @@ static void get_bytes(private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
                add_mod(this->b, sum, one, xkey);
                DBG3("XKEY %b", xkey, this->b);
        }
-       
+
        /* 3.3 done already, mod q not used */
 }
 
@@ -179,7 +179,7 @@ static void set_key(private_fips_prf_t *this, chunk_t key)
 void g_sha1(private_fips_prf_t *this, chunk_t c, u_int8_t res[])
 {
        u_int8_t buf[64];
-       
+
        if (c.len < sizeof(buf))
        {
                /* pad c with zeros */
@@ -193,7 +193,7 @@ void g_sha1(private_fips_prf_t *this, chunk_t c, u_int8_t res[])
                /* not more than 512 bits can be G()-ed */
                c.len = sizeof(buf);
        }
-       
+
        /* use the keyed hasher, but use an empty key to use SHA1 IV */
        this->keyed_prf->set_key(this->keyed_prf, chunk_empty);
        this->keyed_prf->get_bytes(this->keyed_prf, c, res);
@@ -215,14 +215,14 @@ static void destroy(private_fips_prf_t *this)
 fips_prf_t *fips_prf_create(pseudo_random_function_t algo)
 {
        private_fips_prf_t *this = malloc_thing(private_fips_prf_t);
-       
+
        this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
        this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
        this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size;
        this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
        this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
        this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
-       
+
        switch (algo)
        {
                case PRF_FIPS_SHA1_160:
@@ -244,7 +244,7 @@ fips_prf_t *fips_prf_create(pseudo_random_function_t algo)
                        return NULL;
        }
        this->key = malloc(this->b);
-       
+
        return &this->public;
 }
 
index b2940be72c0558333abe9b9b240e079efcb79371..514e3c5d9e6865b71295f0f00acf1465830a4695 100644 (file)
@@ -37,7 +37,7 @@ typedef struct fips_prf_t fips_prf_t;
  * The FIPS PRF is stateful; the key changes every time when bytes are acquired.
  */
 struct fips_prf_t {
-       
+
        /**
         * Generic prf_t interface for this fips_prf_t class.
         */
@@ -46,7 +46,7 @@ struct fips_prf_t {
 
 /**
  * Creates a new fips_prf_t object.
- * 
+ *
  * FIPS 186-2 defines G() functions used in the PRF function. It can
  * be implemented either based on SHA1 or DES.
  * The G() function is selected using the algo parameter.
index 7576e79ad824d2a5c013364d5cb40e0d3a528c9e..6c0842f81f741c80c280b92274761e6c2e3779d6 100644 (file)
@@ -47,11 +47,11 @@ static void destroy(private_fips_prf_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_fips_prf_plugin_t *this = malloc_thing(private_fips_prf_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_prf(lib->crypto, PRF_FIPS_SHA1_160,
                                                 (prf_constructor_t)fips_prf_create);
-       
+
        return &this->public.plugin;
 }
index f82d2318528833fd7a9938d206c4f80269ec3c54..1eee6226d31dc04234264f187a108804e310ed39 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2009 Martin Willi
- * Hochschule fuer Technik Rapperswil 
+ * Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -25,17 +25,17 @@ typedef struct private_gcrypt_crypter_t private_gcrypt_crypter_t;
  * Private data of gcrypt_crypter_t
  */
 struct private_gcrypt_crypter_t {
-       
+
        /**
         * Public part of this class.
         */
        gcrypt_crypter_t public;
-       
+
        /**
         * gcrypt cipher handle
         */
        gcry_cipher_hd_t h;
-       
+
        /**
         * gcrypt algorithm identifier
         */
@@ -49,7 +49,7 @@ static void decrypt(private_gcrypt_crypter_t *this, chunk_t data,
                                        chunk_t iv, chunk_t *dst)
 {
        gcry_cipher_setiv(this->h, iv.ptr, iv.len);
-       
+
        if (dst)
        {
                *dst = chunk_alloc(data.len);
@@ -68,7 +68,7 @@ static void encrypt(private_gcrypt_crypter_t *this, chunk_t data,
                                        chunk_t iv, chunk_t *dst)
 {
        gcry_cipher_setiv(this->h, iv.ptr, iv.len);
-       
+
        if (dst)
        {
                *dst = chunk_alloc(data.len);
@@ -86,7 +86,7 @@ static void encrypt(private_gcrypt_crypter_t *this, chunk_t data,
 static size_t get_block_size(private_gcrypt_crypter_t *this)
 {
        size_t len = 0;
-       
+
        gcry_cipher_algo_info(this->alg, GCRYCTL_GET_BLKLEN, NULL, &len);
        return len;
 }
@@ -97,7 +97,7 @@ static size_t get_block_size(private_gcrypt_crypter_t *this)
 static size_t get_key_size(private_gcrypt_crypter_t *this)
 {
        size_t len = 0;
-       
+
        gcry_cipher_algo_info(this->alg, GCRYCTL_GET_KEYLEN, NULL, &len);
        return len;
 }
@@ -129,7 +129,7 @@ gcrypt_crypter_t *gcrypt_crypter_create(encryption_algorithm_t algo,
        int gcrypt_alg;
        int mode = GCRY_CIPHER_MODE_CBC;
        gcry_error_t err;
-       
+
        switch (algo)
        {
                case ENCR_DES:
@@ -227,9 +227,9 @@ gcrypt_crypter_t *gcrypt_crypter_create(encryption_algorithm_t algo,
                default:
                        return NULL;
        }
-       
+
        this = malloc_thing(private_gcrypt_crypter_t);
-       
+
        this->alg = gcrypt_alg;
        err = gcry_cipher_open(&this->h, gcrypt_alg, mode, 0);
        if (err)
@@ -239,14 +239,14 @@ gcrypt_crypter_t *gcrypt_crypter_create(encryption_algorithm_t algo,
                free(this);
                return NULL;
        }
-       
+
        this->public.crypter_interface.encrypt = (void (*) (crypter_t *, chunk_t,chunk_t, chunk_t *))encrypt;
        this->public.crypter_interface.decrypt = (void (*) (crypter_t *, chunk_t , chunk_t, chunk_t *))decrypt;
        this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *))get_block_size;
        this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *))get_key_size;
        this->public.crypter_interface.set_key = (void (*) (crypter_t *,chunk_t))set_key;
        this->public.crypter_interface.destroy = (void (*) (crypter_t *))destroy;
-       
+
        return &this->public;
 }
 
index c5a5e6723aa42b32c74dc8d4437cb2ab1ca4b181..ce0ead4a89e1084962504c32eb133ec173ac6fe5 100644 (file)
@@ -29,7 +29,7 @@ typedef struct gcrypt_crypter_t gcrypt_crypter_t;
  * Implementation of crypters using gcrypt.
  */
 struct gcrypt_crypter_t {
-       
+
        /**
         * The crypter_t interface.
         */
@@ -38,7 +38,7 @@ struct gcrypt_crypter_t {
 
 /**
  * Constructor to create gcrypt_crypter_t.
- * 
+ *
  * @param algo                 algorithm to implement
  * @param key_size             key size in bytes
  * @return                             gcrypt_crypter_t, NULL if not supported
index 89d9f234807660d37335e675b9d76ea85d9e16d1..59c82f1e777ef39b065ab5c2e10f7c304b1ee74e 100644 (file)
@@ -278,7 +278,7 @@ static u_int8_t group18_modulus[] = {
 
 typedef struct modulus_entry_t modulus_entry_t;
 
-/** 
+/**
  * Entry of the modulus list.
  */
 struct modulus_entry_t {
@@ -312,7 +312,7 @@ static modulus_entry_t modulus_entries[] = {
 static modulus_entry_t *find_entry(diffie_hellman_group_t group)
 {
        int i;
-       
+
        for (i = 0; i < countof(modulus_entries); i++)
        {
                if (modulus_entries[i].group == group)
@@ -329,47 +329,47 @@ typedef struct private_gcrypt_dh_t private_gcrypt_dh_t;
  * Private data of an gcrypt_dh_t object.
  */
 struct private_gcrypt_dh_t {
-       
+
        /**
         * Public gcrypt_dh_t interface
         */
        gcrypt_dh_t public;
-       
+
        /**
         * Diffie Hellman group number
         */
        u_int16_t group;
-       
-       /* 
+
+       /*
         * Generator value
-        */     
+        */
        gcry_mpi_t g;
-       
+
        /**
         * Own private value
         */
        gcry_mpi_t xa;
-       
+
        /**
         * Own public value
         */
        gcry_mpi_t ya;
-       
+
        /**
         * Other public value
         */
        gcry_mpi_t yb;
-       
+
        /**
         * Shared secret
         */
        gcry_mpi_t zz;
-       
+
        /**
         * Modulus
         */
        gcry_mpi_t p;
-       
+
        /**
         * Modulus length.
         */
@@ -383,7 +383,7 @@ static void set_other_public_value(private_gcrypt_dh_t *this, chunk_t value)
 {
        gcry_mpi_t p_min_1;
        gcry_error_t err;
-       
+
        if (this->yb)
        {
                gcry_mpi_release(this->yb);
@@ -395,11 +395,11 @@ static void set_other_public_value(private_gcrypt_dh_t *this, chunk_t value)
                DBG1("importing mpi yb failed: %s", gpg_strerror(err));
                return;
        }
-       
+
        p_min_1 = gcry_mpi_new(this->p_len * 8);
        gcry_mpi_sub_ui(p_min_1, this->p, 1);
-       
-       /* check public value: 
+
+       /* check public value:
         * 1. 0 or 1 is invalid as 0^a = 0 and 1^a = 1
         * 2. a public value larger or equal the modulus is invalid */
        if (gcry_mpi_cmp_ui(this->yb, 1) > 0 &&
@@ -425,7 +425,7 @@ static chunk_t export_mpi(gcry_mpi_t value, size_t len)
 {
        chunk_t chunk;
        size_t written;
-       
+
        chunk = chunk_alloc(len);
        gcry_mpi_print(GCRYMPI_FMT_USG, chunk.ptr, chunk.len, &written, value);
        if (written < len)
@@ -490,21 +490,21 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
        chunk_t random;
        rng_t *rng;
        size_t len;
-       
+
        entry = find_entry(group);
        if (!entry)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_gcrypt_dh_t);
-       
+
        this->public.dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_shared_secret;
        this->public.dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t )) set_other_public_value;
        this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
        this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
        this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
-       
+
        this->group = group;
        this->p_len = entry->modulus.len;
        err = gcry_mpi_scan(&this->p, GCRYMPI_FMT_USG,
@@ -524,7 +524,7 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
        {
                len = entry->opt_len;
        }
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
        if (rng)
        {       /* prefer external randomizer */
@@ -551,14 +551,14 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
                /* achieve bitsof(p)-1 by setting MSB to 0 */
                gcry_mpi_clear_bit(this->xa, len * 8 - 1);
        }
-       
+
        this->g = gcry_mpi_set_ui(NULL, entry->g);
        this->ya = gcry_mpi_new(this->p_len * 8);
        this->yb = NULL;
        this->zz = NULL;
-       
+
        gcry_mpi_powm(this->ya, this->g, this->xa, this->p);
-       
+
        return &this->public;
 }
 
index dbef96ca7b8cf20272ac65a62377d70b2aba3170..95b68dcd08b97f9a90b43587413b6b0c94c8ef1f 100644 (file)
@@ -29,7 +29,7 @@ typedef struct gcrypt_dh_t gcrypt_dh_t;
  * Implementation of the Diffie-Hellman algorithm using libgcrypt mpi.
  */
 struct gcrypt_dh_t {
-       
+
        /**
         * Implements diffie_hellman_t interface.
         */
@@ -38,7 +38,7 @@ struct gcrypt_dh_t {
 
 /**
  * Creates a new gcrypt_dh_t object.
- * 
+ *
  * @param group                        Diffie Hellman group number to use
  * @return                             gcrypt_dh_t object, NULL if not supported
  */
index 41e17c8977b943ed7e022d1cf8bd0b720ec643c8..d12fe11d566ab05dd4e1522424ddc341b2a48ee7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2009 Martin Willi
- * Hochschule fuer Technik Rapperswil 
+ * Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -25,12 +25,12 @@ typedef struct private_gcrypt_hasher_t private_gcrypt_hasher_t;
  * Private data of gcrypt_hasher_t
  */
 struct private_gcrypt_hasher_t {
-       
+
        /**
         * Public part of this class.
         */
        gcrypt_hasher_t public;
-       
+
        /**
         * gcrypt hasher context
         */
@@ -101,7 +101,7 @@ gcrypt_hasher_t *gcrypt_hasher_create(hash_algorithm_t algo)
        private_gcrypt_hasher_t *this;
        int gcrypt_alg;
        gcry_error_t err;
-       
+
        switch (algo)
        {
                case HASH_MD2:
@@ -131,9 +131,9 @@ gcrypt_hasher_t *gcrypt_hasher_create(hash_algorithm_t algo)
                default:
                        return NULL;
        }
-       
+
        this = malloc_thing(private_gcrypt_hasher_t);
-       
+
        err = gcry_md_open(&this->hd, gcrypt_alg, 0);
        if (err)
        {
@@ -142,13 +142,13 @@ gcrypt_hasher_t *gcrypt_hasher_create(hash_algorithm_t algo)
                free(this);
                return NULL;
        }
-       
+
        this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
        this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
        this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size;
        this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
        this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-       
+
        return &this->public;
 }
 
index 6f724fba8be672f73ca7298c69e18f041e064c53..708ccaafb691e371c6d3ba6420e250062a422128 100644 (file)
@@ -29,7 +29,7 @@ typedef struct gcrypt_hasher_t gcrypt_hasher_t;
  * Implementation of hashers using libgcrypt.
  */
 struct gcrypt_hasher_t {
-       
+
        /**
         * The hasher_t interface.
         */
@@ -38,7 +38,7 @@ struct gcrypt_hasher_t {
 
 /**
  * Constructor to create gcrypt_hasher_t.
- * 
+ *
  * @param algo                 algorithm
  * @return                             gcrypt_hasher_t, NULL if not supported
  */
index 939e0886cc1c2c936d1123501f7b95262c848b4d..0e3ba5e25319abbd992fa5e66224520b04c44c62 100644 (file)
@@ -57,7 +57,7 @@ static int mutex_init(void **lock)
 static int mutex_destroy(void **lock)
 {
        mutex_t *mutex = *lock;
-       
+
        mutex->destroy(mutex);
        return 0;
 }
@@ -68,7 +68,7 @@ static int mutex_destroy(void **lock)
 static int mutex_lock(void **lock)
 {
        mutex_t *mutex = *lock;
-       
+
        mutex->lock(mutex);
        return 0;
 }
@@ -79,7 +79,7 @@ static int mutex_lock(void **lock)
 static int mutex_unlock(void **lock)
 {
        mutex_t *mutex = *lock;
-       
+
        mutex->unlock(mutex);
        return 0;
 }
@@ -119,15 +119,15 @@ static void destroy(private_gcrypt_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_gcrypt_plugin_t *this;
-       
+
        gcry_control(GCRYCTL_SET_THREAD_CBS, &thread_functions);
-       
+
        if (!gcry_check_version(GCRYPT_VERSION))
        {
                DBG1("libgcrypt version mismatch");
                return NULL;
        }
-       
+
        /* we currently do not use secure memory */
        gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
        if (lib->settings->get_bool(lib->settings,
@@ -136,11 +136,11 @@ plugin_t *plugin_create()
                gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM, 0);
        }
        gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
-       
+
        this = malloc_thing(private_gcrypt_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        /* hashers */
        lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
                                        (hasher_constructor_t)gcrypt_hasher_create);
@@ -156,7 +156,7 @@ plugin_t *plugin_create()
                                        (hasher_constructor_t)gcrypt_hasher_create);
        lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
                                        (hasher_constructor_t)gcrypt_hasher_create);
-       
+
        /* crypters */
        lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
                                        (crypter_constructor_t)gcrypt_crypter_create);
@@ -176,39 +176,39 @@ plugin_t *plugin_create()
                                        (crypter_constructor_t)gcrypt_crypter_create);
        lib->crypto->add_crypter(lib->crypto, ENCR_TWOFISH_CBC,
                                        (crypter_constructor_t)gcrypt_crypter_create);
-       
+
        /* random numbers */
-       lib->crypto->add_rng(lib->crypto, RNG_WEAK, 
+       lib->crypto->add_rng(lib->crypto, RNG_WEAK,
                                                 (rng_constructor_t)gcrypt_rng_create);
-       lib->crypto->add_rng(lib->crypto, RNG_STRONG, 
+       lib->crypto->add_rng(lib->crypto, RNG_STRONG,
                                                 (rng_constructor_t)gcrypt_rng_create);
-       lib->crypto->add_rng(lib->crypto, RNG_TRUE, 
+       lib->crypto->add_rng(lib->crypto, RNG_TRUE,
                                                 (rng_constructor_t)gcrypt_rng_create);
-       
+
        /* diffie hellman groups, using modp */
-       lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
-       lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
-       lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
-       lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
-       lib->crypto->add_dh(lib->crypto, MODP_6144_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
-       lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
        lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
-       lib->crypto->add_dh(lib->crypto, MODP_768_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
                                        (dh_constructor_t)gcrypt_dh_create);
-       
+
        /* RSA */
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                        (builder_constructor_t)gcrypt_rsa_private_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                        (builder_constructor_t)gcrypt_rsa_public_key_builder);
-       
+
        return &this->public.plugin;
 }
 
index 64b4eb8d08737e81631b420f7490df9dfbdd5320..d0d252572085353bc0e2715f055b755c62d5348b 100644 (file)
@@ -28,7 +28,7 @@ struct private_gcrypt_rng_t {
         * Public gcrypt_rng_t interface.
         */
        gcrypt_rng_t public;
-       
+
        /**
         * RNG quality of this instance
         */
@@ -79,7 +79,7 @@ static void destroy(private_gcrypt_rng_t *this)
 gcrypt_rng_t *gcrypt_rng_create(rng_quality_t quality)
 {
        private_gcrypt_rng_t *this;
-       
+
        switch (quality)
        {
                case RNG_WEAK:
@@ -89,15 +89,15 @@ gcrypt_rng_t *gcrypt_rng_create(rng_quality_t quality)
                default:
                        return NULL;
        }
-       
+
        this = malloc_thing(private_gcrypt_rng_t);
-       
+
        this->public.rng.get_bytes = (void (*) (rng_t *, size_t, u_int8_t*)) get_bytes;
        this->public.rng.allocate_bytes = (void (*) (rng_t *, size_t, chunk_t*)) allocate_bytes;
        this->public.rng.destroy = (void (*) (rng_t *))destroy;
-       
+
        this->quality = quality;
-       
+
        return &this->public;
 }
 
index 3cfde8447de63b25c327b805e20ac597825d1882..a0cc123695ae745a4f59238c626df4ffb2a13546 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup gcrypt_rng gcrypt_rng
  * @{ @ingroup gcrypt_p
@@ -29,7 +29,7 @@ typedef struct gcrypt_rng_t gcrypt_rng_t;
  * rng_t implementation using libgcrypt.
  */
 struct gcrypt_rng_t {
-       
+
        /**
         * Implements rng_t.
         */
@@ -38,7 +38,7 @@ struct gcrypt_rng_t {
 
 /**
  * Creates an gcrypt_rng_t instance.
- * 
+ *
  * @param quality      required quality of gcryptness
  * @return                     created gcrypt_rng_t
  */
index 0d8f3d2072ea46e8d1a3b506fa1554f6568fa666..64ec789279f02bd19bccee9ff6a13847fe44267b 100644 (file)
@@ -28,17 +28,17 @@ typedef struct private_gcrypt_rsa_private_key_t private_gcrypt_rsa_private_key_t
  * Private data of a gcrypt_rsa_private_key_t object.
  */
 struct private_gcrypt_rsa_private_key_t {
-       
+
        /**
         * Public interface
         */
        gcrypt_rsa_private_key_t public;
-       
+
        /**
         * gcrypt S-expression representing an RSA key
         */
        gcry_sexp_t key;
-       
+
        /**
         * reference count
         */
@@ -54,7 +54,7 @@ chunk_t gcrypt_rsa_find_token(gcry_sexp_t sexp, char *name, gcry_sexp_t key)
        gcry_sexp_t token;
        chunk_t data = chunk_empty, tmp;
        size_t len = 0;
-       
+
        token = gcry_sexp_find_token(sexp, name, 1);
        if (token)
        {
@@ -108,7 +108,7 @@ static bool sign_raw(private_gcrypt_rsa_private_key_t *this,
        gcry_error_t err;
        chunk_t em;
        size_t k;
-       
+
        /* EM = 0x00 || 0x01 || PS || 0x00 || T
         * PS = 0xFF padding, with length to fill em
         * T  = data
@@ -124,7 +124,7 @@ static bool sign_raw(private_gcrypt_rsa_private_key_t *this,
        em.ptr[1] = 0x01;
        em.ptr[em.len - data.len - 1] = 0x00;
        memcpy(em.ptr + em.len - data.len, data.ptr, data.len);
-       
+
        err = gcry_sexp_build(&in, NULL, "(data(flags raw)(value %b))",
                                                  em.len, em.ptr);
        chunk_free(&em);
@@ -157,7 +157,7 @@ static bool sign_pkcs1(private_gcrypt_rsa_private_key_t *this,
        gcry_error_t err;
        gcry_sexp_t in, out;
        int hash_oid;
-       
+
        hash_oid = hasher_algorithm_to_oid(hash_algorithm);
        if (hash_oid == OID_UNKNOWN)
        {
@@ -170,7 +170,7 @@ static bool sign_pkcs1(private_gcrypt_rsa_private_key_t *this,
        }
        hasher->allocate_hash(hasher, data, &hash);
        hasher->destroy(hasher);
-       
+
        err = gcry_sexp_build(&in, NULL, "(data(flags pkcs1)(hash %s %b))",
                                                  hash_name, hash.len, hash.ptr);
        chunk_free(&hash);
@@ -202,7 +202,7 @@ static key_type_t get_type(private_gcrypt_rsa_private_key_t *this)
 /**
  * Implementation of gcrypt_rsa_private_key.destroy.
  */
-static bool sign(private_gcrypt_rsa_private_key_t *this, signature_scheme_t scheme, 
+static bool sign(private_gcrypt_rsa_private_key_t *this, signature_scheme_t scheme,
                                 chunk_t data, chunk_t *sig)
 {
        switch (scheme)
@@ -238,7 +238,7 @@ static bool decrypt(private_gcrypt_rsa_private_key_t *this,
        gcry_sexp_t in, out;
        chunk_t padded;
        u_char *pos = NULL;;
-       
+
        err = gcry_sexp_build(&in, NULL, "(enc-val(flags)(rsa(a %b)))",
                                                  encrypted.len, encrypted.ptr);
        if (err)
@@ -290,15 +290,15 @@ static public_key_t* get_public_key(private_gcrypt_rsa_private_key_t *this)
 {
        chunk_t n, e;
        public_key_t *public;
-       
+
        n = gcrypt_rsa_find_token(this->key, "n", NULL);
        e = gcrypt_rsa_find_token(this->key, "e", NULL);
-       
+
        public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END);
        chunk_free(&n);
        chunk_free(&e);
-       
+
        return public;
 }
 
@@ -312,12 +312,12 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
        gcry_mpi_t p = NULL, q = NULL, d = NULL, exp1, exp2;
        gcry_error_t err;
        bool success;
-       
+
        /* p and q are swapped, gcrypt expects p < q */
        cp = gcrypt_rsa_find_token(this->key, "q", NULL);
        cq = gcrypt_rsa_find_token(this->key, "p", NULL);
        cd = gcrypt_rsa_find_token(this->key, "d", NULL);
-       
+
        err = gcry_mpi_scan(&p, GCRYMPI_FMT_USG, cp.ptr, cp.len, NULL)
                | gcry_mpi_scan(&q, GCRYMPI_FMT_USG, cq.ptr, cq.len, NULL)
                | gcry_mpi_scan(&d, GCRYMPI_FMT_USG, cd.ptr, cd.len, NULL);
@@ -332,24 +332,24 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
                DBG1("scanning mpi for export failed: %s", gpg_strerror(err));
                return FALSE;
        }
-       
+
        gcry_mpi_sub_ui(p, p, 1);
        exp1 = gcry_mpi_new(gcry_pk_get_nbits(this->key));
        gcry_mpi_mod(exp1, d, p);
        gcry_mpi_release(p);
-       
+
        gcry_mpi_sub_ui(q, q, 1);
        exp2 = gcry_mpi_new(gcry_pk_get_nbits(this->key));
        gcry_mpi_mod(exp1, d, q);
        gcry_mpi_release(q);
-       
+
        err = gcry_mpi_aprint(GCRYMPI_FMT_USG, &cexp1.ptr, &cexp1.len, exp1)
                | gcry_mpi_aprint(GCRYMPI_FMT_USG, &cexp2.ptr, &cexp2.len, exp2);
-       
+
        gcry_mpi_release(d);
        gcry_mpi_release(exp1);
        gcry_mpi_release(exp2);
-       
+
        if (err)
        {
                DBG1("printing mpi for export failed: %s", gpg_strerror(err));
@@ -360,11 +360,11 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
                chunk_clear(&cexp2);
                return FALSE;
        }
-       
+
        cn = gcrypt_rsa_find_token(this->key, "n", NULL);
        ce = gcrypt_rsa_find_token(this->key, "e", NULL);
        cu = gcrypt_rsa_find_token(this->key, "u", NULL);
-       
+
        success = lib->encoding->encode(lib->encoding, type, NULL, encoding,
                                                        KEY_PART_RSA_MODULUS, cn,
                                                        KEY_PART_RSA_PUB_EXP, ce, KEY_PART_RSA_PRIV_EXP, cd,
@@ -379,7 +379,7 @@ static bool get_encoding(private_gcrypt_rsa_private_key_t *this,
        chunk_clear(&cexp1);
        chunk_clear(&cexp2);
        chunk_clear(&cu);
-       
+
        return success;
 }
 
@@ -391,14 +391,14 @@ static bool get_fingerprint(private_gcrypt_rsa_private_key_t *this,
 {
        chunk_t n, e;
        bool success;
-       
+
        if (lib->encoding->get_cache(lib->encoding, type, this, fp))
        {
                return TRUE;
        }
        n = gcrypt_rsa_find_token(this->key, "n", NULL);
        e = gcrypt_rsa_find_token(this->key, "e", NULL);
-       
+
        success = lib->encoding->encode(lib->encoding,
                                                                type, this, fp, KEY_PART_RSA_MODULUS, n,
                                                                KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
@@ -435,7 +435,7 @@ static void destroy(private_gcrypt_rsa_private_key_t *this)
 static private_gcrypt_rsa_private_key_t *gcrypt_rsa_private_key_create_empty()
 {
        private_gcrypt_rsa_private_key_t *this = malloc_thing(private_gcrypt_rsa_private_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type;
        this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign;
        this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt;
@@ -447,10 +447,10 @@ static private_gcrypt_rsa_private_key_t *gcrypt_rsa_private_key_create_empty()
        this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref;
        this->public.interface.destroy = (void (*)(private_key_t *this))destroy;
-       
+
        this->key = NULL;
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -462,14 +462,14 @@ static gcrypt_rsa_private_key_t *generate(size_t key_size)
        private_gcrypt_rsa_private_key_t *this;
        gcry_sexp_t param, key;
        gcry_error_t err;
-       
+
        err = gcry_sexp_build(&param, NULL, "(genkey(rsa(nbits %d)))", key_size);
        if (err)
        {
                DBG1("building S-expression failed: %s", gpg_strerror(err));
                return NULL;
        }
-       
+
        err = gcry_pk_genkey(&key, param);
        gcry_sexp_release(param);
        if (err)
@@ -479,7 +479,7 @@ static gcrypt_rsa_private_key_t *generate(size_t key_size)
        }
        this = gcrypt_rsa_private_key_create_empty();
        this->key = key;
-       
+
        return &this->public;
 }
 
@@ -491,7 +491,7 @@ static gcrypt_rsa_private_key_t *load(chunk_t n, chunk_t e, chunk_t d,
 {
        gcry_error_t err;
        private_gcrypt_rsa_private_key_t *this = gcrypt_rsa_private_key_create_empty();
-       
+
        err = gcry_sexp_build(&this->key, NULL,
                                        "(private-key(rsa(n %b)(e %b)(d %b)(p %b)(q %b)(u %b)))",
                                        n.len, n.ptr, e.len, e.ptr, d.len, d.ptr,
@@ -551,7 +551,7 @@ static gcrypt_rsa_private_key_t *build(private_builder_t *this)
 static void add(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        va_start(args, part);
        switch (part)
        {
@@ -594,19 +594,19 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *gcrypt_rsa_private_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->key_size = 0;
        this->n = this->e = this->d = this->p = this->q = this->u = chunk_empty;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 2edd7ce5d19b22dce20958be6b666c3e644efbdc..248f7c49917885950092866de83b8c8f0e4167e8 100644 (file)
@@ -29,7 +29,7 @@ typedef struct gcrypt_rsa_private_key_t gcrypt_rsa_private_key_t;
  * Private_key_t implementation of RSA algorithm using libgcrypt.
  */
 struct gcrypt_rsa_private_key_t {
-       
+
        /**
         * Implements private_key_t interface
         */
index 2f86774dc17003eb489eccec232928b49a549fb5..d9d4b829932eea247a410c2df005399f546d6071 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include <gcrypt.h>
 
 #include "gcrypt_rsa_public_key.h"
@@ -29,17 +29,17 @@ typedef struct private_gcrypt_rsa_public_key_t private_gcrypt_rsa_public_key_t;
  * Private data structure with signing context.
  */
 struct private_gcrypt_rsa_public_key_t {
-       
+
        /**
         * Public interface for this signer.
         */
        gcrypt_rsa_public_key_t public;
-       
+
        /**
         * gcrypt S-expression representing an public RSA key
         */
        gcry_sexp_t key;
-       
+
        /**
         * reference counter
         */
@@ -61,7 +61,7 @@ static bool verify_raw(private_gcrypt_rsa_public_key_t *this,
        gcry_error_t err;
        chunk_t em;
        size_t k;
-       
+
        /* EM = 0x00 || 0x01 || PS || 0x00 || T
         * PS = 0xFF padding, with length to fill em
         * T  = data
@@ -77,7 +77,7 @@ static bool verify_raw(private_gcrypt_rsa_public_key_t *this,
        em.ptr[1] = 0x01;
        em.ptr[em.len - data.len - 1] = 0x00;
        memcpy(em.ptr + em.len - data.len, data.ptr, data.len);
-       
+
        err = gcry_sexp_build(&in, NULL, "(data(flags raw)(value %b))",
                                                  em.len, em.ptr);
        chunk_free(&em);
@@ -116,7 +116,7 @@ static bool verify_pkcs1(private_gcrypt_rsa_public_key_t *this,
        chunk_t hash;
        gcry_error_t err;
        gcry_sexp_t in, sig;
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, algorithm);
        if (!hasher)
        {
@@ -124,7 +124,7 @@ static bool verify_pkcs1(private_gcrypt_rsa_public_key_t *this,
        }
        hasher->allocate_hash(hasher, data, &hash);
        hasher->destroy(hasher);
-       
+
        err = gcry_sexp_build(&in, NULL, "(data(flags pkcs1)(hash %s %b))",
                                                  hash_name, hash.len, hash.ptr);
        chunk_free(&hash);
@@ -133,7 +133,7 @@ static bool verify_pkcs1(private_gcrypt_rsa_public_key_t *this,
                DBG1("building data S-expression failed: %s", gpg_strerror(err));
                return FALSE;
        }
-       
+
        err = gcry_sexp_build(&sig, NULL, "(sig-val(rsa(s %b)))",
                                                  signature.len, signature.ptr);
        if (err)
@@ -198,7 +198,7 @@ static bool encrypt_(private_gcrypt_rsa_public_key_t *this, chunk_t plain,
 {
        gcry_sexp_t in, out;
        gcry_error_t err;
-       
+
        /* "pkcs1" uses PKCS 1.5 (section 8.1) block type 2 encryption:
         * 00 | 02 | RANDOM | 00 | DATA */
        err = gcry_sexp_build(&in, NULL, "(data(flags pkcs1)(value %b))",
@@ -236,7 +236,7 @@ static bool get_encoding(private_gcrypt_rsa_public_key_t *this,
 {
        chunk_t n, e;
        bool success;
-       
+
        n = gcrypt_rsa_find_token(this->key, "n", NULL);
        e = gcrypt_rsa_find_token(this->key, "e", NULL);
        success = lib->encoding->encode(lib->encoding, type, NULL, encoding,
@@ -244,7 +244,7 @@ static bool get_encoding(private_gcrypt_rsa_public_key_t *this,
                                                        KEY_PART_END);
        chunk_free(&n);
        chunk_free(&e);
-       
+
        return success;
 }
 
@@ -256,14 +256,14 @@ static bool get_fingerprint(private_gcrypt_rsa_public_key_t *this,
 {
        chunk_t n, e;
        bool success;
-       
+
        if (lib->encoding->get_cache(lib->encoding, type, this, fp))
        {
                return TRUE;
        }
        n = gcrypt_rsa_find_token(this->key, "n", NULL);
        e = gcrypt_rsa_find_token(this->key, "e", NULL);
-       
+
        success = lib->encoding->encode(lib->encoding,
                                                                type, this, fp, KEY_PART_RSA_MODULUS, n,
                                                                KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
@@ -300,7 +300,7 @@ static void destroy(private_gcrypt_rsa_public_key_t *this)
 static private_gcrypt_rsa_public_key_t *gcrypt_rsa_public_key_create_empty()
 {
        private_gcrypt_rsa_public_key_t *this = malloc_thing(private_gcrypt_rsa_public_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*)(public_key_t *this))get_type;
        this->public.interface.verify = (bool (*)(public_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t signature))verify;
        this->public.interface.encrypt = (bool (*)(public_key_t *this, chunk_t crypto, chunk_t *plain))encrypt_;
@@ -310,10 +310,10 @@ static private_gcrypt_rsa_public_key_t *gcrypt_rsa_public_key_create_empty()
        this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (public_key_t* (*)(public_key_t *this))get_ref;
        this->public.interface.destroy = (void (*)(public_key_t *this))destroy;
-       
+
        this->key = NULL;
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -324,7 +324,7 @@ static gcrypt_rsa_public_key_t *load(chunk_t n, chunk_t e)
 {
        private_gcrypt_rsa_public_key_t *this;
        gcry_error_t err;
-       
+
        this = gcrypt_rsa_public_key_create_empty();
        err = gcry_sexp_build(&this->key, NULL, "(public-key(rsa(n %b)(e %b)))",
                                                  n.len, n.ptr, e.len, e.ptr);
@@ -355,7 +355,7 @@ struct private_builder_t {
 static gcrypt_rsa_public_key_t *build(private_builder_t *this)
 {
        gcrypt_rsa_public_key_t *key;
-       
+
        key = load(this->n, this->e);
        free(this);
        return key;
@@ -367,7 +367,7 @@ static gcrypt_rsa_public_key_t *build(private_builder_t *this)
 static void add(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        va_start(args, part);
        switch (part)
        {
@@ -390,18 +390,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *gcrypt_rsa_public_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->n = this->e = chunk_empty;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index a03e83e662c3264c4e0da940fc9fbb2d6431c6d6..945d3e3fab1972e364f48f8f4c3f289112ad78d0 100644 (file)
@@ -282,7 +282,7 @@ static u_int8_t group18_modulus[] = {
 
 typedef struct modulus_entry_t modulus_entry_t;
 
-/** 
+/**
  * Entry of the modulus list.
  */
 struct modulus_entry_t {
@@ -290,25 +290,25 @@ struct modulus_entry_t {
         * Group number as it is defined in file transform_substructure.h.
         */
        diffie_hellman_group_t group;
-       
+
        /**
         * Pointer to first byte of modulus (network order).
         */
        u_int8_t *modulus;
-       
-       /* 
+
+       /*
         * Length of modulus in bytes.
-        */     
+        */
        size_t modulus_len;
-       
-       /* 
+
+       /*
         * Optimum length of exponent in bytes.
-        */     
+        */
        size_t opt_exponent_len;
 
-       /* 
+       /*
         * Generator value.
-        */     
+        */
        u_int16_t generator;
 };
 
@@ -336,47 +336,47 @@ struct private_gmp_diffie_hellman_t {
         * Public gmp_diffie_hellman_t interface.
         */
        gmp_diffie_hellman_t public;
-       
+
        /**
         * Diffie Hellman group number.
         */
        u_int16_t group;
-       
-       /* 
+
+       /*
         * Generator value.
-        */     
+        */
        mpz_t g;
-       
+
        /**
         * My private value.
         */
        mpz_t xa;
-       
+
        /**
         * My public value.
         */
        mpz_t ya;
-       
+
        /**
         * Other public value.
-        */     
+        */
        mpz_t yb;
-       
+
        /**
         * Shared secret.
-        */     
+        */
        mpz_t zz;
 
        /**
         * Modulus.
         */
        mpz_t p;
-       
+
        /**
         * Modulus length.
         */
        size_t p_len;
-       
+
        /**
         * Optimal exponent length.
         */
@@ -394,13 +394,13 @@ struct private_gmp_diffie_hellman_t {
 static void set_other_public_value(private_gmp_diffie_hellman_t *this, chunk_t value)
 {
        mpz_t p_min_1;
-       
+
        mpz_init(p_min_1);
        mpz_sub_ui(p_min_1, this->p, 1);
-       
+
        mpz_import(this->yb, value.len, 1, 1, 1, 0, value.ptr);
-       
-       /* check public value: 
+
+       /* check public value:
         * 1. 0 or 1 is invalid as 0^a = 0 and 1^a = 1
         * 2. a public value larger or equal the modulus is invalid */
        if (mpz_cmp_ui(this->yb, 1) > 0 &&
@@ -409,7 +409,7 @@ static void set_other_public_value(private_gmp_diffie_hellman_t *this, chunk_t v
 #ifdef EXTENDED_DH_TEST
                /* 3. test if y ^ q mod p = 1, where q = (p - 1)/2. */
                mpz_t q, one;
-               
+
                mpz_init(q);
                mpz_init(one);
                mpz_fdiv_q_2exp(q, p_min_1, 1);
@@ -483,7 +483,7 @@ static status_t set_modulus(private_gmp_diffie_hellman_t *this)
 {
        int i;
        status_t status = NOT_FOUND;
-       
+
        for (i = 0; i < (sizeof(modulus_entries) / sizeof(modulus_entry_t)); i++)
        {
                if (modulus_entries[i].group == this->group)
@@ -533,7 +533,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
        this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
        this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
        this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
-       
+
        /* private variables */
        this->group = group;
        mpz_init(this->p);
@@ -542,10 +542,10 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
        mpz_init(this->xa);
        mpz_init(this->zz);
        mpz_init(this->g);
-       
+
        this->computed = FALSE;
-               
-       /* find a modulus according to group */ 
+
+       /* find a modulus according to group */
        if (set_modulus(this) != SUCCESS)
        {
                destroy(this);
@@ -561,7 +561,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
 
        ansi_x9_42 = lib->settings->get_int(lib->settings,
                                         "libstrongswan.dh_exponent_ansi_x9_42", TRUE);
-       exponent_len = (ansi_x9_42) ? this->p_len : this->opt_exponent_len;     
+       exponent_len = (ansi_x9_42) ? this->p_len : this->opt_exponent_len;
        rng->allocate_bytes(rng, exponent_len, &random);
        rng->destroy(rng);
 
@@ -575,7 +575,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
        DBG2("size of DH secret exponent: %u bits", mpz_sizeinbase(this->xa, 2));
 
        mpz_powm(this->ya, this->g, this->xa, this->p);
-       
+
        return &this->public;
 }
 
index 774c31cc2f741f4b160e3baa6791bde62cb64575..2a54eebb1865e07e95901554d9c4ae91a030dc4e 100644 (file)
@@ -30,7 +30,7 @@ typedef struct gmp_diffie_hellman_t gmp_diffie_hellman_t;
  * Implementation of the Diffie-Hellman algorithm, as in RFC2631. Uses libgmp.
  */
 struct gmp_diffie_hellman_t {
-       
+
        /**
         * Implements diffie_hellman_t interface.
         */
@@ -39,7 +39,7 @@ struct gmp_diffie_hellman_t {
 
 /**
  * Creates a new gmp_diffie_hellman_t object.
- * 
+ *
  * @param group                        Diffie Hellman group number to use
  * @return                             gmp_diffie_hellman_t object, NULL if not supported
  */
index f6ea964c193ac96f6e0275674f65fc4be2dadfba..84c55dfd8ca701a8fe650de81ec8c010fb11c88e 100644 (file)
@@ -53,31 +53,31 @@ static void destroy(private_gmp_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_gmp_plugin_t *this = malloc_thing(private_gmp_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
-       lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, 
+
+       lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_6144_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
        lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_768_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
                                                (dh_constructor_t)gmp_diffie_hellman_create);
-       
+
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                (builder_constructor_t)gmp_rsa_private_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                (builder_constructor_t)gmp_rsa_public_key_builder);
-       
+
        return &this->public.plugin;
 }
 
index d707d78eadf961c45d336af2081157b7c0ed8b05..77d53965d45d6e175447b216a6dea171240c8185 100644 (file)
@@ -16,7 +16,7 @@
 /**
  * @defgroup gmp_p gmp
  * @ingroup plugins
- * 
+ *
  * @defgroup gmp_plugin gmp_plugin
  * @{ @ingroup gmp_p
  */
index f3192b889163c39e9860fc7a72310cc5cb520824..4241e824a28f88341afd6642c4f820663cd721da 100644 (file)
@@ -42,52 +42,52 @@ struct private_gmp_rsa_private_key_t {
         * Public interface for this signer.
         */
        gmp_rsa_private_key_t public;
-       
+
        /**
         * Public modulus.
         */
        mpz_t n;
-       
+
        /**
         * Public exponent.
         */
        mpz_t e;
-       
+
        /**
         * Private prime 1.
         */
        mpz_t p;
-       
+
        /**
         * Private Prime 2.
         */
        mpz_t q;
-       
+
        /**
         * Private exponent.
         */
        mpz_t d;
-       
+
        /**
         * Private exponent 1.
         */
        mpz_t exp1;
-       
+
        /**
         * Private exponent 2.
         */
        mpz_t exp2;
-       
+
        /**
         * Private coefficient.
         */
        mpz_t coeff;
-       
+
        /**
         * Keysize in bytes.
         */
        size_t k;
-       
+
        /**
         * reference count
         */
@@ -100,7 +100,7 @@ struct private_gmp_rsa_private_key_t {
 chunk_t gmp_mpz_to_chunk(const mpz_t value)
 {
        chunk_t n;
-       
+
        n.len = 1 + mpz_sizeinbase(value, 2) / BITS_PER_BYTE;
        n.ptr = mpz_export(NULL, NULL, 1, n.len, 1, 0, value);
        if (n.ptr == NULL)
@@ -117,7 +117,7 @@ static void mpz_clear_sensitive(mpz_t z)
 {
        size_t len = mpz_size(z) * GMP_LIMB_BITS / BITS_PER_BYTE;
        u_int8_t *random = alloca(len);
-       
+
        memset(random, 0, len);
        /* overwrite mpz_t with zero bytes before clearing it */
        mpz_import(z, len, 1, 1, 1, 0, random);
@@ -132,28 +132,28 @@ static status_t compute_prime(private_gmp_rsa_private_key_t *this,
 {
        rng_t *rng;
        chunk_t random_bytes;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_TRUE);
        if (!rng)
        {
                DBG1("no RNG of quality %N found", rng_quality_names, RNG_TRUE);
                return FAILED;
        }
-       
+
        mpz_init(*prime);
        do
        {
                rng->allocate_bytes(rng, prime_size, &random_bytes);
                /* make sure most significant bit is set */
                random_bytes.ptr[0] = random_bytes.ptr[0] | 0x80;
-               
+
                mpz_import(*prime, random_bytes.len, 1, 1, 1, 0, random_bytes.ptr);
                mpz_nextprime (*prime, *prime);
                chunk_clear(&random_bytes);
        }
        /* check if it isn't too large */
        while (((mpz_sizeinbase(*prime, 2) + 7) / 8) > prime_size);
-       
+
        rng->destroy(rng);
        return SUCCESS;
 }
@@ -165,32 +165,32 @@ static chunk_t rsadp(private_gmp_rsa_private_key_t *this, chunk_t data)
 {
        mpz_t t1, t2;
        chunk_t decrypted;
-       
+
        mpz_init(t1);
        mpz_init(t2);
-       
+
        mpz_import(t1, data.len, 1, 1, 1, 0, data.ptr);
-       
+
        mpz_powm(t2, t1, this->exp1, this->p);  /* m1 = c^dP mod p */
        mpz_powm(t1, t1, this->exp2, this->q);  /* m2 = c^dQ mod Q */
        mpz_sub(t2, t2, t1);                                    /* h = qInv (m1 - m2) mod p */
        mpz_mod(t2, t2, this->p);
        mpz_mul(t2, t2, this->coeff);
        mpz_mod(t2, t2, this->p);
-       
+
        mpz_mul(t2, t2, this->q);                               /* m = m2 + h q */
        mpz_add(t1, t1, t2);
-       
+
        decrypted.len = this->k;
        decrypted.ptr = mpz_export(NULL, NULL, 1, decrypted.len, 1, 0, t1);
        if (decrypted.ptr == NULL)
        {
                decrypted.len = 0;
        }
-       
+
        mpz_clear_sensitive(t1);
        mpz_clear_sensitive(t2);
-       
+
        return decrypted;
 }
 
@@ -217,7 +217,7 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
                hasher_t *hasher;
                chunk_t hash;
                int hash_oid = hasher_algorithm_to_oid(hash_algorithm);
-       
+
                if (hash_oid == OID_UNKNOWN)
                {
                        return FALSE;
@@ -230,7 +230,7 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
                }
                hasher->allocate_hash(hasher, data, &hash);
                hasher->destroy(hasher);
-       
+
                /* build DER-encoded digestInfo */
                digestInfo = asn1_wrap(ASN1_SEQUENCE, "mm",
                                                asn1_algorithmIdentifier(hash_oid),
@@ -246,15 +246,15 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
                DBG1("unable to sign %d bytes using a %dbit key", data.len, this->k * 8);
                return FALSE;
        }
-       
+
        /* build chunk to rsa-decrypt:
-        * EM = 0x00 || 0x01 || PS || 0x00 || T. 
+        * EM = 0x00 || 0x01 || PS || 0x00 || T.
         * PS = 0xFF padding, with length to fill em
         * T = encoded_hash
         */
        em.len = this->k;
        em.ptr = malloc(em.len);
-       
+
        /* fill em with padding */
        memset(em.ptr, 0xFF, em.len);
        /* set magic bytes */
@@ -266,11 +266,11 @@ static bool build_emsa_pkcs1_signature(private_gmp_rsa_private_key_t *this,
 
        /* build signature */
        *signature = rsasp1(this, em);
-       
+
        free(digestInfo.ptr);
        free(em.ptr);
-       
-       return TRUE;    
+
+       return TRUE;
 }
 
 /**
@@ -284,7 +284,7 @@ static key_type_t get_type(private_gmp_rsa_private_key_t *this)
 /**
  * Implementation of gmp_rsa_private_key.sign.
  */
-static bool sign(private_gmp_rsa_private_key_t *this, signature_scheme_t scheme, 
+static bool sign(private_gmp_rsa_private_key_t *this, signature_scheme_t scheme,
                                 chunk_t data, chunk_t *signature)
 {
        switch (scheme)
@@ -318,7 +318,7 @@ static bool decrypt(private_gmp_rsa_private_key_t *this, chunk_t crypto,
 {
        chunk_t em, stripped;
        bool success = FALSE;
-       
+
        /* rsa decryption using PKCS#1 RSADP */
        stripped = em = rsadp(this, crypto);
 
@@ -364,15 +364,15 @@ static public_key_t* get_public_key(private_gmp_rsa_private_key_t *this)
 {
        chunk_t n, e;
        public_key_t *public;
-       
+
        n = gmp_mpz_to_chunk(this->n);
        e = gmp_mpz_to_chunk(this->e);
-       
+
        public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END);
        chunk_free(&n);
        chunk_free(&e);
-       
+
        return public;
 }
 
@@ -400,7 +400,7 @@ static bool get_encoding(private_gmp_rsa_private_key_t *this,
 {
        chunk_t n, e, d, p, q, exp1, exp2, coeff;
        bool success;
-       
+
        n = gmp_mpz_to_chunk(this->n);
        e = gmp_mpz_to_chunk(this->e);
        d = gmp_mpz_to_chunk(this->d);
@@ -409,7 +409,7 @@ static bool get_encoding(private_gmp_rsa_private_key_t *this,
        exp1 = gmp_mpz_to_chunk(this->exp1);
        exp2 = gmp_mpz_to_chunk(this->exp2);
        coeff = gmp_mpz_to_chunk(this->coeff);
-       
+
        success = lib->encoding->encode(lib->encoding,
                                                        type, NULL, encoding, KEY_PART_RSA_MODULUS, n,
                                                        KEY_PART_RSA_PUB_EXP, e, KEY_PART_RSA_PRIV_EXP, d,
@@ -424,7 +424,7 @@ static bool get_encoding(private_gmp_rsa_private_key_t *this,
        chunk_clear(&exp1);
        chunk_clear(&exp2);
        chunk_clear(&coeff);
-       
+
        return success;
 }
 
@@ -436,19 +436,19 @@ static bool get_fingerprint(private_gmp_rsa_private_key_t *this,
 {
        chunk_t n, e;
        bool success;
-       
+
        if (lib->encoding->get_cache(lib->encoding, type, this, fp))
        {
                return TRUE;
        }
        n = gmp_mpz_to_chunk(this->n);
        e = gmp_mpz_to_chunk(this->e);
-       
+
        success = lib->encoding->encode(lib->encoding, type, this, fp,
                                KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
        chunk_free(&n);
        chunk_free(&e);
-       
+
        return success;
 }
 
@@ -488,7 +488,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
 {
        mpz_t t, u, q1;
        status_t status = SUCCESS;
-       
+
        /* PKCS#1 1.5 section 6 requires modulus to have at least 12 octets.
         * We actually require more (for security).
         */
@@ -497,25 +497,25 @@ static status_t check(private_gmp_rsa_private_key_t *this)
                DBG1("key shorter than 512 bits");
                return FAILED;
        }
-       
+
        /* we picked a max modulus size to simplify buffer allocation */
        if (this->k > 8192 / BITS_PER_BYTE)
        {
                DBG1("key larger than 8192 bits");
                return FAILED;
        }
-       
+
        mpz_init(t);
        mpz_init(u);
        mpz_init(q1);
-       
+
        /* check that n == p * q */
        mpz_mul(u, this->p, this->q);
        if (mpz_cmp(u, this->n) != 0)
        {
                status = FAILED;
        }
-       
+
        /* check that e divides neither p-1 nor q-1 */
        mpz_sub_ui(t, this->p, 1);
        mpz_mod(t, t, this->e);
@@ -523,14 +523,14 @@ static status_t check(private_gmp_rsa_private_key_t *this)
        {
                status = FAILED;
        }
-       
+
        mpz_sub_ui(t, this->q, 1);
        mpz_mod(t, t, this->e);
        if (mpz_cmp_ui(t, 0) == 0)
        {
                status = FAILED;
        }
-       
+
        /* check that d is e^-1 (mod lcm(p-1, q-1)) */
        /* see PKCS#1v2, aka RFC 2437, for the "lcm" */
        mpz_sub_ui(q1, this->q, 1);
@@ -538,14 +538,14 @@ static status_t check(private_gmp_rsa_private_key_t *this)
        mpz_gcd(t, u, q1);              /* t := gcd(p-1, q-1) */
        mpz_mul(u, u, q1);              /* u := (p-1) * (q-1) */
        mpz_divexact(u, u, t);  /* u := lcm(p-1, q-1) */
-       
+
        mpz_mul(t, this->d, this->e);
        mpz_mod(t, t, u);
        if (mpz_cmp_ui(t, 1) != 0)
        {
                status = FAILED;
        }
-       
+
        /* check that exp1 is d mod (p-1) */
        mpz_sub_ui(u, this->p, 1);
        mpz_mod(t, this->d, u);
@@ -553,7 +553,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
        {
                status = FAILED;
        }
-       
+
        /* check that exp2 is d mod (q-1) */
        mpz_sub_ui(u, this->q, 1);
        mpz_mod(t, this->d, u);
@@ -561,7 +561,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
        {
                status = FAILED;
        }
-       
+
        /* check that coeff is (q^-1) mod p */
        mpz_mul(t, this->coeff, this->q);
        mpz_mod(t, t, this->p);
@@ -569,7 +569,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
        {
                status = FAILED;
        }
-       
+
        mpz_clear_sensitive(t);
        mpz_clear_sensitive(u);
        mpz_clear_sensitive(q1);
@@ -586,7 +586,7 @@ static status_t check(private_gmp_rsa_private_key_t *this)
 static private_gmp_rsa_private_key_t *gmp_rsa_private_key_create_empty(void)
 {
        private_gmp_rsa_private_key_t *this = malloc_thing(private_gmp_rsa_private_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*) (private_key_t*))get_type;
        this->public.interface.sign = (bool (*) (private_key_t*, signature_scheme_t, chunk_t, chunk_t*))sign;
        this->public.interface.decrypt = (bool (*) (private_key_t*, chunk_t, chunk_t*))decrypt;
@@ -598,9 +598,9 @@ static private_gmp_rsa_private_key_t *gmp_rsa_private_key_create_empty(void)
        this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (private_key_t* (*) (private_key_t*))get_ref;
        this->public.interface.destroy = (void (*) (private_key_t*))destroy;
-       
+
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -612,35 +612,35 @@ static gmp_rsa_private_key_t *generate(size_t key_size)
        mpz_t p, q, n, e, d, exp1, exp2, coeff;
        mpz_t m, q1, t;
        private_gmp_rsa_private_key_t *this = gmp_rsa_private_key_create_empty();
-       
+
        key_size = key_size / BITS_PER_BYTE;
-       
+
        /* Get values of primes p and q  */
        if (compute_prime(this, key_size/2, &p) != SUCCESS)
        {
                free(this);
                return NULL;
-       }       
+       }
        if (compute_prime(this, key_size/2, &q) != SUCCESS)
        {
                mpz_clear(p);
                free(this);
                return NULL;
        }
-       
+
        mpz_init(t);
        mpz_init(n);
        mpz_init(d);
        mpz_init(exp1);
        mpz_init(exp2);
        mpz_init(coeff);
-       
+
        /* Swapping Primes so p is larger then q */
        if (mpz_cmp(p, q) < 0)
        {
                mpz_swap(p, q);
        }
-       
+
        mpz_mul(n, p, q);                                               /* n = p*q */
        mpz_init_set_ui(e, PUBLIC_EXPONENT);    /* assign public exponent */
        mpz_init_set(m, p);                                     /* m = p */
@@ -661,7 +661,7 @@ static gmp_rsa_private_key_t *generate(size_t key_size)
        mpz_mod(exp1, d, t);                                    /* exp1 = d mod p-1 */
        mpz_sub_ui(t, q, 1);                                    /* t = q-1 */
        mpz_mod(exp2, d, t);                                    /* exp2 = d mod q-1 */
-       
+
        mpz_invert(coeff, q, p);                                /* coeff = q^-1 mod p */
        if (mpz_cmp_ui(coeff, 0) < 0)                   /* make coeff d is positive */
        {
@@ -681,10 +681,10 @@ static gmp_rsa_private_key_t *generate(size_t key_size)
        *(this->exp1) = *exp1;
        *(this->exp2) = *exp2;
        *(this->coeff) = *coeff;
-       
+
        /* set key size in bytes */
        this->k = key_size;
-       
+
        return &this->public;
 }
 
@@ -695,7 +695,7 @@ static gmp_rsa_private_key_t *load(chunk_t n, chunk_t e, chunk_t d,
                                chunk_t p, chunk_t q, chunk_t exp1, chunk_t exp2, chunk_t coeff)
 {
        private_gmp_rsa_private_key_t *this = gmp_rsa_private_key_create_empty();
-       
+
        mpz_init(this->n);
        mpz_init(this->e);
        mpz_init(this->p);
@@ -704,7 +704,7 @@ static gmp_rsa_private_key_t *load(chunk_t n, chunk_t e, chunk_t d,
        mpz_init(this->exp1);
        mpz_init(this->exp2);
        mpz_init(this->coeff);
-       
+
        mpz_import(this->n, n.len, 1, 1, 1, 0, n.ptr);
        mpz_import(this->e, e.len, 1, 1, 1, 0, e.ptr);
        mpz_import(this->d, d.len, 1, 1, 1, 0, d.ptr);
@@ -757,7 +757,7 @@ struct private_builder_t {
 static gmp_rsa_private_key_t *build(private_builder_t *this)
 {
        gmp_rsa_private_key_t *key = NULL;
-       
+
        if (this->key_size)
        {
                key = generate(this->key_size);
@@ -777,7 +777,7 @@ static gmp_rsa_private_key_t *build(private_builder_t *this)
 static void add(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        va_start(args, part);
        switch (part)
        {
@@ -821,20 +821,20 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *gmp_rsa_private_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->n = this->e = this->d = this->p = this->q = chunk_empty;
        this->exp1 = this->exp2 = this->coeff = chunk_empty;
        this->key_size = 0;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index ec47ea1e06a43b24752cc57262a5695b340f25f8..0b3e7e2e80d893b3de043e9119c8231a84c7c264 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 #include <gmp.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -38,22 +38,22 @@ struct private_gmp_rsa_public_key_t {
         * Public interface for this signer.
         */
        gmp_rsa_public_key_t public;
-       
+
        /**
         * Public modulus.
         */
        mpz_t n;
-       
+
        /**
         * Public exponent.
         */
        mpz_t e;
-       
+
        /**
         * Keysize in bytes.
         */
        size_t k;
-       
+
        /**
         * reference counter
         */
@@ -72,12 +72,12 @@ static chunk_t rsaep(private_gmp_rsa_public_key_t *this, chunk_t data)
 {
        mpz_t m, c;
        chunk_t encrypted;
-       
+
        mpz_init(c);
        mpz_init(m);
-       
+
        mpz_import(m, data.len, 1, 1, 1, 0, data.ptr);
-       
+
        mpz_powm(c, m, this->e, this->n);
 
        encrypted.len = this->k;
@@ -86,10 +86,10 @@ static chunk_t rsaep(private_gmp_rsa_public_key_t *this, chunk_t data)
        {
                encrypted.len = 0;
        }
-       
+
        mpz_clear(c);
        mpz_clear(m);
-       
+
        return encrypted;
 }
 
@@ -123,34 +123,34 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
 {
        chunk_t em_ori, em;
        bool success = FALSE;
-       
+
        /* remove any preceding 0-bytes from signature */
        while (signature.len && *(signature.ptr) == 0x00)
        {
                signature = chunk_skip(signature, 1);
        }
-       
+
        if (signature.len == 0 || signature.len > this->k)
        {
                return INVALID_ARG;
        }
-       
+
        /* unpack signature */
        em_ori = em = rsavp1(this, signature);
-       
+
        /* result should look like this:
-        * EM = 0x00 || 0x01 || PS || 0x00 || T. 
+        * EM = 0x00 || 0x01 || PS || 0x00 || T.
         * PS = 0xFF padding, with length to fill em
         * T = oid || hash
         */
-       
+
        /* check magic bytes */
        if (*(em.ptr) != 0x00 || *(em.ptr+1) != 0x01)
        {
                goto end;
        }
        em = chunk_skip(em, 2);
-       
+
        /* find magic 0x00 */
        while (em.len > 0)
        {
@@ -227,7 +227,7 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
                                {
                                        chunk_t hash;
                                        hasher_t *hasher;
-                                       
+
                                        hasher = lib->crypto->create_hasher(lib->crypto, hash_algorithm);
                                        if (hasher == NULL)
                                        {
@@ -277,7 +277,7 @@ static key_type_t get_type(private_gmp_rsa_public_key_t *this)
 /**
  * Implementation of public_key_t.verify.
  */
-static bool verify(private_gmp_rsa_public_key_t *this, signature_scheme_t scheme, 
+static bool verify(private_gmp_rsa_public_key_t *this, signature_scheme_t scheme,
                                   chunk_t data, chunk_t signature)
 {
        switch (scheme)
@@ -333,9 +333,9 @@ static bool encrypt_(private_gmp_rsa_public_key_t *this, chunk_t plain,
 
        /* padding according to PKCS#1 7.2.1 (RSAES-PKCS1-v1.5-ENCRYPT) */
        DBG2("padding %u bytes of data to the rsa modulus size of %u bytes",
-                plain.len, this->k); 
+                plain.len, this->k);
        em.len = this->k;
-       em.ptr = malloc(em.len); 
+       em.ptr = malloc(em.len);
        pos = em.ptr;
        *pos++ = 0x00;
        *pos++ = 0x02;
@@ -360,7 +360,7 @@ static bool encrypt_(private_gmp_rsa_public_key_t *this, chunk_t plain,
        /* now add the data */
        memcpy(pos, plain.ptr, plain.len);
        DBG3("padded data before rsa encryption: %B", &em);
-       
+
        /* rsa encryption using PKCS#1 RSAEP */
        *crypto = rsaep(this, em);
        DBG3("rsa encrypted data: %B", crypto);
@@ -392,15 +392,15 @@ static bool get_encoding(private_gmp_rsa_public_key_t *this,
 {
        chunk_t n, e;
        bool success;
-       
+
        n = gmp_mpz_to_chunk(this->n);
        e = gmp_mpz_to_chunk(this->e);
-       
-       success = lib->encoding->encode(lib->encoding, type, NULL, encoding, 
+
+       success = lib->encoding->encode(lib->encoding, type, NULL, encoding,
                                KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
        chunk_free(&n);
        chunk_free(&e);
-       
+
        return success;
 }
 
@@ -412,19 +412,19 @@ static bool get_fingerprint(private_gmp_rsa_public_key_t *this,
 {
        chunk_t n, e;
        bool success;
-       
+
        if (lib->encoding->get_cache(lib->encoding, type, this, fp))
        {
                return TRUE;
        }
        n = gmp_mpz_to_chunk(this->n);
        e = gmp_mpz_to_chunk(this->e);
-       
+
        success = lib->encoding->encode(lib->encoding, type, this, fp,
                                KEY_PART_RSA_MODULUS, n, KEY_PART_RSA_PUB_EXP, e, KEY_PART_END);
        chunk_free(&n);
        chunk_free(&e);
-       
+
        return success;
 }
 
@@ -457,7 +457,7 @@ static void destroy(private_gmp_rsa_public_key_t *this)
 static private_gmp_rsa_public_key_t *gmp_rsa_public_key_create_empty()
 {
        private_gmp_rsa_public_key_t *this = malloc_thing(private_gmp_rsa_public_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*) (public_key_t*))get_type;
        this->public.interface.verify = (bool (*) (public_key_t*, signature_scheme_t, chunk_t, chunk_t))verify;
        this->public.interface.encrypt = (bool (*) (public_key_t*, chunk_t, chunk_t*))encrypt_;
@@ -467,9 +467,9 @@ static private_gmp_rsa_public_key_t *gmp_rsa_public_key_create_empty()
        this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (public_key_t* (*) (public_key_t *this))get_ref;
        this->public.interface.destroy = (void (*) (public_key_t *this))destroy;
-       
+
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -479,15 +479,15 @@ static private_gmp_rsa_public_key_t *gmp_rsa_public_key_create_empty()
 static gmp_rsa_public_key_t *load(chunk_t n, chunk_t e)
 {
        private_gmp_rsa_public_key_t *this = gmp_rsa_public_key_create_empty();
-       
+
        mpz_init(this->n);
        mpz_init(this->e);
-       
+
        mpz_import(this->n, n.len, 1, 1, 1, 0, n.ptr);
        mpz_import(this->e, e.len, 1, 1, 1, 0, e.ptr);
-       
+
        this->k = (mpz_sizeinbase(this->n, 2) + 7) / BITS_PER_BYTE;
-       
+
        return &this->public;
 }
 
@@ -509,7 +509,7 @@ struct private_builder_t {
 static gmp_rsa_public_key_t *build(private_builder_t *this)
 {
        gmp_rsa_public_key_t *key;
-       
+
        key = load(this->n, this->e);
        free(this);
        return key;
@@ -521,7 +521,7 @@ static gmp_rsa_public_key_t *build(private_builder_t *this)
 static void add(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        va_start(args, part);
        switch (part)
        {
@@ -544,18 +544,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *gmp_rsa_public_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->n = this->e = chunk_empty;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 6dfa022332411f3c25cf2d0f753e0237f6acfc5d..c1ab4889931c017502d1e9b764c828f7c570baba 100644 (file)
@@ -23,7 +23,7 @@ typedef struct private_hmac_t private_hmac_t;
 
 /**
  * Private data of a hmac_t object.
- * 
+ *
  * The variable names are the same as in the RFC.
  */
 struct private_hmac_t {
@@ -31,22 +31,22 @@ struct private_hmac_t {
         * Public hmac_t interface.
         */
        hmac_t hmac;
-       
+
        /**
         * Block size, as in RFC.
         */
        u_int8_t b;
-       
+
        /**
         * Hash function.
         */
        hasher_t *h;
-       
+
        /**
         * Previously xor'ed key using opad.
         */
        chunk_t opaded_key;
-       
+
        /**
         * Previously xor'ed key using ipad.
         */
@@ -58,16 +58,16 @@ struct private_hmac_t {
  */
 static void get_mac(private_hmac_t *this, chunk_t data, u_int8_t *out)
 {
-       /* H(K XOR opad, H(K XOR ipad, text)) 
-        * 
+       /* H(K XOR opad, H(K XOR ipad, text))
+        *
         * if out is NULL, we append text to the inner hash.
         * else, we complete the inner and do the outer.
-        * 
+        *
         */
-       
+
        u_int8_t buffer[this->h->get_hash_size(this->h)];
        chunk_t inner;
-       
+
        if (out == NULL)
        {
                /* append data to inner */
@@ -78,14 +78,14 @@ static void get_mac(private_hmac_t *this, chunk_t data, u_int8_t *out)
                /* append and do outer hash */
                inner.ptr = buffer;
                inner.len = this->h->get_hash_size(this->h);
-               
+
                /* complete inner */
                this->h->get_hash(this->h, data, buffer);
-               
+
                /* do outer */
                this->h->get_hash(this->h, this->opaded_key, NULL);
                this->h->get_hash(this->h, inner, out);
-               
+
                /* reinit for next call */
                this->h->get_hash(this->h, this->ipaded_key, NULL);
        }
@@ -109,7 +109,7 @@ static void allocate_mac(private_hmac_t *this, chunk_t data, chunk_t *out)
                this->hmac.get_mac(&(this->hmac), data, out->ptr);
        }
 }
-       
+
 /**
  * Implementation of hmac_t.get_block_size.
  */
@@ -125,27 +125,27 @@ static void set_key(private_hmac_t *this, chunk_t key)
 {
        int i;
        u_int8_t buffer[this->b];
-       
+
        memset(buffer, 0, this->b);
-       
+
        if (key.len > this->b)
-       {       
+       {
                /* if key is too long, it will be hashed */
                this->h->get_hash(this->h, key, buffer);
        }
        else
-       {       
+       {
                /* if not, just copy it in our pre-padded k */
-               memcpy(buffer, key.ptr, key.len);       
+               memcpy(buffer, key.ptr, key.len);
        }
-                       
+
        /* apply ipad and opad to key */
        for (i = 0; i < this->b; i++)
        {
                this->ipaded_key.ptr[i] = buffer[i] ^ 0x36;
                this->opaded_key.ptr[i] = buffer[i] ^ 0x5C;
        }
-       
+
        /* begin hashing of inner pad */
        this->h->reset(this->h);
        this->h->get_hash(this->h, this->ipaded_key, NULL);
@@ -175,7 +175,7 @@ hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
        this->hmac.get_block_size = (size_t (*)(hmac_t *))get_block_size;
        this->hmac.set_key = (void (*)(hmac_t *,chunk_t))set_key;
        this->hmac.destroy = (void (*)(hmac_t *))destroy;
-       
+
        /* set b, according to hasher */
        switch (hash_algorithm)
        {
@@ -190,15 +190,15 @@ hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
                        break;
                default:
                        free(this);
-                       return NULL;    
+                       return NULL;
        }
-       
+
        /* build the hasher */
        this->h = lib->crypto->create_hasher(lib->crypto, hash_algorithm);
        if (this->h == NULL)
        {
                free(this);
-               return NULL;    
+               return NULL;
        }
 
        /* build ipad and opad */
index a204d3b17b11acd27d255c607e30893b4bd2477a..be1bce66d8d26926fcee9ca7a71fc578fc50ee14 100644 (file)
@@ -36,46 +36,46 @@ typedef struct hmac_t hmac_t;
 struct hmac_t {
        /**
         * Generate message authentication code.
-        * 
+        *
         * If buffer is NULL, no result is given back. A next call will
-        * append the data to already supplied data. If buffer is not NULL, 
+        * append the data to already supplied data. If buffer is not NULL,
         * the mac of all apended data is calculated, returned and the
         * state of the hmac_t is reseted.
-        * 
+        *
         * @param data          chunk of data to authenticate
         * @param buffer        pointer where the generated bytes will be written
         */
        void (*get_mac) (hmac_t *this, chunk_t data, u_int8_t *buffer);
-       
+
        /**
         * Generates message authentication code and allocate space for them.
-        * 
+        *
         * If chunk is NULL, no result is given back. A next call will
-        * append the data to already supplied. If chunk is not NULL, 
+        * append the data to already supplied. If chunk is not NULL,
         * the mac of all apended data is calculated, returned and the
         * state of the hmac_t reset;
-        * 
+        *
         * @param data          chunk of data to authenticate
         * @param chunk         chunk which will hold generated bytes
         */
        void (*allocate_mac) (hmac_t *this, chunk_t data, chunk_t *chunk);
-       
+
        /**
         * Get the block size of this hmac_t object.
-        * 
+        *
         * @return                      block size in bytes
         */
-       size_t (*get_block_size) (hmac_t *this);        
-       
+       size_t (*get_block_size) (hmac_t *this);
+
        /**
         * Set the key for this hmac_t object.
-        * 
+        *
         * Any key length is accepted.
-        * 
+        *
         * @param key           key to set
         */
        void (*set_key) (hmac_t *this, chunk_t key);
-       
+
        /**
         * Destroys a hmac_t object.
         */
@@ -84,7 +84,7 @@ struct hmac_t {
 
 /**
  * Creates a new hmac_t object.
- * 
+ *
  * @param hash_algorithm       hash algorithm to use
  * @return                                     hmac_t object, NULL if not supported
  */
index aa1e994b0d1402d3661d183bf406d09c5688a978..94332ee36666d3acba77cd324c91d61894170f3e 100644 (file)
@@ -50,35 +50,35 @@ static void destroy(private_hmac_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_hmac_plugin_t *this = malloc_thing(private_hmac_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
-       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256, 
+
+       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256,
                                                 (prf_constructor_t)hmac_prf_create);
-       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1, 
+       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1,
                                                 (prf_constructor_t)hmac_prf_create);
-       lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5, 
+       lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5,
                                                 (prf_constructor_t)hmac_prf_create);
-       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384, 
+       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384,
                                                 (prf_constructor_t)hmac_prf_create);
-       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512, 
+       lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512,
                                                 (prf_constructor_t)hmac_prf_create);
-       
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96, 
+
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96,
                                                        (signer_constructor_t)hmac_signer_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128, 
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128,
                                                        (signer_constructor_t)hmac_signer_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160, 
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160,
                                                        (signer_constructor_t)hmac_signer_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128, 
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128,
                                                        (signer_constructor_t)hmac_signer_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96, 
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96,
                                                        (signer_constructor_t)hmac_signer_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128, 
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128,
                                                        (signer_constructor_t)hmac_signer_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192, 
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192,
                                                        (signer_constructor_t)hmac_signer_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256, 
+       lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256,
                                                        (signer_constructor_t)hmac_signer_create);
 
        return &this->public.plugin;
index 454d40be331d5d149312e8e88f6a821f67dea1b8..cca6e957056401708699c1fa26d26444ea172090 100644 (file)
@@ -28,8 +28,8 @@ struct private_hmac_prf_t {
        /**
         * Public hmac_prf_t interface.
         */
-       hmac_prf_t public;      
-       
+       hmac_prf_t public;
+
        /**
         * Hmac to use for generation.
         */
@@ -93,7 +93,7 @@ hmac_prf_t *hmac_prf_create(pseudo_random_function_t algo)
 {
        private_hmac_prf_t *this;
        hash_algorithm_t hash;
-       
+
        switch (algo)
        {
                case PRF_HMAC_SHA1:
@@ -114,22 +114,22 @@ hmac_prf_t *hmac_prf_create(pseudo_random_function_t algo)
                default:
                        return NULL;
        }
-       
+
        this = malloc_thing(private_hmac_prf_t);
        this->hmac = hmac_create(hash);
        if (this->hmac == NULL)
        {
                free(this);
-               return NULL;    
+               return NULL;
        }
-       
+
        this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
        this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
        this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size;
        this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
        this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
        this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
-       
+
        return &(this->public);
 }
 
index aa75272e1b58eb4806b0c8bafae18f620b15d154..975b456f5b39c7d6d2ee377b1a349b7eb1c252cc 100644 (file)
@@ -28,12 +28,12 @@ typedef struct hmac_prf_t hmac_prf_t;
 
 /**
  * Implementation of prf_t interface using the HMAC algorithm.
- * 
+ *
  * This simply wraps a hmac_t in a prf_t. More a question of
  * interface matching.
  */
 struct hmac_prf_t {
-       
+
        /**
         * Generic prf_t interface for this hmac_prf_t class.
         */
@@ -42,7 +42,7 @@ struct hmac_prf_t {
 
 /**
  * Creates a new hmac_prf_t object.
- * 
+ *
  * @param algo         algorithm to implement
  * @return                     hmac_prf_t object, NULL if hash not supported
  */
index b44bc210903fbad3c216ba358ffd7da1af37fa09..f82a8f3a1201fcb21a4d16553cf5f55c4f9435d1 100644 (file)
@@ -29,12 +29,12 @@ struct private_hmac_signer_t {
         * Public interface of hmac_signer_t.
         */
        hmac_signer_t public;
-       
+
        /**
         * Assigned hmac function.
         */
        hmac_t *hmac;
-       
+
        /**
         * Block size (truncation of HMAC Hash)
         */
@@ -54,7 +54,7 @@ static void get_signature(private_hmac_signer_t *this,
        else
        {
                u_int8_t mac[this->hmac->get_block_size(this->hmac)];
-               
+
                this->hmac->get_mac(this->hmac, data, mac);
                memcpy(buffer, mac, this->block_size);
        }
@@ -73,12 +73,12 @@ static void allocate_signature (private_hmac_signer_t *this,
        else
        {
                u_int8_t mac[this->hmac->get_block_size(this->hmac)];
-               
+
                this->hmac->get_mac(this->hmac, data, mac);
 
                chunk->ptr = malloc(this->block_size);
                chunk->len = this->block_size;
-               
+
                memcpy(chunk->ptr, mac, this->block_size);
        }
 }
@@ -90,9 +90,9 @@ static bool verify_signature(private_hmac_signer_t *this,
                                                         chunk_t data, chunk_t signature)
 {
        u_int8_t mac[this->hmac->get_block_size(this->hmac)];
-       
+
        this->hmac->get_mac(this->hmac, data, mac);
-       
+
        if (signature.len != this->block_size)
        {
                return FALSE;
@@ -142,7 +142,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
        private_hmac_signer_t *this;
        size_t trunc;
        hash_algorithm_t hash;
-       
+
        switch (algo)
        {
                case AUTH_HMAC_SHA1_96:
@@ -180,7 +180,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
                default:
                        return NULL;
        }
-       
+
        this = malloc_thing(private_hmac_signer_t);
        this->hmac = hmac_create(hash);
        if (this->hmac == NULL)
@@ -190,7 +190,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
        }
        /* prevent invalid truncation */
        this->block_size = min(trunc, this->hmac->get_block_size(this->hmac));
-       
+
        /* interface functions */
        this->public.signer_interface.get_signature = (void (*) (signer_t*, chunk_t, u_int8_t*))get_signature;
        this->public.signer_interface.allocate_signature = (void (*) (signer_t*, chunk_t, chunk_t*))allocate_signature;
@@ -199,7 +199,7 @@ hmac_signer_t *hmac_signer_create(integrity_algorithm_t algo)
        this->public.signer_interface.get_block_size = (size_t (*) (signer_t*))get_block_size;
        this->public.signer_interface.set_key = (void (*) (signer_t*,chunk_t))set_key;
        this->public.signer_interface.destroy = (void (*) (signer_t*))destroy;
-       
+
        return &(this->public);
 }
 
index 197e28fa7fb7f633b64c58ab36702138d61ce9c7..0de93440cbafdeec1e1d2d9b0a6791a3ac2239dc 100644 (file)
@@ -32,7 +32,7 @@ typedef struct hmac_signer_t hmac_signer_t;
  * HMAC uses a standard hash function implemented in a hasher_t to build a MAC.
  */
 struct hmac_signer_t {
-       
+
        /**
         * generic signer_t interface for this signer
         */
index b2a40219ffc61e0aa5d2a4a4298dc56efb9be5f3..ce5b7d56befb7b9057a11798e5926055f3d0ff47 100644 (file)
@@ -38,7 +38,7 @@ struct private_ldap_fetcher_t {
         * Public data
         */
        ldap_fetcher_t public;
-       
+
        /**
         * timeout to use for fetches
         */
@@ -79,7 +79,7 @@ static bool parse(LDAP *ldap, LDAPMessage *result, chunk_t *response)
                        }
                        else
                        {
-                               DBG1("getting LDAP values failed: %s", 
+                               DBG1("getting LDAP values failed: %s",
                                         ldap_err2string(ldap_result2error(ldap, entry, 0)));
                        }
                        ldap_memfree(attr);
@@ -110,7 +110,7 @@ static status_t fetch(private_ldap_fetcher_t *this, char *url,
        int ldap_version = LDAP_VERSION3;
        struct timeval timeout;
        status_t status = FAILED;
-       
+
        if (!strneq(url, "ldap", 4))
        {
                return NOT_SUPPORTED;
@@ -126,7 +126,7 @@ static status_t fetch(private_ldap_fetcher_t *this, char *url,
                ldap_free_urldesc(lurl);
                return FAILED;
        }
-       
+
        timeout.tv_sec = this->timeout;
        timeout.tv_usec = 0;
 
@@ -171,7 +171,7 @@ static status_t fetch(private_ldap_fetcher_t *this, char *url,
 static bool set_option(private_ldap_fetcher_t *this, fetcher_option_t option, ...)
 {
        va_list args;
-       
+
        va_start(args, option);
        switch (option)
        {
@@ -203,9 +203,9 @@ ldap_fetcher_t *ldap_fetcher_create()
        this->public.interface.fetch = (status_t(*)(fetcher_t*,char*,chunk_t*))fetch;
        this->public.interface.set_option = (bool(*)(fetcher_t*, fetcher_option_t option, ...))set_option;
        this->public.interface.destroy = (void (*)(fetcher_t*))destroy;
-       
+
        this->timeout = DEFAULT_TIMEOUT;
-       
+
        return &this->public;
 }
 
index 994f3db4637ea02e5edaabf1a67b684b3641aa8d..a31308bbf29f40cf8afea410a1a34f1353a84834 100644 (file)
@@ -36,7 +36,7 @@ struct private_ldap_plugin_t {
  */
 static void destroy(private_ldap_plugin_t *this)
 {
-       lib->fetcher->remove_fetcher(lib->fetcher, 
+       lib->fetcher->remove_fetcher(lib->fetcher,
                                                                 (fetcher_constructor_t)ldap_fetcher_create);
        free(this);
 }
@@ -47,14 +47,14 @@ static void destroy(private_ldap_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_ldap_plugin_t *this = malloc_thing(private_ldap_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
 
        lib->fetcher->add_fetcher(lib->fetcher,
                                                (fetcher_constructor_t)ldap_fetcher_create, "ldap://");
        lib->fetcher->add_fetcher(lib->fetcher,
                                                (fetcher_constructor_t)ldap_fetcher_create, "ldaps://");
-       
+
        return &this->public.plugin;
 }
 
index 3801110dcbb90cecd073bd96d2a271ce4151d418..81e4000acfb071ee682d287d2c8b8aaee299ec5f 100644 (file)
@@ -2,9 +2,9 @@
  * Copyright (C) 2005-2006 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Hochschule fuer Technik Rapperswil
- * Copyright (C) 1990-1992, RSA Data Security, Inc. Created 1990. 
+ * Copyright (C) 1990-1992, RSA Data Security, Inc. Created 1990.
  * All rights reserved.
- * 
+ *
  * Derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm.
  * Ported to fulfill hasher_t interface.
  *
@@ -83,7 +83,7 @@ struct private_md4_hasher_t {
         * Public interface for this hasher.
         */
        md4_hasher_t public;
-       
+
        /*
         * State of the hasher.
         */
@@ -101,7 +101,7 @@ static void Encode (u_int8_t *output, u_int32_t *input, size_t len)
 {
        size_t i, j;
 
-       for (i = 0, j = 0; j < len; i++, j += 4) 
+       for (i = 0, j = 0; j < len; i++, j += 4)
        {
                output[j] = (u_int8_t)(input[i] & 0xff);
                output[j+1] = (u_int8_t)((input[i] >> 8) & 0xff);
@@ -220,7 +220,7 @@ static void MD4Update(private_md4_hasher_t *this, u_int8_t *input, size_t inputL
        partLen = 64 - index;
 
        /* Transform as many times as possible. */
-       if (inputLen >= partLen) 
+       if (inputLen >= partLen)
        {
                memcpy(&this->buffer[index], input, partLen);
                MD4Transform (this->state, this->buffer);
@@ -288,7 +288,7 @@ static void get_hash(private_md4_hasher_t *this, chunk_t chunk, u_int8_t *buffer
 static void allocate_hash(private_md4_hasher_t *this, chunk_t chunk, chunk_t *hash)
 {
        chunk_t allocated_hash;
-       
+
        MD4Update(this, chunk.ptr, chunk.len);
        if (hash != NULL)
        {
@@ -297,11 +297,11 @@ static void allocate_hash(private_md4_hasher_t *this, chunk_t chunk, chunk_t *ha
 
                MD4Final(this, allocated_hash.ptr);
                this->public.hasher_interface.reset(&(this->public.hasher_interface));
-               
+
                *hash = allocated_hash;
        }
 }
-       
+
 /**
  * Implementation of hasher_t.get_hash_size.
  */
@@ -337,21 +337,21 @@ static void destroy(private_md4_hasher_t *this)
 md4_hasher_t *md4_hasher_create(hash_algorithm_t algo)
 {
        private_md4_hasher_t *this;
-       
+
        if (algo != HASH_MD4)
        {
                return NULL;
        }
        this = malloc_thing(private_md4_hasher_t);
-       
+
        this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
        this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
        this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size;
        this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
        this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-       
+
        /* initialize */
        reset(this);
-       
+
        return &(this->public);
 }
index b0b8c65d2dc96c8177418f7ef53bfed4f820875e..aeb68f718ab5ee72ac780040b484d21609fb8590 100644 (file)
@@ -30,7 +30,7 @@ typedef struct md4_hasher_t md4_hasher_t;
  * Implementation of hasher_t interface using the MD4 algorithm.
  */
 struct md4_hasher_t {
-       
+
        /**
         * Generic hasher_t interface for this hasher.
         */
@@ -39,7 +39,7 @@ struct md4_hasher_t {
 
 /**
  * Creates a new md4_hasher_t.
- * 
+ *
  * @param algo         hash algorithm, must be HASH_MD4
  * @return                     md4_hasher_t object, NULL if not supported
  */
index 43ae6261dda909eb03db7e0808262f9af18ce173..ba4041d2df2205319b6d34ce0d6c5442cfb624a2 100644 (file)
@@ -47,12 +47,12 @@ static void destroy(private_md4_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_md4_plugin_t *this = malloc_thing(private_md4_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_hasher(lib->crypto, HASH_MD4,
                                                        (hasher_constructor_t)md4_hasher_create);
-       
+
        return &this->public.plugin;
 }
 
index 0ec5c073a7553b9c405458ea42182802b240005a..81d5273b078d163950be9c9dbd66e31c59b033d2 100644 (file)
@@ -2,9 +2,9 @@
  * Copyright (C) 2005-2006 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Hochschule fuer Technik Rapperswil
- * Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991. 
+ * Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991.
  * All rights reserved.
- * 
+ *
  * Derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
  * Ported to fulfill hasher_t interface.
  *
@@ -50,7 +50,7 @@ static u_int8_t PADDING[64] = {
 
 /*
  * ugly macro stuff
- */ 
+ */
 /* F, G, H and I are basic MD5 functions.
  */
 #define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
@@ -98,7 +98,7 @@ struct private_md5_hasher_t {
         * Public interface for this hasher.
         */
        md5_hasher_t public;
-       
+
        /*
         * State of the hasher.
         */
@@ -117,7 +117,7 @@ static void Encode (u_int8_t *output, u_int32_t *input, size_t len)
 {
        size_t i, j;
 
-       for (i = 0, j = 0; j < len; i++, j += 4) 
+       for (i = 0, j = 0; j < len; i++, j += 4)
        {
                output[j] = (u_int8_t)(input[i] & 0xff);
                output[j+1] = (u_int8_t)((input[i] >> 8) & 0xff);
@@ -253,7 +253,7 @@ static void MD5Update(private_md5_hasher_t *this, u_int8_t *input, size_t inputL
        partLen = 64 - index;
 
        /* Transform as many times as possible. */
-       if (inputLen >= partLen) 
+       if (inputLen >= partLen)
        {
                memcpy(&this->buffer[index], input, partLen);
                MD5Transform (this->state, this->buffer);
@@ -321,7 +321,7 @@ static void get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer
 static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
 {
        chunk_t allocated_hash;
-       
+
        MD5Update(this, chunk.ptr, chunk.len);
        if (hash != NULL)
        {
@@ -330,11 +330,11 @@ static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *ha
 
                MD5Final(this, allocated_hash.ptr);
                this->public.hasher_interface.reset(&(this->public.hasher_interface));
-               
+
                *hash = allocated_hash;
        }
 }
-       
+
 /**
  * Implementation of hasher_t.get_hash_size.
  */
@@ -370,21 +370,21 @@ static void destroy(private_md5_hasher_t *this)
 md5_hasher_t *md5_hasher_create(hash_algorithm_t algo)
 {
        private_md5_hasher_t *this;
-       
+
        if (algo != HASH_MD5)
        {
                return NULL;
        }
        this = malloc_thing(private_md5_hasher_t);
-       
+
        this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
        this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
        this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size;
        this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
        this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-       
+
        /* initialize */
        reset(this);
-       
+
        return &(this->public);
 }
index 0064c177bbf51902f12af4cbfa1ffded8e58322e..7f29a962195c821b564b02a75eecaedd890db74d 100644 (file)
@@ -30,7 +30,7 @@ typedef struct md5_hasher_t md5_hasher_t;
  * Implementation of hasher_t interface using the MD5 algorithm.
  */
 struct md5_hasher_t {
-       
+
        /**
         * Generic hasher_t interface for this hasher.
         */
@@ -39,7 +39,7 @@ struct md5_hasher_t {
 
 /**
  * Creates a new md5_hasher_t.
- * 
+ *
  * @param algo         hash algorithm, must be HASH_MD5
  * @return                     md5_hasher_t object, NULL if not supported
  */
index b1a3b495c8edc3a956cb569580a12fac1cb61f15..7592c20df8d4dc41f9f24c1d161755255f9bfed7 100644 (file)
@@ -47,12 +47,12 @@ static void destroy(private_md5_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_md5_plugin_t *this = malloc_thing(private_md5_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_hasher(lib->crypto, HASH_MD5,
                                                        (hasher_constructor_t)md5_hasher_create);
-       
+
        return &this->public.plugin;
 }
 
index 341217dd43ca52de465f28125da220f7099b9e24..632437047fb37139113204a9f3530f7ef3c05f6c 100644 (file)
@@ -42,37 +42,37 @@ struct private_mysql_database_t {
         * public functions
         */
        mysql_database_t public;
-       
+
        /**
         * connection pool, contains conn_t
         */
        linked_list_t *pool;
-       
+
        /**
         * mutex to lock pool
         */
        mutex_t *mutex;
-       
+
        /**
         * hostname to connect to
         */
        char *host;
-       
+
        /**
         * username to use
         */
        char *username;
-       
+
        /**
         * password
         */
        char *password;
-       
+
        /**
         * database name
         */
        char *database;
-       
+
        /**
         * tcp port
         */
@@ -85,12 +85,12 @@ typedef struct conn_t conn_t;
  * connection pool entry
  */
 struct conn_t {
-       
+
        /**
         * MySQL database connection
         */
        MYSQL *mysql;
-       
+
        /**
         * connection in use?
         */
@@ -164,9 +164,9 @@ static conn_t *conn_get(private_mysql_database_t *this)
 {
        conn_t *current, *found = NULL;
        enumerator_t *enumerator;
-       
+
        thread_initialize();
-       
+
        while (TRUE)
        {
                this->mutex->lock(this->mutex);
@@ -231,7 +231,7 @@ static MYSQL_STMT* run(MYSQL *mysql, char *sql, va_list *args)
 {
        MYSQL_STMT *stmt;
        int params;
-       
+
        stmt = mysql_stmt_init(mysql);
        if (stmt == NULL)
        {
@@ -249,10 +249,10 @@ static MYSQL_STMT* run(MYSQL *mysql, char *sql, va_list *args)
        {
                int i;
                MYSQL_BIND *bind;
-       
+
                bind = alloca(sizeof(MYSQL_BIND) * params);
                memset(bind, 0, sizeof(MYSQL_BIND) * params);
-               
+
                for (i = 0; i < params; i++)
                {
                        switch (va_arg(*args, db_type_t))
@@ -285,7 +285,7 @@ static MYSQL_STMT* run(MYSQL *mysql, char *sql, va_list *args)
                                        break;
                                }
                                case DB_BLOB:
-                               {       
+                               {
                                        chunk_t chunk = va_arg(*args, chunk_t);
                                        bind[i].buffer_type = MYSQL_TYPE_BLOB;
                                        bind[i].buffer = chunk.ptr;
@@ -353,9 +353,9 @@ typedef struct {
 static void mysql_enumerator_destroy(mysql_enumerator_t *this)
 {
        int columns, i;
-       
+
        columns = mysql_stmt_field_count(this->stmt);
-       
+
        for (i = 0; i < columns; i++)
        {
                switch (this->bind[i].buffer_type)
@@ -385,9 +385,9 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
 {
        int i, columns;
        va_list args;
-       
+
        columns = mysql_stmt_field_count(this->stmt);
-       
+
        /* free/reset data set of previous call */
        for (i = 0; i < columns; i++)
        {
@@ -419,7 +419,7 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
                        DBG1("fetching MySQL row failed: %s", mysql_stmt_error(this->stmt));
                        return FALSE;
        }
-       
+
        va_start(args, this);
        for (i = 0; i < columns; i++)
        {
@@ -481,7 +481,7 @@ static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
        va_list args;
        mysql_enumerator_t *enumerator = NULL;
        conn_t *conn;
-       
+
        conn = conn_get(this);
        if (!conn)
        {
@@ -493,7 +493,7 @@ static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
        if (stmt)
        {
                int columns, i;
-               
+
                enumerator = malloc_thing(mysql_enumerator_t);
                enumerator->public.enumerate = (void*)mysql_enumerator_enumerate;
                enumerator->public.destroy = (void*)mysql_enumerator_destroy;
@@ -527,7 +527,7 @@ static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
                                        break;
                                }
                                case DB_BLOB:
-                               {       
+                               {
                                        enumerator->bind[i].buffer_type = MYSQL_TYPE_BLOB;
                                        enumerator->bind[i].length = &enumerator->length[i];
                                        break;
@@ -569,7 +569,7 @@ static int execute(private_mysql_database_t *this, int *rowid, char *sql, ...)
        va_list args;
        conn_t *conn;
        int affected = -1;
-       
+
        conn = conn_get(this);
        if (!conn)
        {
@@ -590,7 +590,7 @@ static int execute(private_mysql_database_t *this, int *rowid, char *sql, ...)
        conn_release(conn);
        return affected;
 }
-       
+
 /**
  * Implementation of database_t.get_driver
  */
@@ -646,7 +646,7 @@ static bool parse_uri(private_mysql_database_t *this, char *uri)
                        {
                                *pos = '\0';
                                database = pos + 1;
-       
+
                                this->host = strdup(host);
                                this->username = strdup(username);
                                this->password = strdup(password);
@@ -668,19 +668,19 @@ mysql_database_t *mysql_database_create(char *uri)
 {
        conn_t *conn;
        private_mysql_database_t *this;
-       
+
        if (!strneq(uri, "mysql://", 8))
        {
                return NULL;
        }
 
        this = malloc_thing(private_mysql_database_t);
-       
+
        this->public.db.query = (enumerator_t* (*)(database_t *this, char *sql, ...))query;
        this->public.db.execute = (int (*)(database_t *this, int *rowid, char *sql, ...))execute;
        this->public.db.get_driver = (db_driver_t(*)(database_t*))get_driver;
        this->public.db.destroy = (void(*)(database_t*))destroy;
-       
+
        if (!parse_uri(this, uri))
        {
                free(this);
@@ -688,7 +688,7 @@ mysql_database_t *mysql_database_create(char *uri)
        }
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        this->pool = linked_list_create();
-       
+
        /* check connectivity */
        conn = conn_get(this);
        if (!conn)
index 92914ae6d26297f76019b392c03026c7e0b9929a..0e64bbc3dd8d445ee3f897cbcf55de0c6210aa39 100644 (file)
@@ -49,16 +49,16 @@ static void destroy(private_mysql_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_mysql_plugin_t *this;
-       
+
        if (!mysql_database_init())
        {
                DBG1("MySQL client library initialization failed");
                return NULL;
        }
-       
+
        this = malloc_thing(private_mysql_plugin_t);
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->db->add_database(lib->db,
                                                  (database_constructor_t)mysql_database_create);
 
index 424fec60ad8673445bac0c8c6a39ac4c6d0299fe..a8923ab56b3f4a3801b905c0a55c7e32d2f509cf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2008 Tobias Brunner
- * Hochschule fuer Technik Rapperswil 
+ * Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -23,17 +23,17 @@ typedef struct private_openssl_crypter_t private_openssl_crypter_t;
  * Private data of openssl_crypter_t
  */
 struct private_openssl_crypter_t {
-       
+
        /**
         * Public part of this class.
         */
        openssl_crypter_t public;
-       
+
        /*
         * the key
         */
        chunk_t key;
-       
+
        /*
         * the cipher to use
         */
@@ -49,17 +49,17 @@ typedef struct {
         * Identifier specified in IKEv2
         */
        int ikev2_id;
-       
+
        /**
         * Name of the algorithm, as used in OpenSSL
         */
        char *name;
-       
+
        /**
         * Minimum valid key length in bytes
         */
        size_t key_size_min;
-       
+
        /**
         * Maximum valid key length in bytes
         */
@@ -91,7 +91,7 @@ static openssl_algorithm_t encryption_algs[] = {
 /**
  * Look up an OpenSSL algorithm name and validate its key size
  */
-static char* lookup_algorithm(openssl_algorithm_t *openssl_algo, 
+static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
                                           u_int16_t ikev2_algo, size_t *key_size)
 {
        while (openssl_algo->ikev2_id != END_OF_LIST)
@@ -104,7 +104,7 @@ static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
                        {
                                *key_size = openssl_algo->key_size_min;
                        }
-                       
+
                        /* validate key size */
                        if (*key_size < openssl_algo->key_size_min ||
                                *key_size > openssl_algo->key_size_max)
@@ -123,7 +123,7 @@ static void crypt(private_openssl_crypter_t *this, chunk_t data,
 {
        int len;
        u_char *out;
-       
+
        out = data.ptr;
        if (dst)
        {
@@ -144,7 +144,7 @@ static void crypt(private_openssl_crypter_t *this, chunk_t data,
 /**
  * Implementation of crypter_t.decrypt.
  */
-static void decrypt(private_openssl_crypter_t *this, chunk_t data, 
+static void decrypt(private_openssl_crypter_t *this, chunk_t data,
                                                chunk_t iv, chunk_t *dst)
 {
        crypt(this, data, iv, dst, 0);
@@ -154,7 +154,7 @@ static void decrypt(private_openssl_crypter_t *this, chunk_t data,
 /**
  * Implementation of crypter_t.encrypt.
  */
-static void encrypt (private_openssl_crypter_t *this, chunk_t data, 
+static void encrypt (private_openssl_crypter_t *this, chunk_t data,
                                                        chunk_t iv, chunk_t *dst)
 {
        crypt(this, data, iv, dst, 1);
@@ -196,13 +196,13 @@ static void destroy (private_openssl_crypter_t *this)
 /*
  * Described in header
  */
-openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo, 
+openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
                                                                                                  size_t key_size)
 {
        private_openssl_crypter_t *this;
-       
+
        this = malloc_thing(private_openssl_crypter_t);
-       
+
        switch (algo)
        {
                case ENCR_NULL:
@@ -218,7 +218,7 @@ openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
                                        this->cipher = EVP_get_cipherbyname("aes192");
                                        break;
                                case 32:        /* AES-256 */
-                                       this->cipher = EVP_get_cipherbyname("aes256"); 
+                                       this->cipher = EVP_get_cipherbyname("aes256");
                                        break;
                                default:
                                        free(this);
@@ -235,7 +235,7 @@ openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
                                        this->cipher = EVP_get_cipherbyname("camellia192");
                                        break;
                                case 32:        /* CAMELLIA 256 */
-                                       this->cipher = EVP_get_cipherbyname("camellia256"); 
+                                       this->cipher = EVP_get_cipherbyname("camellia256");
                                        break;
                                default:
                                        free(this);
@@ -258,22 +258,22 @@ openssl_crypter_t *openssl_crypter_create(encryption_algorithm_t algo,
                        break;
                }
        }
-       
+
        if (!this->cipher)
        {
                /* OpenSSL does not support the requested algo */
                free(this);
                return NULL;
        }
-       
+
        this->key = chunk_alloc(key_size);
-       
+
        this->public.crypter_interface.encrypt = (void (*) (crypter_t *, chunk_t,chunk_t, chunk_t *)) encrypt;
        this->public.crypter_interface.decrypt = (void (*) (crypter_t *, chunk_t , chunk_t, chunk_t *)) decrypt;
        this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *)) get_block_size;
        this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *)) get_key_size;
        this->public.crypter_interface.set_key = (void (*) (crypter_t *,chunk_t)) set_key;
        this->public.crypter_interface.destroy = (void (*) (crypter_t *)) destroy;
-       
+
        return &this->public;
 }
index e5a8994188d7b104a0f0c47217b0465e8fbdde61..7e30ae03caffa5f5186e3a587614f4bfa11558a1 100644 (file)
@@ -29,7 +29,7 @@ typedef struct openssl_crypter_t openssl_crypter_t;
  * Implementation of crypters using OpenSSL.
  */
 struct openssl_crypter_t {
-       
+
        /**
         * The crypter_t interface.
         */
@@ -38,7 +38,7 @@ struct openssl_crypter_t {
 
 /**
  * Constructor to create openssl_crypter_t.
- * 
+ *
  * @param algo                 algorithm to implement
  * @param key_size             key size in bytes
  * @return                             openssl_crypter_t, NULL if not supported
index fe042efdc7a726192be96f27de85430b8e95433f..80a1ee8787913878c9ff3f21d9f70fa1e30c2f97 100644 (file)
@@ -22,7 +22,7 @@
 
 typedef struct modulus_entry_t modulus_entry_t;
 
-/** 
+/**
  * Entry of the modulus list.
  */
 struct modulus_entry_t {
@@ -30,20 +30,20 @@ struct modulus_entry_t {
         * Group number as it is defined in file transform_substructure.h.
         */
        diffie_hellman_group_t group;
-       
+
        /**
         * Pointer to the function to get the modulus.
         */
        BIGNUM *(*get_prime)(BIGNUM *bn);
-       
-       /* 
+
+       /*
         * Optimum length of exponent in bits.
-        */     
+        */
        long opt_exponent_len;
-       
-       /* 
+
+       /*
         * Generator value.
-        */     
+        */
        u_int16_t generator;
 };
 
@@ -71,27 +71,27 @@ struct private_openssl_diffie_hellman_t {
         * Public openssl_diffie_hellman_t interface.
         */
        openssl_diffie_hellman_t public;
-       
+
        /**
         * Diffie Hellman group number.
         */
        u_int16_t group;
-       
+
        /**
         * Diffie Hellman object
         */
        DH *dh;
-       
+
        /**
         * Other public value
         */
        BIGNUM *pub_key;
-       
+
        /**
         * Shared secret
         */
        chunk_t shared_secret;
-       
+
        /**
         * True if shared secret is computed
         */
@@ -123,7 +123,7 @@ static status_t get_shared_secret(private_openssl_diffie_hellman_t *this,
        /* shared secret should requires a len according the DH group */
        *secret = chunk_alloc(DH_size(this->dh));
        memset(secret->ptr, 0, secret->len);
-       memcpy(secret->ptr + secret->len - this->shared_secret.len, 
+       memcpy(secret->ptr + secret->len - this->shared_secret.len,
                   this->shared_secret.ptr, this->shared_secret.len);
 
        return SUCCESS;
@@ -137,7 +137,7 @@ static void set_other_public_value(private_openssl_diffie_hellman_t *this,
                                                                   chunk_t value)
 {
        int len;
-       
+
        BN_bin2bn(value.ptr, value.len, this->pub_key);
        chunk_clear(&this->shared_secret);
        this->shared_secret.ptr = malloc(DH_size(this->dh));
@@ -167,10 +167,10 @@ static status_t set_modulus(private_openssl_diffie_hellman_t *this)
 {
        int i;
        bool ansi_x9_42;
-       
+
        ansi_x9_42 = lib->settings->get_bool(lib->settings,
                                                                                 "libstrongswan.dh_exponent_ansi_x9_42", TRUE);
-       
+
        for (i = 0; i < (sizeof(modulus_entries) / sizeof(modulus_entry_t)); i++)
        {
                if (modulus_entries[i].group == this->group)
@@ -205,32 +205,32 @@ static void destroy(private_openssl_diffie_hellman_t *this)
 openssl_diffie_hellman_t *openssl_diffie_hellman_create(diffie_hellman_group_t group)
 {
        private_openssl_diffie_hellman_t *this = malloc_thing(private_openssl_diffie_hellman_t);
-       
+
        this->public.dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_shared_secret;
        this->public.dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t )) set_other_public_value;
        this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
        this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
        this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
-       
+
        this->dh = DH_new();
        if (!this->dh)
        {
                free(this);
                return NULL;
        }
-       
+
        this->group = group;
        this->computed = FALSE;
        this->pub_key = BN_new();
        this->shared_secret = chunk_empty;
-       
+
        /* find a modulus according to group */
        if (set_modulus(this) != SUCCESS)
        {
                destroy(this);
                return NULL;
        }
-       
+
        /* generate my public and private values */
        if (!DH_generate_key(this->dh))
        {
@@ -238,6 +238,6 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(diffie_hellman_group_t g
                return NULL;
        }
        DBG2("size of DH secret exponent: %d bits", BN_num_bits(this->dh->priv_key));
-       
+
        return &this->public;
 }
index bdc15381260c03d47ed07403049ac2ab97a00c9d..6c4b4fe814ab881292c556a2a76d15d1d0677eb5 100644 (file)
@@ -29,7 +29,7 @@ typedef struct openssl_diffie_hellman_t openssl_diffie_hellman_t;
  * Implementation of the Diffie-Hellman algorithm using OpenSSL.
  */
 struct openssl_diffie_hellman_t {
-       
+
        /**
         * Implements diffie_hellman_t interface.
         */
@@ -38,7 +38,7 @@ struct openssl_diffie_hellman_t {
 
 /**
  * Creates a new openssl_diffie_hellman_t object.
- * 
+ *
  * @param group                        Diffie Hellman group number to use
  * @return                             openssl_diffie_hellman_t object, NULL if not supported
  */
index 082aed9caa84f400a3de9fc40296610ec2620175..671fa41e25351b6749502a38cb4df98565870837 100644 (file)
@@ -31,27 +31,27 @@ struct private_openssl_ec_diffie_hellman_t {
         * Public openssl_ec_diffie_hellman_t interface.
         */
        openssl_ec_diffie_hellman_t public;
-       
+
        /**
         * Diffie Hellman group number.
         */
        u_int16_t group;
-       
+
        /**
         * EC private (public) key
         */
        EC_KEY *key;
-       
+
        /**
         * EC group
         */
        const EC_GROUP *ec_group;
-       
+
        /**
         * Other public key
         */
        EC_POINT *pub_key;
-       
+
        /**
         * Shared secret
         */
@@ -72,13 +72,13 @@ static bool chunk2ecp(const EC_GROUP *group, chunk_t chunk, EC_POINT *point)
        BN_CTX *ctx;
        BIGNUM *x, *y;
        bool ret = FALSE;
-       
+
        ctx = BN_CTX_new();
        if (!ctx)
        {
                return FALSE;
        }
-       
+
        BN_CTX_start(ctx);
        x = BN_CTX_get(ctx);
        y = BN_CTX_get(ctx);
@@ -86,17 +86,17 @@ static bool chunk2ecp(const EC_GROUP *group, chunk_t chunk, EC_POINT *point)
        {
                goto error;
        }
-       
+
        if (!openssl_bn_split(chunk, x, y))
        {
                goto error;
        }
-       
+
        if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx))
        {
                goto error;
        }
-       
+
        ret = TRUE;
 error:
        BN_CTX_end(ctx);
@@ -114,13 +114,13 @@ static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
        BN_CTX *ctx;
        BIGNUM *x, *y;
        bool ret = FALSE;
-       
+
        ctx = BN_CTX_new();
        if (!ctx)
        {
                return FALSE;
        }
-       
+
        BN_CTX_start(ctx);
        x = BN_CTX_get(ctx);
        y = BN_CTX_get(ctx);
@@ -128,12 +128,12 @@ static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
        {
                goto error;
        }
-       
+
        if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx))
        {
                goto error;
        }
-       
+
        if (x_coordinate_only)
        {
                y = NULL;
@@ -142,7 +142,7 @@ static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
        {
                goto error;
        }
-       
+
        ret = TRUE;
 error:
        BN_CTX_end(ctx);
@@ -152,7 +152,7 @@ error:
 
 /**
  * Compute the shared secret.
- * 
+ *
  * We cannot use the function ECDH_compute_key() because that returns only the
  * x coordinate of the shared secret point (which is defined, for instance, in
  * 'NIST SP 800-56A').
@@ -166,13 +166,13 @@ static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this, chunk_
        const BIGNUM *priv_key;
        EC_POINT *secret = NULL;
        bool x_coordinate_only, ret = FALSE;
-       
+
        priv_key = EC_KEY_get0_private_key(this->key);
        if (!priv_key)
        {
                goto error;
        }
-       
+
        secret = EC_POINT_new(this->ec_group);
        if (!secret)
        {
@@ -183,7 +183,7 @@ static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this, chunk_
        {
                goto error;
        }
-       
+
        /*
         * The default setting ecp_x_coordinate_only = TRUE
         * applies the following errata for RFC 4753:
@@ -195,7 +195,7 @@ static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this, chunk_
        {
                goto error;
        }
-       
+
        ret = TRUE;
 error:
        if (secret)
@@ -215,14 +215,14 @@ static void set_other_public_value(private_openssl_ec_diffie_hellman_t *this, ch
                DBG1("ECDH public value is malformed");
                return;
        }
-       
+
        chunk_free(&this->shared_secret);
-       
+
        if (!compute_shared_key(this, &this->shared_secret)) {
                DBG1("ECDH shared secret computation failed");
                return;
        }
-       
+
        this->computed = TRUE;
 }
 
@@ -272,13 +272,13 @@ static void destroy(private_openssl_ec_diffie_hellman_t *this)
 openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_group_t group)
 {
        private_openssl_ec_diffie_hellman_t *this = malloc_thing(private_openssl_ec_diffie_hellman_t);
-       
+
        this->public.dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *)) get_shared_secret;
        this->public.dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t )) set_other_public_value;
        this->public.dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *)) get_my_public_value;
        this->public.dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *)) get_dh_group;
        this->public.dh.destroy = (void (*)(diffie_hellman_t *)) destroy;
-       
+
        switch (group)
        {
                case ECP_192_BIT:
@@ -300,34 +300,34 @@ openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_gro
                        this->key = NULL;
                        break;
        }
-       
+
        if (!this->key)
        {
                free(this);
                return NULL;
        }
-       
+
        /* caching the EC group */
        this->ec_group = EC_KEY_get0_group(this->key);
-       
+
        this->pub_key = EC_POINT_new(this->ec_group);
        if (!this->pub_key)
        {
                free(this);
                return NULL;
        }
-       
+
        /* generate an EC private (public) key */
        if (!EC_KEY_generate_key(this->key))
        {
                free(this);
                return NULL;
        }
-       
+
        this->group = group;
        this->computed = FALSE;
-       
+
        this->shared_secret = chunk_empty;
-       
+
        return &this->public;
 }
index 9d17aed57c26d2e658aeb4b6a696c4219940220a..fd60732b9387fff7900bc212921d7566ca4ec44f 100644 (file)
@@ -29,7 +29,7 @@ typedef struct openssl_ec_diffie_hellman_t openssl_ec_diffie_hellman_t;
  * Implementation of the EC Diffie-Hellman algorithm using OpenSSL.
  */
 struct openssl_ec_diffie_hellman_t {
-       
+
        /**
         * Implements diffie_hellman_t interface.
         */
@@ -38,7 +38,7 @@ struct openssl_ec_diffie_hellman_t {
 
 /**
  * Creates a new openssl_ec_diffie_hellman_t object.
- * 
+ *
  * @param group                        EC Diffie Hellman group number to use
  * @return                             openssl_ec_diffie_hellman_t object, NULL if not supported
  */
index 6049f1d0621af2e4878971875fc9a675b0ec5b01..c6e651e9bf91cff51752360b7b50ab239232593e 100644 (file)
@@ -34,12 +34,12 @@ struct private_openssl_ec_private_key_t {
         * Public interface for this signer.
         */
        openssl_ec_private_key_t public;
-       
+
        /**
         * EC key object
         */
        EC_KEY *ec;
-       
+
        /**
         * reference count
         */
@@ -57,7 +57,7 @@ static bool build_signature(private_openssl_ec_private_key_t *this,
 {
        bool built = FALSE;
        ECDSA_SIG *sig;
-       
+
        sig = ECDSA_do_sign(hash.ptr, hash.len, this->ec);
        if (sig)
        {
@@ -80,7 +80,7 @@ static bool build_curve_signature(private_openssl_ec_private_key_t *this,
        EC_GROUP *req_group;
        chunk_t hash;
        bool built;
-       
+
        req_group = EC_GROUP_new_by_curve_name(nid_curve);
        if (!req_group)
        {
@@ -114,7 +114,7 @@ static bool build_der_signature(private_openssl_ec_private_key_t *this,
        chunk_t hash, sig;
        int siglen = 0;
        bool built;
-       
+
        if (!openssl_hash_chunk(hash_nid, data, &hash))
        {
                return FALSE;
@@ -153,7 +153,7 @@ static bool sign(private_openssl_ec_private_key_t *this,
                case SIGN_ECDSA_WITH_SHA512_DER:
                        return build_der_signature(this, NID_sha512, data, signature);
                case SIGN_ECDSA_256:
-                       return build_curve_signature(this, scheme, NID_sha256, 
+                       return build_curve_signature(this, scheme, NID_sha256,
                                                                                 NID_X9_62_prime256v1, data, signature);
                case SIGN_ECDSA_384:
                        return build_curve_signature(this, scheme, NID_sha384,
@@ -202,11 +202,11 @@ static public_key_t* get_public_key(private_openssl_ec_private_key_t *this)
        public_key_t *public;
        chunk_t key;
        u_char *p;
-       
+
        key = chunk_alloc(i2d_EC_PUBKEY(this->ec, NULL));
        p = key.ptr;
        i2d_EC_PUBKEY(this->ec, &p);
-       
+
        public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ECDSA,
                                                                BUILD_BLOB_ASN1_DER, key, BUILD_END);
        free(key.ptr);
@@ -229,7 +229,7 @@ static bool get_encoding(private_openssl_ec_private_key_t *this,
                                                 key_encoding_type_t type, chunk_t *encoding)
 {
        u_char *p;
-       
+
        switch (type)
        {
                case KEY_PRIV_ASN1_DER:
@@ -275,7 +275,7 @@ static void destroy(private_openssl_ec_private_key_t *this)
 static private_openssl_ec_private_key_t *create_empty(void)
 {
        private_openssl_ec_private_key_t *this = malloc_thing(private_openssl_ec_private_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type;
        this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign;
        this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt;
@@ -287,10 +287,10 @@ static private_openssl_ec_private_key_t *create_empty(void)
        this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref;
        this->public.interface.destroy = (void (*)(private_key_t *this))destroy;
-       
+
        this->ec = NULL;
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -300,7 +300,7 @@ static private_openssl_ec_private_key_t *create_empty(void)
 static openssl_ec_private_key_t *generate(size_t key_size)
 {
        private_openssl_ec_private_key_t *this = create_empty();
-       
+
        switch (key_size)
        {
                case 256:
@@ -335,9 +335,9 @@ static openssl_ec_private_key_t *generate(size_t key_size)
 static openssl_ec_private_key_t *load(chunk_t blob)
 {
        private_openssl_ec_private_key_t *this = create_empty();
-       
+
        this->ec = d2i_ECPrivateKey(NULL, (const u_char**)&blob.ptr, blob.len);
-       
+
        if (!this->ec)
        {
                destroy(this);
@@ -369,7 +369,7 @@ struct private_builder_t {
 static openssl_ec_private_key_t *build(private_builder_t *this)
 {
        openssl_ec_private_key_t *key = this->key;
-       
+
        free(this);
        return key;
 }
@@ -382,7 +382,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        if (!this->key)
        {
                va_list args;
-               
+
                switch (part)
                {
                        case BUILD_KEY_SIZE:
@@ -416,18 +416,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *openssl_ec_private_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_ECDSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->key = NULL;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 47a3d6a47fcc7a291995d2941fdd153e7144c091..b0b2c9b508b646067e55fc98c85c8c82f43b5ea0 100644 (file)
@@ -33,12 +33,12 @@ struct private_openssl_ec_public_key_t {
         * Public interface for this signer.
         */
        openssl_ec_public_key_t public;
-       
+
        /**
         * EC key object
         */
        EC_KEY *ec;
-       
+
        /**
         * reference counter
         */
@@ -53,7 +53,7 @@ static bool verify_signature(private_openssl_ec_public_key_t *this,
 {
        bool valid = FALSE;
        ECDSA_SIG *sig;
-       
+
        sig = ECDSA_SIG_new();
        if (sig)
        {
@@ -78,7 +78,7 @@ static bool verify_curve_signature(private_openssl_ec_public_key_t *this,
        EC_GROUP *req_group;
        chunk_t hash;
        bool valid;
-       
+
        req_group = EC_GROUP_new_by_curve_name(nid_curve);
        if (!req_group)
        {
@@ -111,7 +111,7 @@ static bool verify_der_signature(private_openssl_ec_public_key_t *this,
 {
        chunk_t hash;
        bool valid = FALSE;
-       
+
        /* remove any preceding 0-bytes from signature */
        while (signature.len && signature.ptr[0] == 0x00)
        {
@@ -194,7 +194,7 @@ bool openssl_ec_fingerprint(EC_KEY *ec, key_encoding_type_t type, chunk_t *fp)
        hasher_t *hasher;
        chunk_t key;
        u_char *p;
-       
+
        if (lib->encoding->get_cache(lib->encoding, type, ec, fp))
        {
                return TRUE;
@@ -244,7 +244,7 @@ static bool get_encoding(private_openssl_ec_public_key_t *this,
                                                 key_encoding_type_t type, chunk_t *encoding)
 {
        u_char *p;
-       
+
        switch (type)
        {
                case KEY_PUB_SPKI_ASN1_DER:
@@ -290,7 +290,7 @@ static void destroy(private_openssl_ec_public_key_t *this)
 static private_openssl_ec_public_key_t *create_empty()
 {
        private_openssl_ec_public_key_t *this = malloc_thing(private_openssl_ec_public_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*)(public_key_t *this))get_type;
        this->public.interface.verify = (bool (*)(public_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t signature))verify;
        this->public.interface.encrypt = (bool (*)(public_key_t *this, chunk_t crypto, chunk_t *plain))encrypt_;
@@ -300,10 +300,10 @@ static private_openssl_ec_public_key_t *create_empty()
        this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (public_key_t* (*)(public_key_t *this))get_ref;
        this->public.interface.destroy = (void (*)(public_key_t *this))destroy;
-       
+
        this->ec = NULL;
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -314,9 +314,9 @@ static openssl_ec_public_key_t *load(chunk_t blob)
 {
        private_openssl_ec_public_key_t *this = create_empty();
        u_char *p = blob.ptr;
-       
+
        this->ec = d2i_EC_PUBKEY(NULL, (const u_char**)&p, blob.len);
-       
+
        if (!this->ec)
        {
                destroy(this);
@@ -343,7 +343,7 @@ struct private_builder_t {
 static openssl_ec_public_key_t *build(private_builder_t *this)
 {
        openssl_ec_public_key_t *key = this->key;
-       
+
        free(this);
        return key;
 }
@@ -356,7 +356,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        if (!this->key)
        {
                va_list args;
-               
+
                switch (part)
                {
                        case BUILD_BLOB_ASN1_DER:
@@ -383,18 +383,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *openssl_ec_public_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_ECDSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->key = NULL;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 90a5229d5d58f98609de42f2d5e45706ae4c62eb..7556bc594c9c6d1af744315c1114aa2238e87b2e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2008 Tobias Brunner
- * Hochschule fuer Technik Rapperswil 
+ * Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -23,19 +23,19 @@ typedef struct private_openssl_hasher_t private_openssl_hasher_t;
  * Private data of openssl_hasher_t
  */
 struct private_openssl_hasher_t {
-       
+
        /**
         * Public part of this class.
         */
        openssl_hasher_t public;
-       
+
        /**
         * the hasher to use
         */
        const EVP_MD *hasher;
-       
+
        /**
-        * the current digest context 
+        * the current digest context
         */
        EVP_MD_CTX *ctx;
 };
@@ -49,7 +49,7 @@ typedef struct {
         * Identifier specified in IKEv2
         */
        int ikev2_id;
-       
+
        /**
         * Name of the algorithm, as used in OpenSSL
         */
@@ -76,7 +76,7 @@ static openssl_algorithm_t integrity_algs[] = {
 /**
  * Look up an OpenSSL algorithm name
  */
-static char* lookup_algorithm(openssl_algorithm_t *openssl_algo, 
+static char* lookup_algorithm(openssl_algorithm_t *openssl_algo,
                                           u_int16_t ikev2_algo)
 {
        while (openssl_algo->ikev2_id != END_OF_LIST)
@@ -133,7 +133,7 @@ static void allocate_hash(private_openssl_hasher_t *this, chunk_t chunk,
        }
        else
        {
-               get_hash(this, chunk, NULL);    
+               get_hash(this, chunk, NULL);
        }
 }
 
@@ -152,7 +152,7 @@ static void destroy (private_openssl_hasher_t *this)
 openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo)
 {
        private_openssl_hasher_t *this;
-       
+
        char* name = lookup_algorithm(integrity_algs, algo);
        if (!name)
        {
@@ -161,7 +161,7 @@ openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo)
        }
 
        this = malloc_thing(private_openssl_hasher_t);
-       
+
        this->hasher = EVP_get_digestbyname(name);
        if (!this->hasher)
        {
@@ -169,17 +169,17 @@ openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo)
                free(this);
                return NULL;
        }
-       
+
        this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
        this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
        this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size;
        this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
        this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-       
+
        this->ctx = EVP_MD_CTX_create();
-       
+
        /* initialization */
        reset(this);
-       
+
        return &this->public;
 }
index aec5bc7dd351d27f04053b8e6dd477fef6f98556..fd7a043d11385c2bf205e1949cfdf9c683ec2780 100644 (file)
@@ -29,7 +29,7 @@ typedef struct openssl_hasher_t openssl_hasher_t;
  * Implementation of hashers using OpenSSL.
  */
 struct openssl_hasher_t {
-       
+
        /**
         * The hasher_t interface.
         */
@@ -38,7 +38,7 @@ struct openssl_hasher_t {
 
 /**
  * Constructor to create openssl_hasher_t.
- * 
+ *
  * @param algo                 algorithm
  * @return                             openssl_hasher_t, NULL if not supported
  */
index a24f88219d9051fbc79c7600ff6fa21abc26b409..38230ef17fa0b63deb1097ed5629ebcd4e5b4002 100644 (file)
@@ -83,7 +83,7 @@ struct CRYPTO_dynlock_value {
 static struct CRYPTO_dynlock_value *create_function(const char *file, int line)
 {
        struct CRYPTO_dynlock_value *lock;
-       
+
        lock = malloc_thing(struct CRYPTO_dynlock_value);
        lock->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
        return lock;
@@ -132,11 +132,11 @@ static void threading_init()
 
        CRYPTO_set_id_callback(id_function);
        CRYPTO_set_locking_callback(locking_function);
-       
+
        CRYPTO_set_dynlock_create_callback(create_function);
        CRYPTO_set_dynlock_lock_callback(lock_function);
        CRYPTO_set_dynlock_destroy_callback(destroy_function);
-       
+
        num_locks = CRYPTO_num_locks();
        mutex = malloc(sizeof(mutex_t*) * num_locks);
        for (i = 0; i < num_locks; i++)
@@ -151,7 +151,7 @@ static void threading_init()
 static void threading_cleanup()
 {
        int i, num_locks;
-       
+
        num_locks = CRYPTO_num_locks();
        for (i = 0; i < num_locks; i++)
        {
@@ -170,9 +170,9 @@ static void destroy(private_openssl_plugin_t *this)
                                        (crypter_constructor_t)openssl_crypter_create);
        lib->crypto->remove_hasher(lib->crypto,
                                        (hasher_constructor_t)openssl_hasher_create);
-       lib->crypto->remove_dh(lib->crypto, 
+       lib->crypto->remove_dh(lib->crypto,
                                        (dh_constructor_t)openssl_diffie_hellman_create);
-       lib->crypto->remove_dh(lib->crypto, 
+       lib->crypto->remove_dh(lib->crypto,
                                        (dh_constructor_t)openssl_ec_diffie_hellman_create);
        lib->creds->remove_builder(lib->creds,
                                        (builder_constructor_t)openssl_rsa_private_key_builder);
@@ -182,13 +182,13 @@ static void destroy(private_openssl_plugin_t *this)
                                        (builder_constructor_t)openssl_ec_private_key_builder);
        lib->creds->remove_builder(lib->creds,
                                        (builder_constructor_t)openssl_ec_public_key_builder);
-       
+
        ENGINE_cleanup();
        EVP_cleanup();
        CONF_modules_free();
-       
+
        threading_cleanup();
-       
+
        free(this);
 }
 
@@ -198,18 +198,18 @@ static void destroy(private_openssl_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_openssl_plugin_t *this = malloc_thing(private_openssl_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        threading_init();
-       
+
        OPENSSL_config(NULL);
        OpenSSL_add_all_algorithms();
-       
+
        /* activate support for hardware accelerators */
        ENGINE_load_builtin_engines();
        ENGINE_register_all_complete();
-       
+
        /* crypter */
        lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
                                        (crypter_constructor_t)openssl_crypter_create);
@@ -231,7 +231,7 @@ plugin_t *plugin_create()
                                        (crypter_constructor_t)openssl_crypter_create);
        lib->crypto->add_crypter(lib->crypto, ENCR_NULL,
                                        (crypter_constructor_t)openssl_crypter_create);
-       
+
        /* hasher */
        lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
                                        (hasher_constructor_t)openssl_hasher_create);
@@ -249,7 +249,7 @@ plugin_t *plugin_create()
                                        (hasher_constructor_t)openssl_hasher_create);
        lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
                                        (hasher_constructor_t)openssl_hasher_create);
-       
+
        /* ec diffie hellman */
        lib->crypto->add_dh(lib->crypto, ECP_192_BIT,
                                                (dh_constructor_t)openssl_ec_diffie_hellman_create);
@@ -261,36 +261,36 @@ plugin_t *plugin_create()
                                                (dh_constructor_t)openssl_ec_diffie_hellman_create);
        lib->crypto->add_dh(lib->crypto, ECP_521_BIT,
                                                (dh_constructor_t)openssl_ec_diffie_hellman_create);
-       
+
        /* diffie hellman */
-       lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_6144_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
        lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
-       lib->crypto->add_dh(lib->crypto, MODP_768_BIT, 
+       lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
                                                (dh_constructor_t)openssl_diffie_hellman_create);
-       
+
        /* rsa */
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                (builder_constructor_t)openssl_rsa_private_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                (builder_constructor_t)openssl_rsa_public_key_builder);
-       
+
        /* ec */
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_ECDSA,
                                                (builder_constructor_t)openssl_ec_private_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ECDSA,
                                                (builder_constructor_t)openssl_ec_public_key_builder);
-       
+
        return &this->public.plugin;
 }
index 3f4e1cd74d4530c1ff81b9c30490dd97d7057452..c68987856e84857f953c541dd10038b5fd92552f 100644 (file)
@@ -38,17 +38,17 @@ struct private_openssl_rsa_private_key_t {
         * Public interface for this signer.
         */
        openssl_rsa_private_key_t public;
-       
+
        /**
         * RSA object from OpenSSL
         */
        RSA *rsa;
-       
+
        /**
         * TRUE if the key is from an OpenSSL ENGINE and might not be readable
         */
        bool engine;
-       
+
        /**
         * reference count
         */
@@ -82,13 +82,13 @@ static bool build_emsa_pkcs1_signature(private_openssl_rsa_private_key_t *this,
                EVP_PKEY *key;
                const EVP_MD *hasher;
                u_int len;
-               
+
                hasher = EVP_get_digestbynid(type);
                if (!hasher)
                {
                        return FALSE;
                }
-               
+
                ctx = EVP_MD_CTX_create();
                key = EVP_PKEY_new();
                if (!ctx || !key)
@@ -111,7 +111,7 @@ static bool build_emsa_pkcs1_signature(private_openssl_rsa_private_key_t *this,
                {
                        success = TRUE;
                }
-       
+
 error:
                if (key)
                {
@@ -140,7 +140,7 @@ static key_type_t get_type(private_openssl_rsa_private_key_t *this)
 /**
  * Implementation of openssl_rsa_private_key.sign.
  */
-static bool sign(private_openssl_rsa_private_key_t *this, signature_scheme_t scheme, 
+static bool sign(private_openssl_rsa_private_key_t *this, signature_scheme_t scheme,
                                 chunk_t data, chunk_t *signature)
 {
        switch (scheme)
@@ -192,7 +192,7 @@ static public_key_t* get_public_key(private_openssl_rsa_private_key_t *this)
        chunk_t enc;
        public_key_t *key;
        u_char *p;
-       
+
        enc = chunk_alloc(i2d_RSAPublicKey(this->rsa, NULL));
        p = enc.ptr;
        i2d_RSAPublicKey(this->rsa, &p);
@@ -218,7 +218,7 @@ static bool get_encoding(private_openssl_rsa_private_key_t *this,
                                                 key_encoding_type_t type, chunk_t *encoding)
 {
        u_char *p;
-       
+
        if (this->engine)
        {
                return FALSE;
@@ -268,7 +268,7 @@ static void destroy(private_openssl_rsa_private_key_t *this)
 static private_openssl_rsa_private_key_t *create_empty(void)
 {
        private_openssl_rsa_private_key_t *this = malloc_thing(private_openssl_rsa_private_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*) (private_key_t*))get_type;
        this->public.interface.sign = (bool (*) (private_key_t*, signature_scheme_t, chunk_t, chunk_t*))sign;
        this->public.interface.decrypt = (bool (*) (private_key_t*, chunk_t, chunk_t*))decrypt;
@@ -280,10 +280,10 @@ static private_openssl_rsa_private_key_t *create_empty(void)
        this->public.interface.get_encoding = (bool(*)(private_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (private_key_t* (*) (private_key_t*))get_ref;
        this->public.interface.destroy = (void (*) (private_key_t*))destroy;
-       
+
        this->engine = FALSE;
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -293,9 +293,9 @@ static private_openssl_rsa_private_key_t *create_empty(void)
 static openssl_rsa_private_key_t *generate(size_t key_size)
 {
        private_openssl_rsa_private_key_t *this = create_empty();
-       
+
        this->rsa = RSA_generate_key(key_size, PUBLIC_EXPONENT, NULL, NULL);
-       
+
        return &this->public;
 }
 
@@ -306,7 +306,7 @@ static openssl_rsa_private_key_t *load(chunk_t blob)
 {
        u_char *p = blob.ptr;
        private_openssl_rsa_private_key_t *this = create_empty();
-       
+
        this->rsa = d2i_RSAPrivateKey(NULL, (const u_char**)&p, blob.len);
        if (!this->rsa)
        {
@@ -330,28 +330,28 @@ static openssl_rsa_private_key_t *load_from_smartcard(char *keyid, char *pin)
        EVP_PKEY *key;
        char *engine_id = lib->settings->get_str(lib->settings,
                                                                "library.plugins.openssl.engine_id", "pkcs11");
-       
+
        ENGINE *engine = ENGINE_by_id(engine_id);
        if (!engine)
        {
                DBG1("engine '%s' is not available", engine_id);
                return NULL;
        }
-       
+
        if (!ENGINE_init(engine))
        {
                DBG1("failed to initialize engine '%s'", engine_id);
                goto error;
        }
-       
+
        if (!ENGINE_ctrl_cmd_string(engine, "PIN", pin, 0))
        {
                DBG1("failed to set PIN on engine '%s'", engine_id);
                goto error;
        }
-       
+
        key = ENGINE_load_private_key(engine, keyid, NULL, NULL);
-       
+
        if (!key)
        {
                DBG1("failed to load private key with ID '%s' from engine '%s'", keyid,
@@ -359,13 +359,13 @@ static openssl_rsa_private_key_t *load_from_smartcard(char *keyid, char *pin)
                goto error;
        }
        ENGINE_free(engine);
-       
+
        this = create_empty();
        this->rsa = EVP_PKEY_get1_RSA(key);
        this->engine = TRUE;
-       
+
        return &this->public;
-       
+
 error:
        ENGINE_free(engine);
        return NULL;
@@ -393,7 +393,7 @@ struct private_builder_t {
 static openssl_rsa_private_key_t *build(private_builder_t *this)
 {
        openssl_rsa_private_key_t *key = this->key;
-       
+
        if (this->keyid && this->pin)
        {
                key = load_from_smartcard(this->keyid, this->pin);
@@ -410,7 +410,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        if (!this->key)
        {
                va_list args;
-               
+
                switch (part)
                {
                        case BUILD_BLOB_ASN1_DER:
@@ -458,20 +458,20 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *openssl_rsa_private_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->key = NULL;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
        this->keyid = NULL;
        this->pin = NULL;
-       
+
        return &this->public;
 }
 
index c20af907a7a3f61acdf97915b297172b2c98d973..e30ab858b6f063183e04dc571d7f37fe2dd5e5c7 100644 (file)
@@ -32,12 +32,12 @@ struct private_openssl_rsa_public_key_t {
         * Public interface for this signer.
         */
        openssl_rsa_public_key_t public;
-       
+
        /**
         * RSA object from OpenSSL
         */
        RSA *rsa;
-       
+
        /**
         * reference counter
         */
@@ -100,7 +100,7 @@ static bool verify_emsa_pkcs1_signature(private_openssl_rsa_public_key_t *this,
                        goto error;
                }
                valid = (EVP_VerifyFinal(ctx, signature.ptr, signature.len, key) == 1);
-       
+
 error:
                if (key)
                {
@@ -125,7 +125,7 @@ static key_type_t get_type(private_openssl_rsa_public_key_t *this)
 /**
  * Implementation of public_key_t.verify.
  */
-static bool verify(private_openssl_rsa_public_key_t *this, signature_scheme_t scheme, 
+static bool verify(private_openssl_rsa_public_key_t *this, signature_scheme_t scheme,
                                   chunk_t data, chunk_t signature)
 {
        switch (scheme)
@@ -177,7 +177,7 @@ bool openssl_rsa_fingerprint(RSA *rsa, key_encoding_type_t type, chunk_t *fp)
        hasher_t *hasher;
        chunk_t key;
        u_char *p;
-       
+
        if (lib->encoding->get_cache(lib->encoding, type, rsa, fp))
        {
                return TRUE;
@@ -227,7 +227,7 @@ static bool get_encoding(private_openssl_rsa_public_key_t *this,
                                                 key_encoding_type_t type, chunk_t *encoding)
 {
        u_char *p;
-       
+
        switch (type)
        {
                case KEY_PUB_SPKI_ASN1_DER:
@@ -280,7 +280,7 @@ static void destroy(private_openssl_rsa_public_key_t *this)
 static private_openssl_rsa_public_key_t *create_empty()
 {
        private_openssl_rsa_public_key_t *this = malloc_thing(private_openssl_rsa_public_key_t);
-       
+
        this->public.interface.get_type = (key_type_t (*)(public_key_t *this))get_type;
        this->public.interface.verify = (bool (*)(public_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t signature))verify;
        this->public.interface.encrypt = (bool (*)(public_key_t *this, chunk_t crypto, chunk_t *plain))encrypt_;
@@ -290,10 +290,10 @@ static private_openssl_rsa_public_key_t *create_empty()
        this->public.interface.get_encoding = (bool(*)(public_key_t*, key_encoding_type_t type, chunk_t *encoding))get_encoding;
        this->public.interface.get_ref = (public_key_t* (*)(public_key_t *this))get_ref;
        this->public.interface.destroy = (void (*)(public_key_t *this))destroy;
-       
+
        this->rsa = NULL;
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -304,14 +304,14 @@ static openssl_rsa_public_key_t *load(chunk_t blob)
 {
        u_char *p = blob.ptr;
        private_openssl_rsa_public_key_t *this = create_empty();
-       
+
        this->rsa = d2i_RSAPublicKey(NULL, (const u_char**)&p, blob.len);
        if (!this->rsa)
        {
                destroy(this);
                return NULL;
        }
-       
+
        return &this->public;
 }
 
@@ -333,7 +333,7 @@ struct private_builder_t {
 static openssl_rsa_public_key_t *build(private_builder_t *this)
 {
        openssl_rsa_public_key_t *key = this->key;
-       
+
        free(this);
        return key;
 }
@@ -346,7 +346,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        if (!this->key)
        {
                va_list args;
-               
+
                switch (part)
                {
                        case BUILD_BLOB_ASN1_DER:
@@ -373,18 +373,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *openssl_rsa_public_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->key = NULL;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 5caae4bdd016586706f1b4c2add8c3177cce7a48..55b18a5248b3305d80b069c6d0eca199d50b04c0 100644 (file)
@@ -33,30 +33,30 @@ bool openssl_hash_chunk(int hash_type, chunk_t data, chunk_t *hash)
        {
                return FALSE;
        }
-       
-       ctx = EVP_MD_CTX_create();      
+
+       ctx = EVP_MD_CTX_create();
        if (!ctx)
        {
                goto error;
        }
-       
+
        if (!EVP_DigestInit_ex(ctx, hasher, NULL))
        {
                goto error;
        }
-       
+
        if (!EVP_DigestUpdate(ctx, data.ptr, data.len))
        {
                goto error;
        }
-       
+
        *hash = chunk_alloc(hasher->md_size);
        if (!EVP_DigestFinal_ex(ctx, hash->ptr, NULL))
        {
                chunk_free(hash);
                goto error;
        }
-       
+
        ret = TRUE;
 error:
        if (ctx)
@@ -72,18 +72,18 @@ error:
 bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk)
 {
        int offset;
-       
+
        chunk->len = len + (b ? len : 0);
        chunk->ptr = malloc(chunk->len);
        memset(chunk->ptr, 0, chunk->len);
-       
+
        /* convert a */
        offset = len - BN_num_bytes(a);
        if (!BN_bn2bin(a, chunk->ptr + offset))
        {
                goto error;
        }
-       
+
        /* optionally convert and concatenate b */
        if (b)
        {
@@ -92,8 +92,8 @@ bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk)
                {
                        goto error;
                }
-       }       
-       
+       }
+
        return TRUE;
 error:
        chunk_free(chunk);
@@ -107,20 +107,20 @@ error:
 bool openssl_bn_split(chunk_t chunk, BIGNUM *a, BIGNUM *b)
 {
        int len;
-       
+
        if ((chunk.len % 2) != 0)
        {
                return FALSE;
        }
-       
+
        len = chunk.len / 2;
-       
+
        if (!BN_bin2bn(chunk.ptr, len, a) ||
                !BN_bin2bn(chunk.ptr + len, len, b))
        {
                return FALSE;
        }
-       
+
        return TRUE;
 }
 
index 6ba1ff07b1b1983e3ec60741dd4085ad227f1611..538008f2c4145425cd47241c46803e4f635774aa 100644 (file)
@@ -31,9 +31,9 @@
 
 /**
  * Creates a hash of a given type of a chunk of data.
- * 
+ *
  * Note: this function allocates memory for the hash
- * 
+ *
  * @param hash_type    NID of the hash
  * @param data         the chunk of data to hash
  * @param hash         chunk that contains the hash
@@ -44,9 +44,9 @@ bool openssl_hash_chunk(int hash_type, chunk_t data, chunk_t *hash);
 /**
  * Concatenates two bignums into a chunk, thereby enfocing the length of
  * a single BIGNUM, if necessary, by pre-pending it with zeros.
- * 
+ *
  * Note: this function allocates memory for the chunk
- * 
+ *
  * @param len          the length of a single BIGNUM
  * @param a                    first BIGNUM
  * @param b                    second BIGNUM
@@ -57,7 +57,7 @@ bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk);
 
 /**
  * Splits a chunk into two bignums of equal binary length.
- * 
+ *
  * @param chunk                a chunk that contains the two BIGNUMs
  * @param a                    first BIGNUM
  * @param b                    second BIGNUM
index afdd85b79bacb4a1ed0c2fdf514e7c172dfdeeb9..9edea4bd3ca2c64af0294ca854b5491ea4a4a5be 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2008 Thomas Kallenberg
  * Copyright (C) 2008 Martin Willi
- * Hochschule fuer Technik Rapperswil 
+ * Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -26,12 +26,12 @@ typedef struct private_padlock_aes_crypter_t private_padlock_aes_crypter_t;
  * Private data of padlock_aes_crypter_t
  */
 struct private_padlock_aes_crypter_t {
-       
+
        /**
         * Public part of this class.
         */
        padlock_aes_crypter_t public;
-       
+
        /*
         * the key
         */
@@ -56,7 +56,7 @@ typedef struct {
 /**
  * Invoke the actual de/encryption
  */
-static void padlock_crypt(void *key, void *ctrl, void *src, void *dst, 
+static void padlock_crypt(void *key, void *ctrl, void *src, void *dst,
                                                  int count, void *iv)
 {
        asm volatile(
@@ -81,7 +81,7 @@ static void padlock_crypt(void *key, void *ctrl, void *src, void *dst,
 /*
  * Implementation of crypter_t.crypt
  */
-static void crypt(private_padlock_aes_crypter_t *this, char *iv, 
+static void crypt(private_padlock_aes_crypter_t *this, char *iv,
                                  chunk_t src, chunk_t *dst, bool enc)
 {
        cword cword PADLOCK_ALIGN;
@@ -110,7 +110,7 @@ static void crypt(private_padlock_aes_crypter_t *this, char *iv,
 /**
  * Implementation of crypter_t.decrypt.
  */
-static void decrypt(private_padlock_aes_crypter_t *this, chunk_t data, 
+static void decrypt(private_padlock_aes_crypter_t *this, chunk_t data,
                                                chunk_t iv, chunk_t *dst)
 {
        crypt(this, iv.ptr, data, dst, TRUE);
@@ -120,7 +120,7 @@ static void decrypt(private_padlock_aes_crypter_t *this, chunk_t data,
 /**
  * Implementation of crypter_t.encrypt.
  */
-static void encrypt (private_padlock_aes_crypter_t *this, chunk_t data, 
+static void encrypt (private_padlock_aes_crypter_t *this, chunk_t data,
                                                        chunk_t iv, chunk_t *dst)
 {
        crypt(this, iv.ptr, data, dst, FALSE);
@@ -162,18 +162,18 @@ static void destroy (private_padlock_aes_crypter_t *this)
 /*
  * Described in header
  */
-padlock_aes_crypter_t *padlock_aes_crypter_create(encryption_algorithm_t algo, 
+padlock_aes_crypter_t *padlock_aes_crypter_create(encryption_algorithm_t algo,
                                                                                                  size_t key_size)
 {
        private_padlock_aes_crypter_t *this;
-       
+
        if (algo != ENCR_AES_CBC)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_padlock_aes_crypter_t);
-       
+
        switch (key_size)
        {
                case 16:        /* AES 128 */
@@ -185,15 +185,15 @@ padlock_aes_crypter_t *padlock_aes_crypter_create(encryption_algorithm_t algo,
                        free(this);
                        return NULL;
        }
-       
+
        this->key = chunk_alloc(key_size);
-       
+
        this->public.crypter_interface.encrypt = (void (*) (crypter_t *, chunk_t,chunk_t, chunk_t *)) encrypt;
        this->public.crypter_interface.decrypt = (void (*) (crypter_t *, chunk_t , chunk_t, chunk_t *)) decrypt;
        this->public.crypter_interface.get_block_size = (size_t (*) (crypter_t *)) get_block_size;
        this->public.crypter_interface.get_key_size = (size_t (*) (crypter_t *)) get_key_size;
        this->public.crypter_interface.set_key = (void (*) (crypter_t *,chunk_t)) set_key;
        this->public.crypter_interface.destroy = (void (*) (crypter_t *)) destroy;
-       
+
        return &this->public;
 }
index d8ac9c2a030af63fed69c783567ae6db96fca6e8..d4c7a757758f70a28917ca1347cfc7d6ee24aed8 100644 (file)
@@ -30,7 +30,7 @@ typedef struct padlock_aes_crypter_t padlock_aes_crypter_t;
  * Implementation of AES-128 using VIA Padlock.
  */
 struct padlock_aes_crypter_t {
-       
+
        /**
         * The crypter_t interface.
         */
@@ -39,7 +39,7 @@ struct padlock_aes_crypter_t {
 
 /**
  * Constructor to create padlock_aes_crypter_t.
- * 
+ *
  * @param key_size             key size in bytes, currently supports only 16.
  * @param algo                 algorithm to implement, must be ENCR_AES_CBC
  * @return                             padlock_aes_crypter_t, NULL if not supported
index e241b59beb8aaf9e4e5a65351d8c29fd9165cce3..32b18ec4bbd7f571eb217760fd8a328df604f38f 100644 (file)
@@ -55,7 +55,7 @@ struct private_padlock_plugin_t {
         * public functions
         */
        padlock_plugin_t public;
-       
+
        /**
         * features supported by Padlock
         */
@@ -81,11 +81,11 @@ static padlock_feature_t get_padlock_features()
 {
        char vendor[3 * sizeof(int) + 1];
        int a, b, c, d;
-       
+
        cpuid(0, a, b, c, d);
        /* VendorID string is in b-d-c (yes, in this order) */
        snprintf(vendor, sizeof(vendor), "%.4s%.4s%.4s", &b, &d, &c);
-       
+
        /* check if we have a VIA chip */
        if (streq(vendor, "CentaurHauls"))
        {
@@ -134,9 +134,9 @@ static void destroy(private_padlock_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_padlock_plugin_t *this = malloc_thing(private_padlock_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        this->features = get_padlock_features();
        if (!this->features)
        {
@@ -154,7 +154,7 @@ plugin_t *plugin_create()
                 this->features & PADLOCK_ACE2_ENABLED ? " ACE2" : "",
                 this->features & PADLOCK_PHE_ENABLED ? " PHE" : "",
                 this->features & PADLOCK_PMM_ENABLED ? " PMM" : "");
-       
+
        if (this->features & PADLOCK_RNG_ENABLED)
        {
                lib->crypto->add_rng(lib->crypto, RNG_TRUE,
index 8a04dccfcd1a068aef5a5bfbe098a4328b6ceb34..8ff46081bfe32c239536753e2b514f41b0051bdb 100644 (file)
@@ -36,12 +36,12 @@ enum padlock_quality_factor_t {
  * Private data of an padlock_rng_t object.
  */
 struct private_padlock_rng_t {
-       
+
        /**
         * Public padlock_rng_t interface.
         */
        padlock_rng_t public;
-       
+
        /**
         * Padlock quality factor
         */
@@ -56,14 +56,14 @@ static void rng(char *buf, int len, int quality)
        while (len > 0)\r
        {
                int status;
-               
+
                /* run XSTORE until we have all bytes needed. We do not use REP, as
                 * this should not be performance critical and it's easier this way. */
                asm volatile (
                        ".byte 0x0F,0xA7,0xC0 \n\t"\r
                        : "=D"(buf), "=a"(status)\r
                        : "d"(quality), "D"(buf));
-               
+
                /* bits[0..4] of status word contains the number of bytes read */
                len -= status & 0x1F;
        }
@@ -78,7 +78,7 @@ static void allocate_bytes(private_padlock_rng_t *this, size_t bytes,
        chunk->len = bytes;
        /* padlock requires some additional bytes */
        chunk->ptr = malloc(bytes + 7);
-       
+
        rng(chunk->ptr, chunk->len, this->quality);
 }
 
@@ -89,7 +89,7 @@ static void get_bytes(private_padlock_rng_t *this, size_t bytes,
                                          u_int8_t *buffer)
 {
        chunk_t chunk;
-       
+
        /* Padlock needs a larger buffer than "bytes", we need a new buffer */
        allocate_bytes(this, bytes, &chunk);
        memcpy(buffer, chunk.ptr, bytes);
@@ -110,11 +110,11 @@ static void destroy(private_padlock_rng_t *this)
 padlock_rng_t *padlock_rng_create(rng_quality_t quality)
 {
        private_padlock_rng_t *this = malloc_thing(private_padlock_rng_t);
-       
+
        this->public.rng.get_bytes = (void (*) (rng_t *, size_t, u_int8_t*)) get_bytes;
        this->public.rng.allocate_bytes = (void (*) (rng_t *, size_t, chunk_t*)) allocate_bytes;
        this->public.rng.destroy = (void (*) (rng_t *))destroy;
-       
+
        /* map RNG quality to Padlock quality factor */
        switch (quality)
        {
@@ -128,7 +128,7 @@ padlock_rng_t *padlock_rng_create(rng_quality_t quality)
                        this->quality = PADLOCK_QF3;
                        break;
        }
-       
+
        return &this->public;
 }
 
index 237d8fbe218c7430b29582b4e3234e0d882a43f8..7fb9a89d5a4ee5e461bffeb2afe5aede56c2cc16 100644 (file)
@@ -29,7 +29,7 @@ typedef struct padlock_rng_t padlock_rng_t;
  * Hardware-RNG based on via Padlock.
  */
 struct padlock_rng_t {
-       
+
        /**
         * Implements rng_t interface.
         */
index b5a6abc6410054b9776f7c0cc4d0295207a87c1a..30c2a861743488789ed7ab3a0d594e54ff0cf17d 100644 (file)
@@ -32,7 +32,7 @@ struct private_padlock_sha1_hasher_t {
         * Public interface for this hasher.
         */
        padlock_sha1_hasher_t public;
-       
+
        /**
         * data collected to hash
         */
@@ -46,7 +46,7 @@ static void padlock_sha1(int len, u_char *in, u_char *out)
 {
        /* rep xsha1 */
     asm volatile (
-               ".byte 0xf3, 0x0f, 0xa6, 0xc8" 
+               ".byte 0xf3, 0x0f, 0xa6, 0xc8"
                : "+S"(in), "+D"(out)
                : "c"(len), "a"(0));
 }
@@ -57,7 +57,7 @@ static void padlock_sha1(int len, u_char *in, u_char *out)
 static void sha1(chunk_t data, u_int32_t *digest)
 {
        u_int32_t hash[128] PADLOCK_ALIGN;
+
        hash[0] = 0x67452301;
        hash[1] = 0xefcdab89;
        hash[2] = 0x98badcfe;
@@ -105,14 +105,14 @@ static void get_hash(private_padlock_sha1_hasher_t *this, chunk_t chunk,
                        sha1(this->data, (u_int32_t*)hash);
                }
                else
-               {   /* hash directly if no previous data found */   
+               {   /* hash directly if no previous data found */
                        sha1(chunk, (u_int32_t*)hash);
                }
                reset(this);
        }
        else
        {
-               append_data(this, chunk);       
+               append_data(this, chunk);
        }
 }
 
@@ -129,10 +129,10 @@ static void allocate_hash(private_padlock_sha1_hasher_t *this, chunk_t chunk,
        }
        else
        {
-               get_hash(this, chunk, NULL);    
+               get_hash(this, chunk, NULL);
        }
 }
-       
+
 /**
  * Implementation of hasher_t.get_hash_size.
  */
@@ -156,20 +156,20 @@ static void destroy(private_padlock_sha1_hasher_t *this)
 padlock_sha1_hasher_t *padlock_sha1_hasher_create(hash_algorithm_t algo)
 {
        private_padlock_sha1_hasher_t *this;
-       
+
        if (algo != HASH_SHA1)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_padlock_sha1_hasher_t);
        this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
        this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
        this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size;
        this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
        this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-       
+
        this->data = chunk_empty;
-       
+
        return &(this->public);
 }
index afa1e046d7f471d5d47c0051ec3f9a3bd0b34a51..740bdfe98b794bd3bf85705e8e7ba6a76f02ba97 100644 (file)
@@ -30,7 +30,7 @@ typedef struct padlock_sha1_hasher_t padlock_sha1_hasher_t;
  * Implementation of hasher_t interface using the SHA1 algorithm.
  */
 struct padlock_sha1_hasher_t {
-       
+
        /**
         * Implements hasher_t interface.
         */
index 2008067cd0e94f308341191554f92910aa682350..7320bae88e0ffbe4524c2b7b128641f3a49acba2 100644 (file)
@@ -70,7 +70,7 @@ struct private_builder_t {
 static bool present(char* pattern, chunk_t* ch)
 {
        u_int len = strlen(pattern);
-       
+
        if (ch->len >= len && strneq(ch->ptr, pattern, len))
        {
                *ch = chunk_skip(*ch, len);
@@ -85,7 +85,7 @@ static bool present(char* pattern, chunk_t* ch)
 static bool find_boundary(char* tag, chunk_t *line)
 {
        chunk_t name = chunk_empty;
-       
+
        if (!present("-----", line) ||
                !present(tag, line) ||
                *line->ptr != ' ')
@@ -93,7 +93,7 @@ static bool find_boundary(char* tag, chunk_t *line)
                return FALSE;
        }
        *line = chunk_skip(*line, 1);
-       
+
        /* extract name */
        name.ptr = line->ptr;
        while (line->len > 0)
@@ -121,7 +121,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
        chunk_t decrypted;
        chunk_t key = {alloca(key_size), key_size};
        u_int8_t padding, *last_padding_pos, *first_padding_pos;
-       
+
        /* build key from passphrase and IV */
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
        if (hasher == NULL)
@@ -134,7 +134,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
        hasher->get_hash(hasher, passphrase, NULL);
        hasher->get_hash(hasher, salt, hash.ptr);
        memcpy(key.ptr, hash.ptr, hash.len);
-       
+
        if (key.len > hash.len)
        {
                hasher->get_hash(hasher, hash, NULL);
@@ -143,7 +143,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
                memcpy(key.ptr + hash.len, hash.ptr, key.len - hash.len);
        }
        hasher->destroy(hasher);
-       
+
        /* decrypt blob */
        crypter = lib->crypto->create_crypter(lib->crypto, alg, key_size);
        if (crypter == NULL)
@@ -153,7 +153,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
                return NOT_SUPPORTED;
        }
        crypter->set_key(crypter, key);
-       
+
        if (iv.len != crypter->get_block_size(crypter) ||
                blob->len % iv.len)
        {
@@ -165,7 +165,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
        crypter->destroy(crypter);
        memcpy(blob->ptr, decrypted.ptr, blob->len);
        chunk_free(&decrypted);
-       
+
        /* determine amount of padding */
        last_padding_pos = blob->ptr + blob->len - 1;
        padding = *last_padding_pos;
@@ -204,7 +204,7 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
                PEM_POST   = 4,
                PEM_ABORT  = 5
        } state_t;
-       
+
        encryption_algorithm_t alg = ENCR_UNDEFINED;
        size_t key_size = 0;
        bool encrypted = FALSE;
@@ -216,11 +216,11 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
        chunk_t passphrase;
        int try = 0;
        u_char iv_buf[HASH_SIZE_MD5];
-       
+
        dst.len = 0;
        iv.ptr = iv_buf;
        iv.len = 0;
-       
+
        while (fetchline(&src, &line))
        {
                if (state == PEM_PRE)
@@ -251,14 +251,14 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
                                err_t ugh = NULL;
                                chunk_t name  = chunk_empty;
                                chunk_t value = chunk_empty;
-                               
+
                                /* an empty line separates HEADER and BODY */
                                if (line.len == 0)
                                {
                                        state = PEM_BODY;
                                        continue;
                                }
-                               
+
                                /* we are looking for a parameter: value pair */
                                DBG2("  %.*s", (int)line.len, line.ptr);
                                ugh = extract_parameter_value(&name, &value, &line);
@@ -273,7 +273,7 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
                                else if (match("DEK-Info", &name))
                                {
                                        chunk_t dek;
-                                       
+
                                        if (!extract_token(&dek, ',', &value))
                                        {
                                                dek = value;
@@ -311,13 +311,13 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
                        else /* state is PEM_BODY */
                        {
                                chunk_t data;
-                               
+
                                /* remove any trailing whitespace */
                                if (!extract_token(&data ,' ', &line))
                                {
                                        data = line;
                                }
-                               
+
                                /* check for PGP armor checksum */
                                if (*data.ptr == '=')
                                {
@@ -327,7 +327,7 @@ status_t pem_to_bin(chunk_t *blob, private_builder_t *this, bool *pgp)
                                        DBG2("  armor checksum: %.*s", (int)data.len, data.ptr);
                                        continue;
                                }
-                               
+
                                if (blob->len - dst.len < data.len / 4 * 3)
                                {
                                        state = PEM_ABORT;
@@ -383,7 +383,7 @@ static void *build_from_blob(private_builder_t *this, chunk_t blob)
 {
        void *cred = NULL;
        bool pgp = FALSE;
-       
+
        blob = chunk_clone(blob);
        if (!is_asn1(blob))
        {
@@ -417,21 +417,21 @@ static void *build_from_file(private_builder_t *this, char *file)
        struct stat sb;
        void *addr;
        int fd;
-       
+
        fd = open(file, O_RDONLY);
        if (fd == -1)
        {
                DBG1("  opening '%s' failed: %s", file, strerror(errno));
                return NULL;
        }
-       
+
        if (fstat(fd, &sb) == -1)
        {
                DBG1("  getting file size of '%s' failed: %s", file, strerror(errno));
                close(fd);
                return NULL;
        }
-       
+
        addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
        if (addr == MAP_FAILED)
        {
@@ -439,9 +439,9 @@ static void *build_from_file(private_builder_t *this, char *file)
                close(fd);
                return NULL;
        }
-       
+
        cred = build_from_blob(this, chunk_create(addr, sb.st_size));
-       
+
        munmap(addr, sb.st_size);
        close(fd);
        return cred;
@@ -455,7 +455,7 @@ static void *build_from_fd(private_builder_t *this, int fd)
        char buf[8096];
        char *pos = buf;
        ssize_t len, total = 0;
-       
+
        while (TRUE)
        {
                len = read(fd, pos, buf + sizeof(buf) - pos);
@@ -484,7 +484,7 @@ static void *build_from_fd(private_builder_t *this, int fd)
 static void *build(private_builder_t *this)
 {
        void *cred = NULL;
-       
+
        if (this->pem.ptr)
        {
                cred = build_from_blob(this, this->pem);
@@ -519,7 +519,7 @@ static chunk_t given_passphrase_cb(chunk_t *passphrase, int try)
 static void add(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_FROM_FILE:
@@ -570,10 +570,10 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 static builder_t *pem_builder(credential_type_t type, int subtype)
 {
        private_builder_t *this = malloc_thing(private_builder_t);
-       
+
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        this->type = type;
        this->subtype = subtype;
        this->file = NULL;
@@ -583,7 +583,7 @@ static builder_t *pem_builder(credential_type_t type, int subtype)
        this->cb = NULL;
        this->data = NULL;
        this->flags = 0;
-       
+
        return &this->public;
 }
 
index 5289361f279807bec124ee4857e823c1b376f76e..a0ecec8262e9a7d7352f7c239d65f26c05b08fc6 100644 (file)
@@ -51,9 +51,9 @@ static void destroy(private_pem_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_pem_plugin_t *this = malloc_thing(private_pem_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        /* register private key PEM decoding builders */
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_ANY,
                                                        (builder_constructor_t)private_key_pem_builder);
@@ -63,7 +63,7 @@ plugin_t *plugin_create()
                                                        (builder_constructor_t)private_key_pem_builder);
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_DSA,
                                                        (builder_constructor_t)private_key_pem_builder);
-       
+
        /* register public key PEM decoding builders */
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
                                                        (builder_constructor_t)public_key_pem_builder);
@@ -73,7 +73,7 @@ plugin_t *plugin_create()
                                                        (builder_constructor_t)public_key_pem_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_DSA,
                                                        (builder_constructor_t)public_key_pem_builder);
-       
+
        /* register certificate PEM decoding builders */
        lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_ANY,
                                                        (builder_constructor_t)certificate_pem_builder);
@@ -91,7 +91,7 @@ plugin_t *plugin_create()
                                                        (builder_constructor_t)certificate_pem_builder);
        lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_GPG,
                                                        (builder_constructor_t)certificate_pem_builder);
-       
+
        /* register pluto specific certificate formats */
        lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_PLUTO_CERT,
                                                        (builder_constructor_t)certificate_pem_builder);
@@ -99,7 +99,7 @@ plugin_t *plugin_create()
                                                        (builder_constructor_t)certificate_pem_builder);
        lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_PLUTO_CRL,
                                                        (builder_constructor_t)certificate_pem_builder);
-       
+
        return &this->public.plugin;
 }
 
index 6d39160f92ccc2fb11d0ed6dcce40df8c96825c4..75616c49656305be12a234d46bf1daaaca4b8b27 100644 (file)
@@ -16,7 +16,7 @@
 /**
  * @defgroup pem_p pem
  * @ingroup plugins
- * 
+ *
  * @defgroup pem_plugin pem_plugin
  * @{ @ingroup pem_p
  */
index 7fc7155fdea74f7a2dfc50c83e9894558cff50f3..fad8fe10f84745ab9e4a2a121e863fb3e6888dc6 100644 (file)
@@ -90,7 +90,7 @@ ENUM(pgp_sym_alg_names, PGP_SYM_ALG_PLAIN, PGP_SYM_ALG_TWOFISH,
 static bool read_scalar(chunk_t *blob, size_t bytes, u_int32_t *scalar)
 {
        u_int32_t res = 0;
-       
+
        if (bytes > blob->len)
        {
                DBG1("PGP data too short to read %d byte scalar", bytes);
@@ -112,14 +112,14 @@ static bool old_packet_length(chunk_t *blob, u_int32_t *length)
 {
        /* bits 0 and 1 define the packet length type */
        u_char type;
-       
+
        if (!blob->len)
        {
                return FALSE;
        }
        type = 0x03 & blob->ptr[0];
        *blob = chunk_skip(*blob, 1);
-       
+
        if (type > 2)
        {
                return FALSE;
@@ -133,7 +133,7 @@ static bool old_packet_length(chunk_t *blob, u_int32_t *length)
 static bool read_mpi(chunk_t *blob, chunk_t *mpi)
 {
        u_int32_t bits, bytes;
-       
+
        if (!read_scalar(blob, 2, &bits))
        {
                DBG1("PGP data too short to read MPI length");
@@ -157,7 +157,7 @@ static public_key_t *parse_public_key(chunk_t blob)
 {
        u_int32_t alg;
        public_key_t *key;
-       
+
        if (!read_scalar(&blob, 1, &alg))
        {
                return NULL;
@@ -184,7 +184,7 @@ static public_key_t *parse_rsa_public_key(chunk_t blob)
 {
        chunk_t mpi[2];
        int i;
-       
+
        for (i = 0; i < 2; i++)
        {
                if (!read_mpi(&blob, &mpi[i]))
@@ -205,7 +205,7 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
        chunk_t mpi[6];
        u_int32_t s2k;
        int i;
-       
+
        for (i = 0; i < 2; i++)
        {
                if (!read_mpi(&blob, &mpi[i]))
@@ -227,7 +227,7 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
                DBG1("%N private key encryption not supported", pgp_sym_alg_names, s2k);
                return NULL;
        }
-       
+
        for (i = 2; i < 6; i++)
        {
                if (!read_mpi(&blob, &mpi[i]))
@@ -235,9 +235,9 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
                        return NULL;
                }
        }
-       
+
        /* PGP has uses p < q, but we use p > q */
-       return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, 
+       return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                BUILD_RSA_MODULUS, mpi[0], BUILD_RSA_PUB_EXP, mpi[1],
                                                BUILD_RSA_PRIV_EXP, mpi[2], BUILD_RSA_PRIME2, mpi[3],
                                                BUILD_RSA_PRIME1, mpi[4], BUILD_RSA_COEFF, mpi[5],
@@ -273,9 +273,9 @@ static private_key_t *parse_private_key(chunk_t blob)
        u_char tag, type;
        u_int32_t len, version, created, days, alg;
        private_key_t *key;
-       
+
        tag = blob.ptr[0];
-       
+
        /* bit 7 must be set */
        if (!(tag & 0x80))
        {
@@ -288,7 +288,7 @@ static private_key_t *parse_private_key(chunk_t blob)
                DBG1("new PGP packet format not supported");
                return NULL;
        }
-       
+
        type = (tag & 0x3C) >> 2;
        if (!old_packet_length(&blob, &len) || len > blob.len)
        {
@@ -298,7 +298,7 @@ static private_key_t *parse_private_key(chunk_t blob)
        packet.len = len;
        packet.ptr = blob.ptr;
        blob = chunk_skip(blob, len);
-       
+
        if (!read_scalar(&packet, 1, &version))
        {
                return NULL;
@@ -377,7 +377,7 @@ struct private_builder_t {
 static public_key_t *build_public(private_builder_t *this)
 {
        public_key_t *key = NULL;
-       
+
        switch (this->type)
        {
                case KEY_ANY:
@@ -399,7 +399,7 @@ static public_key_t *build_public(private_builder_t *this)
 static void add_public(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_BLOB_PGP:
@@ -421,19 +421,19 @@ static void add_public(private_builder_t *this, builder_part_t part, ...)
 builder_t *pgp_public_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_ANY && type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->blob = chunk_empty;
        this->type = type;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_public;
        this->public.build = (void*(*)(builder_t *this))build_public;
-       
+
        return &this->public;
 }
 
@@ -443,7 +443,7 @@ builder_t *pgp_public_key_builder(key_type_t type)
 static private_key_t *build_private(private_builder_t *this)
 {
        private_key_t *key = NULL;
-       
+
        switch (this->type)
        {
                case KEY_ANY:
@@ -465,7 +465,7 @@ static private_key_t *build_private(private_builder_t *this)
 static void add_private(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_BLOB_PGP:
@@ -487,19 +487,19 @@ static void add_private(private_builder_t *this, builder_part_t part, ...)
 builder_t *pgp_private_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_ANY && type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->blob = chunk_empty;
        this->type = type;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_private;
        this->public.build = (void*(*)(builder_t *this))build_private;
-       
+
        return &this->public;
 }
 
index b24c7047d2244d1b7094bbe9ddd997c62638031b..56acac59703c17ece509614dd81e496a2a60dfa1 100644 (file)
@@ -24,7 +24,7 @@ static bool build_v3_fingerprint(chunk_t *encoding, va_list args)
 {
        hasher_t *hasher;
        chunk_t n, e;
-       
+
        if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
                                                  KEY_PART_RSA_PUB_EXP, &e, KEY_PART_END))
        {
index 98f5c3356710ff3d1089032be574efca1208c44c..ed37e1d9f6c47d6c99810aea2a81d21da5a623c4 100644 (file)
@@ -41,9 +41,9 @@ static void destroy(private_pgp_plugin_t *this)
                                                        (builder_constructor_t)pgp_public_key_builder);
        lib->creds->remove_builder(lib->creds,
                                                        (builder_constructor_t)pgp_private_key_builder);
-       
+
        lib->encoding->remove_encoder(lib->encoding, pgp_encoder_encode);
-       
+
        free(this);
 }
 
@@ -53,9 +53,9 @@ static void destroy(private_pgp_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_pgp_plugin_t *this = malloc_thing(private_pgp_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
                                                        (builder_constructor_t)pgp_public_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
@@ -64,9 +64,9 @@ plugin_t *plugin_create()
                                                        (builder_constructor_t)pgp_private_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                        (builder_constructor_t)pgp_private_key_builder);
-       
+
        lib->encoding->add_encoder(lib->encoding, pgp_encoder_encode);
-       
+
        return &this->public.plugin;
 }
 
index abb6c0c0b02c6f10c9763b48f5c4b7fe432baef3..0213076f93c304e4b3153b97dc83776bc7861989 100644 (file)
@@ -47,7 +47,7 @@ static public_key_t *parse_public_key(chunk_t blob)
        key_type_t type = KEY_ANY;
 
        parser = asn1_parser_create(pkinfoObjects, blob);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                switch (objectID)
@@ -56,7 +56,7 @@ static public_key_t *parse_public_key(chunk_t blob)
                        {
                                int oid = asn1_parse_algorithmIdentifier(object,
                                                                                parser->get_level(parser)+1, NULL);
-                               
+
                                if (oid == OID_RSA_ENCRYPTION)
                                {
                                        type = KEY_RSA;
@@ -64,7 +64,7 @@ static public_key_t *parse_public_key(chunk_t blob)
                                else if (oid == OID_EC_PUBLICKEY)
                                {
                                        /* we need the whole subjectPublicKeyInfo for EC public keys */
-                                       key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, 
+                                       key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY,
                                                                KEY_ECDSA, BUILD_BLOB_ASN1_DER, blob, BUILD_END);
                                        goto end;
                                }
@@ -85,11 +85,11 @@ static public_key_t *parse_public_key(chunk_t blob)
                                                                                 BUILD_BLOB_ASN1_DER, object, BUILD_END);
                                break;
                }
-       } 
-       
+       }
+
 end:
        parser->destroy(parser);
-       return key; 
+       return key;
 }
 
 /**
@@ -115,9 +115,9 @@ static public_key_t *parse_rsa_public_key(chunk_t blob)
        chunk_t object;
        int objectID;
        bool success = FALSE;
-       
+
        parser = asn1_parser_create(pubkeyObjects, blob);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                switch (objectID)
@@ -184,10 +184,10 @@ static private_key_t *parse_rsa_private_key(chunk_t blob)
        chunk_t object;
        int objectID ;
        bool success = FALSE;
-       
+
        parser = asn1_parser_create(privkeyObjects, blob);
        parser->set_flags(parser, FALSE, TRUE);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                switch (objectID)
@@ -233,9 +233,9 @@ end:
        {
                return NULL;
        }
-       return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, 
+       return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                        BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_RSA_PRIV_EXP, d,
-                       BUILD_RSA_PRIME1, p,  BUILD_RSA_PRIME2, q, BUILD_RSA_EXP1, exp1, 
+                       BUILD_RSA_PRIME1, p,  BUILD_RSA_PRIME2, q, BUILD_RSA_EXP1, exp1,
                        BUILD_RSA_EXP2, exp2, BUILD_RSA_COEFF, coeff, BUILD_END);
 }
 
@@ -259,7 +259,7 @@ struct private_builder_t {
 static public_key_t *build_public(private_builder_t *this)
 {
        public_key_t *key = NULL;
-       
+
        switch (this->type)
        {
                case KEY_ANY:
@@ -281,7 +281,7 @@ static public_key_t *build_public(private_builder_t *this)
 static void add_public(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_BLOB_ASN1_DER:
@@ -303,19 +303,19 @@ static void add_public(private_builder_t *this, builder_part_t part, ...)
 builder_t *pkcs1_public_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_ANY && type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->blob = chunk_empty;
        this->type = type;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_public;
        this->public.build = (void*(*)(builder_t *this))build_public;
-       
+
        return &this->public;
 }
 
@@ -325,7 +325,7 @@ builder_t *pkcs1_public_key_builder(key_type_t type)
 static private_key_t *build_private(private_builder_t *this)
 {
        private_key_t *key;
-       
+
        key = parse_rsa_private_key(this->blob);
        free(this);
        return key;
@@ -337,7 +337,7 @@ static private_key_t *build_private(private_builder_t *this)
 static void add_private(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_BLOB_ASN1_DER:
@@ -359,19 +359,19 @@ static void add_private(private_builder_t *this, builder_part_t part, ...)
 builder_t *pkcs1_private_key_builder(key_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != KEY_RSA)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->blob = chunk_empty;
        this->type = type;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add_private;
        this->public.build = (void*(*)(builder_t *this))build_private;
-       
+
        return &this->public;
 }
 
index b7c13defbdd6cacc4ce27617311ab78ae7dfa721..0a8da815ad46456bbaf2dded104848774574dad9 100644 (file)
@@ -25,7 +25,7 @@
 bool build_pub(chunk_t *encoding, va_list args)
 {
        chunk_t n, e;
-       
+
        if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
                                                  KEY_PART_RSA_PUB_EXP, &e, KEY_PART_END))
        {
@@ -43,7 +43,7 @@ bool build_pub(chunk_t *encoding, va_list args)
 bool build_pub_info(chunk_t *encoding, va_list args)
 {
        chunk_t n, e;
-       
+
        if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
                                                  KEY_PART_RSA_PUB_EXP, &e, KEY_PART_END))
        {
@@ -64,7 +64,7 @@ bool build_pub_info(chunk_t *encoding, va_list args)
 bool build_priv(chunk_t *encoding, va_list args)
 {
        chunk_t n, e, d, p, q, exp1, exp2, coeff;
-       
+
        if (key_encoding_args(args, KEY_PART_RSA_MODULUS, &n,
                                        KEY_PART_RSA_PUB_EXP, &e, KEY_PART_RSA_PRIV_EXP, &d,
                                        KEY_PART_RSA_PRIME1, &p, KEY_PART_RSA_PRIME2, &q,
@@ -92,7 +92,7 @@ bool build_priv(chunk_t *encoding, va_list args)
 static bool hash_pubkey(chunk_t pubkey, chunk_t *hash)
 {
        hasher_t *hasher;
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (hasher == NULL)
        {
@@ -112,7 +112,7 @@ static bool hash_pubkey(chunk_t pubkey, chunk_t *hash)
 static bool build_info_sha1(chunk_t *encoding, va_list args)
 {
        chunk_t pubkey;
-       
+
        if (build_pub_info(&pubkey, args))
        {
                return hash_pubkey(pubkey, encoding);
@@ -126,7 +126,7 @@ static bool build_info_sha1(chunk_t *encoding, va_list args)
 static bool build_sha1(chunk_t *encoding, va_list args)
 {
        chunk_t pubkey;
-       
+
        if (build_pub(&pubkey, args))
        {
                return hash_pubkey(pubkey, encoding);
index 5e8cf97d8a2878bc7e4360efacf380d305820eac..d0ca8564bc122ef58d8a62125d91ee37f586f62e 100644 (file)
@@ -41,9 +41,9 @@ static void destroy(private_pkcs1_plugin_t *this)
                                                        (builder_constructor_t)pkcs1_public_key_builder);
        lib->creds->remove_builder(lib->creds,
                                                        (builder_constructor_t)pkcs1_private_key_builder);
-       
+
        lib->encoding->remove_encoder(lib->encoding, pkcs1_encoder_encode);
-       
+
        free(this);
 }
 
@@ -53,18 +53,18 @@ static void destroy(private_pkcs1_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_pkcs1_plugin_t *this = malloc_thing(private_pkcs1_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
                                                        (builder_constructor_t)pkcs1_public_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                        (builder_constructor_t)pkcs1_public_key_builder);
        lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                        (builder_constructor_t)pkcs1_private_key_builder);
-       
+
        lib->encoding->add_encoder(lib->encoding, pkcs1_encoder_encode);
-       
+
        return &this->public.plugin;
 }
 
index 6ca71540ccf4e315ba6147cb835f823e5ad5a117..2162cef5e746fa7b5c9b2e87fa3f1c42551971f4 100644 (file)
@@ -27,7 +27,7 @@ typedef struct plugin_t plugin_t;
  * Interface definition of a plugin.
  */
 struct plugin_t {
-       
+
        /**
      * Destroy a plugin instance.
      */
index 49e643f25608351b6593ae8d6881431353471582..644ac1fd218613a90ab998602def68b44389b037 100644 (file)
@@ -37,12 +37,12 @@ struct private_plugin_loader_t {
         * public functions
         */
        plugin_loader_t public;
-       
+
        /**
         * list of loaded plugins
         */
        linked_list_t *plugins;
-       
+
        /**
         * names of loaded plugins
         */
@@ -59,9 +59,9 @@ static plugin_t* load_plugin(private_plugin_loader_t *this,
        void *handle;
        plugin_t *plugin;
        plugin_constructor_t constructor;
-       
+
        snprintf(file, sizeof(file), "%s/libstrongswan-%s.so", path, name);
-       
+
        if (lib->integrity)
        {
                if (!lib->integrity->check_file(lib->integrity, name, file))
@@ -101,7 +101,7 @@ static plugin_t* load_plugin(private_plugin_loader_t *this,
                return NULL;
        }
        DBG2("plugin '%s': loaded successfully", name);
-       
+
        /* we do not store or free dlopen() handles, leak_detective requires
         * the modules to keep loaded until leak report */
        return plugin;
@@ -115,14 +115,14 @@ static bool load(private_plugin_loader_t *this, char *path, char *list)
        enumerator_t *enumerator;
        char *token;
        bool critical_failed = FALSE;
-       
+
        enumerator = enumerator_create_token(list, " ", " ");
        while (!critical_failed && enumerator->enumerate(enumerator, &token))
        {
                plugin_t *plugin;
                bool critical = FALSE;
                int len;
-               
+
                token = strdup(token);
                len = strlen(token);
                if (token[len-1] == '!')
@@ -158,7 +158,7 @@ static void unload(private_plugin_loader_t *this)
 {
        plugin_t *plugin;
        char *name;
-       
+
        while (this->plugins->remove_first(this->plugins,
                                                                           (void**)&plugin) == SUCCESS)
        {
@@ -176,7 +176,7 @@ static void unload(private_plugin_loader_t *this)
 static enumerator_t* create_plugin_enumerator(private_plugin_loader_t *this)
 {
        return this->names->create_enumerator(this->names);
-}       
+}
 
 /**
  * Implementation of plugin_loader_t.destroy
@@ -194,15 +194,15 @@ static void destroy(private_plugin_loader_t *this)
 plugin_loader_t *plugin_loader_create()
 {
        private_plugin_loader_t *this = malloc_thing(private_plugin_loader_t);
-       
+
        this->public.load = (bool(*)(plugin_loader_t*, char *path, char *prefix))load;
        this->public.unload = (void(*)(plugin_loader_t*))unload;
        this->public.create_plugin_enumerator = (enumerator_t*(*)(plugin_loader_t*))create_plugin_enumerator;
        this->public.destroy = (void(*)(plugin_loader_t*))destroy;
-       
+
        this->plugins = linked_list_create();
        this->names = linked_list_create();
-       
+
        return &this->public;
 }
 
index 3429e922405347895448ff6b5b05bef5ede92591..0967b7900f2a28016060ab1dc455e82498606526 100644 (file)
@@ -28,8 +28,8 @@ typedef struct plugin_loader_t plugin_loader_t;
 /**
  * The plugin_loader loads plugins from a directory and initializes them
  */
-struct plugin_loader_t {       
-       
+struct plugin_loader_t {
+
        /**
         * Load a list of plugins from a directory.
         *
@@ -42,19 +42,19 @@ struct plugin_loader_t {
         * @return                              TRUE if all critical plugins loaded successfully
         */
        bool (*load)(plugin_loader_t *this, char *path, char *list);
-       
+
        /**
         * Unload all loaded plugins.
         */
        void (*unload)(plugin_loader_t *this);
-       
+
        /**
         * Create an enumerator over all loaded plugin names.
         *
         * @return                              enumerator over char*
         */
        enumerator_t* (*create_plugin_enumerator)(plugin_loader_t *this);
-       
+
        /**
         * Unload loaded plugins, destroy plugin_loader instance.
         */
index d35824b26d8d7bc26e594af780bcc5e2519caf9f..2f1fb09f7750f56bd70c4eb37c286ae9d50fda1f 100644 (file)
@@ -28,22 +28,22 @@ struct private_pubkey_cert_t {
         * public functions
         */
        pubkey_cert_t public;
-       
+
        /**
         * wrapped public key
         */
        public_key_t *key;
-       
+
        /**
         * dummy issuer id, ID_ANY
         */
        identification_t *issuer;
-       
+
        /**
         * subject, ID_KEY_ID of the public key
         */
        identification_t *subject;
-       
+
        /**
         * reference count
         */
@@ -84,7 +84,7 @@ static id_match_t has_subject(private_pubkey_cert_t *this,
        {
                key_encoding_type_t type;
                chunk_t fingerprint;
-               
+
                for (type = 0; type < KEY_ENCODING_MAX; type++)
                {
                        if (this->key->get_fingerprint(this->key, type, &fingerprint) &&
@@ -112,7 +112,7 @@ static id_match_t has_issuer(private_pubkey_cert_t *this,
 static bool equals(private_pubkey_cert_t *this, certificate_t *other)
 {
        public_key_t *other_key;
-       
+
        other_key = other->get_public_key(other);
        if (other_key)
        {
@@ -174,7 +174,7 @@ static bool is_newer(certificate_t *this, certificate_t *that)
 static chunk_t get_encoding(private_pubkey_cert_t *this)
 {
        chunk_t encoding;
-       
+
        if (this->key->get_encoding(this->key, KEY_PUB_ASN1_DER, &encoding))
        {
                return encoding;
@@ -212,7 +212,7 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key)
 {
        private_pubkey_cert_t *this = malloc_thing(private_pubkey_cert_t);
        chunk_t fingerprint;
-       
+
        this->public.interface.get_type = (certificate_type_t (*)(certificate_t *this))get_type;
        this->public.interface.get_subject = (identification_t* (*)(certificate_t *this))get_subject;
        this->public.interface.get_issuer = (identification_t* (*)(certificate_t *this))get_issuer;
@@ -226,7 +226,7 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key)
        this->public.interface.equals = (bool (*)(certificate_t*, certificate_t *other))equals;
        this->public.interface.get_ref = (certificate_t* (*)(certificate_t *this))get_ref;
        this->public.interface.destroy = (void (*)(certificate_t *this))destroy;
-       
+
        this->ref = 1;
        this->key = key;
        this->issuer = identification_create_from_encoding(ID_ANY, chunk_empty);
@@ -238,7 +238,7 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key)
        {
                this->subject = identification_create_from_encoding(ID_ANY, chunk_empty);
        }
-       
+
        return &this->public;
 }
 
@@ -259,7 +259,7 @@ struct private_builder_t {
 static pubkey_cert_t *build(private_builder_t *this)
 {
        pubkey_cert_t *key = this->key;
-       
+
        free(this);
        return key;
 }
@@ -273,7 +273,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        {
                public_key_t *key;
                va_list args;
-               
+
                switch (part)
                {
                        case BUILD_BLOB_ASN1_DER:
@@ -313,18 +313,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *pubkey_cert_builder(certificate_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != CERT_TRUSTED_PUBKEY)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->key = NULL;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 92aa14a0d75c6a127d1d476824f33e54110ad7be..2af8c9cd34297522adecd8d3db26ba5e17a92ff7 100644 (file)
@@ -47,7 +47,7 @@ static void destroy(private_pubkey_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_pubkey_plugin_t *this = malloc_thing(private_pubkey_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
 
        lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_TRUSTED_PUBKEY,
index 5f04f1d79f2ca6fa0f0ea63f0511d1e54e29a666..df0a8f5566d8b457390d85cd6b99b9b59a53bbe5 100644 (file)
@@ -47,14 +47,14 @@ static void destroy(private_random_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_random_plugin_t *this = malloc_thing(private_random_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
-       lib->crypto->add_rng(lib->crypto, RNG_STRONG, 
+
+       lib->crypto->add_rng(lib->crypto, RNG_STRONG,
                                                 (rng_constructor_t)random_rng_create);
-       lib->crypto->add_rng(lib->crypto, RNG_TRUE, 
+       lib->crypto->add_rng(lib->crypto, RNG_TRUE,
                                                 (rng_constructor_t)random_rng_create);
-       
+
        return &this->public.plugin;
 }
 
index 8145c7875208b7f703055c68bee5f93527262913..6ce0f71bee0fdd4eee9a1a02fdab11c5279db92e 100644 (file)
@@ -16,7 +16,7 @@
 /**
  * @defgroup random_p random
  * @ingroup plugins
- * 
+ *
  * @defgroup random_plugin random_plugin
  * @{ @ingroup random_p
  */
index 22d21574e21fc4d93022f75e1d792f4e3b6a5b65..34f300296f707fbff9dc372ef41fb8b7c319357e 100644 (file)
@@ -43,12 +43,12 @@ struct private_random_rng_t {
         * Public random_rng_t interface.
         */
        random_rng_t public;
-       
+
        /**
         * random device, depends on quality
         */
        int dev;
-       
+
        /**
         * file we read random bytes from
         */
@@ -63,9 +63,9 @@ static void get_bytes(private_random_rng_t *this, size_t bytes,
 {
        size_t done;
        ssize_t got;
-       
+
        done = 0;
-       
+
        while (done < bytes)
        {
                got = read(this->dev, buffer + done, bytes - done);
@@ -120,7 +120,7 @@ random_rng_t *random_rng_create(rng_quality_t quality)
        {
                this->file = DEV_URANDOM;
        }
-       
+
        this->dev = open(this->file, 0);
        if (this->dev < 0)
        {
index bcb9cb20428464137e38c4f5063c5e6f512ba774..4e6f3afb2935210855c5b60e2f7a36f11748024e 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup random_rng random_rng
  * @{ @ingroup random_p
@@ -29,7 +29,7 @@ typedef struct random_rng_t random_rng_t;
  * rng_t implementation on top of /dev/[u]random
  */
 struct random_rng_t {
-       
+
        /**
         * Implements rng_t.
         */
@@ -38,7 +38,7 @@ struct random_rng_t {
 
 /**
  * Creates an random_rng_t instance.
- * 
+ *
  * @param quality      required quality of randomness
  * @return                     created random_rng_t
  */
index ba3dd9592baf4ff8472a8274c81fb6c167d751ff..38b4b38286bfb392377d270e39e72d5a43cba3da 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2005-2006 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Hochschule fuer Technik Rapperswil
- * 
+ *
  * Ported from Steve Reid's <steve@edmweb.com> implementation
  * "SHA1 in C" found in strongSwan.
  *
@@ -24,7 +24,7 @@
 
 /*
  * ugly macro stuff
- */ 
+ */
 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
 
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -54,7 +54,7 @@ struct private_sha1_hasher_t {
         * Public interface for this hasher.
         */
        sha1_hasher_t public;
-       
+
        /*
         * State of the hasher. Shared with sha1_prf.c, do not change it!!!
         */
@@ -63,7 +63,7 @@ struct private_sha1_hasher_t {
     u_int8_t buffer[64];
 };
 
-/* 
+/*
  * Hash a single 512-bit block. This is the core of the algorithm. *
  */
 static void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
@@ -129,17 +129,17 @@ void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len)
     }
     this->count[1] += (len>>29);
     j = (j >> 3) & 63;
-    if ((j + len) > 63) 
+    if ((j + len) > 63)
     {
         memcpy(&this->buffer[j], data, (i = 64-j));
         SHA1Transform(this->state, this->buffer);
-        for ( ; i + 63 < len; i += 64) 
+        for ( ; i + 63 < len; i += 64)
         {
             SHA1Transform(this->state, &data[i]);
         }
         j = 0;
     }
-    else 
+    else
     {
        i = 0;
     }
@@ -147,8 +147,8 @@ void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len)
 }
 
 
-/* 
- * Add padding and return the message digest. 
+/*
+ * Add padding and return the message digest.
  */
 static void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
 {
@@ -156,20 +156,20 @@ static void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
        u_int8_t finalcount[8];
        u_int8_t c;
 
-    for (i = 0; i < 8; i++) 
+    for (i = 0; i < 8; i++)
     {
         finalcount[i] = (u_int8_t)((this->count[(i >= 4 ? 0 : 1)]
          >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
     }
     c = 0200;
     SHA1Update(this, &c, 1);
-    while ((this->count[0] & 504) != 448) 
+    while ((this->count[0] & 504) != 448)
     {
                c = 0000;
         SHA1Update(this, &c, 1);
     }
     SHA1Update(this, finalcount, 8);  /* Should cause a SHA1Transform() */
-    for (i = 0; i < 20; i++) 
+    for (i = 0; i < 20; i++)
     {
         digest[i] = (u_int8_t)((this->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
     }
@@ -209,15 +209,15 @@ static void allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *h
 {
        SHA1Update(this, chunk.ptr, chunk.len);
        if (hash != NULL)
-       {       
+       {
                hash->ptr = malloc(HASH_SIZE_SHA1);
                hash->len = HASH_SIZE_SHA1;
-               
+
                SHA1Final(this, hash->ptr);
                reset(this);
        }
 }
-       
+
 /**
  * Implementation of hasher_t.get_hash_size.
  */
@@ -250,10 +250,10 @@ sha1_hasher_t *sha1_hasher_create(hash_algorithm_t algo)
        this->public.hasher_interface.get_hash_size = (size_t (*) (hasher_t*))get_hash_size;
        this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
        this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
-       
+
        /* initialize */
        reset(this);
-       
+
        return &(this->public);
 }
 
index b9bfe1c864588bc49dac244614dbd74b4e37654e..7fa6f1bc0aa3a6be89bd0016c39050a245cc579f 100644 (file)
@@ -30,7 +30,7 @@ typedef struct sha1_hasher_t sha1_hasher_t;
  * Implementation of hasher_t interface using the SHA1 algorithm.
  */
 struct sha1_hasher_t {
-       
+
        /**
         * Implements hasher_t interface.
         */
index b9eb62ac5d125741d143b5abd4272256c3973771..a038228dae2e2646d994071765c023401f560960 100644 (file)
@@ -50,14 +50,14 @@ static void destroy(private_sha1_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_sha1_plugin_t *this = malloc_thing(private_sha1_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
                                                        (hasher_constructor_t)sha1_hasher_create);
        lib->crypto->add_prf(lib->crypto, PRF_KEYED_SHA1,
                                                        (prf_constructor_t)sha1_prf_create);
-       
+
        return &this->public.plugin;
 }
 
index 4a5f7c293eec2ab9f07e85af831a1909223d2302..a1e205691478297c6dd64d42834728e7a54c5498 100644 (file)
@@ -29,7 +29,7 @@ struct private_sha1_hasher_t {
         * Public interface for this hasher.
         */
        sha1_hasher_t public;
-       
+
        /*
         * State of the hasher. From sha1_hasher.c, do not change it!
         */
@@ -107,7 +107,7 @@ static void set_key(private_sha1_prf_t *this, chunk_t key)
 {
        int i, rounds;
        u_int32_t *iv = (u_int32_t*)key.ptr;
-       
+
        this->hasher->public.hasher_interface.reset(&this->hasher->public.hasher_interface);
        rounds = min(key.len/sizeof(u_int32_t), sizeof(this->hasher->state));
        for (i = 0; i < rounds; i++)
@@ -142,9 +142,9 @@ sha1_prf_t *sha1_prf_create(pseudo_random_function_t algo)
        this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
        this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
        this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
-       
+
        this->hasher = (private_sha1_hasher_t*)sha1_hasher_create(HASH_SHA1);
-       
+
        return &this->public;
 }
 
index b6cd2f9d0061d83d1ca6f7c2ed5e9d74f96631f4..1ab4cbc2427f47c4b2f914d5e9677df592817639 100644 (file)
@@ -29,7 +29,7 @@ typedef struct sha1_prf_t sha1_prf_t;
  * Implementation of prf_t interface using keyed SHA1 algorithm (used for EAP-AKA).
  */
 struct sha1_prf_t {
-       
+
        /**
         * Implements prf_t interface.
         */
index 645f4d786908343e41e6c7a4d790b77bc556db68..d407fad1bdc09b444625afe720605c454c07f469 100644 (file)
@@ -31,7 +31,7 @@ struct private_sha512_hasher_t {
         * Public interface for this hasher.
         */
        sha2_hasher_t public;
-       
+
        unsigned char   sha_out[128];   /* results are here, bytes 0..47/0..63 */
        u_int64_t       sha_H[8];
        u_int64_t       sha_blocks;
@@ -50,7 +50,7 @@ struct private_sha256_hasher_t {
         * Public interface for this hasher.
         */
        sha2_hasher_t public;
-       
+
        unsigned char   sha_out[64];    /* results are here, bytes 0...31 */
        u_int32_t       sha_H[8];
        u_int64_t       sha_blocks;
@@ -60,7 +60,7 @@ struct private_sha256_hasher_t {
 
 static const u_int32_t sha224_hashInit[8] = {
        0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511,
-       0x64f98fa7, 0xbefa4fa4 
+       0x64f98fa7, 0xbefa4fa4
 };
 
 static const u_int32_t sha256_hashInit[8] = {
@@ -139,7 +139,7 @@ static const u_int64_t sha512_K[80] = {
 /**
  * Single block SHA256 transformation
  */
-static void sha256_transform(private_sha256_hasher_t *ctx, 
+static void sha256_transform(private_sha256_hasher_t *ctx,
                                                         const unsigned char *datap)
 {
        register int    j;
@@ -168,7 +168,7 @@ static void sha256_transform(private_sha256_hasher_t *ctx,
        j = 0;
        do
        {
-               if(j >= 16) 
+               if(j >= 16)
                {
                        Wm2 = W[j - 2];
                        Wm15 = W[j - 15];
@@ -198,7 +198,7 @@ static void sha256_transform(private_sha256_hasher_t *ctx,
 /**
  * Update SHA256 hash
  */
-static void sha256_write(private_sha256_hasher_t *ctx, 
+static void sha256_write(private_sha256_hasher_t *ctx,
                                                 const unsigned char *datap, int length)
 {
        while(length > 0)
@@ -243,7 +243,7 @@ static void sha256_final(private_sha256_hasher_t *ctx)
        {
                sha256_write(ctx, &padByte, 1);
        }
-       
+
        /* write bit length, big endian byte order */
        ctx->sha_out[56] = bitLength >> 56;
        ctx->sha_out[57] = bitLength >> 48;
@@ -254,7 +254,7 @@ static void sha256_final(private_sha256_hasher_t *ctx)
        ctx->sha_out[62] = bitLength >> 8;
        ctx->sha_out[63] = bitLength;
        sha256_transform(ctx, &ctx->sha_out[0]);
-       
+
        /* return results in ctx->sha_out[0...31] */
        datap = &ctx->sha_out[0];
        j = 0;
@@ -283,7 +283,7 @@ static void sha256_final(private_sha256_hasher_t *ctx)
 /**
  * Single block SHA384/SHA512 transformation
  */
-static void sha512_transform(private_sha512_hasher_t *ctx, 
+static void sha512_transform(private_sha512_hasher_t *ctx,
                                                         const unsigned char *datap)
 {
        register int    j;
@@ -343,14 +343,14 @@ static void sha512_transform(private_sha512_hasher_t *ctx,
 /**
  * Update a SHA384/SHA512 hash
  */
-static void sha512_write(private_sha512_hasher_t *ctx, 
+static void sha512_write(private_sha512_hasher_t *ctx,
                                                 const unsigned char *datap, int length)
 {
-       while(length > 0) 
+       while(length > 0)
        {
-               if(!ctx->sha_bufCnt) 
+               if(!ctx->sha_bufCnt)
                {
-                       while(length >= sizeof(ctx->sha_out)) 
+                       while(length >= sizeof(ctx->sha_out))
                        {
                                sha512_transform(ctx, datap);
                                datap += sizeof(ctx->sha_out);
@@ -360,7 +360,7 @@ static void sha512_write(private_sha512_hasher_t *ctx,
                }
                ctx->sha_out[ctx->sha_bufCnt] = *datap++;
                length--;
-               if(++ctx->sha_bufCnt == sizeof(ctx->sha_out)) 
+               if(++ctx->sha_bufCnt == sizeof(ctx->sha_out))
                {
                        sha512_transform(ctx, &ctx->sha_out[0]);
                        ctx->sha_bufCnt = 0;
@@ -385,7 +385,7 @@ static void sha512_final(private_sha512_hasher_t *ctx)
 
        /* pad extra space with zeroes */
        padByte = 0;
-       while(ctx->sha_bufCnt != 112) 
+       while(ctx->sha_bufCnt != 112)
        {
                sha512_write(ctx, &padByte, 1);
        }
@@ -408,7 +408,7 @@ static void sha512_final(private_sha512_hasher_t *ctx)
        ctx->sha_out[126] = bitLength >> 8;
        ctx->sha_out[127] = bitLength;
        sha512_transform(ctx, &ctx->sha_out[0]);
-       
+
        /* return results in ctx->sha_out[0...63] */
        datap = &ctx->sha_out[0];
        j = 0;
@@ -429,7 +429,7 @@ static void sha512_final(private_sha512_hasher_t *ctx)
 /**
  * Implementation of hasher_t.get_hash for SHA224.
  */
-static void get_hash224(private_sha256_hasher_t *this, 
+static void get_hash224(private_sha256_hasher_t *this,
                                                chunk_t chunk, u_int8_t *buffer)
 {
        sha256_write(this, chunk.ptr, chunk.len);
@@ -444,7 +444,7 @@ static void get_hash224(private_sha256_hasher_t *this,
 /**
  * Implementation of hasher_t.get_hash for SHA256.
  */
-static void get_hash256(private_sha256_hasher_t *this, 
+static void get_hash256(private_sha256_hasher_t *this,
                                                chunk_t chunk, u_int8_t *buffer)
 {
        sha256_write(this, chunk.ptr, chunk.len);
@@ -489,11 +489,11 @@ static void get_hash512(private_sha512_hasher_t *this,
 /**
  * Implementation of hasher_t.allocate_hash for SHA224.
  */
-static void allocate_hash224(private_sha256_hasher_t *this, 
+static void allocate_hash224(private_sha256_hasher_t *this,
                                                         chunk_t chunk, chunk_t *hash)
 {
        chunk_t allocated_hash;
-       
+
        sha256_write(this, chunk.ptr, chunk.len);
        if (hash != NULL)
        {
@@ -508,11 +508,11 @@ static void allocate_hash224(private_sha256_hasher_t *this,
 /**
  * Implementation of hasher_t.allocate_hash for SHA256.
  */
-static void allocate_hash256(private_sha256_hasher_t *this, 
+static void allocate_hash256(private_sha256_hasher_t *this,
                                                         chunk_t chunk, chunk_t *hash)
 {
        chunk_t allocated_hash;
-       
+
        sha256_write(this, chunk.ptr, chunk.len);
        if (hash != NULL)
        {
@@ -527,11 +527,11 @@ static void allocate_hash256(private_sha256_hasher_t *this,
 /**
  * Implementation of hasher_t.allocate_hash for SHA384.
  */
-static void allocate_hash384(private_sha512_hasher_t *this, 
+static void allocate_hash384(private_sha512_hasher_t *this,
                                                         chunk_t chunk, chunk_t *hash)
 {
        chunk_t allocated_hash;
-       
+
        sha512_write(this, chunk.ptr, chunk.len);
        if (hash != NULL)
        {
@@ -546,11 +546,11 @@ static void allocate_hash384(private_sha512_hasher_t *this,
 /**
  * Implementation of hasher_t.allocate_hash for SHA512.
  */
-static void allocate_hash512(private_sha512_hasher_t *this, 
+static void allocate_hash512(private_sha512_hasher_t *this,
                                                         chunk_t chunk, chunk_t *hash)
 {
        chunk_t allocated_hash;
-       
+
        sha512_write(this, chunk.ptr, chunk.len);
        if (hash != NULL)
        {
@@ -577,7 +577,7 @@ static size_t get_hash_size256(private_sha256_hasher_t *this)
 {
        return HASH_SIZE_SHA256;
 }
-       
+
 /**
  * Implementation of hasher_t.get_hash_size for SHA384.
  */
@@ -585,7 +585,7 @@ static size_t get_hash_size384(private_sha512_hasher_t *this)
 {
        return HASH_SIZE_SHA384;
 }
-       
+
 /**
  * Implementation of hasher_t.get_hash_size for SHA512.
  */
@@ -650,7 +650,7 @@ static void destroy(sha2_hasher_t *this)
 sha2_hasher_t *sha2_hasher_create(hash_algorithm_t algorithm)
 {
        sha2_hasher_t *this;
-       
+
        switch (algorithm)
        {
                case HASH_SHA224:
@@ -686,9 +686,9 @@ sha2_hasher_t *sha2_hasher_create(hash_algorithm_t algorithm)
                        return NULL;
        }
        this->hasher_interface.destroy = (void(*)(hasher_t*))destroy;
-       
+
        /* initialize */
        this->hasher_interface.reset(&this->hasher_interface);
-       
+
        return this;
 }
index 11f4fac261a9fd5ec7c897a365dfc13326ec4c46..ed57ae0bd70d7b192da43ff623b9f93a9acaba81 100644 (file)
@@ -32,7 +32,7 @@ typedef struct sha2_hasher_t sha2_hasher_t;
  * the SHA hash algorithm.
  */
 struct sha2_hasher_t {
-       
+
        /**
         * Generic hasher_t interface for this hasher.
         */
@@ -41,7 +41,7 @@ struct sha2_hasher_t {
 
 /**
  * Creates a new sha2_hasher_t.
- * 
+ *
  * @param      algorithm       HASH_SHA256, HASH_SHA384 or HASH_SHA512
  * @return                             sha2_hasher_t object, NULL if not supported
  */
index 0743f7b1a50f5a5eb0dce717808c4313be11e0fe..90f7cec776b93043dcbbe155cb136225bbee744e 100644 (file)
@@ -47,9 +47,9 @@ static void destroy(private_sha2_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_sha2_plugin_t *this = malloc_thing(private_sha2_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->crypto->add_hasher(lib->crypto, HASH_SHA224,
                                                        (hasher_constructor_t)sha2_hasher_create);
        lib->crypto->add_hasher(lib->crypto, HASH_SHA256,
@@ -58,7 +58,7 @@ plugin_t *plugin_create()
                                                        (hasher_constructor_t)sha2_hasher_create);
        lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
                                                        (hasher_constructor_t)sha2_hasher_create);
-       
+
        return &this->public.plugin;
 }
 
index 6e4951f2d7ad2fe9687367355bc9af73f146af3e..4e18de1c2418ed22ce3673c0b93d3db0c9110851 100644 (file)
@@ -32,12 +32,12 @@ struct private_sqlite_database_t {
         * public functions
         */
        sqlite_database_t public;
-       
+
        /**
         * sqlite database connection
         */
        sqlite3 *db;
-       
+
        /**
         * mutex used to lock execute()
         */
@@ -220,12 +220,12 @@ static enumerator_t* query(private_sqlite_database_t *this, char *sql, ...)
        va_list args;
        sqlite_enumerator_t *enumerator = NULL;
        int i;
-       
+
 #if SQLITE_VERSION_NUMBER < 3005000
        /* sqlite connections prior to 3.5 may be used by a single thread only, */
        this->mutex->lock(this->mutex);
 #endif
-       
+
        va_start(args, sql);
        stmt = run(this, sql, &args);
        if (stmt)
@@ -254,7 +254,7 @@ static int execute(private_sqlite_database_t *this, int *rowid, char *sql, ...)
        sqlite3_stmt *stmt;
        int affected = -1;
        va_list args;
-       
+
        /* we need a lock to get our rowid/changes correctly */
        this->mutex->lock(this->mutex);
        va_start(args, sql);
@@ -316,7 +316,7 @@ sqlite_database_t *sqlite_database_create(char *uri)
 {
        char *file;
        private_sqlite_database_t *this;
-       
+
        /**
         * parse sqlite:///path/to/file.db uri
         */
@@ -325,16 +325,16 @@ sqlite_database_t *sqlite_database_create(char *uri)
                return NULL;
        }
        file = uri + 9;
-       
+
        this = malloc_thing(private_sqlite_database_t);
-       
+
        this->public.db.query = (enumerator_t* (*)(database_t *this, char *sql, ...))query;
        this->public.db.execute = (int (*)(database_t *this, int *rowid, char *sql, ...))execute;
        this->public.db.get_driver = (db_driver_t(*)(database_t*))get_driver;
        this->public.db.destroy = (void(*)(database_t*))destroy;
-       
+
        this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
-       
+
        if (sqlite3_open(file, &this->db) != SQLITE_OK)
        {
                DBG1("opening SQLite database '%s' failed: %s",
@@ -342,9 +342,9 @@ sqlite_database_t *sqlite_database_create(char *uri)
                destroy(this);
                return NULL;
        }
-       
+
        sqlite3_busy_handler(this->db, (void*)busy_handler, this);
-       
+
        return &this->public;
 }
 
index bedf91e0f04138c820db92dbcd5c1d22d14d2730..955402bf941d8d92cda40b112ff7170058ba7826 100644 (file)
@@ -47,9 +47,9 @@ static void destroy(private_sqlite_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_sqlite_plugin_t *this = malloc_thing(private_sqlite_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        lib->db->add_database(lib->db,
                                                  (database_constructor_t)sqlite_database_create);
 
index 63bbb12618b6f1cfba3c45d262c22f2897682f98..a4e06180ade2e9bbc1e8ef017e99dc9fd720725d 100644 (file)
@@ -30,7 +30,7 @@ crypter_test_vector_t blowfish1 = {
 };
 
 /**
- * Test vector by Chilkat Software 
+ * Test vector by Chilkat Software
  * (www.chilkatsoft.com/p/php_blowfish.asp)
  */
 crypter_test_vector_t blowfish2 = {
index 8502df7ad94225705f00405f0801f9302bb3c02a..4dc1cc174876915dfcf53b1c52656dee9f8839e8 100644 (file)
@@ -33,7 +33,7 @@ monobit_t monobit_all = {
 static bool test_monobit(monobit_t *param, chunk_t data)
 {
        int i, j, bits = 0;
-       
+
        for (i = 0; i < data.len; i++)
        {
                for (j = 0; j < 8; j++)
@@ -87,15 +87,15 @@ static bool test_poker(poker_t *param, chunk_t data)
 {
        int i, counter[16];
        double sum = 0.0;
-       
+
        memset(counter, 0, sizeof(counter));
-       
+
        for (i = 0; i < data.len; i++)
        {
                counter[data.ptr[i] & 0x0F]++;
                counter[(data.ptr[i] & 0xF0) >> 4]++;
        }
-       
+
        for (i = 0; i < countof(counter); i++)
        {
                sum += (counter[i] * counter[i]) / 5000.0 * 16.0;
@@ -145,10 +145,10 @@ runs_t runs_all = {
 static bool test_runs(runs_t *param, chunk_t data)
 {
        int i, j, zero_runs[7], one_runs[7], zero = 0, one = 0, longrun = 0;
-       
+
        memset(one_runs, 0, sizeof(zero_runs));
        memset(zero_runs, 0, sizeof(one_runs));
-       
+
        for (i = 0; i < data.len; i++)
        {
                for (j = 0; j < 8; j++)
@@ -189,7 +189,7 @@ static bool test_runs(runs_t *param, chunk_t data)
                        }
                }
        }
-       
+
        DBG2("  Runs: zero: %d/%d/%d/%d/%d/%d, one: %d/%d/%d/%d/%d/%d, "
                 "longruns: %d",
                 zero_runs[1], zero_runs[2], zero_runs[3],
@@ -197,12 +197,12 @@ static bool test_runs(runs_t *param, chunk_t data)
                 one_runs[1], one_runs[2], one_runs[3],
                 one_runs[4], one_runs[5], one_runs[6],
                 longrun);
-       
+
        if (longrun)
        {
                return FALSE;
        }
-       
+
        for (i = 1; i < countof(zero_runs); i++)
        {
                if (zero_runs[i] <= param->lower[i] ||
index b96dc0c9a7de22ce6396d4d2951f072348535c99..7ad8c3c737712fbc4cc337e6c2f59e0911a08f2f 100644 (file)
@@ -108,9 +108,9 @@ plugin_t *plugin_create()
 {
        private_test_vectors_plugin_t *this = malloc_thing(private_test_vectors_plugin_t);
        int i;
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
+
        for (i = 0; i < countof(crypter); i++)
        {
                lib->crypto->add_test_vector(lib->crypto,
@@ -136,7 +136,7 @@ plugin_t *plugin_create()
                lib->crypto->add_test_vector(lib->crypto,
                                                                         RANDOM_NUMBER_GENERATOR, rng[i]);
        }
-       
+
        return &this->public.plugin;
 }
 
index 17f6949b271f529867652d72dc35ad5e635be186..97dca31234cc5bd69df3801b295633d458c18ba6 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2007 Andreas Steffen, Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@ struct ietfAttr_t {
 
        /**
         * Compares two ietfAttributes
-        *      
+        *
         * return -1 if this is earlier in the alphabet than other
         * return  0 if this equals other
         * return +1 if this is later in the alphabet than other
@@ -64,7 +64,7 @@ struct ietfAttr_t {
 
        /**
         * Destroys the ietfAttr_t object.
-        * 
+        *
         * @param this                  ietfAttr_t to destroy
         */
        void (*destroy) (ietfAttr_t *this);
@@ -86,7 +86,7 @@ static int ietfAttr_compare(const ietfAttr_t *this ,const ietfAttr_t *other)
        {
                return 1;
        }
-       
+
     cmp_len = this->value.len - other->value.len;
     len = (cmp_len < 0)? this->value.len : other->value.len;
     cmp_value = memcmp(this->value.ptr, other->value.ptr, len);
@@ -271,7 +271,7 @@ void ietfAttr_list_create_from_string(char *msg, linked_list_t *list)
                if (group.len > 0)
                {
                        ietfAttr_t *attr = ietfAttr_create(IETF_ATTRIBUTE_STRING, group);
-               
+
                        ietfAttr_add(list, attr);
                }
        }
@@ -378,7 +378,7 @@ chunk_t ietfAttr_list_encode(linked_list_t *list)
                ietfAttribute = asn1_simple_object(type, attr->value);
 
                /* copy ietfAttribute into ietfAttributes chunk */
-               memcpy(pos, ietfAttribute.ptr, ietfAttribute.len); 
+               memcpy(pos, ietfAttribute.ptr, ietfAttribute.len);
                pos += ietfAttribute.len;
                free(ietfAttribute.ptr);
        }
index 5807a899e4c2c4ae43377ede96dc37877ae5ff0e..124468baca4b1f67e9a31feb4d43b41457189821 100644 (file)
@@ -31,7 +31,7 @@
  *
  * @param list_a       first alphabetically-sorted list
  * @param list_b       second alphabetically-sorted list
- * @return                     TRUE if equal   
+ * @return                     TRUE if equal
  */
 bool ietfAttr_list_equals(linked_list_t *list_a, linked_list_t *list_b);
 
@@ -39,7 +39,7 @@ bool ietfAttr_list_equals(linked_list_t *list_a, linked_list_t *list_b);
  * @brief Lists a linked list of ietfAttr_t objects
  *
  * @param list         alphabetically-sorted linked list of attributes
- * @param out          output file     
+ * @param out          output file
  */
 void ietfAttr_list_list(linked_list_t *list, FILE *out);
 
index 1dfe1b80d6858694d68419727b530da715077102..ebd6d8331ec9a29ca62583fd8dbd333279ff27cc 100644 (file)
@@ -40,112 +40,112 @@ typedef struct private_x509_ac_t private_x509_ac_t;
  * private data of x509_ac_t object
  */
 struct private_x509_ac_t {
-       
+
        /**
         * public functions
         */
        x509_ac_t public;
-       
+
        /**
         * X.509 attribute certificate encoding in ASN.1 DER format
         */
        chunk_t encoding;
-       
+
        /**
         * X.509 attribute certificate body over which signature is computed
         */
        chunk_t certificateInfo;
-       
+
        /**
         * Version of the X.509 attribute certificate
         */
        u_int version;
-       
+
        /**
         * Serial number of the X.509 attribute certificate
         */
        chunk_t serialNumber;
-       
+
        /**
         * ID representing the issuer of the holder certificate
         */
        identification_t *holderIssuer;
-       
+
        /**
         * Serial number of the holder certificate
         */
        chunk_t holderSerial;
-       
+
        /**
         * ID representing the holder
         */
        identification_t *entityName;
-       
+
        /**
         * ID representing the attribute certificate issuer
         */
        identification_t *issuerName;
-       
+
        /**
         * Start time of certificate validity
         */
        time_t notBefore;
-       
+
        /**
         * End time of certificate validity
         */
        time_t notAfter;
-       
+
        /**
         * List of charging attributes
         */
        linked_list_t *charging;
-       
+
        /**
         * List of groub attributes
         */
        linked_list_t *groups;
-       
+
        /**
         * Authority Key Identifier
         */
        chunk_t authKeyIdentifier;
-       
+
        /**
         * Authority Key Serial Number
         */
        chunk_t authKeySerialNumber;
-       
+
        /**
         * No revocation information available
         */
        bool noRevAvail;
-       
+
        /**
         * Signature algorithm
         */
        int algorithm;
-       
+
        /**
         * Signature
         */
        chunk_t signature;
-       
+
        /**
         * Holder certificate
         */
        certificate_t *holderCert;
-       
+
        /**
         * Signer certificate
         */
        certificate_t *signerCert;
-       
+
        /**
        * Signer private key;
        */
        private_key_t *signerKey;
-       
+
        /**
         * reference count
         */
@@ -573,7 +573,7 @@ static chunk_t build_authorityKeyIdentifier(private_x509_ac_t *this)
        identification_t *issuer;
        public_key_t *public;
        x509_t *x509;
-       
+
        x509 = (x509_t*)this->signerCert;
        issuer = this->signerCert->get_issuer(this->signerCert);
        public = this->signerCert->get_public_key(this->signerCert);
@@ -733,7 +733,7 @@ static bool issued_by(private_x509_ac_t *this, certificate_t *issuer)
        signature_scheme_t scheme;
        bool valid;
        x509_t *x509 = (x509_t*)issuer;
-       
+
        /* check if issuer is an X.509 AA certificate */
        if (issuer->get_type(issuer) != CERT_X509)
        {
@@ -743,22 +743,22 @@ static bool issued_by(private_x509_ac_t *this, certificate_t *issuer)
        {
                return FALSE;
        }
-       
+
        /* get the public key of the issuer */
        key = issuer->get_public_key(issuer);
-       
+
        /* compare keyIdentifiers if available, otherwise use DNs */
        if (this->authKeyIdentifier.ptr && key)
        {
                chunk_t fingerprint;
-               
+
                if (!key->get_fingerprint(key, KEY_ID_PUBKEY_SHA1, &fingerprint) ||
                        !chunk_equals(fingerprint, this->authKeyIdentifier))
                {
                        return FALSE;
                }
        }
-       else 
+       else
        {
                if (!this->issuerName->equals(this->issuerName,
                                                                          issuer->get_subject(issuer)))
@@ -766,10 +766,10 @@ static bool issued_by(private_x509_ac_t *this, certificate_t *issuer)
                        return FALSE;
                }
        }
-       
+
        /* determine signature scheme */
        scheme = signature_scheme_from_oid(this->algorithm);
-       
+
        if (scheme == SIGN_UNKNOWN || key == NULL)
        {
                return FALSE;
@@ -803,7 +803,7 @@ static bool get_validity(private_x509_ac_t *this, time_t *when,
                                                 time_t *not_before, time_t *not_after)
 {
        time_t t;
-       
+
        if (when)
        {
                t = *when;
@@ -841,7 +841,7 @@ static bool is_newer(private_x509_ac_t *this, ac_t *that)
                        &that_update, FALSE, new ? "replaced":"retained");
        return new;
 }
-       
+
 /**
  * Implementation of certificate_t.get_encoding.
  */
@@ -857,14 +857,14 @@ static bool equals(private_x509_ac_t *this, certificate_t *other)
 {
        chunk_t encoding;
        bool equal;
-       
+
        if ((certificate_t*)this == other)
        {
                return TRUE;
        }
        if (other->equals == (void*)equals)
        {       /* skip allocation if we have the same implementation */
-               return chunk_equals(this->encoding, ((private_x509_ac_t*)other)->encoding); 
+               return chunk_equals(this->encoding, ((private_x509_ac_t*)other)->encoding);
        }
        encoding = other->get_encoding(other);
        equal = chunk_equals(this->encoding, encoding);
@@ -901,7 +901,7 @@ static void destroy(private_x509_ac_t *this)
 static private_x509_ac_t *create_empty(void)
 {
        private_x509_ac_t *this = malloc_thing(private_x509_ac_t);
-       
+
        /* public functions */
        this->public.interface.get_serial = (chunk_t (*)(ac_t*))get_serial;
        this->public.interface.get_holderSerial = (chunk_t (*)(ac_t*))get_holderSerial;
@@ -972,9 +972,9 @@ struct private_builder_t {
 static private_x509_ac_t* build(private_builder_t *this)
 {
        private_x509_ac_t *ac = this->ac;
-       
+
        free(this);
-       
+
        /* synthesis if encoding does not exist */
        if (ac && ac->encoding.ptr == NULL)
        {
@@ -1062,18 +1062,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *x509_ac_builder(certificate_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != CERT_X509_AC)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->ac = create_empty();
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 65527523aa1ce9f2b4484501840c6b8d59706c1e..9d6e2be87443f0b3040b9fa9fa952cd96eb316b6 100644 (file)
@@ -64,17 +64,17 @@ struct private_x509_cert_t {
         * Public interface for this certificate.
         */
        x509_cert_t public;
-       
+
        /**
         * X.509 certificate encoding in ASN.1 DER format
         */
        chunk_t encoding;
-       
+
        /**
         * SHA1 hash of the DER encoding of this X.509 certificate
         */
        chunk_t encoding_hash;
-       
+
        /**
         * X.509 certificate body over which signature is computed
         */
@@ -84,87 +84,87 @@ struct private_x509_cert_t {
         * Version of the X.509 certificate
         */
        u_int version;
-       
+
        /**
         * Serial number of the X.509 certificate
         */
        chunk_t serialNumber;
-       
+
        /**
         * ID representing the certificate issuer
         */
        identification_t *issuer;
-       
+
        /**
         * Start time of certificate validity
         */
        time_t notBefore;
-       
+
        /**
         * End time of certificate validity
         */
        time_t notAfter;
-       
+
        /**
         * ID representing the certificate subject
         */
        identification_t *subject;
-       
+
        /**
         * List of subjectAltNames as identification_t
         */
        linked_list_t *subjectAltNames;
-       
+
        /**
         * List of crlDistributionPoints as allocated char*
         */
        linked_list_t *crl_uris;
-       
+
        /**
         * List ocspAccessLocations as identification_t
         */
        linked_list_t *ocsp_uris;
-       
+
        /**
         * certificates embedded public key
         */
        public_key_t *public_key;
-       
+
        /**
         * Subject Key Identifier
         */
        chunk_t subjectKeyID;
-       
+
        /**
         * Authority Key Identifier
         */
        chunk_t authKeyIdentifier;
-       
+
        /**
         * Authority Key Serial Number
         */
        chunk_t authKeySerialNumber;
-       
+
        /**
         * x509 constraints and other flags
         */
        x509_flag_t flags;
-       
+
        /**
         * Signature algorithm
         */
        int algorithm;
-       
+
        /**
         * Signature
         */
        chunk_t signature;
-       
+
        /**
         * Certificate parsed from blob/file?
         */
        bool parsed;
-       
+
        /**
         * reference count
         */
@@ -177,7 +177,7 @@ static u_char ASN1_sAN_oid_buf[] = {
 static const chunk_t ASN1_subjectAltName_oid = chunk_from_buf(ASN1_sAN_oid_buf);
 
 /**
- * ASN.1 definition of a basicConstraints extension 
+ * ASN.1 definition of a basicConstraints extension
  */
 static const asn1Object_t basicConstraintsObjects[] = {
        { 0, "basicConstraints",        ASN1_SEQUENCE,  ASN1_NONE                       }, /*  0 */
@@ -215,7 +215,7 @@ static bool parse_basicConstraints(chunk_t blob, int level0)
 }
 
 /**
- * ASN.1 definition of otherName 
+ * ASN.1 definition of otherName
  */
 static const asn1Object_t otherNameObjects[] = {
        {0, "type-id",  ASN1_OID,                       ASN1_BODY       }, /* 0 */
@@ -261,14 +261,14 @@ static bool parse_otherName(chunk_t blob, int level0)
                }
        }
        success = parser->success(parser);
-       
+
 end:
        parser->destroy(parser);
        return success;
 }
 
 /**
- * ASN.1 definition of generalName 
+ * ASN.1 definition of generalName
  */
 static const asn1Object_t generalNameObjects[] = {
        { 0, "otherName",               ASN1_CONTEXT_C_0,  ASN1_OPT|ASN1_BODY   }, /*  0 */
@@ -309,16 +309,16 @@ static identification_t *parse_generalName(chunk_t blob, int level0)
        asn1_parser_t *parser;
        chunk_t object;
        int objectID ;
-       
+
        identification_t *gn = NULL;
-       
+
        parser = asn1_parser_create(generalNameObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                id_type_t id_type = ID_ANY;
-               
+
                switch (objectID)
                {
                        case GN_OBJ_RFC822_NAME:
@@ -355,14 +355,14 @@ static identification_t *parse_generalName(chunk_t blob, int level0)
                        goto end;
                }
        }
-       
+
 end:
        parser->destroy(parser);
        return gn;
 }
 
 /**
- * ASN.1 definition of generalNames 
+ * ASN.1 definition of generalNames
  */
 static const asn1Object_t generalNamesObjects[] = {
        { 0, "generalNames",    ASN1_SEQUENCE,  ASN1_LOOP }, /* 0 */
@@ -380,18 +380,18 @@ void x509_parse_generalNames(chunk_t blob, int level0, bool implicit, linked_lis
        asn1_parser_t *parser;
        chunk_t object;
        int objectID;
-       
+
        parser = asn1_parser_create(generalNamesObjects, blob);
        parser->set_top_level(parser, level0);
        parser->set_flags(parser, implicit, FALSE);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                if (objectID == GENERAL_NAMES_GN)
                {
                        identification_t *gn = parse_generalName(object,
                                                                                        parser->get_level(parser)+1);
-                       
+
                        if (gn)
                        {
                                list->insert_last(list, (void *)gn);
@@ -402,7 +402,7 @@ void x509_parse_generalNames(chunk_t blob, int level0, bool implicit, linked_lis
 }
 
 /**
- * ASN.1 definition of a authorityKeyIdentifier extension 
+ * ASN.1 definition of a authorityKeyIdentifier extension
  */
 static const asn1Object_t authKeyIdentifierObjects[] = {
        { 0, "authorityKeyIdentifier",          ASN1_SEQUENCE,          ASN1_NONE                       }, /* 0 */
@@ -428,15 +428,15 @@ chunk_t x509_parse_authorityKeyIdentifier(chunk_t blob, int level0,
        chunk_t object;
        int objectID;
        chunk_t authKeyIdentifier = chunk_empty;
-       
+
        *authKeySerialNumber = chunk_empty;
-       
+
        parser = asn1_parser_create(authKeyIdentifierObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
-               switch (objectID) 
+               switch (objectID)
                {
                        case AUTH_KEY_ID_KEY_ID:
                                authKeyIdentifier = chunk_clone(object);
@@ -456,7 +456,7 @@ chunk_t x509_parse_authorityKeyIdentifier(chunk_t blob, int level0,
 }
 
 /**
- * ASN.1 definition of a authorityInfoAccess extension 
+ * ASN.1 definition of a authorityInfoAccess extension
  */
 static const asn1Object_t authInfoAccessObjects[] = {
        { 0, "authorityInfoAccess",     ASN1_SEQUENCE,  ASN1_LOOP }, /* 0 */
@@ -479,13 +479,13 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
        chunk_t object;
        int objectID;
        int accessMethod = OID_UNKNOWN;
-       
+
        parser = asn1_parser_create(authInfoAccessObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
-               switch (objectID) 
+               switch (objectID)
                {
                        case AUTH_INFO_ACCESS_METHOD:
                                accessMethod = asn1_known_oid(object);
@@ -499,7 +499,7 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
                                                {
                                                        identification_t *id;
                                                        char *uri;
-                                                       
+
                                                        id = parse_generalName(object,
                                                                                        parser->get_level(parser)+1);
                                                        if (id == NULL)
@@ -526,7 +526,7 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
                                break;
                }
        }
-       
+
 end:
        parser->destroy(parser);
 }
@@ -551,13 +551,13 @@ static bool parse_extendedKeyUsage(chunk_t blob, int level0)
        chunk_t object;
        int objectID;
        bool ocsp_signing = FALSE;
-       
+
        parser = asn1_parser_create(extendedKeyUsageObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
-               if (objectID == EXT_KEY_USAGE_PURPOSE_ID && 
+               if (objectID == EXT_KEY_USAGE_PURPOSE_ID &&
                        asn1_known_oid(object) == OID_OCSP_SIGNING)
                {
                        ocsp_signing = TRUE;
@@ -598,24 +598,24 @@ static void parse_crlDistributionPoints(chunk_t blob, int level0,
        chunk_t object;
        int objectID;
        linked_list_t *list = linked_list_create();
-       
+
        parser = asn1_parser_create(crlDistributionPointsObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                if (objectID == CRL_DIST_POINTS_FULLNAME)
                {
                        identification_t *id;
-                       
+
                        /* append extracted generalNames to existing chained list */
                        x509_parse_generalNames(object, parser->get_level(parser)+1,
                                                                        TRUE, list);
-       
+
                        while (list->remove_last(list, (void**)&id) == SUCCESS)
                        {
                                char *uri;
-                               
+
                                if (asprintf(&uri, "%Y", id) > 0)
                                {
                                        this->crl_uris->insert_last(this->crl_uris, uri);
@@ -687,13 +687,13 @@ static bool parse_certificate(private_x509_cert_t *this)
        int sig_alg  = OID_UNKNOWN;
        bool success = FALSE;
        bool critical;
-       
+
        parser = asn1_parser_create(certObjects, this->encoding);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                u_int level = parser->get_level(parser)+1;
-               
+
                switch (objectID)
                {
                        case X509_OBJ_TBS_CERTIFICATE:
@@ -780,7 +780,7 @@ static bool parse_certificate(private_x509_cert_t *this)
                                        case OID_NS_CA_REVOCATION_URL:
                                        case OID_NS_CA_POLICY_URL:
                                        case OID_NS_COMMENT:
-                                               if (!asn1_parse_simple_object(&object, ASN1_IA5STRING, 
+                                               if (!asn1_parse_simple_object(&object, ASN1_IA5STRING,
                                                                                        level, oid_names[extn_oid].name))
                                                {
                                                        goto end;
@@ -807,7 +807,7 @@ static bool parse_certificate(private_x509_cert_t *this)
                }
        }
        success = parser->success(parser);
-       
+
 end:
        parser->destroy(parser);
        return success;
@@ -845,7 +845,7 @@ static id_match_t has_subject(private_x509_cert_t *this, identification_t *subje
        identification_t *current;
        enumerator_t *enumerator;
        id_match_t match, best;
-       
+
        if (this->encoding_hash.ptr && subject->get_type(subject) == ID_KEY_ID)
        {
                if (chunk_equals(this->encoding_hash, subject->get_encoding(subject)))
@@ -853,7 +853,7 @@ static id_match_t has_subject(private_x509_cert_t *this, identification_t *subje
                        return ID_MATCH_PERFECT;
                }
        }
-       
+
        best = this->subject->matches(this->subject, subject);
        enumerator = this->subjectAltNames->create_enumerator(this->subjectAltNames);
        while (enumerator->enumerate(enumerator, &current))
@@ -886,7 +886,7 @@ static bool issued_by(private_x509_cert_t *this, certificate_t *issuer)
        signature_scheme_t scheme;
        bool valid;
        x509_t *x509 = (x509_t*)issuer;
-       
+
        if (&this->public.interface.interface == issuer)
        {
                if (this->flags & X509_SELF_SIGNED)
@@ -959,7 +959,7 @@ static bool get_validity(private_x509_cert_t *this, time_t *when,
                                                 time_t *not_before, time_t *not_after)
 {
        time_t t;
-       
+
        if (when)
        {
                t = *when;
@@ -986,7 +986,7 @@ static bool is_newer(certificate_t *this, certificate_t *that)
 {
        time_t this_update, that_update, now = time(NULL);
        bool new;
-       
+
        this->get_validity(this, &now, &this_update, NULL);
        that->get_validity(that, &now, &that_update, NULL);
        new = this_update > that_update;
@@ -995,7 +995,7 @@ static bool is_newer(certificate_t *this, certificate_t *that)
                                &that_update, FALSE, new ? "replaced":"retained");
        return new;
 }
-       
+
 /**
  * Implementation of certificate_t.get_encoding.
  */
@@ -1011,7 +1011,7 @@ static bool equals(private_x509_cert_t *this, certificate_t *other)
 {
        chunk_t encoding;
        bool equal;
-       
+
        if (this == (private_x509_cert_t*)other)
        {
                return TRUE;
@@ -1022,7 +1022,7 @@ static bool equals(private_x509_cert_t *this, certificate_t *other)
        }
        if (other->equals == (void*)equals)
        {       /* skip allocation if we have the same implementation */
-               return chunk_equals(this->encoding, ((private_x509_cert_t*)other)->encoding); 
+               return chunk_equals(this->encoding, ((private_x509_cert_t*)other)->encoding);
        }
        encoding = other->get_encoding(other);
        equal = chunk_equals(this->encoding, encoding);
@@ -1103,7 +1103,7 @@ static void destroy(private_x509_cert_t *this)
 static private_x509_cert_t* create_empty(void)
 {
        private_x509_cert_t *this = malloc_thing(private_x509_cert_t);
-       
+
        this->public.interface.interface.get_type = (certificate_type_t (*) (certificate_t*))get_type;
        this->public.interface.interface.get_subject = (identification_t* (*) (certificate_t*))get_subject;
        this->public.interface.interface.get_issuer = (identification_t* (*) (certificate_t*))get_issuer;
@@ -1123,12 +1123,12 @@ static private_x509_cert_t* create_empty(void)
        this->public.interface.create_subjectAltName_enumerator = (enumerator_t* (*)(x509_t*))create_subjectAltName_enumerator;
        this->public.interface.create_crl_uri_enumerator = (enumerator_t* (*)(x509_t*))create_crl_uri_enumerator;
        this->public.interface.create_ocsp_uri_enumerator = (enumerator_t* (*)(x509_t*))create_ocsp_uri_enumerator;
-       
+
        this->encoding = chunk_empty;
        this->encoding_hash = chunk_empty;
        this->tbsCertificate = chunk_empty;
        this->version = 3;
-       this->serialNumber = chunk_empty;       
+       this->serialNumber = chunk_empty;
        this->notBefore = 0;
        this->notAfter = 0;
        this->public_key = NULL;
@@ -1145,7 +1145,7 @@ static private_x509_cert_t* create_empty(void)
        this->flags = 0;
        this->ref = 1;
        this->parsed = FALSE;
-       
+
        return this;
 }
 
@@ -1156,7 +1156,7 @@ static private_x509_cert_t *create_from_chunk(chunk_t chunk)
 {
        hasher_t *hasher;
        private_x509_cert_t *this = create_empty();
-       
+
        this->encoding = chunk;
        this->parsed = TRUE;
        if (!parse_certificate(this))
@@ -1164,23 +1164,23 @@ static private_x509_cert_t *create_from_chunk(chunk_t chunk)
                destroy(this);
                return NULL;
        }
-       
+
        /* check if the certificate is self-signed */
        if (issued_by(this, &this->public.interface.interface))
        {
                this->flags |= X509_SELF_SIGNED;
        }
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (hasher == NULL)
        {
-               DBG1("  unable to create hash of certificate, SHA1 not supported");     
+               DBG1("  unable to create hash of certificate, SHA1 not supported");
                destroy(this);
-               return NULL;    
+               return NULL;
        }
        hasher->allocate_hash(hasher, this->encoding, &this->encoding_hash);
        hasher->destroy(hasher);
-       
+
        return this;
 }
 
@@ -1213,7 +1213,7 @@ static bool generate(private_builder_t *this)
        chunk_t key_info;
        signature_scheme_t scheme;
        hasher_t *hasher;
-       
+
        subject = this->cert->subject;
        if (this->sign_cert)
        {
@@ -1242,7 +1242,7 @@ static bool generate(private_builder_t *this)
                this->cert->notAfter = this->cert->notBefore + 60 * 60 * 24 * 365;
        }
        this->cert->flags = this->flags;
-       
+
        /* select signature scheme */
        switch (this->sign_key->get_type(this->sign_key))
        {
@@ -1304,8 +1304,8 @@ static bool generate(private_builder_t *this)
        {
                /* TODO: encode subjectAltNames */
        }
-       
-       this->cert->tbsCertificate = asn1_wrap(ASN1_SEQUENCE, "mmmcmcmm", 
+
+       this->cert->tbsCertificate = asn1_wrap(ASN1_SEQUENCE, "mmmcmcmm",
                asn1_simple_object(ASN1_CONTEXT_C_0, ASN1_INTEGER_2),
                asn1_integer("c", this->cert->serialNumber),
                asn1_algorithmIdentifier(this->cert->algorithm),
@@ -1315,8 +1315,8 @@ static bool generate(private_builder_t *this)
                        asn1_from_time(&this->cert->notAfter, ASN1_UTCTIME)),
                subject->get_encoding(subject),
                key_info, extensions);
-       
-       if (!this->sign_key->sign(this->sign_key, scheme, 
+
+       if (!this->sign_key->sign(this->sign_key, scheme,
                                                        this->cert->tbsCertificate, &this->cert->signature))
        {
                return FALSE;
@@ -1325,7 +1325,7 @@ static bool generate(private_builder_t *this)
                                                                this->cert->tbsCertificate,
                                                                asn1_algorithmIdentifier(this->cert->algorithm),
                                                                asn1_bitstring("c", this->cert->signature));
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (!hasher)
        {
@@ -1343,7 +1343,7 @@ static bool generate(private_builder_t *this)
 static private_x509_cert_t *build(private_builder_t *this)
 {
        private_x509_cert_t *cert;
-       
+
        if (this->cert)
        {
                this->cert->flags |= this->flags;
@@ -1370,7 +1370,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        va_list args;
        chunk_t chunk;
        bool handled = TRUE;
-       
+
        va_start(args, part);
        switch (part)
        {
@@ -1401,7 +1401,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
                va_end(args);
                return;
        }
-       
+
        switch (part)
        {
                case BUILD_PUBLIC_KEY:
@@ -1456,14 +1456,14 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *x509_cert_builder(certificate_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != CERT_X509)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->cert = NULL;
        this->flags = 0;
        this->sign_cert = NULL;
@@ -1471,7 +1471,7 @@ builder_t *x509_cert_builder(certificate_type_t type)
        this->digest_alg = HASH_SHA1;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 8df0e2f75f5efce4121191bb21f8244cd00318ce..e826f34f9f0a1e6b76101696122022aa9407d3e4 100644 (file)
@@ -36,12 +36,12 @@ struct revoked_t {
         * serial of the revoked certificate
         */
        chunk_t serial;
-       
+
        /**
         * date of revocation
         */
        time_t date;
-       
+
        /**
         * reason for revocation
         */
@@ -57,7 +57,7 @@ struct private_x509_crl_t {
         * public functions
         */
        x509_crl_t public;
-       
+
        /**
         * X.509 crl encoding in ASN.1 DER format
         */
@@ -72,12 +72,12 @@ struct private_x509_crl_t {
         * Version of the X.509 crl
         */
        u_int version;
-       
+
        /**
         * ID representing the crl issuer
         */
        identification_t *issuer;
-       
+
        /**
         * CRL number
         */
@@ -97,7 +97,7 @@ struct private_x509_crl_t {
         * list of revoked certificates as revoked_t
         */
        linked_list_t *revoked;
-       
+
        /**
         * Authority Key Identifier
         */
@@ -107,17 +107,17 @@ struct private_x509_crl_t {
         * Authority Key Serial Number
         */
        chunk_t authKeySerialNumber;
-       
+
        /**
         * Signature algorithm
         */
        int algorithm;
-       
+
        /**
         * Signature
         */
        chunk_t signature;
-       
+
        /**
         * reference counter
         */
@@ -128,7 +128,7 @@ struct private_x509_crl_t {
  * from x509_cert
  */
 extern chunk_t x509_parse_authorityKeyIdentifier(
-                                                               chunk_t blob, int level0, 
+                                                               chunk_t blob, int level0,
                                                                chunk_t *authKeySerialNumber);
 
 /**
@@ -140,7 +140,7 @@ static const asn1Object_t crlObjects[] = {
        { 2,     "version",                                     ASN1_INTEGER,      ASN1_OPT |
                                                                                                                   ASN1_BODY }, /*  2 */
        { 2,     "end opt",                                     ASN1_EOC,          ASN1_END  }, /*  3 */
-       { 2,     "signature",                           ASN1_EOC,          ASN1_RAW  }, /*  4 */        
+       { 2,     "signature",                           ASN1_EOC,          ASN1_RAW  }, /*  4 */
        { 2,     "issuer",                                      ASN1_SEQUENCE,     ASN1_OBJ  }, /*  5 */
        { 2,     "thisUpdate",                          ASN1_EOC,          ASN1_RAW  }, /*  6 */
        { 2,     "nextUpdate",                          ASN1_EOC,          ASN1_RAW  }, /*  7 */
@@ -348,7 +348,7 @@ static chunk_t get_authKeyIdentifier(private_x509_crl_t *this)
 static enumerator_t* create_enumerator(private_x509_crl_t *this)
 {
        return enumerator_create_filter(
-                                                               this->revoked->create_enumerator(this->revoked), 
+                                                               this->revoked->create_enumerator(this->revoked),
                                                                (void*)filter, NULL, NULL);
 }
 
@@ -390,7 +390,7 @@ static bool issued_by(private_x509_crl_t *this, certificate_t *issuer)
        signature_scheme_t scheme;
        bool valid;
        x509_t *x509 = (x509_t*)issuer;
-       
+
        /* check if issuer is an X.509 CA certificate */
        if (issuer->get_type(issuer) != CERT_X509)
        {
@@ -408,24 +408,24 @@ static bool issued_by(private_x509_crl_t *this, certificate_t *issuer)
        if (this->authKeyIdentifier.ptr && key)
        {
                chunk_t fingerprint;
-               
+
                if (!key->get_fingerprint(key, KEY_ID_PUBKEY_SHA1, &fingerprint) ||
                        !chunk_equals(fingerprint, this->authKeyIdentifier))
                {
                        return FALSE;
                }
        }
-       else 
+       else
        {
                if (!this->issuer->equals(this->issuer, issuer->get_subject(issuer)))
                {
                        return FALSE;
                }
        }
-       
+
        /* determine signature scheme */
        scheme = signature_scheme_from_oid(this->algorithm);
-       
+
        if (scheme == SIGN_UNKNOWN || key == NULL)
        {
                return FALSE;
@@ -459,7 +459,7 @@ static bool get_validity(private_x509_crl_t *this, time_t *when,
                                                 time_t *not_before, time_t *not_after)
 {
        time_t t;
-       
+
        if (when)
        {
                t = *when;
@@ -486,7 +486,7 @@ static bool is_newer(private_x509_crl_t *this, crl_t *that)
 {
        chunk_t that_crlNumber = that->get_serial(that);
        bool new;
-       
+
        /* compare crlNumbers if available - otherwise use thisUpdate */
        if (this->crlNumber.ptr != NULL && that_crlNumber.ptr != NULL)
        {
@@ -495,7 +495,7 @@ static bool is_newer(private_x509_crl_t *this, crl_t *that)
                                &this->crlNumber, new ? "newer":"not newer",
                                &that_crlNumber,  new ? "replaced":"retained");
        }
-       else 
+       else
        {
                certificate_t *this_cert = &this->public.crl.certificate;
                certificate_t *that_cert = &that->certificate;
@@ -511,7 +511,7 @@ static bool is_newer(private_x509_crl_t *this, crl_t *that)
        }
        return new;
 }
-       
+
 /**
  * Implementation of certificate_t.get_encoding.
  */
@@ -527,14 +527,14 @@ static bool equals(private_x509_crl_t *this, certificate_t *other)
 {
        chunk_t encoding;
        bool equal;
-       
+
        if ((certificate_t*)this == other)
        {
                return TRUE;
        }
        if (other->equals == (void*)equals)
        {       /* skip allocation if we have the same implementation */
-               return chunk_equals(this->encoding, ((private_x509_crl_t*)other)->encoding); 
+               return chunk_equals(this->encoding, ((private_x509_crl_t*)other)->encoding);
        }
        encoding = other->get_encoding(other);
        equal = chunk_equals(this->encoding, encoding);
@@ -563,7 +563,7 @@ static void destroy(private_x509_crl_t *this)
 static private_x509_crl_t* create_empty(void)
 {
        private_x509_crl_t *this = malloc_thing(private_x509_crl_t);
-       
+
        this->public.crl.get_serial = (chunk_t (*)(crl_t*))get_serial;
        this->public.crl.get_authKeyIdentifier = (chunk_t (*)(crl_t*))get_authKeyIdentifier;
        this->public.crl.create_enumerator = (enumerator_t* (*)(crl_t*))create_enumerator;
@@ -580,7 +580,7 @@ static private_x509_crl_t* create_empty(void)
        this->public.crl.certificate.equals = (bool (*)(certificate_t*, certificate_t *other))equals;
        this->public.crl.certificate.get_ref = (certificate_t* (*)(certificate_t *this))get_ref;
        this->public.crl.certificate.destroy = (void (*)(certificate_t *this))destroy;
-       
+
        this->encoding = chunk_empty;
        this->tbsCertList = chunk_empty;
        this->issuer = NULL;
@@ -589,7 +589,7 @@ static private_x509_crl_t* create_empty(void)
        this->authKeyIdentifier = chunk_empty;
        this->authKeySerialNumber = chunk_empty;
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -610,7 +610,7 @@ struct private_builder_t {
 static private_x509_crl_t *build(private_builder_t *this)
 {
        private_x509_crl_t *crl = NULL;
-       
+
        if (this->blob.len && this->blob.ptr)
        {
                crl = create_empty();
@@ -631,7 +631,7 @@ static private_x509_crl_t *build(private_builder_t *this)
 static void add(private_builder_t *this, builder_part_t part, ...)
 {
        va_list args;
-       
+
        switch (part)
        {
                case BUILD_BLOB_ASN1_DER:
@@ -653,18 +653,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *x509_crl_builder(certificate_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != CERT_X509_CRL)
        {
                return NULL;
        }
        this = malloc_thing(private_builder_t);
-       
+
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        this->blob = chunk_empty;
-       
+
        return &this->public;
 }
 
index e772b9720f7624bd2b4a0b8e127b3859d3ac065a..76f82a4d41b94568b3a6ca20f16c98655c26d059 100644 (file)
@@ -39,12 +39,12 @@ struct private_x509_ocsp_request_t {
         * public functions
         */
        x509_ocsp_request_t public;
-       
+
        /**
         * CA the candidates belong to
         */
        x509_t *ca;
-       
+
        /**
         * Requestor name, subject of cert used if not set
         */
@@ -54,27 +54,27 @@ struct private_x509_ocsp_request_t {
         * Requestor certificate, included in request
         */
        certificate_t *cert;
-       
+
        /**
         * Requestor private key to sign request
         */
        private_key_t *key;
-       
+
        /**
         * list of certificates to check, x509_t
         */
        linked_list_t *candidates;
-       
+
        /**
         * nonce used in request
         */
        chunk_t nonce;
-       
+
        /**
         * encoded OCSP request
         */
        chunk_t encoding;
-       
+
        /**
         * reference count
         */
@@ -120,7 +120,7 @@ static chunk_t build_requestorName(private_x509_ocsp_request_t *this)
                return asn1_wrap(ASN1_CONTEXT_C_1, "m",
                                        asn1_simple_object(ASN1_CONTEXT_C_4,
                                                this->requestor->get_encoding(this->requestor)));
-       
+
        }
        return chunk_empty;
 }
@@ -151,7 +151,7 @@ static chunk_t build_requestList(private_x509_ocsp_request_t *this)
        certificate_t *cert;
        chunk_t list = chunk_empty;
        public_key_t *public;
-       
+
        cert = (certificate_t*)this->ca;
        public = cert->get_public_key(cert);
        if (public)
@@ -163,17 +163,17 @@ static chunk_t build_requestList(private_x509_ocsp_request_t *this)
                                                                                &issuerKeyHash))
                        {
                                enumerator_t *enumerator;
-                               
+
                                issuer = cert->get_subject(cert);
                                hasher->allocate_hash(hasher, issuer->get_encoding(issuer),
                                                                          &issuerNameHash);
                                hasher->destroy(hasher);
-                               
+
                                enumerator = this->candidates->create_enumerator(this->candidates);
                                while (enumerator->enumerate(enumerator, &x509))
                                {
                                        chunk_t request, serialNumber;
-                                       
+
                                        serialNumber = x509->get_serial(x509);
                                        request = build_Request(this, issuerNameHash, issuerKeyHash,
                                                                                        serialNumber);
@@ -202,7 +202,7 @@ static chunk_t build_requestList(private_x509_ocsp_request_t *this)
 static chunk_t build_nonce(private_x509_ocsp_request_t *this)
 {
        rng_t *rng;
-       
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
        if (rng)
        {
@@ -256,7 +256,7 @@ static chunk_t build_optionalSignature(private_x509_ocsp_request_t *this,
        int oid;
        signature_scheme_t scheme;
        chunk_t certs, signature;
-       
+
        switch (this->key->get_type(this->key))
        {
                /* TODO: use a generic mapping function */
@@ -273,7 +273,7 @@ static chunk_t build_optionalSignature(private_x509_ocsp_request_t *this,
                                 key_type_names, this->key->get_type(this->key));
                        return chunk_empty;
        }
-       
+
        if (!this->key->sign(this->key, scheme, tbsRequest, &signature))
        {
                DBG1("creating OCSP signature failed, skipped");
@@ -286,7 +286,7 @@ static chunk_t build_optionalSignature(private_x509_ocsp_request_t *this,
                                                this->cert->get_encoding(this->cert)));
        }
        return asn1_wrap(ASN1_CONTEXT_C_0, "m",
-                               asn1_wrap(ASN1_SEQUENCE, "cmm", 
+                               asn1_wrap(ASN1_SEQUENCE, "cmm",
                                        asn1_algorithmIdentifier(oid),
                                        asn1_bitstring("m", signature),
                                        certs));
@@ -299,7 +299,7 @@ static chunk_t build_optionalSignature(private_x509_ocsp_request_t *this,
 static chunk_t build_OCSPRequest(private_x509_ocsp_request_t *this)
 {
        chunk_t tbsRequest, optionalSignature = chunk_empty;
-       
+
        tbsRequest = build_tbsRequest(this);
        if (this->key)
        {
@@ -323,7 +323,7 @@ static certificate_type_t get_type(private_x509_ocsp_request_t *this)
 static identification_t* get_subject(private_x509_ocsp_request_t *this)
 {
        certificate_t *ca = (certificate_t*)this->ca;
-       
+
        if (this->requestor)
        {
                return this->requestor;
@@ -341,7 +341,7 @@ static identification_t* get_subject(private_x509_ocsp_request_t *this)
 static identification_t* get_issuer(private_x509_ocsp_request_t *this)
 {
        certificate_t *ca = (certificate_t*)this->ca;
-       
+
        return ca->get_subject(ca);
 }
 
@@ -361,11 +361,11 @@ static id_match_t has_subject(private_x509_ocsp_request_t *this,
                match = current->has_subject(current, subject);
                if (match > best)
                {
-                       best = match;   
+                       best = match;
                }
        }
        enumerator->destroy(enumerator);
-       return best;    
+       return best;
 }
 
 /**
@@ -414,7 +414,7 @@ static bool get_validity(private_x509_ocsp_request_t *this, time_t *when,
        }
        return cert->get_validity(cert, when, not_before, not_after);
 }
-       
+
 /**
  * Implementation of certificate_t.get_encoding.
  */
@@ -430,7 +430,7 @@ static bool equals(private_x509_ocsp_request_t *this, certificate_t *other)
 {
        chunk_t encoding;
        bool equal;
-       
+
        if (this == (private_x509_ocsp_request_t*)other)
        {
                return TRUE;
@@ -441,7 +441,7 @@ static bool equals(private_x509_ocsp_request_t *this, certificate_t *other)
        }
        if (other->equals == (void*)equals)
        {       /* skip allocation if we have the same implementation */
-               return chunk_equals(this->encoding, ((private_x509_ocsp_request_t*)other)->encoding); 
+               return chunk_equals(this->encoding, ((private_x509_ocsp_request_t*)other)->encoding);
        }
        encoding = other->get_encoding(other);
        equal = chunk_equals(this->encoding, encoding);
@@ -482,7 +482,7 @@ static void destroy(private_x509_ocsp_request_t *this)
 static private_x509_ocsp_request_t *create_empty()
 {
        private_x509_ocsp_request_t *this = malloc_thing(private_x509_ocsp_request_t);
-       
+
        this->public.interface.interface.get_type = (certificate_type_t (*)(certificate_t *this))get_type;
        this->public.interface.interface.get_subject = (identification_t* (*)(certificate_t *this))get_subject;
        this->public.interface.interface.get_issuer = (identification_t* (*)(certificate_t *this))get_issuer;
@@ -495,7 +495,7 @@ static private_x509_ocsp_request_t *create_empty()
        this->public.interface.interface.equals = (bool(*)(certificate_t*, certificate_t *other))equals;
        this->public.interface.interface.get_ref = (certificate_t* (*)(certificate_t *this))get_ref;
        this->public.interface.interface.destroy = (void (*)(certificate_t *this))destroy;
-       
+
        this->ca = NULL;
        this->requestor = NULL;
        this->cert = NULL;
@@ -504,7 +504,7 @@ static private_x509_ocsp_request_t *create_empty()
        this->encoding = chunk_empty;
        this->candidates = linked_list_create();
        this->ref = 1;
-       
+
        return this;
 }
 
@@ -525,7 +525,7 @@ struct private_builder_t {
 static x509_ocsp_request_t *build(private_builder_t *this)
 {
        private_x509_ocsp_request_t *req;
-       
+
        req = this->req;
        free(this);
        if (req->ca)
@@ -546,7 +546,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        certificate_t *cert;
        identification_t *subject;
        private_key_t *private;
-       
+
        va_start(args, part);
        switch (part)
        {
@@ -595,18 +595,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *x509_ocsp_request_builder(certificate_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != CERT_X509_OCSP_REQUEST)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->req = create_empty();
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 1472d3d7f5c8cb6b5dfb94b0238617771391f7f4..4e2336a09398635186ab4ec3c1be4c5ad237357d 100644 (file)
@@ -45,42 +45,42 @@ struct private_x509_ocsp_response_t {
         * Public interface for this ocsp object.
         */
        x509_ocsp_response_t public;
-       
+
        /**
         * complete encoded OCSP response
         */
        chunk_t encoding;
-       
+
        /**
         * data for signature verficiation
         */
        chunk_t tbsResponseData;
-       
+
        /**
         * signature algorithm (OID)
         */
        int signatureAlgorithm;
-       
+
        /**
         * signature
         */
        chunk_t signature;
-       
+
        /**
         * name or keyid of the responder
         */
        identification_t *responderId;
-       
+
        /**
         * time of response production
         */
        time_t producedAt;
-       
+
        /**
         * latest nextUpdate in this OCSP response
         */
        time_t usableUntil;
-       
+
        /**
         * list of included certificates
         */
@@ -95,7 +95,7 @@ struct private_x509_ocsp_response_t {
         * Nonce required for ocsp request and response
         */
        chunk_t nonce;
-       
+
        /**
         * reference counter
         */
@@ -167,7 +167,7 @@ static cert_validation_t get_status(private_x509_ocsp_response_t *this,
        single_response_t *response;
        cert_validation_t status = VALIDATION_FAILED;
        certificate_t *issuercert = &issuer->interface;
-       
+
        enumerator = this->responses->create_enumerator(this->responses);
        while (enumerator->enumerate(enumerator, &response))
        {
@@ -175,7 +175,7 @@ static cert_validation_t get_status(private_x509_ocsp_response_t *this,
                identification_t *id;
                key_encoding_type_t type;
                chunk_t hash, fingerprint;
-               
+
                /* check serial first, is cheaper */
                if (!chunk_equals(subject->get_serial(subject), response->serialNumber))
                {
@@ -185,7 +185,7 @@ static cert_validation_t get_status(private_x509_ocsp_response_t *this,
                if (response->issuerKeyHash.ptr)
                {
                        public_key_t *public;
-                       
+
                        public = issuercert->get_public_key(issuercert);
                        if (!public)
                        {
@@ -211,7 +211,7 @@ static cert_validation_t get_status(private_x509_ocsp_response_t *this,
                /* check issuerNameHash, if available */
                else if (response->issuerNameHash.ptr)
                {
-                       hasher = lib->crypto->create_hasher(lib->crypto, 
+                       hasher = lib->crypto->create_hasher(lib->crypto,
                                                        hasher_algorithm_from_oid(response->hashAlgorithm));
                        if (!hasher)
                        {
@@ -235,7 +235,7 @@ static cert_validation_t get_status(private_x509_ocsp_response_t *this,
                *revocation_reason = response->revocationReason;
                *this_update = response->thisUpdate;
                *next_update = response->nextUpdate;
-               
+
                break;
        }
        enumerator->destroy(enumerator);
@@ -312,7 +312,7 @@ static bool parse_singleResponse(private_x509_ocsp_response_t *this,
        bool success = FALSE;
 
        single_response_t *response;
-       
+
        response = malloc_thing(single_response_t);
        response->hashAlgorithm = OID_UNKNOWN;
        response->issuerNameHash = chunk_empty;
@@ -402,14 +402,14 @@ static const asn1Object_t responsesObjects[] = {
 /**
  * Parse all responses
  */
-static bool parse_responses(private_x509_ocsp_response_t *this, 
+static bool parse_responses(private_x509_ocsp_response_t *this,
                                                        chunk_t blob, int level0)
 {
        asn1_parser_t *parser;
        chunk_t object;
        int objectID;
        bool success = FALSE;
-       
+
        parser = asn1_parser_create(responsesObjects, blob);
        parser->set_top_level(parser, level0);
 
@@ -486,7 +486,7 @@ static const asn1Object_t basicResponseObjects[] = {
 /**
  * Parse a basicOCSPResponse
  */
-static bool parse_basicOCSPResponse(private_x509_ocsp_response_t *this, 
+static bool parse_basicOCSPResponse(private_x509_ocsp_response_t *this,
                                                                        chunk_t blob, int level0)
 {
        asn1_parser_t *parser;
@@ -498,7 +498,7 @@ static bool parse_basicOCSPResponse(private_x509_ocsp_response_t *this,
        certificate_t *cert;
        bool success = FALSE;
        bool critical;
-       
+
        parser = asn1_parser_create(basicResponseObjects, blob);
        parser->set_top_level(parser, level0);
 
@@ -691,7 +691,7 @@ static bool issued_by(private_x509_ocsp_response_t *this, certificate_t *issuer)
        signature_scheme_t scheme;
        bool valid;
        x509_t *x509 = (x509_t*)issuer;
-       
+
        if (issuer->get_type(issuer) != CERT_X509)
        {
                return FALSE;
@@ -699,7 +699,7 @@ static bool issued_by(private_x509_ocsp_response_t *this, certificate_t *issuer)
        if (this->responderId->get_type(this->responderId) == ID_KEY_ID)
        {
                chunk_t fingerprint;
-               
+
                key = issuer->get_public_key(issuer);
                if (!key ||
                        !key->get_fingerprint(key, KEY_ID_PUBKEY_SHA1, &fingerprint) ||
@@ -711,7 +711,7 @@ static bool issued_by(private_x509_ocsp_response_t *this, certificate_t *issuer)
                }
                key->destroy(key);
        }
-       else 
+       else
        {
                if (!this->responderId->equals(this->responderId,
                                                                           issuer->get_subject(issuer)))
@@ -791,7 +791,7 @@ static bool is_newer(certificate_t *this, certificate_t *that)
                                &that_update, FALSE, new ? "replaced":"retained");
        return new;
 }
-       
+
 /**
  * Implementation of certificate_t.get_encoding.
  */
@@ -807,7 +807,7 @@ static bool equals(private_x509_ocsp_response_t *this, certificate_t *other)
 {
        chunk_t encoding;
        bool equal;
-       
+
        if (this == (private_x509_ocsp_response_t*)other)
        {
                return TRUE;
@@ -818,7 +818,7 @@ static bool equals(private_x509_ocsp_response_t *this, certificate_t *other)
        }
        if (other->equals == (void*)equals)
        {       /* skip allocation if we have the same implementation */
-               return chunk_equals(this->encoding, ((private_x509_ocsp_response_t*)other)->encoding); 
+               return chunk_equals(this->encoding, ((private_x509_ocsp_response_t*)other)->encoding);
        }
        encoding = other->get_encoding(other);
        equal = chunk_equals(this->encoding, encoding);
@@ -856,9 +856,9 @@ static void destroy(private_x509_ocsp_response_t *this)
 static x509_ocsp_response_t *load(chunk_t data)
 {
        private_x509_ocsp_response_t *this;
-       
+
        this = malloc_thing(private_x509_ocsp_response_t);
-       
+
        this->public.interface.certificate.get_type = (certificate_type_t (*)(certificate_t *this))get_type;
        this->public.interface.certificate.get_subject = (identification_t* (*)(certificate_t *this))get_issuer;
        this->public.interface.certificate.get_issuer = (identification_t* (*)(certificate_t *this))get_issuer;
@@ -874,7 +874,7 @@ static x509_ocsp_response_t *load(chunk_t data)
        this->public.interface.certificate.destroy = (void (*)(certificate_t *this))destroy;
        this->public.interface.get_status = (cert_validation_t(*)(ocsp_response_t*, x509_t *subject, x509_t *issuer, time_t *revocation_time,crl_reason_t *revocation_reason,time_t *this_update, time_t *next_update))get_status;
        this->public.interface.create_cert_enumerator = (enumerator_t*(*)(ocsp_response_t*))create_cert_enumerator;
-       
+
        this->ref = 1;
        this->encoding = data;
        this->tbsResponseData = chunk_empty;
@@ -913,7 +913,7 @@ struct private_builder_t {
 static x509_ocsp_response_t *build(private_builder_t *this)
 {
        x509_ocsp_response_t *res = this->res;
-       
+
        free(this);
        return res;
 }
@@ -927,7 +927,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
        {
                va_list args;
                chunk_t chunk;
-               
+
                switch (part)
                {
                        case BUILD_BLOB_ASN1_DER:
@@ -955,18 +955,18 @@ static void add(private_builder_t *this, builder_part_t part, ...)
 builder_t *x509_ocsp_response_builder(certificate_type_t type)
 {
        private_builder_t *this;
-       
+
        if (type != CERT_X509_OCSP_RESPONSE)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_builder_t);
-       
+
        this->res = NULL;
        this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
        this->public.build = (void*(*)(builder_t *this))build;
-       
+
        return &this->public;
 }
 
index 9ed7f95bd003d02827ddd93d21690db072e779a9..b7e8b5bd310fd5de12e80ec37b8819a2486cb86b 100644 (file)
@@ -59,7 +59,7 @@ static void destroy(private_x509_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_x509_plugin_t *this = malloc_thing(private_x509_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
 
        lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509,
index dd63af005d0a8b5b8ebd5c3f667ce4910e188ed1..b9f03eeac11a7cfddff8615bd798c72a5baca7aa 100644 (file)
@@ -23,7 +23,7 @@ typedef struct private_xcbc_t private_xcbc_t;
 
 /**
  * Private data of a xcbc_t object.
- * 
+ *
  * The variable names are the same as in the RFC.
  */
 struct private_xcbc_t {
@@ -31,42 +31,42 @@ struct private_xcbc_t {
         * Public xcbc_t interface.
         */
        xcbc_t xcbc;
-       
+
        /**
         * Block size, in bytes
         */
        u_int8_t b;
-       
+
        /**
         * crypter using k1
         */
        crypter_t *k1;
-       
+
        /**
         * k2
         */
        u_int8_t *k2;
-       
+
        /**
         * k3
         */
        u_int8_t *k3;
-       
+
        /**
         * E
         */
        u_int8_t *e;
-       
+
        /**
         * remaining, unprocessed bytes in append mode
         */
        u_int8_t *remaining;
-       
+
        /**
         * number of bytes in remaining
         */
        int remaining_bytes;
-       
+
        /**
         * TRUE if we have zero bytes to xcbc in final()
         */
@@ -79,34 +79,34 @@ struct private_xcbc_t {
 static void update(private_xcbc_t *this, chunk_t data)
 {
        chunk_t iv;
-       
+
        if (data.len)
        {
                this->zero = FALSE;
        }
-       
+
        if (this->remaining_bytes + data.len <= this->b)
        {       /* no complete block, just copy into remaining */
                memcpy(this->remaining + this->remaining_bytes, data.ptr, data.len);
                this->remaining_bytes += data.len;
                return;
        }
-       
+
        iv = chunk_alloca(this->b);
        memset(iv.ptr, 0, iv.len);
-       
+
        /* (3) For each block M[i], where i = 1 ... n-1:
         *     XOR M[i] with E[i-1], then encrypt the result with Key K1,
         *     yielding E[i].
         */
-       
+
        /* append data to remaining bytes, process block M[1] */
        memcpy(this->remaining + this->remaining_bytes, data.ptr,
                   this->b - this->remaining_bytes);
        data = chunk_skip(data, this->b - this->remaining_bytes);
        memxor(this->e, this->remaining, this->b);
        this->k1->encrypt(this->k1, chunk_create(this->e, this->b), iv, NULL);
-       
+
        /* process blocks M[2] ... M[n-1] */
        while (data.len > this->b)
        {
@@ -115,7 +115,7 @@ static void update(private_xcbc_t *this, chunk_t data)
                memxor(this->e, this->remaining, this->b);
                this->k1->encrypt(this->k1, chunk_create(this->e, this->b), iv, NULL);
        }
-       
+
        /* store remaining bytes of block M[n] */
        memcpy(this->remaining, data.ptr, data.len);
        this->remaining_bytes = data.len;
@@ -127,10 +127,10 @@ static void update(private_xcbc_t *this, chunk_t data)
 static void final(private_xcbc_t *this, u_int8_t *out)
 {
        chunk_t iv;
-       
+
        iv = chunk_alloca(this->b);
        memset(iv.ptr, 0, iv.len);
-       
+
        /* (4) For block M[n]: */
        if (this->remaining_bytes == this->b && !this->zero)
        {
@@ -165,9 +165,9 @@ static void final(private_xcbc_t *this, u_int8_t *out)
                memxor(this->e, this->k3, this->b);
                this->k1->encrypt(this->k1, chunk_create(this->e, this->b), iv, NULL);
        }
-       
+
        memcpy(out, this->e, this->b);
-       
+
        /* (2) Define E[0] = 0x00000000000000000000000000000000 */
        memset(this->e, 0, this->b);
        this->remaining_bytes = 0;
@@ -181,13 +181,13 @@ static void get_mac(private_xcbc_t *this, chunk_t data, u_int8_t *out)
 {
        /* update E, do not process last block */
        update(this, data);
-       
+
        if (out)
        {       /* if not in append mode, process last block and output result */
                final(this, out);
        }
 }
-       
+
 /**
  * Implementation of xcbc_t.get_block_size.
  */
@@ -225,8 +225,8 @@ static void set_key(private_xcbc_t *this, chunk_t key)
        k1 = chunk_alloca(this->b);
        iv = chunk_alloca(this->b);
        memset(iv.ptr, 0, iv.len);
-       
-       /* 
+
+       /*
         * (1) Derive 3 128-bit keys (K1, K2 and K3) from the 128-bit secret
      *     key K, as follows:
      *     K1 = 0x01010101010101010101010101010101 encrypted with Key K
@@ -263,7 +263,7 @@ xcbc_t *xcbc_create(encryption_algorithm_t algo, size_t key_size)
 {
        private_xcbc_t *this;
        crypter_t *crypter;
-       
+
        crypter = lib->crypto->create_crypter(lib->crypto, algo, key_size);
        if (!crypter)
        {
@@ -275,13 +275,13 @@ xcbc_t *xcbc_create(encryption_algorithm_t algo, size_t key_size)
                crypter->destroy(crypter);
                return NULL;
        }
-       
+
        this = malloc_thing(private_xcbc_t);
        this->xcbc.get_mac = (void (*)(xcbc_t *,chunk_t,u_int8_t*))get_mac;
        this->xcbc.get_block_size = (size_t (*)(xcbc_t *))get_block_size;
        this->xcbc.set_key = (void (*)(xcbc_t *,chunk_t))set_key;
        this->xcbc.destroy = (void (*)(xcbc_t *))destroy;
-       
+
        this->b = crypter->get_block_size(crypter);
        this->k1 = crypter;
        this->k2 = malloc(this->b);
index a334c675b1c228a988fbcf0d0e2bc5dd526df822..f28e0b8e090e933db2721127285ed333683f1a5a 100644 (file)
@@ -32,34 +32,34 @@ typedef struct xcbc_t xcbc_t;
  * described in RFC3566.
  */
 struct xcbc_t {
-       
+
        /**
         * Generate message authentication code.
-        * 
+        *
         * If buffer is NULL, no result is given back. A next call will
-        * append the data to already supplied data. If buffer is not NULL, 
+        * append the data to already supplied data. If buffer is not NULL,
         * the mac of all apended data is calculated, returned and the
         * state of the xcbc_t is reseted.
-        * 
+        *
         * @param data          chunk of data to authenticate
         * @param buffer        pointer where the generated bytes will be written
         */
        void (*get_mac) (xcbc_t *this, chunk_t data, u_int8_t *buffer);
-       
+
        /**
         * Get the block size of this xcbc_t object.
-        * 
+        *
         * @return                      block size in bytes
         */
        size_t (*get_block_size) (xcbc_t *this);
-       
+
        /**
         * Set the key for this xcbc_t object.
-        * 
+        *
         * @param key           key to set
         */
        void (*set_key) (xcbc_t *this, chunk_t key);
-       
+
        /**
         * Destroys a xcbc_t object.
         */
@@ -68,7 +68,7 @@ struct xcbc_t {
 
 /**
  * Creates a new xcbc_t object.
- * 
+ *
  * @param algo                 underlying crypto algorithm
  * @param key_size             key size to use, if required for algorithm
  * @return                             xcbc_t object, NULL if not supported
index 25f59c650cd698507028646bda8784edff7cf065..3eb7f09271d86a5ceebd58ec511301e44269e7c3 100644 (file)
@@ -50,12 +50,12 @@ static void destroy(private_xcbc_plugin_t *this)
 plugin_t *plugin_create()
 {
        private_xcbc_plugin_t *this = malloc_thing(private_xcbc_plugin_t);
-       
+
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-       
-       lib->crypto->add_prf(lib->crypto, PRF_AES128_XCBC, 
+
+       lib->crypto->add_prf(lib->crypto, PRF_AES128_XCBC,
                                                 (prf_constructor_t)xcbc_prf_create);
-       lib->crypto->add_signer(lib->crypto, AUTH_AES_XCBC_96, 
+       lib->crypto->add_signer(lib->crypto, AUTH_AES_XCBC_96,
                                                        (signer_constructor_t)xcbc_signer_create);
 
        return &this->public.plugin;
index a90f2d44f44e46357beb1f1d1d247f5af2bac1e9..2459dc61663b5f09f44105adecc0ebb9efd7a787 100644 (file)
@@ -27,8 +27,8 @@ struct private_xcbc_prf_t {
        /**
         * Public xcbc_prf_t interface.
         */
-       xcbc_prf_t public;      
-       
+       xcbc_prf_t public;
+
        /**
         * xcbc to use for generation.
         */
@@ -100,7 +100,7 @@ xcbc_prf_t *xcbc_prf_create(pseudo_random_function_t algo)
 {
        private_xcbc_prf_t *this;
        xcbc_t *xcbc;
-       
+
        switch (algo)
        {
                case PRF_AES128_XCBC:
@@ -113,17 +113,17 @@ xcbc_prf_t *xcbc_prf_create(pseudo_random_function_t algo)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_xcbc_prf_t);
        this->xcbc = xcbc;
-       
+
        this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
        this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
        this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size;
        this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
        this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
        this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
-       
+
        return &this->public;
 }
 
index bbf5b972aece47bb98aa57446d27cb8d3400879c..d2db9af41f31253c7017e75afced8fb1c7ca3fec 100644 (file)
@@ -27,12 +27,12 @@ typedef struct xcbc_prf_t xcbc_prf_t;
 
 /**
  * Implementation of prf_t on CBC block cipher using XCBC, RFC3664/RFC4434.
- * 
+ *
  * This simply wraps a xcbc_t in a prf_t. More a question of
  * interface matching.
  */
 struct xcbc_prf_t {
-       
+
        /**
         * Generic prf_t interface for this xcbc_prf_t class.
         */
@@ -41,7 +41,7 @@ struct xcbc_prf_t {
 
 /**
  * Creates a new xcbc_prf_t object.
- * 
+ *
  * @param algo         algorithm to implement
  * @return                     xcbc_prf_t object, NULL if hash not supported
  */
index b394bb25184f9e0f74e59a78b92fdd9fc079c9a8..1c98d39d7e32755d9ab505567c2631c5a3c28e80 100644 (file)
@@ -29,12 +29,12 @@ struct private_xcbc_signer_t {
         * Public interface of xcbc_signer_t.
         */
        xcbc_signer_t public;
-       
+
        /**
         * Assigned xcbc function.
         */
        xcbc_t *xcbc;
-       
+
        /**
         * Block size (truncation of XCBC MAC)
         */
@@ -54,7 +54,7 @@ static void get_signature(private_xcbc_signer_t *this,
        else
        {
                u_int8_t mac[this->xcbc->get_block_size(this->xcbc)];
-               
+
                this->xcbc->get_mac(this->xcbc, data, mac);
                memcpy(buffer, mac, this->block_size);
        }
@@ -73,12 +73,12 @@ static void allocate_signature (private_xcbc_signer_t *this,
        else
        {
                u_int8_t mac[this->xcbc->get_block_size(this->xcbc)];
-               
+
                this->xcbc->get_mac(this->xcbc, data, mac);
 
                chunk->ptr = malloc(this->block_size);
                chunk->len = this->block_size;
-               
+
                memcpy(chunk->ptr, mac, this->block_size);
        }
 }
@@ -90,12 +90,12 @@ static bool verify_signature(private_xcbc_signer_t *this,
                                                         chunk_t data, chunk_t signature)
 {
        u_int8_t mac[this->xcbc->get_block_size(this->xcbc)];
-       
+
        if (signature.len != this->block_size)
        {
                return FALSE;
        }
-       
+
        this->xcbc->get_mac(this->xcbc, data, mac);
        return memeq(signature.ptr, mac, this->block_size);
 }
@@ -142,7 +142,7 @@ xcbc_signer_t *xcbc_signer_create(integrity_algorithm_t algo)
        private_xcbc_signer_t *this;
        size_t trunc;
        xcbc_t *xcbc;
-       
+
        switch (algo)
        {
                case AUTH_AES_XCBC_96:
@@ -156,11 +156,11 @@ xcbc_signer_t *xcbc_signer_create(integrity_algorithm_t algo)
        {
                return NULL;
        }
-       
+
        this = malloc_thing(private_xcbc_signer_t);
        this->xcbc = xcbc;
        this->block_size = min(trunc, xcbc->get_block_size(xcbc));
-       
+
        /* interface functions */
        this->public.signer_interface.get_signature = (void (*) (signer_t*, chunk_t, u_int8_t*))get_signature;
        this->public.signer_interface.allocate_signature = (void (*) (signer_t*, chunk_t, chunk_t*))allocate_signature;
@@ -169,7 +169,7 @@ xcbc_signer_t *xcbc_signer_create(integrity_algorithm_t algo)
        this->public.signer_interface.get_block_size = (size_t (*) (signer_t*))get_block_size;
        this->public.signer_interface.set_key = (void (*) (signer_t*,chunk_t))set_key;
        this->public.signer_interface.destroy = (void (*) (signer_t*))destroy;
-       
+
        return &this->public;
 }
 
index dc00873920e1a82fa01cecf265532b30182dfe83..181cfe2991a3d8a0afc9941f74d36387a7ee0021 100644 (file)
@@ -29,7 +29,7 @@ typedef struct xcbc_signer_t xcbc_signer_t;
  * Implementation of signer_t based on CBC symmetric cypher. XCBC, RFC3566.
  */
 struct xcbc_signer_t {
-       
+
        /**
         * generic signer_t interface for this signer
         */
index 692ad9cf8da69d3ee8ebf2a2e5ba89bd425f9263..c0294ee519a7cc1785c18ae3f8013147b658e8b4 100644 (file)
@@ -44,17 +44,17 @@ struct private_printf_hook_t {
  * struct with information about a registered handler
  */
 struct printf_hook_handler_t {
-       
+
        /**
         * callback function
         */
        printf_hook_function_t hook;
-       
+
        /**
         * number of arguments
         */
        int numargs;
-       
+
        /**
         * types of the arguments
         */
@@ -89,11 +89,11 @@ static int custom_print(FILE *stream, const struct printf_info *info,
        char buf[PRINTF_BUF_LEN];
        printf_hook_spec_t spec;
        printf_hook_handler_t *handler = printf_hooks[SPEC_TO_INDEX(info->spec)];
-       
+
        spec.hash = info->alt;
        spec.minus = info->left;
        spec.width = info->width;
-       
+
        written = handler->hook(buf, sizeof(buf), &spec, args);
        if (written > 0)
        {
@@ -110,7 +110,7 @@ static int custom_arginfo(const struct printf_info *info, size_t n, int *argtype
 {
        int i;
        printf_hook_handler_t *handler = printf_hooks[SPEC_TO_INDEX(info->spec)];
-       
+
        if (handler->numargs <= n)
        {
                for (i = 0; i < handler->numargs; ++i)
@@ -136,7 +136,7 @@ static int custom_fmt_cb(Vstr_base *base, size_t pos, Vstr_fmt_spec *fmt_spec)
        const void *args[ARGS_MAX];
        printf_hook_spec_t spec;
        printf_hook_handler_t *handler = printf_hooks[SPEC_TO_INDEX(fmt_spec->name[0])];
-       
+
        for (i = 0; i < handler->numargs; i++)
        {
                switch(handler->argtypes[i])
@@ -149,11 +149,11 @@ static int custom_fmt_cb(Vstr_base *base, size_t pos, Vstr_fmt_spec *fmt_spec)
                                break;
                }
        }
-       
+
        spec.hash = fmt_spec->fmt_hash;
        spec.minus = fmt_spec->fmt_minus;
        spec.width = fmt_spec->fmt_field_width;
-       
+
        written = handler->hook(buf, sizeof(buf), &spec, args);
        if (written > 0)
        {
@@ -331,16 +331,16 @@ static void add_handler(private_printf_hook_t *this, char spec,
        printf_hook_handler_t *handler;
        printf_hook_argtype_t argtype;
        va_list args;
-       
+
        if (!IS_VALID_SPEC(spec))
        {
                DBG1("'%c' is not a valid printf hook specifier, not registered!", spec);
                return;
        }
-       
+
        handler = malloc_thing(printf_hook_handler_t);
        handler->hook = hook;
-       
+
        va_start(args, hook);
        while ((argtype = va_arg(args, printf_hook_argtype_t)) != PRINTF_HOOK_ARGTYPE_END)
        {
@@ -354,9 +354,9 @@ static void add_handler(private_printf_hook_t *this, char spec,
                handler->argtypes[i] = argtype;
        }
        va_end(args);
-       
+
        handler->numargs = i + 1;
-       
+
        if (handler->numargs > 0)
        {
 #if defined(HAVE_PRINTF_HOOKS) && !defined(USE_VSTR)
@@ -385,7 +385,7 @@ static void destroy(private_printf_hook_t *this)
 #ifdef USE_VSTR
        Vstr_conf *conf = get_vstr_conf();
 #endif
-       
+
        for (i = 0; i < NUM_HANDLERS; ++i)
        {
                printf_hook_handler_t *handler = printf_hooks[i];
@@ -398,7 +398,7 @@ static void destroy(private_printf_hook_t *this)
                        free(handler);
                }
        }
-       
+
 #ifdef USE_VSTR
        /* freeing the Vstr_conf of the main thread */
        pthread_key_delete(vstr_conf_key);
@@ -414,12 +414,12 @@ static void destroy(private_printf_hook_t *this)
 printf_hook_t *printf_hook_create()
 {
        private_printf_hook_t *this = malloc_thing(private_printf_hook_t);
-       
+
        this->public.add_handler = (void(*)(printf_hook_t*, char, printf_hook_function_t, ...))add_handler;
        this->public.destroy = (void(*)(printf_hook_t*))destroy;
-       
+
        memset(printf_hooks, 0, sizeof(printf_hooks));
-       
+
 #ifdef USE_VSTR
        if (!vstr_init())
        {
@@ -428,7 +428,7 @@ printf_hook_t *printf_hook_create()
                return NULL;
        }
 #endif
-       
+
        return &this->public;
 }
 
index 02c973580fcc2d823d47114ba1b5d697080962ac..9d0203c0272d6b6b7ca6e9dbe53686099fee50ab 100644 (file)
@@ -77,7 +77,7 @@ int vstr_wrapper_vsnprintf(char *str, size_t size, const char *format, va_list a
 
 /**
  * Callback function type for printf hooks.
- * 
+ *
  * @param dst          destination buffer
  * @param len          length of the buffer
  * @param spec         format specifier
@@ -111,12 +111,12 @@ struct printf_hook_spec_t {
         * TRUE if a '#' was used in the format specifier
         */
        int hash;
-       
+
        /**
         * TRUE if a '-' was used in the format specifier
         */
        int minus;
-       
+
        /**
         * The width as given in the format specifier.
         */
@@ -127,7 +127,7 @@ struct printf_hook_spec_t {
  * Printf handler management.
  */
 struct printf_hook_t {
-       
+
        /**
         * Register a printf handler.
         *
@@ -137,7 +137,7 @@ struct printf_hook_t {
         */
        void (*add_handler)(printf_hook_t *this, char spec,
                                                printf_hook_function_t hook, ...);
-       
+
        /**
      * Destroy a printf_hook instance.
      */
index 64ac09299ed63fead6888ff98874c2db7d6c554a..6a3f74140fb06863501c9cf0a0328ae356a84303 100644 (file)
@@ -38,12 +38,12 @@ struct private_settings_t {
         * public functions
         */
        settings_t public;
-       
+
        /**
         * top level section
         */
        section_t *top;
-       
+
        /**
         * allocated file text
         */
@@ -64,7 +64,7 @@ struct section_t {
         * subsections, as section_t
         */
        linked_list_t *sections;
-       
+
        /**
         * key value pairs, as kv_t
         */
@@ -80,7 +80,7 @@ struct kv_t {
         * key string, relative
         */
        char *key;
-       
+
        /**
         * value as string
         */
@@ -95,7 +95,7 @@ static section_t *find_section(section_t *section, char *key, va_list args)
        char name[512], *pos;
        enumerator_t *enumerator;
        section_t *current, *found = NULL;
-       
+
        if (section == NULL)
        {
                return NULL;
@@ -104,7 +104,7 @@ static section_t *find_section(section_t *section, char *key, va_list args)
        {
                return NULL;
        }
-       
+
        pos = strchr(name, '.');
        if (pos)
        {
@@ -134,17 +134,17 @@ static char *find_value(section_t *section, char *key, va_list args)
        enumerator_t *enumerator;
        kv_t *kv;
        section_t *current, *found = NULL;
-       
+
        if (section == NULL)
        {
                return NULL;
        }
-       
+
        if (vsnprintf(name, sizeof(name), key, args) >= sizeof(name))
        {
                return NULL;
        }
-       
+
        pos = strchr(name, '.');
        if (pos)
        {
@@ -188,7 +188,7 @@ static char* get_str(private_settings_t *this, char *key, char *def, ...)
 {
        char *value;
        va_list args;
-       
+
        va_start(args, def);
        value = find_value(this->top, key, args);
        va_end(args);
@@ -206,7 +206,7 @@ static bool get_bool(private_settings_t *this, char *key, bool def, ...)
 {
        char *value;
        va_list args;
-       
+
        va_start(args, def);
        value = find_value(this->top, key, args);
        va_end(args);
@@ -238,7 +238,7 @@ static int get_int(private_settings_t *this, char *key, int def, ...)
        char *value;
        int intval;
        va_list args;
-       
+
        va_start(args, def);
        value = find_value(this->top, key, args);
        va_end(args);
@@ -262,7 +262,7 @@ static u_int32_t get_time(private_settings_t *this, char *key, u_int32_t def, ..
        char *value, *endptr;
        u_int32_t timeval;
        va_list args;
-       
+
        va_start(args, def);
        value = find_value(this->top, key, args);
        va_end(args);
@@ -310,13 +310,13 @@ static enumerator_t* create_section_enumerator(private_settings_t *this,
 {
        section_t *section;
        va_list args;
-       
+
        va_start(args, key);
        section = find_section(this->top, key, args);
        va_end(args);
-       
+
        if (!section)
-       {       
+       {
                return enumerator_create_empty();
        }
        return enumerator_create_filter(
@@ -331,7 +331,7 @@ static void section_destroy(section_t *this)
 {
        this->kv->destroy_function(this->kv, free);
        this->sections->destroy_function(this->sections, (void*)section_destroy);
-       
+
        free(this);
 }
 
@@ -362,7 +362,7 @@ static char parse(char **text, char *skip, char *term, char *br, char **token)
        {
                char *pos = *text;
                int level = 1;
-               
+
                /* find terminator */
                while (*pos)
                {
@@ -417,15 +417,15 @@ static section_t* parse_section(char **text, char *name)
        section_t *sub, *section;
        bool finished = FALSE;
        char *key, *value, *inner;
-       
+
        static int lev = 0;
        lev++;
-       
+
        section = malloc_thing(section_t);
        section->name = name;
        section->sections = linked_list_create();
        section->kv = linked_list_create();
-       
+
        while (!finished)
        {
                switch (parse(text, "\t\n ", "{=#", NULL, &key))
@@ -485,23 +485,23 @@ static void destroy(private_settings_t *this)
 settings_t *settings_create(char *file)
 {
        private_settings_t *this = malloc_thing(private_settings_t);
-       
+
        this->public.get_str = (char*(*)(settings_t*, char *key, char* def, ...))get_str;
        this->public.get_int = (int(*)(settings_t*, char *key, int def, ...))get_int;
        this->public.get_time = (u_int32_t(*)(settings_t*, char *key, u_int32_t def, ...))get_time;
        this->public.get_bool = (bool(*)(settings_t*, char *key, bool def, ...))get_bool;
        this->public.create_section_enumerator = (enumerator_t*(*)(settings_t*,char *section, ...))create_section_enumerator;
        this->public.destroy = (void(*)(settings_t*))destroy;
-       
+
        this->top = NULL;
        this->text = NULL;
-       
+
        if (file)
        {
                FILE *fd;
                int len;
                char *pos;
-       
+
                fd = fopen(file, "r");
                if (fd == NULL)
                {
index 1816787aeb59a22d3920ef4ab4890f7f40f54f74..f483c3d268d7033596f658a73ba71721ce3155cd 100644 (file)
@@ -63,7 +63,7 @@ struct settings_t {
         * @return                      value pointing to internal string
         */
        char* (*get_str)(settings_t *this, char *key, char *def, ...);
-       
+
        /**
         * Get a boolean yes|no, true|false value.
         *
@@ -73,7 +73,7 @@ struct settings_t {
         * @return                      value of the key
         */
        bool (*get_bool)(settings_t *this, char *key, bool def, ...);
-       
+
        /**
         * Get an integer value.
         *
@@ -83,7 +83,7 @@ struct settings_t {
         * @return                      value of the key
         */
        int (*get_int)(settings_t *this, char *key, int def, ...);
-       
+
        /**
         * Get a time value.
         *
@@ -93,7 +93,7 @@ struct settings_t {
         * @return                      value of the key
         */
        u_int32_t (*get_time)(settings_t *this, char *key, u_int32_t def, ...);
-       
+
        /**
         * Create an enumerator over subsection names of a section.
         *
index 2d5ff3d79298b644003993ca3ebe8688bb6d1b57..e128f61507aa79e06b7851addacf24ada5a08790 100644 (file)
@@ -50,9 +50,9 @@ void *clalloc(void * pointer, size_t size)
 {
        void *data;
        data = malloc(size);
-       
+
        memcpy(data, pointer, size);
-       
+
        return (data);
 }
 
@@ -62,7 +62,7 @@ void *clalloc(void * pointer, size_t size)
 void memxor(u_int8_t dst[], u_int8_t src[], size_t n)
 {
        int m, i;
-       
+
        /* byte wise XOR until dst aligned */
        for (i = 0; (uintptr_t)&dst[i] % sizeof(long); i++)
        {
@@ -171,7 +171,7 @@ time_t time_monotonic(timeval_t *tv)
        /* as we use time_monotonic() for condvar operations, we use the
         * monotonic time source only if it is also supported by pthread. */
        timespec_t ts;
-       
+
        if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
        {
                if (tv)
@@ -233,7 +233,7 @@ void nop()
 #include <pthread.h>
 
 /**
- * We use a single mutex for all refcount variables. 
+ * We use a single mutex for all refcount variables.
  */
 static pthread_mutex_t ref_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -253,7 +253,7 @@ void ref_get(refcount_t *ref)
 bool ref_put(refcount_t *ref)
 {
        bool more_refs;
-       
+
        pthread_mutex_lock(&ref_mutex);
        more_refs = --(*ref);
        pthread_mutex_unlock(&ref_mutex);
@@ -274,7 +274,7 @@ int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
        time_t *time = *((time_t**)(args[0]));
        bool utc = *((bool*)(args[1]));;
        struct tm t;
-       
+
        if (time == UNDEFINED_TIME)
        {
                return print_in_hook(dst, len, "--- -- --:--:--%s----",
@@ -303,7 +303,7 @@ int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
        time_t *arg1 = *((time_t**)(args[0]));
        time_t *arg2 = *((time_t**)(args[1]));
        time_t delta = abs(*arg1 - *arg2);
-       
+
        if (delta > 2 * 60 * 60 * 24)
        {
                delta /= 60 * 60 * 24;
@@ -337,7 +337,7 @@ int mem_printf_hook(char *dst, size_t dstlen,
 {
        char *bytes = *((void**)(args[0]));
        int len = *((size_t*)(args[1]));
-       
+
        char buffer[BYTES_PER_LINE * 3];
        char ascii_buffer[BYTES_PER_LINE + 1];
        char *buffer_pos = buffer;
@@ -346,9 +346,9 @@ int mem_printf_hook(char *dst, size_t dstlen,
        int line_start = 0;
        int i = 0;
        int written = 0;
-       
+
        written += print_in_hook(dst, dstlen, "=> %d bytes @ %p", len, bytes);
-       
+
        while (bytes_pos < bytes_roof)
        {
                *buffer_pos++ = hexdig_upper[(*bytes_pos >> 4) & 0xF];
@@ -357,20 +357,20 @@ int mem_printf_hook(char *dst, size_t dstlen,
                ascii_buffer[i++] =
                                (*bytes_pos > 31 && *bytes_pos < 127) ? *bytes_pos : '.';
 
-               if (++bytes_pos == bytes_roof || i == BYTES_PER_LINE) 
+               if (++bytes_pos == bytes_roof || i == BYTES_PER_LINE)
                {
                        int padding = 3 * (BYTES_PER_LINE - i);
-                       
+
                        while (padding--)
                        {
                                *buffer_pos++ = ' ';
                        }
                        *buffer_pos++ = '\0';
                        ascii_buffer[i] = '\0';
-                       
+
                        written += print_in_hook(dst, dstlen, "\n%4d: %s  %s",
                                                                     line_start, buffer, ascii_buffer);
-                       
+
                        buffer_pos = buffer;
                        line_start += BYTES_PER_LINE;
                        i = 0;
index 35008f4550182c33d3415bb9d55fcdd54a70f2d4..71aeb60f7b5829a59de6b12d2f97490668e59891 100644 (file)
@@ -175,57 +175,57 @@ enum status_t {
         * Call succeeded.
         */
        SUCCESS,
-       
+
        /**
         * Call failed.
         */
        FAILED,
-       
+
        /**
         * Out of resources.
         */
        OUT_OF_RES,
-       
+
        /**
         * The suggested operation is already done
         */
        ALREADY_DONE,
-       
+
        /**
         * Not supported.
         */
        NOT_SUPPORTED,
-       
+
        /**
         * One of the arguments is invalid.
         */
        INVALID_ARG,
-       
+
        /**
         * Something could not be found.
         */
        NOT_FOUND,
-       
+
        /**
         * Error while parsing.
         */
        PARSE_ERROR,
-       
+
        /**
         * Error while verifying.
         */
        VERIFY_ERROR,
-       
+
        /**
         * Object in invalid state.
         */
        INVALID_STATE,
-       
+
        /**
         * Destroy object which called method belongs to.
         */
        DESTROY_ME,
-       
+
        /**
         * Another call to the method is required.
         */
@@ -275,10 +275,10 @@ void memxor(u_int8_t dest[], u_int8_t src[], size_t n);
 void *memstr(const void *haystack, const char *needle, size_t n);
 
 /**
- * Creates a directory and all required parent directories. 
+ * Creates a directory and all required parent directories.
  *
  * @param path         path to the new directory
- * @param mode         permissions of the new directory/directories 
+ * @param mode         permissions of the new directory/directories
  * @return                     TRUE on success
  */
 bool mkdir_p(const char *path, mode_t mode);
@@ -340,7 +340,7 @@ void ref_get(refcount_t *ref);
 /**
  * Put back a unused reference.
  *
- * Decrements the reference counter atomic and 
+ * Decrements the reference counter atomic and
  * says if more references available.
  *
  * @param ref  pointer to ref counter
@@ -353,7 +353,7 @@ bool ref_put(refcount_t *ref);
 /**
  * printf hook for time_t.
  *
- * Arguments are: 
+ * Arguments are:
  *    time_t* time, bool utc
  */
 int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
@@ -362,7 +362,7 @@ int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
 /**
  * printf hook for time_t deltas.
  *
- * Arguments are: 
+ * Arguments are:
  *    time_t* begin, time_t* end
  */
 int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
@@ -371,7 +371,7 @@ int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
 /**
  * printf hook for memory areas.
  *
- * Arguments are: 
+ * Arguments are:
  *    u_char *ptr, int len
  */
 int mem_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
index f110521afe0655f2df4c631862eb4464f5276319..99c93d59bfe51463b456324fa5b6cb6b1ec290cc 100644 (file)
@@ -33,17 +33,17 @@ typedef struct private_backtrace_t private_backtrace_t;
  * Private data of an backtrace_t object.
  */
 struct private_backtrace_t {
-       
+
        /**
         * Public backtrace_t interface.
         */
        backtrace_t public;
-       
+
        /**
         * Number of stacks frames obtained in stack_frames
         */
        int frame_count;
-       
+
        /**
         * Recorded stack frames.
         */
@@ -58,7 +58,7 @@ static void log_(private_backtrace_t *this, FILE *file)
 #ifdef HAVE_BACKTRACE
        size_t i;
        char **strings;
-       
+
        strings = backtrace_symbols(this->frames, this->frame_count);
 
        fprintf(file, " dumping %d stack frame addresses:\n", this->frame_count);
@@ -66,14 +66,14 @@ static void log_(private_backtrace_t *this, FILE *file)
        {
 #ifdef HAVE_DLADDR
                Dl_info info;
-               
+
                if (dladdr(this->frames[i], &info))
                {
                        char cmd[1024];
                        FILE *output;
                        char c;
                        void *ptr = this->frames[i];
-                       
+
                        if (strstr(info.dli_fname, ".so"))
                        {
                                ptr = (void*)(this->frames[i] - info.dli_fbase);
@@ -136,7 +136,7 @@ static bool contains_function(private_backtrace_t *this, char *function)
        for (i = 0; i< this->frame_count; i++)
        {
                Dl_info info;
-               
+
                if (dladdr(this->frames[i], &info) && info.dli_sname)
                {
                        if (streq(info.dli_sname, function))
@@ -165,7 +165,7 @@ backtrace_t *backtrace_create(int skip)
        private_backtrace_t *this;
        void *frames[50];
        int frame_count = 0;
-       
+
 #ifdef HAVE_BACKTRACE
        frame_count = backtrace(frames, countof(frames));
 #endif /* HAVE_BACKTRACE */
@@ -173,11 +173,11 @@ backtrace_t *backtrace_create(int skip)
        this = malloc(sizeof(private_backtrace_t) + frame_count * sizeof(void*));
        memcpy(this->frames, frames + skip, frame_count * sizeof(void*));
        this->frame_count = frame_count;
-       
+
        this->public.log = (void(*)(backtrace_t*,FILE*))log_;
        this->public.contains_function = (bool(*)(backtrace_t*, char *function))contains_function;
        this->public.destroy = (void(*)(backtrace_t*))destroy;
-       
+
        return &this->public;
 }
 
index 061d9f35634d16c049bbf23e2d3af3ea5930d3ba..c4d4284d1be452ebd3b5e54b469718ef54a40e08 100644 (file)
@@ -31,12 +31,12 @@ typedef struct backtrace_t backtrace_t;
  * A backtrace registers the frames on the stack during creation.
  */
 struct backtrace_t {
-       
+
        /**
         * Log the backtrace to a FILE stream.
         */
        void (*log)(backtrace_t *this, FILE *file);
-       
+
        /**
         * Check if the backtrace contains a frame in a specific function.
         *
@@ -44,7 +44,7 @@ struct backtrace_t {
         * @return              TRUE if function is in the stack
         */
        bool (*contains_function)(backtrace_t *this, char *function);
-       
+
        /**
         * Destroy a backtrace instance.
         */
index 08522b8d59b4d6ed3bec6c71be63d6fb5c565011..33b51ff42a59c0e682092e954f21751d91328095 100644 (file)
@@ -77,7 +77,7 @@ static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
 {
        struct dirent *entry = readdir(this->dir);
        size_t len, remaining;
-       
+
        if (!entry)
        {
                return FALSE;
@@ -91,7 +91,7 @@ static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
                *relative = entry->d_name;
        }
        if (absolute || st)
-       {       
+       {
                remaining = sizeof(this->full) - (this->full_end - this->full);
                len = snprintf(this->full_end, remaining, "%s", entry->d_name);
                if (len < 0 || len >= remaining)
@@ -124,7 +124,7 @@ enumerator_t* enumerator_create_directory(char *path)
        dir_enum_t *this = malloc_thing(dir_enum_t);
        this->public.enumerate = (void*)enumerate_dir_enum;
        this->public.destroy = (void*)destroy_dir_enum;
-       
+
        if (*path == '\0')
        {
                path = "./";
@@ -143,7 +143,7 @@ enumerator_t* enumerator_create_directory(char *path)
                this->full[len] = '\0';
        }
        this->full_end = &this->full[len];
-       
+
        this->dir = opendir(path);
        if (this->dir == NULL)
        {
@@ -186,7 +186,7 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
 {
        char *pos = NULL, *tmp, *sep, *trim;
        bool last = FALSE;
-       
+
        /* trim leading characters/separators */
        while (*this->pos)
        {
@@ -215,7 +215,7 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
                        break;
                }
        }
-       
+
        switch (*this->pos)
        {
                case '"':
@@ -259,7 +259,7 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
                        break;
                }
        }
-       
+
        /* trim trailing characters/separators */
        pos--;
        while (pos >= *token)
@@ -289,7 +289,7 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
                        break;
                }
        }
-       
+
        if (!last || pos >= *token)
        {
                return TRUE;
@@ -303,14 +303,14 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
 enumerator_t* enumerator_create_token(char *string, char *sep, char *trim)
 {
        token_enum_t *enumerator = malloc_thing(token_enum_t);
-       
+
        enumerator->public.enumerate = (void*)enumerate_token_enum;
        enumerator->public.destroy = (void*)destroy_token_enum;
        enumerator->string = strdup(string);
        enumerator->pos = enumerator->string;
        enumerator->sep = sep;
        enumerator->trim = trim;
-       
+
        return &enumerator->public;
 }
 
@@ -342,9 +342,9 @@ static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
        while (TRUE)
        {
                while (this->inner == NULL)
-               {       
+               {
                        void *outer;
-                       
+
                        if (!this->outer->enumerate(this->outer, &outer))
                        {
                                return FALSE;
@@ -382,7 +382,7 @@ enumerator_t *enumerator_create_nested(enumerator_t *outer,
                                        void *data, void (*destroy_data)(void *data))
 {
        nested_enumerator_t *enumerator = malloc_thing(nested_enumerator_t);
-       
+
        enumerator->public.enumerate = (void*)enumerate_nested;
        enumerator->public.destroy = (void*)destroy_nested;
        enumerator->outer = outer;
@@ -390,7 +390,7 @@ enumerator_t *enumerator_create_nested(enumerator_t *outer,
        enumerator->create_inner = (void*)inner_constructor;
        enumerator->data = data;
        enumerator->destroy_data = destroy_data;
-       
+
        return &enumerator->public;
 }
 
@@ -444,14 +444,14 @@ enumerator_t *enumerator_create_filter(enumerator_t *unfiltered,
                                                                           void *data, void (*destructor)(void *data))
 {
        filter_enumerator_t *this = malloc_thing(filter_enumerator_t);
-       
+
        this->public.enumerate = (void*)enumerate_filter;
        this->public.destroy = (void*)destroy_filter;
        this->unfiltered = unfiltered;
        this->filter = filter;
        this->data = data;
        this->destructor = destructor;
-       
+
        return &this->public;
 }
 
@@ -491,13 +491,13 @@ enumerator_t *enumerator_create_cleaner(enumerator_t *wrapped,
                                                                                void (*cleanup)(void *data), void *data)
 {
        cleaner_enumerator_t *this = malloc_thing(cleaner_enumerator_t);
-       
+
        this->public.enumerate = (void*)enumerate_cleaner;
        this->public.destroy = (void*)destroy_cleaner;
        this->wrapped = wrapped;
        this->cleanup = cleanup;
        this->data = data;
-       
+
        return &this->public;
 }
 
@@ -543,13 +543,13 @@ static bool enumerate_single(single_enumerator_t *this, void **item)
 enumerator_t *enumerator_create_single(void *item, void (*cleanup)(void *item))
 {
        single_enumerator_t *this = malloc_thing(single_enumerator_t);
-       
+
        this->public.enumerate = (void*)enumerate_single;
        this->public.destroy = (void*)destroy_single;
        this->item = item;
        this->cleanup = cleanup;
        this->done = FALSE;
-       
+
        return &this->public;
 }
 
index 4367d08360c0e1854e22a752a391a456f965b74b..e3afcf074b7dd444af344476e0c33f68f332e937 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup enumerator enumerator
  * @{ @ingroup utils
@@ -33,14 +33,14 @@ struct enumerator_t {
        /**
         * Enumerate collection.
         *
-        * The enumerate function takes a variable argument list containing 
+        * The enumerate function takes a variable argument list containing
         * pointers where the enumerated values get written.
         *
         * @param ...   variable list of enumerated items, implementation dependant
         * @return              TRUE if pointers returned
         */
        bool (*enumerate)(enumerator_t *this, ...);
-               
+
        /**
      * Destroy a enumerator instance.
      */
@@ -75,7 +75,7 @@ enumerator_t *enumerator_create_single(void *item, void (*cleanup)(void *item));
        char *rel, *abs;
        struct stat st;
        enumerator_t *e;
-       
+
        e = enumerator_create_directory("/tmp");
        if (e)
        {
@@ -110,7 +110,7 @@ enumerator_t* enumerator_create_token(char *string, char *sep, char *trim);
 
 /**
  * Creates an enumerator which enumerates over enumerated enumerators :-).
- * 
+ *
  * The variable argument list of enumeration values is limit to 5.
  *
  * @param outer                                        outer enumerator
index 6d33d023b6e1c5826448c02ded0eb1817b7183d0..494d165b3bd9f26f36100327bc7278891a02f51c 100644 (file)
@@ -30,12 +30,12 @@ struct pair_t {
         * Key of a hash table item.
         */
        void *key;
-       
+
        /**
         * Value of a hash table item.
         */
        void *value;
-       
+
        /**
         * Cached hash (used in case of a resize).
         */
@@ -48,11 +48,11 @@ struct pair_t {
 pair_t *pair_create(void *key, void *value, u_int hash)
 {
        pair_t *this = malloc_thing(pair_t);
-       
+
        this->key = key;
        this->value = value;
        this->hash = hash;
-       
+
        return this;
 }
 
@@ -67,37 +67,37 @@ struct private_hashtable_t {
         * Public part of hash table.
         */
        hashtable_t public;
-       
+
        /**
-        * The number of items in the hash table. 
+        * The number of items in the hash table.
         */
        u_int count;
-       
+
        /**
         * The current capacity of the hash table (always a power of 2).
         */
        u_int capacity;
-       
+
        /**
-        * The current mask to calculate the row index (capacity - 1). 
+        * The current mask to calculate the row index (capacity - 1).
         */
        u_int mask;
-       
+
        /**
         * The load factor.
         */
        float load_factor;
-       
+
        /**
         * The actual table.
         */
        linked_list_t **table;
-       
+
        /**
         * The hashing function.
         */
        hashtable_hash_t hash;
-       
+
        /**
         * The equality function.
         */
@@ -115,17 +115,17 @@ struct private_enumerator_t {
         * implements enumerator interface
         */
        enumerator_t enumerator;
-       
+
        /**
         * associated hash table
         */
        private_hashtable_t *table;
-       
+
        /**
         * current row index
         */
        u_int row;
-       
+
        /**
         * enumerator for the current row
         */
@@ -166,7 +166,7 @@ static void init_hashtable(private_hashtable_t *this, u_int capacity)
        this->capacity = get_nearest_powerof2(capacity);
        this->mask = this->capacity - 1;
        this->load_factor = 0.75;
-       
+
        this->table = calloc(this->capacity, sizeof(linked_list_t*));
 }
 
@@ -178,14 +178,14 @@ static void rehash(private_hashtable_t *this)
        u_int row;
        u_int old_capacity = this->capacity;
        linked_list_t **old_table = this->table;
-       
+
        if (old_capacity >= MAX_CAPACITY)
        {
                return;
        }
-       
+
        init_hashtable(this, old_capacity << 1);
-       
+
        for (row = 0; row < old_capacity; ++row)
        {
                linked_list_t *list;
@@ -220,7 +220,7 @@ static void *put(private_hashtable_t *this, void *key, void *value)
        void *old_value = NULL;
        u_int hash = this->hash(key);
        u_int row = hash & this->mask;
-       
+
        if ((list = this->table[row]) != NULL)
        {
                pair_t *pair;
@@ -240,30 +240,30 @@ static void *put(private_hashtable_t *this, void *key, void *value)
        {
                list = this->table[row] = linked_list_create();
        }
-       
+
        if (!old_value)
        {
                list->insert_last(list, pair_create(key, value, hash));
                this->count++;
        }
-       
+
        if (this->count >= this->capacity * this->load_factor)
        {
                rehash(this);
        }
-       
+
        return old_value;
 }
-       
+
 /**
- * Implementation of hashtable_t.get  
+ * Implementation of hashtable_t.get
  */
 static void *get(private_hashtable_t *this, void *key)
 {
        void *value = NULL;
        linked_list_t *list;
        u_int row = this->hash(key) & this->mask;
-       
+
        if ((list = this->table[row]) != NULL)
        {
                pair_t *pair;
@@ -273,10 +273,10 @@ static void *get(private_hashtable_t *this, void *key)
                        value = pair->value;
                }
        }
-       
+
        return value;
 }
-       
+
 /**
  * Implementation of hashtable_t.remove
  */
@@ -284,8 +284,8 @@ static void *remove_(private_hashtable_t *this, void *key)
 {
        void *value = NULL;
        linked_list_t *list;
-       u_int row = this->hash(key) & this->mask;       
-       
+       u_int row = this->hash(key) & this->mask;
+
        if ((list = this->table[row]) != NULL)
        {
                pair_t *pair;
@@ -303,10 +303,10 @@ static void *remove_(private_hashtable_t *this, void *key)
                }
                enumerator->destroy(enumerator);
        }
-       
+
        return value;
 }
-       
+
 /**
  * Implementation of hashtable_t.get_count
  */
@@ -325,7 +325,7 @@ static bool enumerate(private_enumerator_t *this, void **key, void **value)
                if (this->current)
                {
                        pair_t *pair;
-                       
+
                        if (this->current->enumerate(this->current, &pair))
                        {
                                if (key)
@@ -344,7 +344,7 @@ static bool enumerate(private_enumerator_t *this, void **key, void **value)
                else
                {
                        linked_list_t *list;
-                       
+
                        if ((list = this->table->table[this->row]) != NULL)
                        {
                                this->current = list->create_enumerator(list);
@@ -374,16 +374,16 @@ static void enumerator_destroy(private_enumerator_t *this)
 static enumerator_t* create_enumerator(private_hashtable_t *this)
 {
        private_enumerator_t *enumerator = malloc_thing(private_enumerator_t);
-       
+
        enumerator->enumerator.enumerate = (void*)enumerate;
        enumerator->enumerator.destroy = (void*)enumerator_destroy;
        enumerator->table = this;
        enumerator->row = 0;
        enumerator->current = NULL;
-       
+
        return &enumerator->enumerator;
 }
-       
+
 /**
  * Implementation of hashtable_t.destroy
  */
@@ -411,12 +411,12 @@ hashtable_t *hashtable_create(hashtable_hash_t hash, hashtable_equals_t equals,
        private_hashtable_t *this = malloc_thing(private_hashtable_t);
 
        this->public.put = (void*(*)(hashtable_t*,void*,void*))put;
-       this->public.get = (void*(*)(hashtable_t*,void*))get; 
+       this->public.get = (void*(*)(hashtable_t*,void*))get;
        this->public.remove = (void*(*)(hashtable_t*,void*))remove_;
        this->public.get_count = (u_int(*)(hashtable_t*))get_count;
        this->public.create_enumerator = (enumerator_t*(*)(hashtable_t*))create_enumerator;
        this->public.destroy = (void(*)(hashtable_t*))destroy;
-       
+
        this->count = 0;
        this->capacity = 0;
        this->mask = 0;
@@ -424,8 +424,8 @@ hashtable_t *hashtable_create(hashtable_hash_t hash, hashtable_equals_t equals,
        this->table = NULL;
        this->hash = hash;
        this->equals = equals;
-       
+
        init_hashtable(this, capacity);
-       
+
        return &this->public;
 }
index cbe51f55774cf86af288bf97c3e053ec55ae4aca..142ea63297afa75bd0b9cda44580fb2503edc15c 100644 (file)
@@ -48,61 +48,61 @@ typedef bool (*hashtable_equals_t)(void *key, void *other_key);
  * General purpose hash table. This hash table is not synchronized.
  */
 struct hashtable_t {
-       
+
        /**
         * Create an enumerator over the hash table key/value pairs.
-        * 
+        *
         * @return                      enumerator over (void *key, void *value)
         */
        enumerator_t *(*create_enumerator) (hashtable_t *this);
-       
+
        /**
         * Adds the given value with the given key to the hash table, if there
         * exists no entry with that key. NULL is returned in this case.
         * Otherwise the existing value is replaced and the function returns the
         * old value.
-        * 
+        *
         * @param key           the key to store
         * @param value         the value to store
         * @return                      NULL if no item was replaced, the old value otherwise
         */
        void *(*put) (hashtable_t *this, void *key, void *value);
-       
+
        /**
         * Returns the value with the given key, if the hash table contains such an
         * entry, otherwise NULL is returned.
-        * 
+        *
         * @param key           the key of the requested value
-        * @return                      the value, NULL if not found  
+        * @return                      the value, NULL if not found
         */
        void *(*get) (hashtable_t *this, void *key);
-       
+
        /**
         * Removes the value with the given key from the hash table and returns the
         * removed value (or NULL if no such value existed).
-        * 
+        *
         * @param key           the key of the value to remove
         * @return                      the removed value, NULL if not found
         */
        void *(*remove) (hashtable_t *this, void *key);
-       
+
        /**
         * Gets the number of items in the hash table.
-        * 
+        *
         * @return                      number of items
         */
        u_int (*get_count) (hashtable_t *this);
-       
+
        /**
         * Destroys a hash table object.
         */
        void (*destroy) (hashtable_t *this);
-       
+
 };
 
 /**
  * Creates an empty hash table object.
- * 
+ *
  * @param hash                 hash function
  * @param equals               equals function
  * @param capacity             initial capacity
index 661bec31527bbdf2eefaac69718280548695dd26..a610b3a4d67060debc3cebb811abcbca42616971 100644 (file)
@@ -38,7 +38,7 @@ struct private_host_t {
         * Public data
         */
        host_t public;
-       
+
        /**
         * low-lewel structure, wich stores the address
         */
@@ -111,7 +111,7 @@ int host_printf_hook(char *dst, size_t dstlen, printf_hook_spec_t *spec,
 {
        private_host_t *this = *((private_host_t**)(args[0]));
        char buffer[INET6_ADDRSTRLEN + 16];
-       
+
        if (this == NULL)
        {
                snprintf(buffer, sizeof(buffer), "(null)");
@@ -126,10 +126,10 @@ int host_printf_hook(char *dst, size_t dstlen, printf_hook_spec_t *spec,
                void *address;
                u_int16_t port;
                int len;
-               
+
                address = &this->address6.sin6_addr;
                port = this->address6.sin6_port;
-               
+
                switch (this->address.sa_family)
                {
                        case AF_INET:
@@ -137,7 +137,7 @@ int host_printf_hook(char *dst, size_t dstlen, printf_hook_spec_t *spec,
                                port = this->address4.sin_port;
                                /* fall */
                        case AF_INET6:
-       
+
                                if (inet_ntop(this->address.sa_family, address,
                                                          buffer, sizeof(buffer)) == NULL)
                                {
@@ -169,7 +169,7 @@ int host_printf_hook(char *dst, size_t dstlen, printf_hook_spec_t *spec,
 static chunk_t get_address(private_host_t *this)
 {
        chunk_t address = chunk_empty;
-       
+
        switch (this->address.sa_family)
        {
                case AF_INET:
@@ -252,7 +252,7 @@ static void set_port(private_host_t *this, u_int16_t port)
 static private_host_t *clone_(private_host_t *this)
 {
        private_host_t *new = malloc_thing(private_host_t);
-       
+
        memcpy(new, this, sizeof(private_host_t));
        return new;
 }
@@ -267,7 +267,7 @@ static bool ip_equals(private_host_t *this, private_host_t *other)
                /* 0.0.0.0 and 0::0 are equal */
                return (is_anyaddr(this) && is_anyaddr(other));
        }
-       
+
        switch (this->address.sa_family)
        {
                case AF_INET:
@@ -292,7 +292,7 @@ static bool ip_equals(private_host_t *this, private_host_t *other)
 static host_diff_t get_differences(host_t *this, host_t *other)
 {
        host_diff_t ret = HOST_DIFF_NONE;
-       
+
        if (!this->ip_equals(this, other))
        {
                ret |= HOST_DIFF_ADDR;
@@ -302,7 +302,7 @@ static host_diff_t get_differences(host_t *this, host_t *other)
        {
                ret |= HOST_DIFF_PORT;
        }
-       
+
        return ret;
 }
 
@@ -315,7 +315,7 @@ static bool equals(private_host_t *this, private_host_t *other)
        {
                return FALSE;
        }
-       
+
        switch (this->address.sa_family)
        {
                case AF_INET:
@@ -346,7 +346,7 @@ static void destroy(private_host_t *this)
 static private_host_t *host_create_empty(void)
 {
        private_host_t *this = malloc_thing(private_host_t);
-       
+
        this->public.get_sockaddr = (sockaddr_t* (*) (host_t*))get_sockaddr;
        this->public.get_sockaddr_len = (socklen_t*(*) (host_t*))get_sockaddr_len;
        this->public.clone = (host_t* (*) (host_t*))clone_;
@@ -359,7 +359,7 @@ static private_host_t *host_create_empty(void)
        this->public.equals = (bool (*) (host_t *,host_t *)) equals;
        this->public.is_anyaddr = (bool (*) (host_t *)) is_anyaddr;
        this->public.destroy = (void (*) (host_t*))destroy;
-       
+
        return this;
 }
 
@@ -369,7 +369,7 @@ static private_host_t *host_create_empty(void)
 static host_t *host_create_any_port(int family, u_int16_t port)
 {
        host_t *this;
-       
+
        this = host_create_any(family);
        this->set_port(this, port);
        return this;
@@ -381,7 +381,7 @@ static host_t *host_create_any_port(int family, u_int16_t port)
 host_t *host_create_from_string(char *string, u_int16_t port)
 {
        private_host_t *this;
-       
+
        if (streq(string, "%any"))
        {
                return host_create_any_port(AF_INET, port);
@@ -390,7 +390,7 @@ host_t *host_create_from_string(char *string, u_int16_t port)
        {
                return host_create_any_port(AF_INET6, port);
        }
-       
+
        this = host_create_empty();
        if (strchr(string, '.'))
        {
@@ -437,7 +437,7 @@ host_t *host_create_from_string(char *string, u_int16_t port)
 host_t *host_create_from_sockaddr(sockaddr_t *sockaddr)
 {
        private_host_t *this = host_create_empty();
-       
+
        switch (sockaddr->sa_family)
        {
                case AF_INET:
@@ -467,7 +467,7 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port)
        private_host_t *this;
        struct addrinfo hints, *result;
        int error;
-       
+
        if (streq(string, "%any"))
        {
                return host_create_any_port(af ? af : AF_INET, port);
@@ -476,7 +476,7 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port)
        {
                return host_create_any_port(af ? af : AF_INET6, port);
        }
-       
+
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = af;
        error = getaddrinfo(string, NULL, &hints, &result);
@@ -510,7 +510,7 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port)
 host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
 {
        private_host_t *this;
-       
+
        switch (family)
        {
                case AF_INET:
@@ -567,10 +567,10 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
 host_t *host_create_any(int family)
 {
        private_host_t *this = host_create_empty();
-       
+
        memset(&this->address_max, 0, sizeof(struct sockaddr_storage));
        this->address.sa_family = family;
-       
+
        switch (family)
        {
                case AF_INET:
index 0a2541d96fa3f6eca25e2715725d11f4244cea1d..2b70b1b7b9e478504daa3255ff69138658475abf 100644 (file)
@@ -48,103 +48,103 @@ enum host_diff_t {
 
 /**
  * Representates a Host
- * 
- * Host object, identifies a address:port pair and defines some 
+ *
+ * Host object, identifies a address:port pair and defines some
  * useful functions on it.
  */
 struct host_t {
-       
-       /** 
+
+       /**
         * Build a clone of this host object.
-        * 
+        *
         * @return              cloned host
         */
        host_t *(*clone) (host_t *this);
-       
-       /** 
+
+       /**
         * Get a pointer to the internal sockaddr struct.
-        * 
+        *
         * This is used for sending and receiving via sockets.
-        * 
+        *
         * @return              pointer to the internal sockaddr structure
         */
        sockaddr_t  *(*get_sockaddr) (host_t *this);
-       
-       /** 
+
+       /**
         * Get the length of the sockaddr struct.
-        * 
+        *
         * Depending on the family, the length of the sockaddr struct
         * is different. Use this function to get the length of the sockaddr
         * struct returned by get_sock_addr.
-        * 
+        *
         * This is used for sending and receiving via sockets.
-        * 
+        *
         * @return              length of the sockaddr struct
         */
        socklen_t *(*get_sockaddr_len) (host_t *this);
-       
+
        /**
         * Gets the family of the address
-        * 
+        *
         * @return              family
         */
        int (*get_family) (host_t *this);
-       
-       /** 
+
+       /**
         * Checks if the ip address of host is set to default route.
-        * 
+        *
         * @return              TRUE if host is 0.0.0.0 or 0::0, FALSE otherwise
         */
        bool (*is_anyaddr) (host_t *this);
-       
-       /** 
+
+       /**
         * Get the address of this host as chunk_t
-        * 
+        *
         * Returned chunk points to internal data.
-        * 
-        * @return              address string, 
+        *
+        * @return              address string,
         */
        chunk_t (*get_address) (host_t *this);
-               
-       /** 
+
+       /**
         * Get the port of this host
-        * 
+        *
         * @return              port number
         */
        u_int16_t (*get_port) (host_t *this);
 
-       /** 
+       /**
         * Set the port of this host
         *
         * @param port  port numer
         */
        void (*set_port) (host_t *this, u_int16_t port);
-               
-       /** 
+
+       /**
         * Compare the ips of two hosts hosts.
-        * 
+        *
         * @param other the other to compare
         * @return              TRUE if addresses are equal.
         */
        bool (*ip_equals) (host_t *this, host_t *other);
-               
-       /** 
+
+       /**
         * Compare two hosts, with port.
-        * 
+        *
         * @param other the other to compare
         * @return              TRUE if addresses and ports are equal.
         */
        bool (*equals) (host_t *this, host_t *other);
 
-       /** 
+       /**
         * Compare two hosts and return the differences.
         *
         * @param other the other to compare
         * @return              differences in a combination of host_diff_t's
         */
        host_diff_t (*get_differences) (host_t *this, host_t *other);
-       
-       /** 
+
+       /**
         * Destroy this host object.
         */
        void (*destroy) (host_t *this);
@@ -200,7 +200,7 @@ host_t *host_create_any(int family);
 /**
  * printf hook function for host_t.
  *
- * Arguments are: 
+ * Arguments are:
  *    host_t *host
  * Use #-modifier to include port number
  */
index 269c9b166482d934150af03e55d0c9b1a7391f8f..040847029db0915f9b332691f078cad1c412263c 100644 (file)
@@ -55,7 +55,7 @@ ENUM_NEXT(id_type_names, ID_DER_ASN1_GN_URI, ID_MYID, ID_KEY_ID,
 ENUM_END(id_type_names, ID_MYID);
 
 /**
- * coding of X.501 distinguished name 
+ * coding of X.501 distinguished name
  */
 typedef struct {
        const u_char *name;
@@ -108,12 +108,12 @@ struct private_identification_t {
         * Public interface.
         */
        identification_t public;
-       
+
        /**
         * Encoded representation of this ID.
         */
        chunk_t encoded;
-       
+
        /**
         * Type of this ID.
         */
@@ -139,7 +139,7 @@ static bool rdn_enumerate(rdn_enumerator_t *this, chunk_t *oid,
                                                  u_char *type, chunk_t *data)
 {
        chunk_t rdn;
-       
+
        /* a DN contains one or more SET, each containing one or more SEQUENCES,
         * each containing a OID/value RDN */
        if (!this->seqs.len)
@@ -154,7 +154,7 @@ static bool rdn_enumerate(rdn_enumerator_t *this, chunk_t *oid,
                asn1_unwrap(&rdn, oid) == ASN1_OID)
        {
                int t = asn1_unwrap(&rdn, data);
-               
+
                if (t != ASN1_INVALID)
                {
                        *type = t;
@@ -170,10 +170,10 @@ static bool rdn_enumerate(rdn_enumerator_t *this, chunk_t *oid,
 static enumerator_t* create_rdn_enumerator(chunk_t dn)
 {
        rdn_enumerator_t *e = malloc_thing(rdn_enumerator_t);
-       
+
        e->public.enumerate = (void*)rdn_enumerate;
        e->public.destroy = (void*)free;
-       
+
        /* a DN is a SEQUENCE, get the first SET of it */
        if (asn1_unwrap(&dn, &e->sets) == ASN1_SEQUENCE)
        {
@@ -223,7 +223,7 @@ static bool rdn_part_enumerate(rdn_part_enumerator_t *this,
                {OID_EMAIL_ADDRESS,             ID_PART_RDN_E},
                {OID_EMPLOYEE_NUMBER,   ID_PART_RDN_EN},
        };
-       
+
        while (this->inner->enumerate(this->inner, &oid, &strtype, &inner_data))
        {
                known_oid = asn1_known_oid(oid);
@@ -259,11 +259,11 @@ static enumerator_t* create_part_enumerator(private_identification_t *this)
                case ID_DER_ASN1_DN:
                {
                        rdn_part_enumerator_t *e = malloc_thing(rdn_part_enumerator_t);
-                       
+
                        e->inner = create_rdn_enumerator(this->encoded);
                        e->public.enumerate = (void*)rdn_part_enumerate;
                        e->public.destroy = (void*)rdn_part_enumerator_destroy;
-                       
+
                        return &e->public;
                }
                case ID_RFC822_ADDR:
@@ -285,12 +285,12 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
        u_char type;
        int oid, written;
        bool finished = FALSE;
-       
+
        e = create_rdn_enumerator(dn);
        while (e->enumerate(e, &oid_data, &type, &data))
        {
                oid = asn1_known_oid(oid_data);
-               
+
                if (oid == OID_UNKNOWN)
                {
                        written = snprintf(buf, len, "%#B=", &oid_data);
@@ -301,7 +301,7 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
                }
                buf += written;
                len -= written;
-               
+
                if (chunk_printable(data, NULL, '?'))
                {
                        written = snprintf(buf, len, "%.*s", data.len, data.ptr);
@@ -312,7 +312,7 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
                }
                buf += written;
                len -= written;
-               
+
                if (data.ptr + data.len != dn.ptr + dn.len)
                {
                        written = snprintf(buf, len, ", ");
@@ -346,7 +346,7 @@ static status_t atodn(char *src, chunk_t *dn)
                READ_NAME =             3,
                UNKNOWN_OID =   4
        } state_t;
-       
+
        chunk_t oid  = chunk_empty;
        chunk_t name = chunk_empty;
        chunk_t rdns[RDN_MAX];
@@ -357,7 +357,7 @@ static status_t atodn(char *src, chunk_t *dn)
        asn1_t rdn_type;
        state_t state = SEARCH_OID;
        status_t status = SUCCESS;
-       
+
        do
        {
                switch (state)
@@ -378,7 +378,7 @@ static status_t atodn(char *src, chunk_t *dn)
                                else
                                {
                                        bool found = FALSE;
-                                       
+
                                        for (i = 0; i < countof(x501rdns); i++)
                                        {
                                                if (strlen(x501rdns[i].name) == oid.len &&
@@ -423,15 +423,15 @@ static status_t atodn(char *src, chunk_t *dn)
                                        rdn_type = (x501rdns[i].type == ASN1_PRINTABLESTRING
                                                                && !asn1_is_printablestring(name))
                                                                ? ASN1_T61STRING : x501rdns[i].type;
-                                       
+
                                        if (rdn_count < RDN_MAX)
                                        {
                                                chunk_t rdn_oid;
-                                               
+
                                                rdn_oid = asn1_build_known_oid(x501rdns[i].oid);
                                                if (rdn_oid.len)
                                                {
-                                                       rdns[rdn_count] = 
+                                                       rdns[rdn_count] =
                                                                        asn1_wrap(ASN1_SET, "m",
                                                                                asn1_wrap(ASN1_SEQUENCE, "mm",
                                                                                        rdn_oid,
@@ -458,20 +458,20 @@ static status_t atodn(char *src, chunk_t *dn)
                                break;
                }
        } while (*src++ != '\0');
-       
+
        /* build the distinguished name sequence */
        {
                int i;
                u_char *pos = asn1_build_object(dn, ASN1_SEQUENCE, dn_len);
-               
+
                for (i = 0; i < rdn_count; i++)
                {
-                       memcpy(pos, rdns[i].ptr, rdns[i].len); 
+                       memcpy(pos, rdns[i].ptr, rdns[i].len);
                        pos += rdns[i].len;
                        free(rdns[i].ptr);
                }
        }
-       
+
        if (status != SUCCESS)
        {
                free(dn->ptr);
@@ -505,7 +505,7 @@ static bool contains_wildcards_dn(private_identification_t *this)
        bool contains = FALSE;
        id_part_t type;
        chunk_t data;
-       
+
        enumerator = create_part_enumerator(this);
        while (enumerator->enumerate(enumerator, &type, &data))
        {
@@ -553,7 +553,7 @@ static bool compare_dn(chunk_t t_dn, chunk_t o_dn, int *wc)
        chunk_t t_oid, o_oid, t_data, o_data;
        u_char t_type, o_type;
        bool t_next, o_next, finished = FALSE;
-       
+
        if (wc)
        {
                *wc = 0;
@@ -570,14 +570,14 @@ static bool compare_dn(chunk_t t_dn, chunk_t o_dn, int *wc)
        {
                return TRUE;
        }
-       
+
        t = create_rdn_enumerator(t_dn);
        o = create_rdn_enumerator(o_dn);
        while (TRUE)
        {
                t_next = t->enumerate(t, &t_oid, &t_type, &t_data);
                o_next = o->enumerate(o, &o_oid, &o_type, &o_data);
-               
+
                if (!o_next && !t_next)
                {
                        break;
@@ -647,7 +647,7 @@ static bool equals_dn(private_identification_t *this,
 static bool equals_strcasecmp(private_identification_t *this,
                                                          private_identification_t *other)
 {
-       /* we do some extra sanity checks to check for invalid IDs with a 
+       /* we do some extra sanity checks to check for invalid IDs with a
         * terminating null in it. */
        if (this->encoded.len == other->encoded.len &&
                memchr(this->encoded.ptr, 0, this->encoded.len) == NULL &&
@@ -662,14 +662,14 @@ static bool equals_strcasecmp(private_identification_t *this,
 /**
  * Default implementation of identification_t.matches.
  */
-static id_match_t matches_binary(private_identification_t *this, 
+static id_match_t matches_binary(private_identification_t *this,
                                                   private_identification_t *other)
 {
        if (other->type == ID_ANY)
        {
                return ID_MATCH_ANY;
        }
-       if (this->type == other->type && 
+       if (this->type == other->type &&
                chunk_equals(this->encoded, other->encoded))
        {
                return ID_MATCH_PERFECT;
@@ -685,7 +685,7 @@ static id_match_t matches_string(private_identification_t *this,
                                                                 private_identification_t *other)
 {
        u_int len = other->encoded.len;
-       
+
        if (other->type == ID_ANY)
        {
                return ID_MATCH_ANY;
@@ -712,7 +712,7 @@ static id_match_t matches_string(private_identification_t *this,
                {       /* not better than ID_ANY */
                        return ID_MATCH_ANY;
                }
-               if (strncasecmp(this->encoded.ptr + this->encoded.len - len, 
+               if (strncasecmp(this->encoded.ptr + this->encoded.len - len,
                                                other->encoded.ptr + 1, len) == 0)
                {
                        return ID_MATCH_ONE_WILDCARD;
@@ -742,12 +742,12 @@ static id_match_t matches_dn(private_identification_t *this,
                                                         private_identification_t *other)
 {
        int wc;
-       
+
        if (other->type == ID_ANY)
        {
                return ID_MATCH_ANY;
        }
-       
+
        if (this->type == other->type)
        {
                if (compare_dn(this->encoded, other->encoded, &wc))
@@ -768,12 +768,12 @@ int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
        private_identification_t *this = *((private_identification_t**)(args[0]));
        chunk_t proper;
        char buf[512];
-       
+
        if (this == NULL)
        {
                return print_in_hook(dst, len, "%*s", spec->width, "(null)");
        }
-       
+
        switch (this->type)
        {
                case ID_ANY:
@@ -835,7 +835,7 @@ int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
 static identification_t *clone_(private_identification_t *this)
 {
        private_identification_t *clone = malloc_thing(private_identification_t);
-       
+
        memcpy(clone, this, sizeof(private_identification_t));
        if (this->encoded.len)
        {
@@ -859,13 +859,13 @@ static void destroy(private_identification_t *this)
 static private_identification_t *identification_create(id_type_t type)
 {
        private_identification_t *this = malloc_thing(private_identification_t);
-       
+
        this->public.get_encoding = (chunk_t (*) (identification_t*))get_encoding;
        this->public.get_type = (id_type_t (*) (identification_t*))get_type;
        this->public.create_part_enumerator = (enumerator_t*(*)(identification_t*))create_part_enumerator;
        this->public.clone = (identification_t* (*) (identification_t*))clone_;
        this->public.destroy = (void (*) (identification_t*))destroy;
-       
+
        switch (type)
        {
                case ID_ANY:
@@ -890,10 +890,10 @@ static private_identification_t *identification_create(id_type_t type)
                        this->public.contains_wildcards = (bool (*) (identification_t *this))return_false;
                        break;
        }
-       
+
        this->type = type;
        this->encoded = chunk_empty;
-       
+
        return this;
 }
 
@@ -904,7 +904,7 @@ identification_t *identification_create_from_string(char *string)
 {
        private_identification_t *this;
        chunk_t encoded;
-       
+
        if (string == NULL)
        {
                string = "%any";
@@ -945,7 +945,7 @@ identification_t *identification_create_from_string(char *string)
                        {
                                struct in_addr address;
                                chunk_t chunk = {(void*)&address, sizeof(address)};
-                               
+
                                if (inet_pton(AF_INET, string, &address) > 0)
                                {       /* is IPv4 */
                                        this = identification_create(ID_IPV4_ADDR);
@@ -962,7 +962,7 @@ identification_t *identification_create_from_string(char *string)
                        {
                                struct in6_addr address;
                                chunk_t chunk = {(void*)&address, sizeof(address)};
-                               
+
                                if (inet_pton(AF_INET6, string, &address) > 0)
                                {       /* is IPv6 */
                                        this = identification_create(ID_IPV6_ADDR);
@@ -1013,7 +1013,7 @@ identification_t *identification_create_from_encoding(id_type_t type,
                                                                                                          chunk_t encoded)
 {
        private_identification_t *this = identification_create(type);
-       
+
        /* apply encoded chunk */
        if (type != ID_ANY)
        {
index 30cb7e58706c075885e3b0cfda71338f05f79eb3..f6775071ccf523ed2c95986fd809de9bda537a21 100644 (file)
@@ -14,7 +14,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup identification identification
  * @{ @ingroup utils
@@ -31,7 +31,7 @@ typedef enum id_part_t id_part_t;
 
 #include <library.h>
 
-/** 
+/**
  * Matches returned from identification_t.match
  */
 enum id_match_t {
@@ -56,24 +56,24 @@ extern enum_name_t *id_match_names;
  * ID Types in a ID payload.
  */
 enum id_type_t {
-       
+
        /**
         * private type which matches any other id.
         */
        ID_ANY = 0,
-       
+
        /**
         * ID data is a single four (4) octet IPv4 address.
         */
        ID_IPV4_ADDR = 1,
-       
+
        /**
         * ID data is a fully-qualified domain name string.
         * An example of a ID_FQDN is "example.com".
         * The string MUST not contain any terminators (e.g., NULL, CR, etc.).
         */
        ID_FQDN = 2,
-       
+
        /**
         * ID data is a fully-qualified RFC822 email address string.
         * An example of an ID_RFC822_ADDR is "jsmith@example.com".
@@ -81,59 +81,59 @@ enum id_type_t {
         */
        ID_USER_FQDN   = 3,    /* IKEv1 only */
        ID_RFC822_ADDR = 3,    /* IKEv2 only */
-       
+
        /**
         * ID data is an IPv4 subnet (IKEv1 only)
         */
        ID_IPV4_ADDR_SUBNET = 4,
-       
+
        /**
         * ID data is a single sixteen (16) octet IPv6 address.
         */
        ID_IPV6_ADDR = 5,
-       
+
        /**
         * ID data is an IPv6 subnet (IKEv1 only)
         */
        ID_IPV6_ADDR_SUBNET = 6,
-       
+
        /**
         * ID data is an IPv4 address range (IKEv1 only)
         */
        ID_IPV4_ADDR_RANGE = 7,
-       
+
        /**
         * ID data is an IPv6 address range (IKEv1 only)
         */
        ID_IPV6_ADDR_RANGE = 8,
-       
+
        /**
         * ID data is the binary DER encoding of an ASN.1 X.501 Distinguished Name
         */
        ID_DER_ASN1_DN = 9,
-       
+
        /**
         * ID data is the binary DER encoding of an ASN.1 X.509 GeneralName
         */
        ID_DER_ASN1_GN = 10,
-       
+
        /**
         * ID data is an opaque octet stream which may be used to pass vendor-
         * specific information necessary to do certain proprietary
         * types of identification.
         */
        ID_KEY_ID = 11,
-       
+
        /**
         * private type which represents a GeneralName of type URI
         */
        ID_DER_ASN1_GN_URI = 201,
-       
+
        /**
         * IETF Attribute Syntax String (RFC 3281)
         */
        ID_IETF_ATTR_STRING = 202,
-       
+
        /**
         * Private ID used by the pluto daemon for opportunistic encryption
         */
@@ -153,14 +153,14 @@ enum id_part_t {
        ID_PART_USERNAME,
        /** Domain part of an RFC822_ADDR */
        ID_PART_DOMAIN,
-       
+
        /** Top-Level domain of a FQDN */
        ID_PART_TLD,
        /** Second-Level domain of a FQDN */
        ID_PART_SLD,
        /** Another Level domain of a FQDN */
        ID_PART_ALD,
-       
+
        /** Country RDN of a DN */
        ID_PART_RDN_C,
        /** CommonName RDN of a DN */
@@ -197,40 +197,40 @@ enum id_part_t {
 
 /**
  * Generic identification, such as used in ID payload.
- * 
+ *
  * @todo Support for ID_DER_ASN1_GN is minimal right now. Comparison
  * between them and ID_IPV4_ADDR/RFC822_ADDR would be nice.
  */
 struct identification_t {
-       
+
        /**
         * Get the encoding of this id, to send over
         * the network.
-        * 
+        *
         * Result points to internal data, do not free.
-        * 
+        *
         * @return                      a chunk containing the encoded bytes
         */
        chunk_t (*get_encoding) (identification_t *this);
-       
+
        /**
         * Get the type of this identification.
-        * 
+        *
         * @return                      id_type_t
         */
        id_type_t (*get_type) (identification_t *this);
-       
+
        /**
         * Check if two identification_t objects are equal.
-        * 
+        *
         * @param other         other identification_t object
         * @return                      TRUE if the IDs are equal
         */
        bool (*equals) (identification_t *this, identification_t *other);
-       
+
        /**
         * Check if an ID matches a wildcard ID.
-        * 
+        *
         * An identification_t may contain wildcards, such as
         * *.strongswan.org. This call checks if a given ID
         * (e.g. tester.strongswan.org) belongs to a such wildcard
@@ -241,24 +241,24 @@ struct identification_t {
         *
         * The larger the return value is, the better is the match. Zero means
         * no match at all, 1 means a bad match, and 2 a slightly better match.
-        * 
+        *
         * @param other         the ID containing one or more wildcards
         * @param wildcards     returns the number of wildcards, may be NULL
         * @return                      match value as described above
         */
        id_match_t (*matches) (identification_t *this, identification_t *other);
-       
+
        /**
         * Check if an ID is a wildcard ID.
         *
         * If the ID represents multiple IDs (with wildcards, or
         * as the type ID_ANY), TRUE is returned. If it is unique,
         * FALSE is returned.
-        * 
+        *
         * @return                      TRUE if ID contains wildcards
         */
        bool (*contains_wildcards) (identification_t *this);
-       
+
        /**
         * Create an enumerator over subparts of an identity.
         *
@@ -271,10 +271,10 @@ struct identification_t {
         * @return                      an enumerator over (id_part_t type, chunk_t data)
         */
        enumerator_t* (*create_part_enumerator)(identification_t *this);
-       
+
        /**
         * Clone a identification_t instance.
-        * 
+        *
         * @return                      clone of this
         */
        identification_t *(*clone) (identification_t *this);
@@ -299,15 +299,15 @@ struct identification_t {
  * pluto resolves domainnames without an @ to IPv4 addresses. Since
  * we use a seperate host_t class for addresses, this doesn't
  * make sense for us.
- * 
+ *
  * A distinguished name may contain one or more of the following RDNs:
  * ND, UID, DC, CN, S, SN, serialNumber, C, L, ST, O, OU, T, D,
- * N, G, I, ID, EN, EmployeeNumber, E, Email, emailAddress, UN, 
+ * N, G, I, ID, EN, EmployeeNumber, E, Email, emailAddress, UN,
  * unstructuredName, TCGID.
- * 
+ *
  * This constructor never returns NULL. If it does not find a suitable
  * conversion function, it will copy the string to an ID_KEY_ID.
- * 
+ *
  * @param string       input string, which will be converted
  * @return                     identification_t
  */
@@ -315,7 +315,7 @@ identification_t * identification_create_from_string(char *string);
 
 /**
  * Creates an identification_t object from an encoded chunk.
- * 
+ *
  * @param type         type of this id, such as ID_IPV4_ADDR
  * @param encoded      encoded bytes, such as from identification_t.get_encoding
  * @return                     identification_t
@@ -325,7 +325,7 @@ identification_t * identification_create_from_encoding(id_type_t type, chunk_t e
 /**
  * printf hook function for identification_t.
  *
- * Arguments are: 
+ * Arguments are:
  *    identification_t *identification
  */
 int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
index 1dbf01539bbde26c99040414297014bb19e0e603..9be65b229c6bb3451f5dddfca5e3b7895dc33b93 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup iterator iterator
  * @{ @ingroup utils
@@ -39,45 +39,45 @@ struct iterator_t {
 
        /**
         * Return number of list items.
-        * 
+        *
         * @return                              number of list items
         */
        int (*get_count) (iterator_t *this);
-       
+
        /**
         * Iterate over all items.
-        * 
+        *
         * The easy way to iterate over items.
-        * 
+        *
         * @param value         item
         * @return                      TRUE, if there was an element available, FALSE otherwise
         */
        bool (*iterate) (iterator_t *this, void** value);
-       
+
        /**
         * Inserts a new item before the given iterator position.
-        * 
+        *
         * The iterator position is not changed after inserting
-        * 
+        *
         * @param item          value to insert in list
         */
        void (*insert_before) (iterator_t *this, void *item);
 
        /**
         * Inserts a new item after the given iterator position.
-        * 
+        *
         * The iterator position is not changed after inserting.
-        * 
+        *
         * @param this          calling iterator
         * @param item          value to insert in list
         */
        void (*insert_after) (iterator_t *this, void *item);
-       
+
        /**
         * Replace the current item at current iterator position.
-        * 
+        *
         * The iterator position is not changed after replacing.
-        * 
+        *
         * @param this          calling iterator
         * @param old           old value will be written here(can be NULL)
         * @param new           new value
@@ -87,18 +87,18 @@ struct iterator_t {
 
        /**
         * Removes an element from list at the given iterator position.
-        * 
+        *
         * The iterator is set the the following position:
         * - to the item before, if available
         * - it gets reseted, otherwise
-        * 
+        *
         * @return                              SUCCESS, FAILED if iterator is on an invalid position
         */
        status_t (*remove) (iterator_t *this);
-       
+
        /**
         * Resets the iterator position.
-        * 
+        *
         * After reset, the iterator_t objects doesn't point to an element.
         * A call to iterator_t.has_next is necessary to do any other operations
         * with the resetted iterator.
index b620780065d16a5ee21f338039451a054ba5b98b..bae22f172732e9797489d9a88511a061b08eead8 100644 (file)
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
-       
+
 #define _GNU_SOURCE
 #include <sched.h>
 #include <stddef.h>
 #include <string.h>
 #include <stdio.h>
 #include <malloc.h>
-#include <signal.h> 
+#include <signal.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -90,32 +90,32 @@ typedef struct memory_tail_t memory_tail_t;
  * Header which is prepended to each allocated memory block
  */
 struct memory_header_t {
-       
+
        /**
         * Number of bytes following after the header
         */
        u_int bytes;
-       
+
        /**
         * Pointer to previous entry in linked list
         */
        memory_header_t *previous;
-       
+
        /**
         * Pointer to next entry in linked list
         */
        memory_header_t *next;
-       
+
        /**
         * backtrace taken during (re-)allocation
         */
        backtrace_t *backtrace;
-       
+
        /**
         * magic bytes to detect bad free or heap underflow, MEMORY_HEADER_MAGIC
         */
        u_int32_t magic;
-       
+
 }__attribute__((__packed__));
 
 /**
@@ -127,11 +127,11 @@ struct memory_tail_t {
         * Magic bytes to detect heap overflow, MEMORY_TAIL_MAGIC
         */
        u_int32_t magic;
-       
+
 }__attribute__((__packed__));
 
 /**
- * first mem header is just a dummy to chain 
+ * first mem header is just a dummy to chain
  * the others on it...
  */
 static memory_header_t first_header = {
@@ -143,7 +143,7 @@ static memory_header_t first_header = {
 };
 
 /**
- * are the hooks currently installed? 
+ * are the hooks currently installed?
  */
 static bool installed = FALSE;
 
@@ -151,7 +151,7 @@ static bool installed = FALSE;
  * Leak report white list
  *
  * List of functions using static allocation buffers or should be suppressed
- * otherwise on leak report. 
+ * otherwise on leak report.
  */
 char *whitelist[] = {
        /* backtraces, including own */
@@ -233,7 +233,7 @@ void report_leaks()
 {
        memory_header_t *hdr;
        int leaks = 0, whitelisted = 0;
-       
+
        for (hdr = first_header.next; hdr != NULL; hdr = hdr->next)
        {
                if (is_whitelisted(hdr->backtrace))
@@ -248,7 +248,7 @@ void report_leaks()
                        leaks++;
                }
        }
-               
+
        switch (leaks)
        {
                case 0:
@@ -305,12 +305,12 @@ void *malloc_hook(size_t bytes, const void *caller)
        pthread_t thread_id = pthread_self();
     int oldpolicy;
     struct sched_param oldparams, params;
-    
+
     pthread_getschedparam(thread_id, &oldpolicy, &oldparams);
-    
+
     params.__sched_priority = sched_get_priority_max(SCHED_FIFO);
        pthread_setschedparam(thread_id, SCHED_FIFO, &params);
-       
+
        count_malloc++;
        uninstall_hooks();
        hdr = malloc(sizeof(memory_header_t) + bytes + sizeof(memory_tail_t));
@@ -318,13 +318,13 @@ void *malloc_hook(size_t bytes, const void *caller)
        /* set to something which causes crashes */
        memset(hdr, MEMORY_ALLOC_PATTERN,
                   sizeof(memory_header_t) + bytes + sizeof(memory_tail_t));
-       
+
        hdr->magic = MEMORY_HEADER_MAGIC;
        hdr->bytes = bytes;
        hdr->backtrace = backtrace_create(3);
        tail->magic = MEMORY_TAIL_MAGIC;
        install_hooks();
-       
+
        /* insert at the beginning of the list */
        hdr->next = first_header.next;
        if (hdr->next)
@@ -333,9 +333,9 @@ void *malloc_hook(size_t bytes, const void *caller)
        }
        hdr->previous = &first_header;
        first_header.next = hdr;
-       
+
        pthread_setschedparam(thread_id, oldpolicy, &oldparams);
-       
+
        return hdr + 1;
 }
 
@@ -350,7 +350,7 @@ void free_hook(void *ptr, const void *caller)
        pthread_t thread_id = pthread_self();
     int oldpolicy;
     struct sched_param oldparams, params;
-    
+
        /* allow freeing of NULL */
        if (ptr == NULL)
        {
@@ -358,12 +358,12 @@ void free_hook(void *ptr, const void *caller)
        }
        hdr = ptr - sizeof(memory_header_t);
        tail = ptr + hdr->bytes;
-       
+
        pthread_getschedparam(thread_id, &oldpolicy, &oldparams);
-       
+
     params.__sched_priority = sched_get_priority_max(SCHED_FIFO);
        pthread_setschedparam(thread_id, SCHED_FIFO, &params);
-       
+
        count_free++;
        uninstall_hooks();
        if (hdr->magic != MEMORY_HEADER_MAGIC ||
@@ -385,13 +385,13 @@ void free_hook(void *ptr, const void *caller)
                }
                hdr->previous->next = hdr->next;
                hdr->backtrace->destroy(hdr->backtrace);
-               
+
                /* clear MAGIC, set mem to something remarkable */
                memset(hdr, MEMORY_FREE_PATTERN, hdr->bytes + sizeof(memory_header_t));
-               
+
                free(hdr);
        }
-       
+
        install_hooks();
        pthread_setschedparam(thread_id, oldpolicy, &oldparams);
 }
@@ -407,21 +407,21 @@ void *realloc_hook(void *old, size_t bytes, const void *caller)
        pthread_t thread_id = pthread_self();
     int oldpolicy;
     struct sched_param oldparams, params;
-    
+
        /* allow reallocation of NULL */
        if (old == NULL)
        {
                return malloc_hook(bytes, caller);
        }
-       
+
        hdr = old - sizeof(memory_header_t);
        tail = old + hdr->bytes;
-       
+
        pthread_getschedparam(thread_id, &oldpolicy, &oldparams);
-       
+
        params.__sched_priority = sched_get_priority_max(SCHED_FIFO);
        pthread_setschedparam(thread_id, SCHED_FIFO, &params);
-       
+
        count_realloc++;
        uninstall_hooks();
        if (hdr->magic != MEMORY_HEADER_MAGIC ||
@@ -475,21 +475,21 @@ static void destroy(private_leak_detective_t *this)
 leak_detective_t *leak_detective_create()
 {
        private_leak_detective_t *this = malloc_thing(private_leak_detective_t);
-       
+
        this->public.destroy = (void(*)(leak_detective_t*))destroy;
-       
+
        if (getenv("LEAK_DETECTIVE_DISABLE") == NULL)
        {
                cpu_set_t mask;
-               
+
                CPU_ZERO(&mask);
                CPU_SET(0, &mask);
-               
+
                if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) != 0)
                {
                        fprintf(stderr, "setting CPU affinity failed: %m");
                }
-       
+
                lib->leak_detective = TRUE;
                install_hooks();
        }
index cd30dcd5f9e0571dc5cd4c6ab8245b38f124d5b8..835fb85a92b49f2257b6710e2688c4fa080f1caa 100644 (file)
@@ -32,7 +32,7 @@ typedef struct leak_detective_t leak_detective_t;
  * and dynamic whitelisting.
  */
 struct leak_detective_t {
-               
+
        /**
      * Destroy a leak_detective instance.
      */
index 2472f6751acf323483d48af3b98beece22e7449f..b0aced1807a7013628a9a9d0e4779f5f35e35a7e 100644 (file)
@@ -40,31 +40,31 @@ bool match(const char *pattern, const chunk_t *ch)
 bool extract_token(chunk_t *token, const char termination, chunk_t *src)
 {
        u_char *eot = memchr(src->ptr, termination, src->len);
-       
+
        if (termination == ' ')
        {
                u_char *eot_tab = memchr(src->ptr, '\t', src->len);
-               
+
                /* check if a tab instead of a space terminates the token */
                eot = ( eot_tab == NULL || (eot && eot < eot_tab) ) ? eot : eot_tab;
        }
-       
+
        /* initialize empty token */
        *token = chunk_empty;
-       
+
        if (eot == NULL) /* termination symbol not found */
        {
                return FALSE;
        }
-       
+
        /* extract token */
        token->ptr = src->ptr;
        token->len = (u_int)(eot - src->ptr);
-       
+
        /* advance src pointer after termination symbol */
        src->ptr = eot + 1;
        src->len -= (token->len + 1);
-       
+
        return TRUE;
 }
 
@@ -75,23 +75,23 @@ bool extract_token_str(chunk_t *token, const char *termination, chunk_t *src)
 {
        u_char *eot = memstr(src->ptr, termination, src->len);
        size_t l = strlen(termination);
-       
+
        /* initialize empty token */
        *token = chunk_empty;
-       
+
        if (eot == NULL) /* termination string not found */
        {
                return FALSE;
        }
-       
+
        /* extract token */
        token->ptr = src->ptr;
        token->len = (u_int)(eot - src->ptr);
-       
+
        /* advance src pointer after termination string */
        src->ptr = eot + l;
        src->len -= (token->len + l);
-       
+
        return TRUE;
 }
 
index 7e2edb2789e800257168790bed066c0e018f47d7..7eb68069ba0c9f411ef9e24de328a86229c7b5e6 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup lexparser lexparser
  * @{ @ingroup utils
index a45468cca7e5abc2acd5afe85245b2337401a676..4aa8ea6ca8d8eca783c065265846a7f5e976fb17 100644 (file)
@@ -33,14 +33,14 @@ struct element_t {
 
        /**
         * Previous list element.
-        * 
+        *
         * NULL if first element in list.
         */
        element_t *previous;
-       
+
        /**
         * Next list element.
-        * 
+        *
         * NULL if last element in list.
         */
        element_t *next;
@@ -52,11 +52,11 @@ struct element_t {
 element_t *element_create(void *value)
 {
        element_t *this = malloc_thing(element_t);
-       
+
        this->previous = NULL;
        this->next = NULL;
        this->value = value;
-       
+
        return (this);
 }
 
@@ -83,7 +83,7 @@ struct private_linked_list_t {
         * NULL if no elements in list.
         */
        element_t *first;
-       
+
        /**
         * Last element in list.
         * NULL if no elements in list.
@@ -130,12 +130,12 @@ struct private_enumerator_t {
         * implements enumerator interface
         */
        enumerator_t enumerator;
-       
+
        /**
         * associated linked list
         */
        private_linked_list_t *list;
-       
+
        /**
         * current item
         */
@@ -173,12 +173,12 @@ static bool enumerate(private_enumerator_t *this, void **item)
 static enumerator_t* create_enumerator(private_linked_list_t *this)
 {
        private_enumerator_t *enumerator = malloc_thing(private_enumerator_t);
-       
+
        enumerator->enumerator.enumerate = (void*)enumerate;
        enumerator->enumerator.destroy = (void*)free;
        enumerator->list = this;
        enumerator->current = NULL;
-       
+
        return &enumerator->enumerator;
 }
 
@@ -273,7 +273,7 @@ static status_t iterator_remove(private_iterator_t *this)
                this->current->previous->next = this->current->next;
                this->current->next->previous = this->current->previous;
        }
-       
+
        this->list->count--;
        free(this->current);
        /* set the new iterator position */
@@ -290,7 +290,7 @@ static void insert_before(private_iterator_t * iterator, void *item)
        {
                iterator->list->public.insert_first(&(iterator->list->public), item);
        }
-       
+
        element_t *element = element_create(item);
        if (iterator->current->previous == NULL)
        {
@@ -322,7 +322,7 @@ static status_t replace(private_iterator_t *this, void **old_item, void *new_ite
                *old_item = this->current->value;
        }
        this->current->value = new_item;
-       
+
        return SUCCESS;
 }
 
@@ -336,7 +336,7 @@ static void insert_after(private_iterator_t *iterator, void *item)
                iterator->list->public.insert_first(&(iterator->list->public),item);
                return;
        }
-       
+
        element_t *element = element_create(item);
        if (iterator->current->next == NULL)
        {
@@ -376,7 +376,7 @@ static int get_count(private_linked_list_t *this)
 static void insert_first(private_linked_list_t *this, void *item)
 {
        element_t *element;
-       
+
        element = element_create(item);
        if (this->count == 0)
        {
@@ -407,7 +407,7 @@ static element_t* remove_element(private_linked_list_t *this, element_t *element
        next = element->next;
        previous = element->previous;
        free(element);
-       if (next) 
+       if (next)
        {
                next->previous = previous;
        }
@@ -463,7 +463,7 @@ static status_t remove_first(private_linked_list_t *this, void **item)
 static void insert_last(private_linked_list_t *this, void *item)
 {
        element_t *element = element_create(item);
-       
+
        if (this->count == 0)
        {
                /* first entry in list */
@@ -508,7 +508,7 @@ static status_t remove_last(private_linked_list_t *this, void **item)
        }
        return NOT_FOUND;
 }
-       
+
 /**
  * Implementation of linked_list_t.remove.
  */
@@ -517,7 +517,7 @@ static int remove_(private_linked_list_t *this, void *item,
 {
        element_t *current = this->first;
        int removed = 0;
-       
+
        while (current)
        {
                if ((compare && compare(current->value, item)) ||
@@ -556,7 +556,7 @@ static status_t find_first(private_linked_list_t *this, linked_list_match_t matc
                void **item, void *d1, void *d2, void *d3, void *d4, void *d5)
 {
        element_t *current = this->first;
-       
+
        while (current)
        {
                if ((match && match(current->value, d1, d2, d3, d4, d5)) ||
@@ -580,7 +580,7 @@ static status_t find_last(private_linked_list_t *this, linked_list_match_t match
                void **item, void *d1, void *d2, void *d3, void *d4, void *d5)
 {
        element_t *current = this->last;
-       
+
        while (current)
        {
                if ((match && match(current->value, d1, d2, d3, d4, d5)) ||
@@ -604,7 +604,7 @@ static void invoke_offset(private_linked_list_t *this, size_t offset,
                void *d1, void *d2, void *d3, void *d4, void *d5)
 {
        element_t *current = this->first;
-       
+
        while (current)
        {
                linked_list_invoke_t *method = current->value + offset;
@@ -620,7 +620,7 @@ static void invoke_function(private_linked_list_t *this, linked_list_invoke_t fn
                void *d1, void *d2, void *d3, void *d4, void *d5)
 {
        element_t *current = this->first;
-       
+
        while (current)
        {
                fn(current->value, d1, d2, d3, d4, d5);
@@ -635,14 +635,14 @@ static linked_list_t *clone_offset(private_linked_list_t *this, size_t offset)
 {
        linked_list_t *clone = linked_list_create();
        element_t *current = this->first;
-       
+
        while (current)
        {
                void* (**method)(void*) = current->value + offset;
                clone->insert_last(clone, (*method)(current->value));
                current = current->next;
        }
-       
+
        return clone;
 }
 
@@ -653,13 +653,13 @@ static linked_list_t *clone_function(private_linked_list_t *this, void* (*fn)(vo
 {
        linked_list_t *clone = linked_list_create();
        element_t *current = this->first;
-       
+
        while (current)
        {
                clone->insert_last(clone, fn(current->value));
                current = current->next;
        }
-       
+
        return clone;
 }
 
@@ -684,7 +684,7 @@ static void destroy(private_linked_list_t *this)
 static void destroy_offset(private_linked_list_t *this, size_t offset)
 {
        element_t *current = this->first, *next;
-       
+
        while (current)
        {
                void (**method)(void*) = current->value + offset;
@@ -702,7 +702,7 @@ static void destroy_offset(private_linked_list_t *this, size_t offset)
 static void destroy_function(private_linked_list_t *this, void (*fn)(void*))
 {
        element_t *current = this->first, *next;
-       
+
        while (current)
        {
                fn(current->value);
@@ -719,7 +719,7 @@ static void destroy_function(private_linked_list_t *this, void (*fn)(void*))
 static iterator_t *create_iterator(private_linked_list_t *linked_list, bool forward)
 {
        private_iterator_t *this = malloc_thing(private_iterator_t);
-       
+
        this->public.get_count = (int (*) (iterator_t*)) get_list_count;
        this->public.iterate = (bool (*) (iterator_t*, void **value)) iterate;
        this->public.insert_before = (void (*) (iterator_t*, void *item)) insert_before;
@@ -728,11 +728,11 @@ static iterator_t *create_iterator(private_linked_list_t *linked_list, bool forw
        this->public.remove = (status_t (*) (iterator_t*)) iterator_remove;
        this->public.reset = (void (*) (iterator_t*)) iterator_reset;
        this->public.destroy = (void (*) (iterator_t*)) iterator_destroy;
-       
+
        this->forward = forward;
        this->current = NULL;
        this->list = linked_list;
-       
+
        return &this->public;
 }
 
index 8b2de90832260ded2b23fcfeea256d893b7aaa66..98c2bfc9bba2df843338bb6bc33358875ead9638 100644 (file)
@@ -14,7 +14,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup linked_list linked_list
  * @{ @ingroup utils
@@ -56,24 +56,24 @@ struct linked_list_t {
 
        /**
         * Gets the count of items in the list.
-        * 
+        *
         * @return                      number of items in list
         */
        int (*get_count) (linked_list_t *this);
-       
+
        /**
         * Creates a iterator for the given list.
-        * 
+        *
         * @warning Created iterator_t object has to get destroyed by the caller.
         *
         * @deprecated Iterator is obsolete and will disappear, it is too
         * complicated to implement. Use enumerator instead.
-        * 
+        *
         * @param forward       iterator direction (TRUE: front to end)
         * @return                      new iterator_t object
         */
        iterator_t *(*create_iterator) (linked_list_t *this, bool forward);
-       
+
        /**
         * Create an enumerator over the list.
         *
@@ -83,7 +83,7 @@ struct linked_list_t {
         * @return                      enumerator over list items
         */
        enumerator_t* (*create_enumerator)(linked_list_t *this);
-       
+
        /**
         * Inserts a new item at the beginning of the list.
         *
@@ -93,22 +93,22 @@ struct linked_list_t {
 
        /**
         * Removes the first item in the list and returns its value.
-        * 
+        *
         * @param item          returned value of first item, or NULL
         * @return                      SUCCESS, or NOT_FOUND if list is empty
         */
        status_t (*remove_first) (linked_list_t *this, void **item);
-       
+
        /**
         * Remove an item from the list where the enumerator points to.
         *
         * @param enumerator enumerator with position
         */
        void (*remove_at)(linked_list_t *this, enumerator_t *enumerator);
-       
+
        /**
         * Remove items from the list matching item.
-        * 
+        *
         * If a compare function is given, it is called for each item, where
         * the first parameter is the current list item and the second parameter
         * is the supplied item parameter.
@@ -119,10 +119,10 @@ struct linked_list_t {
         * @return                      number of removed items
         */
        int (*remove)(linked_list_t *this, void *item, bool (*compare)(void *,void*));
-       
+
        /**
         * Returns the value of the first list item without removing it.
-        * 
+        *
         * @param this          calling object
         * @param item          returned value of first item
         * @return                      SUCCESS, NOT_FOUND if list is empty
@@ -131,14 +131,14 @@ struct linked_list_t {
 
        /**
         * Inserts a new item at the end of the list.
-        * 
+        *
         * @param item          value to insert into list
         */
        void (*insert_last) (linked_list_t *this, void *item);
 
        /**
         * Removes the last item in the list and returns its value.
-        * 
+        *
         * @param this          calling object
         * @param item          returned value of last item, or NULL
         * @return                      SUCCESS, NOT_FOUND if list is empty
@@ -147,15 +147,15 @@ struct linked_list_t {
 
        /**
         * Returns the value of the last list item without removing it.
-        * 
+        *
         * @param this          calling object
         * @param item          returned value of last item
         * @return                      SUCCESS, NOT_FOUND if list is empty
         */
        status_t (*get_last) (linked_list_t *this, void **item);
-       
+
        /** Find the first matching element in the list.
-        * 
+        *
         * The first object passed to the match function is the current list item,
         * followed by the user supplied data.
         * If the supplied function returns TRUE this function returns SUCCESS, and
@@ -163,7 +163,7 @@ struct linked_list_t {
         * the next item is checked.
         *
         * If match is NULL, *item and the current object are compared.
-        * 
+        *
         * @warning Only use pointers as user supplied data.
         *
         * @param match                 comparison function to call on each object, or NULL
@@ -173,17 +173,17 @@ struct linked_list_t {
         */
        status_t (*find_first) (linked_list_t *this, linked_list_match_t match,
                                                        void **item, ...);
-       
+
        /** Find the last matching element in the list.
-        * 
+        *
         * The first object passed to the match function is the current list item,
         * followed by the user supplied data.
         * If the supplied function returns TRUE this function returns SUCCESS, and
         * the current object is returned in the third parameter, otherwise,
         * the next item is checked.
-        * 
+        *
         * If match is NULL, *item and the current object are compared.
-        * 
+        *
         * @warning Only use pointers as user supplied data.
         *
         * @param match                 comparison function to call on each object, or NULL
@@ -193,7 +193,7 @@ struct linked_list_t {
         */
        status_t (*find_last) (linked_list_t *this, linked_list_match_t match,
                                                   void **item, ...);
-       
+
        /**
         * Invoke a method on all of the contained objects.
         *
@@ -202,41 +202,41 @@ struct linked_list_t {
         * method is specified by an offset of the function pointer,
         * which can be evalutated at compile time using the offsetof
         * macro, e.g.: list->invoke(list, offsetof(object_t, method));
-        * 
+        *
         * @param offset        offset of the method to invoke on objects
         * @param ...           user data to supply to called function (limited to 5 arguments)
         */
        void (*invoke_offset) (linked_list_t *this, size_t offset, ...);
-       
+
        /**
         * Invoke a function on all of the contained objects.
-        * 
+        *
         * @param function      offset of the method to invoke on objects
         * @param ...           user data to supply to called function (limited to 5 arguments)
         */
        void (*invoke_function) (linked_list_t *this, linked_list_invoke_t function, ...);
-       
+
        /**
         * Clones a list and its objects using the objects' clone method.
-        * 
+        *
         * @param offset        offset ot the objects clone function
         * @return                      cloned list
         */
        linked_list_t *(*clone_offset) (linked_list_t *this, size_t offset);
-       
+
        /**
         * Clones a list and its objects using a given function.
-        * 
+        *
         * @param function      function that clones an object
         * @return                      cloned list
         */
        linked_list_t *(*clone_function) (linked_list_t *this, void*(*)(void*));
-       
+
        /**
         * Destroys a linked_list object.
         */
        void (*destroy) (linked_list_t *this);
-       
+
        /**
         * Destroys a list and its objects using the destructor.
         *
@@ -248,10 +248,10 @@ struct linked_list_t {
         * @param offset        offset of the objects destructor
         */
        void (*destroy_offset) (linked_list_t *this, size_t offset);
-       
+
        /**
         * Destroys a list and its contents using a a cleanup function.
-        * 
+        *
         * If a linked list and its contents should get destroyed using a specific
         * cleanup function, use destroy_function. This is useful when the
         * list contains malloc()-ed blocks which should get freed,
@@ -264,7 +264,7 @@ struct linked_list_t {
 
 /**
  * Creates an empty linked list object.
- * 
+ *
  * @return             linked_list_t object.
  */
 linked_list_t *linked_list_create(void);
index a74a4e47d8238a2ffda332fe6f99f53a6e709395..c7797c49e03174eb451a0fa2acb57c6938aecb02 100644 (file)
@@ -47,7 +47,7 @@ struct lock_profile_t {
         * how long threads have waited for the lock in this mutex so far
         */
        timeval_t waited;
-       
+
        /**
         * backtrace where mutex has been created
         */
@@ -81,7 +81,7 @@ static void profiler_init(lock_profile_t *profile)
 #define profiler_start(profile) { \
        struct timeval _start, _end, _diff; \
        time_monotonic(&_start);
-       
+
 #define profiler_end(profile) \
        time_monotonic(&_end); \
        timersub(&_end, &_start, &_diff); \
@@ -106,17 +106,17 @@ struct private_mutex_t {
         * public functions
         */
        mutex_t public;
-       
+
        /**
         * wrapped pthread mutex
         */
        pthread_mutex_t mutex;
-       
+
        /**
         * is this a recursiv emutex, implementing private_r_mutex_t?
         */
        bool recursive;
-       
+
        /**
         * profiling info, if enabled
         */
@@ -132,12 +132,12 @@ struct private_r_mutex_t {
         * Extends private_mutex_t
         */
        private_mutex_t generic;
-       
+
        /**
         * thread which currently owns mutex
         */
        pthread_t thread;
-       
+
        /**
         * times we have locked the lock, stored per thread
         */
@@ -153,7 +153,7 @@ struct private_condvar_t {
         * public functions
         */
        condvar_t public;
-       
+
        /**
         * wrapped pthread condvar
         */
@@ -169,12 +169,12 @@ struct private_rwlock_t {
         * public functions
         */
        rwlock_t public;
-       
+
        /**
         * wrapped pthread rwlock
         */
        pthread_rwlock_t rwlock;
-       
+
        /**
         * profiling info, if enabled
         */
@@ -187,7 +187,7 @@ struct private_rwlock_t {
 static void lock(private_mutex_t *this)
 {
        int err;
-       
+
        profiler_start(&this->profile);
        err = pthread_mutex_lock(&this->mutex);
        if (err)
@@ -203,7 +203,7 @@ static void lock(private_mutex_t *this)
 static void unlock(private_mutex_t *this)
 {
        int err;
-       
+
        err = pthread_mutex_unlock(&this->mutex);
        if (err)
        {
@@ -221,7 +221,7 @@ static void lock_r(private_r_mutex_t *this)
        if (this->thread == self)
        {
                uintptr_t times;
-               
+
                /* times++ */
                times = (uintptr_t)pthread_getspecific(this->times);
                pthread_setspecific(this->times, (void*)times + 1);
@@ -245,7 +245,7 @@ static void unlock_r(private_r_mutex_t *this)
        /* times-- */
        times = (uintptr_t)pthread_getspecific(this->times);
        pthread_setspecific(this->times, (void*)--times);
-       
+
        if (times == 0)
        {
                this->thread = 0;
@@ -284,32 +284,32 @@ mutex_t *mutex_create(mutex_type_t type)
                case MUTEX_TYPE_RECURSIVE:
                {
                        private_r_mutex_t *this = malloc_thing(private_r_mutex_t);
-                       
+
                        this->generic.public.lock = (void(*)(mutex_t*))lock_r;
                        this->generic.public.unlock = (void(*)(mutex_t*))unlock_r;
-                       this->generic.public.destroy = (void(*)(mutex_t*))mutex_destroy_r;      
-                       
+                       this->generic.public.destroy = (void(*)(mutex_t*))mutex_destroy_r;
+
                        pthread_mutex_init(&this->generic.mutex, NULL);
                        pthread_key_create(&this->times, NULL);
                        this->generic.recursive = TRUE;
                        profiler_init(&this->generic.profile);
                        this->thread = 0;
-                       
+
                        return &this->generic.public;
                }
                case MUTEX_TYPE_DEFAULT:
                default:
                {
                        private_mutex_t *this = malloc_thing(private_mutex_t);
-               
+
                        this->public.lock = (void(*)(mutex_t*))lock;
                        this->public.unlock = (void(*)(mutex_t*))unlock;
                        this->public.destroy = (void(*)(mutex_t*))mutex_destroy;
-                       
+
                        pthread_mutex_init(&this->mutex, NULL);
                        this->recursive = FALSE;
                        profiler_init(&this->profile);
-                       
+
                        return &this->public;
                }
        }
@@ -323,7 +323,7 @@ static void _wait(private_condvar_t *this, private_mutex_t *mutex)
        if (mutex->recursive)
        {
                private_r_mutex_t* recursive = (private_r_mutex_t*)mutex;
-               
+
                /* mutex owner gets cleared during condvar wait */
                recursive->thread = 0;
                pthread_cond_wait(&this->condvar, &mutex->mutex);
@@ -343,14 +343,14 @@ static bool timed_wait_abs(private_condvar_t *this, private_mutex_t *mutex,
 {
        struct timespec ts;
        bool timed_out;
-       
+
        ts.tv_sec = time.tv_sec;
        ts.tv_nsec = time.tv_usec * 1000;
-       
+
        if (mutex->recursive)
        {
                private_r_mutex_t* recursive = (private_r_mutex_t*)mutex;
-               
+
                recursive->thread = 0;
                timed_out = pthread_cond_timedwait(&this->condvar, &mutex->mutex,
                                                                                   &ts) == ETIMEDOUT;
@@ -372,15 +372,15 @@ static bool timed_wait(private_condvar_t *this, private_mutex_t *mutex,
 {
        timeval_t tv;
        u_int s, ms;
-       
+
        time_monotonic(&tv);
-       
+
        s = timeout / 1000;
        ms = timeout % 1000;
-       
+
        tv.tv_sec += s;
        tv.tv_usec += ms * 1000;
-       
+
        if (tv.tv_usec > 1000000 /* 1s */)
        {
                tv.tv_usec -= 1000000;
@@ -426,21 +426,21 @@ condvar_t *condvar_create(condvar_type_t type)
                {
                        pthread_condattr_t condattr;
                        private_condvar_t *this = malloc_thing(private_condvar_t);
-                       
+
                        this->public.wait = (void(*)(condvar_t*, mutex_t *mutex))_wait;
                        this->public.timed_wait = (bool(*)(condvar_t*, mutex_t *mutex, u_int timeout))timed_wait;
                        this->public.timed_wait_abs = (bool(*)(condvar_t*, mutex_t *mutex, timeval_t time))timed_wait_abs;
                        this->public.signal = (void(*)(condvar_t*))_signal;
                        this->public.broadcast = (void(*)(condvar_t*))broadcast;
                        this->public.destroy = (void(*)(condvar_t*))condvar_destroy;
-                       
+
                        pthread_condattr_init(&condattr);
 #ifdef HAVE_CONDATTR_CLOCK_MONOTONIC
                        pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
 #endif
                        pthread_cond_init(&this->condvar, &condattr);
                        pthread_condattr_destroy(&condattr);
-                       
+
                        return &this->public;
                }
        }
@@ -452,7 +452,7 @@ condvar_t *condvar_create(condvar_type_t type)
 static void read_lock(private_rwlock_t *this)
 {
        int err;
-       
+
        profiler_start(&this->profile);
        err = pthread_rwlock_rdlock(&this->rwlock);
        if (err != 0)
@@ -468,7 +468,7 @@ static void read_lock(private_rwlock_t *this)
 static void write_lock(private_rwlock_t *this)
 {
        int err;
-       
+
        profiler_start(&this->profile);
        err = pthread_rwlock_wrlock(&this->rwlock);
        if (err != 0)
@@ -492,7 +492,7 @@ static bool try_write_lock(private_rwlock_t *this)
 static void rw_unlock(private_rwlock_t *this)
 {
        int err;
-       
+
        err = pthread_rwlock_unlock(&this->rwlock);
        if (err != 0)
        {
@@ -521,16 +521,16 @@ rwlock_t *rwlock_create(rwlock_type_t type)
                default:
                {
                        private_rwlock_t *this = malloc_thing(private_rwlock_t);
-                       
+
                        this->public.read_lock = (void(*)(rwlock_t*))read_lock;
                        this->public.write_lock = (void(*)(rwlock_t*))write_lock;
                        this->public.try_write_lock = (bool(*)(rwlock_t*))try_write_lock;
                        this->public.unlock = (void(*)(rwlock_t*))rw_unlock;
                        this->public.destroy = (void(*)(rwlock_t*))rw_destroy;
-                       
+
                        pthread_rwlock_init(&this->rwlock, NULL);
                        profiler_init(&this->profile);
-                       
+
                        return &this->public;
                }
        }
index 39763f901c37a1f5834b850738251711bc811882..8e53c82ca029a3d9cfd646fec64d421a8e9704a9 100644 (file)
@@ -93,12 +93,12 @@ struct mutex_t {
         * Acquire the lock to the mutex.
         */
        void (*lock)(mutex_t *this);
-       
+
        /**
         * Release the lock on the mutex.
         */
        void (*unlock)(mutex_t *this);
-       
+
        /**
         * Destroy a mutex instance.
         */
@@ -116,7 +116,7 @@ struct condvar_t {
         * @param mutex                 mutex to release while waiting
         */
        void (*wait)(condvar_t *this, mutex_t *mutex);
-       
+
        /**
         * Wait on a condvar until it gets signalized, or times out.
         *
@@ -125,7 +125,7 @@ struct condvar_t {
         * @return                              TRUE if timed out, FALSE otherwise
         */
        bool (*timed_wait)(condvar_t *this, mutex_t *mutex, u_int timeout);
-       
+
        /**
         * Wait on a condvar until it gets signalized, or times out.
         *
@@ -137,17 +137,17 @@ struct condvar_t {
         * @return                              TRUE if timed out, FALSE otherwise
         */
        bool (*timed_wait_abs)(condvar_t *this, mutex_t *mutex, timeval_t tv);
-       
+
        /**
         * Wake up a single thread in a condvar.
         */
        void (*signal)(condvar_t *this);
-       
+
        /**
         * Wake up all threads in a condvar.
         */
        void (*broadcast)(condvar_t *this);
-       
+
        /**
         * Destroy a condvar and free its resources.
         */
@@ -163,12 +163,12 @@ struct rwlock_t {
         * Acquire the read lock.
         */
        void (*read_lock)(rwlock_t *this);
-       
+
        /**
         * Acquire the write lock.
         */
        void (*write_lock)(rwlock_t *this);
-       
+
        /**
         * Try to acquire the write lock.
         *
@@ -176,13 +176,13 @@ struct rwlock_t {
         *
         * @return              TRUE if lock acquired
         */
-       bool (*try_write_lock)(rwlock_t *this); 
-       
+       bool (*try_write_lock)(rwlock_t *this);
+
        /**
         * Release any acquired lock.
         */
        void (*unlock)(rwlock_t *this);
-       
+
        /**
         * Destroy the read-write lock.
         */
index bf47e6b98078ed114b0e14a3b2b732c92cf7256e..bf528caa0675b90370e094c9f81b659f00144f5e 100644 (file)
@@ -6,7 +6,7 @@
  * under the terms of the GNU Library General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at your
  * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
@@ -83,7 +83,7 @@ bool from(private_options_t *this, char *filename, int *argcp, char **argvp[],
                DBG1("optionsfrom called %d times by \"%s\" - looping?", this->nuses + 1, (*argvp)[0]);
                return FALSE;
        }
-       
+
        fd = fopen(filename, "r");
        if (fd == NULL)
        {
index 05269f4f539763d27f6123ef9078a18a4955b664..b0a9d0096fa87fc50f04a612e403dfa90df8ee1a 100644 (file)
@@ -13,7 +13,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  */
+
 /**
  * @defgroup optionsfrom optionsfrom
  * @{ @ingroup utils
@@ -28,7 +28,7 @@ typedef struct options_t options_t;
  * Reads additional command line arguments from a file
  */
 struct options_t {
-       
+
        /**
         * Check if the PKCS#7 contentType is data
         *
index 5f9c3b623cdeb5f0ab18f22260deb2608b38b40b..dd469cee400a8ec1c887e48a80620817227a9d80 100644 (file)
@@ -30,7 +30,7 @@ struct private_auth_controller_t {
         * public functions
         */
        auth_controller_t public;
-       
+
        /**
         * manager instance
         */
@@ -47,7 +47,7 @@ static void login(private_auth_controller_t *this, request_t *request)
 static void check(private_auth_controller_t *this, request_t *request)
 {
        char *username, *password;
-       
+
        username = request->get_query_data(request, "username");
        password = request->get_query_data(request, "password");
        if (username && password &&
@@ -87,11 +87,11 @@ static void handle(private_auth_controller_t *this,
                {
                        return login(this, request);
                }
-               else if (streq(action, "check")) 
+               else if (streq(action, "check"))
                {
                        return check(this, request);
                }
-               else if (streq(action, "logout")) 
+               else if (streq(action, "logout"))
                {
                        return logout(this, request);
                }
@@ -117,9 +117,9 @@ controller_t *auth_controller_create(context_t *context, void *param)
        this->public.controller.get_name = (char*(*)(controller_t*))get_name;
        this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
        this->public.controller.destroy = (void(*)(controller_t*))destroy;
-       
+
        this->manager = (manager_t*)context;
-       
+
        return &this->public.controller;
 }
 
index dda2938a1e015637df16424a399c33049a682320..828a4ac9729dad124a30dbf2f2dd5ccc7e05d991 100644 (file)
@@ -33,7 +33,7 @@ struct private_config_controller_t {
         * public functions
         */
        config_controller_t public;
-       
+
        /**
         * manager instance
         */
@@ -54,7 +54,7 @@ static void process_peerconfig(private_config_controller_t *this,
        {
                if (streq(name, "name"))
                {
-                       config = value; 
+                       config = value;
                }
                else if (streq(name, "ikeconfig"))
                {
@@ -80,7 +80,7 @@ static void process_peerconfig(private_config_controller_t *this,
                                if (streq(name, "childconfig"))
                                {
                                        int num = 0;
-                                       
+
                                        e2 = xml->children(xml);
                                        while (e2->enumerate(e2, &xml, &name, &value))
                                        {
@@ -199,9 +199,9 @@ controller_t *config_controller_create(context_t *context, void *param)
        this->public.controller.get_name = (char*(*)(controller_t*))get_name;
        this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
        this->public.controller.destroy = (void(*)(controller_t*))destroy;
-       
+
        this->manager = (manager_t*)context;
-       
+
        return &this->public.controller;
 }
 
index c22591182cbacca3a0cbf13300091c983fd98745..fdf66bf14418fb6cab0ceb25d1628ffd859972b2 100644 (file)
@@ -33,7 +33,7 @@ struct private_control_controller_t {
         * public functions
         */
        control_controller_t public;
-       
+
        /**
         * manager instance
         */
@@ -50,7 +50,7 @@ static void handle_result(private_control_controller_t *this, request_t *r,
        xml_t *xml;
        char *name, *value;
        int num = 0;
-       
+
        if (e)
        {
                while (e->enumerate(e, &xml, &name, &value))
@@ -113,7 +113,7 @@ static void terminate(private_control_controller_t *this, request_t *r,
 {
        gateway_t *gateway;
        enumerator_t *e;
-       
+
        r->setf(r, "title=Terminate %s SA %d", ike ? "IKE" : "CHILD", id);
        gateway = this->manager->select_gateway(this->manager, 0);
        e = gateway->terminate(gateway, ike, id);
@@ -145,7 +145,7 @@ static void handle(private_control_controller_t *this,
        if (action)
        {
                u_int32_t id;
-       
+
                if (streq(action, "terminateike"))
                {
                        if (str && (id = atoi(str)))
@@ -196,9 +196,9 @@ controller_t *control_controller_create(context_t *context, void *param)
        this->public.controller.get_name = (char*(*)(controller_t*))get_name;
        this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
        this->public.controller.destroy = (void(*)(controller_t*))destroy;
-       
+
        this->manager = (manager_t*)context;
-       
+
        return &this->public.controller;
 }
 
index 164bf5921ec6d5705e57ace925ac400f48196d20..9fca220e9e4244c2947034d20f0244fdbd76fbad 100644 (file)
@@ -31,12 +31,12 @@ struct private_gateway_controller_t {
         * public functions
         */
        gateway_controller_t public;
-       
+
        /**
         * manager instance
         */
        manager_t *manager;
-       
+
 };
 
 static void list(private_gateway_controller_t *this, request_t *request)
@@ -44,7 +44,7 @@ static void list(private_gateway_controller_t *this, request_t *request)
        enumerator_t *enumerator;
        char *name, *address;
        int id, port;
-       
+
        enumerator = this->manager->create_gateway_enumerator(this->manager);
        while (enumerator->enumerate(enumerator, &id, &name, &port, &address))
        {
@@ -69,7 +69,7 @@ static void list(private_gateway_controller_t *this, request_t *request)
 static void _select(private_gateway_controller_t *this, request_t *request)
 {
        char *id;
-       
+
        id = request->get_query_data(request, "gateway");
        if (id)
        {
@@ -106,7 +106,7 @@ static void handle(private_gateway_controller_t *this,
                {
                        return list(this, request);
                }
-               else if (streq(action, "select")) 
+               else if (streq(action, "select"))
                {
                        return _select(this, request);
                }
@@ -133,9 +133,9 @@ controller_t *gateway_controller_create(context_t *context, void *param)
        this->public.controller.get_name = (char*(*)(controller_t*))get_name;
        this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
        this->public.controller.destroy = (void(*)(controller_t*))destroy;
-       
+
        this->manager = (manager_t*)context;
-       
+
        return &this->public.controller;
 }
 
index c35ff42e68adc4882db5012ae330aeab05087382..afa4a67f8c60924dcd537b79c39ac9ff9275de40 100644 (file)
@@ -33,7 +33,7 @@ struct private_ikesa_controller_t {
         * public functions
         */
        ikesa_controller_t public;
-       
+
        /**
         * manager instance
         */
@@ -50,7 +50,7 @@ static void process_childsa(private_ikesa_controller_t *this, char *id,
        enumerator_t *e1, *e2;
        char *name, *value, *reqid = "", *section = "";
        int num = 0;
-       
+
        while (e->enumerate(e, &xml, &name, &value))
        {
                if (streq(name, "reqid"))
@@ -106,7 +106,7 @@ static void process_ikesa(private_ikesa_controller_t *this,
        {
                if (streq(name, "id"))
                {
-                       id = value;     
+                       id = value;
                }
                else if (streq(name, "local") || streq(name, "remote"))
                {
@@ -223,9 +223,9 @@ controller_t *ikesa_controller_create(context_t *context, void *param)
        this->public.controller.get_name = (char*(*)(controller_t*))get_name;
        this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
        this->public.controller.destroy = (void(*)(controller_t*))destroy;
-       
+
        this->manager = (manager_t*)context;
-       
+
        return &this->public.controller;
 }
 
index f0d557c71b5ef5bbc22082f48317559af9964a34..fd462afa7595ec0d74fca4d806b276bf9a41218c 100644 (file)
@@ -35,22 +35,22 @@ struct private_gateway_t {
         * public functions
         */
        gateway_t public;
-       
+
        /**
         * name of the gateway
         */
        char *name;
-       
+
        /**
         * host to connect using tcp
         */
        host_t *host;
-       
+
        /**
         * socket file descriptor, > 0 if connected
         */
        int fd;
-       
+
        /**
         * unique id assigned to each xml message
         */
@@ -83,7 +83,7 @@ static bool connect_(private_gateway_t *this)
                addr = (struct sockaddr*)&unix_addr;
                len = sizeof(unix_addr);
        }
-       
+
        this->fd = socket(family, SOCK_STREAM, 0);
        if (this->fd < 0)
        {
@@ -115,7 +115,7 @@ static char* request(private_gateway_t *this, char *xml, ...)
                char buf[8096];
                ssize_t len;
                va_list args;
-               
+
                va_start(args, xml);
                len = vsnprintf(buf, sizeof(buf), xml, args);
                va_end(args);
@@ -153,7 +153,7 @@ static enumerator_t* query_ikesalist(private_gateway_t *this)
        char *str, *name, *value;
        xml_t *xml;
        enumerator_t *e1, *e2, *e3, *e4 = NULL;
-       
+
        str = request(this,     "<message type=\"request\" id=\"%d\">"
                                                        "<query>"
                                                                "<ikesalist/>"
@@ -168,7 +168,7 @@ static enumerator_t* query_ikesalist(private_gateway_t *this)
        {
                return NULL;
        }
-       
+
        e1 = xml->children(xml);
        free(str);
        while (e1->enumerate(e1, &xml, &name, &value))
@@ -202,7 +202,7 @@ static enumerator_t* query_ikesalist(private_gateway_t *this)
        return NULL;
 }
 
-       
+
 /**
  * Implementation of gateway_t.query_configlist.
  */
@@ -211,7 +211,7 @@ static enumerator_t* query_configlist(private_gateway_t *this)
        char *str, *name, *value;
        xml_t *xml;
        enumerator_t *e1, *e2, *e3, *e4 = NULL;
-       
+
        str = request(this,     "<message type=\"request\" id=\"%d\">"
                                                        "<query>"
                                                                "<configlist/>"
@@ -226,7 +226,7 @@ static enumerator_t* query_configlist(private_gateway_t *this)
        {
                return NULL;
        }
-       
+
        e1 = xml->children(xml);
        free(str);
        while (e1->enumerate(e1, &xml, &name, &value))
@@ -308,7 +308,7 @@ static enumerator_t* read_result(private_gateway_t *this, char *res)
 static enumerator_t* initiate(private_gateway_t *this, bool ike, char *name)
 {
        char *str, *kind;
-       
+
        if (ike)
        {
                kind = "ike";
@@ -331,7 +331,7 @@ static enumerator_t* initiate(private_gateway_t *this, bool ike, char *name)
 static enumerator_t* terminate(private_gateway_t *this, bool ike, u_int32_t id)
 {
        char *str, *kind;
-       
+
        if (ike)
        {
                kind = "ike";
@@ -368,19 +368,19 @@ static void destroy(private_gateway_t *this)
 static private_gateway_t *gateway_create(char *name)
 {
        private_gateway_t *this = malloc_thing(private_gateway_t);
-       
+
        this->public.request = (char*(*)(gateway_t*, char *xml))request;
        this->public.query_ikesalist = (enumerator_t*(*)(gateway_t*))query_ikesalist;
        this->public.query_configlist = (enumerator_t*(*)(gateway_t*))query_configlist;
        this->public.initiate = (enumerator_t*(*)(gateway_t*, bool ike, char *name))initiate;
        this->public.terminate = (enumerator_t*(*)(gateway_t*, bool ike, u_int32_t id))terminate;
        this->public.destroy = (void(*)(gateway_t*))destroy;
-       
+
        this->name = strdup(name);
        this->host = NULL;
        this->fd = -1;
        this->xmlid = 1;
-       
+
        return this;
 }
 
@@ -390,9 +390,9 @@ static private_gateway_t *gateway_create(char *name)
 gateway_t *gateway_create_tcp(char *name, host_t *host)
 {
        private_gateway_t *this = gateway_create(name);
-       
+
        this->host = host;
-       
+
        return &this->public;
 }
 
@@ -402,7 +402,7 @@ gateway_t *gateway_create_tcp(char *name, host_t *host)
 gateway_t *gateway_create_unix(char *name)
 {
        private_gateway_t *this = gateway_create(name);
-       
+
        return &this->public;
 }
 
index 7c76fa4749e4b37ff79cde6f21952453b0c96169..54aade7b1f1c382870432afce5d4d6571ae91ae9 100644 (file)
@@ -30,7 +30,7 @@ typedef struct gateway_t gateway_t;
  * A connection to a gateway.
  */
 struct gateway_t {
-       
+
        /**
         * Send an XML request to the gateway.
         *
@@ -38,21 +38,21 @@ struct gateway_t {
         * @return                      allocated xml response string
         */
        char* (*request)(gateway_t *this, char *xml);
-       
+
        /**
         * Query the list of IKE_SAs and all its children.
         *
         * @return                      enumerator over ikesa XML elements
         */
        enumerator_t* (*query_ikesalist)(gateway_t *this);
-       
+
        /**
         * Query the list of peer configs and its subconfigs.
         *
         * @return                      enumerator over peerconfig XML elements
         */
        enumerator_t* (*query_configlist)(gateway_t *this);
-       
+
        /**
         * Terminate an IKE or a CHILD SA.
         *
@@ -61,7 +61,7 @@ struct gateway_t {
         * @return                      enumerator over control response XML children
         */
        enumerator_t* (*terminate)(gateway_t *this, bool ike, u_int32_t id);
-       
+
        /**
         * Initiate an IKE or a CHILD SA.
         *
@@ -70,7 +70,7 @@ struct gateway_t {
         * @return                      enumerator over control response XML children
         */
        enumerator_t* (*initiate)(gateway_t *this, bool ike, char *name);
-       
+
        /**
         * Destroy a gateway instance.
         */
index 3d2c4de6b8eca5a8c1ba988aedb0255749ffa569..2db0f215aca3bc05d2eacea6f0429203cf42310e 100644 (file)
@@ -40,7 +40,7 @@ int main (int arc, char *argv[])
        {
                return 1;
        }
-       
+
        socket = lib->settings->get_str(lib->settings, "manager.socket", NULL);
        debug = lib->settings->get_bool(lib->settings, "manager.debug", FALSE);
        timeout = lib->settings->get_time(lib->settings, "manager.timeout", 900);
@@ -51,13 +51,13 @@ int main (int arc, char *argv[])
                DBG1("database URI undefined, set manager.database in strongswan.conf");
                return 1;
        }
-       
+
        storage = storage_create(database);
        if (storage == NULL)
        {
                return 1;
        }
-       
+
        dispatcher = dispatcher_create(socket, debug, timeout,
                                                (context_constructor_t)manager_create, storage);
        dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
@@ -65,14 +65,14 @@ int main (int arc, char *argv[])
        dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
        dispatcher->add_controller(dispatcher, control_controller_create, NULL);
        dispatcher->add_controller(dispatcher, config_controller_create, NULL);
-       
+
        dispatcher->run(dispatcher, threads);
-       
+
        dispatcher->waitsignal(dispatcher);
-       
+
        dispatcher->destroy(dispatcher);
        storage->destroy(storage);
-       
+
        library_deinit();
 
     return 0;
index 72f402a487066e331c76f8a17834cef9047301f6..fb89c6b722e00f7ec80f811e668ec826419015aa 100644 (file)
@@ -30,23 +30,23 @@ struct private_manager_t {
         * public functions
         */
        manager_t public;
-       
+
        /**
         * underlying storage database
         */
        storage_t *store;
-       
+
        /**
         * user id, if we are logged in
         */
        int user;
-       
+
        /**
         * selected gateway
         */
        gateway_t *gateway;
-};     
-       
+};
+
 /**
  * Implementation of manager_t.create_gateway_enumerator.
  */
@@ -66,10 +66,10 @@ static gateway_t* select_gateway(private_manager_t *this, int select_id)
                int id, port;
                char *name, *address;
                host_t *host;
-               
+
                if (this->gateway) this->gateway->destroy(this->gateway);
                this->gateway = NULL;
-               
+
                enumerator = this->store->create_gateway_enumerator(this->store, this->user);
                while (enumerator->enumerate(enumerator, &id, &name, &port, &address))
                {
@@ -143,18 +143,18 @@ static void destroy(private_manager_t *this)
 manager_t *manager_create(storage_t *storage)
 {
        private_manager_t *this = malloc_thing(private_manager_t);
-       
+
        this->public.login = (bool(*)(manager_t*, char *username, char *password))login;
        this->public.logged_in = (bool(*)(manager_t*))logged_in;
        this->public.logout = (void(*)(manager_t*))logout;
        this->public.create_gateway_enumerator = (enumerator_t*(*)(manager_t*))create_gateway_enumerator;
        this->public.select_gateway = (gateway_t*(*)(manager_t*, int id))select_gateway;
        this->public.context.destroy = (void(*)(context_t*))destroy;
-       
+
        this->user = 0;
        this->store = storage;
        this->gateway = NULL;
-       
+
        return &this->public;
 }
 
index dc5fc18311bcf8ffb05350d813bc9955a1aff746..231b0f5f386de4f2ac91738c24dad2157f35cc34 100644 (file)
@@ -44,7 +44,7 @@ struct manager_t {
         * implements context_t interface
         */
        context_t context;
-       
+
        /**
         * Create an iterator over all configured gateways.
         *
@@ -54,7 +54,7 @@ struct manager_t {
         * @return                      enumerator
         */
        enumerator_t* (*create_gateway_enumerator)(manager_t *this);
-       
+
        /**
         * Select a gateway.
         *
@@ -65,7 +65,7 @@ struct manager_t {
         * @return                      selected gateway, or NULL
         */
        gateway_t* (*select_gateway)(manager_t *this, int id);
-       
+
        /**
         * Try to log in.
         *
@@ -74,14 +74,14 @@ struct manager_t {
         * @return                      TRUE if login successful
         */
        bool (*login)(manager_t *this, char *username, char *password);
-       
+
        /**
         * Check if user logged in.
         *
         * @return                      TRUE if logged in
         */
        bool (*logged_in)(manager_t *this);
-       
+
        /**
         * Log out.
         */
index 00e688e088c1bf108189854d2e632bfe0afeca42..f7635ea7175e7daecf7a83a139ec08c5d3fc5627 100644 (file)
@@ -30,7 +30,7 @@ struct private_storage_t {
         * public functions
         */
        storage_t public;
-       
+
        /**
         * database connection
         */
@@ -47,7 +47,7 @@ static int login(private_storage_t *this, char *username, char *password)
        size_t username_len, password_len;
        int uid = 0;
        enumerator_t *enumerator;
-       
+
        /* hash = SHA1( username | password ) */
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (hasher == NULL)
@@ -63,8 +63,8 @@ static int login(private_storage_t *this, char *username, char *password)
        hasher->get_hash(hasher, data, hash.ptr);
        hasher->destroy(hasher);
        hex_str = chunk_to_hex(hash, NULL, FALSE);
-       
-       enumerator = this->db->query(this->db, 
+
+       enumerator = this->db->query(this->db,
                        "SELECT oid FROM users WHERE username = ? AND password = ?;",
                        DB_TEXT, username, DB_TEXT, hex_str.ptr,
                        DB_INT);
@@ -83,8 +83,8 @@ static int login(private_storage_t *this, char *username, char *password)
 static enumerator_t* create_gateway_enumerator(private_storage_t *this, int user)
 {
        enumerator_t *enumerator;
-       
-       enumerator = this->db->query(this->db, 
+
+       enumerator = this->db->query(this->db,
                        "SELECT gateways.oid AS gid, name, port, address FROM "
                        "gateways, user_gateway AS ug ON gid = ug.gateway WHERE ug.user = ?;",
                        DB_INT, user,
@@ -111,11 +111,11 @@ static void destroy(private_storage_t *this)
 storage_t *storage_create(char *uri)
 {
        private_storage_t *this = malloc_thing(private_storage_t);
-       
+
        this->public.login = (int(*)(storage_t*, char *username, char *password))login;
        this->public.create_gateway_enumerator = (enumerator_t*(*)(storage_t*,int))create_gateway_enumerator;
        this->public.destroy = (void(*)(storage_t*))destroy;
-       
+
        this->db = lib->db->create(lib->db, uri);
        if (this->db == NULL)
        {
index 2495b3a26d18211c4d2b53c467794eaf38c9f06f..5860d50ff08e5f581fcbfebf4c601a9f51c0672b 100644 (file)
@@ -39,7 +39,7 @@ struct storage_t {
         * @return                                      user ID if login good, 0 otherwise
         */
        int (*login)(storage_t *this, char *username, char *password);
-       
+
        /**
         * Create an iterator over the gateways.
         *
@@ -49,7 +49,7 @@ struct storage_t {
         * @param user                          user Id
         * @return                                      enumerator
         */
-       enumerator_t* (*create_gateway_enumerator)(storage_t *this, int user);  
+       enumerator_t* (*create_gateway_enumerator)(storage_t *this, int user);
 
        /**
      * Destroy a storage instance.
index 5aa2e3e1e9d0878f11f79bba799d42ac6ae6227a..a9ef60c2490fc95829a3bd8c35dfef2c66e1d17a 100644 (file)
@@ -32,22 +32,22 @@ struct private_xml_t {
         * public functions
         */
        xml_t public;
-       
+
        /**
         * root node of this xml (part)
         */
        xmlNode *node;
-       
+
        /**
         * document, only for root xml_t
         */
        xmlDoc *doc;
-       
+
        /**
         * Root xml_t*
         */
        private_xml_t *root;
-       
+
        /**
         * number of enumerator instances
         */
@@ -79,10 +79,10 @@ static bool child_enumerate(child_enum_t *e, private_xml_t **child,
        if (e->node)
        {
                xmlNode *text;
-               
+
                text = e->node->children;
                *value = NULL;
-               
+
                while (text && text->type != XML_TEXT_NODE)
                {
                        text = text->next;
@@ -109,7 +109,7 @@ static char* get_attribute(private_xml_t *this, char *name)
 }
 
 /**
- * destroy enumerator, and complete tree if this was the last enumerator 
+ * destroy enumerator, and complete tree if this was the last enumerator
  */
 static void child_destroy(child_enum_t *this)
 {
@@ -145,10 +145,10 @@ static enumerator_t* children(private_xml_t *this)
 xml_t *xml_create(char *xml)
 {
        private_xml_t *this = malloc_thing(private_xml_t);
-       
+
        this->public.get_attribute = (char*(*)(xml_t*,char*))get_attribute;
        this->public.children = (enumerator_t*(*)(xml_t*))children;
-       
+
        this->doc = xmlReadMemory(xml, strlen(xml), NULL, NULL, 0);
        if (this->doc == NULL)
        {
@@ -158,7 +158,7 @@ xml_t *xml_create(char *xml)
        this->node = xmlDocGetRootElement(this->doc);
        this->root = this;
        this->enums = 0;
-       
+
        return &this->public;
 }
 
index 230e0f925a51c17b3a96f45b11ef29ae53a87068..0c362fed1ff051cd6d8181cf2d772251f7f6bee6 100644 (file)
@@ -43,7 +43,7 @@ struct xml_t {
         * @return                      enumerator over (xml_t* child, char *name, char *value)
         */
        enumerator_t* (*children)(xml_t *this);
-       
+
        /**
         * Get an attribute value by its name.
         *
index 06c67901fff2f23b276dc078fd12f29dea6e9cf4..e1e4661e0601fc41c0ba40ab79c50681287e500a 100755 (executable)
@@ -42,8 +42,8 @@ struct private_peer_controller_t {
         * active user session
         */
        user_t *user;
-       
-       /** 
+
+       /**
         * underlying database
         */
        database_t *db;
@@ -55,19 +55,19 @@ struct private_peer_controller_t {
 static void list(private_peer_controller_t *this, request_t *request)
 {
        enumerator_t *query;
-       
+
        query = this->db->query(this->db,
                        "SELECT id, alias, keyid FROM peer WHERE user = ? ORDER BY alias",
                        DB_UINT, this->user->get_user(this->user),
                        DB_UINT, DB_TEXT, DB_BLOB);
-       
+
        if (query)
        {
                u_int id;
                char *alias;
                chunk_t keyid;
                identification_t *identifier;
-       
+
                while (query->enumerate(query, &id, &alias, &keyid))
                {
                        request->setf(request, "peers.%d.alias=%s", id, alias);
@@ -89,7 +89,7 @@ static bool verify_alias(private_peer_controller_t *this, request_t *request,
        if (!alias || *alias == '\0')
        {
                request->setf(request, "error=Alias is missing.");
-               return FALSE;   
+               return FALSE;
        }
        while (*alias != '\0')
        {
@@ -122,7 +122,7 @@ static bool parse_public_key(private_peer_controller_t *this,
 {
        public_key_t *public;
        chunk_t blob, id;
-               
+
        if (!public_key || *public_key == '\0')
        {
                request->setf(request, "error=Public key is missing.");
@@ -156,7 +156,7 @@ static bool parse_public_key(private_peer_controller_t *this,
 static void add(private_peer_controller_t *this, request_t *request)
 {
        char *alias = "", *public_key = "";
-       
+
        if (request->get_query_data(request, "back"))
        {
                return request->redirect(request, "peer/list");
@@ -164,10 +164,10 @@ static void add(private_peer_controller_t *this, request_t *request)
        while (request->get_query_data(request, "add"))
        {
                chunk_t encoding, keyid;
-       
+
                alias = request->get_query_data(request, "alias");
                public_key = request->get_query_data(request, "public_key");
-               
+
                if (!verify_alias(this, request, alias))
                {
                        break;
@@ -194,7 +194,7 @@ static void add(private_peer_controller_t *this, request_t *request)
        }
        request->set(request, "alias", alias);
        request->set(request, "public_key", public_key);
-       
+
        return request->render(request, "templates/peer/add.cs");
 }
 
@@ -209,7 +209,7 @@ char* pem_encode(chunk_t der)
        char *pem;
        chunk_t base64;
        int i = 0;
-       
+
        base64 = chunk_to_base64(der, NULL);
        len = strlen(begin) + base64.len + base64.len/64 + strlen(end) + 2;
        pem = malloc(len + 1);
@@ -223,7 +223,7 @@ char* pem_encode(chunk_t der)
        }
        while (i < base64.len - 2);
        strcat(pem, end);
-       
+
        free(base64.ptr);
        return pem;
 }
@@ -235,7 +235,7 @@ static void edit(private_peer_controller_t *this, request_t *request, int id)
 {
        char *alias = "", *public_key = "", *pem;
        chunk_t encoding, keyid;
-       
+
        if (request->get_query_data(request, "back"))
        {
                return request->redirect(request, "peer/list");
@@ -253,7 +253,7 @@ static void edit(private_peer_controller_t *this, request_t *request, int id)
                {
                        alias = request->get_query_data(request, "alias");
                        public_key = request->get_query_data(request, "public_key");
-               
+
                        if (!verify_alias(this, request, alias))
                        {
                                break;
@@ -333,7 +333,7 @@ static void handle(private_peer_controller_t *this, request_t *request,
                {
                        id = atoi(idstr);
                }
-               
+
                if (streq(action, "list"))
                {
                        return list(this, request);
index bc4717e32a52e4ccefbc8bd31b47616b00f0b26d..0f25799d82f2b2a2d7db1e18a240d202ec76e16b 100755 (executable)
@@ -37,12 +37,12 @@ struct private_user_controller_t {
         * database connection
         */
        database_t *db;
-       
+
        /**
         * user session
         */
        user_t *user;
-       
+
        /**
         * minimum required password lenght
         */
@@ -56,7 +56,7 @@ static chunk_t hash_password(char *login, char *password)
 {
        hasher_t *hasher;
        chunk_t hash, data;
-       
+
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
        if (!hasher)
        {
@@ -77,16 +77,16 @@ static void login(private_user_controller_t *this, request_t *request)
        if (request->get_query_data(request, "submit"))
        {
                char *login, *password;
-               
+
                login = request->get_query_data(request, "login");
                password = request->get_query_data(request, "password");
-               
+
                if (login && password)
                {
                        enumerator_t *query;
                        u_int id = 0;
                        chunk_t hash;
-                       
+
                        hash = hash_password(login, password);
                        query = this->db->query(this->db,
                                                "SELECT id FROM user WHERE login = ? AND password = ?",
@@ -126,7 +126,7 @@ static bool verify_login(private_user_controller_t *this, request_t *request,
        if (!login || *login == '\0')
        {
                request->setf(request, "error=Username is missing.");
-               return FALSE;   
+               return FALSE;
        }
        while (*login != '\0')
        {
@@ -190,13 +190,13 @@ static void add(private_user_controller_t *this, request_t *request)
                login = request->get_query_data(request, "new_login");
                password = request->get_query_data(request, "new_password");
                confirm = request->get_query_data(request, "confirm_password");
-               
+
                if (!verify_login(this, request, login) ||
                        !verify_password(this, request, password, confirm))
                {
                        break;
                }
-               
+
                hash = hash_password(login, password);
                if (!hash.ptr || this->db->execute(this->db, &id,
                                                        "INSERT INTO user (login, password) VALUES (?, ?)",
@@ -222,7 +222,7 @@ static void edit(private_user_controller_t *this, request_t *request)
 {
        enumerator_t *query;
        char *old_login;
-       
+
        /* lookup old login */
        query = this->db->query(this->db, "SELECT login FROM user WHERE id = ?",
                                                        DB_INT, this->user->get_user(this->user),
@@ -256,12 +256,12 @@ static void edit(private_user_controller_t *this, request_t *request)
        {
                char *new_login, *old_pass, *new_pass, *confirm;
                chunk_t old_hash, new_hash;
-               
+
                new_login = request->get_query_data(request, "old_login");
                old_pass = request->get_query_data(request, "old_password");
                new_pass = request->get_query_data(request, "new_password");
                confirm = request->get_query_data(request, "confirm_password");
-               
+
                if (!verify_login(this, request, new_login) ||
                        !verify_password(this, request, new_pass, confirm))
                {
@@ -270,7 +270,7 @@ static void edit(private_user_controller_t *this, request_t *request)
                }
                old_hash = hash_password(old_login, old_pass);
                new_hash = hash_password(new_login, new_pass);
-               
+
                if (this->db->execute(this->db, NULL,
                        "UPDATE user SET login = ?, password = ? "
                        "WHERE id = ? AND password = ?",
index 76114a347203a70199a107bbcc1e774173ae61ec..9ed356042dd361aadac526331f7a4bcfea56c1a6 100755 (executable)
@@ -33,7 +33,7 @@ struct private_auth_filter_t {
         * user session\r
         */\r
        user_t *user;
-       
+
        /**
         * database connection
         */
@@ -50,7 +50,7 @@ static bool run(private_auth_filter_t *this, request_t *request,
        {
                enumerator_t *query;
                char *login;
-       
+
                query = this->db->query(this->db, "SELECT login FROM user WHERE id = ?",
                                                                DB_INT, this->user->get_user(this->user),
                                                                DB_TEXT);
index e4f878304217021faaf62413c13d297f9a022ed9..d66d01ecfb5f8fd8092016153e7fe5b2905d9e53 100644 (file)
@@ -32,14 +32,14 @@ int main(int arc, char *argv[])
        bool debug;
        char *uri;
        int timeout, threads;
-       
+
        library_init(STRONGSWAN_CONF);
        if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR,
                        lib->settings->get_str(lib->settings, "medsrv.load", PLUGINS)))
        {
                return 1;
        }
-       
+
        socket = lib->settings->get_str(lib->settings, "medsrv.socket", NULL);
        debug = lib->settings->get_bool(lib->settings, "medsrv.debug", FALSE);
        timeout = lib->settings->get_time(lib->settings, "medsrv.timeout", 900);
@@ -50,14 +50,14 @@ int main(int arc, char *argv[])
                fprintf(stderr, "database URI medsrv.database not defined.\n");
                return 1;
        }
-       
+
        db = lib->db->create(lib->db, uri);
        if (db == NULL)
        {
                fprintf(stderr, "opening database failed.\n");
                return 1;
        }
-       
+
        dispatcher = dispatcher_create(socket, debug, timeout,
                                                                   (context_constructor_t)user_create, db);
        dispatcher->add_filter(dispatcher,
@@ -66,13 +66,13 @@ int main(int arc, char *argv[])
                                                (controller_constructor_t)user_controller_create, db);
        dispatcher->add_controller(dispatcher,
                                                (controller_constructor_t)peer_controller_create, db);
-       
+
        dispatcher->run(dispatcher, threads);
-       
+
        dispatcher->waitsignal(dispatcher);
        dispatcher->destroy(dispatcher);
        db->destroy(db);
-       
+
        library_deinit();
        return 0;
 }
index 2d1c738ca42c4b192375e85c71f39c681be12a78..f14650f032fda214d09f0fd33b245c0b7d42c4cd 100644 (file)
@@ -25,17 +25,17 @@ typedef struct user_t user_t;
  * Per session context. Contains user user state and data.
  */
 struct user_t {
-       
+
        /**
         * implements context_t interface
         */
        context_t context;
-       
+
        /**
         * Set the user ID of the logged in user.
         */
        void (*set_user)(user_t *this, u_int id);
-       
+
        /**
         * Get the user ID of the logged in user.
         */
index d6e75efc31ccbbc766f5370d37f51d0b5251b5a4..766d7504ea4a99e4b36662cd51ff9e2dc988ca62 100755 (executable)
@@ -1,8 +1,8 @@
 /**
  * @file openac.c
- * 
+ *
  * @brief Generation of X.509 attribute certificates.
- * 
+ *
  */
 
 /*
@@ -85,7 +85,7 @@ static chunk_t read_serial(void)
        chunk_t hex, serial = chunk_empty;
        char one[] = {0x01};
        FILE *fd;
-       
+
        fd = fopen(OPENAC_SERIAL, "r");
        if (fd)
        {
@@ -152,7 +152,7 @@ static void openac_dbg(int level, char *fmt, ...)
        char buffer[8192];
        char *current = buffer, *next;
        va_list args;
-       
+
        if (level <= debug_level)
        {
                if (!stderr_quiet)
@@ -211,7 +211,7 @@ int main(int argc, char **argv)
        chunk_t attr_chunk = chunk_empty;
 
        int status = 1;
-       
+
        /* enable openac debugging hook */
        dbg = openac_dbg;
 
@@ -231,7 +231,7 @@ int main(int argc, char **argv)
                fprintf(stderr, "integrity check of openac failed\n");
                exit(SS_RC_DAEMON_INTEGRITY);
        }
-       if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, 
+       if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR,
                        lib->settings->get_str(lib->settings, "openac.load", PLUGINS)))
        {
                exit(SS_RC_INITIALIZATION_FAILED);
@@ -262,7 +262,7 @@ int main(int argc, char **argv)
                        { "debug", required_argument, NULL, 'd' },
                        { 0,0,0,0 }
                };
-       
+
                int c = getopt_long(argc, argv, "hv+:qc:k:p;u:g:D:H:S:E:o:d:", long_opts, NULL);
 
                /* Note: "breaking" from case terminates loop */
@@ -495,7 +495,7 @@ int main(int argc, char **argv)
                {
                        goto end;
                }
-       
+
                /* write the attribute certificate to file */
                attr_chunk = attr_cert->get_encoding(attr_cert);
                if (chunk_write(attr_chunk, outfile, "attribute cert", 0022, TRUE))
index a612a1b07b662e9a7780856c1e40919000170fb7..7e3560db65d46cc346e405cb734a2752023e7f49 100644 (file)
@@ -33,7 +33,7 @@
 static int usage(char *error)
 {
        FILE *out = stdout;
-       
+
        if (error)
        {
                out = stderr;
@@ -107,7 +107,7 @@ static int gen(int argc, char *argv[])
        u_int size = 0;
        private_key_t *key;
        chunk_t encoding;
-       
+
        struct option long_opts[] = {
                { "type", required_argument, NULL, 't' },
                { "size", required_argument, NULL, 's' },
@@ -205,7 +205,7 @@ static int pub(int argc, char *argv[])
        chunk_t encoding;
        char *file = NULL;
        void *cred;
-       
+
        struct option long_opts[] = {
                { "type", required_argument, NULL, 't' },
                { "outform", required_argument, NULL, 'f' },
@@ -263,7 +263,7 @@ static int pub(int argc, char *argv[])
                cred = lib->creds->create(lib->creds, type, subtype,
                                                                         BUILD_FROM_FD, 0, BUILD_END);
        }
-       
+
        if (type == CRED_PRIVATE_KEY)
        {
                private = cred;
@@ -321,7 +321,7 @@ static int keyid(int argc, char *argv[])
        char *file = NULL;
        void *cred;
        chunk_t id;
-       
+
        struct option long_opts[] = {
                { "type", required_argument, NULL, 't' },
                { "in", required_argument, NULL, 'i' },
@@ -382,7 +382,7 @@ static int keyid(int argc, char *argv[])
                fprintf(stderr, "parsing input failed\n");
                return 1;
        }
-       
+
        if (type == CRED_PRIVATE_KEY)
        {
                private = cred;
@@ -447,7 +447,7 @@ static int self(int argc, char *argv[])
        int lifetime = 1080;
        chunk_t serial, encoding;
        time_t not_before, not_after;
-       
+
        struct option long_opts[] = {
                { "type", required_argument, NULL, 't' },
                { "in", required_argument, NULL, 'i' },
@@ -457,7 +457,7 @@ static int self(int argc, char *argv[])
                { "digest", required_argument, NULL, 'h' },
                { 0,0,0,0 }
        };
-       
+
        while (TRUE)
        {
                switch (getopt_long(argc, argv, "", long_opts, NULL))
@@ -529,7 +529,7 @@ static int self(int argc, char *argv[])
                }
                break;
        }
-       
+
        if (!dn)
        {
                return usage("--dn is required");
@@ -625,13 +625,13 @@ static int verify(int argc, char *argv[])
        certificate_t *cert, *ca;
        char *file = NULL, *cafile = NULL;
        bool good = FALSE;
-       
+
        struct option long_opts[] = {
                { "in", required_argument, NULL, 'i' },
                { "ca", required_argument, NULL, 'c' },
                { 0,0,0,0 }
        };
-       
+
        while (TRUE)
        {
                switch (getopt_long(argc, argv, "", long_opts, NULL))
@@ -649,7 +649,7 @@ static int verify(int argc, char *argv[])
                }
                break;
        }
-       
+
        if (file)
        {
                cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
@@ -717,7 +717,7 @@ static int verify(int argc, char *argv[])
                ca->destroy(ca);
        }
        cert->destroy(cert);
-       
+
        return good ? 0 : 2;
 }
 
@@ -735,7 +735,7 @@ int main(int argc, char *argv[])
                { "verify", no_argument, NULL, 'v' },
                { 0,0,0,0 }
        };
-       
+
        atexit(library_deinit);
        if (!library_init(STRONGSWAN_CONF))
        {
@@ -752,7 +752,7 @@ int main(int argc, char *argv[])
        {
                exit(SS_RC_INITIALIZATION_FAILED);
        }
-       
+
        switch (getopt_long(argc, argv, "", long_opts, NULL))
        {
                case 'h':
index 0c36e59456aae4b3085ac4920e578e554a28acf8..769d77e83b2d930a30cc26e3146a9abf8356308e 100644 (file)
@@ -224,7 +224,7 @@ static int cmp_ietfAttr(ietfAttr_t *a,ietfAttr_t *b)
        /* cannot compare OID with STRING or OCTETS attributes */
        if (a->kind == IETF_ATTRIBUTE_OID && b->kind != IETF_ATTRIBUTE_OID)
                return 1;
-               
+
        cmp_len = a->value.len - b->value.len;
        len = (cmp_len < 0)? a->value.len : b->value.len;
        cmp_value = memcmp(a->value.ptr, b->value.ptr, len);
@@ -604,7 +604,7 @@ static void release_ietfAttr(ietfAttr_t* attr)
                        list = *plist;
                }
                *plist = list->next;
-               
+
                free(attr->value.ptr);
                free(attr);
                free(list);
@@ -654,7 +654,7 @@ static void free_first_acert(void)
  * Free all attribute certificates in the chained list
  */
 void free_acerts(void)
-{ 
+{
        while (x509acerts != NULL)
                free_first_acert();
 }
@@ -759,7 +759,7 @@ bool verify_x509acert(x509acert_t *ac, bool strict)
                dntoa(buf, BUF_LEN, ac->issuerName);
                DBG_log("issuer: '%s'",buf);
        )
-       
+
        ugh = check_ac_validity(ac);
 
        if (ugh != NULL)
@@ -822,7 +822,7 @@ void load_acerts(void)
                        {
                                char *filename = filelist[n]->d_name;
                                x509acert_t *ac;
-                               
+
                                ac = lib->creds->create(lib->creds, CRED_CERTIFICATE,
                                                        CERT_PLUTO_AC, BUILD_FROM_FILE, filename,
                                                        BUILD_END);
@@ -859,7 +859,7 @@ void format_groups(const ietfAttrList_t *list, char *buf, int len)
                                                        , (int)attr->value.len, attr->value.ptr);
 
                        first_group = FALSE;
-                       
+
                        /* return value of snprintf() up to glibc 2.0.6 */
                        if (written < 0)
                                break;
@@ -949,7 +949,7 @@ void list_acerts(bool utc)
 void list_groups(bool utc)
 {
        ietfAttrList_t *list = ietfAttributes;
-       
+
        if (list != NULL)
        {
                whack_log(RC_COMMENT, " ");
@@ -962,7 +962,7 @@ void list_groups(bool utc)
                ietfAttr_t *attr = list->attr;
 
                whack_log(RC_COMMENT, "%T, count: %d", &attr->installed, utc, attr->count);
-               
+
                switch (attr->kind)
                {
                case IETF_ATTRIBUTE_OCTETS:
index c25418fc117d5b0755be8f4d94f8a7ca9d60321b..e8f977950b80af82a6dff5ce0f5dbe922f8ecedf 100644 (file)
@@ -238,12 +238,12 @@ static void __alg_info_ike_add (struct alg_info_ike *alg_info, int ealg_id,
  * merging alg_info (ike_info) contents
  */
 
-static int default_ike_groups[] = { 
+static int default_ike_groups[] = {
        MODP_1536_BIT,
        MODP_1024_BIT
 };
 
-/*      
+/*
  *      Add IKE alg info _with_ logic (policy):
  */
 static void alg_info_ike_add (struct alg_info *alg_info, int ealg_id,
@@ -258,7 +258,7 @@ static void alg_info_ike_add (struct alg_info *alg_info, int ealg_id,
                n_groups=0;
                goto in_loop;
        }
-               
+
        for (; n_groups--; i++)
        {
                modp_id = default_ike_groups[i];
@@ -372,7 +372,7 @@ static status_t alg_info_parse_str(struct alg_info *alg_info, char *alg_str)
 
                eat_whitespace(&string);
 
-               if (string.len > 0) 
+               if (string.len > 0)
                {
                        chunk_t alg;
 
@@ -494,7 +494,7 @@ struct alg_info_ike *alg_info_ike_create_from_str(char *alg_str)
  *      several connections instances,
  *      handle free() with ref_cnts
  */
-void 
+void
 alg_info_addref(struct alg_info *alg_info)
 {
        if (alg_info != NULL)
@@ -529,7 +529,7 @@ alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info)
        struct esp_info *esp_info;
        struct ike_info *ike_info;
        int cnt;
-               
+
        switch (alg_info->alg_info_protoid) {
        case PROTO_IPSEC_ESP:
                {
@@ -608,7 +608,7 @@ out:
                        , "buffer space exhausted in alg_info_snprint_ike(), buflen=%d"
                        , buflen);
        }
-               
+
        return ptr - buf;
 }
 
index fcf7efca09f03a837b7d3f91e97fb30089843dec..85b88ddff8c8e808dfee69b366be53860ab18c16 100644 (file)
@@ -74,7 +74,7 @@ extern int alg_info_snprint_esp(char *buf, int buflen
 extern int alg_info_snprint_ike(char *buf, int buflen
        , struct alg_info_ike *alg_info);
 #define ALG_INFO_ESP_FOREACH(ai, ai_esp, i) \
-               for (i=(ai)->alg_info_cnt,ai_esp=(ai)->esp; i--; ai_esp++) 
+               for (i=(ai)->alg_info_cnt,ai_esp=(ai)->esp; i--; ai_esp++)
 #define ALG_INFO_IKE_FOREACH(ai, ai_ike, i) \
-               for (i=(ai)->alg_info_cnt,ai_ike=(ai)->ike; i--; ai_ike++) 
+               for (i=(ai)->alg_info_cnt,ai_ike=(ai)->ike; i--; ai_ike++)
 #endif /* ALG_INFO_H */
index 57b843d2bac2bac830ef40a5ad084f1f780f0aee..2c3a8eaedfb58043ac2f6c5fbd8ca55a1651d4a8 100644 (file)
@@ -59,7 +59,7 @@ static void cert_add(private_builder_t *this, builder_part_t part, ...)
        va_start(args, part);
        blob = va_arg(args, chunk_t);
        va_end(args);
-       
+
        switch (part)
        {
                case BUILD_BLOB_PGP:
@@ -134,7 +134,7 @@ static void ac_add(private_builder_t *this, builder_part_t part, ...)
                        va_start(args, part);
                        blob = va_arg(args, chunk_t);
                        va_end(args);
-       
+
                        this->ac = malloc_thing(x509acert_t);
 
                        *this->ac = empty_ac;
@@ -200,10 +200,10 @@ static void crl_add(private_builder_t *this, builder_part_t part, ...)
 static void *build(private_builder_t *this)
 {
        void *cred;
-       
+
        cred = this->cred;
        free(this);
-       
+
        return cred;
 }
 
@@ -213,7 +213,7 @@ static void *build(private_builder_t *this)
 static builder_t *builder(int subtype)
 {
        private_builder_t *this = malloc_thing(private_builder_t);
-       
+
        switch (subtype)
        {
                case CERT_PLUTO_CERT:
@@ -231,7 +231,7 @@ static builder_t *builder(int subtype)
        }
        this->public.build = (void*(*)(builder_t*))build;
        this->cred = NULL;
-       
+
        return &this->public;
 }
 
index 4fdb8cfe713c9246c1bbcd329ad30495bc748968..77374b6f82506c828303b574236f9ec68d790aaa 100644 (file)
@@ -103,7 +103,7 @@ trusted_ca(chunk_t a, chunk_t b, int *pathlen)
                /* go one level up in the CA chain */
                a = cacert->issuer;
        }
-       
+
        unlock_authcert_list("trusted_ca");
        return match;
 }
@@ -539,7 +539,7 @@ add_ca_info(const whack_message_t *msg)
                /* does the authname already exist? */
                ca = get_ca_info(cacert->subject, cacert->serialNumber
                                , cacert->subjectKeyID);
-               
+
                if (ca != NULL)
                {
                        /* ca_info is already present */
@@ -557,7 +557,7 @@ add_ca_info(const whack_message_t *msg)
 
                /* name */
                ca->name = clone_str(msg->name);
-                       
+
                /* authName */
                ca->authName = chunk_clone(cacert->subject);
                dntoa(buf, BUF_LEN, ca->authName);
@@ -621,7 +621,7 @@ add_ca_info(const whack_message_t *msg)
                ca->next = ca_infos;
                ca_infos = ca;
                ca->installed = time(NULL);
-               
+
                unlock_ca_info_list("add_ca_info");
 
                /* add cacert to list of authcerts */
@@ -644,7 +644,7 @@ void
 list_ca_infos(bool utc)
 {
        ca_info_t *ca = ca_infos;
-       
+
        if (ca != NULL)
        {
                whack_log(RC_COMMENT, " ");
index 92ab2cc8edb305de97d61447d2fb13cd7e02aad5..5c6aa568eee4a357ebf6345b1b6776b2eb8b6165 100644 (file)
@@ -116,7 +116,7 @@ private_key_t* load_private_key(char* filename, prompt_pass_t *pass,
 {
        private_key_t *key = NULL;
        char *path;
-       
+
        path = concatenate_paths(PRIVATE_KEY_PATH, filename);
        if (pass && pass->prompt && pass->fd != NULL_FD)
        {       /* use passphrase callback */
@@ -140,7 +140,7 @@ private_key_t* load_private_key(char* filename, prompt_pass_t *pass,
        {       /* no passphrase */
                key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, type,
                                                                 BUILD_FROM_FILE, path, BUILD_END);
-               
+
        }
        if (key)
        {
index b800b1665e2b69d730e625fd3e037c3cbfe3b753..1eb2d332df4d3daebc1341a6211d0c5dc08d07ae 100644 (file)
@@ -109,7 +109,7 @@ find_host_pair(const ip_address *myaddr, u_int16_t myport
        /* default hisaddr to an appropriate any */
        if (hisaddr == NULL)
                hisaddr = aftoinfo(addrtypeof(myaddr))->any;
-               
+
        if (nat_traversal_enabled)
        {
                /**
@@ -1011,7 +1011,7 @@ add_connection(const whack_message_t *wm)
                                loglog(RC_LOG_SERIOUS, "esp string error");
                        }
                }
-               
+
                if (wm->ike)
                {
                        DBG(DBG_CONTROL,
@@ -1038,7 +1038,7 @@ add_connection(const whack_message_t *wm)
                                loglog(RC_LOG_SERIOUS, "ike string error:");
                        }
                }
-               
+
                c->sa_ike_life_seconds = wm->sa_ike_life_seconds;
                c->sa_ipsec_life_seconds = wm->sa_ipsec_life_seconds;
                c->sa_rekey_margin = wm->sa_rekey_margin;
@@ -1213,7 +1213,7 @@ add_group_instance(struct connection *group, const ip_subnet *target)
                if (t->spd.that.virt)
                {
                        DBG_log("virtual_ip not supported in group instance");
-                       t->spd.that.virt = NULL;    
+                       t->spd.that.virt = NULL;
                }
 
                /* add to connections list */
@@ -2356,7 +2356,7 @@ initiate_opportunistic_body(struct find_oppo_bundle *b
                DBG(DBG_CONTROL, DBG_log("creating new instance from \"%s\"%s"
                                                                 , c->name
                                                                 , (fmt_conn_instance(c, cib), cib)));
-                                                               
+
 
                idtoa(&sr->this.id, mycredentialstr, sizeof(mycredentialstr));
 
@@ -3012,7 +3012,7 @@ ISAKMP_SA_established(struct connection *c, so_serial_t serial)
         */
        if (!isanyaddr(&c->spd.that.host_srcip) && !c->spd.that.has_natip)
                c->spd.that.modecfg = TRUE;
-               
+
        if (uniqueIDs)
        {
                /* for all connections: if the same Phase 1 IDs are used
@@ -4037,7 +4037,7 @@ show_connections_status(bool all, const char *name)
                        if (c->spd.that.groups != NULL)
                        {
                                char buf[BUF_LEN];
-               
+
                                format_groups(c->spd.that.groups, buf, BUF_LEN);
                                whack_log(RC_COMMENT
                                        , "\"%s\"%s:   groups: %s"
@@ -4058,7 +4058,7 @@ show_connections_status(bool all, const char *name)
                                , (unsigned long) c->sa_keying_tries);
 
                        /* show DPD parameters if defined */
-               
+
                        if (c->dpd_action != DPD_ACTION_NONE)
                                whack_log(RC_COMMENT
                                        , "\"%s\"%s:   dpd_action: %N;"
@@ -4095,7 +4095,7 @@ show_connections_status(bool all, const char *name)
                        , instance
                        , c->newest_isakmp_sa
                        , c->newest_ipsec_sa);
-                       
+
                if (all)
                {
                        ike_alg_show_connection(c, instance);
index 16cbbfd72c88d8ec81fe362927c00d290a8e5eb0..512c688f8cb62d1e5d9a194902c83b25161b5b2e 100644 (file)
@@ -292,7 +292,7 @@ find_connection_for_clients(struct spd_route **srp
 
 extern chunk_t get_peer_ca_and_groups(struct connection *c
        , const ietfAttrList_t **peer_list);
-       
+
 /* instantiating routines
  * Note: connection_discard() is in state.h because all its work
  * is looking through state objects.
index d9cf07eeedde77047a5402525751ccf05232e522..f4cfaeb6a83bb42aaf34c9886b720d71e60c0e7b 100644 (file)
@@ -68,8 +68,8 @@ ENUM(dpd_action_names, DPD_ACTION_NONE, DPD_ACTION_RESTART,
        "clear",
        "hold",
        "restart"
-);     
-       
+);
+
 /* Timer events */
 
 ENUM(timer_event_names, EVENT_NULL, EVENT_LOG_DAILY,
@@ -274,7 +274,7 @@ const char *const payload_name_nat_d[] = {
 
 static enum_names payload_names_nat_d =
        { ISAKMP_NEXT_NATD_DRAFTS, ISAKMP_NEXT_NATOA_DRAFTS, payload_name_nat_d, NULL };
-               
+
 enum_names payload_names =
        { ISAKMP_NEXT_NONE, ISAKMP_NEXT_NATOA_RFC, payload_name, &payload_names_nat_d };
 
@@ -845,7 +845,7 @@ static const char *const oakley_auth_name1[] = {
        "ECDSA signature",
        "ECDSA-256 signature",
        "ECDSA-384 signature",
-       "ECDSA-521-signature",   
+       "ECDSA-521-signature",
 };
 
 static const char *const oakley_auth_name2[] = {
@@ -922,7 +922,7 @@ enum_names oakley_group_names_rfc3526 =
                        oakley_group_name_rfc3526, &oakley_group_names_rfc4753 };
 
 enum_names oakley_group_names =
-       { MODP_768_BIT, MODP_1536_BIT, 
+       { MODP_768_BIT, MODP_1536_BIT,
                        oakley_group_name, &oakley_group_names_rfc3526 };
 
 /* Oakley Group Type attribute */
@@ -1153,7 +1153,7 @@ const char *const natt_type_bitnames[] = {
        "4",   "5",   "6",   "7",
        "8",   "9",   "10",  "11",
        "12",  "13",  "14",  "15",
-       "16",  "17",  "18",  "19", 
+       "16",  "17",  "18",  "19",
        "20",  "21",  "22",  "23",
        "24",  "25",  "26",  "27",
        "28",  "29",
@@ -1196,8 +1196,8 @@ enum_show(enum_names *ed, unsigned long val)
 
 static char bitnamesbuf[200];   /* only one!  I hope that it is big enough! */
 
-int 
-enum_search(enum_names *ed, const char *str) 
+int
+enum_search(enum_names *ed, const char *str)
 {
        enum_names  *p;
        const char *ptr;
index dc8d5de85c04fef433b5e25f3bc359d3916a0c61..b20737b73af3bd89e2b9b40b7a4b8cbb189b8d1b 100644 (file)
@@ -689,7 +689,7 @@ extern enum_name_t *cert_policy_names;
 
 typedef enum certpolicy {
        CERT_ALWAYS_SEND   = 0,
-       CERT_SEND_IF_ASKED = 1, 
+       CERT_SEND_IF_ASKED = 1,
        CERT_NEVER_SEND    = 2,
 
        CERT_YES_SEND      = 3,       /* synonym for CERT_ALWAYS_SEND */
index 132caa5e3f5b4242ee13d67cdfaff5987e2108c8..4a7accae744df77db91358a67f2087dfb64ea81b 100644 (file)
@@ -56,7 +56,7 @@ static const asn1Object_t crlObjects[] = {
        { 2,     "version",                                     ASN1_INTEGER,      ASN1_OPT |
                                                                                                                   ASN1_BODY }, /*  2 */
        { 2,     "end opt",                                     ASN1_EOC,          ASN1_END  }, /*  3 */
-       { 2,     "signature",                           ASN1_EOC,          ASN1_RAW  }, /*  4 */        
+       { 2,     "signature",                           ASN1_EOC,          ASN1_RAW  }, /*  4 */
        { 2,     "issuer",                                      ASN1_SEQUENCE,     ASN1_OBJ  }, /*  5 */
        { 2,     "thisUpdate",                          ASN1_EOC,          ASN1_RAW  }, /*  6 */
        { 2,     "nextUpdate",                          ASN1_EOC,          ASN1_RAW  }, /*  7 */
@@ -292,7 +292,7 @@ bool insert_crl(x509crl_t *crl, chunk_t crl_uri, bool cache_crl)
                char digest_buf[HASH_SIZE_SHA1];
                chunk_t subjectKeyID = chunk_from_buf(digest_buf);
                bool has_keyID;
-               
+
                if (issuer_cert->subjectKeyID.ptr == NULL)
                {
                        has_keyID = compute_subjectKeyID(issuer_cert, subjectKeyID);
@@ -343,7 +343,7 @@ void load_crls(void)
                        {
                                char *filename = filelist[n]->d_name;
                                x509crl_t *crl;
-                               
+
                                crl = lib->creds->create(lib->creds, CRED_CERTIFICATE,
                                                CERT_PLUTO_CRL, BUILD_FROM_FILE, filename, BUILD_END);
                                if (crl)
@@ -520,7 +520,7 @@ check_revocation(const x509crl_t *crl, chunk_t serial
 
        *revocationDate = UNDEFINED_TIME;
        *revocationReason = CRL_REASON_UNSPECIFIED;
-       
+
        DBG(DBG_CONTROL,
                DBG_dump_chunk("serial number:", serial)
        )
@@ -649,7 +649,7 @@ verify_by_crl(const x509cert_t *cert, time_t *until, time_t *revocationDate
                                , crl->authKeyID, AUTH_CA);
                valid = x509_check_signature(crl->tbsCertList, crl->signature,
                                                                         crl->algorithm, issuer_cert);
-               
+
                unlock_authcert_list("verify_by_crl");
 
                if (valid)
index dcf039541af3c460d364576cdee18ec563cca0d1..db3080c2af4e6e401d5f7e120cba8c05a17c5a05 100644 (file)
@@ -71,7 +71,7 @@ extern bool cache_crls;
 
 /*
  * check periodically for expired crls
- */ 
+ */
 extern long crl_check_interval;
 
 /* used for initialization */
index f47ad1eeb4ff0db382b8f12a3644a4615afe7434..c6d3950bbef98117110008f3afd628f3b90859d9 100644 (file)
 #include "log.h"
 
 static struct encrypt_desc encrypt_desc_3des =
-{       
+{
        algo_type:       IKE_ALG_ENCRYPT,
-       algo_id:         OAKLEY_3DES_CBC, 
+       algo_id:         OAKLEY_3DES_CBC,
        algo_next:       NULL,
 
-       enc_blocksize:   DES_BLOCK_SIZE, 
+       enc_blocksize:   DES_BLOCK_SIZE,
        keydeflen:               DES_BLOCK_SIZE * 3 * BITS_PER_BYTE,
        keyminlen:               DES_BLOCK_SIZE * 3 * BITS_PER_BYTE,
        keymaxlen:               DES_BLOCK_SIZE * 3 * BITS_PER_BYTE,
@@ -40,7 +40,7 @@ static struct encrypt_desc encrypt_desc_aes =
 {
        algo_type:           IKE_ALG_ENCRYPT,
        algo_id:             OAKLEY_AES_CBC,
-       algo_next:           NULL, 
+       algo_next:           NULL,
 
        enc_blocksize:   AES_BLOCK_SIZE,
        keyminlen:               AES_KEY_MIN_LEN,
@@ -55,7 +55,7 @@ static struct encrypt_desc encrypt_desc_blowfish =
 {
        algo_type:       IKE_ALG_ENCRYPT,
        algo_id:         OAKLEY_BLOWFISH_CBC,
-       algo_next:       NULL, 
+       algo_next:       NULL,
 
        enc_blocksize:   BLOWFISH_BLOCK_SIZE,
        keyminlen:               BLOWFISH_KEY_MIN_LEN,
@@ -83,7 +83,7 @@ static struct encrypt_desc encrypt_desc_serpent =
 #define  TWOFISH_KEY_DEF_LEN   128
 #define  TWOFISH_KEY_MAX_LEN   256
 
-static struct encrypt_desc encrypt_desc_twofish = 
+static struct encrypt_desc encrypt_desc_twofish =
 {
        algo_type:           IKE_ALG_ENCRYPT,
        algo_id:             OAKLEY_TWOFISH_CBC,
@@ -108,18 +108,18 @@ static struct encrypt_desc encrypt_desc_twofish_ssh =
 };
 
 static struct hash_desc hash_desc_md5 =
-{       
+{
        algo_type: IKE_ALG_HASH,
        algo_id:   OAKLEY_MD5,
-       algo_next: NULL, 
+       algo_next: NULL,
        hash_digest_size: HASH_SIZE_MD5,
 };
 
 static struct hash_desc hash_desc_sha1 =
-{       
+{
        algo_type: IKE_ALG_HASH,
        algo_id:   OAKLEY_SHA,
-       algo_next: NULL, 
+       algo_next: NULL,
        hash_digest_size: HASH_SIZE_SHA1,
 };
 
@@ -146,91 +146,91 @@ static struct hash_desc hash_desc_sha2_512 = {
 
 const struct dh_desc unset_group = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_NONE, 
+       algo_id:    MODP_NONE,
        algo_next:  NULL,
        ke_size:    0
 };
 
-static struct dh_desc dh_desc_modp_1024 = {       
+static struct dh_desc dh_desc_modp_1024 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_1024_BIT, 
+       algo_id:    MODP_1024_BIT,
        algo_next:  NULL,
        ke_size:    1024 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_modp_1536 = {       
+static struct dh_desc dh_desc_modp_1536 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_1536_BIT, 
+       algo_id:    MODP_1536_BIT,
        algo_next:  NULL,
        ke_size:    1536 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_modp_2048 = {       
+static struct dh_desc dh_desc_modp_2048 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_2048_BIT, 
+       algo_id:    MODP_2048_BIT,
        algo_next:  NULL,
        ke_size:    2048 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_modp_3072 = {       
+static struct dh_desc dh_desc_modp_3072 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_3072_BIT, 
+       algo_id:    MODP_3072_BIT,
        algo_next:  NULL,
        ke_size:    3072 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_modp_4096 = {       
+static struct dh_desc dh_desc_modp_4096 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_4096_BIT, 
+       algo_id:    MODP_4096_BIT,
        algo_next:  NULL,
        ke_size:    4096 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_modp_6144 = {       
+static struct dh_desc dh_desc_modp_6144 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_6144_BIT, 
+       algo_id:    MODP_6144_BIT,
        algo_next:  NULL,
        ke_size:    6144 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_modp_8192 = {       
+static struct dh_desc dh_desc_modp_8192 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    MODP_8192_BIT, 
+       algo_id:    MODP_8192_BIT,
        algo_next:  NULL,
        ke_size:    8192 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_ecp_256 = {       
+static struct dh_desc dh_desc_ecp_256 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    ECP_256_BIT, 
+       algo_id:    ECP_256_BIT,
        algo_next:  NULL,
        ke_size:    2*256 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_ecp_384 = {       
+static struct dh_desc dh_desc_ecp_384 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    ECP_384_BIT, 
+       algo_id:    ECP_384_BIT,
        algo_next:  NULL,
        ke_size:    2*384 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_ecp_521 = {       
+static struct dh_desc dh_desc_ecp_521 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    ECP_521_BIT, 
+       algo_id:    ECP_521_BIT,
        algo_next:  NULL,
        ke_size:    2*528 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_ecp_192 = {       
+static struct dh_desc dh_desc_ecp_192 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    ECP_192_BIT, 
+       algo_id:    ECP_192_BIT,
        algo_next:  NULL,
        ke_size:    2*192 / BITS_PER_BYTE
 };
 
-static struct dh_desc dh_desc_ecp_224 = {       
+static struct dh_desc dh_desc_ecp_224 = {
        algo_type:  IKE_ALG_DH_GROUP,
-       algo_id:    ECP_224_BIT, 
+       algo_id:    ECP_224_BIT,
        algo_next:  NULL,
        ke_size:    2*224 / BITS_PER_BYTE
 };
@@ -283,12 +283,12 @@ bool init_crypto(void)
                         (no_md5) ? "MD5" : "");
                return FALSE;
        }
-               
+
        enumerator = lib->crypto->create_crypter_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &encryption_alg))
        {
                const struct encrypt_desc *desc;
+
                switch (encryption_alg)
                {
                        case ENCR_3DES:
@@ -308,7 +308,7 @@ bool init_crypto(void)
                                desc = &encrypt_desc_serpent;
                                break;
                        default:
-                               continue;                       
+                               continue;
                }
                ike_alg_add((struct ike_alg *)desc);
        }
@@ -381,7 +381,7 @@ encryption_algorithm_t oakley_to_encryption_algorithm(int alg)
                case OAKLEY_DES_CBC:
                        return ENCR_DES;
                case OAKLEY_IDEA_CBC:
-                       return ENCR_IDEA; 
+                       return ENCR_IDEA;
                case OAKLEY_BLOWFISH_CBC:
                        return ENCR_BLOWFISH;
                case OAKLEY_RC5_R16_B64_CBC:
index 4ba4fa324b9863b9a653b03dfd6a3ad44b5e457b..547ea5f227970d700a37300c12defb15c23e2572 100644 (file)
@@ -1,6 +1,6 @@
 /* Dynamic db (proposal, transforms, attributes) handling.
  * Author: JuanJo Ciarlante <jjo-ipsec@mendoza.gov.ar>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
  * for more details.
  */
 
-/* 
+/*
  * The stratedy is to have (full contained) struct db_prop in db_context
  * pointing to ONE dynamically sizable transform vector (trans0).
  * Each transform stores attrib. in ONE dyn. sizable attribute vector (attrs0)
- * in a "serialized" way (attributes storage is used in linear sequence for 
+ * in a "serialized" way (attributes storage is used in linear sequence for
  * subsecuent transforms).
  *
  * Resizing for both trans0 and attrs0 is supported:
@@ -24,7 +24,7 @@
  *               also update trans_cur (by offset)
  * - For attrs0: after allocating and copying attrs, I must rewrite each
  *               trans->attrs present in trans0; to achieve this, calculate
- *               attrs pointer offset (new minus old) and iterate over 
+ *               attrs pointer offset (new minus old) and iterate over
  *               each transform "adding" this difference.
  *               also update attrs_cur (by offset)
  *
@@ -70,7 +70,7 @@
 #ifdef NOT_YET
 /*
  *      Allocator cache:
- *      Because of the single-threaded nature of pluto/spdb.c, 
+ *      Because of the single-threaded nature of pluto/spdb.c,
  *      alloc()/free() is exercised many times with very small
  *      lifetime objects.
  *      Just caching last object (currently it will select the
@@ -84,9 +84,9 @@ struct db_ops_alloc_cache {
 #endif
 
 #ifndef NO_DB_OPS_STATS
-/*      
- *      stats: do account for allocations       
- *      displayed in db_ops_show_status() 
+/*
+ *      stats: do account for allocations
+ *      displayed in db_ops_show_status()
  */
 struct db_ops_stats {
                int st_curr_cnt;        /* current number of allocations */
@@ -100,7 +100,7 @@ struct db_ops_stats {
 static struct db_ops_stats db_context_st = DB_OPS_ZERO;
 static struct db_ops_stats db_trans_st = DB_OPS_ZERO;
 static struct db_ops_stats db_attrs_st = DB_OPS_ZERO;
-static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st) 
+static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st)
 {
                void *ptr = malloc(size);
                if (ptr)
@@ -108,7 +108,7 @@ static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st)
                                st->st_curr_cnt++;
                                st->st_total_cnt++;
                                if (size > st->st_maxsz) st->st_maxsz=size;
-               }       
+               }
                return ptr;
 }
 #define ALLOC_BYTES_ST(z,st) malloc_bytes_st(z, &st);
@@ -125,13 +125,13 @@ static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st)
  *      as a result of "add" operations
  */
 int
-db_prop_init(struct db_context *ctx, u_int8_t protoid, int max_trans, int max_attrs) 
+db_prop_init(struct db_context *ctx, u_int8_t protoid, int max_trans, int max_attrs)
 {
                ctx->trans0 = NULL;
                ctx->attrs0 = NULL;
 
                if (max_trans > 0) { /* quite silly if not */
-                               ctx->trans0 = ALLOC_BYTES_ST ( sizeof(struct db_trans) * max_trans, 
+                               ctx->trans0 = ALLOC_BYTES_ST ( sizeof(struct db_trans) * max_trans,
                                                                db_trans_st);
                                memset(ctx->trans0, '\0', sizeof(struct db_trans) * max_trans);
                }
@@ -162,12 +162,12 @@ db_trans_expand(struct db_context *ctx, int delta_trans)
                int offset;
 
                old_trans = ctx->trans0;
-               new_trans = ALLOC_BYTES_ST ( sizeof (struct db_trans) * max_trans, 
+               new_trans = ALLOC_BYTES_ST ( sizeof (struct db_trans) * max_trans,
                                                db_trans_st);
                if (!new_trans)
                                goto out;
                memcpy(new_trans, old_trans, ctx->max_trans * sizeof(struct db_trans));
-               
+
                /* update trans0 (obviously) */
                ctx->trans0 = ctx->prop.trans = new_trans;
                /* update trans_cur (by offset) */
@@ -175,7 +175,7 @@ db_trans_expand(struct db_context *ctx, int delta_trans)
 
                {
                  char *cctx = (char *)(ctx->trans_cur);
-               
+
                  cctx += offset;
                  ctx->trans_cur = (struct db_trans *)cctx;
                }
@@ -186,7 +186,7 @@ db_trans_expand(struct db_context *ctx, int delta_trans)
 out:
                return ret;
 }
-/*      
+/*
  *      Expand storage for attributes by delta_attrs number AND
  *      rewrite trans->attr pointers
  */
@@ -201,22 +201,22 @@ db_attrs_expand(struct db_context *ctx, int delta_attrs)
                int offset;
 
                old_attrs = ctx->attrs0;
-               new_attrs = ALLOC_BYTES_ST ( sizeof (struct db_attr) * max_attrs, 
+               new_attrs = ALLOC_BYTES_ST ( sizeof (struct db_attr) * max_attrs,
                                                db_attrs_st);
                if (!new_attrs)
                                goto out;
 
                memcpy(new_attrs, old_attrs, ctx->max_attrs * sizeof(struct db_attr));
-               
+
                /* update attrs0 and attrs_cur (obviously) */
                offset = (char *)(new_attrs) - (char *)(old_attrs);
-               
+
                {
                  char *actx = (char *)(ctx->attrs0);
-               
+
                  actx += offset;
                  ctx->attrs0 = (struct db_attr *)actx;
-               
+
                  actx = (char *)ctx->attrs_cur;
                  actx += offset;
                  ctx->attrs_cur = (struct db_attr *)actx;
@@ -237,13 +237,13 @@ out:
                return ret;
 }
 /*      Allocate a new db object */
-struct db_context * 
-db_prop_new(u_int8_t protoid, int max_trans, int max_attrs) 
+struct db_context *
+db_prop_new(u_int8_t protoid, int max_trans, int max_attrs)
 {
                struct db_context *ctx;
                ctx = ALLOC_BYTES_ST ( sizeof (struct db_context), db_context_st);
                if (!ctx) goto out;
-               
+
                if (db_prop_init(ctx, protoid, max_trans, max_attrs) < 0) {
                                PFREE_ST(ctx, db_context_st);
                                ctx=NULL;
@@ -266,8 +266,8 @@ db_trans_add(struct db_context *ctx, u_int8_t transid)
                /*      skip incrementing current trans pointer the 1st time*/
                if (ctx->trans_cur && ctx->trans_cur->attr_cnt)
                                ctx->trans_cur++;
-               /*      
-                *      Strategy: if more space is needed, expand by 
+               /*
+                *      Strategy: if more space is needed, expand by
                 *                <current_size>/2 + 1
                 *
                 *      This happens to produce a "reasonable" sequence
@@ -287,10 +287,10 @@ db_trans_add(struct db_context *ctx, u_int8_t transid)
 }
 /*      Add attr copy to current transform, expanding attrs0 if needed */
 int
-db_attr_add(struct db_context *ctx, const struct db_attr *a) 
+db_attr_add(struct db_context *ctx, const struct db_attr *a)
 {
-               /*      
-                *      Strategy: if more space is needed, expand by 
+               /*
+                *      Strategy: if more space is needed, expand by
                 *                <current_size>/2 + 1
                 */
                if ((ctx->attrs_cur - ctx->attrs0) >= ctx->max_attrs) {
@@ -302,7 +302,7 @@ db_attr_add(struct db_context *ctx, const struct db_attr *a)
                ctx->trans_cur->attr_cnt++;
                return 0;
 }
-/*      Add attr copy (by value) to current transform, 
+/*      Add attr copy (by value) to current transform,
  *      expanding attrs0 if needed, just calls db_attr_add().
  */
 int
@@ -317,7 +317,7 @@ db_attr_add_values(struct db_context *ctx,  u_int16_t type, u_int16_t val)
 int
 db_ops_show_status(void)
 {
-               whack_log(RC_COMMENT, "stats " __FILE__ ": " 
+               whack_log(RC_COMMENT, "stats " __FILE__ ": "
                                                DB_OPS_STATS_DESC " :"
                                                DB_OPS_STATS_STR("context")
                                                DB_OPS_STATS_STR("trans")
@@ -329,7 +329,7 @@ db_ops_show_status(void)
                return 0;
 }
 #endif /* NO_DB_OPS_STATS */
-/* 
+/*
  * From below to end just testing stuff ....
  */
 #ifdef TEST
@@ -349,7 +349,7 @@ static void db_prop_print(struct db_prop *p)
                                                default:
                                                                continue;
                                }
-                               printf("  transid=\"%s\"\n", 
+                               printf("  transid=\"%s\"\n",
                                                enum_name(n, t->transid));
                                for (ai=0, a=t->attrs; ai < t->attr_cnt; ai++, a++) {
                                                int i;
@@ -367,16 +367,16 @@ static void db_prop_print(struct db_prop *p)
                                                                default:
                                                                                continue;
                                                }
-                                               printf("    type=\"%s\" value=\"%s\"\n", 
+                                               printf("    type=\"%s\" value=\"%s\"\n",
                                                                enum_name(n_at, i),
                                                                enum_name(n_av, a->val));
                                }
                }
 
 }
-static void db_print(struct db_context *ctx) 
+static void db_print(struct db_context *ctx)
 {
-               printf("trans_cur diff=%d, attrs_cur diff=%d\n", 
+               printf("trans_cur diff=%d, attrs_cur diff=%d\n",
                                                ctx->trans_cur - ctx->trans0,
                                                ctx->attrs_cur - ctx->attrs0);
                db_prop_print(&ctx->prop);
index 3cfc909af5f62d62da05474aab9f8e06b5d7fb42..73582dd92e279f29a2fd37ed35cb112df42b1b4a 100644 (file)
@@ -1399,7 +1399,7 @@ process_packet(struct msg_digest **mdp)
                        {
                                memcpy(st->st_ph1_iv, st->st_new_iv, st->st_new_iv_len);
                                st->st_ph1_iv_len = st->st_new_iv_len;
-                               
+
                                /* backup new_iv */
                                new_iv_len = st->st_new_iv_len;
                                passert(new_iv_len <= MAX_DIGEST_LEN)
@@ -1498,7 +1498,7 @@ process_packet(struct msg_digest **mdp)
                }
                else
                {
-                       set_cur_state(st);  
+                       set_cur_state(st);
                        from_state = st->st_state;
                }
 
@@ -1681,7 +1681,7 @@ process_packet(struct msg_digest **mdp)
                default:
                        auth = st->st_oakley.auth;
                }
-               
+
                while (!LHAS(smc->flags, auth))
                {
                        smc++;
@@ -1823,7 +1823,7 @@ process_packet(struct msg_digest **mdp)
                        memcpy(new_iv, data.ptr + data.len - crypter_block_size,
                                   crypter_block_size);
 
-                       crypter->set_key(crypter, st->st_enc_key);      
+                       crypter->set_key(crypter, st->st_enc_key);
                        crypter->decrypt(crypter, data, iv, NULL);
                        crypter->destroy(crypter);
 
@@ -2310,7 +2310,7 @@ complete_state_transition(struct msg_digest **mdp, stf_status result)
                                const char *story = state_story[st->st_state - STATE_MAIN_R0];
                                enum rc_type w = RC_NEW_STATE + st->st_state;
                                char sadetails[128];
-                               
+
                                sadetails[0]='\0';
 
                                if (IS_IPSEC_SA_ESTABLISHED(st->st_state))
index 998a10c3527adc027c9133b8a00b0594c819d3e6..5b2ce4c61fb516be15b5224c611e87af0a0f9d1a 100644 (file)
@@ -1817,7 +1817,7 @@ static void
 recover_adns_die(void)
 {
        struct adns_continuation *cr = NULL;
-       
+
        adns_pid = 0;
        if(adns_restart_count < ADNS_RESTART_MAX) {
                adns_restart_count++;
@@ -1834,7 +1834,7 @@ recover_adns_die(void)
                if(continuations != NULL) {
                        for (; cr->previous != NULL; cr = cr->previous);
                }
-                       
+
                next_query = cr;
 
                if(next_query != NULL) {
index 0c69aa526c0c0aea8fc12842240f28aeb9104d48..b8804fb0778baa61677d671f0619e8fd15a30cc7 100644 (file)
@@ -297,7 +297,7 @@ static char* complete_uri(chunk_t distPoint, const char *ldaphost)
        if (symbol != NULL)
        {
                size_t type_len = symbol - ptr;
-               
+
                if (type_len >= 4 && strncasecmp(ptr, "ldap", 4) == 0)
                {
                        ptr = symbol + 1;
@@ -307,7 +307,7 @@ static char* complete_uri(chunk_t distPoint, const char *ldaphost)
                        {
                                len -= 2;
                                symbol = memchr(ptr, '/', len);
-                               
+
                                if (symbol != NULL && symbol - ptr == 0 && ldaphost != NULL)
                                {
                                        uri = malloc(distPoint.len + strlen(ldaphost) + 1);
@@ -322,7 +322,7 @@ static char* complete_uri(chunk_t distPoint, const char *ldaphost)
                        }
                }
        }
-       
+
        /* default action:  copy distributionPoint without change */
        uri = malloc(distPoint.len + 1);
        sprintf(uri, "%.*s", (int)distPoint.len, distPoint.ptr);
@@ -357,7 +357,7 @@ static void fetch_crls(bool cache_crls)
                {
                        char *uri = complete_uri(gn->name, ldaphost);
                        x509crl_t *crl;
-                       
+
                        crl = fetch_crl(uri);
                        if (crl)
                        {
@@ -413,7 +413,7 @@ static void fetch_ocsp_status(ocsp_location_t* location)
        *(uri + location->uri.len) = '\0';
 
        DBG1("  requesting ocsp status from '%s' ...", uri);
-       if (lib->fetcher->fetch(lib->fetcher, uri, &response, 
+       if (lib->fetcher->fetch(lib->fetcher, uri, &response,
                                                        FETCH_REQUEST_DATA, request,
                                                        FETCH_REQUEST_TYPE, "application/ocsp-request",
                                                        FETCH_END) == SUCCESS)
@@ -432,7 +432,7 @@ static void fetch_ocsp_status(ocsp_location_t* location)
        /* increment the trial counter of the unresolved fetch requests */
        {
                ocsp_certinfo_t *certinfo = location->certinfo;
-               
+
                while (certinfo != NULL)
                {
                        certinfo->trials++;
@@ -562,7 +562,7 @@ void add_distribution_points(const generalName_t *newPoints ,generalName_t **dis
        {
                /* skip empty distribution point */
                if (newPoints->name.len > 0)
-               {       
+               {
                        bool add = TRUE;
                        generalName_t *gn = *distributionPoints;
 
index f833f85b5dd318f857361b08505ab99857a12a72..a2648799c1933a6b5b7ba9cae92c7b5887ed385a 100644 (file)
@@ -176,13 +176,13 @@ struct db_context *ike_alg_db_new(struct connection *c, lset_t policy)
                                        enum_show(&oakley_enc_names, ealg));
                        continue;
                }
-               if (!ike_alg_get_hasher(halg)) 
+               if (!ike_alg_get_hasher(halg))
                {
                        plog("ike alg: hasher %s not present",
                                        enum_show(&oakley_hash_names, halg));
                        continue;
                }
-               if (!ike_alg_get_dh_group(modp)) 
+               if (!ike_alg_get_dh_group(modp))
                {
                        plog("ike alg: dh group %s not present",
                                        enum_show(&oakley_group_names, modp));
index f728065ae06bb34ec60c518c6099a8fbb5d30097..21cecd90b4609d6cd18ebf5806acc52df50d0b44 100644 (file)
@@ -405,7 +405,7 @@ static void send_notification(struct state *sndst, u_int16_t type,
                init_phase2_iv(encst, &msgid);
                if (!encrypt_message(&r_hdr_pbs, encst))
                        impossible();
-                       
+
                /* restore preserved st_iv and st_new_iv */
                memcpy(encst->st_iv, old_iv, old_iv_len);
                memcpy(encst->st_new_iv, new_iv, new_iv_len);
@@ -755,7 +755,7 @@ void accept_delete(struct state *st, struct msg_digest *md,
                        else
                        {
                                struct connection *oldc;
-                               
+
                                oldc = cur_connection;
                                set_cur_connection(dst->st_connection);
 
@@ -791,7 +791,7 @@ void accept_delete(struct state *st, struct msg_digest *md,
                        {
                                struct connection *rc = dst->st_connection;
                                struct connection *oldc;
-                               
+
                                oldc = cur_connection;
                                set_cur_connection(rc);
 
@@ -871,7 +871,7 @@ main_outI1(int whack_sock, struct connection *c, struct state *predecessor
        pb_stream rbody;
 
        int vids_to_send = 0;
-       
+
        /* set up new state */
        st->st_connection = c;
        set_cur_state(st);  /* we must reset before exit */
@@ -1253,7 +1253,7 @@ static bool generate_skeyids_iv(struct state *st)
                prf->allocate_bytes(prf, st->st_shared, NULL);
                prf->allocate_bytes(prf, icookie, NULL);
                prf->allocate_bytes(prf, rcookie, NULL);
-               prf->allocate_bytes(prf, seed_skeyid_d, &st->st_skeyid_d); 
+               prf->allocate_bytes(prf, seed_skeyid_d, &st->st_skeyid_d);
 
                /* SKEYID_A */
                free(st->st_skeyid_a.ptr);
@@ -1261,7 +1261,7 @@ static bool generate_skeyids_iv(struct state *st)
                prf->allocate_bytes(prf, st->st_shared, NULL);
                prf->allocate_bytes(prf, icookie, NULL);
                prf->allocate_bytes(prf, rcookie, NULL);
-               prf->allocate_bytes(prf, seed_skeyid_a, &st->st_skeyid_a); 
+               prf->allocate_bytes(prf, seed_skeyid_a, &st->st_skeyid_a);
 
                /* SKEYID_E */
                free(st->st_skeyid_e.ptr);
@@ -1269,7 +1269,7 @@ static bool generate_skeyids_iv(struct state *st)
                prf->allocate_bytes(prf, st->st_shared, NULL);
                prf->allocate_bytes(prf, icookie, NULL);
                prf->allocate_bytes(prf, rcookie, NULL);
-               prf->allocate_bytes(prf, seed_skeyid_e, &st->st_skeyid_e); 
+               prf->allocate_bytes(prf, seed_skeyid_e, &st->st_skeyid_e);
 
                prf->destroy(prf);
        }
@@ -1288,7 +1288,7 @@ static bool generate_skeyids_iv(struct state *st)
                        DBG_dump_chunk("DH_i:", st->st_gi);
                        DBG_dump_chunk("DH_r:", st->st_gr);
                );
-               
+
                hasher->get_hash(hasher, st->st_gi, NULL);
                hasher->get_hash(hasher, st->st_gr, st->st_new_iv);
                hasher->destroy(hasher);
@@ -1301,7 +1301,7 @@ static bool generate_skeyids_iv(struct state *st)
         */
        {
                size_t keysize = st->st_oakley.enckeylen/BITS_PER_BYTE;
+
                /* free any existing key */
                free(st->st_enc_key.ptr);
 
@@ -1318,7 +1318,7 @@ static bool generate_skeyids_iv(struct state *st)
                        prf = lib->crypto->create_prf(lib->crypto, prf_alg);
                        prf->set_key(prf, st->st_skeyid_e);
                        prf_block_size = prf->get_block_size(prf);
-                       
+
                        for (i = 0;;)
                        {
                                prf->get_bytes(prf, seed, &keytemp[i]);
@@ -1335,7 +1335,7 @@ static bool generate_skeyids_iv(struct state *st)
                else
                {
                        st->st_enc_key = chunk_create(st->st_skeyid_e.ptr, keysize);
-               }                       
+               }
                st->st_enc_key = chunk_clone(st->st_enc_key);
        }
 
@@ -1486,7 +1486,7 @@ static size_t sign_hash(signature_scheme_t scheme, struct connection *c,
  */
 struct tac_state {
        struct state *st;
-       chunk_t hash;   
+       chunk_t hash;
        chunk_t sig;
        int tried_cnt;      /* number of keys tried */
 };
@@ -1723,7 +1723,7 @@ encrypt_message(pb_stream *pbs, struct state *st)
        crypter->set_key(crypter, st->st_enc_key);
        crypter->encrypt(crypter, data, iv, NULL);
        crypter->destroy(crypter);
+
        new_iv = data.ptr + data.len - crypter_block_size;
        memcpy(st->st_new_iv, new_iv, crypter_block_size);
        update_iv(st);
@@ -1755,7 +1755,7 @@ static size_t quick_mode_hash12(u_char *dest, u_char *start, u_char *roof,
        if (hash2)
        {
                prf->get_bytes(prf, st->st_ni, NULL); /* include Ni_b in the hash */
-       }     
+       }
        prf->get_bytes(prf, msg_chunk, dest);
        prf_block_size = prf->get_block_size(prf);
        prf->destroy(prf);
@@ -1781,7 +1781,7 @@ static size_t quick_mode_hash3(u_char *dest, struct state *st)
        pseudo_random_function_t prf_alg;
        prf_t *prf;
        size_t prf_block_size;
-       
+
        prf_alg = oakley_to_prf(st->st_oakley.hash);
        prf = lib->crypto->create_prf(lib->crypto, prf_alg);
        prf->set_key(prf, st->st_skeyid_a);
@@ -1814,7 +1814,7 @@ void init_phase2_iv(struct state *st, const msgid_t *msgid)
 
        st->st_new_iv_len = hasher->get_hash_size(hasher);
        passert(st->st_new_iv_len <= sizeof(st->st_new_iv));
-               
+
        hasher->get_hash(hasher, iv_chunk, NULL);
        hasher->get_hash(hasher, msgid_chunk, st->st_new_iv);
        hasher->destroy(hasher);
@@ -1878,7 +1878,7 @@ stf_status quick_outI1(int whack_sock, struct state *isakmp_sa,
        bool has_client = c->spd.this.has_client || c->spd.that.has_client ||
                                          c->spd.this.protocol || c->spd.that.protocol ||
                                          c->spd.this.port || c->spd.that.port;
-       
+
        bool send_natoa = FALSE;
        u_int8_t np = ISAKMP_NEXT_NONE;
 
@@ -1957,7 +1957,7 @@ stf_status quick_outI1(int whack_sock, struct state *isakmp_sa,
 
        /* SA out */
 
-       /* 
+       /*
         * See if pfs_group has been specified for this conn,
         * if not, fallback to old use-same-as-P1 behaviour
         */
@@ -2142,7 +2142,7 @@ static void decode_cr(struct msg_digest *md, struct connection *c)
        {
                struct isakmp_cr *const cr = &p->payload.cr;
                chunk_t ca_name;
-               
+
                ca_name.len = pbs_left(&p->pbs);
                ca_name.ptr = (ca_name.len > 0)? p->pbs.cur : NULL;
 
@@ -2155,7 +2155,7 @@ static void decode_cr(struct msg_digest *md, struct connection *c)
                        if (ca_name.len > 0)
                        {
                                generalName_t *gn;
-                               
+
                                if (!is_asn1(ca_name))
                                        continue;
 
@@ -2646,7 +2646,7 @@ static void compute_proto_keymat(struct state *st, u_int8_t protoid,
                        if (needed_len && pi->attrs.key_len)
                        {
                                needed_len = pi->attrs.key_len / BITS_PER_BYTE;
-                       }       
+                       }
 
                        switch (pi->attrs.transid)
                        {
@@ -2745,7 +2745,7 @@ static void compute_proto_keymat(struct state *st, u_int8_t protoid,
                        char *keymat_i_peer = pi->peer_keymat + i;
                        chunk_t keymat_our  = { keymat_i_our,  prf_block_size };
                        chunk_t keymat_peer = { keymat_i_peer, prf_block_size };
-                       
+
                        if (st->st_shared.ptr != NULL)
                        {
                                /* PFS: include the g^xy */
@@ -3611,7 +3611,7 @@ main_id_and_auth(struct msg_digest *md
 #endif /* USE_KEYRR */
                                kc == NULL? NULL : kc->ac.gateways_from_dns
                        );
-       
+
                if (r == STF_SUSPEND)
                {
                        /* initiate/resume asynchronous DNS lookup for key */
@@ -3715,7 +3715,7 @@ main_id_and_auth(struct msg_digest *md
  * to find authentication, or we run out of things
  * to try.
  */
-static void key_continue(struct adns_continuation *cr, err_t ugh, 
+static void key_continue(struct adns_continuation *cr, err_t ugh,
                                                 key_tail_fn *tail)
 {
        struct key_continuation *kc = (void *)cr;
@@ -4145,7 +4145,7 @@ stf_status quick_inI1_outR1(struct msg_digest *md)
                if (!decode_net_id(&id_pd->next->payload.ipsec_id, &id_pd->next->pbs
                , &b.my.net, "our client"))
                        return STF_FAIL + INVALID_ID_INFORMATION;
-               
+
                b.my.proto = id_pd->next->payload.ipsec_id.isaiid_protoid;
                b.my.port = id_pd->next->payload.ipsec_id.isaiid_port;
                b.my.net.addr.u.v4.sin_port = htons(b.my.port);
@@ -4492,7 +4492,7 @@ static enum verify_oppo_step quick_inI1_outR1_process_answer(
                {
                        public_key_t *pub_key;
                        struct gw_info *gwp;
-               
+
                        /* check that the public key that authenticated
                         * the ISAKMP SA (p1st) will do for this gateway.
                         */
@@ -4888,14 +4888,14 @@ static void dpd_init(struct state *st)
 {
        struct state *p1st = find_state(st->st_icookie, st->st_rcookie
                                                                , &st->st_connection->spd.that.host_addr, 0);
-       
+
        if (p1st == NULL)
                loglog(RC_LOG_SERIOUS, "could not find phase 1 state for DPD");
        else if (p1st->st_dpd)
        {
                plog("Dead Peer Detection (RFC 3706) enabled");
                /* randomize the first DPD event */
-               
+
                event_schedule(EVENT_DPD
                        , (0.5 + rand()/(RAND_MAX + 1.E0)) * st->st_connection->dpd_delay
                        , st);
@@ -4975,10 +4975,10 @@ stf_status quick_inR1_outI2(struct msg_digest *md)
        }
 
        /* check the peer's group attributes */
-       
+
        {
                const ietfAttrList_t *peer_list = NULL;
-               
+
                get_peer_ca_and_groups(st->st_connection, &peer_list);
 
                if (!group_membership(peer_list, st->st_connection->name
@@ -5041,7 +5041,7 @@ stf_status quick_inR1_outI2(struct msg_digest *md)
                                                           , st->st_connection->newest_ipsec_sa
                                                           , st->st_connection->spd.eroute_owner));
        }
-       
+
        st->st_connection->newest_ipsec_sa = st->st_serialno;
 
        /* note (presumed) success */
@@ -5114,9 +5114,9 @@ static stf_status send_isakmp_notification(struct state *st, u_int16_t type,
        u_char
                *r_hashval,     /* where in reply to jam hash value */
                *r_hash_start;  /* start of what is to be hashed */
-               
+
        msgid = generate_msgid(st);
-       
+
        init_pbs(&reply, reply_buffer, sizeof(reply_buffer), "ISAKMP notify");
 
        /* HDR* */
@@ -5144,22 +5144,22 @@ static stf_status send_isakmp_notification(struct state *st, u_int16_t type,
                isan.isan_np = ISAKMP_NEXT_NONE;
                isan.isan_doi = ISAKMP_DOI_IPSEC;
                isan.isan_protoid = PROTO_ISAKMP;
-               isan.isan_spisize = COOKIE_SIZE * 2;  
+               isan.isan_spisize = COOKIE_SIZE * 2;
                isan.isan_type = type;
                if (!out_struct(&isan, &isakmp_notification_desc, &rbody, &notify_pbs))
                        return STF_INTERNAL_ERROR;
                if (!out_raw(st->st_icookie, COOKIE_SIZE, &notify_pbs, "notify icookie"))
-                       return STF_INTERNAL_ERROR;  
+                       return STF_INTERNAL_ERROR;
                if (!out_raw(st->st_rcookie, COOKIE_SIZE, &notify_pbs, "notify rcookie"))
-                       return STF_INTERNAL_ERROR;  
+                       return STF_INTERNAL_ERROR;
                if (data != NULL && len > 0)
                        if (!out_raw(data, len, &notify_pbs, "notify data"))
-                               return STF_INTERNAL_ERROR;    
+                               return STF_INTERNAL_ERROR;
                close_output_pbs(&notify_pbs);
        }
-                       
+
        {
-               /* finish computing HASH */     
+               /* finish computing HASH */
                chunk_t msgid_chunk = chunk_from_thing(msgid);
                chunk_t msg_chunk = { r_hash_start, rbody.cur-r_hash_start };
                pseudo_random_function_t prf_alg;
@@ -5195,7 +5195,7 @@ static stf_status send_isakmp_notification(struct state *st, u_int16_t type,
                init_phase2_iv(st, &msgid);
                if (!encrypt_message(&rbody, st))
                        return STF_INTERNAL_ERROR;
-       
+
                /* restore preserved st_iv and st_new_iv */
                memcpy(st->st_iv, old_iv, old_iv_len);
                memcpy(st->st_new_iv, new_iv, new_iv_len);
index 46edac1cd9f394e56d19bb9482e7362fc47a2c1a..f9972599b61d67310b705de68daf0f50467ba33b 100644 (file)
@@ -868,7 +868,7 @@ static void set_text_said(char *text_said, const ip_address *dst,
  * this allows the entry to be deleted.
  */
 static struct bare_shunt** bare_shunt_ptr(const ip_subnet *ours,
-                                                                                 const ip_subnet *his, 
+                                                                                 const ip_subnet *his,
                                                                                  int transport_proto)
 {
        struct bare_shunt *p, **pp;
@@ -1861,7 +1861,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                        if (ei == &esp_info[countof(esp_info)])
                        {
                                /* Check for additional kernel alg */
-                               if ((ei=kernel_alg_esp_info(st->st_esp.attrs.transid, 
+                               if ((ei=kernel_alg_esp_info(st->st_esp.attrs.transid,
                                                                                st->st_esp.attrs.auth))!=NULL)
                                {
                                        break;
@@ -1906,7 +1906,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                {
                        case ESP_3DES:
                                /* 168 bits in kernel, need 192 bits for keymat_len */
-                               if (key_len == 21) 
+                               if (key_len == 21)
                                {
                                        key_len = 24;
                                }
@@ -1914,7 +1914,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                        case ESP_DES:
                                /* 56 bits in kernel, need 64 bits for keymat_len */
                                if (key_len == 7)
-                               { 
+                               {
                                        key_len = 8;
                                }
                                break;
@@ -1930,7 +1930,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                                key_len += 4;
                                break;
                        default:
-                               break;                  
+                               break;
                }
 
                /* divide up keying material */
@@ -2032,7 +2032,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                {
                        struct pfkey_proto_info proto_info[4];
                        int i = 0;
-                       
+
                        if (st->st_ipcomp.present)
                        {
                                proto_info[i].proto = IPPROTO_COMP;
@@ -2040,7 +2040,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                                proto_info[i].reqid = c->spd.reqid + 2;
                                i++;
                        }
-                       
+
                        if (st->st_esp.present)
                        {
                                proto_info[i].proto = IPPROTO_ESP;
@@ -2048,7 +2048,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                                proto_info[i].reqid = c->spd.reqid + 1;
                                i++;
                        }
-                       
+
                        if (st->st_ah.present)
                        {
                                proto_info[i].proto = IPPROTO_AH;
@@ -2056,9 +2056,9 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                                proto_info[i].reqid = c->spd.reqid;
                                i++;
                        }
-                       
+
                        proto_info[i].proto = 0;
-                       
+
                        if (kernel_ops->inbound_eroute
                                && encapsulation == ENCAPSULATION_MODE_TUNNEL)
                        {
@@ -2068,7 +2068,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                                        proto_info[i].encapsulation = ENCAPSULATION_MODE_TRANSPORT;
                                }
                        }
-                       
+
                        /* MCR - should be passed a spd_eroute structure here */
                        (void) raw_eroute(&c->spd.that.host_addr, &c->spd.that.client
                                                          , &c->spd.this.host_addr, &c->spd.this.client
@@ -2079,11 +2079,11 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
        }
 
        /* If there are multiple SPIs, group them. */
-       
+
        if (kernel_ops->grp_sa && said_next > &said[1])
        {
                struct kernel_sa *s;
-               
+
                /* group SAs, two at a time, inner to outer (backwards in said[])
                 * The grouping is by pairs.  So if said[] contains ah esp ipip,
                 * the grouping would be ipip:esp, esp:ah.
@@ -2095,15 +2095,15 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
                                text_said1[SATOT_BUF];
 
                        /* group s[1] and s[0], in that order */
-                       
+
                        set_text_said(text_said0, s[0].dst, s[0].spi, s[0].proto);
                        set_text_said(text_said1, s[1].dst, s[1].spi, s[1].proto);
-                       
+
                        DBG(DBG_KLIPS, DBG_log("grouping %s and %s", text_said1, text_said0));
-                       
+
                        s[0].text_said = text_said0;
                        s[1].text_said = text_said1;
-                       
+
                        if (!kernel_ops->grp_sa(s + 1, s))
                        {
                                goto fail;
@@ -2438,7 +2438,7 @@ bool route_and_eroute(struct connection *c USED_BY_KLIPS,
                                , c->name
                                , (c->policy_next ? c->policy_next->name : "none")
                                , ero ? ero->name : "null"
-                               , esr 
+                               , esr
                                , ro ? ro->name : "null"
                                , rosr
                                , st ? st->st_serialno : 0));
@@ -2839,7 +2839,7 @@ static bool update_nat_t_ipsec_esp_sa (struct state *st, bool inbound)
 {
        struct connection *c = st->st_connection;
        char text_said[SATOT_BUF];
-       struct kernel_sa sa;        
+       struct kernel_sa sa;
        ip_address
                src = inbound? c->spd.that.host_addr : c->spd.this.host_addr,
                dst = inbound? c->spd.this.host_addr : c->spd.that.host_addr;
@@ -2924,7 +2924,7 @@ bool was_eroute_idle(struct state *st, time_t idle_max, time_t *idle_time)
                        ret = *idle_time >= idle_max;
                }
        }
-       else 
+       else
        {
                while (f != NULL)
                {
index 7e7d25872be110631da5e1a060149e5c00bc9dcd..35e3eab4acfc953e3302dad129ca6e6875ae1206 100644 (file)
@@ -90,7 +90,7 @@ static struct sadb_alg* sadb_alg_ptr (int satype, int exttype, int alg_id,
        default:
                return NULL;
        }
-       
+
        return alg_p;
 }
 
@@ -154,7 +154,7 @@ bool kernel_alg_esp_enc_ok(u_int alg_id, u_int key_len,
        if (!ret) goto out;
 
        alg_p = &esp_ealg[alg_id];
-       
+
        /*
         * test #2: if key_len specified, it must be in range
         */
@@ -195,8 +195,8 @@ out:
        return ret;
 }
 
-/* 
- * ML: make F_STRICT logic consider enc,auth algorithms 
+/*
+ * ML: make F_STRICT logic consider enc,auth algorithms
  */
 bool kernel_alg_esp_ok_final(u_int ealg, u_int key_len, u_int aalg,
                                                         struct alg_info_esp *alg_info)
@@ -252,7 +252,7 @@ bool kernel_alg_esp_ok_final(u_int ealg, u_int key_len, u_int aalg,
        return TRUE;
 }
 
-/**      
+/**
  * Load kernel_alg arrays from /proc used in manual mode from klips/utils/spi.c
  */
 int kernel_alg_proc_read(void)
@@ -312,7 +312,7 @@ int kernel_alg_proc_read(void)
        return 0;
 }
 
-/**     
+/**
  * Load kernel_alg arrays pluto's SADB_REGISTER user by pluto/kernel.c
  */
 void kernel_alg_register_pfkey(const struct sadb_msg *msg_buf, int buflen)
@@ -422,7 +422,7 @@ u_int kernel_alg_esp_enc_keylen(u_int alg_id)
                        break;
        }
 
-none:   
+none:
        DBG(DBG_KLIPS,
                DBG_log("kernel_alg_esp_enc_keylen(): alg_id=%d, keylen=%d",
                                alg_id, keylen)
@@ -471,7 +471,7 @@ void kernel_alg_list(void)
                }
        }
        whack_log(RC_COMMENT, "  encryption:%s", buf);
-       
+
        pos = buf;
        *pos = '\0';
        len = BUF_LEN;
@@ -507,7 +507,7 @@ void kernel_alg_show_connection(struct connection *c, const char *instance)
 
                pfsgroup_name = (c->policy & POLICY_PFS) ?
                                                (c->alg_info_esp->esp_pfsgroup) ?
-                                                       enum_show(&oakley_group_names, 
+                                                       enum_show(&oakley_group_names,
                                                                                  c->alg_info_esp->esp_pfsgroup) :
                                                        "<Phase1>" : "<N/A>";
 
@@ -634,7 +634,7 @@ static bool kernel_alg_db_add(struct db_context *db_ctx,
                DBG_log("kernel_alg_db_add() kernel enc ealg_id=%d not present", ealg_id);
                return FALSE;
        }
-       
+
        if (!(policy & POLICY_AUTHENTICATE) &&    /* skip ESP auth attrs for AH */
                esp_info->esp_aalg_id != AUTH_ALGORITHM_NONE)
        {
@@ -666,11 +666,11 @@ static bool kernel_alg_db_add(struct db_context *db_ctx,
        {
                db_attr_add_values(db_ctx, KEY_LENGTH, esp_info->esp_ealg_keylen);
        }
-               
+
        return TRUE;
 }
 
-/*      
+/*
  *      Create proposal with runtime kernel algos, merging
  *      with passed proposal if not NULL
  *
@@ -713,7 +713,7 @@ struct db_context* kernel_alg_db_new(struct alg_info_esp *alg_info,
        else
        {
                u_int ealg_id;
-               
+
                ESP_EALG_FOR_EACH_UPDOWN(ealg_id)
                {
                        u_int aalg_id;
index 0376e817be8df4a3111eda6fe86e6b937b58f156..3622703180ce0f357522363bb086839401fcee42 100644 (file)
@@ -183,7 +183,7 @@ static void init_netlink(void)
  * @param hdr - Data to be sent.
  * @param rbuf - Return Buffer - contains data returned from the send.
  * @param rbuf_len - Length of rbuf
- * @param description - String - user friendly description of what is 
+ * @param description - String - user friendly description of what is
  *                      being attempted.  Used for diagnostics
  * @param text_said - String
  * @return bool True if the message was succesfully sent.
@@ -382,7 +382,7 @@ static bool netlink_policy(struct nlmsghdr *hdr, bool enoent_ok,
  * @param proto int (Currently unused) Contains protocol (u=tcp, 17=udp, etc...)
  * @param transport_proto int (Currently unused) 0=tunnel, 1=transport
  * @param satype int
- * @param proto_info 
+ * @param proto_info
  * @param lifetime (Currently unused)
  * @param ip int
  * @return boolean True if successful
@@ -590,7 +590,7 @@ static bool netlink_add_sa(const struct kernel_sa *sa, bool replace)
                char data[1024];
        } req;
        struct rtattr *attr;
-       u_int16_t icv_size = 64;        
+       u_int16_t icv_size = 64;
 
        memset(&req, 0, sizeof(req));
        req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
@@ -680,13 +680,13 @@ static bool netlink_add_sa(const struct kernel_sa *sa, bool replace)
                        attr->rta_type = XFRMA_ALG_AEAD;
                        attr->rta_len = RTA_LENGTH(sizeof(struct xfrm_algo_aead) + sa->enckeylen);
                        req.n.nlmsg_len += attr->rta_len;
-                       
+
                        algo = (struct xfrm_algo_aead*)RTA_DATA(attr);
                        algo->alg_key_len = sa->enckeylen * BITS_PER_BYTE;
                        algo->alg_icv_len = icv_size;
                        strcpy(algo->alg_name, name);
                        memcpy(algo->alg_key, sa->enckey, sa->enckeylen);
-                       
+
                        attr = (struct rtattr *)((char *)attr + attr->rta_len);
                        break;
                }
@@ -962,7 +962,7 @@ static void linux_pfkey_register(void)
 
 /** Create ip_address out of xfrm_address_t.
  *
- * @param family 
+ * @param family
  * @param src xfrm formatted IP address
  * @param dst ip_address formatted destination
  * @return err_t NULL if okay, otherwise an error
@@ -1001,7 +1001,7 @@ static err_t xfrm_sel_to_ip_pair(const struct xfrm_selector *sel,
 
        if ((ugh = xfrm_to_ip_address(family, &sel->saddr, src))
                || (ugh = xfrm_to_ip_address(family, &sel->daddr, dst)))
-       {       
+       {
                return ugh;
        }
 
index 82a6ab648fa2cdd21c397b304b7f95949f91c83f..e99efe0623de554ea644cefbd9d07f9c286e9f9c 100644 (file)
@@ -107,7 +107,7 @@ noklips_del_sa(const struct kernel_sa *sa UNUSED)
 const struct kernel_ops noklips_kernel_ops = {
                type: KERNEL_TYPE_NONE,
                async_fdp: NULL,
-               
+
                init: init_noklips,
                pfkey_register: noklips_register,
                pfkey_register_response: noklips_register_response,
index 7ac405fd4937f4ed955bc13ef5204e12c29b6225..99ba4ff30111d8d9ccad2377c8920bb405fb1021 100644 (file)
@@ -73,7 +73,7 @@ static sparse_names pfkey_type_names = {
                NE(SADB_X_DELFLOW),
                NE(SADB_X_DEBUG),
                NE(SADB_X_NAT_T_NEW_MAPPING),
-               NE(SADB_MAX),   
+               NE(SADB_MAX),
                { 0, sparse_end }
 };
 
@@ -531,7 +531,7 @@ pfkeyext_protocol(int transport_proto
 , const char *text_said
 , struct sadb_ext *extensions[SADB_EXT_MAX + 1])
 {
-       return (transport_proto == 0)? TRUE 
+       return (transport_proto == 0)? TRUE
                : pfkey_build(
                        pfkey_x_protocol_build(extensions + SADB_X_EXT_PROTOCOL, transport_proto)
                        , description, text_said, extensions);
index 72ae19f9eab3a9bac9cd1023b883bc17c915df7c..4035495c60edf49cc4ab7e3ed24405ac6a262f64 100644 (file)
@@ -392,7 +392,7 @@ enum rsa_private_key_part_t {
        RSA_PART_EXPONENT1        = 5,
        RSA_PART_EXPONENT2        = 6,
        RSA_PART_COEFFICIENT      = 7
-}; 
+};
 
 const char *rsa_private_key_part_names[] = {
        "Modulus",
@@ -464,13 +464,13 @@ static err_t process_rsa_secret(private_key_t **key)
                goto end;
        }
 
-       *key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, 
+       *key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                        BUILD_RSA_MODULUS,  rsa_chunk[RSA_PART_MODULUS],
                                        BUILD_RSA_PUB_EXP,  rsa_chunk[RSA_PART_PUBLIC_EXPONENT],
                                        BUILD_RSA_PRIV_EXP, rsa_chunk[RSA_PART_PRIVATE_EXPONENT],
                                        BUILD_RSA_PRIME1,   rsa_chunk[RSA_PART_PRIME1],
                                        BUILD_RSA_PRIME2,   rsa_chunk[RSA_PART_PRIME2],
-                                       BUILD_RSA_EXP1,     rsa_chunk[RSA_PART_EXPONENT1], 
+                                       BUILD_RSA_EXP1,     rsa_chunk[RSA_PART_EXPONENT1],
                                        BUILD_RSA_EXP2,     rsa_chunk[RSA_PART_EXPONENT2],
                                        BUILD_RSA_COEFF,    rsa_chunk[RSA_PART_COEFFICIENT],
                                        BUILD_END);
@@ -486,7 +486,7 @@ end:
        {
                chunk_clear(&rsa_chunk[p]);
        }
-       return ugh;     
+       return ugh;
 }
 
 /**
@@ -714,7 +714,7 @@ static err_t process_pin(secret_t *s, int whackfd)
                }
        }
        else
-       {   
+       {
                /* we read the pin directly from ipsec.secrets */
                err_t ugh = process_psk_secret(&sc->pin);
                if (ugh != NULL)
index e34409f1c3a20848721240bd6b8461b6f16bb9ca..1a211c27a0de09b99f5a6379a23fd5fbbd92efac 100644 (file)
@@ -99,12 +99,12 @@ static void pluto_dbg(int level, char *fmt, ...)
        else if (cur_debugging & DBG_RAW)
        {
                debug_level = 3;
-       }       
+       }
        else if (cur_debugging & DBG_PARSING)
        {
                debug_level = 2;
        }
-       else 
+       else
        {
                debug_level = 1;
        }
@@ -835,8 +835,8 @@ static void show_loaded_plugins()
        char buf[BUF_LEN], *plugin;
        int len = 0;
        enumerator_t *enumerator;
-       
-       buf[0] = '\0';  
+
+       buf[0] = '\0';
        enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
        while (len < BUF_LEN && enumerator->enumerate(enumerator, &plugin))
        {
index 228827f2aa3a6b971d79ec135a58eb635b7cc6e4..c1092f46150d193b5373290d8c0d237f5b106239 100644 (file)
@@ -140,7 +140,7 @@ get_internal_addr(struct connection *c, internal_addr_t *ia)
                c->spd.that.client.addr     = ia->ipaddr;
                c->spd.that.client.maskbits = 32;
                c->spd.that.has_client      = TRUE;
-               
+
                ia->attr_set = LELEM(INTERNAL_IP4_ADDRESS)
                                         | LELEM(INTERNAL_IP4_NETMASK);
        }
@@ -165,7 +165,7 @@ get_internal_addr(struct connection *c, internal_addr_t *ia)
                        }
                        plog("assigning DNS server %s to peer", dns_str);
 
-                       /* differentiate between IP4 and IP6 in modecfg_build_msg() */ 
+                       /* differentiate between IP4 and IP6 in modecfg_build_msg() */
                        ia->attr_set |= LELEM(INTERNAL_IP4_DNS);
                        dns_idx++;
                }
@@ -191,7 +191,7 @@ get_internal_addr(struct connection *c, internal_addr_t *ia)
                        }
                        plog("assigning NBNS server %s to peer", nbns_str);
 
-                       /* differentiate between IP4 and IP6 in modecfg_build_msg() */ 
+                       /* differentiate between IP4 and IP6 in modecfg_build_msg() */
                        ia->attr_set |= LELEM(INTERNAL_IP4_NBNS);
                        nbns_idx++;
                }
@@ -227,7 +227,7 @@ set_internal_addr(struct connection *c, internal_addr_t *ia)
                        plog("replacing virtual IP source address %s by %s"
                                , old_srcip, new_srcip);
                }
-               
+
                /* setting srcip */
                c->spd.this.host_srcip = ia->ipaddr;
 
@@ -263,12 +263,12 @@ static size_t modecfg_hash(u_char *dest, u_char *start, u_char *roof,
        DBG(DBG_CRYPT,
                DBG_log("ModeCfg HASH computed:");
                DBG_dump("", dest, prf_block_size)
-       ) 
+       )
        return prf_block_size;
 }
 
 
-/* 
+/*
  * Generate an IKE message containing ModeCfg information (eg: IP, DNS, WINS)
  */
 static stf_status
@@ -322,7 +322,7 @@ modecfg_build_msg(struct state *st, pb_stream *rbody
                                        is_unity_attr_set = FALSE;
                                }
                        }
-               
+
                        dont_advance = FALSE;
 
                        if (attr_set & 1)
@@ -384,7 +384,7 @@ modecfg_build_msg(struct state *st, pb_stream *rbody
                                                                mask[t] = 0xff;
                                                        m -= 8;
                                                }
-#endif                              
+#endif
                                                if (st->st_connection->spd.this.client.maskbits == 0)
                                                {
                                                        mask = 0;
@@ -735,7 +735,7 @@ modecfg_parse_attributes(pb_stream *attrs, internal_addr_t *ia)
        return STF_OK;
 }
 
-/* 
+/*
  * Parse a ModeCfg message
  */
 static stf_status
@@ -859,7 +859,7 @@ modecfg_inR0(struct msg_digest *md)
 /* STATE_MODE_CFG_I1:
  * HDR*, HASH, ATTR(REPLY=IP)
  *
- * used in ModeCfg pull mode, on the client (initiator) 
+ * used in ModeCfg pull mode, on the client (initiator)
  */
 stf_status
 modecfg_inI1(struct msg_digest *md)
@@ -1148,7 +1148,7 @@ xauth_inR1(struct msg_digest *md)
                plog("user password attribute is missing in XAUTH reply");
                st->st_xauth.status = FALSE;
        }
-       else 
+       else
        {
                xauth_peer_t peer;
 
index 86bfc6ed280240129a67a3da87a134dd269d81f5..bc1443012a89d4b278188d592caaa256bcf41f96 100644 (file)
@@ -1,7 +1,7 @@
 /* Mode Config related functions
  * Copyright (C) 2001-2002 Colubris Networks
  * Copyright (C) 2003-2004 Xelerance Corporation
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
index de3972fe2e799c4d548c85be38e20d1f9e2c6022..ac35b01acfe8412d18fe3ba5b37db0f4fd604be5 100644 (file)
@@ -147,7 +147,7 @@ static void _natd_hash(const struct hash_desc *oakley_hasher, char *hash,
                                addr_chunk = chunk_from_thing(ip->u.v6.sin6_addr.s6_addr);
                                break;
                        default:
-                               addr_chunk = chunk_empty; /* should never occur */ 
+                               addr_chunk = chunk_empty; /* should never occur */
                }
                hasher->get_hash(hasher, addr_chunk, NULL);
                hasher->get_hash(hasher, port_chunk, hash);
@@ -310,7 +310,7 @@ bool nat_traversal_add_natd(u_int8_t np, pb_stream *outs,
        DBG(DBG_EMITTING,
                DBG_log("sending NATD payloads")
        )
-               
+
        /*
         * First one with sender IP & port
         */
@@ -348,7 +348,7 @@ bool nat_traversal_add_natd(u_int8_t np, pb_stream *outs,
 
 /*
  * nat_traversal_natoa_lookup()
- * 
+ *
  * Look for NAT-OA in message
  */
 void nat_traversal_natoa_lookup(struct msg_digest *md)
@@ -435,7 +435,7 @@ void nat_traversal_natoa_lookup(struct msg_digest *md)
                {
                        char ip_t[ADDRTOT_BUF];
                        addrtot(&ip, 0, ip_t, sizeof(ip_t));
-               
+
                        DBG_log("received NAT-OA: %s", ip_t);
                }
        )
@@ -514,7 +514,7 @@ void nat_traversal_show_result (u_int32_t nt, u_int16_t sport)
                mth = natt_type_bitnames[2];
                break;
        }
-       
+
        switch (nt & NAT_T_DETECTED)
        {
        case 0:
index cdbdd32c14b78a693542c7a5ed8d44786af93623..4be3298aef2188789a4294344f8722e13df48f5a 100644 (file)
@@ -294,7 +294,7 @@ static bool build_ocsp_location(const x509cert_t *cert, ocsp_location_t *locatio
 {
        hasher_t *hasher;
        static u_char digest[HASH_SIZE_SHA1];  /* temporary storage */
-       
+
        location->uri = cert->accessLocation;
 
        if (location->uri.ptr == NULL)
@@ -310,7 +310,7 @@ static bool build_ocsp_location(const x509cert_t *cert, ocsp_location_t *locatio
                        return FALSE;
                }
        }
-       
+
        /* compute authNameID from as SHA-1 hash of issuer DN */
        location->authNameID = chunk_create(digest, HASH_SIZE_SHA1);
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
@@ -325,8 +325,8 @@ static bool build_ocsp_location(const x509cert_t *cert, ocsp_location_t *locatio
        location->issuer = cert->issuer;
        location->authKeyID = cert->authKeyID;
        location->authKeySerialNumber = cert->authKeySerialNumber;
-       
-       if (cert->authKeyID.ptr == NULL) 
+
+       if (cert->authKeyID.ptr == NULL)
        {
                x509cert_t *authcert = get_authcert(cert->issuer
                                , cert->authKeySerialNumber, cert->authKeyID, AUTH_CA);
@@ -426,7 +426,7 @@ cert_status_t verify_by_ocsp(const x509cert_t *cert, time_t *until,
 
        *revocationDate = UNDEFINED_TIME;
        *revocationReason = CRL_REASON_UNSPECIFIED;
-       
+
        /* is an ocsp location defined? */
        if (!build_ocsp_location(cert, &location))
                return CERT_UNDEFINED;
@@ -457,7 +457,7 @@ void check_ocsp(void)
 
        lock_ocsp_cache("check_ocsp");
        location = ocsp_cache;
-       
+
        while (location != NULL)
        {
                char buf[BUF_LEN];
@@ -1039,11 +1039,11 @@ static bool valid_ocsp_response(response_t *res)
                        unlock_authcert_list("valid_ocsp_response");
                        return FALSE;
                }
-               
+
                DBG(DBG_CONTROL,
                        DBG_log("certificate is valid")
                )
-               
+
                authcert = get_authcert(cert->issuer, cert->authKeySerialNumber
                        , cert->authKeyID, AUTH_CA);
 
@@ -1388,7 +1388,7 @@ void add_certinfo(ocsp_location_t *loc, ocsp_certinfo_t *info,
                *certinfop = cnew;
                certinfo = cnew;
        }
-               
+
        DBG(DBG_CONTROL,
                datatot(info->serialNumber.ptr, info->serialNumber.len, ':'
                        , buf, BUF_LEN);
@@ -1403,7 +1403,7 @@ void add_certinfo(ocsp_location_t *loc, ocsp_certinfo_t *info,
        if (request)
        {
                certinfo->status = CERT_UNDEFINED;
-               
+
                if (cmp != 0)
                {
                        certinfo->thisUpdate = now;
@@ -1415,7 +1415,7 @@ void add_certinfo(ocsp_location_t *loc, ocsp_certinfo_t *info,
                certinfo->status = info->status;
                certinfo->revocationTime = info->revocationTime;
                certinfo->revocationReason = info->revocationReason;
-               
+
                certinfo->thisUpdate = (info->thisUpdate != UNDEFINED_TIME)?
                        info->thisUpdate : now;
 
@@ -1446,7 +1446,7 @@ static void process_single_response(ocsp_location_t *location,
                plog("ocsp single response has wrong issuer");
                return;
        }
-       
+
        /* traverse list of certinfos in increasing order */
        certinfop = &location->certinfo;
        certinfo = *certinfop;
@@ -1468,14 +1468,14 @@ static void process_single_response(ocsp_location_t *location,
 
        /* unlink cert from ocsp fetch request list */
        *certinfop = certinfo->next;
-       
+
        /* update certinfo using the single response information */
        certinfo->thisUpdate = sres->thisUpdate;
        certinfo->nextUpdate = sres->nextUpdate;
        certinfo->status = sres->status;
        certinfo->revocationTime = sres->revocationTime;
        certinfo->revocationReason = sres->revocationReason;
-       
+
        /* add or update certinfo in ocsp cache */
        lock_ocsp_cache("process_single_response");
        add_certinfo(location, certinfo, &ocsp_cache, FALSE);
index 01967efedb8b90cb4d9fd654ef71ca3022736e59..b82fe20e324d4894d0cf266a4fd68211447ad813 100644 (file)
@@ -535,7 +535,7 @@ struct_desc isakmp_vendor_id_desc = { "ISAKMP Vendor ID Payload", isag_fields, s
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         ! Next Payload  !   RESERVED    !         Payload Length        !
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        !     Type      !   RESERVED    !           Identifier          ! 
+        !     Type      !   RESERVED    !           Identifier          !
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         !                                                               !
         ~                           Attributes                          ~
index 3cbfeb71708b7b2203dde755c911f39568a4ed5b..e1561665a154361fb65ed9d9e91ba5e8c574f03c 100644 (file)
@@ -283,7 +283,7 @@ static bool parse_pgp_pubkey_packet(chunk_t *packet, pgpcert_t *cert)
        else
        {
                chunk_t fp;
-               
+
                /* V3 fingerprint is computed by public_key_t class */
                if (!cert->public_key->get_fingerprint(cert->public_key, KEY_ID_PGPV3,
                                                                                           &fp))
@@ -307,7 +307,7 @@ bool parse_pgp(chunk_t blob, pgpcert_t *cert)
                /* should not occur, nothing to parse */
                return FALSE;
        }
-       
+
        /* parse a PGP certificate file */
        cert->certificate = blob;
        time(&cert->installed);
index 9b13c236aa0e189fcfb34474037c3f9a8b97ceff..e6b085f782915e6a74d36ce70897c0dbc6d13afd 100644 (file)
@@ -155,13 +155,13 @@ static char ASN1_pkcs7_encrypted_data_oid_str[] = {
        0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06
 };
 
-static const chunk_t ASN1_pkcs7_data_oid = 
+static const chunk_t ASN1_pkcs7_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_data_oid_str);
 static const chunk_t ASN1_pkcs7_signed_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_signed_data_oid_str);
 static const chunk_t ASN1_pkcs7_enveloped_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_enveloped_data_oid_str);
-static const chunk_t ASN1_pkcs7_signed_enveloped_data_oid = 
+static const chunk_t ASN1_pkcs7_signed_enveloped_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_signed_enveloped_data_oid_str);
 static const chunk_t ASN1_pkcs7_digested_data_oid =
                                                chunk_from_buf(ASN1_pkcs7_digested_data_oid_str);
@@ -180,7 +180,7 @@ static u_char ASN1_des_cbc_oid_str[] = {
        0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x07
 };
 
-static const chunk_t ASN1_3des_ede_cbc_oid = 
+static const chunk_t ASN1_3des_ede_cbc_oid =
                                                chunk_from_buf(ASN1_3des_ede_cbc_oid_str);
 static const chunk_t ASN1_des_cbc_oid =
                                                chunk_from_buf(ASN1_des_cbc_oid_str);
@@ -308,7 +308,7 @@ bool pkcs7_parse_signedData(chunk_t blob, contentInfo_t *data, x509cert_t **cert
                case PKCS7_SIGNER_INFO:
                        signerInfos++;
                        DBG2("  signer #%d", signerInfos);
-                       break;      
+                       break;
                case PKCS7_SIGNED_ISSUER:
                        dntoa(buf, BUF_LEN, object);
                        DBG2("  '%s'",buf);
@@ -444,21 +444,21 @@ bool pkcs7_parse_envelopedData(chunk_t blob, chunk_t *data,
                case PKCS7_ISSUER:
                        dntoa(buf, BUF_LEN, object);
                        DBG2("  '%s'", buf);
-                       break;      
+                       break;
                case PKCS7_SERIAL_NUMBER:
                        if (!chunk_equals(serialNumber, object))
                        {
                                DBG1("serial numbers do not match");
                                goto end;
-                       }   
-                       break;      
+                       }
+                       break;
                case PKCS7_ENCRYPTION_ALG:
                        enc_alg = asn1_parse_algorithmIdentifier(object, level, NULL);
                        if (enc_alg != OID_RSA_ENCRYPTION)
                        {
                                DBG1("only rsa encryption supported");
                                goto end;
-                       } 
+                       }
                        break;
                case PKCS7_ENCRYPTED_KEY:
                        if (!key->decrypt(key, object, &symmetric_key))
@@ -477,7 +477,7 @@ bool pkcs7_parse_envelopedData(chunk_t blob, chunk_t *data,
                        break;
                case PKCS7_CONTENT_ENC_ALGORITHM:
                        content_enc_alg = asn1_parse_algorithmIdentifier(object, level, &iv);
-       
+
                        if (content_enc_alg == OID_UNKNOWN)
                        {
                                DBG1("unknown content encryption algorithm");
@@ -585,12 +585,12 @@ chunk_t pkcs7_contentType_attribute(void)
 
 /**
  * @brief Builds a messageDigest attribute
- * 
- * 
+ *
+ *
  * @param[in] blob content to create digest of
  * @param[in] digest_alg digest algorithm to be used
  * @return ASN.1 encoded messageDigest attribute
- * 
+ *
  */
 chunk_t pkcs7_messageDigest_attribute(chunk_t content, int digest_alg)
 {
@@ -737,7 +737,7 @@ chunk_t pkcs7_build_envelopedData(chunk_t data, const x509cert_t *cert, int enc_
        /* generate a true random symmetric encryption key and a pseudo-random iv */
        {
                rng_t *rng;
-               
+
                rng = lib->crypto->create_rng(lib->crypto, RNG_TRUE);
                rng->allocate_bytes(rng, crypter->get_key_size(crypter), &symmetricKey);
                DBG4("symmetric encryption key %B", &symmetricKey);
@@ -775,13 +775,13 @@ chunk_t pkcs7_build_envelopedData(chunk_t data, const x509cert_t *cert, int enc_
 
        cert->public_key->encrypt(cert->public_key, symmetricKey, &protectedKey);
 
-       /* build pkcs7 enveloped data object */ 
+       /* build pkcs7 enveloped data object */
        {
-               
+
                chunk_t contentEncryptionAlgorithm = asn1_wrap(ASN1_SEQUENCE, "mm"
                                        , asn1_build_known_oid(enc_alg)
                                        , asn1_simple_object(ASN1_OCTET_STRING, iv));
-               
+
                chunk_t encryptedContentInfo = asn1_wrap(ASN1_SEQUENCE, "cmm"
                                        , ASN1_pkcs7_data_oid
                                        , contentEncryptionAlgorithm
index 550bda99972252c09843634571bc1d49118e99eb..808e5f042d8633b1b19d9c506452296b5f295a36 100644 (file)
@@ -234,8 +234,8 @@ static void print_plugins()
        char buf[BUF_LEN], *plugin;
        int len = 0;
        enumerator_t *enumerator;
-       
-       buf[0] = '\0';  
+
+       buf[0] = '\0';
        enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
        while (len < BUF_LEN && enumerator->enumerate(enumerator, &plugin))
        {
@@ -652,7 +652,7 @@ int main(int argc, char **argv)
        }
 
        /* load plugins, further infrastructure may need it */
-       if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, 
+       if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR,
                        lib->settings->get_str(lib->settings, "pluto.load", PLUGINS)))
        {
                exit(SS_RC_INITIALIZATION_FAILED);
@@ -678,7 +678,7 @@ int main(int argc, char **argv)
 
        /* drop unneeded capabilities and change UID/GID */
        prctl(PR_SET_KEEPCAPS, 1);
-               
+
 #ifdef IPSEC_GROUP
        {
                struct group group, *grp;
index 013deb4467405f7db1ee4cd55aa0719f2317fa15..818b84e6ece8832e9805d237d235a08ed86ecf2a 100644 (file)
@@ -424,7 +424,7 @@ whack_handle(int whackctlfd)
 
        if (msg.whack_ca && msg.cacert != NULL)
                add_ca_info(&msg);
-               
+
        /* process "listen" before any operation that could require it */
        if (msg.whack_listen)
        {
index 9261e1e4c3f172bcf0bd57c90b95a8bed29ebb1d..3283bdc8933110061ef5cc289dfcbee26d0b7227 100644 (file)
@@ -7,10 +7,10 @@
 
  * License is also granted to make and use derivative works provided that
  * such works are identified as "derived from the RSA Security Inc. PKCS #11
- * Cryptographic Token Interface (Cryptoki)" in all material mentioning or 
+ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or
  * referencing the derived work.
 
- * RSA Security Inc. makes no representations concerning either the 
+ * RSA Security Inc. makes no representations concerning either the
  * merchantability of this software or the suitability of this software for
  * any particular purpose. It is provided "as is" without express or implied
  * warranty of any kind.
@@ -275,7 +275,7 @@ extern "C" {
 
 #define CK_PKCS11_FUNCTION_INFO(name) \
   __PASTE(CK_,name) name;
-  
+
 struct CK_FUNCTION_LIST {
 
   CK_VERSION    version;  /* Cryptoki version */
index dec6315dd149fb293c34ac72134cabfd4599d0d6..54b884aed286ed7f8a247a433140fced805db88b 100644 (file)
@@ -7,10 +7,10 @@
 
  * License is also granted to make and use derivative works provided that
  * such works are identified as "derived from the RSA Security Inc. PKCS #11
- * Cryptographic Token Interface (Cryptoki)" in all material mentioning or 
+ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or
  * referencing the derived work.
 
- * RSA Security Inc. makes no representations concerning either the 
+ * RSA Security Inc. makes no representations concerning either the
  * merchantability of this software or the suitability of this software for
  * any particular purpose. It is provided "as is" without express or implied
  * warranty of any kind.
@@ -564,7 +564,7 @@ CK_PKCS11_FUNCTION_INFO(C_Sign)
 
 
 /* C_SignUpdate continues a multiple-part signature operation,
- * where the signature is (will be) an appendix to the data, 
+ * where the signature is (will be) an appendix to the data,
  * and plaintext cannot be recovered from the signature. */
 CK_PKCS11_FUNCTION_INFO(C_SignUpdate)
 #ifdef CK_NEED_ARG_LIST
@@ -576,7 +576,7 @@ CK_PKCS11_FUNCTION_INFO(C_SignUpdate)
 #endif
 
 
-/* C_SignFinal finishes a multiple-part signature operation, 
+/* C_SignFinal finishes a multiple-part signature operation,
  * returning the signature. */
 CK_PKCS11_FUNCTION_INFO(C_SignFinal)
 #ifdef CK_NEED_ARG_LIST
@@ -625,12 +625,12 @@ CK_PKCS11_FUNCTION_INFO(C_VerifyInit)
 (
   CK_SESSION_HANDLE hSession,    /* the session's handle */
   CK_MECHANISM_PTR  pMechanism,  /* the verification mechanism */
-  CK_OBJECT_HANDLE  hKey         /* verification key */ 
+  CK_OBJECT_HANDLE  hKey         /* verification key */
 );
 #endif
 
 
-/* C_Verify verifies a signature in a single-part operation, 
+/* C_Verify verifies a signature in a single-part operation,
  * where the signature is an appendix to the data, and plaintext
  * cannot be recovered from the signature. */
 CK_PKCS11_FUNCTION_INFO(C_Verify)
@@ -646,7 +646,7 @@ CK_PKCS11_FUNCTION_INFO(C_Verify)
 
 
 /* C_VerifyUpdate continues a multiple-part verification
- * operation, where the signature is an appendix to the data, 
+ * operation, where the signature is an appendix to the data,
  * and plaintext cannot be recovered from the signature. */
 CK_PKCS11_FUNCTION_INFO(C_VerifyUpdate)
 #ifdef CK_NEED_ARG_LIST
@@ -772,7 +772,7 @@ CK_PKCS11_FUNCTION_INFO(C_GenerateKey)
 #endif
 
 
-/* C_GenerateKeyPair generates a public-key/private-key pair, 
+/* C_GenerateKeyPair generates a public-key/private-key pair,
  * creating new key objects. */
 CK_PKCS11_FUNCTION_INFO(C_GenerateKeyPair)
 #ifdef CK_NEED_ARG_LIST
index 7e4452d89d1c77ef215e202edc7e435da5249ddd..8b479009f1aa92ebd0fa9da7b249479f502ff8a7 100644 (file)
@@ -115,7 +115,7 @@ static const char *const pkcs11_return_name_10[] = {
        };
 
 static const char *const pkcs11_return_name_20[] = {
-               "CKR_DATA_INVALID", 
+               "CKR_DATA_INVALID",
                "CKR_DATA_LEN_RANGE"
        };
 
@@ -659,7 +659,7 @@ scx_find_all_cert_objects(void)
                                , enum_show(&pkcs11_return_names, rv));
                        continue;
                }
-               
+
                if (!(info.flags & CKF_TOKEN_PRESENT))
                {
                        plog("no token present in slot %lu", slot);
@@ -750,7 +750,7 @@ scx_init(const char* module, const char *init_args)
 }
 
 /*
- * finalize and unload PKCS#11 cryptoki module 
+ * finalize and unload PKCS#11 cryptoki module
  */
 void
 scx_finalize(void)
@@ -791,12 +791,12 @@ scx_on_smartcard(const char *filename)
 
 #ifdef SMARTCARD
 /*
- * find a specific object on the smartcard 
+ * find a specific object on the smartcard
  */
 static bool
-scx_pkcs11_find_object( CK_SESSION_HANDLE session, 
-                                               CK_OBJECT_HANDLE_PTR object, 
-                                               CK_OBJECT_CLASS class, 
+scx_pkcs11_find_object( CK_SESSION_HANDLE session,
+                                               CK_OBJECT_HANDLE_PTR object,
+                                               CK_OBJECT_CLASS class,
                                                const char* id)
 {
        size_t len;
@@ -863,7 +863,7 @@ scx_find_cert_id_in_slot(smartcard_t *sc, CK_SLOT_ID slot)
                        , enum_show(&pkcs11_return_names, rv));
                 return FALSE;
        }
-               
+
        if (!(info.flags & CKF_TOKEN_PRESENT))
        {
                plog("no token present in slot %lu", slot);
@@ -891,7 +891,7 @@ scx_find_cert_id_in_slot(smartcard_t *sc, CK_SLOT_ID slot)
                sc->session_opened = TRUE;
                return TRUE;
        }
-               
+
        rv = pkcs11_functions->C_CloseSession(session);
        if (rv != CKR_OK)
        {
@@ -996,7 +996,7 @@ scx_login(smartcard_t *sc)
                )
                return TRUE;
        }
-               
+
        if (sc->pin.ptr == NULL)
        {
                plog("unable to log in without PIN!");
@@ -1009,7 +1009,7 @@ scx_login(smartcard_t *sc)
                return FALSE;
        }
 
-       rv = pkcs11_functions->C_Login(sc->session, CKU_USER 
+       rv = pkcs11_functions->C_Login(sc->session, CKU_USER
                                                                , (CK_UTF8CHAR *) sc->pin.ptr, sc->pin.len);
        if (rv != CKR_OK && rv != CKR_USER_ALREADY_LOGGED_IN)
        {
@@ -1035,7 +1035,7 @@ static void
 scx_logout(smartcard_t *sc)
 {
        CK_RV rv;
-       
+
        rv = pkcs11_functions->C_Logout(sc->session);
        if (rv != CKR_OK)
                plog("error in C_Logout: %s"
@@ -1067,7 +1067,7 @@ scx_release_context(smartcard_t *sc)
                        scx_logout(sc);
 
                sc->session_opened = FALSE;
-               
+
                rv = pkcs11_functions->C_CloseSession(sc->session);
                if (rv != CKR_OK)
                        plog("error in C_CloseSession: %s"
@@ -1169,7 +1169,7 @@ scx_parse_number_slot_id(const char *number_slot_id)
 
        if (len == 0)                       /* default: use certificate #1 */
        {
-               sc->number = 1; 
+               sc->number = 1;
        }
        else if (*number_slot_id == '#')    /* #number scheme */
        {
@@ -1223,7 +1223,7 @@ scx_verify_pin(smartcard_t *sc)
 {
 #ifdef SMARTCARD
        CK_RV rv;
-       
+
        if (!sc->pinpad)
                sc->valid = FALSE;
 
@@ -1377,7 +1377,7 @@ scx_sign_hash(smartcard_t *sc, const u_char *in, size_t inlen
 #endif
 }
 
-/* 
+/*
  * encrypt data block with an RSA public key
  */
 bool
@@ -1423,7 +1423,7 @@ scx_encrypt(smartcard_t *sc, const u_char *in, size_t inlen
                scx_release_context(sc);
                return FALSE;
        }
-               
+
        /* there must be enough space left for the PKCS#1 v1.5 padding */
        if (inlen > attr[0].ulValueLen - 11)
        {
@@ -1467,7 +1467,7 @@ scx_encrypt(smartcard_t *sc, const u_char *in, size_t inlen
                        rsa_key = asn1_wrap(ASN1_SEQUENCE, "mm",
                                                                asn1_integer("m", rsa_modulus),
                                                                asn1_integer("m", rsa_exponent));
-                       key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,  
+                       key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
                                                                BUILD_BLOB_ASN1_DER, rsa_key, BUILD_END);
                        free(rsa_key.ptr);
                        if (key == NULL)
@@ -1527,7 +1527,7 @@ scx_encrypt(smartcard_t *sc, const u_char *in, size_t inlen
        return FALSE;
 #endif
 }
-/* 
+/*
  * decrypt a data block with an RSA private key
  */
 bool
@@ -1570,7 +1570,7 @@ scx_decrypt(smartcard_t *sc, const u_char *in, size_t inlen
                scx_release_context(sc);
                return FALSE;
        }
-               
+
        DBG(DBG_CONTROL,
                DBG_log("doing RSA decryption on smartcard")
        )
@@ -1680,7 +1680,7 @@ scx_op_via_whack(const char* msg, int inbase, int outbase, sc_op_t op
                DBG_dump("smartcard output data:\n", inbuf, outlen)
        )
 
-       if (outbase == 0)  /* use default base */ 
+       if (outbase == 0)  /* use default base */
                outbase = DEFAULT_BASE;
 
        if (outbase == 256) /* ascii plain text */
@@ -1957,7 +1957,7 @@ scx_list(bool utc)
                        , scx_print_slot(sc, "    ")
                        , sc->session_opened? "opened" : "closed"
                        , sc->logged_in? "in" : "out"
-                       , sc->pinpad? "pin pad" 
+                       , sc->pinpad? "pin pad"
                                : ((sc->pin.ptr == NULL)? "no pin"
                                        : sc->valid? "valid pin" : "invalid pin"));
                if (sc->id != NULL)
index a86c9f21526a1e243378311eb5cd6e98ef3c3b77..975e79f963edfb8ffe7243db38b2cb9130e583a6 100644 (file)
@@ -607,7 +607,7 @@ static u_int32_t decode_long_duration(pb_stream *pbs)
 }
 
 /* Preparse the body of an ISAKMP SA Payload and
- * return body of ISAKMP Proposal Payload 
+ * return body of ISAKMP Proposal Payload
  *
  * Only IPsec DOI is accepted (what is the ISAKMP DOI?).
  * Error response is rudimentary.
@@ -1114,7 +1114,7 @@ notification_t parse_isakmp_sa_body(u_int32_t ipsecdoisit,
                                                                                , (long) val
                                                                                , OAKLEY_ISAKMP_SA_LIFETIME_MAXIMUM);
 #endif
-                                       }   
+                                       }
                                        ta.life_seconds = val;
                                        break;
                                case OAKLEY_LIFE_KILOBYTES:
@@ -2138,7 +2138,7 @@ parse_ipsec_sa_body(
                        }
                        if (tn == esp_proposal.isap_notrans)
                                continue;       /* we didn't find a nice one */
-                       
+
                        esp_attrs.spi = esp_spi;
                        inner_proto = IPPROTO_ESP;
                        if (esp_attrs.encapsulation == ENCAPSULATION_MODE_TUNNEL)
index 5bef36c5c064bebf815f4b54f501e2cd50fe1185..9c6f49235ba2dcb58961335b6415e4c925035c8b 100644 (file)
@@ -448,7 +448,7 @@ void delete_states_by_connection(struct connection *c, bool relations)
                        }
                }
        }
-       
+
        sr = &c->spd;
        while (sr != NULL)
        {
@@ -521,7 +521,7 @@ struct state *duplicate_state(struct state *st)
 
        memcpy(nst->st_icookie, st->st_icookie, COOKIE_SIZE);
        memcpy(nst->st_rcookie, st->st_rcookie, COOKIE_SIZE);
-       
+
        nst->st_connection = st->st_connection;
        nst->st_doi = st->st_doi;
        nst->st_situation = st->st_situation;
@@ -724,7 +724,7 @@ void fmt_state(bool all, struct state *st, time_t n, char *state_buf,
                ? "; eroute owner" : "";
        const char *dpd = (all && st->st_dpd && c->dpd_action != DPD_ACTION_NONE)
                                          ? "; DPD active" : "";
-       
+
        passert(st->st_event != 0);
 
        fmt_conn_instance(c, inst);
index 89082f88e51e16d1c511677d4af8514d0565bff5..1fbd9296903f7e2eecce6d74d0402ba8012eb536 100644 (file)
@@ -143,7 +143,7 @@ void event_schedule(enum event_type type, time_t tm, struct state *st)
 bool init_secret(void)
 {
        rng_t *rng;
-        
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
 
        if (rng == NULL)
@@ -216,7 +216,7 @@ void handle_timer_event(void)
                        passert(st->st_dpd_event == ev);
                        st->st_dpd_event = NULL;
                }
-               else 
+               else
                {
                        passert(st->st_event == ev);
                        st->st_event = NULL;
index 090a3cb90d70fba96b9ee71ee156b02ccb99389c..8c1aaf0b8105f7bbffc8ed2d731243fc0e83e65c 100644 (file)
@@ -158,7 +158,7 @@ static struct vid_struct _vid_tab[] = {
                { VID_CISCO3K, VID_KEEP | VID_SUBSTRING_MATCH, NULL, "Cisco VPN 3000 Series" ,
                  { "\x1f\x07\xf7\x0e\xaa\x65\x14\xd3\xb0\xfa\x96\x54\x2a\x50", 14 } },
 
-               { VID_CISCO_IOS, VID_KEEP | VID_SUBSTRING_MATCH, 
+               { VID_CISCO_IOS, VID_KEEP | VID_SUBSTRING_MATCH,
                  NULL, "Cisco IOS Device", { "\x3e\x98\x40\x48", 4 } },
 
                /*
@@ -297,7 +297,7 @@ static struct vid_struct _vid_tab[] = {
                DEC_MD5_VID(NATT_RFC, "RFC 3947")
 
                /* misc */
-               
+
                { VID_MISC_XAUTH, VID_KEEP, NULL, "XAUTH",
                        { "\x09\x00\x26\x89\xdf\xd6\xb7\x12", 8 } },
 
@@ -305,7 +305,7 @@ static struct vid_struct _vid_tab[] = {
                        { "\xaf\xca\xd7\x13\x68\xa1\xf1\xc9\x6b\x86\x96\xfc\x77\x57\x01\x00", 16 } },
 
                DEC_MD5_VID(MISC_FRAGMENTATION, "FRAGMENTATION")
-               
+
                DEC_MD5_VID(INITIAL_CONTACT, "Vid-Initial-Contact")
 
                /**
@@ -339,7 +339,7 @@ void init_vendorid(void)
                else if (vid->flags & VID_MD5HASH)
                {
                        chunk_t vid_data = { (u_char *)vid->data, strlen(vid->data) };
-                       
+
                        /** VendorID is a string to hash with MD5 **/
                        hasher->allocate_hash(hasher, vid_data, &vid->vid);
                }
index 2067bde01f73ee08ebcb93e5323b18670b99b927..84f24e9c82d30406543d4b5ecec7d16769cc442c 100644 (file)
@@ -227,7 +227,7 @@ struct virtual_t
                }
                else
                        goto fail;
-               
+
                str = *next ? next+1 : NULL;
        }
 
@@ -312,7 +312,7 @@ is_virtual_net_allowed(const struct connection *c, const ip_subnet *peer_net,
        if (c->spd.that.virt->n_net
        &&  net_in_list(peer_net, c->spd.that.virt->net, c->spd.that.virt->n_net))
                return TRUE;
-       
+
        if (c->spd.that.virt->flags & F_VIRTUAL_ALL)
        {
                /** %all must only be used for testing - log it **/
index 827c2c95cad0acc2619e84296d080fa4ac99782c..50322da8836bfc844e880bd52ca734f47f5694f5 100644 (file)
@@ -49,7 +49,7 @@
 static x509cert_t *x509certs     = NULL;
 
 /**
- * ASN.1 definition of a basicConstraints extension 
+ * ASN.1 definition of a basicConstraints extension
  */
 static const asn1Object_t basicConstraintsObjects[] = {
        { 0, "basicConstraints",        ASN1_SEQUENCE, ASN1_NONE          }, /*  0 */
@@ -61,7 +61,7 @@ static const asn1Object_t basicConstraintsObjects[] = {
 #define BASIC_CONSTRAINTS_CA   1
 
 /**
- * ASN.1 definition of a authorityKeyIdentifier extension 
+ * ASN.1 definition of a authorityKeyIdentifier extension
  */
 static const asn1Object_t authKeyIdentifierObjects[] = {
        { 0, "authorityKeyIdentifier",          ASN1_SEQUENCE,    ASN1_NONE          }, /* 0 */
@@ -78,7 +78,7 @@ static const asn1Object_t authKeyIdentifierObjects[] = {
 #define AUTH_KEY_ID_CERT_SERIAL                5
 
 /**
- * ASN.1 definition of a authorityInfoAccess extension 
+ * ASN.1 definition of a authorityInfoAccess extension
  */
 static const asn1Object_t authInfoAccessObjects[] = {
        { 0, "authorityInfoAccess",     ASN1_SEQUENCE,  ASN1_LOOP }, /* 0 */
@@ -103,7 +103,7 @@ static const asn1Object_t extendedKeyUsageObjects[] = {
 #define EXT_KEY_USAGE_PURPOSE_ID       1
 
 /**
- * ASN.1 definition of generalNames 
+ * ASN.1 definition of generalNames
  */
 static const asn1Object_t generalNamesObjects[] = {
        { 0, "generalNames",    ASN1_SEQUENCE,  ASN1_LOOP }, /* 0 */
@@ -114,7 +114,7 @@ static const asn1Object_t generalNamesObjects[] = {
 #define GENERAL_NAMES_GN       1
 
 /**
- * ASN.1 definition of generalName 
+ * ASN.1 definition of generalName
  */
 static const asn1Object_t generalNameObjects[] = {
        { 0, "otherName",               ASN1_CONTEXT_C_0,  ASN1_OPT|ASN1_BODY   }, /*  0 */
@@ -148,7 +148,7 @@ static const asn1Object_t generalNameObjects[] = {
 #define GN_OBJ_REGISTERED_ID   16
 
 /**
- * ASN.1 definition of otherName 
+ * ASN.1 definition of otherName
  */
 static const asn1Object_t otherNameObjects[] = {
        {0, "type-id",  ASN1_OID,                       ASN1_BODY       }, /* 0 */
@@ -396,7 +396,7 @@ static err_t get_next_rdn(chunk_t *rdn, chunk_t * attribute, chunk_t *oid,
                        return "RDN is not a SET";
                }
                attribute->len = asn1_length(rdn);
-               
+
                if (attribute->len == ASN1_INVALID_LENGTH)
                {
                        return "Invalid attribute length";
@@ -416,13 +416,13 @@ static err_t get_next_rdn(chunk_t *rdn, chunk_t * attribute, chunk_t *oid,
 
        /* extract the attribute body */
        body.len = asn1_length(attribute);
-       
+
        if (body.len == ASN1_INVALID_LENGTH)
        {
                return "Invalid attribute body length";
        }
        body.ptr = attribute->ptr;
-       
+
        /* advance to start of next attribute */
        attribute->ptr += body.len;
        attribute->len -= body.len;
@@ -435,8 +435,8 @@ static err_t get_next_rdn(chunk_t *rdn, chunk_t * attribute, chunk_t *oid,
 
        /* extract OID */
        oid->len = asn1_length(&body);
-       
-       if (oid->len == ASN1_INVALID_LENGTH)  
+
+       if (oid->len == ASN1_INVALID_LENGTH)
        {
                return "Invalid attribute OID length";
        }
@@ -451,7 +451,7 @@ static err_t get_next_rdn(chunk_t *rdn, chunk_t * attribute, chunk_t *oid,
 
        /* extract string value */
        value->len = asn1_length(&body);
-       
+
        if (value->len == ASN1_INVALID_LENGTH)
        {
                return "Invalid attribute string length";
@@ -1092,7 +1092,7 @@ chunk_t build_subjectAltNames(generalName_t *subjectAltNames)
        chunk_t names;
        size_t len = 0;
        generalName_t *gn = subjectAltNames;
-               
+
    /* compute the total size of the ASN.1 attributes object */
        while (gn != NULL)
        {
@@ -1127,7 +1127,7 @@ static chunk_t build_tbs_x509cert(x509cert_t *cert, public_key_t *rsa)
        rsa->get_encoding(rsa, KEY_PUB_ASN1_DER, &key);
 
        chunk_t keyInfo = asn1_wrap(ASN1_SEQUENCE, "mm",
-                                                       asn1_algorithmIdentifier(OID_RSA_ENCRYPTION), 
+                                                       asn1_algorithmIdentifier(OID_RSA_ENCRYPTION),
                                                        asn1_bitstring("m", key));
 
        if (cert->subjectAltName != NULL)
@@ -1143,7 +1143,7 @@ static chunk_t build_tbs_x509cert(x509cert_t *cert, public_key_t *rsa)
                                , asn1_algorithmIdentifier(cert->sigAlg)
                                , cert->issuer
                                , asn1_wrap(ASN1_SEQUENCE, "mm"
-                                       , asn1_from_time(&cert->notBefore, ASN1_UTCTIME) 
+                                       , asn1_from_time(&cert->notBefore, ASN1_UTCTIME)
                                        , asn1_from_time(&cert->notAfter,  ASN1_UTCTIME)
                                  )
                                , cert->subject
@@ -1237,7 +1237,7 @@ void store_x509certs(x509cert_t **firstcert, bool strict)
                if (cert->isCA)
                {
                        *pp = cert->next;
-                       
+
                        /* we don't accept self-signed CA certs */
                        if (same_dn(cert->issuer, cert->subject))
                        {
@@ -1258,11 +1258,11 @@ void store_x509certs(x509cert_t **firstcert, bool strict)
        }
 
        /* now verify the candidate CA certs */
-       
+
        while (cacerts != NULL)
        {
                x509cert_t *cert = cacerts;
-               
+
                cacerts = cacerts->next;
 
                if (trust_authcert_candidate(cert, cacerts))
@@ -1275,7 +1275,7 @@ void store_x509certs(x509cert_t **firstcert, bool strict)
                        free_x509cert(cert);
                }
        }
-       
+
        /* now verify the end certificates */
 
        pp = firstcert;
@@ -1314,7 +1314,7 @@ bool x509_check_signature(chunk_t tbs, chunk_t sig, int algorithm,
        {
                return FALSE;
        }
-       return key->verify(key, scheme, tbs, sig); 
+       return key->verify(key, scheme, tbs, sig);
 }
 
 /**
@@ -1329,7 +1329,7 @@ chunk_t x509_build_signature(chunk_t tbs, int algorithm, private_key_t *key,
        if (scheme == SIGN_UNKNOWN || !key->sign(key, scheme, tbs, &signature))
        {
                return chunk_empty;
-       } 
+       }
        return (bit_string) ? asn1_bitstring("m", signature)
                                                : asn1_wrap(ASN1_OCTET_STRING, "m", signature);
 }
@@ -1399,7 +1399,7 @@ void gntoid(struct id *id, const generalName_t *gn)
 bool compute_subjectKeyID(x509cert_t *cert, chunk_t subjectKeyID)
 {
        chunk_t fingerprint;
-       
+
        if (!cert->public_key->get_fingerprint(cert->public_key, KEY_ID_PUBKEY_SHA1,
                                                                                   &fingerprint))
        {
@@ -1446,7 +1446,7 @@ static bool parse_otherName(chunk_t blob, int level0)
                }
        }
        success = parser->success(parser);
-       
+
 end:
        parser->destroy(parser);
        return success;
@@ -1466,11 +1466,11 @@ static generalName_t* parse_generalName(chunk_t blob, int level0)
 
        parser = asn1_parser_create(generalNameObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                bool valid_gn = FALSE;
-               
+
                switch (objectID) {
                case GN_OBJ_RFC822_NAME:
                case GN_OBJ_DNS_NAME:
@@ -1517,7 +1517,7 @@ static generalName_t* parse_generalName(chunk_t blob, int level0)
                        goto end;
                }
        }
-       
+
 end:
        parser->destroy(parser);
        return gn;
@@ -1536,7 +1536,7 @@ static generalName_t* parse_generalNames(chunk_t blob, int level0, bool implicit
        parser = asn1_parser_create(generalNamesObjects, blob);
        parser->set_top_level(parser, level0);
        parser->set_flags(parser, implicit, FALSE);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                if (objectID == GENERAL_NAMES_GN)
@@ -1584,7 +1584,7 @@ void parse_authorityKeyIdentifier(chunk_t blob, int level0,
 
        parser = asn1_parser_create(authKeyIdentifierObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                switch (objectID)
@@ -1623,7 +1623,7 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
 
        parser = asn1_parser_create(authInfoAccessObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                switch (objectID)
@@ -1665,7 +1665,7 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
                        break;
                }
        }
-       
+
 end:
        parser->destroy(parser);
 }
@@ -1682,7 +1682,7 @@ static bool parse_extendedKeyUsage(chunk_t blob, int level0)
 
        parser = asn1_parser_create(extendedKeyUsageObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                if (objectID == EXT_KEY_USAGE_PURPOSE_ID
@@ -1711,7 +1711,7 @@ static generalName_t* parse_crlDistributionPoints(chunk_t blob, int level0)
 
        parser = asn1_parser_create(crlDistributionPointsObjects, blob);
        parser->set_top_level(parser, level0);
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                if (objectID == CRL_DIST_POINTS_FULLNAME)
@@ -1752,7 +1752,7 @@ bool parse_x509cert(chunk_t blob, u_int level0, x509cert_t *cert)
        while (parser->iterate(parser, &objectID, &object))
        {
                u_int level = parser->get_level(parser) + 1;
-               
+
                switch (objectID) {
                case X509_OBJ_CERTIFICATE:
                        cert->certificate = object;
@@ -2015,7 +2015,7 @@ bool verify_x509cert(const x509cert_t *cert, bool strict, time_t *until)
                                DBG(DBG_CONTROL,
                                        DBG_log("certificate is good")
                                )
-                               
+
                                /* with strict crl policy the public key must have the same
                                 * lifetime as the validity of the ocsp status or crl lifetime
                                 */
@@ -2099,7 +2099,7 @@ void list_x509cert_chain(const char *caption, x509cert_t* cert,
                                check_expiry(cert->notAfter, CA_CERT_WARNING_INTERVAL, TRUE));
                        whack_log(RC_COMMENT, "       pubkey:    %N %4d bits%s",
                                key_type_names, key->get_type(key),
-                               key->get_keysize(key) * BITS_PER_BYTE,                          
+                               key->get_keysize(key) * BITS_PER_BYTE,
                                cert->smartcard ? ", on smartcard" :
                                (has_private_key(c)? ", has private key" : ""));
                        if (key->get_fingerprint(key, KEY_ID_PUBKEY_INFO_SHA1, &keyid))
index ab0fbac9e9f3ce76501455456517d19b89424d25..7bad3525711431bbdc9243ac3dbd992ae120c08a 100644 (file)
@@ -69,7 +69,7 @@ struct x509cert {
        time_t               notBefore;
        time_t               notAfter;
        chunk_t            subject;
-       public_key_t       *public_key;  
+       public_key_t       *public_key;
                                  /*   issuerUniqueID */
                                  /*   subjectUniqueID */
                                  /*   v3 extensions */
index af2d72d71e8fca27c5ddb4768455940f74609c57..2086a92cc9221648631329c3fca82ee14bf60a7f 100644 (file)
@@ -1,7 +1,7 @@
 /* Initialization and finalization of the dynamic XAUTH module
  * Copyright (C) 2006 Andreas Steffen
  * Hochschule fuer Technik Rapperswil, Switzerland
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
@@ -23,7 +23,7 @@
 #include "keys.h"
 #include "log.h"
 
-void 
+void
 xauth_init(void)
 {
 #ifdef XAUTH_DEFAULT_LIB
index 8ab125ac41b7fefc6ec99f313dc28bf5c18ff3b0..23cae3ed8d1371f26ab347d27ff0da75b177b2c9 100644 (file)
@@ -1,7 +1,7 @@
 /* Interface definition of the XAUTH server and|or client module
  * Copyright (C) 2006 Andreas Steffen
  * Hochschule fuer Technik Rapperswil, Switzerland
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
index 87041f114eb81eea2f832def62175e283d3a2c4f..539bb5f72d6e84e5de563b819ad2d426e0a17777 100644 (file)
@@ -56,12 +56,12 @@ static void scepclient_dbg(int level, char *fmt, ...)
        else if (cur_debugging & DBG_RAW)
        {
                debug_level = 3;
-       }       
+       }
        else if (cur_debugging & DBG_PARSING)
        {
                debug_level = 2;
        }
-       else 
+       else
        {
                debug_level = 1;
        }
index ca0e808fa19ec65bc5aa93d999395c34dbed3f27..654626d152abc51c34ada901c4d6c1a1b416ab8b 100644 (file)
@@ -50,16 +50,16 @@ static u_char ASN1_extensionRequest_oid_str[] = {
 
 static const chunk_t ASN1_extensionRequest_oid = chunk_from_buf(ASN1_extensionRequest_oid_str);
 
-/** 
+/**
  * @brief Adds a subjectAltName in DER-coded form to a linked list
- * 
+ *
  * @param[in,out]       subjectAltNames head of the linked list of subjectAltNames
  * @param[in]           kind            type of the subjectAltName (which is a generalName)
  * @param[in]           value           value of the subjectAltName as an ASCII string
  */
 void
 pkcs10_add_subjectAltName(generalName_t **subjectAltNames, generalNames_t kind
-, char *value) 
+, char *value)
 {
        generalName_t *gn;
        asn1_t asn1_type = ASN1_EOC;
@@ -102,8 +102,8 @@ pkcs10_add_subjectAltName(generalName_t **subjectAltNames, generalNames_t kind
 }
 
 /**
- * @brief Builds the requestInfoAttributes of the certificationRequestInfo-field 
- * 
+ * @brief Builds the requestInfoAttributes of the certificationRequestInfo-field
+ *
  * challenge password ans subjectAltNames are only included,
  * when avaiable in given #pkcs10_t structure
  *
@@ -117,7 +117,7 @@ build_req_info_attributes(pkcs10_t* pkcs10)
        chunk_t subjectAltNames   = chunk_empty;
        chunk_t challengePassword = chunk_empty;
 
-       if (pkcs10->subjectAltNames != NULL) 
+       if (pkcs10->subjectAltNames != NULL)
        {
 
                subjectAltNames = asn1_wrap(ASN1_SEQUENCE, "cm"
@@ -158,11 +158,11 @@ static chunk_t
 pkcs10_build_request(pkcs10_t *pkcs10, int signature_alg)
 {
        chunk_t key = chunk_empty;
-       
+
        pkcs10->public_key->get_encoding(pkcs10->public_key, KEY_PUB_ASN1_DER, &key);
-       
+
        chunk_t keyInfo = asn1_wrap(ASN1_SEQUENCE, "mm",
-                                                       asn1_algorithmIdentifier(OID_RSA_ENCRYPTION), 
+                                                       asn1_algorithmIdentifier(OID_RSA_ENCRYPTION),
                                                        asn1_bitstring("m", key));
 
        chunk_t cert_req_info = asn1_wrap(ASN1_SEQUENCE, "ccmm",
index 3f29f019a9539ab3d6191c9e33553935990821ff..e10a3ef591f6f61555bfedc850cdb0453cd0db4f 100644 (file)
@@ -1,14 +1,14 @@
 /**
  * @file pkcs10.h
  * @brief Functions to build PKCS#10 Request's
- * 
+ *
  * Contains functions to build DER encoded pkcs#10 certificate requests
  */
 
 /*
  * Copyright (C) 2005 Jan Hutter, Martin Willi
  * Hochschule fuer Technik Rapperswil
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
@@ -34,9 +34,9 @@ typedef struct pkcs10_struct pkcs10_t;
 /**
  * @brief type representating a pkcs#10 request.
  *
- * A pkcs#10 request contains a distinguished name, an optional 
+ * A pkcs#10 request contains a distinguished name, an optional
  * challenge password, a public key and optional subjectAltNames.
- * 
+ *
  * The RSA private key is needed to compute the signature of the given request
  */
 struct pkcs10_struct {
index bf2532c808e6e77c0b713216380ffa8b287cbe94..f496ece334e4316dec8f0b31247bc9cd16683cc4 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * @file scep.c
  * @brief SCEP specific functions
- * 
+ *
  * Contains functions to build SCEP request's and to parse SCEP reply's.
  */
 
@@ -239,7 +239,7 @@ bool parse_attributes(chunk_t blob, scep_attributes_t *attrs)
        DBG(DBG_CONTROL | DBG_PARSING,
                DBG_log("parsing attributes")
        )
-       
+
        while (parser->iterate(parser, &objectID, &object))
        {
                switch (objectID)
@@ -255,14 +255,14 @@ bool parse_attributes(chunk_t blob, scep_attributes_t *attrs)
                }
        }
        success = parser->success(parser);
-       
+
 end:
        parser->destroy(parser);
        return success;
 }
 
 /**
- * Generates a unique fingerprint of the pkcs10 request 
+ * Generates a unique fingerprint of the pkcs10 request
  * by computing an MD5 hash over it
  */
 chunk_t scep_generate_pkcs10_fingerprint(chunk_t pkcs10)
@@ -291,11 +291,11 @@ void scep_generate_transaction_id(public_key_t *key, chunk_t *transID,
        hasher_t *hasher;
        bool msb_set;
        u_char *pos;
-       
+
        key->get_encoding(key, KEY_PUB_ASN1_DER, &keyEncoding);
-       
+
        keyInfo = asn1_wrap(ASN1_SEQUENCE, "mm",
-                                               asn1_algorithmIdentifier(OID_RSA_ENCRYPTION), 
+                                               asn1_algorithmIdentifier(OID_RSA_ENCRYPTION),
                                                asn1_bitstring("m", keyEncoding));
 
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
@@ -497,7 +497,7 @@ bool scep_http_request(const char *url, chunk_t pkcs7, scep_op_t op,
                        free(escaped_req);
 
                        status = lib->fetcher->fetch(lib->fetcher, complete_url, response,
-                                                                                FETCH_HTTP_VERSION_1_0, 
+                                                                                FETCH_HTTP_VERSION_1_0,
                                                                                 FETCH_REQUEST_HEADER, "Pragma:",
                                                                                 FETCH_REQUEST_HEADER, "Host:",
                                                                                 FETCH_REQUEST_HEADER, "Accept:",
@@ -510,7 +510,7 @@ bool scep_http_request(const char *url, chunk_t pkcs7, scep_op_t op,
                        complete_url = malloc(len);
                        snprintf(complete_url, len, "%s?operation=%s", url, operation);
 
-                       status = lib->fetcher->fetch(lib->fetcher, complete_url, response, 
+                       status = lib->fetcher->fetch(lib->fetcher, complete_url, response,
                                                                                 FETCH_REQUEST_DATA, pkcs7,
                                                                                 FETCH_REQUEST_TYPE, "",
                                                                                 FETCH_REQUEST_HEADER, "Expect:",
@@ -527,7 +527,7 @@ bool scep_http_request(const char *url, chunk_t pkcs7, scep_op_t op,
                snprintf(complete_url, len, "%s?operation=%s&message=CAIdentifier"
                                , url, operation);
 
-               status = lib->fetcher->fetch(lib->fetcher, complete_url, response, 
+               status = lib->fetcher->fetch(lib->fetcher, complete_url, response,
                                                                         FETCH_END);
        }
 
index e8dc875918039babf7b99140d7e7c0e5c025c640..e044f0b1ce6a7f80ff88818541fe6308ed3ad178 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * @file scep.h
  * @brief SCEP specific functions
- * 
+ *
  * Contains functions to build and parse SCEP requests and replies
  */
 
index f2b49f256acc3c80da8ea0696b140bc1c845ea17..e325f3f84dd51336fe0a7a02433d1c1c26093df1 100644 (file)
@@ -279,7 +279,7 @@ static void print_plugins()
        char buf[BUF_LEN], *plugin;
        int len = 0;
        enumerator_t *enumerator;
-       
+
        enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
        while (len < BUF_LEN && enumerator->enumerate(enumerator, &plugin))
        {
@@ -544,7 +544,7 @@ int main(int argc, char **argv)
                                }
                                continue;
                        }
-               
+
                case 'f':       /* --force */
                        force = TRUE;
                        continue;
@@ -626,7 +626,7 @@ int main(int argc, char **argv)
                                }
 
                                if (strcaseeq("email", optarg))
-                               {       
+                               {
                                        kind = GN_RFC822_NAME;
                                }
                                else if (strcaseeq("dns", optarg))
@@ -748,7 +748,7 @@ int main(int argc, char **argv)
                        base_debugging |= DBG_PRIVATE;
                        continue;
 #endif
-               default: 
+               default:
                        usage("unknown option");
                }
                /* break from loop */
@@ -759,7 +759,7 @@ int main(int argc, char **argv)
        init_log("scepclient");
 
        /* load plugins, further infrastructure may need it */
-       if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, 
+       if (!lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR,
                        lib->settings->get_str(lib->settings, "scepclient.load", PLUGINS)))
        {
                exit_scepclient("plugin loading failed");
@@ -790,7 +790,7 @@ int main(int argc, char **argv)
        /*
         * input of PKCS#1 file
         */
-       if (filetype_in & PKCS1)    /* load an RSA key pair from file */ 
+       if (filetype_in & PKCS1)    /* load an RSA key pair from file */
        {
                prompt_pass_t pass = { "", FALSE, STDIN_FILENO };
                char *path = concatenate_paths(PRIVATE_KEY_PATH, file_in_pkcs1);
@@ -871,7 +871,7 @@ int main(int argc, char **argv)
                plog("  fingerprint:    %s", fingerprint.ptr);
        }
 
-       /* 
+       /*
         * output of PKCS#10 file
         */
        if (filetype_out & PKCS10)
@@ -960,7 +960,7 @@ int main(int argc, char **argv)
                x509_ca_enc = cert.u.x509;
        }
 
-       /* 
+       /*
         * input of PKCS#7 file
         */
        if (filetype_in & PKCS7)
index f01f3e97fddfadbd3f9304cc5ff3081884ecac1b..b648d40ee975c2aec25ed77380c245a3b68f5178 100644 (file)
@@ -396,7 +396,7 @@ bool assign_arg(kw_token_t token, kw_token_t first, kw_list_t *kw, char *base,
        case ARG_UINT:
                {
                        char *endptr;
-                       u_int *u = (u_int *)p; 
+                       u_int *u = (u_int *)p;
 
                        *u = strtoul(kw->value, &endptr, 10);
 
@@ -509,12 +509,12 @@ bool assign_arg(kw_token_t token, kw_token_t first, kw_list_t *kw, char *base,
                        {
                                char ** lst;
 
-                               for (lst = *listp; lst && *lst; lst++) 
+                               for (lst = *listp; lst && *lst; lst++)
                                {
                                        bool match = FALSE;
 
                                        list = token_info[token].list;
-                               
+
                                        while (*list != NULL && !match)
                                        {
                                                match = streq(*lst, *list++);
index 5fd2b9fbf1ad4f5d81500e6addbc94e52b691073..ef27ce8934c3afb6b9a538b59e985ce1b64a2f0f 100644 (file)
@@ -119,7 +119,7 @@ load_setup(starter_config_t *cfg, config_parsed_t *cfgp)
                bool assigned = FALSE;
 
                kw_token_t token = kw->entry->token;
+
                if (token < KW_SETUP_FIRST || token > KW_SETUP_LAST)
                {
                        plog("# unsupported keyword '%s' in config setup", kw->entry->name);
@@ -165,10 +165,10 @@ kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token
                        ip_subnet net;
                        char *pos;
                        int len = 0;
-                       
+
                        end->has_client = TRUE;
                        conn->tunnel_addr_family = ip_version(value);
-                       
+
                        pos = strchr(value, ',');
                        if (pos)
                        {
@@ -199,7 +199,7 @@ kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token
                {
                        ip_address addr;
                        ip_subnet net;
-               
+
                        conn->tunnel_addr_family = ip_version(value);
                        if (strchr(value, '/'))
                        {       /* CIDR notation, address pool */
@@ -323,7 +323,7 @@ kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token
        case KW_SUBNETWITHIN:
        {
                ip_subnet net;
-               
+
                end->has_client = TRUE;
                end->has_client_wildcard = TRUE;
                conn->tunnel_addr_family = ip_version(value);
@@ -350,7 +350,7 @@ kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token
                if (streq(value, "%defaultroute"))
                {
                        char buf[64];
-               
+
                        if (cfg->defaultroute.defined)
                        {
                                addrtot(&cfg->defaultroute.addr, 0, buf, sizeof(buf));
@@ -365,7 +365,7 @@ kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token
                else
                {
                        ip_address addr;
-                       
+
                        conn->tunnel_addr_family = ip_version(value);
                        ugh = ttoaddr(value, 0, conn->tunnel_addr_family, &addr);
                        if (ugh != NULL)
@@ -510,8 +510,8 @@ load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
                        }
                        else if (streq(kw->value, "transport_proxy"))
                        {
-                               conn->policy |= POLICY_PROXY;                   
-                       }       
+                               conn->policy |= POLICY_PROXY;
+                       }
                        else if (streq(kw->value, "passthrough") || streq(kw->value, "pass"))
                        {
                                conn->policy |= POLICY_SHUNT_PASS;
@@ -535,10 +535,10 @@ load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
                        break;
                case KW_COMPRESS:
                        KW_POLICY_FLAG("yes", "no", POLICY_COMPRESS)
-                       break; 
+                       break;
                case KW_AUTH:
                        KW_POLICY_FLAG("ah", "esp", POLICY_AUTHENTICATE)
-                       break; 
+                       break;
                case KW_AUTHBY:
                        conn->policy &= ~(POLICY_ID_AUTH_MASK | POLICY_ENCRYPT);
 
@@ -591,7 +591,7 @@ load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
                case KW_EAP:
                {
                        char *sep;
-               
+
                        /* check for vendor-type format */
                        sep = strchr(kw->value, '-');
                        if (sep)
@@ -922,7 +922,7 @@ confread_free_ca(starter_ca_t *ca)
 /*
  * free the memory used by a starter_config_t object
  */
-void 
+void
 confread_free(starter_config_t *cfg)
 {
        starter_conn_t *conn = cfg->conn_first;
@@ -1046,7 +1046,7 @@ confread_load(const char *file)
        for (ca = cfg->ca_first; ca; ca = ca->next)
        {
                also_t *also = ca->also;
-       
+
                while (also != NULL)
                {
                        kw_list_t *kw = find_also_ca(also->name, cfg->ca_first, cfg);
@@ -1080,7 +1080,7 @@ confread_load(const char *file)
        for (sconn = cfgp->conn_first; sconn; sconn = sconn->next)
        {
                u_int previous_err;
-               
+
                /* skip %default conn section */
                if (streq(sconn->name, "%default"))
                        continue;
@@ -1093,7 +1093,7 @@ confread_load(const char *file)
                conn_default(sconn->name, conn, &cfg->conn_default);
                conn->kw =  sconn->kw;
                conn->next = NULL;
-               
+
                previous_err = cfg->err;
                load_conn(conn, conn->kw, cfg);
                if (cfg->err > previous_err)
index 2f789e9766f9a8810c90a478c7ac71d4a33ac53a..9fc11382eea514f5e0ae4def806b4637f4066b92 100644 (file)
@@ -128,12 +128,12 @@ struct starter_conn {
                char            *esp;
                char            *ike;
                char            *pfsgroup;
-               
+
                time_t          dpd_delay;
                time_t          dpd_timeout;
                dpd_action_t    dpd_action;
                int             dpd_count;
-               
+
                bool            me_mediation;
                char            *me_mediated_by;
                char            *me_peerid;
index 1eb2a03321cd3f564b52c4ce11bd96a2d243e675..f8aa5e6a91a3aa06636e4fa28cf885904fb7553d 100644 (file)
@@ -127,7 +127,7 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb)
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
        };
-       
+
        if (attach_gdb)
        {
                argc = 0;
@@ -163,7 +163,7 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb)
                        {
                                break;
                        }
-               
+
                        /* get next */
                        pos = strchr(pos, ',');
                        if (pos)
index 08fb0657aeda253cc7db4c058459704c170a1c3b..f91f4b6c9f470f37f309261a20c80c65ef4ac2cd 100644 (file)
@@ -94,7 +94,7 @@ starter_stop_pluto (void)
                /* be more and more aggressive */
                for (i = 0; i < 20 && (pid = _pluto_pid) != 0; i++)
                {
-                       
+
                        if (i < 10)
                        {
                                kill(pid, SIGTERM);
@@ -103,7 +103,7 @@ starter_stop_pluto (void)
                        {
                                kill(pid, SIGKILL);
                                plog("starter_stop_pluto(): pluto does not respond, sending KILL");
-                       }           
+                       }
                        else
                        {
                                kill(pid, SIGKILL);
@@ -147,7 +147,7 @@ starter_start_pluto (starter_config_t *cfg, bool no_fork, bool attach_gdb)
                };
 
        printf ("starter_start_pluto entered\n");
-       
+
        if (attach_gdb)
        {
                argc = 0;
index 061dee50cff6b09759befd308952ba54a0f48519..79bd25c44cb0c54729a01114e93ce2333d625655 100644 (file)
@@ -46,7 +46,7 @@ starter_klips_init(void)
                        return FALSE;
                }
        }
-       
+
        /* load crypto algorithm modules */
        ignore_result(system("modprobe -qv ipsec_aes"));
        ignore_result(system("modprobe -qv ipsec_blowfish"));
@@ -55,7 +55,7 @@ starter_klips_init(void)
        DBG(DBG_CONTROL,
                DBG_log("Found KLIPS IPsec stack")
        )
-       
+
        return TRUE;
 }
 
index e93348df1395ff7ffac317c8ad401d8a7de051fb..1a527d108156e725f04f327070e343c9617b19cc 100644 (file)
@@ -1,4 +1,4 @@
-/* strongSwan KLIPS initialization and cleanup 
+/* strongSwan KLIPS initialization and cleanup
  * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
  *
  * This program is free software; you can redistribute it and/or modify it
index 55f6a7c47d7fa003eea15e53b9e47752edc7fd6c..c12924174295ac1e8b9b6f1b5054e4255692466d 100644 (file)
@@ -1,4 +1,4 @@
-/* strongSwan netkey initialization and cleanup 
+/* strongSwan netkey initialization and cleanup
  * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
  *
  * This program is free software; you can redistribute it and/or modify it
index ff5ab9d873ceccca5a3f9bdeeace29ee27991e23..0aab76d43d95936e64d003ce0bfaec28e8874c07 100644 (file)
@@ -163,7 +163,7 @@ static void fsig(int signal)
 static void generate_selfcert()
 {
        struct stat stb;
-       
+
                /* if ipsec.secrets file is missing then generate RSA default key pair */
                if (stat(SECRETS_FILE, &stb) != 0)
                {
@@ -176,7 +176,7 @@ static void generate_selfcert()
                        {
                                char buf[1024];
                                struct group group, *grp;
-                               
+
                                if (getgrnam_r(IPSEC_GROUP, &group, buf, sizeof(buf), &grp) == 0 &&     grp)
                                {
                                        gid = grp->gr_gid;
@@ -187,7 +187,7 @@ static void generate_selfcert()
                        {
                                char buf[1024];
                                struct passwd passwd, *pwp;
-                               
+
                                if (getpwnam_r(IPSEC_USER, &passwd, buf, sizeof(buf), &pwp) == 0 &&     pwp)
                                {
                                        uid = pwp->pw_uid;
@@ -360,7 +360,7 @@ int main (int argc, char **argv)
                plog("starter is already running (%s exists) -- no fork done", STARTER_PID_FILE);
                exit(LSB_RC_SUCCESS);
        }
-       
+
        generate_selfcert();
 
        /* fork if we're not debugging stuff */
@@ -381,7 +381,7 @@ int main (int argc, char **argv)
                                        dup2(fnull, STDERR_FILENO);
                                        close(fnull);
                                }
-                               setsid(); 
+                               setsid();
                        }
                        break;
                        case -1:
@@ -491,7 +491,7 @@ int main (int argc, char **argv)
                                        _action_ |= FLAG_ACTION_LISTEN;
                                }
 
-                               if (!starter_cmp_pluto(cfg, new_cfg)) 
+                               if (!starter_cmp_pluto(cfg, new_cfg))
                                {
                                        plog("Pluto has changed");
                                        if (starter_pluto_pid())
@@ -620,7 +620,7 @@ int main (int argc, char **argv)
                                        conn->state = STATE_TO_ADD;
                        }
                }
-               
+
                /*
                 * Start charon
                 */
index 96caff8cb719d6aa36abb4d74a78025690cdf825..60da12bcac3e3c4fe8d5140eb58688bf3aa64686 100644 (file)
@@ -81,7 +81,7 @@ static int send_stroke_msg (stroke_msg_t *msg)
 
        ctl_addr.sun_family = AF_UNIX;
        strcpy(ctl_addr.sun_path, CHARON_CTL_FILE);
-       
+
        /* starter is not called from commandline, and therefore absolutely silent */
        msg->output_verbosity = -1;
 
@@ -173,7 +173,7 @@ static void ip_address2string(ip_address *addr, char *buffer, size_t len)
 static void starter_stroke_add_end(stroke_msg_t *msg, stroke_end_t *msg_end, starter_end_t *conn_end)
 {
        char buffer[INET6_ADDRSTRLEN];
-       
+
        msg_end->auth = push_string(msg, conn_end->auth);
        msg_end->auth2 = push_string(msg, conn_end->auth2);
        msg_end->id = push_string(msg, conn_end->id);
@@ -237,7 +237,7 @@ int starter_stroke_add_conn(starter_config_t *cfg, starter_conn_t *conn)
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.add_conn.ikev2 = conn->keyexchange == KEY_EXCHANGE_IKEV2;
        msg.add_conn.name = push_string(&msg, connection_name(conn));
-       
+
        /* PUBKEY is preferred to PSK and EAP */
        if (conn->policy & POLICY_PUBKEY)
        {
@@ -254,7 +254,7 @@ int starter_stroke_add_conn(starter_config_t *cfg, starter_conn_t *conn)
        msg.add_conn.eap_type = conn->eap_type;
        msg.add_conn.eap_vendor = conn->eap_vendor;
        msg.add_conn.eap_identity = push_string(&msg, conn->eap_identity);
-       
+
        if (conn->policy & POLICY_TUNNEL)
        {
                msg.add_conn.mode = MODE_TUNNEL;
@@ -267,7 +267,7 @@ int starter_stroke_add_conn(starter_config_t *cfg, starter_conn_t *conn)
        {
                msg.add_conn.mode = MODE_TRANSPORT;
                msg.add_conn.proxy_mode = TRUE;
-       } 
+       }
        else
        {
                msg.add_conn.mode = MODE_TRANSPORT;
@@ -365,7 +365,7 @@ int starter_stroke_del_ca(starter_ca_t *ca)
 int starter_stroke_configure(starter_config_t *cfg)
 {
        stroke_msg_t msg;
-    
+
        if (cfg->setup.cachecrls)
        {
                msg.type = STR_CONFIG;
index 44b442ae2cfab08fa442ac0bdede6a17073e3cc6..b680961656abc72051d30c9750233241e1b64e34 100644 (file)
@@ -153,7 +153,7 @@ connection_name(starter_conn_t *conn)
 
 static void
 set_whack_end(whack_end_t *w, starter_end_t *end, sa_family_t family)
-{   
+{
        if (end->srcip && end->srcip[0] != '%')
        {
                int len = 0;
@@ -170,9 +170,9 @@ set_whack_end(whack_end_t *w, starter_end_t *end, sa_family_t family)
        }
        else
        {
-               anyaddr(AF_INET, &w->host_srcip);       
+               anyaddr(AF_INET, &w->host_srcip);
        }
-       
+
        w->id                  = end->id;
        w->cert                = end->cert;
        w->ca                  = end->ca;
index 186e480d14fe1cdbb6c64397391e097ae80a311d..955e4953595e9e20b2998f101efff6539d34ed56 100644 (file)
@@ -60,9 +60,9 @@ static int send_stroke_msg (stroke_msg_t *msg)
 
        ctl_addr.sun_family = AF_UNIX;
        strcpy(ctl_addr.sun_path, STROKE_SOCKET);
-       
+
        msg->output_verbosity = 1; /* CONTROL */
-       
+
        sock = socket(AF_UNIX, SOCK_STREAM, 0);
        if (sock < 0)
        {
@@ -76,7 +76,7 @@ static int send_stroke_msg (stroke_msg_t *msg)
                close(sock);
                return -1;
        }
-       
+
        /* send message */
        if (write(sock, msg, msg->length) != msg->length)
        {
@@ -84,12 +84,12 @@ static int send_stroke_msg (stroke_msg_t *msg)
                close(sock);
                return -1;
        }
-       
+
        while ((byte_count = read(sock, buffer, sizeof(buffer)-1)) > 0)
        {
                buffer[byte_count] = '\0';
                printf("%s", buffer);
-               
+
                /* we prompt if we receive the "Passphrase:" magic keyword */
                if (byte_count >= 12 &&
                        strcmp(buffer + byte_count - 12, "Passphrase:\n") == 0)
@@ -104,46 +104,46 @@ static int send_stroke_msg (stroke_msg_t *msg)
        {
                fprintf(stderr, "reading from socket failed: %s\n", strerror(errno));
        }
-       
+
        close(sock);
        return 0;
 }
 
 static int add_connection(char *name,
-                                                 char *my_id, char *other_id, 
+                                                 char *my_id, char *other_id,
                                                  char *my_addr, char *other_addr,
                                                  char *my_nets, char *other_nets)
 {
        stroke_msg_t msg;
-       
+
        memset(&msg, 0, sizeof(msg));
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.type = STR_ADD_CONN;
-       
+
        msg.add_conn.name = push_string(&msg, name);
        msg.add_conn.ikev2 = 1;
        msg.add_conn.auth_method = 2;
        msg.add_conn.mode = 1;
        msg.add_conn.mobike = 1;
        msg.add_conn.dpd.action = 1;
-       
+
        msg.add_conn.me.id = push_string(&msg, my_id);
        msg.add_conn.me.address = push_string(&msg, my_addr);
        msg.add_conn.me.subnets = push_string(&msg, my_nets);
        msg.add_conn.me.sendcert = 1;
-       
+
        msg.add_conn.other.id = push_string(&msg, other_id);
        msg.add_conn.other.address = push_string(&msg, other_addr);
        msg.add_conn.other.subnets = push_string(&msg, other_nets);
        msg.add_conn.other.sendcert = 1;
-       
+
        return send_stroke_msg(&msg);
 }
 
 static int del_connection(char *name)
 {
        stroke_msg_t msg;
-       
+
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.type = STR_DEL_CONN;
        msg.initiate.name = push_string(&msg, name);
@@ -153,7 +153,7 @@ static int del_connection(char *name)
 static int initiate_connection(char *name)
 {
        stroke_msg_t msg;
-       
+
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.type = STR_INITIATE;
        msg.initiate.name = push_string(&msg, name);
@@ -163,7 +163,7 @@ static int initiate_connection(char *name)
 static int terminate_connection(char *name)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_TERMINATE;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.initiate.name = push_string(&msg, name);
@@ -173,7 +173,7 @@ static int terminate_connection(char *name)
 static int terminate_connection_srcip(char *start, char *end)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_TERMINATE_SRCIP;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.terminate_srcip.start = push_string(&msg, start);
@@ -184,7 +184,7 @@ static int terminate_connection_srcip(char *start, char *end)
 static int route_connection(char *name)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_ROUTE;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.route.name = push_string(&msg, name);
@@ -194,7 +194,7 @@ static int route_connection(char *name)
 static int unroute_connection(char *name)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_UNROUTE;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.unroute.name = push_string(&msg, name);
@@ -204,7 +204,7 @@ static int unroute_connection(char *name)
 static int show_status(stroke_keyword_t kw, char *connection)
 {
        stroke_msg_t msg;
-       
+
        msg.type = (kw == STROKE_STATUS)? STR_STATUS:STR_STATUS_ALL;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.status.name = push_string(&msg, connection);
@@ -229,7 +229,7 @@ static int list_flags[] = {
 static int list(stroke_keyword_t kw, int utc)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_LIST;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.list.utc = utc;
@@ -250,7 +250,7 @@ static int reread_flags[] = {
 static int reread(stroke_keyword_t kw)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_REREAD;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.reread.flags = reread_flags[kw - STROKE_REREAD_FIRST];
@@ -265,7 +265,7 @@ static int purge_flags[] = {
 static int purge(stroke_keyword_t kw)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_PURGE;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.purge.flags = purge_flags[kw - STROKE_PURGE_FIRST];
@@ -276,7 +276,7 @@ static int leases(stroke_keyword_t kw, char *pool, char *address)
 {
 
        stroke_msg_t msg;
-       
+
        msg.type = STR_LEASES;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.leases.pool = push_string(&msg, pool);
@@ -287,7 +287,7 @@ static int leases(stroke_keyword_t kw, char *pool, char *address)
 static int set_loglevel(char *type, u_int level)
 {
        stroke_msg_t msg;
-       
+
        msg.type = STR_LOGLEVEL;
        msg.length = offsetof(stroke_msg_t, buffer);
        msg.loglevel.type = push_string(&msg, type);
@@ -359,7 +359,7 @@ int main(int argc, char *argv[])
        {
                exit_usage(NULL);
        }
-       
+
        token = in_word_set(argv[1], strlen(argv[1]));
 
        if (token == NULL)
@@ -375,8 +375,8 @@ int main(int argc, char *argv[])
                                exit_usage("\"add\" needs more parameters...");
                        }
                        res = add_connection(argv[2],
-                                                                argv[3], argv[4], 
-                                                                argv[5], argv[6], 
+                                                                argv[3], argv[4],
+                                                                argv[5], argv[6],
                                                                 argv[7], argv[8]);
                        break;
                case STROKE_DELETE:
@@ -427,7 +427,7 @@ int main(int argc, char *argv[])
                        {
                                exit_usage("\"logtype\" needs more parameters...");
                        }
-                       res = set_loglevel(argv[2], atoi(argv[3])); 
+                       res = set_loglevel(argv[2], atoi(argv[3]));
                        break;
                case STROKE_STATUS:
                case STROKE_STATUSALL:
index 9c3041c3854a0fce70c9b258d0ff134c3e1453f6..f6cf091da6000a1862cf96ffd5baea79802888fb 100644 (file)
@@ -194,7 +194,7 @@ struct stroke_msg_t {
                STR_LEASES,
                /* more to come */
        } type;
-       
+
        /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
        int output_verbosity;
 
@@ -203,7 +203,7 @@ struct stroke_msg_t {
                struct {
                        char *name;
                } initiate, route, unroute, terminate, status, del_conn, del_ca;
-               
+
                /* data for STR_TERMINATE_SRCIP */
                struct {
                        char *start;
@@ -272,7 +272,7 @@ struct stroke_msg_t {
                        char *type;
                        int level;
                } loglevel;
-               
+
                /* data for STR_CONFIG */
                struct {
                        int cachecrl;
index 28112500e7af745479df79b0d5afa243b89cf2c9..817a676d20d8b8d272ba7a330f9a1002e6352668 100644 (file)
@@ -393,7 +393,7 @@ enum {
        END_SRCIP,
        END_HOSTACCESS,
        END_UPDOWN,
-               
+
 #define END_LAST  END_UPDOWN    /* last end description*/
 
 /* Connection Description options -- segregated */
@@ -431,7 +431,7 @@ enum {
        CD_DPDTIMEOUT,
        CD_IKE,
        CD_PFSGROUP,
-       CD_ESP,     
+       CD_ESP,
 
 #   define CD_LAST CD_ESP       /* last connection description */
 
@@ -861,7 +861,7 @@ int main(int argc, char **argv)
 
        msg.addr_family = AF_INET;
        msg.tunnel_addr_family = AF_INET;
-       
+
        msg.cacert = NULL;
        msg.ldaphost = NULL;
        msg.ldapbase = NULL;
@@ -1017,7 +1017,7 @@ int main(int argc, char **argv)
                        if (!options->from(options, optarg, &argc, &argv, optind))
                        {
                                fprintf(stderr, "optionsfrom failed");
-                               whack_exit(RC_WHACK_PROBLEM);                           
+                               whack_exit(RC_WHACK_PROBLEM);
                        }
                        continue;
 
@@ -1134,7 +1134,7 @@ int main(int argc, char **argv)
                case OPT_STATUS:        /* --status */
                        msg.whack_status = TRUE;
                        continue;
-               
+
                case OPT_SHUTDOWN:      /* --shutdown */
                        msg.whack_shutdown = TRUE;
                        continue;
@@ -1180,7 +1180,7 @@ int main(int argc, char **argv)
                                        base = 256;
                                else
                                        diagq("not a valid base", optarg);
-                               
+
                                if (c == SC_INBASE)
                                        msg.inbase = base;
                                else
@@ -1472,7 +1472,7 @@ int main(int argc, char **argv)
                case CD_IKE:    /* --ike <ike_alg1,ike_alg2,...> */
                        msg.ike = optarg;
                        continue;
-                       
+
                case CD_PFSGROUP:       /* --pfsgroup modpXXXX */
                        msg.pfsgroup = optarg;
                        continue;
@@ -1726,10 +1726,10 @@ int main(int argc, char **argv)
        {
                if (msg.dpd_delay <= 0)
                        diag("dpddelay must be larger than zero");
-               
+
                if (msg.dpd_timeout <= 0)
                        diag("dpdtimeout must be larger than zero");
-               
+
                if (msg.dpd_timeout <= msg.dpd_delay)
                        diag("dpdtimeout must be larger than dpddelay");
        }
@@ -1740,7 +1740,7 @@ int main(int argc, char **argv)
 
        /* build esp message as esp="<esp>;<pfsgroup>" */
        if (msg.pfsgroup) {
-                       snprintf(esp_buf, sizeof (esp_buf), "%s;%s", 
+                       snprintf(esp_buf, sizeof (esp_buf), "%s;%s",
                                        msg.esp ? msg.esp : "",
                                        msg.pfsgroup ? msg.pfsgroup : "");
                        msg.esp=esp_buf;
index 79d115262955ea16d60370fa52c0d85a2fa2483f..865e8e59092eebb3476d3a562691fcecb484393c 100644 (file)
@@ -280,7 +280,7 @@ enum rc_type {
 
        /* entry of secrets */
        RC_ENTERSECRET = 40,
-       
+
        /* progress: start of range for successful state transition.
         * Actual value is RC_NEW_STATE plus the new state code.
         */