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
29 int cfg_set_file(const char *file_name);
31 int cfg_lock(uint8_t *cookie, int timeout);
32 void cfg_unlock(void);
34 int cfg_write_data(uint8_t *data, size_t len);
35 bool cfg_is_dirty(void);
37 void cfg_get_all(struct svec *);
39 #define CFG_COOKIE_LEN SHA1_DIGEST_SIZE
40 int cfg_get_cookie(uint8_t *cookie);
42 void cfg_buf_put(struct ofpbuf *buffer);
43 void cfg_get_subsections(struct svec *, const char *, ...) PRINTF_FORMAT(2, 3);
47 CFG_STRING = 1 << 0, /* Arbitrary content. */
48 CFG_KEY = 1 << 0, /* Valid key name. */
49 CFG_INT = 1 << 2, /* Integer value. */
50 CFG_BOOL = 1 << 3, /* Boolean. */
51 CFG_IP = 1 << 4, /* IPv4 address. */
52 CFG_MAC = 1 << 5, /* MAC address. */
53 CFG_VLAN = 1 << 6, /* Integer in range 0...4095. */
54 CFG_DPID = 1 << 7, /* 12 hexadecimal digits. */
57 CFG_REQUIRED = 1 << 8, /* At least one value allowed. */
58 CFG_MULTIPLE = 1 << 9 /* More than one value allowed. */
60 void cfg_register(const char *key_spec, enum cfg_flags);
62 void cfg_add_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
63 void cfg_del_entry(const char *key, ...) PRINTF_FORMAT(1, 2);
64 void cfg_del_section(const char *key, ...) PRINTF_FORMAT(1, 2);
65 void cfg_del_match(const char *pattern, ...) PRINTF_FORMAT(1, 2);
66 void cfg_get_section(struct svec *svec, const char *key, ...)
69 bool cfg_has(const char *key, ...) PRINTF_FORMAT(1, 2);
70 bool cfg_is_valid(enum cfg_flags, const char *key, ...) PRINTF_FORMAT(2, 3);
71 bool cfg_has_section(const char *key, ...) PRINTF_FORMAT(1, 2);
72 int cfg_count(const char *key, ...) PRINTF_FORMAT(1, 2);
74 const char *cfg_get_string(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
75 const char *cfg_get_key(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
76 int cfg_get_int(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
77 bool cfg_get_bool(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
78 uint32_t cfg_get_ip(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
79 uint64_t cfg_get_mac(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
80 int cfg_get_vlan(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
81 uint64_t cfg_get_dpid(int idx, const char *key, ...) PRINTF_FORMAT(2, 3);
83 void cfg_get_all_strings(struct svec *, const char *key, ...)
85 void cfg_get_all_keys(struct svec *, const char *key, ...) PRINTF_FORMAT(2, 3);
87 #endif /* vswitchd/cfg.h */