ifgroup.c (256281) | ifgroup.c (262556) |
---|---|
1/*- 2 * Copyright (c) 2006 Max Laier. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 11 unchanged lines hidden (view full) --- 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#ifndef lint 27static const char rcsid[] = | 1/*- 2 * Copyright (c) 2006 Max Laier. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 11 unchanged lines hidden (view full) --- 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#ifndef lint 27static const char rcsid[] = |
28 "$FreeBSD: stable/10/sbin/ifconfig/ifgroup.c 189864 2009-03-15 22:33:18Z jamie $"; | 28 "$FreeBSD: stable/10/sbin/ifconfig/ifgroup.c 262556 2014-02-27 13:08:43Z des $"; |
29#endif /* not lint */ 30 31#include <sys/types.h> 32#include <sys/ioctl.h> 33#include <sys/socket.h> 34#include <net/if.h> 35 36#include <ctype.h> --- 15 unchanged lines hidden (view full) --- 52 memset(&ifgr, 0, sizeof(ifgr)); 53 strlcpy(ifgr.ifgr_name, name, IFNAMSIZ); 54 55 if (group_name[0] && isdigit(group_name[strlen(group_name) - 1])) 56 errx(1, "setifgroup: group names may not end in a digit"); 57 58 if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ) 59 errx(1, "setifgroup: group name too long"); | 29#endif /* not lint */ 30 31#include <sys/types.h> 32#include <sys/ioctl.h> 33#include <sys/socket.h> 34#include <net/if.h> 35 36#include <ctype.h> --- 15 unchanged lines hidden (view full) --- 52 memset(&ifgr, 0, sizeof(ifgr)); 53 strlcpy(ifgr.ifgr_name, name, IFNAMSIZ); 54 55 if (group_name[0] && isdigit(group_name[strlen(group_name) - 1])) 56 errx(1, "setifgroup: group names may not end in a digit"); 57 58 if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ) 59 errx(1, "setifgroup: group name too long"); |
60 if (ioctl(s, SIOCAIFGROUP, (caddr_t)&ifgr) == -1) | 60 if (ioctl(s, SIOCAIFGROUP, (caddr_t)&ifgr) == -1 && errno != EEXIST) |
61 err(1," SIOCAIFGROUP"); 62} 63 64/* ARGSUSED */ 65static void 66unsetifgroup(const char *group_name, int d, int s, const struct afswtch *rafp) 67{ 68 struct ifgroupreq ifgr; 69 70 memset(&ifgr, 0, sizeof(ifgr)); 71 strlcpy(ifgr.ifgr_name, name, IFNAMSIZ); 72 73 if (group_name[0] && isdigit(group_name[strlen(group_name) - 1])) 74 errx(1, "unsetifgroup: group names may not end in a digit"); 75 76 if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ) 77 errx(1, "unsetifgroup: group name too long"); | 61 err(1," SIOCAIFGROUP"); 62} 63 64/* ARGSUSED */ 65static void 66unsetifgroup(const char *group_name, int d, int s, const struct afswtch *rafp) 67{ 68 struct ifgroupreq ifgr; 69 70 memset(&ifgr, 0, sizeof(ifgr)); 71 strlcpy(ifgr.ifgr_name, name, IFNAMSIZ); 72 73 if (group_name[0] && isdigit(group_name[strlen(group_name) - 1])) 74 errx(1, "unsetifgroup: group names may not end in a digit"); 75 76 if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ) 77 errx(1, "unsetifgroup: group name too long"); |
78 if (ioctl(s, SIOCDIFGROUP, (caddr_t)&ifgr) == -1) | 78 if (ioctl(s, SIOCDIFGROUP, (caddr_t)&ifgr) == -1 && errno != ENOENT) |
79 err(1, "SIOCDIFGROUP"); 80} 81 82static void 83getifgroups(int s) 84{ 85 int len, cnt; 86 struct ifgroupreq ifgr; --- 100 unchanged lines hidden --- | 79 err(1, "SIOCDIFGROUP"); 80} 81 82static void 83getifgroups(int s) 84{ 85 int len, cnt; 86 struct ifgroupreq ifgr; --- 100 unchanged lines hidden --- |