asn1cpatch_3.p0 42.5 KB
Newer Older
1
2
--- asn1c/unber.c	2015-12-08 14:39:33.282543533 +0100
+++ asn1c/unber.c	2015-12-07 10:46:18.382647000 +0100
3
4
5
6
@@ -779,4 +779,6 @@
 
 asn_enc_rval_t OCTET_STRING_encode_aper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void *sptr, asn_per_outp_t *po) { asn_enc_rval_t er = { 0, 0, 0 }; (void)td; (void)cts; (void)sptr; (void)po; return er; }
 
7
+asn_comp_rval_t *  OCTET_STRING_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) { (void)td1; (void)sptr1; (void)td2; (void)sptr2; return 0; }
8
9
+
 size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size) {  (void)chunk_buf; (void)chunk_size; return 0; }
10
11
--- libasn1compiler/asn1c_C.c	2015-12-08 14:39:33.366543533 +0100
+++ libasn1compiler/asn1c_C.c	2015-12-08 08:38:29.002565000 +0100
12
13
14
15
@@ -1082,6 +1082,8 @@
 	enum tvm_compat tv_mode;
 	enum etd_spec etd_spec;
 	char *p;
16
17
+  //char tmp_buf[512];
+  //int i = 0;
18
19
20
21
22
23
24
25
26
27
28
29
30
 
 	if(arg->embed) {
 		enum tnfmt tnfmt = TNF_CTYPE;
@@ -1243,7 +1245,8 @@
 	OUT("td->uper_decoder   = asn_DEF_%s.uper_decoder;\n",   type_name);
 	OUT("td->uper_encoder   = asn_DEF_%s.uper_encoder;\n",   type_name);
 	OUT("td->aper_decoder   = asn_DEF_%s.aper_decoder;\n",   type_name);
-	OUT("td->aper_encoder   = asn_DEF_%s.aper_encoder;\n",   type_name);
+  OUT("td->aper_encoder   = asn_DEF_%s.aper_encoder;\n",   type_name);
+  OUT("td->compare        = asn_DEF_%s.compare;\n",        type_name);
 	if(!terminal && !tags_count) {
 	  OUT("/* The next four lines are here because of -fknown-extern-type */\n");
 	  OUT("td->tags           = asn_DEF_%s.tags;\n",         type_name);
31
@@ -1413,6 +1416,39 @@
32
33
34
35
 	OUT("}\n");
 	OUT("\n");
 
+
36
37
38
39
40
41
+  //i = 0;
+  //while ((p[i] != '_') && (i < sizeof(tmp_buf))) {
+  //  tmp_buf[i] = p[i];
+  //  i++;
+  //}
+  //tmp_buf[i] = '\0';
42
+  // hack, only for s1ap
43
44
+  //if ((strcmp("S1ap", tmp_buf) == 0) || (strcmp("X2ap", tmp_buf) == 0))
+  //  OUT("#include \"%s-ProtocolIE-ID.h\"\n", tmp_buf);
45
46
47
48
+
+
+  p = MKID(expr);
+  if(HIDE_INNER_DEFS) OUT("static ");
49
+              OUT("asn_comp_rval_t * \n");
50
51
52
53
+  OUT("%s", p);
+  if(HIDE_INNER_DEFS) OUT("_%d", expr->_type_unique_index);
+    OUT("_compare(asn_TYPE_descriptor_t *td1,\n");
+  INDENTED(
54
+  OUT("\tconst void *structure1,\n");
55
+  OUT("\tasn_TYPE_descriptor_t *td2,\n");
56
+  OUT("\tconst void *structure2) {\n");
57
+  OUT("asn_comp_rval_t * res  = NULL;\n");
58
59
60
61
+  OUT("%s_%d_inherit_TYPE_descriptor(td1);\n",
+    p, expr->_type_unique_index);
+  OUT("%s_%d_inherit_TYPE_descriptor(td2);\n",
+    p, expr->_type_unique_index);
62
63
+  OUT("res = td1->compare(td1, structure1, td2, structure2);\n");
+  OUT("return res;\n");
64
65
66
67
68
69
70
+  );
+  OUT("}\n");
+  OUT("\n");
+
 	p = MKID(expr);
 	
 	if(HIDE_INNER_DEFS) OUT("static ");
71
@@ -1450,7 +1486,8 @@
72
73
74
75
76
77
78
79
80
 		OUT("per_type_decoder_f %s_decode_uper;\n", p);
 		OUT("per_type_encoder_f %s_encode_uper;\n", p);
 		OUT("per_type_decoder_f %s_decode_aper;\n", p);
-		OUT("per_type_encoder_f %s_encode_aper;\n", p);
+    OUT("per_type_encoder_f %s_encode_aper;\n", p);
+    OUT("type_compare_f     %s_compare;\n", p);
 		}
 	}
 
81
@@ -2501,6 +2538,7 @@
82
83
84
85
86
87
88
 			OUT("0, 0,\t/* No APER support, "
 				"use \"-gen-PER\" to enable */\n");
 		}
