alias_local.h revision 44307
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
55extern int packetAliasMode;
56
57
58/*
59    Structs
60*/
61
62struct alias_link;    /* Incomplete structure */
63
64
65/*
66    Prototypes
67*/
68
69/* General utilities */
70u_short IpChecksum(struct ip *);
71u_short TcpChecksum(struct ip *);
72void DifferentialChecksum(u_short *, u_short *, u_short *, int);
73
74/* Internal data access */
75struct alias_link *
76FindIcmpIn(struct in_addr, struct in_addr, u_short);
77
78struct alias_link *
79FindIcmpOut(struct in_addr, struct in_addr, u_short);
80
81struct alias_link *
82FindFragmentIn1(struct in_addr, struct in_addr, u_short);
83
84struct alias_link *
85FindFragmentIn2(struct in_addr, struct in_addr, u_short);
86
87struct alias_link *
88AddFragmentPtrLink(struct in_addr, u_short);
89
90struct alias_link *
91FindFragmentPtr(struct in_addr, u_short);
92
93struct alias_link *
94FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char);
95
96struct alias_link *
97FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
98
99struct in_addr
100FindOriginalAddress(struct in_addr);
101
102struct in_addr
103FindAliasAddress(struct in_addr);
104
105/* External data access/modification */
106void GetFragmentAddr(struct alias_link *, struct in_addr *);
107void SetFragmentAddr(struct alias_link *, struct in_addr);
108void GetFragmentPtr(struct alias_link *, char **);
109void SetFragmentPtr(struct alias_link *, char *);
110void SetStateIn(struct alias_link *, int);
111void SetStateOut(struct alias_link *, int);
112int GetStateIn(struct alias_link *);
113int GetStateOut(struct alias_link *);
114struct in_addr GetOriginalAddress(struct alias_link *);
115struct in_addr GetDestAddress(struct alias_link *);
116struct in_addr GetAliasAddress(struct alias_link *);
117struct in_addr GetDefaultAliasAddress(void);
118void SetDefaultAliasAddress(struct in_addr);
119u_short GetOriginalPort(struct alias_link *);
120u_short GetAliasPort(struct alias_link *);
121struct in_addr GetProxyAddress(struct alias_link *);
122void SetProxyAddress(struct alias_link *, struct in_addr);
123u_short GetProxyPort(struct alias_link *);
124void SetProxyPort(struct alias_link *, u_short);
125void SetAckModified(struct alias_link *);
126int GetAckModified(struct alias_link *);
127int GetDeltaAckIn(struct ip *, struct alias_link *);
128int GetDeltaSeqOut(struct ip *, struct alias_link *);
129void AddSeq(struct ip *, struct alias_link *, int);
130void SetExpire(struct alias_link *, int);
131void ClearCheckNewLink(void);
132#ifndef NO_FW_PUNCH
133void PunchFWHole(struct alias_link *);
134#endif
135
136
137/* Housekeeping function */
138void HouseKeeping(void);
139
140/* Tcp specfic routines */
141/*lint -save -library Suppress flexelint warnings */
142
143/* FTP routines */
144void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
145
146/* IRC routines */
147void AliasHandleIrcOut(struct ip *pip, struct alias_link *link, int maxsize );
148
149/* NetBIOS routines */
150int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
151int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
152
153/* CUSeeMe routines */
154void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
155void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
156
157/* Transparent proxy routines */
158int ProxyCheck(struct ip *, struct in_addr *, u_short *);
159void ProxyModify(struct alias_link *, struct ip *, int, int);
160
161
162enum alias_tcp_state {
163    ALIAS_TCP_STATE_NOT_CONNECTED,
164    ALIAS_TCP_STATE_CONNECTED,
165    ALIAS_TCP_STATE_DISCONNECTED
166};
167
168int GetPptpAlias (struct in_addr*);
169/*lint -restore */
170#endif /* defined(ALIAS_LOCAL_H) */
171