forked from AdaDoom3/AdaDoom3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neo-system-network.ads
144 lines (143 loc) · 4.12 KB
/
neo-system-network.ads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
WITH
Ada.Finalization.Controlled,
Neo.Foundation.Data_Types;
USE
Neo.Foundation.Data_Types;
PACKAGE Neo.System.Network
IS
----------------
-- EXCEPTIONS --
----------------
SILENCED_WITHOUT_BEING_VOCAL : CONSTANT Exception;
VOCALIZED_WITHOUT_BEING_SILENT : CONSTANT Exception;
INVALID_NETWORK_ADDRESS : CONSTANT Exception;
-------------
-- RECORDS --
-------------
TYPE Record_Network_Address
IS RECORD
IP : Array_Integer_1_Unsigned(1..4) := (OTHERS => 0);
Port : Integer_2_Unsigned := 0;
END RECORD;
TYPE Record_Connection
IS PRIVATE;
-----------------
-- SUBPROGRAMS --
-----------------
PROCEDURE Initialize;
PROCEDURE Finalize;
FUNCTION Get_Local_IP
RETURN String_2;
FUNCTION Get_Network_Address(
Connection : IN Record_Connection)
RETURN Record_Network_Address;
FUNCTION Get_Number_Of_Read_Packets(
Connection : IN Record_Connection)
RETURN Integer_4_Natural;
FUNCTION Get_Number_Of_Read_Bytes(
Connection : IN Record_Connection)
RETURN Integer_4_Natural;
FUNCTION Get_Number_Of_Written_Packets(
Connection : IN Record_Connection)
RETURN Integer_4_Natural;
FUNCTION Get_Number_Of_Written_Bytes(
Connection : IN Record_Connection)
RETURN Integer_4_Natural;
PROCEDURE Set_Address(
Connection : IN OUT Record_Connection;
Network_Address : IN Record_Network_Address);
PROCEDURE Silence(
Connection : IN OUT Record_Connection);
PROCEDURE Vocalize(
Connection : IN OUT Record_Connection);
FUNCTION To_Network_Address(
Item : IN String_2)
RETURN Record_Network_Address;
FUNCTION To_String_2(
Network_Address : IN Record_Network_Address)
RETURN String_2;
FUNCTION "="(
Left : IN Record_Network_Address;
Right : IN String_2)
RETURN Boolean;
FUNCTION "="(
Left : IN String_2;
Right : IN Record_Network_Address)
RETURN Boolean;
FUNCTION Recieve(
Connection : IN Record_Connection;
From : OUT Record_Network_Address)
RETURN Array_Integer_1_Unsigned;
FUNCTION Recieve(
Connection : IN Record_Connection;
From : OUT Record_Network_Address;
Timeout : IN Duration)
RETURN Array_Integer_1_Unsigned;
PROCEDURE Send(
Connection : IN Record_Connection;
To : IN Record_Network_Address;
Data : IN Array_Integer_1_Unsigned);
-------
PRIVATE
-------
-------------
-- RECORDS --
-------------
TYPE Record_Connection
IS Ada.Controlled.Limited_Controlled
WITH RECORD
Network_Address : Record_Network_Address := (OTHERS => <>);
Socket : Integer_4_Natural := 0;
Is_Silenced : Boolean := False;
Number_Of_Read_Packets : Integer_4_Natural := 0;
Number_Of_Read_Bytes : Integer_4_Natural := 0;
Number_Of_Written_Packets : Integer_4_Natural := 0;
Number_Of_Written_Bytes : Integer_4_Natural := 0;
END RECORD;
-----------------
-- SUBPROGRAMS --
-----------------
PROCEDURE Finalize(
Item : IN OUT Record_Connection);
--------------------
-- IMPLEMENTATION --
--------------------
PACKAGE Implementation
IS
PROCEDURE Initialize;
PROCEDURE Finalize;
FUNCTION Get_Local_IP
RETURN String_2;
PROCEDURE Set_Address(
Connection : IN OUT Record_Connection;
Network_Address : IN Record_Network_Address);
FUNCTION Recieve(
Connection : IN Record_Connection;
From : IN Record_Network_Address)
RETURN Array_Integer_1_Unsigned;
FUNCTION Recieve(
Connection : IN Record_Connection;
From : IN Record_Network_Address;
Timeout : IN Duration)
RETURN Array_Integer_1_Unsigned;
PROCEDURE Send(
Connection : IN Record_Connection;
To : IN Record_Network_Address);
END Implementation;
END Neo.System.Network;