Deleted Added
sdiff udiff text old ( 127649 ) new ( 138593 )
full compact
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

--- 17 unchanged lines hidden (view full) ---

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 *
34 * $FreeBSD: head/sbin/ifconfig/ifconfig.h 138593 2004-12-08 19:18:07Z sam $
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 };
55 struct cmd *c_next;
56};
57void cmd_register(struct cmd *);
58
59/*
60 * Macros for declaring command functions and initializing entries.
61 */
62#define DECL_CMD_FUNC(name, cmd, arg) \
63 void name(const char *cmd, int arg, int s, const struct afswtch *afp)
64#define DECL_CMD_FUNC2(name, arg1, arg2) \
65 void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp)
66
67#define DEF_CMD(name, param, func) { name, param, { .c_func = func } }
68#define DEF_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func } }
69#define DEF_CMD_OPTARG(name, func) { name, OPTARG, { .c_func = func } }
70#define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func } }
71
72struct rt_addrinfo;
73struct addrinfo;
74
75enum {
76 RIDADDR,
77 ADDR,
78 MASK,
79 DSTADDR,
80};
81
82struct afswtch {
83 const char *af_name; /* as given on cmd line, e.g. "inet" */
84 short af_af; /* AF_* */
85 /* print status method */
86 void (*af_status)(int, const struct rt_addrinfo *);
87 /* parse address method */
88 void (*af_getaddr)(const char *, int);
89 /* parse prefix method (IPv6) */
90 void (*af_getprefix)(const char *, int);
91 void (*af_postproc)(int s, const struct afswtch *);
92 u_long af_difaddr; /* set dst if address ioctl */
93 u_long af_aifaddr; /* set if address ioctl */
94 void *af_ridreq; /* */
95 void *af_addreq; /* */
96 struct afswtch *af_next;
97
98 /* XXX doesn't fit model */
99 void (*af_status_tunnel)(int);
100 void (*af_settunnel)(int s, struct addrinfo *srcres,
101 struct addrinfo *dstres);
102};
103void af_register(struct afswtch *);
104
105struct option {
106 const char *opt;
107 const char *opt_usage;
108 void (*cb)(const char *arg);
109 struct option *next;
110};
111void opt_register(struct option *);
112
113extern struct ifreq ifr;
114extern char name[IFNAMSIZ]; /* name of interface */
115extern int allmedia;
116extern int supmedia;
117extern int printname;
118extern int flags;
119extern int newaddr;
120extern int verbose;
121extern int setipdst;
122
123void setifcap(const char *, int value, int s, const struct afswtch *);
124
125void Perror(const char *cmd);
126void printb(const char *s, unsigned value, const char *bits);
127
128void ifmaybeload(char *name);
129
130void clone_create(void);