1
/*
2
 * Copyright 2018 Authors of Cilium
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
#ifndef PROXYLIB_TYPES_H
18
#define PROXYLIB_TYPES_H
19

            
20
#include <stdint.h>
21

            
22
typedef enum {
23
  FILTEROP_MORE,   // Need more data
24
  FILTEROP_PASS,   // Pass N bytes
25
  FILTEROP_DROP,   // Drop N bytes
26
  FILTEROP_INJECT, // Inject N>0 bytes
27
  FILTEROP_ERROR,  // Protocol parsing error
28
} FilterOpType;
29

            
30
typedef enum {
31
  FILTEROP_ERROR_INVALID_OP_LENGTH = 1,   // Parser returned invalid operation length
32
  FILTEROP_ERROR_INVALID_FRAME_TYPE,
33
  FILTEROP_ERROR_INVALID_FRAME_LENGTH,
34
} FilterOpError;
35

            
36
typedef struct {
37
  uint64_t op;      // FilterOpType
38
  int64_t  n_bytes; // >0
39
} FilterOp;
40

            
41
typedef enum {
42
  FILTER_OK,                 // Operation was successful
43
  FILTER_POLICY_DROP,        // Connection needs to be dropped due to (L3/L4) policy
44
  FILTER_PARSER_ERROR,       // Connection needs to be dropped due to parser error
45
  FILTER_UNKNOWN_PARSER,     // Connection needs to be dropped due to unknown parser
46
  FILTER_UNKNOWN_CONNECTION, // Connection needs to be dropped due to it being unknown
47
  FILTER_INVALID_ADDRESS,    // Destination address in invalid format
48
  FILTER_INVALID_INSTANCE,   // Destination address in invalid format
49
  FILTER_UNKNOWN_ERROR,      // Error type could not be cast to an error code
50
} FilterResult;
51

            
52
#endif