• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/avahi-0.6.25/avahi-core/

Lines Matching defs:*

0 /* $Id$ */
4 This file is part of avahi.
6 avahi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 avahi is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with avahi; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 #include <sys/types.h>
27 #include <netinet/in.h>
28 #include <sys/socket.h>
29 #include <arpa/inet.h>
30 #include <string.h>
31 #include <assert.h>
33 #include "addr-util.h"
35 AvahiAddress *avahi_address_from_sockaddr(const struct sockaddr* sa, AvahiAddress *ret_addr) {
36 assert(sa);
37 assert(ret_addr);
39 assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6);
41 ret_addr->proto = avahi_af_to_proto(sa->sa_family);
43 if (sa->sa_family == AF_INET)
44 memcpy(&ret_addr->data.ipv4, &((const struct sockaddr_in*) sa)->sin_addr, sizeof(ret_addr->data.ipv4));
45 else
46 memcpy(&ret_addr->data.ipv6, &((const struct sockaddr_in6*) sa)->sin6_addr, sizeof(ret_addr->data.ipv6));
48 return ret_addr;
51 uint16_t avahi_port_from_sockaddr(const struct sockaddr* sa) {
52 assert(sa);
54 assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6);
56 if (sa->sa_family == AF_INET)
57 return ntohs(((const struct sockaddr_in*) sa)->sin_port);
58 else
59 return ntohs(((const struct sockaddr_in6*) sa)->sin6_port);
62 int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a) {
64 static const uint8_t ipv4_in_ipv6[] = {
65 0x00, 0x00, 0x00, 0x00,
66 0x00, 0x00, 0x00, 0x00,
67 0xFF, 0xFF, 0xFF, 0xFF
70 assert(a);
72 if (a->proto != AVAHI_PROTO_INET6)
73 return 0;
75 return memcmp(a->data.ipv6.address, ipv4_in_ipv6, sizeof(ipv4_in_ipv6)) == 0;