xref: /freebsd/sys/netinet/libalias/alias.h (revision 0de89efe5c443f213c7ea28773ef2dc6cf3af2ed)
1 /*lint -save -library Flexelint comment for external headers */
2 
3 /*
4     Alias.h defines the outside world interfaces for the packet
5     aliasing software.
6 
7     This software is placed into the public domain with no restrictions
8     on its distribution.
9 */
10 
11 
12 #ifndef _ALIAS_H_
13 #define _ALIAS_H_
14 
15 #ifndef NULL
16 #define NULL 0
17 #endif
18 
19 /* Alias link representative (incomplete struct) */
20 struct alias_link;
21 
22 /* External interfaces (API) to packet aliasing engine */
23 
24 /* Initialization and Control */
25     extern void
26     PacketAliasInit(void);
27 
28     extern void
29     PacketAliasSetAddress(struct in_addr);
30 
31     extern unsigned int
32     PacketAliasSetMode(unsigned int, unsigned int);
33 
34 /* Packet Handling */
35     extern int
36     PacketAliasIn(char *, int maxpacketsize);
37 
38     extern int
39     PacketAliasOut(char *, int maxpacketsize);
40 
41 /* Port and Address Redirection */
42     extern struct alias_link *
43     PacketAliasRedirectPort(struct in_addr, u_short,
44                             struct in_addr, u_short,
45                             struct in_addr, u_short,
46                             u_char);
47 
48     extern struct alias_link *
49     PacketAliasRedirectAddr(struct in_addr,
50                             struct in_addr);
51 
52     extern void
53     PacketAliasRedirectDelete(struct alias_link *);
54 
55 /* Fragment Handling */
56     extern int
57     PacketAliasSaveFragment(char *);
58 
59     extern char *
60     PacketAliasGetFragment(char *);
61 
62     extern void
63     PacketAliasFragmentIn(char *, char *);
64 
65 /* Miscellaneous Functions */
66     extern u_short
67     PacketAliasInternetChecksum(u_short *, int);
68 
69 
70 /*
71    In version 2.2, the function names were rationalized
72    to all be of the form PacketAlias...  These are the
73    old function names for backwards compatibility
74 */
75 extern int SaveFragmentPtr(char *);
76 extern char *GetNextFragmentPtr(char *);
77 extern void FragmentAliasIn(char *, char *);
78 extern void SetPacketAliasAddress(struct in_addr);
79 extern void InitPacketAlias(void);
80 extern unsigned int SetPacketAliasMode(unsigned int, unsigned int);
81 extern int PacketAliasIn2(char *, struct in_addr, int maxpacketsize);
82 extern int PacketAliasOut2(char *, struct in_addr, int maxpacketsize);
83 extern int
84 PacketAliasPermanentLink(struct in_addr, u_short,
85                          struct in_addr, u_short,
86                          u_short, u_char);
87 extern u_short InternetChecksum(u_short *, int);
88 
89 /* Obsolete constant */
90 #define PKT_ALIAS_NEW_LINK 5
91 
92 /********************** Mode flags ********************/
93 /* Set these flags using SetPacketAliasMode() */
94 
95 /* If PKT_ALIAS_LOG is set, a message will be printed to
96 	/var/log/alias.log every time a link is created or deleted.  This
97 	is useful for debugging */
98 #define PKT_ALIAS_LOG 0x01
99 
100 /* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g.
101 	to ftp, telnet or web servers will be prevented by the aliasing
102 	mechanism.  */
103 #define PKT_ALIAS_DENY_INCOMING 0x02
104 
105 /* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
106 	the same port as they originated on.  This allows eg rsh to work
107 	*99% of the time*, but _not_ 100%.  (It will be slightly flakey
108 	instead of not working at all.)  This mode bit is set by
109         PacketAliasInit(), so it is a default mode of operation. */
110 #define PKT_ALIAS_SAME_PORTS 0x04
111 
112 /* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified
113 	links (e.g. destination port and/or address is zero), the packet
114 	aliasing engine will attempt to allocate a socket for the aliasing
115 	port it chooses.  This will avoid interference with the host
116 	machine.  Fully specified links do not require this.  This bit
117         is set after a call to PacketAliasInit(), so it is a default
118         mode of operation.*/
119 #define PKT_ALIAS_USE_SOCKETS 0x08
120 
121 /* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with with
122 	unregistered source addresses will be aliased (along with those
123 	of the ppp host maching itself.  Private addresses are those
124         in the following ranges:
125 
126 		10.0.0.0     ->   10.255.255.255
127 		172.16.0.0   ->   172.31.255.255
128 		192.168.0.0  ->   192.168.255.255  */
129 #define PKT_ALIAS_UNREGISTERED_ONLY 0x10
130 
131 /* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
132 	aliasing links will be reset whenever PacketAliasSetAddress()
133         changes the default aliasing address.  If the default aliasing
134         address is left unchanged by this functions call, then the
135         table of dynamic aliasing links will be left intact.  This
136         bit is set after a call to PacketAliasInit(). */
137 #define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
138 
139 /* Return Codes */
140 #define PKT_ALIAS_ERROR -1
141 #define PKT_ALIAS_OK 1
142 #define PKT_ALIAS_IGNORED 2
143 #define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
144 #define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
145 
146 #undef __libalias_version
147 #define __libalias_version "2.4"
148 
149 #endif
150 /*lint -restore */
151