Avoid proxy for bypass_socket, enable_udp_decap
[strongswan.git] / src / charon-tkm / src / tkm / tkm_utils.c
1 /*
2 * Copyright (C) 2012 Reto Buerki
3 * Copyright (C) 2012 Adrian-Ken Rueegsegger
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include "tkm_utils.h"
18
19 /* Generic variable-length sequence */
20 struct sequence_type {
21 uint32_t size;
22 byte_t data[];
23 };
24 typedef struct sequence_type sequence_type;
25
26 void sequence_to_chunk(const byte_t * const first, const uint32_t len,
27 chunk_t * const chunk)
28 {
29 *chunk = chunk_alloc(len);
30 memcpy(chunk->ptr, first, len);
31 }
32
33 void chunk_to_sequence(const chunk_t * const chunk, void *sequence)
34 {
35 sequence_type *seq = sequence;
36 seq->size = chunk->len;
37 memcpy(seq->data, chunk->ptr, seq->size);
38 }