On 19.11.2010, at 20:29, Diego Biurrun wrote: > On Fri, Nov 19, 2010 at 05:25:46PM +0000, noreply@xxxxxxxxxxxxx wrote: >> ------------------------------------------------------------ >> 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 [...] >> --- 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 >> @@ -75,3 +78,37 @@ >> +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); > > Why not make locator_info the right type from the start instead of > casting it? struct hip_tlv_common is a data structure common to all parameters. It represents the first bits. -- Dipl.-Inform. Rene Hummen, Ph.D. Student Chair of Communication and Distributed Systems RWTH Aachen University, Germany tel: +49 241 80 20772 web: http://ds.rwth-aachen.de/members/hummen