blob: 10e6bb0a6f570bd495edc797532c2cec775db413 [file] [log] [blame]
Lorenzo Colitti734b14e2021-02-05 23:56:09 +09001/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19// Common definitions for BPF code in the tethering mainline module.
20// These definitions are available to:
21// - The BPF programs in Tethering/bpf_progs/
22// - JNI code that depends on the bpf_tethering_headers library.
Lorenzo Colittib81584d2021-02-06 00:00:58 +090023
24#define BPF_TETHER_ERRORS \
25 ERR(INVALID_IP_VERSION) \
26 ERR(LOW_TTL) \
27 ERR(INVALID_TCP_HEADER) \
28 ERR(TCP_CONTROL_PACKET) \
29 ERR(NON_GLOBAL_SRC) \
30 ERR(NON_GLOBAL_DST) \
31 ERR(LOCAL_SRC_DST) \
32 ERR(NO_STATS_ENTRY) \
33 ERR(NO_LIMIT_ENTRY) \
Lorenzo Colittid561b7f2021-02-09 13:20:29 +090034 ERR(BELOW_IPV4_MTU) \
Lorenzo Colittib81584d2021-02-06 00:00:58 +090035 ERR(BELOW_IPV6_MTU) \
36 ERR(LIMIT_REACHED) \
37 ERR(CHANGE_HEAD_FAILED) \
Lorenzo Colitti72ec3ba2021-02-09 11:47:46 +090038 ERR(TOO_SHORT) \
Lorenzo Colittid561b7f2021-02-09 13:20:29 +090039 ERR(HAS_IP_OPTIONS) \
40 ERR(IS_IP_FRAG) \
41 ERR(CHECKSUM) \
42 ERR(NON_TCP_UDP) \
Maciej Żenczykowski36867352021-02-15 01:53:17 -080043 ERR(NON_TCP) \
Lorenzo Colittid561b7f2021-02-09 13:20:29 +090044 ERR(SHORT_TCP_HEADER) \
45 ERR(SHORT_UDP_HEADER) \
46 ERR(TRUNCATED_IPV4) \
Lorenzo Colittib81584d2021-02-06 00:00:58 +090047 ERR(_MAX)
48
49#define ERR(x) BPF_TETHER_ERR_ ##x,
50enum {
51 BPF_TETHER_ERRORS
52};
53#undef ERR
54
55#define ERR(x) #x,
56static const char *bpf_tether_errors[] = {
57 BPF_TETHER_ERRORS
58};
59#undef ERR