FD.io VPP  v16.06
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  int socket;
26  struct sockaddr_in tx_addr;
28 
29 /* TCP catchup socket */
30 typedef struct {
31  int socket;
33 
37 
40 
41 typedef struct mc_socket_main_t {
43 
44  /* Multicast mastership/to-relay/from-relay sockets. */
46 
47  /* Unicast UDP ack sockets */
49 
50  /* TCP catchup server socket */
52 
53  /* Pool of stream-private catchup sockets */
55 
57 
59 
60  /* Receive MTU in bytes and VLIB buffers. */
62 
63  /* Vector of RX VLIB buffers. */
65  /* Vector of scatter/gather descriptors for sending/receiving VLIB buffers
66  via kernel. */
67  struct iovec * iovecs;
68 
69  /* IP address of interface to use for multicast. */
71 
74 
75  /* Interface on which to listen for multicasts. */
77 
78  /* Multicast address to use (e.g. 0xefff0000).
79  Host byte order. */
81 
82  /* TTL to use for multicasts. */
84 
85  /* Multicast ports for mastership, joins, etc. will be chosen
86  starting at the given port in host byte order.
87  A total of MC_N_TRANSPORT_TYPE ports will be used. */
90 
93 {
94  u32 a = ((i.as_u8[0] << 24)
95  | (i.as_u8[1] << 16)
96  | (i.as_u8[2] << 8)
97  | (i.as_u8[3] << 0));
98  return clib_host_to_net_u32 (a);
99 }
100 
103 { return clib_host_to_net_u16 ((i.as_u8[4] << 8) | i.as_u8[5]); }
104 
106 mc_socket_set_peer_id (u32 address_net_byte_order, u32 port_host_byte_order)
107 {
108  mc_peer_id_t i;
109  u32 a = ntohl (address_net_byte_order);
110  u32 p = port_host_byte_order;
111  i.as_u8[0] = (a >> 24) & 0xff;
112  i.as_u8[1] = (a >> 16) & 0xff;
113  i.as_u8[2] = (a >> 8) & 0xff;
114  i.as_u8[3] = (a >> 0) & 0xff;
115  i.as_u8[4] = (p >> 8) & 0xff;
116  i.as_u8[5] = (p >> 0) & 0xff;
117  i.as_u8[6] = 0;
118  i.as_u8[7] = 0;
119  return i;
120 }
121 
122 clib_error_t *
123 mc_socket_main_init (mc_socket_main_t * msm, char **intfc_probe_list,
124  int n_intfcs_to_probe);
125 #endif /* __included_mc_socket_h__ */
126 
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
int catchup_server_socket
Definition: mc_socket.h:51
a
Definition: bitmap.h:393
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:909
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:106
struct mc_socket_main_t mc_socket_main_t
struct iovec * iovecs
Definition: mc_socket.h:67
#define static_always_inline
Definition: clib.h:85
always_inline u32 mc_socket_peer_id_get_address(mc_peer_id_t i)
Definition: mc_socket.h:92
#define always_inline
Definition: clib.h:84
u32 * rx_buffers
Definition: mc_socket.h:64
mc_main_t mc_main
Definition: mc_socket.h:42
mc_socket_catchup_t * catchups
Definition: mc_socket.h:54
u32 base_multicast_udp_port_host_byte_order
Definition: mc_socket.h:88
uword * catchup_index_by_file_descriptor
Definition: mc_socket.h:56
u32 output_vector_n_written
Definition: mc_socket.h:36
u32 catchup_tcp_port
Definition: mc_socket.h:73
u8 as_u8[8]
Definition: mc.h:39
Definition: mc.h:521
unsigned int u32
Definition: types.h:88
u64 uword
Definition: types.h:112
always_inline u32 mc_socket_peer_id_get_port(mc_peer_id_t i)
Definition: mc_socket.h:102
unsigned char u8
Definition: types.h:56
u32 rx_mtu_n_buffers
Definition: mc_socket.h:61
u32 if_ip4_address_net_byte_order
Definition: mc_socket.h:70
u32 multicast_tx_ip4_address_host_byte_order
Definition: mc_socket.h:80
char * multicast_interface_name
Definition: mc_socket.h:76