FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
mc_socket.h
Go to the documentation of this file.
1 /*
2  * mc_socket.h: socket based multicast for vlib mc
3  *
4  * Copyright (c) 2010 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __included_mc_socket_h__
19 #define __included_mc_socket_h__
20 
21 #include <vlib/unix/unix.h>
22 #include <netinet/in.h>
23 
24 typedef struct
25 {
26  int socket;
27  struct sockaddr_in tx_addr;
29 
30 /* TCP catchup socket */
31 typedef struct
32 {
33  int socket;
35 
39 
42 
43 typedef struct mc_socket_main_t
44 {
45  mc_main_t mc_main;
46 
47  /* Multicast mastership/to-relay/from-relay sockets. */
49 
50  /* Unicast UDP ack sockets */
52 
53  /* TCP catchup server socket */
55 
56  /* Pool of stream-private catchup sockets */
58 
60 
62 
63  /* Receive MTU in bytes and VLIB buffers. */
65 
66  /* Vector of RX VLIB buffers. */
68  /* Vector of scatter/gather descriptors for sending/receiving VLIB buffers
69  via kernel. */
70  struct iovec *iovecs;
71 
72  /* IP address of interface to use for multicast. */
74 
77 
78  /* Interface on which to listen for multicasts. */
80 
81  /* Multicast address to use (e.g. 0xefff0000).
82  Host byte order. */
84 
85  /* TTL to use for multicasts. */
87 
88  /* Multicast ports for mastership, joins, etc. will be chosen
89  starting at the given port in host byte order.
90  A total of MC_N_TRANSPORT_TYPE ports will be used. */
93 
96 {
97  u32 a = ((i.as_u8[0] << 24)
98  | (i.as_u8[1] << 16) | (i.as_u8[2] << 8) | (i.as_u8[3] << 0));
99  return clib_host_to_net_u32 (a);
100 }
101 
104 {
105  return clib_host_to_net_u16 ((i.as_u8[4] << 8) | i.as_u8[5]);
106 }
107 
108 static_always_inline mc_peer_id_t
109 mc_socket_set_peer_id (u32 address_net_byte_order, u32 port_host_byte_order)
110 {
111  mc_peer_id_t i;
112  u32 a = ntohl (address_net_byte_order);
113  u32 p = port_host_byte_order;
114  i.as_u8[0] = (a >> 24) & 0xff;
115  i.as_u8[1] = (a >> 16) & 0xff;
116  i.as_u8[2] = (a >> 8) & 0xff;
117  i.as_u8[3] = (a >> 0) & 0xff;
118  i.as_u8[4] = (p >> 8) & 0xff;
119  i.as_u8[5] = (p >> 0) & 0xff;
120  i.as_u8[6] = 0;
121  i.as_u8[7] = 0;
122  return i;
123 }
124 
126  char **intfc_probe_list,
127  int n_intfcs_to_probe);
128 #endif /* __included_mc_socket_h__ */
129 
130 
131 /*
132  * fd.io coding-style-patch-verification: ON
133  *
134  * Local Variables:
135  * eval: (c-set-style "gnu")
136  * End:
137  */
mc_socket_main_t::multicast_interface_name
char * multicast_interface_name
Definition: mc_socket.h:79
mc_socket_main_t
Definition: mc_socket.h:43
mc_socket_main_t::catchup_tcp_port
u32 catchup_tcp_port
Definition: mc_socket.h:76
mc_socket_main_init
clib_error_t * mc_socket_main_init(mc_socket_main_t *msm, char **intfc_probe_list, int n_intfcs_to_probe)
Definition: mc_socket.c:980
mc_socket_main_t::multicast_ttl
u32 multicast_ttl
Definition: mc_socket.h:86
mc_socket_main_t::rx_mtu_n_bytes
u32 rx_mtu_n_bytes
Definition: mc_socket.h:61
mc_socket_main_t::catchup_server_socket
int catchup_server_socket
Definition: mc_socket.h:54
mc_multicast_socket_t::socket
int socket
Definition: mc_socket.h:26
mc_socket_main_t::mc_main
mc_main_t mc_main
Definition: mc_socket.h:45
mc_socket_main_t::iovecs
struct iovec * iovecs
Definition: mc_socket.h:70
mc_socket_catchup_t::connect_in_progress
u32 connect_in_progress
Definition: mc_socket.h:40
mc_socket_main_t::catchup_index_by_file_descriptor
uword * catchup_index_by_file_descriptor
Definition: mc_socket.h:59
static_always_inline
#define static_always_inline
Definition: clib.h:112
mc_socket_set_peer_id
static_always_inline mc_peer_id_t mc_socket_set_peer_id(u32 address_net_byte_order, u32 port_host_byte_order)
Definition: mc_socket.h:109
mc_socket_catchup_t
Definition: mc_socket.h:31
uword
u64 uword
Definition: types.h:112
mc_socket_catchup_t::output_vector_n_written
u32 output_vector_n_written
Definition: mc_socket.h:38
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
mc_multicast_socket_t
Definition: mc_socket.h:24
mc_socket_main_t::rx_mtu_n_buffers
u32 rx_mtu_n_buffers
Definition: mc_socket.h:64
mc_socket_main_t::base_multicast_udp_port_host_byte_order
u32 base_multicast_udp_port_host_byte_order
Definition: mc_socket.h:91
mc_socket_main_t::multicast_sockets
mc_multicast_socket_t multicast_sockets[MC_N_TRANSPORT_TYPE]
Definition: mc_socket.h:48
mc_socket_main_t::multicast_tx_ip4_address_host_byte_order
u32 multicast_tx_ip4_address_host_byte_order
Definition: mc_socket.h:83
mc_socket_catchup_t::socket
int socket
Definition: mc_socket.h:33
mc_socket_peer_id_get_address
static u32 mc_socket_peer_id_get_address(mc_peer_id_t i)
Definition: mc_socket.h:95
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
mc_socket_main_t::catchups
mc_socket_catchup_t * catchups
Definition: mc_socket.h:57
mc_socket_main_t
struct mc_socket_main_t mc_socket_main_t
mc_socket_peer_id_get_port
static u32 mc_socket_peer_id_get_port(mc_peer_id_t i)
Definition: mc_socket.h:103
u32
unsigned int u32
Definition: types.h:88
mc_socket_main_t::ack_socket
int ack_socket
Definition: mc_socket.h:51
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
mc_socket_catchup_t::output_vector
u8 * output_vector
Definition: mc_socket.h:37
a
a
Definition: bitmap.h:544
unix.h
mc_socket_catchup_t::input_vector
u8 * input_vector
Definition: mc_socket.h:36
mc_socket_main_t::rx_buffers
u32 * rx_buffers
Definition: mc_socket.h:67
mc_socket_catchup_t::clib_file_index
u32 clib_file_index
Definition: mc_socket.h:34
mc_socket_main_t::ack_udp_port
u32 ack_udp_port
Definition: mc_socket.h:75
mc_socket_main_t::if_ip4_address_net_byte_order
u32 if_ip4_address_net_byte_order
Definition: mc_socket.h:73