Alexander Popovsky (apopovsk) | 4a7e58b | 2016-10-05 22:31:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | /** |
| 17 | * @file |
| 18 | * @brief Definitions for punt infrastructure. |
| 19 | */ |
| 20 | #ifndef included_punt_h |
| 21 | #define included_punt_h |
| 22 | |
Pavel Kotucek | e88865d | 2018-11-28 07:42:11 +0100 | [diff] [blame^] | 23 | #include <linux/un.h> |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 24 | #include <stdbool.h> |
| 25 | |
Alexander Popovsky (apopovsk) | 4a7e58b | 2016-10-05 22:31:23 -0700 | [diff] [blame] | 26 | typedef enum |
| 27 | { |
| 28 | #define punt_error(n,s) PUNT_ERROR_##n, |
| 29 | #include <vnet/ip/punt_error.def> |
| 30 | #undef punt_error |
| 31 | PUNT_N_ERROR, |
| 32 | } punt_error_t; |
| 33 | |
| 34 | |
| 35 | clib_error_t *vnet_punt_add_del (vlib_main_t * vm, u8 ipv, |
Ole Troan | f7a55ad | 2017-05-16 14:59:29 +0200 | [diff] [blame] | 36 | u8 protocol, u16 port, bool is_add); |
| 37 | clib_error_t *vnet_punt_socket_add (vlib_main_t * vm, u32 header_version, |
| 38 | bool is_ip4, u8 protocol, u16 port, |
| 39 | char *client_pathname); |
| 40 | clib_error_t *vnet_punt_socket_del (vlib_main_t * vm, bool is_ip4, |
| 41 | u8 l4_protocol, u16 port); |
| 42 | char *vnet_punt_get_server_pathname (void); |
Alexander Popovsky (apopovsk) | 4a7e58b | 2016-10-05 22:31:23 -0700 | [diff] [blame] | 43 | |
Ole Troan | f7a55ad | 2017-05-16 14:59:29 +0200 | [diff] [blame] | 44 | enum punt_action_e |
| 45 | { |
| 46 | PUNT_L2 = 0, |
| 47 | PUNT_IP4_ROUTED, |
| 48 | PUNT_IP6_ROUTED, |
| 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * Packet descriptor header. Version 1 |
| 53 | * If this header changes, the version must also change to notify clients. |
| 54 | */ |
| 55 | #define PUNT_PACKETDESC_VERSION 1 |
| 56 | typedef struct __attribute__ ((packed)) |
| 57 | { |
| 58 | u32 sw_if_index; /* RX or TX interface */ |
| 59 | enum punt_action_e action; |
| 60 | } punt_packetdesc_t; |
| 61 | |
| 62 | /* |
| 63 | * Client registration |
| 64 | */ |
| 65 | typedef struct |
| 66 | { |
Pavel Kotucek | e88865d | 2018-11-28 07:42:11 +0100 | [diff] [blame^] | 67 | u8 protocol; |
Ole Troan | f7a55ad | 2017-05-16 14:59:29 +0200 | [diff] [blame] | 68 | u16 port; |
| 69 | struct sockaddr_un caddr; |
| 70 | } punt_client_t; |
| 71 | |
| 72 | typedef struct |
| 73 | { |
| 74 | int socket_fd; |
| 75 | char sun_path[sizeof (struct sockaddr_un)]; |
| 76 | punt_client_t *clients_by_dst_port4; |
| 77 | punt_client_t *clients_by_dst_port6; |
Damjan Marion | 56dd543 | 2017-09-08 19:52:02 +0200 | [diff] [blame] | 78 | u32 clib_file_index; |
Ole Troan | f7a55ad | 2017-05-16 14:59:29 +0200 | [diff] [blame] | 79 | bool is_configured; |
| 80 | vlib_node_t *interface_output_node; |
| 81 | u32 *ready_fds; |
| 82 | u32 *rx_buffers; |
| 83 | } punt_main_t; |
| 84 | extern punt_main_t punt_main; |
| 85 | |
Pavel Kotucek | e88865d | 2018-11-28 07:42:11 +0100 | [diff] [blame^] | 86 | typedef struct punt_socket_detail_t_ |
| 87 | { |
| 88 | u8 ipv; |
| 89 | u8 l4_protocol; |
| 90 | u16 l4_port; |
| 91 | u8 pathname[108]; |
| 92 | } punt_socket_detail_t; |
| 93 | |
| 94 | punt_socket_detail_t *punt_socket_entries (u8 ipv); |
Ole Troan | f7a55ad | 2017-05-16 14:59:29 +0200 | [diff] [blame] | 95 | #endif |
Alexander Popovsky (apopovsk) | 4a7e58b | 2016-10-05 22:31:23 -0700 | [diff] [blame] | 96 | |
| 97 | /* |
| 98 | * fd.io coding-style-patch-verification: ON |
| 99 | * |
| 100 | * Local Variables: |
| 101 | * eval: (c-set-style "gnu") |
| 102 | * End: |
| 103 | */ |