1 /* Copyright (c) 2008, 2009 Nicira Networks
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #ifndef VSWITCHD_CFG_H
18 #define VSWITCHD_CFG_H 1
30 int cfg_set_file(const char *file_name);
32 int cfg_lock(uint8_t *cookie, int timeout);
33 void cfg_unlock(void);
35 int cfg_write_data(uint8_t *data, size_t len);
36 bool cfg_is_dirty(void);
38 void cfg_get_all(struct svec *);
40 #define CFG_COOKIE_LEN SHA1_DIGEST_SIZE
41 int cfg_get_cookie(uint8_t *cookie);
43 void cfg_buf_put(struct ofpbuf *buffer);
44 void cfg_get_subsections(struct svec *, const char *, ...) PRINTF_FORMAT(2, 3);
48 CFG_STRING = 1 << 0, /* Arbitrary content. */
49 CFG_KEY = 1 << 0, /* Valid key name. */
50 CFG_INT = 1 << 2, /* Integer value. */
51 CFG_BOOL = 1 << 3, /* Boolean. */
52 CFG_IP = 1 << 4, /* IPv4 address. */
53 CFG_MAC = 1 << 5, /* MAC address. */
54 CFG_VLAN = 1 << 6, /* Integer in range 0...4095. */
55 CFG_DPID = 1 << 7, /* 12 hexadecimal digits. */
58 CFG_REQUIRED = 1 << 8, /* At least one value allowed. */
59 CFG_MULTIPLE = 1 << 9 /* More than one value allowed. */
61 void cfg_register(const char *key_spec, enum cfg_flags);
63 void cfg_add_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
64 void cfg_del_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
65 void cfg_del_section(const char *key, ...) PRINTF_FORMAT(1, 2);
66 void cfg_del_match(const char *pattern, ...) PRINTF_FORMAT(1, 2);
67 void cfg_get_matches(struct svec *svec, const char *pattern, ...)
69 void cfg_get_section(struct svec *svec, const char *key, ...)
72 bool cfg_has(const char *key, ...) PRINTF_FORMAT(1, 2);
73 bool cfg_is_valid(enum cfg_flags, const char *key, ...) PRINTF_FORMAT(2, 3);
74 bool cfg_has_section(const char *key, ...) PRINTF_FORMAT(1, 2);
75 int cfg_count(const char *key, ...) PRINTF_FORMAT(1, 2);
77 const char *cfg_get_string(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
78 const char *cfg_get_key(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
79 int cfg_get_int(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
80 bool cfg_get_bool(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
81 uint32_t cfg_get_ip(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
82 uint64_t cfg_get_mac(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
83 int cfg_get_vlan(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
84 uint64_t cfg_get_dpid(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
86 void cfg_get_all_strings(struct svec *, const char *key, ...)
88 void cfg_get_all_keys(struct svec *, const char *key, ...) PRINTF_FORMAT(2, 3);
90 #endif /* vswitchd/cfg.h */