]>
Commit | Line | Data |
---|---|---|
e6ccf245 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 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" |
e1ba42a4 | 21 | #include "store_key_md5.h" |
9c947ba7 | 22 | #include "StoreClient.h" |
e6ccf245 | 23 | |
582c2af2 FC |
24 | class HttpRequest; |
25 | ||
077fe581 | 26 | /** |
63be0a78 | 27 | \ingroup ServerProtocolICPAPI |
28 | * | |
077fe581 | 29 | * This struct is the wire-level header. |
30 | * DO NOT add more move fields on pain of breakage. | |
e6ccf245 | 31 | * DO NOT add virtual methods. |
32 | */ | |
26ac0430 | 33 | struct _icp_common_t { |
63be0a78 | 34 | /** opcode */ |
35 | unsigned char opcode; | |
36 | /** version number */ | |
37 | unsigned char version; | |
38 | /** total length (bytes) */ | |
39 | unsigned short length; | |
40 | /** req number (req'd for UDP) */ | |
09aabd84 FC |
41 | uint32_t reqnum; |
42 | uint32_t flags; | |
43 | uint32_t pad; | |
63be0a78 | 44 | /** sender host id */ |
09aabd84 | 45 | uint32_t shostid; |
63be0a78 | 46 | |
47 | /// \todo I don't believe this header is included in non-c++ code anywhere | |
f53969cc | 48 | /// the struct should become a public POD class and kill these ifdef. |
e6ccf245 | 49 | #ifdef __cplusplus |
62e76326 | 50 | |
51 | _icp_common_t(); | |
52 | _icp_common_t(char *buf, unsigned int len); | |
53 | ||
b7ac5457 | 54 | void handleReply(char *buf, Ip::Address &from); |
e6ccf245 | 55 | static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad); |
56 | icp_opcode getOpCode() const; | |
57 | #endif | |
58 | }; | |
09bbee4c FC |
59 | typedef struct _icp_common_t icp_common_t; |
60 | ||
e6ccf245 | 61 | #ifdef __cplusplus |
62 | ||
63be0a78 | 63 | /** |
64 | \ingroup ServerProtocolICPAPI | |
65 | \todo mempool this | |
66 | */ | |
62e76326 | 67 | class ICPState |
68 | { | |
69 | ||
70 | public: | |
63be0a78 | 71 | ICPState(icp_common_t &aHeader, HttpRequest *aRequest); |
72 | virtual ~ICPState(); | |
e6ccf245 | 73 | icp_common_t header; |
190154cf | 74 | HttpRequest *request; |
e6ccf245 | 75 | int fd; |
62e76326 | 76 | |
b7ac5457 | 77 | Ip::Address from; |
e6ccf245 | 78 | char *url; |
79 | }; | |
80 | ||
81 | #endif | |
82 | ||
63be0a78 | 83 | /// \ingroup ServerProtocolICPAPI |
26ac0430 | 84 | struct icpUdpData { |
65d448bc AJ |
85 | |
86 | /// IP address for the remote end. Because we reply to packets from unknown non-peers. | |
b7ac5457 | 87 | Ip::Address address; |
65d448bc | 88 | |
d4cb310b | 89 | void *msg; |
90 | size_t len; | |
91 | icpUdpData *next; | |
92 | #ifndef LESS_TIMING | |
62e76326 | 93 | |
d4cb310b | 94 | struct timeval start; |
95 | #endif | |
62e76326 | 96 | |
02c8dde5 | 97 | LogTags logcode; |
62e76326 | 98 | |
d4cb310b | 99 | struct timeval queue_time; |
100 | }; | |
101 | ||
e0d28505 AJ |
102 | extern Comm::ConnectionPointer icpIncomingConn; |
103 | extern Comm::ConnectionPointer icpOutgoingConn; | |
104 | extern Ip::Address theIcpPublicHostID; | |
105 | ||
63be0a78 | 106 | /// \ingroup ServerProtocolICPAPI |
8a648e8d | 107 | HttpRequest* icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from); |
62e76326 | 108 | |
63be0a78 | 109 | /// \ingroup ServerProtocolICPAPI |
8a648e8d | 110 | bool icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request); |
62e76326 | 111 | |
63be0a78 | 112 | /// \ingroup ServerProtocolICPAPI |
8a648e8d | 113 | void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from); |
63be0a78 | 114 | |
115 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 116 | icp_opcode icpGetCommonOpcode(); |
e6ccf245 | 117 | |
63be0a78 | 118 | /// \ingroup ServerProtocolICPAPI |
678203f3 | 119 | int icpUdpSend(int, const Ip::Address &, icp_common_t *, const LogTags &, int); |
63be0a78 | 120 | |
121 | /// \ingroup ServerProtocolICPAPI | |
02c8dde5 | 122 | LogTags icpLogFromICPCode(icp_opcode opcode); |
62e76326 | 123 | |
63be0a78 | 124 | /// \ingroup ServerProtocolICPAPI |
b7ac5457 | 125 | void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd); |
63be0a78 | 126 | |
127 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 128 | PF icpHandleUdp; |
63be0a78 | 129 | |
130 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 131 | PF icpUdpSendQueue; |
62e76326 | 132 | |
63be0a78 | 133 | /// \ingroup ServerProtocolICPAPI |
8a648e8d | 134 | void icpHandleIcpV3(int, Ip::Address &, char *, int); |
63be0a78 | 135 | |
136 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 137 | int icpCheckUdpHit(StoreEntry *, HttpRequest * request); |
63be0a78 | 138 | |
139 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 140 | void icpOpenPorts(void); |
63be0a78 | 141 | |
142 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 143 | void icpConnectionShutdown(void); |
63be0a78 | 144 | |
145 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 146 | void icpClosePorts(void); |
63be0a78 | 147 | |
148 | /// \ingroup ServerProtocolICPAPI | |
8a648e8d | 149 | int icpSetCacheKey(const cache_key * key); |
e6ccf245 | 150 | |
63be0a78 | 151 | /// \ingroup ServerProtocolICPAPI |
8a648e8d | 152 | const cache_key *icpGetCacheKey(const char *url, int reqnum); |
e6ccf245 | 153 | |
e6ccf245 | 154 | #endif /* SQUID_ICP_H */ |
f53969cc | 155 |