vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /*- |
| 2 | * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef _BER_DECODER_H_ |
| 6 | #define _BER_DECODER_H_ |
| 7 | |
vlm | d157958 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 8 | #include <asn_application.h> |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 9 | |
vlm | 3a41758 | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
vlm | 574b081 | 2004-09-29 13:24:10 +0000 | [diff] [blame] | 14 | struct asn_TYPE_descriptor_s; /* Forward declaration */ |
| 15 | struct asn_codec_ctx_s; /* Forward declaration */ |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 16 | |
| 17 | /* |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 18 | * The BER decoder of any type. |
| 19 | * This function may be invoked directly from the application. |
| 20 | */ |
vlm | 9de248e | 2004-10-20 15:50:55 +0000 | [diff] [blame] | 21 | asn_dec_rval_t ber_decode(struct asn_codec_ctx_s *opt_codec_ctx, |
vlm | 574b081 | 2004-09-29 13:24:10 +0000 | [diff] [blame] | 22 | struct asn_TYPE_descriptor_s *type_descriptor, |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 23 | void **struct_ptr, /* Pointer to a target structure's pointer */ |
vlm | b02dcc6 | 2005-03-10 18:52:02 +0000 | [diff] [blame] | 24 | const void *buffer, /* Data to be decoded */ |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 25 | size_t size /* Size of that buffer */ |
| 26 | ); |
| 27 | |
| 28 | /* |
| 29 | * Type of generic function which decodes the byte stream into the structure. |
| 30 | */ |
vlm | 9de248e | 2004-10-20 15:50:55 +0000 | [diff] [blame] | 31 | typedef asn_dec_rval_t (ber_type_decoder_f)( |
vlm | 574b081 | 2004-09-29 13:24:10 +0000 | [diff] [blame] | 32 | struct asn_codec_ctx_s *opt_codec_ctx, |
| 33 | struct asn_TYPE_descriptor_s *type_descriptor, |
vlm | b02dcc6 | 2005-03-10 18:52:02 +0000 | [diff] [blame] | 34 | void **struct_ptr, const void *buf_ptr, size_t size, |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 35 | int tag_mode); |
| 36 | |
| 37 | /******************************* |
| 38 | * INTERNALLY USEFUL FUNCTIONS * |
| 39 | *******************************/ |
| 40 | |
| 41 | /* |
| 42 | * Check that all tags correspond to the type definition (as given in head). |
| 43 | * On return, last_length would contain either a non-negative length of the |
| 44 | * value part of the last TLV, or the negative number of expected |
| 45 | * "end of content" sequences. The number may only be negative if the |
| 46 | * head->last_tag_form is non-zero. |
| 47 | */ |
vlm | 9de248e | 2004-10-20 15:50:55 +0000 | [diff] [blame] | 48 | asn_dec_rval_t ber_check_tags( |
vlm | 4d2ca12 | 2005-12-07 05:46:03 +0000 | [diff] [blame] | 49 | struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */ |
| 50 | struct asn_TYPE_descriptor_s *type_descriptor, |
vlm | 574b081 | 2004-09-29 13:24:10 +0000 | [diff] [blame] | 51 | asn_struct_ctx_t *opt_ctx, /* saved decoding context */ |
vlm | b02dcc6 | 2005-03-10 18:52:02 +0000 | [diff] [blame] | 52 | const void *ptr, size_t size, |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 53 | int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ |
vlm | 6678cb1 | 2004-09-26 13:10:40 +0000 | [diff] [blame] | 54 | int last_tag_form, /* {-1,0:1}: any, primitive, constr */ |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 55 | ber_tlv_len_t *last_length, |
vlm | 574b081 | 2004-09-29 13:24:10 +0000 | [diff] [blame] | 56 | int *opt_tlv_form /* optional tag form */ |
| 57 | ); |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 58 | |
vlm | 3a41758 | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 59 | #ifdef __cplusplus |
| 60 | } |
| 61 | #endif |
| 62 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 63 | #endif /* _BER_DECODER_H_ */ |