summaryrefslogtreecommitdiff
path: root/src/pluto/db_ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pluto/db_ops.c')
-rw-r--r--src/pluto/db_ops.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/pluto/db_ops.c b/src/pluto/db_ops.c
index 4ba4fa324..547ea5f22 100644
--- a/src/pluto/db_ops.c
+++ b/src/pluto/db_ops.c
@@ -1,6 +1,6 @@
/* Dynamic db (proposal, transforms, attributes) handling.
* Author: JuanJo Ciarlante <jjo-ipsec@mendoza.gov.ar>
- *
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
@@ -12,11 +12,11 @@
* for more details.
*/
-/*
+/*
* The stratedy is to have (full contained) struct db_prop in db_context
* pointing to ONE dynamically sizable transform vector (trans0).
* Each transform stores attrib. in ONE dyn. sizable attribute vector (attrs0)
- * in a "serialized" way (attributes storage is used in linear sequence for
+ * in a "serialized" way (attributes storage is used in linear sequence for
* subsecuent transforms).
*
* Resizing for both trans0 and attrs0 is supported:
@@ -24,7 +24,7 @@
* also update trans_cur (by offset)
* - For attrs0: after allocating and copying attrs, I must rewrite each
* trans->attrs present in trans0; to achieve this, calculate
- * attrs pointer offset (new minus old) and iterate over
+ * attrs pointer offset (new minus old) and iterate over
* each transform "adding" this difference.
* also update attrs_cur (by offset)
*
@@ -70,7 +70,7 @@
#ifdef NOT_YET
/*
* Allocator cache:
- * Because of the single-threaded nature of pluto/spdb.c,
+ * Because of the single-threaded nature of pluto/spdb.c,
* alloc()/free() is exercised many times with very small
* lifetime objects.
* Just caching last object (currently it will select the
@@ -84,9 +84,9 @@ struct db_ops_alloc_cache {
#endif
#ifndef NO_DB_OPS_STATS
-/*
- * stats: do account for allocations
- * displayed in db_ops_show_status()
+/*
+ * stats: do account for allocations
+ * displayed in db_ops_show_status()
*/
struct db_ops_stats {
int st_curr_cnt; /* current number of allocations */
@@ -100,7 +100,7 @@ struct db_ops_stats {
static struct db_ops_stats db_context_st = DB_OPS_ZERO;
static struct db_ops_stats db_trans_st = DB_OPS_ZERO;
static struct db_ops_stats db_attrs_st = DB_OPS_ZERO;
-static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st)
+static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st)
{
void *ptr = malloc(size);
if (ptr)
@@ -108,7 +108,7 @@ static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st)
st->st_curr_cnt++;
st->st_total_cnt++;
if (size > st->st_maxsz) st->st_maxsz=size;
- }
+ }
return ptr;
}
#define ALLOC_BYTES_ST(z,st) malloc_bytes_st(z, &st);
@@ -125,13 +125,13 @@ static __inline__ void *malloc_bytes_st(size_t size, struct db_ops_stats *st)
* as a result of "add" operations
*/
int
-db_prop_init(struct db_context *ctx, u_int8_t protoid, int max_trans, int max_attrs)
+db_prop_init(struct db_context *ctx, u_int8_t protoid, int max_trans, int max_attrs)
{
ctx->trans0 = NULL;
ctx->attrs0 = NULL;
if (max_trans > 0) { /* quite silly if not */
- ctx->trans0 = ALLOC_BYTES_ST ( sizeof(struct db_trans) * max_trans,
+ ctx->trans0 = ALLOC_BYTES_ST ( sizeof(struct db_trans) * max_trans,
db_trans_st);
memset(ctx->trans0, '\0', sizeof(struct db_trans) * max_trans);
}
@@ -162,12 +162,12 @@ db_trans_expand(struct db_context *ctx, int delta_trans)
int offset;
old_trans = ctx->trans0;
- new_trans = ALLOC_BYTES_ST ( sizeof (struct db_trans) * max_trans,
+ new_trans = ALLOC_BYTES_ST ( sizeof (struct db_trans) * max_trans,
db_trans_st);
if (!new_trans)
goto out;
memcpy(new_trans, old_trans, ctx->max_trans * sizeof(struct db_trans));
-
+
/* update trans0 (obviously) */
ctx->trans0 = ctx->prop.trans = new_trans;
/* update trans_cur (by offset) */
@@ -175,7 +175,7 @@ db_trans_expand(struct db_context *ctx, int delta_trans)
{
char *cctx = (char *)(ctx->trans_cur);
-
+
cctx += offset;
ctx->trans_cur = (struct db_trans *)cctx;
}
@@ -186,7 +186,7 @@ db_trans_expand(struct db_context *ctx, int delta_trans)
out:
return ret;
}
-/*
+/*
* Expand storage for attributes by delta_attrs number AND
* rewrite trans->attr pointers
*/
@@ -201,22 +201,22 @@ db_attrs_expand(struct db_context *ctx, int delta_attrs)
int offset;
old_attrs = ctx->attrs0;
- new_attrs = ALLOC_BYTES_ST ( sizeof (struct db_attr) * max_attrs,
+ new_attrs = ALLOC_BYTES_ST ( sizeof (struct db_attr) * max_attrs,
db_attrs_st);
if (!new_attrs)
goto out;
memcpy(new_attrs, old_attrs, ctx->max_attrs * sizeof(struct db_attr));
-
+
/* update attrs0 and attrs_cur (obviously) */
offset = (char *)(new_attrs) - (char *)(old_attrs);
-
+
{
char *actx = (char *)(ctx->attrs0);
-
+
actx += offset;
ctx->attrs0 = (struct db_attr *)actx;
-
+
actx = (char *)ctx->attrs_cur;
actx += offset;
ctx->attrs_cur = (struct db_attr *)actx;
@@ -237,13 +237,13 @@ out:
return ret;
}
/* Allocate a new db object */
-struct db_context *
-db_prop_new(u_int8_t protoid, int max_trans, int max_attrs)
+struct db_context *
+db_prop_new(u_int8_t protoid, int max_trans, int max_attrs)
{
struct db_context *ctx;
ctx = ALLOC_BYTES_ST ( sizeof (struct db_context), db_context_st);
if (!ctx) goto out;
-
+
if (db_prop_init(ctx, protoid, max_trans, max_attrs) < 0) {
PFREE_ST(ctx, db_context_st);
ctx=NULL;
@@ -266,8 +266,8 @@ db_trans_add(struct db_context *ctx, u_int8_t transid)
/* skip incrementing current trans pointer the 1st time*/
if (ctx->trans_cur && ctx->trans_cur->attr_cnt)
ctx->trans_cur++;
- /*
- * Strategy: if more space is needed, expand by
+ /*
+ * Strategy: if more space is needed, expand by
* <current_size>/2 + 1
*
* This happens to produce a "reasonable" sequence
@@ -287,10 +287,10 @@ db_trans_add(struct db_context *ctx, u_int8_t transid)
}
/* Add attr copy to current transform, expanding attrs0 if needed */
int
-db_attr_add(struct db_context *ctx, const struct db_attr *a)
+db_attr_add(struct db_context *ctx, const struct db_attr *a)
{
- /*
- * Strategy: if more space is needed, expand by
+ /*
+ * Strategy: if more space is needed, expand by
* <current_size>/2 + 1
*/
if ((ctx->attrs_cur - ctx->attrs0) >= ctx->max_attrs) {
@@ -302,7 +302,7 @@ db_attr_add(struct db_context *ctx, const struct db_attr *a)
ctx->trans_cur->attr_cnt++;
return 0;
}
-/* Add attr copy (by value) to current transform,
+/* Add attr copy (by value) to current transform,
* expanding attrs0 if needed, just calls db_attr_add().
*/
int
@@ -317,7 +317,7 @@ db_attr_add_values(struct db_context *ctx, u_int16_t type, u_int16_t val)
int
db_ops_show_status(void)
{
- whack_log(RC_COMMENT, "stats " __FILE__ ": "
+ whack_log(RC_COMMENT, "stats " __FILE__ ": "
DB_OPS_STATS_DESC " :"
DB_OPS_STATS_STR("context")
DB_OPS_STATS_STR("trans")
@@ -329,7 +329,7 @@ db_ops_show_status(void)
return 0;
}
#endif /* NO_DB_OPS_STATS */
-/*
+/*
* From below to end just testing stuff ....
*/
#ifdef TEST
@@ -349,7 +349,7 @@ static void db_prop_print(struct db_prop *p)
default:
continue;
}
- printf(" transid=\"%s\"\n",
+ printf(" transid=\"%s\"\n",
enum_name(n, t->transid));
for (ai=0, a=t->attrs; ai < t->attr_cnt; ai++, a++) {
int i;
@@ -367,16 +367,16 @@ static void db_prop_print(struct db_prop *p)
default:
continue;
}
- printf(" type=\"%s\" value=\"%s\"\n",
+ printf(" type=\"%s\" value=\"%s\"\n",
enum_name(n_at, i),
enum_name(n_av, a->val));
}
}
}
-static void db_print(struct db_context *ctx)
+static void db_print(struct db_context *ctx)
{
- printf("trans_cur diff=%d, attrs_cur diff=%d\n",
+ printf("trans_cur diff=%d, attrs_cur diff=%d\n",
ctx->trans_cur - ctx->trans0,
ctx->attrs_cur - ctx->attrs0);
db_prop_print(&ctx->prop);