summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/packet.c b/packet.c
index 02b629f30..daae9ffaa 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.110 2003/09/19 09:02:02 markus Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.112 2003/09/23 20:17:11 markus Exp $");
41 41
42#include "openbsd-compat/sys-queue.h" 42#include "openbsd-compat/sys-queue.h"
43 43
@@ -165,8 +165,6 @@ packet_set_connection(int fd_in, int fd_out)
165 buffer_init(&incoming_packet); 165 buffer_init(&incoming_packet);
166 TAILQ_INIT(&outgoing); 166 TAILQ_INIT(&outgoing);
167 } 167 }
168 /* Kludge: arrange the close function to be called from fatal(). */
169 fatal_add_cleanup((void (*) (void *)) packet_close, NULL);
170} 168}
171 169
172/* Returns 1 if remote host is connected via socket, 0 if not. */ 170/* Returns 1 if remote host is connected via socket, 0 if not. */
@@ -306,7 +304,7 @@ packet_connection_is_ipv4(void)
306 if (to.ss_family == AF_INET) 304 if (to.ss_family == AF_INET)
307 return 1; 305 return 1;
308#ifdef IPV4_IN_IPV6 306#ifdef IPV4_IN_IPV6
309 if (to.ss_family == AF_INET6 && 307 if (to.ss_family == AF_INET6 &&
310 IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr)) 308 IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr))
311 return 1; 309 return 1;
312#endif 310#endif
@@ -870,7 +868,7 @@ packet_read_seqnr(u_int32_t *seqnr_p)
870 len = read(connection_in, buf, sizeof(buf)); 868 len = read(connection_in, buf, sizeof(buf));
871 if (len == 0) { 869 if (len == 0) {
872 logit("Connection closed by %.200s", get_remote_ipaddr()); 870 logit("Connection closed by %.200s", get_remote_ipaddr());
873 fatal_cleanup(); 871 cleanup_exit(255);
874 } 872 }
875 if (len < 0) 873 if (len < 0)
876 fatal("Read from socket failed: %.100s", strerror(errno)); 874 fatal("Read from socket failed: %.100s", strerror(errno));
@@ -1136,7 +1134,7 @@ packet_read_poll_seqnr(u_int32_t *seqnr_p)
1136 logit("Received disconnect from %s: %u: %.400s", 1134 logit("Received disconnect from %s: %u: %.400s",
1137 get_remote_ipaddr(), reason, msg); 1135 get_remote_ipaddr(), reason, msg);
1138 xfree(msg); 1136 xfree(msg);
1139 fatal_cleanup(); 1137 cleanup_exit(255);
1140 break; 1138 break;
1141 case SSH2_MSG_UNIMPLEMENTED: 1139 case SSH2_MSG_UNIMPLEMENTED:
1142 seqnr = packet_get_int(); 1140 seqnr = packet_get_int();
@@ -1161,7 +1159,7 @@ packet_read_poll_seqnr(u_int32_t *seqnr_p)
1161 msg = packet_get_string(NULL); 1159 msg = packet_get_string(NULL);
1162 logit("Received disconnect from %s: %.400s", 1160 logit("Received disconnect from %s: %.400s",
1163 get_remote_ipaddr(), msg); 1161 get_remote_ipaddr(), msg);
1164 fatal_cleanup(); 1162 cleanup_exit(255);
1165 xfree(msg); 1163 xfree(msg);
1166 break; 1164 break;
1167 default: 1165 default:
@@ -1338,8 +1336,7 @@ packet_disconnect(const char *fmt,...)
1338 1336
1339 /* Close the connection. */ 1337 /* Close the connection. */
1340 packet_close(); 1338 packet_close();
1341 1339 cleanup_exit(255);
1342 fatal_cleanup();
1343} 1340}
1344 1341
1345/* Checks if there is any buffered output, and tries to write some of the output. */ 1342/* Checks if there is any buffered output, and tries to write some of the output. */
@@ -1406,10 +1403,10 @@ packet_not_very_much_data_to_write(void)
1406} 1403}
1407 1404
1408 1405
1409#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
1410static void 1406static void
1411packet_set_tos(int interactive) 1407packet_set_tos(int interactive)
1412{ 1408{
1409#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
1413 int tos = interactive ? IPTOS_LOWDELAY : IPTOS_THROUGHPUT; 1410 int tos = interactive ? IPTOS_LOWDELAY : IPTOS_THROUGHPUT;
1414 1411
1415 if (!packet_connection_is_on_socket() || 1412 if (!packet_connection_is_on_socket() ||
@@ -1419,8 +1416,8 @@ packet_set_tos(int interactive)
1419 sizeof(tos)) < 0) 1416 sizeof(tos)) < 0)
1420 error("setsockopt IP_TOS %d: %.100s:", 1417 error("setsockopt IP_TOS %d: %.100s:",
1421 tos, strerror(errno)); 1418 tos, strerror(errno));
1422}
1423#endif 1419#endif
1420}
1424 1421
1425/* Informs that the current session is interactive. Sets IP flags for that. */ 1422/* Informs that the current session is interactive. Sets IP flags for that. */
1426 1423
@@ -1441,10 +1438,7 @@ packet_set_interactive(int interactive)
1441 return; 1438 return;
1442 if (interactive) 1439 if (interactive)
1443 set_nodelay(connection_in); 1440 set_nodelay(connection_in);
1444#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
1445 packet_set_tos(interactive); 1441 packet_set_tos(interactive);
1446#endif
1447
1448} 1442}
1449 1443
1450/* Returns true if the current connection is interactive. */ 1444/* Returns true if the current connection is interactive. */