2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 1997 Peter Wemm.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the FreeBSD Project
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 #define __constructor __attribute__((constructor))
44 typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp);
45 typedef void c_func2(const char *arg1, const char *arg2, int s, const struct afswtch *afp);
50 #define NEXTARG 0xffffff /* has following arg */
51 #define NEXTARG2 0xfffffe /* has 2 following args */
52 #define OPTARG 0xfffffd /* has optional following arg */
60 void cmd_register(struct cmd *);
62 typedef void callback_func(int s, void *);
63 void callback_register(callback_func *, void *);
66 * Macros for declaring command functions and initializing entries.
68 #define DECL_CMD_FUNC(name, cmd, arg) \
69 void name(const char *cmd, int arg, int s, const struct afswtch *afp)
70 #define DECL_CMD_FUNC2(name, arg1, arg2) \
71 void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp)
73 #define DEF_CMD(name, param, func) { name, param, { .c_func = func }, 0, NULL }
74 #define DEF_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func }, 0, NULL }
75 #define DEF_CMD_OPTARG(name, func) { name, OPTARG, { .c_func = func }, 0, NULL }
76 #define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func }, 0, NULL }
77 #define DEF_CLONE_CMD(name, param, func) { name, param, { .c_func = func }, 1, NULL }
78 #define DEF_CLONE_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func }, 1, NULL }
79 #define DEF_CLONE_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func }, 1, NULL }
92 const char *af_name; /* as given on cmd line, e.g. "inet" */
93 short af_af; /* AF_* */
95 * Status is handled one of two ways; if there is an
96 * address associated with the interface then the
97 * associated address family af_status method is invoked
98 * with the appropriate addressin info. Otherwise, if
99 * all possible info is to be displayed and af_other_status
100 * is defined then it is invoked after all address status
103 void (*af_status)(int, const struct ifaddrs *);
104 void (*af_other_status)(int);
105 /* parse address method */
106 void (*af_getaddr)(const char *, int);
107 /* parse prefix method (IPv6) */
108 void (*af_getprefix)(const char *, int);
109 void (*af_postproc)(int s, const struct afswtch *);
110 u_long af_difaddr; /* set dst if address ioctl */
111 u_long af_aifaddr; /* set if address ioctl */
112 void *af_ridreq; /* */
113 void *af_addreq; /* */
114 struct afswtch *af_next;
116 /* XXX doesn't fit model */
117 void (*af_status_tunnel)(int);
118 void (*af_settunnel)(int s, struct addrinfo *srcres,
119 struct addrinfo *dstres);
121 void af_register(struct afswtch *);
125 const char *opt_usage;
126 void (*cb)(const char *arg);
129 void opt_register(struct option *);
131 extern struct ifreq ifr;
132 extern char name[IFNAMSIZ]; /* name of interface */
135 extern int printkeys;
138 extern int printifname;
139 extern int exit_code;
141 void setifcap(const char *, int value, int s, const struct afswtch *);
143 void Perror(const char *cmd);
144 void printb(const char *s, unsigned value, const char *bits);
146 void ifmaybeload(const char *name);
148 typedef void clone_callback_func(int, struct ifreq *);
149 void clone_setdefcallback(const char *, clone_callback_func *);
151 void sfp_status(int s, struct ifreq *ifr, int verbose);
154 * XXX expose this so modules that neeed to know of any pending
155 * operations on ifmedia can avoid cmd line ordering confusion.
157 struct ifmediareq *ifmedia_getstate(int s);
159 void print_vhid(const struct ifaddrs *, const char *);