Skip to content

Commit

Permalink
Merge pull request robertdavidgraham#244 from mzpqnxow/feature.dedup.…
Browse files Browse the repository at this point in the history
…20160728

[PATCH] FEATURE: Deduplicate ICMP like SYN/ACK and increase deduplication bucket size
  • Loading branch information
robertdavidgraham authored Jun 8, 2017
2 parents e0be8db + 92cca90 commit 7b452cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main-dedup.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <stdlib.h>
#include <string.h>

#define DEDUP_ENTRIES 4096
#define DEDUP_ENTRIES 65536 /* more aggressive deduplication */

struct DedupEntry
{
Expand Down
11 changes: 11 additions & 0 deletions src/proto-icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "output.h"
#include "masscan-status.h"
#include "templ-port.h"
#include "main-dedup.h"


/***************************************************************************
Expand Down Expand Up @@ -65,6 +66,13 @@ handle_icmp(struct Output *out, time_t timestamp,
unsigned ip_them;
unsigned cookie;

/* dedup ICMP echo replies as well as SYN/ACK replies */
static struct DedupTable *echo_reply_dedup = NULL;


if (!echo_reply_dedup)
echo_reply_dedup = dedup_create();

ip_me = parsed->ip_dst[0]<<24 | parsed->ip_dst[1]<<16
| parsed->ip_dst[2]<< 8 | parsed->ip_dst[3]<<0;
ip_them = parsed->ip_src[0]<<24 | parsed->ip_src[1]<<16
Expand All @@ -81,6 +89,9 @@ handle_icmp(struct Output *out, time_t timestamp,
if ((cookie & 0xFFFFFFFF) != seqno_me)
return; /* not my response */

if (dedup_is_duplicate(echo_reply_dedup, ip_them, 0, ip_me, 0))
break;

//if (syn_hash(ip_them, Templ_ICMP_echo) != seqno_me)
// return; /* not my response */

Expand Down

0 comments on commit 7b452cd

Please sign in to comment.