+    FUNCREF(compare);
 
 		if(!terminal || terminal->expr_type == ASN_CONSTR_CHOICE) {
 		//if(expr->expr_type == ASN_CONSTR_CHOICE) {
89
90
--- skeletons/ANY.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/ANY.c	2015-11-26 14:40:56.547616000 +0100
91
92
93
94
95
96
97
98
99
100
@@ -24,7 +24,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	0, 0, 0, 0,
 	0,	/* No PER visible constraints */
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
--- skeletons/asn_application.h	2015-12-08 14:39:12.674543554 +0100
+++ skeletons/asn_application.h	2015-12-07 14:36:32.950633000 +0100
@@ -9,7 +9,8 @@
 #define	_ASN_APPLICATION_H_
 
 #include "asn_system.h"		/* for platform-dependent types */
-#include "asn_codecs.h"		/* for ASN.1 codecs specifics */
+#include "asn_codecs.h"   /* for ASN.1 codecs specifics */
+#include "asn_compare.h"
 
 #ifdef __cplusplus
 extern "C" {
--- skeletons/asn_compare.h	1970-01-01 01:00:00.000000000 +0100
+++ skeletons/asn_compare.h	2015-12-08 10:34:58.090558000 +0100
@@ -0,0 +1,78 @@
+#ifndef	_ASN_COMPARE_H_
+#define	_ASN_COMPARE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct asn_TYPE_descriptor_s;	/* Forward declaration */
+
+
+typedef enum COMPARE_ERR_CODE_e {
+  COMPARE_ERR_CODE_START = 0,
+  COMPARE_ERR_CODE_NONE = COMPARE_ERR_CODE_START,
+  COMPARE_ERR_CODE_NO_MATCH,
+  COMPARE_ERR_CODE_TYPE_MISMATCH,
+  COMPARE_ERR_CODE_TYPE_ARG_NULL,
+  COMPARE_ERR_CODE_VALUE_NULL,
+  COMPARE_ERR_CODE_VALUE_ARG_NULL,
+  COMPARE_ERR_CODE_CHOICE_NUM,
+  COMPARE_ERR_CODE_CHOICE_PRESENT,
+  COMPARE_ERR_CODE_CHOICE_MALFORMED,
+  COMPARE_ERR_CODE_SET_MALFORMED,
+  COMPARE_ERR_CODE_COLLECTION_NUM_ELEMENTS,
+  COMPARE_ERR_CODE_END
+} COMPARE_ERR_CODE_t;
+
+typedef struct asn_comp_rval_s {
+  enum COMPARE_ERR_CODE_e err_code;
+  char                   *name; // e_S1ap_ProtocolIE_ID not available for all ASN1 use (RRC vs S1AP, X2AP)
145
146
+  const void             *structure1;
+  const void             *structure2;
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
+  struct asn_comp_rval_s *next;
+} asn_comp_rval_t;
+
+#define COMPARE_CHECK_ARGS(aRg_tYpE_dEf1, aRg_tYpE_dEf2, aRg_vAl1, aRg_vAl2, rEsUlT) \
+    do {\
+      if ((aRg_tYpE_dEf1) && (aRg_tYpE_dEf2)) {\
+        if ((aRg_tYpE_dEf1->name) && (aRg_tYpE_dEf2->name)) {\
+          if (strcmp(aRg_tYpE_dEf1->name, aRg_tYpE_dEf2->name)) {\
+            rEsUlT           = (asn_comp_rval_t *)calloc(1, sizeof(asn_comp_rval_t));\
+            rEsUlT->err_code = COMPARE_ERR_CODE_TYPE_MISMATCH;\
+            rEsUlT->name     = aRg_tYpE_dEf1->name;\
+            return rEsUlT;\
+          }\
+        } else {\
+          if ((aRg_tYpE_dEf1->xml_tag) && (aRg_tYpE_dEf2->xml_tag)) {\
+            if (strcmp(aRg_tYpE_dEf1->xml_tag, aRg_tYpE_dEf2->xml_tag)) {\
+              rEsUlT           = (asn_comp_rval_t *)calloc(1, sizeof(asn_comp_rval_t));\
+              rEsUlT->err_code = COMPARE_ERR_CODE_TYPE_MISMATCH;\
+              rEsUlT->name     = aRg_tYpE_dEf1->xml_tag;\
+              return rEsUlT;\
+            }\
+          }\
+        }\
+      } else {\
+        rEsUlT             = (asn_comp_rval_t *)calloc(1, sizeof(asn_comp_rval_t));\
+        rEsUlT->name       = aRg_tYpE_dEf1->name;\
+        rEsUlT->structure1 = aRg_vAl1;\
+        rEsUlT->structure2 = aRg_vAl2;\
+        rEsUlT->err_code   = COMPARE_ERR_CODE_TYPE_ARG_NULL;\
+        return rEsUlT;\
+      }\
+      if ((NULL == aRg_vAl1) || (NULL == aRg_vAl2)){\
+        rEsUlT             = (asn_comp_rval_t *)calloc(1, sizeof(asn_comp_rval_t));\
+        rEsUlT->name       = aRg_tYpE_dEf1->name;\
+        rEsUlT->structure1 = aRg_vAl1;\
+        rEsUlT->structure2 = aRg_vAl2;\
+        rEsUlT->err_code   = COMPARE_ERR_CODE_VALUE_ARG_NULL;\
+        return rEsUlT;\
+      }\
+    } while (0);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* _ASN_COMPARE_H_ */
--- skeletons/BIT_STRING.c	2015-12-08 14:39:33.346543533 +0100
+++ skeletons/BIT_STRING.c	2015-11-26 14:41:50.159616000 +0100
196
197
198
199
200
201
202
203
204
205
@@ -30,7 +30,8 @@
 	OCTET_STRING_decode_uper,	/* Unaligned PER decoder */
 	OCTET_STRING_encode_uper,	/* Unaligned PER encoder */
 	OCTET_STRING_decode_aper,	/* Aligned PER decoder */
-	OCTET_STRING_encode_aper,	/* Aligned PER encoder */
+  OCTET_STRING_encode_aper, /* Aligned PER encoder */
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_BIT_STRING_tags,
 	sizeof(asn_DEF_BIT_STRING_tags)
206
207
--- skeletons/BMPString.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/BMPString.c	2015-11-26 14:42:08.487616000 +0100
208
209
210
211
212
213
214
215
216
217
@@ -36,7 +36,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,	/* Aligned PER decoder */
-	OCTET_STRING_encode_aper,	/* Aligned PER encoder */
+  OCTET_STRING_encode_aper, /* Aligned PER encoder */
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_BMPString_tags,
 	sizeof(asn_DEF_BMPString_tags)
218
219
--- skeletons/BOOLEAN.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/BOOLEAN.c	2015-12-08 10:37:11.866558000 +0100
220
221
222
223
224
225
226
227
228
229
@@ -25,7 +25,8 @@
 	BOOLEAN_decode_uper,	/* Unaligned PER decoder */
 	BOOLEAN_encode_uper,	/* Unaligned PER encoder */
 	BOOLEAN_decode_aper,	/* Aligned PER decoder */
-	BOOLEAN_encode_aper,	/* Aligned PER encoder */
+  BOOLEAN_encode_aper,  /* Aligned PER encoder */
+  BOOLEAN_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_BOOLEAN_tags,
 	sizeof(asn_DEF_BOOLEAN_tags) / sizeof(asn_DEF_BOOLEAN_tags[0]),
230
@@ -326,3 +327,22 @@
231
232
233
234
 
 	_ASN_ENCODED_OK(er);
 }
+
235
+asn_comp_rval_t *
236
+BOOLEAN_compare(asn_TYPE_descriptor_t *td1,
237
+  const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) {
238
239
+  const BOOLEAN_t *st1 = (const BOOLEAN_t *)sptr1;
+  const BOOLEAN_t *st2 = (const BOOLEAN_t *)sptr2;
240
241
242
243
244
245
246
247
248
249
250
+  asn_comp_rval_t *res = NULL;
+
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (*st1 == *st2) return NULL;
+  res = calloc(1, sizeof(asn_comp_rval_t));
+  res->name = td1->name;
+  res->structure1 = sptr1;
+  res->structure2 = sptr2;
+  res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+  return res;
251
252
+}
+
253
254
--- skeletons/BOOLEAN.h	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/BOOLEAN.h	2015-11-26 12:46:58.491623000 +0100
255
256
257
258
259
260
261
262
@@ -30,6 +30,7 @@
 per_type_encoder_f BOOLEAN_encode_uper;
 per_type_decoder_f BOOLEAN_decode_aper;
 per_type_encoder_f BOOLEAN_encode_aper;
+type_compare_f     BOOLEAN_compare;
 
 #ifdef __cplusplus
 }
