Skip to content

Commit

Permalink
Fix To_Tag
Browse files Browse the repository at this point in the history
  • Loading branch information
masonticehurst committed Mar 9, 2024
1 parent bbaf503 commit f0c71b7
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
56 changes: 53 additions & 3 deletions eRINA_STM32F7/src/net/cdap.adb
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,24 @@ package body CDAP is
function To_Tag (Field : CDAP_Field; Wire_Type : Wire) return Byte_Vector is
Vec : Byte_Vector;
Tag_Num : constant Integer := CDAP_Field'Enum_Rep (Field);
Tag : constant Byte :=
Byte (Tag_Num * (2**3)) or Byte (Wire'Enum_Rep (Wire_Type));
Wire_Num : constant Integer := Wire'Enum_Rep (Wire_Type);
Key_Value : Natural := (Tag_Num * (2 ** 3)) + Wire_Num;
begin
-- First we need to append the record "tag" field
Vec.Append (Tag);
loop
declare
Byte_To_Add : constant Byte := Byte (Key_Value mod (2 ** 7));
begin
if Key_Value >= 128 then
Vec.Append (Byte_To_Add + 128);
else
Vec.Append (Byte_To_Add);
exit;
end if;
end;

Key_Value := Key_Value / (2 ** 7);
end loop;

return Vec;
end To_Tag;
Expand All @@ -511,6 +524,22 @@ package body CDAP is
return VARINT;
when Scope =>
return VARINT;
when Dest_AE_Inst =>
return LEN;
when Dest_AE_Name =>
return LEN;
when Dest_AP_Inst =>
return LEN;
when Dest_AP_Name =>
return LEN;
when Src_AE_Inst =>
return LEN;
when Src_AE_Name =>
return LEN;
when Src_AP_Inst =>
return LEN;
when Src_AP_Name =>
return LEN;
when others =>
return VARINT;
end case;
Expand Down Expand Up @@ -593,11 +622,32 @@ package body CDAP is
Ret.Append (To_LEN (Self.Obj_Name));
when Obj_Inst =>
Ret.Append (To_VARINT (Self.Obj_Inst));
when Result =>
Ret.Append (To_VARINT (Self.Result));
when Dest_AE_Inst =>
Ret.Append (To_LEN (Self.Dest_Ae_Inst));
when Dest_AE_Name =>
Ret.Append (To_LEN (Self.Dest_Ae_Name));
when Dest_AP_Inst =>
Ret.Append (To_LEN (Self.Dest_Ap_Inst));
when Dest_AP_Name =>
Ret.Append (To_LEN (Self.Dest_Ap_Name));
when Src_AE_Inst =>
Ret.Append (To_LEN (Self.Src_AE_Inst));
when Src_AE_Name =>
Ret.Append (To_LEN (Self.Src_AE_Name));
when Src_AP_Inst =>
Ret.Append (To_LEN (Self.Src_AP_Inst));
when Src_AP_Name =>
Ret.Append (To_LEN (Self.Src_AP_Name));
when others =>
null;
end case;
end loop;

-- Ends with 01
Ret.Append ((16#01#));

return Byte_Vector_To_Buffer (Ret);
end Encode;
end CDAP;
14 changes: 13 additions & 1 deletion eRINA_STM32F7/src/net/net-protos-efcp.adb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
with Debug;
with Net.Headers;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

package body Net.Protos.EFCP is

Expand Down Expand Up @@ -28,10 +29,21 @@ package body Net.Protos.EFCP is

-- Incoming connection request
if Message.OpCode = M_CONNECT then
Message.Abs_Syntax := 73;
Message.OpCode := M_CONNECT_R;
Message.Invoke_Id := 2;
Message.Flags := F_NO_FLAGS;
Message.Src_AP_Name := To_Unbounded_String ("b.IPCP");
Message.Dest_AP_Name := To_Unbounded_String ("a.IPCP");
Message.Version := 1;
Send
(Ifnet,
Message.Encode
((Abs_Syntax, OpCode, Invoke_Id, Flags, Obj_Class, Obj_Name)));
((Abs_Syntax, OpCode, Invoke_Id, Flags,
Obj_Class, Obj_Name, Result, Dest_AE_Inst,
Dest_AE_Name, Dest_Ap_Inst, Dest_AP_Name,
Src_AE_Inst, Src_AE_Name, Src_AP_Inst,
SRC_AP_Name, Version)));
Debug.Print (Debug.Info, "Connect Request");
end if;
end Receive;
Expand Down

0 comments on commit f0c71b7

Please sign in to comment.