2004-06-03 03:38:44 +00:00
|
|
|
/*-
|
2006-07-13 11:19:01 +00:00
|
|
|
* Copyright (c) 2004, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
2004-06-03 03:38:44 +00:00
|
|
|
* Redistribution and modifications are permitted subject to BSD license.
|
|
|
|
*/
|
2016-03-14 09:57:07 +00:00
|
|
|
#ifndef ASN1_CONSTRAINTS_VALIDATOR_H
|
|
|
|
#define ASN1_CONSTRAINTS_VALIDATOR_H
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2004-10-20 15:50:55 +00:00
|
|
|
#include <asn_system.h> /* Platform-dependent types */
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2005-07-24 09:03:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-09-29 13:26:15 +00:00
|
|
|
struct asn_TYPE_descriptor_s; /* Forward declaration */
|
2004-06-03 03:38:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Validate the structure according to the ASN.1 constraints.
|
|
|
|
* If errbuf and errlen are given, they shall be pointing to the appropriate
|
|
|
|
* buffer space and its length before calling this function. Alternatively,
|
|
|
|
* they could be passed as NULL's. If constraints validation fails,
|
|
|
|
* errlen will contain the actual number of bytes taken from the errbuf
|
|
|
|
* to encode an error message (properly 0-terminated).
|
2006-07-13 11:19:01 +00:00
|
|
|
*
|
|
|
|
* RETURN VALUES:
|
|
|
|
* This function returns 0 in case all ASN.1 constraints are met
|
|
|
|
* and -1 if one or more constraints were failed.
|
2004-06-03 03:38:44 +00:00
|
|
|
*/
|
|
|
|
int
|
2004-09-29 13:26:15 +00:00
|
|
|
asn_check_constraints(struct asn_TYPE_descriptor_s *type_descriptor,
|
2004-06-03 03:38:44 +00:00
|
|
|
const void *struct_ptr, /* Target language's structure */
|
|
|
|
char *errbuf, /* Returned error description */
|
|
|
|
size_t *errlen /* Length of the error description */
|
|
|
|
);
|
|
|
|
|
2006-07-13 11:19:01 +00:00
|
|
|
|
2004-06-03 03:38:44 +00:00
|
|
|
/*
|
|
|
|
* Generic type for constraint checking callback,
|
|
|
|
* associated with every type descriptor.
|
|
|
|
*/
|
|
|
|
typedef int (asn_constr_check_f)(
|
2004-09-29 13:26:15 +00:00
|
|
|
struct asn_TYPE_descriptor_s *type_descriptor,
|
2004-06-03 03:38:44 +00:00
|
|
|
const void *struct_ptr,
|
2006-07-13 11:19:01 +00:00
|
|
|
asn_app_constraint_failed_f *optional_callback, /* Log the error */
|
|
|
|
void *optional_app_key /* Opaque key passed to a callback */
|
2004-06-03 03:38:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* INTERNALLY USEFUL FUNCTIONS *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
asn_constr_check_f asn_generic_no_constraint; /* No constraint whatsoever */
|
|
|
|
asn_constr_check_f asn_generic_unknown_constraint; /* Not fully supported */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Invoke the callback with a complete error message.
|
|
|
|
*/
|
2016-03-14 10:08:15 +00:00
|
|
|
#define ASN__CTFAIL if(ctfailcb) ctfailcb
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2005-07-24 09:03:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-03-14 09:57:07 +00:00
|
|
|
#endif /* ASN1_CONSTRAINTS_VALIDATOR_H */
|