263
264
265
--- skeletons/compare.h	1970-01-01 01:00:00.000000000 +0100
+++ skeletons/compare.h	2015-12-08 08:23:03.694566000 +0100
@@ -0,0 +1,28 @@
266
267
268
269
270
271
272
273
274
275
276
277
278
279
+/*-
+ * Eurecom 2015.
+ */
+#ifndef	_COMPARE_H_
+#define	_COMPARE_H_
+
+#include <asn_application.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct asn_TYPE_descriptor_s;	/* Forward declaration */
+
280
+typedef asn_comp_rval_t * (type_compare_f)(
281
+  struct asn_TYPE_descriptor_s *type_descriptor1,
282
+  const void *struct_ptr1,
283
+  struct asn_TYPE_descriptor_s *type_descriptor2,
284
+  const void *struct_ptr2
285
286
+);
+
287
288
+
+
289
290
291
292
293
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* _COMPARE_H_ */
294
295
296
--- skeletons/constr_CHOICE.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/constr_CHOICE.c	2015-12-08 10:39:16.670558000 +0100
@@ -1272,3 +1272,75 @@
297
298
299
300
 		assert(pres_size != sizeof(int));
 	}
 }
+
301
+asn_comp_rval_t *
302
+CHOICE_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2)
303
304
305
306
307
+{
+  asn_CHOICE_specifics_t *specs1 = (asn_CHOICE_specifics_t *)td1->specifics;
+  asn_CHOICE_specifics_t *specs2 = (asn_CHOICE_specifics_t *)td2->specifics;
+  int present1;
+  int present2;
308
+  asn_comp_rval_t *res = NULL;
309
+
310
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
311
312
313
314
315
316
317
318
+
+  /*
+   * Figure out which CHOICE element is encoded.
+   */
+  present1 = _fetch_present_idx(sptr1, specs1->pres_offset,specs1->pres_size);
+  // same specs
+  present2 = _fetch_present_idx(sptr2, specs2->pres_offset,specs2->pres_size);
+
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
+  if (td1->elements_count != td2->elements_count) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_CHOICE_NUM;
+    return res;
+  }
+  if (present1 != present2) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_CHOICE_PRESENT;
+    return res;
+  }
335
336
337
338
339
340
341
342
343
+  if(present1 > 0 && present1 <= td1->elements_count) {
+    asn_TYPE_member_t *elm1 = &td1->elements[present1-1];
+    asn_TYPE_member_t *elm2 = &td2->elements[present2-1];
+    const void *memb_ptr1;
+    const void *memb_ptr2;
+
+    if((elm1->flags & ATF_POINTER) && (elm1->flags & ATF_POINTER)){
+      memb_ptr1 = *(const void * const *)((const char *)sptr1 + elm1->memb_offset);
+      memb_ptr2 = *(const void * const *)((const char *)sptr2 + elm2->memb_offset);
344
345
346
347
348
349
350
351
+      if((!memb_ptr1) || (!memb_ptr2)) {
+        res = calloc(1, sizeof(asn_comp_rval_t));
+        res->name = td1->name;
+        res->structure1 = sptr1;
+        res->structure2 = sptr2;
+        res->err_code = COMPARE_ERR_CODE_VALUE_NULL;
+        return res;
+      }
352
353
354
355
+    } else if (!(elm1->flags & ATF_POINTER) && !(elm1->flags & ATF_POINTER)){
+      memb_ptr1 = (const void *)((const char *)sptr1 + elm1->memb_offset);
+      memb_ptr2 = (const void *)((const char *)sptr2 + elm2->memb_offset);
+    } else {
356
357
358
359
360
361
+      res = calloc(1, sizeof(asn_comp_rval_t));
+      res->name = td1->name;
+      res->structure1 = sptr1;
+      res->structure2 = sptr2;
+      res->err_code = COMPARE_ERR_CODE_CHOICE_MALFORMED;
+      return res;
362
363
364
+    }
+    return elm1->type->compare(elm1->type, memb_ptr1, elm2->type, memb_ptr2);
+  }
365
366
367
368
369
370
+  res = calloc(1, sizeof(asn_comp_rval_t));
+  res->name = td1->name;
+  res->structure1 = sptr1;
+  res->structure2 = sptr2;
+  res->err_code = COMPARE_ERR_CODE_CHOICE_MALFORMED;
+  return res;
371
+}
372
373
--- skeletons/constr_CHOICE.h	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/constr_CHOICE.h	2015-11-26 14:43:57.647616000 +0100
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
@@ -39,7 +39,7 @@
 /*
  * A set specialized functions dealing with the CHOICE type.
  */
-asn_struct_free_f CHOICE_free;
+asn_struct_free_f  CHOICE_free;
 asn_struct_print_f CHOICE_print;
 asn_constr_check_f CHOICE_constraint;
 ber_type_decoder_f CHOICE_decode_ber;
@@ -50,7 +50,8 @@
 per_type_encoder_f CHOICE_encode_uper;
 per_type_decoder_f CHOICE_decode_aper;
 per_type_encoder_f CHOICE_encode_aper;
-asn_outmost_tag_f CHOICE_outmost_tag;
+type_compare_f     CHOICE_compare;
+asn_outmost_tag_f  CHOICE_outmost_tag;
 
 #ifdef __cplusplus
 }
393
394
--- skeletons/constr_SEQUENCE.c	2015-12-08 14:39:33.346543533 +0100
+++ skeletons/constr_SEQUENCE.c	2015-12-08 10:39:52.442558000 +0100
395
@@ -1761,3 +1761,65 @@
396
397
398
399
 
 	_ASN_ENCODED_OK(er);
 }
