OpenCores
URL https://opencores.org/ocsvn/the_wizardry_project/the_wizardry_project/trunk

Subversion Repositories the_wizardry_project

[/] [the_wizardry_project/] [trunk/] [Wizardry/] [VHDL/] [Wizardry Top Level/] [Address Generation/] [NIDS Components/] [EmPAC/] [lengthsaver.vhd] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 mcwaccent
----------------------------------------------------------------------------------
2
--
3
--  This file is a part of Technica Corporation Wizardry Project
4
--
5
--  Copyright (C) 2004-2009, Technica Corporation  
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
----------------------------------------------------------------------------------
21
----------------------------------------------------------------------------------
22
-- Module Name: lengthsaver - Behavioral 
23
-- Project Name: Wizardry
24
-- Target Devices: Virtex 4 ML401
25
-- Description: This component calculates the length of each packet.
26
-- Revision: 1.0
27
-- Additional Comments: 
28
--
29
----------------------------------------------------------------------------------
30
LIBRARY ieee;
31
USE ieee.std_logic_1164.all;
32
USE ieee.std_logic_arith.all;
33
use IEEE.std_logic_unsigned.all;
34
use work.EmPAC_constants.all;
35
 
36
ENTITY lengthsaver IS
37
PORT(
38
        clock   : IN    std_logic;
39
        field_data      : IN       std_logic_vector (31 DOWNTO 0);
40
        length_indicator        : IN       std_logic;
41
        field_type : IN       std_logic_vector (7 DOWNTO 0);
42
        reset   : IN       std_logic;
43
        optional        :       OUT     std_logic;
44
        length1 : OUT   std_logic_vector (17 DOWNTO 0)
45
);
46
END lengthsaver ;
47
-- VHDL Architecture ProtocolAnalyzer.length_block.struct
48
-- Generated by Mentor Graphics' HDL Designer(TM) 2003.1 (Build 399)
49
 
50
 
51
 
52
ARCHITECTURE struct OF lengthsaver IS
53
-- Architecture declarations 
54
-- Internal signal declarations
55
-- SIGNAL IP_header_len : std_logic_vector(15 DOWNTO 0);
56
-- SIGNAL opt            : std_logic := '0';
57
 SIGNAL length1_tmp     : std_logic_vector(17 DOWNTO 0) := (others => '0');
58
-- signal ip_total_len : std_logic_vector(15 downto 0);
59
-- signal tcp_header_len : std_logic_vector(15 downto 0);
60
-- signal no_app_layer : std_logic;
61
-- signal app_layer_len : std_logic_vector(15 downto 0);
62
-- signal tcp_head : std_logic_vector(15 downto 0);
63
-- signal ip_packet_len : std_logic_vector(15 downto 0);
64
signal IPv4_header_len : std_logic_vector(17 downto 0) := (others => '0');
65
signal app_layer: std_logic := '0';
66
signal tcp_header_len : std_logic_Vector(17 downto 0) := (others => '0');
67
signal transport_layer_len : std_logic_Vector(17 downto 0) := (others => '0');
68
signal padding : std_logic_Vector(17 downto 0) := (others => '0');
69
signal total_length : std_logic_Vector(17 downto 0) := (others => '0');
70
signal IPv6transp_true : std_logic := '1';
71
signal opt : std_logic := '0';
72
signal padded : std_logic := '0';
73
signal pad_data,udp_length : std_logic_vector(17 downto 0) := (others => '0');
74
 
75
BEGIN
76
 
77
-- Architecture concurrent statements
78
 
79
-- HDL Embedded Text Block      1 len_calc
80
 
81
-- The field_type bus indicates what packet field is currently coming
82
 
83
-- in on field_data. If the field contains information that will be used to
84
 
85
-- calculate a dynamic field length, the information is registered and/or used
86
 
87
-- in calculations accordingly.
88
 --tcp_head <= "0000000000" & tcp_header_len;
89
-- tcp_head <= "0000000000"&(unsigned(field_data(15 downto 12)) - 5)&"00";
90
 
91
set_len:process(reset,tcp_header_len,field_type,IPv4_header_len,opt,app_layer,clock,transport_layer_len,
92
                                         pad_data)
93
begin
94
--if reset = '1' then
95
--      length1_tmp <= "000000000000000000";
96
 
97
if rising_edge(clock) then
98
        if reset = '1' then
