Deleted Added
full compact
ifconfig.c (199231) ifconfig.c (199770)
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

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

33 The Regents of the University of California. All rights reserved.\n";
34#endif /* not lint */
35
36#ifndef lint
37#if 0
38static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
39#endif
40static 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

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

33 The Regents of the University of California. All rights reserved.\n";
34#endif /* not lint */
35
36#ifndef lint
37#if 0
38static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
39#endif
40static const char rcsid[] =
41 "$FreeBSD: head/sbin/ifconfig/ifconfig.c 199231 2009-11-12 19:02:10Z delphij $";
41 "$FreeBSD: head/sbin/ifconfig/ifconfig.c 199770 2009-11-25 00:00:57Z will $";
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/ioctl.h>
46#include <sys/socket.h>
47#include <sys/sysctl.h>
48#include <sys/time.h>
49#include <sys/module.h>

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

142main(int argc, char *argv[])
143{
144 int c, all, namesonly, downonly, uponly;
145 const struct afswtch *afp = NULL;
146 int ifindex;
147 struct ifaddrs *ifap, *ifa;
148 struct ifreq paifr;
149 const struct sockaddr_dl *sdl;
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/ioctl.h>
46#include <sys/socket.h>
47#include <sys/sysctl.h>
48#include <sys/time.h>
49#include <sys/module.h>

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

142main(int argc, char *argv[])
143{
144 int c, all, namesonly, downonly, uponly;
145 const struct afswtch *afp = NULL;
146 int ifindex;
147 struct ifaddrs *ifap, *ifa;
148 struct ifreq paifr;
149 const struct sockaddr_dl *sdl;
150 char options[1024], *cp;
150 char options[1024], *cp, *namecp = NULL;
151 const char *ifname;
152 struct option *p;
153 size_t iflen;
154
155 all = downonly = uponly = namesonly = noload = verbose = 0;
156
157 /* Parse leading line options */
158 strlcpy(options, "adklmnuv", sizeof(options));

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

289 }
290
291 if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0)
292 continue;
293 if (ifa->ifa_addr->sa_family == AF_LINK)
294 sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
295 else
296 sdl = NULL;
151 const char *ifname;
152 struct option *p;
153 size_t iflen;
154
155 all = downonly = uponly = namesonly = noload = verbose = 0;
156
157 /* Parse leading line options */
158 strlcpy(options, "adklmnuv", sizeof(options));

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

289 }
290
291 if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0)
292 continue;
293 if (ifa->ifa_addr->sa_family == AF_LINK)
294 sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
295 else
296 sdl = NULL;
297 if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0)
297 if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0 && !namesonly)
298 continue;
299 iflen = strlcpy(name, ifa->ifa_name, sizeof(name));
300 if (iflen >= sizeof(name)) {
301 warnx("%s: interface name too long, skipping",
302 ifa->ifa_name);
303 continue;
304 }
305 cp = ifa->ifa_name;
306
307 if (downonly && (ifa->ifa_flags & IFF_UP) != 0)
308 continue;
309 if (uponly && (ifa->ifa_flags & IFF_UP) == 0)
310 continue;
298 continue;
299 iflen = strlcpy(name, ifa->ifa_name, sizeof(name));
300 if (iflen >= sizeof(name)) {
301 warnx("%s: interface name too long, skipping",
302 ifa->ifa_name);
303 continue;
304 }
305 cp = ifa->ifa_name;
306
307 if (downonly && (ifa->ifa_flags & IFF_UP) != 0)
308 continue;
309 if (uponly && (ifa->ifa_flags & IFF_UP) == 0)
310 continue;
311 ifindex++;
312 /*
313 * Are we just listing the interfaces?
314 */
315 if (namesonly) {
311 /*
312 * Are we just listing the interfaces?
313 */
314 if (namesonly) {
315 if (namecp == cp)
316 continue;
317 if (afp != NULL) {
318 /* special case for "ether" address family */
319 if (!strcmp(afp->af_name, "ether")) {
320 if (sdl == NULL ||
321 sdl->sdl_type != IFT_ETHER ||
322 sdl->sdl_alen != ETHER_ADDR_LEN)
323 continue;
324 } else {
325 if (ifa->ifa_addr->sa_family != afp->af_af)
326 continue;
327 }
328 }
329 namecp = cp;
330 ifindex++;
316 if (ifindex > 1)
317 printf(" ");
318 fputs(name, stdout);
319 continue;
320 }
331 if (ifindex > 1)
332 printf(" ");
333 fputs(name, stdout);
334 continue;
335 }
336 ifindex++;
321
322 if (argc > 0)
323 ifconfig(argc, argv, 0, afp);
324 else
325 status(afp, sdl, ifa);
326 }
327 if (namesonly)
328 printf("\n");

--- 777 unchanged lines hidden ---
337
338 if (argc > 0)
339 ifconfig(argc, argv, 0, afp);
340 else
341 status(afp, sdl, ifa);
342 }
343 if (namesonly)
344 printf("\n");

--- 777 unchanged lines hidden ---