dae/common/consts/ebpf.go

140 lines
2.9 KiB
Go
Raw Normal View History

2023-01-23 18:54:21 +07:00
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (c) 2022-2023, v2rayA Organization <team@v2raya.org>
2023-01-23 18:54:21 +07:00
*/
package consts
2023-02-11 20:34:49 +07:00
import (
internal "github.com/v2rayA/dae/pkg/ebpf_internal"
"strconv"
"strings"
2023-02-11 20:34:49 +07:00
)
2023-01-23 18:54:21 +07:00
const (
AppName = "dae"
BpfPinRoot = "/sys/fs/bpf"
2023-01-23 18:54:21 +07:00
AddrHdrSize = 20
TaskCommLen = 16
2023-01-23 18:54:21 +07:00
)
type ParamKey uint32
const (
2023-01-24 16:15:27 +07:00
ZeroKey ParamKey = iota
2023-01-23 18:54:21 +07:00
BigEndianTproxyPortKey
DisableL4TxChecksumKey
DisableL4RxChecksumKey
ControlPlanePidKey
ControlPlaneNatDirectKey
OneKey ParamKey = 1
2023-01-23 18:54:21 +07:00
)
type DisableL4ChecksumPolicy uint32
const (
DisableL4ChecksumPolicy_EnableL4Checksum DisableL4ChecksumPolicy = iota
DisableL4ChecksumPolicy_Restore
DisableL4ChecksumPolicy_SetZero
)
type MatchType uint8
2023-01-23 18:54:21 +07:00
const (
MatchType_DomainSet MatchType = iota
MatchType_IpSet
MatchType_SourceIpSet
MatchType_Port
MatchType_SourcePort
MatchType_L4Proto
MatchType_IpVersion
MatchType_Mac
MatchType_ProcessName
MatchType_Fallback
2023-01-23 18:54:21 +07:00
)
type OutboundIndex uint8
const (
OutboundDirect OutboundIndex = 0
2023-01-27 01:10:27 +07:00
OutboundBlock OutboundIndex = 1
2023-02-12 22:11:40 +07:00
OutboundMustDirect OutboundIndex = 0xFC
OutboundControlPlaneDirect OutboundIndex = 0xFD
OutboundLogicalOr OutboundIndex = 0xFE
OutboundLogicalAnd OutboundIndex = 0xFF
OutboundLogicalMask OutboundIndex = 0xFE
OutboundMax = OutboundLogicalAnd
2023-02-12 22:11:40 +07:00
OutboundUserDefinedMax = OutboundMustDirect - 1
2023-01-23 18:54:21 +07:00
)
func (i OutboundIndex) String() string {
switch i {
case OutboundDirect:
return "direct"
2023-01-27 01:10:27 +07:00
case OutboundBlock:
return "block"
2023-02-12 22:11:40 +07:00
case OutboundMustDirect:
return "must_direct"
case OutboundControlPlaneDirect:
return "<Control Plane Direct>"
case OutboundLogicalOr:
return "<OR>"
2023-01-23 18:54:21 +07:00
case OutboundLogicalAnd:
return "<AND>"
default:
return "<index: " + strconv.Itoa(int(i)) + ">"
2023-01-23 18:54:21 +07:00
}
}
func (i OutboundIndex) IsReserved() bool {
return !strings.HasPrefix(i.String(), "<index: ")
}
2023-01-23 18:54:21 +07:00
const (
MaxMatchSetLen = 32 * 3
2023-01-23 18:54:21 +07:00
)
type L4ProtoType uint8
2023-01-23 18:54:21 +07:00
const (
L4ProtoType_TCP L4ProtoType = 1
L4ProtoType_UDP L4ProtoType = 2
L4ProtoType_TCP_UDP L4ProtoType = 3
2023-01-23 18:54:21 +07:00
)
type IpVersionType uint8
2023-01-23 18:54:21 +07:00
const (
IpVersion_4 IpVersionType = 1
IpVersion_6 IpVersionType = 2
IpVersion_X IpVersionType = 3
2023-01-23 18:54:21 +07:00
)
2023-02-04 10:38:01 +07:00
var (
BasicFeatureVersion = internal.Version{5, 2, 0}
// Deprecated: Ftrace does not support arm64 yet (Linux 6.2).
FtraceFeatureVersion = internal.Version{5, 5, 0}
UserspaceBatchUpdateFeatureVersion = internal.Version{5, 6, 0}
CgSocketCookieFeatureVersion = internal.Version{5, 7, 0}
SkAssignFeatureVersion = internal.Version{5, 7, 0}
ChecksumFeatureVersion = internal.Version{5, 8, 0}
UserspaceBatchUpdateLpmTrieFeatureVersion = internal.Version{5, 13, 0}
2023-02-04 10:38:01 +07:00
)
const (
TproxyMark uint32 = 0x8000000
2023-02-07 20:11:12 +07:00
LoopbackIfIndex = 1
)
2023-02-12 20:50:15 +07:00
2023-02-13 11:54:04 +07:00
type LanWanFlag uint8
2023-02-12 20:50:15 +07:00
const (
2023-02-13 11:54:04 +07:00
LanWanFlag_IsWan LanWanFlag = iota
LanWanFlag_IsLan
LanWanFlag_NotApplicable
2023-02-12 20:50:15 +07:00
)