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

File containing the implementation of mDNS service structures. More...

#include <stdint.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
#include <sys/ioctl.h>
#include <syslog.h>
#include <unistd.h>
#include <eloop.h>
#include <uthash.h>
#include "../capture/middlewares/header_middleware/mdns_decoder.h"
#include "../capture/middlewares/header_middleware/packet_queue.h"
#include "../capture/pcap_service.h"
#include "../supervisor/cmd_processor.h"
#include "../supervisor/supervisor_config.h"
#include "../utils/hashmap.h"
#include "../utils/iface_mapper.h"
#include "../utils/ifaceu.h"
#include "../utils/log.h"
#include "../utils/net.h"
#include "../utils/sockctl.h"
#include "../utils/squeue.h"
#include "mcast.h"
#include "mdns_service.h"
Include dependency graph for mdns_service.c:

Macros

#define MDNS_PORT   5353
 
#define MDNS_ADDR4   (uint32_t)0xE00000FB /* 224.0.0.251 */
 
#define MDNS_ADDR6_INIT
 
#define MDNS_PCAP_BUFFER_TIMEOUT   10
 

Functions

int sockaddr2str (struct sockaddr_storage *sa, char *buffer, uint16_t *port)
 
void close_reflector_if (struct reflection_list *rif)
 
int forward_reflector_if6 (uint8_t *send_buf, size_t len, struct reflection_list *rif)
 
int forward_reflector_if4 (uint8_t *send_buf, size_t len, struct reflection_list *rif)
 
void eloop_reflector_handler (int sock, void *eloop_ctx, void *sock_ctx)
 
int register_reflector_if6 (struct eloop_data *eloop, struct mdns_context *context)
 
int register_reflector_if4 (struct eloop_data *eloop, struct mdns_context *context)
 
int init_reflections (hmap_vlan_conn **vlan_mapper, struct mdns_context *context)
 
int close_mdns (struct mdns_context *context)
 Closes mDNS service. More...
 
int create_domain_command (char *src_ip, char *dst_ip, char **out)
 
int send_bridge_command (struct mdns_context *context, struct tuple_packet *tp)
 
void mdns_pcap_callback (const void *ctx, const void *pcap_ctx, char *ltype, struct pcap_pkthdr *header, uint8_t *packet)
 
void eloop_read_mdns_fd_handler (int sock, void *eloop_ctx, void *sock_ctx)
 
int run_mdns_capture (struct eloop_data *eloop, struct mdns_context *context)
 
int run_mdns (struct mdns_context *context)
 Runs the mDNS forwarder service. More...
 
void free_mdns_context (struct mdns_context *context)
 
int init_mdns_context (struct mdns_conf *mdns_config, char *supervisor_control_path, hmap_vlan_conn *vlan_mapper, struct mdns_context *context)
 
void * mdns_thread (void *arg)
 
int run_mdns_thread (struct mdns_conf *mdns_config, char *supervisor_control_path, hmap_vlan_conn *vlan_mapper, pthread_t *id)
 Runs the mDNS forwarder service thread. More...
 

Detailed Description

File containing the implementation of mDNS service structures.

Author
Alexandru Mereacre
Date
2021

Macro Definition Documentation

◆ MDNS_ADDR4

#define MDNS_ADDR4   (uint32_t)0xE00000FB /* 224.0.0.251 */

◆ MDNS_ADDR6_INIT

#define MDNS_ADDR6_INIT
Value:
{ \
{ \
{ \
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0xfb \
} \
} \
}

◆ MDNS_PCAP_BUFFER_TIMEOUT

#define MDNS_PCAP_BUFFER_TIMEOUT   10

◆ MDNS_PORT

#define MDNS_PORT   5353

Function Documentation

◆ close_mdns()

int close_mdns ( struct mdns_context context)

Closes mDNS service.

Parameters
contextThe mDNS context structure
Returns
0 on success, -1 on failure

◆ close_reflector_if()

void close_reflector_if ( struct reflection_list rif)

◆ create_domain_command()

int create_domain_command ( char *  src_ip,
char *  dst_ip,
char **  out 
)

◆ eloop_read_mdns_fd_handler()

void eloop_read_mdns_fd_handler ( int  sock,
void *  eloop_ctx,
void *  sock_ctx 
)

◆ eloop_reflector_handler()

void eloop_reflector_handler ( int  sock,
void *  eloop_ctx,
void *  sock_ctx 
)

◆ forward_reflector_if4()

int forward_reflector_if4 ( uint8_t *  send_buf,
size_t  len,
struct reflection_list rif 
)

◆ forward_reflector_if6()

int forward_reflector_if6 ( uint8_t *  send_buf,
size_t  len,
struct reflection_list rif 
)

◆ free_mdns_context()

void free_mdns_context ( struct mdns_context context)

◆ init_mdns_context()

int init_mdns_context ( struct mdns_conf mdns_config,
char *  supervisor_control_path,
hmap_vlan_conn vlan_mapper,
struct mdns_context context 
)

◆ init_reflections()

int init_reflections ( hmap_vlan_conn **  vlan_mapper,
struct mdns_context context 
)

◆ mdns_pcap_callback()

void mdns_pcap_callback ( const void *  ctx,
const void *  pcap_ctx,
char *  ltype,
struct pcap_pkthdr *  header,
uint8_t *  packet 
)

◆ mdns_thread()

void* mdns_thread ( void *  arg)

◆ register_reflector_if4()

int register_reflector_if4 ( struct eloop_data *  eloop,
struct mdns_context context 
)

◆ register_reflector_if6()

int register_reflector_if6 ( struct eloop_data *  eloop,
struct mdns_context context 
)

◆ run_mdns()

int run_mdns ( struct mdns_context context)

Runs the mDNS forwarder service.

Parameters
contextThe mDNS context structure.
Returns
int 0 on success, -1 on failure

◆ run_mdns_capture()

int run_mdns_capture ( struct eloop_data *  eloop,
struct mdns_context context 
)

◆ run_mdns_thread()

int run_mdns_thread ( struct mdns_conf mdns_config,
char *  supervisor_control_path,
hmap_vlan_conn vlan_mapper,
pthread_t *  id 
)

Runs the mDNS forwarder service thread.

Parameters
mdns_configThe mDNS config structure
supervisor_control_pathThe UNIX domain supervisor control path
vlan_mapperThe VLAN mapper object
idThe returned thread id
Returns
int 0 on success, -1 on failure

◆ send_bridge_command()

int send_bridge_command ( struct mdns_context context,
struct tuple_packet tp 
)

◆ sockaddr2str()

int sockaddr2str ( struct sockaddr_storage *  sa,
char *  buffer,
uint16_t *  port 
)