99
                length1_tmp <= (others => '0');
100
        elsif field_type = X"02" then
101
                length1_tmp <= (others => '0');
102
        elsif opt = '1' then
103
                if field_type = X"1C" then
104
                        length1_tmp <= IPv4_header_len - "000000000000010100";--x14,   dec_20 
105
                elsif field_type = X"29" then
106
                        length1_tmp <= TCP_header_len - "000000000000010100";--x14,    dec_20
107
                elsif field_type = X"37" then
108
                        length1_tmp <= transport_layer_len;
109
                elsif field_type = X"30" then
110
                        length1_tmp <= "00"&(unsigned(field_data(15 downto 0)) - 8);
111
                else
112
                        length1_tmp <= length1_tmp;
113
                end if;
114
        elsif app_layer = '1' then
115
                if field_type = X"29" then
116
                        length1_tmp <= Transport_layer_len - TCP_header_len;
117
                elsif field_type = X"31" then
118
--                      if padded = '1' then--field_data(15 downto 0) < X"001A" then
119
--                              length1_tmp <= (X"001A" - field_data(15 downto 0)) + ("00"&(unsigned(field_data(15 downto 0)) - 8));
120
--                      else
121
                                length1_tmp <= udp_length + pad_data;
122
--                              length1_tmp <= ("00"&(unsigned(field_data(15 downto 0)) - 8)) + pad_data;--+ padding;--changed 3-26-08
123
--                      end if;
124
                else
125
                        length1_tmp <= length1_tmp;
126
                end if;
127
        elsif opt = '0' and app_layer = '0' then
128
                if field_type = X"29" then
129
                        length1_tmp <= "000000000000000110";
130
                elsif field_type = X"31" then
131
--                      if padded = '1' then --field_data(15 downto 0) < X"001A" then
132
--                              length1_tmp <= (X"001A" - field_data(15 downto 0)) + ("00"&(unsigned(field_data(15 downto 0)) - 8));
133
--                      else
134
                                length1_tmp <= udp_length + pad_data;
135
--                              length1_tmp <= ("00"&(unsigned(field_data(15 downto 0)) - 8)) + pad_data;--+ padding;--changed 3-26-08
136
--                      end if;
137
--                      length1_tmp <= "0000000000"&(unsigned(field_data(7 downto 0)) - 8);--original_wrong
138
                else
139
                        length1_tmp <= length1_tmp;
140
                end if;
141
        else
142
                length1_tmp <= length1_tmp;
143
        end if;
144
else
145
        length1_tmp <= length1_tmp;
146
end if;
147
end process;
148
 
149
length1 <= length1_tmp;-- when padded = '0' else 
150
--                        (length1_tmp + padding) when padded = '1';
151
 
152
process(clock,length_indicator,field_data,field_type)
153
begin
154
        if rising_edge(clock) then
155
                if reset = '1' then
156
                        padded <= '0';
157
                        pad_data <= (others => '0');
158
                        udp_length <= (others => '0');
159
                else
160
                        if length_indicator = '1' then
161
                                if field_type = X"30" then
162
                                        udp_length <= ("00"&(unsigned(field_data(15 downto 0)) - 8));
163
                                        if field_data(15 downto 0) < X"001A" then
164
                                                padded <= '1';
165
                                                pad_data <= "00" & (X"001A" - field_data(15 downto 0));
166
                                        else
167
--                                              udp_length <= udp_length;
168
                                                padded <= '0';
169
                                                pad_data <= (others => '0');
170
                                        end if;
171
                                elsif field_type = X"17" then
172
                                        udp_length <= (others => '0');
173
                                        padded <= '0';
174
                                        pad_data <= (others => '0');
175
                                else
176
                                        udp_length <= udp_length;
177
                                        padded <= padded;
178
                                        pad_data <= pad_data;
179
                                end if;
180
                        else
181
                                udp_length <= udp_length;
182
                                padded <= padded;
183
                                pad_data <= pad_data;
184
                        end if;
185
                end if;
186
        end if;
187
 
188
 
189
end process;
190
 
191
 
192
process(clock,reset,length_indicator,field_type)
193
begin
194
        if rising_edge(clock) then
195
                if reset = '1' then
196
                        TCP_header_len <= (others => '0');
197
                else
198
                        if length_indicator = '1' then
