This is an abstraction of a socket, which provides buffers for input and * output. */
| 66 | /* This is an abstraction of a socket, which provides buffers for input and |
| 67 | * output. */ |
| 68 | class SIPpSocket { |
| 69 | public: |
| 70 | SIPpSocket(bool use_ipv6, int transport, int fd, int accepting); |
| 71 | static SIPpSocket* new_sipp_call_socket(bool use_ipv6, int transport, bool *existing); |
| 72 | void set_bind_port(int bind_port); |
| 73 | |
| 74 | int connect(struct sockaddr_storage* dest = nullptr); |
| 75 | int reconnect(); |
| 76 | |
| 77 | // Reset a failed connection |
| 78 | void reset_connection(); |
| 79 | |
| 80 | // Accept new connections from a TCP socket |
| 81 | SIPpSocket* accept(); |
| 82 | |
| 83 | // Write data to the socket. |
| 84 | int write(const char *buffer, ssize_t len, int flags, struct sockaddr_storage *dest); |
| 85 | |
| 86 | // Empty data from the socket into our buffer |
| 87 | int empty(); |
| 88 | |
| 89 | // Decrement the reference count of this socket, shutting it down when it reaches 0 |
| 90 | void close(); |
| 91 | |
| 92 | int read_error(int ret); |
| 93 | |
| 94 | // Have we read a message from this socket? |
| 95 | bool message_ready() { return ss_msglen > 0; }; |
| 96 | |
| 97 | #ifdef SO_BINDTODEVICE |
| 98 | // Bind to specific network device. |
| 99 | int bind_to_device(const char* device_name); |
| 100 | #endif |
| 101 | |
| 102 | static void pollset_process(int wait); |
| 103 | |
| 104 | int ss_count = 1; /* How many users are there of this socket? */ |
| 105 | bool ss_ipv6 = false; |
| 106 | int ss_transport = 0; /* T_TCP, T_UDP, or T_TLS. */ |
| 107 | bool ss_control = false; /* Is this a control socket? */ |
| 108 | int ss_fd = -1; /* The underlying file descriptor for this socket. */ |
| 109 | int ss_port = 0; /* The port used by this socket */ |
| 110 | int ss_bind_port = 0; /* Optional local port used by this socket */ |
| 111 | void *ss_comp_state = nullptr; /* The compression state. */ |
| 112 | |
| 113 | bool ss_changed_dest = false; /* Has the destination changed from default. */ |
| 114 | struct sockaddr_storage ss_dest; /* Who we are talking to. */ |
| 115 | |
| 116 | private: |
| 117 | bool ss_congested = false; /* Is this socket congested? */ |
| 118 | bool ss_invalid = false; /* Has this socket been closed remotely? */ |
| 119 | |
| 120 | int handleSCTPNotify(char* buffer); |
| 121 | void sipp_sctp_peer_params(); |
| 122 | void invalidate(); |
| 123 | void buffer_read(struct socketbuf *newbuf); |
| 124 | void buffer_write(const char *buffer, size_t len, struct sockaddr_storage *dest); |
| 125 | ssize_t read_message(char *buf, size_t len, struct sockaddr_storage *src); |
nothing calls this directly
no outgoing calls
no test coverage detected