A userspace application that filters DHCP floods to protect a DHCP server. It uses the Netfilter userspace packet queuing API.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dhcp_protect.h 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. typedef struct dp_conf {
  2. int pktint;
  3. int interval;
  4. int debug;
  5. int bltime;
  6. int queue;
  7. int dryrun;
  8. } dp_conf;
  9. typedef struct dp_accounting {
  10. unsigned char remoteid[256];
  11. int len;
  12. int count;
  13. UT_hash_handle hh;
  14. } dp_accounting;
  15. typedef struct dp_blacklist {
  16. unsigned char remoteid[256];
  17. int len;
  18. time_t expire;
  19. UT_hash_handle hh;
  20. } dp_blacklist;
  21. // global hash lists
  22. static dp_accounting *accountings = NULL;
  23. static dp_blacklist *blacklists = NULL;
  24. // timestamp for cleanup interval
  25. static time_t dp_accountingtime = 0;
  26. static time_t dp_cleanuptime = 0;
  27. static int dp_callback (
  28. struct nfq_q_handle*,
  29. struct nfgenmsg*,
  30. struct nfq_data*,
  31. void*);
  32. void usage (char*);
  33. int dhcp_check (struct nfq_data*, dp_conf*);
  34. dp_conf *load_config (dp_conf*, char*);
  35. void nfq_start (dp_conf*);
  36. void dp_accounting_add (dp_conf*, unsigned char *, int);
  37. int dp_accounting_check (dp_conf*, unsigned char *, int);
  38. void dp_blacklist_add (dp_conf*, unsigned char *, int);
  39. int dp_blacklist_check (dp_conf*, unsigned char *, int);
  40. void dp_hash_cleanup (dp_conf*);
  41. void dp_log (unsigned char *, int, char *, ...);