Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iscsi/icl_soft_proxy.c
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 | * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 | ||||
*/ | */ | ||||
/* | /* | ||||
* iSCSI Common Layer, kernel proxy part. | * iSCSI Common Layer, kernel proxy part. | ||||
*/ | */ | ||||
#ifdef ICL_KERNEL_PROXY | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/kthread.h> | #include <sys/kthread.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/socketvar.h> | #include <sys/socketvar.h> | ||||
#include <sys/sx.h> | #include <sys/sx.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#include <dev/iscsi/icl.h> | #include <dev/iscsi/icl.h> | ||||
#include <dev/iscsi/icl_wrappers.h> | |||||
#ifdef ICL_KERNEL_PROXY | |||||
struct icl_listen_sock { | struct icl_listen_sock { | ||||
TAILQ_ENTRY(icl_listen_sock) ils_next; | TAILQ_ENTRY(icl_listen_sock) ils_next; | ||||
struct icl_listen *ils_listen; | struct icl_listen *ils_listen; | ||||
struct socket *ils_socket; | struct socket *ils_socket; | ||||
bool ils_running; | bool ils_running; | ||||
int ils_id; | int ils_id; | ||||
}; | }; | ||||
struct icl_listen { | struct icl_listen { | ||||
TAILQ_HEAD(, icl_listen_sock) il_sockets; | TAILQ_HEAD(, icl_listen_sock) il_sockets; | ||||
struct sx il_lock; | struct sx il_lock; | ||||
void (*il_accept)(struct socket *, | void (*il_accept)(struct socket *, | ||||
struct sockaddr *, int); | struct sockaddr *, int); | ||||
}; | }; | ||||
static MALLOC_DEFINE(M_ICL_PROXY, "ICL_PROXY", "iSCSI common layer proxy"); | static MALLOC_DEFINE(M_ICL_PROXY, "ICL_PROXY", "iSCSI common layer proxy"); | ||||
#endif /* ICL_KERNEL_PROXY */ | |||||
int | int | ||||
icl_soft_proxy_connect(struct icl_conn *ic, int domain, int socktype, | icl_soft_proxy_connect(struct icl_conn *ic, int domain, int socktype, | ||||
int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa) | int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa) | ||||
{ | { | ||||
struct socket *so; | struct socket *so; | ||||
int error; | int error; | ||||
error = socreate(domain, &so, socktype, protocol, | error = socreate(domain, &so, socktype, protocol, | ||||
Show All 28 Lines | icl_soft_proxy_connect(struct icl_conn *ic, int domain, int socktype, | ||||
} | } | ||||
SOCK_UNLOCK(so); | SOCK_UNLOCK(so); | ||||
if (error != 0) { | if (error != 0) { | ||||
soclose(so); | soclose(so); | ||||
return (error); | return (error); | ||||
} | } | ||||
error = icl_soft_handoff_sock(ic, so); | error = ICL_CONN_HANDOFF_SOCK(ic, so); | ||||
if (error != 0) | if (error != 0) | ||||
soclose(so); | soclose(so); | ||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef ICL_KERNEL_PROXY | |||||
struct icl_listen * | struct icl_listen * | ||||
icl_listen_new(void (*accept_cb)(struct socket *, struct sockaddr *, int)) | icl_listen_new(void (*accept_cb)(struct socket *, struct sockaddr *, int)) | ||||
{ | { | ||||
struct icl_listen *il; | struct icl_listen *il; | ||||
il = malloc(sizeof(*il), M_ICL_PROXY, M_ZERO | M_WAITOK); | il = malloc(sizeof(*il), M_ICL_PROXY, M_ZERO | M_WAITOK); | ||||
TAILQ_INIT(&il->il_sockets); | TAILQ_INIT(&il->il_sockets); | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |