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