EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Macros | Functions
mdns_decoder.c File Reference

File containing the implementation of the mdns packet decoder utilities. More...

#include <netinet/udp.h>
#include "../../../utils/allocs.h"
#include "../../../utils/hash.h"
#include "../../../utils/iface.h"
#include "../../../utils/os.h"
#include "../../../utils/squeue.h"
#include "mdns_decoder.h"
#include "packet_decoder.h"
Include dependency graph for mdns_decoder.c:

Macros

#define COMPRESSION_FLAG   0xC0
 
#define COMPRESSION_FLAG_BIT7   0x80
 
#define COMPRESSION_FLAG_BIT6   0x40
 

Functions

int copy_mdns_query_name (uint8_t *start, char **out)
 
uint16_t get_mdns_query_offset (uint8_t low, uint8_t high)
 
int decode_mdns_query_name (uint8_t *payload, size_t len, size_t *first, char **out)
 
int decode_mdns_queries (uint8_t *payload, size_t len, size_t *first, uint16_t nqueries, UT_array *queries)
 Decodes the mdns queries. More...
 
int decode_mdns_answers (uint8_t *payload, size_t len, size_t *first, uint16_t nanswers, UT_array *answers)
 Decodes the mdns answers. More...
 
int decode_mdns_header (uint8_t *packet, struct mdns_header *out)
 Decodes the mdns header. More...
 
bool decode_mdns_packet (struct capture_packet *cpac)
 Decode mdns packet. More...
 

Detailed Description

File containing the implementation of the mdns packet decoder utilities.

Author
Alexandru Mereacre
Date
2021

Macro Definition Documentation

◆ COMPRESSION_FLAG

#define COMPRESSION_FLAG   0xC0

◆ COMPRESSION_FLAG_BIT6

#define COMPRESSION_FLAG_BIT6   0x40

◆ COMPRESSION_FLAG_BIT7

#define COMPRESSION_FLAG_BIT7   0x80

Function Documentation

◆ copy_mdns_query_name()

int copy_mdns_query_name ( uint8_t *  start,
char **  out 
)

◆ decode_mdns_answers()

int decode_mdns_answers ( uint8_t *  payload,
size_t  len,
size_t *  first,
uint16_t  nanswers,
UT_array *  answers 
)

Decodes the mdns answers.

Parameters
payloadThe mdns payload
lenThe mdns payload length
[in,out]firstThe starting index to the answers field in the mdns payload. When done, this will be modified to be the starting index of the next field.
nanswersThe number of answers
[in,out]answersThe mdns_answer_entry answers array
Returns
0 Success, -1 on failure

◆ decode_mdns_header()

int decode_mdns_header ( uint8_t *  packet,
struct mdns_header out 
)

Decodes the mdns header.

Parameters
packetThe mdns packet
outThe output mdns decoded header
Returns
0 Success, -1 on failure

◆ decode_mdns_packet()

bool decode_mdns_packet ( struct capture_packet cpac)

Decode mdns packet.

Parameters
cpacThe capture packet structure
Returns
true Success, false otherwise

◆ decode_mdns_queries()

int decode_mdns_queries ( uint8_t *  payload,
size_t  len,
size_t *  first,
uint16_t  nqueries,
UT_array *  queries 
)

Decodes the mdns queries.

Parameters
payloadThe mdns payload
lenThe mdns payload length
[in,out]firstThe starting index to the queries field in the mdns payload. When done, this will be modified to be the starting index of the next field.
nqueriesThe number of queries
[in,out]queriesThe mdns_query_entry queries array
Returns
0 Success, -1 on failure

◆ decode_mdns_query_name()

int decode_mdns_query_name ( uint8_t *  payload,
size_t  len,
size_t *  first,
char **  out 
)

◆ get_mdns_query_offset()

uint16_t get_mdns_query_offset ( uint8_t  low,
uint8_t  high 
)