summaryrefslogtreecommitdiffstats
path: root/service.h
blob: 7149672fdebd7b27ee3d13efc8477000ca4008bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 2.1
 * as published by the Free Software Foundation
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _SERVICE_H__
#define _SERVICE_H__

#include <libubox/vlist.h>
#include <libubox/avl-cmp.h>

struct service {
	struct vlist_node node;

	time_t t;

	const char *id;
	const char *instance;
	const char *service;
	const char *hostname;
	const uint8_t *txt;
	int txt_len;
	int port;
	int active;
};

struct hostname {
	struct vlist_node node;

	const char *hostname;
};
extern struct vlist_tree hostnames;
extern struct vlist_tree announced_services;

extern void service_init(int announce);
extern void service_cleanup(void);
extern void service_reply(struct interface *iface, struct sockaddr *to, const char *instance, const char *service_domain, int ttl, int force);
extern void service_announce_services(struct interface *iface, struct sockaddr *to, int ttl);
extern void service_update(struct vlist_tree *tree, struct vlist_node *node_new, struct vlist_node *node_old);

#endif