+int
+vppcom_session_stream_connect (uint32_t session_handle,
+ uint32_t parent_session_handle)
+{
+ vcl_worker_t *wrk = vcl_worker_get_current ();
+ vcl_session_t *session, *parent_session;
+ u32 session_index, parent_session_index;
+ int rv;
+
+ session = vcl_session_get_w_handle (wrk, session_handle);
+ if (!session)
+ return VPPCOM_EBADFD;
+ parent_session = vcl_session_get_w_handle (wrk, parent_session_handle);
+ if (!parent_session)
+ return VPPCOM_EBADFD;
+
+ session_index = session->session_index;
+ parent_session_index = parent_session->session_index;
+ if (PREDICT_FALSE (session->is_vep))
+ {
+ VDBG (0, "ERROR: cannot connect epoll session %u!",
+ session->session_index);
+ return VPPCOM_EBADFD;
+ }
+
+ if (PREDICT_FALSE (session->session_state & CLIENT_STATE_OPEN))
+ {
+ VDBG (0, "session handle %u [0x%llx]: session already "
+ "connected to session %u [0x%llx] proto %s, state 0x%x (%s)",
+ session_handle, session->vpp_handle,
+ parent_session_handle, parent_session->vpp_handle,
+ vppcom_proto_str (session->session_type), session->session_state,
+ vppcom_session_state_str (session->session_state));
+ return VPPCOM_OK;
+ }
+
+ /* Connect to quic session specifics */
+ session->transport.is_ip4 = parent_session->transport.is_ip4;
+ session->transport.rmt_ip.ip4.as_u32 = (uint32_t) 1;
+ session->transport.rmt_port = 0;
+ session->transport_opts = parent_session->vpp_handle;
+
+ VDBG (0, "session handle %u: connecting to session %u [0x%llx]",
+ session_handle, parent_session_handle, parent_session->vpp_handle);
+
+ /*
+ * Send connect request and wait for reply from vpp
+ */
+ vppcom_send_connect_sock (session);
+ rv = vppcom_wait_for_session_state_change (session_index, STATE_CONNECT,
+ vcm->cfg.session_timeout);
+
+ session->listener_index = parent_session_index;
+ parent_session = vcl_session_get_w_handle (wrk, parent_session_handle);
+ parent_session->n_accepted_sessions++;
+
+ session = vcl_session_get (wrk, session_index);
+ VDBG (0, "session %u [0x%llx]: connect %s!", session->session_index,
+ session->vpp_handle, rv ? "failed" : "succeeded");
+
+ return rv;
+}
+