include
etsi_its_cam_ts_coding
asn_random_fill.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3
* Redistribution and modifications are permitted subject to BSD license.
4
*/
5
#ifndef ASN_RANDOM_FILL
6
#define ASN_RANDOM_FILL
7
8
/* Forward declarations */
9
struct
asn_TYPE_descriptor_s
;
10
struct
asn_encoding_constraints_s
;
11
12
/*
13
* Initialize a structure with random data according to the type specification
14
* and optional member constraints.
15
* ARGUMENTS:
16
* (max_length) - See (approx_max_length_limit).
17
* (memb_constraints) - Member constraints, if exist.
18
* The type can be constrained differently according
19
* to PER and OER specifications, so we find a value
20
* at the intersection of these constraints.
21
* In case the return differs from ARFILL_OK, the (struct_ptr) contents
22
* and (current_length) value remain in their original state.
23
*/
24
typedef
struct
asn_random_fill_result_s
{
25
enum
{
26
ARFILL_FAILED
= -1,
/* System error (memory?) */
27
ARFILL_OK
= 0,
/* Initialization succeeded */
28
ARFILL_SKIPPED
= 1
/* Not done due to (length?) constraint */
29
}
code
;
30
size_t
length
;
/* Approximate number of bytes created. */
31
}
asn_random_fill_result_t
;
32
typedef
asn_random_fill_result_t
(
asn_random_fill_f
)(
33
const
struct
asn_TYPE_descriptor_s
*td,
void
**struct_ptr,
34
const
struct
asn_encoding_constraints_s
*memb_constraints,
35
size_t
max_length);
36
37
/*
38
* Returns 0 if the structure was properly initialized, -1 otherwise.
39
* The (approx_max_length_limit) specifies the approximate limit of the
40
* resulting structure in units closely resembling bytes. The actual result
41
* might be several times larger or smaller than the length limit.
42
*/
43
int
asn_random_fill
(
const
struct
asn_TYPE_descriptor_s
*td,
void
**struct_ptr,
44
size_t
approx_max_length_limit);
45
46
/*
47
* Returns a random number between min and max.
48
*/
49
intmax_t
asn_random_between
(intmax_t min, intmax_t max);
50
51
#endif
/* ASN_RANDOM_FILL */
asn_random_fill_f
asn_random_fill_result_t() asn_random_fill_f(const struct asn_TYPE_descriptor_s *td, void **struct_ptr, const struct asn_encoding_constraints_s *memb_constraints, size_t max_length)
Definition:
asn_random_fill.h:32
asn_random_fill_result_s::code
enum asn_random_fill_result_s::@3 code
asn_random_fill_result_s::length
size_t length
Definition:
asn_random_fill.h:30
asn_TYPE_descriptor_s
Definition:
constr_TYPE.h:224
asn_random_fill_result_s
Definition:
asn_random_fill.h:24
asn_random_fill
int asn_random_fill(const struct asn_TYPE_descriptor_s *td, void **struct_ptr, size_t approx_max_length_limit)
Definition:
asn_random_fill.c:12
asn_random_fill_result_s::ARFILL_FAILED
@ ARFILL_FAILED
Definition:
asn_random_fill.h:26
asn_random_between
intmax_t asn_random_between(intmax_t min, intmax_t max)
Definition:
asn_random_fill.c:38
asn_encoding_constraints_s
Definition:
constr_TYPE.h:208
asn_random_fill_result_t
struct asn_random_fill_result_s asn_random_fill_result_t
asn_random_fill_result_s::ARFILL_SKIPPED
@ ARFILL_SKIPPED
Definition:
asn_random_fill.h:28
asn_random_fill_result_s::ARFILL_OK
@ ARFILL_OK
Definition:
asn_random_fill.h:27
etsi_its_cam_ts_coding
Author(s): Jean-Pierre Busch
, Guido Küppers
, Lennart Reiher
autogenerated on Sun May 18 2025 02:21:22