corosync  3.0.2
totemip.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005-2019 Red Hat, Inc.
3  *
4  * All rights reserved.
5  *
6  * Author: Patrick Caulfield (pcaulfie@redhat.com)
7  *
8  * This software licensed under BSD license, the text of which follows:
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * - Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * - Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * - Neither the name of the MontaVista Software, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32  * THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /* IPv4/6 abstraction */
36 
37 #include <config.h>
38 
39 #include <sys/ioctl.h>
40 #include <sys/types.h>
41 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
44 #include <netdb.h>
45 #include <net/if.h>
46 #include <string.h>
47 #include <stdio.h>
48 #include <errno.h>
49 #include <assert.h>
50 #include <stdlib.h>
51 #include <unistd.h>
52 #include <ifaddrs.h>
53 
54 #include <corosync/totem/totemip.h>
55 #include <corosync/logsys.h>
56 #include <corosync/swab.h>
57 
58 #define LOCALHOST_IPV4 "127.0.0.1"
59 #define LOCALHOST_IPV6 "::1"
60 
61 #define NETLINK_BUFSIZE 16384
62 
63 #ifdef SO_NOSIGPIPE
64 void totemip_nosigpipe(int s)
65 {
66  int on = 1;
67  setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (void *)&on, sizeof(on));
68 }
69 #endif
70 
71 /* Compare two addresses */
72 int totemip_equal(const struct totem_ip_address *addr1,
73  const struct totem_ip_address *addr2)
74 {
75  int addrlen = 0;
76 
77  if (addr1->family != addr2->family)
78  return 0;
79 
80  if (addr1->family == AF_INET) {
81  addrlen = sizeof(struct in_addr);
82  }
83  if (addr1->family == AF_INET6) {
84  addrlen = sizeof(struct in6_addr);
85  }
86  assert(addrlen);
87 
88  if (memcmp(addr1->addr, addr2->addr, addrlen) == 0)
89  return 1;
90  else
91  return 0;
92 
93 }
94 
95 int totemip_sa_equal(const struct totem_ip_address *totem_ip,
96  const struct sockaddr *sa)
97 {
98  int res;
99 
100  res = 0;
101 
102  if (totem_ip->family != sa->sa_family) {
103  return (res);
104  }
105 
106  switch (totem_ip->family) {
107  case AF_INET:
108  res = (memcmp(totem_ip->addr,
109  &((const struct sockaddr_in *)sa)->sin_addr, sizeof(struct in_addr)) == 0);
110  break;
111  case AF_INET6:
112  res = (memcmp(totem_ip->addr,
113  &((const struct sockaddr_in6 *)sa)->sin6_addr, sizeof(struct in6_addr)) == 0);
114  break;
115  default:
116  assert(0);
117  }
118 
119  return (res);
120 }
121 
122 /* Copy a totem_ip_address */
123 void totemip_copy(struct totem_ip_address *addr1,
124  const struct totem_ip_address *addr2)
125 {
126  memcpy(addr1, addr2, sizeof(struct totem_ip_address));
127 }
128 
130  const struct totem_ip_address *addr2)
131 {
132  addr1->nodeid = swab32(addr2->nodeid);
133  addr1->family = swab16(addr2->family);
134  memcpy(addr1->addr, addr2->addr, TOTEMIP_ADDRLEN);
135 }
136 
137 /*
138  * Multicast address range is 224.0.0.0 to 239.255.255.255 this
139  * translates to the first 4 bits == 1110 (0xE).
140  * http://en.wikipedia.org/wiki/Multicast_address
141  */
142 int32_t totemip_is_mcast(struct totem_ip_address *ip_addr)
143 {
144  uint32_t addr = 0;
145 
146  memcpy (&addr, ip_addr->addr, sizeof (uint32_t));
147 
148  if (ip_addr->family == AF_INET) {
149  addr = ntohl(addr);
150  if ((addr >> 28) != 0xE) {
151  return -1;
152  }
153  }
154  return 0;
155 }
156 
157 /* For sorting etc. params are void * for qsort's benefit */
158 int totemip_compare(const void *a, const void *b)
159 {
160  int i;
161  const struct totem_ip_address *totemip_a = (const struct totem_ip_address *)a;
162  const struct totem_ip_address *totemip_b = (const struct totem_ip_address *)b;
163  struct in_addr ipv4_a1;
164  struct in_addr ipv4_a2;
165  struct in6_addr ipv6_a1;
166  struct in6_addr ipv6_a2;
167  unsigned short family;
168 
169  /*
170  * Use memcpy to align since totem_ip_address is unaligned on various archs
171  */
172  memcpy (&family, &totemip_a->family, sizeof (unsigned short));
173 
174  if (family == AF_INET) {
175  memcpy (&ipv4_a1, totemip_a->addr, sizeof (struct in_addr));
176  memcpy (&ipv4_a2, totemip_b->addr, sizeof (struct in_addr));
177  if (ipv4_a1.s_addr == ipv4_a2.s_addr) {
178  return (0);
179  }
180  if (htonl(ipv4_a1.s_addr) < htonl(ipv4_a2.s_addr)) {
181  return -1;
182  } else {
183  return +1;
184  }
185  } else
186  if (family == AF_INET6) {
187  /*
188  * We can only compare 8 bits at time for portability reasons
189  */
190  memcpy (&ipv6_a1, totemip_a->addr, sizeof (struct in6_addr));
191  memcpy (&ipv6_a2, totemip_b->addr, sizeof (struct in6_addr));
192  for (i = 0; i < 16; i++) {
193  int res = ipv6_a1.s6_addr[i] -
194  ipv6_a2.s6_addr[i];
195  if (res) {
196  return res;
197  }
198  }
199  return 0;
200  } else {
201  /*
202  * Family not set, should be!
203  */
204  assert (0);
205  }
206  return 0;
207 }
208 
209 /* Build a localhost totem_ip_address */
210 int totemip_localhost(int family, struct totem_ip_address *localhost)
211 {
212  const char *addr_text;
213 
214  memset (localhost, 0, sizeof (struct totem_ip_address));
215 
216  if (family == AF_INET) {
217  addr_text = LOCALHOST_IPV4;
218  if (inet_pton(family, addr_text, (char *)&localhost->nodeid) <= 0) {
219  return -1;
220  }
221  } else {
222  addr_text = LOCALHOST_IPV6;
223  }
224 
225  if (inet_pton(family, addr_text, (char *)localhost->addr) <= 0)
226  return -1;
227 
228  localhost->family = family;
229 
230  return 0;
231 }
232 
234 {
235  struct totem_ip_address localhost;
236 
237  if (totemip_localhost(addr->family, &localhost))
238  return 0;
239  return totemip_equal(addr, &localhost);
240 }
241 
242 const char *totemip_sa_print(const struct sockaddr *sa)
243 {
244  static char buf[INET6_ADDRSTRLEN];
245 
246  buf[0] = 0;
247 
248  switch (sa->sa_family) {
249  case AF_INET:
250  inet_ntop(sa->sa_family, &((struct sockaddr_in *)(sa))->sin_addr, buf,
251  INET6_ADDRSTRLEN);
252  break;
253  case AF_INET6:
254  inet_ntop(sa->sa_family, &((struct sockaddr_in6 *)(sa))->sin6_addr, buf,
255  INET6_ADDRSTRLEN);
256  break;
257  default:
258  return (NULL);
259  }
260 
261  return (buf);
262 }
263 
264 const char *totemip_print(const struct totem_ip_address *addr)
265 {
266  static char buf[INET6_ADDRSTRLEN];
267 
268  return (inet_ntop(addr->family, addr->addr, buf, sizeof(buf)));
269 }
270 
271 /* Make a totem_ip_address into a usable sockaddr_storage */
273  uint16_t port, struct sockaddr_storage *saddr, int *addrlen)
274 {
275  int ret = -1;
276 
277  if (ip_addr->family == AF_INET) {
278  struct sockaddr_in *sin = (struct sockaddr_in *)saddr;
279 
280  memset(sin, 0, sizeof(struct sockaddr_in));
281 #ifdef HAVE_SOCK_SIN_LEN
282  sin->sin_len = sizeof(struct sockaddr_in);
283 #endif
284  sin->sin_family = ip_addr->family;
285  sin->sin_port = ntohs(port);
286  memcpy(&sin->sin_addr, ip_addr->addr, sizeof(struct in_addr));
287  *addrlen = sizeof(struct sockaddr_in);
288  ret = 0;
289  }
290 
291  if (ip_addr->family == AF_INET6) {
292  struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr;
293 
294  memset(sin, 0, sizeof(struct sockaddr_in6));
295 #ifdef HAVE_SOCK_SIN6_LEN
296  sin->sin6_len = sizeof(struct sockaddr_in6);
297 #endif
298  sin->sin6_family = ip_addr->family;
299  sin->sin6_port = ntohs(port);
300  sin->sin6_scope_id = 2;
301  memcpy(&sin->sin6_addr, ip_addr->addr, sizeof(struct in6_addr));
302 
303  *addrlen = sizeof(struct sockaddr_in6);
304  ret = 0;
305  }
306 
307  return ret;
308 }
309 
310 /*
311  * Converts an address string string into a totem_ip_address. ip_version enum
312  * defines order.
313  */
314 int totemip_parse(struct totem_ip_address *totemip, const char *addr,
315  enum totem_ip_version_enum ip_version)
316 {
317  struct addrinfo *ainfo;
318  struct addrinfo *ainfo_iter;
319  struct addrinfo *ainfo_ipv4;
320  struct addrinfo *ainfo_ipv6;
321  struct addrinfo *ainfo_final;
322  struct addrinfo ahints;
323  struct sockaddr_in *sa;
324  struct sockaddr_in6 *sa6;
325  int ret;
326  int debug_ip_family;
327  int ai_family;
328 
329  memset(&ahints, 0, sizeof(ahints));
330  ahints.ai_socktype = SOCK_DGRAM;
331  ahints.ai_protocol = IPPROTO_UDP;
332 
333  ai_family = AF_UNSPEC;
334  debug_ip_family = 0;
335 
336  switch (ip_version) {
337  case TOTEM_IP_VERSION_4:
338  ai_family = AF_INET;
339  debug_ip_family = 4;
340  break;
341  case TOTEM_IP_VERSION_6:
342  ai_family = AF_INET6;
343  debug_ip_family = 6;
344  break;
347  /*
348  * ai_family and debug_ip_family are already set correctly
349  */
350  break;
351  }
352 
353  ahints.ai_family = ai_family;
354 
355  ret = getaddrinfo(addr, NULL, &ahints, &ainfo);
356 
357  if (ret == 0 && ai_family == AF_UNSPEC) {
358  ainfo_ipv4 = ainfo_ipv6 = NULL;
359 
360  /*
361  * Walk thru results and store first AF_INET and AF_INET6
362  */
363  for (ainfo_iter = ainfo; ainfo_iter != NULL; ainfo_iter = ainfo_iter->ai_next) {
364  if (ainfo_iter->ai_family == AF_INET && ainfo_ipv4 == NULL) {
365  ainfo_ipv4 = ainfo_iter;
366  }
367 
368  if (ainfo_iter->ai_family == AF_INET6 && ainfo_ipv6 == NULL) {
369  ainfo_ipv6 = ainfo_iter;
370  }
371  }
372 
373  if (ip_version == TOTEM_IP_VERSION_6_4) {
374  if (ainfo_ipv6 != NULL) {
375  ainfo_final = ainfo_ipv6;
376  } else {
377  ainfo_final = ainfo_ipv4;
378  }
379  } else {
380  if (ainfo_ipv4 != NULL) {
381  ainfo_final = ainfo_ipv4;
382  } else {
383  ainfo_final = ainfo_ipv6;
384  }
385  }
386  } else if (ret == 0) {
387  ainfo_final = ainfo;
388  } else {
389  ainfo_final = NULL;
390  }
391 
392  if (ainfo_final == NULL) {
393  if (ret == 0) {
394  freeaddrinfo(ainfo);
395  }
396 
397  if (debug_ip_family == 0) {
398  log_printf(LOGSYS_LEVEL_DEBUG, "totemip_parse: IP address of %s not resolvable",
399  addr);
400  } else {
401  log_printf(LOGSYS_LEVEL_DEBUG, "totemip_parse: IPv%u address of %s not resolvable",
402  debug_ip_family, addr);
403  }
404 
405  return (-1);
406  }
407 
408  totemip->family = ainfo_final->ai_family;
409  if (ainfo_final->ai_family == AF_INET) {
410  sa = (struct sockaddr_in *)ainfo_final->ai_addr;
411  memcpy(totemip->addr, &sa->sin_addr, sizeof(struct in_addr));
412  debug_ip_family = 4;
413  } else {
414  sa6 = (struct sockaddr_in6 *)ainfo_final->ai_addr;
415  memcpy(totemip->addr, &sa6->sin6_addr, sizeof(struct in6_addr));
416  debug_ip_family = 6;
417  }
418 
419  log_printf(LOGSYS_LEVEL_DEBUG, "totemip_parse: IPv%u address of %s resolved as %s",
420  debug_ip_family, addr, totemip_print(totemip));
421 
422  freeaddrinfo(ainfo);
423 
424  return (0);
425 }
426 
427 /* Make a sockaddr_* into a totem_ip_address */
428 int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr,
429  struct totem_ip_address *ip_addr)
430 {
431  int ret = -1;
432 
433  ip_addr->family = saddr->ss_family;
434  ip_addr->nodeid = 0;
435 
436  if (saddr->ss_family == AF_INET) {
437  const struct sockaddr_in *sin = (const struct sockaddr_in *)saddr;
438 
439  memcpy(ip_addr->addr, &sin->sin_addr, sizeof(struct in_addr));
440  ret = 0;
441  }
442 
443  if (saddr->ss_family == AF_INET6) {
444  const struct sockaddr_in6 *sin
445  = (const struct sockaddr_in6 *)saddr;
446 
447  memcpy(ip_addr->addr, &sin->sin6_addr, sizeof(struct in6_addr));
448 
449  ret = 0;
450  }
451  return ret;
452 }
453 
454 int totemip_getifaddrs(struct qb_list_head *addrs)
455 {
456  struct ifaddrs *ifap, *ifa;
457  struct totem_ip_if_address *if_addr;
458 
459  if (getifaddrs(&ifap) != 0)
460  return (-1);
461 
462  qb_list_init(addrs);
463 
464  for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
465  if (ifa->ifa_addr == NULL || ifa->ifa_netmask == NULL)
466  continue ;
467 
468  if ((ifa->ifa_addr->sa_family != AF_INET && ifa->ifa_addr->sa_family != AF_INET6) ||
469  (ifa->ifa_netmask->sa_family != AF_INET && ifa->ifa_netmask->sa_family != AF_INET6 &&
470  ifa->ifa_netmask->sa_family != 0))
471  continue ;
472 
473  if (ifa->ifa_netmask->sa_family == 0) {
474  ifa->ifa_netmask->sa_family = ifa->ifa_addr->sa_family;
475  }
476 
477  if_addr = malloc(sizeof(struct totem_ip_if_address));
478  if (if_addr == NULL) {
479  goto error_free_ifaddrs;
480  }
481 
482  qb_list_init(&if_addr->list);
483 
484  memset(if_addr, 0, sizeof(struct totem_ip_if_address));
485 
486  if_addr->interface_up = ifa->ifa_flags & IFF_UP;
487  if_addr->interface_num = if_nametoindex(ifa->ifa_name);
488  if_addr->name = strdup(ifa->ifa_name);
489  if (if_addr->name == NULL) {
490  goto error_free_addr;
491  }
492 
493  if (totemip_sockaddr_to_totemip_convert((const struct sockaddr_storage *)ifa->ifa_addr,
494  &if_addr->ip_addr) == -1) {
495  goto error_free_addr_name;
496  }
497 
498  if (totemip_sockaddr_to_totemip_convert((const struct sockaddr_storage *)ifa->ifa_netmask,
499  &if_addr->mask_addr) == -1) {
500  goto error_free_addr_name;
501  }
502 
503  qb_list_add_tail(&if_addr->list, addrs);
504  }
505 
506  freeifaddrs(ifap);
507 
508  return (0);
509 
510 error_free_addr_name:
511  free(if_addr->name);
512 
513 error_free_addr:
514  free(if_addr);
515 
516 error_free_ifaddrs:
517  totemip_freeifaddrs(addrs);
518  freeifaddrs(ifap);
519  return (-1);
520 }
521 
522 void totemip_freeifaddrs(struct qb_list_head *addrs)
523 {
524  struct totem_ip_if_address *if_addr;
525  struct qb_list_head *list, *tmp_iter;
526 
527  qb_list_for_each_safe(list, tmp_iter, addrs) {
528  if_addr = qb_list_entry(list, struct totem_ip_if_address, list);
529 
530  free(if_addr->name);
531  qb_list_del(&if_addr->list);
532  free(if_addr);
533  }
534  qb_list_init(addrs);
535 }
536 
538  struct totem_ip_address *boundto,
539  int *interface_up,
540  int *interface_num,
541  int mask_high_bit)
542 {
543  struct qb_list_head addrs;
544  struct qb_list_head *list;
545  struct totem_ip_if_address *if_addr;
546  struct totem_ip_address bn_netaddr, if_netaddr;
547  socklen_t addr_len;
548  socklen_t si;
549  int res = -1;
550  int exact_match_found = 0;
551  int net_match_found = 0;
552 
553  *interface_up = 0;
554  *interface_num = 0;
555 
556  if (totemip_getifaddrs(&addrs) == -1) {
557  return (-1);
558  }
559 
560  qb_list_for_each(list, &addrs) {
561  if_addr = qb_list_entry(list, struct totem_ip_if_address, list);
562 
563  if (bindnet->family != if_addr->ip_addr.family)
564  continue ;
565 
566  addr_len = 0;
567 
568  switch (bindnet->family) {
569  case AF_INET:
570  addr_len = sizeof(struct in_addr);
571  break;
572  case AF_INET6:
573  addr_len = sizeof(struct in6_addr);
574  break;
575  }
576 
577  if (addr_len == 0)
578  continue ;
579 
580  totemip_copy(&bn_netaddr, bindnet);
581  totemip_copy(&if_netaddr, &if_addr->ip_addr);
582 
583  if (totemip_equal(&bn_netaddr, &if_netaddr)) {
584  exact_match_found = 1;
585  }
586 
587  for (si = 0; si < addr_len; si++) {
588  bn_netaddr.addr[si] = bn_netaddr.addr[si] & if_addr->mask_addr.addr[si];
589  if_netaddr.addr[si] = if_netaddr.addr[si] & if_addr->mask_addr.addr[si];
590  }
591 
592  if (exact_match_found || (!net_match_found && totemip_equal(&bn_netaddr, &if_netaddr))) {
593  totemip_copy(boundto, &if_addr->ip_addr);
594  boundto->nodeid = bindnet->nodeid;
595  *interface_up = if_addr->interface_up;
596  *interface_num = if_addr->interface_num;
597 
598  net_match_found = 1;
599  res = 0;
600 
601  if (exact_match_found) {
602  goto finished;
603  }
604  }
605  }
606 
607 finished:
608  totemip_freeifaddrs(&addrs);
609  return (res);
610 }
611 
612 #define TOTEMIP_UDP_HEADER_SIZE 8
613 #define TOTEMIP_IPV4_HEADER_SIZE 20
614 #define TOTEMIP_IPV6_HEADER_SIZE 40
615 
617 {
618  size_t header_size;
619 
620  header_size = 0;
621 
622  switch (family) {
623  case AF_INET:
625  break;
626  case AF_INET6:
628  break;
629  }
630 
631  return (header_size);
632 }
swab32
#define swab32(x)
The swab32 macro.
Definition: swab.h:51
totemip_copy_endian_convert
void totemip_copy_endian_convert(struct totem_ip_address *addr1, const struct totem_ip_address *addr2)
Definition: totemip.c:129
totem_ip_version_enum
totem_ip_version_enum
Definition: totemip.h:70
log_printf
#define log_printf(level, format, args...)
Definition: logsys.h:323
TOTEMIP_IPV4_HEADER_SIZE
#define TOTEMIP_IPV4_HEADER_SIZE
Definition: totemip.c:613
TOTEM_IP_VERSION_6_4
Definition: totemip.h:74
LOGSYS_LEVEL_DEBUG
#define LOGSYS_LEVEL_DEBUG
Definition: logsys.h:76
totemip_localhost
int totemip_localhost(int family, struct totem_ip_address *localhost)
Definition: totemip.c:210
TOTEM_IP_VERSION_4
Definition: totemip.h:71
TOTEM_IP_VERSION_6
Definition: totemip.h:72
totemip_copy
void totemip_copy(struct totem_ip_address *addr1, const struct totem_ip_address *addr2)
Definition: totemip.c:123
TOTEM_IP_VERSION_4_6
Definition: totemip.h:73
totem_ip_if_address::list
struct qb_list_head list
Definition: totemip.h:84
totem_ip_address::nodeid
unsigned int nodeid
Definition: coroapi.h:112
totemip_is_mcast
int32_t totemip_is_mcast(struct totem_ip_address *ip_addr)
Definition: totemip.c:142
swab.h
totemip_localhost_check
int totemip_localhost_check(const struct totem_ip_address *addr)
Definition: totemip.c:233
addr
unsigned char addr[TOTEMIP_ADDRLEN]
Definition: coroapi.h:77
totemip_nosigpipe
#define totemip_nosigpipe(s)
Definition: totemip.h:56
totemip_print
const char * totemip_print(const struct totem_ip_address *addr)
Definition: totemip.c:264
totemip_iface_check
int totemip_iface_check(struct totem_ip_address *bindnet, struct totem_ip_address *boundto, int *interface_up, int *interface_num, int mask_high_bit)
Definition: totemip.c:537
totemip.h
totemip_freeifaddrs
void totemip_freeifaddrs(struct qb_list_head *addrs)
Definition: totemip.c:522
TOTEMIP_ADDRLEN
#define TOTEMIP_ADDRLEN
Definition: coroapi.h:86
totemip_udpip_header_size
size_t totemip_udpip_header_size(int family)
Definition: totemip.c:616
totemip_sa_print
const char * totemip_sa_print(const struct sockaddr *sa)
Definition: totemip.c:242
totemip_totemip_to_sockaddr_convert
int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr, uint16_t port, struct sockaddr_storage *saddr, int *addrlen)
Definition: totemip.c:272
totem_ip_if_address::name
char * name
Definition: totemip.h:83
totemip_getifaddrs
int totemip_getifaddrs(struct qb_list_head *addrs)
Definition: totemip.c:454
totem_ip_if_address::mask_addr
struct totem_ip_address mask_addr
Definition: totemip.h:80
totem_ip_address::family
unsigned short family
Definition: coroapi.h:113
totem_ip_if_address
Definition: totemip.h:77
swab16
#define swab16(x)
The swab16 macro.
Definition: swab.h:39
LOCALHOST_IPV6
#define LOCALHOST_IPV6
Definition: totemip.c:59
family
unsigned short family
Definition: coroapi.h:76
totem_ip_address
The totem_ip_address struct.
Definition: coroapi.h:111
totemip_equal
int totemip_equal(const struct totem_ip_address *addr1, const struct totem_ip_address *addr2)
Definition: totemip.c:72
LOCALHOST_IPV4
#define LOCALHOST_IPV4
Definition: totemip.c:58
totemip_compare
int totemip_compare(const void *a, const void *b)
Definition: totemip.c:158
totem_ip_address::addr
unsigned char addr[TOTEMIP_ADDRLEN]
Definition: coroapi.h:114
TOTEMIP_IPV6_HEADER_SIZE
#define TOTEMIP_IPV6_HEADER_SIZE
Definition: totemip.c:614
totem_ip_if_address::interface_up
int interface_up
Definition: totemip.h:81
totemip_parse
int totemip_parse(struct totem_ip_address *totemip, const char *addr, enum totem_ip_version_enum ip_version)
Definition: totemip.c:314
totemip_sockaddr_to_totemip_convert
int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr, struct totem_ip_address *ip_addr)
Definition: totemip.c:428
totem_ip_if_address::ip_addr
struct totem_ip_address ip_addr
Definition: totemip.h:79
config.h
totem_ip_if_address::interface_num
int interface_num
Definition: totemip.h:82
logsys.h
totemip_sa_equal
int totemip_sa_equal(const struct totem_ip_address *totem_ip, const struct sockaddr *sa)
Definition: totemip.c:95
TOTEMIP_UDP_HEADER_SIZE
#define TOTEMIP_UDP_HEADER_SIZE
Definition: totemip.c:612