- changed ports
[strongswan.git] / Source / charon / configuration_manager.c
1 /**
2 * @file configuration.c
3 *
4 * @brief Configuration class used to store IKE_SA-configurations.
5 *
6 * Object of this type represents a configuration for an IKE_SA and its child_sa's.
7 *
8 */
9
10 /*
11 * Copyright (C) 2005 Jan Hutter, Martin Willi
12 * Hochschule fuer Technik Rapperswil
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 */
24
25 #include <stdlib.h>
26
27 #include "configuration_manager.h"
28
29 #include "types.h"
30 #include "utils/allocator.h"
31
32 /**
33 * Private data of an configuration_t object
34 */
35 typedef struct private_configuration_manager_s private_configuration_manager_t;
36
37 struct private_configuration_manager_s {
38
39 /**
40 * Public part
41 */
42 configuration_manager_t public;
43
44 };
45
46 static status_t get_remote_host(private_configuration_manager_t *this, char *name, host_t **host)
47 {
48 /* some hard coded users for testing */
49 host_t *remote;
50 if (strcmp(name, "pinflb30") == 0) {
51 remote = host_create(AF_INET, "152.96.193.130", 500);
52 if (remote == NULL) {
53 return OUT_OF_RES;
54 }
55 *host = remote;
56 return SUCCESS;
57 }
58 else if (strcmp(name, "pinflb31") == 0) {
59 remote = host_create(AF_INET, "152.96.193.131", 500);
60 if (remote == NULL) {
61 return OUT_OF_RES;
62 }
63 *host = remote;
64 return SUCCESS;
65 }
66 return NOT_FOUND;
67 }
68
69 static status_t get_local_host(private_configuration_manager_t *this, char *name, host_t **host)
70 {
71 /* use default route for now */
72 host_t *local;
73 local = host_create(AF_INET, "0.0.0.0", 0);
74 if (local == NULL)
75 {
76 return OUT_OF_RES;
77 }
78 *host = local;
79 return SUCCESS;
80 }
81
82 static status_t get_proposals_for_host(private_configuration_manager_t *this, host_t *host, linked_list_iterator_t *list)
83 {
84 return FAILED;
85 }
86
87 static status_t select_proposals_for_host(private_configuration_manager_t *this, host_t *host, linked_list_iterator_t *in, linked_list_iterator_t *out)
88 {
89 return FAILED;
90 }
91
92
93 /**
94 * Implements function destroy of configuration_t.
95 * See #configuration_s.destroy for description.
96 */
97 static status_t destroy(private_configuration_manager_t *this)
98 {
99 allocator_free(this);
100 return SUCCESS;
101 }
102
103 /*
104 * Described in header-file
105 */
106 configuration_manager_t *configuration_manager_create()
107 {
108 private_configuration_manager_t *this = allocator_alloc_thing(private_configuration_manager_t);
109 if (this == NULL)
110 {
111 return NULL;
112 }
113
114 /* public functions */
115 this->public.destroy = (status_t(*)(configuration_manager_t*))destroy;
116 this->public.get_remote_host = (status_t(*)(configuration_manager_t*,char*,host_t**))get_remote_host;
117 this->public.get_local_host = (status_t(*)(configuration_manager_t*,char*,host_t**))get_local_host;
118 this->public.get_proposals_for_host = (status_t(*)(configuration_manager_t*,host_t*,linked_list_iterator_t*))get_proposals_for_host;
119 this->public.select_proposals_for_host = (status_t(*)(configuration_manager_t*,host_t*,linked_list_iterator_t*,linked_list_iterator_t*))select_proposals_for_host;
120
121
122 return (&this->public);
123 }