Commit f9a31f29 authored by jhugues's avatar jhugues Committed by yoogx

* Add support for ASN.1 configuration



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-ada@3385 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent d2428f13
......@@ -3,6 +3,7 @@ with Ada.Exceptions;
with Ada.Real_Time;
with Interfaces;
with Ada.Unchecked_Conversion;
with System;
with GNAT.Sockets;
......@@ -11,6 +12,8 @@ with PolyORB_HI.Output;
with PolyORB_HI_Generated.Transport;
with POHICDRIVER_IP;
-- This package provides support for the TCP_IP device driver as
-- defined in the tcp_protocol.aadl AADLv2 model.
......@@ -24,11 +27,18 @@ package body PolyORB_HI_Drivers_Native_TCP_IP is
use Ada.Real_Time;
use Interfaces;
use System;
use GNAT.Sockets;
use PolyORB_HI.Messages;
use PolyORB_HI.Utils;
use PolyORB_HI.Output;
use POHICDRIVER_IP;
type IP_Conf_T_Acc is access all POHICDRIVER_IP.IP_Conf_T;
function To_IP_Conf_T_Acc is new Ada.Unchecked_Conversion
(System.Address, IP_Conf_T_Acc);
type Node_Record is record
Address : Sock_Addr_Type;
Socket_Send : Socket_Type;
......@@ -65,52 +75,64 @@ package body PolyORB_HI_Drivers_Native_TCP_IP is
pragma Warnings (On);
for J in Name_Table'Range loop
if Name_Table (J).Location.L = 0 then
Nodes (J).Address := (GNAT.Sockets.Family_Inet,
GNAT.Sockets.No_Inet_Addr,
GNAT.Sockets.No_Port);
else
-- The structure of the location information is
-- "ip address port"
declare
S : constant String := PolyORB_HI.Utils.To_String
(Name_Table (J).Location);
Addr_First, Addr_Last : Integer;
Port : Integer;
First : Integer;
Last : Integer;
begin
First := S'First;
-- First parse the prefix "ip"
Last := Parse_String (S, First, ' ');
if S (First .. Last) /= "ip" then
raise Program_Error with "Invalid configuration";
end if;
-- Then, parse the address
First := Last + 2;
Last := Parse_String (S, First, ' ');
Addr_First := First;
Addr_Last := Last;
-- Finally the port
First := Last + 2;
Last := Parse_String (S, First, ' ');
Port := Integer'Value (S (First .. Last));
Nodes (J).Address := (GNAT.Sockets.Family_Inet,
GNAT.Sockets.Inet_Addr
(S (Addr_First .. Addr_Last)),
GNAT.Sockets.Port_Type (Port));
end;
end if;
if Name_Table (J).Variable = System.Null_Address then
if Name_Table (J).Location.L = 0 then
Nodes (J).Address := (GNAT.Sockets.Family_Inet,
GNAT.Sockets.No_Inet_Addr,
GNAT.Sockets.No_Port);
else
-- The structure of the location information is
-- "ip address port"
declare
S : constant String := PolyORB_HI.Utils.To_String
(Name_Table (J).Location);
Addr_First, Addr_Last : Integer;
Port : Integer;
First : Integer;
Last : Integer;
begin
First := S'First;
-- First parse the prefix "ip"
Last := Parse_String (S, First, ' ');
if S (First .. Last) /= "ip" then
raise Program_Error with "Invalid configuration";
end if;
-- Then, parse the address
First := Last + 2;
Last := Parse_String (S, First, ' ');
Addr_First := First;
Addr_Last := Last;
-- Finally the port
First := Last + 2;
Last := Parse_String (S, First, ' ');
Port := Integer'Value (S (First .. Last));
Nodes (J).Address := (GNAT.Sockets.Family_Inet,
GNAT.Sockets.Inet_Addr
(S (Addr_First .. Addr_Last)),
GNAT.Sockets.Port_Type (Port));
end;
end if;
else
declare
Configuration : constant IP_Conf_T
:= To_IP_Conf_T_Acc (Name_Table (J).Variable).all;
begin
Nodes (J).Address :=
(GNAT.Sockets.Family_Inet,
GNAT.Sockets.Inet_Addr (Configuration.Address),
GNAT.Sockets.Port_Type (Configuration.Port));
end;
end if;
end loop;
-- Create the local socket if the node is remote-callable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment