Committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx> Date: 30/03/2010 at 11:15:47 Revision: 4096 Revision-id: rene.hummen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: removed pointer from another struct this also fixed userspace ipsec -> working again Modified: M firewall/user_ipsec_sadb.c M firewall/user_ipsec_sadb.h === modified file 'firewall/user_ipsec_sadb.c' --- firewall/user_ipsec_sadb.c 2010-03-29 19:33:56 +0000 +++ firewall/user_ipsec_sadb.c 2010-03-30 08:15:17 +0000 @@ -131,13 +131,12 @@ int err = 0; // values have to be present - HIP_ASSERT(link_entry != NULL && link_entry->dst_addr != NULL && - link_entry->spi != 0); + HIP_ASSERT(link_entry != NULL && link_entry->spi != 0); memset(hash, 0, INDEX_HASH_LENGTH); /* concatenate dst_addr and spi */ - memcpy(&hash_input[0], link_entry->dst_addr, sizeof(struct in6_addr)); + memcpy(&hash_input[0], &link_entry->dst_addr, sizeof(struct in6_addr)); memcpy(&hash_input[sizeof(struct in6_addr)], &link_entry->spi, sizeof(uint32_t)); @@ -172,10 +171,8 @@ unsigned long hash2 = 0; // values have to be present - HIP_ASSERT(link_entry1 != NULL && link_entry1->dst_addr != NULL - && link_entry1->spi != 0); - HIP_ASSERT(link_entry2 != NULL && link_entry2->dst_addr != NULL - && link_entry2->spi != 0); + HIP_ASSERT(link_entry1 != NULL && link_entry1->spi != 0); + HIP_ASSERT(link_entry2 != NULL && link_entry2->spi != 0); _HIP_DEBUG("calculating hash1:\n"); HIP_IFEL(!(hash1 = hip_link_entry_hash(link_entry1)), -1, @@ -244,21 +241,19 @@ static hip_link_entry_t * hip_link_entry_find(const struct in6_addr *dst_addr, uint32_t spi) { - hip_link_entry_t *search_link, *stored_link = NULL; + hip_link_entry_t search_link; + hip_link_entry_t *stored_link = NULL; int err = 0; - HIP_IFEL(!(search_link = (hip_link_entry_t *) malloc(sizeof(hip_link_entry_t))), - -1, "failed to allocate memory\n"); - // search the linkdb for the link to the corresponding entry - memcpy(search_link->dst_addr, dst_addr, sizeof(struct in6_addr)); - search_link->spi = spi; + memcpy(&search_link.dst_addr, dst_addr, sizeof(struct in6_addr)); + search_link.spi = spi; HIP_DEBUG("looking up link entry with following index attributes:\n"); - HIP_DEBUG_HIT("dst_addr", search_link->dst_addr); - HIP_DEBUG("spi: 0x%lx\n", search_link->spi); + HIP_DEBUG_HIT("dst_addr", &search_link.dst_addr); + HIP_DEBUG("spi: 0x%lx\n", search_link.spi); - HIP_IFEL(!(stored_link = hip_ht_find(linkdb, search_link)), -1, + HIP_IFEL(!(stored_link = hip_ht_find(linkdb, &search_link)), -1, "failed to retrieve link entry\n"); out_err: @@ -266,10 +261,6 @@ stored_link = NULL; } - if (search_link) { - free(search_link); - } - return stored_link; } @@ -288,7 +279,7 @@ HIP_IFEL(!(link = (hip_link_entry_t *) malloc(sizeof(hip_link_entry_t))), -1, "failed to allocate memory\n"); - link->dst_addr = dst_addr; + memcpy(&link->dst_addr, dst_addr, sizeof(struct in6_addr)); link->spi = entry->spi; link->linked_sa_entry = entry; @@ -338,7 +329,7 @@ void hip_link_entry_print(hip_link_entry_t *entry) { if (entry) { - HIP_DEBUG_HIT("dst_addr", entry->dst_addr); + HIP_DEBUG_HIT("dst_addr", &entry->dst_addr); HIP_DEBUG("spi: 0x%lx\n", entry->spi); HIP_DEBUG("> sa entry:\n"); } else { === modified file 'firewall/user_ipsec_sadb.h' --- firewall/user_ipsec_sadb.h 2010-03-29 19:33:56 +0000 +++ firewall/user_ipsec_sadb.h 2010-03-30 08:15:17 +0000 @@ -72,7 +72,7 @@ /* Structure for demultiplexing inbound ipsec packets, indexed by dst_addr and spi */ typedef struct hip_link_entry { - struct in6_addr *dst_addr; /* destination address of outer IP header */ + struct in6_addr dst_addr; /* destination address of outer IP header */ uint32_t spi; /* ipsec spi, needed for demultiplexing incoming packets */ hip_sa_entry_t * linked_sa_entry; /* direct link to sa entry */ } hip_link_entry_t;