/* bvirt_ns.h * * Copyright 2009 Benjamin C. R. LaHaise, All Rights Reserved. * Permission is hereby granted to copy under the terms of the GPLv2 * or later. See the file LICENSE for details. */ #include class bvirt_ns_t; typedef int (bvirt_ns_t::*bvirt_ns_rpc2_t)(void *arg1, void *arg2); struct bvirt_ns_rpc { bvirt_ns_rpc2_t func; void *arg1; void *arg2; int reply_fd; }; class bnetlink_t; class bvirt_ns_t { public: bvirt_ns_t(ctrlfd_t *cfd, const char *name); ~bvirt_ns_t(); int sendrpc(bvirt_ns_rpc2_t func, void *arg1, void *arg2, int sync=0); int system_rpc(void *arg1, void *arg2); int l2tpctl_rpc(void *arg1, void *arg2); void *start(void); /* main virt namespace thread */ ctrlfd_t *m_cfd; char *m_name; int m_index; int m_tid; pthread_t m_pthread; int m_pipefds[2]; int m_b_sock_fd; int m_nr_ifaces; bnetlink_t *m_netlink; /* useful rpc operations */ int socket_rpc(int domain, int type, int proto); int sendto_rpc(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dst, socklen_t addrlen); int generic_rpc(int (*fn)(void *arg1, void *arg2), void *arg1, void *arg2, int sync); private: int rpc_socket_rpc(void *arg1, void *arg2); int rpc_sendto_rpc(void *arg1, void *arg2); int rpc_init_rpc(void *arg1, void *arg2); int rpc_generic_rpc(void *arg1, void *arg2); }; bvirt_ns_t *lookup_bvirt_ns(const char *name); int bvirt_parse_ns(ctrlfd_t *cfd, char **strp, bvirt_ns_t **netnsp); int netns_socket(bvirt_ns_t *netns, int domain, int type, int proto); bvirt_ns_t *lookup_bvirt_iface_virt_realm(const char *domain, int *idxp = NULL); void bvirt_show_running_global_config(ctrlfd_t *cfd);