aboutsummaryrefslogtreecommitdiffstats
path: root/ROHC_CNL113426_LATEST/src/ROHC_Types.ttcn
blob: 5ca513ee86182b06b1932985b220d06b2909a4d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
145
146
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// Copyright Test Competence Center(TCC) ETH 2003                            //
//                                                                           //
// The copyright to the computer program(s) herein is the property of TCC.   //
// The program(s) may be used and/or copied only with the written permission //
// of TCC or in accordance with the terms and conditions stipulated in the   //
// agreement/contract under which the program(s) has been supplied.          //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
//
// File: ROHC_Types.ttcn
// Description: ROHC
// Rev: R3A01
// Prodnr: CNL 113 426
// Updated: 2006.04.13
// Contact: http://ttcn.ericsson.se
//

/* Based on RFC 3095, July 2001 */

/* TODO: improvements::
- Profile4_Dynamic_Chain_u should not contain the sn field

ethesi */

module ROHC_Types
{
import from General_Types all;

external function f_ROHC_enc(in ROHC_packet_u pdu, in ROHC_config p_config)
return octetstring;
external function f_ROHC_dec(in octetstring data, inout ROHC_config p_config)
return ROHC_packet_u;
external function f_ROHC_CRC(in octetstring data, in integer crclen)
return integer;
external function f_FBCK_enc(in Feedback_data pdu, in ROHC_config p_config)
return octetstring;
external function f_FBCK_dec(in octetstring data, in ROHC_config p_config)
return Feedback_data;

/* Constants for ROHC mode field values including mode cancellation */
const integer cg_ROHC_mode_C := 0;
const integer cg_ROHC_mode_U := 1;
const integer cg_ROHC_mode_O := 2;
const integer cg_ROHC_mode_R := 3;

/* Constants for ROHC feedback type */
const integer cg_ROHC_fbck_type_ACK := 0;
const integer cg_ROHC_fbck_type_NACK := 1;
const integer cg_ROHC_fbck_type_SNACK := 2;
const integer cg_ROHC_fbck_type_reserved := 3;

type bitstring ROHC_BIT7_BO_LAST length (7) with {variant "BYTEORDER(last)"};

type enumerated Packet_type { R_0(0), R_0_CRC(1), UO_0(2), R_1(3), R_1_ID(4),
  R_1_TS(5), UO_1(6), UO_1_ID(7), UO_1_TS(8), UOR_2(9), UOR_2_ID(10),
  UOR_2_TS(11), IR(12), IR_DYN(13), NOPKT(14) };

/* ==================== ROHC configuration and context ==================== */

  type record IP_context {
    /* Version of this IP level. MSB bit may be set (Profile 4 only). */
    integer version,
    /* RND bit of this IP level (RND or RND2) */
    boolean rnd_bit,
    /* Whether AH is present in the IPX index list */
    boolean ah_present,
    /* Whether GRE is present in the IPX index list */
    boolean gre_present,
    /* Whether ESP is present in the IPX index list */
    boolean esp_present,
    /* Length of the compressed AH data field after the base header */
    integer ah_data_len,
    /* Whether GRE header has GRE checksum or not */
    boolean gre_cksum_present
  };
  
  type record UDP_context {
    boolean udp_cksum
  };
  
  type record of IP_context IP_contexts;  
  
  type record ROHC_context {
      integer mode,
      integer profile,
      /* The decoded packet type */
      Packet_type pkt,
      IP_contexts ip_ctx,
      UDP_context udp_ctx
  };

  type record of integer int_array;

  type record of ROHC_context ROHC_context_rof;

  type record ROHC_config {
      boolean large_cid,
      int_array rtp_ports,
      ROHC_context_rof context
  };

  type port ROHC_ASP_SP_PT message
  {
    inout ROHC_packet_u; 
    inout octetstring;
  } with { extension "internal" }

  
  /* ROHC Configuration port */
  type record ROHC_ROHCCFG_REQ_setconfig 
  {
    ROHC_config config
  }

  type enumerated ROHC_ROHCCFG_REQ_operation { rohccfg_getconfig }
  
  type union ROHC_ROHCCFG_REQ 
  {
    ROHC_ROHCCFG_REQ_operation simpleop,
    ROHC_ROHCCFG_REQ_setconfig setconfig
  }
  
