Skip to content

Commit

Permalink
read in binary mode, watch EOF after reading byte
Browse files Browse the repository at this point in the history
  • Loading branch information
shuckc committed Jun 13, 2012
1 parent 078cd4b commit c3180e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pcap/PcapParser.v
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module PcapParser
$finish_and_return(1);
end

file = $fopen(pcap_filename, "r");
file = $fopen(pcap_filename, "rb");
if (file == `NULL) begin
$display("can't read pcap input");
$finish_and_return(1);
Expand All @@ -81,7 +81,7 @@ module PcapParser
end

always @(posedge CLOCK)
begin
begin
if (eof == 0 && diskSz == 0 && countIPG == 0) begin
// read packet header
// fields of interest are U32 so bear in mind the byte ordering when assembling
Expand All @@ -103,13 +103,13 @@ module PcapParser
countIPG <= ipg; // reload interpacket gap counter

end else if ( diskSz > 0) begin

// packet content is byte-aligned, no swapping required
if (~pause) begin
newpkt <= 0;
eof = $feof(file);
diskSz <= diskSz - 1;
data <= $fgetc(file);
eof = $feof(file);
if ( eof != 0 || diskSz == 1) begin
available <= 0;
end else begin
Expand All @@ -123,7 +123,7 @@ module PcapParser
end else if (eof != 0) begin
pcapfinished <= 1; // terminal loop here
end


end

Expand Down

0 comments on commit c3180e8

Please sign in to comment.