Annotation Mechanism in eCap

Asked by Jatin on 2014-08-23

Hi Alex,

I reference to your suggestion on the squid maling list. I had a question related to that.
------------------------------------------------------------------------
In eCAP terminology, an X-Bump:yes annotation is an adapter
transaction option named X-Bump with a "yes" value. See
libecap::Options, which is a parent of libecap::adapter::Xaction.
------------------------------------------------------------------------

I have seen libecap::Options and it only seemed to me a read only function, where I would pass a variable and it would return a value for that variable.

For example I use it as below:
hostx->option(libecap::metaClientIp);

Please suggest that how can it be used to set a value for a variable. For example X-Bump:yes as you suggested.

Thanks,

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
Alex Rousskov
Solved:
2014-10-13
Last query:
2014-10-13
Last reply:
2014-08-25
Alex Rousskov (rousskov) said : #1

libecap::Options is a class, not a function. Your adapter transaction class is an indirect child of the Options class and, hence, can implement Options' virtual methods. The host application will call your adapter transaction to collect the options those methods return.

For examples, see Adapter::Xaction::option() and Adapter::Xaction::visitEachOption() in eCAP ClamAv adapter.

Jatin (jbhasin83) said : #2

Hi Alex,

I saw these below functions in clamAv adapter.

const libecap::Area Adapter::Xaction::option(const libecap::Name &name) const
{
        if (name == libecap::metaVirusId && !virusId.empty())
                return libecap::Area(virusId.data(), virusId.size());

        return libecap::Area();
}

void Adapter::Xaction::visitEachOption(libecap::NamedValueVisitor &visitor) const
{
        if (!virusId.empty())
                visitor.visit(libecap::metaVirusId,
                        libecap::Area(virusId.data(), virusId.size()));
}

Now it looks like to me that these functions return the virusID if detected any for the current transaction.

But I am not sure when Squid calls these function. I see that these function gets called from configure and reconfigure functions which are in Service.cc of ClamAv adapter.

But when I see squid then it calls the configure function only at the start.

Also I found that squid calls the option function from following (which is in file XactionRep.cc)

Adaptation::Ecap::XactionRep::updateHistory(HttpMsg *adapted)

I wanted to understand the flow that how my X-Bump:yes would flow from ecap adapter to squid.

Please help me with the flow so that I can understand it better.

Best Alex Rousskov (rousskov) said : #3

Adapter's Xaction::option() and Xaction::vistitEachOption() methods are usually called by the host application after receiving the adaptation answer (i.e., during useVirgin(), blockVirgin(), or useAdapted() calls to the host transaction). It is possible that some host applications will also call these methods at other times -- that area of eCAP has not been fully standardized yet.

The Service class also supports Options API, but your question is about Xaction, not Service.

Jatin (jbhasin83) said : #4

Thanks Alex Rousskov, that solved my question.