Deleted Added
sdiff udiff text old ( 147437 ) new ( 166956 )
full compact
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef lint
31static const char rcsid[] =
32 "$FreeBSD: head/sbin/ifconfig/af_inet.c 166956 2007-02-24 23:55:46Z sam $";
33#endif /* not lint */
34
35#include <sys/types.h>
36#include <sys/ioctl.h>
37#include <sys/socket.h>
38#include <net/if.h>
39
40#include <err.h>
41#include <stdio.h>
42#include <stdlib.h>
43#include <string.h>
44#include <unistd.h>
45#include <ifaddrs.h>
46
47#include <netinet/in.h>
48#include <net/if_var.h> /* for struct ifaddr */
49#include <netinet/in_var.h>
50#include <arpa/inet.h>
51#include <netdb.h>
52
53#include "ifconfig.h"
54
55static struct ifaliasreq in_addreq;
56static struct ifreq in_ridreq;
57
58static void
59in_status(int s __unused, const struct ifaddrs *ifa)
60{
61 struct sockaddr_in *sin, null_sin;
62
63 memset(&null_sin, 0, sizeof(null_sin));
64
65 sin = (struct sockaddr_in *)ifa->ifa_addr;
66 if (sin == NULL)
67 return;
68
69 printf("\tinet %s ", inet_ntoa(sin->sin_addr));
70
71 if (ifa->ifa_flags & IFF_POINTOPOINT) {
72 sin = (struct sockaddr_in *)ifa->ifa_dstaddr;
73 if (sin == NULL)
74 sin = &null_sin;
75 printf("--> %s ", inet_ntoa(sin->sin_addr));
76 }
77
78 sin = (struct sockaddr_in *)ifa->ifa_netmask;
79 if (sin == NULL)
80 sin = &null_sin;
81 printf("netmask 0x%lx ", (unsigned long)ntohl(sin->sin_addr.s_addr));
82
83 if (ifa->ifa_flags & IFF_BROADCAST) {
84 sin = (struct sockaddr_in *)ifa->ifa_broadaddr;
85 if (sin != NULL && sin->sin_addr.s_addr != 0)
86 printf("broadcast %s", inet_ntoa(sin->sin_addr));
87 }
88 putchar('\n');
89}
90
91#define SIN(x) ((struct sockaddr_in *) &(x))
92static struct sockaddr_in *sintab[] = {
93 SIN(in_ridreq.ifr_addr), SIN(in_addreq.ifra_addr),

--- 107 unchanged lines hidden ---