]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ICP.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ICP.h
CommitLineData
e6ccf245 1/*
bbc27441 2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
e6ccf245 3 *
bbc27441
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
e6ccf245 7 */
8
9#ifndef SQUID_ICP_H
10#define SQUID_ICP_H
11
63be0a78 12/**
13 \defgroup ServerProtocolICPAPI ICP
14 \ingroup ServerProtocol
15 */
16
e0d28505 17#include "comm/forward.h"
582c2af2 18#include "icp_opcode.h"
e0d28505 19#include "ip/Address.h"
02c8dde5 20#include "LogTags.h"
602d9612 21#include "StoreClient.h"
e6ccf245 22
582c2af2
FC
23class HttpRequest;
24
077fe581 25/**
63be0a78 26 \ingroup ServerProtocolICPAPI
27 *
077fe581 28 * This struct is the wire-level header.
29 * DO NOT add more move fields on pain of breakage.
e6ccf245 30 * DO NOT add virtual methods.
31 */
26ac0430 32struct _icp_common_t {
63be0a78 33 /** opcode */
34 unsigned char opcode;
35 /** version number */
36 unsigned char version;
37 /** total length (bytes) */
38 unsigned short length;
39 /** req number (req'd for UDP) */
09aabd84
FC
40 uint32_t reqnum;
41 uint32_t flags;
42 uint32_t pad;
63be0a78 43 /** sender host id */
09aabd84 44 uint32_t shostid;
63be0a78 45
46/// \todo I don't believe this header is included in non-c++ code anywhere
f53969cc 47/// the struct should become a public POD class and kill these ifdef.
e6ccf245 48#ifdef __cplusplus
62e76326 49
50 _icp_common_t();
51 _icp_common_t(char *buf, unsigned int len);
52
b7ac5457 53 void handleReply(char *buf, Ip::Address &from);
e6ccf245 54 static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad);
55 icp_opcode getOpCode() const;
56#endif
57};
09bbee4c
FC
58typedef struct _icp_common_t icp_common_t;
59
e6ccf245 60#ifdef __cplusplus
61
63be0a78 62/// \ingroup ServerProtocolICPAPI
62e76326 63inline icp_opcode & operator++ (icp_opcode & aCode)
64{
1f1ae50a 65 int tmp = (int) aCode;
66 aCode = (icp_opcode) (++tmp);
e6ccf245 67 return aCode;
68}
69
63be0a78 70/**
71 \ingroup ServerProtocolICPAPI
72 \todo mempool this
73 */
62e76326 74class ICPState
75{
76
77public:
63be0a78 78 ICPState(icp_common_t &aHeader, HttpRequest *aRequest);
79 virtual ~ICPState();
e6ccf245 80 icp_common_t header;
190154cf 81 HttpRequest *request;
e6ccf245 82 int fd;
62e76326 83
b7ac5457 84 Ip::Address from;
e6ccf245 85 char *url;
86};
87
88#endif
89
63be0a78 90/// \ingroup ServerProtocolICPAPI
26ac0430 91struct icpUdpData {
65d448bc
AJ
92
93 /// IP address for the remote end. Because we reply to packets from unknown non-peers.
b7ac5457 94 Ip::Address address;
65d448bc 95
d4cb310b 96 void *msg;
97 size_t len;
98 icpUdpData *next;
99#ifndef LESS_TIMING
62e76326 100
d4cb310b 101 struct timeval start;
102#endif
62e76326 103
02c8dde5 104 LogTags logcode;
62e76326 105
d4cb310b 106 struct timeval queue_time;
107};
108
e0d28505
AJ
109extern Comm::ConnectionPointer icpIncomingConn;
110extern Comm::ConnectionPointer icpOutgoingConn;
111extern Ip::Address theIcpPublicHostID;
112
63be0a78 113/// \ingroup ServerProtocolICPAPI
8a648e8d 114HttpRequest* icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from);
62e76326 115
63be0a78 116/// \ingroup ServerProtocolICPAPI
8a648e8d 117bool icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request);
62e76326 118
63be0a78 119/// \ingroup ServerProtocolICPAPI
8a648e8d 120void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from);
63be0a78 121
122/// \ingroup ServerProtocolICPAPI
8a648e8d 123icp_opcode icpGetCommonOpcode();
e6ccf245 124
63be0a78 125/// \ingroup ServerProtocolICPAPI
02c8dde5 126int icpUdpSend(int, const Ip::Address &, icp_common_t *, LogTags, int);
63be0a78 127
128/// \ingroup ServerProtocolICPAPI
02c8dde5 129LogTags icpLogFromICPCode(icp_opcode opcode);
62e76326 130
63be0a78 131/// \ingroup ServerProtocolICPAPI
b7ac5457 132void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd);
63be0a78 133
134/// \ingroup ServerProtocolICPAPI
8a648e8d 135PF icpHandleUdp;
63be0a78 136
137/// \ingroup ServerProtocolICPAPI
8a648e8d 138PF icpUdpSendQueue;
62e76326 139
63be0a78 140/// \ingroup ServerProtocolICPAPI
8a648e8d 141void icpHandleIcpV3(int, Ip::Address &, char *, int);
63be0a78 142
143/// \ingroup ServerProtocolICPAPI
8a648e8d 144int icpCheckUdpHit(StoreEntry *, HttpRequest * request);
63be0a78 145
146/// \ingroup ServerProtocolICPAPI
8a648e8d 147void icpOpenPorts(void);
63be0a78 148
149/// \ingroup ServerProtocolICPAPI
8a648e8d 150void icpConnectionShutdown(void);
63be0a78 151
152/// \ingroup ServerProtocolICPAPI
8a648e8d 153void icpClosePorts(void);
63be0a78 154
155/// \ingroup ServerProtocolICPAPI
8a648e8d 156int icpSetCacheKey(const cache_key * key);
e6ccf245 157
63be0a78 158/// \ingroup ServerProtocolICPAPI
8a648e8d 159const cache_key *icpGetCacheKey(const char *url, int reqnum);
e6ccf245 160
e6ccf245 161#endif /* SQUID_ICP_H */
f53969cc 162