enable -fno-strict-aliasing until the code base gets a hefty clean up to fix all...
[platform/upstream/net-tools.git] / lib / net-support.h
1 /*
2  * lib/support.h      This file contains the definitions of what is in the
3  *                      support library.  Most of all, it defines structures
4  *                      for accessing support modules, and the function proto-
5  *                      types.
6  *
7  * NET-LIB      A collection of functions used from the base set of the
8  *              NET-3 Networking Distribution for the LINUX operating
9  *              system. (net-tools, net-drivers)
10  *
11  * Version:     lib/net-support.h 1.35 (1996-01-01)
12  *
13  * Maintainer:  Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
14  *
15  * Author:      Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
16  *              Copyright 1993 MicroWalt Corporation
17  *
18  * Modifications:
19  *960125 {1.20} Bernd Eckenfels:        reformated, layout
20  *960202 {1.30} Bernd Eckenfels:        rprint in aftype
21  *960206 {1.31} Bernd Eckenfels:        route_init
22  *960219 {1.32} Bernd Eckenfels:        type for ap->input()
23  *960322 {1.33} Bernd Eckenfels:        activate_ld and const in get_hwtype
24  *960413 {1.34} Bernd Eckenfels:        new RTACTION suport
25  *990101 {1.35} Bernd Eckenfels:        print_(hw|af)list support, added kerneldefines
26  *
27  *              This program is free software; you can redistribute it
28  *              and/or  modify it under  the terms of  the GNU General
29  *              Public  License as  published  by  the  Free  Software
30  *              Foundation;  either  version 2 of the License, or  (at
31  *              your option) any later version.
32  */
33 #include <sys/socket.h>
34
35 /* This structure defines protocol families and their handlers. */
36 struct aftype {
37     char *name;
38     char *title;
39     int af;
40     int alen;
41     char *(*print) (unsigned char *);
42     char *(*sprint) (struct sockaddr *, int numeric);
43     int (*input) (int type, char *bufp, struct sockaddr *);
44     void (*herror) (char *text);
45     int (*rprint) (int options);
46     int (*rinput) (int typ, int ext, char **argv);
47
48     /* may modify src */
49     int (*getmask) (char *src, struct sockaddr * mask, char *name);
50
51     int fd;
52     char *flag_file;
53 };
54
55 extern struct aftype *aftypes[];
56
57 /* This structure defines hardware protocols and their handlers. */
58 struct hwtype {
59     char *name;
60     char *title;
61     int type;
62     int alen;
63     char *(*print) (unsigned char *);
64     int (*input) (char *, struct sockaddr *);
65     int (*activate) (int fd);
66     int suppress_null_addr;
67 };
68
69
70 extern struct hwtype *get_hwtype(const char *name);
71 extern struct hwtype *get_hwntype(int type);
72 extern void          print_hwlist(int type);
73 extern struct aftype *get_aftype(const char *name);
74 extern struct aftype *get_afntype(int type);
75 extern void          print_aflist(int type);
76 extern int           hw_null_address(struct hwtype *hw, void *addr);
77
78 extern int getargs(char *string, char *arguments[]);
79
80 extern int get_socket_for_af(int af);
81
82 extern void getroute_init(void);
83 extern void setroute_init(void);
84 extern void activate_init(void);
85 extern int route_info(const char *afname, int flags);
86 extern int route_edit(int action, const char *afname, int flags, char **argv);
87 extern int activate_ld(const char *hwname, int fd);
88
89 #define RTACTION_ADD   1
90 #define RTACTION_DEL   2
91 #define RTACTION_HELP  3
92 #define RTACTION_FLUSH 4
93 #define RTACTION_SHOW  5
94
95 #define FLAG_EXT       3                /* AND-Mask */
96 #define FLAG_NUM_HOST  4
97 #define FLAG_NUM_PORT  8
98 #define FLAG_NUM_USER 16
99 #define FLAG_NUM     (FLAG_NUM_HOST|FLAG_NUM_PORT|FLAG_NUM_USER)
100 #define FLAG_SYM      32
101 #define FLAG_CACHE    64
102 #define FLAG_FIB     128
103 #define FLAG_VERBOSE 256
104
105 extern int ip_masq_info(int numeric_host, int numeric_port, int ext);
106
107 extern int INET_rprint(int options);
108 extern int INET6_rprint(int options);
109 extern int DDP_rprint(int options);
110 extern int IPX_rprint(int options);
111 extern int NETROM_rprint(int options);
112 extern int AX25_rprint(int options);
113 extern int X25_rprint(int options);
114
115 extern int INET_rinput(int action, int flags, char **argv);
116 extern int INET6_rinput(int action, int flags, char **argv);
117 extern int DDP_rinput(int action, int flags, char **argv);
118 extern int IPX_rinput(int action, int flags, char **argv);
119 extern int NETROM_rinput(int action, int flags, char **argv);
120 extern int AX25_rinput(int action, int flags, char **argv);
121 extern int X25_rinput(int action, int flags, char **argv);
122 extern int ROSE_rinput(int action, int flags, char **argv);
123
124 extern int aftrans_opt(const char *arg);
125 extern void aftrans_def(char *tool, char *argv0, char *dflt);
126
127 extern char *get_sname(int socknumber, char *proto, int numeric);
128
129 extern int flag_unx;
130 extern int flag_ipx;
131 extern int flag_ax25;
132 extern int flag_ddp;
133 extern int flag_netrom;
134 extern int flag_x25;
135 extern int flag_rose;
136 extern int flag_inet;
137 extern int flag_inet6;
138
139 extern char afname[];
140
141 #define AFTRANS_OPTS \
142         {"ax25",        0,      0,      1}, \
143        {"x25",         0,      0,      1}, \
144         {"ip",          0,      0,      1}, \
145         {"ipx",         0,      0,      1}, \
146         {"appletalk",   0,      0,      1}, \
147         {"netrom",      0,      0,      1}, \
148         {"inet",        0,      0,      1}, \
149         {"inet6",       0,      0,      1}, \
150         {"ddp",         0,      0,      1}, \
151         {"rose",                0,      0,      1}, \
152         {"unix",        0,      0,      1}, \
153         {"tcpip",       0,      0,      1}
154 #define AFTRANS_CNT 12
155
156 #define EINTERN(file, text) fprintf(stderr, \
157         _("%s: Internal Error `%s'.\n"),file,text);
158
159 #define ENOSUPP(A,B)    fprintf(stderr,\
160                                 _("%s: feature `%s' not supported.\n" \
161                                   "Please recompile `net-tools' with "\
162                                   "newer kernel source or full configuration.\n"),A,B)
163
164 #define ESYSNOT(A,B)    fprintf(stderr, _("%s: no support for `%s' on this system.\n"),A,B)
165
166 #define E_NOTFOUND      8
167 #define E_SOCK          7
168 #define E_LOOKUP        6
169 #define E_VERSION       5
170 #define E_USAGE         4
171 #define E_OPTERR        3
172 #define E_INTERN        2
173 #define E_NOSUPP        1
174
175
176 /* ========== Kernel Defines =============
177  * Since it is not a good idea to depend on special kernel sources for the headers
178  * and since the libc6 Headers are not always up to date, we keep a copy of the
179  * most often used Flags in this file. We realy need a way to keep them up-to-date.
180  * Perhaps anybody knows how the glibc2 folk is doing it? -ecki
181  */
182
183 /* Keep this ins sync with /usr/src/linux/include/linux/rtnetlink.h */
184 #define RTNH_F_DEAD            1       /* Nexthop is dead (used by multipath)  */
185 #define RTNH_F_PERVASIVE       2       /* Do recursive gateway lookup  */
186 #define RTNH_F_ONLINK          4       /* Gateway is forced on link    */
187
188 /* Keep this in sync with /usr/src/linux/include/linux/in_route.h */
189 #define RTCF_DEAD       RTNH_F_DEAD
190 #define RTCF_ONLINK     RTNH_F_ONLINK
191 /* #define RTCF_NOPMTUDISC RTM_F_NOPMTUDISC */
192 #define RTCF_NOTIFY     0x00010000
193 #define RTCF_DIRECTDST  0x00020000
194 #define RTCF_REDIRECTED 0x00040000
195 #define RTCF_TPROXY     0x00080000
196 #define RTCF_FAST       0x00200000
197 #define RTCF_MASQ       0x00400000
198 #define RTCF_SNAT       0x00800000
199 #define RTCF_DOREDIRECT 0x01000000
200 #define RTCF_DIRECTSRC  0x04000000
201 #define RTCF_DNAT       0x08000000
202 #define RTCF_BROADCAST  0x10000000
203 #define RTCF_MULTICAST  0x20000000
204 #define RTCF_REJECT     0x40000000
205 #define RTCF_LOCAL      0x80000000
206
207 /* Keep this in sync with /usr/src/linux/include/linux/ipv6_route.h */
208 #ifndef RTF_DEFAULT
209 #define RTF_DEFAULT     0x00010000      /* default - learned via ND     */
210 #endif
211 #define RTF_ALLONLINK   0x00020000      /* fallback, no routers on link */
212 #ifndef RTF_ADDRCONF
213 #define RTF_ADDRCONF    0x00040000      /* addrconf route - RA          */
214 #endif
215 #define RTF_NONEXTHOP   0x00200000      /* route with no nexthop        */
216 #define RTF_EXPIRES     0x00400000
217 #define RTF_CACHE       0x01000000      /* cache entry                  */
218 #define RTF_FLOW        0x02000000      /* flow significant route       */
219 #define RTF_POLICY      0x04000000      /* policy route                 */
220 #define RTF_LOCAL       0x80000000
221
222 /* Keep this in sync with /usr/src/linux/include/linux/route.h */
223 #define RTF_UP          0x0001          /* route usable                 */
224 #define RTF_GATEWAY     0x0002          /* destination is a gateway     */
225 #define RTF_HOST        0x0004          /* host entry (net otherwise)   */
226 #define RTF_REINSTATE   0x0008          /* reinstate route after tmout  */
227 #define RTF_DYNAMIC     0x0010          /* created dyn. (by redirect)   */
228 #define RTF_MODIFIED    0x0020          /* modified dyn. (by redirect)  */
229 #define RTF_MTU         0x0040          /* specific MTU for this route  */
230 #ifndef RTF_MSS
231 #define RTF_MSS         RTF_MTU         /* Compatibility :-(            */
232 #endif
233 #define RTF_WINDOW      0x0080          /* per route window clamping    */
234 #define RTF_IRTT        0x0100          /* Initial round trip time      */
235 #define RTF_REJECT      0x0200          /* Reject route                 */
236
237 /* this is a 2.0.36 flag from /usr/src/linux/include/linux/route.h */
238 #define RTF_NOTCACHED   0x0400          /* this route isn't cached        */
239
240 #ifdef HAVE_AFECONET
241 #ifndef AF_ECONET
242 #define AF_ECONET       19      /* Acorn Econet */
243 #endif
244 #endif
245
246 /* End of lib/support.h */
247