+
400
+asn_comp_rval_t * SEQUENCE_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) {
401
+  int edx;
402
403
+  asn_comp_rval_t *res = NULL;
+  asn_comp_rval_t *res2 = NULL;
404
+
405
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
406
+
407
408
409
410
411
412
413
+  if (td1->elements_count != td2->elements_count) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_COLLECTION_NUM_ELEMENTS;
+    return res;
414
415
416
417
418
419
420
421
422
423
424
425
426
427
+  }
+
+  for(edx = 0; edx < td1->elements_count; edx++) {
+    asn_TYPE_member_t *elm1 = &td1->elements[edx];
+    asn_TYPE_member_t *elm2 = &td1->elements[edx];
+    const void *memb_ptr1;
+    const void *memb_ptr2;
+
+    if(elm1->flags & ATF_POINTER) {
+      memb_ptr1 = *(const void * const *)((const char *)sptr1 + elm1->memb_offset);
+      memb_ptr2 = *(const void * const *)((const char *)sptr2 + elm2->memb_offset);
+      if((!memb_ptr1) && (!memb_ptr2)) {
+        if(elm1->optional) continue;
+      }
428
429
430
431
432
433
434
435
436
437
438
439
440
441
+      if ((!memb_ptr1) || (!memb_ptr2)) {
+        res2 = calloc(1, sizeof(asn_comp_rval_t));
+        res2->name = elm1->name;
+        res2->structure1 = memb_ptr1;
+        res2->structure2 = memb_ptr2;
+        res->err_code = COMPARE_ERR_CODE_VALUE_NULL;
+        if (NULL == res) {
+          res = res2;
+        } else {
+          res2->next = res;
+          res = res2;
+        }
+        res2 = NULL;
+      }
442
443
444
445
446
447
+    } else {
+      memb_ptr1 = (const void *)((const char *)sptr1 + elm1->memb_offset);
+      memb_ptr2 = (const void *)((const char *)sptr2 + elm2->memb_offset);
+    }
+
+    /* Compare the member itself */
448
449
450
451
452
453
454
455
456
457
+    res2 = elm1->type->compare(elm1->type, memb_ptr1, elm2->type, memb_ptr2);
+    if(res2) {
+      if (NULL == res) {
+        res = res2;
+      } else {
+        res2->next = res;
+        res = res2;
+      }
+      res2 = NULL;
+    }
458
+  }
459
+  return res;
460
+}
461
462
--- skeletons/constr_SEQUENCE.h	2015-12-08 14:39:33.346543533 +0100
+++ skeletons/constr_SEQUENCE.h	2015-11-26 14:48:14.123616000 +0100
463
464
465
466
467
468
469
470
@@ -54,6 +54,7 @@
 per_type_encoder_f SEQUENCE_encode_uper;
 per_type_decoder_f SEQUENCE_decode_aper;
 per_type_encoder_f SEQUENCE_encode_aper;
+type_compare_f     SEQUENCE_compare;
 
 #ifdef __cplusplus
 }
471
472
--- skeletons/constr_SEQUENCE_OF.h	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/constr_SEQUENCE_OF.h	2015-11-26 15:05:25.399615000 +0100
473
474
475
476
477
478
479
480
481
482
@@ -22,7 +22,8 @@
 #define	SEQUENCE_OF_decode_ber	SET_OF_decode_ber
 #define	SEQUENCE_OF_decode_xer	SET_OF_decode_xer
 #define	SEQUENCE_OF_decode_uper	SET_OF_decode_uper
-#define	SEQUENCE_OF_decode_aper	SET_OF_decode_aper
+#define SEQUENCE_OF_decode_aper SET_OF_decode_aper
+#define SEQUENCE_OF_compare     SET_OF_compare
 der_type_encoder_f SEQUENCE_OF_encode_der;
 xer_type_encoder_f SEQUENCE_OF_encode_xer;
 per_type_encoder_f SEQUENCE_OF_encode_uper;
483
484
--- skeletons/constr_SET.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/constr_SET.c	2015-12-08 10:40:35.066558000 +0100
485
486
487
488
489
490
491
492
493
@@ -1108,7 +1108,7 @@
 	}
 }
 
-int
+long
 SET_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
 	int edx;
494
495
496
497
498
499
@@ -1159,3 +1159,58 @@
 
 	return 0;
 }
+
+asn_comp_rval_t *
500
+SET_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2)
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
+{
+  int edx;
+  asn_comp_rval_t *res = NULL;
+  asn_comp_rval_t *res2 = NULL;
+
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (td1->elements_count != td2->elements_count) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_COLLECTION_NUM_ELEMENTS;
+    return res;
+  }
+
+  for(edx = 0; edx < td1->elements_count; edx++) {
+    asn_TYPE_member_t *elm1 = &td1->elements[edx];
+    asn_TYPE_member_t *elm2 = &td2->elements[edx];
+    const void *memb_ptr1;
+    const void *memb_ptr2;
+
+    if(elm1->flags & ATF_POINTER) {
+      memb_ptr1 = *(const void * const *)((const char *)sptr1 + elm1->memb_offset);
+      memb_ptr2 = *(const void * const *)((const char *)sptr2 + elm2->memb_offset);
+      if(!memb_ptr1) {
+        if(elm1->optional)
+          continue;
+        res = calloc(1, sizeof(asn_comp_rval_t));
+        res->name = td1->name;
+        res->structure1 = sptr1;
+        res->structure2 = sptr2;
+        res->err_code = COMPARE_ERR_CODE_SET_MALFORMED;
+        return res;
+      }
+    } else {
+      memb_ptr1 = (const void *)((const char *)sptr1 + elm1->memb_offset);
+      memb_ptr2 = (const void *)((const char *)sptr2 + elm2->memb_offset);
+    }
+    res2 = elm1->type->compare(elm1->type, memb_ptr1, elm2->type, memb_ptr2);
+    if(res2) {
+      if (NULL == res) {
+        res = res2;
+      } else {
+        res2->next = res;
+        res = res2;
+      }
+      res2 = NULL;
+    }
+  }
+  return res;
+}
--- skeletons/constr_SET.h	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/constr_SET.h	2015-11-26 14:49:09.243616000 +0100
555
556
557
558
559
560
561
562
@@ -56,6 +56,7 @@
 per_type_decoder_f SET_decode_aper;
 per_type_encoder_f SET_encode_uper;
 per_type_encoder_f SET_encode_aper;
