| 2084 | #endif |
| 2085 | |
| 2086 | ssize_t SIPpSocket::write_primitive(const char* buffer, size_t len, |
| 2087 | struct sockaddr_storage* dest) |
| 2088 | { |
| 2089 | ssize_t rc; |
| 2090 | |
| 2091 | /* Refuse to write to invalid sockets. */ |
| 2092 | if (ss_invalid) { |
| 2093 | WARNING("Returning EPIPE on invalid socket: %p (%d)", _RCAST(void*, this), ss_fd); |
| 2094 | errno = EPIPE; |
| 2095 | return -1; |
| 2096 | } |
| 2097 | |
| 2098 | /* Always check congestion before sending. */ |
| 2099 | if (ss_congested) { |
| 2100 | errno = EWOULDBLOCK; |
| 2101 | return -1; |
| 2102 | } |
| 2103 | |
| 2104 | switch(ss_transport) { |
| 2105 | case T_TLS: |
| 2106 | #if defined(USE_OPENSSL) || defined(USE_WOLFSSL) |
| 2107 | rc = send_nowait_tls(ss_ssl, buffer, len, 0); |
| 2108 | #else |
| 2109 | errno = EOPNOTSUPP; |
| 2110 | rc = -1; |
| 2111 | #endif |
| 2112 | break; |
| 2113 | case T_SCTP: |
| 2114 | #ifdef USE_SCTP |
| 2115 | TRACE_MSG("socket_write_primitive %d\n", sctpstate); |
| 2116 | if (sctpstate == SCTP_DOWN) { |
| 2117 | errno = EPIPE; |
| 2118 | return -1; |
| 2119 | } else if (sctpstate == SCTP_CONNECTING) { |
| 2120 | errno = EWOULDBLOCK; |
| 2121 | return -1; |
| 2122 | } |
| 2123 | rc = send_sctp_nowait(ss_fd, buffer, len, 0); |
| 2124 | #else |
| 2125 | errno = EOPNOTSUPP; |
| 2126 | rc = -1; |
| 2127 | #endif |
| 2128 | break; |
| 2129 | case T_TCP: |
| 2130 | rc = send_nowait(ss_fd, buffer, len, 0); |
| 2131 | break; |
| 2132 | |
| 2133 | case T_UDP: |
| 2134 | if (compression) { |
| 2135 | static char comp_msg[SIPP_MAX_MSG_SIZE]; |
| 2136 | strncpy(comp_msg, buffer, sizeof(comp_msg) - 1); |
| 2137 | if (comp_compress(&ss_comp_state, |
| 2138 | comp_msg, |
| 2139 | (unsigned int *) &len) != COMP_OK) { |
| 2140 | ERROR("Compression plugin error"); |
| 2141 | } |
| 2142 | buffer = (char *)comp_msg; |
| 2143 |
nothing calls this directly
no test coverage detected