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.

37 lines
736 B

2 years ago
  1. #!/usr/bin/env python3
  2. # Dictionary of items we need to track to perform txid filtering
  3. """
  4. if c
  5. """
  6. requests = {}
  7. SADDR=0
  8. SPORT=1
  9. DADDR=2
  10. DPORT=3
  11. TXID=4
  12. def drop_packet():
  13. """ """
  14. return 0
  15. def send(skb):
  16. """ Emulate sending of a DNS request"""
  17. request[(skb[SADDR], skb[SPORT], skb[DADDR], skb[DPORT])] = [skb[TXID], 0]
  18. def receive(skb):
  19. """ Emulate receiving of a DNS response"""
  20. if skb[TXID] != request[(skb[DADDR], skb[DPORT], skb[SADDR], skb[SPORT])][0]:
  21. request[(skb[DADDR], skb[DPORT], skb[SADDR], skb[SPORT])][1] += 1
  22. if request[(skb[DADDR], skb[DPORT], skb[SADDR], skb[SPORT])][1] > threshold:
  23. drop_packet()
  24. def main():
  25. """
  26. """
  27. if __name__ == '__main__':
  28. main()