Author: biurrun Date: Thu Oct 15 21:10:21 2009 New Revision: 1204 Log: Revert r1200, it was full of DOS linebreaks. Modified: trunk/community-operator/hipl.c trunk/community-operator/hipl.h Modified: trunk/community-operator/hipl.c ============================================================================== --- trunk/community-operator/hipl.c Thu Oct 15 20:58:10 2009 (r1203) +++ trunk/community-operator/hipl.c Thu Oct 15 21:10:21 2009 (r1204) @@ -1,79 +1,68 @@ -/* - * Copyright (c) 2009, Distributed Systems Group, RWTH Aachen - * All rights reserved. - */ - -#include "hipl.h" -#include "ac_config.h" -#ifdef CONFIG_PISA_WITH_HIPL -# include "certtools.h" /* in libinet6 under the hipl source tree */ -#endif /* CONFIG_PISA_WITH_HIPL */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <netinet/in.h> - -#ifndef HIPL_CERTIFICATE_CHANGES -int createCertificate(time_t *not_before, time_t *not_after, - struct in6_addr *hit, struct in6_addr *issuer_hit, - char *certificate, size_t size) -#else -int createCertificate(time_t *not_before, time_t *not_after, - struct in6_addr *hit, struct in6_addr *issuer_hit, - int parallel_users, char *certificate, size_t size) -#endif /* HIPL_CERTIFICATE_CHANGES */ -{ -#ifdef CONFIG_PISA_WITH_HIPL - struct hip_cert_spki_info cert = { 0 }; - - if (!not_before || !not_after || !hit || !certificate) { - printf("Invalid parameter in create_certificate.\n"); - return -1; - } - -#ifndef HIPL_CERTIFICATE_CHANGES - hip_cert_spki_create_cert(&cert, "hit", issuer_hit, "hit", hit, - not_before, not_after, parallel_users); -#else - hip_cert_spki_create_cert(&cert, "hit", issuer_hit, "hit", hit, - not_before, not_after); -#endif - - snprintf(certificate, size, "(sequence %s%s%s)", cert.public_key, - cert.cert, cert.signature); - -#endif /* CONFIG_PISA_WITH_HIPL */ - return 0; -} - -int getDefaultHIT(struct in6_addr *result) -{ -#ifdef CONFIG_PISA_WITH_HIPL - struct hip_common *msg = NULL; - struct hip_tlv_common *param = NULL; - struct in6_addr *hit = NULL; - - msg = hip_msg_alloc(); - if (!msg) - return -1; - - /* get the default HIT from hipd, 16 is SO_HIP_DEFAULT_HIT */ - if (hip_build_user_hdr(msg, 16, 0) != 0) { - free(msg); - return -1; - } - if (hip_send_recv_daemon_info(msg, 0, 0) != 0) { - free(msg); - return -1; - } - - /* extract the HIT parameter, HIP_PARAM_HIT is 32768 */ - param = hip_get_param(msg, 32768); - hit = (struct in6_addr *) hip_get_param_contents_direct(param); - memcpy(result, hit, sizeof(struct in6_addr)); - - free(msg); -#endif /* CONFIG_PISA_WITH_HIPL */ - return 0; -} +/* + * Copyright (c) 2009, Distributed Systems Group, RWTH Aachen + * All rights reserved. + */ + +#include "hipl.h" +#include "ac_config.h" +#ifdef CONFIG_PISA_WITH_HIPL +# include "certtools.h" /* in libinet6 under the hipl source tree */ +#endif /* CONFIG_PISA_WITH_HIPL */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <netinet/in.h> + +int createCertificate(time_t *not_before, time_t *not_after, + struct in6_addr *hit, struct in6_addr *issuer_hit, + char *certificate, size_t size) +{ +#ifdef CONFIG_PISA_WITH_HIPL + struct hip_cert_spki_info cert = { 0 }; + + if (!not_before || !not_after || !hit || !certificate) { + printf("Invalid parameter in create_certificate.\n"); + return -1; + } + + hip_cert_spki_create_cert(&cert, "hit", issuer_hit, "hit", hit, + not_before, not_after); + + snprintf(certificate, size, "(sequence %s%s%s)", cert.public_key, + cert.cert, cert.signature); + +#endif /* CONFIG_PISA_WITH_HIPL */ + return 0; +} + +int getDefaultHIT(struct in6_addr *result) +{ +#ifdef CONFIG_PISA_WITH_HIPL + struct hip_common *msg = NULL; + struct hip_tlv_common *param = NULL; + struct in6_addr *hit = NULL; + + msg = hip_msg_alloc(); + if (!msg) + return -1; + + /* get the default HIT from hipd, 16 is SO_HIP_DEFAULT_HIT */ + if (hip_build_user_hdr(msg, 16, 0) != 0) { + free(msg); + return -1; + } + if (hip_send_recv_daemon_info(msg, 0, 0) != 0) { + free(msg); + return -1; + } + + /* extract the HIT parameter, HIP_PARAM_HIT is 32768 */ + param = hip_get_param(msg, 32768); + hit = (struct in6_addr *) hip_get_param_contents_direct(param); + memcpy(result, hit, sizeof(struct in6_addr)); + + free(msg); +#endif /* CONFIG_PISA_WITH_HIPL */ + return 0; +} Modified: trunk/community-operator/hipl.h ============================================================================== --- trunk/community-operator/hipl.h Thu Oct 15 20:58:10 2009 (r1203) +++ trunk/community-operator/hipl.h Thu Oct 15 21:10:21 2009 (r1204) @@ -10,7 +10,6 @@ #include <string.h> #include <netinet/in.h> -#ifndef HIPL_CERTIFICATE_CHANGES /** * Create the certificate with the given parameters. This is a wrapper * function for hip_cert_spki_create_cert. It requires a running hipd on @@ -27,25 +26,6 @@ int createCertificate(time_t *not_before, time_t *not_after, struct in6_addr *hit, struct in6_addr *issuer_hit, char *certificate, size_t size); -#else -/** - * Create the certificate with the given parameters. This is a wrapper - * function for hip_cert_spki_create_cert. It requires a running hipd on - * the same machine and superuser privileges. - * - * @param not_before start of certificate lifetime - * @param not_after end of certificate lifetime - * @param hit HIT of subject (the home router HIT) - * @param issuer_hit HIT of issuer (the community operator HIT) - * @param certificate buffer to store the resulting certificate in - * @param size size of the certificate buffer - * @param parallel_users The number of allowed parallel users - * @return 0 on success - */ -int createCertificate(time_t *not_before, time_t *not_after, - struct in6_addr *hit, struct in6_addr *issuer_hit, - int parallel_users, char *certificate, size_t size); -#endif /* HIPL_CERTIFICATE_CHANGES */ /** * Get the default hit of the local HIPD. Requires a running hipd on the same