Committer: Miika Komu <miika@xxxxxx> Date: Sat Feb 27 15:35:38 2010 +0200 Revision: 3726 Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: Doxygen for lib/core/utils.c Modified: M lib/core/utils.c === modified file 'lib/core/utils.c' --- lib/core/utils.c 2010-02-11 09:57:04 +0000 +++ lib/core/utils.c 2010-02-27 13:35:38 +0000 @@ -1,9 +1,27 @@ +/** + * @file + * + * Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a> + * + * This file contains mostly address-related utility functions to + * manipulate LSI/HIT prefixes + * + * @brief Address-related utility functions + * + * @author Miika Komu <miika@xxxxxx> + */ /* required for s6_addr32 */ #define _BSD_SOURCE #include "utils.h" +/** + * Test if the given IPv6 address has HIT prefix (RFC4843 ORCHID prefix) + * + * @param hit the address to be tested + * @return 1 if the address has the HIT prefix or zero otherwise + */ int ipv6_addr_is_hit(const struct in6_addr *hit) { hip_closest_prefix_type_t hit_begin; @@ -13,6 +31,12 @@ return hit_begin == HIP_HIT_PREFIX; } +/** + * Test if a given IPv6 address has a Teredo (RFC4380) prefix + * + * @param teredo the IPv6 address to be tested for Teredo prefix + * @return 1 if the address has the Teredo prefix or zero otherwise + */ int ipv6_addr_is_teredo(const struct in6_addr *teredo) { hip_closest_prefix_type_t teredo_begin; @@ -22,27 +46,63 @@ return teredo_begin == HIP_TEREDO_PREFIX; } +/** + * Test if an IPv6 address is all zeroes + * + * @param ip the IPv6 address to test + * @return one if the address is all zeroes and zero otherwise + */ int ipv6_addr_is_null(struct in6_addr *ip) { return (ip->s6_addr32[0] | ip->s6_addr32[1] | ip->s6_addr32[2] | ip->s6_addr32[3]) == 0; } +/** + * Test if a given IPv6 address is a real HIT instead of a + * pseudo hit + * + * @param hit the IPv6 address to be tested + * @return one if the IPv6 address was a real HIT and +' zero if it was a pseudo HIT + */ int hit_is_real_hit(const struct in6_addr *hit) { return ipv6_addr_is_hit(hit) && (hit->s6_addr32[3] != 0); } +/** + * Test if a given IPv6 address is a pseudo HIT instead of a + * real HIT + * + * @param hit the IPv6 address to be tested + * @return zero if the IPv6 address was a real HIT and +' one if it was a pseudo HIT + */ int hit_is_opportunistic_hit(const struct in6_addr *hit) { return ipv6_addr_is_hit(hit) && (hit->s6_addr32[3] == 0); } +/** + * Test if a given IPv6 address is a pseudo HIT instead of a + * real HIT + * + * @param hit the IPv6 address to be tested + * @return zero if the IPv6 address was a real HIT and +' one if it was a pseudo HIT + */ int hit_is_opportunistic_hashed_hit(const struct in6_addr *hit) { return hit_is_opportunistic_hit(hit); } +/** + * Test if an IPv6 address is all zeroes + * + * @param ip the IPv6 address to test + * @return one if the address is all zeroes and zero otherwise + */ int hit_is_opportunistic_null(const struct in6_addr *hit) { // return hit_is_opportunistic_hit(hit); @@ -50,6 +110,11 @@ hit->s6_addr32[2] | (hit->s6_addr32[3])) == 0; } +/** + * Fill in the HIT prefix for a given IPv6 address + * + * @param hit an IPv6 address for which to set the HIT prefix + */ void set_hit_prefix(struct in6_addr *hit) { hip_closest_prefix_type_t hit_begin; @@ -59,6 +124,11 @@ memcpy(hit, &hit_begin, sizeof(hip_closest_prefix_type_t)); } +/** + * Fill in the LSI prefix for a given IPv4 address + * + * @param lsi an IPv4 address for which to set the LSI prefix + */ inline void set_lsi_prefix(hip_lsi_t *lsi) { hip_closest_prefix_type_t lsi_begin;