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 {
28 unsigned int block_len;
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 SilcClientConfigSectionConnection *conns;
73 SilcClientConfigSectionCommand *commands;
74 } SilcClientConfigObject;
76 typedef SilcClientConfigObject *SilcClientConfig;
78 /* Configuration section type enumerations. */
80 SILC_CLIENT_CONFIG_SECTION_TYPE_NONE = 0,
81 SILC_CLIENT_CONFIG_SECTION_TYPE_CIPHER,
82 SILC_CLIENT_CONFIG_SECTION_TYPE_PKCS,
83 SILC_CLIENT_CONFIG_SECTION_TYPE_HASH_FUNCTION,
84 SILC_CLIENT_CONFIG_SECTION_TYPE_CONNECTION,
85 SILC_CLIENT_CONFIG_SECTION_TYPE_COMMAND = 253, /* Special section */
86 } SilcClientConfigSectionType;
88 /* SILC Configuration Section structure. */
91 SilcClientConfigSectionType type;
92 unsigned int maxfields;
93 } SilcClientConfigSection;
95 /* List of all possible config sections in SILC client */
96 extern SilcClientConfigSection silc_client_config_sections[];
98 /* Structure used in parsing the configuration lines. The line is read
99 from a file to this structure before parsing it further. */
100 typedef struct SilcClientConfigParseStruct {
102 unsigned int linenum;
103 SilcClientConfigSection *section;
104 struct SilcClientConfigParseStruct *next;
105 struct SilcClientConfigParseStruct *prev;
106 } *SilcClientConfigParse;
109 SilcClientConfig silc_client_config_alloc(char *filename);
110 void silc_client_config_free(SilcClientConfig config);
111 int silc_client_config_parse(SilcClientConfig config, SilcBuffer buffer,
112 SilcClientConfigParse *return_config);
113 int silc_client_config_parse_lines(SilcClientConfig config,
114 SilcClientConfigParse parse_config);
115 int silc_client_config_check_sections(unsigned int checkmask);
116 void silc_client_config_setlogfiles(SilcClientConfig config);
117 void silc_client_config_register_ciphers(SilcClientConfig config);
118 void silc_client_config_register_pkcs(SilcClientConfig config);
119 void silc_client_config_register_hashfuncs(SilcClientConfig config);
120 SilcClientConfigSectionConnection *
121 silc_client_config_find_connection(SilcClientConfig config,
122 char *host, int port);