4 * Lars Fenneberg <lf@elemental.net>
6 * This software is Copyright 1996,1997 by the above mentioned author(s),
9 * The license which is distributed with this software in the file COPYRIGHT
10 * applies to this software. If your distribution is missing this file, you
11 * may request it from <pekkas@netcore.fi>.
21 check_device(struct Interface
*iface
)
25 strncpy(ifr
.ifr_name
, iface
->Name
, IFNAMSIZ
-1);
26 ifr
.ifr_name
[IFNAMSIZ
-1] = '\0';
28 if (ioctl(sock
, SIOCGIFFLAGS
, &ifr
) < 0)
30 if (!iface
->IgnoreIfMissing
)
31 flog(LOG_ERR
, "ioctl(SIOCGIFFLAGS) failed for %s: %s",
32 iface
->Name
, strerror(errno
));
36 if (!(ifr
.ifr_flags
& IFF_UP
))
38 if (!iface
->IgnoreIfMissing
)
39 flog(LOG_ERR
, "interface %s is not UP", iface
->Name
);
42 if (!(ifr
.ifr_flags
& IFF_RUNNING
))
44 if (!iface
->IgnoreIfMissing
)
45 flog(LOG_ERR
, "interface %s is not RUNNING", iface
->Name
);
49 if (! iface
->UnicastOnly
&& !(ifr
.ifr_flags
& IFF_MULTICAST
))
51 flog(LOG_WARNING
, "interface %s does not support multicast",
53 flog(LOG_WARNING
, " do you need to add the UnicastOnly flag?");
56 if (! iface
->UnicastOnly
&& !(ifr
.ifr_flags
& IFF_BROADCAST
))
58 flog(LOG_WARNING
, "interface %s does not support broadcast",
60 flog(LOG_WARNING
, " do you need to add the UnicastOnly flag?");
67 get_v4addr(const char *ifn
, unsigned int *dst
)
70 struct sockaddr_in
*addr
;
73 if( ( fd
= socket(AF_INET
,SOCK_DGRAM
,0) ) < 0 )
75 flog(LOG_ERR
, "create socket for IPv4 ioctl failed for %s: %s",
76 ifn
, strerror(errno
));
80 memset(&ifr
, 0, sizeof(ifr
));
81 strncpy(ifr
.ifr_name
, ifn
, IFNAMSIZ
-1);
82 ifr
.ifr_name
[IFNAMSIZ
-1] = '\0';
83 ifr
.ifr_addr
.sa_family
= AF_INET
;
85 if (ioctl(fd
, SIOCGIFADDR
, &ifr
) < 0)
87 flog(LOG_ERR
, "ioctl(SIOCGIFADDR) failed for %s: %s",
88 ifn
, strerror(errno
));
93 addr
= (struct sockaddr_in
*)(&ifr
.ifr_addr
);
95 dlog(LOG_DEBUG
, 3, "IPv4 address for %s is %s", ifn
,
96 inet_ntoa( addr
->sin_addr
) );
98 *dst
= addr
->sin_addr
.s_addr
;