blob: 9defa88178206eeb29d6d75722ae0f1fce666e11 [file] [log] [blame]
Alexander Popovsky (apopovsk)4a7e58b2016-10-05 22:31:23 -07001/*
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
Ole Troanf7a55ad2017-05-16 14:59:29 +020023#include <sys/un.h>
Alexander Popovsky (apopovsk)4a7e58b2016-10-05 22:31:23 -070024typedef enum
25{
26#define punt_error(n,s) PUNT_ERROR_##n,
27#include <vnet/ip/punt_error.def>
28#undef punt_error
29 PUNT_N_ERROR,
30} punt_error_t;
31
32
33clib_error_t *vnet_punt_add_del (vlib_main_t * vm, u8 ipv,
Ole Troanf7a55ad2017-05-16 14:59:29 +020034 u8 protocol, u16 port, bool is_add);
35clib_error_t *vnet_punt_socket_add (vlib_main_t * vm, u32 header_version,
36 bool is_ip4, u8 protocol, u16 port,
37 char *client_pathname);
38clib_error_t *vnet_punt_socket_del (vlib_main_t * vm, bool is_ip4,
39 u8 l4_protocol, u16 port);
40char *vnet_punt_get_server_pathname (void);
Alexander Popovsky (apopovsk)4a7e58b2016-10-05 22:31:23 -070041
Ole Troanf7a55ad2017-05-16 14:59:29 +020042enum punt_action_e
43{
44 PUNT_L2 = 0,
45 PUNT_IP4_ROUTED,
46 PUNT_IP6_ROUTED,
47};
48
49/*
50 * Packet descriptor header. Version 1
51 * If this header changes, the version must also change to notify clients.
52 */
53#define PUNT_PACKETDESC_VERSION 1
54typedef struct __attribute__ ((packed))
55{
56 u32 sw_if_index; /* RX or TX interface */
57 enum punt_action_e action;
58} punt_packetdesc_t;
59
60/*
61 * Client registration
62 */
63typedef struct
64{
65 u16 port;
66 struct sockaddr_un caddr;
67} punt_client_t;
68
69typedef struct
70{
71 int socket_fd;
72 char sun_path[sizeof (struct sockaddr_un)];
73 punt_client_t *clients_by_dst_port4;
74 punt_client_t *clients_by_dst_port6;
Damjan Marion56dd5432017-09-08 19:52:02 +020075 u32 clib_file_index;
Ole Troanf7a55ad2017-05-16 14:59:29 +020076 bool is_configured;
77 vlib_node_t *interface_output_node;
78 u32 *ready_fds;
79 u32 *rx_buffers;
80} punt_main_t;
81extern punt_main_t punt_main;
82
83#endif
Alexander Popovsky (apopovsk)4a7e58b2016-10-05 22:31:23 -070084
85/*
86 * fd.io coding-style-patch-verification: ON
87 *
88 * Local Variables:
89 * eval: (c-set-style "gnu")
90 * End:
91 */