  type enumerated ROHC_ROHCCFG_RSP_operation { rohccfg_ok }

  type record ROHC_ROHCCFG_RSP_config 
  {
    ROHC_config config
  }
  
  type union ROHC_ROHCCFG_RSP
  {
    ROHC_ROHCCFG_RSP_operation simpleop,
    ROHC_ROHCCFG_RSP_config config
  }
  
  type port ROHC_PORTCFG_PT message
  {
    inout ROHC_config;
    inout charstring;
    inout ROHC_ROHCCFG_REQ;
    inout ROHC_ROHCCFG_RSP;
  } with { extension "internal" }

  type union ROHC_packet_u
  {
    ROHC_packet rohc,
    Segment_packet segment
  }

  type record ROHC_packet /* p.42 */
  {
    Padding padding optional,
    Feedback feedback optional,
    Header header,
    Payload payload optional
  };

/* TODO CHECK: why this is needed ?
type record Reconstructed_unit
{
 octetstring reconstructed_packet,
 OCT4 CRC
}; */

  type record Segment_packet /* p.50 */
  {
    Padding padding optional,
    Feedback feedback optional,
    INT7b segment_header_id, /* Must be 127 (0x7F) */
    boolean final,
    Payload payload optional,
    integer crc optional
  };

  type octetstring Padding; /* Must be a serie of 0xE0 */
  type octetstring Payload;

  type OCT1n Feedback1; /* p.91 */

  type record Feedback_opts_u /* p.91 */
  {
    INT4b opt_type,
    INT4b opt_len,
    octetstring opt_data optional
  };

  type record of Feedback_opts_u Feedback_opts; /* p.91 */

  type record Feedback2 /* p.91 */
  {
    INT2b acktype,
    INT2b mode,
    INT12b_BO_LAST sn,
    Feedback_opts feedback_opts optional
  };

  type union Feedback_type /* p.46 */
  {
    Feedback1 feedback1,
    Feedback2 feedback2
  };

  type record Feedback_data /* p.46 */
  {
    INT14b_BO_LAST cid,
    Feedback_type feedback_type
  };

  type record Feedback_u /* p.45 */
  {
    BIT5 feedback_type, /* Must be '11110'B */
    INT3b code,
    LIN1 size optional,
    /* TODO: size could be 0, so feedback_data should be optional;
      although it's a weird case, but still possible */
    Feedback_data feedback_data
  };

  type record of Feedback_u Feedback; /* p.42 */

  type union Header /* p.77 */
  {
    Profile0_headers prof0,
    Profile1_headers prof1,
    Profile2_headers prof2,
    Profile4_headers prof4
  };

  //Profile0

  type union Profile0_headers
  {
    Profile0_IR_packet ir,
    Profile0_normal_packet normal
  };

  type record Profile0_IR_packet /* p.127 */
  {
    INT14b_BO_LAST cid,
    BIT7 type_ind, /* Must be '1111110'B */
    BIT1 d, /* Must be 0 */
    LIN1 profile, /* Must be 0 */
    LIN1 crc,
    octetstring orig_packet
  };

  type record Profile0_normal_packet /* p.128 */
  {
    INT14b_BO_LAST cid,
    octetstring orig_packet
  };

  //Profile1

  type record Profile1_headers /* p.77 */
  {
    Profile1_base_header base_header,
    Profile1_Extension ext optional,
    LIN2_BO_LAST ip_id_outer optional,
    octetstring ah_outer optional,
    LIN2_BO_LAST gre_cksum1 optional,
    LIN2_BO_LAST ip_id_inner optional,
    octetstring ah_inner optional,
    LIN2_BO_LAST gre_cksum2 optional,
    LIN2_BO_LAST udp_cksum optional
  };

  type union Profile1_base_header
  {
    Profile1_IR_header ir,
    Profile1_IR_DYN_header ir_dyn,
    Profile1_R_0_header r_0,
    Profile1_R_0_CRC_header r_0_crc,
    Profile1_UO_0_header uo_0,
    Profile1_R_1_header r_1,
    Profile1_R_1_ID_header r_1_id,
    Profile1_R_1_TS_header r_1_ts,
    Profile1_UO_1_header uo_1,
    Profile1_UO_1_ID_header uo_1_id,
    Profile1_UO_1_TS_header uo_1_ts,
    Profile1_UOR_2_header uor_2,
    Profile1_UOR_2_ID_header uor_2_id,
    Profile1_UOR_2_TS_header uor_2_ts
  };

