------------------------------------------------------------ revno: 5174 committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx> branch nick: mobility-fixes timestamp: Fri 2010-11-19 18:23:54 +0100 message: moved locator construction to update module modified: lib/core/builder.c lib/core/builder.h modules/update/hipd/update_builder.c modules/update/hipd/update_builder.h modules/update/hipd/update_legacy.c -- lp:~hipl-core/hipl/mobility-fixes https://code.launchpad.net/~hipl-core/hipl/mobility-fixes Your team HIPL core team is subscribed to branch lp:~hipl-core/hipl/mobility-fixes. To unsubscribe from this branch go to https://code.launchpad.net/~hipl-core/hipl/mobility-fixes/+edit-subscription
=== modified file 'lib/core/builder.c' --- lib/core/builder.c 2010-11-19 17:10:37 +0000 +++ lib/core/builder.c 2010-11-19 17:23:54 +0000 @@ -1058,7 +1058,7 @@ * @param contents_size size of the contents after the TLV header * (in host byte order) */ -static void hip_calc_generic_param_len(struct hip_tlv_common *tlv_common, +void hip_calc_generic_param_len(struct hip_tlv_common *tlv_common, hip_tlv_len_t tlv_size, hip_tlv_len_t contents_size) { @@ -2818,40 +2818,6 @@ } /** - * build a HIP locator parameter - * - * @param msg the message where the REA will be appended - * @param addrs list of addresses - * @param addr_count number of addresses - * @return 0 on success, otherwise < 0. - */ -int hip_build_param_locator(struct hip_common *msg, - struct hip_locator_info_addr_item *addrs, - int addr_count) -{ - int err = 0; - struct hip_locator *locator_info = NULL; - int addrs_len = addr_count * (sizeof(struct hip_locator_info_addr_item)); - - HIP_IFE(!(locator_info = malloc(sizeof(struct hip_locator) + addrs_len)), -1); - - hip_set_param_type((struct hip_tlv_common *) locator_info, HIP_PARAM_LOCATOR); - - hip_calc_generic_param_len((struct hip_tlv_common *) locator_info, - sizeof(struct hip_locator), - addrs_len); - - memcpy(locator_info + 1, addrs, addrs_len); - HIP_IFE(hip_build_param(msg, locator_info), -1); - -out_err: - if (locator_info) { - free(locator_info); - } - return err; -} - -/** * build and append a ESP PROT transform parameter * * @param msg the message where the parameter will be appended === modified file 'lib/core/builder.h' --- lib/core/builder.h 2010-11-19 17:10:37 +0000 +++ lib/core/builder.h 2010-11-19 17:23:54 +0000 @@ -114,9 +114,6 @@ uint32_t, uint16_t, struct hip_crypto_key *); -int hip_build_param_locator(struct hip_common *, - struct hip_locator_info_addr_item *, - int); int hip_build_param_cert(struct hip_common *, uint8_t, uint8_t, @@ -213,6 +210,9 @@ hip_transform_suite_t hip_get_param_transform_suite_id(const void *); hip_tlv_type_t hip_get_param_type(const void *); void hip_set_param_type(struct hip_tlv_common *tlv_generic, hip_tlv_type_t type); +void hip_calc_generic_param_len(struct hip_tlv_common *tlv_common, + hip_tlv_len_t tlv_size, + hip_tlv_len_t contents_size); void hip_calc_param_len(struct hip_tlv_common *tlv_common, hip_tlv_len_t contents_size); uint16_t hip_get_msg_checksum(struct hip_common *msg); === modified file 'modules/update/hipd/update_builder.c' --- modules/update/hipd/update_builder.c 2010-11-19 17:07:10 +0000 +++ modules/update/hipd/update_builder.c 2010-11-19 17:23:54 +0000 @@ -32,7 +32,10 @@ * @author Rene Hummen */ +#include <string.h> + #include "lib/core/builder.h" +#include "lib/core/ife.h" #include "update_builder.h" @@ -75,3 +78,37 @@ err = hip_build_param(msg, &ack); return err; } + +/** + * build a HIP locator parameter + * + * @param msg the message where the REA will be appended + * @param addrs list of addresses + * @param addr_count number of addresses + * @return 0 on success, otherwise < 0. + */ +int hip_build_param_locator(struct hip_common *msg, + struct hip_locator_info_addr_item *addrs, + int addr_count) +{ + int err = 0; + struct hip_locator *locator_info = NULL; + int addrs_len = addr_count * (sizeof(struct hip_locator_info_addr_item)); + + HIP_IFE(!(locator_info = malloc(sizeof(struct hip_locator) + addrs_len)), -1); + + hip_set_param_type((struct hip_tlv_common *) locator_info, HIP_PARAM_LOCATOR); + + hip_calc_generic_param_len((struct hip_tlv_common *) locator_info, + sizeof(struct hip_locator), + addrs_len); + + memcpy(locator_info + 1, addrs, addrs_len); + HIP_IFE(hip_build_param(msg, locator_info), -1); + +out_err: + if (locator_info) { + free(locator_info); + } + return err; +} === modified file 'modules/update/hipd/update_builder.h' --- modules/update/hipd/update_builder.h 2010-11-19 17:07:10 +0000 +++ modules/update/hipd/update_builder.h 2010-11-19 17:23:54 +0000 @@ -40,5 +40,8 @@ int hip_build_param_seq(struct hip_common *msg, uint32_t update_id); int hip_build_param_ack(struct hip_common *msg, uint32_t peer_update_id); +int hip_build_param_locator(struct hip_common *msg, + struct hip_locator_info_addr_item *addrs, + int addr_count); #endif /* UPDATE_BUILDER_H_ */ === modified file 'modules/update/hipd/update_legacy.c' --- modules/update/hipd/update_legacy.c 2010-09-25 18:30:26 +0000 +++ modules/update/hipd/update_legacy.c 2010-11-19 17:23:54 +0000 @@ -43,6 +43,7 @@ #include "lib/core/list.h" #include "lib/core/prefix.h" #include "lib/core/protodefs.h" +#include "update_builder.h" #include "update.h" #include "update_legacy.h"