source: rtems-libbsd/freebsd/sbin/ifconfig/ifconfig.h @ e599318

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since e599318 was e599318, checked in by Sebastian Huber <sebastian.huber@…>, on 10/09/13 at 20:52:54

Update files to match FreeBSD layout

Add compatibility with Newlib header files. Some FreeBSD header files
are mapped by the translation script:

o rtems/bsd/sys/_types.h
o rtems/bsd/sys/errno.h
o rtems/bsd/sys/lock.h
o rtems/bsd/sys/param.h
o rtems/bsd/sys/resource.h
o rtems/bsd/sys/time.h
o rtems/bsd/sys/timespec.h
o rtems/bsd/sys/types.h
o rtems/bsd/sys/unistd.h

It is now possible to include <sys/socket.h> directly for example.

Generate one Makefile which builds everything including tests.

  • Property mode set to 100644
File size: 5.3 KB
Line 
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 *
34 * $FreeBSD$
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        int     c_iscloneop;
56        struct cmd *c_next;
57};
58void    cmd_register(struct cmd *);
59
60typedef void callback_func(int s, void *);
61void    callback_register(callback_func *, void *);
62
63/*
64 * Macros for declaring command functions and initializing entries.
65 */
66#define DECL_CMD_FUNC(name, cmd, arg) \
67        void name(const char *cmd, int arg, int s, const struct afswtch *afp)
68#define DECL_CMD_FUNC2(name, arg1, arg2) \
69        void name(const char *arg1, const char *arg2, int s, const struct afswtch *afp)
70
71#define DEF_CMD(name, param, func)      { name, param, { .c_func = func }, 0, NULL }
72#define DEF_CMD_ARG(name, func)         { name, NEXTARG, { .c_func = func }, 0, NULL }
73#define DEF_CMD_OPTARG(name, func)      { name, OPTARG, { .c_func = func }, 0, NULL }
74#define DEF_CMD_ARG2(name, func)        { name, NEXTARG2, { .c_func2 = func }, 0, NULL }
75#define DEF_CLONE_CMD(name, param, func) { name, param, { .c_func = func }, 1, NULL }
76#define DEF_CLONE_CMD_ARG(name, func)   { name, NEXTARG, { .c_func = func }, 1, NULL }
77
78struct ifaddrs;
79struct addrinfo;
80
81enum {
82        RIDADDR,
83        ADDR,
84        MASK,
85        DSTADDR,
86};
87
88struct afswtch {
89        const char      *af_name;       /* as given on cmd line, e.g. "inet" */
90        short           af_af;          /* AF_* */
91        /*
92         * Status is handled one of two ways; if there is an
93         * address associated with the interface then the
94         * associated address family af_status method is invoked
95         * with the appropriate addressin info.  Otherwise, if
96         * all possible info is to be displayed and af_other_status
97         * is defined then it is invoked after all address status
98         * is presented.
99         */
100        void            (*af_status)(int, const struct ifaddrs *);
101        void            (*af_other_status)(int);
102                                        /* parse address method */
103        void            (*af_getaddr)(const char *, int);
104                                        /* parse prefix method (IPv6) */
105        void            (*af_getprefix)(const char *, int);
106        void            (*af_postproc)(int s, const struct afswtch *);
107        u_long          af_difaddr;     /* set dst if address ioctl */
108        u_long          af_aifaddr;     /* set if address ioctl */
109        void            *af_ridreq;     /* */
110        void            *af_addreq;     /* */
111        struct afswtch  *af_next;
112
113        /* XXX doesn't fit model */
114        void            (*af_status_tunnel)(int);
115        void            (*af_settunnel)(int s, struct addrinfo *srcres,
116                                struct addrinfo *dstres);
117};
118void    af_register(struct afswtch *);
119
120#ifdef __rtems__
121struct ifconfig_option {
122#else
123struct option {
124#endif
125        const char *opt;
126        const char *opt_usage;
127        void    (*cb)(const char *arg);
128        #ifdef __rtems__
129        struct ifconfig_option *next;
130        #else
131        struct option *next;
132        #endif
133};
134#ifdef __rtems__
135void    opt_register(struct ifconfig_option *);
136#else
137void    opt_register(struct option *);
138#endif
139
140extern  struct ifreq ifr;
141extern  char name[IFNAMSIZ];    /* name of interface */
142extern  int allmedia;
143extern  int supmedia;
144extern  int printkeys;
145extern  int newaddr;
146extern  int verbose;
147
148void    setifcap(const char *, int value, int s, const struct afswtch *);
149
150void    Perror(const char *cmd);
151void    printb(const char *s, unsigned value, const char *bits);
152
153void    ifmaybeload(const char *name);
154
155typedef void clone_callback_func(int, struct ifreq *);
156void    clone_setdefcallback(const char *, clone_callback_func *);
157
158/*
159 * XXX expose this so modules that neeed to know of any pending
160 * operations on ifmedia can avoid cmd line ordering confusion.
161 */
162struct ifmediareq *ifmedia_getstate(int s);
Note: See TracBrowser for help on using the repository browser.