Question: Help me with the given guidelines and C code guidelines. I already have the code for the print menu, I just need help on the
Help me with the given guidelines and C code guidelines. I already have the code for the print menu, I just need help on the codes for, void printpacket, int findbytepacket, int findstringpacket, int findstringall, int findbyteall, int findwebsites, and void storepacket The code should match the given outputs and inputs in the photo provided. Some of the code is provided below and the rest is in in the screenshot provided. Everything needed and mentioned should be in the code below or the screenshots.
Purpose: A simple packet sniffer that can handle packets with nonprintable
characters. The sniffer can find any byte, string, or web address
in any packet.
Assumptions:
Input file is read in as bytes. The input file must have the correct
format. Minimal error checking is included to validate the input data.
Command line argument
Name of file to read. The file must contain one packet per line with
the format
size packetcontents
The size is the number of bytes in the packet, and the packetcontents
is the binary data, read as bytes. The size of the packet must be
correct, and there must be exactly one space character between the size
field and the start of the packetcontents. Note the bytes in a packet
can have any value, so the packet may not be printable.
Bugs:
Notes:
The number of packets that can be stored is limited to MAXPACKETS
because one position is needed to mark where the last packet ends.
See the ECE programming guide
Format with
astyle stylekr labc
Replace kr with: bsd ansi, java, gnu, linux, vtk or google.
#include
#include
#include
#include
#define MAXLINE
#define MAXPACKETLENGTH
#define MAXPACKETS
#define MAXFILESIZE
A stub function for printing packets as byte aligned lines of text.
input:
position: the location of the point of interest. For example, the found
byte or the first character in a found string. If position is
then there is no point of interest.
slen: the length of the found string or for a found byte
packets: an array of pointers to each packet's starting address in memory
packetnum: the index of the packet of interest
output:
prints a packet as formatted byte lines of text.
This function continues to print byte lines so that the entire packet
is displayed. A nonprintable character is replaced with a space
In addition, the point of interest eg the found byte or found string
is marked, as discussed in the pdf
void printpacketint position, int slen, char packetsMAXPACKETS int packetnum
return; fix this
This function is a stub for searching a particular packet for a byte.
Use packetspacketnum as the starting address for the particular packet.
Search within this packet for the first matching byte. Use the starting
address of the next packet packetspacketnum to know when to end.
input:
packets: an array of pointers to each packet's starting address in memory
packetnum: is the index of the packet of interest
byte: is a string with the hex characters of the byte to find
return value:
if byte found within the packet
if byte not found
side effects:
If the byte is found, your function should call printpacket and
display the matched byte as discussed in the pdf
int findbytepacketchar packetsMAXPACKETS int packetnum, char byte
int found ;
return found;
This function is a stub for searching a particular packet for a string.
Use packetspacketnum as the starting address for the particular packet.
Search within this packet for the first matching byte. Use the starting
address of the next packet packetspacketnum to know when to end.
input:
packets: an array of pointers to each packet's starting address in memory
packetnum: is the index of the packet of interest
str: is the string to find
return value:
if string found within the packet
if string not found
side effects:
If the string is found, your function should call printpacket
and display the matched string as discussed in the pdf
int findstringpacketchar packetsMAXPACKETS int packetnum, const char str
int found ;
return found;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
