Skip to content

Commit

Permalink
Merge branch 'master' into TS4
Browse files Browse the repository at this point in the history
  • Loading branch information
masonticehurst committed Mar 20, 2024
2 parents 7e70adc + 3e009b8 commit 7ed9579
Show file tree
Hide file tree
Showing 52 changed files with 5,007 additions and 1,075 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/embedded.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: STM32 Build

on:
push:
paths:
- '**.adb'
- '**.ads'
- '**.gpr'
- '**.yml'
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: alire-project/setup-alire@v2

- name: Build
run: >
alr index --add git+https://github.com/GNAT-Academic-Program/alire-index --name gap &&
cd eRINA_STM32F7 &&
alr build
- name: Slack Notification Success
if: success()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: github-notifications
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://i.imgur.com/B8K3gi8.png
SLACK_USERNAME: Build Bot
SLACK_MESSAGE: 'Build Passed'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Slack Notification Failure
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: github-notifications
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://i.imgur.com/B8K3gi8.png
SLACK_USERNAME: Build Bot
SLACK_MESSAGE: 'Build Failed'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
File renamed without changes.
54 changes: 54 additions & 0 deletions eRINA_Linux/src/bindings-rlite-api.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ pragma Style_Checks (Off);

-- Bindings
with Bindings.Rlite.Ctrl;
with GNAT.Sockets; use GNAT.Sockets;
with Ada.Streams;
use type Ada.Streams.Stream_Element_Count;

-- Exceptions
with Ada.Exceptions; use Ada.Exceptions;
with Buffers; use Buffers;
with Exceptions;
with Debug;

package body Bindings.Rlite.API is

Expand Down Expand Up @@ -57,6 +63,26 @@ package body Bindings.Rlite.API is
Ctrl.RINA_Destroy_IPCP (Fd, Id);
end RINA_Destroy_IPCP;

procedure RINA_Config_IPCP
(Fd : OS.File_Descriptor; Id : Rl_Ipcp_Id_T; Name : String;
Value : String)
is
Name_Str : constant Bounded_String := To_Bounded_String (Name);
Value_Str : constant Bounded_String := To_Bounded_String (Value);
begin
Ctrl.RINA_Config_IPCP (Fd, Id, Name_Str, Value_Str);
end RINA_Config_IPCP;

procedure RINA_Enroll_IPCP
(Fd : OS.File_Descriptor; IPCP_Name : String; Neigh_Name : String;
DIF_Name : String; Supp_DIF_Name : String)
is
begin
Ctrl.RINA_Enroll_IPCP
(Fd, To_Bounded_String (IPCP_Name), To_Bounded_String (Neigh_Name),
To_Bounded_String (DIF_Name), To_Bounded_String (Supp_DIF_Name));
end RINA_Enroll_IPCP;

function RINA_Register
(fd : OS.File_Descriptor; dif_name : String; local_appl : String;
flags : Integer) return OS.File_Descriptor
Expand Down Expand Up @@ -142,4 +168,32 @@ package body Bindings.Rlite.API is
return Ctrl.RINA_Flow_Respond (Fd, Handle, Response);
end RINA_Flow_Respond;

