Deleted Added
full compact
ifvlan.c (95005) ifvlan.c (138593)
1/*
2 * Copyright (c) 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

51#include <unistd.h>
52#include <err.h>
53#include <errno.h>
54
55#include "ifconfig.h"
56
57#ifndef lint
58static const char rcsid[] =
1/*
2 * Copyright (c) 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

51#include <unistd.h>
52#include <err.h>
53#include <errno.h>
54
55#include "ifconfig.h"
56
57#ifndef lint
58static const char rcsid[] =
59 "$FreeBSD: head/sbin/ifconfig/ifvlan.c 95005 2002-04-18 17:14:09Z imp $";
59 "$FreeBSD: head/sbin/ifconfig/ifvlan.c 138593 2004-12-08 19:18:07Z sam $";
60#endif
61static int __tag = 0;
62static int __have_tag = 0;
63
60#endif
61static int __tag = 0;
62static int __have_tag = 0;
63
64void
65vlan_status(int s, struct rt_addrinfo *info __unused)
64static void
65vlan_status(int s, const struct rt_addrinfo *info __unused)
66{
67 struct vlanreq vreq;
68
69 bzero((char *)&vreq, sizeof(struct vlanreq));
70 ifr.ifr_data = (caddr_t)&vreq;
71
72 if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
73 return;
74
75 printf("\tvlan: %d parent interface: %s\n",
76 vreq.vlr_tag, vreq.vlr_parent[0] == '\0' ?
77 "<none>" : vreq.vlr_parent);
78
79 return;
80}
81
66{
67 struct vlanreq vreq;
68
69 bzero((char *)&vreq, sizeof(struct vlanreq));
70 ifr.ifr_data = (caddr_t)&vreq;
71
72 if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
73 return;
74
75 printf("\tvlan: %d parent interface: %s\n",
76 vreq.vlr_tag, vreq.vlr_parent[0] == '\0' ?
77 "<none>" : vreq.vlr_parent);
78
79 return;
80}
81
82void
82static void
83setvlantag(const char *val, int d, int s, const struct afswtch *afp)
84{
85 u_int16_t tag;
86 struct vlanreq vreq;
87
88 __tag = tag = atoi(val);
89 __have_tag = 1;
90

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

97 vreq.vlr_tag = tag;
98
99 if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
100 err(1, "SIOCSETVLAN");
101
102 return;
103}
104
83setvlantag(const char *val, int d, int s, const struct afswtch *afp)
84{
85 u_int16_t tag;
86 struct vlanreq vreq;
87
88 __tag = tag = atoi(val);
89 __have_tag = 1;
90

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

97 vreq.vlr_tag = tag;
98
99 if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
100 err(1, "SIOCSETVLAN");
101
102 return;
103}
104
105void
105static void
106setvlandev(const char *val, int d, int s, const struct afswtch *afp)
107{
108 struct vlanreq vreq;
109
110 if (!__have_tag)
111 errx(1, "must specify both vlan tag and device");
112
113 bzero((char *)&vreq, sizeof(struct vlanreq));

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

120 vreq.vlr_tag = __tag;
121
122 if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
123 err(1, "SIOCSETVLAN");
124
125 return;
126}
127
106setvlandev(const char *val, int d, int s, const struct afswtch *afp)
107{
108 struct vlanreq vreq;
109
110 if (!__have_tag)
111 errx(1, "must specify both vlan tag and device");
112
113 bzero((char *)&vreq, sizeof(struct vlanreq));

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

120 vreq.vlr_tag = __tag;
121
122 if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
123 err(1, "SIOCSETVLAN");
124
125 return;
126}
127
128void
128static void
129unsetvlandev(const char *val, int d, int s, const struct afswtch *afp)
130{
131 struct vlanreq vreq;
132
133 bzero((char *)&vreq, sizeof(struct vlanreq));
134 ifr.ifr_data = (caddr_t)&vreq;
135
136 if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
137 err(1, "SIOCGETVLAN");
138
139 bzero((char *)&vreq.vlr_parent, sizeof(vreq.vlr_parent));
140 vreq.vlr_tag = 0;
141
142 if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
143 err(1, "SIOCSETVLAN");
144
145 return;
146}
129unsetvlandev(const char *val, int d, int s, const struct afswtch *afp)
130{
131 struct vlanreq vreq;
132
133 bzero((char *)&vreq, sizeof(struct vlanreq));
134 ifr.ifr_data = (caddr_t)&vreq;
135
136 if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
137 err(1, "SIOCGETVLAN");
138
139 bzero((char *)&vreq.vlr_parent, sizeof(vreq.vlr_parent));
140 vreq.vlr_tag = 0;
141
142 if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
143 err(1, "SIOCSETVLAN");
144
145 return;
146}
147
148static struct cmd vlan_cmds[] = {
149 DEF_CMD_ARG("vlan", setvlantag),
150 DEF_CMD_ARG("vlandev", setvlandev),
151 DEF_CMD_ARG("-vlandev", unsetvlandev),
152 DEF_CMD("vlanmtu", IFCAP_VLAN_MTU, setifcap),
153 DEF_CMD("-vlanmtu", -IFCAP_VLAN_MTU, setifcap),
154 DEF_CMD("vlanhwtag", IFCAP_VLAN_HWTAGGING, setifcap),
155 DEF_CMD("-vlanhwtag", -IFCAP_VLAN_HWTAGGING, setifcap),
156};
157static struct afswtch af_vlan = {
158 .af_name = "af_vlan",
159 .af_af = AF_UNSPEC,
160 .af_status = vlan_status,
161};
162
163static __constructor void
164vlan_ctor(void)
165{
166#define N(a) (sizeof(a) / sizeof(a[0]))
167 int i;
168
169 for (i = 0; i < N(vlan_cmds); i++)
170 cmd_register(&vlan_cmds[i]);
171 af_register(&af_vlan);
172#undef N
173}