Lines Matching refs:sock
129 struct sock { struct
131 RB_ENTRY(sock) socket_tree; /* tree of pcbs with socket */ argument
132 SLIST_ENTRY(sock) socket_list; /* list of pcbs w/o socket */
134 RB_ENTRY(sock) pcb_tree;
151 static RB_HEAD(socks_t, sock) socks = RB_INITIALIZER(&socks); argument
153 socket_compare(const struct sock *a, const struct sock *b) in socket_compare()
157 RB_GENERATE_STATIC(socks_t, sock, socket_tree, socket_compare);
159 static RB_HEAD(pcbs_t, sock) pcbs = RB_INITIALIZER(&pcbs);
161 pcb_compare(const struct sock *a, const struct sock *b) in pcb_compare()
165 RB_GENERATE_STATIC(pcbs_t, sock, pcb_tree, pcb_compare);
167 static SLIST_HEAD(, sock) nosocks = SLIST_HEAD_INITIALIZER(&nosocks);
366 free_socket(struct sock *sock) in free_socket() argument
370 cur = sock->laddr; in free_socket()
376 cur = sock->faddr; in free_socket()
382 free(sock); in free_socket()
388 struct sock *sock; in gather_sctp() local
424 if ((sock = calloc(1, sizeof *sock)) == NULL) in gather_sctp()
426 sock->socket = xinpcb->socket; in gather_sctp()
427 sock->proto = IPPROTO_SCTP; in gather_sctp()
428 sock->protoname = "sctp"; in gather_sctp()
430 sock->state = SCTP_CLOSED; in gather_sctp()
432 sock->state = SCTP_LISTEN; in gather_sctp()
434 sock->family = AF_INET6; in gather_sctp()
440 sock->vflag = INP_IPV6 | INP_IPV4; in gather_sctp()
442 sock->family = AF_INET; in gather_sctp()
443 sock->vflag = INP_IPV4; in gather_sctp()
480 sock->laddr = laddr; in gather_sctp()
485 if (sock->laddr == NULL) { in gather_sctp()
486 if ((sock->laddr = in gather_sctp()
489 sock->laddr->address.ss_family = sock->family; in gather_sctp()
490 if (sock->family == AF_INET) in gather_sctp()
491 sock->laddr->address.ss_len = in gather_sctp()
494 sock->laddr->address.ss_len = in gather_sctp()
498 if ((sock->faddr = calloc(1, sizeof(struct addr))) == NULL) in gather_sctp()
500 sock->faddr->address.ss_family = sock->family; in gather_sctp()
501 if (sock->family == AF_INET) in gather_sctp()
502 sock->faddr->address.ss_len = in gather_sctp()
505 sock->faddr->address.ss_len = in gather_sctp()
512 if (opt_l && (sock->vflag & vflag) && in gather_sctp()
516 RB_INSERT(socks_t, &socks, sock); in gather_sctp()
518 free_socket(sock); in gather_sctp()
525 if ((sock = calloc(1, sizeof *sock)) == NULL) in gather_sctp()
527 sock->socket = xinpcb->socket; in gather_sctp()
528 sock->proto = IPPROTO_SCTP; in gather_sctp()
529 sock->protoname = "sctp"; in gather_sctp()
530 sock->state = (int)xstcb->state; in gather_sctp()
532 sock->family = AF_INET6; in gather_sctp()
538 sock->vflag = INP_IPV6 | INP_IPV4; in gather_sctp()
540 sock->family = AF_INET; in gather_sctp()
541 sock->vflag = INP_IPV4; in gather_sctp()
584 sock->laddr = laddr; in gather_sctp()
631 sock->faddr = faddr; in gather_sctp()
637 if ((sock->vflag & vflag) && in gather_sctp()
641 RB_INSERT(socks_t, &socks, sock); in gather_sctp()
643 free_socket(sock); in gather_sctp()
660 struct sock *sock; in gather_inet() local
765 if ((sock = calloc(1, sizeof(*sock))) == NULL) in gather_inet()
771 sock->socket = so->xso_so; in gather_inet()
772 sock->splice_socket = so->so_splice_so; in gather_inet()
773 sock->proto = proto; in gather_inet()
774 sock->inp_gencnt = xip->inp_gencnt; in gather_inet()
776 sock->family = AF_INET; in gather_inet()
777 sockaddr(&laddr->address, sock->family, in gather_inet()
779 sockaddr(&faddr->address, sock->family, in gather_inet()
782 sock->family = AF_INET6; in gather_inet()
783 sockaddr(&laddr->address, sock->family, in gather_inet()
785 sockaddr(&faddr->address, sock->family, in gather_inet()
792 sock->laddr = laddr; in gather_inet()
793 sock->faddr = faddr; in gather_inet()
794 sock->vflag = xip->inp_vflag; in gather_inet()
796 sock->state = xtp->t_state; in gather_inet()
797 memcpy(sock->stack, xtp->xt_stack, in gather_inet()
799 memcpy(sock->cc, xtp->xt_cc, TCP_CA_NAME_MAX); in gather_inet()
801 sock->protoname = protoname; in gather_inet()
802 if (sock->socket != 0) in gather_inet()
803 RB_INSERT(socks_t, &socks, sock); in gather_inet()
805 SLIST_INSERT_HEAD(&nosocks, sock, socket_list); in gather_inet()
816 struct sock *sock; in gather_unix() local
875 if ((sock = calloc(1, sizeof(*sock))) == NULL) in gather_unix()
881 sock->socket = xup->xu_socket.xso_so; in gather_unix()
882 sock->pcb = xup->xu_unpp; in gather_unix()
883 sock->proto = proto; in gather_unix()
884 sock->family = AF_UNIX; in gather_unix()
885 sock->protoname = protoname; in gather_unix()
894 sock->laddr = laddr; in gather_unix()
895 sock->faddr = faddr; in gather_unix()
896 RB_INSERT(socks_t, &socks, sock); in gather_unix()
897 RB_INSERT(pcbs_t, &pcbs, sock); in gather_unix()
1018 check_ports(struct sock *s) in check_ports()
1106 displaysock(struct sock *s, int pos) in displaysock()
1156 struct sock *p; in displaysock()
1161 &(struct sock){ .pcb = faddr->conn }); in displaysock()
1181 struct sock *p; in displaysock()
1189 &(struct sock){ .pcb = ref })) != 0) { in displaysock()
1210 struct sock *sp; in displaysock()
1212 sp = RB_FIND(socks_t, &socks, &(struct sock) in displaysock()
1325 struct sock *s; in display()
1357 &(struct sock){ .socket = xf->xf_data}); in display()