diff options
author | Masaq- <tilt@techie.com> | 2019-02-20 03:46:50 +0000 |
---|---|---|
committer | Masaq- <tilt@techie.com> | 2019-02-20 03:46:50 +0000 |
commit | df3843984dac3f73f31f483ad86a7c24f6551337 (patch) | |
tree | f1dbdf36b28cf52377b1e17a9a1546d7763c1d73 | |
parent | 9b16f3b6fb3dd7684d1293d20f917c912943f069 (diff) |
variable length data section
-rw-r--r-- | src/ptunnel.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/ptunnel.c b/src/ptunnel.c index 3f5975d..3f12556 100644 --- a/src/ptunnel.c +++ b/src/ptunnel.c @@ -557,23 +557,29 @@ void* pt_proxy(void *args) { if (cur->state == kProxy_start) { pt_log(kLog_verbose, "Sending proxy request.\n"); cur->last_ack = time_as_double(); - uint16_t *extended_options = 0; + uint16_t extended_options[4]; size_t extended_options_size = 0; - if (opts.window_size || opts.ack_interval || opts.resend_interval || opts.payload_size) { - extended_options = calloc(4, sizeof(uint16_t)); - extended_options_size = 4*sizeof(uint16_t); + memset(extended_options, 0, sizeof(extended_options)); + if (opts.window_size) { + extended_options_size = sizeof(uint16_t); extended_options[0] = htons(opts.window_size); + } + if (opts.ack_interval) { + extended_options_size = 2*sizeof(uint16_t); extended_options[1] = htons(opts.ack_interval); + } + if (opts.resend_interval) { + extended_options_size = 3*sizeof(uint16_t); extended_options[2] = htons(opts.resend_interval); + } + if (opts.payload_size) { + extended_options_size = 4*sizeof(uint16_t); extended_options[3] = htons(opts.payload_size); } queue_packet(fwd_sock, cur->pkt_type, (char *)extended_options, extended_options_size, cur->id_no, cur->id_no, &cur->my_seq, cur->send_ring, &cur->send_idx, &cur->send_wait_ack, cur->dst_ip, cur->dst_port, cur->state | cur->type_flag, &cur->dest_addr, cur->next_remote_seq, &cur->send_first_ack, &cur->ping_seq, cur->window_size); - if (extended_options) { - free(extended_options); - } cur->xfer.icmp_out++; cur->state = kProto_data; } |