version 1.72, 2001/11/10 13:37:20 |
version 1.73, 2001/12/05 03:56:39 |
|
|
/* Returns 1 if remote host is connected via socket, 0 if not. */ |
/* Returns 1 if remote host is connected via socket, 0 if not. */ |
|
|
int |
int |
packet_connection_is_on_socket() |
packet_connection_is_on_socket(void) |
{ |
{ |
struct sockaddr_storage from, to; |
struct sockaddr_storage from, to; |
socklen_t fromlen, tolen; |
socklen_t fromlen, tolen; |
|
|
/* returns 1 if connection is via ipv4 */ |
/* returns 1 if connection is via ipv4 */ |
|
|
int |
int |
packet_connection_is_ipv4() |
packet_connection_is_ipv4(void) |
{ |
{ |
struct sockaddr_storage to; |
struct sockaddr_storage to; |
socklen_t tolen = sizeof(to); |
socklen_t tolen = sizeof(to); |
|
|
/* Sets the connection into non-blocking mode. */ |
/* Sets the connection into non-blocking mode. */ |
|
|
void |
void |
packet_set_nonblocking() |
packet_set_nonblocking(void) |
{ |
{ |
/* Set the socket into non-blocking mode. */ |
/* Set the socket into non-blocking mode. */ |
if (fcntl(connection_in, F_SETFL, O_NONBLOCK) < 0) |
if (fcntl(connection_in, F_SETFL, O_NONBLOCK) < 0) |
|
|
/* Returns the socket used for reading. */ |
/* Returns the socket used for reading. */ |
|
|
int |
int |
packet_get_connection_in() |
packet_get_connection_in(void) |
{ |
{ |
return connection_in; |
return connection_in; |
} |
} |
|
|
/* Returns the descriptor used for writing. */ |
/* Returns the descriptor used for writing. */ |
|
|
int |
int |
packet_get_connection_out() |
packet_get_connection_out(void) |
{ |
{ |
return connection_out; |
return connection_out; |
} |
} |
|
|
/* Closes the connection and clears and frees internal data structures. */ |
/* Closes the connection and clears and frees internal data structures. */ |
|
|
void |
void |
packet_close() |
packet_close(void) |
{ |
{ |
if (!initialized) |
if (!initialized) |
return; |
return; |
|
|
/* Returns the remote protocol flags set earlier by the above function. */ |
/* Returns the remote protocol flags set earlier by the above function. */ |
|
|
u_int |
u_int |
packet_get_protocol_flags() |
packet_get_protocol_flags(void) |
{ |
{ |
return remote_protocol_flags; |
return remote_protocol_flags; |
} |
} |
|
|
} |
} |
|
|
void |
void |
packet_send() |
packet_send(void) |
{ |
{ |
if (compat20) |
if (compat20) |
packet_send2(); |
packet_send2(); |
|
|
/* Returns a character from the packet. */ |
/* Returns a character from the packet. */ |
|
|
u_int |
u_int |
packet_get_char() |
packet_get_char(void) |
{ |
{ |
char ch; |
char ch; |
buffer_get(&incoming_packet, &ch, 1); |
buffer_get(&incoming_packet, &ch, 1); |
|
|
/* Returns an integer from the packet data. */ |
/* Returns an integer from the packet data. */ |
|
|
u_int |
u_int |
packet_get_int() |
packet_get_int(void) |
{ |
{ |
return buffer_get_int(&incoming_packet); |
return buffer_get_int(&incoming_packet); |
} |
} |
|
|
/* Checks if there is any buffered output, and tries to write some of the output. */ |
/* Checks if there is any buffered output, and tries to write some of the output. */ |
|
|
void |
void |
packet_write_poll() |
packet_write_poll(void) |
{ |
{ |
int len = buffer_len(&output); |
int len = buffer_len(&output); |
if (len > 0) { |
if (len > 0) { |
|
|
*/ |
*/ |
|
|
void |
void |
packet_write_wait() |
packet_write_wait(void) |
{ |
{ |
fd_set *setp; |
fd_set *setp; |
|
|
|
|
/* Returns true if there is buffered data to write to the connection. */ |
/* Returns true if there is buffered data to write to the connection. */ |
|
|
int |
int |
packet_have_data_to_write() |
packet_have_data_to_write(void) |
{ |
{ |
return buffer_len(&output) != 0; |
return buffer_len(&output) != 0; |
} |
} |
|
|
/* Returns true if there is not too much data to write to the connection. */ |
/* Returns true if there is not too much data to write to the connection. */ |
|
|
int |
int |
packet_not_very_much_data_to_write() |
packet_not_very_much_data_to_write(void) |
{ |
{ |
if (interactive_mode) |
if (interactive_mode) |
return buffer_len(&output) < 16384; |
return buffer_len(&output) < 16384; |
|
|
/* Returns true if the current connection is interactive. */ |
/* Returns true if the current connection is interactive. */ |
|
|
int |
int |
packet_is_interactive() |
packet_is_interactive(void) |
{ |
{ |
return interactive_mode; |
return interactive_mode; |
} |
} |