]> git.saurik.com Git - apple/network_cmds.git/blob - alias/alias_local.h
network_cmds-85.tar.gz
[apple/network_cmds.git] / alias / alias_local.h
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 Eiklund>
16 */
17 #ifndef ALIAS_LOCAL_H
18 #define ALIAS_LOCAL_H
19
20
21 /*
22 Macros
23 */
24
25 /*
26 The following macro is used to update an
27 internet checksum. "delta" is a 32-bit
28 accumulation of all the changes to the
29 checksum (adding in new 16-bit words and
30 subtracting out old words), and "cksum"
31 is the checksum value to be updated.
32 */
33 #define ADJUST_CHECKSUM(acc, cksum) { \
34 acc += cksum; \
35 if (acc < 0) \
36 { \
37 acc = -acc; \
38 acc = (acc >> 16) + (acc & 0xffff); \
39 acc += acc >> 16; \
40 cksum = (u_short) ~acc; \
41 } \
42 else \
43 { \
44 acc = (acc >> 16) + (acc & 0xffff); \
45 acc += acc >> 16; \
46 cksum = (u_short) acc; \
47 } \
48 }
49
50
51 /*
52 Globals
53 */
54
55 extern int packetAliasMode;
56
57
58 /*
59 Structs
60 */
61
62 struct alias_link; /* Incomplete structure */
63
64
65 /*
66 Prototypes
67 */
68
69 /* General utilities */
70 u_short IpChecksum(struct ip *);
71 u_short TcpChecksum(struct ip *);
72 void DifferentialChecksum(u_short *, u_short *, u_short *, int);
73
74 /* Internal data access */
75 struct alias_link *
76 FindIcmpIn(struct in_addr, struct in_addr, u_short);
77
78 struct alias_link *
79 FindIcmpOut(struct in_addr, struct in_addr, u_short);
80
81 struct alias_link *
82 FindFragmentIn1(struct in_addr, struct in_addr, u_short);
83
84 struct alias_link *
85 FindFragmentIn2(struct in_addr, struct in_addr, u_short);
86
87 struct alias_link *
88 AddFragmentPtrLink(struct in_addr, u_short);
89
90 struct alias_link *
91 FindFragmentPtr(struct in_addr, u_short);
92
93 struct alias_link *
94 FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char);
95
96 struct alias_link *
97 FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
98
99 struct in_addr
100 FindOriginalAddress(struct in_addr);
101
102 struct in_addr
103 FindAliasAddress(struct in_addr);
104
105 /* External data access/modification */
106 void GetFragmentAddr(struct alias_link *, struct in_addr *);
107 void SetFragmentAddr(struct alias_link *, struct in_addr);
108 void GetFragmentPtr(struct alias_link *, char **);
109 void SetFragmentPtr(struct alias_link *, char *);
110 void SetStateIn(struct alias_link *, int);
111 void SetStateOut(struct alias_link *, int);
112 int GetStateIn(struct alias_link *);
113 int GetStateOut(struct alias_link *);
114 struct in_addr GetOriginalAddress(struct alias_link *);
115 struct in_addr GetDestAddress(struct alias_link *);
116 struct in_addr GetAliasAddress(struct alias_link *);
117 struct in_addr GetDefaultAliasAddress(void);
118 void SetDefaultAliasAddress(struct in_addr);
119 u_short GetOriginalPort(struct alias_link *);
120 u_short GetAliasPort(struct alias_link *);
121 struct in_addr GetProxyAddress(struct alias_link *);
122 void SetProxyAddress(struct alias_link *, struct in_addr);
123 u_short GetProxyPort(struct alias_link *);
124 void SetProxyPort(struct alias_link *, u_short);
125 void SetAckModified(struct alias_link *);
126 int GetAckModified(struct alias_link *);
127 int GetDeltaAckIn(struct ip *, struct alias_link *);
128 int GetDeltaSeqOut(struct ip *, struct alias_link *);
129 void AddSeq(struct ip *, struct alias_link *, int);
130 void SetExpire(struct alias_link *, int);
131 void ClearCheckNewLink(void);
132 #ifndef NO_FW_PUNCH
133 void PunchFWHole(struct alias_link *);
134 #endif
135
136
137 /* Housekeeping function */
138 void HouseKeeping(void);
139
140 /* Tcp specfic routines */
141 /*lint -save -library Suppress flexelint warnings */
142
143 /* FTP routines */
144 void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
145
146 /* IRC routines */
147 void AliasHandleIrcOut(struct ip *, struct alias_link *, int);
148
149 /* NetBIOS routines */
150 int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
151 int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
152
153 /* CUSeeMe routines */
154 void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
155 void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
156
157 /* Transparent proxy routines */
158 int ProxyCheck(struct ip *, struct in_addr *, u_short *);
159 void ProxyModify(struct alias_link *, struct ip *, int, int);
160
161
162 enum alias_tcp_state {
163 ALIAS_TCP_STATE_NOT_CONNECTED,
164 ALIAS_TCP_STATE_CONNECTED,
165 ALIAS_TCP_STATE_DISCONNECTED
166 };
167
168 int GetPptpAlias (struct in_addr*);
169 /*lint -restore */
170 #endif /* defined(ALIAS_LOCAL_H) */