Libu2f-emu  0.0.0
Universal 2nd Factor (U2F) Emulation C Library
Data Structures | Macros | Functions | Variables
message.h File Reference
#include <stdint.h>
#include "packet.h"
#include "payload.h"
Include dependency graph for message.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  message
 Message representation. More...
 

Macros

#define BIT(x)   (1 << (x))
 
#define __packed   __attribute__((__packed__))
 
#define MSG_DEF_CAP   1024
 The default capacity of a message. More...
 
#define MSG_MAX_SIZE
 

Functions

struct messagemessage_new (const struct packet_init *init_packet)
 Allocate and initialize a new message from an init packet. More...
 
struct messagemessage_new_blank (uint32_t cid, uint8_t cmd)
 Allocate and initialize a new blank message. More...
 
struct messagemessage_new_from_data (uint32_t cid, uint8_t cmd, const uint8_t *data, size_t size)
 Allocate and initialize a new message from data. More...
 
struct messagemessage_new_from_payload (uint32_t cid, uint8_t cmd, const struct payload *payload)
 Allocate and initialize a new message from payload. More...
 
struct messagemessage_copy (const struct message *message)
 Allocate and initialize a new message from another message. More...
 
bool message_add_data (struct message *message, const uint8_t *data, size_t size)
 Add data to a message. More...
 
bool message_add_part (struct message *message, const struct packet_cont *cont_packet)
 Add a part to a message. More...
 
bool message_next_packet (struct message *message, void **packet_ref)
 Get next packet part of a message for sending a message. More...
 
void message_free (struct message *message)
 Free a message. More...
 

Variables

struct message __attribute__
 

Macro Definition Documentation

#define __packed   __attribute__((__packed__))
#define BIT (   x)    (1 << (x))
#define MSG_DEF_CAP   1024

The default capacity of a message.

#define MSG_MAX_SIZE
Value:
#define PACKET_INIT_DATA_SIZE
Definition: packet.h:20
#define PACKET_CONT_DATA_SIZE
Definition: packet.h:24
#define PACKET_CONT_MAX_SEQ
Definition: packet.h:25

Function Documentation

bool message_add_data ( struct message message,
const uint8_t *  data,
size_t  size 
)

Add data to a message.

Parameters
messageThe message to add data to.
dataThe data to add.
sizeThe size of the data.
Returns
Success: true. Failure: false.
bool message_add_part ( struct message message,
const struct packet_cont cont_packet 
)

Add a part to a message.

Parameters
messageThe message.
cont_packetThe continuation packet.
Returns
Success: true. Failure: false.
struct message* message_copy ( const struct message message)

Allocate and initialize a new message from another message.

Parameters
messageThe message to copy.
Returns
Success: The new allocated and initialized message. Failure: NULL.
void message_free ( struct message message)

Free a message.

Parameters
messageThe message to free.
struct message* message_new ( const struct packet_init init_packet)

Allocate and initialize a new message from an init packet.

Parameters
init_packetThe initialisation packet of the message.
Returns
Success: The new allocated and initialiazed message. Failure: NULL.
struct message* message_new_blank ( uint32_t  cid,
uint8_t  cmd 
)

Allocate and initialize a new blank message.

Parameters
cidThe channel id.
cmdThe associated command.
Returns
Success: The new allocated and initialized blank message. Failure: NULL.
struct message* message_new_from_data ( uint32_t  cid,
uint8_t  cmd,
const uint8_t *  data,
size_t  size 
)

Allocate and initialize a new message from data.

Parameters
cidThe channel id.
cmdThe associated command.
dataThe data to put in the message.
sizeThe size of the data.
Returns
Success: The new allocated and initialized message. Failure: NULL.
struct message* message_new_from_payload ( uint32_t  cid,
uint8_t  cmd,
const struct payload payload 
)

Allocate and initialize a new message from payload.

Parameters
cidThe channel id.
cmdThe associated command.
payloadThe payload ot put in the message.
Returns
Success: The new allocated and initialized message. Failure: NULL.
bool message_next_packet ( struct message message,
void **  packet_ref 
)

Get next packet part of a message for sending a message.

Parameters
messageThe message to get the next packet from.
packet_refPacket reference to put the crafted packet.
Returns
End of message: false. Not end of message: true.

Variable Documentation

struct message __attribute__