1 |
745 |
simons |
/*
|
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 |
|
|
char *(*sprint) (struct sockaddr *);
|
65 |
|
|
int (*input) (char *, struct sockaddr *);
|
66 |
|
|
int (*activate) (int fd);
|
67 |
|
|
int suppress_null_addr;
|
68 |
|
|
};
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
extern struct hwtype *get_hwtype(const char *name);
|
72 |
|
|
extern struct hwtype *get_hwntype(int type);
|
73 |
|
|
extern void print_hwlist(int type);
|
74 |
|
|
extern struct aftype *get_aftype(const char *name);
|
75 |
|
|
extern struct aftype *get_afntype(int type);
|
76 |
|
|
extern void print_aflist(int type);
|
77 |
|
|
extern int hw_null_address(struct hwtype *hw, void *addr);
|
78 |
|
|
|
79 |
|
|
extern int getargs(char *string, char *arguments[]);
|
80 |
|
|
|
81 |
|
|
extern int get_socket_for_af(int af);
|
82 |
|
|
|
83 |
|
|
extern void getroute_init(void);
|
84 |
|
|
extern void setroute_init(void);
|
85 |
|
|
extern void activate_init(void);
|
86 |
|
|
extern int route_info(const char *afname, int flags);
|
87 |
|
|
extern int route_edit(int action, const char *afname, int flags, char **argv);
|
88 |
|
|
extern int activate_ld(const char *hwname, int fd);
|
89 |
|
|
|
90 |
|
|
#define RTACTION_ADD 1
|
91 |
|
|
#define RTACTION_DEL 2
|
92 |
|
|
#define RTACTION_HELP 3
|
93 |
|
|
#define RTACTION_FLUSH 4
|
94 |
|
|
#define RTACTION_SHOW 5
|
95 |
|
|
|
96 |
|
|
#define FLAG_EXT 3 /* AND-Mask */
|
97 |
|
|
#define FLAG_NUM 4
|
98 |
|
|
#define FLAG_SYM 8
|
99 |
|
|
#define FLAG_CACHE 16
|
100 |
|
|
#define FLAG_FIB 32
|
101 |
|
|
#define FLAG_VERBOSE 64
|
102 |
|
|
|
103 |
|
|
extern int ip_masq_info(int numeric, int ext);
|
104 |
|
|
|
105 |
|
|
extern int INET_rprint(int options);
|
106 |
|
|
extern int INET6_rprint(int options);
|
107 |
|
|
extern int DDP_rprint(int options);
|
108 |
|
|
extern int IPX_rprint(int options);
|
109 |
|
|
extern int NETROM_rprint(int options);
|
110 |
|
|
extern int AX25_rprint(int options);
|
111 |
|
|
|
112 |
|
|
extern int INET_rinput(int action, int flags, char **argv);
|
113 |
|
|
extern int INET6_rinput(int action, int flags, char **argv);
|
114 |
|
|
extern int DDP_rinput(int action, int flags, char **argv);
|
115 |
|
|
extern int IPX_rinput(int action, int flags, char **argv);
|
116 |
|
|
extern int NETROM_rinput(int action, int flags, char **argv);
|
117 |
|
|
extern int AX25_rinput(int action, int flags, char **argv);
|
118 |
|
|
|
119 |
|
|
extern int aftrans_opt(const char *arg);
|
120 |
|
|
extern void aftrans_def(char *tool, char *argv0, char *dflt);
|
121 |
|
|
|
122 |
|
|
extern char *get_sname(int socknumber, char *proto, int numeric);
|
123 |
|
|
|
124 |
|
|
extern int flag_unx;
|
125 |
|
|
extern int flag_ipx;
|
126 |
|
|
extern int flag_ax25;
|
127 |
|
|
extern int flag_ddp;
|
128 |
|
|
extern int flag_netrom;
|
129 |
|
|
extern int flag_inet;
|
130 |
|
|
extern int flag_inet6;
|
131 |
|
|
|
132 |
|
|
extern char afname[];
|
133 |
|
|
|
134 |
|
|
#define AFTRANS_OPTS \
|
135 |
|
|
{"ax25", 0, 0, 1}, \
|
136 |
|
|
{"ip", 0, 0, 1}, \
|
137 |
|
|
{"ipx", 0, 0, 1}, \
|
138 |
|
|
{"appletalk", 0, 0, 1}, \
|
139 |
|
|
{"netrom", 0, 0, 1}, \
|
140 |
|
|
{"inet", 0, 0, 1}, \
|
141 |
|
|
{"inet6", 0, 0, 1}, \
|
142 |
|
|
{"ddp", 0, 0, 1}, \
|
143 |
|
|
{"unix", 0, 0, 1}, \
|
144 |
|
|
{"tcpip", 0, 0, 1}
|
145 |
|
|
#define AFTRANS_CNT 10
|
146 |
|
|
|
147 |
|
|
#define EINTERN(file, text) fprintf(stderr, \
|
148 |
|
|
"%s: Internal Error `%s'.\n",file,text);
|
149 |
|
|
|
150 |
|
|
#define ENOSUPP(A,B) fprintf(stderr,\
|
151 |
|
|
_("%s: feature `%s' not supported.\n" \
|
152 |
|
|
"Please recompile `net-tools' with "\
|
153 |
|
|
"newer kernel source or full configuration.\n"),A,B)
|
154 |
|
|
|
155 |
|
|
#define ESYSNOT(A,B) fprintf(stderr, _("%s: no support for `%s' on this system.\n"),A,B)
|
156 |
|
|
|
157 |
|
|
#define E_NOTFOUND 8
|
158 |
|
|
#define E_SOCK 7
|
159 |
|
|
#define E_LOOKUP 6
|
160 |
|
|
#define E_VERSION 5
|
161 |
|
|
#define E_USAGE 4
|
162 |
|
|
#define E_OPTERR 3
|
163 |
|
|
#define E_INTERN 2
|
164 |
|
|
#define E_NOSUPP 1
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
/* ========== Kernel Defines =============
|
168 |
|
|
* Since it is not a good idea to depend on special kernel sources for the headers
|
169 |
|
|
* and since the libc6 Headers are not always up to date, we keep a copy of the
|
170 |
|
|
* most often used Flags in this file. We realy need a way to keep them up-to-date.
|
171 |
|
|
* Perhaps anybody knows how the glibc2 folk is doing it? -ecki
|
172 |
|
|
*/
|
173 |
|
|
|
174 |
|
|
/* Keep this ins sync with /usr/src/linux/include/linux/rtnetlink.h */
|
175 |
|
|
#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
|
176 |
|
|
#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
|
177 |
|
|
#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
|
178 |
|
|
|
179 |
|
|
/* Keep this in sync with /usr/src/linux/include/linux/in_route.h */
|
180 |
|
|
#define RTCF_DEAD RTNH_F_DEAD
|
181 |
|
|
#define RTCF_ONLINK RTNH_F_ONLINK
|
182 |
|
|
/* #define RTCF_NOPMTUDISC RTM_F_NOPMTUDISC */
|
183 |
|
|
#define RTCF_NOTIFY 0x00010000
|
184 |
|
|
#define RTCF_DIRECTDST 0x00020000
|
185 |
|
|
#define RTCF_REDIRECTED 0x00040000
|
186 |
|
|
#define RTCF_TPROXY 0x00080000
|
187 |
|
|
#define RTCF_FAST 0x00200000
|
188 |
|
|
#define RTCF_MASQ 0x00400000
|
189 |
|
|
#define RTCF_SNAT 0x00800000
|
190 |
|
|
#define RTCF_DOREDIRECT 0x01000000
|
191 |
|
|
#define RTCF_DIRECTSRC 0x04000000
|
192 |
|
|
#define RTCF_DNAT 0x08000000
|
193 |
|
|
#define RTCF_BROADCAST 0x10000000
|
194 |
|
|
#define RTCF_MULTICAST 0x20000000
|
195 |
|
|
#define RTCF_REJECT 0x40000000
|
196 |
|
|
#define RTCF_LOCAL 0x80000000
|
197 |
|
|
|
198 |
|
|
/* Keep this in sync with /usr/src/linux/include/linux/ipv6_route.h */
|
199 |
|
|
#ifndef RTF_DEFAULT
|
200 |
|
|
#define RTF_DEFAULT 0x00010000 /* default - learned via ND */
|
201 |
|
|
#endif
|
202 |
|
|
#define RTF_ALLONLINK 0x00020000 /* fallback, no routers on link */
|
203 |
|
|
#ifndef RTF_ADDRCONF
|
204 |
|
|
#define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
|
205 |
|
|
#endif
|
206 |
|
|
#define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */
|
207 |
|
|
#define RTF_EXPIRES 0x00400000
|
208 |
|
|
#define RTF_CACHE 0x01000000 /* cache entry */
|
209 |
|
|
#define RTF_FLOW 0x02000000 /* flow significant route */
|
210 |
|
|
#define RTF_POLICY 0x04000000 /* policy route */
|
211 |
|
|
#define RTF_LOCAL 0x80000000
|
212 |
|
|
|
213 |
|
|
/* Keep this in sync with /usr/src/linux/include/linux/route.h */
|
214 |
|
|
#define RTF_UP 0x0001 /* route usable */
|
215 |
|
|
#define RTF_GATEWAY 0x0002 /* destination is a gateway */
|
216 |
|
|
#define RTF_HOST 0x0004 /* host entry (net otherwise) */
|
217 |
|
|
#define RTF_REINSTATE 0x0008 /* reinstate route after tmout */
|
218 |
|
|
#define RTF_DYNAMIC 0x0010 /* created dyn. (by redirect) */
|
219 |
|
|
#define RTF_MODIFIED 0x0020 /* modified dyn. (by redirect) */
|
220 |
|
|
#define RTF_MTU 0x0040 /* specific MTU for this route */
|
221 |
|
|
#ifndef RTF_MSS
|
222 |
|
|
#define RTF_MSS RTF_MTU /* Compatibility :-( */
|
223 |
|
|
#endif
|
224 |
|
|
#define RTF_WINDOW 0x0080 /* per route window clamping */
|
225 |
|
|
#define RTF_IRTT 0x0100 /* Initial round trip time */
|
226 |
|
|
#define RTF_REJECT 0x0200 /* Reject route */
|
227 |
|
|
|
228 |
|
|
/* this is a 2.0.36 flag from /usr/src/linux/include/linux/route.h */
|
229 |
|
|
#define RTF_NOTCACHED 0x0400 /* this route isn't cached */
|
230 |
|
|
|
231 |
|
|
#ifdef HAVE_AFECONET
|
232 |
|
|
#ifndef AF_ECONET
|
233 |
|
|
#define AF_ECONET 19 /* Acorn Econet */
|
234 |
|
|
#endif
|
235 |
|
|
#endif
|
236 |
|
|
|
237 |
|
|
/* End of lib/support.h */
|
238 |
|
|
|