starter: Removed all unsupported keywords.
[strongswan.git] / src / starter / cmp.c
1 /* strongSwan IPsec starter comparison functions
2 * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
3 *
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>.
8 *
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
12 * for more details.
13 */
14
15 #include <string.h>
16
17 #include "confread.h"
18 #include "args.h"
19 #include "cmp.h"
20
21 #define VARCMP(obj) if (c1->obj != c2->obj) return FALSE
22 #define ADDCMP(obj) if (!sameaddr(&c1->obj,&c2->obj)) return FALSE
23 #define SUBCMP(obj) if (!samesubnet(&c1->obj,&c2->obj)) return FALSE
24 #define STRCMP(obj) if (strcmp(c1->obj,c2->obj)) return FALSE
25
26 static bool starter_cmp_end(starter_end_t *c1, starter_end_t *c2)
27 {
28 if ((c1 == NULL) || (c2 == NULL))
29 return FALSE;
30
31 VARCMP(ikeport);
32 VARCMP(has_natip);
33 VARCMP(modecfg);
34 VARCMP(port);
35 VARCMP(protocol);
36
37 return cmp_args(KW_END_FIRST, KW_END_LAST, (char *)c1, (char *)c2);
38 }
39
40 bool starter_cmp_conn(starter_conn_t *c1, starter_conn_t *c2)
41 {
42 if ((c1 == NULL) || (c2 == NULL))
43 return FALSE;
44
45 VARCMP(options);
46 VARCMP(mark_in.value);
47 VARCMP(mark_in.mask);
48 VARCMP(mark_out.value);
49 VARCMP(mark_in.mask);
50
51 if (!starter_cmp_end(&c1->left, &c2->left))
52 return FALSE;
53 if (!starter_cmp_end(&c1->right, &c2->right))
54 return FALSE;
55
56 return cmp_args(KW_CONN_NAME, KW_CONN_LAST, (char *)c1, (char *)c2);
57 }
58
59 bool starter_cmp_ca(starter_ca_t *c1, starter_ca_t *c2)
60 {
61 if (c1 == NULL || c2 == NULL)
62 return FALSE;
63
64 return cmp_args(KW_CA_NAME, KW_CA_LAST, (char *)c1, (char *)c2);
65 }
66