open62541 1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
mdnsd.h
Go to the documentation of this file.
1#ifndef MDNSD_H_
2#define MDNSD_H_
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "mdnsd_config.h"
9#include "1035.h"
10#if !defined(__bool_true_false_are_defined) && defined(_MSC_VER) && _MSC_VER < 1600
11// VS 2008 has no stdbool.h
12#define bool short
13#define true 1
14#define false 0
15#else
16#include <stdbool.h>
17#endif
18#include <stdio.h>
19
20#define QCLASS_IN (1)
21
22#if MDNSD_LOGLEVEL <= 100
23#define MDNSD_LOG_TRACE(...) do { \
24 printf("mdnsd: TRACE - "); printf(__VA_ARGS__); printf("\n"); } while(0)
25#else
26#define MDNSD_LOG_TRACE(...) do {} while(0)
27#endif
28
29#if MDNSD_LOGLEVEL <= 200
30#define MDNSD_LOG_DEBUG(...) do { \
31 printf("mdnsd: DEBUG - "); printf(__VA_ARGS__); printf("\n"); } while(0)
32#else
33#define MDNSD_LOG_DEBUG(...) do {} while(0)
34#endif
35
36#if MDNSD_LOGLEVEL <= 300
37#define MDNSD_LOG_INFO(...) do { \
38 printf("mdnsd: INFO - "); printf(__VA_ARGS__); printf("\n"); } while(0)
39#else
40#define MDNSD_LOG_INFO(...) do {} while(0)
41#endif
42
43#if MDNSD_LOGLEVEL <= 400
44#define MDNSD_LOG_WARNING(...) do { \
45 printf("mdnsd: WARN - "); printf(__VA_ARGS__); printf("\n"); } while(0)
46#else
47#define MDNSD_LOG_WARNING(...) do {} while(0)
48#endif
49
50#if MDNSD_LOGLEVEL <= 500
51#define MDNSD_LOG_ERROR(...) do { \
52 printf("mdnsd: ERROR - "); printf(__VA_ARGS__); printf("\n"); } while(0)
53#else
54#define MDNSD_LOG_ERROR(...) do {} while(0)
55#endif
56
57#if MDNSD_LOGLEVEL <= 600
58#define MDNSD_LOG_FATAL(...) do { \
59 printf("mdnsd: FATAL - "); printf(__VA_ARGS__); printf("\n"); } while(0)
60#else
61#define MDNSD_LOG_FATAL(...) do {} while(0)
62#endif
63
64
65/** Main daemon data */
66typedef struct mdns_daemon mdns_daemon_t;
67/** Record entry */
68typedef struct mdns_record mdns_record_t;
69
70/** Callback for received record. Data is passed from the register call */
71typedef void (*mdnsd_record_received_callback)(const struct resource* r, void* data);
72
73/** Answer data */
74typedef struct mdns_answer {
75 char *name;
76 unsigned short type;
77 unsigned long ttl;
78 unsigned short rdlen;
79 unsigned char *rdata;
80 struct in_addr ip; /* A */
81 char *rdname; /* NS/CNAME/PTR/SRV */
82 struct {
83 //cppcheck-suppress unusedStructMember
84 unsigned short int priority, weight, port;
85 } srv; /* SRV */
87
88
89
90
91mdns_daemon_t MDNSD_EXPORT * mdnsd_new(int clazz, int frame);
92
93
94void MDNSD_EXPORT mdnsd_shutdown(mdns_daemon_t *d);
95
96
97void MDNSD_EXPORT mdnsd_flush(mdns_daemon_t *d);
98
99
100void MDNSD_EXPORT mdnsd_free(mdns_daemon_t *d);
101
102
104
105
106
107
108int MDNSD_EXPORT mdnsd_in(mdns_daemon_t *d, struct message *m, in_addr_t ip, unsigned short int port);
109
110
111int MDNSD_EXPORT mdnsd_out(mdns_daemon_t *d, struct message *m, struct in_addr *ip, unsigned short int *port);
112
113
114struct timeval MDNSD_EXPORT * mdnsd_sleep(mdns_daemon_t *d);
115
116
117
118
119void MDNSD_EXPORT mdnsd_query(mdns_daemon_t *d, const char *host, int type, int (*answer)(mdns_answer_t *a, void *arg), void *arg);
120
121
122mdns_answer_t MDNSD_EXPORT *mdnsd_list(mdns_daemon_t *d, const char *host, int type, mdns_answer_t *last);
123
124
126
127
128const mdns_answer_t MDNSD_EXPORT *mdnsd_record_data(const mdns_record_t* r) ;
129
130
131
132
133
134mdns_record_t MDNSD_EXPORT * mdnsd_unique(mdns_daemon_t *d, const char *host, unsigned short int type, unsigned long int ttl, void (*conflict)(char *host, int type, void *arg), void *arg);
135
136
137mdns_record_t MDNSD_EXPORT * mdnsd_shared(mdns_daemon_t *d, const char *host, unsigned short int type, unsigned long int ttl);
138
139
140mdns_record_t MDNSD_EXPORT * mdnsd_get_published(const mdns_daemon_t *d, const char *host);
141
142
143int MDNSD_EXPORT mdnsd_has_query(const mdns_daemon_t *d, const char *host);
144
145
146void MDNSD_EXPORT mdnsd_done(mdns_daemon_t *d, mdns_record_t *r);
147
148
149void MDNSD_EXPORT mdnsd_set_raw(mdns_daemon_t *d, mdns_record_t *r, const char *data, unsigned short int len);
150void MDNSD_EXPORT mdnsd_set_host(mdns_daemon_t *d, mdns_record_t *r, const char *name);
151void MDNSD_EXPORT mdnsd_set_ip(mdns_daemon_t *d, mdns_record_t *r, struct in_addr ip);
152void MDNSD_EXPORT mdnsd_set_srv(mdns_daemon_t *d, mdns_record_t *r, unsigned short int priority, unsigned short int weight, unsigned short int port, char *name);
153
154
155unsigned short int MDNSD_EXPORT mdnsd_step(mdns_daemon_t *d, int mdns_socket, bool processIn, bool processOut, struct timeval *nextSleep);
156
157
158#ifdef MDNSD_DEBUG_DUMP_PKGS_FILE
159void mdnsd_debug_dumpCompleteChunk(mdns_daemon_t *d, const char* data, size_t len);
160#endif
161
162#ifdef __cplusplus
163} // extern "C"
164#endif
165
166#endif /* MDNSD_H_ */
unsigned short int MDNSD_EXPORT mdnsd_step(mdns_daemon_t *d, int mdns_socket, bool processIn, bool processOut, struct timeval *nextSleep)
void MDNSD_EXPORT mdnsd_set_host(mdns_daemon_t *d, mdns_record_t *r, const char *name)
mdns_record_t MDNSD_EXPORT * mdnsd_get_published(const mdns_daemon_t *d, const char *host)
void MDNSD_EXPORT mdnsd_register_receive_callback(mdns_daemon_t *d, mdnsd_record_received_callback cb, void *data)
struct timeval MDNSD_EXPORT * mdnsd_sleep(mdns_daemon_t *d)
void MDNSD_EXPORT mdnsd_free(mdns_daemon_t *d)
mdns_record_t MDNSD_EXPORT * mdnsd_unique(mdns_daemon_t *d, const char *host, unsigned short int type, unsigned long int ttl, void(*conflict)(char *host, int type, void *arg), void *arg)
void MDNSD_EXPORT mdnsd_done(mdns_daemon_t *d, mdns_record_t *r)
struct mdns_record mdns_record_t
Record entry.
Definition mdnsd.h:68
void MDNSD_EXPORT mdnsd_query(mdns_daemon_t *d, const char *host, int type, int(*answer)(mdns_answer_t *a, void *arg), void *arg)
struct mdns_daemon mdns_daemon_t
Main daemon data.
Definition mdnsd.h:66
const mdns_answer_t MDNSD_EXPORT * mdnsd_record_data(const mdns_record_t *r)
void MDNSD_EXPORT mdnsd_flush(mdns_daemon_t *d)
mdns_record_t MDNSD_EXPORT * mdnsd_shared(mdns_daemon_t *d, const char *host, unsigned short int type, unsigned long int ttl)
mdns_record_t MDNSD_EXPORT * mdnsd_record_next(const mdns_record_t *r)
int MDNSD_EXPORT mdnsd_in(mdns_daemon_t *d, struct message *m, in_addr_t ip, unsigned short int port)
void MDNSD_EXPORT mdnsd_shutdown(mdns_daemon_t *d)
int MDNSD_EXPORT mdnsd_has_query(const mdns_daemon_t *d, const char *host)
void MDNSD_EXPORT mdnsd_set_ip(mdns_daemon_t *d, mdns_record_t *r, struct in_addr ip)
void MDNSD_EXPORT mdnsd_set_raw(mdns_daemon_t *d, mdns_record_t *r, const char *data, unsigned short int len)
void(* mdnsd_record_received_callback)(const struct resource *r, void *data)
Callback for received record.
Definition mdnsd.h:71
int MDNSD_EXPORT mdnsd_out(mdns_daemon_t *d, struct message *m, struct in_addr *ip, unsigned short int *port)
struct mdns_answer mdns_answer_t
Answer data.
mdns_daemon_t MDNSD_EXPORT * mdnsd_new(int clazz, int frame)
void MDNSD_EXPORT mdnsd_set_srv(mdns_daemon_t *d, mdns_record_t *r, unsigned short int priority, unsigned short int weight, unsigned short int port, char *name)
mdns_answer_t MDNSD_EXPORT * mdnsd_list(mdns_daemon_t *d, const char *host, int type, mdns_answer_t *last)
Answer data.
Definition mdnsd.h:74
struct in_addr ip
Definition mdnsd.h:80
unsigned short type
Definition mdnsd.h:76
unsigned long ttl
Definition mdnsd.h:77
unsigned short rdlen
Definition mdnsd.h:78
unsigned short int port
Definition mdnsd.h:84
unsigned char * rdata
Definition mdnsd.h:79
char * rdname
Definition mdnsd.h:81
struct mdns_answer::@7 srv
char * name
Definition mdnsd.h:75