Skip to content

Commit

Permalink
Use shorthand unsigned type definitions in examples and tests
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux#1398
  • Loading branch information
andrestt committed Oct 28, 2024
1 parent 39d8be1 commit 5c66746
Show file tree
Hide file tree
Showing 76 changed files with 645 additions and 501 deletions.
2 changes: 1 addition & 1 deletion doc/examples/specs/pub_sub.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package Pub_Sub is
SUCCESS => 15
) with Size => 4;

type Length is range 0 .. 2 ** 8 - 1 with Size => 8;
type Length is unsigned 8;

type Message is
message
Expand Down
4 changes: 2 additions & 2 deletions doc/language_reference/language_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ At the moment only non-negative integers are supported.

The set of values of a range integer type consists of all numbers from the lower bound to the upper bound.
The lower bound must be >= 0 and \<= the upper bound.
The bit size has to be specified explicitly and must be a value between 1 and 63 (included).
It can also be larger and does not have to be a multiple of 8 bits.
The bit size has to be specified explicitly and must be a value between 1 and 63 (inclusive).
It does not have to be a multiple of 8 bits.
However, the size of the type must be able to accommodate the upper bound.

..
Expand Down
38 changes: 19 additions & 19 deletions examples/apps/dccp/specs/dccp.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

package DCCP is

type Port_Type is range 0 .. 2 ** 16 - 1 with Size => 16;
type Port_Type is unsigned 16;

-- start offset at 3 since this is the smallest packet size possible
type Data_Offset_Type is range 3 .. 2 ** 8 - 1 with Size => 8;
type Checksum_Type is range 0 .. 2 ** 16 - 1 with Size => 16;
type CCVal_Type is range 0 .. 2 ** 4 - 1 with Size => 4;
type Checksum_Coverage_Type is range 0 .. 2 ** 4 - 1 with Size => 4;
type Reserved_3_Type is range 0 .. 2 ** 3 - 1 with Size => 3;
type Checksum_Type is unsigned 16;
type CCVal_Type is unsigned 4;
type Checksum_Coverage_Type is unsigned 4;
type Reserved_3_Type is unsigned 3;

type Type_Field is
(
Expand All @@ -38,23 +38,23 @@ package DCCP is
DCCP_SYNCACK => 9
) with Size => 4;

type CsCov_Type is range 0 .. 2 ** 4 - 1 with Size => 4;
type CsCov_Type is unsigned 4;

type Ext_Seq_Type is
(
EXTENDED => 1,
NOT_EXTENDED => 0
) with Size => 1;

type Sequence_Number_Long_Type is range 0 .. 2 ** 48 - 1 with Size => 48;
type Sequence_Number_Short_Type is range 0 .. 2 ** 24 - 1 with Size => 24;
type Sequence_Number_Long_Type is unsigned 48;
type Sequence_Number_Short_Type is unsigned 24;

type Reserved_8_Type is range 0 .. 2 ** 8 - 1 with Size => 8;
type Reserved_16_Type is range 0 .. 2 ** 16 - 1 with Size => 16;
type Ack_Number_Long_Type is range 0 .. 2 ** 48 - 1 with Size => 48;
type Ack_Number_Short_Type is range 0 .. 2 ** 24 - 1 with Size => 24;
type Reserved_8_Type is unsigned 8;
type Reserved_16_Type is unsigned 16;
type Ack_Number_Long_Type is unsigned 48;
type Ack_Number_Short_Type is unsigned 24;

type Service_Code_Type is range 0 .. 2 ** 32 - 1 with Size => 32;
type Service_Code_Type is unsigned 32;

type Reset_Code_Type is
(
Expand All @@ -74,7 +74,7 @@ package DCCP is
-- 128 - 255 are CCID-specific codes
) with Size => 8;

type Data_Type is range 0 .. 2 ** 8 - 1 with Size => 8;
type Data_Type is unsigned 8;

type Opt_Type is
(
Expand Down Expand Up @@ -104,7 +104,7 @@ package DCCP is
CCID3_RCV_RATE => 194
) with Size => 8;

type Option_Length_Type is range 0 .. 2 ** 8 - 1 with Size => 8;
type Option_Length_Type is unsigned 8;
type Option_Feature_Type is
(
FEATURE_RESERVED => 0,
Expand All @@ -121,10 +121,10 @@ package DCCP is
-- 128 - 255 CCID-Specific Features
) with Size => 8;

type Receive_Rate_Type is range 0 .. 2 ** 32 - 1 with Size => 32;
type Loss_Rate_Type is range 0 .. 2 ** 32 - 1 with Size => 32;
type Timestamp_Option_Type is range 0 .. 2 ** 32 - 1 with Size => 32;
type Timestamp_Echo_Option_Type is range 0 .. 2 ** 32 - 1 with Size => 32;
type Receive_Rate_Type is unsigned 32;
type Loss_Rate_Type is unsigned 32;
type Timestamp_Option_Type is unsigned 32;
type Timestamp_Echo_Option_Type is unsigned 32;

