5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
21 #ifndef CLIENTCONFIG_H
22 #define CLIENTCONFIG_H
24 /* Holds information of configured algorithms */
25 typedef struct SilcClientConfigSectionAlgStruct {
30 struct SilcClientConfigSectionAlgStruct *next;
31 struct SilcClientConfigSectionAlgStruct *prev;
32 #define SILC_CLIENT_CONFIG_MODNAME "builtin"
33 } SilcClientConfigSectionAlg;
35 /* Holds all server connections from config file */
36 typedef struct SilcClientConfigSectionConnectionStruct {
41 struct SilcClientConfigSectionConnectionStruct *next;
42 struct SilcClientConfigSectionConnectionStruct *prev;
43 #define SILC_CLIENT_CONFIG_AUTH_METH_PASSWD "passwd"
44 #define SILC_CLIENT_CONFIG_AUTH_METH_PUBKEY "pubkey"
45 } SilcClientConfigSectionConnection;
47 /* Holds all given commands from config file */
48 typedef struct SilcClientConfigSectionCommandStruct {
50 struct SilcClientConfigSectionCommandStruct *next;
51 struct SilcClientConfigSectionCommandStruct *prev;
52 } SilcClientConfigSectionCommand;
55 SILC Client Config object.
57 This object holds all the data parsed from the SILC client configuration
58 file. This is mainly used at the initialization of the client.
62 /* Pointer back to the client */
65 /* Filename of the configuration file */
68 /* Configuration sections */
69 SilcClientConfigSectionAlg *cipher;
70 SilcClientConfigSectionAlg *pkcs;
71 SilcClientConfigSectionAlg *hash_func;
72 SilcClientConfigSectionAlg *hmac;
73 SilcClientConfigSectionConnection *conns;
74 SilcClientConfigSectionCommand *commands;
75 } SilcClientConfigObject;
77 typedef SilcClientConfigObject *SilcClientConfig;
79 /* Configuration section type enumerations. */
81 SILC_CLIENT_CONFIG_SECTION_TYPE_NONE = 0,
82 SILC_CLIENT_CONFIG_SECTION_TYPE_CIPHER,
83 SILC_CLIENT_CONFIG_SECTION_TYPE_PKCS,
84 SILC_CLIENT_CONFIG_SECTION_TYPE_HASH_FUNCTION,
85 SILC_CLIENT_CONFIG_SECTION_TYPE_HMAC,
86 SILC_CLIENT_CONFIG_SECTION_TYPE_CONNECTION,
87 SILC_CLIENT_CONFIG_SECTION_TYPE_COMMAND = 253, /* Special section */
88 } SilcClientConfigSectionType;
90 /* SILC Configuration Section structure. */
93 SilcClientConfigSectionType type;
95 } SilcClientConfigSection;
97 /* List of all possible config sections in SILC client */
98 extern SilcClientConfigSection silc_client_config_sections[];
100 /* Structure used in parsing the configuration lines. The line is read
101 from a file to this structure before parsing it further. */
102 typedef struct SilcClientConfigParseStruct {
105 SilcClientConfigSection *section;
106 struct SilcClientConfigParseStruct *next;
107 struct SilcClientConfigParseStruct *prev;
108 } *SilcClientConfigParse;
111 SilcClientConfig silc_client_config_alloc(char *filename);
112 void silc_client_config_free(SilcClientConfig config);
113 int silc_client_config_parse(SilcClientConfig config, SilcBuffer buffer,
114 SilcClientConfigParse *return_config);
115 int silc_client_config_parse_lines(SilcClientConfig config,
116 SilcClientConfigParse parse_config);
117 int silc_client_config_check_sections(uint32 checkmask);
118 void silc_client_config_setlogfiles(SilcClientConfig config);
119 bool silc_client_config_register_ciphers(SilcClientConfig config);
120 bool silc_client_config_register_pkcs(SilcClientConfig config);
121 bool silc_client_config_register_hashfuncs(SilcClientConfig config);
122 bool silc_client_config_register_hmacs(SilcClientConfig config);
123 SilcClientConfigSectionConnection *
124 silc_client_config_find_connection(SilcClientConfig config,
125 char *host, int port);