• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright 2015, 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  #ifndef APF_INTERPRETER_H_
18  #define APF_INTERPRETER_H_
19  
20  #include <stdint.h>
21  
22  #ifdef __cplusplus
23  extern "C" {
24  #endif
25  
26  /**
27   * Version of APF instruction set processed by accept_packet().
28   * Should be returned by wifi_get_packet_filter_info.
29   */
30  #define APF_VERSION 2
31  
32  /**
33   * Runs a packet filtering program over a packet.
34   *
35   * @param program the program bytecode.
36   * @param program_len the length of {@code apf_program} in bytes.
37   * @param packet the packet bytes, starting from the 802.3 header and not
38   *               including any CRC bytes at the end.
39   * @param packet_len the length of {@code packet} in bytes.
40   * @param filter_age the number of seconds since the filter was programmed.
41   *
42   * @return non-zero if packet should be passed to AP, zero if
43   *         packet should be dropped.
44   */
45  int accept_packet(const uint8_t* program, uint32_t program_len,
46                    const uint8_t* packet, uint32_t packet_len,
47                    uint32_t filter_age);
48  
49  #ifdef __cplusplus
50  }
51  #endif
52  
53  #endif  // APF_INTERPRETER_H_
54