Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/hvsock/hv_sock.c
Show First 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | hvs_find_socket_on_list(struct sockaddr_hvs *addr, unsigned char list) | ||||
return s; | return s; | ||||
} | } | ||||
static inline void | static inline void | ||||
hvs_addr_set(struct sockaddr_hvs *addr, unsigned int port) | hvs_addr_set(struct sockaddr_hvs *addr, unsigned int port) | ||||
{ | { | ||||
memset(addr, 0, sizeof(*addr)); | memset(addr, 0, sizeof(*addr)); | ||||
addr->sa_family = AF_HYPERV; | addr->sa_family = AF_HYPERV; | ||||
addr->sa_len = sizeof(*addr); | |||||
addr->hvs_port = port; | addr->hvs_port = port; | ||||
} | } | ||||
void | void | ||||
hvs_addr_init(struct sockaddr_hvs *addr, const struct hyperv_guid *svr_id) | hvs_addr_init(struct sockaddr_hvs *addr, const struct hyperv_guid *svr_id) | ||||
{ | { | ||||
hvs_addr_set(addr, get_port_by_srv_id(svr_id)); | hvs_addr_set(addr, get_port_by_srv_id(svr_id)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | hvs_trans_bind(struct socket *so, struct sockaddr *addr, struct thread *td) | ||||
} | } | ||||
if (sa->sa_family != AF_HYPERV) { | if (sa->sa_family != AF_HYPERV) { | ||||
HVSOCK_DBG(HVSOCK_DBG_ERR, | HVSOCK_DBG(HVSOCK_DBG_ERR, | ||||
"%s: Not supported, sa_family is %u\n", | "%s: Not supported, sa_family is %u\n", | ||||
__func__, sa->sa_family); | __func__, sa->sa_family); | ||||
return (EAFNOSUPPORT); | return (EAFNOSUPPORT); | ||||
} | } | ||||
if (sa->sa_len != sizeof(*sa)) { | |||||
HVSOCK_DBG(HVSOCK_DBG_ERR, | |||||
"%s: Not supported, sa_len is %u\n", | |||||
__func__, sa->sa_len); | |||||
return (EINVAL); | |||||
} | |||||
HVSOCK_DBG(HVSOCK_DBG_VERBOSE, | HVSOCK_DBG(HVSOCK_DBG_VERBOSE, | ||||
"%s: binding port = 0x%x\n", __func__, sa->hvs_port); | "%s: binding port = 0x%x\n", __func__, sa->hvs_port); | ||||
mtx_lock(&hvs_trans_socks_mtx); | mtx_lock(&hvs_trans_socks_mtx); | ||||
if (__hvs_find_socket_on_list(sa, | if (__hvs_find_socket_on_list(sa, | ||||
HVS_LIST_BOUND | HVS_LIST_CONNECTED)) { | HVS_LIST_BOUND | HVS_LIST_CONNECTED)) { | ||||
error = EADDRINUSE; | error = EADDRINUSE; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | hvs_trans_connect(struct socket *so, struct sockaddr *nam, struct thread *td) | ||||
if (pcb == NULL) | if (pcb == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
/* Verify the remote address */ | /* Verify the remote address */ | ||||
if (raddr == NULL) | if (raddr == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (raddr->sa_family != AF_HYPERV) | if (raddr->sa_family != AF_HYPERV) | ||||
return (EAFNOSUPPORT); | return (EAFNOSUPPORT); | ||||
if (raddr->sa_len != sizeof(*raddr)) | |||||
return (EINVAL); | |||||
mtx_lock(&hvs_trans_socks_mtx); | mtx_lock(&hvs_trans_socks_mtx); | ||||
if (so->so_state & | if (so->so_state & | ||||
(SS_ISCONNECTED|SS_ISDISCONNECTING|SS_ISCONNECTING)) { | (SS_ISCONNECTED|SS_ISDISCONNECTING|SS_ISCONNECTING)) { | ||||
HVSOCK_DBG(HVSOCK_DBG_ERR, | HVSOCK_DBG(HVSOCK_DBG_ERR, | ||||
"%s: socket connect in progress\n", | "%s: socket connect in progress\n", | ||||
__func__); | __func__); | ||||
error = EINPROGRESS; | error = EINPROGRESS; | ||||
▲ Show 20 Lines • Show All 1,233 Lines • Show Last 20 Lines |