summaryrefslogtreecommitdiff
path: root/src/libstrongswan/chunk.h
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:42:46 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:42:46 +0000
commitde6b12502cdf42d5d92118f1c0e38dc31becf7c5 (patch)
tree0edac9c79f5a43e01913dd7f71c7abc487e5727b /src/libstrongswan/chunk.h
parent172642669d4a23e17f1ed411fbc8629dcaa5fb46 (diff)
downloadvyos-strongswan-de6b12502cdf42d5d92118f1c0e38dc31becf7c5.tar.gz
vyos-strongswan-de6b12502cdf42d5d92118f1c0e38dc31becf7c5.zip
Updated to new upstream release. interfaces Patch is not from upstream.
Diffstat (limited to 'src/libstrongswan/chunk.h')
-rw-r--r--src/libstrongswan/chunk.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/libstrongswan/chunk.h b/src/libstrongswan/chunk.h
index 66c3f26a2..a526f4a89 100644
--- a/src/libstrongswan/chunk.h
+++ b/src/libstrongswan/chunk.h
@@ -69,9 +69,11 @@ chunk_t chunk_create_clone(u_char *ptr, chunk_t chunk);
size_t chunk_length(const char *mode, ...);
/**
- * Concatenate chunks into a chunk pointing to "ptr",
- * "mode" is a string of "c" (copy) and "m" (move), which says
- * how to handle the chunks in "..."
+ * Concatenate chunks into a chunk pointing to "ptr".
+ *
+ * The mode string specifies the number of chunks, and how to handle each of
+ * them with a single character: 'c' for copy (allocate new chunk), 'm' for move
+ * (free given chunk) or 's' for sensitive-move (clear given chunk, then free).
*/
chunk_t chunk_create_cat(u_char *ptr, const char* mode, ...);
@@ -90,7 +92,7 @@ void chunk_split(chunk_t chunk, const char *mode, ...);
*
* @param chunk contents to write to file
* @param path path where file is written to
- * @param label label specifying file type
+ * @param label label specifying file type
* @param mask file mode creation mask
* @param force overwrite existing file by force
* @return TRUE if write operation was successful
@@ -167,9 +169,9 @@ static inline void chunk_clear(chunk_t *chunk)
}
/**
- * Initialize a chunk to point to buffer inspectable by sizeof()
+ * Initialize a chunk using a char array
*/
-#define chunk_from_buf(str) { str, sizeof(str) }
+#define chunk_from_chars(...) ((chunk_t){(char[]){__VA_ARGS__}, sizeof((char[]){__VA_ARGS__})})
/**
* Initialize a chunk to point to a thing
@@ -179,22 +181,22 @@ static inline void chunk_clear(chunk_t *chunk)
/**
* Allocate a chunk on the heap
*/
-#define chunk_alloc(bytes) chunk_create(malloc(bytes), bytes)
+#define chunk_alloc(bytes) ({size_t x = (bytes); chunk_create(malloc(x), x);})
/**
* Allocate a chunk on the stack
*/
-#define chunk_alloca(bytes) chunk_create(alloca(bytes), bytes)
+#define chunk_alloca(bytes) ({size_t x = (bytes); chunk_create(alloca(x), x);})
/**
* Clone a chunk on heap
*/
-#define chunk_clone(chunk) chunk_create_clone((chunk).len ? malloc((chunk).len) : NULL, chunk)
+#define chunk_clone(chunk) ({chunk_t x = (chunk); chunk_create_clone(x.len ? malloc(x.len) : NULL, x);})
/**
* Clone a chunk on stack
*/
-#define chunk_clonea(chunk) chunk_create_clone(alloca((chunk).len), chunk)
+#define chunk_clonea(chunk) ({chunk_t x = (chunk); chunk_create_clone(alloca(x.len), x);})
/**
* Concatenate chunks into a chunk on heap
@@ -237,6 +239,14 @@ static inline bool chunk_equals(chunk_t a, chunk_t b)
}
/**
+ * Increment a chunk, as it would reprensent a network order integer.
+ *
+ * @param chunk chunk to increment
+ * @return TRUE if an overflow occured
+ */
+bool chunk_increment(chunk_t chunk);
+
+/**
* Check if a chunk has printable characters only.
*
* If sane is given, chunk is cloned into sane and all non printable characters
@@ -263,8 +273,8 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash);
/**
* printf hook function for chunk_t.
*
- * Arguments are:
- * chunk_t *chunk
+ * Arguments are:
+ * chunk_t *chunk
* Use #-modifier to print a compact version
*/
int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,