+type_compare_f     SET_compare;
 
 /***********************
  * Some handy helpers. *
563
564
--- skeletons/constr_SET_OF.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/constr_SET_OF.c	2015-12-08 10:45:54.466557000 +0100
565
@@ -1039,3 +1039,54 @@
566
567
568
569
 	rv.consumed = 0;
 	return rv;
 }
+
570
+asn_comp_rval_t *
571
+SET_OF_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2)
572
573
574
575
576
577
+{
+  asn_TYPE_member_t *elm1 = td1->elements;
+  asn_TYPE_member_t *elm2 = td2->elements;
+  const asn_anonymous_set_ *list1 = _A_CSET_FROM_VOID(sptr1);
+  const asn_anonymous_set_ *list2 = _A_CSET_FROM_VOID(sptr2);
+  int i;
578
579
+  asn_comp_rval_t *res = NULL;
+  asn_comp_rval_t *res2 = NULL;
580
+
581
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
582
+
583
584
585
586
587
588
589
+  if (td1->elements_count != td2->elements_count) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_COLLECTION_NUM_ELEMENTS;
+    return res;
590
591
592
+  }
+
+
593
594
595
596
597
598
599
600
+  if (list1->count != list2->count ) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_COLLECTION_NUM_ELEMENTS;
+    return res;
+  }
601
602
603
604
605
606
+
+  for(i = 0; i < list1->count; i++) {
+    const void *memb_ptr1 = list1->array[i];
+    const void *memb_ptr2 = list2->array[i];
+    if ((!memb_ptr1) & (!memb_ptr2)) continue;
+
607
608
609
610
611
612
613
614
615
616
+    res2 = elm1->type->compare(elm1->type, memb_ptr1, elm2->type, memb_ptr2);
+    if(res2) {
+      if (NULL == res) {
+        res = res2;
+      } else {
+        res2->next = res;
+        res = res2;
+      }
+      res2 = NULL;
+    }
617
+  }
618
+  return  res;
619
+}
620
621
--- skeletons/constr_SET_OF.h	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/constr_SET_OF.h	2015-11-26 14:48:45.067616000 +0100
622
623
624
625
626
627
628
629
@@ -36,6 +36,7 @@
 per_type_encoder_f SET_OF_encode_uper;
 per_type_decoder_f SET_OF_decode_aper;
 per_type_encoder_f SET_OF_encode_aper;
+type_compare_f     SET_OF_compare;
 
 #ifdef __cplusplus
 }
630
631
--- skeletons/constr_TYPE.h	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/constr_TYPE.h	2015-11-26 15:28:05.495613000 +0100
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
@@ -41,7 +41,8 @@
 #include <xer_encoder.h>	/* Encoder into XER (XML, text) */
 #include <per_decoder.h>	/* Packet Encoding Rules decoder */
 #include <per_encoder.h>	/* Packet Encoding Rules encoder */
-#include <constraints.h>	/* Subtype constraints support */
+#include <constraints.h>  /* Subtype constraints support */
+#include <compare.h>      /* Comparison */
 
 /*
  * Free the structure according to its specification.
@@ -101,6 +102,7 @@
 	per_type_encoder_f *uper_encoder;	/* Unaligned PER encoder */
 	per_type_decoder_f *aper_decoder;	/* Aligned PER decoder */
 	per_type_encoder_f *aper_encoder;	/* Aligned PER encoder */
+	type_compare_f     *compare;      /* Comparison between 2 instances */
 
 	/***********************************************************************
 	 * Internally useful members. Not to be used by applications directly. *
650
651
--- skeletons/ENUMERATED.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/ENUMERATED.c	2015-12-08 10:40:55.986558000 +0100
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
@@ -27,7 +27,8 @@
 	ENUMERATED_decode_uper,	/* Unaligned PER decoder */
 	ENUMERATED_encode_uper,	/* Unaligned PER encoder */
 	ENUMERATED_decode_aper,	/* Aligned PER decoder */
-	ENUMERATED_encode_aper,	/* Aligned PER encoder */
+  ENUMERATED_encode_aper, /* Aligned PER encoder */
+  ENUMERATED_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_ENUMERATED_tags,
 	sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]),
@@ -103,3 +104,22 @@
 	
 	return NativeEnumerated_encode_aper(td, constraints, &value, po);
 }
+
667
+asn_comp_rval_t *
668
669
670
671
+ENUMERATED_compare(asn_TYPE_descriptor_t *td1, const void *sptr1,
+                   asn_TYPE_descriptor_t *td2, const void *sptr2) {
+  const ENUMERATED_t *st1 = (const ENUMERATED_t *)sptr1;
+  const ENUMERATED_t *st2 = (const ENUMERATED_t *)sptr2;
672
+  asn_comp_rval_t *res = NULL;
673
+
674
675
676
677
678
679
680
681
682
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (*st1 == *st2) return NULL;
+  res = calloc(1, sizeof(asn_comp_rval_t));
+  res->name = td1->name;
+  res->structure1 = sptr1;
+  res->structure2 = sptr2;
+  res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+  return res;
683
684
+}
+
685
686
--- skeletons/ENUMERATED.h	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/ENUMERATED.h	2015-11-26 12:46:35.523623000 +0100
687
688
689
690
691
692
693
694
@@ -19,6 +19,7 @@
 per_type_encoder_f ENUMERATED_encode_uper;
 per_type_decoder_f ENUMERATED_decode_aper;
 per_type_encoder_f ENUMERATED_encode_aper;
+type_compare_f     ENUMERATED_compare;
 
 #ifdef __cplusplus
 }
695
696
697
--- skeletons/file-dependencies	2015-12-08 14:39:12.678543554 +0100
+++ skeletons/file-dependencies	2015-12-07 15:34:40.454629000 +0100
@@ -39,12 +39,13 @@
698
699
700
701
702
703
704
 constr_SEQUENCE.h constr_SEQUENCE.c
 constr_SEQUENCE_OF.h constr_SEQUENCE_OF.c asn_SEQUENCE_OF.h constr_SET_OF.h
 constr_SET.h constr_SET.c
-constr_SET_OF.h constr_SET_OF.c asn_SET_OF.h
+constr_SET_OF.h constr_SET_OF.c asn_SET_OF.h compare.h
 
 COMMON-FILES:			# THIS IS A SPECIAL SECTION
705
706
707
708
709
710
711
712
713
714
715
-asn_application.h		# Applications should include this file
+asn_application.h   # Applications should include this file
 asn_system.h			# Platform-dependent types
-asn_codecs.h			# Return types of encoders and decoders
+asn_codecs.h      # Return types of encoders and decoders
+asn_compare.h     # Return type of compare
 asn_internal.h			# Internal stuff
 OCTET_STRING.h OCTET_STRING.c	# This one is used too widely
 BIT_STRING.h BIT_STRING.c	# This one is necessary for the above one
--- skeletons/GeneralizedTime.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/GeneralizedTime.c	2015-11-26 15:09:03.899615000 +0100
716
717
718
719
720
721
722
723
724
725
@@ -168,7 +168,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_GeneralizedTime_tags,
 	sizeof(asn_DEF_GeneralizedTime_tags)
