Skip to content

Commit

Permalink
Implement EFCP send procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
masonticehurst committed Mar 9, 2024
1 parent 6f19b33 commit 2bc6f04
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
49 changes: 46 additions & 3 deletions eRINA_STM32F7/src/net/net-protos-efcp.adb
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
with Debug;
with Net.Headers;
with CDAP; use CDAP;
with Buffers; use Buffers;

package body Net.Protos.EFCP is

procedure Receive
(Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Packet : in out Net.Buffers.Buffer_Type)
is

Buf :
Byte_Buffer
(1 .. Integer (Packet.Get_Data_Size (Net.Buffers.EFCP_PACKET))) with
Expand All @@ -26,7 +23,53 @@ package body Net.Protos.EFCP is

Debug.Print (Debug.Info, Buffer_To_Byte_String (Buf));
Message.To_CDAP (Byte_Buffer_To_Vector (Buf));

Message.Put;

-- Incoming connection request
if Message.OpCode = M_CONNECT then
Send (Ifnet, Message.Encode ((Abs_Syntax, OpCode, Invoke_Id, Flags, Obj_Class, Obj_Name)));
Debug.Print (Debug.Info, "Connect Request");
end if;
end Receive;


procedure Send (Ifnet : in out Net.Interfaces.Ifnet_Type'Class; CDAP_Buffer : in Byte_Buffer) is
Buf : Net.Buffers.Buffer_Type;
Req : Net.Headers.EFCP_Packet_Access := new Net.Headers.EFCP_Packet;
begin
Net.Buffers.Allocate(Buf);

if Buf.Is_Null then
Debug.Print(Debug.Error, "Error allocating EFCP packet");
return;
end if;

Req := Buf.EFCP;
Req.Ethernet.Ether_Dhost := (16#ff#, 16#ff#, 16#ff#, 16#ff#, 16#ff#, 16#ff#);
Req.Ethernet.Ether_Shost := Ifnet.Mac;
Req.Ethernet.Ether_Type := Net.Headers.To_Network (16#D1F0#);
Req.EFCP.PDU_Version := 0;
Req.EFCP.PDU_Type := 64;
Req.EFCP.PDU_Flags := 0;
Req.EFCP.PDU_CSum := 0;
Req.EFCP.PDU_TTL := Net.Headers.To_Network (16#4000#);
Req.EFCP.PDU_SeqNum := 0;
Req.EFCP.Dst_Addr := 0;
Req.EFCP.Src_Addr := Net.Headers.To_Network (Uint32 (1));
Req.EFCP.Dst_Cep := 0;
Req.EFCP.Src_Cep := 0;
Req.EFCP.QOS_Id := 0;
Req.CDAP := (others => 0);

for I in CDAP_Buffer'Range loop
Req.CDAP(I) := CDAP_Buffer(I);
end loop;

Req.EFCP.PDU_Len := ((Req.EFCP'Size + CDAP_Buffer'Size) / 8);

Buf.Set_Length ((Req.Ethernet'Size + Req.EFCP'Size + CDAP_Buffer'Size) / 8);
Ifnet.Send (Buf);
end Send;

end Net.Protos.EFCP;
9 changes: 4 additions & 5 deletions eRINA_STM32F7/src/net/net-protos-efcp.ads
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
with Net.Interfaces;
with Net.Buffers;
with CDAP; use CDAP;
with Buffers; use Buffers;

package Net.Protos.EFCP is

procedure Receive
(Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Packet : in out Net.Buffers.Buffer_Type);

-- MT: TODO: Implement me!
procedure Make_Ident is null;
procedure Make_Header is null;
procedure Send_Raw is null;
procedure Send is null;
procedure Send
(Ifnet : in out Net.Interfaces.Ifnet_Type'Class; CDAP_Buffer : in Byte_Buffer);

end Net.Protos.EFCP;

0 comments on commit 2bc6f04

Please sign in to comment.