1 /* 2 ***** BEGIN LICENSE BLOCK ***** 3 4 Copyright (C) 2001-2020 Olof Hagsand 5 6 This file is part of CLIgen. 7 8 Licensed under the Apache License, Version 2.0 (the "License"); 9 you may not use this file except in compliance with the License. 10 You may obtain a copy of the License at 11 12 http://www.apache.org/licenses/LICENSE-2.0 13 14 Unless required by applicable law or agreed to in writing, software 15 distributed under the License is distributed on an "AS IS" BASIS, 16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 See the License for the specific language governing permissions and 18 limitations under the License. 19 20 Alternatively, the contents of this file may be used under the terms of 21 the GNU General Public License Version 2 or later (the "GPL"), 22 in which case the provisions of the GPL are applicable instead 23 of those above. If you wish to allow use of your version of this file only 24 under the terms of the GPL, and not to allow others to 25 use your version of this file under the terms of Apache License version 2, indicate 26 your decision by deleting the provisions above and replace them with the 27 notice and other provisions required by the GPL. If you do not delete 28 the provisions above, a recipient may use your version of this file under 29 the terms of any one of the Apache License version 2 or the GPL. 30 31 ***** END LICENSE BLOCK ***** 32 33 * This is an internal CLIgen header file 34 * Do not use these struct for external use, the internal structure may change. 35 * @see cligen_cv.h for external API use 36 */ 37 38 #ifndef _CLIGEN_CV_INTERNAL_H_ 39 #define _CLIGEN_CV_INTERNAL_H_ 40 41 /* 42 * Constants 43 */ 44 /* Allow use of on/off as alternative truth values to true/false */ 45 #define BOOL_TRUTH_ON_OFF 46 47 /* Allow use of enable/disable as alternative truth values to true/false */ 48 #define BOOL_TRUTH_ENABLE_DISABLE 49 50 /* 51 * Types 52 */ 53 /* 54 * Cligen Variable structure 55 * cg_var / cv 56 * Note that a cv holds a value. The specification of a cv is a cg_varspec 57 */ 58 struct cg_var { 59 enum cv_type var_type; /* Type of variable appears in <name:type ...> */ 60 char *var_name; /* Name of variable appears in <name:type ...> */ 61 char *var_show; /* Show help-text, same as name or <name..show:<show>> */ 62 char var_const; /* Set if the variable is a keyword */ 63 char var_flag ; /* Application-specific flags, no semantics by cligen */ 64 union { 65 uint8_t varu_bool; 66 int8_t varu_int8; 67 int16_t varu_int16; 68 int32_t varu_int32; 69 int64_t varu_int64; 70 uint8_t varu_uint8; 71 uint16_t varu_uint16; 72 uint32_t varu_uint32; 73 uint64_t varu_uint64; 74 char *varu_string; 75 char *varu_interface; 76 struct { 77 int64_t vardec64_i; /* base number i in i x 10^-n */ 78 uint8_t vardec64_n; /* fraction n in i x 10^-n */ 79 } varu_dec64; 80 struct { 81 struct in_addr varipv4_ipv4addr; 82 uint8_t varipv4_masklen; 83 } varu_ipv4addr; 84 struct { 85 struct in6_addr varipv6_ipv6addr; 86 uint8_t varipv6_masklen; 87 } varu_ipv6addr; 88 char varu_macaddr[6]; 89 struct { 90 char *varurl_proto; 91 char *varurl_addr; 92 char *varurl_path; 93 char *varurl_user; 94 char *varurl_passwd; 95 } varu_url; 96 uuid_t varu_uuid; 97 struct timeval varu_time; 98 void *varu_void; 99 } u; 100 }; 101 102 /* 103 * Access macros 104 */ 105 #define var_bool u.varu_bool 106 #define var_int8 u.varu_int8 107 #define var_int16 u.varu_int16 108 #define var_int32 u.varu_int32 109 #define var_int64 u.varu_int64 110 #define var_uint8 u.varu_uint8 111 #define var_uint16 u.varu_uint16 112 #define var_uint32 u.varu_uint32 113 #define var_uint64 u.varu_uint64 114 #define var_dec64_i u.varu_dec64.vardec64_i 115 #define var_dec64_n u.varu_dec64.vardec64_n 116 #define var_string u.varu_string 117 #define var_void u.varu_void 118 #define var_rest u.varu_string 119 #define var_interface u.varu_string 120 #define var_macaddr u.varu_macaddr 121 #define var_uuid u.varu_uuid 122 #define var_time u.varu_time 123 #define var_ipv4addr u.varu_ipv4addr.varipv4_ipv4addr 124 #define var_ipv4masklen u.varu_ipv4addr.varipv4_masklen 125 #define var_ipv6addr u.varu_ipv6addr.varipv6_ipv6addr 126 #define var_ipv6masklen u.varu_ipv6addr.varipv6_masklen 127 #define var_urlproto u.varu_url.varurl_proto 128 #define var_urladdr u.varu_url.varurl_addr 129 #define var_urlpath u.varu_url.varurl_path 130 #define var_urluser u.varu_url.varurl_user 131 #define var_urlpasswd u.varu_url.varurl_passwd 132 133 #endif /* _CLIGEN_CV_INTERNAL_H_ */ 134