File: ipq.py

package info (click to toggle)
pyroute2 0.8.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,700 kB
  • sloc: python: 50,245; makefile: 280; javascript: 183; ansic: 81; sh: 44; awk: 17
file content (18 lines) | stat: -rw-r--r-- 391 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from pyroute2.common import hexdump
from pyroute2 import IPQSocket
from pyroute2.netlink.ipq import NF_ACCEPT
from dpkt.ip import IP

ip = IPQSocket()
ip.bind()
try:
    while True:
        msg = ip.get()[0]
        print("\n")
        print(hexdump(msg.raw))
        print(repr(IP(msg['payload'])))
        ip.verdict(msg['packet_id'], NF_ACCEPT)
except:
    pass
finally:
    ip.release()