726
727
--- skeletons/GeneralString.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/GeneralString.c	2015-11-26 14:50:11.843616000 +0100
728
729
730
731
732
733
734
735
736
737
@@ -25,7 +25,8 @@
 	OCTET_STRING_decode_uper,    /* Implemented in terms of OCTET STRING */
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_GeneralString_tags,
 	sizeof(asn_DEF_GeneralString_tags)
738
739
--- skeletons/GraphicString.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/GraphicString.c	2015-11-26 15:33:33.255613000 +0100
740
741
742
743
744
745
746
747
748
749
@@ -25,7 +25,8 @@
 	OCTET_STRING_decode_uper,    /* Implemented in terms of OCTET STRING */
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_GraphicString_tags,
 	sizeof(asn_DEF_GraphicString_tags)
750
751
--- skeletons/IA5String.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/IA5String.c	2015-11-26 14:50:44.219616000 +0100
752
753
754
755
756
757
758
759
@@ -31,6 +31,7 @@
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
 	OCTET_STRING_encode_aper,
+	OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_IA5String_tags,
 	sizeof(asn_DEF_IA5String_tags)
760
761
--- skeletons/INTEGER.c	2015-12-08 14:39:33.346543533 +0100
+++ skeletons/INTEGER.c	2015-12-08 10:41:08.526558000 +0100
762
763
764
765
766
767
768
769
@@ -35,6 +35,7 @@
 	INTEGER_decode_aper,
 	INTEGER_encode_aper,
 #endif	/* ASN_DISABLE_PER_SUPPORT */
+	INTEGER_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_INTEGER_tags,
 	sizeof(asn_DEF_INTEGER_tags) / sizeof(asn_DEF_INTEGER_tags[0]),
770
@@ -1501,3 +1502,30 @@
771
772
773
 }
 
 
774
+asn_comp_rval_t *
775
776
777
778
+INTEGER_compare(asn_TYPE_descriptor_t *td1, const void *sptr1,
+                asn_TYPE_descriptor_t *td2, const void *sptr2) {
+  const INTEGER_t *st1 = (const INTEGER_t *)sptr1;
+  const INTEGER_t *st2 = (const INTEGER_t *)sptr2;
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
+  asn_comp_rval_t *res = NULL;
+
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (st1->size != st2->size) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
+  }
+  if (0 != memcmp(st1->buf, st2->buf, st1->size)) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
798
+  }
799
+  return NULL;
800
+}
801
802
--- skeletons/INTEGER.h	2015-12-08 14:39:33.346543533 +0100
+++ skeletons/INTEGER.h	2015-11-26 12:50:41.551623000 +0100
803
804
805
806
807
808
809
810
@@ -43,6 +43,7 @@
 per_type_encoder_f INTEGER_encode_uper;
 per_type_decoder_f INTEGER_decode_aper;
 per_type_encoder_f INTEGER_encode_aper;
+type_compare_f     INTEGER_compare;
 
 /***********************************
  * Some handy conversion routines. *
811
812
--- skeletons/ISO646String.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/ISO646String.c	2015-11-26 12:55:48.327623000 +0100
813
814
815
816
817
818
819
820
821
822
@@ -30,7 +30,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_ISO646String_tags,
 	sizeof(asn_DEF_ISO646String_tags)
823
824
825
826
827
828
829
830
--- skeletons/Makefile.am	2015-12-08 14:39:12.666543554 +0100
+++ skeletons/Makefile.am	2015-12-07 15:54:00.150628000 +0100
@@ -46,11 +46,11 @@
 	asn_SET_OF.c asn_SET_OF.h			\
 	asn_application.h asn_codecs.h			\
 	asn_codecs_prim.c asn_codecs_prim.h		\
-	asn_internal.h asn_system.h			\
+	asn_internal.h asn_system.h asn_compare.h			\
831
832
 	ber_decoder.c ber_decoder.h			\
 	ber_tlv_length.c ber_tlv_length.h		\
833
-	ber_tlv_tag.c ber_tlv_tag.h			\
834
-	constr_CHOICE.c constr_CHOICE.h			\
835
+	ber_tlv_tag.c ber_tlv_tag.h compare.h			\
836
837
838
839
+	comparison.h constr_CHOICE.c constr_CHOICE.h			\
 	constr_SEQUENCE.c constr_SEQUENCE.h		\
 	constr_SEQUENCE_OF.c constr_SEQUENCE_OF.h	\
 	constr_SET.c constr_SET.h			\
840
841
--- skeletons/NativeEnumerated.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/NativeEnumerated.c	2015-12-08 10:41:17.662558000 +0100
842
843
844
845
846
847
848
849
850
851
@@ -31,7 +31,8 @@
 	NativeEnumerated_decode_uper,
 	NativeEnumerated_encode_uper,
 	NativeEnumerated_decode_aper,
-	NativeEnumerated_encode_aper,
+  NativeEnumerated_encode_aper,
+  NativeEnumerated_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_NativeEnumerated_tags,
 	sizeof(asn_DEF_NativeEnumerated_tags) / sizeof(asn_DEF_NativeEnumerated_tags[0]),
852
@@ -335,3 +336,22 @@
853
854
855
856
 
 	_ASN_ENCODED_OK(er);
 }
+
857
+asn_comp_rval_t *
858
859
+NativeEnumerated_compare(asn_TYPE_descriptor_t *td1, const void *sptr1,
+    asn_TYPE_descriptor_t *td2, const void *sptr2) {
860
861
+  const asn_INTEGER_enum_map_t *a = sptr1;
+  const asn_INTEGER_enum_map_t *b = sptr2;
862
863
864
+  asn_comp_rval_t *res = NULL;
+
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
865
866
+
+  if(a->nat_value == b->nat_value)
867
868
869
870
871
872
873
+    return NULL;
+  res = calloc(1, sizeof(asn_comp_rval_t));
+  res->name = td1->name;
+  res->structure1 = sptr1;
+  res->structure2 = sptr2;
+  res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+  return res;
874
+}
875
876
--- skeletons/NativeEnumerated.h	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/NativeEnumerated.h	2015-11-26 14:51:43.315616000 +0100
877
878
879
880
881
882
883
884
@@ -26,6 +26,7 @@
 per_type_encoder_f NativeEnumerated_encode_uper;
 per_type_decoder_f NativeEnumerated_decode_aper;
 per_type_encoder_f NativeEnumerated_encode_aper;
+type_compare_f     NativeEnumerated_compare;
 
 #ifdef __cplusplus
 }
885
886
--- skeletons/NativeInteger.c	2015-12-08 14:39:33.346543533 +0100
+++ skeletons/NativeInteger.c	2015-12-08 10:41:24.550558000 +0100
887
888
889
890
891
892
893
894
895
896
@@ -32,7 +32,8 @@
 	NativeInteger_decode_uper,	/* Unaligned PER decoder */
 	NativeInteger_encode_uper,	/* Unaligned PER encoder */
 	NativeInteger_decode_aper,	/* Aligned PER decoder */