199
                                if field_type = X"17" then
200
                                        TCP_header_len <= (others => '0');
201
                                elsif field_type = X"28" then
202
                                        TCP_header_len <= "000000000000" & field_data(15 downto 12) & "00";
203
                                else
204
                                        TCP_header_len <= TCP_header_len;
205
                                end if;
206
                        else
207
                                TCP_header_len <= TCP_header_len;
208
                        end if;
209
                end if;
210
        end if;
211
end process;
212
 
213
 
214
process(clock,reset,length_indicator,field_type)
215
begin
216
        if rising_edge(clock) then
217
                if reset = '1' then
218
                        transport_layer_len <= (others => '0');
219
                else
220
                        if length_indicator = '1' then
221
                                if field_type = X"17" then
222
                                        transport_layer_len <= (others => '0');
223
                                elsif field_type = X"1B" then
224
                                        transport_layer_len <= (("00" & field_data(15 downto 0)) - IPv4_header_len);
225
                                elsif field_type = X"36" then
226
                                        transport_layer_len <= field_data(15 downto 0) & "00";
227
                                else
228
                                        transport_layer_len <= transport_layer_len;
229
                                end if;
230
                        else
231
                                transport_layer_len <= transport_layer_len;
232
                        end if;
233
                end if;
234
        end if;
235
end process;
236
 
237
 
238
process(clock,reset,length_indicator,field_type)
239
begin
240
        if rising_edge(clock) then
241
                if reset = '1' then
242
                        IPv4_header_len <= (others => '0');
243
                else
244
                        if length_indicator = '1' then
245
                                if field_type = X"17" then
246
                                        IPv4_header_len <= (others => '0');
247
                                elsif field_type = X"19" then
248
                                        IPv4_header_len <= "000000000000" & field_data(3 downto 0) & "00";
249
                                else
250
                                        IPv4_header_len <= IPv4_header_len;
251
                                end if;
252
                        else
253
                                IPv4_header_len <= IPv4_header_len;
254
                        end if;
255
                end if;
256
        end if;
257
end process;
258
 
259
process(clock,reset,field_type,field_data)
260
begin
261
        if rising_edge(clock) then
262
                if reset = '1' then
263
                        IPv6transp_true <= '1';
264
                else
265
                        if field_type = X"37" then
266
                                if ((field_data(7 downto 0) = X"06") or (field_data(7 downto 0) = X"11")) then
267
                                        IPv6transp_true <= '1';
268
                                else
269
                                        IPv6transp_true <= '0';
270
                                end if;
271
                        elsif field_type = X"17" then
272
                                IPv6transp_true <= '1';
273
                        else
274
                                IPv6transp_true <= IPv6transp_true;
275
                        end if;
276
                end if;
277
        end if;
278
end process;
279
 
280
process(clock,reset,field_type,field_data,length_indicator)
281
begin
282
        if rising_edge(clock) then
283
                if reset = '1' then
284
                        total_length <= (others => '0');
285
                else
286
                        if field_type = X"1B" then
287
                                Total_length <= (("00" & field_data(15 downto 0)) + X"12");
288
                        elsif field_type = X"02" then
289
                                total_length <= (others => '0');
290
                        else
291
                                total_length <= total_length;
292
                        end if;
293
                end if;
294
        end if;
295
end process;
296
 
297
--process(clock,reset,total_length,field_type)
298
--begin
299
--      if rising_edge(clock) then
300
--              if reset = '1' then
301
--                      padded <= '0';
302
--              else
303
--                      if field_type >= X"1C" then
304
--                              if (total_length < "000000000001000000") then --"X"40") then
305
--                                      padded <= '1';
306
--                              else
307
--                                      padded <= '0';
308
--                              end if;
309
--                      else
310
--                              padded <= '0';
311
--                      end if;
312
--              end if;
313
--      end if;
314
--end process;
315
 
316
 
