]> git.saurik.com Git - apple/network_cmds.git/blame - ifconfig.tproj/ifconfig.h
network_cmds-606.100.3.tar.gz
[apple/network_cmds.git] / ifconfig.tproj / ifconfig.h
CommitLineData
7af5ce03 1/*
e0b07f2d 2 * Copyright (c) 2009-2018 Apple Inc. All rights reserved.
7af5ce03
A
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
b7080c8e
A
29/*
30 * Copyright (c) 1997 Peter Wemm.
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * 3. All advertising materials mentioning features or use of this software
42 * must display the following acknowledgement:
43 * This product includes software developed for the FreeBSD Project
44 * by Peter Wemm.
45 * 4. The name of the author may not be used to endorse or promote products
46 * derived from this software without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
49 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
50 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
51 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
52 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
53 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
55 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * so there!
61 *
8d01c344 62 * $FreeBSD: src/sbin/ifconfig/ifconfig.h,v 1.21.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $
b7080c8e
A
63 */
64
8d01c344 65#define __constructor __attribute__((constructor))
b7080c8e 66
b7080c8e 67struct afswtch;
8d01c344 68struct cmd;
b7080c8e 69
8d01c344
A
70typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp);
71typedef void c_func2(const char *arg1, const char *arg2, int s, const struct afswtch *afp);
e0b07f2d 72typedef int c_funcv(int argc, char *const *argv, int s, const struct afswtch *afp);
7902cf7e 73
8d01c344
A
74struct cmd {
75 const char *c_name;
76 int c_parameter;
77#define NEXTARG 0xffffff /* has following arg */
78#define NEXTARG2 0xfffffe /* has 2 following args */
79#define OPTARG 0xfffffd /* has optional following arg */
e0b07f2d 80#define VAARGS 0xfffffc /* has variable following args */
8d01c344
A
81 union {
82 c_func *c_func;
83 c_func2 *c_func2;
e0b07f2d 84 c_funcv *c_funcv;
8d01c344
A
85 } c_u;
86 int c_iscloneop;
87 struct cmd *c_next;
88};
89void cmd_register(struct cmd *);
7902cf7e 90
8d01c344
A
91typedef void callback_func(int s, void *);
92void callback_register(callback_func *, void *);
93
94/*
95 * Macros for declaring command functions and initializing entries.
96 */
97#define DECL_CMD_FUNC(name, cmd, arg) \
98 void name(const char *cmd, int arg, int s, const struct afswtch *afp)
99#define DECL_CMD_FUNC2(name, arg1, arg2) \
100 void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp)
101
102#define DEF_CMD(name, param, func) { name, param, { .c_func = func } }
103#define DEF_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func } }
104#define DEF_CMD_OPTARG(name, func) { name, OPTARG, { .c_func = func } }
105#define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func } }
e0b07f2d 106#define DEF_CMD_VA(name, func) { name, VAARGS, { .c_funcv = func } }
8d01c344
A
107#define DEF_CLONE_CMD(name, param, func) { name, param, { .c_func = func }, 1 }
108#define DEF_CLONE_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func }, 1 }
109
110struct ifaddrs;
111struct addrinfo;
112
113enum {
114 RIDADDR,
115 ADDR,
116 MASK,
117 DSTADDR,
118};
119
120struct afswtch {
121 const char *af_name; /* as given on cmd line, e.g. "inet" */
122 short af_af; /* AF_* */
123 /*
124 * Status is handled one of two ways; if there is an
125 * address associated with the interface then the
126 * associated address family af_status method is invoked
127 * with the appropriate addressin info. Otherwise, if
128 * all possible info is to be displayed and af_other_status
129 * is defined then it is invoked after all address status
130 * is presented.
131 */
132 void (*af_status)(int, const struct ifaddrs *);
133 void (*af_other_status)(int);
134 /* parse address method */
135 void (*af_getaddr)(const char *, int);
136 /* parse prefix method (IPv6) */
137 void (*af_getprefix)(const char *, int);
138 void (*af_postproc)(int s, const struct afswtch *);
139 u_long af_difaddr; /* set dst if address ioctl */
140 u_long af_aifaddr; /* set if address ioctl */
141 void *af_ridreq; /* */
142 void *af_addreq; /* */
143 struct afswtch *af_next;
144
145 /* XXX doesn't fit model */
146 void (*af_status_tunnel)(int);
147 void (*af_settunnel)(int s, struct addrinfo *srcres,
148 struct addrinfo *dstres);
7af5ce03
A
149
150 void (*af_setrouter)(int, int);
a3cc5c72 151 int (*af_routermode)(int, int, char *const *);
8d01c344
A
152};
153void af_register(struct afswtch *);
154
155struct option {
156 const char *opt;
157 const char *opt_usage;
158 void (*cb)(const char *arg);
159 struct option *next;
160};
161void opt_register(struct option *);
162
163extern struct ifreq ifr;
164extern char name[IFNAMSIZ]; /* name of interface */
165extern int allmedia;
166extern int supmedia;
167extern int printkeys;
168extern int newaddr;
169extern int verbose;
170extern int all;
171
172void setifcap(const char *, int value, int s, const struct afswtch *);
173
174void Perror(const char *cmd);
175void printb(const char *s, unsigned value, const char *bits);
176
177void ifmaybeload(const char *name);
178
179typedef void clone_callback_func(int, struct ifreq *);
180void clone_setcallback(clone_callback_func *);
181
182/*
183 * XXX expose this so modules that neeed to know of any pending
184 * operations on ifmedia can avoid cmd line ordering confusion.
185 */
186struct ifmediareq *ifmedia_getstate(int s);