-	NativeInteger_encode_aper,	/* Aligned PER encoder */
+  NativeInteger_encode_aper,  /* Aligned PER encoder */
+  NativeInteger_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_NativeInteger_tags,
 	sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]),
897
@@ -410,3 +411,21 @@
898
899
900
901
 	}
 }
 
+
902
+asn_comp_rval_t *
903
904
+NativeInteger_compare(asn_TYPE_descriptor_t *td1, const void *sptr1,
+                      asn_TYPE_descriptor_t *td2, const void *sptr2) {
905
906
+  const long *native1 = (const long *)sptr1;
+  const long *native2 = (const long *)sptr2;
907
908
909
910
911
912
913
914
915
916
917
+  asn_comp_rval_t *res = NULL;
+
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (*native1 == *native2) return NULL;
+  res = calloc(1, sizeof(asn_comp_rval_t));
+  res->name = td1->name;
+  res->structure1 = sptr1;
+  res->structure2 = sptr2;
+  res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+  return res;
918
+}
919
920
--- skeletons/NativeInteger.h	2015-12-08 14:39:33.346543533 +0100
+++ skeletons/NativeInteger.h	2015-11-26 14:52:13.931616000 +0100
921
922
923
924
925
926
927
928
@@ -31,6 +31,7 @@
 per_type_encoder_f NativeInteger_encode_uper;
 per_type_decoder_f NativeInteger_decode_aper;
 per_type_encoder_f NativeInteger_encode_aper;
+type_compare_f     NativeInteger_compare;
 
 #ifdef __cplusplus
 }
929
930
--- skeletons/NativeReal.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/NativeReal.c	2015-12-08 10:41:32.666558000 +0100
931
932
933
934
935
936
937
938
939
940
@@ -33,7 +33,8 @@
 	NativeReal_decode_uper,
 	NativeReal_encode_uper,
 	NativeReal_decode_aper,
-	NativeReal_encode_aper,
+  NativeReal_encode_aper,
+  NativeReal_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_NativeReal_tags,
 	sizeof(asn_DEF_NativeReal_tags) / sizeof(asn_DEF_NativeReal_tags[0]),
941
@@ -405,3 +406,30 @@
942
943
944
 	}
 }
 
945
+asn_comp_rval_t *
946
947
948
949
+NativeReal_compare(asn_TYPE_descriptor_t *td1, const void *sptr1,
+                   asn_TYPE_descriptor_t *td2, const void *sptr2) {
+  const REAL_t *st1 = (const REAL_t *)sptr1;
+  const REAL_t *st2 = (const REAL_t *)sptr2;
950
+  asn_comp_rval_t *res = NULL;
951
+
952
953
954
955
956
957
958
959
960
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (st1->size != st2->size) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
961
+  }
962
963
964
965
966
967
968
969
970
+  if (0 != memcmp(st1->buf, st2->buf, st1->size)) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
+  }
+  return NULL;
971
+}
972
973
--- skeletons/NativeReal.h	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/NativeReal.h	2015-11-26 14:31:12.631617000 +0100
974
975
976
977
978
979
980
981
@@ -29,6 +29,7 @@
 per_type_encoder_f NativeReal_encode_uper;
 per_type_decoder_f NativeReal_decode_aper;
 per_type_encoder_f NativeReal_encode_aper;
+type_compare_f     NativeReal_compare;
 
 #ifdef __cplusplus
 }
982
983
--- skeletons/NULL.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/NULL.c	2015-12-07 10:49:05.178647000 +0100
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
@@ -26,7 +26,8 @@
 	NULL_decode_uper,	/* Unaligned PER decoder */
 	NULL_encode_uper,	/* Unaligned PER encoder */
 	NULL_decode_aper,	/* Aligned PER decoder */
-	NULL_encode_aper,	/* Aligned PER encoder */
+  NULL_encode_aper, /* Aligned PER encoder */
+  NULL_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_NULL_tags,
 	sizeof(asn_DEF_NULL_tags) / sizeof(asn_DEF_NULL_tags[0]),
@@ -192,3 +193,10 @@
 	er.encoded = 0;
 	_ASN_ENCODED_OK(er);
 }
+
999
+asn_comp_rval_t *
1000
1001
+NULL_compare(asn_TYPE_descriptor_t *td1, const void *sptr1,
+             asn_TYPE_descriptor_t *td2, const void *sptr2) {
1002
+
1003
+  return NULL;
1004
+}
1005
1006
--- skeletons/NULL.h	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/NULL.h	2015-11-26 14:53:03.875616000 +0100
1007
1008
1009
1010
1011
1012
1013
1014
@@ -27,6 +27,7 @@
 per_type_encoder_f NULL_encode_uper;
 per_type_decoder_f NULL_decode_aper;
 per_type_encoder_f NULL_encode_aper;
+type_compare_f     NULL_compare;
 
 #ifdef __cplusplus
 }
1015
1016
--- skeletons/NumericString.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/NumericString.c	2015-11-26 14:40:39.407616000 +0100
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
@@ -50,7 +50,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_NumericString_tags,
 	sizeof(asn_DEF_NumericString_tags)
1027
1028
--- skeletons/ObjectDescriptor.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/ObjectDescriptor.c	2015-11-26 14:55:46.227615000 +0100
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
@@ -25,7 +25,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_ObjectDescriptor_tags,
 	sizeof(asn_DEF_ObjectDescriptor_tags)
1039
1040
--- skeletons/OBJECT_IDENTIFIER.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/OBJECT_IDENTIFIER.c	2015-11-26 14:55:13.311615000 +0100
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
@@ -28,7 +28,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_OBJECT_IDENTIFIER_tags,
 	sizeof(asn_DEF_OBJECT_IDENTIFIER_tags)
1051
1052
--- skeletons/OCTET_STRING.c	2015-12-08 14:39:44.554543521 +0100
+++ skeletons/OCTET_STRING.c	2015-12-08 10:41:42.838558000 +0100
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
@@ -37,7 +37,8 @@
 	OCTET_STRING_decode_uper,	/* Unaligned PER decoder */
 	OCTET_STRING_encode_uper,	/* Unaligned PER encoder */
 	OCTET_STRING_decode_aper,	/* Aligned PER decoder */
