xref: /freebsd/sys/netinet/libalias/alias_local.h (revision 2b944ee2b959e9b29fd72dcbf87aad8ad5537bc4)
1 /* -*- mode: c; tab-width: 3; c-basic-offset: 3; -*-
2     Alias_local.h contains the function prototypes for alias.c,
3     alias_db.c, alias_util.c and alias_ftp.c, alias_irc.c (as well
4     as any future add-ons).  It also includes macros, globals and
5     struct definitions shared by more than one alias*.c file.
6 
7     This include file is intended to be used only within the aliasing
8     software.  Outside world interfaces are defined in alias.h
9 
10     This software is placed into the public domain with no restrictions
11     on its distribution.
12 
13     Initial version:  August, 1996  (cjm)
14 
15      <updated several times by original author and Eivind Eklund>
16 
17     $FreeBSD$
18 */
19 #ifndef ALIAS_LOCAL_H
20 #define ALIAS_LOCAL_H
21 
22 
23 /*
24     Macros
25  */
26 
27 /*
28    The following macro is used to update an
29    internet checksum.  "delta" is a 32-bit
30    accumulation of all the changes to the
31    checksum (adding in new 16-bit words and
32    subtracting out old words), and "cksum"
33    is the checksum value to be updated.
34 */
35 #define ADJUST_CHECKSUM(acc, cksum) { \
36     acc += cksum; \
37     if (acc < 0) \
38     { \
39         acc = -acc; \
40         acc = (acc >> 16) + (acc & 0xffff); \
41         acc += acc >> 16; \
42         cksum = (u_short) ~acc; \
43     } \
44     else \
45     { \
46         acc = (acc >> 16) + (acc & 0xffff); \
47         acc += acc >> 16; \
48         cksum = (u_short) acc; \
49     } \
50 }
51 
52 
53 /*
54     Globals
55 */
56 
57 extern int packetAliasMode;
58 
59 
60 /*
61     Structs
62 */
63 
64 struct alias_link;    /* Incomplete structure */
65 
66 
67 /*
68     Prototypes
69 */
70 
71 /* General utilities */
72 u_short IpChecksum(struct ip *);
73 u_short TcpChecksum(struct ip *);
74 void DifferentialChecksum(u_short *, u_short *, u_short *, int);
75 
76 /* Internal data access */
77 struct alias_link *
78 FindIcmpIn(struct in_addr, struct in_addr, u_short);
79 
80 struct alias_link *
81 FindIcmpOut(struct in_addr, struct in_addr, u_short);
82 
83 struct alias_link *
84 FindFragmentIn1(struct in_addr, struct in_addr, u_short);
85 
86 struct alias_link *
87 FindFragmentIn2(struct in_addr, struct in_addr, u_short);
88 
89 struct alias_link *
90 AddFragmentPtrLink(struct in_addr, u_short);
91 
92 struct alias_link *
93 FindFragmentPtr(struct in_addr, u_short);
94 
95 struct alias_link *
96 FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char);
97 
98 struct alias_link *
99 FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
100 
101 struct in_addr
102 FindOriginalAddress(struct in_addr);
103 
104 struct in_addr
105 FindAliasAddress(struct in_addr);
106 
107 /* External data access/modification */
108 void GetFragmentAddr(struct alias_link *, struct in_addr *);
109 void SetFragmentAddr(struct alias_link *, struct in_addr);
110 void GetFragmentPtr(struct alias_link *, char **);
111 void SetFragmentPtr(struct alias_link *, char *);
112 void SetStateIn(struct alias_link *, int);
113 void SetStateOut(struct alias_link *, int);
114 int GetStateIn(struct alias_link *);
115 int GetStateOut(struct alias_link *);
116 struct in_addr GetOriginalAddress(struct alias_link *);
117 struct in_addr GetDestAddress(struct alias_link *);
118 struct in_addr GetAliasAddress(struct alias_link *);
119 struct in_addr GetDefaultAliasAddress(void);
120 void SetDefaultAliasAddress(struct in_addr);
121 u_short GetOriginalPort(struct alias_link *);
122 u_short GetAliasPort(struct alias_link *);
123 struct in_addr GetProxyAddress(struct alias_link *);
124 void SetProxyAddress(struct alias_link *, struct in_addr);
125 u_short GetProxyPort(struct alias_link *);
126 void SetProxyPort(struct alias_link *, u_short);
127 void SetAckModified(struct alias_link *);
128 int GetAckModified(struct alias_link *);
129 int GetDeltaAckIn(struct ip *, struct alias_link *);
130 int GetDeltaSeqOut(struct ip *, struct alias_link *);
131 void AddSeq(struct ip *, struct alias_link *, int);
132 void SetExpire(struct alias_link *, int);
133 void ClearCheckNewLink(void);
134 #ifndef NO_FW_PUNCH
135 void PunchFWHole(struct alias_link *);
136 #endif
137 
138 
139 /* Housekeeping function */
140 void HouseKeeping(void);
141 
142 /* Tcp specfic routines */
143 /*lint -save -library Suppress flexelint warnings */
144 
145 /* FTP routines */
146 void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
147 
148 /* IRC routines */
149 void AliasHandleIrcOut(struct ip *, struct alias_link *, int);
150 
151 /* NetBIOS routines */
152 int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
153 int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
154 
155 /* CUSeeMe routines */
156 void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
157 void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
158 
159 /* Transparent proxy routines */
160 int ProxyCheck(struct ip *, struct in_addr *, u_short *);
161 void ProxyModify(struct alias_link *, struct ip *, int, int);
162 
163 
164 enum alias_tcp_state {
165     ALIAS_TCP_STATE_NOT_CONNECTED,
166     ALIAS_TCP_STATE_CONNECTED,
167     ALIAS_TCP_STATE_DISCONNECTED
168 };
169 
170 int GetPptpAlias (struct in_addr*);
171 /*lint -restore */
172 #endif /* defined(ALIAS_LOCAL_H) */
173