* Close one end of a full-duplex connection. */
| 2674 | * Close one end of a full-duplex connection. |
| 2675 | */ |
| 2676 | int |
| 2677 | lwip_shutdown(int s, int how) |
| 2678 | { |
| 2679 | struct lwip_sock *sock; |
| 2680 | err_t err; |
| 2681 | u8_t shut_rx = 0, shut_tx = 0; |
| 2682 | |
| 2683 | LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how)); |
| 2684 | |
| 2685 | sock = get_socket(s); |
| 2686 | if (!sock) { |
| 2687 | return -1; |
| 2688 | } |
| 2689 | |
| 2690 | if (sock->conn != NULL) { |
| 2691 | if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_TCP) { |
| 2692 | sock_set_errno(sock, EOPNOTSUPP); |
| 2693 | done_socket(sock); |
| 2694 | return -1; |
| 2695 | } |
| 2696 | } else { |
| 2697 | sock_set_errno(sock, ENOTCONN); |
| 2698 | done_socket(sock); |
| 2699 | return -1; |
| 2700 | } |
| 2701 | |
| 2702 | if (how == SHUT_RD) { |
| 2703 | shut_rx = 1; |
| 2704 | } else if (how == SHUT_WR) { |
| 2705 | shut_tx = 1; |
| 2706 | } else if (how == SHUT_RDWR) { |
| 2707 | shut_rx = 1; |
| 2708 | shut_tx = 1; |
| 2709 | } else { |
| 2710 | sock_set_errno(sock, EINVAL); |
| 2711 | done_socket(sock); |
| 2712 | return -1; |
| 2713 | } |
| 2714 | err = netconn_shutdown(sock->conn, shut_rx, shut_tx); |
| 2715 | |
| 2716 | sock_set_errno(sock, err_to_errno(err)); |
| 2717 | done_socket(sock); |
| 2718 | return (err == ERR_OK ? 0 : -1); |
| 2719 | } |
| 2720 | |
| 2721 | static int |
| 2722 | lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local) |