infa735-drawbridge/drawbridge/utils/lookup.py
2023-12-04 14:09:05 -08:00

33 lines
No EOL
1 KiB
Python

import socket
import iptc
PROTOCOLS = {
"ah": socket.IPPROTO_AH,
"dstopts": socket.IPPROTO_DSTOPTS,
"egp": socket.IPPROTO_EGP,
"esp": socket.IPPROTO_ESP,
"fragment": socket.IPPROTO_FRAGMENT,
"gre": socket.IPPROTO_GRE,
"hopopts": socket.IPPROTO_HOPOPTS,
"icmp": socket.IPPROTO_ICMP,
"icmpv6": socket.IPPROTO_ICMPV6,
"idp": socket.IPPROTO_IDP,
"igmp": socket.IPPROTO_IGMP,
"ip": socket.IPPROTO_IP,
"ipip": socket.IPPROTO_IPIP,
"ipv6": socket.IPPROTO_IPV6,
"none": socket.IPPROTO_NONE,
"pim": socket.IPPROTO_PIM,
"pup": socket.IPPROTO_PUP,
"raw": socket.IPPROTO_RAW,
"routing": socket.IPPROTO_ROUTING,
"rsvp": socket.IPPROTO_RSVP,
"sctp": socket.IPPROTO_SCTP,
"tcp": socket.IPPROTO_TCP,
"tp": socket.IPPROTO_TP,
"udp": socket.IPPROTO_UDP,
}
ALL_TABLES = [iptc.Table(t) for t in iptc.Table.ALL]
PREROUTING_MANGLE = iptc.Chain(iptc.Table(iptc.Table.MANGLE), "PREROUTING")
OUTGOING_MANGLE = iptc.Chain(iptc.Table(iptc.Table.FILTER), "OUTPUT")