]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/ecap/Host.cc
2 * DEBUG: section 93 eCAP Interface
5 #include <libecap/adapter/service.h>
6 #include <libecap/common/names.h>
7 #include <libecap/common/registry.h>
8 #include "base/TextException.h"
9 #include "adaptation/ecap/ServiceRep.h"
10 #include "adaptation/ecap/Host.h"
11 #include "adaptation/ecap/MessageRep.h"
12 #include "HttpRequest.h"
13 #include "HttpReply.h"
15 const libecap::Name
Adaptation::Ecap::protocolInternal("internal", libecap::Name::NextId());
16 const libecap::Name
Adaptation::Ecap::protocolCacheObj("cache_object", libecap::Name::NextId());
17 const libecap::Name
Adaptation::Ecap::protocolIcp("ICP", libecap::Name::NextId());
19 const libecap::Name
Adaptation::Ecap::protocolHtcp("Htcp", libecap::Name::NextId());
21 const libecap::Name
Adaptation::Ecap::metaBypassable("bypassable", libecap::Name::NextId());
23 /// the host application (i.e., Squid) wrapper registered with libecap
24 static libecap::shared_ptr
<Adaptation::Ecap::Host
> TheHost
;
26 Adaptation::Ecap::Host::Host()
28 // assign our host-specific IDs to well-known names
29 // this code can run only once
31 libecap::headerContentLength
.assignHostId(HDR_CONTENT_LENGTH
);
32 libecap::headerTransferEncoding
.assignHostId(HDR_TRANSFER_ENCODING
);
33 libecap::headerReferer
.assignHostId(HDR_REFERER
);
34 libecap::headerVia
.assignHostId(HDR_VIA
);
35 // TODO: libecap::headerXClientIp.assignHostId(HDR_X_CLIENT_IP);
36 // TODO: libecap::headerXServerIp.assignHostId(HDR_X_SERVER_IP);
38 libecap::protocolHttp
.assignHostId(PROTO_HTTP
);
39 libecap::protocolHttps
.assignHostId(PROTO_HTTPS
);
40 libecap::protocolFtp
.assignHostId(PROTO_FTP
);
41 libecap::protocolGopher
.assignHostId(PROTO_GOPHER
);
42 libecap::protocolWais
.assignHostId(PROTO_WAIS
);
43 libecap::protocolUrn
.assignHostId(PROTO_URN
);
44 libecap::protocolWhois
.assignHostId(PROTO_WHOIS
);
45 protocolInternal
.assignHostId(PROTO_INTERNAL
);
46 protocolCacheObj
.assignHostId(PROTO_CACHEOBJ
);
47 protocolIcp
.assignHostId(PROTO_ICP
);
49 protocolHtcp
.assignHostId(PROTO_HTCP
);
52 // allows adapter to safely ignore this in adapter::Service::configure()
53 metaBypassable
.assignHostId(1);
57 Adaptation::Ecap::Host::uri() const
59 return "ecap://squid-cache.org/ecap/hosts/squid";
63 Adaptation::Ecap::Host::describe(std::ostream
&os
) const
65 os
<< PACKAGE_NAME
<< " v" << PACKAGE_VERSION
;
69 Adaptation::Ecap::Host::noteService(const libecap::weak_ptr
<libecap::adapter::Service
> &weak
)
71 Must(!weak
.expired());
72 RegisterAdapterService(weak
.lock());
76 SquidLogLevel(libecap::LogVerbosity lv
)
79 return DBG_CRITICAL
; // is it a good idea to ignore other flags?
82 return DBG_DATA
; // is it a good idea to ignore other flags?
85 return DBG_IMPORTANT
; // is it a good idea to ignore other flags?
87 return 2 + 2*lv
.debugging() + 3*lv
.operation() + 2*lv
.xaction();
91 Adaptation::Ecap::Host::openDebug(libecap::LogVerbosity lv
)
93 const int squidLevel
= SquidLogLevel(lv
);
94 const int squidSection
= 93; // XXX: this should be a global constant
95 // XXX: Debug.h should provide this to us
96 if ((Debug::level
= squidLevel
) <= Debug::Levels
[squidSection
])
97 return &Debug::getDebugOut();
103 Adaptation::Ecap::Host::closeDebug(std::ostream
*debug
)
106 Debug::finishDebug();
110 Adaptation::Ecap::Host::MessagePtr
111 Adaptation::Ecap::Host::newRequest() const
113 return MessagePtr(new Adaptation::Ecap::MessageRep(new HttpRequest
));
116 Adaptation::Ecap::Host::MessagePtr
117 Adaptation::Ecap::Host::newResponse() const
119 return MessagePtr(new Adaptation::Ecap::MessageRep(new HttpReply
));
123 Adaptation::Ecap::Host::Register()
126 TheHost
.reset(new Adaptation::Ecap::Host
);
127 libecap::RegisterHost(TheHost
);