]>
git.saurik.com Git - apple/network_cmds.git/blob - ifconfig.tproj/ifconfig.h
2 * Copyright (c) 2009-2011 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 * Copyright (c) 1997 Peter Wemm.
31 * All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
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
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.
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
62 * $FreeBSD: src/sbin/ifconfig/ifconfig.h,v 1.21.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $
65 #define __constructor __attribute__((constructor))
70 typedef void c_func(const char *cmd
, int arg
, int s
, const struct afswtch
*afp
);
71 typedef void c_func2(const char *arg1
, const char *arg2
, int s
, const struct afswtch
*afp
);
76 #define NEXTARG 0xffffff /* has following arg */
77 #define NEXTARG2 0xfffffe /* has 2 following args */
78 #define OPTARG 0xfffffd /* has optional following arg */
86 void cmd_register(struct cmd
*);
88 typedef void callback_func(int s
, void *);
89 void callback_register(callback_func
*, void *);
92 * Macros for declaring command functions and initializing entries.
94 #define DECL_CMD_FUNC(name, cmd, arg) \
95 void name(const char *cmd, int arg, int s, const struct afswtch *afp)
96 #define DECL_CMD_FUNC2(name, arg1, arg2) \
97 void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp)
99 #define DEF_CMD(name, param, func) { name, param, { .c_func = func } }
100 #define DEF_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func } }
101 #define DEF_CMD_OPTARG(name, func) { name, OPTARG, { .c_func = func } }
102 #define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func } }
103 #define DEF_CLONE_CMD(name, param, func) { name, param, { .c_func = func }, 1 }
104 #define DEF_CLONE_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func }, 1 }
117 const char *af_name
; /* as given on cmd line, e.g. "inet" */
118 short af_af
; /* AF_* */
120 * Status is handled one of two ways; if there is an
121 * address associated with the interface then the
122 * associated address family af_status method is invoked
123 * with the appropriate addressin info. Otherwise, if
124 * all possible info is to be displayed and af_other_status
125 * is defined then it is invoked after all address status
128 void (*af_status
)(int, const struct ifaddrs
*);
129 void (*af_other_status
)(int);
130 /* parse address method */
131 void (*af_getaddr
)(const char *, int);
132 /* parse prefix method (IPv6) */
133 void (*af_getprefix
)(const char *, int);
134 void (*af_postproc
)(int s
, const struct afswtch
*);
135 u_long af_difaddr
; /* set dst if address ioctl */
136 u_long af_aifaddr
; /* set if address ioctl */
137 void *af_ridreq
; /* */
138 void *af_addreq
; /* */
139 struct afswtch
*af_next
;
141 /* XXX doesn't fit model */
142 void (*af_status_tunnel
)(int);
143 void (*af_settunnel
)(int s
, struct addrinfo
*srcres
,
144 struct addrinfo
*dstres
);
146 void (*af_setrouter
)(int, int);
148 void af_register(struct afswtch
*);
152 const char *opt_usage
;
153 void (*cb
)(const char *arg
);
156 void opt_register(struct option
*);
158 extern struct ifreq ifr
;
159 extern char name
[IFNAMSIZ
]; /* name of interface */
162 extern int printkeys
;
167 void setifcap(const char *, int value
, int s
, const struct afswtch
*);
169 void Perror(const char *cmd
);
170 void printb(const char *s
, unsigned value
, const char *bits
);
172 void ifmaybeload(const char *name
);
174 typedef void clone_callback_func(int, struct ifreq
*);
175 void clone_setcallback(clone_callback_func
*);
178 * XXX expose this so modules that neeed to know of any pending
179 * operations on ifmedia can avoid cmd line ordering confusion.
181 struct ifmediareq
*ifmedia_getstate(int s
);