moved chunk_increment() function to libstrongswan
This commit is contained in:
@@ -173,22 +173,6 @@ static void status(void)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* increment a chunk, as it would reprensent a network order integer
|
|
||||||
*/
|
|
||||||
static void increment_chunk(chunk_t chunk)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = chunk.len - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (++chunk.ptr[i] != 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ipsec pool --add - add a new pool
|
* ipsec pool --add - add a new pool
|
||||||
*/
|
*/
|
||||||
@@ -233,7 +217,7 @@ static void add(char *name, host_t *start, host_t *end, int timeout)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
increment_chunk(cur_addr);
|
chunk_increment(cur_addr);
|
||||||
}
|
}
|
||||||
if (db->get_driver(db) == DB_SQLITE)
|
if (db->get_driver(db) == DB_SQLITE)
|
||||||
{
|
{
|
||||||
@@ -331,7 +315,7 @@ static void resize(char *name, host_t *end)
|
|||||||
}
|
}
|
||||||
while (count-- > 0)
|
while (count-- > 0)
|
||||||
{
|
{
|
||||||
increment_chunk(cur_addr);
|
chunk_increment(cur_addr);
|
||||||
db->execute(db, NULL,
|
db->execute(db, NULL,
|
||||||
"INSERT INTO addresses (pool, address, identity, acquired, released) "
|
"INSERT INTO addresses (pool, address, identity, acquired, released) "
|
||||||
"VALUES (?, ?, ?, ?, ?)",
|
"VALUES (?, ?, ?, ?, ?)",
|
||||||
|
|||||||
@@ -449,6 +449,24 @@ int chunk_compare(chunk_t a, chunk_t b)
|
|||||||
return memcmp(a.ptr, b.ptr, len);
|
return memcmp(a.ptr, b.ptr, len);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
bool chunk_increment(chunk_t chunk)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = chunk.len - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (++chunk.ptr[i] != 0)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove non-printable characters from a chunk.
|
* Remove non-printable characters from a chunk.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -238,6 +238,14 @@ static inline bool chunk_equals(chunk_t a, chunk_t b)
|
|||||||
a.len == b.len && memeq(a.ptr, b.ptr, a.len);
|
a.len == b.len && memeq(a.ptr, b.ptr, a.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Check if a chunk has printable characters only.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user