OpenHIP 0.9svn1
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <pthread.h>
#include <openssl/evp.h>
#include <netinet/ip6.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
#include <openssl/sha.h>
#include <openssl/rand.h>
#include <hip/hip_version.h>
#include <hip/hip_types.h>
#include <hip/hip_globals.h>
#include <hip/hip_funcs.h>
Classes | |
struct | dht_val |
Defines | |
#define | XMLRPC_MODE_GET 0x0001 |
#define | XMLRPC_MODE_PUT 0x0002 |
#define | XMLRPC_MODE_RM 0x0003 |
#define | XMLRPC_MODE_RETRY_OFF 0x0010 |
#define | XMLRPC_MODE_RETRY_ON 0x0020 |
#define | XMLRPC_APP_HIT "hip-name-hit" |
#define | XMLRPC_APP_ADDR "hip-addr" |
#define | DHT_KEY_SIZE 20 |
#define | DHT_VAL_SIZE 1024 |
#define | DHT_DEF_TTL 604800 |
#define | RETNULL NULL; |
#define | VOIDECL void * |
Functions | |
__u32 | get_preferred_addr () |
int | hip_dht_lookup_hit_by_name (char *name, hip_hit *hit, int retry) |
int | hip_dht_lookup_address (hip_hit *hit, struct sockaddr *addr, int retry) |
int | hip_dht_publish_addr (hi_node *hi, struct sockaddr *addr, int retry) |
int | hip_dht_publish_hit (hi_node *hi, char *name, int retry) |
int | hip_dht_select_server (struct sockaddr *addr) |
VOIDECL | hip_dht_resolve_hi_thread (void *void_hi) |
VOIDECL | publish_my_hits_thread (void *void_addr) |
void | hit2hit_key (hip_hit *hit, __u8 *hit_key) |
int | build_hdrr (__u8 *hdrr, int hdrr_size, hi_node *hi, struct sockaddr *addr) |
int | parse_hdrr (__u8 *hdrr, int len) |
int | hip_xmlrpc_getput (int mode, char *app, struct sockaddr *server, char *key, int key_len, char *value, int *value_len, char *secret, int secret_len, int ttl) |
int | hip_xmlrpc_parse_response (int mode, char *xmldata, int len, char *value, int *value_len) |
char * | hip_xmlrpc_resp_to_str (int code) |
xmlNodePtr | xml_new_param (xmlNodePtr node_parent, char *type, char *value) |
int | build_http_post_header (char *buff, int content_len, struct sockaddr *addr) |
struct dht_val * | lookup_dht_val (char *key) |
struct dht_val * | insert_dht_val (char *key) |
int | hip_xmlrpc_rm (struct dht_val *v) |
void | hip_dht_update_my_entries (int flags) |
int | hip_dht_resolve_hi (hi_node *hi, int retry) |
Variables | |
hip_mutex_t | dht_vals_lock |
static struct dht_val * | dht_vals = NULL |
#define DHT_DEF_TTL 604800 |
Referenced by hip_dht_publish_addr(), and hip_dht_publish_hit().
#define DHT_KEY_SIZE 20 |
Referenced by hip_dht_lookup_address(), hip_dht_publish_addr(), hip_xmlrpc_getput(), and hit2hit_key().
#define DHT_VAL_SIZE 1024 |
Referenced by hip_dht_lookup_address(), hip_dht_lookup_hit_by_name(), hip_dht_publish_addr(), and hip_xmlrpc_getput().
#define RETNULL NULL; |
Referenced by hip_dht_resolve_hi_thread(), and publish_my_hits_thread().
#define VOIDECL void * |
#define XMLRPC_APP_ADDR "hip-addr" |
Referenced by hip_dht_lookup_address(), and hip_dht_publish_addr().
#define XMLRPC_APP_HIT "hip-name-hit" |
Referenced by hip_dht_lookup_hit_by_name(), and hip_dht_publish_hit().
#define XMLRPC_MODE_GET 0x0001 |
Referenced by hip_dht_lookup_address(), hip_dht_lookup_hit_by_name(), hip_xmlrpc_getput(), and hip_xmlrpc_parse_response().
#define XMLRPC_MODE_PUT 0x0002 |
Referenced by hip_dht_publish_addr(), hip_dht_publish_hit(), hip_xmlrpc_getput(), and hip_xmlrpc_parse_response().
#define XMLRPC_MODE_RETRY_OFF 0x0010 |
#define XMLRPC_MODE_RETRY_ON 0x0020 |
#define XMLRPC_MODE_RM 0x0003 |
Referenced by hip_xmlrpc_getput(), hip_xmlrpc_parse_response(), and hip_xmlrpc_rm().
References build_tlv_hostid(), build_tlv_hostid_len(), build_tlv_signature(), _hiphdr::checksum, _hiphdr::control, eight_byte_align(), HCNF, _hiphdr::hdr_len, HIP_HDRR, HIP_PROTO_VER, HIP_RES_SHIM6_BITS, _hi_node::hit, _hiphdr::hit_rcvr, HIT_SIZE, _hiphdr::hit_sndr, IPPROTO_NONE, _tlv_seq::length, _tlv_locator::length, hip_conf::loc_lifetime, _locator::locator, _tlv_locator::locator1, _locator::locator_length, _locator::locator_lifetime, LOCATOR_PREFERRED, LOCATOR_TRAFFIC_TYPE_BOTH, _locator::locator_type, LOCATOR_TYPE_IPV6, _hiphdr::nxt_hdr, _hiphdr::packet_type, PARAM_LOCATOR, PARAM_SEQ, _hiphdr::res, _locator::reserved, SA2IP, SAIPLEN, hip_conf::send_hi_name, _locator::traffic_type, _tlv_seq::type, _tlv_locator::type, _tlv_seq::update_id, _hiphdr::version, and zero_hit.
Referenced by hip_dht_publish_addr().
int build_http_post_header | ( | char * | buff, |
int | content_len, | ||
struct sockaddr * | addr | ||
) |
References addr_to_str(), HIP_NAME, and HIP_VERSION.
Referenced by hip_xmlrpc_getput().
__u32 get_preferred_addr | ( | ) |
References _sockaddr_list::addr, my_addr_head, _sockaddr_list::next, and _sockaddr_list::preferred.
Referenced by hip_xmlrpc_getput().
int hip_dht_lookup_address | ( | hip_hit * | hit, |
struct sockaddr * | addr, | ||
int | retry | ||
) |
References _hiphdr::checksum, DHT_KEY_SIZE, DHT_VAL_SIZE, _hi_node::dsa, eight_byte_align(), FALSE, free_hi_node(), handle_hi(), _hiphdr::hdr_len, hip_dht_select_server(), hip_xmlrpc_getput(), hit2hit_key(), _hiphdr::hit_sndr, _tlv_head::length, length, _locator::locator, _locator::locator_length, _locator::locator_type, LOCATOR_TYPE_IPV6, LOCATOR_TYPE_SPI_IPV6, log_(), logaddr(), NORM, PARAM_HIP_SIGNATURE, PARAM_HOST_ID, PARAM_LOCATOR, parse_hdrr(), _hi_node::rsa, SA2IP, SAIPLEN, tlv_length_to_parameter_length(), TRUE, _tlv_head::type, type, validate_hit(), validate_signature(), WARN, XMLRPC_APP_ADDR, XMLRPC_MODE_GET, XMLRPC_MODE_RETRY_OFF, and XMLRPC_MODE_RETRY_ON.
Referenced by hip_dht_resolve_hi().
int hip_dht_lookup_hit_by_name | ( | char * | name, |
hip_hit * | hit, | ||
int | retry | ||
) |
References DHT_VAL_SIZE, hip_dht_select_server(), hip_xmlrpc_getput(), HIT_SIZE, _hiphdr::hit_sndr, parse_hdrr(), XMLRPC_APP_HIT, XMLRPC_MODE_GET, XMLRPC_MODE_RETRY_OFF, and XMLRPC_MODE_RETRY_ON.
Referenced by hip_dht_resolve_hi().
int hip_dht_publish_addr | ( | hi_node * | hi, |
struct sockaddr * | addr, | ||
int | retry | ||
) |
References build_hdrr(), DHT_DEF_TTL, DHT_KEY_SIZE, DHT_VAL_SIZE, hip_dht_select_server(), hip_xmlrpc_getput(), _hi_node::hit, hit2hit_key(), XMLRPC_APP_ADDR, XMLRPC_MODE_PUT, XMLRPC_MODE_RETRY_OFF, and XMLRPC_MODE_RETRY_ON.
Referenced by publish_my_hits_thread().
int hip_dht_publish_hit | ( | hi_node * | hi, |
char * | name, | ||
int | retry | ||
) |
References _hiphdr::checksum, _hiphdr::control, DHT_DEF_TTL, _hiphdr::hdr_len, hip_dht_select_server(), HIP_HDRR, HIP_PROTO_VER, HIP_RES_SHIM6_BITS, hip_xmlrpc_getput(), _hi_node::hit, _hiphdr::hit_rcvr, HIT_SIZE, _hiphdr::hit_sndr, IPPROTO_NONE, _hiphdr::nxt_hdr, _hiphdr::packet_type, _hiphdr::res, _hiphdr::version, XMLRPC_APP_HIT, XMLRPC_MODE_PUT, XMLRPC_MODE_RETRY_OFF, XMLRPC_MODE_RETRY_ON, and zero_hit.
Referenced by publish_my_hits_thread().
int hip_dht_resolve_hi | ( | hi_node * | hi, |
int | retry | ||
) |
References add_address_to_list(), _sockaddr_list::addr, _hi_node::addrs, _hi_node::addrs_mutex, _sockaddr_list::creation_time, DELETED, hip_dht_lookup_address(), hip_dht_lookup_hit_by_name(), hip_dht_resolve_hi_thread(), hip_dht_select_server(), _hi_node::hit, hit_to_str(), hits_equal(), _sockaddr_list::if_index, _sockaddr_list::lifetime, log_(), logaddr(), _hi_node::lsi, _hi_node::name, _hi_node::name_len, _sockaddr_list::nonce, NORM, SA, SALEN, _sockaddr_list::status, TRUE, UNVERIFIED, VALID_FAM, WARN, and zero_hit.
Referenced by hip_convert_lsi_to_peer(), hip_dht_resolve_hi_thread(), and read_identities_file().
VOIDECL hip_dht_resolve_hi_thread | ( | void * | void_hi | ) |
References hip_dht_resolve_hi(), and RETNULL.
Referenced by hip_dht_resolve_hi().
int hip_dht_select_server | ( | struct sockaddr * | addr | ) |
References hip_conf::dht_server, HCNF, SALEN, and VALID_FAM.
Referenced by hip_dht_lookup_address(), hip_dht_lookup_hit_by_name(), hip_dht_publish_addr(), hip_dht_publish_hit(), hip_dht_resolve_hi(), hip_dht_update_my_entries(), and hip_xmlrpc_rm().
void hip_dht_update_my_entries | ( | int | flags | ) |
References _sockaddr_list::addr, dht_vals, dht_vals_lock, hip_dht_select_server(), hip_xmlrpc_rm(), IS_LSI, my_addr_head, _sockaddr_list::next, dht_val::next, _sockaddr_list::preferred, publish_my_hits_thread(), and SA.
Referenced by hip_exit(), and main_loop().
int hip_xmlrpc_getput | ( | int | mode, |
char * | app, | ||
struct sockaddr * | server, | ||
char * | key, | ||
int | key_len, | ||
char * | value, | ||
int * | value_len, | ||
char * | secret, | ||
int | secret_len, | ||
int | ttl | ||
) |
References dht_val::app, build_http_post_header(), closesocket, DHT_KEY_SIZE, DHT_VAL_SIZE, dht_vals_lock, dht_val::expire_time, g_state, get_preferred_addr(), HCNF, hip_sleep(), hip_xmlrpc_parse_response(), hip_xmlrpc_resp_to_str(), insert_dht_val(), log_(), logaddr(), lookup_dht_val(), hip_conf::max_retries, NORM, hip_conf::packet_timeout, SA, SALEN, dht_val::secret, dht_val::secret_len, TDIFF, dht_val::value_hash, dht_val::value_hash_len, WARN, xml_new_param(), XMLRPC_MODE_GET, XMLRPC_MODE_PUT, XMLRPC_MODE_RETRY_ON, and XMLRPC_MODE_RM.
Referenced by hip_dht_lookup_address(), hip_dht_lookup_hit_by_name(), hip_dht_publish_addr(), hip_dht_publish_hit(), and hip_xmlrpc_rm().
int hip_xmlrpc_parse_response | ( | int | mode, |
char * | xmldata, | ||
int | len, | ||
char * | value, | ||
int * | value_len | ||
) |
References XMLRPC_MODE_GET, XMLRPC_MODE_PUT, and XMLRPC_MODE_RM.
Referenced by hip_xmlrpc_getput().
char * hip_xmlrpc_resp_to_str | ( | int | code | ) |
Referenced by hip_xmlrpc_getput().
int hip_xmlrpc_rm | ( | struct dht_val * | v | ) |
References dht_val::app, dht_val::expire_time, hip_dht_select_server(), hip_xmlrpc_getput(), dht_val::key, log_(), NORM, SA, dht_val::secret, dht_val::secret_len, TDIFF, dht_val::value_hash, dht_val::value_hash_len, XMLRPC_MODE_RETRY_OFF, and XMLRPC_MODE_RM.
Referenced by hip_dht_update_my_entries().
References bn2bin_safe(), DHT_KEY_SIZE, and HIT_SIZE.
Referenced by hip_dht_lookup_address(), and hip_dht_publish_addr().
struct dht_val * insert_dht_val | ( | char * | key | ) | [read] |
References dht_vals, dht_val::key, log_(), dht_val::next, and WARN.
Referenced by hip_xmlrpc_getput().
struct dht_val * lookup_dht_val | ( | char * | key | ) | [read] |
References dht_val::key, and dht_val::next.
Referenced by hip_xmlrpc_getput().
int parse_hdrr | ( | __u8 * | hdrr, |
int | len | ||
) |
References _hiphdr::hdr_len, HIP_HDRR, HIP_PROTO_VER, HIP_RES_SHIM6_BITS, IPPROTO_NONE, _hiphdr::nxt_hdr, _hiphdr::packet_type, _hiphdr::res, and _hiphdr::version.
Referenced by hip_dht_lookup_address(), and hip_dht_lookup_hit_by_name().
VOIDECL publish_my_hits_thread | ( | void * | void_addr | ) |
References hip_dht_publish_addr(), hip_dht_publish_hit(), my_hi_head, _hi_node::name, _hi_node::next, RETNULL, SA, and TRUE.
Referenced by hip_dht_update_my_entries().
xmlNodePtr xml_new_param | ( | xmlNodePtr | node_parent, |
char * | type, | ||
char * | value | ||
) |
Referenced by hip_xmlrpc_getput().
Referenced by hip_dht_update_my_entries(), and insert_dht_val().
Referenced by hip_dht_update_my_entries(), and hip_xmlrpc_getput().