procedure Register_UIPCPS (DIF_Name : String; IPCP_Name : String) is
Client : Socket_Type;
Address : Sock_Addr_Type;
Channel : Stream_Access;
Buffer : Byte_Buffer :=
(16#08#, 16#00#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#43#, 16#48#, 16#17#, 16#e6#, 16#06#, 16#25#, 16#fb#,
16#06#, 16#00#, 16#61#, 16#2E#, 16#49#, 16#50#, 16#43#, 16#50#,
16#09#, 16#00#, 16#65#, 16#74#, 16#68#, 16#41#, 16#42#, 16#2E#,
16#44#, 16#49#, 16#46#);
Data : Ada.Streams.Stream_Element_Array (1 .. Buffer'Length) with
Address => Buffer'Address;
begin
begin
delay 1.0;
Create_Socket (Client);
Address.Addr := Inet_Addr ("127.0.0.1");
Address.Port := 6_220;
Connect_Socket (Client, Address);
Channel := Stream (Client);
Ada.Streams.Write (Channel.all, Data);
delay 1.0;
exception
when E : others =>
Debug.Print ("Connect_UIPCPS", Exception_Message (E), Debug.Error);
end;
end Register_UIPCPS;

end Bindings.Rlite.API;
9 changes: 9 additions & 0 deletions eRINA_Linux/src/bindings-rlite-api.ads
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ package Bindings.Rlite.API is
-- (This can be looked up via the IPCP hashmap in Ctrl logic)
procedure RINA_Destroy_IPCP (Fd : OS.File_Descriptor; Id : Rl_Ipcp_Id_T);

procedure RINA_Config_IPCP
(Fd : OS.File_Descriptor; Id : Rl_Ipcp_Id_T; Name : String;
Value : String);

-- Register the application name local_appl to a DIF in the system.
-- After a successful registration, flow allocation requests can be received
-- on fd.
Expand Down Expand Up @@ -99,4 +103,9 @@ package Bindings.Rlite.API is
(Fd : OS.File_Descriptor; Handle : OS.File_Descriptor; Response : Integer)
return OS.File_Descriptor;

procedure Register_UIPCPS (DIF_Name : String; IPCP_Name : String);

procedure RINA_Enroll_IPCP
(Fd : OS.File_Descriptor; IPCP_Name : String; Neigh_Name : String;
DIF_Name : String; Supp_DIF_Name : String);
end Bindings.Rlite.API;
128 changes: 79 additions & 49 deletions eRINA_Linux/src/bindings-rlite-ctrl.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ pragma Style_Checks (Off);

-- Debug
with Debug;

with Names; use Names;
with Ada.Exceptions; use Ada.Exceptions;
with Names; use Names;
with Ada.Streams;
use type Ada.Streams.Stream_Element_Count;

with Exceptions;

Expand Down Expand Up @@ -98,11 +100,7 @@ package body Bindings.Rlite.Ctrl is
Request.DIF_Type := DIF_Type;
Request.DIF_Name := DIF_Name;

declare
Buffer : constant Byte_Buffer := IPCP.Serialize (Request);
begin
Rl_Write_Msg (Fd, Buffer, 0);
end;
Rl_Write_Msg (Fd, Request.Serialize, 0);

-- Wait for a response from rLite
IPCP.Deserialize (Response, Fd);
Expand Down Expand Up @@ -138,27 +136,81 @@ package body Bindings.Rlite.Ctrl is
Request.Hdr.Event_Id := 1;
Request.Ipcp_Id := Id;

declare
Buffer : constant Byte_Buffer := IPCP.Serialize (Request);
begin
Rl_Write_Msg (Fd, Buffer, 0);
end;

Rl_Write_Msg (Fd, Request.Serialize, 0);
Index := Search_Map_By_Value (IPCP_Map, Id);

if Index /= No_Element then
IPCP_Map.Delete (Index);
end if;
end RINA_Destroy_IPCP;

procedure RINA_Config_IPCP
(Fd : OS.File_Descriptor; Id : Rl_Ipcp_Id_T; Name : Bounded_String;
Value : Bounded_String)
is
Config : IPCP.Config;
begin
Config.Hdr.Msg_Type := RLITE_KER_IPCP_CONFIG;
Config.Hdr.Event_Id := 1;
Config.Ipcp_Id := Id;
Config.Name := Name;
Config.Value := Value;

Rl_Write_Msg (Fd, Config.Serialize, 0);
end RINA_Config_IPCP;

procedure RINA_Enroll_IPCP
(Fd : OS.File_Descriptor; IPCP_Name : Bounded_String;
Neigh_Name : Bounded_String; DIF_Name : Bounded_String;
Supp_DIF_Name : Bounded_String)
is
Client : Socket_Type;
Address : Sock_Addr_Type;
Channel : Stream_Access;
Enroll : IPCP.Enroll;
begin
Enroll.Hdr.Msg_Type := RLITE_KER_IPCP_CREATE_RESP;
Enroll.Hdr.Event_Id := 0;
Enroll.IPCP_Name := IPCP_Name;
Enroll.DIF_Name := DIF_Name;
Enroll.Neigh_Name := Neigh_Name;
Enroll.Supp_DIF_Name := Supp_DIF_Name;

declare
Buffer : Byte_Buffer := Enroll.Serialize;
Data : Ada.Streams.Stream_Element_Array (1 .. Buffer'Length) with
Address => Buffer'Address;
begin
Create_Socket (Client);
Address.Addr := Inet_Addr ("127.0.0.1");
Address.Port := 6_220;
Connect_Socket (Client, Address);
Channel := Stream (Client);
Ada.Streams.Write (Channel.all, Data);
exception
when E : others =>
Debug.Print
("RINA_Enroll_IPCP", Exception_Message (E), Debug.Error);
end;

-- MT: TODO:
-- below is wrong! This is really RLITE_U_IPCP_ENROLL
--Enroll.Hdr.Msg_Type := RLITE_KER_IPCP_CREATE_RESP;
--Enroll.Hdr.Event_Id := 0;
--Enroll.Ipcp_Name := IPCP_Name;
--Enroll.DIF_Name := DIF_Name;
--Enroll.Neigh_Name := Neigh_Name;
--Enroll.Supp_DIF_Name := Supp_DIF_Name;

--Rl_Write_Msg (Fd, Enroll.Serialize, 0);
end RINA_Enroll_IPCP;

function RINA_Register_Wait
(Fd : OS.File_Descriptor; Wfd : OS.File_Descriptor)
return OS.File_Descriptor
is
Buffer : Byte_Buffer (1 .. 4_096) := (others => 0);
Bytes_Read : Integer := 0;
Resp : Register.Response;
Move : Register.Move;
Resp : Register.Response;
Move : Register.Move;
begin
Register.Deserialize (Resp, Fd);

Expand Down Expand Up @@ -191,11 +243,7 @@ package body Bindings.Rlite.Ctrl is
Move.Ipcp_Id := Resp.Ipcp_Id;
Move.Fd := Integer_32 (Fd);

declare
Buffer : constant Byte_Buffer := Register.Serialize (Move);
begin
Rl_Write_Msg (Wfd, Buffer, 1);
end;
Rl_Write_Msg (Fd, Move.Serialize, 0);

-- Close our temp writing fd
API.RINA_Close (Wfd);
Expand Down Expand Up @@ -248,11 +296,7 @@ package body Bindings.Rlite.Ctrl is
Request.Appl_Name := Local_Appl;
Request.Dif_Name := Dif_Name;

declare
Buffer : constant Byte_Buffer := Register.Serialize (Request);
begin
Rl_Write_Msg (Fd, Buffer, 0);
end;
Rl_Write_Msg (Fd, Request.Serialize, 0);

if No_Wait > 0 then
-- Return the file descriptor to wait on
Expand All @@ -270,8 +314,7 @@ package body Bindings.Rlite.Ctrl is
Resp : Flow.Response;
Req : Flow.Request_Arrived;
Spi : Sa_Pending_Item;
Buffer : Byte_Buffer (1 .. 4_096) := (others => 0);
Bits_Other_Than_NoResp : constant Unsigned_32 :=
Bits_Other_Than_NoResp : constant Unsigned_32 :=
Unsigned_32 (flags) and not Unsigned_32 (API.RINA_F_NORESP);
Has_NoResp_Flag : constant Unsigned_32 :=
Unsigned_32 (flags) and Unsigned_32 (API.RINA_F_NORESP);
Expand Down Expand Up @@ -323,12 +366,8 @@ package body Bindings.Rlite.Ctrl is
return Spi.Sa_Pending.Handle;
end if;

declare
Buffer : constant Byte_Buffer := Flow.Serialize (Resp);
begin
Rl_Write_Msg (fd, Buffer, 0);
return fd;
end;
Rl_Write_Msg (fd, Resp.Serialize, 0);
return fd;

end RINA_Flow_Accept;

Expand Down Expand Up @@ -383,11 +422,8 @@ package body Bindings.Rlite.Ctrl is
return OS.Invalid_FD;
end if;

declare
Buffer : Byte_Buffer := Flow.Serialize (req);
begin
Rl_Write_Msg (wfd, Buffer, 0);
end;
Rl_Write_Msg (wfd, req.Serialize, 0);

--need to fix
return wfd;

Expand All @@ -408,10 +444,8 @@ package body Bindings.Rlite.Ctrl is
spi : Sa_Pending_Item_Base;
req : Flow.Request_Arrived;
resp : Flow.Response;
ffd : OS.File_Descriptor := OS.Invalid_FD;
ret : Integer;
cursor : Sig_Action_List.Cursor := Sa_Pending.First;
Buffer : Byte_Buffer (1 .. 4_096) := (others => 0);
ffd : OS.File_Descriptor := OS.Invalid_FD;
cursor : Sig_Action_List.Cursor := Sa_Pending.First;
begin
-- List of pending signal actions, contains a nested doubly linked list...
while Sig_Action_List.Has_Element (cursor) loop
Expand Down Expand Up @@ -450,11 +484,7 @@ package body Bindings.Rlite.Ctrl is

-- TODO: Add rl_msg_free

declare
Buffer : constant Byte_Buffer := Flow.Serialize (resp);
begin
Rl_Write_Msg (fd, Buffer, 0);
end;
Rl_Write_Msg (fd, resp.Serialize, 0);

if response >= 0 then
ffd := Rl_Open_Appl_Port (resp.Port_Id);
Expand Down
12 changes: 11 additions & 1 deletion eRINA_Linux/src/bindings-rlite-ctrl.ads
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ with Bindings.Rlite.Common;
with Bindings.Rlite.List; use Bindings.Rlite.List;

with System;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Sockets; use GNAT.Sockets;

with Buffers; use Buffers;

Expand Down Expand Up @@ -65,8 +66,17 @@ package Bindings.Rlite.Ctrl is
DIF_Type : Bindings.Rlite.Msg.IPCP.DIF_Types; DIF_Name : Bounded_String)
return Rl_Ipcp_Id_T;

procedure RINA_Enroll_IPCP
(Fd : OS.File_Descriptor; IPCP_Name : Bounded_String;
Neigh_Name : Bounded_String; DIF_Name : Bounded_String;
Supp_DIF_Name : Bounded_String);

procedure RINA_Destroy_IPCP (Fd : OS.File_Descriptor; Id : Rl_Ipcp_Id_T);

procedure RINA_Config_IPCP
(Fd : OS.File_Descriptor; Id : Rl_Ipcp_Id_T; Name : Bounded_String;
Value : Bounded_String);

-- struct rl_msg_base *rl_read_next_msg(int rfd, int quiet)
function Rl_Read_Msg
(Rfd : OS.File_Descriptor; Quiet : Integer) return Byte_Buffer;
Expand Down
Loading

0 comments on commit 7ed9579

Please sign in to comment.