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

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

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

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

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
43#endif
44static const char rcsid[] =
45 "$Id: ifconfig.c,v 1.37 1998/07/06 19:54:39 bde Exp $";
45 "$Id: ifconfig.c,v 1.38 1998/08/07 06:36:53 phk Exp $";
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/ioctl.h>
50#include <sys/socket.h>
51#include <sys/sysctl.h>
52#include <sys/time.h>
53

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

161 { "-link1", -IFF_LINK1, setifflags },
162 { "link2", IFF_LINK2, setifflags },
163 { "-link2", -IFF_LINK2, setifflags },
164#ifdef USE_IF_MEDIA
165 { "media", NEXTARG, setmedia },
166 { "mediaopt", NEXTARG, setmediaopt },
167 { "-mediaopt", NEXTARG, unsetmediaopt },
168#endif
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/ioctl.h>
50#include <sys/socket.h>
51#include <sys/sysctl.h>
52#include <sys/time.h>
53

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

161 { "-link1", -IFF_LINK1, setifflags },
162 { "link2", IFF_LINK2, setifflags },
163 { "-link2", -IFF_LINK2, setifflags },
164#ifdef USE_IF_MEDIA
165 { "media", NEXTARG, setmedia },
166 { "mediaopt", NEXTARG, setmediaopt },
167 { "-mediaopt", NEXTARG, unsetmediaopt },
168#endif
169#ifdef USE_VLANS
170 { "vlan", NEXTARG, setvlantag },
171 { "vlandev", NEXTARG, setvlandev },
172 { "-vlandev", NEXTARG, unsetvlandev },
173#endif
169 { "normal", -IFF_LINK0, setifflags },
170 { "compress", IFF_LINK0, setifflags },
171 { "noicmp", IFF_LINK1, setifflags },
172 { "mtu", NEXTARG, setifmtu },
173 { 0, 0, setifaddr },
174 { 0, 0, setifdstaddr },
175};
176

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

212 { "ns", AF_NS, xns_status, xns_getaddr,
213 SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
214#endif
215 { "ether", AF_INET, ether_status, NULL }, /* XXX not real!! */
216#if 0 /* XXX conflicts with the media command */
217#ifdef USE_IF_MEDIA
218 { "media", AF_INET, media_status, NULL }, /* XXX not real!! */
219#endif
174 { "normal", -IFF_LINK0, setifflags },
175 { "compress", IFF_LINK0, setifflags },
176 { "noicmp", IFF_LINK1, setifflags },
177 { "mtu", NEXTARG, setifmtu },
178 { 0, 0, setifaddr },
179 { 0, 0, setifdstaddr },
180};
181

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

217 { "ns", AF_NS, xns_status, xns_getaddr,
218 SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
219#endif
220 { "ether", AF_INET, ether_status, NULL }, /* XXX not real!! */
221#if 0 /* XXX conflicts with the media command */
222#ifdef USE_IF_MEDIA
223 { "media", AF_INET, media_status, NULL }, /* XXX not real!! */
224#endif
225#ifdef USE_VLANS
226 { "vlan", AF_INET, media_status, NULL }, /* XXX not real!! */
220#endif
227#endif
228#endif
221 { 0, 0, 0, 0 }
222};
223
224/*
225 * Expand the compacted form of addresses as returned via the
226 * configuration read via sysctl().
227 */
228

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

627 const char *addr;
628 int param __unused;
629 int s;
630 const struct afswtch *afp;
631{
632 (*afp->af_getaddr)(addr, DSTADDR);
633}
634
229 { 0, 0, 0, 0 }
230};
231
232/*
233 * Expand the compacted form of addresses as returned via the
234 * configuration read via sysctl().
235 */
236

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

