]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/ecap/Host.cc
2 #include <libecap/adapter/service.h>
3 #include <libecap/common/names.h>
4 #include "TextException.h"
5 #include "adaptation/ecap/ServiceRep.h"
6 #include "adaptation/ecap/Host.h"
8 const libecap::Name
Adaptation::Ecap::protocolInternal("internal", libecap::Name::NextId());
9 const libecap::Name
Adaptation::Ecap::protocolCacheObj("cache_object", libecap::Name::NextId());
10 const libecap::Name
Adaptation::Ecap::protocolIcp("ICP", libecap::Name::NextId());
12 const libecap::Name
Adaptation::Ecap::protocolHtcp("Htcp", libecap::Name::NextId());
15 Adaptation::Ecap::Host::Host()
17 // assign our host-specific IDs to well-known names
18 libecap::headerReferer
.assignHostId(HDR_REFERER
);
20 libecap::protocolHttp
.assignHostId(PROTO_HTTP
);
21 libecap::protocolHttps
.assignHostId(PROTO_HTTPS
);
22 libecap::protocolFtp
.assignHostId(PROTO_FTP
);
23 libecap::protocolGopher
.assignHostId(PROTO_GOPHER
);
24 libecap::protocolWais
.assignHostId(PROTO_WAIS
);
25 libecap::protocolUrn
.assignHostId(PROTO_URN
);
26 libecap::protocolWhois
.assignHostId(PROTO_WHOIS
);
27 protocolInternal
.assignHostId(PROTO_INTERNAL
);
28 protocolCacheObj
.assignHostId(PROTO_CACHEOBJ
);
29 protocolIcp
.assignHostId(PROTO_ICP
);
31 protocolHtcp
.assignHostId(PROTO_HTCP
);
36 Adaptation::Ecap::Host::uri() const
38 return "ecap://squid-cache.org/ecap/hosts/squid";
42 Adaptation::Ecap::Host::describe(std::ostream
&os
) const
44 os
<< PACKAGE_NAME
<< " v" << PACKAGE_VERSION
;
48 Adaptation::Ecap::Host::noteService(const libecap::weak_ptr
<libecap::adapter::Service
> &weak
)
50 // Many ecap_service lines may use the same service URI. Find each
51 // matching service rep, make sure it is an eCAP rep,
52 // and update it with the actual eCAP service.
55 libecap::shared_ptr
<libecap::adapter::Service
> shared(weak
);
56 typedef Adaptation::Services::iterator SI
;
57 for (SI i
= Adaptation::AllServices().begin(); i
!= Adaptation::AllServices().end(); ++i
) {
58 if ((*i
)->cfg().uri
== shared
->uri().c_str()) {
59 ServiceRep
*rep
= dynamic_cast<ServiceRep
*>(i
->getRaw());
61 rep
->noteService(shared
);
66 debugs(93,5, HERE
<< "Found " << found
<< " ecap_service configs for " <<
69 debugs(93,1, "Warning: ignoring loaded eCAP module service without " <<
70 "a matching ecap_service configuration: " << shared
->uri());
75 SquidLogLevel(libecap::LogVerbosity lv
)
78 return DBG_CRITICAL
; // is it a good idea to ignore other flags?
81 return DBG_DATA
; // is it a good idea to ignore other flags?
84 return DBG_DATA
; // is it a good idea to ignore other flags?
86 return 2 + 2*lv
.debugging() + 3*lv
.operation() + 2*lv
.xaction();
90 Adaptation::Ecap::Host::openDebug(libecap::LogVerbosity lv
)
92 const int squidLevel
= SquidLogLevel(lv
);
93 const int squidSection
= 93; // XXX: this should be a global constant
94 // XXX: Debug.h should provide this to us
95 if ((Debug::level
= squidLevel
) <= Debug::Levels
[squidSection
])
96 return &Debug::getDebugOut();
102 Adaptation::Ecap::Host::closeDebug(std::ostream
*debug
)
105 Debug::finishDebug();