-	OCTET_STRING_encode_aper,	/* Aligned PER encoder */
+  OCTET_STRING_encode_aper, /* Aligned PER encoder */
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_OCTET_STRING_tags,
 	sizeof(asn_DEF_OCTET_STRING_tags)
1063
@@ -2160,3 +2161,30 @@
1064
1065
1066
 	return st;
 }
 
1067
+asn_comp_rval_t *
1068
+OCTET_STRING_compare(asn_TYPE_descriptor_t *td1,
1069
1070
1071
+  const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) {
+  const OCTET_STRING_t *st1 = (const OCTET_STRING_t *)sptr1;
+  const OCTET_STRING_t *st2 = (const OCTET_STRING_t *)sptr2;
1072
+  asn_comp_rval_t *res = NULL;
1073
+
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (st1->size != st2->size) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
+  }
+  if (0 != memcmp(st1->buf, st2->buf, st1->size)) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
1091
+  }
1092
+  return NULL;
1093
+}
1094
1095
--- skeletons/OCTET_STRING.h	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/OCTET_STRING.h	2015-11-26 12:56:15.259623000 +0100
1096
1097
1098
1099
1100
1101
1102
1103
@@ -34,6 +34,7 @@
 per_type_encoder_f OCTET_STRING_encode_uper;
 per_type_decoder_f OCTET_STRING_decode_aper;
 per_type_encoder_f OCTET_STRING_encode_aper;
+type_compare_f     OCTET_STRING_compare;
 
 /******************************
  * Handy conversion routines. *
1104
1105
--- skeletons/PrintableString.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/PrintableString.c	2015-11-26 14:56:09.787615000 +0100
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
@@ -60,7 +60,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_PrintableString_tags,
 	sizeof(asn_DEF_PrintableString_tags)
1116
1117
--- skeletons/REAL.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/REAL.c	2015-12-08 10:41:55.178558000 +0100
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
@@ -46,7 +46,8 @@
 	REAL_decode_uper,
 	REAL_encode_uper,
 	REAL_decode_aper,
-	REAL_encode_aper,
+  REAL_encode_aper,
+  REAL_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_REAL_tags,
 	sizeof(asn_DEF_REAL_tags) / sizeof(asn_DEF_REAL_tags[0]),
1128
@@ -741,3 +742,32 @@
1129
1130
1131
1132
1133
 
 	return 0;
 }
+
+
1134
+asn_comp_rval_t *
1135
1136
1137
1138
+REAL_compare(asn_TYPE_descriptor_t *td1, const void *sptr1,
+             asn_TYPE_descriptor_t *td2, const void *sptr2) {
+  const REAL_t *st1 = (const REAL_t *)sptr1;
+  const REAL_t *st2 = (const REAL_t *)sptr2;
1139
+  asn_comp_rval_t *res = NULL;
1140
+
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
+  COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res)
+
+  if (st1->size != st2->size) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
+  }
+  if (0 != memcmp(st1->buf, st2->buf, st1->size)) {
+    res = calloc(1, sizeof(asn_comp_rval_t));
+    res->name = td1->name;
+    res->structure1 = sptr1;
+    res->structure2 = sptr2;
+    res->err_code = COMPARE_ERR_CODE_NO_MATCH;
+    return res;
1158
+  }
1159
+  return NULL;
1160
+}
1161
1162
--- skeletons/REAL.h	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/REAL.h	2015-11-26 13:00:46.183623000 +0100
1163
1164
1165
1166
1167
1168
1169
1170
@@ -23,6 +23,7 @@
 per_type_encoder_f REAL_encode_uper;
 per_type_decoder_f REAL_decode_aper;
 per_type_encoder_f REAL_encode_aper;
+type_compare_f     REAL_compare;
 
 /***********************************
  * Some handy conversion routines. *
1171
1172
--- skeletons/RELATIVE-OID.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/RELATIVE-OID.c	2015-11-26 14:56:31.703615000 +0100
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
@@ -29,7 +29,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_RELATIVE_OID_tags,
 	sizeof(asn_DEF_RELATIVE_OID_tags)
1183
1184
--- skeletons/T61String.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/T61String.c	2015-11-26 14:57:07.235615000 +0100
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
@@ -25,7 +25,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_T61String_tags,
 	sizeof(asn_DEF_T61String_tags)
1195
1196
--- skeletons/TeletexString.c	2015-12-08 14:39:33.338543533 +0100
+++ skeletons/TeletexString.c	2015-11-26 14:57:17.643615000 +0100
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
@@ -25,7 +25,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_TeletexString_tags,
 	sizeof(asn_DEF_TeletexString_tags)
1207
1208
--- skeletons/UniversalString.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/UniversalString.c	2015-11-26 14:57:29.015615000 +0100
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
@@ -36,7 +36,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_UniversalString_tags,
 	sizeof(asn_DEF_UniversalString_tags)
1219
1220
--- skeletons/UTCTime.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/UTCTime.c	2015-11-26 14:57:44.127615000 +0100
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
@@ -41,7 +41,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_UTCTime_tags,
 	sizeof(asn_DEF_UTCTime_tags)
1231
1232
--- skeletons/UTF8String.c	2015-12-08 14:39:33.314543533 +0100
+++ skeletons/UTF8String.c	2015-11-26 14:06:54.563618000 +0100
1233
1234
1235
1236
1237
1238
1239
1240
@@ -27,6 +27,7 @@
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
 	OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_UTF8String_tags,
 	sizeof(asn_DEF_UTF8String_tags)
1241
1242
--- skeletons/VideotexString.c	2015-12-08 14:39:33.342543533 +0100
+++ skeletons/VideotexString.c	2015-11-26 14:07:06.139618000 +0100
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
@@ -25,7 +25,8 @@
 	OCTET_STRING_decode_uper,    /* Implemented in terms of OCTET STRING */
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_VideotexString_tags,
 	sizeof(asn_DEF_VideotexString_tags)
1253
1254
--- skeletons/VisibleString.c	2015-12-08 14:39:33.350543533 +0100
+++ skeletons/VisibleString.c	2015-11-26 14:07:15.283618000 +0100
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
@@ -30,7 +30,8 @@
 	OCTET_STRING_decode_uper,
 	OCTET_STRING_encode_uper,
 	OCTET_STRING_decode_aper,
-	OCTET_STRING_encode_aper,
+  OCTET_STRING_encode_aper,
+  OCTET_STRING_compare,
 	0, /* Use generic outmost tag fetcher */
 	asn_DEF_VisibleString_tags,
 	sizeof(asn_DEF_VisibleString_tags)