1/* 2 * Copyright (c) 1997 Peter Wemm. 3 * 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 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 16 * by Peter Wemm. 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. 19 * 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 30 * SUCH DAMAGE. 31 * 32 * so there! 33 *
| 1/* 2 * Copyright (c) 1997 Peter Wemm. 3 * 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 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 16 * by Peter Wemm. 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. 19 * 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 30 * SUCH DAMAGE. 31 * 32 * so there! 33 *
|
35 */ 36 37#define __constructor __attribute__((constructor)) 38 39struct afswtch; 40struct cmd; 41 42typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp); 43typedef void c_func2(const char *arg1, const char *arg2, int s, const struct afswtch *afp); 44 45struct cmd { 46 const char *c_name; 47 int c_parameter; 48#define NEXTARG 0xffffff /* has following arg */ 49#define NEXTARG2 0xfffffe /* has 2 following args */ 50#define OPTARG 0xfffffd /* has optional following arg */ 51 union { 52 c_func *c_func; 53 c_func2 *c_func2; 54 } c_u; 55 struct cmd *c_next; 56}; 57void cmd_register(struct cmd *); 58 59typedef void callback_func(int s, void *); 60void callback_register(callback_func *, void *); 61 62/* 63 * Macros for declaring command functions and initializing entries. 64 */ 65#define DECL_CMD_FUNC(name, cmd, arg) \ 66 void name(const char *cmd, int arg, int s, const struct afswtch *afp) 67#define DECL_CMD_FUNC2(name, arg1, arg2) \ 68 void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp) 69 70#define DEF_CMD(name, param, func) { name, param, { .c_func = func } } 71#define DEF_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func } } 72#define DEF_CMD_OPTARG(name, func) { name, OPTARG, { .c_func = func } } 73#define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func } } 74 75struct rt_addrinfo; 76struct addrinfo; 77 78enum { 79 RIDADDR, 80 ADDR, 81 MASK, 82 DSTADDR, 83}; 84 85struct afswtch { 86 const char *af_name; /* as given on cmd line, e.g. "inet" */ 87 short af_af; /* AF_* */ 88 /* 89 * Status is handled one of two ways; if there is an 90 * address associated with the interface then the 91 * associated address family af_status method is invoked 92 * with the appropriate addressin info. Otherwise, if 93 * all possible info is to be displayed and af_other_status 94 * is defined then it is invoked after all address status 95 * is presented. 96 */ 97 void (*af_status)(int, const struct rt_addrinfo *); 98 void (*af_other_status)(int); 99 /* parse address method */ 100 void (*af_getaddr)(const char *, int); 101 /* parse prefix method (IPv6) */ 102 void (*af_getprefix)(const char *, int); 103 void (*af_postproc)(int s, const struct afswtch *); 104 u_long af_difaddr; /* set dst if address ioctl */ 105 u_long af_aifaddr; /* set if address ioctl */ 106 void *af_ridreq; /* */ 107 void *af_addreq; /* */ 108 struct afswtch *af_next; 109 110 /* XXX doesn't fit model */ 111 void (*af_status_tunnel)(int); 112 void (*af_settunnel)(int s, struct addrinfo *srcres, 113 struct addrinfo *dstres); 114}; 115void af_register(struct afswtch *); 116 117struct option { 118 const char *opt; 119 const char *opt_usage; 120 void (*cb)(const char *arg); 121 struct option *next; 122}; 123void opt_register(struct option *); 124 125extern struct ifreq ifr; 126extern char name[IFNAMSIZ]; /* name of interface */ 127extern int allmedia; 128extern int supmedia;
| 35 */ 36 37#define __constructor __attribute__((constructor)) 38 39struct afswtch; 40struct cmd; 41 42typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp); 43typedef void c_func2(const char *arg1, const char *arg2, int s, const struct afswtch *afp); 44 45struct cmd { 46 const char *c_name; 47 int c_parameter; 48#define NEXTARG 0xffffff /* has following arg */ 49#define NEXTARG2 0xfffffe /* has 2 following args */ 50#define OPTARG 0xfffffd /* has optional following arg */ 51 union { 52 c_func *c_func; 53 c_func2 *c_func2; 54 } c_u; 55 struct cmd *c_next; 56}; 57void cmd_register(struct cmd *); 58 59typedef void callback_func(int s, void *); 60void callback_register(callback_func *, void *); 61 62/* 63 * Macros for declaring command functions and initializing entries. 64 */ 65#define DECL_CMD_FUNC(name, cmd, arg) \ 66 void name(const char *cmd, int arg, int s, const struct afswtch *afp) 67#define DECL_CMD_FUNC2(name, arg1, arg2) \ 68 void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp) 69 70#define DEF_CMD(name, param, func) { name, param, { .c_func = func } } 71#define DEF_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func } } 72#define DEF_CMD_OPTARG(name, func) { name, OPTARG, { .c_func = func } } 73#define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func } } 74 75struct rt_addrinfo; 76struct addrinfo; 77 78enum { 79 RIDADDR, 80 ADDR, 81 MASK, 82 DSTADDR, 83}; 84 85struct afswtch { 86 const char *af_name; /* as given on cmd line, e.g. "inet" */ 87 short af_af; /* AF_* */ 88 /* 89 * Status is handled one of two ways; if there is an 90 * address associated with the interface then the 91 * associated address family af_status method is invoked 92 * with the appropriate addressin info. Otherwise, if 93 * all possible info is to be displayed and af_other_status 94 * is defined then it is invoked after all address status 95 * is presented. 96 */ 97 void (*af_status)(int, const struct rt_addrinfo *); 98 void (*af_other_status)(int); 99 /* parse address method */ 100 void (*af_getaddr)(const char *, int); 101 /* parse prefix method (IPv6) */ 102 void (*af_getprefix)(const char *, int); 103 void (*af_postproc)(int s, const struct afswtch *); 104 u_long af_difaddr; /* set dst if address ioctl */ 105 u_long af_aifaddr; /* set if address ioctl */ 106 void *af_ridreq; /* */ 107 void *af_addreq; /* */ 108 struct afswtch *af_next; 109 110 /* XXX doesn't fit model */ 111 void (*af_status_tunnel)(int); 112 void (*af_settunnel)(int s, struct addrinfo *srcres, 113 struct addrinfo *dstres); 114}; 115void af_register(struct afswtch *); 116 117struct option { 118 const char *opt; 119 const char *opt_usage; 120 void (*cb)(const char *arg); 121 struct option *next; 122}; 123void opt_register(struct option *); 124 125extern struct ifreq ifr; 126extern char name[IFNAMSIZ]; /* name of interface */ 127extern int allmedia; 128extern int supmedia;
|
129extern int printname; 130extern int flags; 131extern int newaddr; 132extern int verbose; 133extern int setipdst; 134 135void setifcap(const char *, int value, int s, const struct afswtch *); 136 137void Perror(const char *cmd); 138void printb(const char *s, unsigned value, const char *bits); 139 140void ifmaybeload(char *name); 141 142void clone_create(void);
| 130extern int printname; 131extern int flags; 132extern int newaddr; 133extern int verbose; 134extern int setipdst; 135 136void setifcap(const char *, int value, int s, const struct afswtch *); 137 138void Perror(const char *cmd); 139void printb(const char *s, unsigned value, const char *bits); 140 141void ifmaybeload(char *name); 142 143void clone_create(void);
|