type Option is
message
Expand Down
12 changes: 6 additions & 6 deletions examples/apps/dhcp_client/specs/dhcp.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ package DHCP is
with Size => 8;

type Len is range 1 .. 255 with Size => 8;
type Subnet_Mask is range 0 .. 2 ** 32 - 1 with Size => 32;
type Subnet_Mask is unsigned 32;
type Routers is sequence of IPv4::Address;
type Time_Servers is sequence of IPv4::Address;
type Name_Servers is sequence of IPv4::Address;
Expand Down Expand Up @@ -66,7 +66,7 @@ package DHCP is

type X_Window_System_Font_Servers is sequence of IPv4::Address;
type X_Window_System_Display_Managers is sequence of IPv4::Address;
type Lease_Time is range 0 .. 2 ** 32 - 1 with Size => 32;
type Lease_Time is unsigned 32;

type Option_Overload is
(File_Overload => 1,
Expand All @@ -89,7 +89,7 @@ package DHCP is

type Option_Codes is sequence of Code;
type Maximum_DHCP_Message_Size is range 576 .. 2 ** 16 - 1 with Size => 16;
type Time_Interval is range 0 .. 2 ** 32 - 1 with Size => 32;
type Time_Interval is unsigned 32;

type Option is
message
Expand Down Expand Up @@ -184,9 +184,9 @@ package DHCP is
-- https://www.iana.org/assignments/arp-parameters/arp-parameters.xml#arp-parameters-2.
type Hardware_Address_Type is (HT_Reserved => 0, HT_Ethernet_10 => 1) with Size => 8, Always_Valid;
type Hardware_Address_Length is (HL_Ethernet => 6) with Size => 8;
type Hops is range 0 .. 2 ** 8 - 1 with Size => 8;
type Transaction_ID is range 0 .. 2 ** 32 - 1 with Size => 32;
type Secs is range 0 .. 2 ** 16 - 1 with Size => 16;
type Hops is unsigned 8;
type Transaction_ID is unsigned 32;
type Secs is unsigned 16;
type Reserved_Flags is range 0 .. 0 with Size => 15;
type Magic_Cookie is range 16#63825363# .. 16#63825363# with Size => 32;
type Options is sequence of Option;
Expand Down
18 changes: 9 additions & 9 deletions examples/apps/dhcp_client/specs/ipv4.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package IPv4 is

type Version is range 4 .. 4 with Size => 4;
type IHL is range 5 .. 15 with Size => 4;
type DCSP is range 0 .. 2 ** 6 - 1 with Size => 6;
type ECN is range 0 .. 2 ** 2 - 1 with Size => 2;
type Total_Length is range 0 .. 2 ** 16 - 1 with Size => 16;
type Identification is range 0 .. 2 ** 16 - 1 with Size => 16;
type Fragment_Offset is range 0 .. 2 ** 13 - 1 with Size => 13;
type TTL is range 0 .. 2 ** 8 - 1 with Size => 8;
type DCSP is unsigned 6;
type ECN is unsigned 2;
type Total_Length is unsigned 16;
type Identification is unsigned 16;
type Fragment_Offset is unsigned 13;
type TTL is unsigned 8;
type Protocol is (PROTOCOL_ICMP => 1, PROTOCOL_UDP => 17) with Size => 8, Always_Valid;
type Header_Checksum is range 0 .. 2 ** 16 - 1 with Size => 16;
type Address is range 0 .. 2 ** 32 - 1 with Size => 32;
type Header_Checksum is unsigned 16;
type Address is unsigned 32;

type Option_Class is (CONTROL => 0, DEBUGGING_AND_MEASUREMENT => 2) with Size => 2;
type Option_Number is range 0 .. 2 ** 5 - 1 with Size => 5;
type Option_Number is unsigned 5;
type Option_Length is range 2 .. 2 ** 8 - 1 with Size => 8;

type Option is
Expand Down
12 changes: 6 additions & 6 deletions examples/apps/ping/specs/icmp.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ package ICMP is
with Size => 8;

type Code_Zero is range 0 .. 0 with Size => 8;
type Checksum is range 0 .. 2 ** 16 - 1 with Size => 16;
type Identifier is range 0 .. 2 ** 16 - 1 with Size => 16;
type Sequence_Number is range 0 .. 2 ** 16 - 1 with Size => 16;
type Pointer is range 0 .. 2 ** 8 - 1 with Size => 8;
type Timestamp is range 0 .. 2 ** 32 - 1 with Size => 32;
type Gateway_Internet_Address is range 0 .. 2 ** 32 - 1 with Size => 32;
type Checksum is unsigned 16;
type Identifier is unsigned 16;
type Sequence_Number is unsigned 16;
type Pointer is unsigned 8;
type Timestamp is unsigned 32;
type Gateway_Internet_Address is unsigned 32;
type Unused_16 is range 0 .. 0 with Size => 16;
type Unused_32 is range 0 .. 0 with Size => 32;
type Unused_24 is range 0 .. 0 with Size => 24;
Expand Down
16 changes: 8 additions & 8 deletions examples/apps/ping/specs/ipv4.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ package IPv4 is

type Version is range 4 .. 4 with Size => 4;
type IHL is range 5 .. 15 with Size => 4;
type DCSP is range 0 .. 2 ** 6 - 1 with Size => 6;
type ECN is range 0 .. 2 ** 2 - 1 with Size => 2;
type Total_Length is range 0 .. 2 ** 16 - 1 with Size => 16;
type Identification is range 0 .. 2 ** 16 - 1 with Size => 16;
type Fragment_Offset is range 0 .. 2 ** 13 - 1 with Size => 13;
type TTL is range 0 .. 2 ** 8 - 1 with Size => 8;
type DCSP is unsigned 6;
type ECN is unsigned 2;
type Total_Length is unsigned 16;
type Identification is unsigned 16;
type Fragment_Offset is unsigned 13;
type TTL is unsigned 8;
type Protocol is (P_ICMP => 1, P_UDP => 17) with Size => 8, Always_Valid;
type Header_Checksum is range 0 .. 2 ** 16 - 1 with Size => 16;
type Address is range 0 .. 2 ** 32 - 1 with Size => 32;
type Header_Checksum is unsigned 16;
type Address is unsigned 32;
type Options is sequence of IPv4_Option::Option;

type Packet is
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/ping/specs/ipv4_option.rflx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package IPv4_Option is

type Option_Class is (Control => 0, Debugging_And_Measurement => 2) with Size => 2;
type Option_Number is range 0 .. 2 ** 5 - 1 with Size => 5;
type Option_Number is unsigned 5;
type Option_Length is range 2 .. 2 ** 8 - 1 with Size => 8;

type Option is
Expand Down
54 changes: 27 additions & 27 deletions examples/apps/spdm_responder/specs/spdm.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package SPDM is

-- Base types

type Length_16 is range 0 .. 2 ** 16 - 1 with Size => 16;
type Length_24 is range 0 .. 2 ** 24 - 1 with Size => 24;
type Index is range 0 .. 2 ** 8 - 1 with Size => 8;
type Length_16 is unsigned 16;
type Length_24 is unsigned 24;
type Index is unsigned 8;

-- Eng/RecordFlux/RecordFlux#1058
-- Signature_Length should be 64 .. 512
Expand All @@ -35,10 +35,10 @@ package SPDM is

-- 2.5.1 Version encoding

type Major_Version is range 0 .. 2 ** 4 - 1 with Size => 4;
type Minor_Version is range 0 .. 2 ** 4 - 1 with Size => 4;
type Update_Version_Number is range 0 .. 2 ** 4 - 1 with Size => 4;
type Alpha is range 0 .. 2 ** 4 - 1 with Size => 4;
type Major_Version is unsigned 4;
type Minor_Version is unsigned 4;
type Update_Version_Number is unsigned 4;
type Alpha is unsigned 4;

-- 8.3 SPDM request codes

Expand Down Expand Up @@ -88,7 +88,7 @@ package SPDM is

-- Common types

type Slot_Present is range 0 .. 1 with Size => 1;
type Slot_Present is unsigned 1;

type Slot_Mask is
message
Expand Down Expand Up @@ -139,7 +139,7 @@ package SPDM is

-- 10.3 GET_CAPABILITIES request and CAPABILITIES response messages

type CT_Exponent is range 0 .. 2 ** 8 - 1 with Size => 8;
type CT_Exponent is unsigned 8;
type PSK_Request_Cap is
(PSK_Req_Unsupported => 0,
PSK_Req_Supported => 1)
Expand Down Expand Up @@ -355,9 +355,9 @@ package SPDM is

type Measurement_Record is sequence of Measurement_Block;

type Measurement_Count is range 0 .. 2 ** 8 - 1 with Size => 8;
type Measurement_Count is unsigned 8;

type Block_Count is range 0 .. 2 ** 8 - 1 with Size => 8;
type Block_Count is unsigned 8;

type Measurements_Response (Signature_Length : Signature_Length;
Has_Signature : Boolean) is
Expand Down Expand Up @@ -396,8 +396,8 @@ package SPDM is
Reg_JEDEC => 8)
with Size => 8;

