OpenHIP 0.9svn1
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <hip/hip_service.h>
#include <hip/hip_types.h>
#include <hip/hip_sadb.h>
#include <hip/hip_funcs.h>
#include <hip/hip_usermode.h>
Functions | |
void | esp_start_expire (__u32 spi) |
hip_lsi_entry * | create_lsi_entry (struct sockaddr *lsi) |
void | free_addr_list (sockaddr_list *a) |
int | hip_sadb_delete_entry (hip_sadb_entry *entry, int unlink) |
hip_lsi_entry * | hip_lookup_lsi_by_addr (struct sockaddr *addr) |
hip_lsi_entry * | hip_lookup_lsi (struct sockaddr *lsi) |
int | hip_sadb_add_dst_entry (struct sockaddr *addr, hip_sadb_entry *entry) |
int | hip_sadb_delete_dst_entry (struct sockaddr *addr) |
hip_proto_sel_entry * | hip_lookup_sel_entry (__u32 lsi, __u8 proto, __u8 *header, int dir) |
__u32 | hip_proto_header_to_selector (__u32 lsi, __u8 proto, __u8 *header, int dir) |
hip_proto_sel_entry * | hip_remove_proto_sel_entry (hip_proto_sel_entry *prev, hip_proto_sel_entry *entry) |
int | sadb_hashfn (__u32 spi) |
int | sadb_dst_hashfn (struct sockaddr *dst) |
void | hip_sadb_init () |
void | hip_sadb_deinit () |
int | hip_sadb_add (__u32 mode, int direction, struct sockaddr *src_hit, struct sockaddr *dst_hit, struct sockaddr *src, struct sockaddr *dst, struct sockaddr *src_lsi, struct sockaddr *dst_lsi, __u32 spi, __u32 spinat, __u8 *e_key, __u32 e_type, __u32 e_keylen, __u8 *a_key, __u32 a_type, __u32 a_keylen, __u32 lifetime) |
int | hip_sadb_delete (__u32 spi) |
int | hip_sadb_add_del_addr (__u32 spi, struct sockaddr *addr, int flags) |
void | hip_remove_expired_lsi_entries (struct timeval *now) |
int | buffer_packet (struct sockaddr *lsi, __u8 *data, int len) |
void | unbuffer_packets (hip_lsi_entry *entry) |
hip_sadb_entry * | hip_sadb_lookup_spi (__u32 spi) |
hip_sadb_entry * | hip_sadb_lookup_addr (struct sockaddr *addr) |
hip_sadb_entry * | hip_sadb_get_next (hip_sadb_entry *placemark) |
void | hip_sadb_expire (struct timeval *now) |
int | hip_sadb_get_usage (__u32 spi, __u64 *bytes, struct timeval *usetime) |
int | hip_sadb_get_lost (__u32 spi, __u32 *lost) |
void | hip_sadb_inc_bytes (hip_sadb_entry *entry, __u64 bytes, struct timeval *now, int lock) |
__u32 | hip_sadb_inc_loss (hip_sadb_entry *entry, __u32 loss, struct sockaddr *dst) |
void | hip_sadb_reset_loss (hip_sadb_entry *entry, struct sockaddr *dst) |
int | hip_select_family_by_proto (__u32 lsi, __u8 proto, __u8 *header, struct timeval *now) |
int | hip_add_proto_sel_entry (__u32 lsi, __u8 proto, __u8 *header, int family, int dir, struct timeval *now) |
void | hip_remove_expired_sel_entries (struct timeval *now) |
void | print_sadb () |
Variables | |
int | readsp [2] |
long | g_read_usec |
hip_sadb_entry * | hip_sadb [SADB_SIZE] = {0} |
hip_mutex_t | hip_sadb_locks [SADB_SIZE] |
hip_sadb_dst_entry * | hip_sadb_dst [SADB_SIZE] = {0} |
hip_mutex_t | hip_sadb_dst_locks [SADB_SIZE] |
hip_lsi_entry * | lsi_temp = NULL |
hip_proto_sel_entry * | hip_proto_sel [PROTO_SEL_SIZE] = {0} |
hip_mutex_t | hip_proto_sel_locks [PROTO_SEL_SIZE] |
int buffer_packet | ( | struct sockaddr * | lsi, |
__u8 * | data, | ||
int | len | ||
) |
References create_lsi_entry(), FALSE, hip_lookup_lsi(), LSI_PKT_BUFFER_SIZE, _hip_lsi_entry::next_packet, _hip_lsi_entry::num_packets, _hip_lsi_entry::packet_buffer, and TRUE.
Referenced by hip_esp_output().
hip_lsi_entry * create_lsi_entry | ( | struct sockaddr * | lsi | ) |
void esp_start_expire | ( | __u32 | spi | ) |
References ESP_EXPIRE_SPI, esp_send_to_hipd(), _espmsg::message_data, and _espmsg::message_type.
Referenced by hip_esp_output(), and hip_sadb_expire().
void free_addr_list | ( | sockaddr_list * | a | ) |
References _sockaddr_list::next.
Referenced by hip_sadb_delete_entry().
hip_lsi_entry* hip_lookup_lsi | ( | struct sockaddr * | lsi | ) |
References _hip_lsi_entry::lsi4, _hip_lsi_entry::lsi6, _hip_lsi_entry::next, SA2IP, and SAIPLEN.
Referenced by buffer_packet(), hip_sadb_add(), and hip_sadb_delete().
hip_lsi_entry* hip_lookup_lsi_by_addr | ( | struct sockaddr * | addr | ) |
hip_proto_sel_entry * hip_lookup_sel_entry | ( | __u32 | lsi, |
__u8 | proto, | ||
__u8 * | header, | ||
int | dir | ||
) |
References hip_proto_header_to_selector(), hip_proto_sel_hash, hip_proto_sel_locks, _hip_proto_sel_entry::next, and _hip_proto_sel_entry::selector.
Referenced by hip_select_family_by_proto().
References udphdr::dest, tcphdr::dest, udphdr::source, and tcphdr::source.
Referenced by hip_add_proto_sel_entry(), and hip_lookup_sel_entry().
void hip_remove_expired_lsi_entries | ( | struct timeval * | now | ) |
References _hip_lsi_entry::creation_time, LSI_ENTRY_LIFETIME, lsi_temp, _hip_lsi_entry::next, _hip_lsi_entry::send_packets, and unbuffer_packets().
Referenced by hip_esp_input().
void hip_remove_expired_sel_entries | ( | struct timeval * | now | ) |
References hip_proto_sel_locks, _hip_proto_sel_entry::last_used, _hip_proto_sel_entry::next, PROTO_SEL_ENTRY_LIFETIME, and PROTO_SEL_SIZE.
Referenced by hip_esp_input().
hip_proto_sel_entry * hip_remove_proto_sel_entry | ( | hip_proto_sel_entry * | prev, |
hip_proto_sel_entry * | entry | ||
) |
References _hip_proto_sel_entry::next.
int hip_sadb_add | ( | __u32 | mode, |
int | direction, | ||
struct sockaddr * | src_hit, | ||
struct sockaddr * | dst_hit, | ||
struct sockaddr * | src, | ||
struct sockaddr * | dst, | ||
struct sockaddr * | src_lsi, | ||
struct sockaddr * | dst_lsi, | ||
__u32 | spi, | ||
__u32 | spinat, | ||
__u8 * | e_key, | ||
__u32 | e_type, | ||
__u32 | e_keylen, | ||
__u8 * | a_key, | ||
__u32 | a_type, | ||
__u32 | a_keylen, | ||
__u32 | lifetime | ||
) |
References _hip_sadb_entry::a_key, _hip_sadb_entry::a_keylen, _hip_sadb_entry::a_type, _sockaddr_list::addr, _hip_sadb_entry::aes_key, _hip_sadb_entry::bf_key, _hip_sadb_entry::bytes, checksum_magic(), _hip_sadb_entry::direction, _hip_sadb_entry::dropped, _hip_sadb_entry::dst_addrs, _hip_sadb_entry::dst_hit, _hip_sadb_entry::e_key, _hip_sadb_entry::e_keylen, _hip_sadb_entry::e_type, _hip_sadb_entry::exptime, FALSE, g_read_usec, hip_lookup_lsi(), hip_sadb_add_dst_entry(), hip_sadb_delete_entry(), hip_sadb_locks, _hip_sadb_entry::hit_magic, _hip_sadb_entry::ks, _hip_sadb_entry::lifetime, _hip_sadb_entry::lost, _hip_sadb_entry::lsi, LSI4, _hip_sadb_entry::mode, _hip_sadb_entry::next, _hip_sadb_entry::packets, _hip_sadb_entry::replay_win_map, _hip_sadb_entry::replay_win_max, _hip_sadb_entry::rw_lock, SA, SA2IP, SADB_EALG_3DESCBC, sadb_hashfn(), SADB_X_EALG_AESCBC, SADB_X_EALG_BLOWFISHCBC, SALEN, _hip_lsi_entry::send_packets, _hip_sadb_entry::sequence, _hip_sadb_entry::sequence_hi, _hip_sadb_entry::spi, _hip_sadb_entry::spinat, _hip_sadb_entry::src_addrs, _hip_sadb_entry::src_hit, and _hip_sadb_entry::usetime.
Referenced by complete_base_exchange(), rebuild_sa(), and rebuild_sa_x2().
int hip_sadb_add_del_addr | ( | __u32 | spi, |
struct sockaddr * | addr, | ||
int | flags | ||
) |
References add_address_to_list(), delete_address_from_list(), _hip_sadb_entry::dst_addrs, hip_sadb_locks, hip_sadb_lookup_spi(), sadb_hashfn(), and _hip_sadb_entry::src_addrs.
Referenced by handle_notify_loss().
int hip_sadb_add_dst_entry | ( | struct sockaddr * | addr, |
hip_sadb_entry * | entry | ||
) |
References _hip_sadb_dst_entry::addr, hip_sadb_dst_locks, _hip_sadb_dst_entry::next, _hip_sadb_dst_entry::rw_lock, SA2IP, sadb_dst_hashfn(), _hip_sadb_dst_entry::sadb_entry, SAIPLEN, and SALEN.
Referenced by hip_sadb_add().
void hip_sadb_deinit | ( | ) |
References FALSE, hip_proto_sel_locks, hip_sadb_delete_entry(), hip_sadb_dst_locks, hip_sadb_locks, lsi_temp, _hip_proto_sel_entry::next, _hip_lsi_entry::next, _hip_sadb_dst_entry::next, _hip_sadb_entry::next, PROTO_SEL_SIZE, _hip_sadb_dst_entry::rw_lock, and SADB_SIZE.
Referenced by init_hip(), main(), and ServiceMain().
int hip_sadb_delete | ( | __u32 | spi | ) |
References _hip_lsi_entry::creation_time, _hip_sadb_entry::direction, _hip_sadb_entry::dst_hit, hip_lookup_lsi(), hip_sadb_delete_dst_entry(), hip_sadb_delete_entry(), hip_sadb_lookup_spi(), _hip_sadb_entry::lsi, _hip_sadb_entry::rw_lock, SA, and TRUE.
Referenced by delete_associations(), rebuild_sa(), and rebuild_sa_x2().
int hip_sadb_delete_dst_entry | ( | struct sockaddr * | addr | ) |
References hip_sadb_dst_locks, _hip_sadb_dst_entry::next, SA2IP, sadb_dst_hashfn(), and SAIPLEN.
Referenced by hip_sadb_delete().
int hip_sadb_delete_entry | ( | hip_sadb_entry * | entry, |
int | unlink | ||
) |
References _hip_sadb_entry::a_key, _hip_sadb_entry::a_keylen, _hip_sadb_entry::dst_addrs, _hip_sadb_entry::e_key, _hip_sadb_entry::e_keylen, free_addr_list(), hip_sadb_locks, _hip_sadb_entry::next, _hip_sadb_entry::rw_lock, sadb_hashfn(), _hip_sadb_entry::spi, and _hip_sadb_entry::src_addrs.
Referenced by hip_sadb_add(), hip_sadb_deinit(), and hip_sadb_delete().
void hip_sadb_expire | ( | struct timeval * | now | ) |
References esp_start_expire(), _hip_sadb_entry::exptime, hip_sadb_locks, _hip_sadb_entry::lifetime, _hip_sadb_entry::next, SADB_SIZE, and _hip_sadb_entry::spi.
Referenced by hip_esp_input().
References hip_sadb_lookup_spi(), _hip_sadb_entry::lost, and _hip_sadb_entry::rw_lock.
hip_sadb_entry* hip_sadb_get_next | ( | hip_sadb_entry * | placemark | ) |
References _hip_sadb_entry::direction, hip_sadb_locks, _hip_sadb_entry::next, and SADB_SIZE.
Referenced by hip_esp_output().
References _hip_sadb_entry::bytes, hip_sadb_lookup_spi(), _hip_sadb_entry::rw_lock, and _hip_sadb_entry::usetime.
Referenced by check_last_used().
void hip_sadb_inc_bytes | ( | hip_sadb_entry * | entry, |
__u64 | bytes, | ||
struct timeval * | now, | ||
int | lock | ||
) |
References _hip_sadb_entry::bytes, _hip_sadb_entry::packets, _hip_sadb_entry::rw_lock, and _hip_sadb_entry::usetime.
Referenced by hip_esp_decrypt(), and hip_esp_output().
__u32 hip_sadb_inc_loss | ( | hip_sadb_entry * | entry, |
__u32 | loss, | ||
struct sockaddr * | dst | ||
) |
References _sockaddr_list::addr, _hip_sadb_entry::dst_addrs, _sockaddr_list::next, _sockaddr_list::nonce, SA2IP, and SAIPLEN.
Referenced by hip_esp_decrypt().
void hip_sadb_init | ( | ) |
References hip_proto_sel_locks, hip_sadb_dst_locks, hip_sadb_locks, PROTO_SEL_SIZE, and SADB_SIZE.
Referenced by init_hip().
hip_sadb_entry* hip_sadb_lookup_addr | ( | struct sockaddr * | addr | ) |
References _hip_sadb_dst_entry::addr, hip_sadb_dst_locks, _hip_sadb_dst_entry::next, _hip_sadb_dst_entry::rw_lock, SA2IP, sadb_dst_hashfn(), _hip_sadb_dst_entry::sadb_entry, and SAIPLEN.
Referenced by hip_esp_output().
hip_sadb_entry* hip_sadb_lookup_spi | ( | __u32 | spi | ) |
References hip_sadb_locks, _hip_sadb_entry::next, sadb_hashfn(), and _hip_sadb_entry::spi.
Referenced by get_next_spi(), hip_esp_input(), hip_sadb_add_del_addr(), hip_sadb_delete(), hip_sadb_get_lost(), and hip_sadb_get_usage().
void hip_sadb_reset_loss | ( | hip_sadb_entry * | entry, |
struct sockaddr * | dst | ||
) |
References _sockaddr_list::addr, _hip_sadb_entry::dst_addrs, _sockaddr_list::next, _sockaddr_list::nonce, SA2IP, and SAIPLEN.
Referenced by hip_esp_decrypt().
References _hip_proto_sel_entry::family, hip_add_proto_sel_entry(), hip_lookup_sel_entry(), _hip_proto_sel_entry::last_used, and PROTO_SEL_DEFAULT_FAMILY.
Referenced by hip_esp_decrypt().
void print_sadb | ( | ) |
References _hip_sadb_entry::a_keylen, _hip_sadb_entry::a_type, _hip_sadb_entry::direction, _hip_sadb_entry::e_keylen, _hip_sadb_entry::e_type, _hip_sadb_entry::hit_magic, _hip_sadb_entry::lifetime, _hip_sadb_entry::lsi, _hip_sadb_entry::mode, _hip_sadb_entry::next, _hip_sadb_entry::rw_lock, SADB_SIZE, _hip_sadb_entry::sequence, and _hip_sadb_entry::spi.
int sadb_dst_hashfn | ( | struct sockaddr * | dst | ) |
References SADB_SIZE.
Referenced by hip_sadb_add_dst_entry(), hip_sadb_delete_dst_entry(), and hip_sadb_lookup_addr().
int sadb_hashfn | ( | __u32 | spi | ) |
References SADB_SIZE.
Referenced by dump_sadb(), hip_sadb_add(), hip_sadb_add_del_addr(), hip_sadb_delete_entry(), and hip_sadb_lookup_spi().
void unbuffer_packets | ( | hip_lsi_entry * | entry | ) |
References _hip_lsi_entry::creation_time, g_read_usec, ip::ip_len, ip::ip_v, _hip_lsi_entry::lsi4, LSI4, LSI_PKT_BUFFER_SIZE, _hip_lsi_entry::next_packet, NIPQUAD, _hip_lsi_entry::num_packets, _hip_lsi_entry::packet_buffer, readsp, and _hip_lsi_entry::send_packets.
Referenced by hip_remove_expired_lsi_entries().
long g_read_usec |
Referenced by hip_esp_input(), hip_esp_output(), hip_sadb_add(), and unbuffer_packets().
hip_proto_sel_entry* hip_proto_sel[PROTO_SEL_SIZE] = {0} |
hip_mutex_t hip_proto_sel_locks[PROTO_SEL_SIZE] |
hip_sadb_entry* hip_sadb[SADB_SIZE] = {0} |
hip_sadb_dst_entry* hip_sadb_dst[SADB_SIZE] = {0} |
hip_mutex_t hip_sadb_dst_locks[SADB_SIZE] |
Referenced by hip_sadb_add_dst_entry(), hip_sadb_deinit(), hip_sadb_delete_dst_entry(), hip_sadb_init(), and hip_sadb_lookup_addr().
hip_mutex_t hip_sadb_locks[SADB_SIZE] |
hip_lsi_entry* lsi_temp = NULL |
Referenced by hip_remove_expired_lsi_entries(), and hip_sadb_deinit().
int readsp[2] |
Referenced by hip_esp_output(), init_readsp(), and unbuffer_packets().