summaryrefslogtreecommitdiff
path: root/mcon/U/d_getifaddrs.U
blob: eb12d88a6e911b0d284b0e31abb97e5944555ab8 (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
50
51
52
53
54
?RCS: $Id: d_getifaddrs.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 2006, Christian Biere
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?MAKE:d_getifaddrs: Trylink cat i_netif
?MAKE:	-pick add $@ %<
?S:d_getifaddrs:
?S:	This variable conditionally defines the HAS_GETIFADDRS symbol, which
?S:	indicates to the C program that getifaddrs() support is available.
?S:.
?C:HAS_GETIFADDRS:
?C:	This symbol is defined when getifaddrs() and freeifaddrs() can be used.
?C:.
?H:#$d_getifaddrs HAS_GETIFADDRS
?H:.
?LINT: set d_getifaddrs
: can we use getifaddrs?
$cat >try.c <<EOC
#include <sys/types.h>
#include <sys/socket.h>
#$i_netif I_NET_IF
#ifdef I_NET_IF
#include <net/if.h>
#endif
#include <ifaddrs.h>
int main(void)
{
  struct ifaddrs *ifa0, *ifa;
  static int ret;

  ret |= getifaddrs(&ifa0);

  for (ifa = ifa0; ifa; ifa = ifa->ifa_next) {
    (void) ifa->ifa_flags;
    (void) ifa->ifa_addr;
    (void) ifa->ifa_addr->sa_family;
    (void) ifa->ifa_netmask;
    if ((IFF_LOOPBACK | IFF_UP | IFF_RUNNING) & ifa->ifa_flags)
	break;
  }
  freeifaddrs(ifa0);
  return 0;
}
EOC
cyn=getifaddrs
set d_getifaddrs
eval $trylink