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-
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)
11 * Version: lib/net-support.h 1.35 (1996-01-01)
13 * Maintainer: Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
15 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
16 * Copyright 1993 MicroWalt Corporation
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
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.
33 #include <sys/socket.h>
35 /* This structure defines protocol families and their handlers. */
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);
49 int (*getmask) (char *src, struct sockaddr * mask, char *name);
55 extern struct aftype *aftypes[];
57 /* This structure defines hardware protocols and their handlers. */
63 char *(*print) (unsigned char *);
64 int (*input) (char *, struct sockaddr *);
65 int (*activate) (int fd);
66 int suppress_null_addr;
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);
78 extern int getargs(char *string, char *arguments[]);
80 extern int get_socket_for_af(int af);
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);
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
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)
101 #define FLAG_CACHE 64
103 #define FLAG_VERBOSE 256
105 extern int ip_masq_info(int numeric_host, int numeric_port, int ext);
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);
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);
124 extern int aftrans_opt(const char *arg);
125 extern void aftrans_def(char *tool, char *argv0, char *dflt);
127 extern char *get_sname(int socknumber, char *proto, int numeric);
131 extern int flag_ax25;
133 extern int flag_netrom;
135 extern int flag_rose;
136 extern int flag_inet;
137 extern int flag_inet6;
139 extern char afname[];
141 #define AFTRANS_OPTS \
146 {"appletalk", 0, 0, 1}, \
147 {"netrom", 0, 0, 1}, \
149 {"inet6", 0, 0, 1}, \
154 #define AFTRANS_CNT 12
156 #define EINTERN(file, text) fprintf(stderr, \
157 _("%s: Internal Error `%s'.\n"),file,text);
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)
164 #define ESYSNOT(A,B) fprintf(stderr, _("%s: no support for `%s' on this system.\n"),A,B)
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
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 */
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
207 /* Keep this in sync with /usr/src/linux/include/linux/ipv6_route.h */
209 #define RTF_DEFAULT 0x00010000 /* default - learned via ND */
211 #define RTF_ALLONLINK 0x00020000 /* fallback, no routers on link */
213 #define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
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
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 */
231 #define RTF_MSS RTF_MTU /* Compatibility :-( */
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 */
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 */
242 #define AF_ECONET 19 /* Acorn Econet */
246 /* End of lib/support.h */