25 RCSIDH(types_h,
"$Id: a098e7e1d233a53ec4b6e78973ef3a9358409843 $")
31 #include <freeradius-devel/util/table.h>
32 #include <freeradius-devel/util/talloc.h>
101 #define FR_TYPE_INTEGER_EXCEPT_BOOL_DEF(_beg, _mid, _end) \
102 _beg(FR_TYPE_UINT8) \
103 _mid(FR_TYPE_UINT16) \
104 _mid(FR_TYPE_UINT32) \
105 _mid(FR_TYPE_UINT64) \
107 _mid(FR_TYPE_INT16) \
108 _mid(FR_TYPE_INT32) \
109 _mid(FR_TYPE_INT64) \
111 _mid(FR_TYPE_TIME_DELTA) \
121 #define FR_TYPE_INTEGER_DEF(_beg, _mid, _end) \
123 FR_TYPE_INTEGER_EXCEPT_BOOL_DEF(_mid, _mid, _end)
131 #define FR_TYPE_SIGNED_DEF(_beg, _mid, _end) \
133 _mid(FR_TYPE_INT16) \
134 _mid(FR_TYPE_INT32) \
135 _mid(FR_TYPE_INT64) \
136 _mid(FR_TYPE_TIME_DELTA) \
137 _mid(FR_TYPE_FLOAT32) \
138 _end(FR_TYPE_FLOAT64)
148 #define FR_TYPE_NUMERIC_DEF(_beg, _mid, _end) \
149 _beg(FR_TYPE_FLOAT32) \
150 _mid(FR_TYPE_FLOAT64) \
151 FR_TYPE_INTEGER_DEF(_mid, _mid, _end)
162 #define FR_TYPE_IP_DEF(_beg, _mid, _end) \
163 _beg(FR_TYPE_COMBO_IP_ADDR) \
164 _mid(FR_TYPE_COMBO_IP_PREFIX) \
165 _mid(FR_TYPE_IPV4_ADDR) \
166 _mid(FR_TYPE_IPV4_PREFIX) \
167 _mid(FR_TYPE_IPV6_ADDR) \
168 _end(FR_TYPE_IPV6_PREFIX)
176 #define FR_TYPE_FIXED_SIZE_DEF(_beg, _mid, _end) \
177 _beg(FR_TYPE_ETHERNET) \
179 _mid(FR_TYPE_IPV4_ADDR) \
180 _mid(FR_TYPE_IPV4_PREFIX) \
181 _mid(FR_TYPE_IPV6_ADDR) \
182 _mid(FR_TYPE_IPV6_PREFIX) \
183 FR_TYPE_NUMERIC_DEF(_mid, _mid, _end)
194 #define FR_TYPE_VARIABLE_SIZE_DEF(_beg, _mid, _end) \
195 _beg(FR_TYPE_STRING) \
203 #define FR_TYPE_QUOTED_DEF(_beg, _mid, _end) \
204 _beg(FR_TYPE_STRING) \
214 #define FR_TYPE_STRUCTURAL_EXCEPT_VSA_DEF(_beg, _mid, _end) \
215 _beg(FR_TYPE_GROUP) \
216 _mid(FR_TYPE_STRUCT) \
227 #define FR_TYPE_STRUCTURAL_EXCEPT_GROUP_DEF(_beg, _mid, _end) \
229 _mid(FR_TYPE_STRUCT) \
241 #define FR_TYPE_STRUCTURAL_DEF(_beg, _mid, _end) \
243 FR_TYPE_STRUCTURAL_EXCEPT_VSA_DEF(_mid, _mid, _end)
252 #define FR_TYPE_LEAF_DEF(_beg, _mid, _end) \
253 _beg(FR_TYPE_ETHERNET) \
255 FR_TYPE_IP_DEF(_mid, _mid, _mid) \
256 FR_TYPE_VARIABLE_SIZE_DEF(_mid, _mid, _mid) \
257 FR_TYPE_NUMERIC_DEF(_mid, _mid, _end)
267 #define FR_TYPE_NON_LEAF_DEF(_beg, _mid, _end) \
268 _beg(FR_TYPE_VALUE_BOX) \
272 FR_TYPE_STRUCTURAL_DEF(_mid, _mid, _end)
279 #define CASE_BEG(_type) _type:
280 #define CASE_MID(_type) case _type:
281 #define CASE_END(_type) case _type
283 #define FR_TYPE_INTEGER_EXCEPT_BOOL FR_TYPE_INTEGER_EXCEPT_BOOL_DEF(CASE_BEG, CASE_MID, CASE_END)
284 #define FR_TYPE_INTEGER FR_TYPE_INTEGER_DEF(CASE_BEG, CASE_MID, CASE_END)
285 #define FR_TYPE_SIGNED FR_TYPE_SIGNED_DEF(CASE_BEG, CASE_MID, CASE_END)
286 #define FR_TYPE_NUMERIC FR_TYPE_NUMERIC_DEF(CASE_BEG, CASE_MID, CASE_END)
288 #define FR_TYPE_IP FR_TYPE_IP_DEF(CASE_BEG, CASE_MID, CASE_END)
290 #define FR_TYPE_FIXED_SIZE FR_TYPE_FIXED_SIZE_DEF(CASE_BEG, CASE_MID, CASE_END)
291 #define FR_TYPE_VARIABLE_SIZE FR_TYPE_VARIABLE_SIZE_DEF(CASE_BEG, CASE_MID, CASE_END)
292 #define FR_TYPE_QUOTED FR_TYPE_QUOTED_DEF(CASE_BEG, CASE_MID, CASE_END)
294 #define FR_TYPE_STRUCTURAL_EXCEPT_VSA FR_TYPE_STRUCTURAL_EXCEPT_VSA_DEF(CASE_BEG, CASE_MID, CASE_END)
295 #define FR_TYPE_STRUCTURAL_EXCEPT_GROUP FR_TYPE_STRUCTURAL_EXCEPT_GROUP_DEF(CASE_BEG, CASE_MID, CASE_END)
296 #define FR_TYPE_STRUCTURAL FR_TYPE_STRUCTURAL_DEF(CASE_BEG, CASE_MID, CASE_END)
297 #define FR_TYPE_LEAF FR_TYPE_LEAF_DEF(CASE_BEG, CASE_MID, CASE_END)
298 #define FR_TYPE_NON_LEAF FR_TYPE_NON_LEAF_DEF(CASE_BEG, CASE_MID, CASE_END)
326 #define fr_type_is_null(_x) ((_x) == FR_TYPE_NULL)
327 #define fr_type_is_string(_x) ((_x) == FR_TYPE_STRING)
328 #define fr_type_is_octets(_x) ((_x) == FR_TYPE_OCTETS)
329 #define fr_type_is_ipv4addr(_x) ((_x) == FR_TYPE_IPV4_ADDR)
330 #define fr_type_is_ipv4prefix(_x) ((_x) == FR_TYPE_IPV4_PREFIX)
331 #define fr_type_is_ipv6addr(_x) ((_x) == FR_TYPE_IPV6_ADDR)
332 #define fr_type_is_ipv6prefix(_x) ((_x) == FR_TYPE_IPV6_PREFIX)
333 #define fr_type_is_ifid(_x) ((_x) == FR_TYPE_IFID)
334 #define fr_type_is_combo_ipaddr(_x) ((_x) == FR_TYPE_COMBO_IP_ADDR)
335 #define fr_type_is_combo_ipprefix(_x) ((_x) == FR_TYPE_COMBO_IP_PREFIX)
336 #define fr_type_is_ethernet(_x) ((_x) == FR_TYPE_ETHERNET)
337 #define fr_type_is_bool(_x) ((_x) == FR_TYPE_BOOL)
338 #define fr_type_is_uint8(_x) ((_x) == FR_TYPE_UINT8)
339 #define fr_type_is_uint16(_x) ((_x) == FR_TYPE_UINT16)
340 #define fr_type_is_uint32(_x) ((_x) == FR_TYPE_UINT32)
341 #define fr_type_is_uint64(_x) ((_x) == FR_TYPE_UINT64)
342 #define fr_type_is_int8(_x) ((_x) == FR_TYPE_INT8)
343 #define fr_type_is_int16(_x) ((_x) == FR_TYPE_INT16)
344 #define fr_type_is_int32(_x) ((_x) == FR_TYPE_INT32)
345 #define fr_type_is_int64(_x) ((_x) == FR_TYPE_INT64)
346 #define fr_type_is_float32(_x) ((_x) == FR_TYPE_FLOAT32)
347 #define fr_type_is_float64(_x) ((_x) == FR_TYPE_FLOAT64)
348 #define fr_type_is_date(_x) ((_x) == FR_TYPE_DATE)
349 #define fr_type_is_time_delta(_x) ((_x) == FR_TYPE_TIME_DELTA)
350 #define fr_type_is_size(_x) ((_x) == FR_TYPE_SIZE)
351 #define fr_type_is_tlv(_x) ((_x) == FR_TYPE_TLV)
352 #define fr_type_is_struct(_x) ((_x) == FR_TYPE_STRUCT)
353 #define fr_type_is_vsa(_x) ((_x) == FR_TYPE_VSA)
354 #define fr_type_is_vendor(_x) ((_x) == FR_TYPE_VENDOR)
355 #define fr_type_is_group(_x) ((_x) == FR_TYPE_GROUP)
356 #define fr_type_is_value_box(_x) ((_x) == FR_TYPE_VALUE_BOX)
357 #define fr_type_is_void(_x) ((_x) == FR_TYPE_VOID)
359 #define fr_type_is_integer_except_bool(_x) (fr_type_integer_except_bool[_x])
360 #define fr_type_is_integer(_x) (fr_type_integer[_x])
361 #define fr_type_is_numeric(_x) (fr_type_numeric[_x])
362 #define fr_type_is_signed(_x) (fr_type_signed[_x])
364 #define fr_type_is_ip(_x) (fr_type_ip[_x])
366 #define fr_type_is_fixed_size(_x) (fr_type_fixed_size[_x])
367 #define fr_type_is_variable_size(_x) (fr_type_variable_size[_x])
368 #define fr_type_is_quoted(_x) (fr_type_quoted[_x])
370 #define fr_type_is_structural_except_vsa(_x) (fr_type_structural_except_vsa[_x])
371 #define fr_type_is_structural(_x) (fr_type_structural[_x])
372 #define fr_type_is_leaf(_x) (fr_type_leaf[_x])
373 #define fr_type_is_non_leaf(_x) (fr_type_non_leaf[_x])
385 # define FR_CTYPE_TO_TYPE(_ct) \
387 fr_ethernet_t * : FR_TYPE_ETHERNET, \
388 fr_ethernet_t ** : FR_TYPE_ETHERNET, \
389 fr_ifid_t * : FR_TYPE_IFID, \
390 fr_ifid_t ** : FR_TYPE_IFID, \
391 fr_time_t * : FR_TYPE_DATE, \
392 fr_time_t ** : FR_TYPE_DATE, \
393 fr_time_delta_t * : FR_TYPE_TIME_DELTA, \
394 fr_time_delta_t ** : FR_TYPE_TIME_DELTA, \
395 char const ** : FR_TYPE_STRING, \
396 char const *** : FR_TYPE_STRING, \
397 bool * : FR_TYPE_BOOL, \
398 bool ** : FR_TYPE_BOOL, \
399 uint8_t const ** : FR_TYPE_OCTETS, \
400 uint8_t const *** : FR_TYPE_OCTETS, \
401 uint8_t * : FR_TYPE_UINT8, \
402 uint8_t ** : FR_TYPE_UINT8, \
403 uint16_t * : FR_TYPE_UINT16, \
404 uint16_t ** : FR_TYPE_UINT16, \
405 uint32_t * : FR_TYPE_UINT32, \
406 uint32_t ** : FR_TYPE_UINT32, \
407 uint64_t * : FR_TYPE_UINT64, \
408 uint64_t ** : FR_TYPE_UINT64, \
409 int8_t * : FR_TYPE_INT8, \
410 int8_t ** : FR_TYPE_INT8, \
411 int16_t * : FR_TYPE_INT16, \
412 int16_t ** : FR_TYPE_INT16, \
413 int32_t * : FR_TYPE_INT32, \
414 int32_t ** : FR_TYPE_INT32, \
415 int64_t * : FR_TYPE_INT64, \
416 int64_t ** : FR_TYPE_INT64, \
417 float * : FR_TYPE_FLOAT32, \
418 float ** : FR_TYPE_FLOAT32, \
419 double * : FR_TYPE_FLOAT64, \
420 double ** : FR_TYPE_FLOAT64, \
421 default : FR_TYPE_VOID )
fr_aka_sim_id_type_t type
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
An element in an arbitrarily ordered array of name to num mappings.
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
fr_table_num_ordered_t const fr_type_table[]
Map data types to names representing those types.
bool const fr_type_structural_except_vsa[FR_TYPE_MAX+1]
fr_type_t
Internal data types.
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_FLOAT32
Single precision floating point.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_INT8
8 Bit signed integer.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_ETHERNET
48 Bit Mac-Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_MAX
Number of defined data types.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_INT64
64 Bit signed integer.
@ FR_TYPE_INT16
16 Bit signed integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
@ FR_TYPE_VALUE_BOX
A boxed value.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_INT32
32 Bit signed integer.
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
@ FR_TYPE_IFID
Interface ID.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
@ FR_TYPE_FLOAT64
Double precision floating point.
bool const fr_type_non_leaf[FR_TYPE_MAX+1]
void ** fr_type_array_alloc(TALLOC_CTX *ctx, fr_type_t type, size_t count)
Allocate an array of a given type.
bool fr_type_cast(fr_type_t dst, fr_type_t src)
Return if we're allowed to cast the types.
bool const fr_type_signed[FR_TYPE_MAX+1]
bool const fr_type_integer[FR_TYPE_MAX+1]
bool const fr_type_variable_size[FR_TYPE_MAX+1]
bool const fr_type_numeric[FR_TYPE_MAX+1]
bool const fr_type_ip[FR_TYPE_MAX+1]
bool const fr_type_fixed_size[FR_TYPE_MAX+1]
bool const fr_type_integer_except_bool[FR_TYPE_MAX+1]
bool const fr_type_quoted[FR_TYPE_MAX+1]
bool const fr_type_leaf[FR_TYPE_MAX+1]
fr_type_t fr_type_promote(fr_type_t a, fr_type_t b)
Return the promoted type.
bool const fr_type_structural[FR_TYPE_MAX+1]
static fr_type_t fr_type_from_str(char const *type)
Return the constant value representing a type.