/** * handle_locator_value - This function copies the 2nd address (ipv4) from * the locator from packet returned from lookup * * @param *packet response returned from the lookup service * @param *locator_ipv4 opaque pointer passed to point to the ipv4 address * @return status of the operation 0 on success, -1 on failure */ int handle_locator_value (unsigned char *packet, void *locator_ipv4) { struct hip_locator *locator; struct hip_locator_info_addr_item *locator_address_item = NULL; int locator_item_count = 0; struct in6_addr addr6; struct in_addr addr4; locator = hip_get_param((struct hip_common *)packet, HIP_PARAM_LOCATOR); if (locator) { locator_item_count = hip_get_locator_addr_item_count(locator); locator_item_count--; locator_address_item = hip_get_locator_first_addr_item(locator); memcpy(&addr6, (struct in6_addr*)&locator_address_item[locator_item_count].address, sizeof(struct in6_addr)); if (IN6_IS_ADDR_V4MAPPED(&addr6)) { IPV6_TO_IPV4_MAP(&addr6, &addr4); sprintf((char*)locator_ipv4, "%s", inet_ntoa(addr4)); } else { hip_in6_ntop(&addr6, (char*)locator_ipv4); _HIP_DEBUG("Value: %s\n", (char*)locator_ipv4); } return 0 ; } else return -1; }
/** * handle_hit_value - handles just IP (not locator) returned by lookup services * * @param *packet response returned from the lookup service * @param *hit opaque pointer passed to point to the ip * @return status of the operation 0 on success, -1 on failure */ int handle_ip_value (unsigned char *packet, void *ip) { hip_in6_ntop((struct in6_addr *)packet, (char*)ip); if ((char*)ip) return 0 ; else return -1 ; }
/** * handle_hit_value - This function copies the hit returned from the lookup service * * @param *packet response returned from the lookup service * @param *hit opaque pointer passed to point to the HIT * @return status of the operation 0 on success, -1 on failure */ int handle_hit_value (unsigned char *packet, void *hit) { if (ipv6_addr_is_hit((struct in6_addr*)packet)) { hip_in6_ntop((struct in6_addr *)packet, (char*)hit); return 0 ; } else return -1 ; }
/** * connhipd_send_hitdata_to_daemon - builds a param containing hits to be * sent to the daemon * @param *msg packet to be sent to daemon * @param *hitr remote hit accepted * @param *hitl local hit used * @return 0 on success, -1 on error */ int connhipd_send_hitdata_to_daemon(struct hip_common * msg , struct in6_addr * hitr, struct in6_addr * hitl) { int err = 0; struct hip_uadb_info uadb_info ; char hittest[40]; HIP_DEBUG("Building User Agent DB info message to be sent to daemon.\n"); memcpy(&uadb_info.hitr,hitr, sizeof(struct in6_addr)) ; memcpy(&uadb_info.hitl,hitl, sizeof(struct in6_addr)) ; hip_in6_ntop(&uadb_info.hitr, hittest); HIP_DEBUG("Value: %s\n", hittest); memcpy(uadb_info.cert,"certificate\0",sizeof("certificate\0")); hip_build_param_hip_uadb_info(msg, &uadb_info); HIP_DUMP_MSG (msg); out_err: return (err); }
/** * print a HIT * * @param debug_level the urgency of the message (DEBUG_LEVEL_XX) * @param file the file from where the debug call was made * @param line the line of the debug call in the source file * @param function the name of function where the debug call is located * @param str string to be printed before the HIT * @param hit the HIT to be printed * @note Do not call this function directly. Instead, use the * HIP_DEBUG_HIT and HIP_INFO_HIT macros. */ void hip_print_hit(int debug_level, const char *file, int line, const char *function, const char *str, const struct in6_addr *hit) { if (hit == NULL) { HIP_DEBUG("%s: NULL\n", str); return; } else { char dst[INET6_ADDRSTRLEN]; if (IN6_IS_ADDR_V4MAPPED(hit)) { struct in_addr in_addr; IPV6_TO_IPV4_MAP(hit, &in_addr); hip_print_lsi(debug_level, file, line, function, str, &in_addr); } else { hip_in6_ntop(hit, dst); hip_print_str(debug_level, file, line, function, "%s: %s\n", str, dst); } return; } }