diff --git a/server/fwknopd_common.h b/server/fwknopd_common.h index c4a271f1..c89cade5 100644 --- a/server/fwknopd_common.h +++ b/server/fwknopd_common.h @@ -418,6 +418,7 @@ typedef struct spa_pkt_info { unsigned int packet_data_len; unsigned int packet_src_ip; + unsigned int packet_dst_ip; unsigned short packet_dest_port; unsigned char packet_data[MAX_SPA_PACKET_LEN+1]; } spa_pkt_info_t; diff --git a/server/process_packet.c b/server/process_packet.c index d99136b5..7da19c56 100644 --- a/server/process_packet.c +++ b/server/process_packet.c @@ -54,7 +54,7 @@ process_packet(unsigned char *args, const struct pcap_pkthdr *packet_header, unsigned int ip_hdr_words; unsigned int src_ip; - unsigned int dest_ip; + unsigned int dst_ip; unsigned short src_port; unsigned short dest_port; @@ -133,8 +133,8 @@ process_packet(unsigned char *args, const struct pcap_pkthdr *packet_header, /* Now, find the packet data payload (depending on IPPROTO). */ - src_ip = iph_p->saddr; - dest_ip = iph_p->daddr; + src_ip = iph_p->saddr; + dst_ip = iph_p->daddr; if (iph_p->protocol == IPPROTO_TCP) { @@ -182,6 +182,7 @@ process_packet(unsigned char *args, const struct pcap_pkthdr *packet_header, strlcpy((char *)opts->spa_pkt.packet_data, (char *)pkt_data, pkt_data_len+1); opts->spa_pkt.packet_data_len = pkt_data_len; opts->spa_pkt.packet_src_ip = src_ip; + opts->spa_pkt.packet_dst_ip = dst_ip; opts->spa_pkt.packet_dest_port = dest_port; return; diff --git a/server/replay_cache.c b/server/replay_cache.c index 3d8b8abc..a75f7207 100644 --- a/server/replay_cache.c +++ b/server/replay_cache.c @@ -277,6 +277,7 @@ replay_check_file_cache(fko_srv_options_t *opts, fko_ctx_t ctx) { char *digest = NULL; char src_ip[INET_ADDRSTRLEN+1] = {0}; + char dst_ip[INET_ADDRSTRLEN+1] = {0}; int res = 0, digest_len = 0; FILE *digest_file_cache_ptr = NULL; @@ -326,6 +327,7 @@ replay_check_file_cache(fko_srv_options_t *opts, fko_ctx_t ctx) strlcpy(digest_elm->cache_info.digest, digest, digest_len+1); digest_elm->cache_info.src_ip = opts->spa_pkt.packet_src_ip; + digest_elm->cache_info.dst_ip = opts->spa_pkt.packet_dst_ip; digest_elm->cache_info.created = time(NULL); /* First, add the digest at the head of the in-memory list @@ -344,8 +346,10 @@ replay_check_file_cache(fko_srv_options_t *opts, fko_ctx_t ctx) inet_ntop(AF_INET, &(digest_elm->cache_info.src_ip), src_ip, INET_ADDRSTRLEN); - fprintf(digest_file_cache_ptr, "%s %s %d\n", - digest, src_ip, (int) digest_elm->cache_info.created); + inet_ntop(AF_INET, &(digest_elm->cache_info.dst_ip), + dst_ip, INET_ADDRSTRLEN); + fprintf(digest_file_cache_ptr, "%s %s %s %d\n", + digest, src_ip, dst_ip, (int) digest_elm->cache_info.created); fclose(digest_file_cache_ptr); diff --git a/server/replay_cache.h b/server/replay_cache.h index a8d97ef8..1972f771 100644 --- a/server/replay_cache.h +++ b/server/replay_cache.h @@ -39,6 +39,7 @@ typedef struct digest_cache_info { time_t created; #if USE_FILE_CACHE char *digest; + unsigned int dst_ip; #else time_t first_replay; time_t last_replay;