type Algorithm_ID_16 is range 0 .. 2 ** 16 - 1 with Size => 16;
type Algorithm_ID_32 is range 0 .. 2 ** 32 - 1 with Size => 32;
type Algorithm_ID_16 is unsigned 16;
type Algorithm_ID_32 is unsigned 32;

type Ext_Alg is
message
Expand Down Expand Up @@ -432,7 +432,7 @@ package SPDM is
Key_Schedule => 5)
with Size => 8;

type Alg_Count is range 0 .. 2 ** 4 - 1 with Size => 4;
type Alg_Count is unsigned 4;

type Alg_Struct is
message
Expand Down Expand Up @@ -487,9 +487,9 @@ package SPDM is

-- 10.4 NEGOTIATE_ALGORITHMS request and ALGORITHMS response messages

type Alg_Struct_Count is range 0 .. 2 ** 8 - 1 with Size => 8;
type Ext_Asym_Count is range 0 .. 2 ** 8 - 1 with Size => 8;
type Ext_Hash_Count is range 0 .. 2 ** 8 - 1 with Size => 8;
type Alg_Struct_Count is unsigned 8;
type Ext_Asym_Count is unsigned 8;
type Ext_Hash_Count is unsigned 8;

type Negotiate_Algorithms_Request is
message
Expand Down Expand Up @@ -662,7 +662,7 @@ package SPDM is
Trusted_Environment => 16#FF#)
with Size => 8;

