1 /* 2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org> 3 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License version 2.1 7 * as published by the Free Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 */ 14 15 #ifndef __MDNS_INTERFACE_H 16 #define __MDNS_INTERFACE_H 17 18 #include <sys/types.h> 19 #include <sys/uio.h> 20 21 #include <arpa/inet.h> 22 23 #include <libubox/uloop.h> 24 #include <libubox/vlist.h> 25 26 extern struct vlist_tree interfaces; 27 28 #define SOCKTYPE_BIT_IPV6 (1 << 1) 29 #define SOCKTYPE_BIT_UNICAST (1 << 0) 30 31 enum umdns_socket_type { 32 SOCK_MC_IPV4 = 0, 33 SOCK_UC_IPV4 = SOCKTYPE_BIT_UNICAST, 34 SOCK_MC_IPV6 = SOCKTYPE_BIT_IPV6, 35 SOCK_UC_IPV6 = SOCKTYPE_BIT_IPV6 | SOCKTYPE_BIT_UNICAST, 36 }; 37 38 struct interface_addr_list { 39 union { 40 struct { 41 struct in_addr addr, mask; 42 } *v4; 43 struct { 44 struct in6_addr addr, mask; 45 } *v6; 46 }; 47 int n_addr; 48 }; 49 50 struct interface { 51 struct vlist_node node; 52 53 const char *name; 54 enum umdns_socket_type type; 55 int ifindex; 56 57 struct interface_addr_list addrs; 58 59 struct uloop_timeout announce_timer; 60 int announce_state; 61 }; 62 63 static inline bool interface_multicast(struct interface *iface) 64 { 65 return !(iface->type & SOCKTYPE_BIT_UNICAST); 66 } 67 68 static inline bool interface_ipv6(struct interface *iface) 69 { 70 return !!(iface->type & SOCKTYPE_BIT_IPV6); 71 } 72 73 int interface_add(const char *name); 74 int interface_init(void); 75 void interface_shutdown(void); 76 int interface_send_packet(struct interface *iface, struct sockaddr *to, struct iovec *iov, int iov_len); 77 struct interface* interface_get(const char *name, enum umdns_socket_type type); 78 79 #endif 80
This page was automatically generated by LXR 0.3.1. • OpenWrt