1997-05-04 06:27:45 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997 Peter Wemm.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed for the FreeBSD Project
|
|
|
|
* by Peter Wemm.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* so there!
|
|
|
|
*
|
1999-08-28 00:22:10 +00:00
|
|
|
* $FreeBSD$
|
1997-05-04 06:27:45 +00:00
|
|
|
*/
|
|
|
|
|
2004-12-08 19:18:07 +00:00
|
|
|
#define __constructor __attribute__((constructor))
|
1997-05-04 06:27:45 +00:00
|
|
|
|
1997-05-10 14:47:35 +00:00
|
|
|
struct afswtch;
|
2004-12-08 19:18:07 +00:00
|
|
|
struct cmd;
|
1997-05-04 06:27:45 +00:00
|
|
|
|
2004-12-08 19:18:07 +00:00
|
|
|
typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp);
|
|
|
|
typedef void c_func2(const char *arg1, const char *arg2, int s, const struct afswtch *afp);
|
|
|
|
|
|
|
|
struct cmd {
|
|
|
|
const char *c_name;
|
|
|
|
int c_parameter;
|
|
|
|
#define NEXTARG 0xffffff /* has following arg */
|
|
|
|
#define NEXTARG2 0xfffffe /* has 2 following args */
|
|
|
|
#define OPTARG 0xfffffd /* has optional following arg */
|
|
|
|
union {
|
|
|
|
c_func *c_func;
|
|
|
|
c_func2 *c_func2;
|
2005-04-08 21:37:41 +00:00
|
|
|
} c_u;
|
2008-03-31 15:38:07 +00:00
|
|
|
int c_iscloneop;
|
2004-12-08 19:18:07 +00:00
|
|
|
struct cmd *c_next;
|
|
|
|
};
|
|
|
|
void cmd_register(struct cmd *);
|
|
|
|
|
2004-12-11 02:33:33 +00:00
|
|
|
typedef void callback_func(int s, void *);
|
|
|
|
void callback_register(callback_func *, void *);
|
|
|
|
|
2004-12-08 19:18:07 +00:00
|
|
|
/*
|
|
|
|
* Macros for declaring command functions and initializing entries.
|
|
|
|
*/
|
|
|
|
#define DECL_CMD_FUNC(name, cmd, arg) \
|
|
|
|
void name(const char *cmd, int arg, int s, const struct afswtch *afp)
|
|
|
|
#define DECL_CMD_FUNC2(name, arg1, arg2) \
|
|
|
|
void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp)
|
|
|
|
|
2009-06-23 23:49:52 +00:00
|
|
|
#define DEF_CMD(name, param, func) { name, param, { .c_func = func }, 0, NULL }
|
|
|
|
#define DEF_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func }, 0, NULL }
|
|
|
|
#define DEF_CMD_OPTARG(name, func) { name, OPTARG, { .c_func = func }, 0, NULL }
|
|
|
|
#define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func }, 0, NULL }
|
|
|
|
#define DEF_CLONE_CMD(name, param, func) { name, param, { .c_func = func }, 1, NULL }
|
|
|
|
#define DEF_CLONE_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func }, 1, NULL }
|
2004-12-08 19:18:07 +00:00
|
|
|
|
2007-02-24 23:55:46 +00:00
|
|
|
struct ifaddrs;
|
2004-12-08 19:18:07 +00:00
|
|
|
struct addrinfo;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RIDADDR,
|
|
|
|
ADDR,
|
|
|
|
MASK,
|
|
|
|
DSTADDR,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct afswtch {
|
|
|
|
const char *af_name; /* as given on cmd line, e.g. "inet" */
|
|
|
|
short af_af; /* AF_* */
|
2004-12-31 19:46:27 +00:00
|
|
|
/*
|
|
|
|
* Status is handled one of two ways; if there is an
|
|
|
|
* address associated with the interface then the
|
|
|
|
* associated address family af_status method is invoked
|
|
|
|
* with the appropriate addressin info. Otherwise, if
|
|
|
|
* all possible info is to be displayed and af_other_status
|
|
|
|
* is defined then it is invoked after all address status
|
|
|
|
* is presented.
|
|
|
|
*/
|
2007-02-24 23:55:46 +00:00
|
|
|
void (*af_status)(int, const struct ifaddrs *);
|
2004-12-31 19:46:27 +00:00
|
|
|
void (*af_other_status)(int);
|
2004-12-08 19:18:07 +00:00
|
|
|
/* parse address method */
|
|
|
|
void (*af_getaddr)(const char *, int);
|
|
|
|
/* parse prefix method (IPv6) */
|
|
|
|
void (*af_getprefix)(const char *, int);
|
|
|
|
void (*af_postproc)(int s, const struct afswtch *);
|
|
|
|
u_long af_difaddr; /* set dst if address ioctl */
|
|
|
|
u_long af_aifaddr; /* set if address ioctl */
|
|
|
|
void *af_ridreq; /* */
|
|
|
|
void *af_addreq; /* */
|
|
|
|
struct afswtch *af_next;
|
|
|
|
|
|
|
|
/* XXX doesn't fit model */
|
|
|
|
void (*af_status_tunnel)(int);
|
|
|
|
void (*af_settunnel)(int s, struct addrinfo *srcres,
|
|
|
|
struct addrinfo *dstres);
|
|
|
|
};
|
|
|
|
void af_register(struct afswtch *);
|
|
|
|
|
|
|
|
struct option {
|
|
|
|
const char *opt;
|
|
|
|
const char *opt_usage;
|
|
|
|
void (*cb)(const char *arg);
|
|
|
|
struct option *next;
|
|
|
|
};
|
|
|
|
void opt_register(struct option *);
|
|
|
|
|
|
|
|
extern struct ifreq ifr;
|
|
|
|
extern char name[IFNAMSIZ]; /* name of interface */
|
|
|
|
extern int allmedia;
|
|
|
|
extern int supmedia;
|
2005-07-14 18:33:21 +00:00
|
|
|
extern int printkeys;
|
2004-12-08 19:18:07 +00:00
|
|
|
extern int newaddr;
|
|
|
|
extern int verbose;
|
|
|
|
|
|
|
|
void setifcap(const char *, int value, int s, const struct afswtch *);
|
|
|
|
|
|
|
|
void Perror(const char *cmd);
|
|
|
|
void printb(const char *s, unsigned value, const char *bits);
|
|
|
|
|
2007-02-24 23:55:46 +00:00
|
|
|
void ifmaybeload(const char *name);
|
2004-12-08 19:18:07 +00:00
|
|
|
|
2006-07-09 06:10:23 +00:00
|
|
|
typedef void clone_callback_func(int, struct ifreq *);
|
2009-02-27 00:31:34 +00:00
|
|
|
void clone_setdefcallback(const char *, clone_callback_func *);
|
Update for revised 802.11 support:
o revised channel handling support; ifconfig now queries the kernel to
find the list of available channels and handles channel promotion;
channel attributes can be specified as part of the channel; e.g. 36:a
for channel 36 in 11a (as opposed to turbo A or HT A)
o use channel list to map between freq and IEEE channel #; this eliminates
all knowledge of how the mapping is done and fixes handling of cases
where channels overlap in the IEEE channel # space but are distinct in
the frequency+attributes space (e.g. PSB)
o add new knobs: bgscan, ff (Atheors fast frames), dturbo (Atheros
Dynamic Turbo mode), bgscanidle, bgscanintvl, scanvalid, roam:rssi11a,
roam:rssi11b, roam:rssi11g, roam:rate11a, roam:rate11b, roam:rate11g
(roaming parameters), burst, doth (forthcoming 11h support)
o print contents of WME, ATH, WPA, RSN, information elements with -v option
o print signal strength in dBm
o print noise floor in dBm
o add list txpow to print tx power caps/channel
o change default channel display in status to be more informative
2007-06-11 03:56:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX expose this so modules that neeed to know of any pending
|
|
|
|
* operations on ifmedia can avoid cmd line ordering confusion.
|
|
|
|
*/
|
|
|
|
struct ifmediareq *ifmedia_getstate(int s);
|
A major overhaul of the CARP implementation. The ip_carp.c was started
from scratch, copying needed functionality from the old implemenation
on demand, with a thorough review of all code. The main change is that
interface layer has been removed from the CARP. Now redundant addresses
are configured exactly on the interfaces, they run on.
The CARP configuration itself is, as before, configured and read via
SIOCSVH/SIOCGVH ioctls. A new prefix created with SIOCAIFADDR or
SIOCAIFADDR_IN6 may now be configured to a particular virtual host id,
which makes the prefix redundant.
ifconfig(8) semantics has been changed too: now one doesn't need
to clone carpXX interface, he/she should directly configure a vhid
on a Ethernet interface.
To supply vhid data from the kernel to an application the getifaddrs(8)
function had been changed to pass ifam_data with each address. [1]
The new implementation definitely closes all PRs related to carp(4)
being an interface, and may close several others. It also allows
to run a single redundant IP per interface.
Big thanks to Bjoern Zeeb for his help with inet6 part of patch, for
idea on using ifam_data and for several rounds of reviewing!
PR: kern/117000, kern/126945, kern/126714, kern/120130, kern/117448
Reviewed by: bz
Submitted by: bz [1]
2011-12-16 12:16:56 +00:00
|
|
|
|
|
|
|
void print_vhid(const struct ifaddrs *, const char *);
|
|
|
|
|