  type union Static_Chain_u /* p.91 */
  {
    IPv4_Static ipv4_stat,
    IPv6_Static ipv6_stat,
    UDP_Static udp_stat,
    RTP_Static rtp_stat,
    ESP_Static esp_stat
  };

  type union Dynamic_Chain_u /* p.91 */
  {
    IPv4_Dynamic ipv4_dyn,
    IPv6_Dynamic ipv6_dyn,
    UDP_Dynamic udp_dyn,
    RTP_Dynamic rtp_dyn,
    ESP_Dynamic esp_dyn
  };

  type record of Static_Chain_u Static_Chain; /* p.91 */

  type record of Dynamic_Chain_u Dynamic_Chain; /* p.91 */

  type record Profile1_IR_header /* p.45 */ /* p.91 */
  {
    INT14b_BO_LAST cid,
    BIT7 type_ind, /* Must be '1111110'B */
    BIT1 d,
    LIN1 profile, /* Must be 1 */
    LIN1 crc,
    Static_Chain stat_chain,
    Dynamic_Chain dyn_chain optional
  };

  type record Profile1_IR_DYN_header /* p.46 */ /* p.92 */
  {
    INT14b_BO_LAST cid,
    BIT8 type_ind, /* Must be '11111000'B */
    LIN1 profile, /* Must be 1 */
    LIN1 crc,
    Dynamic_Chain dyn_chain
  };

  type record Profile1_R_0_header /* p.74 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '00'B */
    INT6b sn
  };

  type record Profile1_R_0_CRC_header /* p.74 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '01'B */
    INT7b sn,
    INT7b crc
  };

  type record Profile1_UO_0_header /* p.75 */
  {
    INT14b_BO_LAST cid,
    BIT1 type_ind, /* Must be '0'B */
    INT4b sn,
    INT3b crc
  };

  type record Profile1_R_1_header /* p.75 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    INT6b sn,
    BIT1 m_bit,
    BIT1 x_bit,
    INT6b ts
  };

  type record Profile1_R_1_ID_header /* p.75 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    INT6b sn,
    BIT1 m_bit,
    BIT1 x_bit,
    BIT1 t_bit, /* Must be '0'B */
    INT5b ip_id
  };

  type record Profile1_R_1_TS_header /* p.75 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    INT6b sn,
    BIT1 m_bit,
    BIT1 x_bit,
    BIT1 t_bit, /* Must be '1'B */
    INT5b ts
  };

  type record Profile1_UO_1_header /* p.76 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    INT6b ts,
    BIT1 m_bit,
    INT4b sn,
    INT3b crc
  };

  type record Profile1_UO_1_ID_header /* p.76 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    BIT1 t_bit, /* Must be '0'B */
    INT5b ip_id,
    BIT1 x_bit,
    INT4b sn,
    INT3b crc
  };

  type record Profile1_UO_1_TS_header /* p.76 */
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    BIT1 t_bit, /* Must be '1'B */
    INT5b ts,
    BIT1 m_bit,
    INT4b sn,
    INT3b crc
  };

  type record Profile1_UOR_2_header /* p.77 */
  {
    INT14b_BO_LAST cid,
    BIT3 type_ind, /* Must be '110'B */
    INT6b ts,
    BIT1 m_bit,
    INT6b sn,
    BIT1 x_bit,
    INT7b crc
  };

  type record Profile1_UOR_2_ID_header /* p.77 */
  {
    INT14b_BO_LAST cid,
    BIT3 type_ind, /* Must be '110'B */
    INT5b ip_id,
    BIT1 t_bit, /* Must be '0'B */
    BIT1 m_bit,
    INT6b sn,
    BIT1 x_bit,
    INT7b crc
  };

  type record Profile1_UOR_2_TS_header /* p.77 */
  {
    INT14b_BO_LAST cid,
    BIT3 type_ind, /* Must be '110'B */
    INT5b ts,
    BIT1 t_bit, /* Must be '1'B */
    BIT1 m_bit,
    INT6b sn,
    BIT1 x_bit,
    INT7b crc
  };

  type record Short_Seqnum /* p.120 */
  {
    BIT1 ind, /* Must be '0'B */
    INT7b lsb_of_seqnum
  };

  type record Long_Seqnum /* p.120 */
  {
    BIT1 ind, /* Must be '1'B */
    INT31b_BO_LAST lsb_of_seqnum
  };

  type union AEGSeqnum /* p.112 */
  {
    Short_Seqnum short_form,
    Long_Seqnum long_form
  };

  type record XI_Item4_r /* p.121 */
  {
    BIT1 x_ind,
    INT3b index
  };

  type record XI_Item8_r /* p.121 */
  {
    BIT1 x_ind,
    INT7b index
  };

  type record of XI_Item4_r XI_Item4;

  type record of XI_Item8_r XI_Item8;

  type union XI_list /* p.113 */
  {
    XI_Item4 xi_item4,
    XI_Item8 xi_item8
  };

  type record IPv6_ext_item
  {
    LIN1 nexthead,
    LIN1 hdr_ext_len,
    octetstring data
  }

  type record MINE_item {
    LIN1 protocol,
    BIT1 s_bit,
    ROHC_BIT7_BO_LAST reserved,
    LIN2_BO_LAST cksum,
    OCT4 dstaddr,
    OCT4 srcaddr optional
  } with { 
    variant "FIELDORDER(msb)"; 
    variant (srcaddr)  "PRESENCE(s_bit = '1'B)";
  }

