00001 #ifndef mdnsd_h
00002 #define mdnsd_h
00003 #include "1035.h"
00004 #include <sys/time.h>
00005
00006 #define SRV_PORT 6464
00007
00008 #ifndef RECORD_MAX_TRIES
00009 #define RECORD_MAX_TRIES -1
00010 #endif
00011
00012 #ifndef QUERY_MAX_TRIES
00013 #define QUERY_MAX_TRIES -1
00014 #endif
00015
00016 typedef struct mdnsd_struct *mdnsd;
00017 typedef struct mdnsdr_struct *mdnsdr;
00018
00019 typedef struct mdnsda_struct
00020 {
00021 unsigned char *name;
00022 unsigned short int type;
00023 unsigned long int ttl;
00024 unsigned short int rdlen;
00025 unsigned char *rdata;
00026 unsigned long int ip;
00027 unsigned char *rdname;
00028 struct { unsigned short int priority, weight, port; } srv;
00029 } *mdnsda;
00030
00032
00033
00034
00041 mdnsd mdnsd_new(int aClass, int frame);
00042
00043
00044 void mdnsd_shutdown(mdnsd d);
00045
00046
00047 void mdnsd_flush(mdnsd d);
00048
00049
00050 void mdnsd_free(mdnsd d);
00051
00053
00055
00056
00057
00058 void mdnsd_in(mdnsd d, struct message *m, unsigned long int ip, unsigned short int port);
00059
00060
00061 int mdnsd_out(mdnsd d, struct message *m, unsigned long int *ip, unsigned short int *port);
00062
00069 struct timeval* mdnsd_sleep(mdnsd d);
00070
00074 unsigned int mdnsd_sleep_millis(mdnsd);
00075
00077
00079
00080
00081
00082
00083
00084 void mdnsd_query(mdnsd d,
00085 char* host,
00086 int type,
00087 int (*answer)(mdnsda a, void *arg),
00088 void *arg);
00089
00090 void _mdnsd_query(mdnsd d,
00091 char *host,
00092 int type,
00093 int (*answer)(mdnsda a, void *arg),
00094 void *arg,
00095 char* target_host,
00096 int target_port);
00097
00098
00099
00100 mdnsda mdnsd_list(mdnsd d, char *host, int type, mdnsda last);
00101
00103
00105
00106
00107
00108
00109
00110 mdnsdr mdnsd_unique(mdnsd d, char *host, int type, long int ttl, void (*conflict)(char *host, int type, void *arg), void *arg);
00111
00112 mdnsdr _mdnsd_unique(mdnsd d,
00113 char *host,
00114 int type,
00115 long int ttl,
00116 void (*conflict)(char *host, int type, void *arg),
00117 void *arg,
00118 char* target_host,
00119 int target_port);
00120
00129 mdnsdr mdnsd_shared(mdnsd d, char *host, int type, long int ttl);
00130
00131 mdnsdr _mdnsd_shared(mdnsd d,
00132 char *host,
00133 int type,
00134 long int ttl,
00135 char* target_host,
00136 int target_port);
00137
00138
00139 void mdnsd_done(mdnsd d, mdnsdr r);
00140
00141
00142 void mdnsd_set_raw(mdnsd d, mdnsdr r, unsigned char *data, int len);
00143 void mdnsd_set_host(mdnsd d, mdnsdr r, char *name);
00144 void mdnsd_set_ip(mdnsd d, mdnsdr r, unsigned long int ip);
00145 void mdnsd_set_srv(mdnsd d, mdnsdr r, int priority, int weight, int port, char *name);
00146
00148
00149 #ifdef DEBUG
00150 #define INFO
00151 #endif
00152
00153 #ifdef INFO
00154 #include "xht.h"
00155
00156 void debug_walker(xht h, const char* key, void* val, void* arg);
00157 #endif
00158
00159 #endif