Deleted Added
full compact
af_inet.c (147437) af_inet.c (166956)
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[] =
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 147437 2005-06-16 19:37:09Z ume $";
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>
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#include <net/route.h> /* for RTX_IFA */
40
41#include <err.h>
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45#include <unistd.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
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 rt_addrinfo * info)
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
60{
61 struct sockaddr_in *sin, null_sin;
62
63 memset(&null_sin, 0, sizeof(null_sin));
64
65 sin = (struct sockaddr_in *)info->rti_info[RTAX_IFA];
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
66 if (sin == NULL)
67 return;
68
69 printf("\tinet %s ", inet_ntoa(sin->sin_addr));
70
71 if (flags & IFF_POINTOPOINT) {
72 /* note RTAX_BRD overlap with IFF_BROADCAST */
73 sin = (struct sockaddr_in *)info->rti_info[RTAX_BRD];
74 if (!sin)
71 if (ifa->ifa_flags & IFF_POINTOPOINT) {
72 sin = (struct sockaddr_in *)ifa->ifa_dstaddr;
73 if (sin == NULL)
75 sin = &null_sin;
76 printf("--> %s ", inet_ntoa(sin->sin_addr));
77 }
78
74 sin = &null_sin;
75 printf("--> %s ", inet_ntoa(sin->sin_addr));
76 }
77
79 sin = (struct sockaddr_in *)info->rti_info[RTAX_NETMASK];
80 if (!sin)
78 sin = (struct sockaddr_in *)ifa->ifa_netmask;
79 if (sin == NULL)
81 sin = &null_sin;
82 printf("netmask 0x%lx ", (unsigned long)ntohl(sin->sin_addr.s_addr));
83
80 sin = &null_sin;
81 printf("netmask 0x%lx ", (unsigned long)ntohl(sin->sin_addr.s_addr));
82
84 if (flags & IFF_BROADCAST) {
85 /* note RTAX_BRD overlap with IFF_POINTOPOINT */
86 sin = (struct sockaddr_in *)info->rti_info[RTAX_BRD];
87 if (sin && sin->sin_addr.s_addr != 0)
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)
88 printf("broadcast %s", inet_ntoa(sin->sin_addr));
89 }
90 putchar('\n');
91}
92
93#define SIN(x) ((struct sockaddr_in *) &(x))
94static struct sockaddr_in *sintab[] = {
95 SIN(in_ridreq.ifr_addr), SIN(in_addreq.ifra_addr),

--- 107 unchanged lines hidden ---
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 ---