317
--process(clock,reset,padded)
318
--begin
319
--      if rising_edge(clock) then
320
--              if reset = '1' then
321
--                      padding <= (others => '0');
322
--              else
323
--                      if padded = '1' then
324
--                              padding <= "000000000001000000" - total_length;
325
--                      else
326
--                              padding <= (others => '0');
327
--                      end if;
328
--              end if;
329
--      end if;
330
--end process;
331
--transp_len: process(clock,reset,IPv4_header_len,field_type,length_indicator,field_data)
332
--begin
333
--if reset = '1' then
334
----    TCP_header_len <= "000000000000000000";
335
----    transport_layer_len <= "000000000000000000";
336
----    IPv4_header_len <= "000000000000000000";
337
--      IPv6transp_true <= '1';
338
--elsif rising_edge(clock) then
339
--      if length_indicator = '1' then
340
--              if field_type = X"17" then
341
----                    TCP_header_len <= "000000000000000000";
342
----                    transport_layer_len <= "000000000000000000";
343
----                    IPv4_header_len <= "000000000000000000";
344
--                      IPv6transp_true <= '1';
345
----            elsif field_type = X"19" then
346
----                    IPv4_header_len <= "000000000000" & field_data(3 downto 0) & "00";
347
----                    TCP_header_len <= TCP_header_len;
348
----                    transport_layer_len <= transport_layer_len;
349
--                      IPv6transp_true <= IPv6transp_true;
350
----            elsif field_type = X"1B" then
351
----                    transport_layer_len <= (("00" & field_data(15 downto 0)) - IPv4_header_len); 
352
----                    IPv4_header_len <= IPv4_header_len;
353
----                    TCP_header_len <= TCP_header_len;
354
--                      IPv6transp_true <= IPv6transp_true;
355
--              elsif field_type = X"28" then
356
----                    TCP_header_len <= "000000000000" & field_data(15 downto 12) & "00";
357
----                    IPv4_header_len <= IPv4_header_len;
358
----                    transport_layer_len <= transport_layer_len;
359
--                      IPv6transp_true <= IPv6transp_true;
360
----            elsif field_type = X"36" then
361
----                    transport_layer_len <= field_data(15 downto 0) & "00";
362
----                    IPv4_header_len <= IPv4_header_len;
363
----                    TCP_header_len <= TCP_header_len;
364
--                      IPv6transp_true <= IPv6transp_true;
365
--              elsif field_type = X"37" then
366
--                      if ((field_data(7 downto 0) = X"06") or (field_data(7 downto 0) = X"11")) then
367
--                              IPv6transp_true <= '1';
368
--                      else    
369
--                              IPv6transp_true <= '0';
370
--                      end if;
371
----                    transport_layer_len <= transport_layer_len;
372
----                    IPv4_header_len <= IPv4_header_len;
373
----                    TCP_header_len <= TCP_header_len;
374
--              else
375
----                    IPv4_header_len <= IPv4_header_len;
376
----                    transport_layer_len <= transport_layer_len;
377
----                    TCP_header_len <= TCP_header_len;
378
--                      IPv6transp_true <= IPv6transp_true;
379
--              end if;
380
--      else
381
----            IPv4_header_len <= IPv4_header_len;
382
----                    transport_layer_len <= transport_layer_len;
383
----                    TCP_header_len <= TCP_header_len;
384
--                      IPv6transp_true <= IPv6transp_true;
385
--      end if;
386
--else
387
----    IPv4_header_len <= IPv4_header_len;
388
----            transport_layer_len <= transport_layer_len;
389
----            TCP_header_len <= TCP_header_len;
390
--              IPv6transp_true <= IPv6transp_true;
391
--end if;
392
--end process;          
393
 
394
app_lay: process(clock,transport_layer_len,TCP_header_len)
395
begin
396
--if rising_edge(clock) then
397
        if (transport_layer_len - TCP_header_len) > "000000000000000000" then
398
                app_layer <= '1';
399
        else
400
                app_layer <= '0';
401
        end if;
402
--end if;
403
end process;
404
 
405
--app_layer <= '1' when 
406
 
407
options: process(clock,TCP_header_len,IPv4_header_len,IPv6transp_true)
408
begin
409
--if rising_edge(clock) then
410
--      if field_type = X"16" or field_type = X"17" then --X"2B" or field_type = X"22" or field_type = X"40" then
411
--              opt <= '0';
412
--      els
413
        if (((TCP_header_len > "000000000000010100") or (IPv4_header_len > "000000000000010100")) or (IPv6transp_true = '0')) then
414
                opt <= '1';
415
--      elsif IPv6transp_true = '1' then
416
--              opt <= '1';
417
        else
418
                opt <= '0';
419
        end if;
420
--end if;
421
end process;
422
optional <= opt;
423
 
424
END struct;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.