├── .markdownlint.json
├── LICENSE.md
├── README.md
├── img
└── dogma-logo.svg
└── v1
├── dogma_v1.0.md
├── dogma_v1.md
├── examples
├── 802.3_layer2.dogma
├── dex_v39.dogma
├── dns_query.dogma
├── dns_response.dogma
├── ico.dogma
├── ipv4.dogma
├── json.dogma
├── minidump.dogma
├── rtp_v2.dogma
├── tr_dos.dogma
└── udp.dogma
└── img
├── Wikipedia-TCPIP_802.1ad_DoubleTag.svg
├── dogma-logo.svg
└── sequence-sets.svg
/.markdownlint.json:
--------------------------------------------------------------------------------
1 | {
2 | "MD004": false,
3 | "MD003": false,
4 | "MD007": false,
5 | "MD012": false,
6 | "MD013": false,
7 | "MD031": false,
8 | "MD032": false,
9 | "MD033": false,
10 | "MD035": false,
11 | "MD038": false,
12 | "MD041": false,
13 | "MD046": false
14 | }
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | License for Dogma
2 | =================
3 |
4 | License Type: Creative Commons Attribution 4.0 International Public License
5 |
6 | [Online Reference](https://creativecommons.org/licenses/by/4.0)
7 |
8 |
9 | License
10 | -------
11 |
12 | Creative Commons Attribution 4.0 International Public License
13 |
14 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
15 |
16 | ### Section 1 – Definitions
17 |
18 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
19 |
20 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
21 |
22 | c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
23 |
24 | d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
25 |
26 | e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
27 |
28 | f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
29 |
30 | g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
31 |
32 | h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
33 |
34 | i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
35 |
36 | j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
37 |
38 | k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
39 |
40 | ### Section 2 – Scope
41 |
42 | a. License grant.
43 |
44 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
45 | A. reproduce and Share the Licensed Material, in whole or in part; and
46 | B. produce, reproduce, and Share Adapted Material.
47 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
48 | 3. Term. The term of this Public License is specified in Section 6(a).
49 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
50 | 5. Downstream recipients.
51 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
52 | B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
53 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
54 |
55 | b. Other rights.
56 |
57 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
58 | 2. Patent and trademark rights are not licensed under this Public License.
59 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
60 |
61 | ### Section 3 – License Conditions
62 |
63 | Your exercise of the Licensed Rights is expressly made subject to the following conditions.
64 |
65 | a. Attribution.
66 |
67 | 1. If You Share the Licensed Material (including in modified form), You must:
68 | A. retain the following if it is supplied by the Licensor with the Licensed Material:
69 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
70 | ii. a copyright notice;
71 | iii. a notice that refers to this Public License;
72 | iv. a notice that refers to the disclaimer of warranties;
73 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
74 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
75 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
76 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
77 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
78 | 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
79 |
80 | ### Section 4 – Sui Generis Database Rights
81 |
82 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
83 |
84 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
85 |
86 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
87 |
88 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
89 |
90 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
91 |
92 | ### Section 5 – Disclaimer of Warranties and Limitation of Liability
93 |
94 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
95 |
96 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
97 |
98 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
99 |
100 | ### Section 6 – Term and Termination
101 |
102 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
103 |
104 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
105 |
106 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
107 | 2. upon express reinstatement by the Licensor.
108 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
109 |
110 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
111 |
112 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
113 |
114 | ### Section 7 – Other Terms and Conditions
115 |
116 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
117 |
118 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
119 |
120 | ### Section 8 – Interpretation
121 |
122 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
123 |
124 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
125 |
126 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
127 |
128 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
129 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The Dogma Metalanguage
5 | ======================
6 |
7 | Dogma is a human-friendly metalanguage for describing data formats (text or binary) in documentation.
8 |
9 | Dogma follows the familiar patterns of [Backus-Naur Form](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form), with a number of innovations that make it also suitable for describing binary data.
10 |
11 |
12 |
13 | Specification
14 | -------------
15 |
16 | [The Dogma Specification v1](v1/dogma_v1.0.md)
17 |
18 |
19 |
20 | Syntax Highlighter (VS Code)
21 | ----------------------------
22 |
23 | * [From the marketplace](https://marketplace.visualstudio.com/items?itemName=kstenerud.dogma-v1)
24 | * [From source](https://github.com/kstenerud/dogma-tmlanguage)
25 |
26 |
27 |
28 | Example
29 | -------
30 |
31 | To demonstrate the power of Dogma, here is an Ethernet IEEE 802.3 frame, layer 2 (image from [Wikipedia](https://en.wikipedia.org/wiki/IEEE_802.1Q)):
32 |
33 | 
34 |
35 | ```dogma
36 | dogma_v1 utf-8
37 | - identifier = 802.3_layer2
38 | - description = IEEE 802.3 Ethernet frame, layer 2
39 | - note = Words are byte-ordered big endian, but every octet is sent LSB first.
40 |
41 | frame = preamble
42 | & frame_start
43 | & dst_address
44 | & src_address
45 | & var(etype, ether_type)
46 | & [
47 | etype.type = 0x8100: dot1q_frame;
48 | etype.type = 0x88a8: double_tag_frame;
49 | : payload_by_type(etype.type, 46);
50 | ]
51 | & frame_check
52 | ;
53 | preamble = uint(8, 0b01010101){7};
54 | frame_start = uint(8, 0b11010101);
55 | dst_address = uint(48, ~);
56 | src_address = uint(48, ~);
57 | ether_type = uint(16, var(type, ~));
58 | frame_check = uint(32, ~);
59 |
60 | dot1q_frame = tag_control_info
61 | & var(etype, ether_type)
62 | & payload_by_type(etype.type, 42)
63 | ;
64 | double_tag_frame = service_tag
65 | & uint(16, 0x8100)
66 | & customer_tag
67 | & var(etype, ether_type)
68 | & payload_by_type(etype.type, 38)
69 | ;
70 |
71 | tag_control_info = priority & drop_eligible & vlan_id;
72 | priority = uint(3, ~);
73 | drop_eligible = uint(1, ~);
74 | vlan_id = uint(12, ~);
75 | service_tag = tag_control_info;
76 | customer_tag = tag_control_info;
77 |
78 | payload_by_type(type, min_size) = [
79 | type >= min_size & type <= 1500: generic_payload(type);
80 | type = 0x0800 : ipv4;
81 | type = 0x86dd : ipv6;
82 | # Other types omitted for brevity
83 | ];
84 | generic_payload(length) = uint(8,~){length};
85 | ipv4: bits = """https://somewhere/ipv4.dogma""";
86 | ipv6: bits = """https://somewhere/ipv6.dogma""";
87 | ```
88 |
89 | ### Other Examples
90 |
91 | * [Examples in this repo](v1/examples)
92 | * Concise Text Encoding: [cte.dogma](https://github.com/kstenerud/concise-encoding/blob/master/cte.dogma)
93 | * Concise Binary Encoding: [cbe.dogma](https://github.com/kstenerud/concise-encoding/blob/master/cbe.dogma)
94 |
95 |
96 |
97 | Design Objectives
98 | -----------------
99 |
100 | ### Human readability
101 |
102 | Although Dogma is parser-friendly, its primary purpose is for documentation. It must therefore be easy for a human to read and write, and must favor recognizable patterns over special case notation (which is harder to remember).
103 |
104 | Whitespace _never_ has any semantic meaning in Dogma. It serves purely for token separation and for grammar aesthetics.
105 |
106 | ### Expressiveness
107 |
108 | Binary formats tend to be structured in much more complex ways than text formats in order to optimize for speed, throughput, and ease-of-processing.
109 |
110 | Dogma can describe data down to the bit level, and includes a number of built-in functions to help with complex data matching tasks.
111 |
112 | Calculations aid with length and offset fields, and optional/variable-sized structures can be conditionally parsed. Parsing can also "branch" temporarily to another part of the document (useful for directory-payload style formats).
113 |
114 | Variables and macros offer a limited but balanced way for passing (immutable) context around.
115 |
116 | ### Character set support
117 |
118 | Dogma can be used with any character set. Most codepoints can be directly input, and troublesome codepoints can be represented through escape sequences.
119 |
120 | Unicode characters can be selected by their [Unicode category](https://unicode.org/glossary/#general_category).
121 |
122 | ### Future proof
123 |
124 | No specification is perfect, nor can it stand the test of time. Eventually an incompatible change will become necessary in order to stay relevant.
125 |
126 | Every Dogma document records the Dogma specification version it was built against so that changes can be made to the specification without breaking existing grammars and tooling.
127 |
--------------------------------------------------------------------------------
/img/dogma-logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
15 |
--------------------------------------------------------------------------------
/v1/examples/802.3_layer2.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = 802.3_layer2
3 | - description = IEEE 802.3 Ethernet frame, layer 2
4 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
5 | - note = Words are byte-ordered big endian, but every octet is sent LSB first.
6 |
7 | frame = preamble
8 | & frame_start
9 | & dst_address
10 | & src_address
11 | & var(etype, ether_type)
12 | & [
13 | etype.type = 0x8100: dot1q_frame;
14 | etype.type = 0x88a8: double_tag_frame;
15 | : payload_by_type(etype.type, 46);
16 | ]
17 | & frame_check
18 | ;
19 | preamble = uint(8, 0b01010101){7};
20 | frame_start = uint(8, 0b11010101);
21 | dst_address = uint(48, ~);
22 | src_address = uint(48, ~);
23 | ether_type = uint(16, var(type, ~));
24 | frame_check = uint(32, ~);
25 |
26 | dot1q_frame = tag_control_info
27 | & var(etype, ether_type)
28 | & payload_by_type(etype.type, 42)
29 | ;
30 | double_tag_frame = service_tag
31 | & uint(16, 0x8100)
32 | & customer_tag
33 | & var(etype, ether_type)
34 | & payload_by_type(etype.type, 38)
35 | ;
36 |
37 | tag_control_info = priority & drop_eligible & vlan_id;
38 | priority = uint(3, ~);
39 | drop_eligible = uint(1, ~);
40 | vlan_id = uint(12, ~);
41 | service_tag = tag_control_info;
42 | customer_tag = tag_control_info;
43 |
44 | payload_by_type(type, min_size) = [
45 | type >= min_size & type <= 1500: generic_payload(type);
46 | type = 0x0800 : ipv4;
47 | type = 0x86dd : ipv6;
48 | # TODO: The rest of the payload types
49 | ];
50 | generic_payload(length) = uint(8,~){length};
51 | ipv4: bits = """https://somewhere/ipv4.dogma""";
52 | ipv6: bits = """https://somewhere/ipv6.dogma""";
53 |
--------------------------------------------------------------------------------
/v1/examples/dex_v39.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = dex_v39
3 | - description = Dex file format, version 39
4 | - reference = https://source.android.com/docs/core/runtime/dex-format
5 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
6 |
7 | document = peek(var(head, header))
8 | & [
9 | head.endian.tag = 0x12345678: byte_order(msb, doc_endian);
10 | head.endian.tag = 0x78563412: byte_order(lsb, doc_endian);
11 | ]
12 | ;
13 |
14 | doc_endian = var(head,header)
15 | & offset(head.sect.link_off*8, u8(~){head.sect.link_size})
16 | & offset(head.sect.map_off*8, map_list(head.sect))
17 | & offset(head.sect.string_ids_off*8, string_id_item{head.sect.string_ids_size})
18 | & offset(head.sect.type_ids_off*8, type_id_item(head.sect){head.sect.type_ids_size})
19 | & offset(head.sect.proto_ids_off*8, proto_id_item(head.sect){head.sect.proto_ids_size})
20 | & offset(head.sect.field_ids_off*8, field_id_item(head.sect){head.sect.field_ids_size})
21 | & offset(head.sect.method_ids_off*8, method_id_item(head.sect){head.sect.method_ids_size})
22 | & offset(head.sect.class_defs_off*8, class_def_item(head.sect){head.sect.class_defs_size})
23 | & offset(head.sect.data_off*8, u8(~){head.sect.data_size})
24 | ;
25 |
26 | header = magic
27 | & checksum
28 | & signature
29 | & file_size
30 | & header_size
31 | & var(endian, endian_tag)
32 | & var(sect,sections)
33 | ;
34 | magic = "dex\[a]039\[0]";
35 | checksum = u32(~);
36 | signature = u8(~){20};
37 | file_size = u32(~);
38 | header_size = u32(0x70);
39 | endian_tag = u32(var(tag, 0x12345678 | 0x78563412));
40 | sections = u32(var(link_size,~))
41 | & u32(var(link_off,~))
42 | & u32(var(map_off,1~))
43 | & u32(var(string_ids_size,~))
44 | & u32(var(string_ids_off,~))
45 | & u32(var(type_ids_size,~65535))
46 | & u32(var(type_ids_off,~))
47 | & u32(var(proto_ids_size,~65535))
48 | & u32(var(proto_ids_off,~))
49 | & u32(var(field_ids_size,~))
50 | & u32(var(field_ids_off,~))
51 | & u32(var(method_ids_size,~))
52 | & u32(var(method_ids_off,~))
53 | & u32(var(class_defs_size,~))
54 | & u32(var(class_defs_off,~))
55 | & u32(var(data_size,~))
56 | & u32(var(data_off,~))
57 | ;
58 |
59 | offs_string_item(sect,index) = offset(sect.string_ids_off*8 + index*32, string_id_item);
60 | offs_type_id_item(sect,index) = offset(sect.type_ids_off*8 + index*32, type_id_item(sect));
61 | offs_proto_id_item(sect,index) = offset(sect.proto_ids_off*8 + index*32, proto_id_item(sect));
62 | offs_field_id_item(sect,index) = offset(sect.field_ids_off*8 + index*32, field_id_item(sect));
63 | offs_method_id_item(sect,index) = offset(sect.method_ids_off*8 + index*32, method_id_item(sect));
64 |
65 |
66 | string_id_item = u32(var(file_off,~)) & offset(file_off*8, string_data_item);
67 | string_data_item = utf16_size & mutf8_data;
68 | utf16_size = uleb128(~);
69 | mutf8_data = u8(1~)* & u8(0);
70 |
71 | type_id_item(sect) = u32(var(index,~)) & offs_string_item(sect,index);
72 |
73 | proto_id_item(sect) = u32(var(shorty_idx,~))
74 | & u32(var(return_type_idx,~))
75 | & u32(var(parameters_off,~))
76 | & offs_proto_short_form_desc(sect,shorty_idx)
77 | & offs_return_type(sect,return_type_idx)
78 | & [parameters_off > 0: offset(parameters_off*8,type_list(sect));]
79 | ;
80 | offs_proto_short_form_desc(sect,index) = offs_string_item(sect,index);
81 | offs_return_type(sect,index) = offs_type_id_item(sect,index);
82 |
83 | field_id_item(sect) = u32(var(class_idx,~))
84 | & u32(var(type_idx,~))
85 | & u32(var(name_idx,~))
86 | & offs_type_id_item(sect,class_idx)
87 | & offs_type_id_item(sect,type_idx)
88 | & offs_string_item(sect,name_idx)
89 | ;
90 |
91 | method_id_item(sect) = u32(var(class_idx,~))
92 | & u32(var(proto_idx,~))
93 | & u32(var(name_idx,~))
94 | & offs_type_id_item(sect,class_idx)
95 | & offs_proto_id_item(sect,proto_idx)
96 | & offs_string_item(sect,name_idx)
97 | ;
98 |
99 | class_def_item(sect) = u32(var(class_idx,~))
100 | & access_flags
101 | & u32(var(superclass_idx,~))
102 | & u32(var(interfaces_off,~))
103 | & u32(var(source_file_idx,~))
104 | & u32(var(annotations_off,~))
105 | & u32(var(class_data_off,~))
106 | & u32(var(static_values_off,~))
107 | & offs_type_id_item(sect,class_idx)
108 | & [superclass_idx != NO_INDEX: offs_type_id_item(sect,superclass_idx);]
109 | & [interfaces_off != 0: offset(interfaces_off*8,type_list(sect));]
110 | & offs_string_item(sect,source_file_idx)
111 | & [annotations_off != 0: offset(annotations_off*8,annotations_directory_item(sect));]
112 | & [class_data_off != 0: offset(class_data_off*8,class_data_item(sect));]
113 | & [static_values_off != 0: offset(static_values_off*8,encoded_array_item(sect));]
114 | ;
115 |
116 | annotations_directory_item(sect) = u32(var(class_annotations_off,~))
117 | & u32(var(fields_size,~))
118 | & u32(var(methods_size,~))
119 | & u32(var(parameters_size,~))
120 | & field_annotation(sect){fields_size}
121 | & method_annotation(sect){methods_size}
122 | & parameter_annotation(sect){parameters_size}
123 | & [class_annotations_off != 0: annotation_set_item(sect);]
124 | ;
125 |
126 | annotation_set_item(sect) = u32(var(size,~))
127 | & annotation_off_item(sect){size}
128 | ;
129 |
130 | annotation_off_item(sect) = u32(var(annotation_off,~))
131 | & offset(annotation_off*8, annotation_item(sect))
132 | ;
133 |
134 | annotation_item(sect) = u8(visibility)
135 | & encoded_annotation(sect)
136 | ;
137 |
138 | encoded_annotation(sect) = uleb128(var(type_idx,~))
139 | & uleb128(var(size,~))
140 | & annotation_element(sect){size}
141 | & offs_type_id_item(sect,type_idx)
142 | ;
143 |
144 | annotation_element(sect) = uleb128(var(name_idx,~))
145 | & encoded_value(sect)
146 | & offs_string_item(name_idx)
147 | ;
148 |
149 | encoded_value(sect) = TODO;
150 |
151 | class_data_item(sect) = uleb128(var(static_fields_size,~))
152 | & uleb128(var(instance_fields_size,~))
153 | & uleb128(var(direct_methods_size,~))
154 | & uleb128(var(virtual_methods_size,~))
155 | & static_field(sect){static_fields_size}
156 | & instance_field(sect){instance_fields_size}
157 | & direct_method(sect){direct_methods_size}
158 | & virtual_method(sect){virtual_methods_size}
159 | ;
160 | static_field(sect) = encoded_field(sect);
161 | instance_field(sect) = encoded_field(sect);
162 | direct_method(sect) = encoded_method(sect);
163 | virtual_method(sect) = encoded_method(sect);
164 |
165 | encoded_field(sect) = uleb128(var(field_idx_diff,~))
166 | & uleb128bits(var(access,access_flags))
167 | ;
168 |
169 | encoded_method(sect) = uleb128(var(method_idx_diff,~))
170 | & uleb128bits(var(access,access_flags))
171 | & uleb128(var(method_code_off,~))
172 | & [method_code_off > 0: offset(method_code_off*8, code_item);]
173 | ;
174 |
175 |
176 | encoded_array_item(sect) = TODO;
177 | annotation_set_ref_list(sect) = TODO;
178 | code_item(sect) = TODO;
179 | debug_info_item(sect) = TODO;
180 | hiddenapi_class_data_item(sect) = TODO;
181 |
182 | call_site_id_item = u32(var(file_off,~)) & offset(file_off*8, call_site_item);
183 | call_site_item = TODO;
184 |
185 | type_list(sect) = u32(var(count,~)) & type_item(sect){count};
186 | type_item(sect) = u16(var(index,~)) & offs_type_id_item(sect,index);
187 |
188 |
189 | method_handle_item(sect) = u16(method_handle_type)
190 | & u16(0)
191 | & u16(index)
192 | & u16(0)
193 | & [
194 | method_handle_type = METHOD_HANDLE_TYPE_STATIC_PUT
195 | | method_handle_type = METHOD_HANDLE_TYPE_STATIC_GET
196 | | method_handle_type = METHOD_HANDLE_TYPE_INSTANCE_PUT
197 | | method_handle_type = METHOD_HANDLE_TYPE_INSTANCE_GET
198 | : offs_field_id_item(sect,index);
199 | : offs_method_id_item(sect,index);
200 | ]
201 | ;
202 |
203 | map_list(sect) = u32(var(entry_count,~)) & map_item(sect){entry_count};
204 | map_item(sect) = u16(var(item_type,type)
205 | & u16(~) # Unused
206 | & u32(var(item_count,~))
207 | & u32(var(file_off,~))
208 | & offset(file_off*8,
209 | [
210 | item_type = TYPE_HEADER_ITEM : header{item_count};
211 | item_type = TYPE_STRING_ID_ITEM : string_id_item{item_count};
212 | item_type = TYPE_TYPE_ID_ITEM : type_id_item(sect){item_count};
213 | item_type = TYPE_PROTO_ID_ITEM : proto_id_item(sect){item_count};
214 | item_type = TYPE_FIELD_ID_ITEM : field_id_item(sect){item_count};
215 | item_type = TYPE_METHOD_ID_ITEM : method_id_item(sect){item_count};
216 | item_type = TYPE_CLASS_DEF_ITEM : class_def_item(sect){item_count};
217 | item_type = TYPE_CALL_SITE_ID_ITEM : call_site_id_item(sect){item_count};
218 | item_type = TYPE_METHOD_HANDLE_ITEM : method_handle_item(sect){item_count};
219 | item_type = TYPE_MAP_LIST : map_list(sect){item_count};
220 | item_type = TYPE_TYPE_LIST : type_list(sect){item_count};
221 | item_type = TYPE_ANNOTATION_SET_REF_LIST : annotation_set_ref_list(sect){item_count};
222 | item_type = TYPE_ANNOTATION_SET_ITEM : annotation_set_item(sect){item_count};
223 | item_type = TYPE_CLASS_DATA_ITEM : class_data_item(sect){item_count};
224 | item_type = TYPE_CODE_ITEM : code_item(sect){item_count};
225 | item_type = TYPE_STRING_DATA_ITEM : string_data_item(sect){item_count};
226 | item_type = TYPE_DEBUG_INFO_ITEM : debug_info_item(sect){item_count};
227 | item_type = TYPE_ANNOTATION_ITEM : annotation_item(sect){item_count};
228 | item_type = TYPE_ENCODED_ARRAY_ITEM : encoded_array_item(sect){item_count};
229 | item_type = TYPE_ANNOTATIONS_DIRECTORY_ITEM : annotations_directory_item(sect){item_count};
230 | item_type = TYPE_HIDDENAPI_CLASS_DATA_ITEM : hiddenapi_class_data_item(sect){item_count};
231 | ])
232 | ;
233 |
234 | access_flags = ordered(
235 | uint(14,0)
236 | & u1(var(declared_synchronized,~))
237 | & u1(var(constructor,~))
238 | & u1(0)
239 | & u1(var(enum,~))
240 | & u1(var(annotation,~))
241 | & u1(var(synthetic,~))
242 | & u1(var(strict,~))
243 | & u1(var(abstract,~))
244 | & u1(var(interface,~))
245 | & u1(var(native,~))
246 | & u1(var(transient_or_varargs,~))
247 | & u1(var(volatile_or_bridge,~))
248 | & u1(var(synchronized,~))
249 | & u1(var(final,~))
250 | & u1(var(static,~))
251 | & u1(var(protected,~))
252 | & u1(var(private,~))
253 | & u1(var(public,~))
254 | );
255 |
256 | uleb128p1(values: sintegers): bits = """https://source.android.com/docs/core/runtime/dex-format#leb128""";
257 | uleb128(values: uintegers): bits = """https://source.android.com/docs/core/runtime/dex-format#leb128""";
258 | uleb128bits(expr: bits): bits = """https://source.android.com/docs/core/runtime/dex-format#leb128""";
259 |
260 | u1(values) = uint(1,values);
261 | u3(values) = uint(3,values);
262 | u5(values) = uint(5,values);
263 | u8(values) = uint(8,values);
264 | u16(values) = ordered(uint(16,values));
265 | u32(values) = ordered(uint(32,values));
266 |
267 | NO_INDEX = 0xffffffff;
268 |
269 | visibility = VISIBILITY_BUILD
270 | | VISIBILITY_RUNTIME
271 | | VISIBILITY_SYSTEM
272 | ;
273 | VISIBILITY_BUILD = 0;
274 | VISIBILITY_RUNTIME = 1;
275 | VISIBILITY_SYSTEM = 2;
276 |
277 | method_handle_type = METHOD_HANDLE_TYPE_STATIC_PUT
278 | | METHOD_HANDLE_TYPE_STATIC_GET
279 | | METHOD_HANDLE_TYPE_INSTANCE_PUT
280 | | METHOD_HANDLE_TYPE_INSTANCE_GET
281 | | METHOD_HANDLE_TYPE_INVOKE_STATIC
282 | | METHOD_HANDLE_TYPE_INVOKE_INSTANCE
283 | | METHOD_HANDLE_TYPE_INVOKE_CONSTRUCTOR
284 | | METHOD_HANDLE_TYPE_INVOKE_DIRECT
285 | | METHOD_HANDLE_TYPE_INVOKE_INTERFACE
286 | ;
287 | METHOD_HANDLE_TYPE_STATIC_PUT = 0;
288 | METHOD_HANDLE_TYPE_STATIC_GET = 1;
289 | METHOD_HANDLE_TYPE_INSTANCE_PUT = 2;
290 | METHOD_HANDLE_TYPE_INSTANCE_GET = 3;
291 | METHOD_HANDLE_TYPE_INVOKE_STATIC = 4;
292 | METHOD_HANDLE_TYPE_INVOKE_INSTANCE = 5;
293 | METHOD_HANDLE_TYPE_INVOKE_CONSTRUCTOR = 6;
294 | METHOD_HANDLE_TYPE_INVOKE_DIRECT = 7;
295 | METHOD_HANDLE_TYPE_INVOKE_INTERFACE = 8;
296 |
297 | type = TYPE_HEADER_ITEM
298 | | TYPE_STRING_ID_ITEM
299 | | TYPE_TYPE_ID_ITEM
300 | | TYPE_PROTO_ID_ITEM
301 | | TYPE_FIELD_ID_ITEM
302 | | TYPE_METHOD_ID_ITEM
303 | | TYPE_CLASS_DEF_ITEM
304 | | TYPE_CALL_SITE_ID_ITEM
305 | | TYPE_METHOD_HANDLE_ITEM
306 | | TYPE_MAP_LIST
307 | | TYPE_TYPE_LIST
308 | | TYPE_ANNOTATION_SET_REF_LIST
309 | | TYPE_ANNOTATION_SET_ITEM
310 | | TYPE_CLASS_DATA_ITEM
311 | | TYPE_CODE_ITEM
312 | | TYPE_STRING_DATA_ITEM
313 | | TYPE_DEBUG_INFO_ITEM
314 | | TYPE_ANNOTATION_ITEM
315 | | TYPE_ENCODED_ARRAY_ITEM
316 | | TYPE_ANNOTATIONS_DIRECTORY_ITEM
317 | | TYPE_HIDDENAPI_CLASS_DATA_ITEM
318 | ;
319 | TYPE_HEADER_ITEM = 0;
320 | TYPE_STRING_ID_ITEM = 1;
321 | TYPE_TYPE_ID_ITEM = 2;
322 | TYPE_PROTO_ID_ITEM = 3;
323 | TYPE_FIELD_ID_ITEM = 4;
324 | TYPE_METHOD_ID_ITEM = 5;
325 | TYPE_CLASS_DEF_ITEM = 6;
326 | TYPE_CALL_SITE_ID_ITEM = 7;
327 | TYPE_METHOD_HANDLE_ITEM = 8;
328 | TYPE_MAP_LIST = 0x1000;
329 | TYPE_TYPE_LIST = 0x1001;
330 | TYPE_ANNOTATION_SET_REF_LIST = 0x1002;
331 | TYPE_ANNOTATION_SET_ITEM = 0x1003;
332 | TYPE_CLASS_DATA_ITEM = 0x2000;
333 | TYPE_CODE_ITEM = 0x2001;
334 | TYPE_STRING_DATA_ITEM = 0x2002;
335 | TYPE_DEBUG_INFO_ITEM = 0x2003;
336 | TYPE_ANNOTATION_ITEM = 0x2004;
337 | TYPE_ENCODED_ARRAY_ITEM = 0x2005;
338 | TYPE_ANNOTATIONS_DIRECTORY_ITEM = 0x2006;
339 | TYPE_HIDDENAPI_CLASS_DATA_ITEM = 0xf000;
340 |
--------------------------------------------------------------------------------
/v1/examples/dns_query.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf_8
2 | - identifier = dns_query
3 | - description = Domain Name Service (Query)
4 | - reference = https://www.rfc-editor.org/rfc/rfc1035.txt
5 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.0.md
6 |
7 | query = var(head,header)
8 | & question{head.question_count}
9 | ;
10 |
11 | header = u16(var(identifier,~))
12 | & u1(0)
13 | & u4(opcode)
14 | & u1(0)
15 | & u1(var(truncation,~))
16 | & u1(var(recursion_desired,~))
17 | & u8(0)
18 | & u16(var(question_count,~))
19 | ;
20 |
21 | question = domain_name
22 | & u16(qtype)
23 | & u16(qclass)
24 | ;
25 |
26 | domain_name = var(label,label) & [label.text.length != 0: domain_name;];
27 | label = var(text,label_text) | label_offset;
28 | label_text = u2(label_type_text)
29 | & u6(var(length,~))
30 | & var(contents, u8(~){length})
31 | ;
32 | label_offset = u2(label_type_offset)
33 | & u14(var(offs,~))
34 | & offset(offs, label_text)
35 | ;
36 | label_type_text = 0;
37 | label_type_offset = 3;
38 |
39 | opcode = opcode_query
40 | | opcode_iquery
41 | | opcode_status
42 | ;
43 | opcode_query = 0;
44 | opcode_iquery = 1;
45 | opcode_status = 2;
46 |
47 | type = type_a
48 | | type_ns
49 | | type_md
50 | | type_mf
51 | | type_came
52 | | type_soa
53 | | type_mb
54 | | type_mg
55 | | type_mr
56 | | type_null
57 | | type_wks
58 | | type_ptr
59 | | type_hinfo
60 | | type_minfo
61 | | type_text
62 | ;
63 | qtype = type
64 | | qtype_axfr
65 | | qtype_mailb
66 | | qtype_maila
67 | | qtype_star
68 | ;
69 | type_a = 1;
70 | type_ns = 2;
71 | type_md = 3;
72 | type_mf = 4;
73 | type_came = 5;
74 | type_soa = 6;
75 | type_mb = 7;
76 | type_mg = 8;
77 | type_mr = 9;
78 | type_null = 10;
79 | type_wks = 11;
80 | type_ptr = 12;
81 | type_hinfo = 13;
82 | type_minfo = 14;
83 | type_text = 15;
84 | qtype_axfr = 252;
85 | qtype_mailb = 253;
86 | qtype_maila = 254;
87 | qtype_star = 255;
88 |
89 | class = class_in
90 | | class_cs
91 | | class_ch
92 | | class_hs
93 | ;
94 | qclass = class
95 | | qclass_star
96 | ;
97 | class_in = 1;
98 | class_cs = 2;
99 | class_ch = 3;
100 | class_hs = 4;
101 | qclass_star = 255;
102 |
103 | u1(v) = uint(1,v);
104 | u2(v) = uint(2,v);
105 | u4(v) = uint(4,v);
106 | u6(v) = uint(6,v);
107 | u8(v) = uint(8,v);
108 | u14(v) = uint(14,v);
109 | u16(v) = uint(16,v);
110 |
--------------------------------------------------------------------------------
/v1/examples/dns_response.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf_8
2 | - identifier = dns_response
3 | - description = Domain Name Service (Response)
4 | - reference = https://www.rfc-editor.org/rfc/rfc1035.txt
5 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.0.md
6 |
7 | response = var(head,header)
8 | & resource_record{head.answer_count}
9 | & resource_record{head.name_server_count}
10 | & resource_record{head.additional_records_count}
11 | ;
12 |
13 | header = u16(var(identifier,~))
14 | & u1(1)
15 | & u4(opcode)
16 | & u1(var(authoriative_answer,~))
17 | & u1(var(truncation,~))
18 | & u1(var(recursion_desired,~))
19 | & u1(var(recursion_available,~))
20 | & u3(0)
21 | & u4(var(rcode,response_code))
22 | & u16(0)
23 | & u16(var(answer_count,~))
24 | & u16(var(name_server_count,~))
25 | & u16(var(additional_records_count,~))
26 | ;
27 |
28 | resource_record = domain_name
29 | & u16(type)
30 | & u16(class)
31 | & u32(var(time_to_live,~))
32 | & u16(var(rdlength,~))
33 | & sized(rdlength*8, resource_data(type,class))
34 | ;
35 |
36 | resource_data(type,class) = [
37 | type = type_cname: rdata_cname;
38 | type = type_hinfo: rdata_hinfo;
39 | type = type_mb: rdata_mb;
40 | type = type_md: rdata_md;
41 | type = type_mf: rdata_mf;
42 | type = type_mg: rdata_mg;
43 | type = type_minfo: rdata_minfo;
44 | type = type_mr: rdata_mr;
45 | type = type_mx: rdata_mx;
46 | type = type_null: rdata_null;
47 | type = type_ns: rdata_ns;
48 | type = type_ptr: rdata_ptr;
49 | type = type_soa: rdata_soa;
50 | type = type_txt: rdata_txt;
51 | type = type_a & class = class_in: rdata_a;
52 | type = type_wks & class = class_in: rdata_wks;
53 | ]
54 | ;
55 |
56 | rdata_cname = domain_name;
57 | rdata_hinfo = var(cpu,character_string) & var(os,character_string);
58 | rdata_mb = domain_name;
59 | rdata_md = domain_name;
60 | rdata_mf = domain_name;
61 | rdata_mg = domain_name;
62 | rdata_minfo = var(rmailbx,domain_name) & var(emailbx,domain_name);
63 | rdata_mr = domain_name;
64 | rdata_mx = u16(var(preference,~)) & var(exchange,domain_name);
65 | rdata_null = u8(~)*;
66 | rdata_ns = domain_name;
67 | rdata_ptr = domain_name;
68 | rdata_soa = var(mname,domain_name)
69 | & var(rname,domain_name)
70 | & u32(var(serial,~))
71 | & u32(var(refresh,~))
72 | & u32(var(retry,~))
73 | & u32(var(expire,~))
74 | & u32(var(minimum,~))
75 | ;
76 | rdata_txt = character_string*;
77 |
78 | # Internet-specific
79 | rdata_a = u32(~);
80 | rdata_wks = u32(var(address,~))
81 | & u8(protocol)
82 | & var(bitmap,u1(~)*)
83 | ;
84 |
85 | protocol: uinteger = """https://datatracker.ietf.org/doc/html/rfc1010""";
86 |
87 | domain_name = var(label,label) & [label.text.length != 0: domain_name;];
88 | label = var(text,label_text) | label_offset;
89 | label_text = u2(label_type_text)
90 | & u6(var(length,~))
91 | & var(contents, u8(~){length})
92 | ;
93 | label_offset = u2(label_type_offset)
94 | & u14(var(offs,~))
95 | & offset(offs, label_text)
96 | ;
97 | label_type_text = 0;
98 | label_type_offset = 3;
99 |
100 | character_string = u8(var(length,~)) & u8(~){length};
101 |
102 | opcode = opcode_query
103 | | opcode_iquery
104 | | opcode_status
105 | ;
106 | opcode_query = 0;
107 | opcode_iquery = 1;
108 | opcode_status = 2;
109 |
110 | type = type_a
111 | | type_ns
112 | | type_md
113 | | type_mf
114 | | type_came
115 | | type_soa
116 | | type_mb
117 | | type_mg
118 | | type_mr
119 | | type_null
120 | | type_wks
121 | | type_ptr
122 | | type_hinfo
123 | | type_minfo
124 | | type_text
125 | ;
126 | type_a = 1;
127 | type_ns = 2;
128 | type_md = 3;
129 | type_mf = 4;
130 | type_came = 5;
131 | type_soa = 6;
132 | type_mb = 7;
133 | type_mg = 8;
134 | type_mr = 9;
135 | type_null = 10;
136 | type_wks = 11;
137 | type_ptr = 12;
138 | type_hinfo = 13;
139 | type_minfo = 14;
140 | type_text = 15;
141 |
142 | class = class_in
143 | | class_cs
144 | | class_ch
145 | | class_hs
146 | ;
147 | class_in = 1;
148 | class_cs = 2;
149 | class_ch = 3;
150 | class_hs = 4;
151 |
152 | response_code = response_ok
153 | | response_format_error
154 | | response_server_failure
155 | | response_name_error
156 | | response_not_implemented
157 | | response_refused
158 | ;
159 | response_ok = 0;
160 | response_format_error = 1;
161 | response_server_failure = 2;
162 | response_name_error = 3;
163 | response_not_implemented = 4;
164 | response_refused = 5;
165 |
166 | u1(v) = uint(1,v);
167 | u2(v) = uint(2,v);
168 | u3(v) = uint(3,v);
169 | u4(v) = uint(4,v);
170 | u6(v) = uint(6,v);
171 | u8(v) = uint(8,v);
172 | u14(v) = uint(14,v);
173 | u16(v) = uint(16,v);
174 | u32(v) = uint(32,v);
175 |
--------------------------------------------------------------------------------
/v1/examples/ico.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = ico
3 | - description = Microsoft ICO icon file format
4 | - reference = https://learn.microsoft.com/en-us/previous-versions/ms997538(v=msdn.10)
5 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
6 |
7 | document = byte_order(lsb, document_le);
8 |
9 | document_le = var(head,header)
10 | & icon_dir_entry{head.count}
11 | ;
12 |
13 | header = u16(0)
14 | & u16(1)
15 | & u16(var(count,~))
16 | ;
17 |
18 | icon_dir_entry = width
19 | & height
20 | & color_count
21 | & u8(0)
22 | & color_planes
23 | & bits_per_pixel
24 | & u32(var(byte_count,~))
25 | & u32(var(image_offset,~))
26 | & offset(image_offset*8, image)
27 | ;
28 | width = u8(~);
29 | height = u8(~);
30 | color_count = u8(~);
31 | color_planes = u16(~);
32 | bits_per_pixel = u16(~);
33 |
34 | image = var(info, bitmap_info)
35 | & [
36 | info.bit_count = 1: rgb_quad{2};
37 | info.bit_count = 4: rgb_quad{16};
38 | info.bit_count = 8: rgb_quad{256};
39 | ]
40 | & xor_data(info.width, info.height/2, info.bit_count)
41 | & and_data(info.width, info.height/2)
42 | ;
43 |
44 | bitmap_info = u32(var(size,~))
45 | & u32(var(width,~))
46 | & s32(var(height,~)) # Note: Can be negative!
47 | & u16(var(planes,~))
48 | & u16(var(bit_count, 1 | 4 | 8 | 16 | 24 | 32))
49 | & u32(0) # biCompression
50 | & u32(var(size_image,~))
51 | & u32(0) # biXPelsPerMeter
52 | & u32(0) # biYPelsPerMeter
53 | & u32(0) # biClrUsed
54 | & u32(0) # biClrImportant
55 | ;
56 |
57 | rgb_quad = blue
58 | & green
59 | & red
60 | & u8(0)
61 | ;
62 | blue = u8(~);
63 | green = u8(~);
64 | red = u8(~);
65 |
66 | u8(values) = uint(8,values);
67 | u16(values) = ordered(uint(16,values);
68 | u32(values) = ordered(uint(32,values);
69 | s32(values) = ordered(sint(32,values);
70 |
71 | xor_data(width, height, bpp) = uint(bpp,~){width*height};
72 | and_data(width, height) = uint(1,~){width*height};
73 |
--------------------------------------------------------------------------------
/v1/examples/ipv4.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = ip_v4
3 | - description = Internet Protocol, version 4
4 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
5 |
6 | ip_packet = version
7 | & u4(var(header_length, 5~)) # length is in 32-bit words
8 | & differentiated_services_code_point
9 | & explicit_congestion_notification
10 | & u16(var(total_length, 20~)) # length is in bytes
11 | & identification
12 | & flags
13 | & fragment_offset
14 | & time_to_live
15 | & u8(var(protocol, registered_protocol))
16 | & header_checksum
17 | & source_ip_address
18 | & destination_ip_address
19 | & options((header_length-5) * 32)
20 | & payload(protocol, (total_length-(header_length*4)) * 8)
21 | ;
22 |
23 | version = u4(4);
24 | differentiated_services_code_point = u6(dcsp_0 | dcsp_1 | dcsp_2 | dcsp_3 | dcsp_4 | dcsp_5 | dcsp_6 | dcsp_7);
25 | dcsp_0 = 0x00;
26 | dcsp_1 = 0x08;
27 | dcsp_2 = 0x10;
28 | dcsp_3 = 0x18;
29 | dcsp_4 = 0x20;
30 | dcsp_5 = 0x28;
31 | dcsp_6 = 0x30;
32 | dcsp_7 = 0x38;
33 | explicit_congestion_notification = u2(ect_none | ect_0 | ect_1 | ect_congestion);
34 | ect_none = 0;
35 | ect_0 = 1;
36 | ect_1 = 2;
37 | ect_congestion = 3;
38 | identification = u16(~);
39 | flags = u1(0) & do_not_fragment & more_fragments;
40 | do_not_fragment = u1(~);
41 | more_fragments = u1(~);
42 | fragment_offset = u13(~);
43 | time_to_live = u8(~);
44 | registered_protocol = """https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml""";
45 | header_checksum = u16(~);
46 | source_ip_address = u32(address_space);
47 | destination_ip_address = u32(address_space);
48 | address_space = """https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml""";
49 |
50 | options(bit_count) = sized(bit_count, option*);
51 | option = option_eool
52 | | option_nop
53 | | option_sec
54 | | option_lsr
55 | | option_ts
56 | | option_e_sec
57 | | option_cipso
58 | | option_rr
59 | | option_sid
60 | | option_ssr
61 | # TODO: the rest of the options
62 | ;
63 | option_eool = copy_no & class_control & u5(0);
64 | option_nop = copy_no & class_control & u5(1);
65 | option_sec = copy_yes & class_debug_measure & u5(2) & option_length & rfc1108;
66 | option_lsr = copy_yes & class_control & u5(3) & option_length & rfc791;
67 | option_ts = copy_yes & class_debug_measure & u5(4) & option_length & rfc791;
68 | option_e_sec = copy_yes & class_debug_measure & u5(5) & option_length & rfc1108;
69 | option_cipso = copy_yes & class_debug_measure & u5(6) & option_length & draft_ietf_cipso_ipsecurity_01;
70 | option_rr = copy_no & class_control & u5(7) & option_length & rfc791;
71 | option_sid = copy_yes & class_control & u5(8) & option_length & rfc791;
72 | option_ssr = copy_yes & class_control & u5(9) & option_length & rfc791;
73 | option_length = u8(~);
74 | copy_yes = u1(1);
75 | copy_no = u1(0);
76 | class_control = u2(0);
77 | class_debug_measure = u2(2);
78 | rfc1108: bits = """https://www.rfc-editor.org/rfc/rfc1108.html""";
79 | rfc791 = """https://www.rfc-editor.org/rfc/rfc791.html""";
80 | draft_ietf_cipso_ipsecurity_01 = """https://datatracker.ietf.org/doc/draft-ietf-cipso-ipsecurity/01/""";
81 |
82 | payload(protocol, bit_count) = sized(bit_count, payload_contents(protocol) & u1(0)*);
83 | payload_contents(protocol) = [
84 | protocol = 0: protocol_hopopt;
85 | protocol = 1: protocol_icmp;
86 | # TODO: the rest of the protocols
87 | ];
88 | protocol_hopopt = """https://www.rfc-editor.org/rfc/rfc8200.html""";
89 | protocol_icmp = """https://www.rfc-editor.org/rfc/rfc792.html""";
90 |
91 | u1(v) = uint(1, v);
92 | u2(v) = uint(2, v);
93 | u4(v) = uint(4, v);
94 | u5(v) = uint(5, v);
95 | u6(v) = uint(6, v);
96 | u8(v) = uint(8, v);
97 | u13(v) = uint(13, v);
98 | u16(v) = uint(16, v);
99 | u32(v) = uint(32, v);
100 |
--------------------------------------------------------------------------------
/v1/examples/json.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = json
3 | - description = Javascript Object Notation
4 | - charsets = utf-8, utf-16, utf-16be, utf-16le, utf-32, utf-32be, utf-32le
5 | - reference = https://www.json.org/json-en.html
6 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
7 |
8 | document = element;
9 | element = WS & value & WS;
10 | value = object
11 | | array
12 | | string
13 | | number
14 | | "true"
15 | | "false"
16 | | "null"
17 | ;
18 | object = '{' & member & (',' & member)* & '}';
19 | member = string & ':' & element;
20 | array = '[' & element & (',' & element)* & ']';
21 | string = WS & '"' (character | escape)* '"' & WS;
22 | character = (unicode(L|M|N|P|S|Z|Cf|Co) | '\[9]') ! ('"' | '\\');
23 | escape = '\\' & ('"' | '\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' & hex{4});
24 | hex = '0'~'9' | 'a'~'f' | 'A'~'F';
25 | number = integer & fraction? & exponent?;
26 | integer = '0' | ('-'? & first_digit & next_digit*);
27 | fraction = '.' & next_digit+;
28 | exponent = ('e' | 'E') & ('+' | '-')? & next_digit+;
29 | first_digit = '1'~'9';
30 | next_digit = '0'~'9';
31 | WS = (' ' | '\[a]' | '\[d]' | '\[9]')*;
32 |
--------------------------------------------------------------------------------
/v1/examples/minidump.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = mdmp
3 | - description = Microsoft Minidump
4 | - reference = https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_header
5 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
6 |
7 | document = byte_order(lsb, header);
8 |
9 |
10 | ###############################################################################
11 | # Header
12 | ###############################################################################
13 |
14 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_header
15 | header = "MDMP"
16 | & u16(0xa793) # MDMP Version
17 | & u16(var(impl_version,~))
18 | & u32(var(NumberOfStreams,~))
19 | & u32(var(StreamDirectoryRva,~))
20 | & u32(var(CheckSum,~))
21 | & u32(var(TimeDateStamp,~))
22 | & var(flags,header_flags)
23 | & offset(StreamDirectoryRva*8, directory{NumberOfStreams})
24 | ;
25 |
26 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ne-minidumpapiset-minidump_type
27 | header_flags = ordered(
28 | uint(40,0)
29 | & u1(var(ScanInaccessiblePartialPages,~))
30 | & u1(var(WithIptTrace,~))
31 | & u1(var(WithAvxXStateContext,~))
32 | & u1(var(FilterTriage,~))
33 | & u1(var(WithModuleHeaders,~))
34 | & u1(var(WithTokenInformation,~))
35 | & u1(var(IgnoreInaccessibleMemory,~))
36 | & u1(var(WithPrivateWriteCopyMemory,~))
37 | & u1(var(WithFullAuxiliaryState,~))
38 | & u1(var(WithoutAuxiliaryState,~))
39 | & u1(var(WithCodeSegs,~))
40 | & u1(var(WithThreadInfo,~))
41 | & u1(var(WithFullMemoryInfo,~))
42 | & u1(var(WithoutOptionalData,~))
43 | & u1(var(WithPrivateReadWriteMemory,~))
44 | & u1(var(WithProcessThreadData,~))
45 | & u1(var(FilterModulePaths,~))
46 | & u1(var(WithIndirectlyReferencedMemory,~))
47 | & u1(var(WithUnloadedModules,~))
48 | & u1(var(ScanMemory,~))
49 | & u1(var(FilterMemory,~))
50 | & u1(var(WithHandleData,~))
51 | & u1(var(WithFullMemory,~))
52 | & u1(var(WithDataSegs,~))
53 | );
54 |
55 | ###############################################################################
56 | # Directory
57 | ###############################################################################
58 |
59 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_directory
60 | directory = u32(var(type,stream_type))
61 | & var(loc,location_descriptor)
62 | & offset(loc.rva*8, [
63 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ne-minidumpapiset-minidump_stream_type
64 | type = TypeCommentStreamA : ansi_string(loc.size);
65 | type = TypeCommentStreamW : wide_string(loc.size/2);
66 | type = TypeExceptionStream : exception_stream;
67 | type = TypeFunctionTableStream : function_table_stream;
68 | type = TypeHandleDataStream : handle_data_stream;
69 | type = TypeHandleOperationListStream : operation_list;
70 | type = TypeMemoryListStream : memory_list;
71 | type = TypeMemory64ListStream : memory64_list;
72 | type = TypeMemoryInfoListStream : memory_info_list;
73 | type = TypeMiscInfoStream : peek(u32(var(info_size,~)))
74 | & [
75 | info_size = 24: misc_info;
76 | info_size = 44: misc_info_2;
77 | ]
78 | ;
79 | type = TypeModuleListStream : module_list;
80 | type = TypeSystemInfoStream : system_info;
81 | type = TypeThreadListStream : thread_list;
82 | type = TypeThreadExListStream : thread_ex_list;
83 | type = TypeThreadInfoListStream : thread_info_list;
84 | type = TypeUnloadedModuleListStream : unloaded_module_list;
85 | : u8(~){loc.size};
86 | ]
87 | ;
88 |
89 | stream_type = TypeUnusedStream
90 | | TypeReservedStream0
91 | | TypeReservedStream1
92 | | TypeThreadListStream
93 | | TypeModuleListStream
94 | | TypeMemoryListStream
95 | | TypeExceptionStream
96 | | TypeSystemInfoStream
97 | | TypeThreadExListStream
98 | | TypeMemory64ListStream
99 | | TypeCommentStreamA
100 | | TypeCommentStreamW
101 | | TypeHandleDataStream
102 | | TypeFunctionTableStream
103 | | TypeUnloadedModuleListStream
104 | | TypeMiscInfoStream
105 | | TypeMemoryInfoListStream
106 | | TypeThreadInfoListStream
107 | | TypeHandleOperationListStream
108 | | TypeTokenStream
109 | | TypeJavaScriptDataStream
110 | | TypeSystemMemoryInfoStream
111 | | TypeProcessVmCountersStream
112 | | TypeIptTraceStream
113 | | TypeThreadNamesStream
114 | | TypeCEStreamNull
115 | | TypeCEStreamSystemInfo
116 | | TypeCEStreamException
117 | | TypeCEStreamModuleList
118 | | TypeCEStreamProcessList
119 | | TypeCEStreamThreadList
120 | | TypeCEStreamThreadContextList
121 | | TypeCEStreamThreadCallStackList
122 | | TypeCEStreamMemoryVirtualList
123 | | TypeCEStreamMemoryPhysicalList
124 | | TypeCEStreamBucketParameters
125 | | TypeCEStreamProcessModuleMap
126 | | TypeCEStreamDiagnosisList
127 | | TypeLastReservedStream
128 | ;
129 | TypeUnusedStream = 0;
130 | TypeReservedStream0 = 1;
131 | TypeReservedStream1 = 2;
132 | TypeThreadListStream = 3;
133 | TypeModuleListStream = 4;
134 | TypeMemoryListStream = 5;
135 | TypeExceptionStream = 6;
136 | TypeSystemInfoStream = 7;
137 | TypeThreadExListStream = 8;
138 | TypeMemory64ListStream = 9;
139 | TypeCommentStreamA = 10;
140 | TypeCommentStreamW = 11;
141 | TypeHandleDataStream = 12;
142 | TypeFunctionTableStream = 13;
143 | TypeUnloadedModuleListStream = 14;
144 | TypeMiscInfoStream = 15;
145 | TypeMemoryInfoListStream = 16;
146 | TypeThreadInfoListStream = 17;
147 | TypeHandleOperationListStream = 18;
148 | TypeTokenStream = 19;
149 | TypeJavaScriptDataStream = 20;
150 | TypeSystemMemoryInfoStream = 21;
151 | TypeProcessVmCountersStream = 22;
152 | TypeIptTraceStream = 23;
153 | TypeThreadNamesStream = 24;
154 | TypeCEStreamNull = 0x8000;
155 | TypeCEStreamSystemInfo = 0x8001;
156 | TypeCEStreamException = 0x8002;
157 | TypeCEStreamModuleList = 0x8003;
158 | TypeCEStreamProcessList = 0x8004;
159 | TypeCEStreamThreadList = 0x8005;
160 | TypeCEStreamThreadContextList = 0x8006;
161 | TypeCEStreamThreadCallStackList = 0x8007;
162 | TypeCEStreamMemoryVirtualList = 0x8008;
163 | TypeCEStreamMemoryPhysicalList = 0x8009;
164 | TypeCEStreamBucketParameters = 0x800A;
165 | TypeCEStreamProcessModuleMap = 0x800B;
166 | TypeCEStreamDiagnosisList = 0x800C;
167 | TypeLastReservedStream = 0xffff;
168 |
169 |
170 | ###############################################################################
171 | # Exception
172 | ###############################################################################
173 |
174 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_exception_stream
175 | exception_stream = u32(var(ThreadId,~))
176 | & u32(var(Alignment,~))
177 | & var(ExceptionRecord,exception)
178 | & var(ThreadContext,location_descriptor)
179 | ;
180 |
181 | https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_exception
182 | exception = u32(var(ExceptionCode,exception_code))
183 | & var(ExceptionFlags,exception_flags)
184 | & u64(var(ExeptionRecord,~))
185 | & u64(var(ExeptionAddress,~))
186 | & u32(var(NumberParameters,~))
187 | & u32(var(unusedAlignment,~))
188 | & var(ExceptionInformation,u64(~){NumberParameters})
189 | & [ExceptionRecord != 0: offset(ExceptionRecord*8,exception);]
190 | ;
191 |
192 | exception_flags = uint(31,0)
193 | & u1(var(noncontinuable,~))
194 | ;
195 |
196 | exception_code = EXCEPTION_ACCESS_VIOLATION
197 | | EXCEPTION_ARRAY_BOUNDS_EXCEEDED
198 | | EXCEPTION_BREAKPOINT
199 | | EXCEPTION_DATATYPE_MISALIGNMENT
200 | | EXCEPTION_FLT_DENORMAL_OPERAND
201 | | EXCEPTION_FLT_DIVIDE_BY_ZERO
202 | | EXCEPTION_FLT_INEXACT_RESULT
203 | | EXCEPTION_FLT_INVALID_OPERATION
204 | | EXCEPTION_FLT_OVERFLOW
205 | | EXCEPTION_FLT_STACK_CHECK
206 | | EXCEPTION_FLT_UNDERFLOW
207 | | EXCEPTION_GUARD_PAGE
208 | | EXCEPTION_ILLEGAL_INSTRUCTION
209 | | EXCEPTION_IN_PAGE_ERROR
210 | | EXCEPTION_INT_DIVIDE_BY_ZERO
211 | | EXCEPTION_INT_OVERFLOW
212 | | EXCEPTION_INVALID_DISPOSITION
213 | | EXCEPTION_INVALID_HANDLE
214 | | EXCEPTION_NONCONTINUABLE_EXCEPTION
215 | | EXCEPTION_PRIV_INSTRUCTION
216 | | EXCEPTION_SINGLE_STEP
217 | | EXCEPTION_STACK_OVERFLOW
218 | ;
219 | EXCEPTION_ACCESS_VIOLATION = 0xC0000005;
220 | EXCEPTION_ARRAY_BOUNDS_EXCEEDED = 0xC000008C;
221 | EXCEPTION_BREAKPOINT = 0x80000003;
222 | EXCEPTION_DATATYPE_MISALIGNMENT = 0x80000002;
223 | EXCEPTION_FLT_DENORMAL_OPERAND = 0xC000008D;
224 | EXCEPTION_FLT_DIVIDE_BY_ZERO = 0xC000008E;
225 | EXCEPTION_FLT_INEXACT_RESULT = 0xC000008F;
226 | EXCEPTION_FLT_INVALID_OPERATION = 0xC0000090;
227 | EXCEPTION_FLT_OVERFLOW = 0xC0000091;
228 | EXCEPTION_FLT_STACK_CHECK = 0xC0000092;
229 | EXCEPTION_FLT_UNDERFLOW = 0xC0000093;
230 | EXCEPTION_GUARD_PAGE = 0x80000001;
231 | EXCEPTION_ILLEGAL_INSTRUCTION = 0xC000001D;
232 | EXCEPTION_IN_PAGE_ERROR = 0xC0000006;
233 | EXCEPTION_INT_DIVIDE_BY_ZERO = 0xC0000094;
234 | EXCEPTION_INT_OVERFLOW = 0xC0000095;
235 | EXCEPTION_INVALID_DISPOSITION = 0xC0000026;
236 | EXCEPTION_INVALID_HANDLE = 0xC0000008;
237 | EXCEPTION_NONCONTINUABLE_EXCEPTION = 0xC0000025;
238 | EXCEPTION_PRIV_INSTRUCTION = 0xC0000096;
239 | EXCEPTION_SINGLE_STEP = 0x80000004;
240 | EXCEPTION_STACK_OVERFLOW = 0xC00000FD;
241 |
242 |
243 | ###############################################################################
244 | # Function Table
245 | ###############################################################################
246 |
247 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_function_table_stream
248 | function_table_stream = u32(var(SizeOfHeader,~))
249 | & u32(var(SizeOfDescriptor,~))
250 | & u32(var(SizeOfNativeDescriptor,~))
251 | & u32(var(SizeOfFunctionEntry,~))
252 | & u32(var(NumberOfDescriptors,~))
253 | & u32(var(SizeOfAlignPad,~))
254 | & (
255 | function_table_descriptor(SizeOfNativeDescriptor,SizeOfFunctionEntry)
256 | & u8(0){SizeOfAlignPad}
257 | ){NumberOfDescriptors}
258 | ;
259 |
260 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_function_table_descriptor
261 | function_table_descriptor(desc_size, func_size)
262 | = u64(var(MinimumAddress,~))
263 | & u64(var(MaximumAddress,~))
264 | & u64(var(BaseAddress,~))
265 | & u32(var(EntryCount,~))
266 | & u32(var(SizeOfAlignPad,~))
267 | & u8(~){desc_size}
268 | & (
269 | u8(~){func_size}
270 | u8(0){SizeOfAlignPad}
271 | ){EntryCount}
272 | ;
273 |
274 |
275 | ###############################################################################
276 | # Handles
277 | ###############################################################################
278 |
279 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_handle_data_stream
280 | handle_data_stream = u32(var(SizeOfHeader,~))
281 | & u32(var(SizeOfDescriptor,~))
282 | & u32(var(NumberOfDescriptors,~))
283 | & u32(0)
284 | & [
285 | SizeOfDescriptor = 32: handle_descriptor;
286 | SizeOfDescriptor = 36: handle_descriptor_2;
287 | ]{NumberOfDescriptors}
288 | ;
289 |
290 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_handle_descriptor
291 | handle_descriptor = u64(var(Handle,~))
292 | & u32(var(TypeNameRva,~))
293 | & u32(var(ObjectNameRva,~))
294 | & u32(var(Attributes,~))
295 | & u32(var(GrantedAccess,~))
296 | & u32(var(HandleCount,~))
297 | & u32(var(PointerCount,~))
298 | & offset(TypeNameRva*8, string)
299 | & offset(ObjectNameRva*8, string)
300 | ;
301 |
302 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_handle_descriptor_2
303 | handle_descriptor_2 = u64(var(Handle,~))
304 | & u32(var(TypeNameRva,~))
305 | & u32(var(ObjectNameRva,~))
306 | & u32(var(Attributes,~))
307 | & u32(var(GrantedAccess,~))
308 | & u32(var(HandleCount,~))
309 | & u32(var(PointerCount,~))
310 | & u32(var(ObjectInfoRva,~))
311 | & u32(0)
312 | & offset(TypeNameRva*8, string)
313 | & offset(ObjectNameRva*8, string)
314 | & offset(ObjectInfoRva*8, handle_object_info)
315 | ;
316 |
317 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_handle_object_information
318 | handle_object_info = u32(var(NextInfoRva,~))
319 | & u32(var(InfoType,object_info_type))
320 | & u32(var(SizeOfInfo,~))
321 | & u8(~){SizeOfInfo}
322 | ;
323 |
324 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ne-minidumpapiset-minidump_handle_object_information_type
325 | object_info_type = MiniHandleObjectInformationNone
326 | | MiniThreadInformation1
327 | | MiniMutantInformation1
328 | | MiniMutantInformation2
329 | | MiniProcessInformation1
330 | | MiniProcessInformation2
331 | | MiniEventInformation1
332 | | MiniSectionInformation1
333 | | MiniSemaphoreInformation1
334 | ;
335 | MiniHandleObjectInformationNone = 0;
336 | MiniThreadInformation1 = 1;
337 | MiniMutantInformation1 = 2;
338 | MiniMutantInformation2 = 3;
339 | MiniProcessInformation1 = 4;
340 | MiniProcessInformation2 = 5;
341 | MiniEventInformation1 = 6;
342 | MiniSectionInformation1 = 7;
343 | MiniSemaphoreInformation1 = 8;
344 |
345 |
346 | ###############################################################################
347 | # Operation List
348 | ###############################################################################
349 |
350 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_handle_operation_list
351 | operation_list = u32(var(SizeOfHeader,~))
352 | & u32(var(SizeOfEntry,~))
353 | & u32(var(NumberOfEntries,~))
354 | & u32(0)
355 | & avrf_handle_operation{NumberOfEntries}
356 | ;
357 |
358 | # https://learn.microsoft.com/en-us/windows/win32/api/avrfsdk/ns-avrfsdk-avrf_handle_operation
359 | avrf_handle_operation = u64(var(Handle,~))
360 | & u32(var(ProcessId,~))
361 | & u32(var(ThreadId,~))
362 | & u32(var(OperationType,ehandle_trace_operations))
363 | & u32(var(Spare0,~))
364 | ;
365 |
366 | ehandle_trace_operations = OperationDbUnused
367 | | OperationDbOPEN
368 | | OperationDbCLOSE
369 | | OperationDbBADREF
370 | ;
371 | OperationDbUnused = 0;
372 | OperationDbOPEN = 1;
373 | OperationDbCLOSE = 2;
374 | OperationDbBADREF = 3;
375 |
376 |
377 | ###############################################################################
378 | # Memory List
379 | ###############################################################################
380 |
381 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_memory_list
382 | memory_list = u32(var(count,~))
383 | & memory_descriptor{count}
384 | ;
385 |
386 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_memory_descriptor
387 | memory_descriptor = u64(var(StartOfMemoryRange,~))
388 | & var(Memory,location_descriptor)
389 | ;
390 |
391 |
392 | ###############################################################################
393 | # Memory64 List
394 | ###############################################################################
395 |
396 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_memory_list
397 | memory64_list = u64(var(count,~))
398 | & u64(var(BaseRva,~))
399 | & memory64_descriptor{count}
400 | ;
401 |
402 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_memory_descriptor
403 | memory64_descriptor = u64(var(StartOfMemoryRange,~))
404 | & u64(var(DataSize,~))
405 | ;
406 |
407 |
408 | ###############################################################################
409 | # Memory Info List
410 | ###############################################################################
411 |
412 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_memory_info_list
413 | memory_info_list = u32(var(SizeOfHeader,~))
414 | & u32(var(SizeOfEntry,~))
415 | & u64(var(NumberOfEntries,~))
416 | & memory_info{NumberOfEntries}
417 | ;
418 |
419 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_memory_info
420 | memory_info = u64(var(BaseAddress,~))
421 | & u64(var(AllocationBase,~))
422 | & u32(var(AllocationProtect,~))
423 | & u32(~)
424 | & u64(var(RegionSize,~))
425 | & u32(var(State,memory_state))
426 | & u32(var(Protect,~))
427 | & u32(var(Type,memory_type))
428 | & u32(~)
429 | ;
430 |
431 | memory_type = MEM_IMAGE
432 | | MEM_MAPPED
433 | | MEM_PRIVATE
434 | ;
435 | MEM_IMAGE = 0x1000000;
436 | MEM_MAPPED = 0x40000;
437 | MEM_PRIVATE = 0x20000;
438 |
439 | memory_state = MEM_COMMIT
440 | | MEM_FREE
441 | | MEM_RESERVE
442 | ;
443 | MEM_COMMIT = 0x1000;
444 | MEM_FREE = 0x10000;
445 | MEM_RESERVE = 0x2000;
446 |
447 |
448 | ###############################################################################
449 | # Misc Info
450 | ###############################################################################
451 |
452 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_misc_info
453 | misc_info = u32(var(SizeOfHeader,~))
454 | & var(Flags1,misc_info_flags)
455 | & u32(var(ProcessId,~))
456 | & u32(var(ProcessCreateTime,~))
457 | & u32(var(ProcessUserTime,~))
458 | & u32(var(ProcessKernelTime,~))
459 | ;
460 |
461 | misc_info_flags = ordered(
462 | uint(30,0)
463 | & u1(var(process_times,~))
464 | & u1(var(process_id,~))
465 | )
466 | ;
467 |
468 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_misc_info_2
469 | misc_info_2 = u32(var(SizeOfHeader))
470 | & var(Flags1,misc_info_2_flags)
471 | & u32(var(ProcessId))
472 | & u32(var(ProcessCreateTime))
473 | & u32(var(ProcessUserTime))
474 | & u32(var(ProcessKernelTime))
475 | & u32(var(ProcessorMaxMhz))
476 | & u32(var(ProcessorCurrentMhz))
477 | & u32(var(ProcessorMhzLimit))
478 | & u32(var(ProcessorMaxIdleState))
479 | & u32(var(ProcessorCurrentIdleState))
480 | ;
481 |
482 | misc_info_2_flags = ordered(
483 | uint(29,0)
484 | & u1(var(processor_power_info,~))
485 | & u1(var(process_times,~))
486 | & u1(var(process_id,~))
487 | )
488 | ;
489 |
490 | ###############################################################################
491 | # Module List
492 | ###############################################################################
493 |
494 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_module_list
495 | module_list = u32(var(count,~))
496 | & module{count}
497 | ;
498 |
499 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_module
500 | module = u64(var(BaseOfImage,~))
501 | & u32(var(SizeOfImage,~))
502 | & u32(var(CheckSum,~))
503 | & u32(var(TimeDateStamp,~))
504 | & u32(var(ModuleNameRva,~))
505 | & var(VersionInfo,fixed_file_info)
506 | & var(CvRecord,location_descriptor)
507 | & var(MiscRecord,location_descriptor)
508 | & u64(0)
509 | & u64(0)
510 | & offset(ModuleNameRva*8,string)
511 | ;
512 |
513 | # https://learn.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo
514 | fixed_file_info = u32(0xFEEF04BD)
515 | & u32(var(StrucVersion,~))
516 | & u32(var(FileVersionMS,~))
517 | & u32(var(FileVersionLS,~))
518 | & u32(var(ProductVersionMS,~))
519 | & u32(var(ProductVersionLS,~))
520 | & u32(var(FileFlagsMask,~))
521 | & var(FileFlags,fixed_file_flags)
522 | & var(FileOS,os_flags)
523 | & u32(var(FileType,file_type))
524 | & u32(var(FileSubtype,[
525 | FileType = FileTypeFont: font_subtype;
526 | : file_subtype;
527 | ]))
528 | & u32(var(FileDateMS,~))
529 | & u32(var(FileDateLS,~))
530 | ;
531 |
532 | fixed_file_flags = ordered(uint(26,0)
533 | & u1(var(SpecialBuild,~))
534 | & u1(var(InfoInferred,~))
535 | & u1(var(PrivateBuild,~))
536 | & u1(var(Patched,~))
537 | & u1(var(Prerelease,~))
538 | & u1(var(Debug,~))
539 | );
540 |
541 | os_flags = ordered(uint(13,0)
542 | & u1(var(NT))
543 | & u1(var(OS2))
544 | & u1(var(DOS))
545 | & uint(13,0)
546 | & u1(var(WIN32))
547 | & u1(var(PM))
548 | & u1(var(WIN16))
549 | );
550 |
551 |
552 | file_type = FileTypeUnknown
553 | | FileTypeApp
554 | | FileTypeDLL
555 | | FileTypeDriver
556 | | FileTypeFont
557 | | FileTypeVirtualDevice
558 | | FileTypeStaticLib
559 | ;
560 | FileTypeUnknown = 0;
561 | FileTypeApp = 1;
562 | FileTypeDLL = 2;
563 | FileTypeDriver = 3;
564 | FileTypeFont = 4;
565 | FileTypeVirtualDevice = 5;
566 | FileTypeStaticLib = 7;
567 |
568 | file_subtype = FileSubtypeUnknown
569 | | FileSubtypePrinterDriver
570 | | FileSubtypeKeyboardDriver
571 | | FileSubtypeLanguageDriver
572 | | FileSubtypeDisplayDriver
573 | | FileSubtypeMouseDriver
574 | | FileSubtypeNetworkDriver
575 | | FileSubtypeSystemDriver
576 | | FileSubtypeInstallableDriver
577 | | FileSubtypeSoundDriver
578 | | FileSubtypeCommDriver
579 | | FileSubtypeVersionedPrinterDriver
580 | ;
581 | FileSubtypeUnknown = 0;
582 | FileSubtypePrinterDriver = 1;
583 | FileSubtypeKeyboardDriver = 2;
584 | FileSubtypeLanguageDriver = 3;
585 | FileSubtypeDisplayDriver = 4;
586 | FileSubtypeMouseDriver = 5;
587 | FileSubtypeNetworkDriver = 6;
588 | FileSubtypeSystemDriver = 7;
589 | FileSubtypeInstallableDriver = 8;
590 | FileSubtypeSoundDriver = 9;
591 | FileSubtypeCommDriver = 10;
592 | FileSubtypeVersionedPrinterDriver = 12;
593 |
594 | font_subtype = FontSubtypeUnknown
595 | | FontsubtypeRaster
596 | | FontSubtypeVector
597 | | FontSubtypeTrueType
598 | ;
599 | FontSubtypeUnknown = 0;
600 | FontsubtypeRaster = 1;
601 | FontSubtypeVector = 2;
602 | FontSubtypeTrueType = 3;
603 |
604 |
605 | ###############################################################################
606 | # System Info
607 | ###############################################################################
608 |
609 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_system_info
610 | system_info = u16(var(ProcessorArchitecture,processor_architecture))
611 | & u16(var(ProcessorLevel, [
612 | ProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL: PROCESSOR_LEVEL_386
613 | | PROCESSOR_LEVEL_486
614 | | PROCESSOR_LEVEL_PENTIUM
615 | | PROCESSOR_LEVEL_PENTIUM_2
616 | ;
617 | ProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 : PROCESSOR_LEVEL_IA64;
618 | : 0;
619 | ]))
620 | & u16(var(ProcessorRevision,~))
621 | & u8(var(NumberOfProcessors,~))
622 | & u8(var(ProductType,product_type))
623 | & u32(var(MajorVersion,~))
624 | & u32(var(MinorVersion,~))
625 | & u32(var(BuildNumber,~))
626 | & u32(var(PlatformId,2))
627 | & u32(var(CSDVersionRva,~))
628 | & var(SuiteMask,suite_mask)
629 | & u16(0)
630 | & var(Cpu,cpu_information)
631 | & offset(CSDVersionRva*8,string)
632 | ;
633 |
634 | cpu_information = TODO;
635 |
636 | suite_mask = ordered(u1(0)
637 | & u1(var(ComputeServer,~))
638 | & u1(var(StorageServer,~))
639 | & u1(0)
640 | & u1(0)
641 | & u1(var(Blade,~))
642 | & u1(var(Personal,~))
643 | & u1(var(SingleUserTS,~))
644 | & u1(var(DataCenter,~))
645 | & u1(var(EmbeddedNT,~))
646 | & u1(var(SmallBusinessRestricted,~))
647 | & u1(var(Terminal,~))
648 | & u1(0)
649 | & u1(var(BackOffice,~))
650 | & u1(var(Enterprise,~))
651 | & u1(var(SmallBusiness,~))
652 | );
653 |
654 | product_type = VER_NT_WORKSTATION
655 | | VER_NT_DOMAIN_CONTROLLER
656 | | VER_NT_SERVER
657 | ;
658 | VER_NT_WORKSTATION = 1;
659 | VER_NT_DOMAIN_CONTROLLER = 2;
660 | VER_NT_SERVER = 3;
661 |
662 | PROCESSOR_LEVEL_IA64 = 1;
663 | PROCESSOR_LEVEL_386 = 3;
664 | PROCESSOR_LEVEL_486 = 4;
665 | PROCESSOR_LEVEL_PENTIUM = 5;
666 | PROCESSOR_LEVEL_PENTIUM_2 = 6;
667 |
668 | processor_architecture = PROCESSOR_ARCHITECTURE_INTEL
669 | | PROCESSOR_ARCHITECTURE_ARM
670 | | PROCESSOR_ARCHITECTURE_IA64
671 | | PROCESSOR_ARCHITECTURE_AMD64
672 | | PROCESSOR_ARCHITECTURE_UNKNOWN
673 | ;
674 | PROCESSOR_ARCHITECTURE_INTEL = 0;
675 | PROCESSOR_ARCHITECTURE_ARM = 5;
676 | PROCESSOR_ARCHITECTURE_IA64 = 6;
677 | PROCESSOR_ARCHITECTURE_AMD64 = 9;
678 | PROCESSOR_ARCHITECTURE_UNKNOWN = 0xffff;
679 |
680 |
681 | ###############################################################################
682 | # Thread List
683 | ###############################################################################
684 |
685 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_thread_list
686 | thread_list = u32(var(count,~))
687 | & thread{count}
688 | ;
689 |
690 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_thread
691 | thread = u32(var(ThreadId,~))
692 | & u32(var(SuspendCount,~))
693 | & u32(var(PriorityClass,~))
694 | & u32(var(Priority,~))
695 | & u64(var(Teb,~))
696 | & var(Stack,memory_descriptor)
697 | & var(ThreadContext,location_descriptor)
698 | ;
699 |
700 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_thread_ex_list
701 | thread_ex_list = u32(var(NumberOfThreads,~))
702 | & thread_ex{NumberOfThreads}
703 | ;
704 |
705 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_thread_ex
706 | thread_ex = u32(var(ThreadId,~))
707 | & u32(var(SuspendCount,~))
708 | & u32(var(PriorityClass,~))
709 | & u32(var(Priority,~))
710 | & u64(var(Teb,~))
711 | & var(Stack,memory_descriptor)
712 | & var(ThreadContext,location_descriptor)
713 | & var(BackingStore,memory_descriptor)
714 | ;
715 |
716 |
717 | ###############################################################################
718 | # Thread Info
719 | ###############################################################################
720 |
721 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_thread_info_list
722 | thread_info_list = u32(var(SizeOfHeader,~))
723 | & u32(var(SizeOfEntry,~))
724 | & u32(var(NumberOfEntries,~))
725 | & thread_info{NumberOfEntries}
726 | ;
727 |
728 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_thread_info
729 | thread_info = u32(var(ThreadId,~))
730 | & thread_dump_flags
731 | & u32(var(DumpError,~))
732 | & u32(var(ExitStatus,~))
733 | & u64(var(CreateTime,~))
734 | & u64(var(ExitTime,~))
735 | & u64(var(KernelTime,~))
736 | & u64(var(UserTime,~))
737 | & u64(var(StartAddress,~))
738 | & u64(var(Affinity,~))
739 | ;
740 |
741 | thread_dump_flags = ordered(
742 | uint(26,0)
743 | & u1(var(invalid_teb,~))
744 | & u1(var(invalid_context,~))
745 | & u1(var(invalid_info,~))
746 | & u1(var(exited_thread,~))
747 | & u1(var(writing_thread,~))
748 | & u1(var(error_thread,~))
749 | )
750 | ;
751 |
752 |
753 | ###############################################################################
754 | # Unloaded Module
755 | ###############################################################################
756 |
757 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_unloaded_module_list
758 | unloaded_module_list = u32(var(SizeOfHeader,~))
759 | & u32(var(SizeOfEntry,~))
760 | & u32(var(NumberOfEntries,~))
761 | & unloaded_module{NumberOfEntries}
762 | ;
763 |
764 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_unloaded_module
765 | unloaded_module = u64(var(BaseOfImage,~))
766 | & u32(var(SizeOfImage,~))
767 | & u32(var(CheckSum,~))
768 | & u32(var(TimeDateStamp,~))
769 | & u32(var(ModuleNameRva,~))
770 | & offset(ModuleNameRva*8, string)
771 | ;
772 |
773 |
774 | ###############################################################################
775 | # Common
776 | ###############################################################################
777 |
778 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_location_descriptor
779 | location_descriptor = u32(var(size,~))
780 | & u32(var(rva,~))
781 | ;
782 |
783 | # https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_string
784 | string = u32(var(length,~))
785 | & utf16le(~){length}
786 | ;
787 |
788 | u1(values) = uint(1,values);
789 | u8(values) = uint(8,values);
790 | u16(values) = ordered(uint(16,values));
791 | u32(values) = ordered(uint(32,values));
792 | u64(values) = ordered(uint(64,values));
793 |
794 | ansi_string(count) = u8(~){count};
795 | wide_string(count) = u16(~){count};
796 |
797 | utf16le(codepoints: codepoint): bits = """https://en.wikipedia.org/wiki/UTF-16""";
798 |
--------------------------------------------------------------------------------
/v1/examples/rtp_v2.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = rtp_v2
3 | - description = Real-time Transport Protocol packet, version 2
4 | - reference = https://www.rfc-editor.org/rfc/rfc3550
5 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
6 |
7 | rtp_packet = version
8 | & uint(1,var(has_padding,~))
9 | & uint(1,var(has_extension,~))
10 | & uint(4,var(csrc_count,~))
11 | & marker
12 | & payload_type
13 | & sequence_no
14 | & timestamp
15 | & ssrc
16 | & csrc_list(has_padding, csrc_count)
17 | & [has_extension = 1: extension;]
18 | ;
19 | version = uint(2,2);
20 | marker = uint(1,~);
21 | payload_type = uint(7,~);
22 | sequence_no = uint(16,~);
23 | timestamp = uint(32,~);
24 | ssrc = uint(32,~);
25 | csrc = uint(32,~);
26 |
27 | csrc_list(has_padding, count) = [
28 | has_padding = 1: peek(uint(8,~){count*4-3} & uint(8,var(pad_length,4~)))
29 | & csrc{count - pad_length/4}
30 | & padding{pad_length-4}
31 | & padding_last(pad_length)
32 | ;
33 | : csrc{count};
34 | ];
35 |
36 | padding = uint(8,0);
37 | padding_last(length) = padding{3} & uint(8,length);
38 |
39 | extension = custom_data
40 | & uint(16,var(length,~))
41 | & extension_payload(length)
42 | ;
43 | custom_data = uint(16,~);
44 | ext_payload(length) = uint(32,~){length};
45 |
--------------------------------------------------------------------------------
/v1/examples/tr_dos.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = trdos_filedesc
3 | - description = TR-DOS file descriptor
4 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
5 |
6 | file_descriptor = filename
7 | & var(ext, extension)
8 | & [
9 | ext.type = 'B': format_basic;
10 | ext.type = 'C': format_code;
11 | ext.type = 'D': format_data;
12 | ext.type = '#': format_print;
13 | : format_generic;
14 | ]
15 | & file_sectors
16 | & start_sector
17 | & start_track
18 | ;
19 |
20 | filename = sized(8*8, uint(8,~)+ & uint(8,' ')*);
21 | extension = var(type, uint(8, ~));
22 | file_sectors = uint(8, ~);
23 | start_sector = uint(8, ~);
24 | start_track = uint(8, ~);
25 |
26 | format_basic = program_length & variables_offset;
27 | program_length = uint(16,~);
28 | variables_offset = uint(16,~);
29 |
30 | format_code = load_addres & code_length;
31 | load_address = uint(16,~);
32 | code_length = uint(16,~);
33 |
34 | format_data = data_type & array_length;
35 | data_type = uint(16,~);
36 | array_length = uint(16,~);
37 |
38 | format_print = extent_no & uint(8, 0x20) & print_length;
39 | extent_no = uint(8, ~);
40 | print_length = uint(16, 0~4096);
41 |
42 | format_generic = uint(16,~) & generic_length;
43 | generic_length = uint(16,~);
44 |
--------------------------------------------------------------------------------
/v1/examples/udp.dogma:
--------------------------------------------------------------------------------
1 | dogma_v1 utf-8
2 | - identifier = udp
3 | - description = User Datagram Protocol packet
4 | - dogma = https://github.com/kstenerud/dogma/blob/master/v1/dogma_v1.md
5 |
6 | udp_packet = src_port
7 | & dst_port
8 | & uint(16,var(length,8~))
9 | & checksum
10 | & body(length - 8)
11 | ;
12 | src_port = uint(16,~);
13 | dst_port = uint(16,~);
14 | checksum = uint(16,~);
15 | body(length) = uint(8,~){length};
16 |
--------------------------------------------------------------------------------
/v1/img/Wikipedia-TCPIP_802.1ad_DoubleTag.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | image/svg+xml
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 1
17 |
18 | 2
19 |
20 | 3
21 |
22 | 4
23 |
24 | 5
25 |
26 | 6
27 |
28 | Destination MAC
29 |
30 |
31 |
32 | 1
33 |
34 | 2
35 |
36 | 3
37 |
38 | 4
39 |
40 | 5
41 |
42 | 6
43 |
44 | Source MAC
45 |
46 |
47 |
48 | 1
49 |
50 | 2
51 |
52 | 3
53 |
54 | 4
55 |
56 | 802.1Q Header
57 |
58 |
59 | TPID=0x8100
60 | PCP/DEI/VID
61 |
62 |
63 |
64 | 1
65 |
66 | .
67 |
68 | .
69 |
70 | .
71 |
72 | n
73 |
74 | Payload
75 |
76 |
77 |
78 | 1
79 |
80 | 2
81 |
82 | EtherType/
83 | Size
84 |
85 |
86 |
87 | 1
88 |
89 | 2
90 |
91 | 3
92 |
93 | 4
94 |
95 | CRC / FCS
96 |
97 |
98 |
99 | 1
100 |
101 | 2
102 |
103 | 3
104 |
105 | 4
106 |
107 | 5
108 |
109 | 6
110 |
111 | Destination MAC
112 |
113 |
114 |
115 | 1
116 |
117 | 2
118 |
119 | 3
120 |
121 | 4
122 |
123 | 5
124 |
125 | 6
126 |
127 | Source MAC
128 |
129 |
130 |
131 | 1
132 |
133 | .
134 |
135 | .
136 |
137 | .
138 |
139 | n
140 |
141 | Payload
142 |
143 |
144 |
145 | 1
146 |
147 | 2
148 |
149 | EtherType/
150 | Size
151 |
152 |
153 |
154 | 1
155 |
156 | 2
157 |
158 | 3
159 |
160 | 4
161 |
162 | CRC / FCS
163 |
164 | n = 42–1500
165 | n = 46–1500
166 |
167 |
168 |
169 | 1
170 |
171 | 2
172 |
173 | 3
174 |
175 | 4
176 |
177 | 5
178 |
179 | 6
180 |
181 | Preamble
182 |
183 | 7
184 |
185 | 8
186 |
187 | SFD
188 |
189 |
190 |
191 |
192 | 1
193 |
194 | 2
195 |
196 | 3
197 |
198 | 4
199 |
200 | 5
201 |
202 | 6
203 |
204 | Preamble
205 |
206 | 7
207 |
208 | 8
209 |
210 | SFD
211 |
212 |
213 |
214 | 1
215 |
216 | 2
217 |
218 | 3
219 |
220 | 4
221 |
222 | 5
223 |
224 | 6
225 |
226 | Destination MAC
227 |
228 |
229 |
230 | 1
231 |
232 | 2
233 |
234 | 3
235 |
236 | 4
237 |
238 | 5
239 |
240 | 6
241 |
242 | Source MAC
243 |
244 |
245 |
246 | 1
247 |
248 | 2
249 |
250 | 3
251 |
252 | 4
253 |
254 | 802.1Q Header
255 |
256 |
257 | TPID=0x88A8
258 | PCP/DEI/VID
259 |
260 |
261 |
262 | 1
263 |
264 | .
265 |
266 | .
267 |
268 | .
269 |
270 | n
271 |
272 | Payload
273 |
274 |
275 |
276 | 1
277 |
278 | 2
279 |
280 | EtherType/
281 | Size
282 |
283 |
284 |
285 | 1
286 |
287 | 2
288 |
289 | 3
290 |
291 | 4
292 |
293 | CRC / FCS
294 |
295 | n = 38–1500
296 |
297 |
298 |
299 | 1
300 |
301 | 2
302 |
303 | 3
304 |
305 | 4
306 |
307 | 5
308 |
309 | 6
310 |
311 | Preamble
312 |
313 | 7
314 |
315 | 8
316 |
317 | SFD
318 |
319 |
320 |
321 |
322 | 1
323 |
324 | 2
325 |
326 | 3
327 |
328 | 4
329 |
330 | 802.1Q Header
331 |
332 |
333 | TPID=0x8100
334 | PCP/DEI/VID
335 |
336 |
--------------------------------------------------------------------------------
/v1/img/dogma-logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
15 |
--------------------------------------------------------------------------------
/v1/img/sequence-sets.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | A
5 |
6 | C
7 |
8 |
9 | D
10 |
11 |
12 | E
13 |
14 | F
15 |
16 | G
17 |
18 | H
19 |
20 |
21 | B
22 |
23 |
24 |
25 | I
26 |
27 |
28 |
--------------------------------------------------------------------------------