00001 #ifndef fooaddresshfoo 00002 #define fooaddresshfoo 00003 00004 /* $Id: address.h 1477 2007-05-09 19:45:54Z lennart $ */ 00005 00006 /*** 00007 This file is part of avahi. 00008 00009 avahi is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Lesser General Public License as 00011 published by the Free Software Foundation; either version 2.1 of the 00012 License, or (at your option) any later version. 00013 00014 avahi is distributed in the hope that it will be useful, but WITHOUT 00015 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00016 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 00017 Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with avahi; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00022 USA. 00023 ***/ 00024 00027 #include <inttypes.h> 00028 #include <sys/types.h> 00029 00030 #include <avahi-common/cdecl.h> 00031 00032 AVAHI_C_DECL_BEGIN 00033 00035 typedef int AvahiProtocol; 00036 00038 typedef int AvahiIfIndex; 00039 00041 enum { 00042 AVAHI_PROTO_INET = 0, 00043 AVAHI_PROTO_INET6 = 1, 00044 AVAHI_PROTO_UNSPEC = -1 00045 }; 00046 00048 enum { 00049 AVAHI_IF_UNSPEC = -1 00050 }; 00051 00053 #define AVAHI_ADDRESS_STR_MAX 40 /* IPv6 Max = 4*8 + 7 + 1 for NUL */ 00054 00056 #define AVAHI_IF_VALID(ifindex) (((ifindex) >= 0) || ((ifindex) == AVAHI_IF_UNSPEC)) 00057 00059 #define AVAHI_PROTO_VALID(protocol) (((protocol) == AVAHI_PROTO_INET) || ((protocol) == AVAHI_PROTO_INET6) || ((protocol) == AVAHI_PROTO_UNSPEC)) 00060 00062 typedef struct AvahiIPv4Address { 00063 uint32_t address; 00064 } AvahiIPv4Address; 00065 00067 typedef struct AvahiIPv6Address { 00068 uint8_t address[16]; 00069 } AvahiIPv6Address; 00070 00072 typedef struct AvahiAddress { 00073 AvahiProtocol proto; 00075 union { 00076 AvahiIPv6Address ipv6; 00077 AvahiIPv4Address ipv4; 00078 uint8_t data[1]; 00079 } data; 00080 } AvahiAddress; 00081 00085 int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b); 00086 00092 char *avahi_address_snprint(char *ret_s, size_t length, const AvahiAddress *a); 00093 00097 AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol af, AvahiAddress *ret_addr); 00098 00103 char* avahi_reverse_lookup_name(const AvahiAddress *a, char *ret_s, size_t length); 00109 int avahi_proto_to_af(AvahiProtocol proto); 00110 00112 AvahiProtocol avahi_af_to_proto(int af); 00113 00115 const char* avahi_proto_to_string(AvahiProtocol proto); 00116 00119 AVAHI_C_DECL_END 00120 00121 #endif