diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-08-13 12:07:52 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-08-13 12:07:52 +0200 |
commit | 09ae3d79ca0f1143736a0de45678915a3ebe5a3f (patch) | |
tree | d304e8e618450d0e4867dfc72e14ed575a442c20 /src/libstrongswan/bio/bio_writer.c | |
parent | e4ef4c9877d5ccb773ace0edf655351428c39572 (diff) | |
parent | efbb5e8c57330ec730825aa31ac5153f1d1c5913 (diff) | |
download | strongswan-09ae3d79ca0f1143736a0de45678915a3ebe5a3f.tar.bz2 strongswan-09ae3d79ca0f1143736a0de45678915a3ebe5a3f.tar.xz |
Merge branch 'android-app'
This branch introduces a userland IPsec implementation (libipsec) and an
Android App which targets the VpnService API that is provided by Android 4+.
The implementation is based on the bachelor thesis 'Userland IPsec for
Android 4' by Giuliano Grassi and Ralf Sager.
Diffstat (limited to 'src/libstrongswan/bio/bio_writer.c')
-rw-r--r-- | src/libstrongswan/bio/bio_writer.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libstrongswan/bio/bio_writer.c b/src/libstrongswan/bio/bio_writer.c index bf373d6ac..8576843ee 100644 --- a/src/libstrongswan/bio/bio_writer.c +++ b/src/libstrongswan/bio/bio_writer.c @@ -1,4 +1,7 @@ /* + * Copyright (C) 2012 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * * Copyright (C) 2010 Martin Willi * Copyright (C) 2010 revosec AG * @@ -199,12 +202,35 @@ METHOD(bio_writer_t, wrap32, void, this->used += 4; } +METHOD(bio_writer_t, skip, chunk_t, + private_bio_writer_t *this, size_t len) +{ + chunk_t skipped; + + while (this->used + len > this->buf.len) + { + increase(this); + } + skipped = chunk_create(this->buf.ptr + this->used, len); + this->used += len; + return skipped; +} + METHOD(bio_writer_t, get_buf, chunk_t, private_bio_writer_t *this) { return chunk_create(this->buf.ptr, this->used); } +METHOD(bio_writer_t, extract_buf, chunk_t, + private_bio_writer_t *this) +{ + chunk_t buf = get_buf(this); + this->buf = chunk_empty; + this->used = 0; + return buf; +} + METHOD(bio_writer_t, destroy, void, private_bio_writer_t *this) { @@ -235,7 +261,9 @@ bio_writer_t *bio_writer_create(u_int32_t bufsize) .wrap16 = _wrap16, .wrap24 = _wrap24, .wrap32 = _wrap32, + .skip = _skip, .get_buf = _get_buf, + .extract_buf = _extract_buf, .destroy = _destroy, }, .increase = bufsize ? max(bufsize, 4) : 32, |