------------------------------------------------------------ revno: 5171 committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx> branch nick: mobility-fixes timestamp: Fri 2010-11-19 18:07:10 +0100 message: moved parameter building functions for mobility to update module added: modules/update/hipd/update_builder.c modules/update/hipd/update_builder.h modified: hipd/esp_prot_hipd_msg.c hipd/esp_prot_light_update.c lib/core/builder.c lib/core/builder.h modules/update/Makefile.am modules/update/hipd/update.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 'hipd/esp_prot_hipd_msg.c' --- hipd/esp_prot_hipd_msg.c 2010-10-15 15:29:14 +0000 +++ hipd/esp_prot_hipd_msg.c 2010-11-19 17:07:10 +0000 @@ -45,6 +45,7 @@ #include "lib/core/ife.h" #include "lib/core/protodefs.h" #include "lib/tool/xfrmapi.h" +#include "modules/update/hipd/update_builder.h" #include "cookie.h" #include "esp_prot_anchordb.h" #include "esp_prot_light_update.h" === modified file 'hipd/esp_prot_light_update.c' --- hipd/esp_prot_light_update.c 2010-10-15 15:29:14 +0000 +++ hipd/esp_prot_light_update.c 2010-11-19 17:07:10 +0000 @@ -43,6 +43,7 @@ #include "lib/core/ife.h" #include "lib/core/protodefs.h" #include "lib/tool/xfrmapi.h" +#include "modules/update/hipd/update_builder.h" #include "esp_prot_anchordb.h" #include "esp_prot_hipd_msg.h" #include "hipd.h" === modified file 'lib/core/builder.c' --- lib/core/builder.c 2010-11-15 12:40:48 +0000 +++ lib/core/builder.c 2010-11-19 17:07:10 +0000 @@ -393,7 +393,7 @@ * @param tlv_generic pointer to the parameter * @param type type of the parameter (in host byte order) */ -static void hip_set_param_type(struct hip_tlv_common *tlv_generic, hip_tlv_type_t type) +void hip_set_param_type(struct hip_tlv_common *tlv_generic, hip_tlv_type_t type) { tlv_generic->type = htons(type); } @@ -1089,7 +1089,7 @@ * @param contents_size size of the contents after type and length fields * (in host byte order) */ -static void hip_calc_param_len(struct hip_tlv_common *tlv_common, +void hip_calc_param_len(struct hip_tlv_common *tlv_common, hip_tlv_len_t contents_size) { hip_calc_generic_param_len(tlv_common, @@ -2862,50 +2862,6 @@ return err; } - - -/** - * build and append a HIP SEQ parameter to a message - * - * @param msg the message where the parameter will be appended - * @param update_id Update ID - * @return 0 on success, otherwise < 0. - */ -int hip_build_param_seq(struct hip_common *msg, uint32_t update_id) -{ - int err = 0; - struct hip_seq seq; - - hip_set_param_type((struct hip_tlv_common *) &seq, HIP_PARAM_SEQ); - hip_calc_generic_param_len((struct hip_tlv_common *) &seq, - sizeof(struct hip_seq), - 0); - seq.update_id = htonl(update_id); - err = hip_build_param(msg, &seq); - return err; -} - -/** - * build and append a HIP ACK parameter to a message - * - * @param msg the message where the parameter will be appended - * @param peer_update_id peer Update ID - * @return 0 on success, otherwise < 0. - */ -int hip_build_param_ack(struct hip_common *msg, uint32_t peer_update_id) -{ - int err = 0; - struct hip_ack ack; - - hip_set_param_type((struct hip_tlv_common *) &ack, HIP_PARAM_ACK); - hip_calc_generic_param_len((struct hip_tlv_common *) &ack, - sizeof(struct hip_ack), - 0); - ack.peer_update_id = htonl(peer_update_id); - err = hip_build_param(msg, &ack); - return err; -} - /** * build and append a ESP PROT transform parameter * === modified file 'lib/core/builder.h' --- lib/core/builder.h 2010-10-15 15:29:14 +0000 +++ lib/core/builder.h 2010-11-19 17:07:10 +0000 @@ -68,7 +68,6 @@ const struct in6_addr *, const struct in6_addr *); int hip_host_id_hits(hip_ha_t *entry, struct hip_common *msg); -int hip_build_param_ack(struct hip_common *, uint32_t); int hip_build_param_contents(struct hip_common *, const void *, hip_tlv_type_t, @@ -139,7 +138,6 @@ int hip_build_param_r1_counter(struct hip_common *, uint64_t); -int hip_build_param_seq(struct hip_common *, uint32_t); int hip_build_param_signature2_contents(struct hip_common *, const void *, hip_tlv_len_t, @@ -216,6 +214,9 @@ hip_tlv_len_t hip_get_param_total_len(const void *); 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_param_len(struct hip_tlv_common *tlv_common, + hip_tlv_len_t contents_size); uint16_t hip_get_msg_checksum(struct hip_common *msg); const char *hip_message_type_name(const uint8_t); struct hip_common *hip_msg_alloc(void); === modified file 'modules/update/Makefile.am' --- modules/update/Makefile.am 2010-03-30 08:44:33 +0000 +++ modules/update/Makefile.am 2010-11-19 17:07:10 +0000 @@ -1,6 +1,7 @@ lib_LTLIBRARIES += modules/update/hipd/libhipupdate.la modules_update_hipd_libhipupdate_la_SOURCES = modules/update/hipd/update.c \ - modules/update/hipd/update_legacy.c + modules/update/hipd/update_legacy.c \ + modules/update/hipd/update_builder.c hipd_hipd_LDADD += modules/update/hipd/libhipupdate.la === modified file 'modules/update/hipd/update.c' --- modules/update/hipd/update.c 2010-11-19 14:34:06 +0000 +++ modules/update/hipd/update.c 2010-11-19 17:07:10 +0000 @@ -49,7 +49,6 @@ #include "hipd/pisa.h" #include "hipd/pkt_handling.h" #include "hipd/user.h" -#include "lib/core/builder.h" #include "lib/core/common.h" #include "lib/core/crypto.h" #include "lib/core/debug.h" @@ -62,6 +61,7 @@ #include "lib/core/protodefs.h" #include "lib/core/solve.h" #include "lib/core/modularization.h" +#include "update_builder.h" #include "update_legacy.h" #include "update.h" === added file 'modules/update/hipd/update_builder.c' --- modules/update/hipd/update_builder.c 1970-01-01 00:00:00 +0000 +++ modules/update/hipd/update_builder.c 2010-11-19 17:07:10 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2010 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 + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * @file + * + * This file facilitates buiding of mobility and multi-homing-specific + * parameters. + * + * @author Rene Hummen + */ + +#include "lib/core/builder.h" +#include "update_builder.h" + + +/** + * build and append a HIP SEQ parameter to a message + * + * @param msg the message where the parameter will be appended + * @param update_id Update ID + * @return 0 on success, otherwise < 0. + */ +int hip_build_param_seq(struct hip_common *msg, uint32_t update_id) +{ + int err = 0; + struct hip_seq seq; + + hip_set_param_type((struct hip_tlv_common *) &seq, HIP_PARAM_SEQ); + hip_calc_param_len((struct hip_tlv_common *) &seq, + sizeof(struct hip_seq)); + seq.update_id = htonl(update_id); + err = hip_build_param(msg, &seq); + return err; +} + +/** + * build and append a HIP ACK parameter to a message + * + * @param msg the message where the parameter will be appended + * @param peer_update_id peer Update ID + * @return 0 on success, otherwise < 0. + */ +int hip_build_param_ack(struct hip_common *msg, uint32_t peer_update_id) +{ + int err = 0; + struct hip_ack ack; + + hip_set_param_type((struct hip_tlv_common *) &ack, HIP_PARAM_ACK); + hip_calc_param_len((struct hip_tlv_common *) &ack, + sizeof(struct hip_ack)); + ack.peer_update_id = htonl(peer_update_id); + err = hip_build_param(msg, &ack); + return err; +} === added file 'modules/update/hipd/update_builder.h' --- modules/update/hipd/update_builder.h 1970-01-01 00:00:00 +0000 +++ modules/update/hipd/update_builder.h 2010-11-19 17:07:10 +0000 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2010 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 + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * @file + * + * This file facilitates buiding of mobility and multi-homing-specific + * parameters. + * + * @author Rene Hummen + */ + +#include "lib/core/protodefs.h" + + +#ifndef MODULES_UPDATE_UPDATE_BUILDER_H_ +#define MODULES_UPDATE_UPDATE_BUILDER_H_ + +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); + +#endif /* UPDATE_BUILDER_H_ */