1
/* FreeS/WAN comparisons functions (cmp.c)
2
* Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* RCSID $Id: cmp.c,v 1.7 2004/12/01 07:33:14 ken Exp $
17
#include <sys/queue.h>
25
#define streqn(a,b) (a)?((b)?(strcmp(a,b)):(-1)):(b!=NULL)
27
#define STRCMP(obj) if (streqn(c1->obj,c2->obj)) return -1
28
#define VARCMP(obj) if (c1->obj!=c2->obj) return -1
29
#define MEMCMP(obj) if (memcmp(&c1->obj,&c2->obj,sizeof(c1->obj))) return -1
30
#define ADDCMP(obj) if (addrcmp(&c1->obj,&c2->obj)) return -1
31
#define SUBCMP(obj) if (samesubnet(&c1->obj,&c2->obj)==0) return -1
33
static int starter_cmp_end (struct starter_end *c1, struct starter_end *c2)
35
if ((!c1) || (!c2)) return -1;
45
STRCMP(strings[KSCF_UPDOWN]);
47
VARCMP(has_client_wildcard);
56
int starter_cmp_conn (struct starter_conn *c1, struct starter_conn *c2)
58
if ((!c1) || (!c2)) return -1;
61
VARCMP(options[KBF_IKELIFETIME]);
62
VARCMP(options[KBF_SALIFETIME]);
63
VARCMP(options[KBF_REKEYMARGIN]);
64
VARCMP(options[KBF_REKEYFUZZ]);
65
VARCMP(options[KBF_KEYINGTRIES]);
66
if (starter_cmp_end(&c1->left,&c2->left)) return -1;
67
if (starter_cmp_end(&c1->right,&c2->right)) return -1;
68
VARCMP(options[KBF_AUTO]);
74
int starter_cmp_klips (struct starter_config *c1, struct starter_config *c2)
76
if ((!c1) || (!c2)) return -1;
77
VARCMP(setup.options[KBF_KLIPSDEBUG]);
78
VARCMP(setup.options[KBF_FRAGICMP]);
79
VARCMP(setup.options[KBF_HIDETOS]);
83
int starter_cmp_pluto (struct starter_config *c1, struct starter_config *c2)
85
if ((!c1) || (!c2)) return -1;
86
VARCMP(setup.options[KBF_PLUTODEBUG]);
87
STRCMP(setup.strings[KSF_PREPLUTO]);
88
STRCMP(setup.strings[KSF_POSTPLUTO]);
89
VARCMP(setup.options[KBF_UNIQUEIDS]);
90
VARCMP(setup.options[KBF_STRICTCRLPOLICY]);
91
VARCMP(setup.options[KBF_NOCRSEND]);
92
VARCMP(setup.options[KBF_NHELPERS]);
94
VARCMP(setup.options[KBF_NATTRAVERSAL]);
95
VARCMP(setup.options[KBF_KEEPALIVE]);
98
STRCMP(setup.strings[KSF_VIRTUALPRIVATE]);