linux/include/net/af_vsock.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * VMware vSockets Driver
 *
 * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
 */

#ifndef __AF_VSOCK_H__
#define __AF_VSOCK_H__

#include <linux/kernel.h>
#include <linux/workqueue.h>
#include <net/sock.h>
#include <uapi/linux/vm_sockets.h>

#include "vsock_addr.h"

#define LAST_RESERVED_PORT

#define VSOCK_HASH_SIZE
extern struct list_head vsock_bind_table[VSOCK_HASH_SIZE + 1];
extern struct list_head vsock_connected_table[VSOCK_HASH_SIZE];
extern spinlock_t vsock_table_lock;

#define vsock_sk(__sk)
#define sk_vsock(__vsk)

struct vsock_sock {};

s64 vsock_connectible_has_data(struct vsock_sock *vsk);
s64 vsock_stream_has_data(struct vsock_sock *vsk);
s64 vsock_stream_has_space(struct vsock_sock *vsk);
struct sock *vsock_create_connected(struct sock *parent);
void vsock_data_ready(struct sock *sk);

/**** TRANSPORT ****/

struct vsock_transport_recv_notify_data {};

struct vsock_transport_send_notify_data {};

/* Transport features flags */
/* Transport provides host->guest communication */
#define VSOCK_TRANSPORT_F_H2G
/* Transport provides guest->host communication */
#define VSOCK_TRANSPORT_F_G2H
/* Transport provides DGRAM communication */
#define VSOCK_TRANSPORT_F_DGRAM
/* Transport provides local (loopback) communication */
#define VSOCK_TRANSPORT_F_LOCAL

struct vsock_transport {};

/**** CORE ****/

int vsock_core_register(const struct vsock_transport *t, int features);
void vsock_core_unregister(const struct vsock_transport *t);

/* The transport may downcast this to access transport-specific functions */
const struct vsock_transport *vsock_core_get_transport(struct vsock_sock *vsk);

/**** UTILS ****/

/* vsock_table_lock must be held */
static inline bool __vsock_in_bound_table(struct vsock_sock *vsk)
{}

/* vsock_table_lock must be held */
static inline bool __vsock_in_connected_table(struct vsock_sock *vsk)
{}

void vsock_add_pending(struct sock *listener, struct sock *pending);
void vsock_remove_pending(struct sock *listener, struct sock *pending);
void vsock_enqueue_accept(struct sock *listener, struct sock *connected);
void vsock_insert_connected(struct vsock_sock *vsk);
void vsock_remove_bound(struct vsock_sock *vsk);
void vsock_remove_connected(struct vsock_sock *vsk);
struct sock *vsock_find_bound_socket(struct sockaddr_vm *addr);
struct sock *vsock_find_connected_socket(struct sockaddr_vm *src,
					 struct sockaddr_vm *dst);
void vsock_remove_sock(struct vsock_sock *vsk);
void vsock_for_each_connected_socket(struct vsock_transport *transport,
				     void (*fn)(struct sock *sk));
int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk);
bool vsock_find_cid(unsigned int cid);

/**** TAP ****/

struct vsock_tap {};

int vsock_add_tap(struct vsock_tap *vt);
int vsock_remove_tap(struct vsock_tap *vt);
void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque);
int __vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
				int flags);
int vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
			      int flags);
int __vsock_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
			  size_t len, int flags);
int vsock_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
			size_t len, int flags);

#ifdef CONFIG_BPF_SYSCALL
extern struct proto vsock_proto;
int vsock_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore);
void __init vsock_bpf_build_proto(void);
#else
static inline void __init vsock_bpf_build_proto(void)
{}
#endif

static inline bool vsock_msgzerocopy_allow(const struct vsock_transport *t)
{}
#endif /* __AF_VSOCK_H__ */