------------------------------------------------------------ revno: 6090 committer: David Martin <david.martin.mailbox@xxxxxxxxxxxxxx> branch nick: hipl_state-removal timestamp: Mon 2011-10-17 17:22:35 +0200 message: Move hip_state #defines into enum, use enum instead of int in functions. Basically lots and lots of function parameters that needed rewriting. Noteworthy change in hip_state_str() which does not use that weird array construction anymore but a proper switch case and lib/core/state.h where the defines have been moved into the enum. modified: firewall/cache.c firewall/cache.h hipd/close.c hipd/close.h hipd/esp_prot_hipd_msg.c hipd/esp_prot_hipd_msg.h hipd/esp_prot_light_update.c hipd/esp_prot_light_update.h hipd/hiprelay.c hipd/hiprelay.h hipd/input.c hipd/input.h hipd/output.c hipd/output.h hipd/pkt_handling.c hipd/pkt_handling.h lib/core/debug.h lib/core/state.h modules/midauth/hipd/midauth.c modules/update/hipd/update.c modules/update/hipd/update_param_handling.c modules/update/hipd/update_param_handling.h -- lp:hipl https://code.launchpad.net/~hipl-core/hipl/trunk Your team HIPL core team is subscribed to branch lp:hipl. To unsubscribe from this branch go to https://code.launchpad.net/~hipl-core/hipl/trunk/+edit-subscription
=== modified file 'firewall/cache.c' --- firewall/cache.c 2011-08-15 14:11:56 +0000 +++ firewall/cache.c 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -300,7 +300,7 @@ */ int hip_firewall_cache_set_bex_state(const struct in6_addr *hit_our, const struct in6_addr *hit_peer, - int state) + enum hip_state state) { int err = 0; struct hip_hadb_user_info_state *entry; === modified file 'firewall/cache.h' --- firewall/cache.h 2011-01-17 21:31:06 +0000 +++ firewall/cache.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -44,6 +44,6 @@ int hip_firewall_cache_set_bex_state(const struct in6_addr *hit_s, const struct in6_addr *hit_r, - int state); + enum hip_state state); #endif /* HIP_FIREWALL_CACHE_H */ === modified file 'hipd/close.c' --- hipd/close.c 2011-08-15 14:11:56 +0000 +++ hipd/close.c 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -230,7 +230,7 @@ * @return zero on success, non-negative on error. */ int hip_close_check_packet(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -283,7 +283,7 @@ * @return zero on success, non-negative on error. */ int hip_close_create_response(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0, echo_len; @@ -337,7 +337,7 @@ * @return zero on success, non-negative on error. */ int hip_close_send_response(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -397,7 +397,7 @@ * @return zero on success, non-negative on error. */ int hip_close_ack_check_packet(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -465,7 +465,7 @@ * @return zero on success, non-negative on error. */ int hip_close_ack_handle_packet(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; === modified file 'hipd/close.h' --- hipd/close.h 2011-01-03 19:36:44 +0000 +++ hipd/close.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -30,19 +30,19 @@ int hip_send_close(struct hip_common *msg, int delete_ha_info); int hip_close_check_packet(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_close_create_response(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_close_send_response(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_close_ack_check_packet(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_close_ack_handle_packet(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_purge_closing_ha(struct hip_hadb_state *ha, void *opaque); === modified file 'hipd/esp_prot_hipd_msg.c' --- hipd/esp_prot_hipd_msg.c 2011-08-15 14:11:56 +0000 +++ hipd/esp_prot_hipd_msg.c 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -581,7 +581,7 @@ * @return Always 0. */ int esp_prot_r1_handle_transforms(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct esp_prot_preferred_tfms *prot_transforms = NULL; === modified file 'hipd/esp_prot_hipd_msg.h' --- hipd/esp_prot_hipd_msg.h 2011-08-15 14:11:56 +0000 +++ hipd/esp_prot_hipd_msg.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -51,7 +51,7 @@ const int direction, const int update); int esp_prot_r1_add_transforms(struct hip_common *msg); int esp_prot_r1_handle_transforms(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx); int esp_prot_i2_add_anchor(struct hip_packet_context *ctx); int esp_prot_i2_handle_anchor(struct hip_packet_context *ctx); === modified file 'hipd/esp_prot_light_update.c' --- hipd/esp_prot_light_update.c 2011-08-15 14:11:56 +0000 +++ hipd/esp_prot_light_update.c 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -213,7 +213,7 @@ * @return 0 in case of succcess, -1 otherwise */ int esp_prot_handle_light_update(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_seq *seq = NULL; === modified file 'hipd/esp_prot_light_update.h' --- hipd/esp_prot_light_update.h 2011-08-15 14:11:56 +0000 +++ hipd/esp_prot_light_update.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -44,7 +44,7 @@ const unsigned char *branch_nodes[MAX_NUM_PARALLEL_HCHAINS], const int branch_length[]); int esp_prot_handle_light_update(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); #endif /* HIP_HIPD_ESP_PROT_LIGHT_UPDATE_H */ === modified file 'hipd/hiprelay.c' --- hipd/hiprelay.c 2011-08-15 14:11:56 +0000 +++ hipd/hiprelay.c 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -88,7 +88,7 @@ * @note Related draft: * <a href="http://www.ietf.org/internet-drafts/draft-ietf-hip-nat-traversal-03.txt";> * draft-ietf-hip-nat-traversal-03</a> - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -1080,7 +1080,7 @@ * @return zero on success or negative on error */ int hip_relay_handle_relay_to(const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -1288,7 +1288,7 @@ * @return zero on success or negative on error */ int hip_relay_handle_relay_to_in_client(const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; === modified file 'hipd/hiprelay.h' --- hipd/hiprelay.h 2011-08-15 14:11:56 +0000 +++ hipd/hiprelay.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -122,11 +122,11 @@ struct in6_addr *dest_ip, in_port_t *dest_port); int hip_relay_handle_relay_to_in_client(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_relay_handle_relay_to(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_relay_forward(const struct hip_packet_context *ctx, === modified file 'hipd/input.c' --- hipd/input.c 2011-10-12 09:26:52 +0000 +++ hipd/input.c 2011-10-17 15:22:35 +0000 @@ -475,6 +475,8 @@ if (type == HIP_R1 || type == HIP_R2) { return 1; } + default: + return 0; } return 0; @@ -657,7 +659,7 @@ * @return zero on success, or negative error value on error. */ int hip_check_r1(RVS const uint8_t packet_type, - RVS const uint32_t ha_state, + RVS const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0, mask = HIP_PACKET_CTRL_ANON, len; @@ -783,7 +785,7 @@ * double jump problem. */ int hip_handle_r1(UNUSED const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx) { int retransmission = 0; @@ -867,7 +869,7 @@ } int hip_build_esp_info(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { /* SPI is set in another handler */ @@ -880,7 +882,7 @@ } int hip_build_solution(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_puzzle *pz = NULL; @@ -899,7 +901,7 @@ } int hip_handle_diffie_hellman(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_diffie_hellman *dh_req; @@ -956,7 +958,7 @@ * */ int hip_handle_i2_in_i2_sent(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { if (hip_hit_is_bigger(&ctx->hadb_entry->hit_peer, @@ -979,7 +981,7 @@ * @return zero on success, or negative error value on error. */ int hip_check_r2(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -1054,7 +1056,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_r2(RVS const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_locator *locator = NULL; @@ -1138,7 +1140,7 @@ } int hip_setup_ipsec_sa(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { /* If we have old SAs with these HITs delete them */ @@ -1167,7 +1169,7 @@ * @return zero on success, or negative error value on error. */ int hip_check_i1(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int mask = 0; @@ -1247,7 +1249,7 @@ * is parsed. */ int hip_handle_i1(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { /* In some environments, a copy of broadcast our own I1 packets @@ -1304,7 +1306,7 @@ * @return zero on success, or negative error value on error. */ int hip_check_i2(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0, is_loopback = 0; @@ -1613,7 +1615,7 @@ * RFC 5201</a>. */ int hip_handle_i2(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0, if_index = 0; @@ -1727,7 +1729,7 @@ * @return zero on success, or negative error value on error. */ int hip_check_notify(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -1771,7 +1773,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_notify(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; === modified file 'hipd/input.h' --- hipd/input.h 2011-08-15 14:11:56 +0000 +++ hipd/input.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -67,64 +67,64 @@ int hip_receive_udp_control_packet(struct hip_packet_context *ctx); int hip_check_i1(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_check_i2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_i1(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_i2_in_i2_sent(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_i2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_check_notify(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_notify(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_check_r1(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_r1(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_check_r2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_r2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_setup_ipsec_sa(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_build_esp_info(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_build_solution(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_diffie_hellman(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx); #endif /* HIP_HIPD_INPUT_H */ === modified file 'hipd/output.c' --- hipd/output.c 2011-10-13 08:56:50 +0000 +++ hipd/output.c 2011-10-17 15:22:35 +0000 @@ -277,7 +277,7 @@ * @return zero on success, negative value on error */ int hip_add_unsigned_echo_response(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { return hip_add_echo_response(ctx, 0); @@ -296,7 +296,7 @@ * @return zero on success, negative value on error. */ int hip_add_signed_echo_response(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { return hip_add_echo_response(ctx, 1); @@ -337,7 +337,7 @@ * @return zero on success, negative value on error. */ int hip_mac_and_sign_handler(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { if (hip_mac_and_sign_packet(ctx->output_msg, ctx->hadb_entry)) { @@ -360,7 +360,7 @@ * @return zero on success, non-negative on error. */ int hip_create_i2(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { hip_transform_suite transform_hip_suite, transform_esp_suite; @@ -553,7 +553,7 @@ * @return zero on success, non-negative on error. */ int hip_send_i2(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { struct in6_addr daddr; @@ -780,7 +780,7 @@ * @return zero on success, or negative error value on error. */ int hip_send_r1(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -916,7 +916,7 @@ * @return zero */ int hip_add_rvs_reg_from(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, RVS struct hip_packet_context *ctx) { #ifdef CONFIG_HIP_RVS @@ -944,7 +944,7 @@ * @return zero on success, negative otherwise. */ int hip_hmac2_and_sign(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { /* Create HMAC2 parameter. */ @@ -978,7 +978,7 @@ * @return zero */ int hip_add_rvs_relay_to(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, RVS struct hip_packet_context *ctx) { #ifdef CONFIG_HIP_RVS @@ -1009,7 +1009,7 @@ * @return zero on success, negative otherwise. */ int hip_create_r2(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -1070,7 +1070,7 @@ * @return zero on success, negative otherwise. */ int hip_send_r2(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; === modified file 'hipd/output.h' --- hipd/output.h 2011-08-15 14:11:56 +0000 +++ hipd/output.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -44,52 +44,52 @@ const int cookie_k); int hip_send_r1(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_add_rvs_reg_from(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_hmac2_and_sign(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_add_rvs_relay_to(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_create_r2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_send_r2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_send_i1(hip_hit_t *, const hip_hit_t *, struct hip_hadb_state *); int hip_add_signed_echo_response(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_mac_and_sign_packet(struct hip_common *msg, const struct hip_hadb_state *const hadb_entry); int hip_mac_and_sign_handler(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_add_unsigned_echo_response(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_create_i2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_send_i2(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int are_addresses_compatible(const struct in6_addr *src_addr, === modified file 'hipd/pkt_handling.c' --- hipd/pkt_handling.c 2011-08-15 14:11:56 +0000 +++ hipd/pkt_handling.c 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -41,7 +41,7 @@ struct handle_function { uint16_t priority; int (*func_ptr)(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); }; @@ -65,9 +65,9 @@ * Error = -1 */ int hip_register_handle_function(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, int (*handle_function)(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx), const uint16_t priority) { @@ -111,9 +111,9 @@ * Error = -1 */ int hip_unregister_handle_function(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, int (*handle_function)(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx)) { return lmod_unregister_function(hip_handle_functions[packet_type][ha_state], @@ -134,7 +134,7 @@ * Error = -1 */ int hip_run_handle_functions(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; === modified file 'hipd/pkt_handling.h' --- hipd/pkt_handling.h 2011-08-15 14:11:56 +0000 +++ hipd/pkt_handling.h 2011-10-17 15:22:35 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. + * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -29,22 +29,23 @@ #include <stdint.h> #include "lib/core/protodefs.h" +#include "lib/core/state.h" int hip_register_handle_function(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, int (*handle_function)(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx), const uint16_t priority); int hip_unregister_handle_function(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, int (*handle_function)(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx)); int hip_run_handle_functions(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); void hip_uninit_handle_functions(void); === modified file 'lib/core/debug.h' --- lib/core/debug.h 2011-05-31 18:21:28 +0000 +++ lib/core/debug.h 2011-10-17 15:22:35 +0000 @@ -32,6 +32,7 @@ #include "config.h" #include "common.h" #include "protodefs.h" +#include "state.h" /** * Error handling macros used for checking errors. To use these macros, define a @@ -407,29 +408,31 @@ * @param state a state state value * @return a state name as a string. */ -static inline const char *hip_state_str(unsigned int state) +static inline const char *hip_state_str(enum hip_state state) { - const char *str = "UNKNOWN"; - static const char *states[] = { - "NONE", // 0 - "UNASSOCIATED", // 1 - "I1-SENT", // 2 - "I2-SENT", // 3 - "R2-SENT", // 4 - "ESTABLISHED", // 5 - "UNKNOWN", // 6 is not currently used. - "FAILED", // 7 - "CLOSING", // 8 - "CLOSED", // 9 - "FILTERING" // 10 - }; - if (state < ARRAY_SIZE(states)) { - str = states[state]; - } else { + switch (state) { + case HIP_STATE_NONE: + return "NONE"; + case HIP_STATE_UNASSOCIATED: + return "UNASSOCIATED"; + case HIP_STATE_I1_SENT: + return "I1-SENT"; + case HIP_STATE_I2_SENT: + return "I2-SENT"; + case HIP_STATE_R2_SENT: + return "R2-SENT"; + case HIP_STATE_ESTABLISHED: + return "ESTABLISHED"; + case HIP_STATE_FAILED: + return "FAILED"; + case HIP_STATE_CLOSING: + return "CLOSING"; + case HIP_STATE_CLOSED: + return "CLOSED"; + default: HIP_ERROR("invalid state %u\n", state); + return "UNKNOWN"; } - - return str; } #endif /* HIP_LIB_CORE_DEBUG_H */ === modified file 'lib/core/state.h' --- lib/core/state.h 2011-10-17 14:23:19 +0000 +++ lib/core/state.h 2011-10-17 15:22:35 +0000 @@ -50,26 +50,26 @@ /** - * @defgroup hip_ha_state HIP association states + * HIP association states * * HIP states as specifed in section 4.4.1.\ of draft-ietf-hip-base-10. * * The states are: UNASSOCIATED, I1-SENT, I2-SENT, R2-SENT ESTABLISHED, CLOSING, * CLOSED, E-FAILED. - * @{ */ /* When adding new states update debug.h hip_state_str(). Doxygen comments to * these states are available at doc/doxygen.h */ -#define HIP_STATE_NONE 0 /**< no state, structure unused */ -#define HIP_STATE_UNASSOCIATED 1 /**< state machine start */ -#define HIP_STATE_I1_SENT 2 /**< initiating base exchange */ -#define HIP_STATE_I2_SENT 3 /**< waiting to complete base exchange */ -#define HIP_STATE_R2_SENT 4 /**< waiting to complete base exchange */ -#define HIP_STATE_ESTABLISHED 5 /**< HIP association established */ -#define HIP_STATE_FAILED 7 /**< HIP exchange failed */ -#define HIP_STATE_CLOSING 8 /**< HIP association closing, no data can be sent */ -#define HIP_STATE_CLOSED 9 /**< HIP association closed, no data can be sent */ -/* @} */ +enum hip_state { + HIP_STATE_NONE, /**< no state, structure unused */ + HIP_STATE_UNASSOCIATED, /**< state machine start */ + HIP_STATE_I1_SENT, /**< initiating base exchange */ + HIP_STATE_I2_SENT, /**< waiting to complete base exchange */ + HIP_STATE_R2_SENT, /**< waiting to complete base exchange */ + HIP_STATE_ESTABLISHED, /**< HIP association established */ + HIP_STATE_FAILED, /**< HIP exchange failed */ + HIP_STATE_CLOSING, /**< HIP association closing, no data can be sent */ + HIP_STATE_CLOSED /**< HIP association closed, no data can be sent */ +}; /** * @todo add description @@ -151,14 +151,14 @@ enum hip_ha_state ha_state; /** Counter to tear down a HA in CLOSING or CLOSED state */ int purge_timeout; - /** The state of this host association. @see hip_ha_state */ - int state; + /** The state of this host association. */ + enum hip_state state; /** This guarantees that retransmissions work properly also in * non-established state.*/ - int retrans_state; + enum hip_state retrans_state; /** A kludge to get the UPDATE retransmission to work. * @todo Remove this kludge. */ - int update_state; + enum hip_state update_state; /** Our control values related to this host association. * @see hip_ha_controls */ hip_controls local_controls; === modified file 'modules/midauth/hipd/midauth.c' --- modules/midauth/hipd/midauth.c 2011-08-15 14:11:56 +0000 +++ modules/midauth/hipd/midauth.c 2011-10-17 15:22:35 +0000 @@ -41,6 +41,7 @@ #include "lib/core/modularization.h" #include "lib/core/protodefs.h" #include "lib/core/solve.h" +#include "lib/core/state.h" #include "modules/midauth/lib/midauth_builder.h" #include "modules/update/hipd/update.h" #include "midauth.h" @@ -60,7 +61,7 @@ * parameter was attached to the packet, negative value otherwise. */ static int handle_challenge_request_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_challenge_request *request = NULL; @@ -115,7 +116,7 @@ * @return zero on success, negative value otherwise */ static int add_host_id_param_update(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_challenge_request *const challenge_request = @@ -161,10 +162,10 @@ return -1; } - const int challenge_request_R1_states[] = { HIP_STATE_I1_SENT, - HIP_STATE_I2_SENT, - HIP_STATE_CLOSING, - HIP_STATE_CLOSED }; + const enum hip_state challenge_request_R1_states[] = { HIP_STATE_I1_SENT, + HIP_STATE_I2_SENT, + HIP_STATE_CLOSING, + HIP_STATE_CLOSED }; for (unsigned i = 0; i < ARRAY_SIZE(challenge_request_R1_states); i++) { if (hip_register_handle_function(HIP_R1, challenge_request_R1_states[i], @@ -180,14 +181,14 @@ // R2 packet is first allocated at 40000, so we use a higher // base priority here. // - const int challenge_request_I2_states[] = { HIP_STATE_UNASSOCIATED, - HIP_STATE_I1_SENT, - HIP_STATE_I2_SENT, - HIP_STATE_R2_SENT, - HIP_STATE_ESTABLISHED, - HIP_STATE_CLOSING, - HIP_STATE_CLOSED, - HIP_STATE_NONE }; + const enum hip_state challenge_request_I2_states[] = { HIP_STATE_UNASSOCIATED, + HIP_STATE_I1_SENT, + HIP_STATE_I2_SENT, + HIP_STATE_R2_SENT, + HIP_STATE_ESTABLISHED, + HIP_STATE_CLOSING, + HIP_STATE_CLOSED, + HIP_STATE_NONE }; for (unsigned i = 0; i < ARRAY_SIZE(challenge_request_I2_states); i++) { if (hip_register_handle_function(HIP_I2, challenge_request_I2_states[i], @@ -203,8 +204,8 @@ // priority 30000 already (checking is 20000) and we must add our // CHALLENGE_REQUEST verification in between, hence a lower base priority. // - const int challenge_request_UPDATE_states[] = { HIP_STATE_R2_SENT, - HIP_STATE_ESTABLISHED }; + const enum hip_state challenge_request_UPDATE_states[] = { HIP_STATE_R2_SENT, + HIP_STATE_ESTABLISHED }; for (unsigned i = 0; i < ARRAY_SIZE(challenge_request_UPDATE_states); i++) { if (hip_register_handle_function(HIP_UPDATE, challenge_request_UPDATE_states[i], === modified file 'modules/update/hipd/update.c' --- modules/update/hipd/update.c 2011-10-17 14:23:19 +0000 +++ modules/update/hipd/update.c 2011-10-17 15:22:35 +0000 @@ -74,7 +74,7 @@ * @return always returns zero */ static int hip_prepare_update_response(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { hip_msg_init(ctx->output_msg); @@ -202,7 +202,7 @@ * @return zero on success or negative on failure */ static int hip_check_update_freshness(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { struct update_state *localstate = NULL; @@ -283,7 +283,7 @@ * @return zero on success, non-negative on error. */ static int hip_check_update_packet(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -322,7 +322,7 @@ * @return zero on success, or negative error value on error. */ static int hip_send_update_packet(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -421,7 +421,7 @@ * @return zero on success, or negative error value on error. */ static int hip_set_active_addresses(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const enum update_types update_type = hip_classify_update_type(ctx->input_msg); @@ -455,7 +455,7 @@ * @return zero on success, or negative error value on error. */ static int hip_create_ipsec_sa(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { enum update_types update_type = UNKNOWN_UPDATE_PACKET; @@ -489,7 +489,7 @@ * @return zero on success, or negative error value on error. */ static int hip_delete_ipsec_sa(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const enum update_types update_type = hip_classify_update_type(ctx->input_msg); @@ -600,7 +600,7 @@ * @return zero on success, or negative error value on error. */ static int hip_update_change_state(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { /* RFC 5201 Section 4.4.2, Table 5: According to the state processes === modified file 'modules/update/hipd/update_param_handling.c' --- modules/update/hipd/update_param_handling.c 2011-08-15 14:11:56 +0000 +++ modules/update/hipd/update_param_handling.c 2011-10-17 15:22:35 +0000 @@ -99,7 +99,7 @@ * @return zero on success, or negative error value on error. */ int hip_add_esp_info_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { if (hip_classify_update_type(ctx->input_msg) == FIRST_UPDATE_PACKET) { @@ -128,7 +128,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_esp_info_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_esp_info *esp_info = NULL; @@ -162,7 +162,7 @@ * @return zero on success, or negative error value on error. */ int hip_add_seq_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { struct update_state *localstate = NULL; @@ -197,7 +197,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_seq_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_seq *seq = NULL; @@ -240,7 +240,7 @@ * @return zero on success, or negative error value on error. */ int hip_add_echo_request_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int err = 0; @@ -280,7 +280,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_echo_request_sign_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_echo_request *echo_request = NULL; @@ -322,7 +322,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_echo_request_param(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_echo_request *echo_request = NULL; @@ -364,7 +364,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_locator_parameter(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { int locator_addr_count = 0; @@ -440,7 +440,7 @@ * @return zero on success, or negative error value on error. */ int hip_handle_locator(UNUSED const uint8_t packet_type, - UNUSED const uint32_t ha_state, + UNUSED const enum hip_state ha_state, struct hip_packet_context *ctx) { const struct hip_locator *locator = NULL; === modified file 'modules/update/hipd/update_param_handling.h' --- modules/update/hipd/update_param_handling.h 2011-08-15 14:11:56 +0000 +++ modules/update/hipd/update_param_handling.h 2011-10-17 15:22:35 +0000 @@ -36,39 +36,39 @@ #include "update.h" int hip_add_esp_info_param(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_esp_info_param(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_add_seq_param(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_seq_param(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_add_echo_request_param(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_echo_request_sign_param(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_echo_request_param(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_locator_parameter(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); int hip_handle_locator(const uint8_t packet_type, - const uint32_t ha_state, + const enum hip_state ha_state, struct hip_packet_context *ctx); #endif /* HIP_MODULES_UPDATE_HIPD_UPDATE_PARAM_HANDLING_H */