diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.156 2008/07/04 23:08:25 djm Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.157 2008/07/10 18:08:11 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -147,6 +147,7 @@ static struct packet_state { | |||
147 | u_int32_t seqnr; | 147 | u_int32_t seqnr; |
148 | u_int32_t packets; | 148 | u_int32_t packets; |
149 | u_int64_t blocks; | 149 | u_int64_t blocks; |
150 | u_int64_t bytes; | ||
150 | } p_read, p_send; | 151 | } p_read, p_send; |
151 | 152 | ||
152 | static u_int64_t max_blocks_in, max_blocks_out; | 153 | static u_int64_t max_blocks_in, max_blocks_out; |
@@ -191,6 +192,7 @@ packet_set_connection(int fd_in, int fd_out) | |||
191 | buffer_init(&outgoing_packet); | 192 | buffer_init(&outgoing_packet); |
192 | buffer_init(&incoming_packet); | 193 | buffer_init(&incoming_packet); |
193 | TAILQ_INIT(&outgoing); | 194 | TAILQ_INIT(&outgoing); |
195 | p_send.packets = p_read.packets = 0; | ||
194 | } | 196 | } |
195 | } | 197 | } |
196 | 198 | ||
@@ -311,18 +313,25 @@ packet_get_ssh1_cipher(void) | |||
311 | } | 313 | } |
312 | 314 | ||
313 | void | 315 | void |
314 | packet_get_state(int mode, u_int32_t *seqnr, u_int64_t *blocks, u_int32_t *packets) | 316 | packet_get_state(int mode, u_int32_t *seqnr, u_int64_t *blocks, u_int32_t *packets, |
317 | u_int64_t *bytes) | ||
315 | { | 318 | { |
316 | struct packet_state *state; | 319 | struct packet_state *state; |
317 | 320 | ||
318 | state = (mode == MODE_IN) ? &p_read : &p_send; | 321 | state = (mode == MODE_IN) ? &p_read : &p_send; |
319 | *seqnr = state->seqnr; | 322 | if (seqnr) |
320 | *blocks = state->blocks; | 323 | *seqnr = state->seqnr; |
321 | *packets = state->packets; | 324 | if (blocks) |
325 | *blocks = state->blocks; | ||
326 | if (packets) | ||
327 | *packets = state->packets; | ||
328 | if (bytes) | ||
329 | *bytes = state->bytes; | ||
322 | } | 330 | } |
323 | 331 | ||
324 | void | 332 | void |
325 | packet_set_state(int mode, u_int32_t seqnr, u_int64_t blocks, u_int32_t packets) | 333 | packet_set_state(int mode, u_int32_t seqnr, u_int64_t blocks, u_int32_t packets, |
334 | u_int64_t bytes) | ||
326 | { | 335 | { |
327 | struct packet_state *state; | 336 | struct packet_state *state; |
328 | 337 | ||
@@ -330,6 +339,7 @@ packet_set_state(int mode, u_int32_t seqnr, u_int64_t blocks, u_int32_t packets) | |||
330 | state->seqnr = seqnr; | 339 | state->seqnr = seqnr; |
331 | state->blocks = blocks; | 340 | state->blocks = blocks; |
332 | state->packets = packets; | 341 | state->packets = packets; |
342 | state->bytes = bytes; | ||
333 | } | 343 | } |
334 | 344 | ||
335 | /* returns 1 if connection is via ipv4 */ | 345 | /* returns 1 if connection is via ipv4 */ |
@@ -608,7 +618,8 @@ packet_send1(void) | |||
608 | fprintf(stderr, "encrypted: "); | 618 | fprintf(stderr, "encrypted: "); |
609 | buffer_dump(&output); | 619 | buffer_dump(&output); |
610 | #endif | 620 | #endif |
611 | 621 | p_send.packets++; | |
622 | p_send.bytes += len + buffer_len(&outgoing_packet); | ||
612 | buffer_clear(&outgoing_packet); | 623 | buffer_clear(&outgoing_packet); |
613 | 624 | ||
614 | /* | 625 | /* |
@@ -834,6 +845,7 @@ packet_send2_wrapped(void) | |||
834 | if (!(datafellows & SSH_BUG_NOREKEY)) | 845 | if (!(datafellows & SSH_BUG_NOREKEY)) |
835 | fatal("XXX too many packets with same key"); | 846 | fatal("XXX too many packets with same key"); |
836 | p_send.blocks += (packet_length + 4) / block_size; | 847 | p_send.blocks += (packet_length + 4) / block_size; |
848 | p_send.bytes += packet_length + 4; | ||
837 | buffer_clear(&outgoing_packet); | 849 | buffer_clear(&outgoing_packet); |
838 | 850 | ||
839 | if (type == SSH2_MSG_NEWKEYS) | 851 | if (type == SSH2_MSG_NEWKEYS) |
@@ -1096,6 +1108,8 @@ packet_read_poll1(void) | |||
1096 | buffer_append(&incoming_packet, buffer_ptr(&compression_buffer), | 1108 | buffer_append(&incoming_packet, buffer_ptr(&compression_buffer), |
1097 | buffer_len(&compression_buffer)); | 1109 | buffer_len(&compression_buffer)); |
1098 | } | 1110 | } |
1111 | p_read.packets++; | ||
1112 | p_read.bytes += padded_len + 4; | ||
1099 | type = buffer_get_char(&incoming_packet); | 1113 | type = buffer_get_char(&incoming_packet); |
1100 | if (type < SSH_MSG_MIN || type > SSH_MSG_MAX) | 1114 | if (type < SSH_MSG_MIN || type > SSH_MSG_MAX) |
1101 | packet_disconnect("Invalid ssh1 packet type: %d", type); | 1115 | packet_disconnect("Invalid ssh1 packet type: %d", type); |
@@ -1184,6 +1198,7 @@ packet_read_poll2(u_int32_t *seqnr_p) | |||
1184 | if (!(datafellows & SSH_BUG_NOREKEY)) | 1198 | if (!(datafellows & SSH_BUG_NOREKEY)) |
1185 | fatal("XXX too many packets with same key"); | 1199 | fatal("XXX too many packets with same key"); |
1186 | p_read.blocks += (packet_length + 4) / block_size; | 1200 | p_read.blocks += (packet_length + 4) / block_size; |
1201 | p_read.bytes += packet_length + 4; | ||
1187 | 1202 | ||
1188 | /* get padlen */ | 1203 | /* get padlen */ |
1189 | cp = buffer_ptr(&incoming_packet); | 1204 | cp = buffer_ptr(&incoming_packet); |