/* TODO: check why better use INTn intead of OCTn */
  type record AH_item /* RFC 2402, p.3 */
  {
    LIN1 nexthead, /* Must be 51 */
    LIN1 payload_len,
    LIN2_BO_LAST reserved, /* Must be 0 */
    LIN4_BO_LAST spi,
    LIN4_BO_LAST sn,
    octetstring auth_data optional
  }

  type record ESP_item
  {
    LIN1 nexthead, /* Must be 50 */
    LIN4_BO_LAST spi,
    LIN4_BO_LAST sn
  }

  type record GRE_item
  {
    LIN1 nexthead, /* Must be 47 */
    BIT1 C_bit,
    BIT1 reserved_1, /* Must be '0'B */
    BIT1 K_bit,
    BIT1 S_bit,
    BIT1 reserved_2, /* Must be '0'B */
    BIT3 version,
    LIN2_BO_LAST cksum optional,
    LIN4_BO_LAST key optional,
    LIN4_BO_LAST sn optional
  }

  type union Item
  {
    IPv6_ext_item ipv6_ext_item,
    AH_item ah_item,
    ESP_item esp_item,
    GRE_item gre_item,
    MINE_item mine_item
/* TODO CHECK: could we use it ?
    octetstring any_item */
  }

  type record of Item IP_Item_list;

  type record of OCT4n CSRC_Item_list;
  
  /* TODO: temporary solution for profile4 tests */
  type record of octetstring RAW_data;

  type union Item_list
  {
    CSRC_Item_list csrc_item_list,
    IP_Item_list ip_item_list,
    /* TODO: temporary solution for profile4 tests */
    RAW_data raw_data
  }

  type record Enc_Type_0 /* p.112 */
  {
    BIT2 et, /* Must be '00'B */
    BIT1 gp_bit,
    BIT1 ps_bit,
    INT4b cc,
    LIN1 gen_id optional,
    XI_list xi_list optional,
    BIT4 padding optional, /* Must be '0000'B */
    Item_list item_list optional
  };

  type record Enc_Type_1 /* p.114 */
  {
    BIT2 et, /* Must be '01'B */
    BIT1 gp_bit,
    BIT1 ps_bit,
    INT4b xi1,
    LIN1 gen_id optional,
    LIN1 ref_id,
    octetstring insbitmask,
    XI_list xi_list optional,
    BIT4 padding optional, /* Must be '0000'B */
    Item_list item_list optional
  };

  type record Enc_Type_2 /* p.115 */
  {
    BIT2 et, /* Must be '10'B */
    BIT1 gp_bit,
    BIT1 res,
    INT4b count,
    LIN1 gen_id optional,
    LIN1 ref_id,
    octetstring rembitmask
  };

  type record Enc_Type_3 /* p.115 */
  {
    BIT2 et, /* Must be '11'B */
    BIT1 gp_bit,
    BIT1 ps_bit,
    INT4b xi1,
    LIN1 gen_id optional,
    LIN1 ref_id,
    octetstring rembitmask,
    octetstring insbitmask,
    XI_list xi_list optional,
    BIT4 padding optional, /* Must be '0000'B */
    Item_list item_list optional
  };

  type record IPv4_Static /* p.94 */
  {
    INT4b version, /* Must be '0100'B */
    INT4b reserved, /* Must be '0000'B */
    LIN1 proto,
    OCT4 srcaddr,
    OCT4 dstaddr
  };

  type record IPv4_Dynamic /* p.94 */
  {
    LIN1 tos,
    LIN1 ttl,
    LIN2_BO_LAST identification,
    BIT1 df_bit,
    BIT1 rnd_bit,
    BIT1 nbo_bit,
    BIT5 reserved, /* Must be '00000'B */
    Enc_Type_0 genextheadlist
  };
  
  type record IPv6_Static /* p.93 */
  {
    INT4b version, /* Must be '0110'B */
    INT20b_BO_LAST flowlabel,
    LIN1 nexthead,
    OCT16 srcaddr,
    OCT16 dstaddr
  };

  type record IPv6_Dynamic /* p.93 */
  {
    LIN1 trafficclass,
    LIN1 hoplimit,
    Enc_Type_0 genextheadlist
  };

  type record UDP_Static /* p.95 */
  {
    LIN2_BO_LAST srcport,
    LIN2_BO_LAST dstport
  };

  type record UDP_Dynamic /* p.95 */
  {
    LIN2_BO_LAST cksum
  };

  type record RTP_Static /* p.96 */
  {
    OCT4 ssrc
  };

  type record Rx_Field /* p.96 */
  {
    BIT3 reserved, /* Must be '000'B */
    BIT1 xbit,
    INT2b mode,
    BIT1 tisbit,
    BIT1 tssbit
  };

  type record RTP_Dynamic /* p.96 */
  {
    INT2b vfield, /* Must be '10'B */
    BIT1 pbit,
    BIT1 rxbit,
    INT4b ccfield,
    BIT1 mbit,
    INT7b ptfield,
    LIN2_BO_LAST rtpseqnum,
    LIN4_BO_LAST rtpts,
    Enc_Type_0 gencsrclist,
    Rx_Field rx_field optional,
    integer ts_stride optional,
    integer time_stride optional
  };

  type record ESP_Static /* p.97 */
  {
    LIN4_BO_LAST spi
  };

  type record ESP_Dynamic /* p.97 */
  {
    LIN4_BO_LAST seqnum
  };

  type union Compr_head_list /* p.112 */
  {
    Enc_Type_0 enctype0,
    Enc_Type_1 enctype1,
    Enc_Type_2 enctype2,
    Enc_Type_3 enctype3
  };
  
  type record IP_Ext_heads /* p.111 */
  {
    BIT1 cl,
    BIT1 aseq,
    BIT1 eseq,
    BIT1 gseq,
    BIT4 res,
    AEGSeqnum ah_seq optional,
    AEGSeqnum esp_seq optional,
    AEGSeqnum gre_seq optional,
    Compr_head_list compr_head_list optional
  };

  type record Outer_IP_fields /* p.82 */
  {
    LIN1 tos optional,
    LIN1 ttl optional,
    LIN1 proto optional,
    IP_Ext_heads ext_heads optional,
    LIN2_BO_LAST ip_id optional
  };

  type record Outer_IP_flags /* p.81 */
  {
    BIT1 tos2,
    BIT1 ttl2,
    BIT1 df2,
    BIT1 pr2,
    BIT1 ipx2,
    BIT1 nbo2,
    BIT1 rnd2,
    BIT1 i2_bit
  };

  type record Inner_IP_fields /* p.81 */
  {
    LIN1 tos optional,
    LIN1 ttl optional,
    LIN1 proto optional,
    IP_Ext_heads ext_heads optional
  };

  type record Inner_IP_flags /* p.80 */
  {
    BIT1 tos,
    BIT1 ttl,
    BIT1 df,
    BIT1 pr,
    BIT1 ipx,
    BIT1 nbo,
    BIT1 rnd_bit,
    BIT1 ip2_bit
  };

  type record RTP_flags
  {
    BIT1 r_p,
    INT7b rtp_pt
  }

  type record RTP_flags_fields /* p.82 */
  {
    INT2b mode,
    BIT1 r_pt,
    BIT1 m_bit,
    BIT1 r_x,
    BIT1 csrc,
    BIT1 tss,
    BIT1 tis,
    RTP_flags flags optional,
    Compr_head_list csrc_list optional,
    integer ts_stride optional,
    integer time_stride optional
  }

  type record Extension0 /* p.79 */
  {
    BIT2 ext_type, /* Must be '00'B */
    INT3b sn,
    INT3b plust
  }

  type record Extension1 /* p.79 */
  {
    BIT2 ext_type, /* Must be '01'B */
    INT3b sn,
    INT3b plust,
    LIN1 minust
  };

  type record Extension2 /* p.79 */
  {
    BIT2 ext_type, /* Must be '10'B */
    INT3b sn,
    INT11b_BO_LAST plust,
    LIN1 minust
  };

  type record Extension3 /* p.79 */
  {
    BIT2 ext_type, /* Must be '11'B */
    BIT1 s_bit,
    BIT1 r_ts_bit,
    BIT1 tsc_bit,
    BIT1 i_bit,
    BIT1 ip_bit,
    BIT1 rtp_bit,
    Inner_IP_flags inner_ip_flags optional,
    Outer_IP_flags outer_ip_flags optional,
    LIN1 sn optional,
    integer ts optional,
    /* This field contains the length of the SDVL encoded TS value counted in
      octets. */
    integer ts_length optional,
    Inner_IP_fields inner_ip_hdr optional,
    LIN2_BO_LAST ip_id optional,
    Outer_IP_fields outer_ip_hdr optional,
    RTP_flags_fields rtp_fl_fi optional
  };

  type union Profile1_Extension /* p.79 */
  {
    Extension0 ext0,
    Extension1 ext1,
    Extension2 ext2,
    Extension3 ext3
  };

  //Profile2

  type record Profile2_headers /* p.77 */
  {
    Profile2_base_header base_header,
    Profile2_Extension ext optional,
    LIN2_BO_LAST ip_id_outer optional,
    octetstring ah_outer optional,
    LIN2_BO_LAST gre_cksum1 optional,
    LIN2_BO_LAST ip_id_inner optional,
    octetstring ah_inner optional,
    LIN2_BO_LAST gre_cksum2 optional,
    LIN2_BO_LAST udp_cksum optional
  };

  type union Profile2_base_header
  {
    Profile2_IR_header ir,
    Profile2_IR_DYN_header ir_dyn,
    Profile1_R_0_header r_0,
    Profile1_R_0_CRC_header r_0_crc,
    Profile1_UO_0_header uo_0,
    Profile2_R_1_header r_1,
    Profile2_UO_1_header uo_1,
    Profile2_UOR_2_header uor_2
  };

  type union Profile2_Static_Chain_u
  {
    IPv4_Static ipv4_stat,
    IPv6_Static ipv6_stat,
    UDP_Static udp_stat
  };

  type record Profile2_UDP_Dynamic
  {
    LIN2_BO_LAST cksum,
    LIN2_BO_LAST udp_sn
  };

  type union Profile2_Dynamic_Chain_u
  {
    IPv4_Dynamic ipv4_dyn,
    IPv6_Dynamic ipv6_dyn,
    Profile2_UDP_Dynamic udp_dyn
  };

  type record of Profile2_Static_Chain_u Profile2_Static_Chain;

  type record of Profile2_Dynamic_Chain_u Profile2_Dynamic_Chain;

  type record Profile2_IR_header
  {
    INT14b_BO_LAST cid,
    BIT7 type_ind, /* Must be '1111110'B */
    BIT1 d,
    LIN1 profile, /* Must be 2 */
    LIN1 crc,
    Profile2_Static_Chain stat_chain,
    Profile2_Dynamic_Chain dyn_chain optional
  };

  type record Profile2_IR_DYN_header /* p.46 */ /* p.92 */
  {
    INT14b_BO_LAST cid,
    BIT8 type_ind, /* Must be '11111000'B */
    LIN1 profile, /* Must be 2 */
    LIN1 crc,
    Profile2_Dynamic_Chain dyn_chain
  };

  type record Profile2_R_1_header
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    INT6b sn,
    BIT1 x_bit,
    INT7b ip_id
  };

  type record Profile2_UO_1_header
  {
    INT14b_BO_LAST cid,
    BIT2 type_ind, /* Must be '10'B */
    INT6b ip_id,
    INT5b sn,
    INT3b crc
  };

  type record Profile2_UOR_2_header
  {
    INT14b_BO_LAST cid,
    BIT3 type_ind, /* Must be '110'B */
    INT5b sn,
    BIT1 x_bit,
    INT7b crc
  };

  type record Profile2_Inner_IP_flags
  {
    BIT1 tos,
    BIT1 ttl,
    BIT1 df,
    BIT1 pr,
    BIT1 ipx,
    BIT1 nbo,
    BIT1 rnd_bit,
    BIT1 reserved /* Must be '0'B */
  };

  type union Profile2_Extension
  {
    Profile2_Extension0 ext0,
    Profile2_Extension1 ext1,
    Profile2_Extension2 ext2,
    Profile2_Extension3 ext3
  };

  type record Profile2_Extension0
  {
    BIT2 ext_type, /* Must be '00'B */
    INT3b sn,
    INT3b ip_id
  }

  type record Profile2_Extension1
  {
    BIT2 ext_type, /* Must be '01'B */
    INT3b sn,
    INT11b_BO_LAST ip_id
  };

  type record Profile2_Extension2
  {
    BIT2 ext_type, /* Must be '10'B */
    INT3b sn,
    INT11b_BO_LAST ip_id2,
    LIN1 ip_id
  };

  type record Profile2_Extension3
  {
    BIT2 ext_type, /* Must be '11'B */
    BIT1 s_bit,
    INT2b mode,
    BIT1 i_bit,
    BIT1 ip_bit,
    BIT1 ip2_bit,
    Profile2_Inner_IP_flags inner_ip_flags optional,
    Outer_IP_flags outer_ip_flags optional,
    LIN1 sn optional,
    Inner_IP_fields inner_ip_hdr optional,
    LIN2_BO_LAST ip_id optional,
    Outer_IP_fields outer_ip_hdr optional
  };

  //Profile4

  type record Profile4_headers
  {
    Profile4_base_header base_header,
    Profile2_Extension ext optional,
    LIN2_BO_LAST ip_id_outer optional,
    octetstring ah_outer optional,
    LIN2_BO_LAST gre_cksum1 optional,
    LIN2_BO_LAST ip_id_inner optional,
    octetstring ah_inner optional,
    LIN2_BO_LAST gre_cksum2 optional,
    Profile4_Dynamic_Chain additional_IP optional
  };

  type union Profile4_base_header
  {
    Profile4_IR_header ir,
    Profile4_IR_DYN_header ir_dyn,
    Profile1_R_0_header r_0,
    Profile1_R_0_CRC_header r_0_crc,
    Profile1_UO_0_header uo_0,
    Profile2_R_1_header r_1,
    Profile2_UO_1_header uo_1,
    Profile2_UOR_2_header uor_2
  };

  type union Profile4_Static_Chain_u
  {
    IPv4_Static ipv4_stat,
    IPv6_Static ipv6_stat
  };
  
  type record Profile4_IPv4_Dynamic
  {
    LIN1 tos,
    LIN1 ttl,
    LIN2_BO_LAST identification,
    BIT1 df_bit,
    BIT1 rnd_bit,
    BIT1 nbo_bit,
    BIT1 sid_bit,
    BIT4 reserved, /* Must be '0000'B */
    Enc_Type_0 genextheadlist
  };

  type union Profile4_Dynamic_Chain_u
  {
    Profile4_IPv4_Dynamic ipv4_dyn,
    IPv6_Dynamic ipv6_dyn,
    LIN2_BO_LAST sn
  };

  type record of Profile4_Static_Chain_u Profile4_Static_Chain;

  type record of Profile4_Dynamic_Chain_u Profile4_Dynamic_Chain;

  type record Profile4_IR_header
  {
    INT14b_BO_LAST cid,
    BIT7 type_ind, /* Must be '1111110'B */
    BIT1 d,
    LIN1 profile, /* Must be 4 */
    LIN1 crc,
    Profile4_Static_Chain stat_chain,
    Profile4_Dynamic_Chain dyn_chain optional
  };

  type record Profile4_IR_DYN_header
  {
    INT14b_BO_LAST cid,
    BIT8 type_ind, /* Must be '11111000'B */
    LIN1 profile, /* Must be 4 */
    LIN1 crc,
    Profile4_Dynamic_Chain dyn_chain
  };

} with { encode "RAW" }