1 /* Copyright (c) 2008, 2009 Nicira Networks
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * In addition, as a special exception, Nicira Networks gives permission
17 * to link the code of its release of vswitchd with the OpenSSL project's
18 * "OpenSSL" library (or with modified versions of it that use the same
19 * license as the "OpenSSL" library), and distribute the linked
20 * executables. You must obey the GNU General Public License in all
21 * respects for all of the code used other than "OpenSSL". If you modify
22 * this file, you may extend this exception to your version of the file,
23 * but you are not obligated to do so. If you do not wish to do so,
24 * delete this exception statement from your version.
28 #ifndef VSWITCHD_CFG_H
29 #define VSWITCHD_CFG_H 1
40 int cfg_set_file(const char *file_name);
42 int cfg_lock(uint8_t *cookie, int timeout);
43 void cfg_unlock(void);
45 int cfg_write_data(uint8_t *data, size_t len);
46 bool cfg_is_dirty(void);
48 void cfg_get_all(struct svec *);
50 #define CFG_COOKIE_LEN SHA1HashSize
51 int cfg_get_cookie(uint8_t *cookie);
53 void cfg_buf_put(struct ofpbuf *buffer);
54 void cfg_get_subsections(struct svec *, const char *, ...) PRINTF_FORMAT(2, 3);
58 CFG_STRING = 1 << 0, /* Arbitrary content. */
59 CFG_KEY = 1 << 0, /* Valid key name. */
60 CFG_INT = 1 << 2, /* Integer value. */
61 CFG_BOOL = 1 << 3, /* Boolean. */
62 CFG_IP = 1 << 4, /* IPv4 address. */
63 CFG_MAC = 1 << 5, /* MAC address. */
64 CFG_VLAN = 1 << 6, /* Integer in range 0...4095. */
65 CFG_DPID = 1 << 7, /* 12 hexadecimal digits. */
68 CFG_REQUIRED = 1 << 8, /* At least one value allowed. */
69 CFG_MULTIPLE = 1 << 9 /* More than one value allowed. */
71 void cfg_register(const char *key_spec, enum cfg_flags);
73 void cfg_add_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
74 void cfg_del_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
75 void cfg_del_section(const char *key, ...) PRINTF_FORMAT(1, 2);
76 void cfg_del_match(const char *pattern, ...) PRINTF_FORMAT(1, 2);
77 void cfg_get_section(struct svec *svec, const char *key, ...)
80 bool cfg_has(const char *key, ...) PRINTF_FORMAT(1, 2);
81 bool cfg_is_valid(enum cfg_flags, const char *key, ...) PRINTF_FORMAT(2, 3);
82 bool cfg_has_section(const char *key, ...) PRINTF_FORMAT(1, 2);
83 int cfg_count(const char *key, ...) PRINTF_FORMAT(1, 2);
85 const char *cfg_get_string(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
86 const char *cfg_get_key(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
87 int cfg_get_int(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
88 bool cfg_get_bool(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
89 uint32_t cfg_get_ip(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
90 uint64_t cfg_get_mac(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
91 int cfg_get_vlan(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
92 uint64_t cfg_get_dpid(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
94 void cfg_get_all_strings(struct svec *, const char *key, ...)
96 void cfg_get_all_keys(struct svec *, const char *key, ...) PRINTF_FORMAT(2, 3);
98 #endif /* vswitchd/cfg.h */