Added dst IP to tracked SPA data
The digest cache now contains destination IP addresses of valid SPA packets. The complete format is now: <digest> <src_ip> <dst_ip> <creation time>
This commit is contained in:
parent
4197e51c9d
commit
6982a72c07
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user