1f987e1bdSBrian Somers /*- 2e83aaae3SBrian Somers * Copyright (c) 2001 Charles Mott <cm@linktel.net> 3f987e1bdSBrian Somers * All rights reserved. 4f987e1bdSBrian Somers * 5f987e1bdSBrian Somers * Redistribution and use in source and binary forms, with or without 6f987e1bdSBrian Somers * modification, are permitted provided that the following conditions 7f987e1bdSBrian Somers * are met: 8f987e1bdSBrian Somers * 1. Redistributions of source code must retain the above copyright 9f987e1bdSBrian Somers * notice, this list of conditions and the following disclaimer. 10f987e1bdSBrian Somers * 2. Redistributions in binary form must reproduce the above copyright 11f987e1bdSBrian Somers * notice, this list of conditions and the following disclaimer in the 12f987e1bdSBrian Somers * documentation and/or other materials provided with the distribution. 13f987e1bdSBrian Somers * 14f987e1bdSBrian Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15f987e1bdSBrian Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16f987e1bdSBrian Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17f987e1bdSBrian Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18f987e1bdSBrian Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19f987e1bdSBrian Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20f987e1bdSBrian Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21f987e1bdSBrian Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22f987e1bdSBrian Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23f987e1bdSBrian Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24f987e1bdSBrian Somers * SUCH DAMAGE. 25f987e1bdSBrian Somers * 26f987e1bdSBrian Somers * $FreeBSD$ 27f987e1bdSBrian Somers */ 28f987e1bdSBrian Somers 2971593f95SBrian Somers /* 3071593f95SBrian Somers * Alias_local.h contains the function prototypes for alias.c, 3171593f95SBrian Somers * alias_db.c, alias_util.c and alias_ftp.c, alias_irc.c (as well 3271593f95SBrian Somers * as any future add-ons). It also includes macros, globals and 3371593f95SBrian Somers * struct definitions shared by more than one alias*.c file. 3471593f95SBrian Somers * 3571593f95SBrian Somers * This include file is intended to be used only within the aliasing 3671593f95SBrian Somers * software. Outside world interfaces are defined in alias.h 3771593f95SBrian Somers * 3871593f95SBrian Somers * This software is placed into the public domain with no restrictions 3971593f95SBrian Somers * on its distribution. 4071593f95SBrian Somers * 4171593f95SBrian Somers * Initial version: August, 1996 (cjm) 4271593f95SBrian Somers * 4371593f95SBrian Somers * <updated several times by original author and Eivind Eklund> 443b160b8bSBrian Somers */ 453b160b8bSBrian Somers 4671593f95SBrian Somers #ifndef _ALIAS_LOCAL_H_ 4771593f95SBrian Somers #define _ALIAS_LOCAL_H_ 4871593f95SBrian Somers 49be4f3cd0SPaolo Pisati #include <sys/types.h> 50be4f3cd0SPaolo Pisati #include <sys/sysctl.h> 515e289f9eSPoul-Henning Kamp 52c8564bffSGleb Smirnoff #ifdef _KERNEL 53be4f3cd0SPaolo Pisati #include <sys/malloc.h> 54ccd57eeaSPaolo Pisati #include <sys/param.h> 55be4f3cd0SPaolo Pisati #include <sys/lock.h> 56ccd57eeaSPaolo Pisati #include <sys/mutex.h> 57ccd57eeaSPaolo Pisati 58be4f3cd0SPaolo Pisati /* XXX: LibAliasSetTarget() uses this constant. */ 59c8564bffSGleb Smirnoff #define INADDR_NONE 0xffffffff 60c8564bffSGleb Smirnoff #endif 61c8564bffSGleb Smirnoff 625e289f9eSPoul-Henning Kamp /* Sizes of input and output link tables */ 635e289f9eSPoul-Henning Kamp #define LINK_TABLE_OUT_SIZE 101 645e289f9eSPoul-Henning Kamp #define LINK_TABLE_IN_SIZE 4001 655e289f9eSPoul-Henning Kamp 665e289f9eSPoul-Henning Kamp struct proxy_entry; 675e289f9eSPoul-Henning Kamp 685e289f9eSPoul-Henning Kamp struct libalias { 695e289f9eSPoul-Henning Kamp LIST_ENTRY(libalias) instancelist; 705e289f9eSPoul-Henning Kamp 715e289f9eSPoul-Henning Kamp int packetAliasMode; /* Mode flags */ 725e289f9eSPoul-Henning Kamp /* - documented in alias.h */ 735e289f9eSPoul-Henning Kamp 745e289f9eSPoul-Henning Kamp struct in_addr aliasAddress; /* Address written onto source */ 755e289f9eSPoul-Henning Kamp /* field of IP packet. */ 765e289f9eSPoul-Henning Kamp 775e289f9eSPoul-Henning Kamp struct in_addr targetAddress; /* IP address incoming packets */ 785e289f9eSPoul-Henning Kamp /* are sent to if no aliasing */ 795e289f9eSPoul-Henning Kamp /* link already exists */ 805e289f9eSPoul-Henning Kamp 815e289f9eSPoul-Henning Kamp struct in_addr nullAddress; /* Used as a dummy parameter for */ 825e289f9eSPoul-Henning Kamp /* some function calls */ 835e289f9eSPoul-Henning Kamp 845e289f9eSPoul-Henning Kamp LIST_HEAD (, alias_link) linkTableOut[LINK_TABLE_OUT_SIZE]; 855e289f9eSPoul-Henning Kamp /* Lookup table of pointers to */ 865e289f9eSPoul-Henning Kamp /* chains of link records. Each */ 875e289f9eSPoul-Henning Kamp 885e289f9eSPoul-Henning Kamp LIST_HEAD (, alias_link) linkTableIn[LINK_TABLE_IN_SIZE]; 895e289f9eSPoul-Henning Kamp /* link record is doubly indexed */ 905e289f9eSPoul-Henning Kamp /* into input and output lookup */ 915e289f9eSPoul-Henning Kamp /* tables. */ 925e289f9eSPoul-Henning Kamp 935e289f9eSPoul-Henning Kamp /* Link statistics */ 945e289f9eSPoul-Henning Kamp int icmpLinkCount; 955e289f9eSPoul-Henning Kamp int udpLinkCount; 965e289f9eSPoul-Henning Kamp int tcpLinkCount; 975e289f9eSPoul-Henning Kamp int pptpLinkCount; 985e289f9eSPoul-Henning Kamp int protoLinkCount; 995e289f9eSPoul-Henning Kamp int fragmentIdLinkCount; 1005e289f9eSPoul-Henning Kamp int fragmentPtrLinkCount; 1015e289f9eSPoul-Henning Kamp int sockCount; 1025e289f9eSPoul-Henning Kamp 1035e289f9eSPoul-Henning Kamp int cleanupIndex; /* Index to chain of link table */ 1045e289f9eSPoul-Henning Kamp /* being inspected for old links */ 1055e289f9eSPoul-Henning Kamp 1065e289f9eSPoul-Henning Kamp int timeStamp; /* System time in seconds for */ 1075e289f9eSPoul-Henning Kamp /* current packet */ 1085e289f9eSPoul-Henning Kamp 109f0f93429SDag-Erling Smørgrav int lastCleanupTime; /* Last time 110f0f93429SDag-Erling Smørgrav * IncrementalCleanup() */ 1115e289f9eSPoul-Henning Kamp /* was called */ 1125e289f9eSPoul-Henning Kamp 1135e289f9eSPoul-Henning Kamp int houseKeepingResidual; /* used by HouseKeeping() */ 1145e289f9eSPoul-Henning Kamp 1155e289f9eSPoul-Henning Kamp int deleteAllLinks; /* If equal to zero, DeleteLink() */ 1165e289f9eSPoul-Henning Kamp /* will not remove permanent links */ 117be4f3cd0SPaolo Pisati 118be4f3cd0SPaolo Pisati /* log descriptor */ 119be4f3cd0SPaolo Pisati #ifdef _KERNEL 120be4f3cd0SPaolo Pisati char *logDesc; 121be4f3cd0SPaolo Pisati #else 122be4f3cd0SPaolo Pisati FILE *logDesc; 12340106c14SGleb Smirnoff #endif 124be4f3cd0SPaolo Pisati /* statistics monitoring */ 1255e289f9eSPoul-Henning Kamp 1265e289f9eSPoul-Henning Kamp int newDefaultLink; /* Indicates if a new aliasing */ 1275e289f9eSPoul-Henning Kamp /* link has been created after a */ 1285e289f9eSPoul-Henning Kamp /* call to PacketAliasIn/Out(). */ 1295e289f9eSPoul-Henning Kamp 1305e289f9eSPoul-Henning Kamp #ifndef NO_FW_PUNCH 1315e289f9eSPoul-Henning Kamp int fireWallFD; /* File descriptor to be able to */ 1325e289f9eSPoul-Henning Kamp /* control firewall. Opened by */ 1335e289f9eSPoul-Henning Kamp /* PacketAliasSetMode on first */ 1345e289f9eSPoul-Henning Kamp /* setting the PKT_ALIAS_PUNCH_FW */ 1355e289f9eSPoul-Henning Kamp /* flag. */ 136f0f93429SDag-Erling Smørgrav int fireWallBaseNum; /* The first firewall entry 137f0f93429SDag-Erling Smørgrav * free for our use */ 138f0f93429SDag-Erling Smørgrav int fireWallNumNums; /* How many entries can we 139f0f93429SDag-Erling Smørgrav * use? */ 140f0f93429SDag-Erling Smørgrav int fireWallActiveNum; /* Which entry did we last 141f0f93429SDag-Erling Smørgrav * use? */ 1425e289f9eSPoul-Henning Kamp char *fireWallField; /* bool array for entries */ 1435e289f9eSPoul-Henning Kamp #endif 1445e289f9eSPoul-Henning Kamp 1455e289f9eSPoul-Henning Kamp unsigned int skinnyPort; /* TCP port used by the Skinny */ 1465e289f9eSPoul-Henning Kamp /* protocol. */ 1475e289f9eSPoul-Henning Kamp 1485e289f9eSPoul-Henning Kamp struct proxy_entry *proxyList; 1495e289f9eSPoul-Henning Kamp 1505e289f9eSPoul-Henning Kamp struct in_addr true_addr; /* in network byte order. */ 1515e289f9eSPoul-Henning Kamp u_short true_port; /* in host byte order. */ 152ccd57eeaSPaolo Pisati #ifdef _KERNEL 153ccd57eeaSPaolo Pisati /* 154ccd57eeaSPaolo Pisati * avoid races in libalias: every public function has to use it. 155ccd57eeaSPaolo Pisati */ 156ccd57eeaSPaolo Pisati struct mtx mutex; 157ccd57eeaSPaolo Pisati #endif 1585e289f9eSPoul-Henning Kamp }; 1595e289f9eSPoul-Henning Kamp 16071593f95SBrian Somers /* Macros */ 1617d96f4efSBrian Somers 162ccd57eeaSPaolo Pisati #ifdef _KERNEL 163ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK_INIT(l) \ 164ccd57eeaSPaolo Pisati mtx_init(&l->mutex, "per-instance libalias mutex", NULL, MTX_DEF) 165ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK_ASSERT(l) mtx_assert(&l->mutex, MA_OWNED) 166ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK(l) mtx_lock(&l->mutex) 167ccd57eeaSPaolo Pisati #define LIBALIAS_UNLOCK(l) mtx_unlock(&l->mutex) 168ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK_DESTROY(l) mtx_destroy(&l->mutex) 169ccd57eeaSPaolo Pisati #else 170ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK_INIT(l) 171ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK_ASSERT(l) 172ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK(l) 173ccd57eeaSPaolo Pisati #define LIBALIAS_UNLOCK(l) 174ccd57eeaSPaolo Pisati #define LIBALIAS_LOCK_DESTROY(l) 175ccd57eeaSPaolo Pisati #endif 176ccd57eeaSPaolo Pisati 1777d96f4efSBrian Somers /* 17871593f95SBrian Somers * The following macro is used to update an 17971593f95SBrian Somers * internet checksum. "delta" is a 32-bit 18071593f95SBrian Somers * accumulation of all the changes to the 18171593f95SBrian Somers * checksum (adding in new 16-bit words and 18271593f95SBrian Somers * subtracting out old words), and "cksum" 18371593f95SBrian Somers * is the checksum value to be updated. 1847d96f4efSBrian Somers */ 18571593f95SBrian Somers #define ADJUST_CHECKSUM(acc, cksum) \ 18671593f95SBrian Somers do { \ 1877d96f4efSBrian Somers acc += cksum; \ 18871593f95SBrian Somers if (acc < 0) { \ 1897d96f4efSBrian Somers acc = -acc; \ 1907d96f4efSBrian Somers acc = (acc >> 16) + (acc & 0xffff); \ 1917d96f4efSBrian Somers acc += acc >> 16; \ 1927d96f4efSBrian Somers cksum = (u_short) ~acc; \ 19371593f95SBrian Somers } else { \ 1947d96f4efSBrian Somers acc = (acc >> 16) + (acc & 0xffff); \ 1957d96f4efSBrian Somers acc += acc >> 16; \ 1967d96f4efSBrian Somers cksum = (u_short) acc; \ 1977d96f4efSBrian Somers } \ 19871593f95SBrian Somers } while (0) 1997d96f4efSBrian Somers 2003b160b8bSBrian Somers 20171593f95SBrian Somers /* Prototypes */ 2023b160b8bSBrian Somers 20359dde15eSGleb Smirnoff /* 20459dde15eSGleb Smirnoff * We do not calculate TCP checksums when libalias is a kernel 20559dde15eSGleb Smirnoff * module, since it has no idea about checksum offloading. 20659dde15eSGleb Smirnoff * If TCP data has changed, then we just set checksum to zero, 20759dde15eSGleb Smirnoff * and caller must recalculate it himself. 20859dde15eSGleb Smirnoff * In case if libalias will edit UDP data, the same approach 20959dde15eSGleb Smirnoff * should be used. 21059dde15eSGleb Smirnoff */ 21159dde15eSGleb Smirnoff #ifndef _KERNEL 21271593f95SBrian Somers u_short IpChecksum(struct ip *_pip); 21371593f95SBrian Somers u_short TcpChecksum(struct ip *_pip); 21459dde15eSGleb Smirnoff #endif 215f0f93429SDag-Erling Smørgrav void 2162871c501SDag-Erling Smørgrav DifferentialChecksum(u_short * _cksum, void * _new, void * _old, int _n); 2173b160b8bSBrian Somers 2183b160b8bSBrian Somers /* Internal data access */ 2193b160b8bSBrian Somers struct alias_link * 2205e289f9eSPoul-Henning Kamp FindIcmpIn(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr, 22171593f95SBrian Somers u_short _id_alias, int _create); 2223b160b8bSBrian Somers struct alias_link * 2235e289f9eSPoul-Henning Kamp FindIcmpOut(struct libalias *la, struct in_addr _src_addr, struct in_addr _dst_addr, 22471593f95SBrian Somers u_short _id, int _create); 2253b160b8bSBrian Somers struct alias_link * 2265e289f9eSPoul-Henning Kamp FindFragmentIn1(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr, 22771593f95SBrian Somers u_short _ip_id); 2283b160b8bSBrian Somers struct alias_link * 2295e289f9eSPoul-Henning Kamp FindFragmentIn2(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr, 23071593f95SBrian Somers u_short _ip_id); 2313b160b8bSBrian Somers struct alias_link * 2325e289f9eSPoul-Henning Kamp AddFragmentPtrLink(struct libalias *la, struct in_addr _dst_addr, u_short _ip_id); 2333b160b8bSBrian Somers struct alias_link * 2345e289f9eSPoul-Henning Kamp FindFragmentPtr(struct libalias *la, struct in_addr _dst_addr, u_short _ip_id); 2353b160b8bSBrian Somers struct alias_link * 2365e289f9eSPoul-Henning Kamp FindProtoIn(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr, 23771593f95SBrian Somers u_char _proto); 238483d2f22SRuslan Ermilov struct alias_link * 2395e289f9eSPoul-Henning Kamp FindProtoOut(struct libalias *la, struct in_addr _src_addr, struct in_addr _dst_addr, 24071593f95SBrian Somers u_char _proto); 241483d2f22SRuslan Ermilov struct alias_link * 2425e289f9eSPoul-Henning Kamp FindUdpTcpIn(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr, 24371593f95SBrian Somers u_short _dst_port, u_short _alias_port, u_char _proto, int _create); 2443b160b8bSBrian Somers struct alias_link * 2455e289f9eSPoul-Henning Kamp FindUdpTcpOut(struct libalias *la, struct in_addr _src_addr, struct in_addr _dst_addr, 24671593f95SBrian Somers u_short _src_port, u_short _dst_port, u_char _proto, int _create); 24755a39fc5SRuslan Ermilov struct alias_link * 2485e289f9eSPoul-Henning Kamp AddPptp(struct libalias *la, struct in_addr _src_addr, struct in_addr _dst_addr, 24971593f95SBrian Somers struct in_addr _alias_addr, u_int16_t _src_call_id); 25055a39fc5SRuslan Ermilov struct alias_link * 2515e289f9eSPoul-Henning Kamp FindPptpOutByCallId(struct libalias *la, struct in_addr _src_addr, 25271593f95SBrian Somers struct in_addr _dst_addr, u_int16_t _src_call_id); 25303453c5eSRuslan Ermilov struct alias_link * 2545e289f9eSPoul-Henning Kamp FindPptpInByCallId(struct libalias *la, struct in_addr _dst_addr, 25571593f95SBrian Somers struct in_addr _alias_addr, u_int16_t _dst_call_id); 25603453c5eSRuslan Ermilov struct alias_link * 2575e289f9eSPoul-Henning Kamp FindPptpOutByPeerCallId(struct libalias *la, struct in_addr _src_addr, 25871593f95SBrian Somers struct in_addr _dst_addr, u_int16_t _dst_call_id); 25903453c5eSRuslan Ermilov struct alias_link * 2605e289f9eSPoul-Henning Kamp FindPptpInByPeerCallId(struct libalias *la, struct in_addr _dst_addr, 26171593f95SBrian Somers struct in_addr _alias_addr, u_int16_t _alias_call_id); 262642e43b3SArchie Cobbs struct alias_link * 2635e289f9eSPoul-Henning Kamp FindRtspOut(struct libalias *la, struct in_addr _src_addr, struct in_addr _dst_addr, 26471593f95SBrian Somers u_short _src_port, u_short _alias_port, u_char _proto); 2653b160b8bSBrian Somers struct in_addr 2665e289f9eSPoul-Henning Kamp FindOriginalAddress(struct libalias *la, struct in_addr _alias_addr); 2673b160b8bSBrian Somers struct in_addr 2685e289f9eSPoul-Henning Kamp FindAliasAddress(struct libalias *la, struct in_addr _original_addr); 2693b160b8bSBrian Somers 2703b160b8bSBrian Somers /* External data access/modification */ 271f0f93429SDag-Erling Smørgrav int 272f0f93429SDag-Erling Smørgrav FindNewPortGroup(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr, 27371593f95SBrian Somers u_short _src_port, u_short _dst_port, u_short _port_count, 27471593f95SBrian Somers u_char _proto, u_char _align); 275ed01a582SDag-Erling Smørgrav void GetFragmentAddr(struct alias_link *_lnk, struct in_addr *_src_addr); 276ed01a582SDag-Erling Smørgrav void SetFragmentAddr(struct alias_link *_lnk, struct in_addr _src_addr); 277ed01a582SDag-Erling Smørgrav void GetFragmentPtr(struct alias_link *_lnk, char **_fptr); 278ed01a582SDag-Erling Smørgrav void SetFragmentPtr(struct alias_link *_lnk, char *fptr); 279ed01a582SDag-Erling Smørgrav void SetStateIn(struct alias_link *_lnk, int _state); 280ed01a582SDag-Erling Smørgrav void SetStateOut(struct alias_link *_lnk, int _state); 281ed01a582SDag-Erling Smørgrav int GetStateIn (struct alias_link *_lnk); 282ed01a582SDag-Erling Smørgrav int GetStateOut(struct alias_link *_lnk); 28371593f95SBrian Somers struct in_addr 284ed01a582SDag-Erling Smørgrav GetOriginalAddress(struct alias_link *_lnk); 28571593f95SBrian Somers struct in_addr 286ed01a582SDag-Erling Smørgrav GetDestAddress(struct alias_link *_lnk); 28771593f95SBrian Somers struct in_addr 288ed01a582SDag-Erling Smørgrav GetAliasAddress(struct alias_link *_lnk); 28971593f95SBrian Somers struct in_addr 2905e289f9eSPoul-Henning Kamp GetDefaultAliasAddress(struct libalias *la); 2915e289f9eSPoul-Henning Kamp void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr); 292ed01a582SDag-Erling Smørgrav u_short GetOriginalPort(struct alias_link *_lnk); 293ed01a582SDag-Erling Smørgrav u_short GetAliasPort(struct alias_link *_lnk); 29471593f95SBrian Somers struct in_addr 295ed01a582SDag-Erling Smørgrav GetProxyAddress(struct alias_link *_lnk); 296ed01a582SDag-Erling Smørgrav void SetProxyAddress(struct alias_link *_lnk, struct in_addr _addr); 297ed01a582SDag-Erling Smørgrav u_short GetProxyPort(struct alias_link *_lnk); 298ed01a582SDag-Erling Smørgrav void SetProxyPort(struct alias_link *_lnk, u_short _port); 299ed01a582SDag-Erling Smørgrav void SetAckModified(struct alias_link *_lnk); 300ed01a582SDag-Erling Smørgrav int GetAckModified(struct alias_link *_lnk); 301ed01a582SDag-Erling Smørgrav int GetDeltaAckIn(struct ip *_pip, struct alias_link *_lnk); 302ed01a582SDag-Erling Smørgrav int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_lnk); 303ed01a582SDag-Erling Smørgrav void AddSeq (struct ip *_pip, struct alias_link *_lnk, int _delta); 304ed01a582SDag-Erling Smørgrav void SetExpire (struct alias_link *_lnk, int _expire); 3055e289f9eSPoul-Henning Kamp void ClearCheckNewLink(struct libalias *la); 306ed01a582SDag-Erling Smørgrav void SetProtocolFlags(struct alias_link *_lnk, int _pflags); 307ed01a582SDag-Erling Smørgrav int GetProtocolFlags(struct alias_link *_lnk); 308ed01a582SDag-Erling Smørgrav void SetDestCallId(struct alias_link *_lnk, u_int16_t _cid); 309f0f93429SDag-Erling Smørgrav 310b5ce85feSBrian Somers #ifndef NO_FW_PUNCH 311ed01a582SDag-Erling Smørgrav void PunchFWHole(struct alias_link *_lnk); 312f0f93429SDag-Erling Smørgrav 313b5ce85feSBrian Somers #endif 3148ddc51bcSEivind Eklund 3153b160b8bSBrian Somers /* Housekeeping function */ 3165e289f9eSPoul-Henning Kamp void HouseKeeping(struct libalias *); 3173b160b8bSBrian Somers 3183b160b8bSBrian Somers /* Tcp specfic routines */ 3193b160b8bSBrian Somers /* lint -save -library Suppress flexelint warnings */ 3207d96f4efSBrian Somers 3217d96f4efSBrian Somers /* Transparent proxy routines */ 322f0f93429SDag-Erling Smørgrav int 323f0f93429SDag-Erling Smørgrav ProxyCheck(struct libalias *la, struct ip *_pip, struct in_addr *_proxy_server_addr, 32471593f95SBrian Somers u_short * _proxy_server_port); 325f0f93429SDag-Erling Smørgrav void 326ed01a582SDag-Erling Smørgrav ProxyModify(struct libalias *la, struct alias_link *_lnk, struct ip *_pip, 32771593f95SBrian Somers int _maxpacketsize, int _proxy_type); 3283efa11bbSBrian Somers 3298ddc51bcSEivind Eklund enum alias_tcp_state { 3308ddc51bcSEivind Eklund ALIAS_TCP_STATE_NOT_CONNECTED, 3318ddc51bcSEivind Eklund ALIAS_TCP_STATE_CONNECTED, 3328ddc51bcSEivind Eklund ALIAS_TCP_STATE_DISCONNECTED 3338ddc51bcSEivind Eklund }; 33471593f95SBrian Somers 3359fa0fd26SDag-Erling Smørgrav #if defined(_NETINET_IP_H_) 3369fa0fd26SDag-Erling Smørgrav static __inline void * 3379fa0fd26SDag-Erling Smørgrav ip_next(struct ip *iphdr) 3389fa0fd26SDag-Erling Smørgrav { 3399fa0fd26SDag-Erling Smørgrav char *p = (char *)iphdr; 3409fa0fd26SDag-Erling Smørgrav return (&p[iphdr->ip_hl * 4]); 3419fa0fd26SDag-Erling Smørgrav } 3429fa0fd26SDag-Erling Smørgrav #endif 3439fa0fd26SDag-Erling Smørgrav 3449fa0fd26SDag-Erling Smørgrav #if defined(_NETINET_TCP_H_) 3459fa0fd26SDag-Erling Smørgrav static __inline void * 3469fa0fd26SDag-Erling Smørgrav tcp_next(struct tcphdr *tcphdr) 3479fa0fd26SDag-Erling Smørgrav { 3489fa0fd26SDag-Erling Smørgrav char *p = (char *)tcphdr; 3499fa0fd26SDag-Erling Smørgrav return (&p[tcphdr->th_off * 4]); 3509fa0fd26SDag-Erling Smørgrav } 3519fa0fd26SDag-Erling Smørgrav #endif 3529fa0fd26SDag-Erling Smørgrav 3539fa0fd26SDag-Erling Smørgrav #if defined(_NETINET_UDP_H_) 3549fa0fd26SDag-Erling Smørgrav static __inline void * 3559fa0fd26SDag-Erling Smørgrav udp_next(struct udphdr *udphdr) 3569fa0fd26SDag-Erling Smørgrav { 3579fa0fd26SDag-Erling Smørgrav return ((void *)(udphdr + 1)); 3589fa0fd26SDag-Erling Smørgrav } 3599fa0fd26SDag-Erling Smørgrav #endif 3609fa0fd26SDag-Erling Smørgrav 36171593f95SBrian Somers #endif /* !_ALIAS_LOCAL_H_ */ 362