| 1720 | #endif |
| 1721 | |
| 1722 | void sipp_customize_socket(SIPpSocket *socket) |
| 1723 | { |
| 1724 | unsigned int buffsize = buff_size; |
| 1725 | |
| 1726 | /* Allows fast TCP reuse of the socket */ |
| 1727 | if (socket->ss_transport == T_TCP || socket->ss_transport == T_TLS || |
| 1728 | socket->ss_transport == T_SCTP) { |
| 1729 | int sock_opt = 1; |
| 1730 | |
| 1731 | if (setsockopt(socket->ss_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&sock_opt, |
| 1732 | sizeof (sock_opt)) == -1) { |
| 1733 | ERROR_NO("setsockopt(SO_REUSEADDR) failed"); |
| 1734 | } |
| 1735 | |
| 1736 | #ifdef USE_SCTP |
| 1737 | if (socket->ss_transport == T_SCTP) { |
| 1738 | struct sctp_event_subscribe event; |
| 1739 | memset(&event, 0, sizeof(event)); |
| 1740 | event.sctp_data_io_event = 1; |
| 1741 | event.sctp_association_event = 1; |
| 1742 | event.sctp_shutdown_event = 1; |
| 1743 | if (setsockopt(socket->ss_fd, IPPROTO_SCTP, SCTP_EVENTS, &event, |
| 1744 | sizeof(event)) == -1) { |
| 1745 | ERROR_NO("setsockopt(SCTP_EVENTS) failed, errno=%d", errno); |
| 1746 | } |
| 1747 | |
| 1748 | if (assocmaxret > 0) { |
| 1749 | struct sctp_assocparams associnfo; |
| 1750 | memset(&associnfo, 0, sizeof(associnfo)); |
| 1751 | associnfo.sasoc_asocmaxrxt = assocmaxret; |
| 1752 | if (setsockopt(socket->ss_fd, IPPROTO_SCTP, SCTP_ASSOCINFO, &associnfo, |
| 1753 | sizeof(associnfo)) == -1) { |
| 1754 | WARNING("setsockopt(SCTP_ASSOCINFO) failed, errno=%d", errno); |
| 1755 | } |
| 1756 | } |
| 1757 | |
| 1758 | if (setsockopt(socket->ss_fd, IPPROTO_SCTP, SCTP_NODELAY, |
| 1759 | (void *)&sock_opt, sizeof (sock_opt)) == -1) { |
| 1760 | WARNING("setsockopt(SCTP_NODELAY) failed, errno=%d", errno); |
| 1761 | } |
| 1762 | } |
| 1763 | #endif |
| 1764 | |
| 1765 | #ifndef SOL_TCP |
| 1766 | #define SOL_TCP 6 |
| 1767 | #endif |
| 1768 | if (socket->ss_transport != T_SCTP) { |
| 1769 | if (setsockopt(socket->ss_fd, SOL_TCP, TCP_NODELAY, (void *)&sock_opt, |
| 1770 | sizeof (sock_opt)) == -1) { |
| 1771 | { |
| 1772 | ERROR_NO("setsockopt(TCP_NODELAY) failed"); |
| 1773 | } |
| 1774 | } |
| 1775 | } |
| 1776 | |
| 1777 | { |
| 1778 | struct linger linger; |
| 1779 |
no test coverage detected