A userspace application that filters DHCP floods to protect a DHCP server. It uses the Netfilter userspace packet queuing API.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dhcp_protect.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 dp_usage (char*);
  33. dp_conf *dp_load_config (dp_conf*, char*);
  34. void dp_nfq_start (dp_conf*);
  35. void dp_accounting_add (dp_conf*, unsigned char *, int);
  36. int dp_accounting_check (dp_conf*, unsigned char *, int);
  37. void dp_blacklist_add (dp_conf*, unsigned char *, int);
  38. int dp_blacklist_check (dp_conf*, unsigned char *, int);
  39. void dp_hash_cleanup (dp_conf*);
  40. void dp_log (unsigned char *, int, char *, ...);
  41. int dp_dhcp_check (struct nfq_data*, dp_conf*);
  42. void dp_dhcpv4_check (
  43. dp_conf*,
  44. unsigned char*,
  45. int,
  46. int,
  47. unsigned char**,
  48. int*);
  49. void dp_dhcpv6_check (
  50. dp_conf*,
  51. unsigned char*,
  52. int,
  53. int,
  54. unsigned char**,
  55. int*);