summaryrefslogtreecommitdiff
path: root/src/libfreeswan/pfkey_v2_build.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libfreeswan/pfkey_v2_build.c')
-rw-r--r--src/libfreeswan/pfkey_v2_build.c118
1 files changed, 59 insertions, 59 deletions
diff --git a/src/libfreeswan/pfkey_v2_build.c b/src/libfreeswan/pfkey_v2_build.c
index ddc21040f..c0bb369cb 100644
--- a/src/libfreeswan/pfkey_v2_build.c
+++ b/src/libfreeswan/pfkey_v2_build.c
@@ -1,12 +1,12 @@
/*
* RFC2367 PF_KEYv2 Key management API message parser
* Copyright (C) 1999, 2000, 2001 Richard Guy Briggs.
- *
+ *
* 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
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
+ *
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
@@ -48,7 +48,7 @@ void
pfkey_extensions_init(struct sadb_ext *extensions[SADB_EXT_MAX + 1])
{
int i;
-
+
for (i = 0; i != SADB_EXT_MAX + 1; i++) {
extensions[i] = NULL;
}
@@ -58,7 +58,7 @@ void
pfkey_extensions_free(struct sadb_ext *extensions[SADB_EXT_MAX + 1])
{
int i;
-
+
if (!extensions) {
return;
}
@@ -68,7 +68,7 @@ pfkey_extensions_free(struct sadb_ext *extensions[SADB_EXT_MAX + 1])
FREE(extensions[0]);
extensions[0] = NULL;
}
-
+
for (i = 1; i != SADB_EXT_MAX + 1; i++) {
if(extensions[i]) {
memset(extensions[i], 0, extensions[i]->sadb_ext_len * IPSEC_PFKEYv2_ALIGN);
@@ -135,7 +135,7 @@ pfkey_msg_hdr_build(struct sadb_ext** pfkey_ext,
if (satype > SADB_SATYPE_MAX) {
DEBUGGING(
"pfkey_msg_hdr_build: "
- "satype %d > max %d\n",
+ "satype %d > max %d\n",
satype, SADB_SATYPE_MAX);
SENDERR(EINVAL);
}
@@ -169,7 +169,7 @@ pfkey_msg_hdr_build(struct sadb_ext** pfkey_ext,
*pfkey_ext);
errlab:
return error;
-}
+}
int
pfkey_sa_ref_build(struct sadb_ext ** pfkey_ext,
@@ -254,7 +254,7 @@ pfkey_sa_ref_build(struct sadb_ext ** pfkey_ext,
SADB_SASTATE_DEAD);
SENDERR(EINVAL);
}
-
+
if ((IPSEC_SAREF_NULL != ref) && (ref >= (1 << IPSEC_SA_REF_TABLE_IDX_WIDTH))) {
DEBUGGING(
"pfkey_sa_build: "
@@ -264,7 +264,7 @@ pfkey_sa_ref_build(struct sadb_ext ** pfkey_ext,
IPSEC_SA_REF_TABLE_NUM_ENTRIES);
SENDERR(EINVAL);
}
-
+
pfkey_sa = (struct sadb_sa*)MALLOC(sizeof(struct sadb_sa));
*pfkey_ext = (struct sadb_ext*)pfkey_sa;
@@ -275,7 +275,7 @@ pfkey_sa_ref_build(struct sadb_ext ** pfkey_ext,
SENDERR(ENOMEM);
}
memset(pfkey_sa, 0, sizeof(struct sadb_sa));
-
+
pfkey_sa->sadb_sa_len = sizeof(*pfkey_sa) / IPSEC_PFKEYv2_ALIGN;
pfkey_sa->sadb_sa_exttype = exttype;
pfkey_sa->sadb_sa_spi = spi;
@@ -284,11 +284,11 @@ pfkey_sa_ref_build(struct sadb_ext ** pfkey_ext,
pfkey_sa->sadb_sa_auth = auth;
pfkey_sa->sadb_sa_encrypt = encrypt;
pfkey_sa->sadb_sa_flags = flags;
- pfkey_sa->sadb_x_sa_ref = ref;
+ pfkey_sa->sadb_x_sa_ref = ref;
errlab:
return error;
-}
+}
int
pfkey_sa_build(struct sadb_ext ** pfkey_ext,
@@ -377,7 +377,7 @@ pfkey_address_build(struct sadb_ext** pfkey_ext,
int saddr_len = 0;
char ipaddr_txt[ADDRTOT_BUF + 6/*extra for port number*/];
struct sadb_address *pfkey_address = (struct sadb_address *)*pfkey_ext;
-
+
DEBUGGING(
"pfkey_address_build: "
"exttype=%d proto=%d prefixlen=%d\n",
@@ -397,8 +397,8 @@ pfkey_address_build(struct sadb_ext** pfkey_ext,
"address is NULL\n");
SENDERR(EINVAL);
}
-
- switch(exttype) {
+
+ switch(exttype) {
case SADB_EXT_ADDRESS_SRC:
case SADB_EXT_ADDRESS_DST:
case SADB_EXT_ADDRESS_PROXY:
@@ -410,11 +410,11 @@ pfkey_address_build(struct sadb_ext** pfkey_ext,
case SADB_X_EXT_NAT_T_OA:
break;
default:
- DEBUGGING(
+ DEBUGGING(
"pfkey_address_build: "
- "unrecognised ext_type=%d.\n",
- exttype);
- SENDERR(EINVAL);
+ "unrecognised ext_type=%d.\n",
+ exttype);
+ SENDERR(EINVAL);
}
switch (address->sa_family) {
@@ -479,10 +479,10 @@ pfkey_address_build(struct sadb_ext** pfkey_ext,
0,
ALIGN_N(sizeof(struct sadb_address) + saddr_len,
IPSEC_PFKEYv2_ALIGN));
-
+
pfkey_address->sadb_address_len = DIVUP(sizeof(struct sadb_address) + saddr_len,
IPSEC_PFKEYv2_ALIGN);
-
+
pfkey_address->sadb_address_exttype = exttype;
pfkey_address->sadb_address_proto = proto;
pfkey_address->sadb_address_prefixlen = prefixlen;
@@ -540,7 +540,7 @@ pfkey_key_build(struct sadb_ext** pfkey_ext,
}
pfkey_key = (struct sadb_key*)
- MALLOC(sizeof(struct sadb_key) +
+ MALLOC(sizeof(struct sadb_key) +
DIVUP(key_bits, 64) * IPSEC_PFKEYv2_ALIGN);
*pfkey_ext = (struct sadb_ext*)pfkey_key;
@@ -554,7 +554,7 @@ pfkey_key_build(struct sadb_ext** pfkey_ext,
0,
sizeof(struct sadb_key) +
DIVUP(key_bits, 64) * IPSEC_PFKEYv2_ALIGN);
-
+
pfkey_key->sadb_key_len = DIVUP(sizeof(struct sadb_key) * IPSEC_PFKEYv2_ALIGN + key_bits,
64);
pfkey_key->sadb_key_exttype = exttype;
@@ -622,12 +622,12 @@ pfkey_ident_build(struct sadb_ext** pfkey_ext,
"string required to allocate size of extension.\n");
SENDERR(EINVAL);
}
-
+
#if 0
if (ident_type == SADB_IDENTTYPE_USERFQDN) {
}
#endif
-
+
pfkey_ident = (struct sadb_ident*)
MALLOC(ident_len * IPSEC_PFKEYv2_ALIGN);
*pfkey_ext = (struct sadb_ext*)pfkey_ident;
@@ -639,7 +639,7 @@ pfkey_ident_build(struct sadb_ext** pfkey_ext,
SENDERR(ENOMEM);
}
memset(pfkey_ident, 0, ident_len * IPSEC_PFKEYv2_ALIGN);
-
+
pfkey_ident->sadb_ident_len = ident_len;
pfkey_ident->sadb_ident_exttype = exttype;
pfkey_ident->sadb_ident_type = ident_type;
@@ -699,7 +699,7 @@ pfkey_sens_build(struct sadb_ext** pfkey_ext,
0,
sizeof(struct sadb_sens) +
(sens_len + integ_len) * sizeof(uint64_t));
-
+
pfkey_sens->sadb_sens_len = (sizeof(struct sadb_sens) +
(sens_len + integ_len) * sizeof(uint64_t)) / IPSEC_PFKEYv2_ALIGN;
pfkey_sens->sadb_sens_exttype = SADB_EXT_SENSITIVITY;
@@ -761,7 +761,7 @@ pfkey_prop_build(struct sadb_ext** pfkey_ext,
0,
sizeof(struct sadb_prop) +
comb_num * sizeof(struct sadb_comb));
-
+
pfkey_prop->sadb_prop_len = (sizeof(struct sadb_prop) +
comb_num * sizeof(struct sadb_comb)) / IPSEC_PFKEYv2_ALIGN;
@@ -846,7 +846,7 @@ pfkey_supported_build(struct sadb_ext** pfkey_ext,
sizeof(struct sadb_supported) +
alg_num *
sizeof(struct sadb_alg));
-
+
pfkey_supported->sadb_supported_len = (sizeof(struct sadb_supported) +
alg_num *
sizeof(struct sadb_alg)) /
@@ -860,7 +860,7 @@ pfkey_supported_build(struct sadb_ext** pfkey_ext,
pfkey_alg->sadb_alg_reserved = 0;
pfkey_alg++;
}
-
+
#if 0
DEBUGGING(
"pfkey_supported_build: "
@@ -886,7 +886,7 @@ pfkey_spirange_build(struct sadb_ext** pfkey_ext,
{
int error = 0;
struct sadb_spirange *pfkey_spirange = (struct sadb_spirange *)*pfkey_ext;
-
+
/* sanity checks... */
if (pfkey_spirange) {
DEBUGGING(
@@ -894,7 +894,7 @@ pfkey_spirange_build(struct sadb_ext** pfkey_ext,
"why is pfkey_spirange already pointing to something?\n");
SENDERR(EINVAL);
}
-
+
if (ntohl(max) < ntohl(min)) {
DEBUGGING(
"pfkey_spirange_build: "
@@ -903,7 +903,7 @@ pfkey_spirange_build(struct sadb_ext** pfkey_ext,
ntohl(max));
SENDERR(EINVAL);
}
-
+
if (ntohl(min) <= 255) {
DEBUGGING(
"pfkey_spirange_build: "
@@ -911,7 +911,7 @@ pfkey_spirange_build(struct sadb_ext** pfkey_ext,
ntohl(min));
SENDERR(EEXIST);
}
-
+
pfkey_spirange = (struct sadb_spirange*)
MALLOC(sizeof(struct sadb_spirange));
*pfkey_ext = (struct sadb_ext*)pfkey_spirange;
@@ -925,7 +925,7 @@ pfkey_spirange_build(struct sadb_ext** pfkey_ext,
memset(pfkey_spirange,
0,
sizeof(struct sadb_spirange));
-
+
pfkey_spirange->sadb_spirange_len = sizeof(struct sadb_spirange) / IPSEC_PFKEYv2_ALIGN;
pfkey_spirange->sadb_spirange_exttype = SADB_EXT_SPIRANGE;
@@ -949,7 +949,7 @@ pfkey_x_kmprivate_build(struct sadb_ext** pfkey_ext)
"why is pfkey_x_kmprivate already pointing to something?\n");
SENDERR(EINVAL);
}
-
+
pfkey_x_kmprivate->sadb_x_kmprivate_reserved = 0;
DEBUGGING(
@@ -971,7 +971,7 @@ pfkey_x_kmprivate_build(struct sadb_ext** pfkey_ext)
memset(pfkey_x_kmprivate,
0,
sizeof(struct sadb_x_kmprivate));
-
+
pfkey_x_kmprivate->sadb_x_kmprivate_len =
sizeof(struct sadb_x_kmprivate) / IPSEC_PFKEYv2_ALIGN;
@@ -998,7 +998,7 @@ pfkey_x_satype_build(struct sadb_ext** pfkey_ext,
"why is pfkey_x_satype already pointing to something?\n");
SENDERR(EINVAL);
}
-
+
if (!satype) {
DEBUGGING(
"pfkey_x_satype_build: "
@@ -1009,7 +1009,7 @@ pfkey_x_satype_build(struct sadb_ext** pfkey_ext,
if (satype > SADB_SATYPE_MAX) {
DEBUGGING(
"pfkey_x_satype_build: "
- "satype %d > max %d\n",
+ "satype %d > max %d\n",
satype, SADB_SATYPE_MAX);
SENDERR(EINVAL);
}
@@ -1028,7 +1028,7 @@ pfkey_x_satype_build(struct sadb_ext** pfkey_ext,
memset(pfkey_x_satype,
0,
sizeof(struct sadb_x_satype));
-
+
pfkey_x_satype->sadb_x_satype_len = sizeof(struct sadb_x_satype) / IPSEC_PFKEYv2_ALIGN;
pfkey_x_satype->sadb_x_satype_exttype = SADB_X_EXT_SATYPE2;
@@ -1069,7 +1069,7 @@ pfkey_x_debug_build(struct sadb_ext** pfkey_ext,
"why is pfkey_x_debug already pointing to something?\n");
SENDERR(EINVAL);
}
-
+
DEBUGGING(
"pfkey_x_debug_build: "
"tunnel=%x netlink=%x xform=%x eroute=%x spi=%x radij=%x esp=%x ah=%x rcv=%x pfkey=%x ipcomp=%x verbose=%x?\n",
@@ -1090,7 +1090,7 @@ pfkey_x_debug_build(struct sadb_ext** pfkey_ext,
0,
sizeof(struct sadb_x_debug));
#endif
-
+
pfkey_x_debug->sadb_x_debug_len = sizeof(struct sadb_x_debug) / IPSEC_PFKEYv2_ALIGN;
pfkey_x_debug->sadb_x_debug_exttype = SADB_X_EXT_DEBUG;
@@ -1132,7 +1132,7 @@ pfkey_x_nat_t_type_build(struct sadb_ext** pfkey_ext,
"why is pfkey_x_nat_t_type already pointing to something?\n");
SENDERR(EINVAL);
}
-
+
DEBUGGING(
"pfkey_x_nat_t_type_build: "
"type=%d\n", type);
@@ -1147,7 +1147,7 @@ pfkey_x_nat_t_type_build(struct sadb_ext** pfkey_ext,
"memory allocation failed\n");
SENDERR(ENOMEM);
}
-
+
pfkey_x_nat_t_type->sadb_x_nat_t_type_len = sizeof(struct sadb_x_nat_t_type) / IPSEC_PFKEYv2_ALIGN;
pfkey_x_nat_t_type->sadb_x_nat_t_type_exttype = SADB_X_EXT_NAT_T_TYPE;
pfkey_x_nat_t_type->sadb_x_nat_t_type_type = type;
@@ -1176,17 +1176,17 @@ pfkey_x_nat_t_port_build(struct sadb_ext** pfkey_ext,
"why is pfkey_x_nat_t_port already pointing to something?\n");
SENDERR(EINVAL);
}
-
- switch (exttype) {
+
+ switch (exttype) {
case SADB_X_EXT_NAT_T_SPORT:
case SADB_X_EXT_NAT_T_DPORT:
break;
default:
- DEBUGGING(
+ DEBUGGING(
"pfkey_nat_t_port_build: "
- "unrecognised ext_type=%d.\n",
- exttype);
- SENDERR(EINVAL);
+ "unrecognised ext_type=%d.\n",
+ exttype);
+ SENDERR(EINVAL);
}
DEBUGGING(
@@ -1203,7 +1203,7 @@ pfkey_x_nat_t_port_build(struct sadb_ext** pfkey_ext,
"memory allocation failed\n");
SENDERR(ENOMEM);
}
-
+
pfkey_x_nat_t_port->sadb_x_nat_t_port_len = sizeof(struct sadb_x_nat_t_port) / IPSEC_PFKEYv2_ALIGN;
pfkey_x_nat_t_port->sadb_x_nat_t_port_exttype = exttype;
pfkey_x_nat_t_port->sadb_x_nat_t_port_port = port;
@@ -1281,7 +1281,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
struct sadb_ext *pfkey_ext;
int extensions_seen = 0;
struct sadb_ext *extensions_check[SADB_EXT_MAX + 1];
-
+
if (!extensions[0]) {
DEBUGGING(
"pfkey_msg_build: "
@@ -1294,7 +1294,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
if(extensions[ext]) {
total_size += (extensions[ext])->sadb_ext_len;
}
- }
+ }
if (!(*pfkey_msg = (struct sadb_msg*)MALLOC(total_size * IPSEC_PFKEYv2_ALIGN))) {
DEBUGGING(
@@ -1320,14 +1320,14 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
for (ext = 1; ext <= SADB_EXT_MAX; ext++) {
/* copy from extension[ext] to buffer */
- if (extensions[ext]) {
+ if (extensions[ext]) {
/* Is this type of extension permitted for this type of message? */
if (!(extensions_bitmaps[dir][EXT_BITS_PERM][(*pfkey_msg)->sadb_msg_type] &
1<<ext)) {
DEBUGGING(
"pfkey_msg_build: "
- "ext type %d not permitted, exts_perm=%08x, 1<<type=%08x\n",
- ext,
+ "ext type %d not permitted, exts_perm=%08x, 1<<type=%08x\n",
+ ext,
extensions_bitmaps[dir][EXT_BITS_PERM][(*pfkey_msg)->sadb_msg_type],
1<<ext);
SENDERR(EINVAL);
@@ -1342,7 +1342,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
memcpy(pfkey_ext,
extensions[ext],
(extensions[ext])->sadb_ext_len * IPSEC_PFKEYv2_ALIGN);
- {
+ {
char *pfkey_ext_c = (char *)pfkey_ext;
pfkey_ext_c += (extensions[ext])->sadb_ext_len * IPSEC_PFKEYv2_ALIGN;
@@ -1360,7 +1360,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
extensions_bitmaps[dir][EXT_BITS_PERM][(*pfkey_msg)->sadb_msg_type],
extensions_seen,
extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]);
-
+
if ((extensions_seen &
extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]) !=
extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]) {
@@ -1372,7 +1372,7 @@ pfkey_msg_build(struct sadb_msg **pfkey_msg, struct sadb_ext *extensions[], int
extensions_bitmaps[dir][EXT_BITS_REQ][(*pfkey_msg)->sadb_msg_type]) );
SENDERR(EINVAL);
}
-
+
error = pfkey_msg_parse(*pfkey_msg, NULL, extensions_check, dir);
if (error) {
DEBUGGING(