2 * Copyright (c) 2009 Hiroki Sato. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
17 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 static const char rcsid[] =
31 #include <sys/param.h>
32 #include <sys/ioctl.h>
33 #include <sys/socket.h>
34 #include <sys/sockio.h>
39 #include <net/ethernet.h>
41 #include <net/if_gif.h>
42 #include <net/route.h>
54 static void gif_status(int);
60 { "ACCEPT_REV_ETHIP_VER", GIF_ACCEPT_REVETHIP },
61 { "SEND_REV_ETHIP_VER", GIF_SEND_REVETHIP },
71 ifr.ifr_data = (caddr_t)&opts;
72 if (ioctl(s, GIFGOPTS, &ifr) == -1)
77 printf("\toptions=%d<", opts);
78 for (i=0; i < sizeof(gif_opts)/sizeof(gif_opts[0]); i++) {
79 if (opts & gif_opts[i].mask) {
82 printf("%s", gif_opts[i].label);
89 setgifopts(const char *val,
90 int d, int s, const struct afswtch *afp)
94 ifr.ifr_data = (caddr_t)&opts;
95 if (ioctl(s, GIFGOPTS, &ifr) == -1) {
96 warn("ioctl(GIFGOPTS)");
105 if (ioctl(s, GIFSOPTS, &ifr) == -1) {
106 warn("ioctl(GIFSOPTS)");
111 static struct cmd gif_cmds[] = {
112 DEF_CMD("accept_rev_ethip_ver", GIF_ACCEPT_REVETHIP, setgifopts),
113 DEF_CMD("-accept_rev_ethip_ver",-GIF_ACCEPT_REVETHIP, setgifopts),
114 DEF_CMD("send_rev_ethip_ver", GIF_SEND_REVETHIP, setgifopts),
115 DEF_CMD("-send_rev_ethip_ver", -GIF_SEND_REVETHIP, setgifopts),
118 static struct afswtch af_gif = {
121 .af_other_status = gif_status,
124 static __constructor void
127 #define N(a) (sizeof(a) / sizeof(a[0]))
130 for (i = 0; i < N(gif_cmds); i++)
131 cmd_register(&gif_cmds[i]);
132 af_register(&af_gif);