type Offset is range 0 .. 2 ** 16 - 1 with Size => 16;
type Offset is unsigned 16;

type Get_Certificate_Request is
message
Expand Down Expand Up @@ -756,10 +756,10 @@ package SPDM is
Vendor => 16#FF#)
with Size => 8;

type Error_Session_ID is range 0 .. 2 ** 8 - 1 with Size => 8;
type Error_Session_ID is unsigned 8;

type RDT_Exponent is range 0 .. 2 ** 8 - 1 with Size => 8;
type Token is range 0 .. 2 ** 8 - 1 with Size => 8;
type RDT_Exponent is unsigned 8;
type Token is unsigned 8;
type RDTM is range 1 .. 2 ** 8 - 1 with Size => 8;

type Response_Not_Ready_Data is
Expand All @@ -772,9 +772,9 @@ package SPDM is

type Zero_Error_Data is range 0 .. 0 with Size => 8;

type Vendor_ID_Len is range 0 .. 2 ** 8 - 1 with Size => 8;
type Vendor_ID_Double is range 0 .. 2 ** 16 - 1 with Size => 16;
type Vendor_ID_Quad is range 0 .. 2 ** 32 - 1 with Size => 32;
type Vendor_ID_Len is unsigned 8;
type Vendor_ID_Double is unsigned 16;
type Vendor_ID_Quad is unsigned 32;

type Error_Response is
message
Expand Down Expand Up @@ -846,7 +846,7 @@ package SPDM is
end message;
-- 10.16 KEY_EXCHANGE request and KEY_EXCHANGE_RSP response messages

type Session_ID is range 0 .. 2 ** 16 - 1 with Size => 16;
type Session_ID is unsigned 16;

type Key_Exchange_Request (Exchange_Data_Length : Exchange_Data_Length) is
message
Expand All @@ -864,7 +864,7 @@ package SPDM is
end message
with Byte_Order => Low_Order_First;

type Heartbeat_Period is range 0 .. 2 ** 8 - 1 with Size => 8;
type Heartbeat_Period is unsigned 8;

type Key_Exchange_Response (Exchange_Data_Length : Exchange_Data_Length;
Hash_Length : Hash_Length;
Expand Down Expand Up @@ -959,7 +959,7 @@ package SPDM is

type Key_Operation is (Update_Key => 1, Update_All_Keys => 2, Verify_New_Key => 3) with Size => 8;

type Key_Update_Tag is range 0 .. 2 ** 8 - 1 with Size => 8;
type Key_Update_Tag is unsigned 8;

type Key_Update_Request is
message
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/spdm_responder/specs/spdm_responder.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ package SPDM_Responder is
with Size => Length * 8;
end message;

type Transcript_ID is range 0 .. 2 ** 32 - 1 with Size => 32;
type Transcript_ID is unsigned 32;

type Transcript_Kind is
(Session_Transcript => 0,
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/arp.rflx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package ARP is

type Opcode is (OP_REQUEST => 1, OP_REPLY => 2) with Size => 16;

type Address_Length is range 0 .. 2 ** 8 - 1 with Size => 8;
type Address_Length is unsigned 8;

type Packet_IPv4 is
message
Expand Down
Loading

0 comments on commit 5c66746

Please sign in to comment.