forked from AdaDoom3/AdaDoom3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneo-system-network.adb
199 lines (198 loc) · 5.27 KB
/
neo-system-network.adb
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
PACKAGE BODY Neo.System.Network
IS
--------------------
-- IMPLEMENTATION --
--------------------
PACKAGE BODY Implementation
IS SEPARATE;
----------------
-- Initialize --
----------------
PROCEDURE Initialize
RENAMES Implementation.Initialize;
--------------
-- Finalize --
--------------
PROCEDURE Finalize
RENAMES Implementation.Finalize;
-----------------
-- Set_Address --
-----------------
PROCEDURE Set_Address(
Connection : IN OUT Record_Connection;
Network_Address : IN Record_Network_Address)
RENAMES Implementation.Set_Address;
-------------
-- Recieve --
-------------
FUNCTION Recieve(
Connection : IN Record_Connection;
From : OUT Record_Network_Address)
RETURN Array_Integer_1_Unsigned
RENAMES Implementation.Recieve;
FUNCTION Recieve(
Connection : IN Record_Connection;
From : OUT Record_Network_Address;
Timeout : IN Duration)
RETURN Array_Integer_1_Unsigned
RENAMES Implementation.Recieve;
----------
-- Send --
----------
PROCEDURE Send(
Connection : IN Record_Connection;
To : IN Record_Network_Address;
Data : IN Array_Integer_1_Unsigned)
RENAMES Implementation.Send;
------------------
-- Get_Local_IP --
------------------
FUNCTION Get_Local_IP
RETURN String_2
RENAMES Implementation.Get_Local_IP;
-------------------------
-- Get_Network_Address --
-------------------------
FUNCTION Get_Network_Address(
Connection : IN Record_Connection)
RETURN Record_Network_Address
IS
BEGIN
RETURN Connection.Network_Address;
END Get_Network_Address;
--------------------------------
-- Get_Number_Of_Read_Packets --
--------------------------------
FUNCTION Get_Number_Of_Read_Packets(
Connection : IN Record_Connection)
RETURN Integer_4_Natural
IS
BEGIN
RETURN Connection.Number_Of_Read_Packets;
END Get_Number_Of_Read_Packets;
------------------------------
-- Get_Number_Of_Read_Bytes --
------------------------------
FUNCTION Get_Number_Of_Read_Bytes(
Connection : IN Record_Connection)
RETURN Integer_4_Natural
IS
BEGIN
RETURN Connection.Number_Of_Read_Bytes;
END Get_Number_Of_Read_Bytes;
-----------------------------------
-- Get_Number_Of_Written_Packets --
-----------------------------------
FUNCTION Get_Number_Of_Written_Packets(
Connection : IN Record_Connection)
RETURN Integer_4_Natural
IS
BEGIN
RETURN Connection.Number_Of_Written_Packets;
END Get_Number_Of_Written_Packets;
---------------------------------
-- Get_Number_Of_Written_Bytes --
---------------------------------
FUNCTION Get_Number_Of_Written_Bytes(
Connection : IN Record_Connection)
RETURN Integer_4_Natural
IS
BEGIN
RETURN Connection.Number_Of_Written_Bytes;
END Get_Number_Of_Written_Bytes;
-------------
-- Silence --
-------------
PROCEDURE Silence(
Connection : IN OUT Record_Connection)
IS
BEGIN
IF Connection.Is_Silenced THEN
RAISE SILENCED_WITHOUT_BEING_VOCAL;
END IF;
Connection.Is_Silenced := True;
END Silence;
--------------
-- Vocalize --
--------------
PROCEDURE Vocalize(
Connection : IN OUT Record_Connection)
IS
BEGIN
IF NOT Connection.Is_Silenced THEN
RAISE VOCALIZED_WITHOUT_BEING_SILENT;
END IF;
Connection.Is_Silenced := False;
END Silence;
------------------------
-- To_Network_Address --
------------------------
FUNCTION To_Network_Address(
Item : IN String_2)
RETURN Record_Network_Address
IS
Result : Record_Network_Address := (OTHERS => <>);
Previous : Integer_4_Signed := Item'First;
J : Integer_4_Signed := Result.IP'First;
BEGIN
FOR I IN Item'Range LOOP
IF Item(I) = ':' THEN
ELSIF Item(I) = '.' THEN
Result.IP(J) := ;
J := J + 1;
END IF;
END LOOP;
EXCEPTION
WHEN
END To_Network_Address;
-----------------
-- To_String_2 --
-----------------
FUNCTION To_String_2(
Network_Address : IN Record_Network_Address)
RETURN String_2
IS
BEGIN
RETURN
Trim(Integer_1_Unsigned'Wide_Image(Network_Address.IP(1)), Both) & "." &
Trim(Integer_1_Unsigned'Wide_Image(Network_Address.IP(2)), Both) & "." &
Trim(Integer_1_Unsigned'Wide_Image(Network_Address.IP(3)), Both) & "." &
Trim(Integer_1_Unsigned'Wide_Image(Network_Address.IP(4)), Both) & ":" &
Trim(Integer_2_Unsigned'Wide_Image(Network_Address.Port), Both);
END To_String_2;
---------
-- "=" --
---------
FUNCTION "="(
Left : IN Record_Network_Address;
Right : IN String_2)
RETURN Boolean
IS
BEGIN
RETURN Left = To_String_2(Right);
END "=";
FUNCTION "="(
Left : IN String_2;
Right : IN Record_Network_Address)
RETURN Boolean
IS
BEGIN
RETURN Right = Left;
END "=";
END Neo.System.Network;