Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/sys_socket.c
Show First 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) | ||||
struct sockaddr *sa; | struct sockaddr *sa; | ||||
struct inpcb *inpcb; | struct inpcb *inpcb; | ||||
struct unpcb *unpcb; | struct unpcb *unpcb; | ||||
struct socket *so; | struct socket *so; | ||||
int error; | int error; | ||||
kif->kf_type = KF_TYPE_SOCKET; | kif->kf_type = KF_TYPE_SOCKET; | ||||
so = fp->f_data; | so = fp->f_data; | ||||
kif->kf_sock_domain = so->so_proto->pr_domain->dom_family; | kif->kf_un.kf_sock.kf_sock_domain0 = | ||||
kif->kf_sock_type = so->so_type; | so->so_proto->pr_domain->dom_family; | ||||
kif->kf_sock_protocol = so->so_proto->pr_protocol; | kif->kf_un.kf_sock.kf_sock_type0 = so->so_type; | ||||
kif->kf_un.kf_sock.kf_sock_protocol0 = so->so_proto->pr_protocol; | |||||
kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; | kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; | ||||
switch (kif->kf_sock_domain) { | switch (kif->kf_un.kf_sock.kf_sock_domain0) { | ||||
case AF_INET: | case AF_INET: | ||||
case AF_INET6: | case AF_INET6: | ||||
if (kif->kf_sock_protocol == IPPROTO_TCP) { | if (kif->kf_un.kf_sock.kf_sock_protocol0 == IPPROTO_TCP) { | ||||
if (so->so_pcb != NULL) { | if (so->so_pcb != NULL) { | ||||
inpcb = (struct inpcb *)(so->so_pcb); | inpcb = (struct inpcb *)(so->so_pcb); | ||||
kif->kf_un.kf_sock.kf_sock_inpcb = | kif->kf_un.kf_sock.kf_sock_inpcb = | ||||
(uintptr_t)inpcb->inp_ppcb; | (uintptr_t)inpcb->inp_ppcb; | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case AF_UNIX: | case AF_UNIX: | ||||
if (so->so_pcb != NULL) { | if (so->so_pcb != NULL) { | ||||
unpcb = (struct unpcb *)(so->so_pcb); | unpcb = (struct unpcb *)(so->so_pcb); | ||||
if (unpcb->unp_conn) { | if (unpcb->unp_conn) { | ||||
kif->kf_un.kf_sock.kf_sock_unpconn = | kif->kf_un.kf_sock.kf_sock_unpconn = | ||||
(uintptr_t)unpcb->unp_conn; | (uintptr_t)unpcb->unp_conn; | ||||
kif->kf_un.kf_sock.kf_sock_rcv_sb_state = | kif->kf_un.kf_sock.kf_sock_rcv_sb_state = | ||||
so->so_rcv.sb_state; | so->so_rcv.sb_state; | ||||
kif->kf_un.kf_sock.kf_sock_snd_sb_state = | kif->kf_un.kf_sock.kf_sock_snd_sb_state = | ||||
so->so_snd.sb_state; | so->so_snd.sb_state; | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); | error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); | ||||
if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_local)) { | if (error == 0 && | ||||
bcopy(sa, &kif->kf_sa_local, sa->sa_len); | sa->sa_len <= sizeof(kif->kf_un.kf_sock.kf_sa_local)) { | ||||
bcopy(sa, &kif->kf_un.kf_sock.kf_sa_local, sa->sa_len); | |||||
free(sa, M_SONAME); | free(sa, M_SONAME); | ||||
} | } | ||||
error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa); | error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa); | ||||
if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_peer)) { | if (error == 0 && | ||||
bcopy(sa, &kif->kf_sa_peer, sa->sa_len); | sa->sa_len <= sizeof(kif->kf_un.kf_sock.kf_sa_peer)) { | ||||
bcopy(sa, &kif->kf_un.kf_sock.kf_sa_peer, sa->sa_len); | |||||
free(sa, M_SONAME); | free(sa, M_SONAME); | ||||
} | } | ||||
strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name, | strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name, | ||||
sizeof(kif->kf_path)); | sizeof(kif->kf_path)); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines |