Deleted Added
full compact
ifconfig.c (228571) ifconfig.c (231642)
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 228571 2011-12-16 12:16:56Z glebius $";
41 "$FreeBSD: head/sbin/ifconfig/ifconfig.c 231642 2012-02-14 07:14:42Z rmh $";
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/ioctl.h>
46#include <sys/socket.h>
47#include <sys/time.h>
48#include <sys/module.h>
49#include <sys/linker.h>

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

61#include <arpa/inet.h>
62#include <netdb.h>
63
64#include <ifaddrs.h>
65#include <ctype.h>
66#include <err.h>
67#include <errno.h>
68#include <fcntl.h>
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/ioctl.h>
46#include <sys/socket.h>
47#include <sys/time.h>
48#include <sys/module.h>
49#include <sys/linker.h>

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

61#include <arpa/inet.h>
62#include <netdb.h>
63
64#include <ifaddrs.h>
65#include <ctype.h>
66#include <err.h>
67#include <errno.h>
68#include <fcntl.h>
69#ifdef JAIL
69#include <jail.h>
70#include <jail.h>
71#endif
70#include <stdio.h>
71#include <stdlib.h>
72#include <string.h>
73#include <unistd.h>
74
75#include "ifconfig.h"
76
77/*

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

250 strcmp(argv[0], "plumb") == 0)) {
251 iflen = strlcpy(name, ifname, sizeof(name));
252 if (iflen >= sizeof(name))
253 errx(1, "%s: cloning name too long",
254 ifname);
255 ifconfig(argc, argv, 1, NULL);
256 exit(0);
257 }
72#include <stdio.h>
73#include <stdlib.h>
74#include <string.h>
75#include <unistd.h>
76
77#include "ifconfig.h"
78
79/*

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

252 strcmp(argv[0], "plumb") == 0)) {
253 iflen = strlcpy(name, ifname, sizeof(name));
254 if (iflen >= sizeof(name))
255 errx(1, "%s: cloning name too long",
256 ifname);
257 ifconfig(argc, argv, 1, NULL);
258 exit(0);
259 }
260#ifdef JAIL
258 /*
259 * NOTE: We have to special-case the `-vnet' command
260 * right here as we would otherwise fail when trying
261 * to find the interface as it lives in another vnet.
262 */
263 if (argc > 0 && (strcmp(argv[0], "-vnet") == 0)) {
264 iflen = strlcpy(name, ifname, sizeof(name));
265 if (iflen >= sizeof(name))
266 errx(1, "%s: interface name too long",
267 ifname);
268 ifconfig(argc, argv, 0, NULL);
269 exit(0);
270 }
261 /*
262 * NOTE: We have to special-case the `-vnet' command
263 * right here as we would otherwise fail when trying
264 * to find the interface as it lives in another vnet.
265 */
266 if (argc > 0 && (strcmp(argv[0], "-vnet") == 0)) {
267 iflen = strlcpy(name, ifname, sizeof(name));
268 if (iflen >= sizeof(name))
269 errx(1, "%s: interface name too long",
270 ifname);
271 ifconfig(argc, argv, 0, NULL);
272 exit(0);
273 }
274#endif
271 errx(1, "interface %s does not exist", ifname);
272 }
273 }
274
275 /* Check for address family */
276 if (argc > 0) {
277 afp = af_getbyname(*argv);
278 if (afp != NULL)

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

683static void
684deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
685{
686
687 if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0)
688 err(1, "SIOCDIFPHYADDR");
689}
690
275 errx(1, "interface %s does not exist", ifname);
276 }
277 }
278
279 /* Check for address family */
280 if (argc > 0) {
281 afp = af_getbyname(*argv);
282 if (afp != NULL)

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

687static void
688deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
689{
690
691 if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0)
692 err(1, "SIOCDIFPHYADDR");
693}
694
695#ifdef JAIL
691static void
692setifvnet(const char *jname, int dummy __unused, int s,
693 const struct afswtch *afp)
694{
695 struct ifreq my_ifr;
696
697 memcpy(&my_ifr, &ifr, sizeof(my_ifr));
698 my_ifr.ifr_jid = jail_getid(jname);

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

710
711 memcpy(&my_ifr, &ifr, sizeof(my_ifr));
712 my_ifr.ifr_jid = jail_getid(jname);
713 if (my_ifr.ifr_jid < 0)
714 errx(1, "%s", jail_errmsg);
715 if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0)
716 err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name);
717}
696static void
697setifvnet(const char *jname, int dummy __unused, int s,
698 const struct afswtch *afp)
699{
700 struct ifreq my_ifr;
701
702 memcpy(&my_ifr, &ifr, sizeof(my_ifr));
703 my_ifr.ifr_jid = jail_getid(jname);

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

715
716 memcpy(&my_ifr, &ifr, sizeof(my_ifr));
717 my_ifr.ifr_jid = jail_getid(jname);
718 if (my_ifr.ifr_jid < 0)
719 errx(1, "%s", jail_errmsg);
720 if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0)
721 err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name);
722}
723#endif
718
719static void
720setifnetmask(const char *addr, int dummy __unused, int s,
721 const struct afswtch *afp)
722{
723 if (afp->af_getaddr != NULL) {
724 setmask++;
725 afp->af_getaddr(addr, MASK);

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

1168#endif
1169 DEF_CMD_ARG("netmask", setifnetmask),
1170 DEF_CMD_ARG("metric", setifmetric),
1171 DEF_CMD_ARG("broadcast", setifbroadaddr),
1172 DEF_CMD_ARG("ipdst", setifipdst),
1173 DEF_CMD_ARG2("tunnel", settunnel),
1174 DEF_CMD("-tunnel", 0, deletetunnel),
1175 DEF_CMD("deletetunnel", 0, deletetunnel),
724
725static void
726setifnetmask(const char *addr, int dummy __unused, int s,
727 const struct afswtch *afp)
728{
729 if (afp->af_getaddr != NULL) {
730 setmask++;
731 afp->af_getaddr(addr, MASK);

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

1174#endif
1175 DEF_CMD_ARG("netmask", setifnetmask),
1176 DEF_CMD_ARG("metric", setifmetric),
1177 DEF_CMD_ARG("broadcast", setifbroadaddr),
1178 DEF_CMD_ARG("ipdst", setifipdst),
1179 DEF_CMD_ARG2("tunnel", settunnel),
1180 DEF_CMD("-tunnel", 0, deletetunnel),
1181 DEF_CMD("deletetunnel", 0, deletetunnel),
1182#ifdef JAIL
1176 DEF_CMD_ARG("vnet", setifvnet),
1177 DEF_CMD_ARG("-vnet", setifrvnet),
1183 DEF_CMD_ARG("vnet", setifvnet),
1184 DEF_CMD_ARG("-vnet", setifrvnet),
1185#endif
1178 DEF_CMD("link0", IFF_LINK0, setifflags),
1179 DEF_CMD("-link0", -IFF_LINK0, setifflags),
1180 DEF_CMD("link1", IFF_LINK1, setifflags),
1181 DEF_CMD("-link1", -IFF_LINK1, setifflags),
1182 DEF_CMD("link2", IFF_LINK2, setifflags),
1183 DEF_CMD("-link2", -IFF_LINK2, setifflags),
1184 DEF_CMD("monitor", IFF_MONITOR, setifflags),
1185 DEF_CMD("-monitor", -IFF_MONITOR, setifflags),

--- 39 unchanged lines hidden ---
1186 DEF_CMD("link0", IFF_LINK0, setifflags),
1187 DEF_CMD("-link0", -IFF_LINK0, setifflags),
1188 DEF_CMD("link1", IFF_LINK1, setifflags),
1189 DEF_CMD("-link1", -IFF_LINK1, setifflags),
1190 DEF_CMD("link2", IFF_LINK2, setifflags),
1191 DEF_CMD("-link2", -IFF_LINK2, setifflags),
1192 DEF_CMD("monitor", IFF_MONITOR, setifflags),
1193 DEF_CMD("-monitor", -IFF_MONITOR, setifflags),

--- 39 unchanged lines hidden ---