635 const char *addr;
636 int param __unused;
637 int s;
638 const struct afswtch *afp;
639{
640 (*afp->af_getaddr)(addr, DSTADDR);
641}
642
643/*
644 * Note: doing an SIOCIGIFFLAGS scribbles on the union portion
645 * of the ifreq structure, which may confuse other parts of ifconfig.
646 * Make a private copy so we can avoid that.
647 */
635void
636setifflags(vname, value, s, afp)
637 const char *vname;
638 int value;
639 int s;
640 const struct afswtch *afp;
641{
648void
649setifflags(vname, value, s, afp)
650 const char *vname;
651 int value;
652 int s;
653 const struct afswtch *afp;
654{
642 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
655 struct ifreq my_ifr;
656
657 bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq));
658
659 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
643 Perror("ioctl (SIOCGIFFLAGS)");
644 exit(1);
645 }
660 Perror("ioctl (SIOCGIFFLAGS)");
661 exit(1);
662 }
646 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
647 flags = ifr.ifr_flags;
663 strncpy(my_ifr.ifr_name, name, sizeof (my_ifr.ifr_name));
664 flags = my_ifr.ifr_flags;
648
649 if (value < 0) {
650 value = -value;
651 flags &= ~value;
652 } else
653 flags |= value;
665
666 if (value < 0) {
667 value = -value;
668 flags &= ~value;
669 } else
670 flags |= value;
654 ifr.ifr_flags = flags;
655 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0)
671 my_ifr.ifr_flags = flags;
672 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
656 Perror(vname);
657}
658
659void
660setifmetric(val, dummy, s, afp)
661 const char *val;
662 int dummy __unused;
663 int s;

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

748 rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
749 &info);
750
751 if (!allfamilies) {
752 if (afp->af_af == info.rti_info[RTAX_IFA]->sa_family &&
753#ifdef USE_IF_MEDIA
754 afp->af_status != media_status &&
755#endif
673 Perror(vname);
674}
675
676void
677setifmetric(val, dummy, s, afp)
678 const char *val;
679 int dummy __unused;
680 int s;

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

765 rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
766 &info);
767
768 if (!allfamilies) {
769 if (afp->af_af == info.rti_info[RTAX_IFA]->sa_family &&
770#ifdef USE_IF_MEDIA
771 afp->af_status != media_status &&
772#endif
773#ifdef USE_VLANS
774 afp->af_status != vlan_status &&
775#endif
756 afp->af_status != ether_status) {
757 p = afp;
758 (*p->af_status)(s, &info);
759 }
760 } else for (p = afs; p->af_name; p++) {
761 if (p->af_af == info.rti_info[RTAX_IFA]->sa_family &&
762#ifdef USE_IF_MEDIA
763 p->af_status != media_status &&
764#endif
776 afp->af_status != ether_status) {
777 p = afp;
778 (*p->af_status)(s, &info);
779 }
780 } else for (p = afs; p->af_name; p++) {
781 if (p->af_af == info.rti_info[RTAX_IFA]->sa_family &&
782#ifdef USE_IF_MEDIA
783 p->af_status != media_status &&
784#endif
785#ifdef USE_VLANS
786 p->af_status != vlan_status &&
787#endif
765 p->af_status != ether_status)
766 (*p->af_status)(s, &info);
767 }
768 addrcount--;
769 ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen);
770 }
771 if (allfamilies || afp->af_status == ether_status)
772 ether_status(s, (struct rt_addrinfo *)sdl);
773#ifdef USE_IF_MEDIA
774 if (allfamilies || afp->af_status == media_status)
775 media_status(s, NULL);
776#endif
788 p->af_status != ether_status)
789 (*p->af_status)(s, &info);
790 }
791 addrcount--;
792 ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen);
793 }
794 if (allfamilies || afp->af_status == ether_status)
795 ether_status(s, (struct rt_addrinfo *)sdl);
796#ifdef USE_IF_MEDIA
797 if (allfamilies || afp->af_status == media_status)
798 media_status(s, NULL);
799#endif
800#ifdef USE_VLANS
801 if (allfamilies || afp->af_status == vlan_status)
802 vlan_status(s, NULL);
803#endif
777 if (!allfamilies && !p && afp->af_status != media_status &&
804 if (!allfamilies && !p && afp->af_status != media_status &&
778 afp->af_status != ether_status)
805 afp->af_status != ether_status && afp->af_status != vlan_status)
779 warnx("%s has no %s interface address!", name, afp->af_name);
780
781 close(s);
782 return;
783}
784
785void
786in_status(s, info)

--- 328 unchanged lines hidden ---
806 warnx("%s has no %s interface address!", name, afp->af_name);
807
808 close(s);
809 return;
810}
811
812void
813in_status(s, info)

--- 328 unchanged lines hidden ---