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
);
123 extern int aftrans_opt(const char *arg
);
124 extern void aftrans_def(char *tool
, char *argv0
, char *dflt
);
126 extern char *get_sname(int socknumber
, char *proto
, int numeric
);
130 extern int flag_ax25
;
132 extern int flag_netrom
;
134 extern int flag_inet
;
135 extern int flag_inet6
;
137 extern char afname
[];
139 #define AFTRANS_OPTS \
144 {"appletalk", 0, 0, 1}, \
145 {"netrom", 0, 0, 1}, \
147 {"inet6", 0, 0, 1}, \
151 #define AFTRANS_CNT 11
153 #define EINTERN(file, text) fprintf(stderr, \
154 _("%s: Internal Error `%s'.\n"),file,text);
156 #define ENOSUPP(A,B) fprintf(stderr,\
157 _("%s: feature `%s' not supported.\n" \
158 "Please recompile `net-tools' with "\
159 "newer kernel source or full configuration.\n"),A,B)
161 #define ESYSNOT(A,B) fprintf(stderr, _("%s: no support for `%s' on this system.\n"),A,B)
173 /* ========== Kernel Defines =============
174 * Since it is not a good idea to depend on special kernel sources for the headers
175 * and since the libc6 Headers are not always up to date, we keep a copy of the
176 * most often used Flags in this file. We realy need a way to keep them up-to-date.
177 * Perhaps anybody knows how the glibc2 folk is doing it? -ecki
180 /* Keep this ins sync with /usr/src/linux/include/linux/rtnetlink.h */
181 #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
182 #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
183 #define RTNH_F_ONLINK 4 /* Gateway is forced on link */
185 /* Keep this in sync with /usr/src/linux/include/linux/in_route.h */
186 #define RTCF_DEAD RTNH_F_DEAD
187 #define RTCF_ONLINK RTNH_F_ONLINK
188 /* #define RTCF_NOPMTUDISC RTM_F_NOPMTUDISC */
189 #define RTCF_NOTIFY 0x00010000
190 #define RTCF_DIRECTDST 0x00020000
191 #define RTCF_REDIRECTED 0x00040000
192 #define RTCF_TPROXY 0x00080000
193 #define RTCF_FAST 0x00200000
194 #define RTCF_MASQ 0x00400000
195 #define RTCF_SNAT 0x00800000
196 #define RTCF_DOREDIRECT 0x01000000
197 #define RTCF_DIRECTSRC 0x04000000
198 #define RTCF_DNAT 0x08000000
199 #define RTCF_BROADCAST 0x10000000
200 #define RTCF_MULTICAST 0x20000000
201 #define RTCF_REJECT 0x40000000
202 #define RTCF_LOCAL 0x80000000
204 /* Keep this in sync with /usr/src/linux/include/linux/ipv6_route.h */
206 #define RTF_DEFAULT 0x00010000 /* default - learned via ND */
208 #define RTF_ALLONLINK 0x00020000 /* fallback, no routers on link */
210 #define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
212 #define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */
213 #define RTF_EXPIRES 0x00400000
214 #define RTF_CACHE 0x01000000 /* cache entry */
215 #define RTF_FLOW 0x02000000 /* flow significant route */
216 #define RTF_POLICY 0x04000000 /* policy route */
217 #define RTF_LOCAL 0x80000000
219 /* Keep this in sync with /usr/src/linux/include/linux/route.h */
220 #define RTF_UP 0x0001 /* route usable */
221 #define RTF_GATEWAY 0x0002 /* destination is a gateway */
222 #define RTF_HOST 0x0004 /* host entry (net otherwise) */
223 #define RTF_REINSTATE 0x0008 /* reinstate route after tmout */
224 #define RTF_DYNAMIC 0x0010 /* created dyn. (by redirect) */
225 #define RTF_MODIFIED 0x0020 /* modified dyn. (by redirect) */
226 #define RTF_MTU 0x0040 /* specific MTU for this route */
228 #define RTF_MSS RTF_MTU /* Compatibility :-( */
230 #define RTF_WINDOW 0x0080 /* per route window clamping */
231 #define RTF_IRTT 0x0100 /* Initial round trip time */
232 #define RTF_REJECT 0x0200 /* Reject route */
234 /* this is a 2.0.36 flag from /usr/src/linux/include/linux/route.h */
235 #define RTF_NOTCACHED 0x0400 /* this route isn't cached */
239 #define AF_ECONET 19 /* Acorn Econet */
243 /* End of lib/support.h */