P2P Transmitter
Loading...
Searching...
No Matches
packet.h File Reference
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  Byte
 
struct  Packet
 

Typedefs

typedef struct Byte Byte
 
typedef struct Packet Packet
 

Functions

BytetoByte (char c)
 Converts a character to a Byte struct (linked list node)
 
PacketcreatePacket ()
 Creates a reserved, empty Packet struct instance.
 
PacketcreateRetransmitPacket (uint8_t identifier)
 Creates a Packet requesting that the peer retransmit the cached Packet with the specified identifier.
 
PackettoPacket (char *s)
 Converts a char* string to a Packet containing one Byte per char.
 
PacketbyteToPacket (Byte *b)
 Creates a Packet structure containing the provided Byte.
 
uint8_t getPacketID (Packet *p)
 Extracts the Packet Identifier from the header field.
 
bool getPacketRT (Packet *p)
 Checks the header field to determine if the specified Packet ID should be retransmitted.
 
void setPacketID (Packet *p, uint8_t id)
 Sets the Packet Identifier within the header field.
 
void packetAppendByte (Packet *p, Byte *b)
 Creates a Packet to be stored within the PacketCache.
 
void printByte (Byte *b)
 Sending and retransmitting.
 
void printPacket (Packet *p)
 Display the bytes contained within the packet and their ASCII representation.
 
void freePacket (Packet *p)
 Free the memory reserved for the packet and all contained bytes.
 

Function Documentation

◆ byteToPacket()

Packet * byteToPacket ( Byte * b)

Creates a Packet structure containing the provided Byte.

Parameters
bPointer to the Byte to be wrapped
Returns
Pointer to the resulting Packet

◆ createPacket()

Packet * createPacket ( )

Creates a reserved, empty Packet struct instance.

Returns
Pointer to the resulting Packet, NULL if there is no available memory

◆ createRetransmitPacket()

Packet * createRetransmitPacket ( uint8_t identifier)

Creates a Packet requesting that the peer retransmit the cached Packet with the specified identifier.

Returns
Pointer to the resulting Packet, NULL if there is no available memory

◆ freePacket()

void freePacket ( Packet * p)

Free the memory reserved for the packet and all contained bytes.

Parameters
pPointer to the Packet to be freed

◆ getPacketID()

uint8_t getPacketID ( Packet * p)

Extracts the Packet Identifier from the header field.

Parameters
pPointer to the Packet to be examined
Returns
The value of the Packet Identifier (ID) bits

◆ getPacketRT()

bool getPacketRT ( Packet * p)

Checks the header field to determine if the specified Packet ID should be retransmitted.

Parameters
pPointer to the Packet to be examined
Returns
The value of the Retransmission (RT) bit

◆ packetAppendByte()

void packetAppendByte ( Packet * p,
Byte * b )

Creates a Packet to be stored within the PacketCache.

Returns
Pointer to the resulting Packet, NULL if there is no available memory
Deprecated
The Packet Cache is being migrated to main.c

Inserts a Byte at the end of a Packet. This function ignores linked Bytes, so they should be handled appropriately.

Parameters
pPointer to the Packet to be modified
bPointer to the Byte to be appended. The addresses stored within .previous and .next will be overwritten.

◆ printByte()

void printByte ( Byte * b)

Sending and retransmitting.

Deprecated
Packet transmission should be implemented in uart.c

Sending and retransmitting

Deprecated
Packet transmission should be implemented in uart.c

Print the detailed contents of a Byte struct instance

Parameters
bPointer to the Byte to be printed

◆ printPacket()

void printPacket ( Packet * p)

Display the bytes contained within the packet and their ASCII representation.

Parameters
pPointer to the Packet to be printed

◆ setPacketID()

void setPacketID ( Packet * p,
uint8_t id )

Sets the Packet Identifier within the header field.

Parameters
pPointer to the Packet to be modified
idThe 3-bit Packet ID value

◆ toByte()

Byte * toByte ( char c)

Converts a character to a Byte struct (linked list node)

Parameters
c8-bit char to be used as the Byte's value
Returns
Pointer to the resulting Byte, NULL if there is no available memory

◆ toPacket()

Packet * toPacket ( char * s)

Converts a char* string to a Packet containing one Byte per char.

Parameters
sThe char* string to be converted to a Byte sequence
Returns
Pointer to the resulting Packet, NULL if there is no available memory