codekingpro/portable-devtools
114k
1# -*- coding: utf-8 -*-2# Copyright (C) 2016 Fabio Falcinelli, Maximilian Hils3#4# This program is free software: you can redistribute it and/or modify5# it under the terms of the GNU Lesser General Public License as published by6# the Free Software Foundation, either version 3 of the License, or7# (at your option) any later version.8#9# This program is distributed in the hope that it will be useful,10# but WITHOUT ANY WARRANTY; without even the implied warranty of11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12# GNU Lesser General Public License for more details.13#14# You should have received a copy of the GNU Lesser General Public License15# along with this program. If not, see <http://www.gnu.org/licenses/>.16from enum import IntEnum17 18 19# Divert layers.20class Layer(IntEnum):21 """22 See https://reqrypt.org/windivert-doc.html#divert_open23 """24 NETWORK = 025 NETWORK_FORWARD = 126 27 28# Divert Flag.29class Flag(IntEnum):30 """31 See https://reqrypt.org/windivert-doc.html#divert_open32 """33 DEFAULT = 034 SNIFF = 135 DROP = 236 NO_CHECKSUM = 1024 # Deprecated since Windivert 1.237 38 39# Divert parameters.40class Param(IntEnum):41 """42 See https://reqrypt.org/windivert-doc.html#divert_set_param43 """44 QUEUE_LEN = 0 # Packet queue length 1 < default 512 (actually 1024) < 819245 QUEUE_TIME = 1 # Packet queue time 128 < default 512 < 204846 QUEUE_SIZE = 2 # Packet queue size (bytes) 4096 (4KB) < default 4194304 (4MB) < 33554432 (32MB)47 48 49# Direction outbound/inbound50class Direction(IntEnum):51 """52 See https://reqrypt.org/windivert-doc.html#divert_address53 """54 OUTBOUND = 055 INBOUND = 156 57 58# Checksums59class CalcChecksumsOption(IntEnum):60 """61 See https://reqrypt.org/windivert-doc.html#divert_helper_calc_checksums62 """63 NO_IP_CHECKSUM = 164 NO_ICMP_CHECKSUM = 265 NO_ICMPV6_CHECKSUM = 466 NO_TCP_CHECKSUM = 867 NO_UDP_CHECKSUM = 1668 NO_REPLACE = 204869 70 71class Protocol(IntEnum):72 """73 Transport protocol values define the layout of the header that will immediately follow the IPv4 or IPv6 header.74 See http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml75 """76 HOPOPT = 077 ICMP = 178 TCP = 679 UDP = 1780 ROUTING = 4381 FRAGMENT = 4482 AH = 5183 ICMPV6 = 5884 NONE = 5985 DSTOPTS = 6086 87 88IPV6_EXT_HEADERS = {89 Protocol.HOPOPT,90 Protocol.ROUTING,91 Protocol.FRAGMENT,92 Protocol.DSTOPTS,93 Protocol.AH,94}95 