2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2009 Hiroki Sato. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 * THE POSSIBILITY OF SUCH DAMAGE.
29 static const char rcsid[] =
33 #include <sys/param.h>
34 #include <sys/ioctl.h>
35 #include <sys/socket.h>
36 #include <sys/sockio.h>
41 #include <net/ethernet.h>
43 #include <net/if_gif.h>
44 #include <net/route.h>
56 #define GIFBITS "\020\2IGNORE_SOURCE"
59 gif_status(if_ctx *ctx)
63 ifr.ifr_data = (caddr_t)&opts;
64 if (ioctl_ctx(ctx, GIFGOPTS, &ifr) == -1)
68 printb("\toptions", opts, GIFBITS);
73 setgifopts(if_ctx *ctx, const char *val __unused, int d)
77 ifr.ifr_data = (caddr_t)&opts;
78 if (ioctl_ctx(ctx, GIFGOPTS, &ifr) == -1) {
79 warn("ioctl(GIFGOPTS)");
88 if (ioctl_ctx(ctx, GIFSOPTS, &ifr) == -1) {
89 warn("ioctl(GIFSOPTS)");
94 static struct cmd gif_cmds[] = {
95 DEF_CMD("ignore_source", GIF_IGNORE_SOURCE, setgifopts),
96 DEF_CMD("-ignore_source", -GIF_IGNORE_SOURCE, setgifopts),
99 static struct afswtch af_gif = {
102 .af_other_status = gif_status,
105 static __constructor void
110 for (i = 0; i < nitems(gif_cmds); i++)
111 cmd_register(&gif_cmds[i]);
112 af_register(&af_gif);